From fda89737640baf44ea4e318e39633c2cb0aadb39 Mon Sep 17 00:00:00 2001 From: Robert Konrad Date: Sun, 25 Aug 2024 00:31:12 +0200 Subject: [PATCH] Fix global base type member access in HLSL --- Sources/backends/hlsl.c | 3 +++ tests/in/test.kong | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/Sources/backends/hlsl.c b/Sources/backends/hlsl.c index e2851c3..94564a7 100644 --- a/Sources/backends/hlsl.c +++ b/Sources/backends/hlsl.c @@ -513,6 +513,9 @@ static void write_functions(char *hlsl, size_t *offset, shader_stage stage, func global g = get_global(j); if (o->op_load_member.from.index == g.var_index) { global_var_index = g.var_index; + if (get_type(g.type)->built_in) { + global_var_index = 0; + } break; } } diff --git a/tests/in/test.kong b/tests/in/test.kong index 9f9d7db..03baccf 100644 --- a/tests/in/test.kong +++ b/tests/in/test.kong @@ -62,6 +62,20 @@ fun sendrays(): void { var target: float3 = float3((uv.x * 2 - 1) * 1.8 * (size.x / size.y), (1 - uv.y) * 4 - 2 + camera.y, 0); + + //RayDesc ray; + //ray.Origin = camera; + //ray.Direction = target - camera; + //ray.TMin = 0.001; + //ray.TMax = 1000; + + var payload: Payload; + payload.allow_reflection = true; + payload.missed = false; + + //TraceRay(scene, RAY_FLAG_NONE, 0xFF, 0, 0, 0, ray, payload); + + //uav[idx] = float4(payload.color, 1); } fun raymissed(payload: Payload): void {