Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cuda/cpp/metal crash when using GLSL shader inputs #4378

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion source/slang/slang-ir-explicit-global-context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<IRDecoration>(user))
continue;
jkwak-work marked this conversation as resolved.
Show resolved Hide resolved

// 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);

Expand Down
13 changes: 8 additions & 5 deletions tests/glsl/matrix-mul.slang
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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{{.*}}
}

Loading