// 2D image blit for the Direct3D backends (the D3D port of scene.vert/scene.frag). // // The scene image is drawn as a single fullscreen triangle sampling the // software-rendered `ra3::render::image`. The constant buffer carries the // destination rectangle in window-normalized coordinates (y down), so the map // is letterboxed rather than stretched. D3D clip space has +Y up, so the vertex // position flips Y relative to the Vulkan shader (which relies on Vulkan's // +Y-down clip space); the sampled UVs and the image's top-left origin are // unchanged. cbuffer RectCB : register(b0) { float4 rect; // xy = top-left (0..1), zw = size (0..1) }; Texture2D scene_tex : register(t0); SamplerState scene_smp : register(s0); struct VSOut { float4 pos : SV_Position; float2 uv : TEXCOORD0; }; VSOut VSMain(uint vertex_id : SV_VertexID) { float2 p = float2((vertex_id << 1) & 2, vertex_id & 2); VSOut o; o.uv = (p - rect.xy) / rect.zw; o.pos = float4(p.x * 2.0 - 1.0, 1.0 - p.y * 2.0, 0.0, 1.0); return o; } float4 PSMain(VSOut input) : SV_Target { if (input.uv.x < 0.0 || input.uv.x > 1.0 || input.uv.y < 0.0 || input.uv.y > 1.0) discard; return scene_tex.Sample(scene_smp, input.uv); }