Merge pull request #6362 from aliaspider/master

update SPIRV-Cross.
This commit is contained in:
Twinaphex 2018-03-06 04:47:01 +01:00 committed by GitHub
commit 333ef62e25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
168 changed files with 6205 additions and 356 deletions

View File

@ -2,7 +2,7 @@ language: cpp
os:
- linux
- osx
osx_image: xcode8.2
osx_image: xcode8.3
# Use Ubuntu 14.04 LTS (Trusty) as the Linux testing environment.
sudo: required
@ -13,7 +13,7 @@ env:
- GLSLANG_REV=9c6f8cc29ba303b43ccf36deea6bb38a304f9b92 SPIRV_TOOLS_REV=e28edd458b729da7bbfd51e375feb33103709e6f
before_script:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; brew install python3; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew upgrade python3; fi
- git clone https://github.com/KhronosGroup/glslang.git glslang
- git clone https://github.com/KhronosGroup/SPIRV-Tools SPIRV-Tools
- git clone https://github.com/KhronosGroup/SPIRV-Headers.git SPIRV-Tools/external/spirv-headers

View File

@ -101,12 +101,17 @@ spirv_cross_add_library(spirv-cross-hlsl spirv_cross_hlsl STATIC
${CMAKE_CURRENT_SOURCE_DIR}/spirv_hlsl.hpp
${CMAKE_CURRENT_SOURCE_DIR}/spirv_hlsl.cpp)
spirv_cross_add_library(spirv-cross-util spirv_cross_util STATIC
${CMAKE_CURRENT_SOURCE_DIR}/spirv_cross_util.hpp
${CMAKE_CURRENT_SOURCE_DIR}/spirv_cross_util.cpp)
add_executable(spirv-cross main.cpp)
target_compile_options(spirv-cross PRIVATE ${spirv-compiler-options})
target_compile_definitions(spirv-cross PRIVATE ${spirv-compiler-defines})
install(TARGETS spirv-cross RUNTIME DESTINATION bin)
target_link_libraries(spirv-cross spirv-cross-glsl spirv-cross-hlsl spirv-cross-cpp spirv-cross-msl spirv-cross-core)
target_link_libraries(spirv-cross spirv-cross-glsl spirv-cross-hlsl spirv-cross-cpp spirv-cross-msl spirv-cross-util spirv-cross-core)
target_link_libraries(spirv-cross-util spirv-cross-core)
target_link_libraries(spirv-cross-glsl spirv-cross-core)
target_link_libraries(spirv-cross-msl spirv-cross-glsl)
target_link_libraries(spirv-cross-hlsl spirv-cross-glsl)

View File

@ -7,8 +7,8 @@ SPIRV-Cross is a tool designed for parsing and converting SPIR-V to other shader
## Features
- Convert SPIR-V to readable, usable and efficient GLSL
- Convert SPIR-V to readable, usable and efficient Metal Shading Language (MSL) [EXPERIMENTAL]
- Convert SPIR-V to readable, usable and efficient HLSL [EXPERIMENTAL]
- Convert SPIR-V to readable, usable and efficient Metal Shading Language (MSL)
- Convert SPIR-V to readable, usable and efficient HLSL
- Convert SPIR-V to debuggable C++ [EXPERIMENTAL]
- Reflection API to simplify the creation of Vulkan pipeline layouts
- Reflection API to modify and tweak OpDecorations

View File

@ -4,7 +4,7 @@ include $(CLEAR_VARS)
LOCAL_CFLAGS += -std=c++11 -Wall -Wextra
LOCAL_MODULE := spirv-cross
LOCAL_SRC_FILES := ../spirv_cfg.cpp ../spirv_cross.cpp ../spirv_glsl.cpp ../spirv_msl.cpp ../spirv_cpp.cpp
LOCAL_SRC_FILES := ../spirv_cfg.cpp ../spirv_cross.cpp ../spirv_cross_util.cpp ../spirv_glsl.cpp ../spirv_hlsl.cpp ../spirv_msl.cpp ../spirv_cpp.cpp
LOCAL_CPP_FEATURES := exceptions
LOCAL_ARM_MODE := arm
LOCAL_CFLAGS := -D__STDC_LIMIT_MACROS

View File

