Skip to content

Commit 6e42757

Browse files
committed
Fix SERWaveIncoherentHitTest: Use ray_flags to be independent of aabb/tri hit order
1 parent 15140b1 commit 6e42757

1 file changed

Lines changed: 15 additions & 13 deletions

File tree

tools/clang/unittests/HLSLExec/ExecutionTest_SER.h

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2303,17 +2303,20 @@ void raygen()
23032303
23042304
dx::HitObject hitObject;
23052305
2306+
int cat = (launchIndex.x + launchIndex.y) % 4;
2307+
23062308
// Use wave incoherence to decide how to create the HitObject
2307-
if (launchIndex.x % 4 == 1)
2309+
if (cat == 1)
23082310
{
2309-
ray.Origin.x += 2.0f;
2310-
hitObject = dx::HitObject::TraceRay(topObject, RAY_FLAG_SKIP_CLOSEST_HIT_SHADER, 0xFF, 0, 0, 0, ray, payload);
2311+
// Turn this into an expected miss by moving eye behind triangles
2312+
ray.Origin.z -= 1000.0f;
2313+
hitObject = dx::HitObject::TraceRay(topObject, RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES, 0xFF, 0, 0, 0, ray, payload);
23112314
}
2312-
else if (launchIndex.x % 4 == 2)
2315+
else if (cat == 2)
23132316
{
23142317
hitObject = dx::HitObject::TraceRay(topObject, RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES, 0xFF, 0, 0, 0, ray, payload);
23152318
}
2316-
else if (launchIndex.x % 4 == 3)
2319+
else if (cat == 3)
23172320
{
23182321
hitObject = dx::HitObject::TraceRay(topObject, RAY_FLAG_SKIP_TRIANGLES, 0xFF, 0, 0, 0, ray, payload);
23192322
}
@@ -2376,7 +2379,7 @@ void intersection()
23762379
// hitPos is intersection point with plane (base, n)
23772380
float3 base = {0.0f,0.0f,0.5f};
23782381
float3 n = normalize(float3(0.0f,0.5f,0.5f));
2379-
float radius = 1000.f;
2382+
float radius = 500.f;
23802383
// Plane hit
23812384
float t = dot(n, base - ObjectRayOrigin()) / dot(n, ObjectRayDirection());
23822385
if (t > RayTCurrent() || t < RayTMin()) {
@@ -2412,13 +2415,12 @@ void intersection()
24122415
std::map<int, int> Histo;
24132416
for (int Val : TestData)
24142417
++Histo[Val];
2415-
VERIFY_ARE_EQUAL(Histo.size(), 6);
2416-
VERIFY_ARE_EQUAL(Histo[1], 1024); // nop
2417-
VERIFY_ARE_EQUAL(Histo[2], 1022); // miss
2418-
VERIFY_ARE_EQUAL(Histo[4], 12); // triangle hit, no ch
2419-
VERIFY_ARE_EQUAL(Histo[8], 1008); // procedural hit, no ch
2420-
VERIFY_ARE_EQUAL(Histo[20], 11); // triangle hit, 'closesthit' invoked
2421-
VERIFY_ARE_EQUAL(Histo[40], 1019); // procedural hit, 'chAABB' invoked
2418+
2419+
VERIFY_ARE_EQUAL(Histo.size(), 4);
2420+
VERIFY_ARE_EQUAL(Histo[1], 1024); // nop
2421+
VERIFY_ARE_EQUAL(Histo[2], 2243); // miss
2422+
VERIFY_ARE_EQUAL(Histo[20], 16); // triangle hit
2423+
VERIFY_ARE_EQUAL(Histo[40], 813); // procedural hit
24222424
}
24232425

24242426
TEST_F(ExecutionTest, SERReorderCoherentTest) {

0 commit comments

Comments
 (0)