Merge pull request #1027 from KhronosGroup/fix-1026

MSL: Fix regression with Private parameter declaration.
This commit is contained in:
Hans-Kristian Arntzen 2019-06-13 13:45:01 +02:00 committed by GitHub
commit 4104e36300
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 84 additions and 0 deletions

View File

@ -0,0 +1,17 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float3 FragColor [[color(0)]];
};
fragment main0_out main0()
{
main0_out out = {};
out.FragColor = float3(1.0);
return out;
}

View File

@ -0,0 +1,39 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct AStruct
{
float4 foobar;
};
struct main0_out
{
float3 FragColor [[color(0)]];
};
void someFunction(thread AStruct& s)
{
s.foobar = float4(1.0);
}
void otherFunction(thread float3& global_variable)
{
global_variable = float3(1.0);
}
fragment main0_out main0()
{
main0_out out = {};
AStruct param;
someFunction(param);
AStruct inputs = param;
float3 global_variable;
otherFunction(global_variable);
out.FragColor = global_variable;
return out;
}

View File

@ -0,0 +1,20 @@
#version 450
struct AStruct { vec4 foobar; };
void someFunction(out AStruct s) { s.foobar = vec4(1.0); }
highp vec3 global_variable;
void otherFunction() {
global_variable = vec3(1.0);
}
layout(location = 0) out vec3 FragColor;
void main() {
AStruct inputs;
someFunction(inputs);
otherFunction();
FragColor = global_variable;
}

View File

@ -10660,6 +10660,14 @@ void CompilerGLSL::emit_function(SPIRFunction &func, const Bitset &return_flags)
end_scope();
processing_entry_point = false;
statement("");
// Make sure deferred declaration state for local variables is cleared when we are done with function.
// We risk declaring Private/Workgroup variables in places we are not supposed to otherwise.
for (auto &v : func.local_variables)
{
auto &var = get<SPIRVariable>(v);
var.deferred_declaration = false;
}
}
void CompilerGLSL::emit_fixup()