@ -15,6 +15,7 @@
*/
#include "spirv_cpp.hpp"
#include "spirv_cross_util.hpp"
#include "spirv_glsl.hpp"
#include "spirv_hlsl.hpp"
#include "spirv_msl.hpp"
@ -286,9 +287,9 @@ static void print_resources(const Compiler &compiler, const ShaderResources &res
uint64_t modes = compiler.get_execution_mode_mask();
fprintf(stderr, "Entry points:\n");
auto entry_points = compiler.get_entry_points();
auto entry_points = compiler.get_entry_points_and_stages();
for (auto &e : entry_points)
fprintf(stderr, " %s (%s)\n", e.c_str(), execution_model_to_str(compiler.get_entry_point(e).model));
fprintf(stderr, " %s (%s)\n", e.name.c_str(), execution_model_to_str(e.execution_model));
fprintf(stderr, "\n");
fprintf(stderr, "Execution modes:\n");
@ -467,8 +468,15 @@ struct CLIArguments
vector<InterfaceVariableRename> interface_variable_renames;
vector<HLSLVertexAttributeRemap> hlsl_attr_remap;
string entry;
string entry_stage;
vector<pair<string, string>> entry_point_rename;
struct Rename
{
string old_name;
string new_name;
ExecutionModel execution_model;
};
vector<Rename> entry_point_rename;
uint32_t iterations = 1;
bool cpp = false;
@ -491,12 +499,13 @@ static void print_help()
"[--hlsl] [--shader-model] [--hlsl-enable-compat] "
"[--separate-shader-objects]"
"[--pls-in format input-name] [--pls-out format output-name] [--remap source_name target_name "
"components] [--extension ext] [--entry name] [--remove-unused-variables] "
"components] [--extension ext] [--entry name] [--stage <stage (vert, frag, geom, tesc, tese, "
"comp)>] [--remove-unused-variables] "
"[--flatten-multidimensional-arrays] [--no-420pack-extension] "
"[--remap-variable-type <variable_name> <new_variable_type>] "
"[--rename-interface-variable <in|out> <location> <new_variable_name>] "
"[--set-hlsl-vertex-input-semantic <location> <semantic>] "
"[--rename-entry-point <old> <new>] "
"[--rename-entry-point <old> <new> <stage>] "
"\n");
}
@ -584,31 +593,22 @@ static PlsFormat pls_format(const char *str)
return PlsNone;
}
void rename_interface_variable(Compiler &compiler, const vector<Resource> &resources,
const InterfaceVariableRename &rename)
static ExecutionModel stage_to_execution_model(const std::string &stage)
{
for (auto &v : resources)
{
if (!compiler.has_decoration(v.id, spv::DecorationLocation))
continue;
auto loc = compiler.get_decoration(v.id, spv::DecorationLocation);
if (loc != rename.location)
continue;
auto &type = compiler.get_type(v.base_type_id);
// This is more of a friendly variant. If we need to rename interface variables, we might have to rename
// structs as well and make sure all the names match up.
if (type.basetype == SPIRType::Struct)
{
compiler.set_name(v.base_type_id, join("SPIRV_Cross_Interface_Location", rename.location));
for (uint32_t i = 0; i < uint32_t(type.member_types.size()); i++)
compiler.set_member_name(v.base_type_id, i, join("InterfaceMember", i));
}
compiler.set_name(v.id, rename.variable_name);
}
if (stage == "vert")
return ExecutionModelVertex;
else if (stage == "frag")
return ExecutionModelFragment;
else if (stage == "comp")
return ExecutionModelGLCompute;
else if (stage == "tesc")
return ExecutionModelTessellationControl;
else if (stage == "tese")
return ExecutionModelTessellationEvaluation;
else if (stage == "geom")
return ExecutionModelGeometry;
else
SPIRV_CROSS_THROW("Invalid stage.");
}
static int main_inner(int argc, char *argv[])
@ -652,9 +652,11 @@ static int main_inner(int argc, char *argv[])
cbs.add("--rename-entry-point", [&args](CLIParser &parser) {
auto old_name = parser.next_string();
auto new_name = parser.next_string();
args.entry_point_rename.push_back({ old_name, new_name });
auto model = stage_to_execution_model(parser.next_string());
args.entry_point_rename.push_back({ old_name, new_name, move(model) });
});
cbs.add("--entry", [&args](CLIParser &parser) { args.entry = parser.next_string(); });
cbs.add("--stage", [&args](CLIParser &parser) { args.entry_stage = parser.next_string(); });
cbs.add("--separate-shader-objects", [&args](CLIParser &) { args.sso = true; });
cbs.add("--set-hlsl-vertex-input-semantic", [&args](CLIParser &parser) {
HLSLVertexAttributeRemap remap;
@ -733,6 +735,7 @@ static int main_inner(int argc, char *argv[])
unique_ptr<CompilerGLSL> compiler;
bool combined_image_samplers = false;
bool build_dummy_sampler = false;
if (args.cpp)
{
@ -755,6 +758,7 @@ static int main_inner(int argc, char *argv[])
else
{
combined_image_samplers = !args.vulkan_semantics;
build_dummy_sampler = true;
compiler = unique_ptr<CompilerGLSL>(new CompilerGLSL(read_spirv_file(args.input)));
}
@ -770,10 +774,82 @@ static int main_inner(int argc, char *argv[])
}
for (auto &rename : args.entry_point_rename)
compiler->rename_entry_point(rename.first, rename.second);
compiler->rename_entry_point(rename.old_name, rename.new_name, rename.execution_model);
if (!args.entry.empty())
compiler->set_entry_point(args.entry);
auto entry_points = compiler->get_entry_points_and_stages();
auto entry_point = args.entry;
ExecutionModel model = ExecutionModelMax;
if (!args.entry_stage.empty())
{
model = stage_to_execution_model(args.entry_stage);
if (entry_point.empty())
{
// Just use the first entry point with this stage.
for (auto &e : entry_points)
{
if (e.execution_model == model)
{
entry_point = e.name;
break;
}
}
if (entry_point.empty())
{
fprintf(stderr, "Could not find an entry point with stage: %s\n", args.entry_stage.c_str());
return EXIT_FAILURE;
}
}
else
{
// Make sure both stage and name exists.
bool exists = false;
for (auto &e : entry_points)
{
if (e.execution_model == model && e.name == entry_point)
{
exists = true;
break;
}
}
if (!exists)
{
fprintf(stderr, "Could not find an entry point %s with stage: %s\n", entry_point.c_str(),
args.entry_stage.c_str());
return EXIT_FAILURE;
}
}
}
else if (!entry_point.empty())
{
// Make sure there is just one entry point with this name, or the stage
// is ambiguous.
uint32_t stage_count = 0;
for (auto &e : entry_points)
{
if (e.name == entry_point)
{
stage_count++;
model = e.execution_model;
}
}
if (stage_count == 0)
{
fprintf(stderr, "There is no entry point with name: %s\n", entry_point.c_str());
return EXIT_FAILURE;
}
else if (stage_count > 1)
{
fprintf(stderr, "There is more than one entry point with name: %s. Use --stage.\n", entry_point.c_str());
return EXIT_FAILURE;
}
}
if (!entry_point.empty())
compiler->set_entry_point(entry_point, model);
if (!args.set_version && !compiler->get_options().version)
{
@ -816,10 +892,14 @@ static int main_inner(int argc, char *argv[])
{
// Enable all compat options.
hlsl_opts.point_size_compat = true;
hlsl_opts.point_coord_compat = true;
}
hlsl->set_options(hlsl_opts);
}
if (build_dummy_sampler)
compiler->build_dummy_sampler_for_combined_images();
ShaderResources res;
if (args.remove_unused)
{
@ -858,9 +938,11 @@ static int main_inner(int argc, char *argv[])
for (auto &rename : args.interface_variable_renames)
{
if (rename.storageClass == StorageClassInput)
rename_interface_variable(*compiler, res.stage_inputs, rename);
spirv_cross_util::rename_interface_variable(*compiler, res.stage_inputs, rename.location,
rename.variable_name);
else if (rename.storageClass == StorageClassOutput)
rename_interface_variable(*compiler, res.stage_outputs, rename);
spirv_cross_util::rename_interface_variable(*compiler, res.stage_outputs, rename.location,
rename.variable_name);
else
{
fprintf(stderr, "error at --rename-interface-variable <in|out> ...\n");
@ -887,6 +969,17 @@ static int main_inner(int argc, char *argv[])
}
}
if (args.hlsl)
{
auto *hlsl_compiler = static_cast<CompilerHLSL *>(compiler.get());
uint32_t new_builtin = hlsl_compiler->remap_num_workgroups_builtin();
if (new_builtin)
{
hlsl_compiler->set_decoration(new_builtin, DecorationDescriptorSet, 0);
hlsl_compiler->set_decoration(new_builtin, DecorationBinding, 0);
}
}
string glsl;
for (uint32_t i = 0; i < args.iterations; i++)
{

View File

@ -130,6 +130,7 @@
<ClCompile Include="..\spirv_hlsl.cpp" />
<ClCompile Include="..\spirv_msl.cpp" />
<ClCompile Include="..\spirv_cfg.cpp" />
<ClCompile Include="..\spirv_cross_util.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\GLSL.std.450.h" />
@ -141,6 +142,7 @@
<ClInclude Include="..\spirv_hlsl.hpp" />
<ClInclude Include="..\spirv_msl.hpp" />
<ClInclude Include="..\spirv_cfg.hpp" />
<ClInclude Include="..\spirv_cross_util.hpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View File

@ -36,6 +36,9 @@
<ClCompile Include="..\spirv_hlsl.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\spirv_cross_util.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\GLSL.std.450.h">
@ -65,5 +68,8 @@
<ClInclude Include="..\spirv_hlsl.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\spirv_cross_util.hpp">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -0,0 +1,29 @@
static float4 FragColor;
static float4 vA;
static float4 vB;
struct SPIRV_Cross_Input
{
float4 vA : TEXCOORD0;
float4 vB : TEXCOORD1;
};
struct SPIRV_Cross_Output
{
float4 FragColor : SV_Target0;
};
void frag_main()
{
FragColor = fmod(vA, vB);
}
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
vA = stage_input.vA;
vB = stage_input.vB;
frag_main();
SPIRV_Cross_Output stage_output;
stage_output.FragColor = FragColor;
return stage_output;
}

View File

@ -0,0 +1,19 @@
static float4 FragColor;
struct SPIRV_Cross_Output
{
float4 FragColor : SV_Target0;
};
void frag_main()
{
FragColor = (((1.0f.xxxx + 1.0f.xxxx) + (1.0f.xxx.xyzz + 1.0f.xxxx)) + (1.0f.xxxx + 2.0f.xxxx)) + (1.0f.xx.xyxy + 2.0f.xxxx);
}
SPIRV_Cross_Output main()
{
frag_main();
SPIRV_Cross_Output stage_output;
stage_output.FragColor = FragColor;
return stage_output;
}

View File

@ -0,0 +1,122 @@
RWByteAddressBuffer _15 : register(u0);
ByteAddressBuffer _20 : register(t1);
// Returns the inverse of a matrix, by using the algorithm of calculating the classical
// adjoint and dividing by the determinant. The contents of the matrix are changed.
float2x2 SPIRV_Cross_Inverse(float2x2 m)
{
float2x2 adj; // The adjoint matrix (inverse after dividing by determinant)
// Create the transpose of the cofactors, as the classical adjoint of the matrix.
adj[0][0] = m[1][1];
adj[0][1] = -m[0][1];
adj[1][0] = -m[1][0];
adj[1][1] = m[0][0];
// Calculate the determinant as a combination of the cofactors of the first row.
float det = (adj[0][0] * m[0][0]) + (adj[0][1] * m[1][0]);
// Divide the classical adjoint matrix by the determinant.
// If determinant is zero, matrix is not invertable, so leave it unchanged.
return (det != 0.0f) ? (adj * (1.0f / det)) : m;
}
// Returns the determinant of a 2x2 matrix.
float SPIRV_Cross_Det2x2(float a1, float a2, float b1, float b2)
{
return a1 * b2 - b1 * a2;
}
// Returns the inverse of a matrix, by using the algorithm of calculating the classical
// adjoint and dividing by the determinant. The contents of the matrix are changed.
float3x3 SPIRV_Cross_Inverse(float3x3 m)
{
float3x3 adj; // The adjoint matrix (inverse after dividing by determinant)
// Create the transpose of the cofactors, as the classical adjoint of the matrix.
adj[0][0] = SPIRV_Cross_Det2x2(m[1][1], m[1][2], m[2][1], m[2][2]);
adj[0][1] = -SPIRV_Cross_Det2x2(m[0][1], m[0][2], m[2][1], m[2][2]);
adj[0][2] = SPIRV_Cross_Det2x2(m[0][1], m[0][2], m[1][1], m[1][2]);
adj[1][0] = -SPIRV_Cross_Det2x2(m[1][0], m[1][2], m[2][0], m[2][2]);
adj[1][1] = SPIRV_Cross_Det2x2(m[0][0], m[0][2], m[2][0], m[2][2]);
adj[1][2] = -SPIRV_Cross_Det2x2(m[0][0], m[0][2], m[1][0], m[1][2]);
adj[2][0] = SPIRV_Cross_Det2x2(m[1][0], m[1][1], m[2][0], m[2][1]);
adj[2][1] = -SPIRV_Cross_Det2x2(m[0][0], m[0][1], m[2][0], m[2][1]);
adj[2][2] = SPIRV_Cross_Det2x2(m[0][0], m[0][1], m[1][0], m[1][1]);
// Calculate the determinant as a combination of the cofactors of the first row.
float det = (adj[0][0] * m[0][0]) + (adj[0][1] * m[1][0]) + (adj[0][2] * m[2][0]);
// Divide the classical adjoint matrix by the determinant.
// If determinant is zero, matrix is not invertable, so leave it unchanged.
return (det != 0.0f) ? (adj * (1.0f / det)) : m;
}
// Returns the determinant of a 3x3 matrix.
float SPIRV_Cross_Det3x3(float a1, float a2, float a3, float b1, float b2, float b3, float c1, float c2, float c3)
{
return a1 * SPIRV_Cross_Det2x2(b2, b3, c2, c3) - b1 * SPIRV_Cross_Det2x2(a2, a3, c2, c3) + c1 * SPIRV_Cross_Det2x2(a2, a3, b2, b3);
}
// Returns the inverse of a matrix, by using the algorithm of calculating the classical
// adjoint and dividing by the determinant. The contents of the matrix are changed.
float4x4 SPIRV_Cross_Inverse(float4x4 m)
{
float4x4 adj; // The adjoint matrix (inverse after dividing by determinant)
// Create the transpose of the cofactors, as the classical adjoint of the matrix.
adj[0][0] = SPIRV_Cross_Det3x3(m[1][1], m[1][2], m[1][3], m[2][1], m[2][2], m[2][3], m[3][1], m[3][2], m[3][3]);
adj[0][1] = -SPIRV_Cross_Det3x3(m[0][1], m[0][2], m[0][3], m[2][1], m[2][2], m[2][3], m[3][1], m[3][2], m[3][3]);
adj[0][2] = SPIRV_Cross_Det3x3(m[0][1], m[0][2], m[0][3], m[1][1], m[1][2], m[1][3], m[3][1], m[3][2], m[3][3]);
adj[0][3] = -SPIRV_Cross_Det3x3(m[0][1], m[0][2], m[0][3], m[1][1], m[1][2], m[1][3], m[2][1], m[2][2], m[2][3]);
adj[1][0] = -SPIRV_Cross_Det3x3(m[1][0], m[1][2], m[1][3], m[2][0], m[2][2], m[2][3], m[3][0], m[3][2], m[3][3]);
adj[1][1] = SPIRV_Cross_Det3x3(m[0][0], m[0][2], m[0][3], m[2][0], m[2][2], m[2][3], m[3][0], m[3][2], m[3][3]);
adj[1][2] = -SPIRV_Cross_Det3x3(m[0][0], m[0][2], m[0][3], m[1][0], m[1][2], m[1][3], m[3][0], m[3][2], m[3][3]);
adj[1][3] = SPIRV_Cross_Det3x3(m[0][0], m[0][2], m[0][3], m[1][0], m[1][2], m[1][3], m[2][0], m[2][2], m[2][3]);
adj[2][0] = SPIRV_Cross_Det3x3(m[1][0], m[1][1], m[1][3], m[2][0], m[2][1], m[2][3], m[3][0], m[3][1], m[3][3]);
adj[2][1] = -SPIRV_Cross_Det3x3(m[0][0], m[0][1], m[0][3], m[2][0], m[2][1], m[2][3], m[3][0], m[3][1], m[3][3]);
adj[2][2] = SPIRV_Cross_Det3x3(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[3][0], m[3][1], m[3][3]);
adj[2][3] = -SPIRV_Cross_Det3x3(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[2][0], m[2][1], m[2][3]);
adj[3][0] = -SPIRV_Cross_Det3x3(m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], m[2][2], m[3][0], m[3][1], m[3][2]);
adj[3][1] = SPIRV_Cross_Det3x3(m[0][0], m[0][1], m[0][2], m[2][0], m[2][1], m[2][2], m[3][0], m[3][1], m[3][2]);
adj[3][2] = -SPIRV_Cross_Det3x3(m[0][0], m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[3][0], m[3][1], m[3][2]);
adj[3][3] = SPIRV_Cross_Det3x3(m[0][0], m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], m[2][2]);
// Calculate the determinant as a combination of the cofactors of the first row.
float det = (adj[0][0] * m[0][0]) + (adj[0][1] * m[1][0]) + (adj[0][2] * m[2][0]) + (adj[0][3] * m[3][0]);
// Divide the classical adjoint matrix by the determinant.
// If determinant is zero, matrix is not invertable, so leave it unchanged.
return (det != 0.0f) ? (adj * (1.0f / det)) : m;
}
void comp_main()
{
float2x2 _23 = asfloat(uint2x2(_20.Load2(0), _20.Load2(8)));
float2x2 _24 = SPIRV_Cross_Inverse(_23);
_15.Store2(0, asuint(_24[0]));
_15.Store2(8, asuint(_24[1]));
float3x3 _29 = asfloat(uint3x3(_20.Load3(16), _20.Load3(32), _20.Load3(48)));
float3x3 _30 = SPIRV_Cross_Inverse(_29);
_15.Store3(16, asuint(_30[0]));
_15.Store3(32, asuint(_30[1]));
_15.Store3(48, asuint(_30[2]));
float4x4 _35 = asfloat(uint4x4(_20.Load4(64), _20.Load4(80), _20.Load4(96), _20.Load4(112)));
float4x4 _36 = SPIRV_Cross_Inverse(_35);
_15.Store4(64, asuint(_36[0]));
_15.Store4(80, asuint(_36[1]));
_15.Store4(96, asuint(_36[2]));
_15.Store4(112, asuint(_36[3]));
}
[numthreads(1, 1, 1)]
void main()
{
comp_main();
}

View File

@ -0,0 +1,16 @@
RWByteAddressBuffer _10 : register(u0);
cbuffer SPIRV_Cross_NumWorkgroups : register(b0)
{
uint3 SPIRV_Cross_NumWorkgroups_count : packoffset(c0);
};
void comp_main()
{
_10.Store3(0, SPIRV_Cross_NumWorkgroups_count);
}
[numthreads(1, 1, 1)]
void main()
{
comp_main();
}

View File

@ -0,0 +1,23 @@
RWByteAddressBuffer _10 : register(u0);
cbuffer SPIRV_Cross_NumWorkgroups : register(b0)
{
uint3 SPIRV_Cross_NumWorkgroups_count : packoffset(c0);
};
static uint3 gl_WorkGroupID;
struct SPIRV_Cross_Input
{
uint3 gl_WorkGroupID : SV_GroupID;
};
void comp_main()
{
_10.Store3(0, SPIRV_Cross_NumWorkgroups_count + gl_WorkGroupID);
}
[numthreads(1, 1, 1)]
void main(SPIRV_Cross_Input stage_input)
{
gl_WorkGroupID = stage_input.gl_WorkGroupID;
comp_main();
}

View File

@ -0,0 +1,30 @@
static float gl_ClipDistance[2];
static float gl_CullDistance[1];
static float FragColor;
struct SPIRV_Cross_Input
{
float2 gl_ClipDistance0 : SV_ClipDistance0;
float gl_CullDistance0 : SV_CullDistance0;
};
struct SPIRV_Cross_Output
{
float FragColor : SV_Target0;
};
void frag_main()
{
FragColor = (gl_ClipDistance[0] + gl_CullDistance[0]) + gl_ClipDistance[1];
}
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
gl_ClipDistance[0] = stage_input.gl_ClipDistance0.x;
gl_ClipDistance[1] = stage_input.gl_ClipDistance0.y;
gl_CullDistance[0] = stage_input.gl_CullDistance0.x;
frag_main();
SPIRV_Cross_Output stage_output;
stage_output.FragColor = FragColor;
return stage_output;
}

View File

@ -0,0 +1,39 @@
static bool gl_FrontFacing;
static float4 FragColor;
static float4 vA;
static float4 vB;
struct SPIRV_Cross_Input
{
float4 vA : TEXCOORD0;
float4 vB : TEXCOORD1;
bool gl_FrontFacing : SV_IsFrontFace;
};
struct SPIRV_Cross_Output
{
float4 FragColor : SV_Target0;
};
void frag_main()
{
if (gl_FrontFacing)
{
FragColor = vA;
}
else
{
FragColor = vB;
}
}
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
gl_FrontFacing = stage_input.gl_FrontFacing;
vA = stage_input.vA;
vB = stage_input.vB;
frag_main();
SPIRV_Cross_Output stage_output;
stage_output.FragColor = FragColor;
return stage_output;
}

