vk: fix crashing on maps with skybox

We were using a negative value for `SURF_SKY` surfaces, which hit an
assert on uploading kusochki.
This commit is contained in:
Ivan Avdeev 2023-11-07 13:30:46 -05:00
parent c6c58a9842
commit 2c0e7033ed
5 changed files with 24 additions and 3 deletions

View File

@ -4,6 +4,13 @@
- [x] remove stvecs from patches -- not used, inconvenient
- [x] patch texture coordinates by matrices
- [x] add `_xvk_tex_rotate`
- [x] ASSERT in c2a5 -- skybox sentinel
- [ ] woditschka
- [ ] height not switching to negative underwater
- not even sure we need it?
- [ ] do not draw water sides when not requested.
- [ ] potentially collinear planes vs ray tracing #264
- [ ] update animated textures is now super slow
# 2023-11-06 E325
- [x] fix material asserts and inherit
@ -182,7 +189,6 @@
- [ ] rtx: do not rebuild static studio models (most of them). BLAS building takes most of the frame time (~12ms where ray tracing itself is just 3ms)
- [ ] rtx: importance-sample sky light; there are sky surfaces that we can consider light sources
- [ ] cull water surfaces (see c3a2a)
- [ ] create water surfaces once in vk_brush
- [ ] consider doing per-geometry rendermode: brushes can be built only once; late transparency depth sorting for vk render;
- [ ] rtx: too many emissive lights in c3a1b
- [ ] studio models: pre-compute buffer sizes and allocate them at once
@ -606,3 +612,6 @@
- [x] render skybox
- [x] better flashlight: spotlight instead of dlight point
- [x] rtx: add fps: rasterize into G-buffer, and only then compute lighting with rtx
# Done somewhen
- [x] create water surfaces once in vk_brush

View File

@ -71,7 +71,7 @@ LIST_SPECIALIZATION_CONSTANTS(DECLARE_SPECIALIZATION_CONSTANT)
#define MATERIAL_MODE_BLEND_GLOW 5
#define MATERIAL_MODE_COUNT 6
#define TEX_BASE_SKYBOX 0xffffffffu
#define TEX_BASE_SKYBOX 0x0f000000u
struct Material {
uint tex_base_color;

View File

@ -1174,7 +1174,7 @@ static qboolean fillBrushSurfaces(fill_geometries_args_t args) {
model_geometry->index_offset = index_offset;
if ( type == BrushSurface_Sky ) {
#define TEX_BASE_SKYBOX 0xffffffffu // FIXME ray_interop.h
#define TEX_BASE_SKYBOX 0x0f000000u // FIXME ray_interop.h
model_geometry->material.tex_base_color = TEX_BASE_SKYBOX;
} else {
ASSERT(!FBitSet( surf->flags, SURF_DRAWTILED ));

View File

@ -161,6 +161,11 @@ static int addMaterial(const char *name, const r_vk_material_t* mat) {
printMaterial(g_materials.count);
ASSERT(mat->tex_base_color >= 0);
ASSERT(mat->tex_metalness >= 0);
ASSERT(mat->tex_roughness >= 0);
ASSERT(mat->tex_normalmap >= 0);
return g_materials.count++;
}

View File

@ -30,9 +30,16 @@ static void applyMaterialToKusok(vk_kusok_data_t* kusok, const vk_render_geometr
ASSERT(mat);
ASSERT(mat->tex_base_color >= 0);
ASSERT(mat->tex_base_color < MAX_TEXTURES || mat->tex_base_color == TEX_BASE_SKYBOX);
ASSERT(mat->tex_roughness >= 0);
ASSERT(mat->tex_roughness < MAX_TEXTURES);
ASSERT(mat->tex_metalness >= 0);
ASSERT(mat->tex_metalness < MAX_TEXTURES);
ASSERT(mat->tex_normalmap >= 0);
ASSERT(mat->tex_normalmap < MAX_TEXTURES);
// TODO split kusochki into static geometry data and potentially dynamic material data
// This data is static, should never change