Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Multi entrypoint tests for RayTracing #7989

Open
spencer-lunarg opened this issue May 10, 2024 · 0 comments
Open

Create Multi entrypoint tests for RayTracing #7989

spencer-lunarg opened this issue May 10, 2024 · 0 comments
Assignees
Labels
CI/Tests Anything related to CI or testing GPU-AV GPU Assisted Validation RT Ray Tracing

Comments

@spencer-lunarg
Copy link
Contributor

Same idea as PositiveGpuAVOOB/VertexFragmentMultiEntrypoint/NegativeGpuAVOOB.VertexFragmentMultiEntrypoint (from
https://github.com/KhronosGroup/Vulkan-ValidationLayers/pull/7778/files)

We should add a simple RTX test in PositiveGpuAVRayTracing/NegativeGpuAVRayTracing to test we handle this correctly

The biggest issue is the rt::Pipeline::SetRayGenShader test framework interface allows no way to do this currently

Here is a simple HLSL (and SPIR-V) example

// Compile with
// dxc -spirv -T lib_6_4 -fspv-target-env=vulkan1.2 -Fo out.spv in.hlsl 
struct ColorPayload {
    uint index;
};

[shader("miss")] 
void mainMiss(inout ColorPayload payload) {
    payload.index = 0;
}

[shader("closesthit")]
void mainClosestHit(inout ColorPayload payload, BuiltInTriangleIntersectionAttributes attr) {
    payload.index = 1;
}

RWStructuredBuffer<float> OutBuffer : register(u0); // StorageBuffer (set 0, binding 0)
Texture2D MyTextures[] : register(t1); // Texture array (set 0, binding 1)
RaytracingAccelerationStructure _tlas; // (set 0, binding 2)

[shader("raygeneration")]
void mainRaygen() {
    float2 uv = float2(0.5, 0.5);

    RayDesc ray;
    ray.Origin = ray.Origin;
    ray.TMin = 0;
    ray.Direction = float3(0.5, 0.5, 0.5);
    ray.TMax = 1e6;

    ColorPayload payload;
    TraceRay(_tlas, -1, RAY_FLAG_NONE, 0, 0, 0, ray, payload);
    
    // the index will either be 0 or 1, this can be adjusted, but the main thing is to use this to trigger (or not trigger) descriptor indexing OOB
    Texture2D tex = MyTextures[NonUniformResourceIndex(payload.index)];
    float4 val = tex[uv];
    OutBuffer[0] = val.x;
}

Spirv

OpCapability RayTracingKHR OpCapability RuntimeDescriptorArray OpCapability ShaderNonUniform OpCapability SampledImageArrayNonUniformIndexing OpExtension "SPV_KHR_ray_tracing" OpExtension "SPV_EXT_descriptor_indexing" OpMemoryModel Logical GLSL450 OpEntryPoint MissNV %mainMiss "mainMiss" %payload OpEntryPoint ClosestHitNV %mainClosestHit "mainClosestHit" %payload_0 OpEntryPoint RayGenerationNV %mainRaygen "mainRaygen" %OutBuffer %MyTextures %_tlas %payload_1 OpSource HLSL 640 OpName %type_RWStructuredBuffer_float "type.RWStructuredBuffer.float" OpName %OutBuffer "OutBuffer" OpName %type_2d_image "type.2d.image" OpName %MyTextures "MyTextures" OpName %accelerationStructureNV "accelerationStructureNV" OpName %_tlas "_tlas" OpName %ColorPayload "ColorPayload" OpMemberName %ColorPayload 0 "index" OpName %payload "payload" OpName %payload_0 "payload" OpName %payload_1 "payload" OpName %mainMiss "mainMiss" OpName %mainClosestHit "mainClosestHit" OpName %mainRaygen "mainRaygen" OpDecorate %payload_1 Location 0 OpDecorate %OutBuffer DescriptorSet 0 OpDecorate %OutBuffer Binding 0 OpDecorate %MyTextures DescriptorSet 0 OpDecorate %MyTextures Binding 1 OpDecorate %_tlas DescriptorSet 0 OpDecorate %_tlas Binding 2 OpDecorate %_runtimearr_float ArrayStride 4 OpMemberDecorate %type_RWStructuredBuffer_float 0 Offset 0 OpDecorate %type_RWStructuredBuffer_float Block OpDecorate %15 NonUniform OpDecorate %16 NonUniform OpDecorate %17 NonUniform %uint = OpTypeInt 32 0 %uint_0 = OpConstant %uint 0 %int = OpTypeInt 32 1 %int_0 = OpConstant %int 0 %uint_1 = OpConstant %uint 1 %float = OpTypeFloat 32 %float_0_5 = OpConstant %float 0.5 %float_0 = OpConstant %float 0 %v3float = OpTypeVector %float 3 %27 = OpConstantComposite %v3float %float_0_5 %float_0_5 %float_0_5 %float_1000000 = OpConstant %float 1000000 %uint_4294967295 = OpConstant %uint 4294967295 %_runtimearr_float = OpTypeRuntimeArray %float %type_RWStructuredBuffer_float = OpTypeStruct %_runtimearr_float %_ptr_StorageBuffer_type_RWStructuredBuffer_float = OpTypePointer StorageBuffer %type_RWStructuredBuffer_float %type_2d_image = OpTypeImage %float 2D 2 0 0 1 Unknown %_runtimearr_type_2d_image = OpTypeRuntimeArray %type_2d_image %_ptr_UniformConstant__runtimearr_type_2d_image = OpTypePointer UniformConstant %_runtimearr_type_2d_image %accelerationStructureNV = OpTypeAccelerationStructureKHR %_ptr_UniformConstant_accelerationStructureNV = OpTypePointer UniformConstant %accelerationStructureNV %ColorPayload = OpTypeStruct %uint %_ptr_IncomingRayPayloadNV_ColorPayload = OpTypePointer IncomingRayPayloadNV %ColorPayload %_ptr_RayPayloadNV_ColorPayload = OpTypePointer RayPayloadNV %ColorPayload %void = OpTypeVoid %37 = OpTypeFunction %void %v4float = OpTypeVector %float 4 %_ptr_UniformConstant_type_2d_image = OpTypePointer UniformConstant %type_2d_image %v2uint = OpTypeVector %uint 2 %_ptr_StorageBuffer_float = OpTypePointer StorageBuffer %float %OutBuffer = OpVariable %_ptr_StorageBuffer_type_RWStructuredBuffer_float StorageBuffer %MyTextures = OpVariable %_ptr_UniformConstant__runtimearr_type_2d_image UniformConstant %_tlas = OpVariable %_ptr_UniformConstant_accelerationStructureNV UniformConstant %payload = OpVariable %_ptr_IncomingRayPayloadNV_ColorPayload IncomingRayPayloadNV %payload_0 = OpVariable %_ptr_IncomingRayPayloadNV_ColorPayload IncomingRayPayloadNV %payload_1 = OpVariable %_ptr_RayPayloadNV_ColorPayload RayPayloadNV %42 = OpUndef %v3float %43 = OpUndef %uint %44 = OpConstantComposite %ColorPayload %uint_0 %45 = OpConstantComposite %ColorPayload %uint_1 %46 = OpConstantComposite %v2uint %uint_0 %uint_0 %mainMiss = OpFunction %void None %37 %47 = OpLabel OpStore %payload %44 OpReturn OpFunctionEnd %mainClosestHit = OpFunction %void None %37 %48 = OpLabel OpStore %payload_0 %45 OpReturn OpFunctionEnd %mainRaygen = OpFunction %void None %37 %49 = OpLabel %50 = OpCompositeConstruct %ColorPayload %43 OpStore %payload_1 %50 %51 = OpLoad %accelerationStructureNV %_tlas OpTraceRayKHR %51 %uint_4294967295 %uint_0 %uint_0 %uint_0 %uint_0 %42 %float_0 %27 %float_1000000 %payload_1 %52 = OpLoad %ColorPayload %payload_1 %53 = OpCompositeExtract %uint %52 0 %15 = OpCopyObject %uint %53 %16 = OpAccessChain %_ptr_UniformConstant_type_2d_image %MyTextures %15 %17 = OpLoad %type_2d_image %16 %54 = OpImageFetch %v4float %17 %46 Lod %uint_0 %55 = OpCompositeExtract %float %54 0 %56 = OpAccessChain %_ptr_StorageBuffer_float %OutBuffer %int_0 %uint_0 OpStore %56 %55 OpReturn OpFunctionEnd
@spencer-lunarg spencer-lunarg added GPU-AV GPU Assisted Validation RT Ray Tracing CI/Tests Anything related to CI or testing labels May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/Tests Anything related to CI or testing GPU-AV GPU Assisted Validation RT Ray Tracing
Projects
None yet
Development

No branches or pull requests

2 participants