From 1bc60032e755e883958a04147f2cb22f14b4200e Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Sun, 10 Jan 2021 13:07:44 +0200 Subject: [PATCH 1/2] Fix pipeline debug naming --- src/client/refresh/vk/header/qvk.h | 6 +-- src/client/refresh/vk/vk_common.c | 61 +++++++++++++++++------------- src/client/refresh/vk/vk_rmain.c | 2 +- 3 files changed, 38 insertions(+), 31 deletions(-) diff --git a/src/client/refresh/vk/header/qvk.h b/src/client/refresh/vk/header/qvk.h index f7361b8e..4af28ce8 100644 --- a/src/client/refresh/vk/header/qvk.h +++ b/src/client/refresh/vk/header/qvk.h @@ -228,9 +228,9 @@ extern VkDescriptorSetLayout vk_samplerDescSetLayout; // *** pipelines *** extern qvkpipeline_t vk_drawTexQuadPipeline; -extern qvkpipeline_t vk_drawColorQuadPipeline[2]; -extern qvkpipeline_t vk_drawModelPipelineStrip[2]; -extern qvkpipeline_t vk_drawModelPipelineFan[2]; +extern qvkpipeline_t vk_drawColorQuadPipeline[RP_COUNT]; +extern qvkpipeline_t vk_drawModelPipelineStrip[RP_COUNT]; +extern qvkpipeline_t vk_drawModelPipelineFan[RP_COUNT]; extern qvkpipeline_t vk_drawNoDepthModelPipelineStrip; extern qvkpipeline_t vk_drawNoDepthModelPipelineFan; extern qvkpipeline_t vk_drawLefthandModelPipelineStrip; diff --git a/src/client/refresh/vk/vk_common.c b/src/client/refresh/vk/vk_common.c index 95ea545e..671f6b65 100644 --- a/src/client/refresh/vk/vk_common.c +++ b/src/client/refresh/vk/vk_common.c @@ -124,9 +124,12 @@ qboolean vk_frameStarted = false; // render pipelines qvkpipeline_t vk_drawTexQuadPipeline = QVKPIPELINE_INIT; -qvkpipeline_t vk_drawColorQuadPipeline[2] = { QVKPIPELINE_INIT, QVKPIPELINE_INIT }; -qvkpipeline_t vk_drawModelPipelineStrip[2] = { QVKPIPELINE_INIT, QVKPIPELINE_INIT }; -qvkpipeline_t vk_drawModelPipelineFan[2] = { QVKPIPELINE_INIT, QVKPIPELINE_INIT }; +qvkpipeline_t vk_drawColorQuadPipeline[RP_COUNT] = { + QVKPIPELINE_INIT, QVKPIPELINE_INIT, QVKPIPELINE_INIT }; +qvkpipeline_t vk_drawModelPipelineStrip[RP_COUNT] = { + QVKPIPELINE_INIT, QVKPIPELINE_INIT, QVKPIPELINE_INIT }; +qvkpipeline_t vk_drawModelPipelineFan[RP_COUNT] = { + QVKPIPELINE_INIT, QVKPIPELINE_INIT, QVKPIPELINE_INIT }; qvkpipeline_t vk_drawNoDepthModelPipelineStrip = QVKPIPELINE_INIT; qvkpipeline_t vk_drawNoDepthModelPipelineFan = QVKPIPELINE_INIT; qvkpipeline_t vk_drawLefthandModelPipelineStrip = QVKPIPELINE_INIT; @@ -248,6 +251,12 @@ VkDescriptorSetLayout vk_uboDescSetLayout; VkDescriptorSetLayout vk_samplerDescSetLayout; VkDescriptorSetLayout vk_samplerLightmapDescSetLayout; +static const char *renderpassObjectNames[] = { + "RP_WORLD", + "RP_UI", + "RP_WORLD_WARP" +}; + VkFormat QVk_FindDepthFormat() { VkFormat depthFormats[] = { @@ -348,7 +357,7 @@ static VkResult CreateFramebuffers() vk_framebuffers[i] = (VkFramebuffer *)malloc(vk_swapchain.imageCount * sizeof(VkFramebuffer)); VkFramebufferCreateInfo fbCreateInfos[] = { - // main world view framebuffer + // RP_WORLD: main world view framebuffer { .sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, .pNext = NULL, @@ -359,7 +368,7 @@ static VkResult CreateFramebuffers() .height = vk_swapchain.extent.height, .layers = 1 }, - // UI framebuffer + // RP_UI: UI framebuffer { .sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, .pNext = NULL, @@ -370,7 +379,7 @@ static VkResult CreateFramebuffers() .height = vk_swapchain.extent.height, .layers = 1 }, - // warped main world view (postprocessing) framebuffer + // RP_WORLD_WARP: warped main world view (postprocessing) framebuffer { .sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, .pNext = NULL, @@ -399,7 +408,7 @@ static VkResult CreateFramebuffers() VkResult res = vkCreateFramebuffer(vk_device.logical, &fbCreateInfos[j], NULL, &vk_framebuffers[j][i]); QVk_DebugSetObjectName((uint64_t)vk_framebuffers[j][i], VK_OBJECT_TYPE_FRAMEBUFFER, va("Framebuffer #" YQ2_COM_PRIdS "for Render Pass %s", - i, j == RP_WORLD ? "RP_WORLD" : j == RP_UI ? "RP_UI" : "RP_WORLD_WARP")); + i, renderpassObjectNames[j])); if (res != VK_SUCCESS) { @@ -684,12 +693,10 @@ static VkResult CreateRenderpasses() R_Printf(PRINT_ALL, "%s(): renderpass #%d create error: %s\n", __func__, i, QVk_GetError(res)); return res; } + QVk_DebugSetObjectName((uint64_t)vk_renderpasses[i].rp, VK_OBJECT_TYPE_RENDER_PASS, + va("Render Pass: %s", renderpassObjectNames[i])); } - QVk_DebugSetObjectName((uint64_t)vk_renderpasses[RP_WORLD].rp, VK_OBJECT_TYPE_RENDER_PASS, "Render Pass: World"); - QVk_DebugSetObjectName((uint64_t)vk_renderpasses[RP_WORLD_WARP].rp, VK_OBJECT_TYPE_RENDER_PASS, "Render Pass: UI"); - QVk_DebugSetObjectName((uint64_t)vk_renderpasses[RP_UI].rp, VK_OBJECT_TYPE_RENDER_PASS, "Render Pass: Warp Postprocess"); - return VK_SUCCESS; } @@ -1248,16 +1255,16 @@ static void CreatePipelines() // colored quad pipeline VK_LOAD_VERTFRAG_SHADERS(shaders, basic_color_quad, basic_color_quad); - for (int i = 0; i < 2; ++i) + for (int i = 0; i < RP_COUNT; ++i) { vk_drawColorQuadPipeline[i].depthTestEnable = VK_FALSE; vk_drawColorQuadPipeline[i].blendOpts.blendEnable = VK_TRUE; QVk_CreatePipeline(&vk_uboDescSetLayout, 1, &vertInfoRG, &vk_drawColorQuadPipeline[i], &vk_renderpasses[i], shaders, 2); + QVk_DebugSetObjectName((uint64_t)vk_drawColorQuadPipeline[i].layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, + va("Pipeline Layout: colored quad (%s)", renderpassObjectNames[i])); + QVk_DebugSetObjectName((uint64_t)vk_drawColorQuadPipeline[i].pl, VK_OBJECT_TYPE_PIPELINE, + va("Pipeline: colored quad (%s)", renderpassObjectNames[i])); } - QVk_DebugSetObjectName((uint64_t)vk_drawColorQuadPipeline[0].layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "Pipeline Layout: colored quad (RP_WORLD)"); - QVk_DebugSetObjectName((uint64_t)vk_drawColorQuadPipeline[0].pl, VK_OBJECT_TYPE_PIPELINE, "Pipeline: colored quad (RP_WORLD)"); - QVk_DebugSetObjectName((uint64_t)vk_drawColorQuadPipeline[1].layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "Pipeline Layout: colored quad (RP_UI)"); - QVk_DebugSetObjectName((uint64_t)vk_drawColorQuadPipeline[1].pl, VK_OBJECT_TYPE_PIPELINE, "Pipeline: colored quad (RP_UI)"); // untextured null model VK_LOAD_VERTFRAG_SHADERS(shaders, nullmodel, basic_color_quad); @@ -1269,24 +1276,24 @@ static void CreatePipelines() // textured model VK_LOAD_VERTFRAG_SHADERS(shaders, model, model); - for (int i = 0; i < 2; ++i) + for (int i = 0; i < RP_COUNT; ++i) { vk_drawModelPipelineStrip[i].topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; vk_drawModelPipelineStrip[i].blendOpts.blendEnable = VK_TRUE; QVk_CreatePipeline(samplerUboDsLayouts, 2, &vertInfoRGB_RGBA_RG, &vk_drawModelPipelineStrip[i], &vk_renderpasses[i], shaders, 2); + QVk_DebugSetObjectName((uint64_t)vk_drawModelPipelineStrip[i].layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, + va("Pipeline Layout: draw model: strip (%s)", renderpassObjectNames[i])); + QVk_DebugSetObjectName((uint64_t)vk_drawModelPipelineStrip[i].pl, VK_OBJECT_TYPE_PIPELINE, + va("Pipeline: draw model: strip (%s)", renderpassObjectNames[i])); vk_drawModelPipelineFan[i].topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; vk_drawModelPipelineFan[i].blendOpts.blendEnable = VK_TRUE; QVk_CreatePipeline(samplerUboDsLayouts, 2, &vertInfoRGB_RGBA_RG, &vk_drawModelPipelineFan[i], &vk_renderpasses[i], shaders, 2); + QVk_DebugSetObjectName((uint64_t)vk_drawModelPipelineFan[i].layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, + va("Pipeline Layout: draw model: fan (%s)", renderpassObjectNames[i])); + QVk_DebugSetObjectName((uint64_t)vk_drawModelPipelineFan[i].pl, VK_OBJECT_TYPE_PIPELINE, + va("Pipeline: draw model: fan (%s)", renderpassObjectNames[i])); } - QVk_DebugSetObjectName((uint64_t)vk_drawModelPipelineStrip[0].layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "Pipeline Layout: draw model: strip (RP_WORLD)"); - QVk_DebugSetObjectName((uint64_t)vk_drawModelPipelineStrip[0].pl, VK_OBJECT_TYPE_PIPELINE, "Pipeline: draw model: strip (RP_WORLD)"); - QVk_DebugSetObjectName((uint64_t)vk_drawModelPipelineStrip[1].layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "Pipeline Layout: draw model: strip (RP_UI)"); - QVk_DebugSetObjectName((uint64_t)vk_drawModelPipelineStrip[1].pl, VK_OBJECT_TYPE_PIPELINE, "Pipeline: draw model: strip (RP_UI)"); - QVk_DebugSetObjectName((uint64_t)vk_drawModelPipelineFan[0].layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "Pipeline Layout: draw model: fan (RP_WORLD)"); - QVk_DebugSetObjectName((uint64_t)vk_drawModelPipelineFan[0].pl, VK_OBJECT_TYPE_PIPELINE, "Pipeline: draw model: fan (RP_WORLD)"); - QVk_DebugSetObjectName((uint64_t)vk_drawModelPipelineFan[1].layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "Pipeline Layout: draw model: fan (RP_UI)"); - QVk_DebugSetObjectName((uint64_t)vk_drawModelPipelineFan[1].pl, VK_OBJECT_TYPE_PIPELINE, "Pipeline: draw model: fan (RP_UI)"); // dedicated model pipelines for translucent objects with depth write disabled vk_drawNoDepthModelPipelineStrip.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; @@ -1450,7 +1457,7 @@ void QVk_Shutdown( void ) { R_Printf(PRINT_ALL, "Shutting down Vulkan\n"); - for (int i = 0; i < 2; ++i) + for (int i = 0; i < RP_COUNT; ++i) { QVk_DestroyPipeline(&vk_drawColorQuadPipeline[i]); QVk_DestroyPipeline(&vk_drawModelPipelineStrip[i]); @@ -2225,7 +2232,7 @@ static uint8_t *QVk_GetIndexBuffer(VkDeviceSize size, VkDeviceSize *dstOffset) uint8_t *QVk_GetUniformBuffer(VkDeviceSize size, uint32_t *dstOffset, VkDescriptorSet *dstUboDescriptorSet) { // 0x100 alignment is required by Vulkan spec - const uint32_t aligned_size = ROUNDUP(size, 256); + const uint32_t aligned_size = ROUNDUP(size, 0x100); if (vk_dynUniformBuffers[vk_activeDynBufferIdx].currentOffset + UNIFORM_ALLOC_SIZE > vk_config.uniform_buffer_size) { diff --git a/src/client/refresh/vk/vk_rmain.c b/src/client/refresh/vk/vk_rmain.c index ae93ae54..fa5c8b45 100644 --- a/src/client/refresh/vk/vk_rmain.c +++ b/src/client/refresh/vk/vk_rmain.c @@ -897,7 +897,7 @@ R_SetupVulkan (void) vkCmdPushConstants(vk_activeCmdbuffer, vk_drawTexQuadPipeline.layout, VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(r_viewproj_matrix), r_viewproj_matrix); } -void R_Flash( void ) +static void R_Flash( void ) { R_PolyBlend (); } From 3b9aa6448ea5fde2b6aed667272f3010ec7029b3 Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Sun, 10 Jan 2021 13:25:10 +0200 Subject: [PATCH 2/2] Enable depthWriteEnable for particles --- src/client/refresh/vk/spirv/particle_vert.c | 4 ++-- src/client/refresh/vk/vk_common.c | 4 ++-- stuff/shaders/particle.vert | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/client/refresh/vk/spirv/particle_vert.c b/src/client/refresh/vk/spirv/particle_vert.c index 6e33bcf9..a0206ec6 100644 --- a/src/client/refresh/vk/spirv/particle_vert.c +++ b/src/client/refresh/vk/spirv/particle_vert.c @@ -1,4 +1,4 @@ - // 8.13.3559 + // 8.13.3743 #pragma once const uint32_t particle_vert_spv[] = { 0x07230203,0x00010000,0x00080008,0x0000002d,0x00000000,0x00020011,0x00000001,0x0006000b, @@ -34,7 +34,7 @@ const uint32_t particle_vert_spv[] = { 0x00000001,0x0004003b,0x0000001e,0x00000026,0x00000003,0x00040020,0x00000027,0x00000001, 0x00000007,0x0004003b,0x00000027,0x00000028,0x00000001,0x00040020,0x0000002a,0x00000003, 0x00000006,0x0004003b,0x0000002a,0x0000002b,0x00000003,0x0004002b,0x00000006,0x0000002c, - 0x00000000,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005, + 0x3f000000,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005, 0x00050041,0x00000011,0x00000012,0x00000010,0x0000000c,0x0004003d,0x0000000d,0x00000013, 0x00000012,0x0004003d,0x00000014,0x00000017,0x00000016,0x00050051,0x00000006,0x00000019, 0x00000017,0x00000000,0x00050051,0x00000006,0x0000001a,0x00000017,0x00000001,0x00050051, diff --git a/src/client/refresh/vk/vk_common.c b/src/client/refresh/vk/vk_common.c index 671f6b65..c9e30c0f 100644 --- a/src/client/refresh/vk/vk_common.c +++ b/src/client/refresh/vk/vk_common.c @@ -1238,7 +1238,7 @@ static void CreatePipelines() // draw particles pipeline (using a texture) VK_LOAD_VERTFRAG_SHADERS(shaders, particle, basic); - vk_drawParticlesPipeline.depthWriteEnable = VK_FALSE; + vk_drawParticlesPipeline.depthWriteEnable = VK_TRUE; vk_drawParticlesPipeline.blendOpts.blendEnable = VK_TRUE; QVk_CreatePipeline(&vk_samplerDescSetLayout, 1, &vertInfoRGB_RGBA_RG, &vk_drawParticlesPipeline, &vk_renderpasses[RP_WORLD], shaders, 2); QVk_DebugSetObjectName((uint64_t)vk_drawParticlesPipeline.layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "Pipeline Layout: textured particles"); @@ -1247,7 +1247,7 @@ static void CreatePipelines() // draw particles pipeline (using point list) VK_LOAD_VERTFRAG_SHADERS(shaders, point_particle, point_particle); vk_drawPointParticlesPipeline.topology = VK_PRIMITIVE_TOPOLOGY_POINT_LIST; - vk_drawPointParticlesPipeline.depthWriteEnable = VK_FALSE; + vk_drawPointParticlesPipeline.depthWriteEnable = VK_TRUE; vk_drawPointParticlesPipeline.blendOpts.blendEnable = VK_TRUE; QVk_CreatePipeline(&vk_uboDescSetLayout, 1, &vertInfoRGB_RGBA, &vk_drawPointParticlesPipeline, &vk_renderpasses[RP_WORLD], shaders, 2); QVk_DebugSetObjectName((uint64_t)vk_drawPointParticlesPipeline.layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "Pipeline Layout: point particles"); diff --git a/stuff/shaders/particle.vert b/stuff/shaders/particle.vert index 785b555e..40fd6742 100644 --- a/stuff/shaders/particle.vert +++ b/stuff/shaders/particle.vert @@ -22,5 +22,5 @@ void main() { gl_Position = pc.mvpMatrix * vec4(inVertex, 1.0); texCoord = inTexCoord; color = inColor; - aTreshold = 0.0; + aTreshold = 0.5; }