Skip to content
Open
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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ set(spirv-cross-util-sources
${CMAKE_CURRENT_SOURCE_DIR}/spirv_cross_util.hpp)

set(spirv-cross-abi-major 0)
set(spirv-cross-abi-minor 67)
set(spirv-cross-abi-minor 68)
set(spirv-cross-abi-patch 0)
set(SPIRV_CROSS_VERSION ${spirv-cross-abi-major}.${spirv-cross-abi-minor}.${spirv-cross-abi-patch})

Expand Down
222 changes: 130 additions & 92 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -920,17 +920,31 @@ static void print_help_msl()
"'primitive', or 'patch' to indicate a per-vertex, per-primitive, or per-patch variable.\n"
"\t\tUseful if shader stage interfaces don't match up, as pipeline creation might otherwise fail.\n"
"\t[--msl-add-shader-output <index> <format> <size> <rate>]:\n\t\tSpecify the format of the shader output at <index>.\n"
"\t\t<format> can be 'any32', 'any16', 'u16', 'u8', or 'other', to indicate a 32-bit opaque value, 16-bit opaque value, 16-bit unsigned integer, 8-bit unsigned integer, "
"or other-typed variable. <size> is the vector length of the variable, which must be greater than or equal to that declared in the shader. <rate> can be 'vertex', "
"'primitive', or 'patch' to indicate a per-vertex, per-primitive, or per-patch variable.\n"
"\t\tUseful if shader stage interfaces don't match up, as pipeline creation might otherwise fail.\n"
"\t\t<format> can be 'any32', 'any16', 'u32' 'u16', 'u8', 's32',\n"
"\t\t's16', 's8', or 'other', to indicate a 32-bit opaque value, 16-\n"
"\t\tbit opaque value, 32-bit unsigned integer, 16-bit unsigned\n"
"\t\tinteger, 8-bit unsigned integer, 32-bit signed integer, 16-bit\n"
"\t\tsigned integer, 8-bit signed integer, or other-typed variable.\n"
"\t\t<size> is the vector length of the variable, which must be\n"
"\t\tgreater than or equal to that declared in the shader. <rate> can\n"
"\t\tbe 'vertex', 'primitive', or 'patch' to indicate a per-vertex,\n"
"\t\tper-primitive, or per-patch variable.\n"
"\t\tUseful if shader stage interfaces don't match up, as pipeline\n"
"\t\tcreation might otherwise fail.\n"
"\t[--msl-shader-input <index> <format> <size>]:\n\t\tSpecify the format of the shader input at <index>.\n"
"\t\t<format> can be 'any32', 'any16', 'u16', 'u8', or 'other', to indicate a 32-bit opaque value, 16-bit opaque value, 16-bit unsigned integer, 8-bit unsigned integer, "
"or other-typed variable. <size> is the vector length of the variable, which must be greater than or equal to that declared in the shader."
"\t\tEquivalent to --msl-add-shader-input with a rate of 'vertex'.\n"
"\t[--msl-shader-output <index> <format> <size>]:\n\t\tSpecify the format of the shader output at <index>.\n"
"\t\t<format> can be 'any32', 'any16', 'u16', 'u8', or 'other', to indicate a 32-bit opaque value, 16-bit opaque value, 16-bit unsigned integer, 8-bit unsigned integer, "
"or other-typed variable. <size> is the vector length of the variable, which must be greater than or equal to that declared in the shader."
"\t\t<format> can be 'any32', 'any16', 'u32' 'u16', 'u8', 's32',\n"
"\t\t's16', 's8', or 'other', to indicate a 32-bit opaque value, 16-\n"
"\t\tbit opaque value, 32-bit unsigned integer, 16-bit unsigned\n"
"\t\tinteger, 8-bit unsigned integer, 32-bit signed integer, 16-bit\n"
"\t\tsigned integer, 8-bit signed integer, or other-typed variable.\n"
"\t\t<size> is the vector length of the variable, which must be\n"
"\t\tgreater than or equal to that declared in the shader. <rate> can\n"
"\t\tbe 'vertex', 'primitive', or 'patch' to indicate a per-vertex,\n"
"\t\tper-primitive, or per-patch variable.\n"
"\t\tEquivalent to --msl-add-shader-output with a rate of 'vertex'.\n"
"\t[--msl-raw-buffer-tese-input]:\n\t\tUse raw buffers for tessellation evaluation input.\n"
"\t\tThis allows the use of nested structures and arrays.\n"
Expand Down Expand Up @@ -1724,92 +1738,116 @@ static int main_inner(int argc, char *argv[])
[&args](CLIParser &parser) { args.msl_enable_frag_output_mask = parser.next_hex_uint(); });
cbs.add("--msl-no-clip-distance-user-varying",
[&args](CLIParser &) { args.msl_enable_clip_distance_user_varying = false; });
cbs.add("--msl-add-shader-input", [&args](CLIParser &parser) {
MSLShaderInterfaceVariable input;
// Make sure next_uint() is called in-order.
input.location = parser.next_uint();
const char *format = parser.next_value_string("other");
if (strcmp(format, "any32") == 0)
input.format = MSL_SHADER_VARIABLE_FORMAT_ANY32;
else if (strcmp(format, "any16") == 0)
input.format = MSL_SHADER_VARIABLE_FORMAT_ANY16;
else if (strcmp(format, "u16") == 0)
input.format = MSL_SHADER_VARIABLE_FORMAT_UINT16;
else if (strcmp(format, "u8") == 0)
input.format = MSL_SHADER_VARIABLE_FORMAT_UINT8;
else
input.format = MSL_SHADER_VARIABLE_FORMAT_OTHER;
input.vecsize = parser.next_uint();
const char *rate = parser.next_value_string("vertex");
if (strcmp(rate, "primitive") == 0)
input.rate = MSL_SHADER_VARIABLE_RATE_PER_PRIMITIVE;
else if (strcmp(rate, "patch") == 0)
input.rate = MSL_SHADER_VARIABLE_RATE_PER_PATCH;
else
input.rate = MSL_SHADER_VARIABLE_RATE_PER_VERTEX;
args.msl_shader_inputs.push_back(input);
});
cbs.add("--msl-add-shader-output", [&args](CLIParser &parser) {
MSLShaderInterfaceVariable output;
// Make sure next_uint() is called in-order.
output.location = parser.next_uint();
const char *format = parser.next_value_string("other");
if (strcmp(format, "any32") == 0)
output.format = MSL_SHADER_VARIABLE_FORMAT_ANY32;
else if (strcmp(format, "any16") == 0)
output.format = MSL_SHADER_VARIABLE_FORMAT_ANY16;
else if (strcmp(format, "u16") == 0)
output.format = MSL_SHADER_VARIABLE_FORMAT_UINT16;
else if (strcmp(format, "u8") == 0)
output.format = MSL_SHADER_VARIABLE_FORMAT_UINT8;
else
output.format = MSL_SHADER_VARIABLE_FORMAT_OTHER;
output.vecsize = parser.next_uint();
const char *rate = parser.next_value_string("vertex");
if (strcmp(rate, "primitive") == 0)
output.rate = MSL_SHADER_VARIABLE_RATE_PER_PRIMITIVE;
else if (strcmp(rate, "patch") == 0)
output.rate = MSL_SHADER_VARIABLE_RATE_PER_PATCH;
else
output.rate = MSL_SHADER_VARIABLE_RATE_PER_VERTEX;
args.msl_shader_outputs.push_back(output);
});
cbs.add("--msl-shader-input", [&args](CLIParser &parser) {
MSLShaderInterfaceVariable input;
// Make sure next_uint() is called in-order.
input.location = parser.next_uint();
const char *format = parser.next_value_string("other");
if (strcmp(format, "any32") == 0)
input.format = MSL_SHADER_VARIABLE_FORMAT_ANY32;
else if (strcmp(format, "any16") == 0)
input.format = MSL_SHADER_VARIABLE_FORMAT_ANY16;
else if (strcmp(format, "u16") == 0)
input.format = MSL_SHADER_VARIABLE_FORMAT_UINT16;
else if (strcmp(format, "u8") == 0)
input.format = MSL_SHADER_VARIABLE_FORMAT_UINT8;
else
input.format = MSL_SHADER_VARIABLE_FORMAT_OTHER;
input.vecsize = parser.next_uint();
args.msl_shader_inputs.push_back(input);
});
cbs.add("--msl-shader-output", [&args](CLIParser &parser) {
MSLShaderInterfaceVariable output;
// Make sure next_uint() is called in-order.
output.location = parser.next_uint();
const char *format = parser.next_value_string("other");
if (strcmp(format, "any32") == 0)
output.format = MSL_SHADER_VARIABLE_FORMAT_ANY32;
else if (strcmp(format, "any16") == 0)
output.format = MSL_SHADER_VARIABLE_FORMAT_ANY16;
else if (strcmp(format, "u16") == 0)
output.format = MSL_SHADER_VARIABLE_FORMAT_UINT16;
else if (strcmp(format, "u8") == 0)
output.format = MSL_SHADER_VARIABLE_FORMAT_UINT8;
else
output.format = MSL_SHADER_VARIABLE_FORMAT_OTHER;
output.vecsize = parser.next_uint();
args.msl_shader_outputs.push_back(output);
});
cbs.add("--msl-add-shader-input",
[&args](CLIParser &parser)
{
MSLShaderInterfaceVariable input;
// Make sure next_uint() is called in-order.
input.location = parser.next_uint();
const char *format = parser.next_value_string("other");
if (strcmp(format, "any32") == 0)
input.format = MSL_SHADER_VARIABLE_FORMAT_ANY32;
else if (strcmp(format, "any16") == 0)
input.format = MSL_SHADER_VARIABLE_FORMAT_ANY16;
else if (strcmp(format, "u16") == 0)
input.format = MSL_SHADER_VARIABLE_FORMAT_UINT16;
else if (strcmp(format, "u8") == 0)
input.format = MSL_SHADER_VARIABLE_FORMAT_UINT8;
else
input.format = MSL_SHADER_VARIABLE_FORMAT_OTHER;
input.vecsize = parser.next_uint();
const char *rate = parser.next_value_string("vertex");
if (strcmp(rate, "primitive") == 0)
input.rate = MSL_SHADER_VARIABLE_RATE_PER_PRIMITIVE;
else if (strcmp(rate, "patch") == 0)
input.rate = MSL_SHADER_VARIABLE_RATE_PER_PATCH;
else
input.rate = MSL_SHADER_VARIABLE_RATE_PER_VERTEX;
args.msl_shader_inputs.push_back(input);
});
cbs.add("--msl-add-shader-output",
[&args](CLIParser &parser)
{
MSLShaderInterfaceVariable output;
// Make sure next_uint() is called in-order.
output.location = parser.next_uint();
const char *format = parser.next_value_string("other");
if (strcmp(format, "any32") == 0)
output.format = MSL_SHADER_VARIABLE_FORMAT_ANY32;
else if (strcmp(format, "any16") == 0)
output.format = MSL_SHADER_VARIABLE_FORMAT_ANY16;
else if (strcmp(format, "u32") == 0)
output.format = MSL_SHADER_VARIABLE_FORMAT_UINT32;
else if (strcmp(format, "u16") == 0)
output.format = MSL_SHADER_VARIABLE_FORMAT_UINT16;
else if (strcmp(format, "u8") == 0)
output.format = MSL_SHADER_VARIABLE_FORMAT_UINT8;
else if (strcmp(format, "s32") == 0)
output.format = MSL_SHADER_VARIABLE_FORMAT_SINT32;
else if (strcmp(format, "s16") == 0)
output.format = MSL_SHADER_VARIABLE_FORMAT_SINT16;
else if (strcmp(format, "s8") == 0)
output.format = MSL_SHADER_VARIABLE_FORMAT_SINT8;
else
output.format = MSL_SHADER_VARIABLE_FORMAT_OTHER;
output.vecsize = parser.next_uint();
const char *rate = parser.next_value_string("vertex");
if (strcmp(rate, "primitive") == 0)
output.rate = MSL_SHADER_VARIABLE_RATE_PER_PRIMITIVE;
else if (strcmp(rate, "patch") == 0)
output.rate = MSL_SHADER_VARIABLE_RATE_PER_PATCH;
else
output.rate = MSL_SHADER_VARIABLE_RATE_PER_VERTEX;
args.msl_shader_outputs.push_back(output);
});
cbs.add("--msl-shader-input",
[&args](CLIParser &parser)
{
MSLShaderInterfaceVariable input;
// Make sure next_uint() is called in-order.
input.location = parser.next_uint();
const char *format = parser.next_value_string("other");
if (strcmp(format, "any32") == 0)
input.format = MSL_SHADER_VARIABLE_FORMAT_ANY32;
else if (strcmp(format, "any16") == 0)
input.format = MSL_SHADER_VARIABLE_FORMAT_ANY16;
else if (strcmp(format, "u16") == 0)
input.format = MSL_SHADER_VARIABLE_FORMAT_UINT16;
else if (strcmp(format, "u8") == 0)
input.format = MSL_SHADER_VARIABLE_FORMAT_UINT8;
else
input.format = MSL_SHADER_VARIABLE_FORMAT_OTHER;
input.vecsize = parser.next_uint();
args.msl_shader_inputs.push_back(input);
});
cbs.add("--msl-shader-output",
[&args](CLIParser &parser)
{
MSLShaderInterfaceVariable output;
// Make sure next_uint() is called in-order.
output.location = parser.next_uint();
const char *format = parser.next_value_string("other");
if (strcmp(format, "any32") == 0)
output.format = MSL_SHADER_VARIABLE_FORMAT_ANY32;
else if (strcmp(format, "any16") == 0)
output.format = MSL_SHADER_VARIABLE_FORMAT_ANY16;
else if (strcmp(format, "u32") == 0)
output.format = MSL_SHADER_VARIABLE_FORMAT_UINT32;
else if (strcmp(format, "u16") == 0)
output.format = MSL_SHADER_VARIABLE_FORMAT_UINT16;
else if (strcmp(format, "u8") == 0)
output.format = MSL_SHADER_VARIABLE_FORMAT_UINT8;
else if (strcmp(format, "s32") == 0)
output.format = MSL_SHADER_VARIABLE_FORMAT_SINT32;
else if (strcmp(format, "s16") == 0)
output.format = MSL_SHADER_VARIABLE_FORMAT_SINT16;
else if (strcmp(format, "s8") == 0)
output.format = MSL_SHADER_VARIABLE_FORMAT_SINT8;
else
output.format = MSL_SHADER_VARIABLE_FORMAT_OTHER;
output.vecsize = parser.next_uint();
args.msl_shader_outputs.push_back(output);
});
cbs.add("--msl-raw-buffer-tese-input", [&args](CLIParser &) { args.msl_raw_buffer_tese_input = true; });
cbs.add("--msl-multi-patch-workgroup", [&args](CLIParser &) { args.msl_multi_patch_workgroup = true; });
cbs.add("--msl-vertex-for-tessellation", [&args](CLIParser &) { args.msl_vertex_for_tessellation = true; });
Expand Down
87 changes: 87 additions & 0 deletions reference/opt/shaders-msl/frag/fragment.signed-mismatch.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#pragma clang diagnostic ignored "-Wmissing-braces"

