From ecc6ecb3a25a28eb5e85cfdb2bf170448ab9a4e7 Mon Sep 17 00:00:00 2001 From: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> Date: Thu, 13 Jun 2024 14:54:58 -0400 Subject: Fix cuda/cpp/metal crash for when using GLSL style shader inputs (#4378) Decorations were not expected as an input, this causes a crash. --- source/slang/slang-ir-explicit-global-context.cpp | 6 +++++- tests/glsl/matrix-mul.slang | 13 ++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/source/slang/slang-ir-explicit-global-context.cpp b/source/slang/slang-ir-explicit-global-context.cpp index 9bbaf3875..9d3f09712 100644 --- a/source/slang/slang-ir-explicit-global-context.cpp +++ b/source/slang/slang-ir-explicit-global-context.cpp @@ -462,11 +462,15 @@ struct IntroduceExplicitGlobalContextPass for( IRUse* use = globalVar->firstUse; use; use = nextUse ) { nextUse = use->nextUse; + auto user = use->getUser(); + + // Ensure the use site checked actually requires a replacement + if (as(user)) + continue; // At each use site, we need to look up the context // pointer that is appropriate for that use. // - auto user = use->getUser(); auto contextParam = findOrCreateContextPtrForInst(user); builder.setInsertBefore(user); diff --git a/tests/glsl/matrix-mul.slang b/tests/glsl/matrix-mul.slang index c87c8ad18..156673b87 100644 --- a/tests/glsl/matrix-mul.slang +++ b/tests/glsl/matrix-mul.slang @@ -1,5 +1,6 @@ -//TEST:SIMPLE(filecheck=CHECK): -target spirv -stage vertex -entry main -allow-glsl -emit-spirv-directly -//TEST:SIMPLE(filecheck=CHECK): -target spirv -stage vertex -entry main -allow-glsl +//TEST:SIMPLE(filecheck=SPIRV): -target spirv -stage vertex -entry main -allow-glsl -emit-spirv-directly +//TEST:SIMPLE(filecheck=SPIRV): -target spirv -stage vertex -entry main -allow-glsl +//TEST:SIMPLE(filecheck=METAL): -target metal -stage vertex -entry main -allow-glsl #version 310 es layout(location = 0) in highp vec4 a_position; @@ -13,8 +14,10 @@ void main() { gl_Position = m1 * m2 * a_position; - // CHECK: OpEntryPoint - // CHECK: OpMatrixTimesMatrix - // CHECK: OpMatrixTimesVector + // SPIRV: OpEntryPoint + // SPIRV: OpMatrixTimesMatrix + // SPIRV: OpMatrixTimesVector + + // METAL: {{.*}}m1{{.*}}*{{.*}}m2{{.*}}*{{.*}}a_position{{.*}} } -- cgit v1.2.3