From 490617de7a35db3c7bedbd96835582fa459a1ed1 Mon Sep 17 00:00:00 2001 From: myT <> Date: Fri, 29 Mar 2024 02:38:29 +0100 Subject: [PATCH] added debug label scopes and pipeline creation helpers --- code/renderer/crp_dof_accum.cpp | 18 ++------ code/renderer/crp_dof_gather.cpp | 67 +++++++--------------------- code/renderer/crp_dynamic_lights.cpp | 16 ++----- code/renderer/crp_gbuffer_viz.cpp | 32 ++++--------- code/renderer/crp_local.h | 3 ++ code/renderer/crp_magnifier.cpp | 6 +-- code/renderer/crp_main.cpp | 26 ++++++++--- code/renderer/crp_motion_blur.cpp | 37 +++++---------- code/renderer/crp_prepass.cpp | 6 +-- code/renderer/crp_tone_map.cpp | 16 ++----- code/renderer/crp_transp_resolve.cpp | 6 +-- code/renderer/srp_imgui.cpp | 2 +- code/renderer/srp_local.h | 14 ++++++ 13 files changed, 85 insertions(+), 164 deletions(-) diff --git a/code/renderer/crp_dof_accum.cpp b/code/renderer/crp_dof_accum.cpp index 5909166..84242ba 100644 --- a/code/renderer/crp_dof_accum.cpp +++ b/code/renderer/crp_dof_accum.cpp @@ -128,33 +128,21 @@ void AccumDepthOfField::Init() { { GraphicsPipelineDesc desc("DOF Accumulate"); - desc.shortLifeTime = true; - desc.vertexShader = ShaderByteCode(g_fullscreen_vs); - desc.pixelShader = ShaderByteCode(g_accum_ps); - desc.depthStencil.DisableDepth(); - desc.rasterizer.cullMode = CT_TWO_SIDED; + MakeFullScreenPipeline(desc, ShaderByteCode(g_accum_ps)); desc.AddRenderTarget(GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE, crp.renderTargetFormat); accumPipeline = CreateGraphicsPipeline(desc); } { GraphicsPipelineDesc desc("DOF Normalize"); - desc.shortLifeTime = true; - desc.vertexShader = ShaderByteCode(g_fullscreen_vs); - desc.pixelShader = ShaderByteCode(g_norm_ps); - desc.depthStencil.DisableDepth(); - desc.rasterizer.cullMode = CT_TWO_SIDED; + MakeFullScreenPipeline(desc, ShaderByteCode(g_norm_ps)); desc.AddRenderTarget(0, crp.renderTargetFormat); normPipeline = CreateGraphicsPipeline(desc); } { GraphicsPipelineDesc desc("DOF Debug"); - desc.shortLifeTime = true; - desc.vertexShader = ShaderByteCode(g_fullscreen_vs); - desc.pixelShader = ShaderByteCode(g_debug_ps); - desc.depthStencil.DisableDepth(); - desc.rasterizer.cullMode = CT_TWO_SIDED; + MakeFullScreenPipeline(desc, ShaderByteCode(g_debug_ps)); desc.AddRenderTarget(0, crp.renderTargetFormat); debugPipeline = CreateGraphicsPipeline(desc); } diff --git a/code/renderer/crp_dof_gather.cpp b/code/renderer/crp_dof_gather.cpp index b49da01..df5b808 100644 --- a/code/renderer/crp_dof_gather.cpp +++ b/code/renderer/crp_dof_gather.cpp @@ -143,59 +143,22 @@ void GatherDepthOfField::Init() tileTextureWidth = (uint32_t)(glConfig.vidWidth + 15) / 16; tileTextureHeight = (uint32_t)(glConfig.vidHeight + 15) / 16; - { - ComputePipelineDesc desc("DOF split"); - desc.shortLifeTime = true; - desc.shader = ShaderByteCode(g_split_cs); - splitPipeline = CreateComputePipeline(desc); - } - - { - ComputePipelineDesc desc("DOF near CoC tile generation"); - desc.shortLifeTime = true; - desc.shader = ShaderByteCode(g_coc_tile_gen_cs); - nearCocTileGenPipeline = CreateComputePipeline(desc); - } - - { - ComputePipelineDesc desc("DOF near CoC tile dilation"); - desc.shortLifeTime = true; - desc.shader = ShaderByteCode(g_coc_tile_max_cs); - nearCocTileMaxPipeline = CreateComputePipeline(desc); - } - - { - ComputePipelineDesc desc("DOF blur"); - desc.shortLifeTime = true; - desc.shader = ShaderByteCode(g_blur_cs); - blurPipeline = CreateComputePipeline(desc); - } - - { - ComputePipelineDesc desc("DOF fill"); - desc.shortLifeTime = true; - desc.shader = ShaderByteCode(g_fill_cs); - fillPipeline = CreateComputePipeline(desc); - } + splitPipeline = CreateComputePipeline("DOF split", ShaderByteCode(g_split_cs)); + nearCocTileGenPipeline = CreateComputePipeline("DOF near CoC tile generation", ShaderByteCode(g_coc_tile_gen_cs)); + nearCocTileMaxPipeline = CreateComputePipeline("DOF near CoC tile dilation", ShaderByteCode(g_coc_tile_max_cs)); + blurPipeline = CreateComputePipeline("DOF blur", ShaderByteCode(g_blur_cs)); + fillPipeline = CreateComputePipeline("DOF fill", ShaderByteCode(g_fill_cs)); { GraphicsPipelineDesc desc("DOF combine"); - desc.shortLifeTime = true; - desc.vertexShader = ShaderByteCode(g_fullscreen_vs); - desc.pixelShader = ShaderByteCode(g_combine_ps); - desc.depthStencil.DisableDepth(); - desc.rasterizer.cullMode = CT_TWO_SIDED; + MakeFullScreenPipeline(desc, ShaderByteCode(g_combine_ps)); desc.AddRenderTarget(0, renderTargetFormat); combinePipeline = CreateGraphicsPipeline(desc); } { GraphicsPipelineDesc desc("DOF viz"); - desc.shortLifeTime = true; - desc.vertexShader = ShaderByteCode(g_fullscreen_vs); - desc.pixelShader = ShaderByteCode(g_debug_ps); - desc.depthStencil.DisableDepth(); - desc.rasterizer.cullMode = CT_TWO_SIDED; + MakeFullScreenPipeline(desc, ShaderByteCode(g_debug_ps)); desc.AddRenderTarget(0, renderTargetFormat); debugPipeline = CreateGraphicsPipeline(desc); } @@ -244,6 +207,8 @@ void GatherDepthOfField::Draw() return; } + SCOPED_RENDER_PASS("Gather DOF", 0.125f, 0.125f, 0.25f); + DrawSplit(); DrawNearCocTileGen(); DrawNearCocTileMax(); @@ -260,7 +225,7 @@ void GatherDepthOfField::DrawDebug() return; } - SCOPED_RENDER_PASS("DOF Debug", 0.125f, 0.125f, 0.25f); + SCOPED_DEBUG_LABEL("DOF Debug", 0.125f, 0.125f, 0.25f); crp.SwapRenderTargets(); @@ -289,7 +254,7 @@ void GatherDepthOfField::DrawDebug() void GatherDepthOfField::DrawSplit() { - SCOPED_RENDER_PASS("DOF Split", 0.125f, 0.125f, 0.25f); + SCOPED_DEBUG_LABEL("DOF Split", 0.125f, 0.125f, 0.25f); CmdBeginBarrier(); CmdTextureBarrier(crp.depthTexture, ResourceStates::ComputeShaderAccessBit); @@ -321,7 +286,7 @@ void GatherDepthOfField::DrawSplit() void GatherDepthOfField::DrawNearCocTileGen() { - SCOPED_RENDER_PASS("DOF Tile Gen", 0.125f, 0.125f, 0.25f); + SCOPED_DEBUG_LABEL("DOF Tile Gen", 0.125f, 0.125f, 0.25f); CmdBeginBarrier(); CmdTextureBarrier(nearCocTexture, ResourceStates::ComputeShaderAccessBit); @@ -339,7 +304,7 @@ void GatherDepthOfField::DrawNearCocTileGen() void GatherDepthOfField::DrawNearCocTileMax() { - SCOPED_RENDER_PASS("DOF Tile Max", 0.125f, 0.125f, 0.25f); + SCOPED_DEBUG_LABEL("DOF Tile Max", 0.125f, 0.125f, 0.25f); CmdBeginBarrier(); CmdTextureBarrier(nearCocTileTexture, ResourceStates::ComputeShaderAccessBit); @@ -358,7 +323,7 @@ void GatherDepthOfField::DrawNearCocTileMax() void GatherDepthOfField::DrawBlur() { - SCOPED_RENDER_PASS("DOF Blur", 0.125f, 0.125f, 0.25f); + SCOPED_DEBUG_LABEL("DOF Blur", 0.125f, 0.125f, 0.25f); CmdBeginBarrier(); CmdTextureBarrier(crp.renderTarget, ResourceStates::ComputeShaderAccessBit); @@ -392,7 +357,7 @@ void GatherDepthOfField::DrawBlur() void GatherDepthOfField::DrawFill() { - SCOPED_RENDER_PASS("DOF Fill", 0.125f, 0.125f, 0.25f); + SCOPED_DEBUG_LABEL("DOF Fill", 0.125f, 0.125f, 0.25f); CmdBeginBarrier(); CmdTextureBarrier(nearBlurTexture, ResourceStates::ComputeShaderAccessBit); @@ -415,7 +380,7 @@ void GatherDepthOfField::DrawFill() void GatherDepthOfField::DrawCombine() { - SCOPED_RENDER_PASS("DOF Combine", 0.125f, 0.125f, 0.25f); + SCOPED_DEBUG_LABEL("DOF Combine", 0.125f, 0.125f, 0.25f); CmdBeginBarrier(); CmdTextureBarrier(nearColorTexture, ResourceStates::PixelShaderAccessBit); diff --git a/code/renderer/crp_dynamic_lights.cpp b/code/renderer/crp_dynamic_lights.cpp index 3e5667f..005e8ec 100644 --- a/code/renderer/crp_dynamic_lights.cpp +++ b/code/renderer/crp_dynamic_lights.cpp @@ -52,22 +52,14 @@ void DynamicLights::Init() { GraphicsPipelineDesc desc("Dynamic Lights"); - desc.shortLifeTime = true; - desc.vertexShader = ShaderByteCode(g_fullscreen_vs); - desc.pixelShader = ShaderByteCode(g_dl_draw_ps); - desc.depthStencil.DisableDepth(); - desc.rasterizer.cullMode = CT_TWO_SIDED; + MakeFullScreenPipeline(desc, ShaderByteCode(g_dl_draw_ps)); desc.AddRenderTarget(0, crp.renderTargetFormat); pipeline = CreateGraphicsPipeline(desc); } { GraphicsPipelineDesc desc("Dynamic Lights Denoising"); - desc.shortLifeTime = true; - desc.vertexShader = ShaderByteCode(g_fullscreen_vs); - desc.pixelShader = ShaderByteCode(g_dl_denoising_ps); - desc.depthStencil.DisableDepth(); - desc.rasterizer.cullMode = CT_TWO_SIDED; + MakeFullScreenPipeline(desc, ShaderByteCode(g_dl_denoising_ps)); desc.AddRenderTarget(0, crp.renderTargetFormat); denoisingPipeline = CreateGraphicsPipeline(desc); } @@ -95,7 +87,7 @@ void DynamicLights::Draw() srp.renderMode = RenderMode::None; { - SCOPED_RENDER_PASS("Dynamic Lights", 1.0f, 1.0f, 1.0f); + SCOPED_DEBUG_LABEL("DL Draw", 1.0f, 1.0f, 1.0f); CmdSetViewportAndScissor(0, 0, glConfig.vidWidth, glConfig.vidHeight); @@ -114,7 +106,7 @@ void DynamicLights::Draw() } { - SCOPED_RENDER_PASS("DL Denoising", 1.0f, 1.0f, 1.0f); + SCOPED_DEBUG_LABEL("DL Denoise", 1.0f, 1.0f, 1.0f); CmdSetViewportAndScissor(0, 0, glConfig.vidWidth, glConfig.vidHeight); diff --git a/code/renderer/crp_gbuffer_viz.cpp b/code/renderer/crp_gbuffer_viz.cpp index 36f7723..f8827c5 100644 --- a/code/renderer/crp_gbuffer_viz.cpp +++ b/code/renderer/crp_gbuffer_viz.cpp @@ -63,44 +63,28 @@ void GBufferViz::Init() { { GraphicsPipelineDesc desc("G-Buffer Depth"); - desc.shortLifeTime = true; - desc.vertexShader = ShaderByteCode(g_fullscreen_vs); - desc.pixelShader = ShaderByteCode(g_gbufferviz_depth_ps); - desc.depthStencil.DisableDepth(); - desc.rasterizer.cullMode = CT_TWO_SIDED; + MakeFullScreenPipeline(desc, ShaderByteCode(g_gbufferviz_depth_ps)); desc.AddRenderTarget(0, crp.renderTargetFormat); linearizeDepthPipeline = CreateGraphicsPipeline(desc); } { GraphicsPipelineDesc desc("G-Buffer Normal"); - desc.shortLifeTime = true; - desc.vertexShader = ShaderByteCode(g_fullscreen_vs); - desc.pixelShader = ShaderByteCode(g_gbufferviz_normal_ps); - desc.depthStencil.DisableDepth(); - desc.rasterizer.cullMode = CT_TWO_SIDED; + MakeFullScreenPipeline(desc, ShaderByteCode(g_gbufferviz_normal_ps)); desc.AddRenderTarget(0, crp.renderTargetFormat); decodeNormalsPipeline = CreateGraphicsPipeline(desc); } { GraphicsPipelineDesc desc("G-Buffer Position"); - desc.shortLifeTime = true; - desc.vertexShader = ShaderByteCode(g_fullscreen_vs); - desc.pixelShader = ShaderByteCode(g_gbufferviz_position_ps); - desc.depthStencil.DisableDepth(); - desc.rasterizer.cullMode = CT_TWO_SIDED; + MakeFullScreenPipeline(desc, ShaderByteCode(g_gbufferviz_position_ps)); desc.AddRenderTarget(0, crp.renderTargetFormat); decodeShadingPositionPipeline = CreateGraphicsPipeline(desc); } { GraphicsPipelineDesc desc("G-Buffer Motion"); - desc.shortLifeTime = true; - desc.vertexShader = ShaderByteCode(g_fullscreen_vs); - desc.pixelShader = ShaderByteCode(g_gbufferviz_motion_ps); - desc.depthStencil.DisableDepth(); - desc.rasterizer.cullMode = CT_TWO_SIDED; + MakeFullScreenPipeline(desc, ShaderByteCode(g_gbufferviz_motion_ps)); desc.AddRenderTarget(0, crp.renderTargetFormat); motionVectorPipeline = CreateGraphicsPipeline(desc); } @@ -121,7 +105,7 @@ void GBufferViz::DrawGUI() { srp.renderMode = RenderMode::None; - SCOPED_RENDER_PASS("Debug Depth", 1.0f, 1.0f, 1.0f); + SCOPED_DEBUG_LABEL("Debug Depth", 1.0f, 1.0f, 1.0f); CmdSetViewportAndScissor(0, 0, glConfig.vidWidth, glConfig.vidHeight); @@ -144,7 +128,7 @@ void GBufferViz::DrawGUI() { srp.renderMode = RenderMode::None; - SCOPED_RENDER_PASS("Debug Normal", 1.0f, 1.0f, 1.0f); + SCOPED_DEBUG_LABEL("Debug Normal", 1.0f, 1.0f, 1.0f); CmdSetViewportAndScissor(0, 0, glConfig.vidWidth, glConfig.vidHeight); @@ -165,7 +149,7 @@ void GBufferViz::DrawGUI() { srp.renderMode = RenderMode::None; - SCOPED_RENDER_PASS("Debug Position", 1.0f, 1.0f, 1.0f); + SCOPED_DEBUG_LABEL("Debug Position", 1.0f, 1.0f, 1.0f); CmdSetViewportAndScissor(0, 0, glConfig.vidWidth, glConfig.vidHeight); @@ -193,7 +177,7 @@ void GBufferViz::DrawGUI() crp.motionVectorTexture : crp.motionVectorMBTexture; - SCOPED_RENDER_PASS("Debug Motion", 1.0f, 1.0f, 1.0f); + SCOPED_DEBUG_LABEL("Debug Motion", 1.0f, 1.0f, 1.0f); CmdSetViewportAndScissor(0, 0, glConfig.vidWidth, glConfig.vidHeight); diff --git a/code/renderer/crp_local.h b/code/renderer/crp_local.h index e4bde9b..bd266bd 100644 --- a/code/renderer/crp_local.h +++ b/code/renderer/crp_local.h @@ -561,4 +561,7 @@ struct CRP : IRenderPipeline GBufferViz gbufferViz; }; +HPipeline CreateComputePipeline(const char* name, const ShaderByteCode& shader); +void MakeFullScreenPipeline(GraphicsPipelineDesc& desc, const ShaderByteCode& pixelShader); + extern CRP crp; diff --git a/code/renderer/crp_magnifier.cpp b/code/renderer/crp_magnifier.cpp index 1bddb60..4b2fdeb 100644 --- a/code/renderer/crp_magnifier.cpp +++ b/code/renderer/crp_magnifier.cpp @@ -44,11 +44,7 @@ struct MagnifierRC void Magnifier::Init() { GraphicsPipelineDesc desc("Magnifier"); - desc.shortLifeTime = true; - desc.vertexShader = ShaderByteCode(g_fullscreen_vs); - desc.pixelShader = ShaderByteCode(g_magnifier_ps); - desc.depthStencil.DisableDepth(); - desc.rasterizer.cullMode = CT_TWO_SIDED; + MakeFullScreenPipeline(desc, ShaderByteCode(g_magnifier_ps)); desc.AddRenderTarget(0, crp.renderTargetFormat); pipeline = CreateGraphicsPipeline(desc); } diff --git a/code/renderer/crp_main.cpp b/code/renderer/crp_main.cpp index 6f283b1..b256636 100644 --- a/code/renderer/crp_main.cpp +++ b/code/renderer/crp_main.cpp @@ -246,6 +246,22 @@ static HTexture LoadTexture(const char* name, int flags, textureWrap_t glWrapCla return image->texture; } +HPipeline CreateComputePipeline(const char* name, const ShaderByteCode& shader) +{ + ComputePipelineDesc desc(name); + desc.shortLifeTime = true; + desc.shader = shader; + + return CreateComputePipeline(desc); +} + +void MakeFullScreenPipeline(GraphicsPipelineDesc& desc, const ShaderByteCode& pixelShader) +{ + desc.shortLifeTime = true; + desc.vertexShader = ShaderByteCode(g_fullscreen_vs); + desc.pixelShader = pixelShader; + desc.SetPostProcessState(); +} void PSOCache::Init(Entry* entries_, uint32_t maxEntryCount_) { @@ -485,11 +501,7 @@ void CRP::Init() { GraphicsPipelineDesc desc("blit LDR"); - desc.shortLifeTime = true; - desc.vertexShader = ShaderByteCode(g_fullscreen_vs); - desc.pixelShader = ShaderByteCode(g_blit_ps); - desc.depthStencil.DisableDepth(); - desc.rasterizer.cullMode = CT_TWO_SIDED; + MakeFullScreenPipeline(desc, ShaderByteCode(g_blit_ps)); desc.AddRenderTarget(0, TextureFormat::R8G8B8A8_UNorm); blitPipelineLDR = CreateGraphicsPipeline(desc); desc.name = "blit HDR"; @@ -609,7 +621,7 @@ void CRP::EndFrame() void CRP::Blit(HTexture destination, HTexture source, const char* passName, bool hdr, const vec2_t tcScale, const vec2_t tcBias) { - SCOPED_RENDER_PASS(passName, 0.125f, 0.125f, 0.5f); + SCOPED_DEBUG_LABEL(passName, 0.125f, 0.125f, 0.5f); CmdBeginBarrier(); CmdTextureBarrier(source, ResourceStates::PixelShaderAccessBit); @@ -909,7 +921,7 @@ void CRP::UploadSceneViewData() return; } - SCOPED_RENDER_PASS("Scene View Upload", 1.0f, 1.0f, 1.0f); + SCOPED_DEBUG_LABEL("Scene View Upload", 1.0f, 1.0f, 1.0f); const trRefdef_t& refdef = backEnd.refdef; const viewParms_t& vp = backEnd.viewParms; diff --git a/code/renderer/crp_motion_blur.cpp b/code/renderer/crp_motion_blur.cpp index 07ae7bc..086a7b3 100644 --- a/code/renderer/crp_motion_blur.cpp +++ b/code/renderer/crp_motion_blur.cpp @@ -70,36 +70,17 @@ void MotionBlur::Init() { GraphicsPipelineDesc desc("MBlur velocity/depth packing"); - desc.shortLifeTime = true; - desc.vertexShader = ShaderByteCode(g_fullscreen_vs); - desc.pixelShader = ShaderByteCode(g_pack_ps); - desc.depthStencil.DisableDepth(); - desc.rasterizer.cullMode = CT_TWO_SIDED; + MakeFullScreenPipeline(desc, ShaderByteCode(g_pack_ps)); desc.AddRenderTarget(0, TextureFormat::R32G32_UInt); packPipeline = CreateGraphicsPipeline(desc); } - { - ComputePipelineDesc desc("MBlur tile generation"); - desc.shortLifeTime = true; - desc.shader = ShaderByteCode(g_tile_gen_cs); - tileGenPipeline = CreateComputePipeline(desc); - } - - { - ComputePipelineDesc desc("MBlur tile dilation"); - desc.shortLifeTime = true; - desc.shader = ShaderByteCode(g_tile_max_cs); - tileMaxPipeline = CreateComputePipeline(desc); - } + tileGenPipeline = CreateComputePipeline("MBlur tile generation", ShaderByteCode(g_tile_gen_cs)); + tileMaxPipeline = CreateComputePipeline("MBlur tile dilation", ShaderByteCode(g_tile_max_cs)); { GraphicsPipelineDesc desc("MBlur reconstruction filter"); - desc.shortLifeTime = true; - desc.vertexShader = ShaderByteCode(g_fullscreen_vs); - desc.pixelShader = ShaderByteCode(g_blur_ps); - desc.depthStencil.DisableDepth(); - desc.rasterizer.cullMode = CT_TWO_SIDED; + MakeFullScreenPipeline(desc, ShaderByteCode(g_blur_ps)); desc.AddRenderTarget(0, crp.renderTargetFormat); blurPipeline = CreateGraphicsPipeline(desc); } @@ -136,6 +117,8 @@ void MotionBlur::Draw() return; } + SCOPED_RENDER_PASS("Motion Blur", 0.125f, 0.125f, 0.25f); + DrawPack(); DrawTileGen(); DrawTileMax(); @@ -144,7 +127,7 @@ void MotionBlur::Draw() void MotionBlur::DrawPack() { - SCOPED_RENDER_PASS("MBlur Pack", 0.125f, 0.125f, 0.25f); + SCOPED_DEBUG_LABEL("MBlur Pack", 0.125f, 0.125f, 0.25f); CmdBeginBarrier(); CmdTextureBarrier(crp.motionVectorMBTexture, ResourceStates::PixelShaderAccessBit); @@ -164,7 +147,7 @@ void MotionBlur::DrawPack() void MotionBlur::DrawTileGen() { - SCOPED_RENDER_PASS("MBlur Tile Gen", 0.125f, 0.125f, 0.25f); + SCOPED_DEBUG_LABEL("MBlur Tile Gen", 0.125f, 0.125f, 0.25f); CmdBeginBarrier(); CmdTextureBarrier(packedTexture, ResourceStates::ComputeShaderAccessBit); @@ -182,7 +165,7 @@ void MotionBlur::DrawTileGen() void MotionBlur::DrawTileMax() { - SCOPED_RENDER_PASS("MBlur Tile Max", 0.125f, 0.125f, 0.25f); + SCOPED_DEBUG_LABEL("MBlur Tile Max", 0.125f, 0.125f, 0.25f); CmdBeginBarrier(); CmdTextureBarrier(tileTexture, ResourceStates::ComputeShaderAccessBit); @@ -201,7 +184,7 @@ void MotionBlur::DrawTileMax() void MotionBlur::DrawBlur() { - SCOPED_RENDER_PASS("MBlur Blur", 0.125f, 0.125f, 0.25f); + SCOPED_DEBUG_LABEL("MBlur Blur", 0.125f, 0.125f, 0.25f); crp.SwapRenderTargets(); diff --git a/code/renderer/crp_prepass.cpp b/code/renderer/crp_prepass.cpp index 0b5fbaf..665cfef 100644 --- a/code/renderer/crp_prepass.cpp +++ b/code/renderer/crp_prepass.cpp @@ -147,11 +147,7 @@ void Prepass::Init() { GraphicsPipelineDesc desc("Skybox Motion Vectors"); - desc.shortLifeTime = true; - desc.vertexShader.Set(g_fullscreen_vs); - desc.pixelShader.Set(g_skybox_motion_ps); - desc.depthStencil.DisableDepth(); - desc.rasterizer.cullMode = CT_TWO_SIDED; + MakeFullScreenPipeline(desc, ShaderByteCode(g_skybox_motion_ps)); desc.AddRenderTarget(0, TextureFormat::R16G16_Float); skyboxMotionPipeline = CreateGraphicsPipeline(desc); } diff --git a/code/renderer/crp_tone_map.cpp b/code/renderer/crp_tone_map.cpp index acf68f2..7caff16 100644 --- a/code/renderer/crp_tone_map.cpp +++ b/code/renderer/crp_tone_map.cpp @@ -53,22 +53,14 @@ void ToneMap::Init() { { GraphicsPipelineDesc desc("Tone Map"); - desc.shortLifeTime = true; - desc.vertexShader = ShaderByteCode(g_fullscreen_vs); - desc.pixelShader = ShaderByteCode(g_tone_map_ps); - desc.depthStencil.DisableDepth(); - desc.rasterizer.cullMode = CT_TWO_SIDED; + MakeFullScreenPipeline(desc, ShaderByteCode(g_tone_map_ps)); desc.AddRenderTarget(0, crp.renderTargetFormat); pipeline = CreateGraphicsPipeline(desc); } { GraphicsPipelineDesc desc("Inverse Tone Map"); - desc.shortLifeTime = true; - desc.vertexShader = ShaderByteCode(g_fullscreen_vs); - desc.pixelShader = ShaderByteCode(g_tone_map_inverse_ps); - desc.depthStencil.DisableDepth(); - desc.rasterizer.cullMode = CT_TWO_SIDED; + MakeFullScreenPipeline(desc, ShaderByteCode(g_tone_map_inverse_ps)); desc.AddRenderTarget(0, crp.renderTargetFormat); pipeline = CreateGraphicsPipeline(desc); } @@ -78,7 +70,7 @@ void ToneMap::DrawToneMap() { srp.renderMode = RenderMode::None; - SCOPED_RENDER_PASS("Tone Map", 1.0f, 1.0f, 1.0f); + SCOPED_DEBUG_LABEL("Tone Map", 1.0f, 1.0f, 1.0f); CmdSetViewportAndScissor(0, 0, glConfig.vidWidth, glConfig.vidHeight); @@ -106,7 +98,7 @@ void ToneMap::DrawInverseToneMap() { srp.renderMode = RenderMode::None; - SCOPED_RENDER_PASS("Inverse Tone Map", 1.0f, 1.0f, 1.0f); + SCOPED_DEBUG_LABEL("Inverse Tone Map", 1.0f, 1.0f, 1.0f); CmdSetViewportAndScissor(0, 0, glConfig.vidWidth, glConfig.vidHeight); diff --git a/code/renderer/crp_transp_resolve.cpp b/code/renderer/crp_transp_resolve.cpp index 5fad79c..b8ca96e 100644 --- a/code/renderer/crp_transp_resolve.cpp +++ b/code/renderer/crp_transp_resolve.cpp @@ -49,11 +49,7 @@ struct TranspResolveRC void TranspResolve::Init() { GraphicsPipelineDesc desc("OIT Resolve"); - desc.shortLifeTime = true; - desc.vertexShader = ShaderByteCode(g_fullscreen_vs); - desc.pixelShader = ShaderByteCode(g_transp_resolve_ps); - desc.depthStencil.DisableDepth(); - desc.rasterizer.cullMode = CT_TWO_SIDED; + MakeFullScreenPipeline(desc, ShaderByteCode(g_transp_resolve_ps)); desc.AddRenderTarget(0, crp.renderTargetFormat); pipeline = CreateGraphicsPipeline(desc); } diff --git a/code/renderer/srp_imgui.cpp b/code/renderer/srp_imgui.cpp index 46903a8..0bc10ed 100644 --- a/code/renderer/srp_imgui.cpp +++ b/code/renderer/srp_imgui.cpp @@ -167,7 +167,7 @@ void ImGUI::Draw(HTexture renderTarget) return; } - SCOPED_RENDER_PASS("Dear ImGUI", 0.5f, 0.5f, 1.0f); + SCOPED_DEBUG_LABEL("Dear ImGUI", 0.5f, 0.5f, 1.0f); FrameResources* fr = &frameResources[GetFrameIndex()]; diff --git a/code/renderer/srp_local.h b/code/renderer/srp_local.h index beb334a..858eec8 100644 --- a/code/renderer/srp_local.h +++ b/code/renderer/srp_local.h @@ -402,7 +402,21 @@ struct ScopedRenderPass uint32_t index; }; +struct ScopedDebugLabel +{ + ScopedDebugLabel(const char* name, float r, float g, float b) + { + CmdBeginDebugLabel(name, r, g, b); + } + + ~ScopedDebugLabel() + { + CmdEndDebugLabel(); + } +}; + #define SCOPED_RENDER_PASS(Name, R, G, B) ScopedRenderPass CONCAT(rp_, __LINE__)(Name, R, G, B) +#define SCOPED_DEBUG_LABEL(Name, R, G, B) ScopedDebugLabel CONCAT(rp_, __LINE__)(Name, R, G, B) #define BASE_SAMPLER_COUNT ((int)(TW_COUNT * TextureFilter::Count * MaxTextureMips))