Test a blit shader implementation
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
// 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 pad[3];
|
||||
};
|
||||
|
||||
[[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) {
|
||||
return textures[NonUniformResourceIndex(blit.selected)].Sample(input.UV);
|
||||
}
|
||||
Reference in New Issue
Block a user