#include <metal_stdlib>
#include <simd/simd.h>

using namespace metal;

template<typename T, size_t Num>
struct spvUnsafeArray
{
T elements[Num ? Num : 1];

thread T& operator [] (size_t pos) thread
{
return elements[pos];
}
constexpr const thread T& operator [] (size_t pos) const thread
{
return elements[pos];
}

device T& operator [] (size_t pos) device
{
return elements[pos];
}
constexpr const device T& operator [] (size_t pos) const device
{
return elements[pos];
}

constexpr const constant T& operator [] (size_t pos) const constant
{
return elements[pos];
}

threadgroup T& operator [] (size_t pos) threadgroup
{
return elements[pos];
}
constexpr const threadgroup T& operator [] (size_t pos) const threadgroup
{
return elements[pos];
}
};

struct main0_out
{
uint4 out0 [[color(0)]];
ushort4 out1_0 [[color(1)]];
ushort3 out1_1 [[color(2)]];
int4 out3 [[color(3)]];
short2 out4 [[color(4)]];
short4 m_location_5 [[color(5)]];
float4 out6 [[color(6)]];
};

struct main0_in
{
uchar4 vColor [[user(locn0)]];
};

fragment main0_out main0(main0_in in [[stage_in]])
{
main0_out out = {};
int4 out0 = {};
spvUnsafeArray<short3, 2> out1 = {};
uint2 out3 = {};
ushort out4 = {};
uint2 out5 = {};
out0 = int4(uint4(in.vColor));
out1[0] = short3(ushort3(in.vColor.yyy));
out1[1] = short3(ushort3(in.vColor.wxz));
out3.x = uint(in.vColor.x);
out3.y = uint(in.vColor.w);
out4 = ushort(in.vColor.z);
out5 = uint2(in.vColor.zx);
out.out6 = float4(in.vColor);
out.out0 = uint4(out0);
out.out1_0 = ushort4(out1[0].xyzz);
out.out1_1 = ushort3(out1[1]);
out.out3.xy = int2(out3);
out.out4.x = short(out4);
out.m_location_5.zw = short2(out5);
return out;
}

Loading