Skip to content

Add ClipDistance and CullDistance tests#1168

Open
EmilioLaiso wants to merge 2 commits into
llvm:mainfrom
Traverse-Research:clip-cull-distance-test
Open

Add ClipDistance and CullDistance tests#1168
EmilioLaiso wants to merge 2 commits into
llvm:mainfrom
Traverse-Research:clip-cull-distance-test

Conversation

@EmilioLaiso
Copy link
Copy Markdown
Collaborator

Adds baseline tests for two graphics-stage system values from the
rasterization-coverage epic (#1146).
Both attach a float to a vertex. The rasterizer reads them and decides
whether to draw — but at different granularities:

  • SV_ClipDistance: the value is interpolated across the
    primitive. Any pixel whose interpolated value is negative is dropped
    before the pixel shader runs.
  • SV_CullDistance: the value is not interpolated. If every
    vertex of a primitive has a negative value, the entire primitive is
    dropped before rasterization.

ClipDistance.test

A fullscreen quad over a 4×1 render target. The vertex buffer is set up
so that clipDist == NDC.x at every vertex. After linear interpolation
across the quad, every pixel's clipDist equals its own NDC x.

Pixel centers in NDC land at -0.75, -0.25, +0.25, +0.75, so:

  • Pixels 0, 1 get a negative clip-distance → clipped, RT stays cleared.
  • Pixels 2, 3 get a positive clip-distance → pixel shader runs, writes red.

CullDistance.test

Two separate triangles drawn in a single call onto a 4×1 RT, each with
a uniform cullDist at all three of its vertices:

  • Triangle A covers pixels 0 and 1, cullDist = +1 everywhere → kept,
    pixel shader writes red.
  • Triangle B covers pixels 2 and 3, cullDist = -1 everywhere → entire
    primitive dropped before rasterization
    , pixels stay cleared.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants