mirror of
https://github.com/libretro/RetroArch
synced 2025-02-19 12:41:00 +00:00
Squashed 'deps/SPIRV-Cross/' changes from 33c5cd9..c9516fa
c9516fa Fix OSX Travis. 94cd777 Move `rename_interface_variable` to util 467c956 Merge pull request #480 from KhronosGroup/fix-476 1e4db56 Run format_all.sh. eecbeaa Take execution model into account for entry point methods. 337150f Merge pull request #479 from KhronosGroup/fix-477 3c1b147 Support Invariant for BuiltInPosition. cae1722 Merge pull request #475 from KhronosGroup/fix-convert-cast e69b1ae Fix implicit conversion bug. b39c063 Merge pull request #474 from KhronosGroup/fix-pointer-overload fda36f8 Fix function overload when SPIR-V overloads on pointer type. a61e728 Merge pull request #472 from KhronosGroup/fix-446 6a12ff7 Fix multiple declaration of spvDet2x2 on MSL. b380a21 Implement MatrixInverse on HLSL. 6066fe4 Merge pull request #471 from KhronosGroup/fix-462 f6d08e6 Add workaround for PointCoord builtin on HLSL. fb196c2 Merge pull request #470 from KhronosGroup/fix-459 dd603ea Support spec constant array size in blocks. 32b1c7d Merge pull request #469 from KhronosGroup/fix-454 a04bdcc Handle overloaded functions which share the same OpName. f887b20 Merge pull request #468 from KhronosGroup/fix-461 4543dac Run format_all.sh. 047ad7d Support special float constants (NaN/Inf). 3f64f56 Merge pull request #465 from KhronosGroup/fix-445 0673f27 Fix incorrect loop range. 114c2c5 Add clip/cull-distance support to HLSL. fb3f92a Overhaul clip/cull distance support in GLSL. 11bbccb Merge pull request #464 from billhollings/master 50ef6cd CompilerMSL remove incorrect packing of non-interface type-aliased structs. 3925fe8 Merge pull request #460 from KhronosGroup/fix-424 47b3742 Run format_all.sh. 1a2e4de Add test for texelFetch without sampler. 4db7061 Begin implementing texelFetch(texture2D) workaround on GLSL. d871a89 Remove "EXPERIMENTAL" tag from MSL/HLSL. 218b0a5 Merge pull request #455 from KhronosGroup/fix-452 8a3bef2 Add OpFRem tests. 54a065b Run format_all.sh. 3fa6cc8 Implement FRem. a9a6bca Merge pull request #453 from KhronosGroup/fix-444 843e34b Add IsFrontFace support to HLSL. 3d0c61f Merge pull request #451 from KhronosGroup/fix-437 636cc30 Fix case where hoisted temporaries were used before being declared. 4d1c5ad Merge pull request #450 from jodavis42/OpCopyMemoryCrash b4b629b Null crash fix in OpCopyMemory. 6a0f698 Set width when creating NumWorkgroups buffer. 2bda0d5 Merge pull request #449 from billhollings/master 2964e32 CompilerMSL support gl_SampleMask and convert it to scalar uint from array. 64d3083 Merge pull request #448 from billhollings/master b453348 Merge branch 'master' of https://github.com/billhollings/SPIRV-Cross 607b0d6 CompilerMSL support smaller offsets for 3-row row-major matrices. 7be30aa Merge pull request #442 from KhronosGroup/fix-435 a3104e9 Also check that type we load is an image. a3ae861 Fix depth image usage in MSL for separate image/samplers. 702e086 Support passing implicit frag_coord arguments down to functions. 0912427 Begin implementing subpassLoad in MSL. 18a594a Implement subpass input support in HLSL. f4bce68 Merge pull request #433 from KhronosGroup/fix-428 c9db3e5 Overload on constant storage. b2c9487 Attempt to deduce constant/thread storage. 1a9c960 MSL cannot declare inline arrays except in certain cases. 156dd90 Implicit return value takes thread storage. d89b790 Fix wrong function declaration in MSL. 00ccd59 Return arrays in HLSL/MSL by writing to an output variable instead. 9fa91f7 Support returning arrays from functions in GLSL/MSL. ed6b775 Merge pull request #417 from msiglreith/root_constants_overwrite 369f5f6 Add missing include d096f5c hlsl: Support custom root constant layout 4b58f65 Merge pull request #438 from zeux/msvc-warning-fix 24cf308 Fix MSVC 2015 warning 8b53b70 Merge pull request #434 from KhronosGroup/fix-429 18e8833 Support gl_NumWorkgroups in HLSL. 181a5fa Fix formatting after merge. e3f4041 Fixes MSVC 2013 compilation ef33770 Merge pull request #431 from twinaphex/master 59a12c7 Uniquely name these static functions git-subtree-dir: deps/SPIRV-Cross git-subtree-split: c9516fa91709b68ac20fa614625e85e0ced3f23f
This commit is contained in:
parent
f880cb2d48
commit
f48c1800c0
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
163
main.cpp
163
main.cpp
@ -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++)
|
||||
{
|
||||
|
@ -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">
|
||||
|
@ -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>
|
||||
|
29
reference/opt/shaders-hlsl/asm/frag/frem.asm.frag
Normal file
29
reference/opt/shaders-hlsl/asm/frag/frem.asm.frag
Normal 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;
|
||||
}
|
@ -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;
|
||||
}
|
122
reference/opt/shaders-hlsl/comp/inverse.comp
Normal file
122
reference/opt/shaders-hlsl/comp/inverse.comp
Normal 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();
|
||||
}
|
16
reference/opt/shaders-hlsl/comp/num-workgroups-alone.comp
Normal file
16
reference/opt/shaders-hlsl/comp/num-workgroups-alone.comp
Normal 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();
|
||||
}
|
@ -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();
|
||||
}
|
30
reference/opt/shaders-hlsl/frag/clip-cull-distance.frag
Normal file
30
reference/opt/shaders-hlsl/frag/clip-cull-distance.frag
Normal 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;
|
||||
}
|
39
reference/opt/shaders-hlsl/frag/front-facing.frag
Normal file
39
reference/opt/shaders-hlsl/frag/front-facing.frag
Normal 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;
|
||||
}
|
19
reference/opt/shaders-hlsl/frag/inf-nan-constant.frag
Normal file
19
reference/opt/shaders-hlsl/frag/inf-nan-constant.frag
Normal 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;
|
||||
}
|
32
reference/opt/shaders-hlsl/frag/input-attachment-ms.frag
Normal file
32
reference/opt/shaders-hlsl/frag/input-attachment-ms.frag
Normal 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;
|
||||
}
|
29
reference/opt/shaders-hlsl/frag/input-attachment.frag
Normal file
29
reference/opt/shaders-hlsl/frag/input-attachment.frag
Normal 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;
|
||||
}
|
19
reference/opt/shaders-hlsl/frag/point-coord-compat.frag
Normal file
19
reference/opt/shaders-hlsl/frag/point-coord-compat.frag
Normal 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;
|
||||
}
|
@ -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;
|
||||
}
|
28
reference/opt/shaders-hlsl/vert/clip-cull-distance.vert
Normal file
28
reference/opt/shaders-hlsl/vert/clip-cull-distance.vert
Normal 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;
|
||||
}
|
@ -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()
|
||||
|
31
reference/opt/shaders-hlsl/vert/return-array.vert
Normal file
31
reference/opt/shaders-hlsl/vert/return-array.vert
Normal 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;
|
||||
}
|
23
reference/opt/shaders-msl/asm/frag/frem.asm.frag
Normal file
23
reference/opt/shaders-msl/asm/frag/frem.asm.frag
Normal 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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
123
reference/opt/shaders-msl/comp/inverse.comp
Normal file
123
reference/opt/shaders-msl/comp/inverse.comp
Normal 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);
|
||||
}
|
||||
|
29
reference/opt/shaders-msl/comp/struct-nested.comp
Normal file
29
reference/opt/shaders-msl/comp/struct-nested.comp
Normal 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;
|
||||
}
|
||||
|
@ -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];
|
||||
}
|
||||
|
||||
|
@ -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 = {};
|
||||
|
@ -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 = {};
|
||||
|
30
reference/opt/shaders-msl/frag/front-facing.frag
Normal file
30
reference/opt/shaders-msl/frag/front-facing.frag
Normal 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;
|
||||
}
|
||||
|
17
reference/opt/shaders-msl/frag/inf-nan-constant.frag
Normal file
17
reference/opt/shaders-msl/frag/inf-nan-constant.frag
Normal 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;
|
||||
}
|
||||
|
17
reference/opt/shaders-msl/frag/input-attachment-ms.frag
Normal file
17
reference/opt/shaders-msl/frag/input-attachment-ms.frag
Normal 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;
|
||||
}
|
||||
|
17
reference/opt/shaders-msl/frag/input-attachment.frag
Normal file
17
reference/opt/shaders-msl/frag/input-attachment.frag
Normal 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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
19
reference/opt/shaders-msl/frag/sample-mask.frag
Normal file
19
reference/opt/shaders-msl/frag/sample-mask.frag
Normal 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;
|
||||
}
|
||||
|
27
reference/opt/shaders-msl/frag/spec-constant-block-size.frag
Normal file
27
reference/opt/shaders-msl/frag/spec-constant-block-size.frag
Normal 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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
56
reference/opt/shaders-msl/vert/packed_matrix.vert
Normal file
56
reference/opt/shaders-msl/vert/packed_matrix.vert
Normal 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;
|
||||
}
|
||||
|
24
reference/opt/shaders-msl/vert/return-array.vert
Normal file
24
reference/opt/shaders-msl/vert/return-array.vert
Normal 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;
|
||||
}
|
||||
|
13
reference/opt/shaders/asm/frag/frem.asm.frag
Normal file
13
reference/opt/shaders/asm/frag/frem.asm.frag
Normal 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);
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
9
reference/opt/shaders/asm/vert/invariant-block.asm.vert
Normal file
9
reference/opt/shaders/asm/vert/invariant-block.asm.vert
Normal file
@ -0,0 +1,9 @@
|
||||
#version 450
|
||||
|
||||
invariant gl_Position;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(1.0);
|
||||
}
|
||||
|
17
reference/opt/shaders/asm/vert/invariant-block.sso.asm.vert
Normal file
17
reference/opt/shaders/asm/vert/invariant-block.sso.asm.vert
Normal 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);
|
||||
}
|
||||
|
9
reference/opt/shaders/asm/vert/invariant.asm.vert
Normal file
9
reference/opt/shaders/asm/vert/invariant.asm.vert
Normal file
@ -0,0 +1,9 @@
|
||||
#version 450
|
||||
|
||||
invariant gl_Position;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(1.0);
|
||||
}
|
||||
|
14
reference/opt/shaders/asm/vert/invariant.sso.asm.vert
Normal file
14
reference/opt/shaders/asm/vert/invariant.sso.asm.vert
Normal file
@ -0,0 +1,14 @@
|
||||
#version 450
|
||||
|
||||
out gl_PerVertex
|
||||
{
|
||||
vec4 gl_Position;
|
||||
};
|
||||
|
||||
invariant gl_Position;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(1.0);
|
||||
}
|
||||
|
@ -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];
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
20
reference/opt/shaders/frag/front-facing.frag
Normal file
20
reference/opt/shaders/frag/front-facing.frag
Normal 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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
11
reference/opt/shaders/frag/inf-nan-constant.frag
Normal file
11
reference/opt/shaders/frag/inf-nan-constant.frag
Normal 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));
|
||||
}
|
||||
|
9
reference/opt/shaders/vert/return-array.vert
Normal file
9
reference/opt/shaders/vert/return-array.vert
Normal file
@ -0,0 +1,9 @@
|
||||
#version 310 es
|
||||
|
||||
layout(location = 1) in vec4 vInput1;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(10.0) + vInput1;
|
||||
}
|
||||
|
@ -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];
|
||||
}
|
||||
|
@ -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];
|
||||
}
|
||||
|
29
reference/shaders-hlsl/asm/frag/frem.asm.frag
Normal file
29
reference/shaders-hlsl/asm/frag/frem.asm.frag
Normal 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;
|
||||
}
|
@ -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;
|
||||
}
|
122
reference/shaders-hlsl/comp/inverse.comp
Normal file
122
reference/shaders-hlsl/comp/inverse.comp
Normal 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();
|
||||
}
|
16
reference/shaders-hlsl/comp/num-workgroups-alone.comp
Normal file
16
reference/shaders-hlsl/comp/num-workgroups-alone.comp
Normal 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();
|
||||
}
|
@ -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();
|
||||
}
|
30
reference/shaders-hlsl/frag/clip-cull-distance.frag
Normal file
30
reference/shaders-hlsl/frag/clip-cull-distance.frag
Normal 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;
|
||||
}
|
39
reference/shaders-hlsl/frag/front-facing.frag
Normal file
39
reference/shaders-hlsl/frag/front-facing.frag
Normal 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;
|
||||
}
|
19
reference/shaders-hlsl/frag/inf-nan-constant.frag
Normal file
19
reference/shaders-hlsl/frag/inf-nan-constant.frag
Normal 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;
|
||||
}
|
37
reference/shaders-hlsl/frag/input-attachment-ms.frag
Normal file
37
reference/shaders-hlsl/frag/input-attachment-ms.frag
Normal 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;
|
||||
}
|
34
reference/shaders-hlsl/frag/input-attachment.frag
Normal file
34
reference/shaders-hlsl/frag/input-attachment.frag
Normal 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;
|
||||
}
|
19
reference/shaders-hlsl/frag/point-coord-compat.frag
Normal file
19
reference/shaders-hlsl/frag/point-coord-compat.frag
Normal 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;
|
||||
}
|
33
reference/shaders-hlsl/frag/spec-constant-block-size.frag
Normal file
33
reference/shaders-hlsl/frag/spec-constant-block-size.frag
Normal 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;
|
||||
}
|
28
reference/shaders-hlsl/vert/clip-cull-distance.vert
Normal file
28
reference/shaders-hlsl/vert/clip-cull-distance.vert
Normal 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;
|
||||
}
|
@ -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()
|
||||
|
48
reference/shaders-hlsl/vert/return-array.vert
Normal file
48
reference/shaders-hlsl/vert/return-array.vert
Normal 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;
|
||||
}
|
23
reference/shaders-msl/asm/frag/frem.asm.frag
Normal file
23
reference/shaders-msl/asm/frag/frem.asm.frag
Normal 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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 = {};
|
||||
|
123
reference/shaders-msl/comp/inverse.comp
Normal file
123
reference/shaders-msl/comp/inverse.comp
Normal 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);
|
||||
}
|
||||
|
27
reference/shaders-msl/comp/struct-nested.comp
Normal file
27
reference/shaders-msl/comp/struct-nested.comp
Normal 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;
|
||||
}
|
||||
|
@ -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];
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 = {};
|
||||
|
30
reference/shaders-msl/frag/front-facing.frag
Normal file
30
reference/shaders-msl/frag/front-facing.frag
Normal 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;
|
||||
}
|
||||
|
17
reference/shaders-msl/frag/inf-nan-constant.frag
Normal file
17
reference/shaders-msl/frag/inf-nan-constant.frag
Normal 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;
|
||||
}
|
||||
|
24
reference/shaders-msl/frag/input-attachment-ms.frag
Normal file
24
reference/shaders-msl/frag/input-attachment-ms.frag
Normal 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;
|
||||
}
|
||||
|
24
reference/shaders-msl/frag/input-attachment.frag
Normal file
24
reference/shaders-msl/frag/input-attachment.frag
Normal 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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
19
reference/shaders-msl/frag/sample-mask.frag
Normal file
19
reference/shaders-msl/frag/sample-mask.frag
Normal 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;
|
||||
}
|
||||
|
27
reference/shaders-msl/frag/spec-constant-block-size.frag
Normal file
27
reference/shaders-msl/frag/spec-constant-block-size.frag
Normal 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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
56
reference/shaders-msl/vert/packed_matrix.vert
Normal file
56
reference/shaders-msl/vert/packed_matrix.vert
Normal 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;
|
||||
}
|
||||
|
58
reference/shaders-msl/vert/return-array.vert
Normal file
58
reference/shaders-msl/vert/return-array.vert
Normal 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;
|
||||
}
|
||||
|
13
reference/shaders/asm/frag/frem.asm.frag
Normal file
13
reference/shaders/asm/frag/frem.asm.frag
Normal 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);
|
||||
}
|
||||
|
39
reference/shaders/asm/frag/function-overload-alias.asm.frag
Normal file
39
reference/shaders/asm/frag/function-overload-alias.asm.frag
Normal 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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
9
reference/shaders/asm/vert/invariant-block.asm.vert
Normal file
9
reference/shaders/asm/vert/invariant-block.asm.vert
Normal file
@ -0,0 +1,9 @@
|
||||
#version 450
|
||||
|
||||
invariant gl_Position;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(1.0);
|
||||
}
|
||||
|
17
reference/shaders/asm/vert/invariant-block.sso.asm.vert
Normal file
17
reference/shaders/asm/vert/invariant-block.sso.asm.vert
Normal 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);
|
||||
}
|
||||
|
14
reference/shaders/asm/vert/invariant.asm.vert
Normal file
14
reference/shaders/asm/vert/invariant.asm.vert
Normal file
@ -0,0 +1,14 @@
|
||||
#version 450
|
||||
|
||||
invariant gl_Position;
|
||||
|
||||
vec4 _main()
|
||||
{
|
||||
return vec4(1.0);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = _main();
|
||||
}
|
||||
|
19
reference/shaders/asm/vert/invariant.sso.asm.vert
Normal file
19
reference/shaders/asm/vert/invariant.sso.asm.vert
Normal 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();
|
||||
}
|
||||
|
@ -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];
|
||||
}
|
||||
|
@ -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
Loading…
x
Reference in New Issue
Block a user