View File

@ -0,0 +1,19 @@
static float3 FragColor;
struct SPIRV_Cross_Output
{
float3 FragColor : SV_Target0;
};
void frag_main()
{
FragColor = float3(asfloat(0x7f800000u), asfloat(0xff800000u), asfloat(0xffc00000u));
}
SPIRV_Cross_Output main()
{
frag_main();
SPIRV_Cross_Output stage_output;
stage_output.FragColor = FragColor;
return stage_output;
}

View File

@ -0,0 +1,32 @@
Texture2DMS<float4> uSubpass0 : register(t0);
Texture2DMS<float4> uSubpass1 : register(t1);
static float4 gl_FragCoord;
static int gl_SampleID;
static float4 FragColor;
struct SPIRV_Cross_Input
{
float4 gl_FragCoord : SV_Position;
uint gl_SampleID : SV_SampleIndex;
};
struct SPIRV_Cross_Output
{
float4 FragColor : SV_Target0;
};
void frag_main()
{
FragColor = (uSubpass0.Load(int2(gl_FragCoord.xy), 1) + uSubpass1.Load(int2(gl_FragCoord.xy), 2)) + uSubpass0.Load(int2(gl_FragCoord.xy), gl_SampleID);
}
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
gl_FragCoord = stage_input.gl_FragCoord;
gl_SampleID = stage_input.gl_SampleID;
frag_main();
SPIRV_Cross_Output stage_output;
stage_output.FragColor = FragColor;
return stage_output;
}

View File

@ -0,0 +1,29 @@
Texture2D<float4> uSubpass0 : register(t0);
Texture2D<float4> uSubpass1 : register(t1);
static float4 gl_FragCoord;
static float4 FragColor;
struct SPIRV_Cross_Input
{
float4 gl_FragCoord : SV_Position;
};
struct SPIRV_Cross_Output
{
float4 FragColor : SV_Target0;
};
void frag_main()
{
FragColor = uSubpass0.Load(int3(int2(gl_FragCoord.xy), 0)) + uSubpass1.Load(int3(int2(gl_FragCoord.xy), 0));
}
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
gl_FragCoord = stage_input.gl_FragCoord;
frag_main();
SPIRV_Cross_Output stage_output;
stage_output.FragColor = FragColor;
return stage_output;
}

View File

@ -0,0 +1,19 @@
static float2 FragColor;
struct SPIRV_Cross_Output
{
float2 FragColor : SV_Target0;
};
void frag_main()
{
FragColor = float2(0.5f, 0.5f);
}
SPIRV_Cross_Output main()
{
frag_main();
SPIRV_Cross_Output stage_output;
stage_output.FragColor = FragColor;
return stage_output;
}

View File

@ -0,0 +1,33 @@
static const int Value = 2;
cbuffer _15 : register(b0)
{
float4 _15_samples[Value] : packoffset(c0);
};
static float4 FragColor;
static int Index;
struct SPIRV_Cross_Input
{
nointerpolation int Index : TEXCOORD0;
};
struct SPIRV_Cross_Output
{
float4 FragColor : SV_Target0;
};
void frag_main()
{
FragColor = _15_samples[Index];
}
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
Index = stage_input.Index;
frag_main();
SPIRV_Cross_Output stage_output;
stage_output.FragColor = FragColor;
return stage_output;
}

View File

@ -0,0 +1,28 @@
static float4 gl_Position;
static float gl_ClipDistance[2];
static float gl_CullDistance[1];
struct SPIRV_Cross_Output
{
float4 gl_Position : SV_Position;
float2 gl_ClipDistance0 : SV_ClipDistance0;
float gl_CullDistance0 : SV_CullDistance0;
};
void vert_main()
{
gl_Position = 1.0f.xxxx;
gl_ClipDistance[0] = 0.0f;
gl_ClipDistance[1] = 0.0f;
gl_CullDistance[0] = 4.0f;
}
SPIRV_Cross_Output main()
{
vert_main();
SPIRV_Cross_Output stage_output;
stage_output.gl_Position = gl_Position;
stage_output.gl_ClipDistance0.x = gl_ClipDistance[0];
stage_output.gl_ClipDistance0.y = gl_ClipDistance[1];
stage_output.gl_CullDistance0.x = gl_CullDistance[0];
return stage_output;
}

View File

@ -8,7 +8,7 @@ struct SPIRV_Cross_Output
void vert_main()
{
gl_Position = 1.0f.xxxx;
gl_PointSize = 10.0f;
gl_PointSize = 1.0f;
}
SPIRV_Cross_Output main()

View File

@ -0,0 +1,31 @@
static const float4 _20[2] = { 10.0f.xxxx, 20.0f.xxxx };
static float4 gl_Position;
static float4 vInput0;
static float4 vInput1;
struct SPIRV_Cross_Input
{
float4 vInput0 : TEXCOORD0;
float4 vInput1 : TEXCOORD1;
};
struct SPIRV_Cross_Output
{
float4 gl_Position : SV_Position;
};
void vert_main()
{
gl_Position = 10.0f.xxxx + vInput1;
}
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
vInput0 = stage_input.vInput0;
vInput1 = stage_input.vInput1;
vert_main();
SPIRV_Cross_Output stage_output;
stage_output.gl_Position = gl_Position;
return stage_output;
}

View File

@ -0,0 +1,23 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_in
{
float4 vB [[user(locn1)]];
float4 vA [[user(locn0)]];
};
struct main0_out
{
float4 FragColor [[color(0)]];
};
fragment main0_out main0(main0_in in [[stage_in]])
{
main0_out out = {};
out.FragColor = fmod(in.vA, in.vB);
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(1.0) + float4(1.0)) + (float3(1.0).xyzz + float4(1.0))) + (float4(1.0) + float4(2.0))) + (float2(1.0).xyxy + float4(2.0));
return out;
}

View File

@ -0,0 +1,123 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct MatrixOut
{
float2x2 m2out;
float3x3 m3out;
float4x4 m4out;
};
struct MatrixIn
{
float2x2 m2in;
float3x3 m3in;
float4x4 m4in;
};
// Returns the determinant of a 2x2 matrix.
inline float spvDet2x2(float a1, float a2, float b1, float b2)
{
return a1 * b2 - b1 * a2;
}
// Returns the determinant of a 3x3 matrix.
inline float spvDet3x3(float a1, float a2, float a3, float b1, float b2, float b3, float c1, float c2, float c3)
{
return a1 * spvDet2x2(b2, b3, c2, c3) - b1 * spvDet2x2(a2, a3, c2, c3) + c1 * spvDet2x2(a2, a3, b2, b3);
}
// Returns the inverse of a matrix, by using the algorithm of calculating the classical
// adjoint and dividing by the determinant. The contents of the matrix are changed.
float4x4 spvInverse4x4(float4x4 m)
{
float4x4 adj; // The adjoint matrix (inverse after dividing by determinant)
// Create the transpose of the cofactors, as the classical adjoint of the matrix.
adj[0][0] = spvDet3x3(m[1][1], m[1][2], m[1][3], m[2][1], m[2][2], m[2][3], m[3][1], m[3][2], m[3][3]);
adj[0][1] = -spvDet3x3(m[0][1], m[0][2], m[0][3], m[2][1], m[2][2], m[2][3], m[3][1], m[3][2], m[3][3]);
adj[0][2] = spvDet3x3(m[0][1], m[0][2], m[0][3], m[1][1], m[1][2], m[1][3], m[3][1], m[3][2], m[3][3]);
adj[0][3] = -spvDet3x3(m[0][1], m[0][2], m[0][3], m[1][1], m[1][2], m[1][3], m[2][1], m[2][2], m[2][3]);
adj[1][0] = -spvDet3x3(m[1][0], m[1][2], m[1][3], m[2][0], m[2][2], m[2][3], m[3][0], m[3][2], m[3][3]);
adj[1][1] = spvDet3x3(m[0][0], m[0][2], m[0][3], m[2][0], m[2][2], m[2][3], m[3][0], m[3][2], m[3][3]);
adj[1][2] = -spvDet3x3(m[0][0], m[0][2], m[0][3], m[1][0], m[1][2], m[1][3], m[3][0], m[3][2], m[3][3]);
adj[1][3] = spvDet3x3(m[0][0], m[0][2], m[0][3], m[1][0], m[1][2], m[1][3], m[2][0], m[2][2], m[2][3]);
adj[2][0] = spvDet3x3(m[1][0], m[1][1], m[1][3], m[2][0], m[2][1], m[2][3], m[3][0], m[3][1], m[3][3]);
adj[2][1] = -spvDet3x3(m[0][0], m[0][1], m[0][3], m[2][0], m[2][1], m[2][3], m[3][0], m[3][1], m[3][3]);
adj[2][2] = spvDet3x3(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[3][0], m[3][1], m[3][3]);
adj[2][3] = -spvDet3x3(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[2][0], m[2][1], m[2][3]);
adj[3][0] = -spvDet3x3(m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], m[2][2], m[3][0], m[3][1], m[3][2]);
adj[3][1] = spvDet3x3(m[0][0], m[0][1], m[0][2], m[2][0], m[2][1], m[2][2], m[3][0], m[3][1], m[3][2]);
adj[3][2] = -spvDet3x3(m[0][0], m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[3][0], m[3][1], m[3][2]);
adj[3][3] = spvDet3x3(m[0][0], m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], m[2][2]);
// Calculate the determinant as a combination of the cofactors of the first row.
float det = (adj[0][0] * m[0][0]) + (adj[0][1] * m[1][0]) + (adj[0][2] * m[2][0]) + (adj[0][3] * m[3][0]);
// Divide the classical adjoint matrix by the determinant.
// If determinant is zero, matrix is not invertable, so leave it unchanged.
return (det != 0.0f) ? (adj * (1.0f / det)) : m;
}
// Returns the inverse of a matrix, by using the algorithm of calculating the classical
// adjoint and dividing by the determinant. The contents of the matrix are changed.
float3x3 spvInverse3x3(float3x3 m)
{
float3x3 adj; // The adjoint matrix (inverse after dividing by determinant)
// Create the transpose of the cofactors, as the classical adjoint of the matrix.
adj[0][0] = spvDet2x2(m[1][1], m[1][2], m[2][1], m[2][2]);
adj[0][1] = -spvDet2x2(m[0][1], m[0][2], m[2][1], m[2][2]);
adj[0][2] = spvDet2x2(m[0][1], m[0][2], m[1][1], m[1][2]);
adj[1][0] = -spvDet2x2(m[1][0], m[1][2], m[2][0], m[2][2]);
adj[1][1] = spvDet2x2(m[0][0], m[0][2], m[2][0], m[2][2]);
adj[1][2] = -spvDet2x2(m[0][0], m[0][2], m[1][0], m[1][2]);
adj[2][0] = spvDet2x2(m[1][0], m[1][1], m[2][0], m[2][1]);
adj[2][1] = -spvDet2x2(m[0][0], m[0][1], m[2][0], m[2][1]);
adj[2][2] = spvDet2x2(m[0][0], m[0][1], m[1][0], m[1][1]);
// Calculate the determinant as a combination of the cofactors of the first row.
float det = (adj[0][0] * m[0][0]) + (adj[0][1] * m[1][0]) + (adj[0][2] * m[2][0]);
// Divide the classical adjoint matrix by the determinant.
// If determinant is zero, matrix is not invertable, so leave it unchanged.
return (det != 0.0f) ? (adj * (1.0f / det)) : m;
}
// Returns the inverse of a matrix, by using the algorithm of calculating the classical
// adjoint and dividing by the determinant. The contents of the matrix are changed.
float2x2 spvInverse2x2(float2x2 m)
{
float2x2 adj; // The adjoint matrix (inverse after dividing by determinant)
// Create the transpose of the cofactors, as the classical adjoint of the matrix.
adj[0][0] = m[1][1];
adj[0][1] = -m[0][1];
adj[1][0] = -m[1][0];
adj[1][1] = m[0][0];
// Calculate the determinant as a combination of the cofactors of the first row.
float det = (adj[0][0] * m[0][0]) + (adj[0][1] * m[1][0]);
// Divide the classical adjoint matrix by the determinant.
// If determinant is zero, matrix is not invertable, so leave it unchanged.
return (det != 0.0f) ? (adj * (1.0f / det)) : m;
}
kernel void main0(device MatrixOut& _15 [[buffer(0)]], device MatrixIn& _20 [[buffer(1)]])
{
_15.m2out = spvInverse2x2(_20.m2in);
_15.m3out = spvInverse3x3(_20.m3in);
_15.m4out = spvInverse4x4(_20.m4in);
}

