rayquery-decls.hlsl 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // RUN: %dxc -T vs_6_5 -E main %s | FileCheck %s
  2. RaytracingAccelerationStructure RTAS;
  3. // We should eliminate these calls somehow in the future, but for now, that does not look like a legal optimization.
  4. // CHECK: call i32 @dx.op.allocateRayQuery(i32 178, i32 0)
  5. // CHECK: call i32 @dx.op.allocateRayQuery(i32 178, i32 0)
  6. // CHECK: call i32 @dx.op.allocateRayQuery(i32 178, i32 0)
  7. // CHECK: call i32 @dx.op.allocateRayQuery(i32 178, i32 0)
  8. static RayQuery<0> g_rayQueryArray[4];
  9. // g_rayQueryUnused should be optimized away
  10. static RayQuery<0> g_rayQueryUnused;
  11. void main(uint i : IDX, RayDesc rayDesc : RAYDESC) {
  12. // CHECK: %[[rayQuery0a:[^ ]+]] = call i32 @dx.op.allocateRayQuery(i32 178, i32 0)
  13. RayQuery<0> rayQuery0a;
  14. // rayQuery0b should be completely optimized away
  15. // CHECK-NOT: call i32 @dx.op.allocateRayQuery(i32 178, i32 0)
  16. RayQuery<0> rayQuery0b;
  17. g_rayQueryArray[i] = rayQuery0b; // Stored here, then overwritten with rayQuery0a
  18. g_rayQueryArray[i] = rayQuery0a;
  19. // No separate allocation, just a handle copy
  20. // optimizations should have eliminated load from global array
  21. // CHECK-NOT: load
  22. RayQuery<0> rayQuery0c = g_rayQueryArray[i];
  23. // rayQuery0a is the one actually used here
  24. // CHECK: call void @dx.op.rayQuery_TraceRayInline(i32 179, i32 %[[rayQuery0a]],
  25. rayQuery0c.TraceRayInline(RTAS, 1, 2, rayDesc);
  26. // AllocateRayQuery occurs here, rather than next to allocas
  27. // Should not be extray allocate, since above should allocate and copy
  28. // CHECK: %[[rayQuery1c:[^ ]+]] = call i32 @dx.op.allocateRayQuery(i32 178, i32 1)
  29. // CHECK-NOT: call i32 @dx.op.allocateRayQuery(i32 178, i32 0)
  30. RayQuery<RAY_FLAG_FORCE_OPAQUE> rayQuery1c = RayQuery<RAY_FLAG_FORCE_OPAQUE>();
  31. // CHECK: call void @dx.op.rayQuery_TraceRayInline(i32 179, i32 %[[rayQuery1c]],
  32. rayQuery1c.TraceRayInline(RTAS, 3, 4, rayDesc);
  33. }