GLSL: Handle tracing against incoming payload/callable.

This commit is contained in:
Hans-Kristian Arntzen 2021-01-22 11:22:10 +01:00
parent 9acb9ec31f
commit 66fb0bd9df
9 changed files with 70 additions and 3 deletions

View File

@ -1,7 +1,7 @@
#version 460
#extension GL_EXT_ray_tracing : require
rayPayloadInEXT float payload;
layout(location = 0) rayPayloadInEXT float payload;
void main()
{

View File

@ -0,0 +1,10 @@
#version 460
#extension GL_EXT_ray_tracing : require
layout(location = 0) callableDataInEXT float c;
void main()
{
executeCallableEXT(10u, 0);
}

View File

@ -0,0 +1,11 @@
#version 460
#extension GL_EXT_ray_tracing : require
layout(set = 0, binding = 0) uniform accelerationStructureEXT as;
layout(location = 0) rayPayloadInEXT float p;
void main()
{
traceRayEXT(as, 0u, 255u, 0u, 1u, 0u, vec3(float(gl_LaunchIDEXT.x) / float(gl_LaunchSizeEXT.x), float(gl_LaunchIDEXT.y) / float(gl_LaunchSizeEXT.y), 1.0), 0.0, vec3(0.0, 0.0, -1.0), 1000.0, 0);
}

View File

@ -1,7 +1,7 @@
#version 460
#extension GL_EXT_ray_tracing : require
rayPayloadInEXT float payload;
layout(location = 0) rayPayloadInEXT float payload;
void in_func()
{

View File

@ -0,0 +1,10 @@
#version 460
#extension GL_EXT_ray_tracing : require
layout(location = 0) callableDataInEXT float c;
void main()
{
executeCallableEXT(10u, 0);
}

View File

@ -0,0 +1,13 @@
#version 460
#extension GL_EXT_ray_tracing : require
layout(set = 0, binding = 0) uniform accelerationStructureEXT as;
layout(location = 0) rayPayloadInEXT float p;
void main()
{
vec3 origin = vec3(float(gl_LaunchIDEXT.x) / float(gl_LaunchSizeEXT.x), float(gl_LaunchIDEXT.y) / float(gl_LaunchSizeEXT.y), 1.0);
vec3 direction = vec3(0.0, 0.0, -1.0);
traceRayEXT(as, 0u, 255u, 0u, 1u, 0u, origin, 0.0, direction, 1000.0, 0);
}

View File

@ -0,0 +1,9 @@
#version 460
#extension GL_EXT_ray_tracing : require
layout(location = 4) callableDataInEXT float c;
void main()
{
executeCallableEXT(10, 4);
}

View File

@ -0,0 +1,12 @@
#version 460
#extension GL_EXT_ray_tracing : require
layout(set = 0, binding = 0) uniform accelerationStructureEXT as;
layout(location = 3) rayPayloadInEXT float p;
void main()
{
vec3 origin = vec3(float(gl_LaunchIDEXT.x) / float(gl_LaunchSizeEXT.x), float(gl_LaunchIDEXT.y) / float(gl_LaunchSizeEXT.y), 1.0);
vec3 direction = vec3(0.0, 0.0, -1.0);
traceRayEXT(as, 0u, 255u, 0u, 1u, 0u, origin, 0.0, direction, 1000.0, 3);
}

View File

@ -538,7 +538,9 @@ void CompilerGLSL::ray_tracing_khr_fixup_locations()
{
uint32_t location = 0;
ir.for_each_typed_id<SPIRVariable>([&](uint32_t, SPIRVariable &var) {
if (var.storage != StorageClassRayPayloadKHR && var.storage != StorageClassCallableDataKHR)
// Incoming payload storage can also be used for tracing.
if (var.storage != StorageClassRayPayloadKHR && var.storage != StorageClassCallableDataKHR &&
var.storage != StorageClassIncomingRayPayloadKHR && var.storage != StorageClassIncomingCallableDataKHR)
return;
if (!interface_variable_exists_in_entry_point(var.self))
return;