View File

@ -0,0 +1,29 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct s1
{
int a;
};
struct s2
{
s1 b;
};
struct dstbuffer
{
s2 test[1];
};
constant s2 _31 = {};
kernel void main0(device dstbuffer& _19 [[buffer(0)]])
{
s2 _30 = _31;
_30.b.a = 0;
_19.test[0].b.a = _30.b.a;
}

View File

@ -3,6 +3,8 @@
using namespace metal;
typedef float3x2 packed_float2x3;
struct S0
{
float2 a[1];
@ -58,8 +60,10 @@ struct SSBO1
float3x2 m3;
float2x2 m4;
float2x2 m5[9];
float2x3 m6[4][2];
packed_float2x3 m6[4][2];
char pad10[8];
float3x2 m7;
char pad11[8];
float array[1];
};
@ -96,5 +100,6 @@ kernel void main0(device SSBO1& ssbo_430 [[buffer(0)]], device SSBO0& ssbo_140 [
ssbo_430.content.m3s[5].c = ssbo_140.content.m3s[5].c;
ssbo_430.content.m3s[6].c = ssbo_140.content.m3s[6].c;
ssbo_430.content.m3s[7].c = ssbo_140.content.m3s[7].c;
ssbo_430.content.m1.a = ssbo_430.content.m3.a * ssbo_430.m6[1][1];
}

View File

@ -1,3 +1,5 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
@ -9,6 +11,12 @@ struct Foobar
float b;
};
constant float4 _37[3] = {float4(1.0), float4(2.0), float4(3.0)};
constant float4 _49[2] = {float4(1.0), float4(2.0)};
constant float4 _54[2] = {float4(8.0), float4(10.0)};
constant float4 _55[2][2] = {{float4(1.0), float4(2.0)}, {float4(8.0), float4(10.0)}};
constant Foobar _75[2] = {{10.0, 40.0}, {90.0, 70.0}};
struct main0_in
{
int index [[user(locn0)]];
@ -19,6 +27,20 @@ struct main0_out
float4 FragColor [[color(0)]];
};
// Implementation of an array copy function to cover GLSL's ability to copy an array via assignment.
template<typename T, uint N>
void spvArrayCopy(thread T (&dst)[N], thread const T (&src)[N])
{
for (uint i = 0; i < N; dst[i] = src[i], i++);
}
// An overload for constant arrays.
template<typename T, uint N>
void spvArrayCopyConstant(thread T (&dst)[N], constant T (&src)[N])
{
for (uint i = 0; i < N; dst[i] = src[i], i++);
}
fragment main0_out main0(main0_in in [[stage_in]])
{
main0_out out = {};

View File

@ -1,3 +1,5 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
@ -9,6 +11,9 @@ struct Foo
float b;
};
constant float _16[4] = {1.0, 4.0, 3.0, 2.0};
constant Foo _28[2] = {{10.0, 20.0}, {30.0, 40.0}};
struct main0_in
{
int line [[user(locn0)]];
@ -19,6 +24,20 @@ struct main0_out
float4 FragColor [[color(0)]];
};
// Implementation of an array copy function to cover GLSL's ability to copy an array via assignment.
template<typename T, uint N>
void spvArrayCopy(thread T (&dst)[N], thread const T (&src)[N])
{
for (uint i = 0; i < N; dst[i] = src[i], i++);
}
// An overload for constant arrays.
template<typename T, uint N>
void spvArrayCopyConstant(thread T (&dst)[N], constant T (&src)[N])
{
for (uint i = 0; i < N; dst[i] = src[i], i++);
}
fragment main0_out main0(main0_in in [[stage_in]])
{
main0_out out = {};

View File

@ -0,0 +1,30 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_in
{
float4 vB [[user(locn1)]];
float4 vA [[user(locn0)]];
};
struct main0_out
{
float4 FragColor [[color(0)]];
};
fragment main0_out main0(main0_in in [[stage_in]], bool gl_FrontFacing [[front_facing]])
{
main0_out out = {};
if (gl_FrontFacing)
{
out.FragColor = in.vA;
}
else
{
out.FragColor = in.vB;
}
return out;
}

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(as_type<float>(0x7f800000u), as_type<float>(0xff800000u), as_type<float>(0xffc00000u));
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(texture2d_ms<float> uSubpass0 [[texture(0)]], texture2d_ms<float> uSubpass1 [[texture(1)]], uint gl_SampleID [[sample_id]], float4 gl_FragCoord [[position]])
{
main0_out out = {};
out.FragColor = (uSubpass0.read(uint2(gl_FragCoord.xy), 1) + uSubpass1.read(uint2(gl_FragCoord.xy), 2)) + uSubpass0.read(uint2(gl_FragCoord.xy), gl_SampleID);
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(texture2d<float> uSubpass0 [[texture(0)]], texture2d<float> uSubpass1 [[texture(1)]], float4 gl_FragCoord [[position]])
{
main0_out out = {};
out.FragColor = uSubpass0.read(uint2(gl_FragCoord.xy), 0) + uSubpass1.read(uint2(gl_FragCoord.xy), 0);
return out;
}

View File

@ -0,0 +1,17 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float FragColor [[color(0)]];
};
fragment main0_out main0(depth2d<float> uDepth [[texture(0)]], texture2d<float> uColor [[texture(1)]], sampler uSamplerShadow [[sampler(0)]], sampler uSampler [[sampler(1)]])
{
main0_out out = {};
out.FragColor = uDepth.sample_compare(uSamplerShadow, float3(0.5).xy, 0.5) + uColor.sample(uSampler, float2(0.5)).x;
return out;
}

View File

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

View File

@ -0,0 +1,27 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct SpecConstArray
{
float4 samples[2];
};
struct main0_in
{
int Index [[user(locn0)]];
};
struct main0_out
{
float4 FragColor [[color(0)]];
};
fragment main0_out main0(main0_in in [[stage_in]], constant SpecConstArray& _15 [[buffer(0)]])
{
main0_out out = {};
out.FragColor = _15.samples[in.Index];
return out;
}

View File

@ -75,31 +75,31 @@ inline float spvDet3x3(float a1, float a2, float a3, float b1, float b2, float b
float4x4 spvInverse4x4(float4x4 m)
{
float4x4 adj; // The adjoint matrix (inverse after dividing by determinant)
// Create the transpose of the cofactors, as the classical adjoint of the matrix.
adj[0][0] = spvDet3x3(m[1][1], m[1][2], m[1][3], m[2][1], m[2][2], m[2][3], m[3][1], m[3][2], m[3][3]);
adj[0][1] = -spvDet3x3(m[0][1], m[0][2], m[0][3], m[2][1], m[2][2], m[2][3], m[3][1], m[3][2], m[3][3]);
adj[0][2] = spvDet3x3(m[0][1], m[0][2], m[0][3], m[1][1], m[1][2], m[1][3], m[3][1], m[3][2], m[3][3]);
adj[0][3] = -spvDet3x3(m[0][1], m[0][2], m[0][3], m[1][1], m[1][2], m[1][3], m[2][1], m[2][2], m[2][3]);
adj[1][0] = -spvDet3x3(m[1][0], m[1][2], m[1][3], m[2][0], m[2][2], m[2][3], m[3][0], m[3][2], m[3][3]);
adj[1][1] = spvDet3x3(m[0][0], m[0][2], m[0][3], m[2][0], m[2][2], m[2][3], m[3][0], m[3][2], m[3][3]);
adj[1][2] = -spvDet3x3(m[0][0], m[0][2], m[0][3], m[1][0], m[1][2], m[1][3], m[3][0], m[3][2], m[3][3]);
adj[1][3] = spvDet3x3(m[0][0], m[0][2], m[0][3], m[1][0], m[1][2], m[1][3], m[2][0], m[2][2], m[2][3]);
adj[2][0] = spvDet3x3(m[1][0], m[1][1], m[1][3], m[2][0], m[2][1], m[2][3], m[3][0], m[3][1], m[3][3]);
adj[2][1] = -spvDet3x3(m[0][0], m[0][1], m[0][3], m[2][0], m[2][1], m[2][3], m[3][0], m[3][1], m[3][3]);
adj[2][2] = spvDet3x3(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[3][0], m[3][1], m[3][3]);
adj[2][3] = -spvDet3x3(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[2][0], m[2][1], m[2][3]);
adj[3][0] = -spvDet3x3(m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], m[2][2], m[3][0], m[3][1], m[3][2]);
adj[3][1] = spvDet3x3(m[0][0], m[0][1], m[0][2], m[2][0], m[2][1], m[2][2], m[3][0], m[3][1], m[3][2]);
adj[3][2] = -spvDet3x3(m[0][0], m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[3][0], m[3][1], m[3][2]);
adj[3][3] = spvDet3x3(m[0][0], m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], m[2][2]);
// Calculate the determinant as a combination of the cofactors of the first row.
float det = (adj[0][0] * m[0][0]) + (adj[0][1] * m[1][0]) + (adj[0][2] * m[2][0]) + (adj[0][3] * m[3][0]);
// Divide the classical adjoint matrix by the determinant.
// If determinant is zero, matrix is not invertable, so leave it unchanged.
return (det != 0.0f) ? (adj * (1.0f / det)) : m;

View File

@ -0,0 +1,56 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
typedef float3x4 packed_float4x3;
struct _15
{
packed_float4x3 _m0;
packed_float4x3 _m1;
};
struct _42
{
float4x4 _m0;
float4x4 _m1;
float _m2;
char pad3[12];
packed_float3 _m3;
float _m4;
packed_float3 _m5;
float _m6;
float _m7;
float _m8;
float2 _m9;
};
struct main0_in
{
float4 m_25 [[attribute(0)]];
};
struct main0_out
{
float3 m_72 [[user(locn0)]];
float4 gl_Position [[position]];
};
vertex main0_out main0(main0_in in [[stage_in]], constant _15& _17 [[buffer(0)]], constant _42& _44 [[buffer(1)]])
{
main0_out out = {};
float3 _34;
do
{
_34 = normalize(float4(in.m_25.xyz, 0.0) * _17._m1);
break;
} while (false);
float4 _70 = _44._m0 * float4(_44._m3 + (in.m_25.xyz * (_44._m6 + _44._m7)), 1.0);
out.m_72 = _34;
float4 _95 = _70;
_95.y = -_70.y;
out.gl_Position = _95;
return out;
}

View File

@ -0,0 +1,24 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
constant float4 _20[2] = {float4(10.0), float4(20.0)};
struct main0_in
{
float4 vInput1 [[attribute(1)]];
};
struct main0_out
{
float4 gl_Position [[position]];
};
vertex main0_out main0(main0_in in [[stage_in]])
{
main0_out out = {};
out.gl_Position = float4(10.0) + in.vInput1;
return out;
}

View File

@ -0,0 +1,13 @@
#version 310 es
precision mediump float;
precision highp int;
layout(location = 0) out vec4 FragColor;
layout(location = 0) in vec4 vA;
layout(location = 1) in vec4 vB;
void main()
{
FragColor = vA - vB * trunc(vA / vB);
}

View File

@ -0,0 +1,11 @@
#version 310 es
precision mediump float;
precision highp int;
layout(location = 0) out vec4 FragColor;
void main()
{
FragColor = (((vec4(1.0) + vec4(1.0)) + (vec3(1.0).xyzz + vec4(1.0))) + (vec4(1.0) + vec4(2.0))) + (vec2(1.0).xyxy + vec4(2.0));
}

View File

@ -0,0 +1,13 @@
#version 450
uniform sampler2D SPIRV_Cross_CombinedSampledImageSPIRV_Cross_DummySampler;
uniform sampler2D SPIRV_Cross_CombinedSampledImageSampler;
layout(location = 0) out vec4 _entryPointOutput;
void main()
{
ivec3 _122 = ivec3(int(gl_FragCoord.x * 1280.0), int(gl_FragCoord.y * 720.0), 0);
_entryPointOutput = ((texelFetch(SPIRV_Cross_CombinedSampledImageSPIRV_Cross_DummySampler, _122.xy, 0) + texelFetch(SPIRV_Cross_CombinedSampledImageSPIRV_Cross_DummySampler, _122.xy, 0)) + texture(SPIRV_Cross_CombinedSampledImageSampler, gl_FragCoord.xy)) + texture(SPIRV_Cross_CombinedSampledImageSampler, gl_FragCoord.xy);
}

View File

@ -0,0 +1,14 @@
#version 450
layout(set = 0, binding = 0) uniform sampler Sampler;
layout(set = 0, binding = 0) uniform texture2D SampledImage;
uniform sampler SPIRV_Cross_DummySampler;
layout(location = 0) out vec4 _entryPointOutput;
void main()
{
ivec3 _122 = ivec3(int(gl_FragCoord.x * 1280.0), int(gl_FragCoord.y * 720.0), 0);
_entryPointOutput = ((texelFetch(sampler2D(SampledImage, SPIRV_Cross_DummySampler), _122.xy, 0) + texelFetch(sampler2D(SampledImage, SPIRV_Cross_DummySampler), _122.xy, 0)) + texture(sampler2D(SampledImage, Sampler), gl_FragCoord.xy)) + texture(sampler2D(SampledImage, Sampler), gl_FragCoord.xy);
}

View File

@ -0,0 +1,9 @@
#version 450
invariant gl_Position;
void main()
{
gl_Position = vec4(1.0);
}

View File

@ -0,0 +1,17 @@
#version 450
out gl_PerVertex
{
vec4 gl_Position;
float gl_PointSize;
float gl_ClipDistance[1];
float gl_CullDistance[1];
};
invariant gl_Position;
void main()
{
gl_Position = vec4(1.0);
}

View File

@ -0,0 +1,9 @@
#version 450
invariant gl_Position;
void main()
{
gl_Position = vec4(1.0);
}

View File

@ -0,0 +1,14 @@
#version 450
out gl_PerVertex
{
vec4 gl_Position;
};
invariant gl_Position;
void main()
{
gl_Position = vec4(1.0);
}

View File

@ -0,0 +1,12 @@
#version 450
in float gl_ClipDistance[4];
in float gl_CullDistance[3];
layout(location = 0) out float FragColor;
void main()
{
FragColor = gl_ClipDistance[0] + gl_CullDistance[0];
}

View File

@ -0,0 +1,11 @@
#version 450
#extension GL_ARB_gpu_shader_int64 : require
layout(location = 0) out vec3 FragColor;
layout(location = 0) flat in double vTmp;
void main()
{
FragColor = vec3(dvec3(uint64BitsToDouble(0x7ff0000000000000ul), uint64BitsToDouble(0xfff0000000000000ul), uint64BitsToDouble(0xfff8000000000000ul)) + dvec3(vTmp));
}

View File

@ -0,0 +1,20 @@
#version 450
out gl_PerVertex
{
vec4 gl_Position;
float gl_PointSize;
float gl_ClipDistance[4];
float gl_CullDistance[3];
};
void main()
{
gl_Position = vec4(1.0);
gl_ClipDistance[0] = 0.0;
gl_ClipDistance[1] = 0.0;
gl_ClipDistance[2] = 0.0;
gl_ClipDistance[3] = 0.0;
gl_CullDistance[1] = 4.0;
}

View File

@ -1,11 +1,15 @@
#version 450
out float gl_ClipDistance[4];
out float gl_CullDistance[3];
void main()
{
gl_Position = vec4(10.0);
gl_ClipDistance[0] = 1.0;
gl_ClipDistance[1] = 4.0;
gl_CullDistance[0] = 4.0;
gl_CullDistance[1] = 9.0;
gl_Position = vec4(1.0);
gl_ClipDistance[0] = 0.0;
gl_ClipDistance[1] = 0.0;
gl_ClipDistance[2] = 0.0;
gl_ClipDistance[3] = 0.0;
gl_CullDistance[1] = 4.0;
}

View File

@ -0,0 +1,20 @@
#version 310 es
precision mediump float;
precision highp int;
layout(location = 0) out vec4 FragColor;
layout(location = 0) in vec4 vA;
layout(location = 1) in vec4 vB;
void main()
{
if (gl_FrontFacing)
{
FragColor = vA;
}
else
{
FragColor = vB;
}
}

View File

@ -0,0 +1,37 @@
#version 310 es
precision mediump float;
precision highp int;
layout(location = 0) out vec4 FragColor;
layout(location = 0) flat in mediump int vA;
layout(location = 1) flat in mediump int vB;
void main()
{
FragColor = vec4(0.0);
mediump int _49;
int _60;
for (int _57 = 0, _58 = 0; _58 < vA; _57 = _60, _58 += _49)
{
if ((vA + _58) == 20)
{
_60 = 50;
}
else
{
int _59;
if ((vB + _58) == 40)
{
_59 = 60;
}
else
{
_59 = _57;
}
_60 = _59;
}
_49 = _60 + 10;
FragColor += vec4(1.0);
}
}

View File

@ -0,0 +1,11 @@
#version 310 es
precision mediump float;
precision highp int;
layout(location = 0) out highp vec3 FragColor;
void main()
{
FragColor = vec3(uintBitsToFloat(0x7f800000u), uintBitsToFloat(0xff800000u), uintBitsToFloat(0xffc00000u));
}

View File

@ -0,0 +1,9 @@
#version 310 es
layout(location = 1) in vec4 vInput1;
void main()
{
gl_Position = vec4(10.0) + vInput1;
}

View File

@ -0,0 +1,17 @@
#version 310 es
precision mediump float;
precision highp int;
layout(binding = 0, std140) uniform SpecConstArray
{
vec4 samples[2];
} _15;
layout(location = 0) out vec4 FragColor;
layout(location = 0) flat in mediump int Index;
void main()
{
FragColor = _15.samples[Index];
}

View File

@ -0,0 +1,19 @@
#version 310 es
precision mediump float;
precision highp int;
layout(constant_id = 10) const int Value = 2;
layout(set = 0, binding = 0, std140) uniform SpecConstArray
{
vec4 samples[Value];
} _15;
layout(location = 0) out vec4 FragColor;
layout(location = 0) flat in mediump int Index;
void main()
{
FragColor = _15.samples[Index];
}

View File

@ -0,0 +1,29 @@
static float4 FragColor;
static float4 vA;
static float4 vB;
struct SPIRV_Cross_Input
{
float4 vA : TEXCOORD0;
float4 vB : TEXCOORD1;
};
struct SPIRV_Cross_Output
{
float4 FragColor : SV_Target0;
};
void frag_main()
{
FragColor = fmod(vA, vB);
}
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
vA = stage_input.vA;
vB = stage_input.vB;
frag_main();
SPIRV_Cross_Output stage_output;
stage_output.FragColor = FragColor;
return stage_output;
}

