diff --git a/README.md b/README.md index cbe195a6..95cb4a03 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,8 @@ Goals: * [x] RGB particles support instead palette based one, * [x] Get rid of VID_PaletteColor client internal api use, * [x] Broken maps groups from base2 to next, +* [ ] Group images in vulkan render, +* [ ] Rearange surfaces in vulkan render before render, * [ ] Single player ReRelease support, * [ ] Support effects and additional flags for ReRelease when possible. * [ ] Use shared model cache in client code insted reimplemnet in each render, diff --git a/src/client/refresh/vk/header/local.h b/src/client/refresh/vk/header/local.h index 05345df2..5e053b29 100644 --- a/src/client/refresh/vk/header/local.h +++ b/src/client/refresh/vk/header/local.h @@ -340,6 +340,7 @@ qboolean Vkimp_CreateSurface(SDL_Window *window); extern mvtx_t *verts_buffer; extern uint16_t *vertIdxData; +extern int drawCalls; void Mesh_Init (void); void Mesh_Free (void); diff --git a/src/client/refresh/vk/vk_common.c b/src/client/refresh/vk/vk_common.c index 1307d39a..58a18b62 100644 --- a/src/client/refresh/vk/vk_common.c +++ b/src/client/refresh/vk/vk_common.c @@ -2199,6 +2199,7 @@ VkResult QVk_BeginFrame(const VkViewport* viewport, const VkRect2D* scissor) ReleaseSwapBuffers(); + // VK_ERROR: Validation Error: [ VUID-vkAcquireNextImageKHR-semaphore-01779 ] Object 0: handle = 0x620000000062, name = Semaphore: image available #30, type = VK_OBJECT_TYPE_SEMAPHORE; | MessageID = 0x5717e75b | vkAcquireNextImageKHR(): Semaphore must not have any pending operations. The Vulkan spec states: If semaphore is not VK_NULL_HANDLE it must not have any uncompleted signal or wait operations pending (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkAcquireNextImageKHR-semaphore-01779) (validation) VkResult result = vkAcquireNextImageKHR(vk_device.logical, vk_swapchain.sc, 500000000 /* 0.5 sec */, vk_imageAvailableSemaphores[vk_imageSemaphoreIdx], VK_NULL_HANDLE, &vk_imageIndex); if (result == VK_ERROR_OUT_OF_DATE_KHR || result == VK_SUBOPTIMAL_KHR || result == VK_ERROR_SURFACE_LOST_KHR || result == VK_TIMEOUT) @@ -2718,6 +2719,7 @@ QVk_Draw2DCallsRender(void) vkCmdBindIndexBuffer(vk_activeCmdbuffer, vk_rectIbo.resource.buffer, vk_rectIboffet, VK_INDEX_TYPE_UINT16); vkCmdDrawIndexed(vk_activeCmdbuffer, 6 * draw2dcolor_num, 1, 0, 0, 0); + printf("%d: %s Color\n", drawCalls++, __func__); } else if (draw2dcolor_calltype == CALL_TEX) { @@ -2759,6 +2761,7 @@ QVk_Draw2DCallsRender(void) vkCmdBindIndexBuffer(vk_activeCmdbuffer, vk_rectIbo.resource.buffer, vk_rectIboffet, VK_INDEX_TYPE_UINT16); vkCmdDrawIndexed(vk_activeCmdbuffer, 6 * draw2dcolor_num, 1, 0, 0, 0); + printf("%d: %s Tex\n", drawCalls++, __func__); } draw2dcolor_num = 0; diff --git a/src/client/refresh/vk/vk_image.c b/src/client/refresh/vk/vk_image.c index 8ea150f6..41fd8dda 100644 --- a/src/client/refresh/vk/vk_image.c +++ b/src/client/refresh/vk/vk_image.c @@ -390,8 +390,12 @@ static void ChangeColorBufferLayout(VkImage image, VkImageLayout fromLayout, VkI .image = image, .subresourceRange = subresourceRange, }; +/* + * VK_WARNING: Validation Warning: [ BestPractices-TransitionUndefinedToReadOnly ] Object 0: handle = 0x1a000000001a, type = VK_OBJECT_TYPE_IMAGE; | MessageID = 0xe10fe22f | vkCmdPipelineBarrier(): pImageMemoryBarriers[0] VkImageMemoryBarrier is being submitted with oldLayout VK_IMAGE_LAYOUT_UNDEFINED and the contents may be discarded, but the newLayout is VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, which is read only. (validation) +*/ - vkCmdPipelineBarrier(commandBuffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0u, 0u, NULL, 0u, NULL, 1u, &imageBarrier); + vkCmdPipelineBarrier(commandBuffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, + VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0u, 0u, NULL, 0u, NULL, 1u, &imageBarrier); QVk_SubmitCommand(&commandBuffer, &vk_device.transferQueue); vkFreeCommandBuffers(vk_device.logical, vk_transferCommandPool, 1, &commandBuffer); diff --git a/src/client/refresh/vk/vk_light.c b/src/client/refresh/vk/vk_light.c index f476f285..89e2093c 100644 --- a/src/client/refresh/vk/vk_light.c +++ b/src/client/refresh/vk/vk_light.c @@ -85,6 +85,7 @@ R_RenderDlight(dlight_t *light) vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_drawDLightPipeline.layout, 0, 1, &uboDescriptorSet, 1, &uboOffset); vkCmdBindIndexBuffer(vk_activeCmdbuffer, *buffer, dstOffset, VK_INDEX_TYPE_UINT16); vkCmdDrawIndexed(vk_activeCmdbuffer, 48, 1, 0, 0, 0); + printf("%d: %s\n", drawCalls++, __func__); } void diff --git a/src/client/refresh/vk/vk_main.c b/src/client/refresh/vk/vk_main.c index 4cceb5e8..07c05f93 100644 --- a/src/client/refresh/vk/vk_main.c +++ b/src/client/refresh/vk/vk_main.c @@ -233,6 +233,7 @@ R_DrawSpriteModel(entity_t *currententity, const model_t *currentmodel) vk_drawSpritePipeline.layout, 0, 1, &skin->vk_texture.descriptorSet, 0, NULL); vkCmdDraw(vk_activeCmdbuffer, 6, 1, 0, 0); + printf("%d: %s\n", drawCalls++, __func__); } static void @@ -311,6 +312,7 @@ R_DrawNullModel(entity_t *currententity) vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1, &vbo, &vboOffset); vkCmdBindIndexBuffer(vk_activeCmdbuffer, *buffer, dstOffset, VK_INDEX_TYPE_UINT16); vkCmdDrawIndexed(vk_activeCmdbuffer, 24, 1, 0, 0, 0); + printf("%d: %s\n", drawCalls++, __func__); } static void @@ -527,6 +529,7 @@ Vk_DrawParticles(int num_particles, const particle_t particles[]) vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1, &vbo, &vboOffset); vkCmdDraw(vk_activeCmdbuffer, (currentvertex - visibleParticles), 1, 0, 0); + printf("%d: %s\n", drawCalls++, __func__); } static void @@ -597,6 +600,7 @@ R_DrawParticles(void) vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_drawPointParticlesPipeline.layout, 0, 1, &uboDescriptorSet, 1, &uboOffset); vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1, &vbo, &vboOffset); vkCmdDraw(vk_activeCmdbuffer, r_newrefdef.num_particles, 1, 0, 0); + printf("%d: %s\n", drawCalls++, __func__); } else { @@ -1050,6 +1054,7 @@ qboolean RE_EndWorldRenderpass(void) vkCmdSetViewport(vk_activeCmdbuffer, 0u, 1u, &vk_viewport); vkCmdSetScissor(vk_activeCmdbuffer, 0u, 1u, &vk_scissor); vkCmdDraw(vk_activeCmdbuffer, 3, 1, 0, 0); + printf("%d: %s\n", drawCalls++, __func__); vkCmdEndRenderPass(vk_activeCmdbuffer); // start drawing UI @@ -1080,6 +1085,7 @@ R_SetVulkan2D(const VkViewport* viewport, const VkRect2D* scissor) vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_postprocessPipeline.layout, 0, 1, &vk_colorbufferWarp.descriptorSet, 0, NULL); QVk_BindPipeline(&vk_postprocessPipeline); vkCmdDraw(vk_activeCmdbuffer, 3, 1, 0, 0); + printf("%d: %s\n", drawCalls++, __func__); } } @@ -1433,6 +1439,8 @@ RE_BeginFrame(float camera_separation) QVk_BeginRenderpass(RP_WORLD); } +int drawCalls = 0; + /* ===================== RE_EndFrame @@ -1445,6 +1453,9 @@ RE_EndFrame(void) // world has not rendered yet world_rendered = false; + + printf("%s: Calls count %d\n", __func__, drawCalls); + drawCalls = 0; } unsigned r_rawpalette[256]; @@ -1566,6 +1577,7 @@ R_DrawBeam(entity_t *currententity ) vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_drawBeamPipeline.layout, 0, 1, &uboDescriptorSet, 1, &uboOffset); vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1, &vbo, &vboOffset); vkCmdDraw(vk_activeCmdbuffer, NUM_BEAM_SEGS * 4, 1, 0, 0); + printf("%d: %s\n", drawCalls++, __func__); } //=================================================================== diff --git a/src/client/refresh/vk/vk_mesh.c b/src/client/refresh/vk/vk_mesh.c index c0817e28..a3cd706c 100644 --- a/src/client/refresh/vk/vk_mesh.c +++ b/src/client/refresh/vk/vk_mesh.c @@ -406,6 +406,7 @@ Vk_DrawAliasFrameLerp(entity_t *currententity, dmdx_t *paliashdr, float backlerp vkCmdBindIndexBuffer(vk_activeCmdbuffer, **buffer, *dstOffset, VK_INDEX_TYPE_UINT16); vkCmdDrawIndexed(vk_activeCmdbuffer, *index_pos, 1, 0, 0, 0); + printf("%d: %s\n", drawCalls++, __func__); } static void @@ -836,5 +837,6 @@ R_DrawAliasModel(entity_t *currententity, const model_t *currentmodel) vkCmdBindIndexBuffer(vk_activeCmdbuffer, *buffer, dstOffset, VK_INDEX_TYPE_UINT16); vkCmdDrawIndexed(vk_activeCmdbuffer, index_pos, 1, 0, 0, 0); + printf("%d: %s\n", drawCalls++, __func__); } } diff --git a/src/client/refresh/vk/vk_surf.c b/src/client/refresh/vk/vk_surf.c index 23332d1f..9cdddb18 100644 --- a/src/client/refresh/vk/vk_surf.c +++ b/src/client/refresh/vk/vk_surf.c @@ -89,6 +89,7 @@ DrawVkPoly(msurface_t *fa, image_t *texture, const float *color) vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1, &vbo, &vboOffset); vkCmdBindIndexBuffer(vk_activeCmdbuffer, *buffer, dstOffset, VK_INDEX_TYPE_UINT16); vkCmdDrawIndexed(vk_activeCmdbuffer, (p->numverts - 2) * 3, 1, 0, 0, 0); + printf("%d: %s\n", drawCalls++, __func__); } static void @@ -145,6 +146,7 @@ R_DrawTriangleOutlines(void) vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1, &vbo, &vboOffset); vkCmdDraw(vk_activeCmdbuffer, 4, 1, 0, 0); + printf("%d: %s\n", drawCalls++, __func__); } } } @@ -466,6 +468,7 @@ Vk_RenderLightmappedPoly(msurface_t *surf, float alpha, vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1, &vbo, &vboOffset); vkCmdBindIndexBuffer(vk_activeCmdbuffer, *buffer, dstOffset, VK_INDEX_TYPE_UINT16); vkCmdDrawIndexed(vk_activeCmdbuffer, index_pos, 1, 0, 0, 0); + printf("%d: %s\n", drawCalls++, __func__); //PGM //========== } diff --git a/src/client/refresh/vk/vk_warp.c b/src/client/refresh/vk/vk_warp.c index 20d900f7..b2b82ff7 100644 --- a/src/client/refresh/vk/vk_warp.c +++ b/src/client/refresh/vk/vk_warp.c @@ -156,6 +156,7 @@ EmitWaterPolys(msurface_t *fa, image_t *texture, const float *modelMatrix, vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1, &vbo, &vboOffset); vkCmdBindIndexBuffer(vk_activeCmdbuffer, *buffer, dstOffset, VK_INDEX_TYPE_UINT16); vkCmdDrawIndexed(vk_activeCmdbuffer, index_pos, 1, 0, 0, 0); + printf("%d: %s\n", drawCalls++, __func__); } void @@ -261,6 +262,7 @@ R_DrawSkyBox(void) vkCmdBindIndexBuffer(vk_activeCmdbuffer, *buffer, dstOffset, VK_INDEX_TYPE_UINT16); vkCmdDrawIndexed(vk_activeCmdbuffer, 6, 1, 0, 0, 0); + printf("%d: %s\n", drawCalls++, __func__); } }