Merge pull request #1369 from KhronosGroup/more-rt-tests
GLSL: Add more tests for RT.
This commit is contained in:
commit
29ad40e93e
@ -0,0 +1,24 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
struct Foo
|
||||
{
|
||||
float a;
|
||||
float b;
|
||||
};
|
||||
|
||||
struct Foo2
|
||||
{
|
||||
float a;
|
||||
float b;
|
||||
};
|
||||
|
||||
layout(location = 0) rayPayloadInNV Foo payload;
|
||||
hitAttributeNV Foo2 hit;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload.a = hit.a;
|
||||
payload.b = hit.b;
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
struct Foo
|
||||
{
|
||||
float a;
|
||||
float b;
|
||||
};
|
||||
|
||||
struct Foo2
|
||||
{
|
||||
float a;
|
||||
float b;
|
||||
};
|
||||
|
||||
layout(location = 0) rayPayloadInNV Foo payload;
|
||||
hitAttributeNV Foo2 hit;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload.a = hit.a;
|
||||
payload.b = hit.b;
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV vec2 payload;
|
||||
hitAttributeNV vec2 hit;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = hit;
|
||||
}
|
||||
|
@ -0,0 +1,17 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
struct Foo
|
||||
{
|
||||
float a;
|
||||
float b;
|
||||
};
|
||||
|
||||
layout(location = 0) rayPayloadInNV Foo payload;
|
||||
hitAttributeNV Foo hit;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = hit;
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV uint payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = gl_HitKindNV;
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV float payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = gl_HitTNV;
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV uint payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = gl_IncomingRayFlagsNV;
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV uint payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = uint(gl_InstanceCustomIndexNV);
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV uint payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = uint(gl_InstanceID);
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV vec3 payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = gl_ObjectRayDirectionNV;
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV vec3 payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = gl_ObjectRayOriginNV;
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV vec3 payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = gl_ObjectToWorldNV * vec4(payload, 1.0);
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
struct Payload
|
||||
{
|
||||
vec4 a;
|
||||
};
|
||||
|
||||
layout(location = 0) rayPayloadInNV Payload payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload.a = vec4(10.0);
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV uint payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = uint(gl_PrimitiveID);
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV float payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = gl_RayTmaxNV;
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV float payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = gl_RayTminNV;
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV vec3 payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = gl_WorldRayDirectionNV;
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV vec3 payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = gl_WorldRayOriginNV;
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV vec3 payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = gl_WorldToObjectNV * vec4(payload, 1.0);
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(set = 0, binding = 0) uniform writeonly image2D uImage;
|
||||
|
||||
void main()
|
||||
{
|
||||
imageStore(uImage, ivec2(gl_LaunchIDNV.xy), vec4(1.0));
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(set = 0, binding = 0) uniform writeonly image2D uImage;
|
||||
|
||||
void main()
|
||||
{
|
||||
imageStore(uImage, ivec2(gl_LaunchSizeNV.xy) - ivec2(1), vec4(1.0));
|
||||
}
|
||||
|
@ -0,0 +1,31 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
struct Payload
|
||||
{
|
||||
float a;
|
||||
float b;
|
||||
};
|
||||
|
||||
struct Block
|
||||
{
|
||||
float a;
|
||||
float b;
|
||||
Payload c;
|
||||
Payload d;
|
||||
};
|
||||
|
||||
layout(set = 0, binding = 1) uniform accelerationStructureNV as;
|
||||
layout(location = 1) rayPayloadNV Payload payload2;
|
||||
layout(location = 0) rayPayloadNV float payload1;
|
||||
layout(location = 2) rayPayloadNV Block _71;
|
||||
layout(set = 0, binding = 0, rgba8) uniform writeonly image2D image;
|
||||
|
||||
void main()
|
||||
{
|
||||
traceNV(as, 0u, 255u, 0u, 1u, 0u, vec3(1.0, 0.0, 0.0), 0.0, vec3(0.0, 1.0, 0.0), 1000.0, 0);
|
||||
traceNV(as, 0u, 255u, 0u, 1u, 0u, vec3(1.0, 0.0, 0.0), 0.0, vec3(0.0, 1.0, 0.0), 1000.0, 1);
|
||||
traceNV(as, 0u, 255u, 0u, 1u, 0u, vec3(1.0, 0.0, 0.0), 0.0, vec3(0.0, 1.0, 0.0), 1000.0, 2);
|
||||
imageStore(image, ivec2(gl_LaunchIDNV.xy), (vec4(payload1) + (vec4(payload2.a) + vec4(payload2.b))) + vec4(((((_71.a + _71.b) + _71.c.a) + _71.c.b) + _71.d.a) + _71.d.b));
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
struct Foo
|
||||
{
|
||||
float a;
|
||||
float b;
|
||||
};
|
||||
|
||||
struct Foo2
|
||||
{
|
||||
float a;
|
||||
float b;
|
||||
};
|
||||
|
||||
layout(location = 0) rayPayloadInNV Foo payload;
|
||||
hitAttributeNV Foo2 hit;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload.a = hit.a;
|
||||
payload.b = hit.b;
|
||||
}
|
||||
|
@ -0,0 +1,29 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
struct Foo
|
||||
{
|
||||
float a;
|
||||
float b;
|
||||
};
|
||||
|
||||
struct Foo2
|
||||
{
|
||||
float a;
|
||||
float b;
|
||||
};
|
||||
|
||||
layout(location = 0) rayPayloadInNV Foo payload;
|
||||
hitAttributeNV Foo2 hit;
|
||||
|
||||
void in_function()
|
||||
{
|
||||
payload.a = hit.a;
|
||||
payload.b = hit.b;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
in_function();
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV vec2 payload;
|
||||
hitAttributeNV vec2 hit;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = hit;
|
||||
}
|
||||
|
@ -0,0 +1,17 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
struct Foo
|
||||
{
|
||||
float a;
|
||||
float b;
|
||||
};
|
||||
|
||||
layout(location = 0) rayPayloadInNV Foo payload;
|
||||
hitAttributeNV Foo hit;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = hit;
|
||||
}
|
||||
|
10
reference/shaders/vulkan/rchit/hit_kind.nocompat.vk.rchit.vk
Normal file
10
reference/shaders/vulkan/rchit/hit_kind.nocompat.vk.rchit.vk
Normal file
@ -0,0 +1,10 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV uint payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = gl_HitKindNV;
|
||||
}
|
||||
|
10
reference/shaders/vulkan/rchit/hit_t.nocompat.vk.rchit.vk
Normal file
10
reference/shaders/vulkan/rchit/hit_t.nocompat.vk.rchit.vk
Normal file
@ -0,0 +1,10 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV float payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = gl_HitTNV;
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV uint payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = gl_IncomingRayFlagsNV;
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV uint payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = uint(gl_InstanceCustomIndexNV);
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV uint payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = uint(gl_InstanceID);
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV vec3 payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = gl_ObjectRayDirectionNV;
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV vec3 payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = gl_ObjectRayOriginNV;
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV vec3 payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = gl_ObjectToWorldNV * vec4(payload, 1.0);
|
||||
}
|
||||
|
20
reference/shaders/vulkan/rchit/payloads.nocompat.vk.rchit.vk
Normal file
20
reference/shaders/vulkan/rchit/payloads.nocompat.vk.rchit.vk
Normal file
@ -0,0 +1,20 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
struct Payload
|
||||
{
|
||||
vec4 a;
|
||||
};
|
||||
|
||||
layout(location = 0) rayPayloadInNV Payload payload;
|
||||
|
||||
void write_incoming_payload_in_function()
|
||||
{
|
||||
payload.a = vec4(10.0);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
write_incoming_payload_in_function();
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV uint payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = uint(gl_PrimitiveID);
|
||||
}
|
||||
|
10
reference/shaders/vulkan/rchit/ray_tmax.nocompat.vk.rchit.vk
Normal file
10
reference/shaders/vulkan/rchit/ray_tmax.nocompat.vk.rchit.vk
Normal file
@ -0,0 +1,10 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV float payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = gl_RayTmaxNV;
|
||||
}
|
||||
|
10
reference/shaders/vulkan/rchit/ray_tmin.nocompat.vk.rchit.vk
Normal file
10
reference/shaders/vulkan/rchit/ray_tmin.nocompat.vk.rchit.vk
Normal file
@ -0,0 +1,10 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV float payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = gl_RayTminNV;
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV vec3 payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = gl_WorldRayDirectionNV;
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV vec3 payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = gl_WorldRayOriginNV;
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV vec3 payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = gl_WorldToObjectNV * vec4(payload, 1.0);
|
||||
}
|
||||
|
10
reference/shaders/vulkan/rgen/launch_id.nocompat.vk.rgen.vk
Normal file
10
reference/shaders/vulkan/rgen/launch_id.nocompat.vk.rgen.vk
Normal file
@ -0,0 +1,10 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(set = 0, binding = 0) uniform writeonly image2D uImage;
|
||||
|
||||
void main()
|
||||
{
|
||||
imageStore(uImage, ivec2(gl_LaunchIDNV.xy), vec4(1.0));
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(set = 0, binding = 0) uniform writeonly image2D uImage;
|
||||
|
||||
void main()
|
||||
{
|
||||
imageStore(uImage, ivec2(gl_LaunchSizeNV.xy) - ivec2(1), vec4(1.0));
|
||||
}
|
||||
|
47
reference/shaders/vulkan/rgen/payloads.nocompat.vk.rgen.vk
Normal file
47
reference/shaders/vulkan/rgen/payloads.nocompat.vk.rgen.vk
Normal file
@ -0,0 +1,47 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
struct Payload
|
||||
{
|
||||
float a;
|
||||
float b;
|
||||
};
|
||||
|
||||
struct Block
|
||||
{
|
||||
float a;
|
||||
float b;
|
||||
Payload c;
|
||||
Payload d;
|
||||
};
|
||||
|
||||
layout(set = 0, binding = 1) uniform accelerationStructureNV as;
|
||||
layout(location = 1) rayPayloadNV Payload payload2;
|
||||
layout(location = 0) rayPayloadNV float payload1;
|
||||
layout(location = 2) rayPayloadNV Block _71;
|
||||
layout(set = 0, binding = 0, rgba8) uniform writeonly image2D image;
|
||||
|
||||
vec4 trace_in_function()
|
||||
{
|
||||
vec4 result = vec4(0.0);
|
||||
vec3 origin = vec3(1.0, 0.0, 0.0);
|
||||
vec3 direction = vec3(0.0, 1.0, 0.0);
|
||||
traceNV(as, 0u, 255u, 0u, 1u, 0u, origin, 0.0, direction, 1000.0, 1);
|
||||
result += vec4(payload2.a);
|
||||
result += vec4(payload2.b);
|
||||
return result;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 origin = vec3(1.0, 0.0, 0.0);
|
||||
vec3 direction = vec3(0.0, 1.0, 0.0);
|
||||
traceNV(as, 0u, 255u, 0u, 1u, 0u, origin, 0.0, direction, 1000.0, 0);
|
||||
vec4 result = vec4(payload1);
|
||||
vec4 _62 = trace_in_function();
|
||||
result += _62;
|
||||
traceNV(as, 0u, 255u, 0u, 1u, 0u, origin, 0.0, direction, 1000.0, 2);
|
||||
result += vec4(((((_71.a + _71.b) + _71.c.a) + _71.c.b) + _71.d.a) + _71.d.b);
|
||||
imageStore(image, ivec2(gl_LaunchIDNV.xy), result);
|
||||
}
|
||||
|
11
shaders/vulkan/rchit/hit_attribute_block.nocompat.vk.rchit
Normal file
11
shaders/vulkan/rchit/hit_attribute_block.nocompat.vk.rchit
Normal file
@ -0,0 +1,11 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV Foo { float a; float b; } payload;
|
||||
hitAttributeNV Foo2 { float a; float b; } hit;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload.a = hit.a;
|
||||
payload.b = hit.b;
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV Foo { float a; float b; } payload;
|
||||
hitAttributeNV Foo2 { float a; float b; } hit;
|
||||
|
||||
void in_function()
|
||||
{
|
||||
payload.a = hit.a;
|
||||
payload.b = hit.b;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
in_function();
|
||||
}
|
10
shaders/vulkan/rchit/hit_attribute_plain.nocompat.vk.rchit
Normal file
10
shaders/vulkan/rchit/hit_attribute_plain.nocompat.vk.rchit
Normal file
@ -0,0 +1,10 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV vec2 payload;
|
||||
hitAttributeNV vec2 hit;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = hit;
|
||||
}
|
12
shaders/vulkan/rchit/hit_attribute_struct.nocompat.vk.rchit
Normal file
12
shaders/vulkan/rchit/hit_attribute_struct.nocompat.vk.rchit
Normal file
@ -0,0 +1,12 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
struct Foo { float a; float b; };
|
||||
|
||||
layout(location = 0) rayPayloadInNV Foo payload;
|
||||
hitAttributeNV Foo hit;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = hit;
|
||||
}
|
9
shaders/vulkan/rchit/hit_kind.nocompat.vk.rchit
Normal file
9
shaders/vulkan/rchit/hit_kind.nocompat.vk.rchit
Normal file
@ -0,0 +1,9 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV uint payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = gl_HitKindNV;
|
||||
}
|
9
shaders/vulkan/rchit/hit_t.nocompat.vk.rchit
Normal file
9
shaders/vulkan/rchit/hit_t.nocompat.vk.rchit
Normal file
@ -0,0 +1,9 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV float payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = gl_HitTNV;
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV uint payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = gl_IncomingRayFlagsNV;
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV uint payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = gl_InstanceCustomIndexNV;
|
||||
}
|
9
shaders/vulkan/rchit/instance_id.nocompat.vk.rchit
Normal file
9
shaders/vulkan/rchit/instance_id.nocompat.vk.rchit
Normal file
@ -0,0 +1,9 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV uint payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = gl_InstanceID;
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV vec3 payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = gl_ObjectRayDirectionNV;
|
||||
}
|
9
shaders/vulkan/rchit/object_ray_origin.nocompat.vk.rchit
Normal file
9
shaders/vulkan/rchit/object_ray_origin.nocompat.vk.rchit
Normal file
@ -0,0 +1,9 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV vec3 payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = gl_ObjectRayOriginNV;
|
||||
}
|
9
shaders/vulkan/rchit/object_to_world.nocompat.vk.rchit
Normal file
9
shaders/vulkan/rchit/object_to_world.nocompat.vk.rchit
Normal file
@ -0,0 +1,9 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV vec3 payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = gl_ObjectToWorldNV * vec4(payload, 1.0);
|
||||
}
|
19
shaders/vulkan/rchit/payloads.nocompat.vk.rchit
Normal file
19
shaders/vulkan/rchit/payloads.nocompat.vk.rchit
Normal file
@ -0,0 +1,19 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
struct Payload
|
||||
{
|
||||
vec4 a;
|
||||
};
|
||||
|
||||
layout(location = 0) rayPayloadInNV Payload payload;
|
||||
|
||||
void write_incoming_payload_in_function()
|
||||
{
|
||||
payload.a = vec4(10.0);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
write_incoming_payload_in_function();
|
||||
}
|
9
shaders/vulkan/rchit/primitive_id.nocompat.vk.rchit
Normal file
9
shaders/vulkan/rchit/primitive_id.nocompat.vk.rchit
Normal file
@ -0,0 +1,9 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV uint payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = gl_PrimitiveID;
|
||||
}
|
9
shaders/vulkan/rchit/ray_tmax.nocompat.vk.rchit
Normal file
9
shaders/vulkan/rchit/ray_tmax.nocompat.vk.rchit
Normal file
@ -0,0 +1,9 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV float payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = gl_RayTmaxNV;
|
||||
}
|
9
shaders/vulkan/rchit/ray_tmin.nocompat.vk.rchit
Normal file
9
shaders/vulkan/rchit/ray_tmin.nocompat.vk.rchit
Normal file
@ -0,0 +1,9 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV float payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = gl_RayTminNV;
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV vec3 payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = gl_WorldRayDirectionNV;
|
||||
}
|
9
shaders/vulkan/rchit/world_ray_origin.nocompat.vk.rchit
Normal file
9
shaders/vulkan/rchit/world_ray_origin.nocompat.vk.rchit
Normal file
@ -0,0 +1,9 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV vec3 payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = gl_WorldRayOriginNV;
|
||||
}
|
9
shaders/vulkan/rchit/world_to_object.nocompat.vk.rchit
Normal file
9
shaders/vulkan/rchit/world_to_object.nocompat.vk.rchit
Normal file
@ -0,0 +1,9 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV vec3 payload;
|
||||
|
||||
void main()
|
||||
{
|
||||
payload = gl_WorldToObjectNV * vec4(payload, 1.0);
|
||||
}
|
9
shaders/vulkan/rgen/launch_id.nocompat.vk.rgen
Normal file
9
shaders/vulkan/rgen/launch_id.nocompat.vk.rgen
Normal file
@ -0,0 +1,9 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(set = 0, binding = 0) uniform writeonly image2D uImage;
|
||||
|
||||
void main()
|
||||
{
|
||||
imageStore(uImage, ivec2(gl_LaunchIDNV.xy), vec4(1.0));
|
||||
}
|
9
shaders/vulkan/rgen/launch_size.nocompat.vk.rgen
Normal file
9
shaders/vulkan/rgen/launch_size.nocompat.vk.rgen
Normal file
@ -0,0 +1,9 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(set = 0, binding = 0) uniform writeonly image2D uImage;
|
||||
|
||||
void main()
|
||||
{
|
||||
imageStore(uImage, ivec2(gl_LaunchSizeNV.xy) - 1, vec4(1.0));
|
||||
}
|
49
shaders/vulkan/rgen/payloads.nocompat.vk.rgen
Normal file
49
shaders/vulkan/rgen/payloads.nocompat.vk.rgen
Normal file
@ -0,0 +1,49 @@
|
||||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(set = 0, binding = 0, rgba8) uniform image2D image;
|
||||
layout(set = 0, binding = 1) uniform accelerationStructureNV as;
|
||||
|
||||
struct Payload
|
||||
{
|
||||
float a, b;
|
||||
};
|
||||
|
||||
// Plain payload
|
||||
layout(location = 0) rayPayloadNV float payload1;
|
||||
// Struct payload
|
||||
layout(location = 1) rayPayloadNV Payload payload2;
|
||||
|
||||
// This is syntactic sugar with the struct formulation (pretty sure), spec is kinda vague.
|
||||
layout(location = 2) rayPayloadNV Block
|
||||
{
|
||||
float a, b;
|
||||
Payload c, d;
|
||||
};
|
||||
|
||||
vec4 trace_in_function()
|
||||
{
|
||||
vec4 result = vec4(0.0);
|
||||
// Test that we can write to a payload in a function.
|
||||
vec3 origin = vec3(1.0, 0.0, 0.0);
|
||||
vec3 direction = vec3(0.0, 1.0, 0.0);
|
||||
traceNV(as, 0u, 255u, 0u, 1u, 0u, origin, 0.0, direction, 1000.0, 1);
|
||||
result += payload2.a;
|
||||
result += payload2.b;
|
||||
return result;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 origin = vec3(1.0, 0.0, 0.0);
|
||||
vec3 direction = vec3(0.0, 1.0, 0.0);
|
||||
traceNV(as, 0u, 255u, 0u, 1u, 0u, origin, 0.0, direction, 1000.0, 0);
|
||||
vec4 result = vec4(payload1);
|
||||
|
||||
result += trace_in_function();
|
||||
|
||||
traceNV(as, 0u, 255u, 0u, 1u, 0u, origin, 0.0, direction, 1000.0, 2);
|
||||
result += a + b + c.a + c.b + d.a + d.b;
|
||||
|
||||
imageStore(image, ivec2(gl_LaunchIDNV.xy), result);
|
||||
}
|
@ -2943,16 +2943,28 @@ void CompilerGLSL::emit_resources()
|
||||
}
|
||||
else if (id.get_type() == TypeType)
|
||||
{
|
||||
auto &type = id.get<SPIRType>();
|
||||
if (type.basetype == SPIRType::Struct && type.array.empty() && !type.pointer &&
|
||||
(!ir.meta[type.self].decoration.decoration_flags.get(DecorationBlock) &&
|
||||
!ir.meta[type.self].decoration.decoration_flags.get(DecorationBufferBlock)))
|
||||
auto *type = &id.get<SPIRType>();
|
||||
|
||||
bool is_natural_struct =
|
||||
type->basetype == SPIRType::Struct && type->array.empty() && !type->pointer &&
|
||||
(!has_decoration(type->self, DecorationBlock) && !has_decoration(type->self, DecorationBufferBlock));
|
||||
|
||||
// Special case, ray payload and hit attribute blocks are not really blocks, just regular structs.
|
||||
if (type->basetype == SPIRType::Struct && type->pointer && has_decoration(type->self, DecorationBlock) &&
|
||||
(type->storage == StorageClassRayPayloadNV || type->storage == StorageClassIncomingRayPayloadNV ||
|
||||
type->storage == StorageClassHitAttributeNV))
|
||||
{
|
||||
type = &get<SPIRType>(type->parent_type);
|
||||
is_natural_struct = true;
|
||||
}
|
||||
|
||||
if (is_natural_struct)
|
||||
{
|
||||
if (emitted)
|
||||
statement("");
|
||||
emitted = false;
|
||||
|
||||
emit_struct(type);
|
||||
emit_struct(*type);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -10792,21 +10804,26 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
|
||||
|
||||
case OpReportIntersectionNV:
|
||||
statement("reportIntersectionNV(", to_expression(ops[0]), ", ", to_expression(ops[1]), ");");
|
||||
flush_control_dependent_expressions(current_emitting_block->self);
|
||||
break;
|
||||
case OpIgnoreIntersectionNV:
|
||||
statement("ignoreIntersectionNV();");
|
||||
flush_control_dependent_expressions(current_emitting_block->self);
|
||||
break;
|
||||
case OpTerminateRayNV:
|
||||
statement("terminateRayNV();");
|
||||
flush_control_dependent_expressions(current_emitting_block->self);
|
||||
break;
|
||||
case OpTraceNV:
|
||||
statement("traceNV(", to_expression(ops[0]), ", ", to_expression(ops[1]), ", ", to_expression(ops[2]), ", ",
|
||||
to_expression(ops[3]), ", ", to_expression(ops[4]), ", ", to_expression(ops[5]), ", ",
|
||||
to_expression(ops[6]), ", ", to_expression(ops[7]), ", ", to_expression(ops[8]), ", ",
|
||||
to_expression(ops[9]), ", ", to_expression(ops[10]), ");");
|
||||
flush_control_dependent_expressions(current_emitting_block->self);
|
||||
break;
|
||||
case OpExecuteCallableNV:
|
||||
statement("executeCallableNV(", to_expression(ops[0]), ", ", to_expression(ops[1]), ");");
|
||||
flush_control_dependent_expressions(current_emitting_block->self);
|
||||
break;
|
||||
|
||||
case OpConvertUToPtr:
|
||||
@ -13407,6 +13424,7 @@ void CompilerGLSL::bitcast_from_builtin_load(uint32_t source_id, std::string &ex
|
||||
case BuiltInBaseInstance:
|
||||
case BuiltInDrawIndex:
|
||||
case BuiltInFragStencilRefEXT:
|
||||
case BuiltInInstanceCustomIndexNV:
|
||||
expected_type = SPIRType::Int;
|
||||
break;
|
||||
|
||||
@ -13416,6 +13434,9 @@ void CompilerGLSL::bitcast_from_builtin_load(uint32_t source_id, std::string &ex
|
||||
case BuiltInLocalInvocationIndex:
|
||||
case BuiltInWorkgroupSize:
|
||||
case BuiltInNumWorkgroups:
|
||||
case BuiltInIncomingRayFlagsNV:
|
||||
case BuiltInLaunchIdNV:
|
||||
case BuiltInLaunchSizeNV:
|
||||
expected_type = SPIRType::UInt;
|
||||
break;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user