View File

@ -0,0 +1,47 @@
static float4 FragColor;
struct SPIRV_Cross_Output
{
float4 FragColor : SV_Target0;
};
float4 foo(float4 foo_1)
{
return foo_1 + 1.0f.xxxx;
}
float4 foo(float3 foo_1)
{
return foo_1.xyzz + 1.0f.xxxx;
}
float4 foo_1(float4 foo_2)
{
return foo_2 + 2.0f.xxxx;
}
float4 foo(float2 foo_2)
{
return foo_2.xyxy + 2.0f.xxxx;
}
void frag_main()
{
float4 foo_3 = 1.0f.xxxx;
float4 foo_2 = foo(foo_3);
float3 foo_5 = 1.0f.xxx;
float4 foo_4 = foo(foo_5);
float4 foo_7 = 1.0f.xxxx;
float4 foo_6 = foo_1(foo_7);
float2 foo_9 = 1.0f.xx;
float4 foo_8 = foo(foo_9);
FragColor = ((foo_2 + foo_4) + foo_6) + foo_8;
}
SPIRV_Cross_Output main()
{
frag_main();
SPIRV_Cross_Output stage_output;
stage_output.FragColor = FragColor;
return stage_output;
}

View File

@ -0,0 +1,122 @@
RWByteAddressBuffer _15 : register(u0);
ByteAddressBuffer _20 : register(t1);
// Returns the inverse of a matrix, by using the algorithm of calculating the classical
// adjoint and dividing by the determinant. The contents of the matrix are changed.
float2x2 SPIRV_Cross_Inverse(float2x2 m)
{
float2x2 adj; // The adjoint matrix (inverse after dividing by determinant)
// Create the transpose of the cofactors, as the classical adjoint of the matrix.
adj[0][0] = m[1][1];
adj[0][1] = -m[0][1];
adj[1][0] = -m[1][0];
adj[1][1] = m[0][0];
// Calculate the determinant as a combination of the cofactors of the first row.
float det = (adj[0][0] * m[0][0]) + (adj[0][1] * m[1][0]);
// Divide the classical adjoint matrix by the determinant.
// If determinant is zero, matrix is not invertable, so leave it unchanged.
return (det != 0.0f) ? (adj * (1.0f / det)) : m;
}
// Returns the determinant of a 2x2 matrix.
float SPIRV_Cross_Det2x2(float a1, float a2, float b1, float b2)
{
return a1 * b2 - b1 * a2;
}
// Returns the inverse of a matrix, by using the algorithm of calculating the classical
// adjoint and dividing by the determinant. The contents of the matrix are changed.
float3x3 SPIRV_Cross_Inverse(float3x3 m)
{
float3x3 adj; // The adjoint matrix (inverse after dividing by determinant)
// Create the transpose of the cofactors, as the classical adjoint of the matrix.
adj[0][0] = SPIRV_Cross_Det2x2(m[1][1], m[1][2], m[2][1], m[2][2]);
adj[0][1] = -SPIRV_Cross_Det2x2(m[0][1], m[0][2], m[2][1], m[2][2]);
adj[0][2] = SPIRV_Cross_Det2x2(m[0][1], m[0][2], m[1][1], m[1][2]);
adj[1][0] = -SPIRV_Cross_Det2x2(m[1][0], m[1][2], m[2][0], m[2][2]);
adj[1][1] = SPIRV_Cross_Det2x2(m[0][0], m[0][2], m[2][0], m[2][2]);
adj[1][2] = -SPIRV_Cross_Det2x2(m[0][0], m[0][2], m[1][0], m[1][2]);
adj[2][0] = SPIRV_Cross_Det2x2(m[1][0], m[1][1], m[2][0], m[2][1]);
adj[2][1] = -SPIRV_Cross_Det2x2(m[0][0], m[0][1], m[2][0], m[2][1]);
adj[2][2] = SPIRV_Cross_Det2x2(m[0][0], m[0][1], m[1][0], m[1][1]);
// Calculate the determinant as a combination of the cofactors of the first row.
float det = (adj[0][0] * m[0][0]) + (adj[0][1] * m[1][0]) + (adj[0][2] * m[2][0]);
// Divide the classical adjoint matrix by the determinant.
// If determinant is zero, matrix is not invertable, so leave it unchanged.
return (det != 0.0f) ? (adj * (1.0f / det)) : m;
}
// Returns the determinant of a 3x3 matrix.
float SPIRV_Cross_Det3x3(float a1, float a2, float a3, float b1, float b2, float b3, float c1, float c2, float c3)
{
return a1 * SPIRV_Cross_Det2x2(b2, b3, c2, c3) - b1 * SPIRV_Cross_Det2x2(a2, a3, c2, c3) + c1 * SPIRV_Cross_Det2x2(a2, a3, b2, b3);
}
// Returns the inverse of a matrix, by using the algorithm of calculating the classical
// adjoint and dividing by the determinant. The contents of the matrix are changed.
float4x4 SPIRV_Cross_Inverse(float4x4 m)
{
float4x4 adj; // The adjoint matrix (inverse after dividing by determinant)
// Create the transpose of the cofactors, as the classical adjoint of the matrix.
adj[0][0] = SPIRV_Cross_Det3x3(m[1][1], m[1][2], m[1][3], m[2][1], m[2][2], m[2][3], m[3][1], m[3][2], m[3][3]);
adj[0][1] = -SPIRV_Cross_Det3x3(m[0][1], m[0][2], m[0][3], m[2][1], m[2][2], m[2][3], m[3][1], m[3][2], m[3][3]);
adj[0][2] = SPIRV_Cross_Det3x3(m[0][1], m[0][2], m[0][3], m[1][1], m[1][2], m[1][3], m[3][1], m[3][2], m[3][3]);
adj[0][3] = -SPIRV_Cross_Det3x3(m[0][1], m[0][2], m[0][3], m[1][1], m[1][2], m[1][3], m[2][1], m[2][2], m[2][3]);
adj[1][0] = -SPIRV_Cross_Det3x3(m[1][0], m[1][2], m[1][3], m[2][0], m[2][2], m[2][3], m[3][0], m[3][2], m[3][3]);
adj[1][1] = SPIRV_Cross_Det3x3(m[0][0], m[0][2], m[0][3], m[2][0], m[2][2], m[2][3], m[3][0], m[3][2], m[3][3]);
adj[1][2] = -SPIRV_Cross_Det3x3(m[0][0], m[0][2], m[0][3], m[1][0], m[1][2], m[1][3], m[3][0], m[3][2], m[3][3]);
adj[1][3] = SPIRV_Cross_Det3x3(m[0][0], m[0][2], m[0][3], m[1][0], m[1][2], m[1][3], m[2][0], m[2][2], m[2][3]);
adj[2][0] = SPIRV_Cross_Det3x3(m[1][0], m[1][1], m[1][3], m[2][0], m[2][1], m[2][3], m[3][0], m[3][1], m[3][3]);
adj[2][1] = -SPIRV_Cross_Det3x3(m[0][0], m[0][1], m[0][3], m[2][0], m[2][1], m[2][3], m[3][0], m[3][1], m[3][3]);
adj[2][2] = SPIRV_Cross_Det3x3(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[3][0], m[3][1], m[3][3]);
adj[2][3] = -SPIRV_Cross_Det3x3(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[2][0], m[2][1], m[2][3]);
adj[3][0] = -SPIRV_Cross_Det3x3(m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], m[2][2], m[3][0], m[3][1], m[3][2]);
adj[3][1] = SPIRV_Cross_Det3x3(m[0][0], m[0][1], m[0][2], m[2][0], m[2][1], m[2][2], m[3][0], m[3][1], m[3][2]);
adj[3][2] = -SPIRV_Cross_Det3x3(m[0][0], m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[3][0], m[3][1], m[3][2]);
adj[3][3] = SPIRV_Cross_Det3x3(m[0][0], m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], m[2][2]);
// Calculate the determinant as a combination of the cofactors of the first row.
float det = (adj[0][0] * m[0][0]) + (adj[0][1] * m[1][0]) + (adj[0][2] * m[2][0]) + (adj[0][3] * m[3][0]);
// Divide the classical adjoint matrix by the determinant.
// If determinant is zero, matrix is not invertable, so leave it unchanged.
return (det != 0.0f) ? (adj * (1.0f / det)) : m;
}
void comp_main()
{
float2x2 _23 = asfloat(uint2x2(_20.Load2(0), _20.Load2(8)));
float2x2 _24 = SPIRV_Cross_Inverse(_23);
_15.Store2(0, asuint(_24[0]));
_15.Store2(8, asuint(_24[1]));
float3x3 _29 = asfloat(uint3x3(_20.Load3(16), _20.Load3(32), _20.Load3(48)));
float3x3 _30 = SPIRV_Cross_Inverse(_29);
_15.Store3(16, asuint(_30[0]));
_15.Store3(32, asuint(_30[1]));
_15.Store3(48, asuint(_30[2]));
float4x4 _35 = asfloat(uint4x4(_20.Load4(64), _20.Load4(80), _20.Load4(96), _20.Load4(112)));
float4x4 _36 = SPIRV_Cross_Inverse(_35);
_15.Store4(64, asuint(_36[0]));
_15.Store4(80, asuint(_36[1]));
_15.Store4(96, asuint(_36[2]));
_15.Store4(112, asuint(_36[3]));
}
[numthreads(1, 1, 1)]
void main()
{
comp_main();
}

