// Prism fullscreen texture blit shader. // // Draws a selected texture from the bindless array as a fullscreen quad that // is letterboxed/pillarboxed to preserve aspect ratio (contain-fit). The NDC // content rect is supplied via push constants so the texture is never // stretched, squashed, or cropped. struct BlitData { float4 rect; // NDC fit rect: x0, y0, x1, y1 uint selected; uint mode; // 0 = sample texture, 1 = solid background uint pad[2]; }; [[vk::push_constant]] BlitData blit; Sampler2D textures[]; struct VSOutput { float4 Pos : SV_POSITION; float2 UV; }; [shader("vertex")] VSOutput main(uint vertexIndex : SV_VertexID) { VSOutput output; float2 uv = float2(float(vertexIndex & 1), float((vertexIndex >> 1) & 1)); output.UV = uv; float2 pos = lerp(blit.rect.xy, blit.rect.zw, uv); output.Pos = float4(pos, 0.0, 1.0); return output; } [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); }