Skip to content

Commit

Permalink
Add test to closesthit shader
Browse files Browse the repository at this point in the history
Add test to closesthit.slang to test the slang
stdlib API: HitTriangleVertexPosition.

The new test will add the checking for extension declaration,
built-in declaration, and built-in variable access.
  • Loading branch information
kaizhangNV committed Jan 17, 2024
1 parent 159e318 commit 715d102
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tests/vkray/closesthit.slang
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// closesthit.slang
//TEST:SIMPLE(filecheck=CHECK): -profile glsl_460+GL_NV_ray_tracing -stage closesthit -entry main -target spirv-assembly
//TEST:SIMPLE(filecheck=CHECK): -profile glsl_460+GL_EXT_ray_tracing -stage closesthit -entry main -target spirv-assembly
//TEST:SIMPLE(filecheck=CHECK): -stage closesthit -entry main -target spirv-assembly -emit-spirv-directly

struct ReflectionRay
Expand Down Expand Up @@ -30,19 +30,33 @@ void main(
color *= RayTCurrent() - RayTMin();

ioPayload.color = color;

uint index = 0U;
HitTriangleVertexPosition(index);

index = 1U;
HitTriangleVertexPosition(index);

index = 2U;
HitTriangleVertexPosition(index);
}

// CHECK: OpCapability RayTracing
// CHECK: OpCapability RayTracingPositionFetchKHR
// CHECK: OpEntryPoint ClosestHitNV %main "main"
// CHECK-DAG: OpDecorate %[[INSTANCE_ID:[A-Za-z0-9_]+]] BuiltIn InstanceId
// CHECK-DAG: OpDecorate %[[INSTANCE_INDEX:[A-Za-z0-9_]+]] BuiltIn InstanceCustomIndexNV
// CHECK-DAG: OpDecorate %{{.*}} BuiltIn PrimitiveId
// CHECK-DAG: OpDecorate %{{.*}} BuiltIn HitKindNV
// CHECK-DAG: OpDecorate %{{.*}} BuiltIn RayTmaxNV
// CHECK-DAG: OpDecorate %{{.*}} BuiltIn RayTminNV
// CHECK-DAG: OpDecorate %{{.*}} BuiltIn HitTriangleVertexPositionsKHR
// CHECK-DAG: %ShaderRecord{{.*}} = OpVariable %_ptr_ShaderRecordBufferNV{{.*}} ShaderRecordBufferNV
// CHECK-DAG: %{{.*}} = OpVariable %_ptr_IncomingRayPayloadNV_ReflectionRay{{.*}} IncomingRayPayloadNV
// CHECK-DAG: %{{.*}} = OpLoad %{{u?}}int %[[INSTANCE_ID]]
// CHECK-DAG: %{{.*}} = OpLoad %{{u?}}int %[[INSTANCE_INDEX]]
// CHECK-DAG: %{{.*}} = OpAccessChain %_ptr_ShaderRecordBufferNV_uint %ShaderRecord{{.*}} %int_0
// CHECK-DAG: %{{.*}} = OpAccessChain %_ptr_IncomingRayPayloadNV_v4float %{{.*}} %int_0
// CHECK-DAG: %{{.*}} = OpAccessChain %_ptr_Input_v3float %{{.*}} %{{u?}}int_0
// CHECK-DAG: %{{.*}} = OpAccessChain %_ptr_Input_v3float %{{.*}} %{{u?}}int_1
// CHECK-DAG: %{{.*}} = OpAccessChain %_ptr_Input_v3float %{{.*}} %{{u?}}int_2

0 comments on commit 715d102

Please sign in to comment.