From dca42e0a04fe3b6f1caba3f1f6cb7cb5629cecce Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Tue, 6 Aug 2024 23:06:02 +0300 Subject: [PATCH] vk: use vkCmdDrawIndexed in R_DrawSkyBox --- src/client/refresh/vk/vk_warp.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/client/refresh/vk/vk_warp.c b/src/client/refresh/vk/vk_warp.c index 1205b1e6..b85eda54 100644 --- a/src/client/refresh/vk/vk_warp.c +++ b/src/client/refresh/vk/vk_warp.c @@ -168,8 +168,10 @@ RE_ClearSkyBox(void) void R_DrawSkyBox(void) { - int i; + VkDeviceSize dstOffset; + VkBuffer *buffer; qboolean farsee; + int i; farsee = (r_farsee->value == 0); @@ -204,6 +206,10 @@ R_DrawSkyBox(void) uint8_t *uboData = QVk_GetUniformBuffer(sizeof(model), &uboOffset, &uboDescriptorSet); memcpy(uboData, model, sizeof(model)); + Mesh_VertsRealloc(6); + GenFanIndexes(vertIdxData, 0, 4); + buffer = UpdateIndexBuffer(vertIdxData, 6 * sizeof(uint16_t), &dstOffset); + for (i = 0; i < 6; i++) { if (skyrotate) @@ -231,13 +237,8 @@ R_DrawSkyBox(void) VkBuffer vbo; VkDeviceSize vboOffset; - uint8_t *vertData = QVk_GetVertexBuffer(sizeof(mvtx_t) * 6, &vbo, &vboOffset); - memcpy(vertData + sizeof(mvtx_t) * 0, &skyVerts[0], sizeof(mvtx_t)); - memcpy(vertData + sizeof(mvtx_t) * 1, &skyVerts[1], sizeof(mvtx_t)); - memcpy(vertData + sizeof(mvtx_t) * 2, &skyVerts[2], sizeof(mvtx_t)); - memcpy(vertData + sizeof(mvtx_t) * 3, &skyVerts[0], sizeof(mvtx_t)); - memcpy(vertData + sizeof(mvtx_t) * 4, &skyVerts[2], sizeof(mvtx_t)); - memcpy(vertData + sizeof(mvtx_t) * 5, &skyVerts[3], sizeof(mvtx_t)); + uint8_t *vertData = QVk_GetVertexBuffer(sizeof(mvtx_t) * 4, &vbo, &vboOffset); + memcpy(vertData, skyVerts, sizeof(mvtx_t) * 4); VkDescriptorSet descriptorSets[] = { sky_images[skytexorder[i]]->vk_texture.descriptorSet, @@ -252,7 +253,9 @@ R_DrawSkyBox(void) vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_drawSkyboxPipeline.layout, 0, 2, descriptorSets, 1, &uboOffset); vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1, &vbo, &vboOffset); - vkCmdDraw(vk_activeCmdbuffer, 6, 1, 0, 0); + + vkCmdBindIndexBuffer(vk_activeCmdbuffer, *buffer, dstOffset, VK_INDEX_TYPE_UINT16); + vkCmdDrawIndexed(vk_activeCmdbuffer, 6, 1, 0, 0, 0); } }