Compare commits

..

2 Commits

Author SHA1 Message Date
abdelrahman e59865bff5 Fix slangc warnings 2026-08-09 20:46:14 +01:00
abdelrahman e206e4647b Clear screen to neutral gray 2026-08-09 20:45:36 +01:00
3 changed files with 32 additions and 3 deletions
+5 -1
View File
@@ -8,7 +8,8 @@
struct BlitData { struct BlitData {
float4 rect; // NDC fit rect: x0, y0, x1, y1 float4 rect; // NDC fit rect: x0, y0, x1, y1
uint selected; uint selected;
uint pad[3]; uint mode; // 0 = sample texture, 1 = solid background
uint pad[2];
}; };
[[vk::push_constant]] [[vk::push_constant]]
@@ -33,5 +34,8 @@ VSOutput main(uint vertexIndex : SV_VertexID) {
[shader("fragment")] [shader("fragment")]
float4 main(VSOutput input) { 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); return textures[NonUniformResourceIndex(blit.selected)].Sample(input.UV);
} }
+9 -1
View File
@@ -33,7 +33,15 @@ vendor:
# Compile shaders from .slang to SPIR-V # Compile shaders from .slang to SPIR-V
shaders: shaders:
mkdir -p {{BUILDDIR}}/shaders mkdir -p {{BUILDDIR}}/shaders
{{VK_SDK}}/bin/slangc -target spirv -profile spirv_1_4 \ {{VK_SDK}}/bin/slangc -target spirv \
-profile spirv_1_6+\
SPV_GOOGLE_user_type+\
spvFragmentFullyCoveredEXT+\
spvDerivativeControl+\
spvImageQuery+\
spvImageGatherExtended+\
spvSparseResidency+\
spvMinLod \
-o {{BUILDDIR}}/shaders/blit.spv assets/blit.slang -o {{BUILDDIR}}/shaders/blit.spv assets/blit.slang
# Build all objects, then link # Build all objects, then link
+18 -1
View File
@@ -50,7 +50,8 @@ struct TextureResources {
struct BlitData { struct BlitData {
f32 rect[4]; // NDC fit rect: x0, y0, x1, y1 f32 rect[4]; // NDC fit rect: x0, y0, x1, y1
u32 selected; u32 selected;
u32 pad[3]; u32 mode; // 0 = sample texture, 1 = solid background
u32 pad[2];
}; };
// Typedefs for wapp arrays of our types // Typedefs for wapp arrays of our types
@@ -481,12 +482,28 @@ int main() {
prRhiCmdBindDescriptorSets(cb, PR_RHI_PIPELINE_BIND_POINT_GRAPHICS, prRhiCmdBindDescriptorSets(cb, PR_RHI_PIPELINE_BIND_POINT_GRAPHICS,
app.pipeline_layout, 0, sets); 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 = {}; BlitData blit = {};
blit.rect[0] = fit_rect[0]; blit.rect[0] = fit_rect[0];
blit.rect[1] = fit_rect[1]; blit.rect[1] = fit_rect[1];
blit.rect[2] = fit_rect[2]; blit.rect[2] = fit_rect[2];
blit.rect[3] = fit_rect[3]; blit.rect[3] = fit_rect[3];
blit.selected = app.selected; blit.selected = app.selected;
blit.mode = 0;
prRhiCmdPushConstants(cb, app.pipeline_layout, prRhiCmdPushConstants(cb, app.pipeline_layout,
(PrRhiShaderStage)(PR_RHI_SHADER_STAGE_VERTEX | (PrRhiShaderStage)(PR_RHI_SHADER_STAGE_VERTEX |
PR_RHI_SHADER_STAGE_FRAGMENT), PR_RHI_SHADER_STAGE_FRAGMENT),