[vulkan] Fix the bsp vertex index list creation

There's still a problem with the vertex data itself not getting sent to
the GPU properly, but vulkan is now happy with my tiny test map (which
required disabling skies entirely until I get null textures working).
This commit is contained in:
Bill Currie 2021-01-21 14:37:39 +09:00
parent 2c1a335715
commit eb9807576d
3 changed files with 20 additions and 31 deletions

View file

@ -108,13 +108,13 @@
descriptorCount = 1;
stageFlags = fragment;
},
{
/*{
binding = 4;
descriptorType = combined_image_sampler;
descriptorCount = 1;
stageFlags = fragment;
},
/*{
{
binding = 5;
descriptorType = combined_image_sampler;
descriptorCount = 1;

View file

@ -3,7 +3,7 @@
layout (set = 0, binding = 1) uniform sampler2D Texture;
layout (set = 0, binding = 2) uniform sampler2D Glowmap;
layout (set = 0, binding = 3) uniform sampler2D Lightmap;
layout (set = 0, binding = 4) uniform sampler2DArray SkySheet;
//layout (set = 0, binding = 4) uniform sampler2DArray SkySheet;
//layout (set = 0, binding = 5) uniform samplerCube SkyCube;
layout (push_constant) uniform PushConstants {
@ -46,7 +46,7 @@ fogBlend (vec4 color)
return vec4 (mix (fog_color.rgb, color.rgb, fog_factor), color.a);
}
/*
vec4
sky_sheet (vec3 dir, float time)
{
@ -71,7 +71,7 @@ sky_sheet (vec3 dir, float time)
return c;
}
/*
vec4
sky_cube (vec3 dir, float time)
{
@ -81,7 +81,7 @@ sky_cube (vec3 dir, float time)
// to do here is swizzle the Y and Z coordinates
return texture (SkyCube, dir.xzy);
}
*/
vec4
sky_color (vec3 dir, float time)
{
@ -91,15 +91,15 @@ sky_color (vec3 dir, float time)
} if (!doSkyCube) {
return sky_sheet (dir, time);
} else {
/*// can see through the sheet (may look funny when looking down)
// can see through the sheet (may look funny when looking down)
// maybe have 4 sheet layers instead of 2?
vec4 c1 = sky_sheet (dir, time);
vec4 c2 = sky_cube (dir, time);
return vec4 (mix (c2.rgb, c1.rgb, c1.a), max (c1.a, c2.a));*/
return vec4 (mix (c2.rgb, c1.rgb, c1.a), max (c1.a, c2.a));
return vec4 (1, 0, 1, 1);
}
}
*/
void
main (void)
{
@ -110,11 +110,11 @@ main (void)
if (doWarp) {
t_st = warp_st (t_st, time);
}
if (doSkyCube || doSkySheet) {
/*if (doSkyCube || doSkySheet) {
c = sky_color (direction, time);
} else {
c = texture (Texture, t_st);
}
}*/
if (doLight) {
c *= texture (Lightmap, l_st);
}

View file

@ -33,9 +33,6 @@
# include "config.h"
#endif
#define NH_DEFINE
//#include "namehack.h"
#ifdef HAVE_STRING_H
# include <string.h>
#endif
@ -337,7 +334,7 @@ build_surf_displist (model_t **models, msurface_t *fa, int base,
numverts = fa->numedges;
numindices = numverts + 1;
verts = *vert_list;
// surf->polys is set to the next slow before the call
// surf->polys is set to the next slot before the call
poly = (bsppoly_t *) fa->polys;
poly->count = numindices;
for (i = 0, ind = poly->indices; i < numverts; i++) {
@ -474,7 +471,6 @@ Vulkan_BuildDisplayLists (model_t **models, int num_models, vulkan_ctx_t *ctx)
vulktex_t *tex;
instsurf_t *is;
elechain_t *ec = 0;
//elements_t *el = 0;
tex = bctx->texture_chains.a[i];
@ -482,20 +478,10 @@ Vulkan_BuildDisplayLists (model_t **models, int num_models, vulkan_ctx_t *ctx)
msurface_t *surf = is->surface;
if (!tex->elechain) {
ec = add_elechain (tex, surf->ec_index, bctx);
//el = ec->elements;
vertex_index_base = 0;
}
if (surf->ec_index != ec->index) { // next sub-model
ec = add_elechain (tex, surf->ec_index, bctx);
//el = ec->elements;
vertex_index_base = 0;
}
/*if (vertex_index_base + surf->numedges > 65535) {
// elements index overflow
el->next = get_elements (bctx);
el = el->next;
vertex_index_base = 0;
}*/
surf->polys = (glpoly_t *) poly;
poly = build_surf_displist (models, surf, vertex_index_base,
@ -534,6 +520,7 @@ Vulkan_BuildDisplayLists (model_t **models, int num_models, vulkan_ctx_t *ctx)
uint32_t offset = index_count * i;
bctx->frames.a[i].index_data = index_data + offset;
bctx->frames.a[i].index_offset = offset * sizeof (uint32_t);
bctx->frames.a[i].index_count = 0;
}
}
if (vertex_buffer_size > bctx->vertex_buffer_size) {
@ -884,7 +871,7 @@ bsp_begin (vulkan_ctx_t *ctx)
VK_INDEX_TYPE_UINT32);
dfunc->vkCmdPushDescriptorSetKHR (cmd, VK_PIPELINE_BIND_POINT_GRAPHICS,
bctx->layout, 0, 5, write);
bctx->layout, 0, 4, write);
//XXX glsl_Fog_GetColor (fog);
//XXX fog[3] = glsl_Fog_GetDensity () / 64.0;
@ -1063,18 +1050,19 @@ add_surf_elements (vulktex_t *tex, instsurf_t *is,
(*ec)->transform = is->transform;
(*ec)->color = is->color;
(*el) = (*ec)->elements;
(*el)-> first_index = bframe->index_count;
(*el)->first_index = bframe->index_count;
}
if (is->transform != (*ec)->transform || is->color != (*ec)->color) {
(*ec) = add_elechain (tex, surf->ec_index, bctx);
(*ec)->transform = is->transform;
(*ec)->color = is->color;
(*el) = (*ec)->elements;
(*el)-> first_index = bframe->index_count;
(*el)->first_index = bframe->index_count;
}
memcpy (bframe->index_data + bframe->index_count,
poly->indices, poly->count * sizeof (poly->indices[0]));
(*el)->index_count += poly->count;
bframe->index_count += poly->count;
}
static void
@ -1105,12 +1093,13 @@ Vulkan_DrawWorld (vulkan_ctx_t *ctx)
entity_t worldent;
clear_texture_chains (bctx); // do this first for water and skys
bframe->index_count = 0;
memset (&worldent, 0, sizeof (worldent));
worldent.model = r_worldentity.model;
vulktex_t *tex = r_worldentity.model->skytexture->render;
bctx->skysheet_tex = tex->tex;
//vulktex_t *tex = r_worldentity.model->skytexture->render;
//bctx->skysheet_tex = tex->tex;
currententity = &worldent;