From e206e4647b68d353291f21db4f1122147f43ba65 Mon Sep 17 00:00:00 2001 From: Abdelrahman Date: Sun, 9 Aug 2026 20:45:36 +0100 Subject: [PATCH] Clear screen to neutral gray --- assets/blit.slang | 6 +++++- src/main.cpp | 19 ++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/assets/blit.slang b/assets/blit.slang index de08d92..9778f0b 100644 --- a/assets/blit.slang +++ b/assets/blit.slang @@ -8,7 +8,8 @@ struct BlitData { float4 rect; // NDC fit rect: x0, y0, x1, y1 uint selected; - uint pad[3]; + uint mode; // 0 = sample texture, 1 = solid background + uint pad[2]; }; [[vk::push_constant]] @@ -33,5 +34,8 @@ VSOutput main(uint vertexIndex : SV_VertexID) { [shader("fragment")] float4 main(VSOutput input) { + if (blit.mode == 1) { + return float4(0.18, 0.18, 0.18, 1.0); + } return textures[NonUniformResourceIndex(blit.selected)].Sample(input.UV); } diff --git a/src/main.cpp b/src/main.cpp index 0e56b47..7bdfb00 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -50,7 +50,8 @@ struct TextureResources { struct BlitData { f32 rect[4]; // NDC fit rect: x0, y0, x1, y1 u32 selected; - u32 pad[3]; + u32 mode; // 0 = sample texture, 1 = solid background + u32 pad[2]; }; // Typedefs for wapp arrays of our types @@ -481,12 +482,28 @@ int main() { prRhiCmdBindDescriptorSets(cb, PR_RHI_PIPELINE_BIND_POINT_GRAPHICS, app.pipeline_layout, 0, sets); + // Draw background (fullscreen grey quad) + BlitData bg = {}; + bg.rect[0] = -1.0f; + bg.rect[1] = -1.0f; + bg.rect[2] = 1.0f; + bg.rect[3] = 1.0f; + bg.selected = 0; + bg.mode = 1; + prRhiCmdPushConstants(cb, app.pipeline_layout, + (PrRhiShaderStage)(PR_RHI_SHADER_STAGE_VERTEX | + PR_RHI_SHADER_STAGE_FRAGMENT), + 0, sizeof(BlitData), &bg); + prRhiCmdDraw(cb, 4, 1, 0, 0); + + // Draw texture (contain-fit) BlitData blit = {}; blit.rect[0] = fit_rect[0]; blit.rect[1] = fit_rect[1]; blit.rect[2] = fit_rect[2]; blit.rect[3] = fit_rect[3]; blit.selected = app.selected; + blit.mode = 0; prRhiCmdPushConstants(cb, app.pipeline_layout, (PrRhiShaderStage)(PR_RHI_SHADER_STAGE_VERTEX | PR_RHI_SHADER_STAGE_FRAGMENT),