mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 19:08:38 +00:00
On a GPU without a D24 attachment (AMD) the layer stores D24_UNORM_S8_UINT as D32_SFLOAT_S8_UINT. Draws then broke two D3D rules: the integer DepthBias was scaled by the primitive's exponent instead of D24 units, and fragment depth was not quantised like the clears, so an EQUAL test at a cleared value failed. Single-sampled graphics pipelines with depth enabled on such a target now have their pixel stage write FragDepth = quantise(z + D3D bias), with the bias in D24 units and the quantisation of depth24_convert.comp; the rasterizer's own bias is off for them. A pipeline without a pixel shader, with or without a geometry shader, gets a built-in one. d3d12_depth24_draw_test covers the finding's cases, stored depth with constant and slope-scaled bias, a shader that writes depth, and a VS + GS pipeline without a pixel shader. Co-authored-by: UlteriorMotive00 <132296248+UlteriorMotive00@users.noreply.github.com>
17 lines
685 B
GLSL
17 lines
685 B
GLSL
#version 460
|
|
// A full-screen triangle at a chosen depth, written to the translator's runtime contract (docs/design.md, "User
|
|
// data"), for d3d12_depth24_draw_test: s0 is the depth at the centre and s1 how much it changes per unit of clip-space
|
|
// x, so s1 = 0 gives a flat triangle and anything else a constant slope across the target.
|
|
|
|
layout(push_constant) uniform UserData {
|
|
uint s[32];
|
|
uvec2 heap_base;
|
|
uvec2 code_base;
|
|
} pc;
|
|
|
|
void main() {
|
|
const vec2 corner = vec2(float(gl_VertexIndex & 2), float((gl_VertexIndex << 1) & 2));
|
|
const vec2 xy = corner * 2.0 - 1.0;
|
|
gl_Position = vec4(xy, uintBitsToFloat(pc.s[0]) + uintBitsToFloat(pc.s[1]) * xy.x, 1.0);
|
|
}
|