View File

@ -0,0 +1,16 @@
RWByteAddressBuffer _10 : register(u0);
cbuffer SPIRV_Cross_NumWorkgroups : register(b0)
{
uint3 SPIRV_Cross_NumWorkgroups_count : packoffset(c0);
};
void comp_main()
{
_10.Store3(0, SPIRV_Cross_NumWorkgroups_count);
}
[numthreads(1, 1, 1)]
void main()
{
comp_main();
}

View File

@ -0,0 +1,23 @@
RWByteAddressBuffer _10 : register(u0);
cbuffer SPIRV_Cross_NumWorkgroups : register(b0)
{
uint3 SPIRV_Cross_NumWorkgroups_count : packoffset(c0);
};
static uint3 gl_WorkGroupID;
struct SPIRV_Cross_Input
{
uint3 gl_WorkGroupID : SV_GroupID;
};
void comp_main()
{
_10.Store3(0, SPIRV_Cross_NumWorkgroups_count + gl_WorkGroupID);
}
[numthreads(1, 1, 1)]
void main(SPIRV_Cross_Input stage_input)
{
gl_WorkGroupID = stage_input.gl_WorkGroupID;
comp_main();
}

View File

@ -0,0 +1,30 @@
static float gl_ClipDistance[2];
static float gl_CullDistance[1];
static float FragColor;
struct SPIRV_Cross_Input
{
float2 gl_ClipDistance0 : SV_ClipDistance0;
float gl_CullDistance0 : SV_CullDistance0;
};
struct SPIRV_Cross_Output
{
float FragColor : SV_Target0;
};
void frag_main()
{
FragColor = (gl_ClipDistance[0] + gl_CullDistance[0]) + gl_ClipDistance[1];
}
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
gl_ClipDistance[0] = stage_input.gl_ClipDistance0.x;
gl_ClipDistance[1] = stage_input.gl_ClipDistance0.y;
gl_CullDistance[0] = stage_input.gl_CullDistance0.x;
frag_main();
SPIRV_Cross_Output stage_output;
stage_output.FragColor = FragColor;
return stage_output;
}

View File

@ -0,0 +1,39 @@
static bool gl_FrontFacing;
static float4 FragColor;
static float4 vA;
static float4 vB;
struct SPIRV_Cross_Input
{
float4 vA : TEXCOORD0;
float4 vB : TEXCOORD1;
bool gl_FrontFacing : SV_IsFrontFace;
};
struct SPIRV_Cross_Output
{
float4 FragColor : SV_Target0;
};
void frag_main()
{
if (gl_FrontFacing)
{
FragColor = vA;
}
else
{
FragColor = vB;
}
}
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
gl_FrontFacing = stage_input.gl_FrontFacing;
vA = stage_input.vA;
vB = stage_input.vB;
frag_main();
SPIRV_Cross_Output stage_output;
stage_output.FragColor = FragColor;
return stage_output;
}

View File

@ -0,0 +1,19 @@
static float3 FragColor;
struct SPIRV_Cross_Output
{
float3 FragColor : SV_Target0;
};
void frag_main()
{
FragColor = float3(asfloat(0x7f800000u), asfloat(0xff800000u), asfloat(0xffc00000u));
}
SPIRV_Cross_Output main()
{
frag_main();
SPIRV_Cross_Output stage_output;
stage_output.FragColor = FragColor;
return stage_output;
}

View File

@ -0,0 +1,37 @@
Texture2DMS<float4> uSubpass0 : register(t0);
Texture2DMS<float4> uSubpass1 : register(t1);
static float4 gl_FragCoord;
static int gl_SampleID;
static float4 FragColor;
struct SPIRV_Cross_Input
{
float4 gl_FragCoord : SV_Position;
uint gl_SampleID : SV_SampleIndex;
};
struct SPIRV_Cross_Output
{
float4 FragColor : SV_Target0;
};
float4 load_subpasses(Texture2DMS<float4> uInput)
{
return uInput.Load(int2(gl_FragCoord.xy), gl_SampleID);
}
void frag_main()
{
FragColor = (uSubpass0.Load(int2(gl_FragCoord.xy), 1) + uSubpass1.Load(int2(gl_FragCoord.xy), 2)) + load_subpasses(uSubpass0);
}
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
gl_FragCoord = stage_input.gl_FragCoord;
gl_SampleID = stage_input.gl_SampleID;
frag_main();
SPIRV_Cross_Output stage_output;
stage_output.FragColor = FragColor;
return stage_output;
}

View File

@ -0,0 +1,34 @@
Texture2D<float4> uSubpass0 : register(t0);
Texture2D<float4> uSubpass1 : register(t1);
static float4 gl_FragCoord;
static float4 FragColor;
struct SPIRV_Cross_Input
{
float4 gl_FragCoord : SV_Position;
};
struct SPIRV_Cross_Output
{
float4 FragColor : SV_Target0;
};
float4 load_subpasses(Texture2D<float4> uInput)
{
return uInput.Load(int3(int2(gl_FragCoord.xy), 0));
}
void frag_main()
{
FragColor = uSubpass0.Load(int3(int2(gl_FragCoord.xy), 0)) + load_subpasses(uSubpass1);
}
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
gl_FragCoord = stage_input.gl_FragCoord;
frag_main();
SPIRV_Cross_Output stage_output;
stage_output.FragColor = FragColor;
return stage_output;
}

View File

@ -0,0 +1,19 @@
static float2 FragColor;
struct SPIRV_Cross_Output
{
float2 FragColor : SV_Target0;
};
void frag_main()
{
FragColor = float2(0.5f, 0.5f);
}
SPIRV_Cross_Output main()
{
frag_main();
SPIRV_Cross_Output stage_output;
stage_output.FragColor = FragColor;
return stage_output;
}

View File

@ -0,0 +1,33 @@
static const int Value = 2;
cbuffer _15 : register(b0)
{
float4 _15_samples[Value] : packoffset(c0);
};
static float4 FragColor;
static int Index;
struct SPIRV_Cross_Input
{
nointerpolation int Index : TEXCOORD0;
};
struct SPIRV_Cross_Output
{
float4 FragColor : SV_Target0;
};
void frag_main()
{
FragColor = _15_samples[Index];
}
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
Index = stage_input.Index;
frag_main();
SPIRV_Cross_Output stage_output;
stage_output.FragColor = FragColor;
return stage_output;
}

View File

@ -0,0 +1,28 @@
static float4 gl_Position;
static float gl_ClipDistance[2];
static float gl_CullDistance[1];
struct SPIRV_Cross_Output
{
float4 gl_Position : SV_Position;
float2 gl_ClipDistance0 : SV_ClipDistance0;
float gl_CullDistance0 : SV_CullDistance0;
};
void vert_main()
{
gl_Position = 1.0f.xxxx;
gl_ClipDistance[0] = 0.0f;
gl_ClipDistance[1] = 0.0f;
gl_CullDistance[0] = 4.0f;
}
SPIRV_Cross_Output main()
{
vert_main();
SPIRV_Cross_Output stage_output;
stage_output.gl_Position = gl_Position;
stage_output.gl_ClipDistance0.x = gl_ClipDistance[0];
stage_output.gl_ClipDistance0.y = gl_ClipDistance[1];
stage_output.gl_CullDistance0.x = gl_CullDistance[0];
return stage_output;
}

View File

@ -8,7 +8,7 @@ struct SPIRV_Cross_Output
void vert_main()
{
gl_Position = 1.0f.xxxx;
gl_PointSize = 10.0f;
gl_PointSize = 1.0f;
}
SPIRV_Cross_Output main()

View File

@ -0,0 +1,48 @@
static const float4 _20[2] = { 10.0f.xxxx, 20.0f.xxxx };
static float4 gl_Position;
static float4 vInput0;
static float4 vInput1;
struct SPIRV_Cross_Input
{
float4 vInput0 : TEXCOORD0;
float4 vInput1 : TEXCOORD1;
};
struct SPIRV_Cross_Output
{
float4 gl_Position : SV_Position;
};
void test(out float4 SPIRV_Cross_return_value[2])
{
SPIRV_Cross_return_value = _20;
}
void test2(out float4 SPIRV_Cross_return_value[2])
{
float4 foobar[2];
foobar[0] = vInput0;
foobar[1] = vInput1;
SPIRV_Cross_return_value = foobar;
}
void vert_main()
{
float4 _42[2];
test(_42);
float4 _44[2];
test2(_44);
gl_Position = _42[0] + _44[1];
}
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
vInput0 = stage_input.vInput0;
vInput1 = stage_input.vInput1;
vert_main();
SPIRV_Cross_Output stage_output;
stage_output.gl_Position = gl_Position;
return stage_output;
}

View File

@ -0,0 +1,23 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_in
{
float4 vB [[user(locn1)]];
float4 vA [[user(locn0)]];
};
struct main0_out
{
float4 FragColor [[color(0)]];
};
fragment main0_out main0(main0_in in [[stage_in]])
{
main0_out out = {};
out.FragColor = fmod(in.vA, in.vB);
return out;
}

View File

@ -0,0 +1,47 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 FragColor [[color(0)]];
};
float4 foo(thread const float4& foo_1)
{
return foo_1 + float4(1.0);
}
float4 foo(thread const float3& foo_1)
{
return foo_1.xyzz + float4(1.0);
}
float4 foo_1(thread const float4& foo_2)
{
return foo_2 + float4(2.0);
}
float4 foo(thread const float2& foo_2)
{
return foo_2.xyxy + float4(2.0);
}
fragment main0_out main0()
{
main0_out out = {};
float4 foo_3 = float4(1.0);
float4 foo_2 = foo(foo_3);
float3 foo_5 = float3(1.0);
float4 foo_4 = foo(foo_5);
float4 foo_7 = float4(1.0);
float4 foo_6 = foo_1(foo_7);
float2 foo_9 = float2(1.0);
float4 foo_8 = foo(foo_9);
out.FragColor = ((foo_2 + foo_4) + foo_6) + foo_8;
return out;
}

View File

