Support gl_InstanceID in RT shaders.

This commit is contained in:
Hans-Kristian Arntzen 2020-05-08 13:39:43 +02:00
parent b7823ec389
commit 86380acf4d
4 changed files with 18 additions and 5 deletions

View File

@ -5,6 +5,6 @@ layout(location = 0) rayPayloadInNV float payload;
void main()
{
payload = 1.0;
payload = 1.0 + float(gl_InstanceID);
}

View File

@ -5,6 +5,6 @@ layout(location = 0) rayPayloadInNV float payload;
void main()
{
payload = 1.0;
payload = 1.0 + float(gl_InstanceID);
}

View File

@ -5,5 +5,5 @@ layout(location = 0) rayPayloadInNV float payload;
void main()
{
payload = 1.0;
payload = 1.0 + float(gl_InstanceID);
}

View File

@ -6792,8 +6792,21 @@ string CompilerGLSL::builtin_to_glsl(BuiltIn builtin, StorageClass storage)
return "gl_VertexID";
case BuiltInInstanceId:
if (options.vulkan_semantics)
SPIRV_CROSS_THROW(
"Cannot implement gl_InstanceID in Vulkan GLSL. This shader was created with GL semantics.");
{
auto model = get_entry_point().model;
switch (model)
{
case spv::ExecutionModelIntersectionKHR:
case spv::ExecutionModelAnyHitKHR:
case spv::ExecutionModelClosestHitKHR:
// gl_InstanceID is allowed in these shaders.
break;
default:
SPIRV_CROSS_THROW(
"Cannot implement gl_InstanceID in Vulkan GLSL. This shader was created with GL semantics.");
}
}
return "gl_InstanceID";
case BuiltInVertexIndex:
if (options.vulkan_semantics)