diff --git a/src/client/refresh/vk/header/local.h b/src/client/refresh/vk/header/local.h index 859cf8b1..05345df2 100644 --- a/src/client/refresh/vk/header/local.h +++ b/src/client/refresh/vk/header/local.h @@ -339,6 +339,7 @@ IMPLEMENTATION SPECIFIC FUNCTIONS qboolean Vkimp_CreateSurface(SDL_Window *window); extern mvtx_t *verts_buffer; +extern uint16_t *vertIdxData; void Mesh_Init (void); void Mesh_Free (void); diff --git a/src/client/refresh/vk/vk_main.c b/src/client/refresh/vk/vk_main.c index 40f3074f..51167a1b 100644 --- a/src/client/refresh/vk/vk_main.c +++ b/src/client/refresh/vk/vk_main.c @@ -291,8 +291,8 @@ R_DrawNullModel(entity_t *currententity) verts[i][2] = shadelight[2]; } - VkBuffer vbo, fan; - VkDeviceSize vboOffset, fanOffset; + VkBuffer vbo, *buffer; + VkDeviceSize vboOffset, dstOffset; uint32_t uboOffset; VkDescriptorSet uboDescriptorSet; uint8_t *vertData = QVk_GetVertexBuffer(sizeof(verts), &vbo, &vboOffset); @@ -300,13 +300,17 @@ R_DrawNullModel(entity_t *currententity) memcpy(vertData, verts, sizeof(verts)); memcpy(uboData, model, sizeof(model)); - fan = QVk_GetTriangleFanIbo(12, &fanOffset); + Mesh_VertsRealloc(24); + GenFanIndexes(vertIdxData, 0, 4); + GenFanIndexes(vertIdxData + 4 * 3, 6, 10); + buffer = UpdateIndexBuffer(vertIdxData, 24 * sizeof(uint16_t), &dstOffset); + QVk_BindPipeline(&vk_drawNullModelPipeline); - vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_drawNullModelPipeline.layout, 0, 1, &uboDescriptorSet, 1, &uboOffset); + vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, + vk_drawNullModelPipeline.layout, 0, 1, &uboDescriptorSet, 1, &uboOffset); vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1, &vbo, &vboOffset); - vkCmdBindIndexBuffer(vk_activeCmdbuffer, fan, fanOffset, VK_INDEX_TYPE_UINT16); - vkCmdDrawIndexed(vk_activeCmdbuffer, 12, 1, 0, 0, 0); - vkCmdDrawIndexed(vk_activeCmdbuffer, 12, 1, 0, 6, 0); + vkCmdBindIndexBuffer(vk_activeCmdbuffer, *buffer, dstOffset, VK_INDEX_TYPE_UINT16); + vkCmdDrawIndexed(vk_activeCmdbuffer, 24, 1, 0, 0, 0); } static void diff --git a/src/client/refresh/vk/vk_mesh.c b/src/client/refresh/vk/vk_mesh.c index ef3c4fe9..c0817e28 100644 --- a/src/client/refresh/vk/vk_mesh.c +++ b/src/client/refresh/vk/vk_mesh.c @@ -41,7 +41,7 @@ typedef struct { mvtx_t *verts_buffer = NULL; static modelvert *vertList = NULL; static vec3_t *shadowverts = NULL; -static uint16_t *vertIdxData = NULL; +uint16_t *vertIdxData = NULL; static int verts_count = 0; diff --git a/src/client/refresh/vk/vk_surf.c b/src/client/refresh/vk/vk_surf.c index 85a81bdf..0f2ffa2b 100644 --- a/src/client/refresh/vk/vk_surf.c +++ b/src/client/refresh/vk/vk_surf.c @@ -448,6 +448,14 @@ Vk_RenderLightmappedPoly(msurface_t *surf, const float *modelMatrix, float alpha Com_Error(ERR_FATAL, "%s: can't allocate memory", __func__); } + VkDescriptorSet descriptorSets[] = { + image->vk_texture.descriptorSet, + uboDescriptorSet, + vk_state.lightmap_textures[lmtex].descriptorSet + }; + + vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_drawPolyLmapPipeline.layout, 0, 3, descriptorSets, 1, &uboOffset); + if (is_dynamic) { int smax, tmax, size; @@ -489,12 +497,6 @@ Vk_RenderLightmappedPoly(msurface_t *surf, const float *modelMatrix, float alpha VkBuffer vbo; VkDeviceSize vboOffset; - VkDescriptorSet descriptorSets[] = { - image->vk_texture.descriptorSet, - uboDescriptorSet, - vk_state.lightmap_textures[lmtex].descriptorSet - }; - vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_drawPolyLmapPipeline.layout, 0, 3, descriptorSets, 1, &uboOffset); for (p = surf->polys; p; p = p->chain) { @@ -522,13 +524,6 @@ Vk_RenderLightmappedPoly(msurface_t *surf, const float *modelMatrix, float alpha { VkDeviceSize vboOffset; VkBuffer vbo; - VkDescriptorSet descriptorSets[] = { - image->vk_texture.descriptorSet, - uboDescriptorSet, - vk_state.lightmap_textures[lmtex].descriptorSet - }; - - vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_drawPolyLmapPipeline.layout, 0, 3, descriptorSets, 1, &uboOffset); for (p = surf->polys; p; p = p->chain) { @@ -577,14 +572,7 @@ Vk_RenderLightmappedPoly(msurface_t *surf, const float *modelMatrix, float alpha vertData = QVk_GetVertexBuffer(sizeof(mvtx_t) * nv, &vbo, &vboOffset); memcpy(vertData, verts_buffer, sizeof(mvtx_t) * nv); - VkDescriptorSet descriptorSets[] = { - image->vk_texture.descriptorSet, - uboDescriptorSet, - vk_state.lightmap_textures[lmtex].descriptorSet - }; - fan = QVk_GetTriangleFanIbo((nv - 2) * 3, &fanOffset); - vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_drawPolyLmapPipeline.layout, 0, 3, descriptorSets, 1, &uboOffset); vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1, &vbo, &vboOffset); vkCmdBindIndexBuffer(vk_activeCmdbuffer, fan, fanOffset, VK_INDEX_TYPE_UINT16); vkCmdDrawIndexed(vk_activeCmdbuffer, (nv - 2) * 3, 1, 0, 0, 0); @@ -603,14 +591,7 @@ Vk_RenderLightmappedPoly(msurface_t *surf, const float *modelMatrix, float alpha vertData = QVk_GetVertexBuffer(sizeof(mvtx_t) * nv, &vbo, &vboOffset); memcpy(vertData, p->verts, sizeof(mvtx_t) * nv); - VkDescriptorSet descriptorSets[] = { - image->vk_texture.descriptorSet, - uboDescriptorSet, - vk_state.lightmap_textures[lmtex].descriptorSet - }; - fan = QVk_GetTriangleFanIbo((nv - 2) * 3, &fanOffset); - vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_drawPolyLmapPipeline.layout, 0, 3, descriptorSets, 1, &uboOffset); vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1, &vbo, &vboOffset); vkCmdBindIndexBuffer(vk_activeCmdbuffer, fan, fanOffset, VK_INDEX_TYPE_UINT16); vkCmdDrawIndexed(vk_activeCmdbuffer, (nv - 2) * 3, 1, 0, 0, 0);