@ -1,3 +1,5 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
@ -9,11 +11,27 @@ struct D
float b;
};
constant float4 _14[4] = {float4(0.0), float4(0.0), float4(0.0), float4(0.0)};
struct main0_out
{
float FragColor [[color(0)]];
};
// Implementation of an array copy function to cover GLSL's ability to copy an array via assignment.
template<typename T, uint N>
void spvArrayCopy(thread T (&dst)[N], thread const T (&src)[N])
{
for (uint i = 0; i < N; dst[i] = src[i], i++);
}
// An overload for constant arrays.
template<typename T, uint N>
void spvArrayCopyConstant(thread T (&dst)[N], constant T (&src)[N])
{
for (uint i = 0; i < N; dst[i] = src[i], i++);
}
fragment main0_out main0()
{
main0_out out = {};

View File

@ -0,0 +1,123 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct MatrixOut
{
float2x2 m2out;
float3x3 m3out;
float4x4 m4out;
};
struct MatrixIn
{
float2x2 m2in;
float3x3 m3in;
float4x4 m4in;
};
// Returns the determinant of a 2x2 matrix.
inline float spvDet2x2(float a1, float a2, float b1, float b2)
{
return a1 * b2 - b1 * a2;
}
// Returns the determinant of a 3x3 matrix.
inline float spvDet3x3(float a1, float a2, float a3, float b1, float b2, float b3, float c1, float c2, float c3)
{
return a1 * spvDet2x2(b2, b3, c2, c3) - b1 * spvDet2x2(a2, a3, c2, c3) + c1 * spvDet2x2(a2, a3, b2, b3);
}
// Returns the inverse of a matrix, by using the algorithm of calculating the classical
// adjoint and dividing by the determinant. The contents of the matrix are changed.
float4x4 spvInverse4x4(float4x4 m)
{
float4x4 adj; // The adjoint matrix (inverse after dividing by determinant)
// Create the transpose of the cofactors, as the classical adjoint of the matrix.
adj[0][0] = spvDet3x3(m[1][1], m[1][2], m[1][3], m[2][1], m[2][2], m[2][3], m[3][1], m[3][2], m[3][3]);
adj[0][1] = -spvDet3x3(m[0][1], m[0][2], m[0][3], m[2][1], m[2][2], m[2][3], m[3][1], m[3][2], m[3][3]);
adj[0][2] = spvDet3x3(m[0][1], m[0][2], m[0][3], m[1][1], m[1][2], m[1][3], m[3][1], m[3][2], m[3][3]);
adj[0][3] = -spvDet3x3(m[0][1], m[0][2], m[0][3], m[1][1], m[1][2], m[1][3], m[2][1], m[2][2], m[2][3]);
adj[1][0] = -spvDet3x3(m[1][0], m[1][2], m[1][3], m[2][0], m[2][2], m[2][3], m[3][0], m[3][2], m[3][3]);
adj[1][1] = spvDet3x3(m[0][0], m[0][2], m[0][3], m[2][0], m[2][2], m[2][3], m[3][0], m[3][2], m[3][3]);
adj[1][2] = -spvDet3x3(m[0][0], m[0][2], m[0][3], m[1][0], m[1][2], m[1][3], m[3][0], m[3][2], m[3][3]);
adj[1][3] = spvDet3x3(m[0][0], m[0][2], m[0][3], m[1][0], m[1][2], m[1][3], m[2][0], m[2][2], m[2][3]);
adj[2][0] = spvDet3x3(m[1][0], m[1][1], m[1][3], m[2][0], m[2][1], m[2][3], m[3][0], m[3][1], m[3][3]);
adj[2][1] = -spvDet3x3(m[0][0], m[0][1], m[0][3], m[2][0], m[2][1], m[2][3], m[3][0], m[3][1], m[3][3]);
adj[2][2] = spvDet3x3(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[3][0], m[3][1], m[3][3]);
adj[2][3] = -spvDet3x3(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[2][0], m[2][1], m[2][3]);
adj[3][0] = -spvDet3x3(m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], m[2][2], m[3][0], m[3][1], m[3][2]);
adj[3][1] = spvDet3x3(m[0][0], m[0][1], m[0][2], m[2][0], m[2][1], m[2][2], m[3][0], m[3][1], m[3][2]);
adj[3][2] = -spvDet3x3(m[0][0], m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[3][0], m[3][1], m[3][2]);
adj[3][3] = spvDet3x3(m[0][0], m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], m[2][2]);
// Calculate the determinant as a combination of the cofactors of the first row.
float det = (adj[0][0] * m[0][0]) + (adj[0][1] * m[1][0]) + (adj[0][2] * m[2][0]) + (adj[0][3] * m[3][0]);
// Divide the classical adjoint matrix by the determinant.
// If determinant is zero, matrix is not invertable, so leave it unchanged.
return (det != 0.0f) ? (adj * (1.0f / det)) : m;
}
// Returns the inverse of a matrix, by using the algorithm of calculating the classical
// adjoint and dividing by the determinant. The contents of the matrix are changed.
float3x3 spvInverse3x3(float3x3 m)
{
float3x3 adj; // The adjoint matrix (inverse after dividing by determinant)
// Create the transpose of the cofactors, as the classical adjoint of the matrix.
adj[0][0] = spvDet2x2(m[1][1], m[1][2], m[2][1], m[2][2]);
adj[0][1] = -spvDet2x2(m[0][1], m[0][2], m[2][1], m[2][2]);
adj[0][2] = spvDet2x2(m[0][1], m[0][2], m[1][1], m[1][2]);
adj[1][0] = -spvDet2x2(m[1][0], m[1][2], m[2][0], m[2][2]);
adj[1][1] = spvDet2x2(m[0][0], m[0][2], m[2][0], m[2][2]);
adj[1][2] = -spvDet2x2(m[0][0], m[0][2], m[1][0], m[1][2]);
adj[2][0] = spvDet2x2(m[1][0], m[1][1], m[2][0], m[2][1]);
adj[2][1] = -spvDet2x2(m[0][0], m[0][1], m[2][0], m[2][1]);
adj[2][2] = spvDet2x2(m[0][0], m[0][1], m[1][0], m[1][1]);
// Calculate the determinant as a combination of the cofactors of the first row.
float det = (adj[0][0] * m[0][0]) + (adj[0][1] * m[1][0]) + (adj[0][2] * m[2][0]);
// Divide the classical adjoint matrix by the determinant.
// If determinant is zero, matrix is not invertable, so leave it unchanged.
return (det != 0.0f) ? (adj * (1.0f / det)) : m;
}
// Returns the inverse of a matrix, by using the algorithm of calculating the classical
// adjoint and dividing by the determinant. The contents of the matrix are changed.
float2x2 spvInverse2x2(float2x2 m)
{
float2x2 adj; // The adjoint matrix (inverse after dividing by determinant)
// Create the transpose of the cofactors, as the classical adjoint of the matrix.
adj[0][0] = m[1][1];
adj[0][1] = -m[0][1];
adj[1][0] = -m[1][0];
adj[1][1] = m[0][0];
// Calculate the determinant as a combination of the cofactors of the first row.
float det = (adj[0][0] * m[0][0]) + (adj[0][1] * m[1][0]);
// Divide the classical adjoint matrix by the determinant.
// If determinant is zero, matrix is not invertable, so leave it unchanged.
return (det != 0.0f) ? (adj * (1.0f / det)) : m;
}
kernel void main0(device MatrixOut& _15 [[buffer(0)]], device MatrixIn& _20 [[buffer(1)]])
{
_15.m2out = spvInverse2x2(_20.m2in);
_15.m3out = spvInverse3x3(_20.m3in);
_15.m4out = spvInverse4x4(_20.m4in);
}

View File

@ -0,0 +1,27 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct s1
{
int a;
};
struct s2
{
s1 b;
};
struct dstbuffer
{
s2 test[1];
};
kernel void main0(device dstbuffer& _19 [[buffer(0)]])
{
s2 testVal;
testVal.b.a = 0;
_19.test[0].b.a = testVal.b.a;
}

View File

@ -3,6 +3,8 @@
using namespace metal;
typedef float3x2 packed_float2x3;
struct S0
{
float2 a[1];
@ -58,8 +60,10 @@ struct SSBO1
float3x2 m3;
float2x2 m4;
float2x2 m5[9];
float2x3 m6[4][2];
packed_float2x3 m6[4][2];
char pad10[8];
float3x2 m7;
char pad11[8];
float array[1];
};
@ -96,5 +100,6 @@ kernel void main0(device SSBO1& ssbo_430 [[buffer(0)]], device SSBO0& ssbo_140 [
ssbo_430.content.m3s[5].c = ssbo_140.content.m3s[5].c;
ssbo_430.content.m3s[6].c = ssbo_140.content.m3s[6].c;
ssbo_430.content.m3s[7].c = ssbo_140.content.m3s[7].c;
ssbo_430.content.m1.a = ssbo_430.content.m3.a * ssbo_430.m6[1][1];
}

View File

@ -11,6 +11,12 @@ struct Foobar
float b;
};
constant float4 _37[3] = {float4(1.0), float4(2.0), float4(3.0)};
constant float4 _49[2] = {float4(1.0), float4(2.0)};
constant float4 _54[2] = {float4(8.0), float4(10.0)};
constant float4 _55[2][2] = {{float4(1.0), float4(2.0)}, {float4(8.0), float4(10.0)}};
constant Foobar _75[2] = {{10.0, 40.0}, {90.0, 70.0}};
struct main0_in
{
int index [[user(locn0)]];
@ -21,6 +27,20 @@ struct main0_out
float4 FragColor [[color(0)]];
};
// Implementation of an array copy function to cover GLSL's ability to copy an array via assignment.
template<typename T, uint N>
void spvArrayCopy(thread T (&dst)[N], thread const T (&src)[N])
{
for (uint i = 0; i < N; dst[i] = src[i], i++);
}
// An overload for constant arrays.
template<typename T, uint N>
void spvArrayCopyConstant(thread T (&dst)[N], constant T (&src)[N])
{
for (uint i = 0; i < N; dst[i] = src[i], i++);
}
float4 resolve(thread const Foobar& f)
{
return float4(f.a + f.b);

View File

@ -1,3 +1,5 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
@ -9,6 +11,9 @@ struct Foo
float b;
};
constant float _16[4] = {1.0, 4.0, 3.0, 2.0};
constant Foo _28[2] = {{10.0, 20.0}, {30.0, 40.0}};
struct main0_in
{
int line [[user(locn0)]];
@ -19,6 +24,20 @@ struct main0_out
float4 FragColor [[color(0)]];
};
// Implementation of an array copy function to cover GLSL's ability to copy an array via assignment.
template<typename T, uint N>
void spvArrayCopy(thread T (&dst)[N], thread const T (&src)[N])
{
for (uint i = 0; i < N; dst[i] = src[i], i++);
}
// An overload for constant arrays.
template<typename T, uint N>
void spvArrayCopyConstant(thread T (&dst)[N], constant T (&src)[N])
{
for (uint i = 0; i < N; dst[i] = src[i], i++);
}
fragment main0_out main0(main0_in in [[stage_in]])
{
main0_out out = {};

View File

@ -0,0 +1,30 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_in
{
float4 vB [[user(locn1)]];
float4 vA [[user(locn0)]];
};
struct main0_out
{
float4 FragColor [[color(0)]];
};
fragment main0_out main0(main0_in in [[stage_in]], bool gl_FrontFacing [[front_facing]])
{
main0_out out = {};
if (gl_FrontFacing)
{
out.FragColor = in.vA;
}
else
{
out.FragColor = in.vB;
}
return out;
}

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(as_type<float>(0x7f800000u), as_type<float>(0xff800000u), as_type<float>(0xffc00000u));
return out;
}

View File

@ -0,0 +1,24 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 FragColor [[color(0)]];
};
float4 load_subpasses(thread const texture2d_ms<float> uInput, thread uint& gl_SampleID, thread float4& gl_FragCoord)
{
return uInput.read(uint2(gl_FragCoord.xy), gl_SampleID);
}
fragment main0_out main0(texture2d_ms<float> uSubpass0 [[texture(0)]], texture2d_ms<float> uSubpass1 [[texture(1)]], uint gl_SampleID [[sample_id]], float4 gl_FragCoord [[position]])
{
main0_out out = {};
out.FragColor = (uSubpass0.read(uint2(gl_FragCoord.xy), 1) + uSubpass1.read(uint2(gl_FragCoord.xy), 2)) + load_subpasses(uSubpass0, gl_SampleID, gl_FragCoord);
return out;
}

View File

@ -0,0 +1,24 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 FragColor [[color(0)]];
};
float4 load_subpasses(thread const texture2d<float> uInput, thread float4& gl_FragCoord)
{
return uInput.read(uint2(gl_FragCoord.xy), 0);
}
fragment main0_out main0(texture2d<float> uSubpass0 [[texture(0)]], texture2d<float> uSubpass1 [[texture(1)]], float4 gl_FragCoord [[position]])
{
main0_out out = {};
out.FragColor = uSubpass0.read(uint2(gl_FragCoord.xy), 0) + load_subpasses(uSubpass1, gl_FragCoord);
return out;
}

View File

