Contract amendment 2 of three, and V4g's remaining half behind it. Plan section
5.5.16 defect 2: PortalDepthMaskRenderer's two-pass punch (#117) is built on
glStencilFunc/glStencilOp/glStencilMask, GpuPipelineDescription carried no
stencil state at all, and nothing else can express it - so the renderer stayed
raw GL, invisible to the Vulkan arm, and V4g's "stencil/depth-mask pipelines"
row could not be written.
The amendment splits the way core Vulkan 1.3 splits. The ENABLE and the
attachment intent are baked: GpuPipelineDescription.StencilTest, false by
default so no pipeline in the tree changed. The per-draw compare, three outcome
ops, reference and both masks are a GpuStencilState that the pipeline carries as
a DEFAULT and IGpuPassEncoder.SetStencil overrides - exactly the split cull
mode, front face and depth write already have, and exactly what
VK_DYNAMIC_STATE_STENCIL_OP/_COMPARE_MASK/_WRITE_MASK/_REFERENCE make dynamic.
The four stencil dynamic states are declared ONLY by a pipeline that tests
stencil: declaring a dynamic state obliges every draw with the pipeline to have
set it, so adding them unconditionally would make every existing pipeline depend
on a call none of them make. GpuStencilOp carries three values because the punch
uses three - Replace marks, Equal gates, Zero self-cleans - and a fourth would
be a facility with no consumer.
The arm. Three pipelines, not one, because depth COMPARE is not dynamic in the
contract and the punch's two passes differ in it: mark tests LEQUAL and writes
no depth, punch tests ALWAYS and writes, seal is ALWAYS + write with no stencil.
All three write no colour, which is what retail's "COLOR-INVISIBLE triangle fan"
means. The fan is expanded to a triangle LIST on the CPU - the contract has no
fan topology and Vulkan's is not portable - which is exact: triangle i is
(v0, v[i+1], v[i+2]), the same triangles in the same order.
portal_depth.{vert,frag} is a new committed shader pair, and this is the ONE
renderer in the campaign whose two arms do not share a source. Its clip planes
have to travel in the TerrainClip uniform block at binding 2, which is already
precisely this shape and already read by terrain_modern.vert and sky.vert - but
on GL that binding is held globally by ClipFrame for terrain, so a portal draw
that rebound it would leave every later terrain draw in the frame reading the
wrong region. The GL arm therefore keeps its inline program.
PortalDepthShaderParityTests is the tripwire: retail's far-Z constant
(0.99999988, from DrawPortalPolyInternal 0x0059bc90), #129's capped mark-bias
expression and the eight-half-plane loop are asserted to appear in both. Both
are deleted at V11. 9/10 shader pairs now compile to SPIR-V.
Two GL-side gaps closed while the state was being extended, both of section 7.1
rule 1's class rather than new work. GlAmbientCapabilityState now saves and
restores the stencil test, function, ops and both masks - the portal punch draws
mid-frame among renderers that are still raw GL and assume the test is off - and
the COLOUR MASK, which had no consumer until a colour-invisible pipeline existed
and whose absence would have blacked out every raw-GL renderer after such a
pass.
PortalTunnelPresentation was re-read and confirmed as V6k left it: it clears
depth and draws into the active viewport, binds no framebuffer of its own, and
needs no port for section 5.4's sake. It remains unported on the Vulkan arm -
the composition uses NullLocalPlayerTeleportPresentation there - which is an
absence on the V7 list, not a defect.
Gates. Release build green. App tests 4,129/3 skips; complete Release suite
9,192/5 (one solution-wide run reported a single App failure that did not
reproduce in two subsequent runs, solution-wide or alone - the documented
rerun-singly flake class). Strict GL offline pixel gate against 08ffe141:
2.31e-05, 13 differing pixels of 563,200, inside the documented 9-31 band. GL
connected -Runs 3: 3/3 RENDERED on the desktop witness and 3/3 on the client
capture. One offline Vulkan run with VK_LAYER_KHRONOS_validation proven inserted
by the loader: zero validation errors, zero warnings, a captured world frame.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
70 lines
3.2 KiB
GLSL
70 lines
3.2 KiB
GLSL
#version 430 core
|
|
|
|
// Campaign V slice V6l: retail's invisible portal depth write, moved out of
|
|
// PortalDepthMaskRenderer's inline GLSL string and into the shader tree so both
|
|
// backends compile it from one source. The BODY is the one that renderer has
|
|
// carried since BR-2 and #117; only how its inputs arrive changed.
|
|
//
|
|
// Three input moves, each because Vulkan GLSL has no default uniform block:
|
|
//
|
|
// uPlaneCount / uPlanes[8] -> the TerrainClip UBO at binding=2, which is
|
|
// already exactly this shape (int count + 8
|
|
// clip-space half-planes) and is already
|
|
// declared identically by terrain_modern.vert
|
|
// and sky.vert. Retail clips the portal polygon
|
|
// on the CPU against the installed view
|
|
// (polyClipFinish); we apply the SAME view
|
|
// region through gl_ClipDistance, so the depth
|
|
// write lands only inside the slice region.
|
|
// uForceFarZ -> uRenderPass, the shared push block's pass
|
|
// selector. This shader's two passes ARE seal
|
|
// (retail maxZ2, true projected depth) and punch
|
|
// (retail maxZ1, far-plane z).
|
|
// uDepthBias / EyeCapN -> uParamA / uParamB.
|
|
|
|
layout(location = 0) in vec3 aPos;
|
|
|
|
// Loose uniforms for the GL dialect. Under Vulkan the compiler drops these
|
|
// declarations and the injected preamble #defines each name onto its member of
|
|
// the shared 96-byte push block (tools/ShaderCompiler/VulkanGlslPreamble.cs).
|
|
uniform mat4 uViewProjection;
|
|
uniform int uRenderPass; // 0 = seal (retail maxZ2), 1 = punch (retail maxZ1)
|
|
uniform float uParamA; // #117 mark-pass NDC bias toward the viewer
|
|
uniform float uParamB; // #129 eye-span cap x near plane
|
|
|
|
layout(std140, ACDREAM_UBO_SET binding = 2) uniform TerrainClip {
|
|
int uTerrainClipCount;
|
|
vec4 uTerrainClipPlanes[8];
|
|
};
|
|
|
|
// Core profile: redeclare gl_PerVertex so writing gl_ClipDistance[] is legal
|
|
// (mirrors terrain_modern.vert and sky.vert). Sized 8 to match the
|
|
// ClipFrame.MaxPlanes budget and GL's guaranteed GL_MAX_CLIP_DISTANCES >= 8.
|
|
out gl_PerVertex {
|
|
vec4 gl_Position;
|
|
float gl_ClipDistance[8];
|
|
};
|
|
|
|
void main()
|
|
{
|
|
vec4 clipPos = uViewProjection * vec4(aPos, 1.0);
|
|
for (int i = 0; i < 8; i++)
|
|
gl_ClipDistance[i] = (i < uTerrainClipCount) ? dot(uTerrainClipPlanes[i], clipPos) : 1.0;
|
|
|
|
if (uRenderPass == 1)
|
|
{
|
|
clipPos.z = clipPos.w * 0.99999988; // retail far-z punch constant (0x0059bc90 tail)
|
|
}
|
|
else if (uParamA > 0.0)
|
|
{
|
|
// #117 mark-pass bias, #129 eye-space cap. clipPos.w = eye depth d;
|
|
// an NDC bias b spans ~b*d*d/near meters of eye depth, so the
|
|
// constant-NDC form alone reached METERS at distance (door-shaped
|
|
// leaks through hills/houses). Keep in sync with
|
|
// PortalDepthMaskRenderer.MarkBiasNdc.
|
|
float biasNdc = min(uParamA, uParamB / max(clipPos.w * clipPos.w, 1e-6));
|
|
clipPos.z -= biasNdc * clipPos.w;
|
|
}
|
|
|
|
gl_Position = clipPos;
|
|
}
|