Compare commits
2 Commits
a0b7c0672a
...
e59865bff5
| Author | SHA1 | Date | |
|---|---|---|---|
| e59865bff5 | |||
| e206e4647b |
+5
-1
@@ -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);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,15 @@ vendor:
|
||||
# Compile shaders from .slang to SPIR-V
|
||||
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
|
||||
|
||||
# Build all objects, then link
|
||||
|
||||
+18
-1
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user