Merge pull request #520 from KhronosGroup/fix-517

Add more illegal name replacement in MSL.
This commit is contained in:
Hans-Kristian Arntzen 2018-04-03 16:04:45 +02:00 committed by GitHub
commit a1e30c8c2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 64 additions and 7 deletions

View File

@ -16,7 +16,7 @@ constant Foo _28[2] = {{10.0, 20.0}, {30.0, 40.0}};
struct main0_in
{
int line [[user(locn0)]];
int _line [[user(locn0)]];
};
struct main0_out
@ -43,8 +43,8 @@ fragment main0_out main0(main0_in in [[stage_in]])
main0_out out = {};
float lut[4] = {1.0, 4.0, 3.0, 2.0};
Foo foos[2] = {{10.0, 20.0}, {30.0, 40.0}};
out.FragColor = float4(lut[in.line]);
out.FragColor += float4(foos[in.line].a * (foos[1 - in.line].a));
out.FragColor = float4(lut[in._line]);
out.FragColor += float4(foos[in._line].a * (foos[1 - in._line].a));
return out;
}

View File

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

View File

@ -16,7 +16,7 @@ constant Foo _28[2] = {{10.0, 20.0}, {30.0, 40.0}};
struct main0_in
{
int line [[user(locn0)]];
int _line [[user(locn0)]];
};
struct main0_out
@ -43,8 +43,8 @@ fragment main0_out main0(main0_in in [[stage_in]])
main0_out out = {};
float lut[4] = {1.0, 4.0, 3.0, 2.0};
Foo foos[2] = {{10.0, 20.0}, {30.0, 40.0}};
out.FragColor = float4(lut[in.line]);
out.FragColor += float4(foos[in.line].a * (foos[1 - in.line].a));
out.FragColor = float4(lut[in._line]);
out.FragColor += float4(foos[in._line].a * (foos[1 - in._line].a));
return out;
}

View File

@ -0,0 +1,21 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 FragColor [[color(0)]];
};
fragment main0_out main0()
{
main0_out out = {};
float4 fragment0 = float4(10.0);
float4 compute0 = float4(10.0);
float4 kernel0 = float4(10.0);
float4 vertex0 = float4(10.0);
out.FragColor = ((fragment0 + compute0) + kernel0) + vertex0;
return out;
}

View File

@ -0,0 +1,12 @@
#version 450
layout(location = 0) out vec4 FragColor;
void main()
{
vec4 fragment = vec4(10.0);
vec4 compute = vec4(10.0);
vec4 kernel = vec4(10.0);
vec4 vertex = vec4(10.0);
FragColor = fragment + compute + kernel + vertex;
}

View File

@ -1700,7 +1700,7 @@ void CompilerGLSL::replace_illegal_names()
"uimageCubeArray", "uint", "uniform", "union", "unsigned", "usampler1D", "usampler1DArray", "usampler2D", "usampler2DArray",
"usampler2DMS", "usampler2DMSArray", "usampler2DRect", "usampler3D", "usamplerBuffer", "usamplerCube",
"usamplerCubeArray", "using", "uvec2", "uvec3", "uvec4", "varying", "vec2", "vec3", "vec4", "void", "volatile", "volatile",
"while", "writeonly", "texture"
"while", "writeonly", "texture",
};
// clang-format on

View File

@ -3262,8 +3262,13 @@ string CompilerMSL::ensure_valid_name(string name, string pfx)
// Replace all names that match MSL keywords or Metal Standard Library functions.
void CompilerMSL::replace_illegal_names()
{
// FIXME: MSL and GLSL are doing two different things here.
// Agree on convention and remove this override.
static const unordered_set<string> keywords = {
"kernel",
"vertex",
"fragment",
"compute",
"bias",
};
@ -3318,6 +3323,8 @@ void CompilerMSL::replace_illegal_names()
// Always write this because entry point might have been renamed earlier.
meta[entry.first].decoration.alias = ep_name;
}
CompilerGLSL::replace_illegal_names();
}
string CompilerMSL::to_qualifiers_glsl(uint32_t id)