From 25bc5a3ada5a2404f25ecf2de7d035ba60cd9fdf Mon Sep 17 00:00:00 2001 From: venkataram-nv Date: Fri, 16 Aug 2024 23:08:00 -0700 Subject: Avoiding the use of the global AST builder in DeclRefType::create (#4866) --- tests/modules/environment.slang | 29 +++++++++++++++++++++++++++++ tests/modules/hit.slang | 24 ++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 tests/modules/environment.slang create mode 100644 tests/modules/hit.slang (limited to 'tests/modules') diff --git a/tests/modules/environment.slang b/tests/modules/environment.slang new file mode 100644 index 000000000..915e04c54 --- /dev/null +++ b/tests/modules/environment.slang @@ -0,0 +1,29 @@ +module environment; + +uint lcg(inout uint prev) +{ + const uint LCG_A = 1664525u; + const uint LCG_C = 1013904223u; + prev = (LCG_A * prev + LCG_C); + return prev & 0x00FFFFFF; +} + +public float rnd(inout uint prev) +{ + return ((float) lcg(prev) / (float) 0x01000000); +} + +public struct Environment_sample_data +{ + uint alias; + float q; +}; + +public float3 environment_sample(StructuredBuffer sample_buffer, inout int seed) +{ + float3 xi; + xi.x = rnd(seed); + xi.y = rnd(seed); + xi.z = rnd(seed); + return xi.z; +} diff --git a/tests/modules/hit.slang b/tests/modules/hit.slang new file mode 100644 index 000000000..d175275b4 --- /dev/null +++ b/tests/modules/hit.slang @@ -0,0 +1,24 @@ +//TEST:COMPILE: tests/modules/environment.slang -o tests/modules/environment.slang-module +//TEST:COMPILE: tests/modules/hit.slang -stage closesthit -entry closesthit -target dxil -o monolithic.dxil + +import environment; + +StructuredBuffer environment_sample_buffer; + +float3 sample_lights(inout uint seed) +{ + return environment_sample(environment_sample_buffer, seed); +} + +struct RadianceHitInfo +{ + float3 contribution; +}; + +struct Attributes +{ + float2 bary; +}; + +[shader("closesthit")] +void closesthit(inout RadianceHitInfo payload, Attributes attrib) {} -- cgit v1.2.3