@ -0,0 +1,29 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float FragColor [[color(0)]];
};
float sample_depth_from_function(thread const depth2d<float> uT, thread const sampler uS)
{
return uT.sample_compare(uS, float3(0.5).xy, float3(0.5).z);
}
float sample_color_from_function(thread const texture2d<float> uT, thread const sampler uS)
{
return uT.sample(uS, float2(0.5)).x;
}
fragment main0_out main0(depth2d<float> uDepth [[texture(0)]], texture2d<float> uColor [[texture(1)]], sampler uSamplerShadow [[sampler(0)]], sampler uSampler [[sampler(1)]])
{
main0_out out = {};
out.FragColor = sample_depth_from_function(uDepth, uSamplerShadow) + sample_color_from_function(uColor, uSampler);
return out;
}

View File

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

View File

@ -0,0 +1,27 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct SpecConstArray
{
float4 samples[2];
};
struct main0_in
{
int Index [[user(locn0)]];
};
struct main0_out
{
float4 FragColor [[color(0)]];
};
fragment main0_out main0(main0_in in [[stage_in]], constant SpecConstArray& _15 [[buffer(0)]])
{
main0_out out = {};
out.FragColor = _15.samples[in.Index];
return out;
}

View File

@ -75,31 +75,31 @@ inline float spvDet3x3(float a1, float a2, float a3, float b1, float b2, float b
float4x4 spvInverse4x4(float4x4 m)
{
float4x4 adj; // The adjoint matrix (inverse after dividing by determinant)
// Create the transpose of the cofactors, as the classical adjoint of the matrix.
adj[0][0] = spvDet3x3(m[1][1], m[1][2], m[1][3], m[2][1], m[2][2], m[2][3], m[3][1], m[3][2], m[3][3]);
adj[0][1] = -spvDet3x3(m[0][1], m[0][2], m[0][3], m[2][1], m[2][2], m[2][3], m[3][1], m[3][2], m[3][3]);
adj[0][2] = spvDet3x3(m[0][1], m[0][2], m[0][3], m[1][1], m[1][2], m[1][3], m[3][1], m[3][2], m[3][3]);
adj[0][3] = -spvDet3x3(m[0][1], m[0][2], m[0][3], m[1][1], m[1][2], m[1][3], m[2][1], m[2][2], m[2][3]);
adj[1][0] = -spvDet3x3(m[1][0], m[1][2], m[1][3], m[2][0], m[2][2], m[2][3], m[3][0], m[3][2], m[3][3]);
adj[1][1] = spvDet3x3(m[0][0], m[0][2], m[0][3], m[2][0], m[2][2], m[2][3], m[3][0], m[3][2], m[3][3]);
adj[1][2] = -spvDet3x3(m[0][0], m[0][2], m[0][3], m[1][0], m[1][2], m[1][3], m[3][0], m[3][2], m[3][3]);
adj[1][3] = spvDet3x3(m[0][0], m[0][2], m[0][3], m[1][0], m[1][2], m[1][3], m[2][0], m[2][2], m[2][3]);
adj[2][0] = spvDet3x3(m[1][0], m[1][1], m[1][3], m[2][0], m[2][1], m[2][3], m[3][0], m[3][1], m[3][3]);
adj[2][1] = -spvDet3x3(m[0][0], m[0][1], m[0][3], m[2][0], m[2][1], m[2][3], m[3][0], m[3][1], m[3][3]);
adj[2][2] = spvDet3x3(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[3][0], m[3][1], m[3][3]);
adj[2][3] = -spvDet3x3(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[2][0], m[2][1], m[2][3]);
adj[3][0] = -spvDet3x3(m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], m[2][2], m[3][0], m[3][1], m[3][2]);
adj[3][1] = spvDet3x3(m[0][0], m[0][1], m[0][2], m[2][0], m[2][1], m[2][2], m[3][0], m[3][1], m[3][2]);
adj[3][2] = -spvDet3x3(m[0][0], m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[3][0], m[3][1], m[3][2]);
adj[3][3] = spvDet3x3(m[0][0], m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], m[2][2]);
// Calculate the determinant as a combination of the cofactors of the first row.
float det = (adj[0][0] * m[0][0]) + (adj[0][1] * m[1][0]) + (adj[0][2] * m[2][0]) + (adj[0][3] * m[3][0]);
// Divide the classical adjoint matrix by the determinant.
// If determinant is zero, matrix is not invertable, so leave it unchanged.
return (det != 0.0f) ? (adj * (1.0f / det)) : m;

View File

@ -0,0 +1,56 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
typedef float3x4 packed_float4x3;
struct _15
{
packed_float4x3 _m0;
packed_float4x3 _m1;
};
struct _42
{
float4x4 _m0;
float4x4 _m1;
float _m2;
char pad3[12];
packed_float3 _m3;
float _m4;
packed_float3 _m5;
float _m6;
float _m7;
float _m8;
float2 _m9;
};
struct main0_in
{
float4 m_25 [[attribute(0)]];
};
struct main0_out
{
float3 m_72 [[user(locn0)]];
float4 gl_Position [[position]];
};
vertex main0_out main0(main0_in in [[stage_in]], constant _15& _17 [[buffer(0)]], constant _42& _44 [[buffer(1)]])
{
main0_out out = {};
float3 _13;
do
{
_13 = normalize(float4(in.m_25.xyz, 0.0) * _17._m1);
break;
} while (false);
float4 _39 = _44._m0 * float4(_44._m3 + (in.m_25.xyz * (_44._m6 + _44._m7)), 1.0);
out.m_72 = _13;
float4 _74 = _39;
_74.y = -_39.y;
out.gl_Position = _74;
return out;
}

View File

@ -0,0 +1,58 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
constant float4 _20[2] = {float4(10.0), float4(20.0)};
struct main0_in
{
float4 vInput1 [[attribute(1)]];
float4 vInput0 [[attribute(0)]];
};
struct main0_out
{
float4 gl_Position [[position]];
};
// Implementation of an array copy function to cover GLSL's ability to copy an array via assignment.
template<typename T, uint N>
void spvArrayCopy(thread T (&dst)[N], thread const T (&src)[N])
{
for (uint i = 0; i < N; dst[i] = src[i], i++);
}
// An overload for constant arrays.
template<typename T, uint N>
void spvArrayCopyConstant(thread T (&dst)[N], constant T (&src)[N])
{
for (uint i = 0; i < N; dst[i] = src[i], i++);
}
void test(thread float4 (&SPIRV_Cross_return_value)[2])
{
spvArrayCopyConstant(SPIRV_Cross_return_value, _20);
}
void test2(thread float4 (&SPIRV_Cross_return_value)[2], thread float4& vInput0, thread float4& vInput1)
{
float4 foobar[2];
foobar[0] = vInput0;
foobar[1] = vInput1;
spvArrayCopy(SPIRV_Cross_return_value, foobar);
}
vertex main0_out main0(main0_in in [[stage_in]])
{
main0_out out = {};
float4 _42[2];
test(_42);
float4 _44[2];
test2(_44, in.vInput0, in.vInput1);
out.gl_Position = _42[0] + _44[1];
return out;
}

View File

@ -0,0 +1,13 @@
#version 310 es
precision mediump float;
precision highp int;
layout(location = 0) out vec4 FragColor;
layout(location = 0) in vec4 vA;
layout(location = 1) in vec4 vB;
void main()
{
FragColor = vA - vB * trunc(vA / vB);
}

View File

@ -0,0 +1,39 @@
#version 310 es
precision mediump float;
precision highp int;
layout(location = 0) out vec4 FragColor;
vec4 foo(vec4 foo_1)
{
return foo_1 + vec4(1.0);
}
vec4 foo(vec3 foo_1)
{
return foo_1.xyzz + vec4(1.0);
}
vec4 foo_1(vec4 foo_2)
{
return foo_2 + vec4(2.0);
}
vec4 foo(vec2 foo_2)
{
return foo_2.xyxy + vec4(2.0);
}
void main()
{
highp vec4 foo_3 = vec4(1.0);
vec4 foo_2 = foo(foo_3);
highp vec3 foo_5 = vec3(1.0);
vec4 foo_4 = foo(foo_5);
highp vec4 foo_7 = vec4(1.0);
vec4 foo_6 = foo_1(foo_7);
highp vec2 foo_9 = vec2(1.0);
vec4 foo_8 = foo(foo_9);
FragColor = ((foo_2 + foo_4) + foo_6) + foo_8;
}

View File

@ -0,0 +1,38 @@
#version 450
uniform sampler2D SPIRV_Cross_CombinedparamSPIRV_Cross_DummySampler;
uniform sampler2D SPIRV_Cross_CombinedSampledImageSPIRV_Cross_DummySampler;
uniform sampler2D SPIRV_Cross_CombinedparamSampler;
uniform sampler2D SPIRV_Cross_CombinedSampledImageSampler;
layout(location = 0) out vec4 _entryPointOutput;
vec4 sample_fetch(ivec3 UV, sampler2D SPIRV_Cross_CombinedtexSPIRV_Cross_DummySampler)
{
return texelFetch(SPIRV_Cross_CombinedtexSPIRV_Cross_DummySampler, UV.xy, UV.z);
}
vec4 sample_sampler(vec2 UV, sampler2D SPIRV_Cross_CombinedtexSampler)
{
return texture(SPIRV_Cross_CombinedtexSampler, UV);
}
vec4 _main(vec4 xIn)
{
ivec3 coord = ivec3(int(xIn.x * 1280.0), int(xIn.y * 720.0), 0);
ivec3 param = coord;
vec4 value = sample_fetch(param, SPIRV_Cross_CombinedparamSPIRV_Cross_DummySampler);
value += texelFetch(SPIRV_Cross_CombinedSampledImageSPIRV_Cross_DummySampler, coord.xy, coord.z);
vec2 param_1 = xIn.xy;
value += sample_sampler(param_1, SPIRV_Cross_CombinedparamSampler);
value += texture(SPIRV_Cross_CombinedSampledImageSampler, xIn.xy);
return value;
}
void main()
{
vec4 xIn = gl_FragCoord;
vec4 param = xIn;
_entryPointOutput = _main(param);
}

View File

@ -0,0 +1,37 @@
#version 450
layout(set = 0, binding = 0) uniform sampler Sampler;
layout(set = 0, binding = 0) uniform texture2D SampledImage;
uniform sampler SPIRV_Cross_DummySampler;
layout(location = 0) out vec4 _entryPointOutput;
vec4 sample_fetch(texture2D tex, ivec3 UV)
{
return texelFetch(sampler2D(tex, SPIRV_Cross_DummySampler), UV.xy, UV.z);
}
vec4 sample_sampler(texture2D tex, vec2 UV)
{
return texture(sampler2D(tex, Sampler), UV);
}
vec4 _main(vec4 xIn)
{
ivec3 coord = ivec3(int(xIn.x * 1280.0), int(xIn.y * 720.0), 0);
ivec3 param = coord;
vec4 value = sample_fetch(SampledImage, param);
value += texelFetch(sampler2D(SampledImage, SPIRV_Cross_DummySampler), coord.xy, coord.z);
vec2 param_1 = xIn.xy;
value += sample_sampler(SampledImage, param_1);
value += texture(sampler2D(SampledImage, Sampler), xIn.xy);
return value;
}
void main()
{
vec4 xIn = gl_FragCoord;
vec4 param = xIn;
_entryPointOutput = _main(param);
}

View File

@ -0,0 +1,9 @@
#version 450
invariant gl_Position;
void main()
{
gl_Position = vec4(1.0);
}

View File

@ -0,0 +1,17 @@
#version 450
out gl_PerVertex
{
vec4 gl_Position;
float gl_PointSize;
float gl_ClipDistance[1];
float gl_CullDistance[1];
};
invariant gl_Position;
void main()
{
gl_Position = vec4(1.0);
}

View File

@ -0,0 +1,14 @@
#version 450
invariant gl_Position;
vec4 _main()
{
return vec4(1.0);
}
void main()
{
gl_Position = _main();
}

View File

@ -0,0 +1,19 @@
#version 450
out gl_PerVertex
{
vec4 gl_Position;
};
invariant gl_Position;
vec4 _main()
{
return vec4(1.0);
}
void main()
{
gl_Position = _main();
}

View File

@ -0,0 +1,12 @@
#version 450
in float gl_ClipDistance[4];
in float gl_CullDistance[3];
layout(location = 0) out float FragColor;
void main()
{
FragColor = gl_ClipDistance[0] + gl_CullDistance[0];
}

View File

@ -0,0 +1,11 @@
#version 450
#extension GL_ARB_gpu_shader_int64 : require
layout(location = 0) out vec3 FragColor;
layout(location = 0) flat in double vTmp;
void main()
{
FragColor = vec3(dvec3(uint64BitsToDouble(0x7ff0000000000000ul), uint64BitsToDouble(0xfff0000000000000ul), uint64BitsToDouble(0xfff8000000000000ul)) + dvec3(vTmp));
}

Some files were not shown because too many files have changed in this diff Show More