From 8db625dd5948656e76f7ff9d490a7234c2604922 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Thu, 1 Feb 2018 20:10:07 +0100 Subject: [PATCH 001/232] (slang) slang_process.cpp: add support for more shaders. --- gfx/drivers_shader/slang_process.cpp | 69 +++++++++++++++++++++------- 1 file changed, 52 insertions(+), 17 deletions(-) diff --git a/gfx/drivers_shader/slang_process.cpp b/gfx/drivers_shader/slang_process.cpp index b1f017eaff..552b1fae05 100644 --- a/gfx/drivers_shader/slang_process.cpp +++ b/gfx/drivers_shader/slang_process.cpp @@ -94,27 +94,33 @@ static bool slang_process_reflection( unordered_map texture_semantic_map; unordered_map texture_semantic_uniform_map; - string name = shader_info->pass[pass_number].alias; + for (unsigned i = 0; i <= pass_number; i++) + { + if(!*shader_info->pass[i].alias) + continue; - if (!set_unique_map( - texture_semantic_map, name, - slang_texture_semantic_map{ SLANG_TEXTURE_SEMANTIC_PASS_OUTPUT, pass_number })) - return false; + string name = shader_info->pass[i].alias; - if (!set_unique_map( - texture_semantic_uniform_map, name + "Size", - slang_texture_semantic_map{ SLANG_TEXTURE_SEMANTIC_PASS_OUTPUT, pass_number })) - return false; + if (!set_unique_map( + texture_semantic_map, name, + slang_texture_semantic_map{ SLANG_TEXTURE_SEMANTIC_PASS_OUTPUT, i })) + return false; - if (!set_unique_map( - texture_semantic_map, name + "Feedback", - slang_texture_semantic_map{ SLANG_TEXTURE_SEMANTIC_PASS_FEEDBACK, pass_number })) - return false; + if (!set_unique_map( + texture_semantic_uniform_map, name + "Size", + slang_texture_semantic_map{ SLANG_TEXTURE_SEMANTIC_PASS_OUTPUT, i })) + return false; - if (!set_unique_map( - texture_semantic_uniform_map, name + "FeedbackSize", - slang_texture_semantic_map{ SLANG_TEXTURE_SEMANTIC_PASS_FEEDBACK, pass_number })) - return false; + if (!set_unique_map( + texture_semantic_map, name + "Feedback", + slang_texture_semantic_map{ SLANG_TEXTURE_SEMANTIC_PASS_FEEDBACK, i })) + return false; + + if (!set_unique_map( + texture_semantic_uniform_map, name + "FeedbackSize", + slang_texture_semantic_map{ SLANG_TEXTURE_SEMANTIC_PASS_FEEDBACK, i })) + return false; + } for (unsigned i = 0; i < shader_info->luts; i++) { @@ -130,6 +136,7 @@ static bool slang_process_reflection( } unordered_map uniform_semantic_map; + for (unsigned i = 0; i < shader_info->num_parameters; i++) { if (!set_unique_map( @@ -305,6 +312,9 @@ bool slang_process( if (!slang_preprocess_parse_parameters(output.meta, shader_info)) return false; + if (!output.meta.name.empty()) + strncpy(pass.alias, output.meta.name.c_str(), sizeof(pass.alias) - 1); + out->format = output.meta.rt_format; if (out->format == SLANG_FORMAT_UNKNOWN) @@ -363,6 +373,31 @@ bool slang_process( ps_attrib_remap.push_back({ location, "SV_Position" }); } } + + /* "line" is a reserved keyword in hlsl + * maybe there is an easier way to rename a variable ? */ + + int id = 0; + while(true) + { + try + { + string name = ps->get_name(id); + + if(name == "line") + { + ps->set_name(id, "var_line"); + break; + } + + id++; + } + catch (const std::exception& e) + { + break; + } + } + VariableTypeRemapCallback ps_var_remap_cb = [](const SPIRType& type, const std::string& var_name, std::string& name_of_type) { if (var_name == "FragCoord") From 461a936eb4f91445e8ca44cbdba7c78f8522f4d7 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Thu, 1 Feb 2018 20:56:40 +0100 Subject: [PATCH 002/232] (D3D11) correct the size data of the last pass. --- gfx/drivers/d3d11.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/gfx/drivers/d3d11.c b/gfx/drivers/d3d11.c index f6db4471a0..fdf3bf805e 100644 --- a/gfx/drivers/d3d11.c +++ b/gfx/drivers/d3d11.c @@ -128,6 +128,8 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const D3D11Flush(d3d11->ctx); d3d11_free_shader_preset(d3d11); + d3d11->resize_fbos = true; + if (!path) return true; @@ -709,8 +711,7 @@ static bool d3d11_init_frame_textures(d3d11_video_t* d3d11, unsigned width, unsi switch (pass->fbo.type_x) { case RARCH_SCALE_INPUT: - if (pass->fbo.scale_x) - width *= pass->fbo.scale_x; + width *= pass->fbo.scale_x; break; case RARCH_SCALE_VIEWPORT: @@ -728,8 +729,7 @@ static bool d3d11_init_frame_textures(d3d11_video_t* d3d11, unsigned width, unsi switch (pass->fbo.type_y) { case RARCH_SCALE_INPUT: - if (pass->fbo.scale_y) - height *= pass->fbo.scale_y; + height *= pass->fbo.scale_y; break; case RARCH_SCALE_VIEWPORT: @@ -750,17 +750,18 @@ static bool d3d11_init_frame_textures(d3d11_video_t* d3d11, unsigned width, unsi if (!height) height = d3d11->vp.height; - d3d11->pass[i].viewport.Width = width; - d3d11->pass[i].viewport.Height = height; - d3d11->pass[i].viewport.MaxDepth = 1.0; - d3d11->pass[i].rt.desc.Width = width; - d3d11->pass[i].rt.desc.Height = height; - d3d11->pass[i].rt.desc.BindFlags = D3D11_BIND_RENDER_TARGET; - d3d11->pass[i].rt.desc.Format = glslang_format_to_dxgi(d3d11->pass[i].semantics.format); + RARCH_LOG("[D3D11]: Updating framebuffer size %u x %u.\n", width, height); if ((i != (d3d11->shader_preset->passes - 1)) || (width != d3d11->vp.width) || (height != d3d11->vp.height)) { + d3d11->pass[i].viewport.Width = width; + d3d11->pass[i].viewport.Height = height; + d3d11->pass[i].viewport.MaxDepth = 1.0; + d3d11->pass[i].rt.desc.Width = width; + d3d11->pass[i].rt.desc.Height = height; + d3d11->pass[i].rt.desc.BindFlags = D3D11_BIND_RENDER_TARGET; + d3d11->pass[i].rt.desc.Format = glslang_format_to_dxgi(d3d11->pass[i].semantics.format); d3d11_init_texture(d3d11->device, &d3d11->pass[i].rt); } else @@ -787,6 +788,7 @@ static bool d3d11_init_frame_textures(d3d11_video_t* d3d11, unsigned width, unsi } d3d11->resize_fbos = false; + return true; #if 0 error: @@ -844,6 +846,9 @@ static bool d3d11_gfx_frame( if (frame && width && height) { if (d3d11->frame.texture.desc.Width != width || d3d11->frame.texture.desc.Height != height) + d3d11->resize_fbos = true; + + if (d3d11->resize_fbos) d3d11_init_frame_textures(d3d11, width, height); d3d11_update_texture( @@ -853,10 +858,6 @@ static bool d3d11_gfx_frame( D3D11SetVertexBuffer(d3d11->ctx, 0, d3d11->frame.vbo, sizeof(d3d11_vertex_t), 0); D3D11SetBlendState(d3d11->ctx, d3d11->blend_disable, NULL, D3D11_DEFAULT_SAMPLE_MASK); - /* todo: single pass shaders can also have an empty rt texture */ - if (d3d11->shader_preset && (d3d11->resize_fbos || !d3d11->pass[0].rt.handle)) - d3d11_init_frame_textures(d3d11, width, height); - d3d11_texture_t* texture = &d3d11->frame.texture; if (d3d11->shader_preset) From 80880ec857a97cd48a78e1e3375f8f76c9c33ee9 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Thu, 1 Feb 2018 21:45:36 +0100 Subject: [PATCH 003/232] (slang) slang_process.cpp: enforce the binding of the uniform and push constant blocks. --- gfx/drivers_shader/slang_process.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gfx/drivers_shader/slang_process.cpp b/gfx/drivers_shader/slang_process.cpp index 552b1fae05..2323078935 100644 --- a/gfx/drivers_shader/slang_process.cpp +++ b/gfx/drivers_shader/slang_process.cpp @@ -351,6 +351,16 @@ bool slang_process( vs_resources = vs_compiler->get_shader_resources(); ps_resources = ps_compiler->get_shader_resources(); + if(!vs_resources.uniform_buffers.empty()) + vs_compiler->set_decoration(vs_resources.uniform_buffers[0].id, spv::DecorationBinding, 0); + if(!ps_resources.uniform_buffers.empty()) + ps_compiler->set_decoration(ps_resources.uniform_buffers[0].id, spv::DecorationBinding, 0); + + if(!vs_resources.push_constant_buffers.empty()) + vs_compiler->set_decoration(vs_resources.push_constant_buffers[0].id, spv::DecorationBinding, 1); + if(!ps_resources.push_constant_buffers.empty()) + ps_compiler->set_decoration(ps_resources.push_constant_buffers[0].id, spv::DecorationBinding, 1); + if (dst_type == RARCH_SHADER_HLSL || dst_type == RARCH_SHADER_CG) { CompilerHLSL::Options options; From b8e3933fe0117127d85ac8818f223f150a2db965 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Thu, 1 Feb 2018 22:11:11 +0100 Subject: [PATCH 004/232] (slang) slang_process: 'linear' and 'point' are also reserved keywords in HLSL. --- gfx/drivers_shader/slang_process.cpp | 29 +++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/gfx/drivers_shader/slang_process.cpp b/gfx/drivers_shader/slang_process.cpp index 2323078935..5ed6ad48b2 100644 --- a/gfx/drivers_shader/slang_process.cpp +++ b/gfx/drivers_shader/slang_process.cpp @@ -389,16 +389,35 @@ bool slang_process( int id = 0; while(true) + { + try + { + string name = vs->get_name(id); + + if(name == "line" || + name == "point" || + name == "linear") + vs->set_name(id, string("var_") + name); + + id++; + } + catch (const std::exception& e) + { + break; + } + } + + id = 0; + while(true) { try { string name = ps->get_name(id); - if(name == "line") - { - ps->set_name(id, "var_line"); - break; - } + if(name == "line" || + name == "point" || + name == "linear") + ps->set_name(id, string("var_") + name); id++; } From 189ea0578de378b9c5c14c0416a20c99fb060c3e Mon Sep 17 00:00:00 2001 From: aliaspider Date: Thu, 1 Feb 2018 22:22:56 +0100 Subject: [PATCH 005/232] (slang) slang_process: change the type of FragCoord only when it is a pixel shader input. --- gfx/drivers_shader/slang_process.cpp | 61 ++++++++++++++-------------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/gfx/drivers_shader/slang_process.cpp b/gfx/drivers_shader/slang_process.cpp index 5ed6ad48b2..a4566ac54c 100644 --- a/gfx/drivers_shader/slang_process.cpp +++ b/gfx/drivers_shader/slang_process.cpp @@ -96,7 +96,7 @@ static bool slang_process_reflection( for (unsigned i = 0; i <= pass_number; i++) { - if(!*shader_info->pass[i].alias) + if (!*shader_info->pass[i].alias) continue; string name = shader_info->pass[i].alias; @@ -351,15 +351,17 @@ bool slang_process( vs_resources = vs_compiler->get_shader_resources(); ps_resources = ps_compiler->get_shader_resources(); - if(!vs_resources.uniform_buffers.empty()) + if (!vs_resources.uniform_buffers.empty()) vs_compiler->set_decoration(vs_resources.uniform_buffers[0].id, spv::DecorationBinding, 0); - if(!ps_resources.uniform_buffers.empty()) + if (!ps_resources.uniform_buffers.empty()) ps_compiler->set_decoration(ps_resources.uniform_buffers[0].id, spv::DecorationBinding, 0); - if(!vs_resources.push_constant_buffers.empty()) - vs_compiler->set_decoration(vs_resources.push_constant_buffers[0].id, spv::DecorationBinding, 1); - if(!ps_resources.push_constant_buffers.empty()) - ps_compiler->set_decoration(ps_resources.push_constant_buffers[0].id, spv::DecorationBinding, 1); + if (!vs_resources.push_constant_buffers.empty()) + vs_compiler->set_decoration( + vs_resources.push_constant_buffers[0].id, spv::DecorationBinding, 1); + if (!ps_resources.push_constant_buffers.empty()) + ps_compiler->set_decoration( + ps_resources.push_constant_buffers[0].id, spv::DecorationBinding, 1); if (dst_type == RARCH_SHADER_HLSL || dst_type == RARCH_SHADER_CG) { @@ -375,63 +377,60 @@ bool slang_process( /* not exactly a vertex attribute but this remaps * float2 FragCoord :TEXCOORD# to float4 FragCoord : SV_POSITION */ std::vector ps_attrib_remap; - for (Resource& resource : ps_resources.stage_inputs) - { - if (ps->get_name(resource.id) == "FragCoord") - { - uint32_t location = ps->get_decoration(resource.id, spv::DecorationLocation); - ps_attrib_remap.push_back({ location, "SV_Position" }); - } - } /* "line" is a reserved keyword in hlsl * maybe there is an easier way to rename a variable ? */ int id = 0; - while(true) + while (true) { try { string name = vs->get_name(id); - if(name == "line" || - name == "point" || - name == "linear") + if (name == "line" || name == "point" || name == "linear") vs->set_name(id, string("var_") + name); id++; - } - catch (const std::exception& e) + } catch (const std::exception& e) { break; } } id = 0; - while(true) + while (true) { try { string name = ps->get_name(id); - if(name == "line" || - name == "point" || - name == "linear") + if (name == "line" || name == "point" || name == "linear") ps->set_name(id, string("var_") + name); id++; - } - catch (const std::exception& e) + } catch (const std::exception& e) { break; } } - VariableTypeRemapCallback ps_var_remap_cb = - [](const SPIRType& type, const std::string& var_name, std::string& name_of_type) { - if (var_name == "FragCoord") + VariableTypeRemapCallback ps_var_remap_cb = [&](const SPIRType& type, + const std::string& var_name, + std::string& name_of_type) { + if (var_name == "FragCoord") + { + for (Resource& resource : ps_resources.stage_inputs) + { + if (ps->get_name(resource.id) == "FragCoord") + { + uint32_t location = ps->get_decoration(resource.id, spv::DecorationLocation); + ps_attrib_remap.push_back({ location, "SV_Position" }); name_of_type = "float4"; - }; + } + } + } + }; ps->set_variable_type_remap_callback(ps_var_remap_cb); vs_code = vs->compile(vs_attrib_remap); From dda52a1eeda4fecdc57f7f0a4ef6a8e630f7fd44 Mon Sep 17 00:00:00 2001 From: leiradel Date: Thu, 1 Feb 2018 21:54:11 +0000 Subject: [PATCH 006/232] Fixed unable to use savestates when the game has no cheevos and an associated freeze --- cheevos/cheevos.c | 74 ++++++++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 33 deletions(-) diff --git a/cheevos/cheevos.c b/cheevos/cheevos.c index 425577807e..3d25b8091f 100644 --- a/cheevos/cheevos.c +++ b/cheevos/cheevos.c @@ -611,19 +611,19 @@ static void cheevos_build_memaddr(const cheevos_condition_t* condition, case CHEEVOS_COND_OP_EQUALS: cheevos_add_char(&aux, &left, '='); break; - case CHEEVOS_COND_OP_GREATER_THAN: + case CHEEVOS_COND_OP_GREATER_THAN: cheevos_add_char(&aux, &left, '>'); break; - case CHEEVOS_COND_OP_GREATER_THAN_OR_EQUAL: + case CHEEVOS_COND_OP_GREATER_THAN_OR_EQUAL: cheevos_add_string(&aux, &left, ">="); break; - case CHEEVOS_COND_OP_LESS_THAN: + case CHEEVOS_COND_OP_LESS_THAN: cheevos_add_char(&aux, &left, '<'); break; - case CHEEVOS_COND_OP_LESS_THAN_OR_EQUAL: + case CHEEVOS_COND_OP_LESS_THAN_OR_EQUAL: cheevos_add_string(&aux, &left, "<="); break; - case CHEEVOS_COND_OP_NOT_EQUAL_TO: + case CHEEVOS_COND_OP_NOT_EQUAL_TO: cheevos_add_string(&aux, &left, "!="); break; } @@ -3095,6 +3095,26 @@ found: if ((void*)coro->json) free((void*)coro->json); + if ( cheevos_locals.core.count == 0 + && cheevos_locals.unofficial.count == 0 + && cheevos_locals.lboard_count == 0) + { + runloop_msg_queue_push( + "This game has no achievements.", + 0, 5 * 60, false); + + cheevos_free_cheevo_set(&cheevos_locals.core); + cheevos_free_cheevo_set(&cheevos_locals.unofficial); + + cheevos_locals.core.cheevos = NULL; + cheevos_locals.unofficial.cheevos = NULL; + cheevos_locals.core.count = 0; + cheevos_locals.unofficial.count = 0; + + cheevos_loaded = false; + CORO_STOP(); + } + cheevos_loaded = true; /* @@ -3109,40 +3129,28 @@ found: */ CORO_GOSUB(PLAYING); - if (coro->settings->bools.cheevos_verbose_enable) + if (coro->settings->bools.cheevos_verbose_enable && cheevos_locals.core.count > 0) { - if(cheevos_locals.core.count > 0) - { - char msg[256]; - int mode = CHEEVOS_ACTIVE_SOFTCORE; - const cheevo_t* cheevo = cheevos_locals.core.cheevos; - const cheevo_t* end = cheevo + cheevos_locals.core.count; - int number_of_unlocked = cheevos_locals.core.count; + char msg[256]; + int mode = CHEEVOS_ACTIVE_SOFTCORE; + const cheevo_t* cheevo = cheevos_locals.core.cheevos; + const cheevo_t* end = cheevo + cheevos_locals.core.count; + int number_of_unlocked = cheevos_locals.core.count; - if (coro->settings->bools.cheevos_hardcore_mode_enable) - mode = CHEEVOS_ACTIVE_HARDCORE; + if (coro->settings->bools.cheevos_hardcore_mode_enable) + mode = CHEEVOS_ACTIVE_HARDCORE; - for (; cheevo < end; cheevo++) - if(cheevo->active & mode) - number_of_unlocked--; + for (; cheevo < end; cheevo++) + if(cheevo->active & mode) + number_of_unlocked--; - snprintf(msg, sizeof(msg), - "You have %d of %d achievements unlocked.", - number_of_unlocked, cheevos_locals.core.count); - msg[sizeof(msg) - 1] = 0; - runloop_msg_queue_push(msg, 0, 6 * 60, false); - } - else - runloop_msg_queue_push( - "This game has no achievements.", - 0, 5 * 60, false); + snprintf(msg, sizeof(msg), + "You have %d of %d achievements unlocked.", + number_of_unlocked, cheevos_locals.core.count); + msg[sizeof(msg) - 1] = 0; + runloop_msg_queue_push(msg, 0, 6 * 60, false); } - if ( cheevos_locals.core.count == 0 - && cheevos_locals.unofficial.count == 0 - && cheevos_locals.lboard_count == 0) - cheevos_unload(); - CORO_GOSUB(GET_BADGES); CORO_STOP(); From caad590d04f5cd527d0a31ee8294ac3998cf01b0 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Fri, 2 Feb 2018 01:50:18 +0100 Subject: [PATCH 007/232] (slang) slang_process: fix compatibility with more shaders. --- gfx/drivers_shader/slang_process.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/gfx/drivers_shader/slang_process.cpp b/gfx/drivers_shader/slang_process.cpp index a4566ac54c..af54e3b8b5 100644 --- a/gfx/drivers_shader/slang_process.cpp +++ b/gfx/drivers_shader/slang_process.cpp @@ -420,18 +420,19 @@ bool slang_process( std::string& name_of_type) { if (var_name == "FragCoord") { - for (Resource& resource : ps_resources.stage_inputs) - { - if (ps->get_name(resource.id) == "FragCoord") - { - uint32_t location = ps->get_decoration(resource.id, spv::DecorationLocation); - ps_attrib_remap.push_back({ location, "SV_Position" }); - name_of_type = "float4"; - } - } + name_of_type = "float4"; } }; - ps->set_variable_type_remap_callback(ps_var_remap_cb); + for (Resource& resource : ps_resources.stage_inputs) + { + if (ps->get_name(resource.id) == "FragCoord") + { + uint32_t location = ps->get_decoration(resource.id, spv::DecorationLocation); + ps_attrib_remap.push_back({ location, "SV_Position" }); + ps->set_variable_type_remap_callback(ps_var_remap_cb); + } + } + vs_code = vs->compile(vs_attrib_remap); ps_code = ps->compile(ps_attrib_remap); From 1e96393228dd980048cf938a7ab23a1eebd6971d Mon Sep 17 00:00:00 2001 From: aliaspider Date: Fri, 2 Feb 2018 02:21:18 +0100 Subject: [PATCH 008/232] (D3D11) font renderer: fix line spacing. --- gfx/drivers_font/d3d11_font.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/drivers_font/d3d11_font.c b/gfx/drivers_font/d3d11_font.c index 09f6c36b83..ab47e5f681 100644 --- a/gfx/drivers_font/d3d11_font.c +++ b/gfx/drivers_font/d3d11_font.c @@ -244,7 +244,7 @@ static void d3d11_font_render_message( return; } - line_height = scale / font->font_driver->get_line_height(font->font_data); + line_height = font->font_driver->get_line_height(font->font_data) * scale / video_info->height; for (;;) { From cd5852d3b0f87869f43d6ccd15291226a036ddfc Mon Sep 17 00:00:00 2001 From: aliaspider Date: Fri, 2 Feb 2018 11:53:23 +0100 Subject: [PATCH 009/232] use git subtree for deps/SPIRV-Cross --- deps/SPIRV-Cross/.clang-format | 167 - deps/SPIRV-Cross/.gitignore | 19 - deps/SPIRV-Cross/.travis.yml | 33 - deps/SPIRV-Cross/CMakeLists.txt | 145 - deps/SPIRV-Cross/GLSL.std.450.h | 131 - deps/SPIRV-Cross/LICENSE | 202 - deps/SPIRV-Cross/Makefile | 41 - deps/SPIRV-Cross/README.md | 350 - .../checkout_glslang_spirv_tools.sh | 57 - deps/SPIRV-Cross/format_all.sh | 7 - .../include/spirv_cross/barrier.hpp | 79 - .../include/spirv_cross/external_interface.h | 126 - .../SPIRV-Cross/include/spirv_cross/image.hpp | 62 - .../spirv_cross/internal_interface.hpp | 603 -- .../include/spirv_cross/sampler.hpp | 105 - .../include/spirv_cross/thread_group.hpp | 113 - deps/SPIRV-Cross/jni/Android.mk | 12 - deps/SPIRV-Cross/jni/Application.mk | 2 - deps/SPIRV-Cross/main.cpp | 923 -- deps/SPIRV-Cross/msvc/SPIRV-Cross.sln | 28 - deps/SPIRV-Cross/msvc/SPIRV-Cross.vcxproj | 148 - .../msvc/SPIRV-Cross.vcxproj.filters | 69 - ...lization-constant-workgroup.nofxc.asm.comp | 16 - .../comp/storage-buffer-basic.nofxc.asm.comp | 24 - .../asm/frag/cbuffer-stripped.asm.frag | 25 - .../asm/frag/unreachable.asm.frag | 42 - .../asm/vert/empty-struct-composite.asm.vert | 8 - .../asm/vert/vertex-id-instance-id.asm.vert | 28 - .../opt/shaders-hlsl/comp/access-chains.comp | 21 - .../shaders-hlsl/comp/address-buffers.comp | 15 - .../opt/shaders-hlsl/comp/atomic.comp | 89 - .../opt/shaders-hlsl/comp/barriers.comp | 26 - .../opt/shaders-hlsl/comp/bitfield.noopt.comp | 113 - .../opt/shaders-hlsl/comp/builtins.comp | 9 - .../opt/shaders-hlsl/comp/image.comp | 62 - .../shaders-hlsl/comp/rwbuffer-matrix.comp | 90 - .../opt/shaders-hlsl/comp/shared.comp | 29 - .../opt/shaders-hlsl/comp/ssbo-array.comp | 9 - .../opt/shaders-hlsl/frag/basic.frag | 32 - .../shaders-hlsl/frag/bit-conversions.frag | 26 - .../opt/shaders-hlsl/frag/boolean-mix.frag | 27 - .../opt/shaders-hlsl/frag/builtins.frag | 33 - .../shaders-hlsl/frag/bvec-operations.frag | 27 - .../combined-texture-sampler-parameter.frag | 24 - .../frag/combined-texture-sampler-shadow.frag | 23 - .../frag/constant-buffer-array.sm51.frag | 43 - .../frag/early-fragment-test.frag | 9 - .../opt/shaders-hlsl/frag/fp16-packing.frag | 44 - .../frag/image-query-selective.frag | 29 - .../opt/shaders-hlsl/frag/image-query.frag | 8 - .../opt/shaders-hlsl/frag/io-block.frag | 28 - .../opt/shaders-hlsl/frag/matrix-input.frag | 26 - .../reference/opt/shaders-hlsl/frag/mod.frag | 67 - .../reference/opt/shaders-hlsl/frag/mrt.frag | 31 - .../opt/shaders-hlsl/frag/no-return.frag | 8 - .../opt/shaders-hlsl/frag/no-return2.frag | 16 - .../frag/partial-write-preserve.frag | 14 - .../shaders-hlsl/frag/query-lod.desktop.frag | 30 - .../opt/shaders-hlsl/frag/resources.frag | 39 - .../frag/sample-cmp-level-zero.frag | 57 - .../opt/shaders-hlsl/frag/sampler-array.frag | 29 - .../opt/shaders-hlsl/frag/spec-constant.frag | 33 - .../opt/shaders-hlsl/frag/swizzle-scalar.frag | 41 - .../opt/shaders-hlsl/frag/tex-sampling.frag | 87 - .../frag/texture-proj-shadow.frag | 66 - .../opt/shaders-hlsl/frag/unary-enclose.frag | 29 - .../frag/unorm-snorm-packing.frag | 109 - .../shaders-hlsl/frag/various-glsl-ops.frag | 26 - .../opt/shaders-hlsl/vert/basic.vert | 38 - .../opt/shaders-hlsl/vert/instancing.vert | 28 - .../opt/shaders-hlsl/vert/locations.vert | 79 - .../shaders-hlsl/vert/matrix-attribute.vert | 35 - .../opt/shaders-hlsl/vert/matrix-output.vert | 23 - .../opt/shaders-hlsl/vert/no-input.vert | 18 - .../shaders-hlsl/vert/point-size-compat.vert | 20 - .../opt/shaders-hlsl/vert/qualifiers.vert | 50 - .../shaders-hlsl/vert/sampler-buffers.vert | 22 - .../vert/struct-composite-decl.vert | 44 - .../opt/shaders-hlsl/vert/texture_buffer.vert | 21 - .../asm/comp/bitcast_iadd.asm.comp | 29 - .../shaders-msl/asm/comp/bitcast_sar.asm.comp | 29 - .../asm/comp/bitcast_sdiv.asm.comp | 29 - .../shaders-msl/asm/comp/bitcast_slr.asm.comp | 29 - .../asm/comp/multiple-entry.asm.comp | 29 - .../shaders-msl/asm/comp/quantize.asm.comp | 21 - ...specialization-constant-workgroup.asm.comp | 21 - .../asm/comp/storage-buffer-basic.asm.comp | 21 - .../asm/frag/default-member-names.asm.frag | 41 - .../inliner-dominator-inside-loop.asm.frag | 235 - .../asm/frag/op-constant-null.asm.frag | 23 - .../asm/frag/phi-loop-variable.asm.frag | 12 - .../asm/frag/undef-variable-store.asm.frag | 38 - .../shaders-msl/asm/frag/unreachable.asm.frag | 38 - .../asm/frag/vector-shuffle-oom.asm.frag | 321 - .../asm/vert/empty-struct-composite.asm.vert | 9 - .../opt/shaders-msl/comp/atomic.comp | 36 - .../opt/shaders-msl/comp/bake_gradient.comp | 22 - .../opt/shaders-msl/comp/barriers.comp | 20 - .../reference/opt/shaders-msl/comp/basic.comp | 33 - .../opt/shaders-msl/comp/bitfield.noopt.comp | 47 - .../opt/shaders-msl/comp/builtins.comp | 9 - .../comp/cfg-preserve-parameter.comp | 9 - .../opt/shaders-msl/comp/coherent-block.comp | 15 - .../opt/shaders-msl/comp/coherent-image.comp | 15 - .../opt/shaders-msl/comp/culling.comp | 35 - .../opt/shaders-msl/comp/defer-parens.comp | 21 - .../opt/shaders-msl/comp/dowhile.comp | 39 - .../opt/shaders-msl/comp/functions.comp | 11 - ...vocation-id-writable-ssbo-in-function.comp | 26 - .../comp/global-invocation-id.comp | 26 - .../reference/opt/shaders-msl/comp/image.comp | 10 - .../opt/shaders-msl/comp/insert.comp | 26 - .../shaders-msl/comp/local-invocation-id.comp | 26 - .../comp/local-invocation-index.comp | 26 - .../opt/shaders-msl/comp/loop.noopt.comp | 107 - .../reference/opt/shaders-msl/comp/mat3.comp | 15 - .../reference/opt/shaders-msl/comp/mod.comp | 31 - .../reference/opt/shaders-msl/comp/modf.comp | 22 - .../opt/shaders-msl/comp/read-write-only.comp | 29 - .../opt/shaders-msl/comp/return.comp | 33 - .../opt/shaders-msl/comp/rmw-opt.comp | 26 - .../opt/shaders-msl/comp/shared.comp | 25 - .../opt/shaders-msl/comp/struct-layout.comp | 25 - .../opt/shaders-msl/comp/struct-packing.comp | 100 - .../opt/shaders-msl/comp/torture-loop.comp | 79 - .../opt/shaders-msl/comp/type-alias.comp | 35 - .../reference/opt/shaders-msl/comp/udiv.comp | 20 - .../opt/shaders-msl/comp/writable-ssbo.comp | 26 - .../desktop-only/frag/image-ms.desktop.frag | 11 - .../frag/query-levels.desktop.frag | 17 - .../frag/sampler-ms-query.desktop.frag | 17 - .../desktop-only/vert/basic.desktop.sso.vert | 30 - .../vert/clip-cull-distance.desktop.vert | 23 - .../shaders-msl/flatten/basic.flatten.vert | 30 - .../flatten/multiindex.flatten.vert | 27 - .../flatten/push-constant.flatten.vert | 32 - .../shaders-msl/flatten/rowmajor.flatten.vert | 29 - .../shaders-msl/flatten/struct.flatten.vert | 40 - .../shaders-msl/flatten/swizzle.flatten.vert | 47 - .../shaders-msl/flatten/types.flatten.frag | 35 - .../reference/opt/shaders-msl/frag/basic.frag | 23 - .../opt/shaders-msl/frag/bitcasting.frag | 26 - .../opt/shaders-msl/frag/builtins.frag | 24 - .../composite-extract-forced-temporary.frag | 24 - .../opt/shaders-msl/frag/constant-array.frag | 31 - .../opt/shaders-msl/frag/false-loop-init.frag | 38 - .../opt/shaders-msl/frag/flush_params.frag | 22 - .../opt/shaders-msl/frag/for-loop-init.frag | 57 - .../opt/shaders-msl/frag/in_block.frag | 23 - .../frag/in_block_assign.noopt.frag | 30 - .../reference/opt/shaders-msl/frag/mix.frag | 29 - .../reference/opt/shaders-msl/frag/pls.frag | 31 - .../opt/shaders-msl/frag/sampler-ms.frag | 18 - .../opt/shaders-msl/frag/sampler.frag | 23 - .../frag/separate-image-sampler-argument.frag | 17 - .../opt/shaders-msl/frag/swizzle.frag | 28 - .../shaders-msl/frag/texture-proj-shadow.frag | 29 - .../opt/shaders-msl/frag/ubo_layout.frag | 32 - .../opt/shaders-msl/frag/unary-enclose.frag | 22 - .../legacy/vert/transpose.legacy.vert | 29 - .../reference/opt/shaders-msl/vert/basic.vert | 30 - .../opt/shaders-msl/vert/copy.flatten.vert | 43 - .../opt/shaders-msl/vert/dynamic.flatten.vert | 43 - .../opt/shaders-msl/vert/functions.vert | 119 - .../opt/shaders-msl/vert/out_block.vert | 32 - .../opt/shaders-msl/vert/pointsize.vert | 33 - .../opt/shaders-msl/vert/texture_buffer.vert | 17 - .../opt/shaders-msl/vert/ubo.alignment.vert | 38 - .../reference/opt/shaders-msl/vert/ubo.vert | 30 - .../vulkan/frag/push-constant.vk.frag | 28 - .../vulkan/frag/spec-constant.vk.frag | 22 - .../vulkan/vert/vulkan-vertex.vk.vert | 17 - ...etch_subpassInput.vk.nocompat.invalid.frag | 11 - ...h_subpassInput.vk.nocompat.invalid.frag.vk | 11 - .../reference/opt/shaders/amd/fs.invalid.frag | 15 - .../reference/opt/shaders/amd/gcn_shader.comp | 8 - .../opt/shaders/amd/shader_ballot.comp | 26 - ...ballot_nonuniform_invocations.invalid.comp | 11 - .../opt/shaders/amd/shader_group_vote.comp | 7 - .../shaders/amd/shader_trinary_minmax.comp | 7 - .../shaders/asm/comp/bitcast_iadd.asm.comp | 27 - .../shaders/asm/comp/bitcast_iequal.asm.comp | 31 - .../opt/shaders/asm/comp/bitcast_sar.asm.comp | 27 - .../shaders/asm/comp/bitcast_sdiv.asm.comp | 27 - .../opt/shaders/asm/comp/bitcast_slr.asm.comp | 27 - .../opt/shaders/asm/comp/logical.asm.comp | 7 - .../shaders/asm/comp/multiple-entry.asm.comp | 27 - .../asm/comp/name-alias.asm.invalid.comp | 37 - .../opt/shaders/asm/comp/quantize.asm.comp | 19 - ...specialization-constant-workgroup.asm.comp | 13 - .../asm/comp/storage-buffer-basic.asm.comp | 18 - ...osite-construct-struct-no-swizzle.asm.frag | 18 - .../asm/frag/default-member-names.asm.frag | 33 - .../hlsl-sample-cmp-level-zero-cube.asm.frag | 11 - .../frag/hlsl-sample-cmp-level-zero.asm.frag | 14 - .../inliner-dominator-inside-loop.asm.frag | 227 - .../shaders/asm/frag/invalidation.asm.frag | 11 - ...op-body-dominator-continue-access.asm.frag | 52 - .../asm/frag/multi-for-loop-init.asm.frag | 19 - .../asm/frag/op-constant-null.asm.frag | 17 - .../asm/frag/phi-loop-variable.asm.frag | 9 - .../sampler-buffer-without-sampler.asm.frag | 13 - .../struct-composite-extract-swizzle.asm.frag | 21 - .../asm/frag/temporary-phi-hoisting.asm.frag | 26 - .../asm/frag/undef-variable-store.asm.frag | 30 - .../opt/shaders/asm/frag/unreachable.asm.frag | 26 - .../asm/frag/vector-shuffle-oom.asm.frag | 316 - ...s-fixed-input-array-builtin-array.asm.tesc | 81 - .../opt/shaders/asm/vert/empty-io.asm.vert | 19 - .../asm/vert/empty-struct-composite.asm.vert | 6 - .../asm/vert/global-builtin.sso.asm.vert | 26 - .../reference/opt/shaders/comp/atomic.comp | 49 - .../opt/shaders/comp/bake_gradient.comp | 23 - .../reference/opt/shaders/comp/barriers.comp | 28 - .../reference/opt/shaders/comp/basic.comp | 28 - .../opt/shaders/comp/bitfield.noopt.comp | 19 - .../reference/opt/shaders/comp/casts.comp | 18 - .../shaders/comp/cfg-preserve-parameter.comp | 7 - .../reference/opt/shaders/comp/cfg.comp | 56 - .../opt/shaders/comp/coherent-block.comp | 13 - .../opt/shaders/comp/coherent-image.comp | 15 - .../opt/shaders/comp/composite-construct.comp | 26 - .../reference/opt/shaders/comp/culling.comp | 28 - .../opt/shaders/comp/defer-parens.comp | 19 - .../reference/opt/shaders/comp/dowhile.comp | 39 - .../opt/shaders/comp/generate_height.comp | 54 - .../reference/opt/shaders/comp/image.comp | 11 - .../shaders/comp/inout-struct.invalid.comp | 65 - .../reference/opt/shaders/comp/insert.comp | 24 - .../opt/shaders/comp/loop.noopt.comp | 105 - .../reference/opt/shaders/comp/mat3.comp | 13 - .../reference/opt/shaders/comp/mod.comp | 20 - .../reference/opt/shaders/comp/modf.comp | 20 - .../opt/shaders/comp/read-write-only.comp | 27 - .../reference/opt/shaders/comp/return.comp | 31 - .../reference/opt/shaders/comp/rmw-opt.comp | 24 - .../reference/opt/shaders/comp/shared.comp | 23 - .../opt/shaders/comp/ssbo-array.comp | 13 - .../opt/shaders/comp/struct-layout.comp | 23 - .../opt/shaders/comp/struct-packing.comp | 104 - .../opt/shaders/comp/torture-loop.comp | 77 - .../opt/shaders/comp/type-alias.comp | 33 - .../reference/opt/shaders/comp/udiv.comp | 18 - .../desktop-only/comp/enhanced-layouts.comp | 40 - .../desktop-only/comp/fp64.desktop.comp | 63 - .../image-formats.desktop.noeliminate.comp | 7 - .../desktop-only/comp/int64.desktop.comp | 52 - .../frag/hlsl-uav-block-alias.asm.frag | 19 - .../desktop-only/frag/image-ms.desktop.frag | 12 - .../frag/image-query.desktop.frag | 16 - .../frag/in-block-qualifiers.frag | 21 - .../frag/query-levels.desktop.frag | 11 - .../desktop-only/frag/query-lod.desktop.frag | 12 - .../frag/sampler-ms-query.desktop.frag | 14 - .../frag/texture-proj-shadow.desktop.frag | 26 - .../desktop-only/geom/basic.desktop.sso.geom | 35 - .../geom/viewport-index.desktop.geom | 9 - .../desktop-only/tesc/basic.desktop.sso.tesc | 27 - .../tese/triangle.desktop.sso.tese | 18 - .../desktop-only/vert/basic.desktop.sso.vert | 22 - .../vert/clip-cull-distance.desktop.vert | 11 - .../vert/out-block-qualifiers.vert | 27 - .../opt/shaders/flatten/array.flatten.vert | 10 - .../opt/shaders/flatten/basic.flatten.vert | 13 - .../opt/shaders/flatten/copy.flatten.vert | 25 - .../opt/shaders/flatten/dynamic.flatten.vert | 25 - .../shaders/flatten/matrixindex.flatten.vert | 19 - ...multi-dimensional.desktop.flatten_dim.frag | 34 - .../shaders/flatten/multiindex.flatten.vert | 10 - .../flatten/push-constant.flatten.vert | 13 - .../opt/shaders/flatten/rowmajor.flatten.vert | 10 - .../opt/shaders/flatten/struct.flatten.vert | 22 - .../flatten/struct.rowmajor.flatten.vert | 20 - .../opt/shaders/flatten/swizzle.flatten.vert | 21 - .../opt/shaders/flatten/types.flatten.frag | 14 - .../reference/opt/shaders/frag/basic.frag | 15 - .../composite-extract-forced-temporary.frag | 16 - .../opt/shaders/frag/constant-array.frag | 21 - .../frag/eliminate-dead-variables.frag | 14 - .../opt/shaders/frag/false-loop-init.frag | 28 - .../opt/shaders/frag/flush_params.frag | 16 - .../opt/shaders/frag/for-loop-init.frag | 51 - .../opt/shaders/frag/frexp-modf.frag | 33 - .../reference/opt/shaders/frag/ground.frag | 35 - .../frag/image-load-store-uint-coord.asm.frag | 17 - .../reference/opt/shaders/frag/mix.frag | 18 - .../shaders/frag/partial-write-preserve.frag | 14 - .../reference/opt/shaders/frag/pls.frag | 21 - .../opt/shaders/frag/sample-parameter.frag | 13 - .../opt/shaders/frag/sampler-ms-query.frag | 14 - .../opt/shaders/frag/sampler-ms.frag | 14 - .../opt/shaders/frag/sampler-proj.frag | 16 - .../reference/opt/shaders/frag/sampler.frag | 15 - .../reference/opt/shaders/frag/swizzle.frag | 20 - .../reference/opt/shaders/frag/temporary.frag | 14 - .../opt/shaders/frag/ubo_layout.frag | 26 - .../opt/shaders/frag/unary-enclose.frag | 12 - .../reference/opt/shaders/geom/basic.geom | 26 - .../opt/shaders/geom/lines-adjacency.geom | 26 - .../reference/opt/shaders/geom/lines.geom | 23 - .../reference/opt/shaders/geom/points.geom | 26 - .../opt/shaders/geom/single-invocation.geom | 26 - .../opt/shaders/geom/triangles-adjacency.geom | 26 - .../reference/opt/shaders/geom/triangles.geom | 26 - .../legacy/fragment/explicit-lod.legacy.frag | 12 - .../legacy/fragment/io-blocks.legacy.frag | 12 - .../fragment/struct-varying.legacy.frag | 18 - .../legacy/vert/implicit-lod.legacy.vert | 9 - .../shaders/legacy/vert/io-block.legacy.vert | 13 - .../legacy/vert/struct-varying.legacy.vert | 30 - .../shaders/legacy/vert/transpose.legacy.vert | 18 - .../reference/opt/shaders/tesc/basic.tesc | 17 - .../opt/shaders/tesc/water_tess.tesc | 79 - .../reference/opt/shaders/tese/ccw.tese | 9 - .../reference/opt/shaders/tese/cw.tese | 9 - .../reference/opt/shaders/tese/equal.tese | 9 - .../opt/shaders/tese/fractional_even.tese | 9 - .../opt/shaders/tese/fractional_odd.tese | 9 - .../reference/opt/shaders/tese/line.tese | 9 - .../reference/opt/shaders/tese/triangle.tese | 9 - .../opt/shaders/tese/water_tess.tese | 37 - .../reference/opt/shaders/vert/basic.vert | 17 - .../reference/opt/shaders/vert/ground.vert | 87 - .../reference/opt/shaders/vert/ocean.vert | 117 - .../opt/shaders/vert/texture_buffer.vert | 11 - .../reference/opt/shaders/vert/ubo.vert | 17 - .../combined-texture-sampler-shadow.vk.frag | 14 - ...combined-texture-sampler-shadow.vk.frag.vk | 15 - .../frag/combined-texture-sampler.vk.frag | 17 - .../frag/combined-texture-sampler.vk.frag.vk | 17 - .../vulkan/frag/desktop-mediump.vk.frag | 12 - .../vulkan/frag/desktop-mediump.vk.frag.vk | 12 - .../vulkan/frag/input-attachment-ms.vk.frag | 12 - .../frag/input-attachment-ms.vk.frag.vk | 12 - .../vulkan/frag/input-attachment.vk.frag | 14 - .../vulkan/frag/input-attachment.vk.frag.vk | 14 - .../shaders/vulkan/frag/push-constant.vk.frag | 20 - .../vulkan/frag/push-constant.vk.frag.vk | 18 - .../frag/separate-sampler-texture.vk.frag | 20 - .../frag/separate-sampler-texture.vk.frag.vk | 21 - .../shaders/vulkan/frag/spec-constant.vk.frag | 20 - .../vulkan/frag/spec-constant.vk.frag.vk | 25 - .../vulkan/vert/multiview.nocompat.vk.vert | 15 - .../vulkan/vert/multiview.nocompat.vk.vert.vk | 15 - .../shaders/vulkan/vert/vulkan-vertex.vk.vert | 9 - .../vulkan/vert/vulkan-vertex.vk.vert.vk | 7 - ...lization-constant-workgroup.nofxc.asm.comp | 16 - .../comp/storage-buffer-basic.nofxc.asm.comp | 26 - .../asm/frag/cbuffer-stripped.asm.frag | 31 - .../asm/frag/unreachable.asm.frag | 44 - .../asm/vert/empty-struct-composite.asm.vert | 8 - .../asm/vert/vertex-id-instance-id.asm.vert | 28 - .../shaders-hlsl/comp/access-chains.comp | 21 - .../shaders-hlsl/comp/address-buffers.comp | 15 - .../reference/shaders-hlsl/comp/atomic.comp | 89 - .../reference/shaders-hlsl/comp/barriers.comp | 81 - .../shaders-hlsl/comp/bitfield.noopt.comp | 113 - .../reference/shaders-hlsl/comp/builtins.comp | 32 - .../reference/shaders-hlsl/comp/image.comp | 71 - .../shaders-hlsl/comp/rwbuffer-matrix.comp | 136 - .../reference/shaders-hlsl/comp/shared.comp | 31 - .../shaders-hlsl/comp/ssbo-array.comp | 11 - .../reference/shaders-hlsl/frag/basic.frag | 32 - .../shaders-hlsl/frag/bit-conversions.frag | 27 - .../shaders-hlsl/frag/boolean-mix.frag | 27 - .../reference/shaders-hlsl/frag/builtins.frag | 33 - .../shaders-hlsl/frag/bvec-operations.frag | 29 - .../combined-texture-sampler-parameter.frag | 44 - .../frag/combined-texture-sampler-shadow.frag | 40 - .../frag/constant-buffer-array.sm51.frag | 43 - .../frag/early-fragment-test.frag | 9 - .../shaders-hlsl/frag/fp16-packing.frag | 44 - .../frag/image-query-selective.frag | 146 - .../shaders-hlsl/frag/image-query.frag | 132 - .../reference/shaders-hlsl/frag/io-block.frag | 28 - .../shaders-hlsl/frag/matrix-input.frag | 26 - .../reference/shaders-hlsl/frag/mod.frag | 71 - .../reference/shaders-hlsl/frag/mrt.frag | 31 - .../shaders-hlsl/frag/no-return.frag | 8 - .../shaders-hlsl/frag/no-return2.frag | 17 - .../frag/partial-write-preserve.frag | 73 - .../shaders-hlsl/frag/query-lod.desktop.frag | 30 - .../shaders-hlsl/frag/resources.frag | 42 - .../frag/sample-cmp-level-zero.frag | 66 - .../shaders-hlsl/frag/sampler-array.frag | 43 - .../shaders-hlsl/frag/spec-constant.frag | 79 - .../shaders-hlsl/frag/swizzle-scalar.frag | 41 - .../shaders-hlsl/frag/tex-sampling.frag | 118 - .../frag/texture-proj-shadow.frag | 66 - .../shaders-hlsl/frag/unary-enclose.frag | 32 - .../frag/unorm-snorm-packing.frag | 109 - .../shaders-hlsl/frag/various-glsl-ops.frag | 28 - .../reference/shaders-hlsl/vert/basic.vert | 38 - .../shaders-hlsl/vert/instancing.vert | 28 - .../shaders-hlsl/vert/locations.vert | 75 - .../shaders-hlsl/vert/matrix-attribute.vert | 35 - .../shaders-hlsl/vert/matrix-output.vert | 23 - .../reference/shaders-hlsl/vert/no-input.vert | 18 - .../shaders-hlsl/vert/point-size-compat.vert | 20 - .../shaders-hlsl/vert/qualifiers.vert | 50 - .../shaders-hlsl/vert/sampler-buffers.vert | 27 - .../vert/struct-composite-decl.vert | 50 - .../shaders-hlsl/vert/texture_buffer.vert | 21 - .../vert/functions_nested.vert | 189 - .../asm/comp/bitcast_iadd.asm.comp | 29 - .../shaders-msl/asm/comp/bitcast_sar.asm.comp | 29 - .../asm/comp/bitcast_sdiv.asm.comp | 29 - .../shaders-msl/asm/comp/bitcast_slr.asm.comp | 29 - .../asm/comp/multiple-entry.asm.comp | 29 - .../shaders-msl/asm/comp/quantize.asm.comp | 21 - ...specialization-constant-workgroup.asm.comp | 21 - .../asm/comp/storage-buffer-basic.asm.comp | 22 - .../asm/frag/default-member-names.asm.frag | 40 - .../inliner-dominator-inside-loop.asm.frag | 235 - .../asm/frag/op-constant-null.asm.frag | 28 - .../asm/frag/phi-loop-variable.asm.frag | 12 - .../asm/frag/undef-variable-store.asm.frag | 37 - .../shaders-msl/asm/frag/unreachable.asm.frag | 40 - .../asm/frag/vector-shuffle-oom.asm.frag | 321 - .../asm/vert/empty-struct-composite.asm.vert | 9 - .../reference/shaders-msl/comp/atomic.comp | 36 - .../shaders-msl/comp/bake_gradient.comp | 40 - .../reference/shaders-msl/comp/barriers.comp | 67 - .../reference/shaders-msl/comp/basic.comp | 34 - .../shaders-msl/comp/bitfield.noopt.comp | 47 - .../reference/shaders-msl/comp/builtins.comp | 17 - .../comp/cfg-preserve-parameter.comp | 78 - .../shaders-msl/comp/coherent-block.comp | 15 - .../shaders-msl/comp/coherent-image.comp | 15 - .../reference/shaders-msl/comp/culling.comp | 36 - .../shaders-msl/comp/defer-parens.comp | 23 - .../reference/shaders-msl/comp/dowhile.comp | 29 - .../reference/shaders-msl/comp/functions.comp | 18 - ...vocation-id-writable-ssbo-in-function.comp | 31 - .../comp/global-invocation-id.comp | 26 - .../reference/shaders-msl/comp/image.comp | 11 - .../reference/shaders-msl/comp/insert.comp | 21 - .../shaders-msl/comp/local-invocation-id.comp | 26 - .../comp/local-invocation-index.comp | 26 - .../shaders-msl/comp/loop.noopt.comp | 107 - .../reference/shaders-msl/comp/mat3.comp | 16 - .../reference/shaders-msl/comp/mod.comp | 35 - .../reference/shaders-msl/comp/modf.comp | 24 - .../shaders-msl/comp/read-write-only.comp | 29 - .../reference/shaders-msl/comp/return.comp | 36 - .../reference/shaders-msl/comp/rmw-opt.comp | 29 - .../reference/shaders-msl/comp/shared.comp | 27 - .../shaders-msl/comp/struct-layout.comp | 26 - .../shaders-msl/comp/struct-packing.comp | 100 - .../shaders-msl/comp/torture-loop.comp | 51 - .../shaders-msl/comp/type-alias.comp | 53 - .../reference/shaders-msl/comp/udiv.comp | 20 - .../shaders-msl/comp/writable-ssbo.comp | 26 - .../desktop-only/frag/image-ms.desktop.frag | 13 - .../frag/query-levels.desktop.frag | 17 - .../frag/sampler-ms-query.desktop.frag | 17 - .../desktop-only/vert/basic.desktop.sso.vert | 30 - .../vert/clip-cull-distance.desktop.vert | 23 - .../shaders-msl/flatten/basic.flatten.vert | 30 - .../flatten/multiindex.flatten.vert | 27 - .../flatten/push-constant.flatten.vert | 32 - .../shaders-msl/flatten/rowmajor.flatten.vert | 38 - .../shaders-msl/flatten/struct.flatten.vert | 40 - .../shaders-msl/flatten/swizzle.flatten.vert | 47 - .../shaders-msl/flatten/types.flatten.frag | 35 - .../reference/shaders-msl/frag/basic.frag | 23 - .../shaders-msl/frag/bitcasting.frag | 30 - .../reference/shaders-msl/frag/builtins.frag | 24 - .../composite-extract-forced-temporary.frag | 23 - .../shaders-msl/frag/constant-array.frag | 40 - .../shaders-msl/frag/false-loop-init.frag | 35 - .../shaders-msl/frag/flush_params.frag | 38 - .../shaders-msl/frag/for-loop-init.frag | 58 - .../reference/shaders-msl/frag/in_block.frag | 23 - .../frag/in_block_assign.noopt.frag | 30 - .../reference/shaders-msl/frag/mix.frag | 31 - .../reference/shaders-msl/frag/pls.frag | 31 - .../shaders-msl/frag/sampler-ms.frag | 18 - .../reference/shaders-msl/frag/sampler.frag | 31 - .../frag/separate-image-sampler-argument.frag | 24 - .../reference/shaders-msl/frag/swizzle.frag | 28 - .../shaders-msl/frag/texture-proj-shadow.frag | 29 - .../shaders-msl/frag/ubo_layout.frag | 32 - .../shaders-msl/frag/unary-enclose.frag | 26 - .../legacy/vert/transpose.legacy.vert | 33 - .../reference/shaders-msl/vert/basic.vert | 30 - .../shaders-msl/vert/copy.flatten.vert | 47 - .../shaders-msl/vert/dynamic.flatten.vert | 43 - .../reference/shaders-msl/vert/functions.vert | 119 - .../reference/shaders-msl/vert/out_block.vert | 32 - .../reference/shaders-msl/vert/pointsize.vert | 33 - .../shaders-msl/vert/texture_buffer.vert | 17 - .../shaders-msl/vert/ubo.alignment.vert | 38 - .../reference/shaders-msl/vert/ubo.vert | 30 - .../vulkan/frag/push-constant.vk.frag | 28 - .../vulkan/frag/spec-constant.vk.frag | 74 - .../vulkan/vert/vulkan-vertex.vk.vert | 17 - ...etch_subpassInput.vk.nocompat.invalid.frag | 11 - ...h_subpassInput.vk.nocompat.invalid.frag.vk | 11 - .../reference/shaders/amd/fs.invalid.frag | 15 - .../reference/shaders/amd/gcn_shader.comp | 12 - .../reference/shaders/amd/shader_ballot.comp | 32 - ...ballot_nonuniform_invocations.invalid.comp | 11 - .../shaders/amd/shader_group_vote.comp | 18 - .../shaders/amd/shader_trinary_minmax.comp | 11 - .../shaders/asm/comp/bitcast_iadd.asm.comp | 27 - .../shaders/asm/comp/bitcast_iequal.asm.comp | 31 - .../shaders/asm/comp/bitcast_sar.asm.comp | 27 - .../shaders/asm/comp/bitcast_sdiv.asm.comp | 27 - .../shaders/asm/comp/bitcast_slr.asm.comp | 27 - .../shaders/asm/comp/logical.asm.comp | 56 - .../shaders/asm/comp/multiple-entry.asm.comp | 27 - .../asm/comp/name-alias.asm.invalid.comp | 37 - .../shaders/asm/comp/quantize.asm.comp | 19 - ...specialization-constant-workgroup.asm.comp | 13 - .../asm/comp/storage-buffer-basic.asm.comp | 20 - ...osite-construct-struct-no-swizzle.asm.frag | 19 - .../asm/frag/default-member-names.asm.frag | 32 - .../hlsl-sample-cmp-level-zero-cube.asm.frag | 17 - .../frag/hlsl-sample-cmp-level-zero.asm.frag | 27 - .../inliner-dominator-inside-loop.asm.frag | 227 - .../shaders/asm/frag/invalidation.asm.frag | 15 - ...op-body-dominator-continue-access.asm.frag | 48 - .../asm/frag/multi-for-loop-init.asm.frag | 19 - .../asm/frag/op-constant-null.asm.frag | 22 - .../asm/frag/phi-loop-variable.asm.frag | 9 - .../sampler-buffer-without-sampler.asm.frag | 20 - .../struct-composite-extract-swizzle.asm.frag | 21 - .../asm/frag/temporary-phi-hoisting.asm.frag | 26 - .../asm/frag/undef-variable-store.asm.frag | 29 - .../shaders/asm/frag/unreachable.asm.frag | 28 - .../asm/frag/vector-shuffle-oom.asm.frag | 316 - ...s-fixed-input-array-builtin-array.asm.tesc | 79 - .../shaders/asm/vert/empty-io.asm.vert | 29 - .../asm/vert/empty-struct-composite.asm.vert | 6 - .../asm/vert/global-builtin.sso.asm.vert | 35 - .../reference/shaders/comp/atomic.comp | 49 - .../reference/shaders/comp/bake_gradient.comp | 39 - .../reference/shaders/comp/barriers.comp | 83 - .../reference/shaders/comp/basic.comp | 29 - .../shaders/comp/bitfield.noopt.comp | 19 - .../reference/shaders/comp/casts.comp | 19 - .../shaders/comp/cfg-preserve-parameter.comp | 74 - .../reference/shaders/comp/cfg.comp | 81 - .../shaders/comp/coherent-block.comp | 13 - .../shaders/comp/coherent-image.comp | 15 - .../shaders/comp/composite-construct.comp | 38 - .../reference/shaders/comp/culling.comp | 29 - .../reference/shaders/comp/defer-parens.comp | 21 - .../reference/shaders/comp/dowhile.comp | 29 - .../shaders/comp/generate_height.comp | 96 - .../reference/shaders/comp/image.comp | 12 - .../shaders/comp/inout-struct.invalid.comp | 65 - .../reference/shaders/comp/insert.comp | 19 - .../reference/shaders/comp/loop.noopt.comp | 105 - .../reference/shaders/comp/mat3.comp | 14 - .../reference/shaders/comp/mod.comp | 24 - .../reference/shaders/comp/modf.comp | 22 - .../shaders/comp/read-write-only.comp | 27 - .../reference/shaders/comp/return.comp | 34 - .../reference/shaders/comp/rmw-opt.comp | 27 - .../reference/shaders/comp/shared.comp | 25 - .../reference/shaders/comp/ssbo-array.comp | 14 - .../reference/shaders/comp/struct-layout.comp | 24 - .../shaders/comp/struct-packing.comp | 104 - .../reference/shaders/comp/torture-loop.comp | 49 - .../reference/shaders/comp/type-alias.comp | 49 - .../reference/shaders/comp/udiv.comp | 18 - .../desktop-only/comp/enhanced-layouts.comp | 40 - .../desktop-only/comp/fp64.desktop.comp | 84 - .../image-formats.desktop.noeliminate.comp | 47 - .../desktop-only/comp/int64.desktop.comp | 52 - .../frag/hlsl-uav-block-alias.asm.frag | 24 - .../desktop-only/frag/image-ms.desktop.frag | 13 - .../frag/image-query.desktop.frag | 53 - .../frag/in-block-qualifiers.frag | 21 - .../frag/query-levels.desktop.frag | 11 - .../desktop-only/frag/query-lod.desktop.frag | 12 - .../frag/sampler-ms-query.desktop.frag | 14 - .../frag/texture-proj-shadow.desktop.frag | 26 - .../desktop-only/geom/basic.desktop.sso.geom | 35 - .../geom/viewport-index.desktop.geom | 9 - .../desktop-only/tesc/basic.desktop.sso.tesc | 27 - .../tese/triangle.desktop.sso.tese | 18 - .../desktop-only/vert/basic.desktop.sso.vert | 22 - .../vert/clip-cull-distance.desktop.vert | 11 - .../vert/out-block-qualifiers.vert | 27 - .../shaders/flatten/array.flatten.vert | 12 - .../shaders/flatten/basic.flatten.vert | 13 - .../shaders/flatten/copy.flatten.vert | 29 - .../shaders/flatten/dynamic.flatten.vert | 25 - .../shaders/flatten/matrixindex.flatten.vert | 19 - ...multi-dimensional.desktop.flatten_dim.frag | 24 - .../shaders/flatten/multiindex.flatten.vert | 10 - .../flatten/push-constant.flatten.vert | 13 - .../shaders/flatten/rowmajor.flatten.vert | 11 - .../shaders/flatten/struct.flatten.vert | 22 - .../flatten/struct.rowmajor.flatten.vert | 25 - .../shaders/flatten/swizzle.flatten.vert | 21 - .../shaders/flatten/types.flatten.frag | 14 - .../reference/shaders/frag/basic.frag | 15 - .../composite-extract-forced-temporary.frag | 15 - .../shaders/frag/constant-array.frag | 28 - .../shaders/frag/false-loop-init.frag | 25 - .../reference/shaders/frag/flush_params.frag | 30 - .../reference/shaders/frag/for-loop-init.frag | 52 - .../reference/shaders/frag/frexp-modf.frag | 43 - .../reference/shaders/frag/ground.frag | 62 - .../frag/image-load-store-uint-coord.asm.frag | 26 - .../reference/shaders/frag/mix.frag | 20 - .../shaders/frag/partial-write-preserve.frag | 109 - .../reference/shaders/frag/pls.frag | 21 - .../shaders/frag/sample-parameter.frag | 13 - .../reference/shaders/frag/sampler-ms.frag | 14 - .../reference/shaders/frag/sampler-proj.frag | 16 - .../reference/shaders/frag/sampler.frag | 21 - .../reference/shaders/frag/swizzle.frag | 20 - .../reference/shaders/frag/ubo_layout.frag | 26 - .../reference/shaders/frag/unary-enclose.frag | 16 - .../reference/shaders/geom/basic.geom | 26 - .../shaders/geom/lines-adjacency.geom | 26 - .../reference/shaders/geom/lines.geom | 23 - .../reference/shaders/geom/points.geom | 26 - .../shaders/geom/single-invocation.geom | 26 - .../shaders/geom/triangles-adjacency.geom | 26 - .../reference/shaders/geom/triangles.geom | 26 - .../legacy/fragment/explicit-lod.legacy.frag | 12 - .../legacy/fragment/io-blocks.legacy.frag | 12 - .../fragment/struct-varying.legacy.frag | 22 - .../legacy/vert/implicit-lod.legacy.vert | 9 - .../shaders/legacy/vert/io-block.legacy.vert | 13 - .../legacy/vert/struct-varying.legacy.vert | 32 - .../shaders/legacy/vert/transpose.legacy.vert | 22 - .../reference/shaders/tesc/basic.tesc | 17 - .../reference/shaders/tesc/water_tess.tesc | 117 - .../reference/shaders/tese/ccw.tese | 9 - .../reference/shaders/tese/cw.tese | 9 - .../reference/shaders/tese/equal.tese | 9 - .../shaders/tese/fractional_even.tese | 9 - .../shaders/tese/fractional_odd.tese | 9 - .../reference/shaders/tese/line.tese | 9 - .../reference/shaders/tese/triangle.tese | 9 - .../reference/shaders/tese/water_tess.tese | 61 - .../reference/shaders/vert/basic.vert | 17 - .../reference/shaders/vert/ground.vert | 110 - .../reference/shaders/vert/ocean.vert | 133 - .../shaders/vert/texture_buffer.vert | 11 - .../reference/shaders/vert/ubo.vert | 17 - .../combined-texture-sampler-shadow.vk.frag | 31 - ...combined-texture-sampler-shadow.vk.frag.vk | 32 - .../frag/combined-texture-sampler.vk.frag | 48 - .../frag/combined-texture-sampler.vk.frag.vk | 48 - .../vulkan/frag/desktop-mediump.vk.frag | 12 - .../vulkan/frag/desktop-mediump.vk.frag.vk | 12 - .../vulkan/frag/input-attachment-ms.vk.frag | 12 - .../frag/input-attachment-ms.vk.frag.vk | 12 - .../vulkan/frag/input-attachment.vk.frag | 14 - .../vulkan/frag/input-attachment.vk.frag.vk | 14 - .../shaders/vulkan/frag/push-constant.frag.vk | 18 - .../shaders/vulkan/frag/push-constant.vk.frag | 20 - .../vulkan/frag/push-constant.vk.frag.vk | 18 - .../frag/separate-sampler-texture.vk.frag | 37 - .../frag/separate-sampler-texture.vk.frag.vk | 38 - .../shaders/vulkan/frag/spec-constant.vk.frag | 59 - .../vulkan/frag/spec-constant.vk.frag.vk | 68 - .../vulkan/vert/multiview.nocompat.vk.vert | 15 - .../vulkan/vert/multiview.nocompat.vk.vert.vk | 15 - .../shaders/vulkan/vert/vulkan-vertex.vert | 9 - .../shaders/vulkan/vert/vulkan-vertex.vert.vk | 7 - .../shaders/vulkan/vert/vulkan-vertex.vk.vert | 9 - .../vulkan/vert/vulkan-vertex.vk.vert.vk | 7 - deps/SPIRV-Cross/samples/cpp/Makefile | 28 - deps/SPIRV-Cross/samples/cpp/atomics.comp | 29 - deps/SPIRV-Cross/samples/cpp/atomics.cpp | 90 - deps/SPIRV-Cross/samples/cpp/multiply.comp | 22 - deps/SPIRV-Cross/samples/cpp/multiply.cpp | 91 - deps/SPIRV-Cross/samples/cpp/shared.comp | 36 - deps/SPIRV-Cross/samples/cpp/shared.cpp | 89 - ...lization-constant-workgroup.nofxc.asm.comp | 47 - .../comp/storage-buffer-basic.nofxc.asm.comp | 57 - .../asm/frag/cbuffer-stripped.asm.frag | 55 - .../asm/frag/unreachable.asm.frag | 61 - .../asm/vert/empty-struct-composite.asm.vert | 37 - .../asm/vert/vertex-id-instance-id.asm.vert | 53 - .../shaders-hlsl/comp/access-chains.comp | 24 - .../shaders-hlsl/comp/address-buffers.comp | 23 - .../SPIRV-Cross/shaders-hlsl/comp/atomic.comp | 66 - .../shaders-hlsl/comp/barriers.comp | 79 - .../shaders-hlsl/comp/bitfield.noopt.comp | 44 - .../shaders-hlsl/comp/builtins.comp | 11 - deps/SPIRV-Cross/shaders-hlsl/comp/image.comp | 77 - .../shaders-hlsl/comp/rwbuffer-matrix.comp | 104 - .../SPIRV-Cross/shaders-hlsl/comp/shared.comp | 27 - .../shaders-hlsl/comp/ssbo-array.comp | 29 - deps/SPIRV-Cross/shaders-hlsl/frag/basic.frag | 13 - .../shaders-hlsl/frag/bit-conversions.frag | 12 - .../shaders-hlsl/frag/boolean-mix.frag | 10 - .../shaders-hlsl/frag/builtins.frag | 11 - .../shaders-hlsl/frag/bvec-operations.frag | 13 - .../combined-texture-sampler-parameter.frag | 31 - .../frag/combined-texture-sampler-shadow.frag | 29 - .../frag/constant-buffer-array.sm51.frag | 32 - .../frag/early-fragment-test.frag | 7 - .../shaders-hlsl/frag/fp16-packing.frag | 12 - .../frag/image-query-selective.frag | 35 - .../shaders-hlsl/frag/image-query.frag | 33 - .../shaders-hlsl/frag/io-block.frag | 16 - .../shaders-hlsl/frag/matrix-input.frag | 9 - deps/SPIRV-Cross/shaders-hlsl/frag/mod.frag | 22 - deps/SPIRV-Cross/shaders-hlsl/frag/mrt.frag | 15 - .../shaders-hlsl/frag/no-return.frag | 5 - .../shaders-hlsl/frag/no-return2.frag | 9 - .../frag/partial-write-preserve.frag | 64 - .../shaders-hlsl/frag/query-lod.desktop.frag | 10 - .../shaders-hlsl/frag/resources.frag | 27 - .../frag/sample-cmp-level-zero.frag | 27 - .../shaders-hlsl/frag/sampler-array.frag | 28 - .../shaders-hlsl/frag/spec-constant.frag | 80 - .../shaders-hlsl/frag/swizzle-scalar.frag | 16 - .../shaders-hlsl/frag/tex-sampling.frag | 81 - .../frag/texture-proj-shadow.frag | 21 - .../shaders-hlsl/frag/unary-enclose.frag | 15 - .../frag/unorm-snorm-packing.frag | 24 - .../shaders-hlsl/frag/various-glsl-ops.frag | 17 - deps/SPIRV-Cross/shaders-hlsl/vert/basic.vert | 15 - .../shaders-hlsl/vert/instancing.vert | 6 - .../shaders-hlsl/vert/locations.vert | 51 - .../shaders-hlsl/vert/matrix-attribute.vert | 9 - .../shaders-hlsl/vert/matrix-output.vert | 9 - .../shaders-hlsl/vert/no-input.vert | 6 - .../shaders-hlsl/vert/point-size-compat.vert | 8 - .../shaders-hlsl/vert/qualifiers.vert | 27 - .../shaders-hlsl/vert/sampler-buffers.vert | 17 - .../vert/struct-composite-decl.vert | 26 - .../shaders-hlsl/vert/texture_buffer.vert | 9 - .../vert/functions_nested.vert | 132 - .../asm/comp/bitcast_iadd.asm.comp | 79 - .../shaders-msl/asm/comp/bitcast_sar.asm.comp | 77 - .../asm/comp/bitcast_sdiv.asm.comp | 77 - .../shaders-msl/asm/comp/bitcast_slr.asm.comp | 77 - .../asm/comp/multiple-entry.asm.comp | 97 - .../shaders-msl/asm/comp/quantize.asm.comp | 67 - ...specialization-constant-workgroup.asm.comp | 47 - .../asm/comp/storage-buffer-basic.asm.comp | 58 - .../asm/frag/default-member-names.asm.frag | 57 - .../inliner-dominator-inside-loop.asm.frag | 646 -- .../asm/frag/op-constant-null.asm.frag | 85 - .../asm/frag/phi-loop-variable.asm.frag | 71 - .../asm/frag/undef-variable-store.asm.frag | 85 - .../shaders-msl/asm/frag/unreachable.asm.frag | 61 - .../asm/frag/vector-shuffle-oom.asm.frag | 886 -- .../asm/vert/empty-struct-composite.asm.vert | 37 - deps/SPIRV-Cross/shaders-msl/comp/atomic.comp | 33 - .../shaders-msl/comp/barriers.comp | 83 - deps/SPIRV-Cross/shaders-msl/comp/basic.comp | 28 - .../shaders-msl/comp/bitfield.noopt.comp | 23 - .../shaders-msl/comp/builtins.comp | 12 - .../comp/cfg-preserve-parameter.comp | 54 - .../shaders-msl/comp/coherent-block.comp | 12 - .../shaders-msl/comp/coherent-image.comp | 14 - .../SPIRV-Cross/shaders-msl/comp/culling.comp | 26 - .../shaders-msl/comp/defer-parens.comp | 30 - .../SPIRV-Cross/shaders-msl/comp/dowhile.comp | 31 - .../shaders-msl/comp/functions.comp | 12 - ...vocation-id-writable-ssbo-in-function.comp | 12 - .../comp/global-invocation-id.comp | 9 - deps/SPIRV-Cross/shaders-msl/comp/image.comp | 12 - deps/SPIRV-Cross/shaders-msl/comp/insert.comp | 18 - .../shaders-msl/comp/local-invocation-id.comp | 9 - .../comp/local-invocation-index.comp | 9 - .../shaders-msl/comp/loop.noopt.comp | 98 - deps/SPIRV-Cross/shaders-msl/comp/mat3.comp | 14 - deps/SPIRV-Cross/shaders-msl/comp/mod.comp | 26 - deps/SPIRV-Cross/shaders-msl/comp/modf.comp | 23 - .../shaders-msl/comp/read-write-only.comp | 26 - deps/SPIRV-Cross/shaders-msl/comp/return.comp | 33 - .../SPIRV-Cross/shaders-msl/comp/rmw-opt.comp | 27 - deps/SPIRV-Cross/shaders-msl/comp/shared.comp | 27 - .../shaders-msl/comp/struct-layout.comp | 24 - .../shaders-msl/comp/struct-packing.comp | 76 - .../shaders-msl/comp/torture-loop.comp | 40 - .../shaders-msl/comp/type-alias.comp | 45 - deps/SPIRV-Cross/shaders-msl/comp/udiv.comp | 17 - .../shaders-msl/comp/writable-ssbo.comp | 9 - .../desktop-only/frag/image-ms.desktop.frag | 13 - .../frag/query-levels.desktop.frag | 11 - .../frag/sampler-ms-query.desktop.frag | 14 - .../desktop-only/vert/basic.desktop.sso.vert | 20 - .../vert/clip-cull-distance.desktop.vert | 10 - .../shaders-msl/flatten/basic.flatten.vert | 16 - .../flatten/multiindex.flatten.vert | 13 - .../flatten/push-constant.flatten.vert | 17 - .../shaders-msl/flatten/rowmajor.flatten.vert | 16 - .../shaders-msl/flatten/struct.flatten.vert | 30 - .../shaders-msl/flatten/swizzle.flatten.vert | 47 - .../shaders-msl/flatten/types.flatten.frag | 27 - deps/SPIRV-Cross/shaders-msl/frag/basic.frag | 13 - .../shaders-msl/frag/bitcasting.frag | 24 - .../shaders-msl/frag/builtins.frag | 11 - .../composite-extract-forced-temporary.frag | 11 - .../shaders-msl/frag/constant-array.frag | 21 - .../shaders-msl/frag/false-loop-init.frag | 19 - .../shaders-msl/frag/flush_params.frag | 27 - .../shaders-msl/frag/for-loop-init.frag | 52 - .../shaders-msl/frag/in_block.frag | 14 - .../frag/in_block_assign.noopt.frag | 16 - deps/SPIRV-Cross/shaders-msl/frag/mix.frag | 20 - deps/SPIRV-Cross/shaders-msl/frag/pls.frag | 20 - .../shaders-msl/frag/sampler-ms.frag | 16 - .../SPIRV-Cross/shaders-msl/frag/sampler.frag | 18 - .../frag/separate-image-sampler-argument.frag | 16 - .../SPIRV-Cross/shaders-msl/frag/swizzle.frag | 17 - .../shaders-msl/frag/texture-proj-shadow.frag | 19 - .../shaders-msl/frag/ubo_layout.frag | 24 - .../shaders-msl/frag/unary-enclose.frag | 15 - .../legacy/vert/transpose.legacy.vert | 20 - deps/SPIRV-Cross/shaders-msl/vert/basic.vert | 17 - .../shaders-msl/vert/copy.flatten.vert | 34 - .../shaders-msl/vert/dynamic.flatten.vert | 33 - .../shaders-msl/vert/functions.vert | 28 - .../shaders-msl/vert/out_block.vert | 22 - .../shaders-msl/vert/pointsize.vert | 15 - .../shaders-msl/vert/texture_buffer.vert | 10 - .../shaders-msl/vert/ubo.alignment.vert | 23 - deps/SPIRV-Cross/shaders-msl/vert/ubo.vert | 16 - .../vulkan/frag/push-constant.vk.frag | 16 - .../vulkan/frag/spec-constant.vk.frag | 67 - .../vulkan/vert/vulkan-vertex.vk.vert | 6 - ...etch_subpassInput.vk.nocompat.invalid.frag | 10 - deps/SPIRV-Cross/shaders/amd/fs.invalid.frag | 14 - deps/SPIRV-Cross/shaders/amd/gcn_shader.comp | 13 - .../shaders/amd/shader_ballot.comp | 33 - ...ballot_nonuniform_invocations.invalid.comp | 9 - .../shaders/amd/shader_group_vote.comp | 18 - .../shaders/amd/shader_trinary_minmax.comp | 11 - .../shaders/asm/comp/bitcast_iadd.asm.comp | 79 - .../shaders/asm/comp/bitcast_iequal.asm.comp | 90 - .../shaders/asm/comp/bitcast_sar.asm.comp | 77 - .../shaders/asm/comp/bitcast_sdiv.asm.comp | 77 - .../shaders/asm/comp/bitcast_slr.asm.comp | 77 - .../shaders/asm/comp/logical.asm.comp | 191 - .../shaders/asm/comp/multiple-entry.asm.comp | 97 - .../asm/comp/name-alias.asm.invalid.comp | 124 - .../shaders/asm/comp/quantize.asm.comp | 67 - ...specialization-constant-workgroup.asm.comp | 47 - .../asm/comp/storage-buffer-basic.asm.comp | 57 - ...osite-construct-struct-no-swizzle.asm.frag | 51 - .../asm/frag/default-member-names.asm.frag | 57 - .../hlsl-sample-cmp-level-zero-cube.asm.frag | 58 - .../frag/hlsl-sample-cmp-level-zero.asm.frag | 113 - .../inliner-dominator-inside-loop.asm.frag | 646 -- .../shaders/asm/frag/invalidation.asm.frag | 46 - ...op-body-dominator-continue-access.asm.frag | 190 - .../asm/frag/multi-for-loop-init.asm.frag | 111 - .../asm/frag/op-constant-null.asm.frag | 85 - .../asm/frag/phi-loop-variable.asm.frag | 71 - .../sampler-buffer-without-sampler.asm.frag | 59 - .../struct-composite-extract-swizzle.asm.frag | 55 - .../asm/frag/temporary-phi-hoisting.asm.frag | 75 - .../asm/frag/undef-variable-store.asm.frag | 85 - .../shaders/asm/frag/unreachable.asm.frag | 61 - .../asm/frag/vector-shuffle-oom.asm.frag | 886 -- ...s-fixed-input-array-builtin-array.asm.tesc | 248 - .../shaders/asm/vert/empty-io.asm.vert | 70 - .../asm/vert/empty-struct-composite.asm.vert | 37 - .../asm/vert/global-builtin.sso.asm.vert | 68 - deps/SPIRV-Cross/shaders/comp/atomic.comp | 56 - .../shaders/comp/bake_gradient.comp | 55 - deps/SPIRV-Cross/shaders/comp/barriers.comp | 79 - deps/SPIRV-Cross/shaders/comp/basic.comp | 28 - .../shaders/comp/bitfield.noopt.comp | 21 - deps/SPIRV-Cross/shaders/comp/casts.comp | 18 - .../shaders/comp/cfg-preserve-parameter.comp | 54 - deps/SPIRV-Cross/shaders/comp/cfg.comp | 91 - .../shaders/comp/coherent-block.comp | 12 - .../shaders/comp/coherent-image.comp | 14 - .../shaders/comp/composite-construct.comp | 40 - deps/SPIRV-Cross/shaders/comp/culling.comp | 26 - .../shaders/comp/defer-parens.comp | 30 - deps/SPIRV-Cross/shaders/comp/dowhile.comp | 31 - .../shaders/comp/generate_height.comp | 97 - deps/SPIRV-Cross/shaders/comp/image.comp | 12 - .../shaders/comp/inout-struct.invalid.comp | 55 - deps/SPIRV-Cross/shaders/comp/insert.comp | 18 - deps/SPIRV-Cross/shaders/comp/loop.noopt.comp | 98 - deps/SPIRV-Cross/shaders/comp/mat3.comp | 14 - deps/SPIRV-Cross/shaders/comp/mod.comp | 26 - deps/SPIRV-Cross/shaders/comp/modf.comp | 23 - .../shaders/comp/read-write-only.comp | 26 - deps/SPIRV-Cross/shaders/comp/return.comp | 33 - deps/SPIRV-Cross/shaders/comp/rmw-opt.comp | 27 - deps/SPIRV-Cross/shaders/comp/shared.comp | 27 - deps/SPIRV-Cross/shaders/comp/ssbo-array.comp | 14 - .../shaders/comp/struct-layout.comp | 24 - .../shaders/comp/struct-packing.comp | 86 - .../shaders/comp/torture-loop.comp | 40 - deps/SPIRV-Cross/shaders/comp/type-alias.comp | 45 - deps/SPIRV-Cross/shaders/comp/udiv.comp | 17 - .../desktop-only/comp/enhanced-layouts.comp | 39 - .../desktop-only/comp/fp64.desktop.comp | 91 - .../image-formats.desktop.noeliminate.comp | 48 - .../desktop-only/comp/int64.desktop.comp | 55 - .../frag/hlsl-uav-block-alias.asm.frag | 56 - .../desktop-only/frag/image-ms.desktop.frag | 12 - .../frag/image-query.desktop.frag | 56 - .../frag/in-block-qualifiers.frag | 20 - .../frag/query-levels.desktop.frag | 9 - .../desktop-only/frag/query-lod.desktop.frag | 10 - .../frag/sampler-ms-query.desktop.frag | 17 - .../frag/texture-proj-shadow.desktop.frag | 21 - .../desktop-only/geom/basic.desktop.sso.geom | 37 - .../geom/viewport-index.desktop.geom | 11 - .../desktop-only/tesc/basic.desktop.sso.tesc | 28 - .../tese/triangle.desktop.sso.tese | 22 - .../desktop-only/vert/basic.desktop.sso.vert | 20 - .../vert/clip-cull-distance.desktop.vert | 10 - .../vert/out-block-qualifiers.vert | 26 - .../shaders/flatten/array.flatten.vert | 19 - .../shaders/flatten/basic.flatten.vert | 16 - .../shaders/flatten/copy.flatten.vert | 34 - .../shaders/flatten/dynamic.flatten.vert | 33 - .../shaders/flatten/matrixindex.flatten.vert | 25 - ...multi-dimensional.desktop.flatten_dim.frag | 18 - .../shaders/flatten/multiindex.flatten.vert | 13 - .../flatten/push-constant.flatten.vert | 17 - .../shaders/flatten/rowmajor.flatten.vert | 16 - .../shaders/flatten/struct.flatten.vert | 30 - .../flatten/struct.rowmajor.flatten.vert | 26 - .../shaders/flatten/swizzle.flatten.vert | 47 - .../shaders/flatten/types.flatten.frag | 27 - deps/SPIRV-Cross/shaders/frag/basic.frag | 13 - .../composite-extract-forced-temporary.frag | 11 - .../shaders/frag/constant-array.frag | 21 - .../shaders/frag/false-loop-init.frag | 19 - .../shaders/frag/flush_params.frag | 27 - .../shaders/frag/for-loop-init.frag | 52 - deps/SPIRV-Cross/shaders/frag/frexp-modf.frag | 24 - deps/SPIRV-Cross/shaders/frag/ground.frag | 162 - .../frag/image-load-store-uint-coord.asm.frag | 103 - deps/SPIRV-Cross/shaders/frag/mix.frag | 20 - .../shaders/frag/partial-write-preserve.frag | 95 - deps/SPIRV-Cross/shaders/frag/pls.frag | 20 - .../shaders/frag/sample-parameter.frag | 11 - deps/SPIRV-Cross/shaders/frag/sampler-ms.frag | 16 - .../shaders/frag/sampler-proj.frag | 12 - deps/SPIRV-Cross/shaders/frag/sampler.frag | 18 - deps/SPIRV-Cross/shaders/frag/swizzle.frag | 17 - deps/SPIRV-Cross/shaders/frag/ubo_layout.frag | 24 - .../shaders/frag/unary-enclose.frag | 15 - deps/SPIRV-Cross/shaders/geom/basic.geom | 28 - .../shaders/geom/lines-adjacency.geom | 28 - deps/SPIRV-Cross/shaders/geom/lines.geom | 24 - deps/SPIRV-Cross/shaders/geom/points.geom | 28 - .../shaders/geom/single-invocation.geom | 28 - .../shaders/geom/triangles-adjacency.geom | 28 - deps/SPIRV-Cross/shaders/geom/triangles.geom | 28 - .../legacy/fragment/explicit-lod.legacy.frag | 12 - .../legacy/fragment/io-blocks.legacy.frag | 16 - .../fragment/struct-varying.legacy.frag | 25 - .../legacy/vert/implicit-lod.legacy.vert | 8 - .../shaders/legacy/vert/io-block.legacy.vert | 17 - .../legacy/vert/struct-varying.legacy.vert | 33 - .../shaders/legacy/vert/transpose.legacy.vert | 20 - deps/SPIRV-Cross/shaders/tesc/basic.tesc | 17 - deps/SPIRV-Cross/shaders/tesc/water_tess.tesc | 115 - deps/SPIRV-Cross/shaders/tese/ccw.tese | 10 - deps/SPIRV-Cross/shaders/tese/cw.tese | 10 - deps/SPIRV-Cross/shaders/tese/equal.tese | 10 - .../shaders/tese/fractional_even.tese | 10 - .../shaders/tese/fractional_odd.tese | 10 - deps/SPIRV-Cross/shaders/tese/line.tese | 10 - deps/SPIRV-Cross/shaders/tese/triangle.tese | 10 - deps/SPIRV-Cross/shaders/tese/water_tess.tese | 65 - deps/SPIRV-Cross/shaders/vert/basic.vert | 16 - deps/SPIRV-Cross/shaders/vert/ground.vert | 202 - deps/SPIRV-Cross/shaders/vert/ocean.vert | 200 - .../shaders/vert/texture_buffer.vert | 10 - deps/SPIRV-Cross/shaders/vert/ubo.vert | 16 - .../combined-texture-sampler-shadow.vk.frag | 29 - .../frag/combined-texture-sampler.vk.frag | 47 - .../vulkan/frag/desktop-mediump.vk.frag | 11 - .../vulkan/frag/input-attachment-ms.vk.frag | 10 - .../vulkan/frag/input-attachment.vk.frag | 11 - .../shaders/vulkan/frag/push-constant.vk.frag | 16 - .../frag/separate-sampler-texture.vk.frag | 36 - .../shaders/vulkan/frag/spec-constant.vk.frag | 77 - .../vulkan/vert/multiview.nocompat.vk.vert | 14 - .../shaders/vulkan/vert/vulkan-vertex.vk.vert | 6 - deps/SPIRV-Cross/spirv.hpp | 968 -- deps/SPIRV-Cross/spirv_cfg.cpp | 229 - deps/SPIRV-Cross/spirv_cfg.hpp | 119 - deps/SPIRV-Cross/spirv_common.hpp | 1026 -- deps/SPIRV-Cross/spirv_cpp.cpp | 522 - deps/SPIRV-Cross/spirv_cpp.hpp | 77 - deps/SPIRV-Cross/spirv_cross.cpp | 3957 -------- deps/SPIRV-Cross/spirv_cross.hpp | 753 -- deps/SPIRV-Cross/spirv_glsl.cpp | 8545 ----------------- deps/SPIRV-Cross/spirv_glsl.hpp | 534 - deps/SPIRV-Cross/spirv_hlsl.cpp | 3676 ------- deps/SPIRV-Cross/spirv_hlsl.hpp | 164 - deps/SPIRV-Cross/spirv_msl.cpp | 3591 ------- deps/SPIRV-Cross/spirv_msl.hpp | 331 - deps/SPIRV-Cross/test_shaders.py | 451 - deps/SPIRV-Cross/test_shaders.sh | 17 - deps/SPIRV-Cross/update_test_shaders.sh | 17 - 1005 files changed, 65012 deletions(-) delete mode 100755 deps/SPIRV-Cross/.clang-format delete mode 100644 deps/SPIRV-Cross/.gitignore delete mode 100644 deps/SPIRV-Cross/.travis.yml delete mode 100644 deps/SPIRV-Cross/CMakeLists.txt delete mode 100644 deps/SPIRV-Cross/GLSL.std.450.h delete mode 100644 deps/SPIRV-Cross/LICENSE delete mode 100644 deps/SPIRV-Cross/Makefile delete mode 100644 deps/SPIRV-Cross/README.md delete mode 100644 deps/SPIRV-Cross/checkout_glslang_spirv_tools.sh delete mode 100755 deps/SPIRV-Cross/format_all.sh delete mode 100644 deps/SPIRV-Cross/include/spirv_cross/barrier.hpp delete mode 100644 deps/SPIRV-Cross/include/spirv_cross/external_interface.h delete mode 100644 deps/SPIRV-Cross/include/spirv_cross/image.hpp delete mode 100644 deps/SPIRV-Cross/include/spirv_cross/internal_interface.hpp delete mode 100644 deps/SPIRV-Cross/include/spirv_cross/sampler.hpp delete mode 100644 deps/SPIRV-Cross/include/spirv_cross/thread_group.hpp delete mode 100644 deps/SPIRV-Cross/jni/Android.mk delete mode 100644 deps/SPIRV-Cross/jni/Application.mk delete mode 100644 deps/SPIRV-Cross/main.cpp delete mode 100644 deps/SPIRV-Cross/msvc/SPIRV-Cross.sln delete mode 100644 deps/SPIRV-Cross/msvc/SPIRV-Cross.vcxproj delete mode 100644 deps/SPIRV-Cross/msvc/SPIRV-Cross.vcxproj.filters delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/asm/comp/specialization-constant-workgroup.nofxc.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/asm/comp/storage-buffer-basic.nofxc.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/asm/frag/cbuffer-stripped.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/asm/frag/unreachable.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/asm/vert/empty-struct-composite.asm.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/asm/vert/vertex-id-instance-id.asm.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/access-chains.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/address-buffers.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/atomic.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/barriers.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/bitfield.noopt.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/builtins.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/image.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/rwbuffer-matrix.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/shared.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/ssbo-array.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/basic.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/bit-conversions.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/boolean-mix.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/builtins.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/bvec-operations.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/combined-texture-sampler-parameter.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/combined-texture-sampler-shadow.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/constant-buffer-array.sm51.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/early-fragment-test.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/fp16-packing.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/image-query-selective.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/image-query.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/io-block.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/matrix-input.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/mod.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/mrt.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/no-return.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/no-return2.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/partial-write-preserve.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/query-lod.desktop.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/resources.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/sample-cmp-level-zero.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/sampler-array.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/spec-constant.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/swizzle-scalar.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/tex-sampling.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/texture-proj-shadow.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/unary-enclose.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/unorm-snorm-packing.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/various-glsl-ops.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/basic.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/instancing.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/locations.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/matrix-attribute.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/matrix-output.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/no-input.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/point-size-compat.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/qualifiers.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/sampler-buffers.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/struct-composite-decl.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/texture_buffer.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/bitcast_iadd.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/bitcast_sar.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/bitcast_sdiv.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/bitcast_slr.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/multiple-entry.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/quantize.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/specialization-constant-workgroup.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/storage-buffer-basic.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/asm/frag/default-member-names.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/asm/frag/op-constant-null.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/asm/frag/phi-loop-variable.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/asm/frag/undef-variable-store.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/asm/frag/unreachable.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/asm/vert/empty-struct-composite.asm.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/atomic.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/bake_gradient.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/barriers.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/basic.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/bitfield.noopt.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/builtins.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/cfg-preserve-parameter.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/coherent-block.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/coherent-image.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/culling.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/defer-parens.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/dowhile.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/functions.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/global-invocation-id-writable-ssbo-in-function.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/global-invocation-id.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/image.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/insert.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/local-invocation-id.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/local-invocation-index.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/loop.noopt.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/mat3.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/mod.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/modf.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/read-write-only.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/return.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/rmw-opt.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/shared.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/struct-layout.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/struct-packing.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/torture-loop.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/type-alias.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/udiv.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/writable-ssbo.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/desktop-only/frag/image-ms.desktop.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/desktop-only/frag/query-levels.desktop.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/desktop-only/frag/sampler-ms-query.desktop.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/desktop-only/vert/basic.desktop.sso.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/desktop-only/vert/clip-cull-distance.desktop.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/basic.flatten.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/multiindex.flatten.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/push-constant.flatten.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/rowmajor.flatten.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/struct.flatten.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/swizzle.flatten.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/types.flatten.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/frag/basic.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/frag/bitcasting.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/frag/builtins.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/frag/composite-extract-forced-temporary.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/frag/constant-array.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/frag/false-loop-init.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/frag/flush_params.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/frag/for-loop-init.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/frag/in_block.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/frag/in_block_assign.noopt.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/frag/mix.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/frag/pls.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/frag/sampler-ms.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/frag/sampler.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/frag/separate-image-sampler-argument.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/frag/swizzle.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/frag/texture-proj-shadow.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/frag/ubo_layout.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/frag/unary-enclose.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/legacy/vert/transpose.legacy.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/vert/basic.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/vert/copy.flatten.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/vert/dynamic.flatten.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/vert/functions.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/vert/out_block.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/vert/pointsize.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/vert/texture_buffer.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/vert/ubo.alignment.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/vert/ubo.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/vulkan/frag/push-constant.vk.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/vulkan/frag/spec-constant.vk.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/vulkan/vert/vulkan-vertex.vk.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag.vk delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/amd/fs.invalid.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/amd/gcn_shader.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/amd/shader_ballot.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/amd/shader_ballot_nonuniform_invocations.invalid.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/amd/shader_group_vote.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/amd/shader_trinary_minmax.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/comp/bitcast_iadd.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/comp/bitcast_iequal.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/comp/bitcast_sar.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/comp/bitcast_sdiv.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/comp/bitcast_slr.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/comp/logical.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/comp/multiple-entry.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/comp/name-alias.asm.invalid.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/comp/quantize.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/comp/specialization-constant-workgroup.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/comp/storage-buffer-basic.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/frag/composite-construct-struct-no-swizzle.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/frag/default-member-names.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/frag/hlsl-sample-cmp-level-zero-cube.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/frag/hlsl-sample-cmp-level-zero.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/frag/invalidation.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/frag/multi-for-loop-init.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/frag/op-constant-null.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/frag/phi-loop-variable.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/frag/sampler-buffer-without-sampler.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/frag/struct-composite-extract-swizzle.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/frag/temporary-phi-hoisting.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/frag/undef-variable-store.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/frag/unreachable.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/frag/vector-shuffle-oom.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/tesc/tess-fixed-input-array-builtin-array.asm.tesc delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/vert/empty-io.asm.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/vert/empty-struct-composite.asm.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/vert/global-builtin.sso.asm.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/atomic.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/bake_gradient.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/barriers.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/basic.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/bitfield.noopt.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/casts.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/cfg-preserve-parameter.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/cfg.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/coherent-block.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/coherent-image.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/composite-construct.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/culling.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/defer-parens.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/dowhile.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/generate_height.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/image.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/inout-struct.invalid.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/insert.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/loop.noopt.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/mat3.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/mod.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/modf.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/read-write-only.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/return.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/rmw-opt.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/shared.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/ssbo-array.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/struct-layout.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/struct-packing.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/torture-loop.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/type-alias.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/udiv.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/desktop-only/comp/enhanced-layouts.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/desktop-only/comp/fp64.desktop.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/desktop-only/comp/image-formats.desktop.noeliminate.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/desktop-only/comp/int64.desktop.comp delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/hlsl-uav-block-alias.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/image-ms.desktop.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/image-query.desktop.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/in-block-qualifiers.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/query-levels.desktop.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/query-lod.desktop.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/sampler-ms-query.desktop.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/texture-proj-shadow.desktop.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/desktop-only/geom/basic.desktop.sso.geom delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/desktop-only/geom/viewport-index.desktop.geom delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/desktop-only/tesc/basic.desktop.sso.tesc delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/desktop-only/tese/triangle.desktop.sso.tese delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/desktop-only/vert/basic.desktop.sso.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/desktop-only/vert/clip-cull-distance.desktop.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/desktop-only/vert/out-block-qualifiers.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/flatten/array.flatten.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/flatten/basic.flatten.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/flatten/copy.flatten.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/flatten/dynamic.flatten.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/flatten/matrixindex.flatten.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/flatten/multi-dimensional.desktop.flatten_dim.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/flatten/multiindex.flatten.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/flatten/push-constant.flatten.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/flatten/rowmajor.flatten.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/flatten/struct.flatten.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/flatten/struct.rowmajor.flatten.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/flatten/swizzle.flatten.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/flatten/types.flatten.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/basic.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/composite-extract-forced-temporary.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/constant-array.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/eliminate-dead-variables.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/false-loop-init.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/flush_params.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/for-loop-init.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/frexp-modf.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/ground.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/image-load-store-uint-coord.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/mix.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/partial-write-preserve.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/pls.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/sample-parameter.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/sampler-ms-query.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/sampler-ms.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/sampler-proj.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/sampler.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/swizzle.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/temporary.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/ubo_layout.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/unary-enclose.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/geom/basic.geom delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/geom/lines-adjacency.geom delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/geom/lines.geom delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/geom/points.geom delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/geom/single-invocation.geom delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/geom/triangles-adjacency.geom delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/geom/triangles.geom delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/legacy/fragment/explicit-lod.legacy.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/legacy/fragment/io-blocks.legacy.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/legacy/fragment/struct-varying.legacy.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/legacy/vert/implicit-lod.legacy.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/legacy/vert/io-block.legacy.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/legacy/vert/struct-varying.legacy.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/legacy/vert/transpose.legacy.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/tesc/basic.tesc delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/tesc/water_tess.tesc delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/tese/ccw.tese delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/tese/cw.tese delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/tese/equal.tese delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/tese/fractional_even.tese delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/tese/fractional_odd.tese delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/tese/line.tese delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/tese/triangle.tese delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/tese/water_tess.tese delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vert/basic.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vert/ground.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vert/ocean.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vert/texture_buffer.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vert/ubo.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag.vk delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/combined-texture-sampler.vk.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/combined-texture-sampler.vk.frag.vk delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/desktop-mediump.vk.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/desktop-mediump.vk.frag.vk delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/input-attachment-ms.vk.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/input-attachment-ms.vk.frag.vk delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/input-attachment.vk.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/input-attachment.vk.frag.vk delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/push-constant.vk.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/push-constant.vk.frag.vk delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/separate-sampler-texture.vk.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/separate-sampler-texture.vk.frag.vk delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/spec-constant.vk.frag delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/spec-constant.vk.frag.vk delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/vert/multiview.nocompat.vk.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/vert/multiview.nocompat.vk.vert.vk delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/vert/vulkan-vertex.vk.vert delete mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/vert/vulkan-vertex.vk.vert.vk delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/asm/comp/specialization-constant-workgroup.nofxc.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/asm/comp/storage-buffer-basic.nofxc.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/asm/frag/cbuffer-stripped.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/asm/frag/unreachable.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/asm/vert/empty-struct-composite.asm.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/asm/vert/vertex-id-instance-id.asm.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/comp/access-chains.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/comp/address-buffers.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/comp/atomic.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/comp/barriers.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/comp/bitfield.noopt.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/comp/builtins.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/comp/image.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/comp/rwbuffer-matrix.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/comp/shared.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/comp/ssbo-array.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/basic.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/bit-conversions.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/boolean-mix.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/builtins.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/bvec-operations.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/combined-texture-sampler-parameter.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/combined-texture-sampler-shadow.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/constant-buffer-array.sm51.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/early-fragment-test.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/fp16-packing.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/image-query-selective.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/image-query.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/io-block.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/matrix-input.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/mod.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/mrt.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/no-return.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/no-return2.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/partial-write-preserve.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/query-lod.desktop.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/resources.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/sample-cmp-level-zero.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/sampler-array.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/spec-constant.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/swizzle-scalar.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/tex-sampling.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/texture-proj-shadow.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/unary-enclose.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/unorm-snorm-packing.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/various-glsl-ops.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/vert/basic.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/vert/instancing.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/vert/locations.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/vert/matrix-attribute.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/vert/matrix-output.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/vert/no-input.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/vert/point-size-compat.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/vert/qualifiers.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/vert/sampler-buffers.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/vert/struct-composite-decl.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/vert/texture_buffer.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl-no-opt/vert/functions_nested.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/asm/comp/bitcast_iadd.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/asm/comp/bitcast_sar.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/asm/comp/bitcast_sdiv.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/asm/comp/bitcast_slr.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/asm/comp/multiple-entry.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/asm/comp/quantize.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/asm/comp/specialization-constant-workgroup.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/asm/comp/storage-buffer-basic.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/asm/frag/default-member-names.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/asm/frag/op-constant-null.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/asm/frag/phi-loop-variable.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/asm/frag/undef-variable-store.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/asm/frag/unreachable.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/asm/vert/empty-struct-composite.asm.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/atomic.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/bake_gradient.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/barriers.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/basic.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/bitfield.noopt.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/builtins.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/cfg-preserve-parameter.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/coherent-block.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/coherent-image.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/culling.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/defer-parens.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/dowhile.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/functions.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/global-invocation-id-writable-ssbo-in-function.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/global-invocation-id.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/image.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/insert.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/local-invocation-id.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/local-invocation-index.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/loop.noopt.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/mat3.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/mod.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/modf.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/read-write-only.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/return.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/rmw-opt.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/shared.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/struct-layout.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/struct-packing.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/torture-loop.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/type-alias.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/udiv.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/writable-ssbo.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/desktop-only/frag/image-ms.desktop.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/desktop-only/frag/query-levels.desktop.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/desktop-only/frag/sampler-ms-query.desktop.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/desktop-only/vert/basic.desktop.sso.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/desktop-only/vert/clip-cull-distance.desktop.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/flatten/basic.flatten.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/flatten/multiindex.flatten.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/flatten/push-constant.flatten.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/flatten/rowmajor.flatten.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/flatten/struct.flatten.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/flatten/swizzle.flatten.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/flatten/types.flatten.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/frag/basic.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/frag/bitcasting.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/frag/builtins.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/frag/composite-extract-forced-temporary.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/frag/constant-array.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/frag/false-loop-init.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/frag/flush_params.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/frag/for-loop-init.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/frag/in_block.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/frag/in_block_assign.noopt.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/frag/mix.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/frag/pls.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/frag/sampler-ms.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/frag/sampler.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/frag/separate-image-sampler-argument.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/frag/swizzle.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/frag/texture-proj-shadow.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/frag/ubo_layout.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/frag/unary-enclose.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/legacy/vert/transpose.legacy.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/vert/basic.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/vert/copy.flatten.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/vert/dynamic.flatten.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/vert/functions.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/vert/out_block.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/vert/pointsize.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/vert/texture_buffer.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/vert/ubo.alignment.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/vert/ubo.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/vulkan/frag/push-constant.vk.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/vulkan/frag/spec-constant.vk.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders-msl/vulkan/vert/vulkan-vertex.vk.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag.vk delete mode 100644 deps/SPIRV-Cross/reference/shaders/amd/fs.invalid.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/amd/gcn_shader.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/amd/shader_ballot.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/amd/shader_ballot_nonuniform_invocations.invalid.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/amd/shader_group_vote.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/amd/shader_trinary_minmax.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/asm/comp/bitcast_iadd.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/asm/comp/bitcast_iequal.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/asm/comp/bitcast_sar.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/asm/comp/bitcast_sdiv.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/asm/comp/bitcast_slr.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/asm/comp/logical.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/asm/comp/multiple-entry.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/asm/comp/name-alias.asm.invalid.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/asm/comp/quantize.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/asm/comp/specialization-constant-workgroup.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/asm/comp/storage-buffer-basic.asm.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/asm/frag/composite-construct-struct-no-swizzle.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/asm/frag/default-member-names.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/asm/frag/hlsl-sample-cmp-level-zero-cube.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/asm/frag/hlsl-sample-cmp-level-zero.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/asm/frag/invalidation.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/asm/frag/multi-for-loop-init.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/asm/frag/op-constant-null.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/asm/frag/phi-loop-variable.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/asm/frag/sampler-buffer-without-sampler.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/asm/frag/struct-composite-extract-swizzle.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/asm/frag/temporary-phi-hoisting.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/asm/frag/undef-variable-store.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/asm/frag/unreachable.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/asm/frag/vector-shuffle-oom.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/asm/tesc/tess-fixed-input-array-builtin-array.asm.tesc delete mode 100644 deps/SPIRV-Cross/reference/shaders/asm/vert/empty-io.asm.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders/asm/vert/empty-struct-composite.asm.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders/asm/vert/global-builtin.sso.asm.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders/comp/atomic.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/comp/bake_gradient.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/comp/barriers.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/comp/basic.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/comp/bitfield.noopt.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/comp/casts.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/comp/cfg-preserve-parameter.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/comp/cfg.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/comp/coherent-block.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/comp/coherent-image.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/comp/composite-construct.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/comp/culling.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/comp/defer-parens.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/comp/dowhile.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/comp/generate_height.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/comp/image.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/comp/inout-struct.invalid.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/comp/insert.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/comp/loop.noopt.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/comp/mat3.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/comp/mod.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/comp/modf.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/comp/read-write-only.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/comp/return.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/comp/rmw-opt.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/comp/shared.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/comp/ssbo-array.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/comp/struct-layout.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/comp/struct-packing.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/comp/torture-loop.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/comp/type-alias.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/comp/udiv.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/desktop-only/comp/enhanced-layouts.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/desktop-only/comp/fp64.desktop.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/desktop-only/comp/image-formats.desktop.noeliminate.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/desktop-only/comp/int64.desktop.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/desktop-only/frag/hlsl-uav-block-alias.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/desktop-only/frag/image-ms.desktop.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/desktop-only/frag/image-query.desktop.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/desktop-only/frag/in-block-qualifiers.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/desktop-only/frag/query-levels.desktop.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/desktop-only/frag/query-lod.desktop.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/desktop-only/frag/sampler-ms-query.desktop.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/desktop-only/frag/texture-proj-shadow.desktop.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/desktop-only/geom/basic.desktop.sso.geom delete mode 100644 deps/SPIRV-Cross/reference/shaders/desktop-only/geom/viewport-index.desktop.geom delete mode 100644 deps/SPIRV-Cross/reference/shaders/desktop-only/tesc/basic.desktop.sso.tesc delete mode 100644 deps/SPIRV-Cross/reference/shaders/desktop-only/tese/triangle.desktop.sso.tese delete mode 100644 deps/SPIRV-Cross/reference/shaders/desktop-only/vert/basic.desktop.sso.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders/desktop-only/vert/clip-cull-distance.desktop.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders/desktop-only/vert/out-block-qualifiers.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders/flatten/array.flatten.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders/flatten/basic.flatten.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders/flatten/copy.flatten.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders/flatten/dynamic.flatten.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders/flatten/matrixindex.flatten.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders/flatten/multi-dimensional.desktop.flatten_dim.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/flatten/multiindex.flatten.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders/flatten/push-constant.flatten.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders/flatten/rowmajor.flatten.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders/flatten/struct.flatten.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders/flatten/struct.rowmajor.flatten.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders/flatten/swizzle.flatten.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders/flatten/types.flatten.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/frag/basic.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/frag/composite-extract-forced-temporary.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/frag/constant-array.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/frag/false-loop-init.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/frag/flush_params.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/frag/for-loop-init.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/frag/frexp-modf.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/frag/ground.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/frag/image-load-store-uint-coord.asm.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/frag/mix.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/frag/partial-write-preserve.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/frag/pls.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/frag/sample-parameter.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/frag/sampler-ms.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/frag/sampler-proj.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/frag/sampler.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/frag/swizzle.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/frag/ubo_layout.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/frag/unary-enclose.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/geom/basic.geom delete mode 100644 deps/SPIRV-Cross/reference/shaders/geom/lines-adjacency.geom delete mode 100644 deps/SPIRV-Cross/reference/shaders/geom/lines.geom delete mode 100644 deps/SPIRV-Cross/reference/shaders/geom/points.geom delete mode 100644 deps/SPIRV-Cross/reference/shaders/geom/single-invocation.geom delete mode 100644 deps/SPIRV-Cross/reference/shaders/geom/triangles-adjacency.geom delete mode 100644 deps/SPIRV-Cross/reference/shaders/geom/triangles.geom delete mode 100644 deps/SPIRV-Cross/reference/shaders/legacy/fragment/explicit-lod.legacy.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/legacy/fragment/io-blocks.legacy.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/legacy/fragment/struct-varying.legacy.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/legacy/vert/implicit-lod.legacy.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders/legacy/vert/io-block.legacy.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders/legacy/vert/struct-varying.legacy.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders/legacy/vert/transpose.legacy.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders/tesc/basic.tesc delete mode 100644 deps/SPIRV-Cross/reference/shaders/tesc/water_tess.tesc delete mode 100644 deps/SPIRV-Cross/reference/shaders/tese/ccw.tese delete mode 100644 deps/SPIRV-Cross/reference/shaders/tese/cw.tese delete mode 100644 deps/SPIRV-Cross/reference/shaders/tese/equal.tese delete mode 100644 deps/SPIRV-Cross/reference/shaders/tese/fractional_even.tese delete mode 100644 deps/SPIRV-Cross/reference/shaders/tese/fractional_odd.tese delete mode 100644 deps/SPIRV-Cross/reference/shaders/tese/line.tese delete mode 100644 deps/SPIRV-Cross/reference/shaders/tese/triangle.tese delete mode 100644 deps/SPIRV-Cross/reference/shaders/tese/water_tess.tese delete mode 100644 deps/SPIRV-Cross/reference/shaders/vert/basic.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders/vert/ground.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders/vert/ocean.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders/vert/texture_buffer.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders/vert/ubo.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag.vk delete mode 100644 deps/SPIRV-Cross/reference/shaders/vulkan/frag/combined-texture-sampler.vk.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/vulkan/frag/combined-texture-sampler.vk.frag.vk delete mode 100644 deps/SPIRV-Cross/reference/shaders/vulkan/frag/desktop-mediump.vk.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/vulkan/frag/desktop-mediump.vk.frag.vk delete mode 100644 deps/SPIRV-Cross/reference/shaders/vulkan/frag/input-attachment-ms.vk.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/vulkan/frag/input-attachment-ms.vk.frag.vk delete mode 100644 deps/SPIRV-Cross/reference/shaders/vulkan/frag/input-attachment.vk.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/vulkan/frag/input-attachment.vk.frag.vk delete mode 100644 deps/SPIRV-Cross/reference/shaders/vulkan/frag/push-constant.frag.vk delete mode 100644 deps/SPIRV-Cross/reference/shaders/vulkan/frag/push-constant.vk.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/vulkan/frag/push-constant.vk.frag.vk delete mode 100644 deps/SPIRV-Cross/reference/shaders/vulkan/frag/separate-sampler-texture.vk.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/vulkan/frag/separate-sampler-texture.vk.frag.vk delete mode 100644 deps/SPIRV-Cross/reference/shaders/vulkan/frag/spec-constant.vk.frag delete mode 100644 deps/SPIRV-Cross/reference/shaders/vulkan/frag/spec-constant.vk.frag.vk delete mode 100644 deps/SPIRV-Cross/reference/shaders/vulkan/vert/multiview.nocompat.vk.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders/vulkan/vert/multiview.nocompat.vk.vert.vk delete mode 100644 deps/SPIRV-Cross/reference/shaders/vulkan/vert/vulkan-vertex.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders/vulkan/vert/vulkan-vertex.vert.vk delete mode 100644 deps/SPIRV-Cross/reference/shaders/vulkan/vert/vulkan-vertex.vk.vert delete mode 100644 deps/SPIRV-Cross/reference/shaders/vulkan/vert/vulkan-vertex.vk.vert.vk delete mode 100644 deps/SPIRV-Cross/samples/cpp/Makefile delete mode 100644 deps/SPIRV-Cross/samples/cpp/atomics.comp delete mode 100644 deps/SPIRV-Cross/samples/cpp/atomics.cpp delete mode 100644 deps/SPIRV-Cross/samples/cpp/multiply.comp delete mode 100644 deps/SPIRV-Cross/samples/cpp/multiply.cpp delete mode 100644 deps/SPIRV-Cross/samples/cpp/shared.comp delete mode 100644 deps/SPIRV-Cross/samples/cpp/shared.cpp delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/asm/comp/specialization-constant-workgroup.nofxc.asm.comp delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/asm/comp/storage-buffer-basic.nofxc.asm.comp delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/asm/frag/cbuffer-stripped.asm.frag delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/asm/frag/unreachable.asm.frag delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/asm/vert/empty-struct-composite.asm.vert delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/asm/vert/vertex-id-instance-id.asm.vert delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/comp/access-chains.comp delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/comp/address-buffers.comp delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/comp/atomic.comp delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/comp/barriers.comp delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/comp/bitfield.noopt.comp delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/comp/builtins.comp delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/comp/image.comp delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/comp/rwbuffer-matrix.comp delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/comp/shared.comp delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/comp/ssbo-array.comp delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/basic.frag delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/bit-conversions.frag delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/boolean-mix.frag delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/builtins.frag delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/bvec-operations.frag delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/combined-texture-sampler-parameter.frag delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/combined-texture-sampler-shadow.frag delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/constant-buffer-array.sm51.frag delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/early-fragment-test.frag delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/fp16-packing.frag delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/image-query-selective.frag delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/image-query.frag delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/io-block.frag delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/matrix-input.frag delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/mod.frag delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/mrt.frag delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/no-return.frag delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/no-return2.frag delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/partial-write-preserve.frag delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/query-lod.desktop.frag delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/resources.frag delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/sample-cmp-level-zero.frag delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/sampler-array.frag delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/spec-constant.frag delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/swizzle-scalar.frag delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/tex-sampling.frag delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/texture-proj-shadow.frag delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/unary-enclose.frag delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/unorm-snorm-packing.frag delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/various-glsl-ops.frag delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/vert/basic.vert delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/vert/instancing.vert delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/vert/locations.vert delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/vert/matrix-attribute.vert delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/vert/matrix-output.vert delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/vert/no-input.vert delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/vert/point-size-compat.vert delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/vert/qualifiers.vert delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/vert/sampler-buffers.vert delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/vert/struct-composite-decl.vert delete mode 100644 deps/SPIRV-Cross/shaders-hlsl/vert/texture_buffer.vert delete mode 100644 deps/SPIRV-Cross/shaders-msl-no-opt/vert/functions_nested.vert delete mode 100644 deps/SPIRV-Cross/shaders-msl/asm/comp/bitcast_iadd.asm.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/asm/comp/bitcast_sar.asm.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/asm/comp/bitcast_sdiv.asm.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/asm/comp/bitcast_slr.asm.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/asm/comp/multiple-entry.asm.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/asm/comp/quantize.asm.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/asm/comp/specialization-constant-workgroup.asm.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/asm/comp/storage-buffer-basic.asm.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/asm/frag/default-member-names.asm.frag delete mode 100644 deps/SPIRV-Cross/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag delete mode 100644 deps/SPIRV-Cross/shaders-msl/asm/frag/op-constant-null.asm.frag delete mode 100644 deps/SPIRV-Cross/shaders-msl/asm/frag/phi-loop-variable.asm.frag delete mode 100644 deps/SPIRV-Cross/shaders-msl/asm/frag/undef-variable-store.asm.frag delete mode 100644 deps/SPIRV-Cross/shaders-msl/asm/frag/unreachable.asm.frag delete mode 100644 deps/SPIRV-Cross/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag delete mode 100644 deps/SPIRV-Cross/shaders-msl/asm/vert/empty-struct-composite.asm.vert delete mode 100644 deps/SPIRV-Cross/shaders-msl/comp/atomic.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/comp/barriers.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/comp/basic.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/comp/bitfield.noopt.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/comp/builtins.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/comp/cfg-preserve-parameter.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/comp/coherent-block.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/comp/coherent-image.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/comp/culling.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/comp/defer-parens.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/comp/dowhile.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/comp/functions.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/comp/global-invocation-id-writable-ssbo-in-function.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/comp/global-invocation-id.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/comp/image.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/comp/insert.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/comp/local-invocation-id.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/comp/local-invocation-index.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/comp/loop.noopt.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/comp/mat3.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/comp/mod.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/comp/modf.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/comp/read-write-only.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/comp/return.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/comp/rmw-opt.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/comp/shared.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/comp/struct-layout.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/comp/struct-packing.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/comp/torture-loop.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/comp/type-alias.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/comp/udiv.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/comp/writable-ssbo.comp delete mode 100644 deps/SPIRV-Cross/shaders-msl/desktop-only/frag/image-ms.desktop.frag delete mode 100644 deps/SPIRV-Cross/shaders-msl/desktop-only/frag/query-levels.desktop.frag delete mode 100644 deps/SPIRV-Cross/shaders-msl/desktop-only/frag/sampler-ms-query.desktop.frag delete mode 100644 deps/SPIRV-Cross/shaders-msl/desktop-only/vert/basic.desktop.sso.vert delete mode 100644 deps/SPIRV-Cross/shaders-msl/desktop-only/vert/clip-cull-distance.desktop.vert delete mode 100644 deps/SPIRV-Cross/shaders-msl/flatten/basic.flatten.vert delete mode 100644 deps/SPIRV-Cross/shaders-msl/flatten/multiindex.flatten.vert delete mode 100644 deps/SPIRV-Cross/shaders-msl/flatten/push-constant.flatten.vert delete mode 100644 deps/SPIRV-Cross/shaders-msl/flatten/rowmajor.flatten.vert delete mode 100644 deps/SPIRV-Cross/shaders-msl/flatten/struct.flatten.vert delete mode 100644 deps/SPIRV-Cross/shaders-msl/flatten/swizzle.flatten.vert delete mode 100644 deps/SPIRV-Cross/shaders-msl/flatten/types.flatten.frag delete mode 100644 deps/SPIRV-Cross/shaders-msl/frag/basic.frag delete mode 100644 deps/SPIRV-Cross/shaders-msl/frag/bitcasting.frag delete mode 100644 deps/SPIRV-Cross/shaders-msl/frag/builtins.frag delete mode 100644 deps/SPIRV-Cross/shaders-msl/frag/composite-extract-forced-temporary.frag delete mode 100644 deps/SPIRV-Cross/shaders-msl/frag/constant-array.frag delete mode 100644 deps/SPIRV-Cross/shaders-msl/frag/false-loop-init.frag delete mode 100644 deps/SPIRV-Cross/shaders-msl/frag/flush_params.frag delete mode 100644 deps/SPIRV-Cross/shaders-msl/frag/for-loop-init.frag delete mode 100644 deps/SPIRV-Cross/shaders-msl/frag/in_block.frag delete mode 100644 deps/SPIRV-Cross/shaders-msl/frag/in_block_assign.noopt.frag delete mode 100644 deps/SPIRV-Cross/shaders-msl/frag/mix.frag delete mode 100644 deps/SPIRV-Cross/shaders-msl/frag/pls.frag delete mode 100644 deps/SPIRV-Cross/shaders-msl/frag/sampler-ms.frag delete mode 100644 deps/SPIRV-Cross/shaders-msl/frag/sampler.frag delete mode 100644 deps/SPIRV-Cross/shaders-msl/frag/separate-image-sampler-argument.frag delete mode 100644 deps/SPIRV-Cross/shaders-msl/frag/swizzle.frag delete mode 100644 deps/SPIRV-Cross/shaders-msl/frag/texture-proj-shadow.frag delete mode 100644 deps/SPIRV-Cross/shaders-msl/frag/ubo_layout.frag delete mode 100644 deps/SPIRV-Cross/shaders-msl/frag/unary-enclose.frag delete mode 100644 deps/SPIRV-Cross/shaders-msl/legacy/vert/transpose.legacy.vert delete mode 100644 deps/SPIRV-Cross/shaders-msl/vert/basic.vert delete mode 100644 deps/SPIRV-Cross/shaders-msl/vert/copy.flatten.vert delete mode 100644 deps/SPIRV-Cross/shaders-msl/vert/dynamic.flatten.vert delete mode 100644 deps/SPIRV-Cross/shaders-msl/vert/functions.vert delete mode 100644 deps/SPIRV-Cross/shaders-msl/vert/out_block.vert delete mode 100644 deps/SPIRV-Cross/shaders-msl/vert/pointsize.vert delete mode 100644 deps/SPIRV-Cross/shaders-msl/vert/texture_buffer.vert delete mode 100644 deps/SPIRV-Cross/shaders-msl/vert/ubo.alignment.vert delete mode 100644 deps/SPIRV-Cross/shaders-msl/vert/ubo.vert delete mode 100644 deps/SPIRV-Cross/shaders-msl/vulkan/frag/push-constant.vk.frag delete mode 100644 deps/SPIRV-Cross/shaders-msl/vulkan/frag/spec-constant.vk.frag delete mode 100644 deps/SPIRV-Cross/shaders-msl/vulkan/vert/vulkan-vertex.vk.vert delete mode 100644 deps/SPIRV-Cross/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag delete mode 100644 deps/SPIRV-Cross/shaders/amd/fs.invalid.frag delete mode 100644 deps/SPIRV-Cross/shaders/amd/gcn_shader.comp delete mode 100644 deps/SPIRV-Cross/shaders/amd/shader_ballot.comp delete mode 100644 deps/SPIRV-Cross/shaders/amd/shader_ballot_nonuniform_invocations.invalid.comp delete mode 100644 deps/SPIRV-Cross/shaders/amd/shader_group_vote.comp delete mode 100644 deps/SPIRV-Cross/shaders/amd/shader_trinary_minmax.comp delete mode 100644 deps/SPIRV-Cross/shaders/asm/comp/bitcast_iadd.asm.comp delete mode 100644 deps/SPIRV-Cross/shaders/asm/comp/bitcast_iequal.asm.comp delete mode 100644 deps/SPIRV-Cross/shaders/asm/comp/bitcast_sar.asm.comp delete mode 100644 deps/SPIRV-Cross/shaders/asm/comp/bitcast_sdiv.asm.comp delete mode 100644 deps/SPIRV-Cross/shaders/asm/comp/bitcast_slr.asm.comp delete mode 100644 deps/SPIRV-Cross/shaders/asm/comp/logical.asm.comp delete mode 100644 deps/SPIRV-Cross/shaders/asm/comp/multiple-entry.asm.comp delete mode 100644 deps/SPIRV-Cross/shaders/asm/comp/name-alias.asm.invalid.comp delete mode 100644 deps/SPIRV-Cross/shaders/asm/comp/quantize.asm.comp delete mode 100644 deps/SPIRV-Cross/shaders/asm/comp/specialization-constant-workgroup.asm.comp delete mode 100644 deps/SPIRV-Cross/shaders/asm/comp/storage-buffer-basic.asm.comp delete mode 100644 deps/SPIRV-Cross/shaders/asm/frag/composite-construct-struct-no-swizzle.asm.frag delete mode 100644 deps/SPIRV-Cross/shaders/asm/frag/default-member-names.asm.frag delete mode 100644 deps/SPIRV-Cross/shaders/asm/frag/hlsl-sample-cmp-level-zero-cube.asm.frag delete mode 100644 deps/SPIRV-Cross/shaders/asm/frag/hlsl-sample-cmp-level-zero.asm.frag delete mode 100644 deps/SPIRV-Cross/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag delete mode 100644 deps/SPIRV-Cross/shaders/asm/frag/invalidation.asm.frag delete mode 100644 deps/SPIRV-Cross/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag delete mode 100644 deps/SPIRV-Cross/shaders/asm/frag/multi-for-loop-init.asm.frag delete mode 100644 deps/SPIRV-Cross/shaders/asm/frag/op-constant-null.asm.frag delete mode 100644 deps/SPIRV-Cross/shaders/asm/frag/phi-loop-variable.asm.frag delete mode 100644 deps/SPIRV-Cross/shaders/asm/frag/sampler-buffer-without-sampler.asm.frag delete mode 100644 deps/SPIRV-Cross/shaders/asm/frag/struct-composite-extract-swizzle.asm.frag delete mode 100644 deps/SPIRV-Cross/shaders/asm/frag/temporary-phi-hoisting.asm.frag delete mode 100644 deps/SPIRV-Cross/shaders/asm/frag/undef-variable-store.asm.frag delete mode 100644 deps/SPIRV-Cross/shaders/asm/frag/unreachable.asm.frag delete mode 100644 deps/SPIRV-Cross/shaders/asm/frag/vector-shuffle-oom.asm.frag delete mode 100644 deps/SPIRV-Cross/shaders/asm/tesc/tess-fixed-input-array-builtin-array.asm.tesc delete mode 100644 deps/SPIRV-Cross/shaders/asm/vert/empty-io.asm.vert delete mode 100644 deps/SPIRV-Cross/shaders/asm/vert/empty-struct-composite.asm.vert delete mode 100644 deps/SPIRV-Cross/shaders/asm/vert/global-builtin.sso.asm.vert delete mode 100644 deps/SPIRV-Cross/shaders/comp/atomic.comp delete mode 100644 deps/SPIRV-Cross/shaders/comp/bake_gradient.comp delete mode 100644 deps/SPIRV-Cross/shaders/comp/barriers.comp delete mode 100644 deps/SPIRV-Cross/shaders/comp/basic.comp delete mode 100644 deps/SPIRV-Cross/shaders/comp/bitfield.noopt.comp delete mode 100644 deps/SPIRV-Cross/shaders/comp/casts.comp delete mode 100644 deps/SPIRV-Cross/shaders/comp/cfg-preserve-parameter.comp delete mode 100644 deps/SPIRV-Cross/shaders/comp/cfg.comp delete mode 100644 deps/SPIRV-Cross/shaders/comp/coherent-block.comp delete mode 100644 deps/SPIRV-Cross/shaders/comp/coherent-image.comp delete mode 100644 deps/SPIRV-Cross/shaders/comp/composite-construct.comp delete mode 100644 deps/SPIRV-Cross/shaders/comp/culling.comp delete mode 100644 deps/SPIRV-Cross/shaders/comp/defer-parens.comp delete mode 100644 deps/SPIRV-Cross/shaders/comp/dowhile.comp delete mode 100644 deps/SPIRV-Cross/shaders/comp/generate_height.comp delete mode 100644 deps/SPIRV-Cross/shaders/comp/image.comp delete mode 100644 deps/SPIRV-Cross/shaders/comp/inout-struct.invalid.comp delete mode 100644 deps/SPIRV-Cross/shaders/comp/insert.comp delete mode 100644 deps/SPIRV-Cross/shaders/comp/loop.noopt.comp delete mode 100644 deps/SPIRV-Cross/shaders/comp/mat3.comp delete mode 100644 deps/SPIRV-Cross/shaders/comp/mod.comp delete mode 100644 deps/SPIRV-Cross/shaders/comp/modf.comp delete mode 100644 deps/SPIRV-Cross/shaders/comp/read-write-only.comp delete mode 100644 deps/SPIRV-Cross/shaders/comp/return.comp delete mode 100644 deps/SPIRV-Cross/shaders/comp/rmw-opt.comp delete mode 100644 deps/SPIRV-Cross/shaders/comp/shared.comp delete mode 100644 deps/SPIRV-Cross/shaders/comp/ssbo-array.comp delete mode 100644 deps/SPIRV-Cross/shaders/comp/struct-layout.comp delete mode 100644 deps/SPIRV-Cross/shaders/comp/struct-packing.comp delete mode 100644 deps/SPIRV-Cross/shaders/comp/torture-loop.comp delete mode 100644 deps/SPIRV-Cross/shaders/comp/type-alias.comp delete mode 100644 deps/SPIRV-Cross/shaders/comp/udiv.comp delete mode 100644 deps/SPIRV-Cross/shaders/desktop-only/comp/enhanced-layouts.comp delete mode 100644 deps/SPIRV-Cross/shaders/desktop-only/comp/fp64.desktop.comp delete mode 100644 deps/SPIRV-Cross/shaders/desktop-only/comp/image-formats.desktop.noeliminate.comp delete mode 100644 deps/SPIRV-Cross/shaders/desktop-only/comp/int64.desktop.comp delete mode 100644 deps/SPIRV-Cross/shaders/desktop-only/frag/hlsl-uav-block-alias.asm.frag delete mode 100644 deps/SPIRV-Cross/shaders/desktop-only/frag/image-ms.desktop.frag delete mode 100644 deps/SPIRV-Cross/shaders/desktop-only/frag/image-query.desktop.frag delete mode 100644 deps/SPIRV-Cross/shaders/desktop-only/frag/in-block-qualifiers.frag delete mode 100644 deps/SPIRV-Cross/shaders/desktop-only/frag/query-levels.desktop.frag delete mode 100644 deps/SPIRV-Cross/shaders/desktop-only/frag/query-lod.desktop.frag delete mode 100644 deps/SPIRV-Cross/shaders/desktop-only/frag/sampler-ms-query.desktop.frag delete mode 100644 deps/SPIRV-Cross/shaders/desktop-only/frag/texture-proj-shadow.desktop.frag delete mode 100644 deps/SPIRV-Cross/shaders/desktop-only/geom/basic.desktop.sso.geom delete mode 100644 deps/SPIRV-Cross/shaders/desktop-only/geom/viewport-index.desktop.geom delete mode 100644 deps/SPIRV-Cross/shaders/desktop-only/tesc/basic.desktop.sso.tesc delete mode 100644 deps/SPIRV-Cross/shaders/desktop-only/tese/triangle.desktop.sso.tese delete mode 100644 deps/SPIRV-Cross/shaders/desktop-only/vert/basic.desktop.sso.vert delete mode 100644 deps/SPIRV-Cross/shaders/desktop-only/vert/clip-cull-distance.desktop.vert delete mode 100644 deps/SPIRV-Cross/shaders/desktop-only/vert/out-block-qualifiers.vert delete mode 100644 deps/SPIRV-Cross/shaders/flatten/array.flatten.vert delete mode 100644 deps/SPIRV-Cross/shaders/flatten/basic.flatten.vert delete mode 100644 deps/SPIRV-Cross/shaders/flatten/copy.flatten.vert delete mode 100644 deps/SPIRV-Cross/shaders/flatten/dynamic.flatten.vert delete mode 100644 deps/SPIRV-Cross/shaders/flatten/matrixindex.flatten.vert delete mode 100644 deps/SPIRV-Cross/shaders/flatten/multi-dimensional.desktop.flatten_dim.frag delete mode 100644 deps/SPIRV-Cross/shaders/flatten/multiindex.flatten.vert delete mode 100644 deps/SPIRV-Cross/shaders/flatten/push-constant.flatten.vert delete mode 100644 deps/SPIRV-Cross/shaders/flatten/rowmajor.flatten.vert delete mode 100644 deps/SPIRV-Cross/shaders/flatten/struct.flatten.vert delete mode 100644 deps/SPIRV-Cross/shaders/flatten/struct.rowmajor.flatten.vert delete mode 100644 deps/SPIRV-Cross/shaders/flatten/swizzle.flatten.vert delete mode 100644 deps/SPIRV-Cross/shaders/flatten/types.flatten.frag delete mode 100644 deps/SPIRV-Cross/shaders/frag/basic.frag delete mode 100644 deps/SPIRV-Cross/shaders/frag/composite-extract-forced-temporary.frag delete mode 100644 deps/SPIRV-Cross/shaders/frag/constant-array.frag delete mode 100644 deps/SPIRV-Cross/shaders/frag/false-loop-init.frag delete mode 100644 deps/SPIRV-Cross/shaders/frag/flush_params.frag delete mode 100644 deps/SPIRV-Cross/shaders/frag/for-loop-init.frag delete mode 100644 deps/SPIRV-Cross/shaders/frag/frexp-modf.frag delete mode 100755 deps/SPIRV-Cross/shaders/frag/ground.frag delete mode 100644 deps/SPIRV-Cross/shaders/frag/image-load-store-uint-coord.asm.frag delete mode 100644 deps/SPIRV-Cross/shaders/frag/mix.frag delete mode 100644 deps/SPIRV-Cross/shaders/frag/partial-write-preserve.frag delete mode 100644 deps/SPIRV-Cross/shaders/frag/pls.frag delete mode 100644 deps/SPIRV-Cross/shaders/frag/sample-parameter.frag delete mode 100644 deps/SPIRV-Cross/shaders/frag/sampler-ms.frag delete mode 100644 deps/SPIRV-Cross/shaders/frag/sampler-proj.frag delete mode 100644 deps/SPIRV-Cross/shaders/frag/sampler.frag delete mode 100644 deps/SPIRV-Cross/shaders/frag/swizzle.frag delete mode 100644 deps/SPIRV-Cross/shaders/frag/ubo_layout.frag delete mode 100644 deps/SPIRV-Cross/shaders/frag/unary-enclose.frag delete mode 100644 deps/SPIRV-Cross/shaders/geom/basic.geom delete mode 100644 deps/SPIRV-Cross/shaders/geom/lines-adjacency.geom delete mode 100644 deps/SPIRV-Cross/shaders/geom/lines.geom delete mode 100644 deps/SPIRV-Cross/shaders/geom/points.geom delete mode 100644 deps/SPIRV-Cross/shaders/geom/single-invocation.geom delete mode 100644 deps/SPIRV-Cross/shaders/geom/triangles-adjacency.geom delete mode 100644 deps/SPIRV-Cross/shaders/geom/triangles.geom delete mode 100644 deps/SPIRV-Cross/shaders/legacy/fragment/explicit-lod.legacy.frag delete mode 100644 deps/SPIRV-Cross/shaders/legacy/fragment/io-blocks.legacy.frag delete mode 100644 deps/SPIRV-Cross/shaders/legacy/fragment/struct-varying.legacy.frag delete mode 100644 deps/SPIRV-Cross/shaders/legacy/vert/implicit-lod.legacy.vert delete mode 100644 deps/SPIRV-Cross/shaders/legacy/vert/io-block.legacy.vert delete mode 100644 deps/SPIRV-Cross/shaders/legacy/vert/struct-varying.legacy.vert delete mode 100644 deps/SPIRV-Cross/shaders/legacy/vert/transpose.legacy.vert delete mode 100644 deps/SPIRV-Cross/shaders/tesc/basic.tesc delete mode 100644 deps/SPIRV-Cross/shaders/tesc/water_tess.tesc delete mode 100644 deps/SPIRV-Cross/shaders/tese/ccw.tese delete mode 100644 deps/SPIRV-Cross/shaders/tese/cw.tese delete mode 100644 deps/SPIRV-Cross/shaders/tese/equal.tese delete mode 100644 deps/SPIRV-Cross/shaders/tese/fractional_even.tese delete mode 100644 deps/SPIRV-Cross/shaders/tese/fractional_odd.tese delete mode 100644 deps/SPIRV-Cross/shaders/tese/line.tese delete mode 100644 deps/SPIRV-Cross/shaders/tese/triangle.tese delete mode 100644 deps/SPIRV-Cross/shaders/tese/water_tess.tese delete mode 100644 deps/SPIRV-Cross/shaders/vert/basic.vert delete mode 100755 deps/SPIRV-Cross/shaders/vert/ground.vert delete mode 100644 deps/SPIRV-Cross/shaders/vert/ocean.vert delete mode 100644 deps/SPIRV-Cross/shaders/vert/texture_buffer.vert delete mode 100644 deps/SPIRV-Cross/shaders/vert/ubo.vert delete mode 100644 deps/SPIRV-Cross/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag delete mode 100644 deps/SPIRV-Cross/shaders/vulkan/frag/combined-texture-sampler.vk.frag delete mode 100644 deps/SPIRV-Cross/shaders/vulkan/frag/desktop-mediump.vk.frag delete mode 100644 deps/SPIRV-Cross/shaders/vulkan/frag/input-attachment-ms.vk.frag delete mode 100644 deps/SPIRV-Cross/shaders/vulkan/frag/input-attachment.vk.frag delete mode 100644 deps/SPIRV-Cross/shaders/vulkan/frag/push-constant.vk.frag delete mode 100644 deps/SPIRV-Cross/shaders/vulkan/frag/separate-sampler-texture.vk.frag delete mode 100644 deps/SPIRV-Cross/shaders/vulkan/frag/spec-constant.vk.frag delete mode 100644 deps/SPIRV-Cross/shaders/vulkan/vert/multiview.nocompat.vk.vert delete mode 100644 deps/SPIRV-Cross/shaders/vulkan/vert/vulkan-vertex.vk.vert delete mode 100644 deps/SPIRV-Cross/spirv.hpp delete mode 100644 deps/SPIRV-Cross/spirv_cfg.cpp delete mode 100644 deps/SPIRV-Cross/spirv_cfg.hpp delete mode 100644 deps/SPIRV-Cross/spirv_common.hpp delete mode 100644 deps/SPIRV-Cross/spirv_cpp.cpp delete mode 100644 deps/SPIRV-Cross/spirv_cpp.hpp delete mode 100644 deps/SPIRV-Cross/spirv_cross.cpp delete mode 100644 deps/SPIRV-Cross/spirv_cross.hpp delete mode 100644 deps/SPIRV-Cross/spirv_glsl.cpp delete mode 100644 deps/SPIRV-Cross/spirv_glsl.hpp delete mode 100644 deps/SPIRV-Cross/spirv_hlsl.cpp delete mode 100644 deps/SPIRV-Cross/spirv_hlsl.hpp delete mode 100644 deps/SPIRV-Cross/spirv_msl.cpp delete mode 100644 deps/SPIRV-Cross/spirv_msl.hpp delete mode 100755 deps/SPIRV-Cross/test_shaders.py delete mode 100644 deps/SPIRV-Cross/test_shaders.sh delete mode 100644 deps/SPIRV-Cross/update_test_shaders.sh diff --git a/deps/SPIRV-Cross/.clang-format b/deps/SPIRV-Cross/.clang-format deleted file mode 100755 index 443f90b774..0000000000 --- a/deps/SPIRV-Cross/.clang-format +++ /dev/null @@ -1,167 +0,0 @@ -# The style used for all options not specifically set in the configuration. -BasedOnStyle: LLVM - -# The extra indent or outdent of access modifiers, e.g. public:. -AccessModifierOffset: -4 - -# If true, aligns escaped newlines as far left as possible. Otherwise puts them into the right-most column. -AlignEscapedNewlinesLeft: true - -# If true, aligns trailing comments. -AlignTrailingComments: false - -# Allow putting all parameters of a function declaration onto the next line even if BinPackParameters is false. -AllowAllParametersOfDeclarationOnNextLine: false - -# Allows contracting simple braced statements to a single line. -AllowShortBlocksOnASingleLine: false - -# If true, short case labels will be contracted to a single line. -AllowShortCaseLabelsOnASingleLine: false - -# Dependent on the value, int f() { return 0; } can be put on a single line. Possible values: None, Inline, All. -AllowShortFunctionsOnASingleLine: None - -# If true, if (a) return; can be put on a single line. -AllowShortIfStatementsOnASingleLine: false - -# If true, while (true) continue; can be put on a single line. -AllowShortLoopsOnASingleLine: false - -# If true, always break after function definition return types. -AlwaysBreakAfterDefinitionReturnType: false - -# If true, always break before multiline string literals. -AlwaysBreakBeforeMultilineStrings: false - -# If true, always break after the template<...> of a template declaration. -AlwaysBreakTemplateDeclarations: true - -# If false, a function call's arguments will either be all on the same line or will have one line each. -BinPackArguments: true - -# If false, a function declaration's or function definition's parameters will either all be on the same line -# or will have one line each. -BinPackParameters: true - -# The way to wrap binary operators. Possible values: None, NonAssignment, All. -BreakBeforeBinaryOperators: None - -# The brace breaking style to use. Possible values: Attach, Linux, Stroustrup, Allman, GNU. -BreakBeforeBraces: Allman - -# If true, ternary operators will be placed after line breaks. -BreakBeforeTernaryOperators: false - -# Always break constructor initializers before commas and align the commas with the colon. -BreakConstructorInitializersBeforeComma: true - -# The column limit. A column limit of 0 means that there is no column limit. -ColumnLimit: 120 - -# A regular expression that describes comments with special meaning, which should not be split into lines or otherwise changed. -CommentPragmas: '^ *' - -# If the constructor initializers don't fit on a line, put each initializer on its own line. -ConstructorInitializerAllOnOneLineOrOnePerLine: false - -# The number of characters to use for indentation of constructor initializer lists. -ConstructorInitializerIndentWidth: 4 - -# Indent width for line continuations. -ContinuationIndentWidth: 4 - -# If true, format braced lists as best suited for C++11 braced lists. -Cpp11BracedListStyle: false - -# Disables formatting at all. -DisableFormat: false - -# A vector of macros that should be interpreted as foreach loops instead of as function calls. -#ForEachMacros: '' - -# Indent case labels one level from the switch statement. -# When false, use the same indentation level as for the switch statement. -# Switch statement body is always indented one level more than case labels. -IndentCaseLabels: false - -# The number of columns to use for indentation. -IndentWidth: 4 - -# Indent if a function definition or declaration is wrapped after the type. -IndentWrappedFunctionNames: false - -# If true, empty lines at the start of blocks are kept. -KeepEmptyLinesAtTheStartOfBlocks: true - -# Language, this format style is targeted at. Possible values: None, Cpp, Java, JavaScript, Proto. -Language: Cpp - -# The maximum number of consecutive empty lines to keep. -MaxEmptyLinesToKeep: 1 - -# The indentation used for namespaces. Possible values: None, Inner, All. -NamespaceIndentation: None - -# The penalty for breaking a function call after "call(". -PenaltyBreakBeforeFirstCallParameter: 19 - -# The penalty for each line break introduced inside a comment. -PenaltyBreakComment: 300 - -# The penalty for breaking before the first <<. -PenaltyBreakFirstLessLess: 120 - -# The penalty for each line break introduced inside a string literal. -PenaltyBreakString: 1000 - -# The penalty for each character outside of the column limit. -PenaltyExcessCharacter: 1000000 - -# Penalty for putting the return type of a function onto its own line. -PenaltyReturnTypeOnItsOwnLine: 1000000000 - -# Pointer and reference alignment style. Possible values: Left, Right, Middle. -PointerAlignment: Right - -# If true, a space may be inserted after C style casts. -SpaceAfterCStyleCast: false - -# If false, spaces will be removed before assignment operators. -SpaceBeforeAssignmentOperators: true - -# Defines in which cases to put a space before opening parentheses. Possible values: Never, ControlStatements, Always. -SpaceBeforeParens: ControlStatements - -# If true, spaces may be inserted into '()'. -SpaceInEmptyParentheses: false - -# The number of spaces before trailing line comments (// - comments). -SpacesBeforeTrailingComments: 1 - -# If true, spaces will be inserted after '<' and before '>' in template argument lists. -SpacesInAngles: false - -# If true, spaces may be inserted into C style casts. -SpacesInCStyleCastParentheses: false - -# If true, spaces are inserted inside container literals (e.g. ObjC and Javascript array and dict literals). -SpacesInContainerLiterals: false - -# If true, spaces will be inserted after '(' and before ')'. -SpacesInParentheses: false - -# If true, spaces will be inserted after '[' and befor']'. -SpacesInSquareBrackets: false - -# Format compatible with this standard, e.g. use A > instead of A> for LS_Cpp03. Possible values: Cpp03, Cpp11, Auto. -Standard: Cpp11 - -# The number of columns used for tab stops. -TabWidth: 4 - -# The way to use tab characters in the resulting file. Possible values: Never, ForIndentation, Always. -UseTab: ForIndentation - -# Do not reflow comments -ReflowComments: false diff --git a/deps/SPIRV-Cross/.gitignore b/deps/SPIRV-Cross/.gitignore deleted file mode 100644 index b89f729741..0000000000 --- a/deps/SPIRV-Cross/.gitignore +++ /dev/null @@ -1,19 +0,0 @@ -*.o -*.d -*.txt -/test -/spirv-cross -*.spv -/obj -/msvc/x64 -/msvc/Debug -/msvc/Release -*.suo -*.sdf -*.opensdf -*.shader -*.a -*.bc -/external - -!CMakeLists.txt diff --git a/deps/SPIRV-Cross/.travis.yml b/deps/SPIRV-Cross/.travis.yml deleted file mode 100644 index 21af2a0203..0000000000 --- a/deps/SPIRV-Cross/.travis.yml +++ /dev/null @@ -1,33 +0,0 @@ -language: cpp -os: - - linux - - osx -osx_image: xcode8.2 - -# Use Ubuntu 14.04 LTS (Trusty) as the Linux testing environment. -sudo: required -dist: trusty - -# We check out glslang and SPIRV-Tools at specific revisions to avoid test output mismatches -env: - - GLSLANG_REV=9c6f8cc29ba303b43ccf36deea6bb38a304f9b92 SPIRV_TOOLS_REV=e28edd458b729da7bbfd51e375feb33103709e6f - -before_script: - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; brew install 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 - -script: - - git -C glslang checkout $GLSLANG_REV - - git -C SPIRV-Tools checkout $SPIRV_TOOLS_REV - - cd glslang && cmake . && make -j2 && cd .. - - cd SPIRV-Tools && cmake . && make -j2 && cd .. - - make -j2 - - PATH=./glslang/StandAlone:./SPIRV-Tools/tools:$PATH - - ./test_shaders.py shaders - - ./test_shaders.py --msl shaders-msl - - ./test_shaders.py --hlsl shaders-hlsl - - ./test_shaders.py shaders --opt - - ./test_shaders.py --msl shaders-msl --opt - - ./test_shaders.py --hlsl shaders-hlsl --opt diff --git a/deps/SPIRV-Cross/CMakeLists.txt b/deps/SPIRV-Cross/CMakeLists.txt deleted file mode 100644 index cd3f677475..0000000000 --- a/deps/SPIRV-Cross/CMakeLists.txt +++ /dev/null @@ -1,145 +0,0 @@ -# Copyright 2016 Google Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -cmake_minimum_required(VERSION 2.8) -project(SPIRV-Cross) -enable_testing() - -option(SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS "Instead of throwing exceptions assert" OFF) - -if(${CMAKE_GENERATOR} MATCHES "Makefile") - if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR}) - message(FATAL_ERROR "Build out of tree to avoid overwriting Makefile") - endif() -endif() - -set(spirv-compiler-options "") -set(spirv-compiler-defines "") - -if(SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS) - set(spirv-compiler-defines ${spirv-compiler-defines} SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS) -endif() - -# To specify special debug or optimization options, use -# -DCMAKE_CXX_COMPILE_FLAGS -# However, we require the C++11 dialect. -if (NOT "${MSVC}") - set(spirv-compiler-options ${spirv-compiler-options} -std=c++11 -Wall -Wextra -Werror -Wshadow) - set(spirv-compiler-defines ${spirv-compiler-defines} __STDC_LIMIT_MACROS) - - if(SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS) - set(spirv-compiler-options ${spirv-compiler-options} -fno-exceptions) - endif() -endif() - -macro(extract_headers out_abs file_list) - set(${out_abs}) # absolute paths - foreach(_a ${file_list}) - # get_filename_component only returns the longest extension, so use a regex - string(REGEX REPLACE ".*\\.(h|hpp)" "\\1" ext ${_a}) - if(("${ext}" STREQUAL "h") OR ("${ext}" STREQUAL "hpp")) - list(APPEND ${out_abs} "${_a}") - endif() - endforeach() -endmacro() - -macro(spirv_cross_add_library name config_name) - add_library(${name} ${ARGN}) - extract_headers(hdrs "${ARGN}") - target_include_directories(${name} PUBLIC - $ - $) - set_target_properties(${name} PROPERTIES - PUBLIC_HEADERS "${hdrs}") - target_compile_options(${name} PRIVATE ${spirv-compiler-options}) - target_compile_definitions(${name} PRIVATE ${spirv-compiler-defines}) - install(TARGETS ${name} - EXPORT ${config_name}Config - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - PUBLIC_HEADER DESTINATION include/spirv_cross) - install(FILES ${hdrs} DESTINATION include/spirv_cross) - install(EXPORT ${config_name}Config DESTINATION share/${config_name}/cmake) - export(TARGETS ${targets} FILE ${config_name}Config.cmake) -endmacro() - - -spirv_cross_add_library(spirv-cross-core spirv_cross_core STATIC - ${CMAKE_CURRENT_SOURCE_DIR}/GLSL.std.450.h - ${CMAKE_CURRENT_SOURCE_DIR}/spirv_common.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/spirv.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/spirv_cross.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/spirv_cross.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/spirv_cfg.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/spirv_cfg.cpp) - -spirv_cross_add_library(spirv-cross-glsl spirv_cross_glsl STATIC - ${CMAKE_CURRENT_SOURCE_DIR}/spirv_glsl.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/spirv_glsl.hpp) - -spirv_cross_add_library(spirv-cross-cpp spirv_cross_cpp STATIC - ${CMAKE_CURRENT_SOURCE_DIR}/spirv_cpp.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/spirv_cpp.cpp) - -spirv_cross_add_library(spirv-cross-msl spirv_cross_msl STATIC - ${CMAKE_CURRENT_SOURCE_DIR}/spirv_msl.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/spirv_msl.cpp) - -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) - -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-glsl spirv-cross-core) -target_link_libraries(spirv-cross-msl spirv-cross-glsl) -target_link_libraries(spirv-cross-hlsl spirv-cross-glsl) -target_link_libraries(spirv-cross-cpp spirv-cross-glsl) - -# Set up tests, using only the simplest modes of the test_shaders -# script. You have to invoke the script manually to: -# - Update the reference files -# - Get cycle counts from malisc -# - Keep failing outputs -find_package(PythonInterp) -if (${PYTHONINTERP_FOUND}) - if (${PYTHON_VERSION_MAJOR} GREATER 2) - add_test(NAME spirv-cross-test - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_shaders.py - ${CMAKE_CURRENT_SOURCE_DIR}/shaders) - add_test(NAME spirv-cross-test-metal - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_shaders.py --metal - ${CMAKE_CURRENT_SOURCE_DIR}/shaders-msl) - add_test(NAME spirv-cross-test-hlsl - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_shaders.py --hlsl - ${CMAKE_CURRENT_SOURCE_DIR}/shaders-hlsl) - add_test(NAME spirv-cross-test-opt - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_shaders.py --opt - ${CMAKE_CURRENT_SOURCE_DIR}/shaders) - add_test(NAME spirv-cross-test-metal-opt - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_shaders.py --metal --opt - ${CMAKE_CURRENT_SOURCE_DIR}/shaders-msl) - add_test(NAME spirv-cross-test-hlsl-opt - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_shaders.py --hlsl --opt - ${CMAKE_CURRENT_SOURCE_DIR}/shaders-hlsl) - endif() -else() - message(WARNING "Testing disabled. Could not find python3. If you have python3 installed try running " - "cmake with -DPYTHON_EXECUTABLE:FILEPATH=/path/to/python3 to help it find the executable") -endif() diff --git a/deps/SPIRV-Cross/GLSL.std.450.h b/deps/SPIRV-Cross/GLSL.std.450.h deleted file mode 100644 index 54cc00e9a8..0000000000 --- a/deps/SPIRV-Cross/GLSL.std.450.h +++ /dev/null @@ -1,131 +0,0 @@ -/* -** Copyright (c) 2014-2016 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a copy -** of this software and/or associated documentation files (the "Materials"), -** to deal in the Materials without restriction, including without limitation -** the rights to use, copy, modify, merge, publish, distribute, sublicense, -** and/or sell copies of the Materials, and to permit persons to whom the -** Materials are furnished to do so, subject to the following conditions: -** -** The above copyright notice and this permission notice shall be included in -** all copies or substantial portions of the Materials. -** -** MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS -** STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND -** HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -** OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -** THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -** FROM,OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS -** IN THE MATERIALS. -*/ - -#ifndef GLSLstd450_H -#define GLSLstd450_H - -static const int GLSLstd450Version = 100; -static const int GLSLstd450Revision = 3; - -enum GLSLstd450 { - GLSLstd450Bad = 0, // Don't use - - GLSLstd450Round = 1, - GLSLstd450RoundEven = 2, - GLSLstd450Trunc = 3, - GLSLstd450FAbs = 4, - GLSLstd450SAbs = 5, - GLSLstd450FSign = 6, - GLSLstd450SSign = 7, - GLSLstd450Floor = 8, - GLSLstd450Ceil = 9, - GLSLstd450Fract = 10, - - GLSLstd450Radians = 11, - GLSLstd450Degrees = 12, - GLSLstd450Sin = 13, - GLSLstd450Cos = 14, - GLSLstd450Tan = 15, - GLSLstd450Asin = 16, - GLSLstd450Acos = 17, - GLSLstd450Atan = 18, - GLSLstd450Sinh = 19, - GLSLstd450Cosh = 20, - GLSLstd450Tanh = 21, - GLSLstd450Asinh = 22, - GLSLstd450Acosh = 23, - GLSLstd450Atanh = 24, - GLSLstd450Atan2 = 25, - - GLSLstd450Pow = 26, - GLSLstd450Exp = 27, - GLSLstd450Log = 28, - GLSLstd450Exp2 = 29, - GLSLstd450Log2 = 30, - GLSLstd450Sqrt = 31, - GLSLstd450InverseSqrt = 32, - - GLSLstd450Determinant = 33, - GLSLstd450MatrixInverse = 34, - - GLSLstd450Modf = 35, // second operand needs an OpVariable to write to - GLSLstd450ModfStruct = 36, // no OpVariable operand - GLSLstd450FMin = 37, - GLSLstd450UMin = 38, - GLSLstd450SMin = 39, - GLSLstd450FMax = 40, - GLSLstd450UMax = 41, - GLSLstd450SMax = 42, - GLSLstd450FClamp = 43, - GLSLstd450UClamp = 44, - GLSLstd450SClamp = 45, - GLSLstd450FMix = 46, - GLSLstd450IMix = 47, // Reserved - GLSLstd450Step = 48, - GLSLstd450SmoothStep = 49, - - GLSLstd450Fma = 50, - GLSLstd450Frexp = 51, // second operand needs an OpVariable to write to - GLSLstd450FrexpStruct = 52, // no OpVariable operand - GLSLstd450Ldexp = 53, - - GLSLstd450PackSnorm4x8 = 54, - GLSLstd450PackUnorm4x8 = 55, - GLSLstd450PackSnorm2x16 = 56, - GLSLstd450PackUnorm2x16 = 57, - GLSLstd450PackHalf2x16 = 58, - GLSLstd450PackDouble2x32 = 59, - GLSLstd450UnpackSnorm2x16 = 60, - GLSLstd450UnpackUnorm2x16 = 61, - GLSLstd450UnpackHalf2x16 = 62, - GLSLstd450UnpackSnorm4x8 = 63, - GLSLstd450UnpackUnorm4x8 = 64, - GLSLstd450UnpackDouble2x32 = 65, - - GLSLstd450Length = 66, - GLSLstd450Distance = 67, - GLSLstd450Cross = 68, - GLSLstd450Normalize = 69, - GLSLstd450FaceForward = 70, - GLSLstd450Reflect = 71, - GLSLstd450Refract = 72, - - GLSLstd450FindILsb = 73, - GLSLstd450FindSMsb = 74, - GLSLstd450FindUMsb = 75, - - GLSLstd450InterpolateAtCentroid = 76, - GLSLstd450InterpolateAtSample = 77, - GLSLstd450InterpolateAtOffset = 78, - - GLSLstd450NMin = 79, - GLSLstd450NMax = 80, - GLSLstd450NClamp = 81, - - GLSLstd450Count -}; - -#endif // #ifndef GLSLstd450_H diff --git a/deps/SPIRV-Cross/LICENSE b/deps/SPIRV-Cross/LICENSE deleted file mode 100644 index d645695673..0000000000 --- a/deps/SPIRV-Cross/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/deps/SPIRV-Cross/Makefile b/deps/SPIRV-Cross/Makefile deleted file mode 100644 index 0564b650ad..0000000000 --- a/deps/SPIRV-Cross/Makefile +++ /dev/null @@ -1,41 +0,0 @@ -TARGET := spirv-cross - -SOURCES := $(wildcard spirv_*.cpp) -CLI_SOURCES := main.cpp - -OBJECTS := $(SOURCES:.cpp=.o) -CLI_OBJECTS := $(CLI_SOURCES:.cpp=.o) - -STATIC_LIB := lib$(TARGET).a - -DEPS := $(OBJECTS:.o=.d) $(CLI_OBJECTS:.o=.d) - -CXXFLAGS += -std=c++11 -Wall -Wextra -Wshadow -D__STDC_LIMIT_MACROS - -ifeq ($(DEBUG), 1) - CXXFLAGS += -O0 -g -else - CXXFLAGS += -O2 -DNDEBUG -endif - -ifeq ($(SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS), 1) - CXXFLAGS += -DSPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS -fno-exceptions -endif - -all: $(TARGET) - --include $(DEPS) - -$(TARGET): $(CLI_OBJECTS) $(STATIC_LIB) - $(CXX) -o $@ $(CLI_OBJECTS) $(STATIC_LIB) $(LDFLAGS) - -$(STATIC_LIB): $(OBJECTS) - $(AR) rcs $@ $(OBJECTS) - -%.o: %.cpp - $(CXX) -c -o $@ $< $(CXXFLAGS) -MMD - -clean: - rm -f $(TARGET) $(OBJECTS) $(CLI_OBJECTS) $(STATIC_LIB) $(DEPS) - -.PHONY: clean diff --git a/deps/SPIRV-Cross/README.md b/deps/SPIRV-Cross/README.md deleted file mode 100644 index e1409a4bf7..0000000000 --- a/deps/SPIRV-Cross/README.md +++ /dev/null @@ -1,350 +0,0 @@ -# SPIRV-Cross - -SPIRV-Cross is a tool designed for parsing and converting SPIR-V to other shader languages. - -[![Build Status](https://travis-ci.org/KhronosGroup/SPIRV-Cross.svg?branch=master)](https://travis-ci.org/KhronosGroup/SPIRV-Cross) - -## 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 debuggable C++ [EXPERIMENTAL] - - Reflection API to simplify the creation of Vulkan pipeline layouts - - Reflection API to modify and tweak OpDecorations - - Supports "all" of vertex, fragment, tessellation, geometry and compute shaders. - -SPIRV-Cross tries hard to emit readable and clean output from the SPIR-V. -The goal is to emit GLSL or MSL that looks like it was written by a human and not awkward IR/assembly-like code. - -NOTE: Individual features are expected to be mostly complete, but it is possible that certain obscure GLSL features are not yet supported. -However, most missing features are expected to be "trivial" improvements at this stage. - -## Building - -SPIRV-Cross has been tested on Linux, OSX and Windows. - -The make and CMake build flavors offer the option to treat exceptions as assertions. To disable exceptions for make just append SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS=1 to the command line. For CMake append -DSPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS=ON. By default exceptions are enabled. - -### Linux and macOS - -Just run `make` on the command line. A recent GCC (4.8+) or Clang (3.x+) compiler is required as SPIRV-Cross uses C++11 extensively. - -### Windows - -MinGW-w64 based compilation works with `make`, and an MSVC 2013 solution is also included. - -## Usage - -### Using the C++ API - -To perform reflection and convert to other shader languages you can use the SPIRV-Cross API. -For example: - -``` -#include "spirv_glsl.hpp" -#include -#include - -extern std::vector load_spirv_file(); - -int main() -{ - // Read SPIR-V from disk or similar. - std::vector spirv_binary = load_spirv_file(); - - spirv_cross::CompilerGLSL glsl(std::move(spirv_binary)); - - // The SPIR-V is now parsed, and we can perform reflection on it. - spirv_cross::ShaderResources resources = glsl.get_shader_resources(); - - // Get all sampled images in the shader. - for (auto &resource : resources.sampled_images) - { - unsigned set = glsl.get_decoration(resource.id, spv::DecorationDescriptorSet); - unsigned binding = glsl.get_decoration(resource.id, spv::DecorationBinding); - printf("Image %s at set = %u, binding = %u\n", resource.name.c_str(), set, binding); - - // Modify the decoration to prepare it for GLSL. - glsl.unset_decoration(resource.id, spv::DecorationDescriptorSet); - - // Some arbitrary remapping if we want. - glsl.set_decoration(resource.id, spv::DecorationBinding, set * 16 + binding); - } - - // Set some options. - spirv_cross::CompilerGLSL::Options options; - options.version = 310; - options.es = true; - glsl.set_options(options); - - // Compile to GLSL, ready to give to GL driver. - std::string source = glsl.compile(); -} -``` - -#### Integrating SPIRV-Cross in a custom build system - -To add SPIRV-Cross to your own codebase, just copy the source and header files from root directory -and build the relevant .cpp files you need. Make sure to build with C++11 support, e.g. `-std=c++11` in GCC and Clang. -Alternatively, the Makefile generates a libspirv-cross.a static library during build that can be linked in. - -### Creating a SPIR-V file from GLSL with glslang - -``` -glslangValidator -H -V -o test.spv test.frag -``` - -### Converting a SPIR-V file to GLSL ES - -``` -glslangValidator -H -V -o test.spv shaders/comp/basic.comp -./spirv-cross --version 310 --es test.spv -``` - -#### Converting to desktop GLSL - -``` -glslangValidator -H -V -o test.spv shaders/comp/basic.comp -./spirv-cross --version 330 test.spv --output test.comp -``` - -#### Disable prettifying optimizations - -``` -glslangValidator -H -V -o test.spv shaders/comp/basic.comp -./spirv-cross --version 310 --es test.spv --output test.comp --force-temporary -``` - -### Using shaders generated from C++ backend - -Please see `samples/cpp` where some GLSL shaders are compiled to SPIR-V, decompiled to C++ and run with test data. -Reading through the samples should explain how to use the C++ interface. -A simple Makefile is included to build all shaders in the directory. - -### Implementation notes - -When using SPIR-V and SPIRV-Cross as an intermediate step for cross-compiling between high level languages there are some considerations to take into account, -as not all features used by one high-level language are necessarily supported natively by the target shader language. -SPIRV-Cross aims to provide the tools needed to handle these scenarios in a clean and robust way, but some manual action is required to maintain compatibility. - -#### HLSL source to GLSL - -##### HLSL entry points - -When using SPIR-V shaders compiled from HLSL, there are some extra things you need to take care of. -First make sure that the entry point is used correctly. -If you forget to set the entry point correctly in glslangValidator (-e MyFancyEntryPoint), -you will likely encounter this error message: - -``` -Cannot end a function before ending the current block. -Likely cause: If this SPIR-V was created from glslang HLSL, make sure the entry point is valid. -``` - -##### Vertex/Fragment interface linking - -HLSL relies on semantics in order to effectively link together shader stages. In the SPIR-V generated by glslang, the transformation from HLSL to GLSL ends up looking like - -``` -struct VSOutput { - // SV_Position is rerouted to gl_Position - float4 position : SV_Position; - float4 coord : TEXCOORD0; -}; - -VSOutput main(...) {} -``` - -``` -struct VSOutput { - float4 coord; -} -layout(location = 0) out VSOutput _magicNameGeneratedByGlslang; -``` - -While this works, be aware of the type of the struct which is used in the vertex stage and the fragment stage. -There may be issues if the structure type name differs in vertex stage and fragment stage. - -You can make use of the reflection interface to force the name of the struct type. - -``` -// Something like this for both vertex outputs and fragment inputs. -compiler.set_name(varying_resource.base_type_id, "VertexFragmentLinkage"); -``` - -Some platform may require identical variable name for both vertex outputs and fragment inputs. (for example MacOSX) -to rename varaible base on location, please add -``` ---rename-interface-variable -``` - -#### HLSL source to legacy GLSL/ESSL - -HLSL tends to emit varying struct types to pass data between vertex and fragment. -This is not supported in legacy GL/GLES targets, so to support this, varying structs are flattened. -This is done automatically, but the API user might need to be aware that this is happening in order to support all cases. - -Modern GLES code like this: -``` -struct Output { - vec4 a; - vec2 b; -}; -out Output vout; -``` - -Is transformed into: -``` -struct Output { - vec4 a; - vec2 b; -}; -varying vec4 Output_a; -varying vec2 Output_b; -``` - -Note that now, both the struct name and the member names will participate in the linking interface between vertex and fragment, so -API users might want to ensure that both the struct names and member names match so that vertex outputs and fragment inputs can link properly. - - -#### Separate image samplers (HLSL/Vulkan) for backends which do not support it (GLSL) - -Another thing you need to remember is when using samplers and textures in HLSL these are separable, and not directly compatible with GLSL. If you need to use this with desktop GL/GLES, you need to call `Compiler::build_combined_image_samplers` first before calling `Compiler::compile`, or you will get an exception. - -``` -// From main.cpp -// Builds a mapping for all combinations of images and samplers. -compiler->build_combined_image_samplers(); - -// Give the remapped combined samplers new names. -// Here you can also set up decorations if you want (binding = #N). -for (auto &remap : compiler->get_combined_image_samplers()) -{ - compiler->set_name(remap.combined_id, join("SPIRV_Cross_Combined", compiler->get_name(remap.image_id), - compiler->get_name(remap.sampler_id))); -} -``` - -If your target is Vulkan GLSL, `--vulkan-semantics` will emit separate image samplers as you'd expect. -The command line client calls `Compiler::build_combined_image_samplers` automatically, but if you're calling the library, you'll need to do this yourself. - -#### Descriptor sets (Vulkan GLSL) for backends which do not support them (HLSL/GLSL/Metal) - -Descriptor sets are unique to Vulkan, so make sure that descriptor set + binding is remapped to a flat binding scheme (set always 0), so that other APIs can make sense of the bindings. -This can be done with `Compiler::set_decoration(id, spv::DecorationDescriptorSet)`. - -#### Linking by name for targets which do not support explicit locations (legacy GLSL/ESSL) - -Modern GLSL and HLSL sources (and SPIR-V) relies on explicit layout(location) qualifiers to guide the linking process between shader stages, -but older GLSL relies on symbol names to perform the linking. When emitting shaders with older versions, these layout statements will be removed, -so it is important that the API user ensures that the names of I/O variables are sanitized so that linking will work properly. -The reflection API can rename variables, struct types and struct members to deal with these scenarios using `Compiler::set_name` and friends. - -#### Clip-space conventions - -SPIRV-Cross can perform some common clip space conversions on gl_Position/SV_Position by enabling `CompilerGLSL::Options.vertex.fixup_clipspace`. -While this can be convenient, it is recommended to modify the projection matrices instead as that can achieve the same result. - -For GLSL targets, enabling this will convert a shader which assumes `[0, w]` depth range (Vulkan / D3D / Metal) into `[-w, w]` range. -For MSL and HLSL targets, enabling this will convert a shader in `[-w, w]` depth range (OpenGL) to `[0, w]` depth range. - -By default, the CLI will not enable `fixup_clipspace`, but in the API you might want to set an explicit value using `CompilerGLSL::set_options()`. - -Y-flipping of gl_Position and similar is also supported. -The use of this is discouraged, because relying on vertex shader Y-flipping tends to get quite messy. -To enable this, set `CompilerGLSL::Options.vertex.flip_vert_y` or `--flip-vert-y` in CLI. - -## Contributing - -Contributions to SPIRV-Cross are welcome. See Testing and Licensing sections for details. - -### Testing - -SPIRV-Cross maintains a test suite of shaders with reference output of how the output looks after going through a roundtrip through -glslangValidator then back through SPIRV-Cross again. The reference files are stored inside the repository in order to be able to track regressions. - -All pull requests should ensure that test output does not change unexpectedly. This can be tested with: - -``` -./test_shaders.py shaders -./test_shaders.py shaders --opt -./test_shaders.py shaders-hlsl --hlsl -./test_shaders.py shaders-hlsl --hlsl --opt -./test_shaders.py shaders-msl --msl -./test_shaders.py shaders-msl --msl --opt -``` - -although there are a couple of convenience script for doing this: - -``` -./checkout_glslang_spirv_tools.sh # Checks out glslang and SPIRV-Tools at a fixed revision which matches the reference output. -./test_shaders.sh # Runs over all changes and makes sure that there are no deltas compared to reference files. -``` - -However, when improving SPIRV-Cross there are of course legitimate cases where reference output should change. -In these cases, run: - -``` -./update_test_shaders.sh -``` - -to update the reference files and include these changes as part of the pull request. -Always make sure you are running the correct version of glslangValidator as well as SPIRV-Tools when updating reference files. -See `checkout_glslang_spirv_tools.sh`. - -In short, the master branch should always be able to run `./test_shaders.py shaders` and friends without failure. -SPIRV-Cross uses Travis CI to test all pull requests, so it is not strictly needed to perform testing yourself if you have problems running it locally. -A pull request which does not pass testing on Travis will not be accepted however. - -When adding support for new features to SPIRV-Cross, a new shader and reference file should be added which covers usage of the new shader features in question. - -### Licensing - -Contributors of new files should add a copyright header at the top of every new source code file with their copyright -along with the Apache 2.0 licensing stub. - -### Formatting - -SPIRV-Cross uses `clang-format` to automatically format code. -Please use `clang-format` with the style sheet found in `.clang-format` to automatically format code before submitting a pull request. - -To make things easy, the `format_all.sh` script can be used to format all -source files in the library. In this directory, run the following from the -command line: - - ./format_all.sh - -## ABI concerns - -### SPIR-V headers - -The current repository uses the latest SPIR-V and GLSL.std.450 headers. -SPIR-V files created from older headers could have ABI issues. - -## Regression testing - -In shaders/ a collection of shaders are maintained for purposes of regression testing. -The current reference output is contained in reference/. -`./test_shaders.py shaders` can be run to perform regression testing. - -See `./test_shaders.py --help` for more. - -### Metal backend - -To test the roundtrip path GLSL -> SPIR-V -> MSL, `--msl` can be added, e.g. `./test_shaders.py --msl shaders-msl`. - -### HLSL backend - -To test the roundtrip path GLSL -> SPIR-V -> HLSL, `--hlsl` can be added, e.g. `./test_shaders.py --hlsl shaders-hlsl`. - -### Updating regression tests - -When legitimate changes are found, use `--update` flag to update regression files. -Otherwise, `./test_shaders.py` will fail with error code. - -### Mali Offline Compiler cycle counts - -To obtain a CSV of static shader cycle counts before and after going through spirv-cross, add -`--malisc` flag to `./test_shaders`. This requires the Mali Offline Compiler to be installed in PATH. - diff --git a/deps/SPIRV-Cross/checkout_glslang_spirv_tools.sh b/deps/SPIRV-Cross/checkout_glslang_spirv_tools.sh deleted file mode 100644 index a4674c14e1..0000000000 --- a/deps/SPIRV-Cross/checkout_glslang_spirv_tools.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash - -GLSLANG_REV=9c6f8cc29ba303b43ccf36deea6bb38a304f9b92 -SPIRV_TOOLS_REV=e28edd458b729da7bbfd51e375feb33103709e6f - -if [ -d external/glslang ]; then - echo "Updating glslang to revision $GLSLANG_REV." - cd external/glslang - git fetch origin - git checkout $GLSLANG_REV -else - echo "Cloning glslang revision $GLSLANG_REV." - mkdir -p external - cd external - git clone git://github.com/KhronosGroup/glslang.git - cd glslang - git checkout $GLSLANG_REV -fi -cd ../.. - -echo "Building glslang." -mkdir -p external/glslang-build -cd external/glslang-build -cmake ../glslang -DCMAKE_BUILD_TYPE=Release -G"Unix Makefiles" -make -j$(nproc) -cd ../.. - -if [ -d external/spirv-tools ]; then - echo "Updating SPIRV-Tools to revision $SPIRV_TOOLS_REV." - cd external/spirv-tools - git fetch origin - git checkout $SPIRV_TOOLS_REV -else - echo "Cloning SPIRV-Tools revision $SPIRV_TOOLS_REV." - mkdir -p external - cd external - git clone git://github.com/KhronosGroup/SPIRV-Tools.git spirv-tools - cd spirv-tools - git checkout $SPIRV_TOOLS_REV - - if [ -d external/spirv-headers ]; then - cd external/spirv-headers - git pull origin master - cd ../.. - else - git clone git://github.com/KhronosGroup/SPIRV-Headers.git external/spirv-headers - fi -fi -cd ../.. - -echo "Building SPIRV-Tools." -mkdir -p external/spirv-tools-build -cd external/spirv-tools-build -cmake ../spirv-tools -DCMAKE_BUILD_TYPE=Release -G"Unix Makefiles" -make -j$(nproc) -cd ../.. - diff --git a/deps/SPIRV-Cross/format_all.sh b/deps/SPIRV-Cross/format_all.sh deleted file mode 100755 index 05efeb3eae..0000000000 --- a/deps/SPIRV-Cross/format_all.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -for file in spirv_*.{cpp,hpp} include/spirv_cross/*.{hpp,h} samples/cpp/*.cpp main.cpp -do - echo "Formatting file: $file ..." - clang-format -style=file -i $file -done diff --git a/deps/SPIRV-Cross/include/spirv_cross/barrier.hpp b/deps/SPIRV-Cross/include/spirv_cross/barrier.hpp deleted file mode 100644 index bfcd228431..0000000000 --- a/deps/SPIRV-Cross/include/spirv_cross/barrier.hpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2015-2017 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef SPIRV_CROSS_BARRIER_HPP -#define SPIRV_CROSS_BARRIER_HPP - -#include -#include - -namespace spirv_cross -{ -class Barrier -{ -public: - Barrier() - { - count.store(0); - iteration.store(0); - } - - void set_release_divisor(unsigned divisor) - { - this->divisor = divisor; - } - - static inline void memoryBarrier() - { - std::atomic_thread_fence(std::memory_order_seq_cst); - } - - void reset_counter() - { - count.store(0); - iteration.store(0); - } - - void wait() - { - unsigned target_iteration = iteration.load(std::memory_order_relaxed) + 1; - // Overflows cleanly. - unsigned target_count = divisor * target_iteration; - - // Barriers don't enforce memory ordering. - // Be as relaxed about the barrier as we possibly can! - unsigned c = count.fetch_add(1u, std::memory_order_relaxed); - - if (c + 1 == target_count) - { - iteration.store(target_iteration, std::memory_order_relaxed); - } - else - { - // If we have more threads than the CPU, don't hog the CPU for very long periods of time. - while (iteration.load(std::memory_order_relaxed) != target_iteration) - std::this_thread::yield(); - } - } - -private: - unsigned divisor = 1; - std::atomic count; - std::atomic iteration; -}; -} - -#endif diff --git a/deps/SPIRV-Cross/include/spirv_cross/external_interface.h b/deps/SPIRV-Cross/include/spirv_cross/external_interface.h deleted file mode 100644 index 1d26f1e1e4..0000000000 --- a/deps/SPIRV-Cross/include/spirv_cross/external_interface.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright 2015-2017 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef SPIRV_CROSS_EXTERNAL_INTERFACE_H -#define SPIRV_CROSS_EXTERNAL_INTERFACE_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -typedef struct spirv_cross_shader spirv_cross_shader_t; - -struct spirv_cross_interface -{ - spirv_cross_shader_t *(*construct)(void); - void (*destruct)(spirv_cross_shader_t *thiz); - void (*invoke)(spirv_cross_shader_t *thiz); -}; - -void spirv_cross_set_stage_input(spirv_cross_shader_t *thiz, unsigned location, void *data, size_t size); - -void spirv_cross_set_stage_output(spirv_cross_shader_t *thiz, unsigned location, void *data, size_t size); - -void spirv_cross_set_push_constant(spirv_cross_shader_t *thiz, void *data, size_t size); - -void spirv_cross_set_uniform_constant(spirv_cross_shader_t *thiz, unsigned location, void *data, size_t size); - -void spirv_cross_set_resource(spirv_cross_shader_t *thiz, unsigned set, unsigned binding, void **data, size_t size); - -const struct spirv_cross_interface *spirv_cross_get_interface(void); - -typedef enum spirv_cross_builtin { - SPIRV_CROSS_BUILTIN_POSITION = 0, - SPIRV_CROSS_BUILTIN_FRAG_COORD = 1, - SPIRV_CROSS_BUILTIN_WORK_GROUP_ID = 2, - SPIRV_CROSS_BUILTIN_NUM_WORK_GROUPS = 3, - SPIRV_CROSS_NUM_BUILTINS -} spirv_cross_builtin; - -void spirv_cross_set_builtin(spirv_cross_shader_t *thiz, spirv_cross_builtin builtin, void *data, size_t size); - -#define SPIRV_CROSS_NUM_DESCRIPTOR_SETS 4 -#define SPIRV_CROSS_NUM_DESCRIPTOR_BINDINGS 16 -#define SPIRV_CROSS_NUM_STAGE_INPUTS 16 -#define SPIRV_CROSS_NUM_STAGE_OUTPUTS 16 -#define SPIRV_CROSS_NUM_UNIFORM_CONSTANTS 32 - -enum spirv_cross_format -{ - SPIRV_CROSS_FORMAT_R8_UNORM = 0, - SPIRV_CROSS_FORMAT_R8G8_UNORM = 1, - SPIRV_CROSS_FORMAT_R8G8B8_UNORM = 2, - SPIRV_CROSS_FORMAT_R8G8B8A8_UNORM = 3, - - SPIRV_CROSS_NUM_FORMATS -}; - -enum spirv_cross_wrap -{ - SPIRV_CROSS_WRAP_CLAMP_TO_EDGE = 0, - SPIRV_CROSS_WRAP_REPEAT = 1, - - SPIRV_CROSS_NUM_WRAP -}; - -enum spirv_cross_filter -{ - SPIRV_CROSS_FILTER_NEAREST = 0, - SPIRV_CROSS_FILTER_LINEAR = 1, - - SPIRV_CROSS_NUM_FILTER -}; - -enum spirv_cross_mipfilter -{ - SPIRV_CROSS_MIPFILTER_BASE = 0, - SPIRV_CROSS_MIPFILTER_NEAREST = 1, - SPIRV_CROSS_MIPFILTER_LINEAR = 2, - - SPIRV_CROSS_NUM_MIPFILTER -}; - -struct spirv_cross_miplevel -{ - const void *data; - unsigned width, height; - size_t stride; -}; - -struct spirv_cross_sampler_info -{ - const struct spirv_cross_miplevel *mipmaps; - unsigned num_mipmaps; - - enum spirv_cross_format format; - enum spirv_cross_wrap wrap_s; - enum spirv_cross_wrap wrap_t; - enum spirv_cross_filter min_filter; - enum spirv_cross_filter mag_filter; - enum spirv_cross_mipfilter mip_filter; -}; - -typedef struct spirv_cross_sampler_2d spirv_cross_sampler_2d_t; -spirv_cross_sampler_2d_t *spirv_cross_create_sampler_2d(const struct spirv_cross_sampler_info *info); -void spirv_cross_destroy_sampler_2d(spirv_cross_sampler_2d_t *samp); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/deps/SPIRV-Cross/include/spirv_cross/image.hpp b/deps/SPIRV-Cross/include/spirv_cross/image.hpp deleted file mode 100644 index 73de894f88..0000000000 --- a/deps/SPIRV-Cross/include/spirv_cross/image.hpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2015-2017 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef SPIRV_CROSS_IMAGE_HPP -#define SPIRV_CROSS_IMAGE_HPP - -#ifndef GLM_SWIZZLE -#define GLM_SWIZZLE -#endif - -#ifndef GLM_FORCE_RADIANS -#define GLM_FORCE_RADIANS -#endif - -#include - -namespace spirv_cross -{ -template -struct image2DBase -{ - virtual ~image2DBase() = default; - inline virtual T load(glm::ivec2 coord) const - { - return T(0, 0, 0, 1); - } - inline virtual void store(glm::ivec2 coord, const T &v) - { - } -}; - -typedef image2DBase image2D; -typedef image2DBase iimage2D; -typedef image2DBase uimage2D; - -template -inline T imageLoad(const image2DBase &image, glm::ivec2 coord) -{ - return image.load(coord); -} - -template -void imageStore(image2DBase &image, glm::ivec2 coord, const T &value) -{ - image.store(coord, value); -} -} - -#endif diff --git a/deps/SPIRV-Cross/include/spirv_cross/internal_interface.hpp b/deps/SPIRV-Cross/include/spirv_cross/internal_interface.hpp deleted file mode 100644 index e56223dfdb..0000000000 --- a/deps/SPIRV-Cross/include/spirv_cross/internal_interface.hpp +++ /dev/null @@ -1,603 +0,0 @@ -/* - * Copyright 2015-2017 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef SPIRV_CROSS_INTERNAL_INTERFACE_HPP -#define SPIRV_CROSS_INTERNAL_INTERFACE_HPP - -// This file must only be included by the shader generated by spirv-cross! - -#ifndef GLM_FORCE_SWIZZLE -#define GLM_FORCE_SWIZZLE -#endif - -#ifndef GLM_FORCE_RADIANS -#define GLM_FORCE_RADIANS -#endif - -#include - -#include "barrier.hpp" -#include "external_interface.h" -#include "image.hpp" -#include "sampler.hpp" -#include "thread_group.hpp" -#include -#include - -namespace internal -{ -// Adaptor helpers to adapt GLSL access chain syntax to C++. -// Don't bother with arrays of arrays on uniforms ... -// Would likely need horribly complex variadic template munging. - -template -struct Interface -{ - enum - { - ArraySize = 1, - Size = sizeof(T) - }; - - Interface() - : ptr(0) - { - } - T &get() - { - assert(ptr); - return *ptr; - } - - T *ptr; -}; - -// For array types, return a pointer instead. -template -struct Interface -{ - enum - { - ArraySize = U, - Size = U * sizeof(T) - }; - - Interface() - : ptr(0) - { - } - T *get() - { - assert(ptr); - return ptr; - } - - T *ptr; -}; - -// For case when array size is 1, avoid double dereference. -template -struct PointerInterface -{ - enum - { - ArraySize = 1, - Size = sizeof(T *) - }; - enum - { - PreDereference = true - }; - - PointerInterface() - : ptr(0) - { - } - - T &get() - { - assert(ptr); - return *ptr; - } - - T *ptr; -}; - -// Automatically converts a pointer down to reference to match GLSL syntax. -template -struct DereferenceAdaptor -{ - DereferenceAdaptor(T **ptr) - : ptr(ptr) - { - } - T &operator[](unsigned index) const - { - return *(ptr[index]); - } - T **ptr; -}; - -// We can't have a linear array of T* since T* can be an abstract type in case of samplers. -// We also need a list of pointers since we can have run-time length SSBOs. -template -struct PointerInterface -{ - enum - { - ArraySize = U, - Size = sizeof(T *) * U - }; - enum - { - PreDereference = false - }; - PointerInterface() - : ptr(0) - { - } - - DereferenceAdaptor get() - { - assert(ptr); - return DereferenceAdaptor(ptr); - } - - T **ptr; -}; - -// Resources can be more abstract and be unsized, -// so we need to have an array of pointers for those cases. -template -struct Resource : PointerInterface -{ -}; - -// POD with no unknown sizes, so we can express these as flat arrays. -template -struct UniformConstant : Interface -{ -}; -template -struct StageInput : Interface -{ -}; -template -struct StageOutput : Interface -{ -}; -template -struct PushConstant : Interface -{ -}; -} - -struct spirv_cross_shader -{ - struct PPSize - { - PPSize() - : ptr(0) - , size(0) - { - } - void **ptr; - size_t size; - }; - - struct PPSizeResource - { - PPSizeResource() - : ptr(0) - , size(0) - , pre_dereference(false) - { - } - void **ptr; - size_t size; - bool pre_dereference; - }; - - PPSizeResource resources[SPIRV_CROSS_NUM_DESCRIPTOR_SETS][SPIRV_CROSS_NUM_DESCRIPTOR_BINDINGS]; - PPSize stage_inputs[SPIRV_CROSS_NUM_STAGE_INPUTS]; - PPSize stage_outputs[SPIRV_CROSS_NUM_STAGE_OUTPUTS]; - PPSize uniform_constants[SPIRV_CROSS_NUM_UNIFORM_CONSTANTS]; - PPSize push_constant; - PPSize builtins[SPIRV_CROSS_NUM_BUILTINS]; - - template - void register_builtin(spirv_cross_builtin builtin, const U &value) - { - assert(!builtins[builtin].ptr); - - builtins[builtin].ptr = (void **)&value.ptr; - builtins[builtin].size = sizeof(*value.ptr) * U::ArraySize; - } - - void set_builtin(spirv_cross_builtin builtin, void *data, size_t size) - { - assert(builtins[builtin].ptr); - assert(size >= builtins[builtin].size); - - *builtins[builtin].ptr = data; - } - - template - void register_resource(const internal::Resource &value, unsigned set, unsigned binding) - { - assert(set < SPIRV_CROSS_NUM_DESCRIPTOR_SETS); - assert(binding < SPIRV_CROSS_NUM_DESCRIPTOR_BINDINGS); - assert(!resources[set][binding].ptr); - - resources[set][binding].ptr = (void **)&value.ptr; - resources[set][binding].size = internal::Resource::Size; - resources[set][binding].pre_dereference = internal::Resource::PreDereference; - } - - template - void register_stage_input(const internal::StageInput &value, unsigned location) - { - assert(location < SPIRV_CROSS_NUM_STAGE_INPUTS); - assert(!stage_inputs[location].ptr); - - stage_inputs[location].ptr = (void **)&value.ptr; - stage_inputs[location].size = internal::StageInput::Size; - } - - template - void register_stage_output(const internal::StageOutput &value, unsigned location) - { - assert(location < SPIRV_CROSS_NUM_STAGE_OUTPUTS); - assert(!stage_outputs[location].ptr); - - stage_outputs[location].ptr = (void **)&value.ptr; - stage_outputs[location].size = internal::StageOutput::Size; - } - - template - void register_uniform_constant(const internal::UniformConstant &value, unsigned location) - { - assert(location < SPIRV_CROSS_NUM_UNIFORM_CONSTANTS); - assert(!uniform_constants[location].ptr); - - uniform_constants[location].ptr = (void **)&value.ptr; - uniform_constants[location].size = internal::UniformConstant::Size; - } - - template - void register_push_constant(const internal::PushConstant &value) - { - assert(!push_constant.ptr); - - push_constant.ptr = (void **)&value.ptr; - push_constant.size = internal::PushConstant::Size; - } - - void set_stage_input(unsigned location, void *data, size_t size) - { - assert(location < SPIRV_CROSS_NUM_STAGE_INPUTS); - assert(stage_inputs[location].ptr); - assert(size >= stage_inputs[location].size); - - *stage_inputs[location].ptr = data; - } - - void set_stage_output(unsigned location, void *data, size_t size) - { - assert(location < SPIRV_CROSS_NUM_STAGE_OUTPUTS); - assert(stage_outputs[location].ptr); - assert(size >= stage_outputs[location].size); - - *stage_outputs[location].ptr = data; - } - - void set_uniform_constant(unsigned location, void *data, size_t size) - { - assert(location < SPIRV_CROSS_NUM_UNIFORM_CONSTANTS); - assert(uniform_constants[location].ptr); - assert(size >= uniform_constants[location].size); - - *uniform_constants[location].ptr = data; - } - - void set_push_constant(void *data, size_t size) - { - assert(push_constant.ptr); - assert(size >= push_constant.size); - - *push_constant.ptr = data; - } - - void set_resource(unsigned set, unsigned binding, void **data, size_t size) - { - assert(set < SPIRV_CROSS_NUM_DESCRIPTOR_SETS); - assert(binding < SPIRV_CROSS_NUM_DESCRIPTOR_BINDINGS); - assert(resources[set][binding].ptr); - assert(size >= resources[set][binding].size); - - // We're using the regular PointerInterface, dereference ahead of time. - if (resources[set][binding].pre_dereference) - *resources[set][binding].ptr = *data; - else - *resources[set][binding].ptr = data; - } -}; - -namespace spirv_cross -{ -template -struct BaseShader : spirv_cross_shader -{ - void invoke() - { - static_cast(this)->main(); - } -}; - -struct FragmentResources -{ - internal::StageOutput gl_FragCoord; - void init(spirv_cross_shader &s) - { - s.register_builtin(SPIRV_CROSS_BUILTIN_FRAG_COORD, gl_FragCoord); - } -#define gl_FragCoord __res->gl_FragCoord.get() -}; - -template -struct FragmentShader : BaseShader> -{ - inline void main() - { - impl.main(); - } - - FragmentShader() - { - resources.init(*this); - impl.__res = &resources; - } - - T impl; - Res resources; -}; - -struct VertexResources -{ - internal::StageOutput gl_Position; - void init(spirv_cross_shader &s) - { - s.register_builtin(SPIRV_CROSS_BUILTIN_POSITION, gl_Position); - } -#define gl_Position __res->gl_Position.get() -}; - -template -struct VertexShader : BaseShader> -{ - inline void main() - { - impl.main(); - } - - VertexShader() - { - resources.init(*this); - impl.__res = &resources; - } - - T impl; - Res resources; -}; - -struct TessEvaluationResources -{ - inline void init(spirv_cross_shader &) - { - } -}; - -template -struct TessEvaluationShader : BaseShader> -{ - inline void main() - { - impl.main(); - } - - TessEvaluationShader() - { - resources.init(*this); - impl.__res = &resources; - } - - T impl; - Res resources; -}; - -struct TessControlResources -{ - inline void init(spirv_cross_shader &) - { - } -}; - -template -struct TessControlShader : BaseShader> -{ - inline void main() - { - impl.main(); - } - - TessControlShader() - { - resources.init(*this); - impl.__res = &resources; - } - - T impl; - Res resources; -}; - -struct GeometryResources -{ - inline void init(spirv_cross_shader &) - { - } -}; - -template -struct GeometryShader : BaseShader> -{ - inline void main() - { - impl.main(); - } - - GeometryShader() - { - resources.init(*this); - impl.__res = &resources; - } - - T impl; - Res resources; -}; - -struct ComputeResources -{ - internal::StageInput gl_WorkGroupID__; - internal::StageInput gl_NumWorkGroups__; - void init(spirv_cross_shader &s) - { - s.register_builtin(SPIRV_CROSS_BUILTIN_WORK_GROUP_ID, gl_WorkGroupID__); - s.register_builtin(SPIRV_CROSS_BUILTIN_NUM_WORK_GROUPS, gl_NumWorkGroups__); - } -#define gl_WorkGroupID __res->gl_WorkGroupID__.get() -#define gl_NumWorkGroups __res->gl_NumWorkGroups__.get() - - Barrier barrier__; -#define barrier() __res->barrier__.wait() -}; - -struct ComputePrivateResources -{ - uint32_t gl_LocalInvocationIndex__; -#define gl_LocalInvocationIndex __priv_res.gl_LocalInvocationIndex__ - glm::uvec3 gl_LocalInvocationID__; -#define gl_LocalInvocationID __priv_res.gl_LocalInvocationID__ - glm::uvec3 gl_GlobalInvocationID__; -#define gl_GlobalInvocationID __priv_res.gl_GlobalInvocationID__ -}; - -template -struct ComputeShader : BaseShader> -{ - inline void main() - { - resources.barrier__.reset_counter(); - - for (unsigned z = 0; z < WorkGroupZ; z++) - for (unsigned y = 0; y < WorkGroupY; y++) - for (unsigned x = 0; x < WorkGroupX; x++) - impl[z][y][x].__priv_res.gl_GlobalInvocationID__ = - glm::uvec3(WorkGroupX, WorkGroupY, WorkGroupZ) * resources.gl_WorkGroupID__.get() + - glm::uvec3(x, y, z); - - group.run(); - group.wait(); - } - - ComputeShader() - : group(&impl[0][0][0]) - { - resources.init(*this); - resources.barrier__.set_release_divisor(WorkGroupX * WorkGroupY * WorkGroupZ); - - unsigned i = 0; - for (unsigned z = 0; z < WorkGroupZ; z++) - { - for (unsigned y = 0; y < WorkGroupY; y++) - { - for (unsigned x = 0; x < WorkGroupX; x++) - { - impl[z][y][x].__priv_res.gl_LocalInvocationID__ = glm::uvec3(x, y, z); - impl[z][y][x].__priv_res.gl_LocalInvocationIndex__ = i++; - impl[z][y][x].__res = &resources; - } - } - } - } - - T impl[WorkGroupZ][WorkGroupY][WorkGroupX]; - ThreadGroup group; - Res resources; -}; - -inline void memoryBarrierShared() -{ - Barrier::memoryBarrier(); -} -inline void memoryBarrier() -{ - Barrier::memoryBarrier(); -} -// TODO: Rest of the barriers. - -// Atomics -template -inline T atomicAdd(T &v, T a) -{ - static_assert(sizeof(std::atomic) == sizeof(T), "Cannot cast properly to std::atomic."); - - // We need explicit memory barriers in GLSL to enfore any ordering. - // FIXME: Can we really cast this? There is no other way I think ... - return std::atomic_fetch_add_explicit(reinterpret_cast *>(&v), a, std::memory_order_relaxed); -} -} - -void spirv_cross_set_stage_input(spirv_cross_shader_t *shader, unsigned location, void *data, size_t size) -{ - shader->set_stage_input(location, data, size); -} - -void spirv_cross_set_stage_output(spirv_cross_shader_t *shader, unsigned location, void *data, size_t size) -{ - shader->set_stage_output(location, data, size); -} - -void spirv_cross_set_uniform_constant(spirv_cross_shader_t *shader, unsigned location, void *data, size_t size) -{ - shader->set_uniform_constant(location, data, size); -} - -void spirv_cross_set_resource(spirv_cross_shader_t *shader, unsigned set, unsigned binding, void **data, size_t size) -{ - shader->set_resource(set, binding, data, size); -} - -void spirv_cross_set_push_constant(spirv_cross_shader_t *shader, void *data, size_t size) -{ - shader->set_push_constant(data, size); -} - -void spirv_cross_set_builtin(spirv_cross_shader_t *shader, spirv_cross_builtin builtin, void *data, size_t size) -{ - shader->set_builtin(builtin, data, size); -} - -#endif diff --git a/deps/SPIRV-Cross/include/spirv_cross/sampler.hpp b/deps/SPIRV-Cross/include/spirv_cross/sampler.hpp deleted file mode 100644 index a95d489e2d..0000000000 --- a/deps/SPIRV-Cross/include/spirv_cross/sampler.hpp +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 2015-2017 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef SPIRV_CROSS_SAMPLER_HPP -#define SPIRV_CROSS_SAMPLER_HPP - -#include - -namespace spirv_cross -{ -struct spirv_cross_sampler_2d -{ - inline virtual ~spirv_cross_sampler_2d() - { - } -}; - -template -struct sampler2DBase : spirv_cross_sampler_2d -{ - sampler2DBase(const spirv_cross_sampler_info *info) - { - mips.insert(mips.end(), info->mipmaps, info->mipmaps + info->num_mipmaps); - format = info->format; - wrap_s = info->wrap_s; - wrap_t = info->wrap_t; - min_filter = info->min_filter; - mag_filter = info->mag_filter; - mip_filter = info->mip_filter; - } - - inline virtual T sample(glm::vec2 uv, float bias) - { - return sampleLod(uv, bias); - } - - inline virtual T sampleLod(glm::vec2 uv, float lod) - { - if (mag_filter == SPIRV_CROSS_FILTER_NEAREST) - { - uv.x = wrap(uv.x, wrap_s, mips[0].width); - uv.y = wrap(uv.y, wrap_t, mips[0].height); - glm::vec2 uv_full = uv * glm::vec2(mips[0].width, mips[0].height); - - int x = int(uv_full.x); - int y = int(uv_full.y); - return sample(x, y, 0); - } - else - { - return T(0, 0, 0, 1); - } - } - - inline float wrap(float v, spirv_cross_wrap wrap, unsigned size) - { - switch (wrap) - { - case SPIRV_CROSS_WRAP_REPEAT: - return v - glm::floor(v); - case SPIRV_CROSS_WRAP_CLAMP_TO_EDGE: - { - float half = 0.5f / size; - return glm::clamp(v, half, 1.0f - half); - } - - default: - return 0.0f; - } - } - - std::vector mips; - spirv_cross_format format; - spirv_cross_wrap wrap_s; - spirv_cross_format wrap_t; - spirv_cross_filter min_filter; - spirv_cross_filter mag_filter; - spirv_cross_mipfilter mip_filter; -}; - -typedef sampler2DBase sampler2D; -typedef sampler2DBase isampler2D; -typedef sampler2DBase usampler2D; - -template -inline T texture(const sampler2DBase &samp, const glm::vec2 &uv, float bias = 0.0f) -{ - return samp.sample(uv, bias); -} -} - -#endif diff --git a/deps/SPIRV-Cross/include/spirv_cross/thread_group.hpp b/deps/SPIRV-Cross/include/spirv_cross/thread_group.hpp deleted file mode 100644 index 377f098b4f..0000000000 --- a/deps/SPIRV-Cross/include/spirv_cross/thread_group.hpp +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright 2015-2017 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef SPIRV_CROSS_THREAD_GROUP_HPP -#define SPIRV_CROSS_THREAD_GROUP_HPP - -#include -#include -#include - -namespace spirv_cross -{ -template -class ThreadGroup -{ -public: - ThreadGroup(T *impl) - { - for (unsigned i = 0; i < Size; i++) - workers[i].start(&impl[i]); - } - - void run() - { - for (auto &worker : workers) - worker.run(); - } - - void wait() - { - for (auto &worker : workers) - worker.wait(); - } - -private: - struct Thread - { - enum State - { - Idle, - Running, - Dying - }; - State state = Idle; - - void start(T *impl) - { - worker = std::thread([impl, this] { - for (;;) - { - { - std::unique_lock l{ lock }; - cond.wait(l, [this] { return state != Idle; }); - if (state == Dying) - break; - } - - impl->main(); - - std::lock_guard l{ lock }; - state = Idle; - cond.notify_one(); - } - }); - } - - void wait() - { - std::unique_lock l{ lock }; - cond.wait(l, [this] { return state == Idle; }); - } - - void run() - { - std::lock_guard l{ lock }; - state = Running; - cond.notify_one(); - } - - ~Thread() - { - if (worker.joinable()) - { - { - std::lock_guard l{ lock }; - state = Dying; - cond.notify_one(); - } - worker.join(); - } - } - std::thread worker; - std::condition_variable cond; - std::mutex lock; - }; - Thread workers[Size]; -}; -} - -#endif diff --git a/deps/SPIRV-Cross/jni/Android.mk b/deps/SPIRV-Cross/jni/Android.mk deleted file mode 100644 index ca5014d63a..0000000000 --- a/deps/SPIRV-Cross/jni/Android.mk +++ /dev/null @@ -1,12 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -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_CPP_FEATURES := exceptions -LOCAL_ARM_MODE := arm -LOCAL_CFLAGS := -D__STDC_LIMIT_MACROS - -include $(BUILD_STATIC_LIBRARY) diff --git a/deps/SPIRV-Cross/jni/Application.mk b/deps/SPIRV-Cross/jni/Application.mk deleted file mode 100644 index 9a2e77f2d1..0000000000 --- a/deps/SPIRV-Cross/jni/Application.mk +++ /dev/null @@ -1,2 +0,0 @@ -APP_STL := c++_static -APP_ABI := armeabi-v7a diff --git a/deps/SPIRV-Cross/main.cpp b/deps/SPIRV-Cross/main.cpp deleted file mode 100644 index 49fc8653b3..0000000000 --- a/deps/SPIRV-Cross/main.cpp +++ /dev/null @@ -1,923 +0,0 @@ -/* - * Copyright 2015-2017 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "spirv_cpp.hpp" -#include "spirv_glsl.hpp" -#include "spirv_hlsl.hpp" -#include "spirv_msl.hpp" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef _MSC_VER -#pragma warning(disable : 4996) -#endif - -using namespace spv; -using namespace spirv_cross; -using namespace std; - -#ifdef SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS -static inline void THROW(const char *str) -{ - fprintf(stderr, "SPIRV-Cross will abort: %s\n", str); - fflush(stderr); - abort(); -} -#else -#define THROW(x) throw runtime_error(x) -#endif - -struct CLIParser; -struct CLICallbacks -{ - void add(const char *cli, const function &func) - { - callbacks[cli] = func; - } - unordered_map> callbacks; - function error_handler; - function default_handler; -}; - -struct CLIParser -{ - CLIParser(CLICallbacks cbs_, int argc_, char *argv_[]) - : cbs(move(cbs_)) - , argc(argc_) - , argv(argv_) - { - } - - bool parse() - { -#ifndef SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS - try -#endif - { - while (argc && !ended_state) - { - const char *next = *argv++; - argc--; - - if (*next != '-' && cbs.default_handler) - { - cbs.default_handler(next); - } - else - { - auto itr = cbs.callbacks.find(next); - if (itr == ::end(cbs.callbacks)) - { - THROW("Invalid argument"); - } - - itr->second(*this); - } - } - - return true; - } -#ifndef SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS - catch (...) - { - if (cbs.error_handler) - { - cbs.error_handler(); - } - return false; - } -#endif - } - - void end() - { - ended_state = true; - } - - uint32_t next_uint() - { - if (!argc) - { - THROW("Tried to parse uint, but nothing left in arguments"); - } - - uint32_t val = stoul(*argv); - if (val > numeric_limits::max()) - { - THROW("next_uint() out of range"); - } - - argc--; - argv++; - - return val; - } - - double next_double() - { - if (!argc) - { - THROW("Tried to parse double, but nothing left in arguments"); - } - - double val = stod(*argv); - - argc--; - argv++; - - return val; - } - - const char *next_string() - { - if (!argc) - { - THROW("Tried to parse string, but nothing left in arguments"); - } - - const char *ret = *argv; - argc--; - argv++; - return ret; - } - - CLICallbacks cbs; - int argc; - char **argv; - bool ended_state = false; -}; - -static vector read_spirv_file(const char *path) -{ - FILE *file = fopen(path, "rb"); - if (!file) - { - fprintf(stderr, "Failed to open SPIRV file: %s\n", path); - return {}; - } - - fseek(file, 0, SEEK_END); - long len = ftell(file) / sizeof(uint32_t); - rewind(file); - - vector spirv(len); - if (fread(spirv.data(), sizeof(uint32_t), len, file) != size_t(len)) - spirv.clear(); - - fclose(file); - return spirv; -} - -static bool write_string_to_file(const char *path, const char *string) -{ - FILE *file = fopen(path, "w"); - if (!file) - { - fprintf(stderr, "Failed to write file: %s\n", path); - return false; - } - - fprintf(file, "%s", string); - fclose(file); - return true; -} - -static void print_resources(const Compiler &compiler, const char *tag, const vector &resources) -{ - fprintf(stderr, "%s\n", tag); - fprintf(stderr, "=============\n\n"); - bool print_ssbo = !strcmp(tag, "ssbos"); - - for (auto &res : resources) - { - auto &type = compiler.get_type(res.type_id); - auto mask = compiler.get_decoration_mask(res.id); - - if (print_ssbo && compiler.buffer_is_hlsl_counter_buffer(res.id)) - continue; - - // If we don't have a name, use the fallback for the type instead of the variable - // for SSBOs and UBOs since those are the only meaningful names to use externally. - // Push constant blocks are still accessed by name and not block name, even though they are technically Blocks. - bool is_push_constant = compiler.get_storage_class(res.id) == StorageClassPushConstant; - bool is_block = (compiler.get_decoration_mask(type.self) & - ((1ull << DecorationBlock) | (1ull << DecorationBufferBlock))) != 0; - bool is_sized_block = is_block && (compiler.get_storage_class(res.id) == StorageClassUniform || - compiler.get_storage_class(res.id) == StorageClassUniformConstant); - uint32_t fallback_id = !is_push_constant && is_block ? res.base_type_id : res.id; - - uint32_t block_size = 0; - if (is_sized_block) - block_size = uint32_t(compiler.get_declared_struct_size(compiler.get_type(res.base_type_id))); - - string array; - for (auto arr : type.array) - array = join("[", arr ? convert_to_string(arr) : "", "]") + array; - - fprintf(stderr, " ID %03u : %s%s", res.id, - !res.name.empty() ? res.name.c_str() : compiler.get_fallback_name(fallback_id).c_str(), array.c_str()); - - if (mask & (1ull << DecorationLocation)) - fprintf(stderr, " (Location : %u)", compiler.get_decoration(res.id, DecorationLocation)); - if (mask & (1ull << DecorationDescriptorSet)) - fprintf(stderr, " (Set : %u)", compiler.get_decoration(res.id, DecorationDescriptorSet)); - if (mask & (1ull << DecorationBinding)) - fprintf(stderr, " (Binding : %u)", compiler.get_decoration(res.id, DecorationBinding)); - if (mask & (1ull << DecorationInputAttachmentIndex)) - fprintf(stderr, " (Attachment : %u)", compiler.get_decoration(res.id, DecorationInputAttachmentIndex)); - if (mask & (1ull << DecorationNonReadable)) - fprintf(stderr, " writeonly"); - if (mask & (1ull << DecorationNonWritable)) - fprintf(stderr, " readonly"); - if (is_sized_block) - fprintf(stderr, " (BlockSize : %u bytes)", block_size); - - uint32_t counter_id = 0; - if (print_ssbo && compiler.buffer_get_hlsl_counter_buffer(res.id, counter_id)) - fprintf(stderr, " (HLSL counter buffer ID: %u)", counter_id); - fprintf(stderr, "\n"); - } - fprintf(stderr, "=============\n\n"); -} - -static const char *execution_model_to_str(spv::ExecutionModel model) -{ - switch (model) - { - case spv::ExecutionModelVertex: - return "vertex"; - case spv::ExecutionModelTessellationControl: - return "tessellation control"; - case ExecutionModelTessellationEvaluation: - return "tessellation evaluation"; - case ExecutionModelGeometry: - return "geometry"; - case ExecutionModelFragment: - return "fragment"; - case ExecutionModelGLCompute: - return "compute"; - default: - return "???"; - } -} - -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(); - 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, "\n"); - - fprintf(stderr, "Execution modes:\n"); - for (unsigned i = 0; i < 64; i++) - { - if (!(modes & (1ull << i))) - continue; - - auto mode = static_cast(i); - uint32_t arg0 = compiler.get_execution_mode_argument(mode, 0); - uint32_t arg1 = compiler.get_execution_mode_argument(mode, 1); - uint32_t arg2 = compiler.get_execution_mode_argument(mode, 2); - - switch (static_cast(i)) - { - case ExecutionModeInvocations: - fprintf(stderr, " Invocations: %u\n", arg0); - break; - - case ExecutionModeLocalSize: - fprintf(stderr, " LocalSize: (%u, %u, %u)\n", arg0, arg1, arg2); - break; - - case ExecutionModeOutputVertices: - fprintf(stderr, " OutputVertices: %u\n", arg0); - break; - -#define CHECK_MODE(m) \ - case ExecutionMode##m: \ - fprintf(stderr, " %s\n", #m); \ - break - CHECK_MODE(SpacingEqual); - CHECK_MODE(SpacingFractionalEven); - CHECK_MODE(SpacingFractionalOdd); - CHECK_MODE(VertexOrderCw); - CHECK_MODE(VertexOrderCcw); - CHECK_MODE(PixelCenterInteger); - CHECK_MODE(OriginUpperLeft); - CHECK_MODE(OriginLowerLeft); - CHECK_MODE(EarlyFragmentTests); - CHECK_MODE(PointMode); - CHECK_MODE(Xfb); - CHECK_MODE(DepthReplacing); - CHECK_MODE(DepthGreater); - CHECK_MODE(DepthLess); - CHECK_MODE(DepthUnchanged); - CHECK_MODE(LocalSizeHint); - CHECK_MODE(InputPoints); - CHECK_MODE(InputLines); - CHECK_MODE(InputLinesAdjacency); - CHECK_MODE(Triangles); - CHECK_MODE(InputTrianglesAdjacency); - CHECK_MODE(Quads); - CHECK_MODE(Isolines); - CHECK_MODE(OutputPoints); - CHECK_MODE(OutputLineStrip); - CHECK_MODE(OutputTriangleStrip); - CHECK_MODE(VecTypeHint); - CHECK_MODE(ContractionOff); - - default: - break; - } - } - fprintf(stderr, "\n"); - - print_resources(compiler, "subpass inputs", res.subpass_inputs); - print_resources(compiler, "inputs", res.stage_inputs); - print_resources(compiler, "outputs", res.stage_outputs); - print_resources(compiler, "textures", res.sampled_images); - print_resources(compiler, "separate images", res.separate_images); - print_resources(compiler, "separate samplers", res.separate_samplers); - print_resources(compiler, "images", res.storage_images); - print_resources(compiler, "ssbos", res.storage_buffers); - print_resources(compiler, "ubos", res.uniform_buffers); - print_resources(compiler, "push", res.push_constant_buffers); - print_resources(compiler, "counters", res.atomic_counters); -} - -static void print_push_constant_resources(const Compiler &compiler, const vector &res) -{ - for (auto &block : res) - { - auto ranges = compiler.get_active_buffer_ranges(block.id); - fprintf(stderr, "Active members in buffer: %s\n", - !block.name.empty() ? block.name.c_str() : compiler.get_fallback_name(block.id).c_str()); - - fprintf(stderr, "==================\n\n"); - for (auto &range : ranges) - { - const auto &name = compiler.get_member_name(block.base_type_id, range.index); - - fprintf(stderr, "Member #%3u (%s): Offset: %4u, Range: %4u\n", range.index, - !name.empty() ? name.c_str() : compiler.get_fallback_member_name(range.index).c_str(), - unsigned(range.offset), unsigned(range.range)); - } - fprintf(stderr, "==================\n\n"); - } -} - -static void print_spec_constants(const Compiler &compiler) -{ - auto spec_constants = compiler.get_specialization_constants(); - fprintf(stderr, "Specialization constants\n"); - fprintf(stderr, "==================\n\n"); - for (auto &c : spec_constants) - fprintf(stderr, "ID: %u, Spec ID: %u\n", c.id, c.constant_id); - fprintf(stderr, "==================\n\n"); -} - -static void print_capabilities_and_extensions(const Compiler &compiler) -{ - fprintf(stderr, "Capabilities\n"); - fprintf(stderr, "============\n"); - for (auto &capability : compiler.get_declared_capabilities()) - fprintf(stderr, "Capability: %u\n", static_cast(capability)); - fprintf(stderr, "============\n\n"); - - fprintf(stderr, "Extensions\n"); - fprintf(stderr, "============\n"); - for (auto &ext : compiler.get_declared_extensions()) - fprintf(stderr, "Extension: %s\n", ext.c_str()); - fprintf(stderr, "============\n\n"); -} - -struct PLSArg -{ - PlsFormat format; - string name; -}; - -struct Remap -{ - string src_name; - string dst_name; - unsigned components; -}; - -struct VariableTypeRemap -{ - string variable_name; - string new_variable_type; -}; - -struct InterfaceVariableRename -{ - StorageClass storageClass; - uint32_t location; - string variable_name; -}; - -struct CLIArguments -{ - const char *input = nullptr; - const char *output = nullptr; - const char *cpp_interface_name = nullptr; - uint32_t version = 0; - uint32_t shader_model = 0; - uint32_t msl_version = 0; - bool es = false; - bool set_version = false; - bool set_shader_model = false; - bool set_msl_version = false; - bool set_es = false; - bool dump_resources = false; - bool force_temporary = false; - bool flatten_ubo = false; - bool fixup = false; - bool yflip = false; - bool sso = false; - vector pls_in; - vector pls_out; - vector remaps; - vector extensions; - vector variable_type_remaps; - vector interface_variable_renames; - vector hlsl_attr_remap; - string entry; - - vector> entry_point_rename; - - uint32_t iterations = 1; - bool cpp = false; - bool msl = false; - bool hlsl = false; - bool hlsl_compat = false; - bool vulkan_semantics = false; - bool flatten_multidimensional_arrays = false; - bool use_420pack_extension = true; - bool remove_unused = false; -}; - -static void print_help() -{ - fprintf(stderr, "Usage: spirv-cross [--output ] [SPIR-V file] [--es] [--no-es] " - "[--version ] [--dump-resources] [--help] [--force-temporary] " - "[--vulkan-semantics] [--flatten-ubo] [--fixup-clipspace] [--flip-vert-y] [--iterations iter] " - "[--cpp] [--cpp-interface-name ] " - "[--msl] [--msl-version ]" - "[--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] " - "[--flatten-multidimensional-arrays] [--no-420pack-extension] " - "[--remap-variable-type ] " - "[--rename-interface-variable ] " - "[--set-hlsl-vertex-input-semantic ] " - "[--rename-entry-point ] " - "\n"); -} - -static bool remap_generic(Compiler &compiler, const vector &resources, const Remap &remap) -{ - auto itr = - find_if(begin(resources), end(resources), [&remap](const Resource &res) { return res.name == remap.src_name; }); - - if (itr != end(resources)) - { - compiler.set_remapped_variable_state(itr->id, true); - compiler.set_name(itr->id, remap.dst_name); - compiler.set_subpass_input_remapped_components(itr->id, remap.components); - return true; - } - else - return false; -} - -static vector remap_pls(const vector &pls_variables, const vector &resources, - const vector *secondary_resources) -{ - vector ret; - - for (auto &pls : pls_variables) - { - bool found = false; - for (auto &res : resources) - { - if (res.name == pls.name) - { - ret.push_back({ res.id, pls.format }); - found = true; - break; - } - } - - if (!found && secondary_resources) - { - for (auto &res : *secondary_resources) - { - if (res.name == pls.name) - { - ret.push_back({ res.id, pls.format }); - found = true; - break; - } - } - } - - if (!found) - fprintf(stderr, "Did not find stage input/output/target with name \"%s\".\n", pls.name.c_str()); - } - - return ret; -} - -static PlsFormat pls_format(const char *str) -{ - if (!strcmp(str, "r11f_g11f_b10f")) - return PlsR11FG11FB10F; - else if (!strcmp(str, "r32f")) - return PlsR32F; - else if (!strcmp(str, "rg16f")) - return PlsRG16F; - else if (!strcmp(str, "rg16")) - return PlsRG16; - else if (!strcmp(str, "rgb10_a2")) - return PlsRGB10A2; - else if (!strcmp(str, "rgba8")) - return PlsRGBA8; - else if (!strcmp(str, "rgba8i")) - return PlsRGBA8I; - else if (!strcmp(str, "rgba8ui")) - return PlsRGBA8UI; - else if (!strcmp(str, "rg16i")) - return PlsRG16I; - else if (!strcmp(str, "rgb10_a2ui")) - return PlsRGB10A2UI; - else if (!strcmp(str, "rg16ui")) - return PlsRG16UI; - else if (!strcmp(str, "r32ui")) - return PlsR32UI; - else - return PlsNone; -} - -void rename_interface_variable(Compiler &compiler, const vector &resources, - const InterfaceVariableRename &rename) -{ - 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); - } -} - -static int main_inner(int argc, char *argv[]) -{ - CLIArguments args; - CLICallbacks cbs; - - cbs.add("--help", [](CLIParser &parser) { - print_help(); - parser.end(); - }); - cbs.add("--output", [&args](CLIParser &parser) { args.output = parser.next_string(); }); - cbs.add("--es", [&args](CLIParser &) { - args.es = true; - args.set_es = true; - }); - cbs.add("--no-es", [&args](CLIParser &) { - args.es = false; - args.set_es = true; - }); - cbs.add("--version", [&args](CLIParser &parser) { - args.version = parser.next_uint(); - args.set_version = true; - }); - cbs.add("--dump-resources", [&args](CLIParser &) { args.dump_resources = true; }); - cbs.add("--force-temporary", [&args](CLIParser &) { args.force_temporary = true; }); - cbs.add("--flatten-ubo", [&args](CLIParser &) { args.flatten_ubo = true; }); - cbs.add("--fixup-clipspace", [&args](CLIParser &) { args.fixup = true; }); - cbs.add("--flip-vert-y", [&args](CLIParser &) { args.yflip = true; }); - cbs.add("--iterations", [&args](CLIParser &parser) { args.iterations = parser.next_uint(); }); - cbs.add("--cpp", [&args](CLIParser &) { args.cpp = true; }); - cbs.add("--cpp-interface-name", [&args](CLIParser &parser) { args.cpp_interface_name = parser.next_string(); }); - cbs.add("--metal", [&args](CLIParser &) { args.msl = true; }); // Legacy compatibility - cbs.add("--msl", [&args](CLIParser &) { args.msl = true; }); - cbs.add("--hlsl", [&args](CLIParser &) { args.hlsl = true; }); - cbs.add("--hlsl-enable-compat", [&args](CLIParser &) { args.hlsl_compat = true; }); - cbs.add("--vulkan-semantics", [&args](CLIParser &) { args.vulkan_semantics = true; }); - cbs.add("--flatten-multidimensional-arrays", [&args](CLIParser &) { args.flatten_multidimensional_arrays = true; }); - cbs.add("--no-420pack-extension", [&args](CLIParser &) { args.use_420pack_extension = false; }); - cbs.add("--extension", [&args](CLIParser &parser) { args.extensions.push_back(parser.next_string()); }); - 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 }); - }); - cbs.add("--entry", [&args](CLIParser &parser) { args.entry = 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; - remap.location = parser.next_uint(); - remap.semantic = parser.next_string(); - args.hlsl_attr_remap.push_back(move(remap)); - }); - - cbs.add("--remap", [&args](CLIParser &parser) { - string src = parser.next_string(); - string dst = parser.next_string(); - uint32_t components = parser.next_uint(); - args.remaps.push_back({ move(src), move(dst), components }); - }); - - cbs.add("--remap-variable-type", [&args](CLIParser &parser) { - string var_name = parser.next_string(); - string new_type = parser.next_string(); - args.variable_type_remaps.push_back({ move(var_name), move(new_type) }); - }); - - cbs.add("--rename-interface-variable", [&args](CLIParser &parser) { - StorageClass cls = StorageClassMax; - string clsStr = parser.next_string(); - if (clsStr == "in") - cls = StorageClassInput; - else if (clsStr == "out") - cls = StorageClassOutput; - - uint32_t loc = parser.next_uint(); - string var_name = parser.next_string(); - args.interface_variable_renames.push_back({ cls, loc, move(var_name) }); - }); - - cbs.add("--pls-in", [&args](CLIParser &parser) { - auto fmt = pls_format(parser.next_string()); - auto name = parser.next_string(); - args.pls_in.push_back({ move(fmt), move(name) }); - }); - cbs.add("--pls-out", [&args](CLIParser &parser) { - auto fmt = pls_format(parser.next_string()); - auto name = parser.next_string(); - args.pls_out.push_back({ move(fmt), move(name) }); - }); - cbs.add("--shader-model", [&args](CLIParser &parser) { - args.shader_model = parser.next_uint(); - args.set_shader_model = true; - }); - cbs.add("--msl-version", [&args](CLIParser &parser) { - args.msl_version = parser.next_uint(); - args.set_msl_version = true; - }); - - cbs.add("--remove-unused-variables", [&args](CLIParser &) { args.remove_unused = true; }); - - cbs.default_handler = [&args](const char *value) { args.input = value; }; - cbs.error_handler = [] { print_help(); }; - - CLIParser parser{ move(cbs), argc - 1, argv + 1 }; - if (!parser.parse()) - { - return EXIT_FAILURE; - } - else if (parser.ended_state) - { - return EXIT_SUCCESS; - } - - if (!args.input) - { - fprintf(stderr, "Didn't specify input file.\n"); - print_help(); - return EXIT_FAILURE; - } - - unique_ptr compiler; - - bool combined_image_samplers = false; - - if (args.cpp) - { - compiler = unique_ptr(new CompilerCPP(read_spirv_file(args.input))); - if (args.cpp_interface_name) - static_cast(compiler.get())->set_interface_name(args.cpp_interface_name); - } - else if (args.msl) - { - compiler = unique_ptr(new CompilerMSL(read_spirv_file(args.input))); - - auto *msl_comp = static_cast(compiler.get()); - auto msl_opts = msl_comp->get_options(); - if (args.set_msl_version) - msl_opts.msl_version = args.msl_version; - msl_comp->set_options(msl_opts); - } - else if (args.hlsl) - compiler = unique_ptr(new CompilerHLSL(read_spirv_file(args.input))); - else - { - combined_image_samplers = !args.vulkan_semantics; - compiler = unique_ptr(new CompilerGLSL(read_spirv_file(args.input))); - } - - if (!args.variable_type_remaps.empty()) - { - auto remap_cb = [&](const SPIRType &, const string &name, string &out) -> void { - for (const VariableTypeRemap &remap : args.variable_type_remaps) - if (name == remap.variable_name) - out = remap.new_variable_type; - }; - - compiler->set_variable_type_remap_callback(move(remap_cb)); - } - - for (auto &rename : args.entry_point_rename) - compiler->rename_entry_point(rename.first, rename.second); - - if (!args.entry.empty()) - compiler->set_entry_point(args.entry); - - if (!args.set_version && !compiler->get_options().version) - { - fprintf(stderr, "Didn't specify GLSL version and SPIR-V did not specify language.\n"); - print_help(); - return EXIT_FAILURE; - } - - CompilerGLSL::Options opts = compiler->get_options(); - if (args.set_version) - opts.version = args.version; - if (args.set_es) - opts.es = args.es; - opts.force_temporary = args.force_temporary; - opts.separate_shader_objects = args.sso; - opts.flatten_multidimensional_arrays = args.flatten_multidimensional_arrays; - opts.enable_420pack_extension = args.use_420pack_extension; - opts.vulkan_semantics = args.vulkan_semantics; - opts.vertex.fixup_clipspace = args.fixup; - opts.vertex.flip_vert_y = args.yflip; - compiler->set_options(opts); - - // Set HLSL specific options. - if (args.hlsl) - { - auto *hlsl = static_cast(compiler.get()); - auto hlsl_opts = hlsl->get_options(); - if (args.set_shader_model) - { - if (args.shader_model < 30) - { - fprintf(stderr, "Shader model earlier than 30 (3.0) not supported.\n"); - return EXIT_FAILURE; - } - - hlsl_opts.shader_model = args.shader_model; - } - - if (args.hlsl_compat) - { - // Enable all compat options. - hlsl_opts.point_size_compat = true; - } - hlsl->set_options(hlsl_opts); - } - - ShaderResources res; - if (args.remove_unused) - { - auto active = compiler->get_active_interface_variables(); - res = compiler->get_shader_resources(active); - compiler->set_enabled_interface_variables(move(active)); - } - else - res = compiler->get_shader_resources(); - - if (args.flatten_ubo) - { - for (auto &ubo : res.uniform_buffers) - compiler->flatten_buffer_block(ubo.id); - for (auto &ubo : res.push_constant_buffers) - compiler->flatten_buffer_block(ubo.id); - } - - auto pls_inputs = remap_pls(args.pls_in, res.stage_inputs, &res.subpass_inputs); - auto pls_outputs = remap_pls(args.pls_out, res.stage_outputs, nullptr); - compiler->remap_pixel_local_storage(move(pls_inputs), move(pls_outputs)); - - for (auto &ext : args.extensions) - compiler->require_extension(ext); - - for (auto &remap : args.remaps) - { - if (remap_generic(*compiler, res.stage_inputs, remap)) - continue; - if (remap_generic(*compiler, res.stage_outputs, remap)) - continue; - if (remap_generic(*compiler, res.subpass_inputs, remap)) - continue; - } - - for (auto &rename : args.interface_variable_renames) - { - if (rename.storageClass == StorageClassInput) - rename_interface_variable(*compiler, res.stage_inputs, rename); - else if (rename.storageClass == StorageClassOutput) - rename_interface_variable(*compiler, res.stage_outputs, rename); - else - { - fprintf(stderr, "error at --rename-interface-variable ...\n"); - return EXIT_FAILURE; - } - } - - if (args.dump_resources) - { - print_resources(*compiler, res); - print_push_constant_resources(*compiler, res.push_constant_buffers); - print_spec_constants(*compiler); - print_capabilities_and_extensions(*compiler); - } - - if (combined_image_samplers) - { - compiler->build_combined_image_samplers(); - // Give the remapped combined samplers new names. - for (auto &remap : compiler->get_combined_image_samplers()) - { - compiler->set_name(remap.combined_id, join("SPIRV_Cross_Combined", compiler->get_name(remap.image_id), - compiler->get_name(remap.sampler_id))); - } - } - - string glsl; - for (uint32_t i = 0; i < args.iterations; i++) - { - if (args.hlsl) - glsl = static_cast(compiler.get())->compile(move(args.hlsl_attr_remap)); - else - glsl = compiler->compile(); - } - - if (args.output) - write_string_to_file(args.output, glsl.c_str()); - else - printf("%s", glsl.c_str()); - - return EXIT_SUCCESS; -} - -int main(int argc, char *argv[]) -{ -#ifdef SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS - return main_inner(argc, argv); -#else - // Make sure we catch the exception or it just disappears into the aether on Windows. - try - { - return main_inner(argc, argv); - } - catch (const std::exception &e) - { - fprintf(stderr, "SPIRV-Cross threw an exception: %s\n", e.what()); - return EXIT_FAILURE; - } -#endif -} diff --git a/deps/SPIRV-Cross/msvc/SPIRV-Cross.sln b/deps/SPIRV-Cross/msvc/SPIRV-Cross.sln deleted file mode 100644 index c265ec3347..0000000000 --- a/deps/SPIRV-Cross/msvc/SPIRV-Cross.sln +++ /dev/null @@ -1,28 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Express 2013 for Windows Desktop -VisualStudioVersion = 12.0.31101.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SPIRV-Cross", "SPIRV-Cross.vcxproj", "{977E3701-1A21-4425-B7E5-6BDF5EA062CD}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {977E3701-1A21-4425-B7E5-6BDF5EA062CD}.Debug|Win32.ActiveCfg = Debug|Win32 - {977E3701-1A21-4425-B7E5-6BDF5EA062CD}.Debug|Win32.Build.0 = Debug|Win32 - {977E3701-1A21-4425-B7E5-6BDF5EA062CD}.Debug|x64.ActiveCfg = Debug|x64 - {977E3701-1A21-4425-B7E5-6BDF5EA062CD}.Debug|x64.Build.0 = Debug|x64 - {977E3701-1A21-4425-B7E5-6BDF5EA062CD}.Release|Win32.ActiveCfg = Release|Win32 - {977E3701-1A21-4425-B7E5-6BDF5EA062CD}.Release|Win32.Build.0 = Release|Win32 - {977E3701-1A21-4425-B7E5-6BDF5EA062CD}.Release|x64.ActiveCfg = Release|x64 - {977E3701-1A21-4425-B7E5-6BDF5EA062CD}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/deps/SPIRV-Cross/msvc/SPIRV-Cross.vcxproj b/deps/SPIRV-Cross/msvc/SPIRV-Cross.vcxproj deleted file mode 100644 index 8c57633e94..0000000000 --- a/deps/SPIRV-Cross/msvc/SPIRV-Cross.vcxproj +++ /dev/null @@ -1,148 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {977E3701-1A21-4425-B7E5-6BDF5EA062CD} - SPIRV-Cross - - - - Application - true - v120 - MultiByte - - - Application - true - v120 - MultiByte - - - Application - false - v120 - true - MultiByte - - - Application - false - v120 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - Level3 - Disabled - true - _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - - - true - - - - - Level3 - Disabled - true - _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - - - true - - - - - Level3 - MaxSpeed - true - true - true - _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - MultiThreadedDLL - - - true - true - true - - - - - Level3 - MaxSpeed - true - true - true - _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - MultiThreadedDLL - - - true - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/deps/SPIRV-Cross/msvc/SPIRV-Cross.vcxproj.filters b/deps/SPIRV-Cross/msvc/SPIRV-Cross.vcxproj.filters deleted file mode 100644 index c9edf4608b..0000000000 --- a/deps/SPIRV-Cross/msvc/SPIRV-Cross.vcxproj.filters +++ /dev/null @@ -1,69 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/asm/comp/specialization-constant-workgroup.nofxc.asm.comp b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/asm/comp/specialization-constant-workgroup.nofxc.asm.comp deleted file mode 100644 index 8243347bf6..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/asm/comp/specialization-constant-workgroup.nofxc.asm.comp +++ /dev/null @@ -1,16 +0,0 @@ -static const uint _5 = 9u; -static const uint _6 = 4u; -static const uint3 gl_WorkGroupSize = uint3(_5, 20u, _6); - -RWByteAddressBuffer _4 : register(u0); - -void comp_main() -{ - _4.Store(0, asuint(asfloat(_4.Load(0)) + 1.0f)); -} - -[numthreads(9, 20, 4)] -void main() -{ - comp_main(); -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/asm/comp/storage-buffer-basic.nofxc.asm.comp b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/asm/comp/storage-buffer-basic.nofxc.asm.comp deleted file mode 100644 index 1bdb27d7fa..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/asm/comp/storage-buffer-basic.nofxc.asm.comp +++ /dev/null @@ -1,24 +0,0 @@ -static const uint _3 = 1u; -static const uint _4 = 3u; -static const uint3 gl_WorkGroupSize = uint3(_3, 2u, _4); - -RWByteAddressBuffer _8 : register(u0); -RWByteAddressBuffer _9 : register(u1); - -static uint3 gl_WorkGroupID; -struct SPIRV_Cross_Input -{ - uint3 gl_WorkGroupID : SV_GroupID; -}; - -void comp_main() -{ - _8.Store(gl_WorkGroupID.x * 4 + 0, asuint(asfloat(_9.Load(gl_WorkGroupID.x * 4 + 0)) + asfloat(_8.Load(gl_WorkGroupID.x * 4 + 0)))); -} - -[numthreads(1, 2, 3)] -void main(SPIRV_Cross_Input stage_input) -{ - gl_WorkGroupID = stage_input.gl_WorkGroupID; - comp_main(); -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/asm/frag/cbuffer-stripped.asm.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/asm/frag/cbuffer-stripped.asm.frag deleted file mode 100644 index 25eee2d954..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/asm/frag/cbuffer-stripped.asm.frag +++ /dev/null @@ -1,25 +0,0 @@ -cbuffer _5 : register(b0) -{ - column_major float2x4 _5_m0 : packoffset(c0); - float4 _5_m1 : packoffset(c4); -}; - -static float2 _3; - -struct SPIRV_Cross_Output -{ - float2 _3 : SV_Target0; -}; - -void frag_main() -{ - _3 = mul(_5_m0, _5_m1); -} - -SPIRV_Cross_Output main() -{ - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output._3 = _3; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/asm/frag/unreachable.asm.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/asm/frag/unreachable.asm.frag deleted file mode 100644 index e7cb790205..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/asm/frag/unreachable.asm.frag +++ /dev/null @@ -1,42 +0,0 @@ -static int counter; -static float4 FragColor; - -struct SPIRV_Cross_Input -{ - nointerpolation int counter : TEXCOORD0; -}; - -struct SPIRV_Cross_Output -{ - float4 FragColor : SV_Target0; -}; - -float4 _21; - -void frag_main() -{ - float4 _33; - do - { - if (counter == 10) - { - _33 = 10.0f.xxxx; - break; - } - else - { - _33 = 30.0f.xxxx; - break; - } - } while (false); - FragColor = _33; -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - counter = stage_input.counter; - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/asm/vert/empty-struct-composite.asm.vert b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/asm/vert/empty-struct-composite.asm.vert deleted file mode 100644 index 103ff46a3f..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/asm/vert/empty-struct-composite.asm.vert +++ /dev/null @@ -1,8 +0,0 @@ -void vert_main() -{ -} - -void main() -{ - vert_main(); -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/asm/vert/vertex-id-instance-id.asm.vert b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/asm/vert/vertex-id-instance-id.asm.vert deleted file mode 100644 index 8d5e771fe4..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/asm/vert/vertex-id-instance-id.asm.vert +++ /dev/null @@ -1,28 +0,0 @@ -static float4 gl_Position; -static int gl_VertexID; -static int gl_InstanceID; -struct SPIRV_Cross_Input -{ - uint gl_VertexID : SV_VertexID; - uint gl_InstanceID : SV_InstanceID; -}; - -struct SPIRV_Cross_Output -{ - float4 gl_Position : SV_Position; -}; - -void vert_main() -{ - gl_Position = float(gl_VertexID + gl_InstanceID).xxxx; -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - gl_VertexID = int(stage_input.gl_VertexID); - gl_InstanceID = int(stage_input.gl_InstanceID); - vert_main(); - SPIRV_Cross_Output stage_output; - stage_output.gl_Position = gl_Position; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/access-chains.comp b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/access-chains.comp deleted file mode 100644 index 924e919124..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/access-chains.comp +++ /dev/null @@ -1,21 +0,0 @@ -RWByteAddressBuffer wo : register(u1); -ByteAddressBuffer ro : register(t0); - -static uint3 gl_GlobalInvocationID; -struct SPIRV_Cross_Input -{ - uint3 gl_GlobalInvocationID : SV_DispatchThreadID; -}; - -void comp_main() -{ - wo.Store4(gl_GlobalInvocationID.x * 64 + 272, asuint(asfloat(ro.Load4(gl_GlobalInvocationID.x * 64 + 160)))); - wo.Store4(gl_GlobalInvocationID.x * 16 + 480, asuint(asfloat(ro.Load4(gl_GlobalInvocationID.x * 16 + 480)))); -} - -[numthreads(1, 1, 1)] -void main(SPIRV_Cross_Input stage_input) -{ - gl_GlobalInvocationID = stage_input.gl_GlobalInvocationID; - comp_main(); -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/address-buffers.comp b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/address-buffers.comp deleted file mode 100644 index a252fc8ae3..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/address-buffers.comp +++ /dev/null @@ -1,15 +0,0 @@ -RWByteAddressBuffer WriteOnly : register(u2); -ByteAddressBuffer ReadOnly : register(t0); -RWByteAddressBuffer ReadWrite : register(u1); - -void comp_main() -{ - WriteOnly.Store4(0, asuint(asfloat(ReadOnly.Load4(0)))); - ReadWrite.Store4(0, asuint(asfloat(ReadWrite.Load4(0)) + 10.0f.xxxx)); -} - -[numthreads(1, 1, 1)] -void main() -{ - comp_main(); -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/atomic.comp b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/atomic.comp deleted file mode 100644 index 72e15bf77d..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/atomic.comp +++ /dev/null @@ -1,89 +0,0 @@ -RWByteAddressBuffer ssbo : register(u2); -RWTexture2D uImage : register(u0); -RWTexture2D iImage : register(u1); - -groupshared int int_atomic; -groupshared uint uint_atomic; -groupshared int int_atomic_array[1]; -groupshared uint uint_atomic_array[1]; - -void comp_main() -{ - uint _19; - InterlockedAdd(uImage[int2(1, 5)], 1u, _19); - uint _27; - InterlockedAdd(uImage[int2(1, 5)], 1u, _27); - iImage[int2(1, 6)] = int(_27).x; - uint _32; - InterlockedOr(uImage[int2(1, 5)], 1u, _32); - uint _34; - InterlockedXor(uImage[int2(1, 5)], 1u, _34); - uint _36; - InterlockedAnd(uImage[int2(1, 5)], 1u, _36); - uint _38; - InterlockedMin(uImage[int2(1, 5)], 1u, _38); - uint _40; - InterlockedMax(uImage[int2(1, 5)], 1u, _40); - uint _44; - InterlockedCompareExchange(uImage[int2(1, 5)], 10u, 2u, _44); - int _47; - InterlockedAdd(iImage[int2(1, 6)], 1, _47); - int _49; - InterlockedOr(iImage[int2(1, 6)], 1, _49); - int _51; - InterlockedXor(iImage[int2(1, 6)], 1, _51); - int _53; - InterlockedAnd(iImage[int2(1, 6)], 1, _53); - int _55; - InterlockedMin(iImage[int2(1, 6)], 1, _55); - int _57; - InterlockedMax(iImage[int2(1, 6)], 1, _57); - int _61; - InterlockedCompareExchange(iImage[int2(1, 5)], 10, 2, _61); - uint _68; - ssbo.InterlockedAdd(0, 1u, _68); - uint _70; - ssbo.InterlockedOr(0, 1u, _70); - uint _72; - ssbo.InterlockedXor(0, 1u, _72); - uint _74; - ssbo.InterlockedAnd(0, 1u, _74); - uint _76; - ssbo.InterlockedMin(0, 1u, _76); - uint _78; - ssbo.InterlockedMax(0, 1u, _78); - uint _80; - ssbo.InterlockedExchange(0, 1u, _80); - uint _82; - ssbo.InterlockedCompareExchange(0, 10u, 2u, _82); - int _85; - ssbo.InterlockedAdd(4, 1, _85); - int _87; - ssbo.InterlockedOr(4, 1, _87); - int _89; - ssbo.InterlockedXor(4, 1, _89); - int _91; - ssbo.InterlockedAnd(4, 1, _91); - int _93; - ssbo.InterlockedMin(4, 1, _93); - int _95; - ssbo.InterlockedMax(4, 1, _95); - int _97; - ssbo.InterlockedExchange(4, 1, _97); - int _99; - ssbo.InterlockedCompareExchange(4, 10, 2, _99); - int _102; - InterlockedAdd(int_atomic, 10, _102); - uint _105; - InterlockedAdd(uint_atomic, 10u, _105); - int _110; - InterlockedAdd(int_atomic_array[0], 10, _110); - uint _115; - InterlockedAdd(uint_atomic_array[0], 10u, _115); -} - -[numthreads(1, 1, 1)] -void main() -{ - comp_main(); -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/barriers.comp b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/barriers.comp deleted file mode 100644 index 7ac2a656f0..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/barriers.comp +++ /dev/null @@ -1,26 +0,0 @@ -static const uint3 gl_WorkGroupSize = uint3(4u, 1u, 1u); - -void comp_main() -{ - GroupMemoryBarrier(); - AllMemoryBarrier(); - DeviceMemoryBarrier(); - DeviceMemoryBarrier(); - AllMemoryBarrier(); - GroupMemoryBarrierWithGroupSync(); - AllMemoryBarrier(); - GroupMemoryBarrierWithGroupSync(); - DeviceMemoryBarrier(); - GroupMemoryBarrierWithGroupSync(); - DeviceMemoryBarrier(); - GroupMemoryBarrierWithGroupSync(); - AllMemoryBarrier(); - GroupMemoryBarrierWithGroupSync(); - GroupMemoryBarrierWithGroupSync(); -} - -[numthreads(4, 1, 1)] -void main() -{ - comp_main(); -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/bitfield.noopt.comp b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/bitfield.noopt.comp deleted file mode 100644 index 6839d9569e..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/bitfield.noopt.comp +++ /dev/null @@ -1,113 +0,0 @@ -uint SPIRV_Cross_bitfieldInsert(uint Base, uint Insert, uint Offset, uint Count) -{ - uint Mask = Count == 32 ? 0xffffffff : (((1u << Count) - 1) << (Offset & 31)); - return (Base & ~Mask) | ((Insert << Offset) & Mask); -} - -uint2 SPIRV_Cross_bitfieldInsert(uint2 Base, uint2 Insert, uint Offset, uint Count) -{ - uint Mask = Count == 32 ? 0xffffffff : (((1u << Count) - 1) << (Offset & 31)); - return (Base & ~Mask) | ((Insert << Offset) & Mask); -} - -uint3 SPIRV_Cross_bitfieldInsert(uint3 Base, uint3 Insert, uint Offset, uint Count) -{ - uint Mask = Count == 32 ? 0xffffffff : (((1u << Count) - 1) << (Offset & 31)); - return (Base & ~Mask) | ((Insert << Offset) & Mask); -} - -uint4 SPIRV_Cross_bitfieldInsert(uint4 Base, uint4 Insert, uint Offset, uint Count) -{ - uint Mask = Count == 32 ? 0xffffffff : (((1u << Count) - 1) << (Offset & 31)); - return (Base & ~Mask) | ((Insert << Offset) & Mask); -} - -uint SPIRV_Cross_bitfieldUExtract(uint Base, uint Offset, uint Count) -{ - uint Mask = Count == 32 ? 0xffffffff : ((1 << Count) - 1); - return (Base >> Offset) & Mask; -} - -uint2 SPIRV_Cross_bitfieldUExtract(uint2 Base, uint Offset, uint Count) -{ - uint Mask = Count == 32 ? 0xffffffff : ((1 << Count) - 1); - return (Base >> Offset) & Mask; -} - -uint3 SPIRV_Cross_bitfieldUExtract(uint3 Base, uint Offset, uint Count) -{ - uint Mask = Count == 32 ? 0xffffffff : ((1 << Count) - 1); - return (Base >> Offset) & Mask; -} - -uint4 SPIRV_Cross_bitfieldUExtract(uint4 Base, uint Offset, uint Count) -{ - uint Mask = Count == 32 ? 0xffffffff : ((1 << Count) - 1); - return (Base >> Offset) & Mask; -} - -int SPIRV_Cross_bitfieldSExtract(int Base, int Offset, int Count) -{ - int Mask = Count == 32 ? -1 : ((1 << Count) - 1); - int Masked = (Base >> Offset) & Mask; - int ExtendShift = (32 - Count) & 31; - return (Masked << ExtendShift) >> ExtendShift; -} - -int2 SPIRV_Cross_bitfieldSExtract(int2 Base, int Offset, int Count) -{ - int Mask = Count == 32 ? -1 : ((1 << Count) - 1); - int2 Masked = (Base >> Offset) & Mask; - int ExtendShift = (32 - Count) & 31; - return (Masked << ExtendShift) >> ExtendShift; -} - -int3 SPIRV_Cross_bitfieldSExtract(int3 Base, int Offset, int Count) -{ - int Mask = Count == 32 ? -1 : ((1 << Count) - 1); - int3 Masked = (Base >> Offset) & Mask; - int ExtendShift = (32 - Count) & 31; - return (Masked << ExtendShift) >> ExtendShift; -} - -int4 SPIRV_Cross_bitfieldSExtract(int4 Base, int Offset, int Count) -{ - int Mask = Count == 32 ? -1 : ((1 << Count) - 1); - int4 Masked = (Base >> Offset) & Mask; - int ExtendShift = (32 - Count) & 31; - return (Masked << ExtendShift) >> ExtendShift; -} - -void comp_main() -{ - int signed_value = 0; - uint unsigned_value = 0u; - int3 signed_values = int3(0, 0, 0); - uint3 unsigned_values = uint3(0u, 0u, 0u); - int s = SPIRV_Cross_bitfieldSExtract(signed_value, 5, 20); - uint u = SPIRV_Cross_bitfieldUExtract(unsigned_value, 6, 21); - s = int(SPIRV_Cross_bitfieldInsert(s, 40, 5, 4)); - u = SPIRV_Cross_bitfieldInsert(u, 60u, 5, 4); - u = reversebits(u); - s = reversebits(s); - int v0 = countbits(u); - int v1 = countbits(s); - int v2 = firstbithigh(u); - int v3 = firstbitlow(s); - int3 s_1 = SPIRV_Cross_bitfieldSExtract(signed_values, 5, 20); - uint3 u_1 = SPIRV_Cross_bitfieldUExtract(unsigned_values, 6, 21); - s_1 = int3(SPIRV_Cross_bitfieldInsert(s_1, int3(40, 40, 40), 5, 4)); - u_1 = SPIRV_Cross_bitfieldInsert(u_1, uint3(60u, 60u, 60u), 5, 4); - u_1 = reversebits(u_1); - s_1 = reversebits(s_1); - int3 v0_1 = countbits(u_1); - int3 v1_1 = countbits(s_1); - int3 v2_1 = firstbithigh(u_1); - int3 v3_1 = firstbitlow(s_1); -} - -[numthreads(1, 1, 1)] -void main() -{ - comp_main(); -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/builtins.comp b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/builtins.comp deleted file mode 100644 index 990fc85337..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/builtins.comp +++ /dev/null @@ -1,9 +0,0 @@ -void comp_main() -{ -} - -[numthreads(8, 4, 2)] -void main() -{ - comp_main(); -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/image.comp b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/image.comp deleted file mode 100644 index a8fc137581..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/image.comp +++ /dev/null @@ -1,62 +0,0 @@ -RWTexture2D uImageInF : register(u0); -RWTexture2D uImageOutF : register(u1); -RWTexture2D uImageInI : register(u2); -RWTexture2D uImageOutI : register(u3); -RWTexture2D uImageInU : register(u4); -RWTexture2D uImageOutU : register(u5); -RWBuffer uImageInBuffer : register(u6); -RWBuffer uImageOutBuffer : register(u7); -RWTexture2D uImageInF2 : register(u8); -RWTexture2D uImageOutF2 : register(u9); -RWTexture2D uImageInI2 : register(u10); -RWTexture2D uImageOutI2 : register(u11); -RWTexture2D uImageInU2 : register(u12); -RWTexture2D uImageOutU2 : register(u13); -RWBuffer uImageInBuffer2 : register(u14); -RWBuffer uImageOutBuffer2 : register(u15); -RWTexture2D uImageInF4 : register(u16); -RWTexture2D uImageOutF4 : register(u17); -RWTexture2D uImageInI4 : register(u18); -RWTexture2D uImageOutI4 : register(u19); -RWTexture2D uImageInU4 : register(u20); -RWTexture2D uImageOutU4 : register(u21); -RWBuffer uImageInBuffer4 : register(u22); -RWBuffer uImageOutBuffer4 : register(u23); -RWTexture2D uImageNoFmtF : register(u24); -RWTexture2D uImageNoFmtU : register(u25); -RWTexture2D uImageNoFmtI : register(u26); - -static uint3 gl_GlobalInvocationID; -struct SPIRV_Cross_Input -{ - uint3 gl_GlobalInvocationID : SV_DispatchThreadID; -}; - -void comp_main() -{ - uImageOutF[int2(gl_GlobalInvocationID.xy)] = uImageInF[int2(gl_GlobalInvocationID.xy)].x; - uImageOutI[int2(gl_GlobalInvocationID.xy)] = uImageInI[int2(gl_GlobalInvocationID.xy)].x; - uImageOutU[int2(gl_GlobalInvocationID.xy)] = uImageInU[int2(gl_GlobalInvocationID.xy)].x; - uImageOutBuffer[int(gl_GlobalInvocationID.x)] = uImageInBuffer[int(gl_GlobalInvocationID.x)].x; - uImageOutF2[int2(gl_GlobalInvocationID.xy)] = uImageInF2[int2(gl_GlobalInvocationID.xy)].xy; - uImageOutI2[int2(gl_GlobalInvocationID.xy)] = uImageInI2[int2(gl_GlobalInvocationID.xy)].xy; - uImageOutU2[int2(gl_GlobalInvocationID.xy)] = uImageInU2[int2(gl_GlobalInvocationID.xy)].xy; - float4 _135 = uImageInBuffer2[int(gl_GlobalInvocationID.x)].xyyy; - uImageOutBuffer2[int(gl_GlobalInvocationID.x)] = _135.xy; - uImageOutF4[int2(gl_GlobalInvocationID.xy)] = uImageInF4[int2(gl_GlobalInvocationID.xy)]; - int4 _165 = uImageInI4[int2(gl_GlobalInvocationID.xy)]; - uImageOutI4[int2(gl_GlobalInvocationID.xy)] = _165; - uint4 _180 = uImageInU4[int2(gl_GlobalInvocationID.xy)]; - uImageOutU4[int2(gl_GlobalInvocationID.xy)] = _180; - uImageOutBuffer4[int(gl_GlobalInvocationID.x)] = uImageInBuffer4[int(gl_GlobalInvocationID.x)]; - uImageNoFmtF[int2(gl_GlobalInvocationID.xy)] = _135; - uImageNoFmtU[int2(gl_GlobalInvocationID.xy)] = _180; - uImageNoFmtI[int2(gl_GlobalInvocationID.xy)] = _165; -} - -[numthreads(1, 1, 1)] -void main(SPIRV_Cross_Input stage_input) -{ - gl_GlobalInvocationID = stage_input.gl_GlobalInvocationID; - comp_main(); -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/rwbuffer-matrix.comp b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/rwbuffer-matrix.comp deleted file mode 100644 index c05f8ffbf8..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/rwbuffer-matrix.comp +++ /dev/null @@ -1,90 +0,0 @@ -RWByteAddressBuffer _28 : register(u0); -cbuffer _68 : register(b1) -{ - int _68_index0 : packoffset(c0); - int _68_index1 : packoffset(c0.y); -}; - -void comp_main() -{ - float4x4 _253 = asfloat(uint4x4(_28.Load(64), _28.Load(80), _28.Load(96), _28.Load(112), _28.Load(68), _28.Load(84), _28.Load(100), _28.Load(116), _28.Load(72), _28.Load(88), _28.Load(104), _28.Load(120), _28.Load(76), _28.Load(92), _28.Load(108), _28.Load(124))); - _28.Store4(0, asuint(_253[0])); - _28.Store4(16, asuint(_253[1])); - _28.Store4(32, asuint(_253[2])); - _28.Store4(48, asuint(_253[3])); - float2x2 _256 = asfloat(uint2x2(_28.Load(144), _28.Load(152), _28.Load(148), _28.Load(156))); - _28.Store2(128, asuint(_256[0])); - _28.Store2(136, asuint(_256[1])); - float2x3 _259 = asfloat(uint2x3(_28.Load(192), _28.Load(200), _28.Load(208), _28.Load(196), _28.Load(204), _28.Load(212))); - _28.Store3(160, asuint(_259[0])); - _28.Store3(176, asuint(_259[1])); - float3x2 _262 = asfloat(uint3x2(_28.Load(240), _28.Load(256), _28.Load(244), _28.Load(260), _28.Load(248), _28.Load(264))); - _28.Store2(216, asuint(_262[0])); - _28.Store2(224, asuint(_262[1])); - _28.Store2(232, asuint(_262[2])); - float4x4 _265 = asfloat(uint4x4(_28.Load4(0), _28.Load4(16), _28.Load4(32), _28.Load4(48))); - _28.Store(64, asuint(_265[0].x)); - _28.Store(68, asuint(_265[1].x)); - _28.Store(72, asuint(_265[2].x)); - _28.Store(76, asuint(_265[3].x)); - _28.Store(80, asuint(_265[0].y)); - _28.Store(84, asuint(_265[1].y)); - _28.Store(88, asuint(_265[2].y)); - _28.Store(92, asuint(_265[3].y)); - _28.Store(96, asuint(_265[0].z)); - _28.Store(100, asuint(_265[1].z)); - _28.Store(104, asuint(_265[2].z)); - _28.Store(108, asuint(_265[3].z)); - _28.Store(112, asuint(_265[0].w)); - _28.Store(116, asuint(_265[1].w)); - _28.Store(120, asuint(_265[2].w)); - _28.Store(124, asuint(_265[3].w)); - float2x2 _268 = asfloat(uint2x2(_28.Load2(128), _28.Load2(136))); - _28.Store(144, asuint(_268[0].x)); - _28.Store(148, asuint(_268[1].x)); - _28.Store(152, asuint(_268[0].y)); - _28.Store(156, asuint(_268[1].y)); - float2x3 _271 = asfloat(uint2x3(_28.Load3(160), _28.Load3(176))); - _28.Store(192, asuint(_271[0].x)); - _28.Store(196, asuint(_271[1].x)); - _28.Store(200, asuint(_271[0].y)); - _28.Store(204, asuint(_271[1].y)); - _28.Store(208, asuint(_271[0].z)); - _28.Store(212, asuint(_271[1].z)); - float3x2 _274 = asfloat(uint3x2(_28.Load2(216), _28.Load2(224), _28.Load2(232))); - _28.Store(240, asuint(_274[0].x)); - _28.Store(244, asuint(_274[1].x)); - _28.Store(248, asuint(_274[2].x)); - _28.Store(256, asuint(_274[0].y)); - _28.Store(260, asuint(_274[1].y)); - _28.Store(264, asuint(_274[2].y)); - _28.Store(_68_index0 * 4 + _68_index1 * 16 + 64, asuint(1.0f)); - _28.Store(_68_index0 * 4 + _68_index1 * 8 + 144, asuint(2.0f)); - _28.Store(_68_index0 * 4 + _68_index1 * 8 + 192, asuint(3.0f)); - _28.Store(_68_index0 * 4 + _68_index1 * 16 + 240, asuint(4.0f)); - _28.Store(_68_index0 * 4 + 64, asuint(1.0f.x)); - _28.Store(_68_index0 * 4 + 80, asuint(1.0f.xxxx.y)); - _28.Store(_68_index0 * 4 + 96, asuint(1.0f.xxxx.z)); - _28.Store(_68_index0 * 4 + 112, asuint(1.0f.xxxx.w)); - _28.Store(_68_index0 * 4 + 144, asuint(2.0f.x)); - _28.Store(_68_index0 * 4 + 152, asuint(2.0f.xx.y)); - _28.Store(_68_index0 * 4 + 192, asuint(3.0f.x)); - _28.Store(_68_index0 * 4 + 200, asuint(3.0f.xxx.y)); - _28.Store(_68_index0 * 4 + 208, asuint(3.0f.xxx.z)); - _28.Store(_68_index0 * 4 + 240, asuint(4.0f.x)); - _28.Store(_68_index0 * 4 + 256, asuint(4.0f.xx.y)); - _28.Store(_68_index0 * 16 + _68_index1 * 4 + 0, asuint(1.0f)); - _28.Store(_68_index0 * 8 + _68_index1 * 4 + 128, asuint(2.0f)); - _28.Store(_68_index0 * 16 + _68_index1 * 4 + 160, asuint(3.0f)); - _28.Store(_68_index0 * 8 + _68_index1 * 4 + 216, asuint(4.0f)); - _28.Store4(_68_index0 * 16 + 0, asuint(1.0f.xxxx)); - _28.Store2(_68_index0 * 8 + 128, asuint(2.0f.xx)); - _28.Store3(_68_index0 * 16 + 160, asuint(3.0f.xxx)); - _28.Store2(_68_index0 * 8 + 216, asuint(4.0f.xx)); -} - -[numthreads(1, 1, 1)] -void main() -{ - comp_main(); -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/shared.comp b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/shared.comp deleted file mode 100644 index 498241eaca..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/shared.comp +++ /dev/null @@ -1,29 +0,0 @@ -static const uint3 gl_WorkGroupSize = uint3(4u, 1u, 1u); - -ByteAddressBuffer _22 : register(t0); -RWByteAddressBuffer _44 : register(u1); - -static uint3 gl_GlobalInvocationID; -static uint gl_LocalInvocationIndex; -struct SPIRV_Cross_Input -{ - uint3 gl_GlobalInvocationID : SV_DispatchThreadID; - uint gl_LocalInvocationIndex : SV_GroupIndex; -}; - -groupshared float sShared[4]; - -void comp_main() -{ - sShared[gl_LocalInvocationIndex] = asfloat(_22.Load(gl_GlobalInvocationID.x * 4 + 0)); - GroupMemoryBarrierWithGroupSync(); - _44.Store(gl_GlobalInvocationID.x * 4 + 0, asuint(sShared[(4u - gl_LocalInvocationIndex) - 1u])); -} - -[numthreads(4, 1, 1)] -void main(SPIRV_Cross_Input stage_input) -{ - gl_GlobalInvocationID = stage_input.gl_GlobalInvocationID; - gl_LocalInvocationIndex = stage_input.gl_LocalInvocationIndex; - comp_main(); -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/ssbo-array.comp b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/ssbo-array.comp deleted file mode 100644 index d8bce8d54b..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/ssbo-array.comp +++ /dev/null @@ -1,9 +0,0 @@ -void comp_main() -{ -} - -[numthreads(1, 1, 1)] -void main() -{ - comp_main(); -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/basic.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/basic.frag deleted file mode 100644 index 6d067041c2..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/basic.frag +++ /dev/null @@ -1,32 +0,0 @@ -Texture2D uTex : register(t0); -SamplerState _uTex_sampler : register(s0); - -static float4 FragColor; -static float4 vColor; -static float2 vTex; - -struct SPIRV_Cross_Input -{ - float4 vColor : TEXCOORD0; - float2 vTex : TEXCOORD1; -}; - -struct SPIRV_Cross_Output -{ - float4 FragColor : SV_Target0; -}; - -void frag_main() -{ - FragColor = vColor * uTex.Sample(_uTex_sampler, vTex); -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - vColor = stage_input.vColor; - vTex = stage_input.vTex; - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/bit-conversions.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/bit-conversions.frag deleted file mode 100644 index b60b2ebb4a..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/bit-conversions.frag +++ /dev/null @@ -1,26 +0,0 @@ -static float2 value; -static float4 FragColor; - -struct SPIRV_Cross_Input -{ - float2 value : TEXCOORD0; -}; - -struct SPIRV_Cross_Output -{ - float4 FragColor : SV_Target0; -}; - -void frag_main() -{ - FragColor = float4(1.0f, 0.0f, asfloat(asint(value.x)), 1.0f); -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - value = stage_input.value; - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/boolean-mix.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/boolean-mix.frag deleted file mode 100644 index f3e84898d6..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/boolean-mix.frag +++ /dev/null @@ -1,27 +0,0 @@ -static float2 FragColor; -static float2 x0; - -struct SPIRV_Cross_Input -{ - float2 x0 : TEXCOORD0; -}; - -struct SPIRV_Cross_Output -{ - float2 FragColor : SV_Target0; -}; - -void frag_main() -{ - bool2 _27 = (x0.x > x0.y).xx; - FragColor = float2(_27.x ? float2(1.0f, 0.0f).x : float2(0.0f, 1.0f).x, _27.y ? float2(1.0f, 0.0f).y : float2(0.0f, 1.0f).y); -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - x0 = stage_input.x0; - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/builtins.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/builtins.frag deleted file mode 100644 index 922eca7c2d..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/builtins.frag +++ /dev/null @@ -1,33 +0,0 @@ -static float4 gl_FragCoord; -static float gl_FragDepth; -static float4 FragColor; -static float4 vColor; - -struct SPIRV_Cross_Input -{ - float4 vColor : TEXCOORD0; - float4 gl_FragCoord : SV_Position; -}; - -struct SPIRV_Cross_Output -{ - float4 FragColor : SV_Target0; - float gl_FragDepth : SV_Depth; -}; - -void frag_main() -{ - FragColor = gl_FragCoord + vColor; - gl_FragDepth = 0.5f; -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - gl_FragCoord = stage_input.gl_FragCoord; - vColor = stage_input.vColor; - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.gl_FragDepth = gl_FragDepth; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/bvec-operations.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/bvec-operations.frag deleted file mode 100644 index 886e71180e..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/bvec-operations.frag +++ /dev/null @@ -1,27 +0,0 @@ -static float2 value; -static float4 FragColor; - -struct SPIRV_Cross_Input -{ - float2 value : TEXCOORD0; -}; - -struct SPIRV_Cross_Output -{ - float4 FragColor : SV_Target0; -}; - -void frag_main() -{ - bool2 _25 = bool2(value.x == 0.0f, value.y == 0.0f); - FragColor = float4(1.0f, 0.0f, float(bool2(!_25.x, !_25.y).x), float(bool2(value.x <= float2(1.5f, 0.5f).x, value.y <= float2(1.5f, 0.5f).y).x)); -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - value = stage_input.value; - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/combined-texture-sampler-parameter.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/combined-texture-sampler-parameter.frag deleted file mode 100644 index 18968cb193..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/combined-texture-sampler-parameter.frag +++ /dev/null @@ -1,24 +0,0 @@ -Texture2D uSampler : register(t0); -SamplerState _uSampler_sampler : register(s0); -Texture2D uSamplerShadow : register(t1); -SamplerComparisonState _uSamplerShadow_sampler : register(s1); - -static float FragColor; - -struct SPIRV_Cross_Output -{ - float FragColor : SV_Target0; -}; - -void frag_main() -{ - FragColor = (uSampler.Sample(_uSampler_sampler, 1.0f.xx) + uSampler.Load(int3(int2(10, 10), 0))).x + uSamplerShadow.SampleCmp(_uSamplerShadow_sampler, 1.0f.xxx.xy, 1.0f); -} - -SPIRV_Cross_Output main() -{ - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/combined-texture-sampler-shadow.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/combined-texture-sampler-shadow.frag deleted file mode 100644 index 6e8f833b34..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/combined-texture-sampler-shadow.frag +++ /dev/null @@ -1,23 +0,0 @@ -Texture2D uDepth : register(t2); -SamplerComparisonState uSampler : register(s0); -SamplerState uSampler1 : register(s1); - -static float FragColor; - -struct SPIRV_Cross_Output -{ - float FragColor : SV_Target0; -}; - -void frag_main() -{ - FragColor = uDepth.SampleCmp(uSampler, 1.0f.xxx.xy, 1.0f) + uDepth.Sample(uSampler1, 1.0f.xx).x; -} - -SPIRV_Cross_Output main() -{ - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/constant-buffer-array.sm51.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/constant-buffer-array.sm51.frag deleted file mode 100644 index 7e613da1cf..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/constant-buffer-array.sm51.frag +++ /dev/null @@ -1,43 +0,0 @@ -struct CBO_1 -{ - float4 a; - float4 b; - float4 c; - float4 d; -}; - -ConstantBuffer cbo[2][4] : register(b4, space0); -cbuffer push -{ - float4 push_a : packoffset(c0); - float4 push_b : packoffset(c1); - float4 push_c : packoffset(c2); - float4 push_d : packoffset(c3); -}; - -static float4 FragColor; - -struct SPIRV_Cross_Output -{ - float4 FragColor : SV_Target0; -}; - -void frag_main() -{ - FragColor = cbo[1][2].a; - FragColor += cbo[1][2].b; - FragColor += cbo[1][2].c; - FragColor += cbo[1][2].d; - FragColor += push_a; - FragColor += push_b; - FragColor += push_c; - FragColor += push_d; -} - -SPIRV_Cross_Output main() -{ - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/early-fragment-test.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/early-fragment-test.frag deleted file mode 100644 index ae2569d5cf..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/early-fragment-test.frag +++ /dev/null @@ -1,9 +0,0 @@ -void frag_main() -{ -} - -[earlydepthstencil] -void main() -{ - frag_main(); -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/fp16-packing.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/fp16-packing.frag deleted file mode 100644 index d87828225f..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/fp16-packing.frag +++ /dev/null @@ -1,44 +0,0 @@ -static float2 FP32Out; -static uint FP16; -static uint FP16Out; -static float2 FP32; - -struct SPIRV_Cross_Input -{ - nointerpolation uint FP16 : TEXCOORD0; - nointerpolation float2 FP32 : TEXCOORD1; -}; - -struct SPIRV_Cross_Output -{ - float2 FP32Out : SV_Target0; - uint FP16Out : SV_Target1; -}; - -uint SPIRV_Cross_packHalf2x16(float2 value) -{ - uint2 Packed = f32tof16(value); - return Packed.x | (Packed.y << 16); -} - -float2 SPIRV_Cross_unpackHalf2x16(uint value) -{ - return f16tof32(uint2(value & 0xffff, value >> 16)); -} - -void frag_main() -{ - FP32Out = SPIRV_Cross_unpackHalf2x16(FP16); - FP16Out = SPIRV_Cross_packHalf2x16(FP32); -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - FP16 = stage_input.FP16; - FP32 = stage_input.FP32; - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FP32Out = FP32Out; - stage_output.FP16Out = FP16Out; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/image-query-selective.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/image-query-selective.frag deleted file mode 100644 index c73b742b5a..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/image-query-selective.frag +++ /dev/null @@ -1,29 +0,0 @@ -Texture1D uSampler1DUint : register(t0); -SamplerState _uSampler1DUint_sampler : register(s0); -Texture1D uSampler1DInt : register(t0); -SamplerState _uSampler1DInt_sampler : register(s0); - -uint SPIRV_Cross_textureSize(Texture1D Tex, uint Level, out uint Param) -{ - uint ret; - Tex.GetDimensions(Level, ret.x, Param); - return ret; -} - -uint SPIRV_Cross_textureSize(Texture1D Tex, uint Level, out uint Param) -{ - uint ret; - Tex.GetDimensions(Level, ret.x, Param); - return ret; -} - -void frag_main() -{ - uint _17_dummy_parameter; - uint _24_dummy_parameter; -} - -void main() -{ - frag_main(); -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/image-query.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/image-query.frag deleted file mode 100644 index 3b50282fe0..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/image-query.frag +++ /dev/null @@ -1,8 +0,0 @@ -void frag_main() -{ -} - -void main() -{ - frag_main(); -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/io-block.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/io-block.frag deleted file mode 100644 index 52c1f518bf..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/io-block.frag +++ /dev/null @@ -1,28 +0,0 @@ -static float4 FragColor; - -struct VertexOut -{ - float4 a : TEXCOORD1; - float4 b : TEXCOORD2; -}; - -static VertexOut _12; - -struct SPIRV_Cross_Output -{ - float4 FragColor : SV_Target0; -}; - -void frag_main() -{ - FragColor = _12.a + _12.b; -} - -SPIRV_Cross_Output main(in VertexOut stage_input_12) -{ - _12 = stage_input_12; - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/matrix-input.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/matrix-input.frag deleted file mode 100644 index 92d87d396e..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/matrix-input.frag +++ /dev/null @@ -1,26 +0,0 @@ -static float4 FragColor; -static float4x4 m; - -struct SPIRV_Cross_Input -{ - float4x4 m : TEXCOORD1; -}; - -struct SPIRV_Cross_Output -{ - float4 FragColor : SV_Target0; -}; - -void frag_main() -{ - FragColor = ((m[0] + m[1]) + m[2]) + m[3]; -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - m = stage_input.m; - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/mod.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/mod.frag deleted file mode 100644 index 41ac930496..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/mod.frag +++ /dev/null @@ -1,67 +0,0 @@ -static float4 a4; -static float4 b4; -static float3 a3; -static float3 b3; -static float2 a2; -static float2 b2; -static float a1; -static float b1; -static float4 FragColor; - -struct SPIRV_Cross_Input -{ - float4 a4 : TEXCOORD0; - float3 a3 : TEXCOORD1; - float2 a2 : TEXCOORD2; - float a1 : TEXCOORD3; - float4 b4 : TEXCOORD4; - float3 b3 : TEXCOORD5; - float2 b2 : TEXCOORD6; - float b1 : TEXCOORD7; -}; - -struct SPIRV_Cross_Output -{ - float4 FragColor : SV_Target0; -}; - -float mod(float x, float y) -{ - return x - y * floor(x / y); -} - -float2 mod(float2 x, float2 y) -{ - return x - y * floor(x / y); -} - -float3 mod(float3 x, float3 y) -{ - return x - y * floor(x / y); -} - -float4 mod(float4 x, float4 y) -{ - return x - y * floor(x / y); -} - -void frag_main() -{ - FragColor = ((mod(a4, b4) + mod(a3, b3).xyzx) + mod(a2, b2).xyxy) + mod(a1, b1).xxxx; -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - a4 = stage_input.a4; - b4 = stage_input.b4; - a3 = stage_input.a3; - b3 = stage_input.b3; - a2 = stage_input.a2; - b2 = stage_input.b2; - a1 = stage_input.a1; - b1 = stage_input.b1; - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/mrt.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/mrt.frag deleted file mode 100644 index e69e91196a..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/mrt.frag +++ /dev/null @@ -1,31 +0,0 @@ -static float4 RT0; -static float4 RT1; -static float4 RT2; -static float4 RT3; - -struct SPIRV_Cross_Output -{ - float4 RT0 : SV_Target0; - float4 RT1 : SV_Target1; - float4 RT2 : SV_Target2; - float4 RT3 : SV_Target3; -}; - -void frag_main() -{ - RT0 = 1.0f.xxxx; - RT1 = 2.0f.xxxx; - RT2 = 3.0f.xxxx; - RT3 = 4.0f.xxxx; -} - -SPIRV_Cross_Output main() -{ - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.RT0 = RT0; - stage_output.RT1 = RT1; - stage_output.RT2 = RT2; - stage_output.RT3 = RT3; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/no-return.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/no-return.frag deleted file mode 100644 index 3b50282fe0..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/no-return.frag +++ /dev/null @@ -1,8 +0,0 @@ -void frag_main() -{ -} - -void main() -{ - frag_main(); -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/no-return2.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/no-return2.frag deleted file mode 100644 index e9d7bbc8f9..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/no-return2.frag +++ /dev/null @@ -1,16 +0,0 @@ -static float4 vColor; - -struct SPIRV_Cross_Input -{ - float4 vColor : TEXCOORD0; -}; - -void frag_main() -{ -} - -void main(SPIRV_Cross_Input stage_input) -{ - vColor = stage_input.vColor; - frag_main(); -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/partial-write-preserve.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/partial-write-preserve.frag deleted file mode 100644 index 20da99c336..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/partial-write-preserve.frag +++ /dev/null @@ -1,14 +0,0 @@ -struct B -{ - float a; - float b; -}; - -void frag_main() -{ -} - -void main() -{ - frag_main(); -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/query-lod.desktop.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/query-lod.desktop.frag deleted file mode 100644 index fd95798bf4..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/query-lod.desktop.frag +++ /dev/null @@ -1,30 +0,0 @@ -Texture2D uSampler : register(t0); -SamplerState _uSampler_sampler : register(s0); - -static float4 FragColor; -static float2 vTexCoord; - -struct SPIRV_Cross_Input -{ - float2 vTexCoord : TEXCOORD0; -}; - -struct SPIRV_Cross_Output -{ - float4 FragColor : SV_Target0; -}; - -void frag_main() -{ - float _19_tmp = uSampler.CalculateLevelOfDetail(_uSampler_sampler, vTexCoord); - FragColor = float2(_19_tmp, _19_tmp).xyxy; -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - vTexCoord = stage_input.vTexCoord; - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/resources.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/resources.frag deleted file mode 100644 index 24b93c239c..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/resources.frag +++ /dev/null @@ -1,39 +0,0 @@ -cbuffer cbuf : register(b3) -{ - float4 cbuf_a : packoffset(c0); -}; -cbuffer registers -{ - float4 registers_d : packoffset(c0); -}; -Texture2D uSampledImage : register(t4); -SamplerState _uSampledImage_sampler : register(s4); -Texture2D uTexture : register(t5); -SamplerState uSampler : register(s6); - -static float2 vTex; -static float4 FragColor; - -struct SPIRV_Cross_Input -{ - float2 vTex : TEXCOORD0; -}; - -struct SPIRV_Cross_Output -{ - float4 FragColor : SV_Target0; -}; - -void frag_main() -{ - FragColor = (uSampledImage.Sample(_uSampledImage_sampler, vTex) + uTexture.Sample(uSampler, vTex)) + (cbuf_a + registers_d); -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - vTex = stage_input.vTex; - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/sample-cmp-level-zero.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/sample-cmp-level-zero.frag deleted file mode 100644 index 6f5ae7e38c..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/sample-cmp-level-zero.frag +++ /dev/null @@ -1,57 +0,0 @@ -Texture2D uSampler2D : register(t0); -SamplerComparisonState _uSampler2D_sampler : register(s0); -Texture2DArray uSampler2DArray : register(t1); -SamplerComparisonState _uSampler2DArray_sampler : register(s1); -TextureCube uSamplerCube : register(t2); -SamplerComparisonState _uSamplerCube_sampler : register(s2); -TextureCubeArray uSamplerCubeArray : register(t3); -SamplerComparisonState _uSamplerCubeArray_sampler : register(s3); - -static float3 vUVRef; -static float4 vDirRef; -static float FragColor; - -struct SPIRV_Cross_Input -{ - float3 vUVRef : TEXCOORD0; - float4 vDirRef : TEXCOORD1; -}; - -struct SPIRV_Cross_Output -{ - float FragColor : SV_Target0; -}; - -float SPIRV_Cross_projectTextureCoordinate(float2 coord) -{ - return coord.x / coord.y; -} - -float2 SPIRV_Cross_projectTextureCoordinate(float3 coord) -{ - return float2(coord.x, coord.y) / coord.z; -} - -float3 SPIRV_Cross_projectTextureCoordinate(float4 coord) -{ - return float3(coord.x, coord.y, coord.z) / coord.w; -} - -void frag_main() -{ - float4 _80 = vDirRef; - _80.z = vDirRef.w; - float4 _87 = vDirRef; - _87.z = vDirRef.w; - FragColor = (((((((uSampler2D.SampleCmp(_uSampler2D_sampler, vUVRef.xy, vUVRef.z, int2(-1, -1)) + uSampler2DArray.SampleCmp(_uSampler2DArray_sampler, vDirRef.xyz, vDirRef.w, int2(-1, -1))) + uSamplerCube.SampleCmp(_uSamplerCube_sampler, vDirRef.xyz, vDirRef.w)) + uSamplerCubeArray.SampleCmp(_uSamplerCubeArray_sampler, vDirRef, 0.5f)) + uSampler2D.SampleCmpLevelZero(_uSampler2D_sampler, vUVRef.xy, vUVRef.z, int2(-1, -1))) + uSampler2DArray.SampleCmpLevelZero(_uSampler2DArray_sampler, vDirRef.xyz, vDirRef.w, int2(-1, -1))) + uSamplerCube.SampleCmpLevelZero(_uSamplerCube_sampler, vDirRef.xyz, vDirRef.w)) + uSampler2D.SampleCmp(_uSampler2D_sampler, SPIRV_Cross_projectTextureCoordinate(_80.xyz), vDirRef.z, int2(1, 1))) + uSampler2D.SampleCmpLevelZero(_uSampler2D_sampler, SPIRV_Cross_projectTextureCoordinate(_87.xyz), vDirRef.z, int2(1, 1)); -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - vUVRef = stage_input.vUVRef; - vDirRef = stage_input.vDirRef; - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/sampler-array.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/sampler-array.frag deleted file mode 100644 index 5b8e492de6..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/sampler-array.frag +++ /dev/null @@ -1,29 +0,0 @@ -Texture2D uCombined[4] : register(t0); -SamplerState _uCombined_sampler[4] : register(s0); -Texture2D uTex[4] : register(t4); -SamplerState uSampler[4] : register(s8); -RWTexture2D uImage[8] : register(u12); - -static float4 gl_FragCoord; -static float2 vTex; -static int vIndex; - -struct SPIRV_Cross_Input -{ - float2 vTex : TEXCOORD0; - nointerpolation int vIndex : TEXCOORD1; - float4 gl_FragCoord : SV_Position; -}; - -void frag_main() -{ - uImage[vIndex][int2(gl_FragCoord.xy)] = ((uCombined[vIndex].Sample(_uCombined_sampler[vIndex], vTex) + uTex[vIndex].Sample(uSampler[vIndex], vTex)) + (uCombined[vIndex + 1].Sample(_uCombined_sampler[vIndex + 1], vTex))) + (uTex[vIndex + 1].Sample(uSampler[vIndex + 1], vTex)); -} - -void main(SPIRV_Cross_Input stage_input) -{ - gl_FragCoord = stage_input.gl_FragCoord; - vTex = stage_input.vTex; - vIndex = stage_input.vIndex; - frag_main(); -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/spec-constant.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/spec-constant.frag deleted file mode 100644 index 781e3f20b8..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/spec-constant.frag +++ /dev/null @@ -1,33 +0,0 @@ -static const float a = 1.0f; -static const float b = 2.0f; -static const int c = 3; -static const int d = 4; - -struct Foo -{ - float elems[(d + 2)]; -}; - -static float4 FragColor; - -struct SPIRV_Cross_Output -{ - float4 FragColor : SV_Target0; -}; - -void frag_main() -{ - float vec0[(c + 3)][8]; - vec0[0][0] = 10.0f; - Foo foo; - foo.elems[c] = 10.0f; - FragColor = (((a + b).xxxx + vec0[0][0].xxxx) + 20.0f.xxxx) + foo.elems[c].xxxx; -} - -SPIRV_Cross_Output main() -{ - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/swizzle-scalar.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/swizzle-scalar.frag deleted file mode 100644 index ab310b82f2..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/swizzle-scalar.frag +++ /dev/null @@ -1,41 +0,0 @@ -static float4 Float; -static float vFloat; -static int4 Int; -static int vInt; -static float4 Float2; -static int4 Int2; - -struct SPIRV_Cross_Input -{ - nointerpolation float vFloat : TEXCOORD0; - nointerpolation int vInt : TEXCOORD1; -}; - -struct SPIRV_Cross_Output -{ - float4 Float : SV_Target0; - int4 Int : SV_Target1; - float4 Float2 : SV_Target2; - int4 Int2 : SV_Target3; -}; - -void frag_main() -{ - Float = vFloat.xxxx * 2.0f; - Int = vInt.xxxx * int4(2, 2, 2, 2); - Float2 = 10.0f.xxxx; - Int2 = int4(10, 10, 10, 10); -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - vFloat = stage_input.vFloat; - vInt = stage_input.vInt; - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.Float = Float; - stage_output.Int = Int; - stage_output.Float2 = Float2; - stage_output.Int2 = Int2; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/tex-sampling.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/tex-sampling.frag deleted file mode 100644 index 6ebca5d8d1..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/tex-sampling.frag +++ /dev/null @@ -1,87 +0,0 @@ -Texture1D tex1d; -SamplerState _tex1d_sampler; -Texture2D tex2d; -SamplerState _tex2d_sampler; -Texture3D tex3d; -SamplerState _tex3d_sampler; -TextureCube texCube; -SamplerState _texCube_sampler; -Texture1D tex1dShadow; -SamplerComparisonState _tex1dShadow_sampler; -Texture2D tex2dShadow; -SamplerComparisonState _tex2dShadow_sampler; -TextureCube texCubeShadow; -SamplerComparisonState _texCubeShadow_sampler; -Texture1DArray tex1dArray; -SamplerState _tex1dArray_sampler; -Texture2DArray tex2dArray; -SamplerState _tex2dArray_sampler; -TextureCubeArray texCubeArray; -SamplerState _texCubeArray_sampler; -Texture2D separateTex2d; -SamplerState samplerNonDepth; -Texture2D separateTex2dDepth; -SamplerComparisonState samplerDepth; - -static float texCoord1d; -static float2 texCoord2d; -static float3 texCoord3d; -static float4 texCoord4d; -static float4 FragColor; - -struct SPIRV_Cross_Input -{ - float texCoord1d : TEXCOORD0; - float2 texCoord2d : TEXCOORD1; - float3 texCoord3d : TEXCOORD2; - float4 texCoord4d : TEXCOORD3; -}; - -struct SPIRV_Cross_Output -{ - float4 FragColor : SV_Target0; -}; - -float SPIRV_Cross_projectTextureCoordinate(float2 coord) -{ - return coord.x / coord.y; -} - -float2 SPIRV_Cross_projectTextureCoordinate(float3 coord) -{ - return float2(coord.x, coord.y) / coord.z; -} - -float3 SPIRV_Cross_projectTextureCoordinate(float4 coord) -{ - return float3(coord.x, coord.y, coord.z) / coord.w; -} - -void frag_main() -{ - float4 _162 = (((((((((((((((((((tex1d.Sample(_tex1d_sampler, texCoord1d) + tex1d.Sample(_tex1d_sampler, texCoord1d, 1)) + tex1d.SampleLevel(_tex1d_sampler, texCoord1d, 2.0f)) + tex1d.SampleGrad(_tex1d_sampler, texCoord1d, 1.0f, 2.0f)) + tex1d.Sample(_tex1d_sampler, SPIRV_Cross_projectTextureCoordinate(float2(texCoord1d, 2.0f)))) + tex1d.SampleBias(_tex1d_sampler, texCoord1d, 1.0f)) + tex2d.Sample(_tex2d_sampler, texCoord2d)) + tex2d.Sample(_tex2d_sampler, texCoord2d, int2(1, 2))) + tex2d.SampleLevel(_tex2d_sampler, texCoord2d, 2.0f)) + tex2d.SampleGrad(_tex2d_sampler, texCoord2d, float2(1.0f, 2.0f), float2(3.0f, 4.0f))) + tex2d.Sample(_tex2d_sampler, SPIRV_Cross_projectTextureCoordinate(float3(texCoord2d, 2.0f)))) + tex2d.SampleBias(_tex2d_sampler, texCoord2d, 1.0f)) + tex3d.Sample(_tex3d_sampler, texCoord3d)) + tex3d.Sample(_tex3d_sampler, texCoord3d, int3(1, 2, 3))) + tex3d.SampleLevel(_tex3d_sampler, texCoord3d, 2.0f)) + tex3d.SampleGrad(_tex3d_sampler, texCoord3d, float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f))) + tex3d.Sample(_tex3d_sampler, SPIRV_Cross_projectTextureCoordinate(float4(texCoord3d, 2.0f)))) + tex3d.SampleBias(_tex3d_sampler, texCoord3d, 1.0f)) + texCube.Sample(_texCube_sampler, texCoord3d)) + texCube.SampleLevel(_texCube_sampler, texCoord3d, 2.0f)) + texCube.SampleBias(_texCube_sampler, texCoord3d, 1.0f); - float _178 = _162.w + tex1dShadow.SampleCmp(_tex1dShadow_sampler, float3(texCoord1d, 0.0f, 0.0f).x, 0.0f); - float4 _327 = _162; - _327.w = _178; - float _193 = _178 + tex2dShadow.SampleCmp(_tex2dShadow_sampler, float3(texCoord2d, 0.0f).xy, 0.0f); - float4 _331 = _327; - _331.w = _193; - float4 _335 = _331; - _335.w = _193 + texCubeShadow.SampleCmp(_texCubeShadow_sampler, float4(texCoord3d, 0.0f).xyz, 0.0f); - float4 _308 = ((((((((((((((_335 + tex1dArray.Sample(_tex1dArray_sampler, texCoord2d)) + tex2dArray.Sample(_tex2dArray_sampler, texCoord3d)) + texCubeArray.Sample(_texCubeArray_sampler, texCoord4d)) + tex2d.GatherRed(_tex2d_sampler, texCoord2d)) + tex2d.GatherRed(_tex2d_sampler, texCoord2d)) + tex2d.GatherGreen(_tex2d_sampler, texCoord2d)) + tex2d.GatherBlue(_tex2d_sampler, texCoord2d)) + tex2d.GatherAlpha(_tex2d_sampler, texCoord2d)) + tex2d.GatherRed(_tex2d_sampler, texCoord2d, int2(1, 1))) + tex2d.GatherRed(_tex2d_sampler, texCoord2d, int2(1, 1))) + tex2d.GatherGreen(_tex2d_sampler, texCoord2d, int2(1, 1))) + tex2d.GatherBlue(_tex2d_sampler, texCoord2d, int2(1, 1))) + tex2d.GatherAlpha(_tex2d_sampler, texCoord2d, int2(1, 1))) + tex2d.Load(int3(int2(1, 2), 0))) + separateTex2d.Sample(samplerNonDepth, texCoord2d); - float4 _339 = _308; - _339.w = _308.w + separateTex2dDepth.SampleCmp(samplerDepth, texCoord3d.xy, texCoord3d.z); - FragColor = _339; -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - texCoord1d = stage_input.texCoord1d; - texCoord2d = stage_input.texCoord2d; - texCoord3d = stage_input.texCoord3d; - texCoord4d = stage_input.texCoord4d; - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/texture-proj-shadow.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/texture-proj-shadow.frag deleted file mode 100644 index 4beaa11761..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/texture-proj-shadow.frag +++ /dev/null @@ -1,66 +0,0 @@ -Texture1D uShadow1D : register(t0); -SamplerComparisonState _uShadow1D_sampler : register(s0); -Texture2D uShadow2D : register(t1); -SamplerComparisonState _uShadow2D_sampler : register(s1); -Texture1D uSampler1D : register(t2); -SamplerState _uSampler1D_sampler : register(s2); -Texture2D uSampler2D : register(t3); -SamplerState _uSampler2D_sampler : register(s3); -Texture3D uSampler3D : register(t4); -SamplerState _uSampler3D_sampler : register(s4); - -static float FragColor; -static float4 vClip4; -static float2 vClip2; -static float3 vClip3; - -struct SPIRV_Cross_Input -{ - float3 vClip3 : TEXCOORD0; - float4 vClip4 : TEXCOORD1; - float2 vClip2 : TEXCOORD2; -}; - -struct SPIRV_Cross_Output -{ - float FragColor : SV_Target0; -}; - -float SPIRV_Cross_projectTextureCoordinate(float2 coord) -{ - return coord.x / coord.y; -} - -float2 SPIRV_Cross_projectTextureCoordinate(float3 coord) -{ - return float2(coord.x, coord.y) / coord.z; -} - -float3 SPIRV_Cross_projectTextureCoordinate(float4 coord) -{ - return float3(coord.x, coord.y, coord.z) / coord.w; -} - -void frag_main() -{ - float4 _20 = vClip4; - _20.y = vClip4.w; - FragColor = uShadow1D.SampleCmp(_uShadow1D_sampler, SPIRV_Cross_projectTextureCoordinate(_20.xy), vClip4.z); - float4 _30 = vClip4; - _30.z = vClip4.w; - FragColor = uShadow2D.SampleCmp(_uShadow2D_sampler, SPIRV_Cross_projectTextureCoordinate(_30.xyz), vClip4.z); - FragColor = uSampler1D.Sample(_uSampler1D_sampler, SPIRV_Cross_projectTextureCoordinate(vClip2)).x; - FragColor = uSampler2D.Sample(_uSampler2D_sampler, SPIRV_Cross_projectTextureCoordinate(vClip3)).x; - FragColor = uSampler3D.Sample(_uSampler3D_sampler, SPIRV_Cross_projectTextureCoordinate(vClip4)).x; -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - vClip4 = stage_input.vClip4; - vClip2 = stage_input.vClip2; - vClip3 = stage_input.vClip3; - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/unary-enclose.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/unary-enclose.frag deleted file mode 100644 index 76e98a66d0..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/unary-enclose.frag +++ /dev/null @@ -1,29 +0,0 @@ -static float4 FragColor; -static float4 vIn; -static int4 vIn1; - -struct SPIRV_Cross_Input -{ - float4 vIn : TEXCOORD0; - nointerpolation int4 vIn1 : TEXCOORD1; -}; - -struct SPIRV_Cross_Output -{ - float4 FragColor : SV_Target0; -}; - -void frag_main() -{ - FragColor = -(-vIn); -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - vIn = stage_input.vIn; - vIn1 = stage_input.vIn1; - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/unorm-snorm-packing.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/unorm-snorm-packing.frag deleted file mode 100644 index 57b5950636..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/unorm-snorm-packing.frag +++ /dev/null @@ -1,109 +0,0 @@ -static float4 FP32Out; -static uint UNORM8; -static uint SNORM8; -static uint UNORM16; -static uint SNORM16; -static uint UNORM8Out; -static float4 FP32; -static uint SNORM8Out; -static uint UNORM16Out; -static uint SNORM16Out; - -struct SPIRV_Cross_Input -{ - nointerpolation uint SNORM8 : TEXCOORD0; - nointerpolation uint UNORM8 : TEXCOORD1; - nointerpolation uint SNORM16 : TEXCOORD2; - nointerpolation uint UNORM16 : TEXCOORD3; - nointerpolation float4 FP32 : TEXCOORD4; -}; - -struct SPIRV_Cross_Output -{ - float4 FP32Out : SV_Target0; - uint UNORM8Out : SV_Target1; - uint SNORM8Out : SV_Target2; - uint UNORM16Out : SV_Target3; - uint SNORM16Out : SV_Target4; -}; - -uint SPIRV_Cross_packUnorm4x8(float4 value) -{ - uint4 Packed = uint4(round(saturate(value) * 255.0)); - return Packed.x | (Packed.y << 8) | (Packed.z << 16) | (Packed.w << 24); -} - -float4 SPIRV_Cross_unpackUnorm4x8(uint value) -{ - uint4 Packed = uint4(value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, value >> 24); - return float4(Packed) / 255.0; -} - -uint SPIRV_Cross_packSnorm4x8(float4 value) -{ - int4 Packed = int4(round(clamp(value, -1.0, 1.0) * 127.0)) & 0xff; - return uint(Packed.x | (Packed.y << 8) | (Packed.z << 16) | (Packed.w << 24)); -} - -float4 SPIRV_Cross_unpackSnorm4x8(uint value) -{ - int SignedValue = int(value); - int4 Packed = int4(SignedValue << 24, SignedValue << 16, SignedValue << 8, SignedValue) >> 24; - return clamp(float4(Packed) / 127.0, -1.0, 1.0); -} - -uint SPIRV_Cross_packUnorm2x16(float2 value) -{ - uint2 Packed = uint2(round(saturate(value) * 65535.0)); - return Packed.x | (Packed.y << 16); -} - -float2 SPIRV_Cross_unpackUnorm2x16(uint value) -{ - uint2 Packed = uint2(value & 0xffff, value >> 16); - return float2(Packed) / 65535.0; -} - -uint SPIRV_Cross_packSnorm2x16(float2 value) -{ - int2 Packed = int2(round(clamp(value, -1.0, 1.0) * 32767.0)) & 0xffff; - return uint(Packed.x | (Packed.y << 16)); -} - -float2 SPIRV_Cross_unpackSnorm2x16(uint value) -{ - int SignedValue = int(value); - int2 Packed = int2(SignedValue << 16, SignedValue) >> 16; - return clamp(float2(Packed) / 32767.0, -1.0, 1.0); -} - -void frag_main() -{ - FP32Out = SPIRV_Cross_unpackUnorm4x8(UNORM8); - FP32Out = SPIRV_Cross_unpackSnorm4x8(SNORM8); - float2 _21 = SPIRV_Cross_unpackUnorm2x16(UNORM16); - FP32Out = float4(_21.x, _21.y, FP32Out.z, FP32Out.w); - float2 _26 = SPIRV_Cross_unpackSnorm2x16(SNORM16); - FP32Out = float4(_26.x, _26.y, FP32Out.z, FP32Out.w); - UNORM8Out = SPIRV_Cross_packUnorm4x8(FP32); - SNORM8Out = SPIRV_Cross_packSnorm4x8(FP32); - UNORM16Out = SPIRV_Cross_packUnorm2x16(FP32.xy); - SNORM16Out = SPIRV_Cross_packSnorm2x16(FP32.zw); -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - UNORM8 = stage_input.UNORM8; - SNORM8 = stage_input.SNORM8; - UNORM16 = stage_input.UNORM16; - SNORM16 = stage_input.SNORM16; - FP32 = stage_input.FP32; - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FP32Out = FP32Out; - stage_output.UNORM8Out = UNORM8Out; - stage_output.SNORM8Out = SNORM8Out; - stage_output.UNORM16Out = UNORM16Out; - stage_output.SNORM16Out = SNORM16Out; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/various-glsl-ops.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/various-glsl-ops.frag deleted file mode 100644 index 0bc2fc1a96..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/various-glsl-ops.frag +++ /dev/null @@ -1,26 +0,0 @@ -static float2 interpolant; -static float4 FragColor; - -struct SPIRV_Cross_Input -{ - float2 interpolant : TEXCOORD0; -}; - -struct SPIRV_Cross_Output -{ - float4 FragColor : SV_Target0; -}; - -void frag_main() -{ - FragColor = float4(0.0f, 0.0f, 0.0f, EvaluateAttributeSnapped(interpolant, 0.100000001490116119384765625f.xx).x) + float4(0.0f, 0.0f, 0.0f, ddx_coarse(interpolant.x)); -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - interpolant = stage_input.interpolant; - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/basic.vert b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/basic.vert deleted file mode 100644 index 5f0a5f3d1a..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/basic.vert +++ /dev/null @@ -1,38 +0,0 @@ -cbuffer _16 -{ - row_major float4x4 _16_uMVP : packoffset(c0); -}; - -static float4 gl_Position; -static float4 aVertex; -static float3 vNormal; -static float3 aNormal; - -struct SPIRV_Cross_Input -{ - float4 aVertex : TEXCOORD0; - float3 aNormal : TEXCOORD1; -}; - -struct SPIRV_Cross_Output -{ - float3 vNormal : TEXCOORD0; - float4 gl_Position : SV_Position; -}; - -void vert_main() -{ - gl_Position = mul(aVertex, _16_uMVP); - vNormal = aNormal; -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - aVertex = stage_input.aVertex; - aNormal = stage_input.aNormal; - vert_main(); - SPIRV_Cross_Output stage_output; - stage_output.gl_Position = gl_Position; - stage_output.vNormal = vNormal; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/instancing.vert b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/instancing.vert deleted file mode 100644 index 48b2df20d3..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/instancing.vert +++ /dev/null @@ -1,28 +0,0 @@ -static float4 gl_Position; -static int gl_VertexIndex; -static int gl_InstanceIndex; -struct SPIRV_Cross_Input -{ - uint gl_VertexIndex : SV_VertexID; - uint gl_InstanceIndex : SV_InstanceID; -}; - -struct SPIRV_Cross_Output -{ - float4 gl_Position : SV_Position; -}; - -void vert_main() -{ - gl_Position = float(gl_VertexIndex + gl_InstanceIndex).xxxx; -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - gl_VertexIndex = int(stage_input.gl_VertexIndex); - gl_InstanceIndex = int(stage_input.gl_InstanceIndex); - vert_main(); - SPIRV_Cross_Output stage_output; - stage_output.gl_Position = gl_Position; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/locations.vert b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/locations.vert deleted file mode 100644 index ba36c4ae39..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/locations.vert +++ /dev/null @@ -1,79 +0,0 @@ -struct Foo -{ - float3 a; - float3 b; - float3 c; -}; - -static float4 gl_Position; -static float4 Input2; -static float4 Input4; -static float4 Input0; -static float vLocation0; -static float vLocation1; -static float vLocation2[2]; -static Foo vLocation4; -static float vLocation9; - -struct VertexOut -{ - float3 color : TEXCOORD7; - float3 foo : TEXCOORD8; -}; - -static VertexOut vout; - -struct SPIRV_Cross_Input -{ - float4 Input0 : TEXCOORD0; - float4 Input2 : TEXCOORD2; - float4 Input4 : TEXCOORD4; -}; - -struct SPIRV_Cross_Output -{ - float vLocation0 : TEXCOORD0; - float vLocation1 : TEXCOORD1; - float vLocation2[2] : TEXCOORD2; - Foo vLocation4 : TEXCOORD4; - float vLocation9 : TEXCOORD9; - float4 gl_Position : SV_Position; -}; - -Foo _70; - -void vert_main() -{ - gl_Position = ((1.0f.xxxx + Input2) + Input4) + Input0; - vLocation0 = 0.0f; - vLocation1 = 1.0f; - vLocation2[0] = 2.0f; - vLocation2[1] = 2.0f; - Foo _65 = _70; - _65.a = 1.0f.xxx; - Foo _67 = _65; - _67.b = 1.0f.xxx; - Foo _69 = _67; - _69.c = 1.0f.xxx; - vLocation4 = _69; - vLocation9 = 9.0f; - vout.color = 2.0f.xxx; - vout.foo = 4.0f.xxx; -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input, out VertexOut stage_outputvout) -{ - Input2 = stage_input.Input2; - Input4 = stage_input.Input4; - Input0 = stage_input.Input0; - vert_main(); - stage_outputvout = vout; - SPIRV_Cross_Output stage_output; - stage_output.gl_Position = gl_Position; - stage_output.vLocation0 = vLocation0; - stage_output.vLocation1 = vLocation1; - stage_output.vLocation2 = vLocation2; - stage_output.vLocation4 = vLocation4; - stage_output.vLocation9 = vLocation9; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/matrix-attribute.vert b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/matrix-attribute.vert deleted file mode 100644 index a3d0eef56e..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/matrix-attribute.vert +++ /dev/null @@ -1,35 +0,0 @@ -static float4 gl_Position; -static float4x4 m; -static float3 pos; - -struct SPIRV_Cross_Input -{ - float3 pos : TEXCOORD0; - float4 m_0 : TEXCOORD1_0; - float4 m_1 : TEXCOORD1_1; - float4 m_2 : TEXCOORD1_2; - float4 m_3 : TEXCOORD1_3; -}; - -struct SPIRV_Cross_Output -{ - float4 gl_Position : SV_Position; -}; - -void vert_main() -{ - gl_Position = mul(float4(pos, 1.0f), m); -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - m[0] = stage_input.m_0; - m[1] = stage_input.m_1; - m[2] = stage_input.m_2; - m[3] = stage_input.m_3; - pos = stage_input.pos; - vert_main(); - SPIRV_Cross_Output stage_output; - stage_output.gl_Position = gl_Position; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/matrix-output.vert b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/matrix-output.vert deleted file mode 100644 index dc776cb5ec..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/matrix-output.vert +++ /dev/null @@ -1,23 +0,0 @@ -static float4 gl_Position; -static float4x4 m; - -struct SPIRV_Cross_Output -{ - float4x4 m : TEXCOORD0; - float4 gl_Position : SV_Position; -}; - -void vert_main() -{ - gl_Position = 1.0f.xxxx; - m = float4x4(float4(1.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 1.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 1.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 1.0f)); -} - -SPIRV_Cross_Output main() -{ - vert_main(); - SPIRV_Cross_Output stage_output; - stage_output.gl_Position = gl_Position; - stage_output.m = m; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/no-input.vert b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/no-input.vert deleted file mode 100644 index c98544dbe8..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/no-input.vert +++ /dev/null @@ -1,18 +0,0 @@ -static float4 gl_Position; -struct SPIRV_Cross_Output -{ - float4 gl_Position : SV_Position; -}; - -void vert_main() -{ - gl_Position = 1.0f.xxxx; -} - -SPIRV_Cross_Output main() -{ - vert_main(); - SPIRV_Cross_Output stage_output; - stage_output.gl_Position = gl_Position; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/point-size-compat.vert b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/point-size-compat.vert deleted file mode 100644 index 83333d0be2..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/point-size-compat.vert +++ /dev/null @@ -1,20 +0,0 @@ -static float4 gl_Position; -static float gl_PointSize; -struct SPIRV_Cross_Output -{ - float4 gl_Position : SV_Position; -}; - -void vert_main() -{ - gl_Position = 1.0f.xxxx; - gl_PointSize = 10.0f; -} - -SPIRV_Cross_Output main() -{ - vert_main(); - SPIRV_Cross_Output stage_output; - stage_output.gl_Position = gl_Position; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/qualifiers.vert b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/qualifiers.vert deleted file mode 100644 index 13ee2a8c1c..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/qualifiers.vert +++ /dev/null @@ -1,50 +0,0 @@ -static float4 gl_Position; -static float vFlat; -static float vCentroid; -static float vSample; -static float vNoperspective; - -struct Block -{ - nointerpolation float vFlat : TEXCOORD4; - centroid float vCentroid : TEXCOORD5; - sample float vSample : TEXCOORD6; - noperspective float vNoperspective : TEXCOORD7; -}; - -static Block vout; - -struct SPIRV_Cross_Output -{ - nointerpolation float vFlat : TEXCOORD0; - centroid float vCentroid : TEXCOORD1; - sample float vSample : TEXCOORD2; - noperspective float vNoperspective : TEXCOORD3; - float4 gl_Position : SV_Position; -}; - -void vert_main() -{ - gl_Position = 1.0f.xxxx; - vFlat = 0.0f; - vCentroid = 1.0f; - vSample = 2.0f; - vNoperspective = 3.0f; - vout.vFlat = 0.0f; - vout.vCentroid = 1.0f; - vout.vSample = 2.0f; - vout.vNoperspective = 3.0f; -} - -SPIRV_Cross_Output main(out Block stage_outputvout) -{ - vert_main(); - stage_outputvout = vout; - SPIRV_Cross_Output stage_output; - stage_output.gl_Position = gl_Position; - stage_output.vFlat = vFlat; - stage_output.vCentroid = vCentroid; - stage_output.vSample = vSample; - stage_output.vNoperspective = vNoperspective; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/sampler-buffers.vert b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/sampler-buffers.vert deleted file mode 100644 index 3652185443..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/sampler-buffers.vert +++ /dev/null @@ -1,22 +0,0 @@ -Buffer uFloatSampler : register(t1); -Buffer uIntSampler : register(t2); -Buffer uUintSampler : register(t3); - -static float4 gl_Position; -struct SPIRV_Cross_Output -{ - float4 gl_Position : SV_Position; -}; - -void vert_main() -{ - gl_Position = (uFloatSampler.Load(20) + asfloat(uIntSampler.Load(40))) + asfloat(uUintSampler.Load(60)); -} - -SPIRV_Cross_Output main() -{ - vert_main(); - SPIRV_Cross_Output stage_output; - stage_output.gl_Position = gl_Position; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/struct-composite-decl.vert b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/struct-composite-decl.vert deleted file mode 100644 index 76bd349775..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/struct-composite-decl.vert +++ /dev/null @@ -1,44 +0,0 @@ -struct VOut -{ - float4 a; - float4 b; - float4 c; - float4 d; -}; - -static VOut vout; -static float4 a; -static float4 b; -static float4 c; -static float4 d; - -struct SPIRV_Cross_Input -{ - float4 a : TEXCOORD0; - float4 b : TEXCOORD1; - float4 c : TEXCOORD2; - float4 d : TEXCOORD3; -}; - -struct SPIRV_Cross_Output -{ - VOut vout : TEXCOORD0; -}; - -void vert_main() -{ - VOut _26 = { a, b, c, d }; - vout = _26; -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - a = stage_input.a; - b = stage_input.b; - c = stage_input.c; - d = stage_input.d; - vert_main(); - SPIRV_Cross_Output stage_output; - stage_output.vout = vout; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/texture_buffer.vert b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/texture_buffer.vert deleted file mode 100644 index 1c92f6fe65..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/texture_buffer.vert +++ /dev/null @@ -1,21 +0,0 @@ -Buffer uSamp : register(t4); -RWBuffer uSampo : register(u5); - -static float4 gl_Position; -struct SPIRV_Cross_Output -{ - float4 gl_Position : SV_Position; -}; - -void vert_main() -{ - gl_Position = uSamp.Load(10) + uSampo[100]; -} - -SPIRV_Cross_Output main() -{ - vert_main(); - SPIRV_Cross_Output stage_output; - stage_output.gl_Position = gl_Position; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/bitcast_iadd.asm.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/bitcast_iadd.asm.comp deleted file mode 100644 index 47ce85f8fc..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/bitcast_iadd.asm.comp +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include - -using namespace metal; - -struct _3 -{ - int4 _m0; - uint4 _m1; -}; - -struct _4 -{ - uint4 _m0; - int4 _m1; -}; - -kernel void main0(device _3& _5 [[buffer(0)]], device _4& _6 [[buffer(1)]]) -{ - _6._m0 = _5._m1 + uint4(_5._m0); - _6._m0 = uint4(_5._m0) + _5._m1; - _6._m0 = _5._m1 + _5._m1; - _6._m0 = uint4(_5._m0 + _5._m0); - _6._m1 = int4(_5._m1 + _5._m1); - _6._m1 = _5._m0 + _5._m0; - _6._m1 = int4(_5._m1) + _5._m0; - _6._m1 = _5._m0 + int4(_5._m1); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/bitcast_sar.asm.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/bitcast_sar.asm.comp deleted file mode 100644 index 20d6fe9e9d..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/bitcast_sar.asm.comp +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include - -using namespace metal; - -struct _3 -{ - int4 _m0; - uint4 _m1; -}; - -struct _4 -{ - uint4 _m0; - int4 _m1; -}; - -kernel void main0(device _3& _5 [[buffer(0)]], device _4& _6 [[buffer(1)]]) -{ - _6._m0 = uint4(int4(_5._m1) >> _5._m0); - _6._m0 = uint4(_5._m0 >> int4(_5._m1)); - _6._m0 = uint4(int4(_5._m1) >> int4(_5._m1)); - _6._m0 = uint4(_5._m0 >> _5._m0); - _6._m1 = int4(_5._m1) >> int4(_5._m1); - _6._m1 = _5._m0 >> _5._m0; - _6._m1 = int4(_5._m1) >> _5._m0; - _6._m1 = _5._m0 >> int4(_5._m1); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/bitcast_sdiv.asm.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/bitcast_sdiv.asm.comp deleted file mode 100644 index f18b318bbb..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/bitcast_sdiv.asm.comp +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include - -using namespace metal; - -struct _3 -{ - int4 _m0; - uint4 _m1; -}; - -struct _4 -{ - uint4 _m0; - int4 _m1; -}; - -kernel void main0(device _3& _5 [[buffer(0)]], device _4& _6 [[buffer(1)]]) -{ - _6._m0 = uint4(int4(_5._m1) / _5._m0); - _6._m0 = uint4(_5._m0 / int4(_5._m1)); - _6._m0 = uint4(int4(_5._m1) / int4(_5._m1)); - _6._m0 = uint4(_5._m0 / _5._m0); - _6._m1 = int4(_5._m1) / int4(_5._m1); - _6._m1 = _5._m0 / _5._m0; - _6._m1 = int4(_5._m1) / _5._m0; - _6._m1 = _5._m0 / int4(_5._m1); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/bitcast_slr.asm.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/bitcast_slr.asm.comp deleted file mode 100644 index 9fd60bef26..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/bitcast_slr.asm.comp +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include - -using namespace metal; - -struct _3 -{ - int4 _m0; - uint4 _m1; -}; - -struct _4 -{ - uint4 _m0; - int4 _m1; -}; - -kernel void main0(device _3& _5 [[buffer(0)]], device _4& _6 [[buffer(1)]]) -{ - _6._m0 = _5._m1 >> uint4(_5._m0); - _6._m0 = uint4(_5._m0) >> _5._m1; - _6._m0 = _5._m1 >> _5._m1; - _6._m0 = uint4(_5._m0) >> uint4(_5._m0); - _6._m1 = int4(_5._m1 >> _5._m1); - _6._m1 = int4(uint4(_5._m0) >> uint4(_5._m0)); - _6._m1 = int4(_5._m1 >> uint4(_5._m0)); - _6._m1 = int4(uint4(_5._m0) >> _5._m1); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/multiple-entry.asm.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/multiple-entry.asm.comp deleted file mode 100644 index 7652733268..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/multiple-entry.asm.comp +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include - -using namespace metal; - -struct _6 -{ - int4 _m0; - uint4 _m1; -}; - -struct _7 -{ - uint4 _m0; - int4 _m1; -}; - -kernel void main0(device _6& _8 [[buffer(0)]], device _7& _9 [[buffer(1)]]) -{ - _9._m0 = _8._m1 + uint4(_8._m0); - _9._m0 = uint4(_8._m0) + _8._m1; - _9._m0 = _8._m1 + _8._m1; - _9._m0 = uint4(_8._m0 + _8._m0); - _9._m1 = int4(_8._m1 + _8._m1); - _9._m1 = _8._m0 + _8._m0; - _9._m1 = int4(_8._m1) + _8._m0; - _9._m1 = _8._m0 + int4(_8._m1); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/quantize.asm.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/quantize.asm.comp deleted file mode 100644 index 1839ec7a3b..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/quantize.asm.comp +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include - -using namespace metal; - -struct SSBO0 -{ - float scalar; - float2 vec2_val; - float3 vec3_val; - float4 vec4_val; -}; - -kernel void main0(device SSBO0& _4 [[buffer(0)]]) -{ - _4.scalar = float(half(_4.scalar)); - _4.vec2_val = float2(half2(_4.vec2_val)); - _4.vec3_val = float3(half3(_4.vec3_val)); - _4.vec4_val = float4(half4(_4.vec4_val)); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/specialization-constant-workgroup.asm.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/specialization-constant-workgroup.asm.comp deleted file mode 100644 index 5802ddac90..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/specialization-constant-workgroup.asm.comp +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include - -using namespace metal; - -constant uint _5_tmp [[function_constant(10)]]; -constant uint _5 = is_function_constant_defined(_5_tmp) ? _5_tmp : 9u; -constant uint _6_tmp [[function_constant(12)]]; -constant uint _6 = is_function_constant_defined(_6_tmp) ? _6_tmp : 4u; -constant uint3 gl_WorkGroupSize = uint3(_5, 20u, _6); - -struct SSBO -{ - float a; -}; - -kernel void main0(device SSBO& _4 [[buffer(0)]]) -{ - _4.a += 1.0; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/storage-buffer-basic.asm.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/storage-buffer-basic.asm.comp deleted file mode 100644 index 1dff618b3a..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/storage-buffer-basic.asm.comp +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include - -using namespace metal; - -constant uint _3_tmp [[function_constant(0)]]; -constant uint _3 = is_function_constant_defined(_3_tmp) ? _3_tmp : 1u; -constant uint _4_tmp [[function_constant(2)]]; -constant uint _4 = is_function_constant_defined(_4_tmp) ? _4_tmp : 3u; -constant uint3 gl_WorkGroupSize = uint3(_3, 2u, _4); - -struct _6 -{ - float _m0[1]; -}; - -kernel void main0(uint3 gl_WorkGroupID [[threadgroup_position_in_grid]], device _6& _8 [[buffer(0)]], device _6& _9 [[buffer(1)]]) -{ - _8._m0[gl_WorkGroupID.x] = _9._m0[gl_WorkGroupID.x] + _8._m0[gl_WorkGroupID.x]; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/frag/default-member-names.asm.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/frag/default-member-names.asm.frag deleted file mode 100644 index 1c730c7bbc..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/frag/default-member-names.asm.frag +++ /dev/null @@ -1,41 +0,0 @@ -#include -#include - -using namespace metal; - -struct _9 -{ - float _m0; -}; - -struct _10 -{ - float _m0; - float _m1; - float _m2; - float _m3; - float _m4; - float _m5; - float _m6; - float _m7; - float _m8; - float _m9; - float _m10; - float _m11; - _9 _m12; -}; - -constant _10 _51 = {}; - -struct main0_out -{ - float4 m_3 [[color(0)]]; -}; - -fragment main0_out main0() -{ - main0_out out = {}; - out.m_3 = float4(_51._m0, _51._m1, _51._m2, _51._m3); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag deleted file mode 100644 index 98a1674865..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag +++ /dev/null @@ -1,235 +0,0 @@ -#include -#include - -using namespace metal; - -struct VertexOutput -{ - float4 HPosition; - float4 Uv_EdgeDistance1; - float4 UvStuds_EdgeDistance2; - float4 Color; - float4 LightPosition_Fog; - float4 View_Depth; - float4 Normal_SpecPower; - float3 Tangent; - float4 PosLightSpace_Reflectance; - float studIndex; -}; - -struct Surface -{ - float3 albedo; - float3 normal; - float specular; - float gloss; - float reflectance; - float opacity; -}; - -struct SurfaceInput -{ - float4 Color; - float2 Uv; - float2 UvStuds; -}; - -struct Globals -{ - float4x4 ViewProjection; - float4 ViewRight; - float4 ViewUp; - float4 ViewDir; - float3 CameraPosition; - float3 AmbientColor; - float3 Lamp0Color; - float3 Lamp0Dir; - float3 Lamp1Color; - float4 FogParams; - float3 FogColor; - float4 LightBorder; - float4 LightConfig0; - float4 LightConfig1; - float4 LightConfig2; - float4 LightConfig3; - float4 RefractionBias_FadeDistance_GlowFactor; - float4 OutlineBrightness_ShadowInfo; - float4 ShadowMatrix0; - float4 ShadowMatrix1; - float4 ShadowMatrix2; -}; - -struct Params -{ - float4 LqmatFarTilingFactor; -}; - -struct CB0 -{ - Globals CB0; -}; - -struct CB2 -{ - Params CB2; -}; - -constant VertexOutput _121 = {}; -constant SurfaceInput _122 = {}; -constant float2 _123 = {}; -constant float4 _124 = {}; -constant Surface _125 = {}; -constant float4 _192 = {}; -constant float4 _219 = {}; -constant float4 _297 = {}; - -struct main0_in -{ - float IN_studIndex [[user(locn8)]]; - float4 IN_PosLightSpace_Reflectance [[user(locn7)]]; - float3 IN_Tangent [[user(locn6)]]; - float4 IN_Normal_SpecPower [[user(locn5)]]; - float4 IN_View_Depth [[user(locn4)]]; - float4 IN_LightPosition_Fog [[user(locn3)]]; - float4 IN_Color [[user(locn2)]]; - float4 IN_UvStuds_EdgeDistance2 [[user(locn1)]]; - float4 IN_Uv_EdgeDistance1 [[user(locn0)]]; -}; - -struct main0_out -{ - float4 _entryPointOutput [[color(0)]]; -}; - -fragment main0_out main0(main0_in in [[stage_in]], float4 gl_FragCoord [[position]], constant CB0& _19 [[buffer(0)]], texture3d LightMapTexture [[texture(0)]], sampler LightMapSampler [[sampler(0)]], sampler ShadowMapSampler [[sampler(1)]], texture2d ShadowMapTexture [[texture(1)]], texturecube EnvironmentMapTexture [[texture(2)]], sampler EnvironmentMapSampler [[sampler(2)]], sampler DiffuseMapSampler [[sampler(3)]], texture2d DiffuseMapTexture [[texture(3)]], sampler NormalMapSampler [[sampler(4)]], texture2d NormalMapTexture [[texture(4)]], texture2d NormalDetailMapTexture [[texture(5)]], sampler NormalDetailMapSampler [[sampler(5)]], texture2d StudsMapTexture [[texture(6)]], sampler StudsMapSampler [[sampler(6)]], sampler SpecularMapSampler [[sampler(7)]], texture2d SpecularMapTexture [[texture(7)]]) -{ - main0_out out = {}; - VertexOutput _128 = _121; - _128.HPosition = gl_FragCoord; - VertexOutput _130 = _128; - _130.Uv_EdgeDistance1 = in.IN_Uv_EdgeDistance1; - VertexOutput _132 = _130; - _132.UvStuds_EdgeDistance2 = in.IN_UvStuds_EdgeDistance2; - VertexOutput _134 = _132; - _134.Color = in.IN_Color; - VertexOutput _136 = _134; - _136.LightPosition_Fog = in.IN_LightPosition_Fog; - VertexOutput _138 = _136; - _138.View_Depth = in.IN_View_Depth; - VertexOutput _140 = _138; - _140.Normal_SpecPower = in.IN_Normal_SpecPower; - VertexOutput _142 = _140; - _142.Tangent = in.IN_Tangent; - VertexOutput _144 = _142; - _144.PosLightSpace_Reflectance = in.IN_PosLightSpace_Reflectance; - VertexOutput _146 = _144; - _146.studIndex = in.IN_studIndex; - SurfaceInput _147 = _122; - _147.Color = in.IN_Color; - SurfaceInput _149 = _147; - _149.Uv = in.IN_Uv_EdgeDistance1.xy; - SurfaceInput _151 = _149; - _151.UvStuds = in.IN_UvStuds_EdgeDistance2.xy; - SurfaceInput _156 = _151; - _156.UvStuds.y = (fract(_151.UvStuds.y) + in.IN_studIndex) * 0.25; - float _163 = _146.View_Depth.w * _19.CB0.RefractionBias_FadeDistance_GlowFactor.y; - float _165 = clamp(1.0 - _163, 0.0, 1.0); - float2 _166 = in.IN_Uv_EdgeDistance1.xy * 1.0; - bool _173; - float4 _193; - do - { - _173 = 0.0 == 0.0; - if (_173) - { - _193 = DiffuseMapTexture.sample(DiffuseMapSampler, _166); - break; - } - else - { - float _180 = 1.0 / (1.0 - 0.0); - _193 = mix(DiffuseMapTexture.sample(DiffuseMapSampler, (_166 * 0.25)), DiffuseMapTexture.sample(DiffuseMapSampler, _166), float4(clamp((clamp(1.0 - (_146.View_Depth.w * 0.00333332992158830165863037109375), 0.0, 1.0) * _180) - (0.0 * _180), 0.0, 1.0))); - break; - } - _193 = _192; - break; - } while (false); - float4 _220; - do - { - if (_173) - { - _220 = NormalMapTexture.sample(NormalMapSampler, _166); - break; - } - else - { - float _207 = 1.0 / (1.0 - 0.0); - _220 = mix(NormalMapTexture.sample(NormalMapSampler, (_166 * 0.25)), NormalMapTexture.sample(NormalMapSampler, _166), float4(clamp((_165 * _207) - (0.0 * _207), 0.0, 1.0))); - break; - } - _220 = _219; - break; - } while (false); - float2 _223 = float2(1.0); - float2 _224 = (_220.wy * 2.0) - _223; - float3 _232 = float3(_224, sqrt(clamp(1.0 + dot(-_224, _224), 0.0, 1.0))); - float2 _240 = (NormalDetailMapTexture.sample(NormalDetailMapSampler, (_166 * 0.0)).wy * 2.0) - _223; - float2 _252 = _232.xy + (float3(_240, sqrt(clamp(1.0 + dot(-_240, _240), 0.0, 1.0))).xy * 0.0); - float3 _253 = float3(_252.x, _252.y, _232.z); - float2 _255 = _253.xy * _165; - float3 _256 = float3(_255.x, _255.y, _253.z); - float3 _271 = ((in.IN_Color.xyz * (_193 * 1.0).xyz) * (1.0 + (_256.x * 0.300000011920928955078125))) * (StudsMapTexture.sample(StudsMapSampler, _156.UvStuds).x * 2.0); - float4 _298; - do - { - if (0.75 == 0.0) - { - _298 = SpecularMapTexture.sample(SpecularMapSampler, _166); - break; - } - else - { - float _285 = 1.0 / (1.0 - 0.75); - _298 = mix(SpecularMapTexture.sample(SpecularMapSampler, (_166 * 0.25)), SpecularMapTexture.sample(SpecularMapSampler, _166), float4(clamp((_165 * _285) - (0.75 * _285), 0.0, 1.0))); - break; - } - _298 = _297; - break; - } while (false); - float2 _303 = mix(float2(0.800000011920928955078125, 120.0), (_298.xy * float2(2.0, 256.0)) + float2(0.0, 0.00999999977648258209228515625), float2(_165)); - Surface _304 = _125; - _304.albedo = _271; - Surface _305 = _304; - _305.normal = _256; - float _306 = _303.x; - Surface _307 = _305; - _307.specular = _306; - float _308 = _303.y; - Surface _309 = _307; - _309.gloss = _308; - float _312 = (_298.xy.y * _165) * 0.0; - Surface _313 = _309; - _313.reflectance = _312; - float4 _318 = float4(_271, _146.Color.w); - float3 _329 = normalize(((in.IN_Tangent * _313.normal.x) + (cross(in.IN_Normal_SpecPower.xyz, in.IN_Tangent) * _313.normal.y)) + (in.IN_Normal_SpecPower.xyz * _313.normal.z)); - float3 _332 = -_19.CB0.Lamp0Dir; - float _333 = dot(_329, _332); - float _357 = clamp(dot(step(_19.CB0.LightConfig3.xyz, abs(in.IN_LightPosition_Fog.xyz - _19.CB0.LightConfig2.xyz)), float3(1.0)), 0.0, 1.0); - float4 _368 = mix(LightMapTexture.sample(LightMapSampler, (in.IN_LightPosition_Fog.xyz.yzx - (in.IN_LightPosition_Fog.xyz.yzx * _357))), _19.CB0.LightBorder, float4(_357)); - float2 _376 = ShadowMapTexture.sample(ShadowMapSampler, in.IN_PosLightSpace_Reflectance.xyz.xy).xy; - float _392 = (1.0 - (((step(_376.x, in.IN_PosLightSpace_Reflectance.xyz.z) * clamp(9.0 - (20.0 * abs(in.IN_PosLightSpace_Reflectance.xyz.z - 0.5)), 0.0, 1.0)) * _376.y) * _19.CB0.OutlineBrightness_ShadowInfo.w)) * _368.w; - float3 _403 = mix(_318.xyz, EnvironmentMapTexture.sample(EnvironmentMapSampler, reflect(-in.IN_View_Depth.xyz, _329)).xyz, float3(_312)); - float4 _404 = float4(_403.x, _403.y, _403.z, _318.w); - float3 _422 = (((_19.CB0.AmbientColor + (((_19.CB0.Lamp0Color * clamp(_333, 0.0, 1.0)) + (_19.CB0.Lamp1Color * max(-_333, 0.0))) * _392)) + _368.xyz) * _404.xyz) + (_19.CB0.Lamp0Color * (((step(0.0, _333) * _306) * _392) * pow(clamp(dot(_329, normalize(_332 + normalize(in.IN_View_Depth.xyz))), 0.0, 1.0), _308))); - float4 _425 = float4(_422.x, _422.y, _422.z, _124.w); - _425.w = _404.w; - float2 _435 = min(in.IN_Uv_EdgeDistance1.wz, in.IN_UvStuds_EdgeDistance2.wz); - float _439 = min(_435.x, _435.y) / _163; - float3 _445 = _425.xyz * clamp((clamp((_163 * _19.CB0.OutlineBrightness_ShadowInfo.x) + _19.CB0.OutlineBrightness_ShadowInfo.y, 0.0, 1.0) * (1.5 - _439)) + _439, 0.0, 1.0); - float4 _446 = float4(_445.x, _445.y, _445.z, _425.w); - float3 _453 = mix(_19.CB0.FogColor, _446.xyz, float3(clamp(_146.LightPosition_Fog.w, 0.0, 1.0))); - out._entryPointOutput = float4(_453.x, _453.y, _453.z, _446.w); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/frag/op-constant-null.asm.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/frag/op-constant-null.asm.frag deleted file mode 100644 index 9472add395..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/frag/op-constant-null.asm.frag +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -using namespace metal; - -struct D -{ - float4 a; - float b; -}; - -struct main0_out -{ - float FragColor [[color(0)]]; -}; - -fragment main0_out main0() -{ - main0_out out = {}; - out.FragColor = 0.0; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/frag/phi-loop-variable.asm.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/frag/phi-loop-variable.asm.frag deleted file mode 100644 index 036774d661..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/frag/phi-loop-variable.asm.frag +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include - -using namespace metal; - -fragment void main0() -{ - for (int _22 = 35; _22 >= 0; _22--) - { - } -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/frag/undef-variable-store.asm.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/frag/undef-variable-store.asm.frag deleted file mode 100644 index fb39c46fbb..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/frag/undef-variable-store.asm.frag +++ /dev/null @@ -1,38 +0,0 @@ -#include -#include - -using namespace metal; - -constant float4 _38 = {}; -constant float4 _50 = {}; - -struct main0_out -{ - float4 _entryPointOutput [[color(0)]]; -}; - -fragment main0_out main0() -{ - main0_out out = {}; - float4 _51; - _51 = _50; - float4 _52; - for (;;) - { - if (0.0 != 0.0) - { - _52 = float4(1.0, 0.0, 0.0, 1.0); - break; - } - else - { - _52 = float4(1.0, 1.0, 0.0, 1.0); - break; - } - _52 = _38; - break; - } - out._entryPointOutput = _52; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/frag/unreachable.asm.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/frag/unreachable.asm.frag deleted file mode 100644 index 3e80051e6b..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/frag/unreachable.asm.frag +++ /dev/null @@ -1,38 +0,0 @@ -#include -#include - -using namespace metal; - -constant float4 _21 = {}; - -struct main0_in -{ - int counter [[user(locn0)]]; -}; - -struct main0_out -{ - float4 FragColor [[color(0)]]; -}; - -fragment main0_out main0(main0_in in [[stage_in]]) -{ - main0_out out = {}; - float4 _33; - do - { - if (in.counter == 10) - { - _33 = float4(10.0); - break; - } - else - { - _33 = float4(30.0); - break; - } - } while (false); - out.FragColor = _33; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag deleted file mode 100644 index 17cd528d41..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag +++ /dev/null @@ -1,321 +0,0 @@ -#include -#include - -using namespace metal; - -struct _28 -{ - float4 _m0; -}; - -struct _6 -{ - float4 _m0; - float _m1; - float4 _m2; -}; - -struct _10 -{ - float3 _m0; - packed_float3 _m1; - float _m2; - packed_float3 _m3; - float _m4; - packed_float3 _m5; - float _m6; - packed_float3 _m7; - float _m8; - packed_float3 _m9; - float _m10; - packed_float3 _m11; - float _m12; - float2 _m13; - float2 _m14; - packed_float3 _m15; - float _m16; - float _m17; - float _m18; - float _m19; - float _m20; - float4 _m21; - float4 _m22; - float4x4 _m23; - float4 _m24; -}; - -struct _18 -{ - float4x4 _m0; - float4x4 _m1; - float4x4 _m2; - float4x4 _m3; - float4 _m4; - float4 _m5; - float _m6; - float _m7; - float _m8; - float _m9; - packed_float3 _m10; - float _m11; - packed_float3 _m12; - float _m13; - packed_float3 _m14; - float _m15; - packed_float3 _m16; - float _m17; - float _m18; - float _m19; - float2 _m20; - float2 _m21; - float2 _m22; - float4 _m23; - float2 _m24; - float2 _m25; - float2 _m26; - char pad27[8]; - packed_float3 _m27; - float _m28; - float _m29; - float _m30; - float _m31; - float _m32; - float2 _m33; - float _m34; - float _m35; - float3 _m36; - float4x4 _m37[2]; - float4 _m38[2]; -}; - -constant _28 _74 = {}; - -struct main0_out -{ - float4 m_5 [[color(0)]]; -}; - -fragment main0_out main0(float4 gl_FragCoord [[position]], constant _6& _7 [[buffer(0)]], texture2d _8 [[texture(0)]], sampler _9 [[sampler(0)]], constant _10& _11 [[buffer(1)]], texture2d _12 [[texture(1)]], sampler _13 [[sampler(1)]], texture2d _14 [[texture(2)]], sampler _15 [[sampler(2)]], constant _18& _19 [[buffer(2)]]) -{ - main0_out out = {}; - _28 _77 = _74; - _77._m0 = float4(0.0); - float2 _82 = gl_FragCoord.xy * _19._m23.xy; - float4 _88 = _7._m2 * _7._m0.xyxy; - float2 _97 = clamp(_82 + (float3(0.0, -2.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - float3 _109 = _11._m5 * clamp(_8.sample(_9, _97, level(0.0)).w * _7._m1, 0.0, 1.0); - float4 _113 = _12.sample(_13, _97, level(0.0)); - float3 _129; - if (_113.y > 0.0) - { - _129 = _109 + (_14.sample(_15, _97, level(0.0)).xyz * clamp(_113.y * _113.z, 0.0, 1.0)); - } - else - { - _129 = _109; - } - float3 _133 = float4(0.0).xyz + (_129 * 0.5); - float4 _134 = float4(_133.x, _133.y, _133.z, float4(0.0).w); - _28 _135 = _77; - _135._m0 = _134; - float2 _144 = clamp(_82 + (float3(-1.0, -1.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - float3 _156 = _11._m5 * clamp(_8.sample(_9, _144, level(0.0)).w * _7._m1, 0.0, 1.0); - float4 _160 = _12.sample(_13, _144, level(0.0)); - float3 _176; - if (_160.y > 0.0) - { - _176 = _156 + (_14.sample(_15, _144, level(0.0)).xyz * clamp(_160.y * _160.z, 0.0, 1.0)); - } - else - { - _176 = _156; - } - float3 _180 = _134.xyz + (_176 * 0.5); - float4 _181 = float4(_180.x, _180.y, _180.z, _134.w); - _28 _182 = _135; - _182._m0 = _181; - float2 _191 = clamp(_82 + (float3(0.0, -1.0, 0.75).xy * _7._m0.xy), _88.xy, _88.zw); - float3 _203 = _11._m5 * clamp(_8.sample(_9, _191, level(0.0)).w * _7._m1, 0.0, 1.0); - float4 _207 = _12.sample(_13, _191, level(0.0)); - float3 _223; - if (_207.y > 0.0) - { - _223 = _203 + (_14.sample(_15, _191, level(0.0)).xyz * clamp(_207.y * _207.z, 0.0, 1.0)); - } - else - { - _223 = _203; - } - float3 _227 = _181.xyz + (_223 * 0.75); - float4 _228 = float4(_227.x, _227.y, _227.z, _181.w); - _28 _229 = _182; - _229._m0 = _228; - float2 _238 = clamp(_82 + (float3(1.0, -1.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - float3 _250 = _11._m5 * clamp(_8.sample(_9, _238, level(0.0)).w * _7._m1, 0.0, 1.0); - float4 _254 = _12.sample(_13, _238, level(0.0)); - float3 _270; - if (_254.y > 0.0) - { - _270 = _250 + (_14.sample(_15, _238, level(0.0)).xyz * clamp(_254.y * _254.z, 0.0, 1.0)); - } - else - { - _270 = _250; - } - float3 _274 = _228.xyz + (_270 * 0.5); - float4 _275 = float4(_274.x, _274.y, _274.z, _228.w); - _28 _276 = _229; - _276._m0 = _275; - float2 _285 = clamp(_82 + (float3(-2.0, 0.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - float3 _297 = _11._m5 * clamp(_8.sample(_9, _285, level(0.0)).w * _7._m1, 0.0, 1.0); - float4 _301 = _12.sample(_13, _285, level(0.0)); - float3 _317; - if (_301.y > 0.0) - { - _317 = _297 + (_14.sample(_15, _285, level(0.0)).xyz * clamp(_301.y * _301.z, 0.0, 1.0)); - } - else - { - _317 = _297; - } - float3 _321 = _275.xyz + (_317 * 0.5); - float4 _322 = float4(_321.x, _321.y, _321.z, _275.w); - _28 _323 = _276; - _323._m0 = _322; - float2 _332 = clamp(_82 + (float3(-1.0, 0.0, 0.75).xy * _7._m0.xy), _88.xy, _88.zw); - float3 _344 = _11._m5 * clamp(_8.sample(_9, _332, level(0.0)).w * _7._m1, 0.0, 1.0); - float4 _348 = _12.sample(_13, _332, level(0.0)); - float3 _364; - if (_348.y > 0.0) - { - _364 = _344 + (_14.sample(_15, _332, level(0.0)).xyz * clamp(_348.y * _348.z, 0.0, 1.0)); - } - else - { - _364 = _344; - } - float3 _368 = _322.xyz + (_364 * 0.75); - float4 _369 = float4(_368.x, _368.y, _368.z, _322.w); - _28 _370 = _323; - _370._m0 = _369; - float2 _379 = clamp(_82 + (float3(0.0, 0.0, 1.0).xy * _7._m0.xy), _88.xy, _88.zw); - float3 _391 = _11._m5 * clamp(_8.sample(_9, _379, level(0.0)).w * _7._m1, 0.0, 1.0); - float4 _395 = _12.sample(_13, _379, level(0.0)); - float3 _411; - if (_395.y > 0.0) - { - _411 = _391 + (_14.sample(_15, _379, level(0.0)).xyz * clamp(_395.y * _395.z, 0.0, 1.0)); - } - else - { - _411 = _391; - } - float3 _415 = _369.xyz + (_411 * 1.0); - float4 _416 = float4(_415.x, _415.y, _415.z, _369.w); - _28 _417 = _370; - _417._m0 = _416; - float2 _426 = clamp(_82 + (float3(1.0, 0.0, 0.75).xy * _7._m0.xy), _88.xy, _88.zw); - float3 _438 = _11._m5 * clamp(_8.sample(_9, _426, level(0.0)).w * _7._m1, 0.0, 1.0); - float4 _442 = _12.sample(_13, _426, level(0.0)); - float3 _458; - if (_442.y > 0.0) - { - _458 = _438 + (_14.sample(_15, _426, level(0.0)).xyz * clamp(_442.y * _442.z, 0.0, 1.0)); - } - else - { - _458 = _438; - } - float3 _462 = _416.xyz + (_458 * 0.75); - float4 _463 = float4(_462.x, _462.y, _462.z, _416.w); - _28 _464 = _417; - _464._m0 = _463; - float2 _473 = clamp(_82 + (float3(2.0, 0.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - float3 _485 = _11._m5 * clamp(_8.sample(_9, _473, level(0.0)).w * _7._m1, 0.0, 1.0); - float4 _489 = _12.sample(_13, _473, level(0.0)); - float3 _505; - if (_489.y > 0.0) - { - _505 = _485 + (_14.sample(_15, _473, level(0.0)).xyz * clamp(_489.y * _489.z, 0.0, 1.0)); - } - else - { - _505 = _485; - } - float3 _509 = _463.xyz + (_505 * 0.5); - float4 _510 = float4(_509.x, _509.y, _509.z, _463.w); - _28 _511 = _464; - _511._m0 = _510; - float2 _520 = clamp(_82 + (float3(-1.0, 1.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - float3 _532 = _11._m5 * clamp(_8.sample(_9, _520, level(0.0)).w * _7._m1, 0.0, 1.0); - float4 _536 = _12.sample(_13, _520, level(0.0)); - float3 _552; - if (_536.y > 0.0) - { - _552 = _532 + (_14.sample(_15, _520, level(0.0)).xyz * clamp(_536.y * _536.z, 0.0, 1.0)); - } - else - { - _552 = _532; - } - float3 _556 = _510.xyz + (_552 * 0.5); - float4 _557 = float4(_556.x, _556.y, _556.z, _510.w); - _28 _558 = _511; - _558._m0 = _557; - float2 _567 = clamp(_82 + (float3(0.0, 1.0, 0.75).xy * _7._m0.xy), _88.xy, _88.zw); - float3 _579 = _11._m5 * clamp(_8.sample(_9, _567, level(0.0)).w * _7._m1, 0.0, 1.0); - float4 _583 = _12.sample(_13, _567, level(0.0)); - float3 _599; - if (_583.y > 0.0) - { - _599 = _579 + (_14.sample(_15, _567, level(0.0)).xyz * clamp(_583.y * _583.z, 0.0, 1.0)); - } - else - { - _599 = _579; - } - float3 _603 = _557.xyz + (_599 * 0.75); - float4 _604 = float4(_603.x, _603.y, _603.z, _557.w); - _28 _605 = _558; - _605._m0 = _604; - float2 _614 = clamp(_82 + (float3(1.0, 1.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - float3 _626 = _11._m5 * clamp(_8.sample(_9, _614, level(0.0)).w * _7._m1, 0.0, 1.0); - float4 _630 = _12.sample(_13, _614, level(0.0)); - float3 _646; - if (_630.y > 0.0) - { - _646 = _626 + (_14.sample(_15, _614, level(0.0)).xyz * clamp(_630.y * _630.z, 0.0, 1.0)); - } - else - { - _646 = _626; - } - float3 _650 = _604.xyz + (_646 * 0.5); - float4 _651 = float4(_650.x, _650.y, _650.z, _604.w); - _28 _652 = _605; - _652._m0 = _651; - float2 _661 = clamp(_82 + (float3(0.0, 2.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - float3 _673 = _11._m5 * clamp(_8.sample(_9, _661, level(0.0)).w * _7._m1, 0.0, 1.0); - float4 _677 = _12.sample(_13, _661, level(0.0)); - float3 _693; - if (_677.y > 0.0) - { - _693 = _673 + (_14.sample(_15, _661, level(0.0)).xyz * clamp(_677.y * _677.z, 0.0, 1.0)); - } - else - { - _693 = _673; - } - float3 _697 = _651.xyz + (_693 * 0.5); - float4 _698 = float4(_697.x, _697.y, _697.z, _651.w); - _28 _699 = _652; - _699._m0 = _698; - float3 _702 = _698.xyz / float3(((((((((((((0.0 + 0.5) + 0.5) + 0.75) + 0.5) + 0.5) + 0.75) + 1.0) + 0.75) + 0.5) + 0.5) + 0.75) + 0.5) + 0.5); - _28 _704 = _699; - _704._m0 = float4(_702.x, _702.y, _702.z, _698.w); - _28 _705 = _704; - _705._m0.w = 1.0; - out.m_5 = _705._m0; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/vert/empty-struct-composite.asm.vert b/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/vert/empty-struct-composite.asm.vert deleted file mode 100644 index 9e024c2095..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/vert/empty-struct-composite.asm.vert +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include - -using namespace metal; - -vertex void main0() -{ -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/atomic.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/atomic.comp deleted file mode 100644 index 90a39ec643..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/atomic.comp +++ /dev/null @@ -1,36 +0,0 @@ -#pragma clang diagnostic ignored "-Wunused-variable" - -#include -#include -#include - -using namespace metal; - -struct SSBO -{ - uint u32; - int i32; -}; - -kernel void main0(device SSBO& ssbo [[buffer(0)]]) -{ - uint _16 = atomic_fetch_add_explicit((volatile device atomic_uint*)&(ssbo.u32), 1u, memory_order_relaxed); - uint _18 = atomic_fetch_or_explicit((volatile device atomic_uint*)&(ssbo.u32), 1u, memory_order_relaxed); - uint _20 = atomic_fetch_xor_explicit((volatile device atomic_uint*)&(ssbo.u32), 1u, memory_order_relaxed); - uint _22 = atomic_fetch_and_explicit((volatile device atomic_uint*)&(ssbo.u32), 1u, memory_order_relaxed); - uint _24 = atomic_fetch_min_explicit((volatile device atomic_uint*)&(ssbo.u32), 1u, memory_order_relaxed); - uint _26 = atomic_fetch_max_explicit((volatile device atomic_uint*)&(ssbo.u32), 1u, memory_order_relaxed); - uint _28 = atomic_exchange_explicit((volatile device atomic_uint*)&(ssbo.u32), 1u, memory_order_relaxed); - uint _30 = 10u; - uint _32 = atomic_compare_exchange_weak_explicit((volatile device atomic_uint*)&(ssbo.u32), &(_30), 2u, memory_order_relaxed, memory_order_relaxed); - int _36 = atomic_fetch_add_explicit((volatile device atomic_int*)&(ssbo.i32), 1, memory_order_relaxed); - int _38 = atomic_fetch_or_explicit((volatile device atomic_int*)&(ssbo.i32), 1, memory_order_relaxed); - int _40 = atomic_fetch_xor_explicit((volatile device atomic_int*)&(ssbo.i32), 1, memory_order_relaxed); - int _42 = atomic_fetch_and_explicit((volatile device atomic_int*)&(ssbo.i32), 1, memory_order_relaxed); - int _44 = atomic_fetch_min_explicit((volatile device atomic_int*)&(ssbo.i32), 1, memory_order_relaxed); - int _46 = atomic_fetch_max_explicit((volatile device atomic_int*)&(ssbo.i32), 1, memory_order_relaxed); - int _48 = atomic_exchange_explicit((volatile device atomic_int*)&(ssbo.i32), 1, memory_order_relaxed); - int _50 = 10; - int _52 = atomic_compare_exchange_weak_explicit((volatile device atomic_int*)&(ssbo.i32), &(_50), 2, memory_order_relaxed, memory_order_relaxed); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/bake_gradient.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/bake_gradient.comp deleted file mode 100644 index fe7ac2b7d4..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/bake_gradient.comp +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -using namespace metal; - -constant uint3 gl_WorkGroupSize = uint3(8u, 8u, 1u); - -struct UBO -{ - float4 uInvSize; - float4 uScale; -}; - -kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], constant UBO& _46 [[buffer(0)]], texture2d uHeight [[texture(0)]], sampler uHeightSmplr [[sampler(0)]], texture2d uDisplacement [[texture(1)]], sampler uDisplacementSmplr [[sampler(1)]], texture2d iHeightDisplacement [[texture(2)]], texture2d iGradJacobian [[texture(3)]]) -{ - float4 _59 = (float2(gl_GlobalInvocationID.xy) * _46.uInvSize.xy).xyxy + (_46.uInvSize * 0.5); - float2 _157 = ((uDisplacement.sample(uDisplacementSmplr, _59.zw, level(0.0), int2(1, 0)).xy - uDisplacement.sample(uDisplacementSmplr, _59.zw, level(0.0), int2(-1, 0)).xy) * 0.60000002384185791015625) * _46.uScale.z; - float2 _161 = ((uDisplacement.sample(uDisplacementSmplr, _59.zw, level(0.0), int2(0, 1)).xy - uDisplacement.sample(uDisplacementSmplr, _59.zw, level(0.0), int2(0, -1)).xy) * 0.60000002384185791015625) * _46.uScale.z; - iHeightDisplacement.write(float4(uHeight.sample(uHeightSmplr, _59.xy, level(0.0)).x, 0.0, 0.0, 0.0), uint2(int2(gl_GlobalInvocationID.xy))); - iGradJacobian.write(float4((_46.uScale.xy * 0.5) * float2(uHeight.sample(uHeightSmplr, _59.xy, level(0.0), int2(1, 0)).x - uHeight.sample(uHeightSmplr, _59.xy, level(0.0), int2(-1, 0)).x, uHeight.sample(uHeightSmplr, _59.xy, level(0.0), int2(0, 1)).x - uHeight.sample(uHeightSmplr, _59.xy, level(0.0), int2(0, -1)).x), ((1.0 + _157.x) * (1.0 + _161.y)) - (_157.y * _161.x), 0.0), uint2(int2(gl_GlobalInvocationID.xy))); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/barriers.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/barriers.comp deleted file mode 100644 index 23a19914c2..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/barriers.comp +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include - -using namespace metal; - -constant uint3 gl_WorkGroupSize = uint3(4u, 1u, 1u); - -kernel void main0() -{ - threadgroup_barrier(mem_flags::mem_threadgroup); - threadgroup_barrier(mem_flags::mem_threadgroup); - threadgroup_barrier(mem_flags::mem_none); - threadgroup_barrier(mem_flags::mem_threadgroup); - threadgroup_barrier(mem_flags::mem_threadgroup); - threadgroup_barrier(mem_flags::mem_threadgroup); - threadgroup_barrier(mem_flags::mem_none); - threadgroup_barrier(mem_flags::mem_threadgroup); - threadgroup_barrier(mem_flags::mem_threadgroup); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/basic.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/basic.comp deleted file mode 100644 index 363c207186..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/basic.comp +++ /dev/null @@ -1,33 +0,0 @@ -#pragma clang diagnostic ignored "-Wunused-variable" - -#include -#include -#include - -using namespace metal; - -struct SSBO -{ - float4 in_data[1]; -}; - -struct SSBO2 -{ - float4 out_data[1]; -}; - -struct SSBO3 -{ - uint counter; -}; - -kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _23 [[buffer(0)]], device SSBO2& _45 [[buffer(1)]], device SSBO3& _48 [[buffer(2)]]) -{ - float4 _29 = _23.in_data[gl_GlobalInvocationID.x]; - if (dot(_29, float4(1.0, 5.0, 6.0, 2.0)) > 8.19999980926513671875) - { - uint _52 = atomic_fetch_add_explicit((volatile device atomic_uint*)&(_48.counter), 1u, memory_order_relaxed); - _45.out_data[_52] = _29; - } -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/bitfield.noopt.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/bitfield.noopt.comp deleted file mode 100644 index 62ef02c997..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/bitfield.noopt.comp +++ /dev/null @@ -1,47 +0,0 @@ -#pragma clang diagnostic ignored "-Wmissing-prototypes" - -#include -#include - -using namespace metal; - -// Implementation of the GLSL findLSB() function -template -T findLSB(T x) -{ - return select(ctz(x), T(-1), x == T(0)); -} - -// Implementation of the signed GLSL findMSB() function -template -T findSMSB(T x) -{ - T v = select(x, T(-1) - x, x < T(0)); - return select(clz(T(0)) - (clz(v) + T(1)), T(-1), v == T(0)); -} - -// Implementation of the unsigned GLSL findMSB() function -template -T findUMSB(T x) -{ - return select(clz(T(0)) - (clz(x) + T(1)), T(-1), x == T(0)); -} - -kernel void main0() -{ - int signed_value = 0; - uint unsigned_value = 0u; - int s = extract_bits(signed_value, 5, 20); - uint u = extract_bits(unsigned_value, 6, 21); - s = insert_bits(s, 40, 5, 4); - u = insert_bits(u, 60u, 5, 4); - u = reverse_bits(u); - s = reverse_bits(s); - int v0 = popcount(u); - int v1 = popcount(s); - int v2 = findUMSB(u); - int v3 = findSMSB(s); - int v4 = findLSB(u); - int v5 = findLSB(s); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/builtins.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/builtins.comp deleted file mode 100644 index 8278220225..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/builtins.comp +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include - -using namespace metal; - -kernel void main0(uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]], uint3 gl_NumWorkGroups [[threadgroups_per_grid]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]]) -{ -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/cfg-preserve-parameter.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/cfg-preserve-parameter.comp deleted file mode 100644 index 59fc03a752..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/cfg-preserve-parameter.comp +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include - -using namespace metal; - -kernel void main0() -{ -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/coherent-block.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/coherent-block.comp deleted file mode 100644 index bec9b218c7..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/coherent-block.comp +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include - -using namespace metal; - -struct SSBO -{ - float4 value; -}; - -kernel void main0(device SSBO& _10 [[buffer(0)]]) -{ - _10.value = float4(20.0); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/coherent-image.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/coherent-image.comp deleted file mode 100644 index 0fe044fb9a..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/coherent-image.comp +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include - -using namespace metal; - -struct SSBO -{ - int4 value; -}; - -kernel void main0(device SSBO& _10 [[buffer(0)]], texture2d uImage [[texture(0)]]) -{ - _10.value = uImage.read(uint2(int2(10))); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/culling.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/culling.comp deleted file mode 100644 index 64127d2c26..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/culling.comp +++ /dev/null @@ -1,35 +0,0 @@ -#pragma clang diagnostic ignored "-Wunused-variable" - -#include -#include -#include - -using namespace metal; - -constant uint3 gl_WorkGroupSize = uint3(4u, 1u, 1u); - -struct SSBO -{ - float in_data[1]; -}; - -struct SSBO2 -{ - float out_data[1]; -}; - -struct SSBO3 -{ - uint count; -}; - -kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _22 [[buffer(0)]], device SSBO2& _38 [[buffer(1)]], device SSBO3& _41 [[buffer(2)]]) -{ - float _28 = _22.in_data[gl_GlobalInvocationID.x]; - if (_28 > 12.0) - { - uint _45 = atomic_fetch_add_explicit((volatile device atomic_uint*)&(_41.count), 1u, memory_order_relaxed); - _38.out_data[_45] = _28; - } -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/defer-parens.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/defer-parens.comp deleted file mode 100644 index b9a742a13c..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/defer-parens.comp +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include - -using namespace metal; - -struct SSBO -{ - float4 data; - int index; -}; - -kernel void main0(device SSBO& _13 [[buffer(0)]]) -{ - float4 _17 = _13.data; - _13.data = float4(_17.x, _17.yz + float2(10.0), _17.w); - _13.data = (_17 + _17) + _17; - _13.data = (_17.yz + float2(10.0)).xxyy; - _13.data = float4((_17.yz + float2(10.0)).y); - _13.data = float4((_17.zw + float2(10.0))[_13.index]); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/dowhile.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/dowhile.comp deleted file mode 100644 index fca434d9a4..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/dowhile.comp +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include - -using namespace metal; - -struct SSBO -{ - float4x4 mvp; - float4 in_data[1]; -}; - -struct SSBO2 -{ - float4 out_data[1]; -}; - -kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _28 [[buffer(0)]], device SSBO2& _52 [[buffer(1)]]) -{ - int i = 0; - float4 _56; - _56 = _28.in_data[gl_GlobalInvocationID.x]; - float4 _42; - for (;;) - { - _42 = _28.mvp * _56; - i++; - if (i < 16) - { - _56 = _42; - continue; - } - else - { - break; - } - } - _52.out_data[gl_GlobalInvocationID.x] = _42; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/functions.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/functions.comp deleted file mode 100644 index 35ee32d220..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/functions.comp +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include - -using namespace metal; - -kernel void main0() -{ - threadgroup int foo[1337]; - foo[0] = 13; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/global-invocation-id-writable-ssbo-in-function.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/global-invocation-id-writable-ssbo-in-function.comp deleted file mode 100644 index fe0212ec3f..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/global-invocation-id-writable-ssbo-in-function.comp +++ /dev/null @@ -1,26 +0,0 @@ -#pragma clang diagnostic ignored "-Wmissing-prototypes" - -#include -#include - -using namespace metal; - -struct myBlock -{ - int a; - float b[1]; -}; - -// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() -template -Tx mod(Tx x, Ty y) -{ - return x - y * floor(x / y); -} - -kernel void main0(device myBlock& myStorage [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) -{ - myStorage.a = (myStorage.a + 1) % 256; - myStorage.b[gl_GlobalInvocationID.x] = mod(myStorage.b[gl_GlobalInvocationID.x] + 0.0199999995529651641845703125, 1.0); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/global-invocation-id.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/global-invocation-id.comp deleted file mode 100644 index fe0212ec3f..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/global-invocation-id.comp +++ /dev/null @@ -1,26 +0,0 @@ -#pragma clang diagnostic ignored "-Wmissing-prototypes" - -#include -#include - -using namespace metal; - -struct myBlock -{ - int a; - float b[1]; -}; - -// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() -template -Tx mod(Tx x, Ty y) -{ - return x - y * floor(x / y); -} - -kernel void main0(device myBlock& myStorage [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) -{ - myStorage.a = (myStorage.a + 1) % 256; - myStorage.b[gl_GlobalInvocationID.x] = mod(myStorage.b[gl_GlobalInvocationID.x] + 0.0199999995529651641845703125, 1.0); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/image.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/image.comp deleted file mode 100644 index edccd31bc9..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/image.comp +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include - -using namespace metal; - -kernel void main0(texture2d uImageIn [[texture(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], texture2d uImageOut [[texture(1)]]) -{ - uImageOut.write(uImageIn.read(uint2((int2(gl_GlobalInvocationID.xy) + int2(uImageIn.get_width(), uImageIn.get_height())))), uint2(int2(gl_GlobalInvocationID.xy))); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/insert.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/insert.comp deleted file mode 100644 index 1418ce35b5..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/insert.comp +++ /dev/null @@ -1,26 +0,0 @@ -#include -#include - -using namespace metal; - -struct SSBO -{ - float4 out_data[1]; -}; - -constant float4 _52 = {}; - -kernel void main0(device SSBO& _27 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) -{ - float4 _45 = _52; - _45.x = 10.0; - float4 _47 = _45; - _47.y = 30.0; - float4 _49 = _47; - _49.z = 70.0; - float4 _51 = _49; - _51.w = 90.0; - _27.out_data[gl_GlobalInvocationID.x] = _51; - _27.out_data[gl_GlobalInvocationID.x].y = 20.0; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/local-invocation-id.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/local-invocation-id.comp deleted file mode 100644 index 772e5e0d86..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/local-invocation-id.comp +++ /dev/null @@ -1,26 +0,0 @@ -#pragma clang diagnostic ignored "-Wmissing-prototypes" - -#include -#include - -using namespace metal; - -struct myBlock -{ - int a; - float b[1]; -}; - -// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() -template -Tx mod(Tx x, Ty y) -{ - return x - y * floor(x / y); -} - -kernel void main0(device myBlock& myStorage [[buffer(0)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]]) -{ - myStorage.a = (myStorage.a + 1) % 256; - myStorage.b[gl_LocalInvocationID.x] = mod(myStorage.b[gl_LocalInvocationID.x] + 0.0199999995529651641845703125, 1.0); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/local-invocation-index.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/local-invocation-index.comp deleted file mode 100644 index 41adbdca5c..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/local-invocation-index.comp +++ /dev/null @@ -1,26 +0,0 @@ -#pragma clang diagnostic ignored "-Wmissing-prototypes" - -#include -#include - -using namespace metal; - -struct myBlock -{ - int a; - float b[1]; -}; - -// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() -template -Tx mod(Tx x, Ty y) -{ - return x - y * floor(x / y); -} - -kernel void main0(device myBlock& myStorage [[buffer(0)]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]]) -{ - myStorage.a = (myStorage.a + 1) % 256; - myStorage.b[gl_LocalInvocationIndex] = mod(myStorage.b[gl_LocalInvocationIndex] + 0.0199999995529651641845703125, 1.0); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/loop.noopt.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/loop.noopt.comp deleted file mode 100644 index 55d850d191..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/loop.noopt.comp +++ /dev/null @@ -1,107 +0,0 @@ -#include -#include - -using namespace metal; - -struct SSBO -{ - float4x4 mvp; - float4 in_data[1]; -}; - -struct SSBO2 -{ - float4 out_data[1]; -}; - -kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _24 [[buffer(0)]], device SSBO2& _177 [[buffer(1)]]) -{ - uint ident = gl_GlobalInvocationID.x; - float4 idat = _24.in_data[ident]; - int k = 0; - uint i = 0u; - if (idat.y == 20.0) - { - do - { - k *= 2; - i++; - } while (i < ident); - } - switch (k) - { - case 10: - { - for (;;) - { - i++; - if (i > 10u) - { - break; - } - continue; - } - break; - } - default: - { - for (;;) - { - i += 2u; - if (i > 20u) - { - break; - } - continue; - } - break; - } - } - while (k < 10) - { - idat *= 2.0; - k++; - } - for (uint i_1 = 0u; i_1 < 16u; i_1++, k++) - { - for (uint j = 0u; j < 30u; j++) - { - idat = _24.mvp * idat; - } - } - k = 0; - for (;;) - { - k++; - if (k > 10) - { - k += 2; - } - else - { - k += 3; - continue; - } - k += 10; - continue; - } - k = 0; - do - { - k++; - } while (k > 10); - int l = 0; - for (;;) - { - if (l == 5) - { - l++; - continue; - } - idat += float4(1.0); - l++; - continue; - } - _177.out_data[ident] = idat; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/mat3.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/mat3.comp deleted file mode 100644 index e466d25f97..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/mat3.comp +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include - -using namespace metal; - -struct SSBO2 -{ - float3x3 out_data[1]; -}; - -kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO2& _22 [[buffer(0)]]) -{ - _22.out_data[gl_GlobalInvocationID.x] = float3x3(float3(10.0), float3(20.0), float3(40.0)); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/mod.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/mod.comp deleted file mode 100644 index 01dc6726ed..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/mod.comp +++ /dev/null @@ -1,31 +0,0 @@ -#pragma clang diagnostic ignored "-Wmissing-prototypes" - -#include -#include - -using namespace metal; - -struct SSBO -{ - float4 in_data[1]; -}; - -struct SSBO2 -{ - float4 out_data[1]; -}; - -// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() -template -Tx mod(Tx x, Ty y) -{ - return x - y * floor(x / y); -} - -kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _23 [[buffer(0)]], device SSBO2& _33 [[buffer(1)]]) -{ - _33.out_data[gl_GlobalInvocationID.x] = mod(_23.in_data[gl_GlobalInvocationID.x], _33.out_data[gl_GlobalInvocationID.x]); - _33.out_data[gl_GlobalInvocationID.x] = as_type(as_type(_23.in_data[gl_GlobalInvocationID.x]) % as_type(_33.out_data[gl_GlobalInvocationID.x])); - _33.out_data[gl_GlobalInvocationID.x] = as_type(as_type(_23.in_data[gl_GlobalInvocationID.x]) % as_type(_33.out_data[gl_GlobalInvocationID.x])); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/modf.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/modf.comp deleted file mode 100644 index 3a4cfd6975..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/modf.comp +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -using namespace metal; - -struct SSBO -{ - float4 in_data[1]; -}; - -struct SSBO2 -{ - float4 out_data[1]; -}; - -kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _23 [[buffer(0)]], device SSBO2& _35 [[buffer(1)]]) -{ - float4 i; - float4 _31 = modf(_23.in_data[gl_GlobalInvocationID.x], i); - _35.out_data[gl_GlobalInvocationID.x] = _31; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/read-write-only.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/read-write-only.comp deleted file mode 100644 index ba53b334ba..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/read-write-only.comp +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include - -using namespace metal; - -struct SSBO2 -{ - float4 data4; - float4 data5; -}; - -struct SSBO0 -{ - float4 data0; - float4 data1; -}; - -struct SSBO1 -{ - float4 data2; - float4 data3; -}; - -kernel void main0(device SSBO2& _10 [[buffer(0)]], device SSBO0& _15 [[buffer(1)]], device SSBO1& _21 [[buffer(2)]]) -{ - _10.data4 = _15.data0 + _21.data2; - _10.data5 = _15.data1 + _21.data3; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/return.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/return.comp deleted file mode 100644 index eaa25c5c7b..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/return.comp +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include - -using namespace metal; - -struct SSBO2 -{ - float4 out_data[1]; -}; - -constant int _69 = {}; - -kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO2& _27 [[buffer(0)]]) -{ - if (gl_GlobalInvocationID.x == 2u) - { - _27.out_data[gl_GlobalInvocationID.x] = float4(20.0); - } - else - { - if (gl_GlobalInvocationID.x == 4u) - { - _27.out_data[gl_GlobalInvocationID.x] = float4(10.0); - return; - } - } - for (int _68 = 0; _68 < 20; _68 = _69 + 1) - { - return; - } - _27.out_data[gl_GlobalInvocationID.x] = float4(10.0); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/rmw-opt.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/rmw-opt.comp deleted file mode 100644 index 4bbd8b3c71..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/rmw-opt.comp +++ /dev/null @@ -1,26 +0,0 @@ -#include -#include - -using namespace metal; - -struct SSBO -{ - int a; -}; - -kernel void main0(device SSBO& _9 [[buffer(0)]]) -{ - _9.a += 10; - _9.a -= 10; - _9.a *= 10; - _9.a /= 10; - _9.a = _9.a << 2; - _9.a = _9.a >> 3; - _9.a &= 40; - _9.a ^= 10; - _9.a %= 40; - _9.a |= 1; - bool _65 = false && true; - _9.a = int(_65 && (true || _65)); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/shared.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/shared.comp deleted file mode 100644 index 7408e3ecb1..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/shared.comp +++ /dev/null @@ -1,25 +0,0 @@ -#include -#include - -using namespace metal; - -constant uint3 gl_WorkGroupSize = uint3(4u, 1u, 1u); - -struct SSBO -{ - float in_data[1]; -}; - -struct SSBO2 -{ - float out_data[1]; -}; - -kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _22 [[buffer(0)]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]], device SSBO2& _44 [[buffer(1)]]) -{ - threadgroup float sShared[4]; - sShared[gl_LocalInvocationIndex] = _22.in_data[gl_GlobalInvocationID.x]; - threadgroup_barrier(mem_flags::mem_threadgroup); - _44.out_data[gl_GlobalInvocationID.x] = sShared[(4u - gl_LocalInvocationIndex) - 1u]; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/struct-layout.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/struct-layout.comp deleted file mode 100644 index 28e81e7361..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/struct-layout.comp +++ /dev/null @@ -1,25 +0,0 @@ -#include -#include - -using namespace metal; - -struct Foo -{ - float4x4 m; -}; - -struct SSBO2 -{ - Foo out_data[1]; -}; - -struct SSBO -{ - Foo in_data[1]; -}; - -kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO2& _23 [[buffer(0)]], device SSBO& _30 [[buffer(1)]]) -{ - _23.out_data[gl_GlobalInvocationID.x].m = _30.in_data[gl_GlobalInvocationID.x].m * _30.in_data[gl_GlobalInvocationID.x].m; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/struct-packing.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/struct-packing.comp deleted file mode 100644 index cf626ce63f..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/struct-packing.comp +++ /dev/null @@ -1,100 +0,0 @@ -#include -#include - -using namespace metal; - -struct S0 -{ - float2 a[1]; - float b; -}; - -struct S1 -{ - packed_float3 a; - float b; -}; - -struct S2 -{ - float3 a[1]; - float b; -}; - -struct S3 -{ - float2 a; - float b; -}; - -struct S4 -{ - float2 c; -}; - -struct Content -{ - S0 m0s[1]; - S1 m1s[1]; - S2 m2s[1]; - S0 m0; - S1 m1; - S2 m2; - S3 m3; - char pad7[4]; - float m4; - S4 m3s[8]; -}; - -struct SSBO1 -{ - Content content; - Content content1[2]; - Content content2; - char pad3[8]; - float2x2 m0; - float2x2 m1; - float2x3 m2[4]; - float3x2 m3; - float2x2 m4; - float2x2 m5[9]; - float2x3 m6[4][2]; - float3x2 m7; - float array[1]; -}; - -struct SSBO0 -{ - Content content; - Content content1[2]; - Content content2; - float array[1]; -}; - -kernel void main0(device SSBO1& ssbo_430 [[buffer(0)]], device SSBO0& ssbo_140 [[buffer(1)]]) -{ - ssbo_430.content.m0s[0].a[0] = ssbo_140.content.m0s[0].a[0]; - ssbo_430.content.m0s[0].b = ssbo_140.content.m0s[0].b; - ssbo_430.content.m1s[0].a = ssbo_140.content.m1s[0].a; - ssbo_430.content.m1s[0].b = ssbo_140.content.m1s[0].b; - ssbo_430.content.m2s[0].a[0] = ssbo_140.content.m2s[0].a[0]; - ssbo_430.content.m2s[0].b = ssbo_140.content.m2s[0].b; - ssbo_430.content.m0.a[0] = ssbo_140.content.m0.a[0]; - ssbo_430.content.m0.b = ssbo_140.content.m0.b; - ssbo_430.content.m1.a = ssbo_140.content.m1.a; - ssbo_430.content.m1.b = ssbo_140.content.m1.b; - ssbo_430.content.m2.a[0] = ssbo_140.content.m2.a[0]; - ssbo_430.content.m2.b = ssbo_140.content.m2.b; - ssbo_430.content.m3.a = ssbo_140.content.m3.a; - ssbo_430.content.m3.b = ssbo_140.content.m3.b; - ssbo_430.content.m4 = ssbo_140.content.m4; - ssbo_430.content.m3s[0].c = ssbo_140.content.m3s[0].c; - ssbo_430.content.m3s[1].c = ssbo_140.content.m3s[1].c; - ssbo_430.content.m3s[2].c = ssbo_140.content.m3s[2].c; - ssbo_430.content.m3s[3].c = ssbo_140.content.m3s[3].c; - ssbo_430.content.m3s[4].c = ssbo_140.content.m3s[4].c; - 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; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/torture-loop.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/torture-loop.comp deleted file mode 100644 index 47acff93b0..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/torture-loop.comp +++ /dev/null @@ -1,79 +0,0 @@ -#include -#include - -using namespace metal; - -struct SSBO -{ - float4x4 mvp; - float4 in_data[1]; -}; - -struct SSBO2 -{ - float4 out_data[1]; -}; - -constant uint _98 = {}; - -kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _24 [[buffer(0)]], device SSBO2& _89 [[buffer(1)]]) -{ - float4 _93; - int _94; - _93 = _24.in_data[gl_GlobalInvocationID.x]; - _94 = 0; - int _48; - int _40; - float4 _46; - for (;;) - { - _40 = _94 + 1; - if (_40 < 10) - { - _46 = _93 * 2.0; - _48 = _40 + 1; - _93 = _46; - _94 = _48; - continue; - } - else - { - break; - } - } - float4 _95; - int _96; - _95 = _93; - _96 = _40; - float4 _100; - uint _101; - uint _99; - for (uint _97 = 0u; _97 < 16u; _95 = _100, _96++, _97++, _99 = _101) - { - _100 = _95; - _101 = 0u; - float4 _71; - for (; _101 < 30u; _100 = _71, _101++) - { - _71 = _24.mvp * _100; - } - } - int _102; - _102 = _96; - int _83; - for (;;) - { - _83 = _102 + 1; - if (_83 > 10) - { - _102 = _83; - continue; - } - else - { - break; - } - } - _89.out_data[gl_GlobalInvocationID.x] = _95; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/type-alias.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/type-alias.comp deleted file mode 100644 index 167d4370c0..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/type-alias.comp +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include - -using namespace metal; - -struct S0 -{ - float4 a; -}; - -struct S1 -{ - float4 a; -}; - -struct SSBO0 -{ - S0 s0s[1]; -}; - -struct SSBO1 -{ - S1 s1s[1]; -}; - -struct SSBO2 -{ - float4 outputs[1]; -}; - -kernel void main0(device SSBO0& _36 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO1& _55 [[buffer(1)]], device SSBO2& _66 [[buffer(2)]]) -{ - _66.outputs[gl_GlobalInvocationID.x] = _36.s0s[gl_GlobalInvocationID.x].a + _55.s1s[gl_GlobalInvocationID.x].a; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/udiv.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/udiv.comp deleted file mode 100644 index ed82369b99..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/udiv.comp +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include - -using namespace metal; - -struct SSBO2 -{ - uint outputs[1]; -}; - -struct SSBO -{ - uint inputs[1]; -}; - -kernel void main0(device SSBO2& _10 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _23 [[buffer(1)]]) -{ - _10.outputs[gl_GlobalInvocationID.x] = _23.inputs[gl_GlobalInvocationID.x] / 29u; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/writable-ssbo.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/writable-ssbo.comp deleted file mode 100644 index 9dc53b6dd5..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/writable-ssbo.comp +++ /dev/null @@ -1,26 +0,0 @@ -#pragma clang diagnostic ignored "-Wmissing-prototypes" - -#include -#include - -using namespace metal; - -struct myBlock -{ - int a; - float b; -}; - -// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() -template -Tx mod(Tx x, Ty y) -{ - return x - y * floor(x / y); -} - -kernel void main0(device myBlock& myStorage [[buffer(0)]]) -{ - myStorage.a = (myStorage.a + 1) % 256; - myStorage.b = mod(myStorage.b + 0.0199999995529651641845703125, 1.0); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/desktop-only/frag/image-ms.desktop.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/desktop-only/frag/image-ms.desktop.frag deleted file mode 100644 index 4083e4ea16..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/desktop-only/frag/image-ms.desktop.frag +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include - -using namespace metal; - -fragment void main0(texture2d_ms uImageMS [[texture(0)]], texture2d_array uImageArray [[texture(1)]], texture2d uImage [[texture(2)]]) -{ - uImage.write(uImageMS.read(uint2(int2(1, 2)), 2), uint2(int2(2, 3))); - uImageArray.write(uImageArray.read(uint2(int3(1, 2, 4).xy), uint(int3(1, 2, 4).z)), uint2(int3(2, 3, 7).xy), uint(int3(2, 3, 7).z)); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/desktop-only/frag/query-levels.desktop.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/desktop-only/frag/query-levels.desktop.frag deleted file mode 100644 index 922796b749..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/desktop-only/frag/query-levels.desktop.frag +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_out -{ - float4 FragColor [[color(0)]]; -}; - -fragment main0_out main0(texture2d uSampler [[texture(0)]], sampler uSamplerSmplr [[sampler(0)]]) -{ - main0_out out = {}; - out.FragColor = float4(float(int(uSampler.get_num_mip_levels()))); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/desktop-only/frag/sampler-ms-query.desktop.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/desktop-only/frag/sampler-ms-query.desktop.frag deleted file mode 100644 index 4d2eee11c5..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/desktop-only/frag/sampler-ms-query.desktop.frag +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_out -{ - float4 FragColor [[color(0)]]; -}; - -fragment main0_out main0(texture2d_ms uSampler [[texture(0)]], sampler uSamplerSmplr [[sampler(0)]], texture2d_ms uSamplerArray [[texture(1)]], sampler uSamplerArraySmplr [[sampler(1)]], texture2d_ms uImage [[texture(2)]], texture2d_ms uImageArray [[texture(3)]]) -{ - main0_out out = {}; - out.FragColor = float4(float(((int(uSampler.get_num_samples()) + int(uSamplerArray.get_num_samples())) + int(uImage.get_num_samples())) + int(uImageArray.get_num_samples()))); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/desktop-only/vert/basic.desktop.sso.vert b/deps/SPIRV-Cross/reference/opt/shaders-msl/desktop-only/vert/basic.desktop.sso.vert deleted file mode 100644 index 1592b5c5cf..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/desktop-only/vert/basic.desktop.sso.vert +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -using namespace metal; - -struct UBO -{ - float4x4 uMVP; -}; - -struct main0_in -{ - float3 aNormal [[attribute(1)]]; - float4 aVertex [[attribute(0)]]; -}; - -struct main0_out -{ - float3 vNormal [[user(locn0)]]; - float4 gl_Position [[position]]; -}; - -vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _16 [[buffer(0)]]) -{ - main0_out out = {}; - out.gl_Position = _16.uMVP * in.aVertex; - out.vNormal = in.aNormal; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/desktop-only/vert/clip-cull-distance.desktop.vert b/deps/SPIRV-Cross/reference/opt/shaders-msl/desktop-only/vert/clip-cull-distance.desktop.vert deleted file mode 100644 index 32f0d9aa0d..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/desktop-only/vert/clip-cull-distance.desktop.vert +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_out -{ - float4 gl_Position [[position]]; - float gl_ClipDistance [[clip_distance]] [2]; - float gl_CullDistance[2]; -}; - -vertex main0_out main0() -{ - main0_out out = {}; - out.gl_Position = float4(10.0); - out.gl_ClipDistance[0] = 1.0; - out.gl_ClipDistance[1] = 4.0; - out.gl_CullDistance[0] = 4.0; - out.gl_CullDistance[1] = 9.0; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/basic.flatten.vert b/deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/basic.flatten.vert deleted file mode 100644 index 1592b5c5cf..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/basic.flatten.vert +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -using namespace metal; - -struct UBO -{ - float4x4 uMVP; -}; - -struct main0_in -{ - float3 aNormal [[attribute(1)]]; - float4 aVertex [[attribute(0)]]; -}; - -struct main0_out -{ - float3 vNormal [[user(locn0)]]; - float4 gl_Position [[position]]; -}; - -vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _16 [[buffer(0)]]) -{ - main0_out out = {}; - out.gl_Position = _16.uMVP * in.aVertex; - out.vNormal = in.aNormal; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/multiindex.flatten.vert b/deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/multiindex.flatten.vert deleted file mode 100644 index 84c4b408b2..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/multiindex.flatten.vert +++ /dev/null @@ -1,27 +0,0 @@ -#include -#include - -using namespace metal; - -struct UBO -{ - float4 Data[3][5]; -}; - -struct main0_in -{ - int2 aIndex [[attribute(0)]]; -}; - -struct main0_out -{ - float4 gl_Position [[position]]; -}; - -vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _20 [[buffer(0)]]) -{ - main0_out out = {}; - out.gl_Position = _20.Data[in.aIndex.x][in.aIndex.y]; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/push-constant.flatten.vert b/deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/push-constant.flatten.vert deleted file mode 100644 index 83def9c0bb..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/push-constant.flatten.vert +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include - -using namespace metal; - -struct PushMe -{ - float4x4 MVP; - float2x2 Rot; - float Arr[4]; -}; - -struct main0_in -{ - float4 Pos [[attribute(1)]]; - float2 Rot [[attribute(0)]]; -}; - -struct main0_out -{ - float2 vRot [[user(locn0)]]; - float4 gl_Position [[position]]; -}; - -vertex main0_out main0(main0_in in [[stage_in]], constant PushMe& registers [[buffer(0)]]) -{ - main0_out out = {}; - out.gl_Position = registers.MVP * in.Pos; - out.vRot = (registers.Rot * in.Rot) + float2(registers.Arr[2]); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/rowmajor.flatten.vert b/deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/rowmajor.flatten.vert deleted file mode 100644 index 3e0fcdbb75..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/rowmajor.flatten.vert +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include - -using namespace metal; - -struct UBO -{ - float4x4 uMVPR; - float4x4 uMVPC; - float2x4 uMVP; -}; - -struct main0_in -{ - float4 aVertex [[attribute(0)]]; -}; - -struct main0_out -{ - float4 gl_Position [[position]]; -}; - -vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _18 [[buffer(0)]]) -{ - main0_out out = {}; - out.gl_Position = (_18.uMVPR * in.aVertex) + (in.aVertex * _18.uMVPC); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/struct.flatten.vert b/deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/struct.flatten.vert deleted file mode 100644 index 594d29fe57..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/struct.flatten.vert +++ /dev/null @@ -1,40 +0,0 @@ -#include -#include - -using namespace metal; - -struct Light -{ - packed_float3 Position; - float Radius; - float4 Color; -}; - -struct UBO -{ - float4x4 uMVP; - Light light; -}; - -struct main0_in -{ - float3 aNormal [[attribute(1)]]; - float4 aVertex [[attribute(0)]]; -}; - -struct main0_out -{ - float4 vColor [[user(locn0)]]; - float4 gl_Position [[position]]; -}; - -vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _18 [[buffer(0)]]) -{ - main0_out out = {}; - out.gl_Position = _18.uMVP * in.aVertex; - out.vColor = float4(0.0); - float3 _39 = in.aVertex.xyz - _18.light.Position; - out.vColor += ((_18.light.Color * clamp(1.0 - (length(_39) / _18.light.Radius), 0.0, 1.0)) * dot(in.aNormal, normalize(_39))); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/swizzle.flatten.vert b/deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/swizzle.flatten.vert deleted file mode 100644 index 53fc21f99e..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/swizzle.flatten.vert +++ /dev/null @@ -1,47 +0,0 @@ -#include -#include - -using namespace metal; - -struct UBO -{ - float4 A; - float2 B0; - float2 B1; - float C0; - float3 C1; - packed_float3 D0; - float D1; - float E0; - float E1; - float E2; - float E3; - float F0; - float2 F1; - float F2; -}; - -struct main0_out -{ - float4 oA [[user(locn0)]]; - float4 oB [[user(locn1)]]; - float4 oC [[user(locn2)]]; - float4 oD [[user(locn3)]]; - float4 oE [[user(locn4)]]; - float4 oF [[user(locn5)]]; - float4 gl_Position [[position]]; -}; - -vertex main0_out main0(constant UBO& _22 [[buffer(0)]]) -{ - main0_out out = {}; - out.gl_Position = float4(0.0); - out.oA = _22.A; - out.oB = float4(_22.B0, _22.B1); - out.oC = float4(_22.C0, _22.C1) + float4(_22.C1.xy, _22.C1.z, _22.C0); - out.oD = float4(_22.D0, _22.D1) + float4(float3(_22.D0).xy, float3(_22.D0).z, _22.D1); - out.oE = float4(_22.E0, _22.E1, _22.E2, _22.E3); - out.oF = float4(_22.F0, _22.F1, _22.F2); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/types.flatten.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/types.flatten.frag deleted file mode 100644 index cee53d9e58..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/types.flatten.frag +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include - -using namespace metal; - -struct UBO1 -{ - int4 c; - int4 d; -}; - -struct UBO2 -{ - uint4 e; - uint4 f; -}; - -struct UBO0 -{ - float4 a; - float4 b; -}; - -struct main0_out -{ - float4 FragColor [[color(0)]]; -}; - -fragment main0_out main0(constant UBO1& _14 [[buffer(0)]], constant UBO2& _29 [[buffer(1)]], constant UBO0& _41 [[buffer(2)]]) -{ - main0_out out = {}; - out.FragColor = ((((float4(_14.c) + float4(_14.d)) + float4(_29.e)) + float4(_29.f)) + _41.a) + _41.b; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/basic.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/basic.frag deleted file mode 100644 index 4d33ee7bca..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/basic.frag +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_in -{ - float2 vTex [[user(locn1)]]; - float4 vColor [[user(locn0)]]; -}; - -struct main0_out -{ - float4 FragColor [[color(0)]]; -}; - -fragment main0_out main0(main0_in in [[stage_in]], texture2d uTex [[texture(0)]], sampler uTexSmplr [[sampler(0)]]) -{ - main0_out out = {}; - out.FragColor = in.vColor * uTex.sample(uTexSmplr, in.vTex); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/bitcasting.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/bitcasting.frag deleted file mode 100644 index 8a7f750f90..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/bitcasting.frag +++ /dev/null @@ -1,26 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_in -{ - float4 VertGeom [[user(locn0)]]; -}; - -struct main0_out -{ - float4 FragColor0 [[color(0)]]; - float4 FragColor1 [[color(1)]]; -}; - -fragment main0_out main0(main0_in in [[stage_in]], texture2d TextureBase [[texture(0)]], sampler TextureBaseSmplr [[sampler(0)]], texture2d TextureDetail [[texture(1)]], sampler TextureDetailSmplr [[sampler(1)]]) -{ - main0_out out = {}; - float4 _20 = TextureBase.sample(TextureBaseSmplr, in.VertGeom.xy); - float4 _31 = TextureDetail.sample(TextureDetailSmplr, in.VertGeom.xy, int2(3, 2)); - out.FragColor0 = as_type(as_type(_20)) * as_type(as_type(_31)); - out.FragColor1 = as_type(as_type(_20)) * as_type(as_type(_31)); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/builtins.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/builtins.frag deleted file mode 100644 index 9283d1a66b..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/builtins.frag +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_in -{ - float4 vColor [[user(locn0)]]; -}; - -struct main0_out -{ - float4 FragColor [[color(0)]]; - float gl_FragDepth [[depth(any)]]; -}; - -fragment main0_out main0(main0_in in [[stage_in]], float4 gl_FragCoord [[position]]) -{ - main0_out out = {}; - out.FragColor = gl_FragCoord + in.vColor; - out.gl_FragDepth = 0.5; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/composite-extract-forced-temporary.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/composite-extract-forced-temporary.frag deleted file mode 100644 index 5539c2508f..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/composite-extract-forced-temporary.frag +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_in -{ - float2 vTexCoord [[user(locn0)]]; -}; - -struct main0_out -{ - float4 FragColor [[color(0)]]; -}; - -fragment main0_out main0(main0_in in [[stage_in]], texture2d Texture [[texture(0)]], sampler TextureSmplr [[sampler(0)]]) -{ - main0_out out = {}; - float4 _19 = Texture.sample(TextureSmplr, in.vTexCoord); - float _22 = _19.x; - out.FragColor = float4(_22 * _22); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/constant-array.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/constant-array.frag deleted file mode 100644 index 7a9a0dea1c..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/constant-array.frag +++ /dev/null @@ -1,31 +0,0 @@ -#include -#include - -using namespace metal; - -struct Foobar -{ - float a; - float b; -}; - -struct main0_in -{ - int index [[user(locn0)]]; -}; - -struct main0_out -{ - float4 FragColor [[color(0)]]; -}; - -fragment main0_out main0(main0_in in [[stage_in]]) -{ - main0_out out = {}; - float4 indexable[3] = {float4(1.0), float4(2.0), float4(3.0)}; - float4 indexable_1[2][2] = {{float4(1.0), float4(2.0)}, {float4(8.0), float4(10.0)}}; - Foobar indexable_2[2] = {{10.0, 40.0}, {90.0, 70.0}}; - out.FragColor = ((indexable[in.index] + (indexable_1[in.index][in.index + 1])) + float4(10.0 + 20.0)) + float4(indexable_2[in.index].a + indexable_2[in.index].b); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/false-loop-init.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/false-loop-init.frag deleted file mode 100644 index c67bb9d396..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/false-loop-init.frag +++ /dev/null @@ -1,38 +0,0 @@ -#include -#include - -using namespace metal; - -constant uint _49 = {}; - -struct main0_in -{ - float4 accum [[user(locn0)]]; -}; - -struct main0_out -{ - float4 result [[color(0)]]; -}; - -fragment main0_out main0(main0_in in [[stage_in]]) -{ - main0_out out = {}; - out.result = float4(0.0); - uint _51; - uint _50; - for (int _48 = 0; _48 < 4; _48 += int(_51), _50 = _51) - { - if (in.accum.y > 10.0) - { - _51 = 40u; - } - else - { - _51 = 30u; - } - out.result += in.accum; - } - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/flush_params.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/flush_params.frag deleted file mode 100644 index 059167fd4b..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/flush_params.frag +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -using namespace metal; - -struct Structy -{ - float4 c; -}; - -struct main0_out -{ - float4 FragColor [[color(0)]]; -}; - -fragment main0_out main0() -{ - main0_out out = {}; - out.FragColor = float4(10.0); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/for-loop-init.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/for-loop-init.frag deleted file mode 100644 index 0e5c92c7e5..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/for-loop-init.frag +++ /dev/null @@ -1,57 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_out -{ - int FragColor [[color(0)]]; -}; - -fragment main0_out main0() -{ - main0_out out = {}; - out.FragColor = 16; - for (int _140 = 0; _140 < 25; _140++) - { - out.FragColor += 10; - } - for (int _141 = 1; _141 < 30; _141++) - { - out.FragColor += 11; - } - int _142; - _142 = 0; - for (; _142 < 20; _142++) - { - out.FragColor += 12; - } - int _62 = _142 + 3; - out.FragColor += _62; - if (_62 == 40) - { - for (int _143 = 0; _143 < 40; _143++) - { - out.FragColor += 13; - } - return out; - } - else - { - out.FragColor += _62; - } - int2 _144; - _144 = int2(0); - int2 _139; - for (; _144.x < 10; _139 = _144, _139.x = _144.x + 4, _144 = _139) - { - out.FragColor += _144.y; - } - for (int _145 = _62; _145 < 40; _145++) - { - out.FragColor += _145; - } - out.FragColor += _62; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/in_block.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/in_block.frag deleted file mode 100644 index 43b4a05897..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/in_block.frag +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_in -{ - float4 VertexOut_color2 [[user(locn3)]]; - float4 VertexOut_color [[user(locn2)]]; -}; - -struct main0_out -{ - float4 FragColor [[color(0)]]; -}; - -fragment main0_out main0(main0_in in [[stage_in]]) -{ - main0_out out = {}; - out.FragColor = in.VertexOut_color + in.VertexOut_color2; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/in_block_assign.noopt.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/in_block_assign.noopt.frag deleted file mode 100644 index d06863d99c..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/in_block_assign.noopt.frag +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -using namespace metal; - -struct VOUT -{ - float4 a; -}; - -struct main0_in -{ - float4 VOUT_a [[user(locn0)]]; -}; - -struct main0_out -{ - float4 FragColor [[color(0)]]; -}; - -fragment main0_out main0(main0_in in [[stage_in]]) -{ - main0_out out = {}; - VOUT tmp; - tmp.a = in.VOUT_a; - tmp.a += float4(1.0); - out.FragColor = tmp.a; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/mix.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/mix.frag deleted file mode 100644 index 9c9b8398cf..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/mix.frag +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_in -{ - float vIn3 [[user(locn3)]]; - float vIn2 [[user(locn2)]]; - float4 vIn1 [[user(locn1)]]; - float4 vIn0 [[user(locn0)]]; -}; - -struct main0_out -{ - float4 FragColor [[color(0)]]; -}; - -fragment main0_out main0(main0_in in [[stage_in]]) -{ - main0_out out = {}; - out.FragColor = float4(bool4(false, true, false, false).x ? in.vIn1.x : in.vIn0.x, bool4(false, true, false, false).y ? in.vIn1.y : in.vIn0.y, bool4(false, true, false, false).z ? in.vIn1.z : in.vIn0.z, bool4(false, true, false, false).w ? in.vIn1.w : in.vIn0.w); - out.FragColor = float4(true ? in.vIn3 : in.vIn2); - bool4 _37 = bool4(true); - out.FragColor = float4(_37.x ? in.vIn0.x : in.vIn1.x, _37.y ? in.vIn0.y : in.vIn1.y, _37.z ? in.vIn0.z : in.vIn1.z, _37.w ? in.vIn0.w : in.vIn1.w); - out.FragColor = float4(true ? in.vIn2 : in.vIn3); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/pls.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/pls.frag deleted file mode 100644 index 42b5d2bf59..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/pls.frag +++ /dev/null @@ -1,31 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_in -{ - float4 PLSIn3 [[user(locn3)]]; - float4 PLSIn2 [[user(locn2)]]; - float4 PLSIn1 [[user(locn1)]]; - float4 PLSIn0 [[user(locn0)]]; -}; - -struct main0_out -{ - float4 PLSOut0 [[color(0)]]; - float4 PLSOut1 [[color(1)]]; - float4 PLSOut2 [[color(2)]]; - float4 PLSOut3 [[color(3)]]; -}; - -fragment main0_out main0(main0_in in [[stage_in]]) -{ - main0_out out = {}; - out.PLSOut0 = in.PLSIn0 * 2.0; - out.PLSOut1 = in.PLSIn1 * 6.0; - out.PLSOut2 = in.PLSIn2 * 7.0; - out.PLSOut3 = in.PLSIn3 * 4.0; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/sampler-ms.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/sampler-ms.frag deleted file mode 100644 index 5fcb3bcbfb..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/sampler-ms.frag +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_out -{ - float4 FragColor [[color(0)]]; -}; - -fragment main0_out main0(float4 gl_FragCoord [[position]], texture2d_ms uSampler [[texture(0)]], sampler uSamplerSmplr [[sampler(0)]]) -{ - main0_out out = {}; - int2 _17 = int2(gl_FragCoord.xy); - out.FragColor = ((uSampler.read(uint2(_17), 0) + uSampler.read(uint2(_17), 1)) + uSampler.read(uint2(_17), 2)) + uSampler.read(uint2(_17), 3); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/sampler.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/sampler.frag deleted file mode 100644 index 4d33ee7bca..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/sampler.frag +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_in -{ - float2 vTex [[user(locn1)]]; - float4 vColor [[user(locn0)]]; -}; - -struct main0_out -{ - float4 FragColor [[color(0)]]; -}; - -fragment main0_out main0(main0_in in [[stage_in]], texture2d uTex [[texture(0)]], sampler uTexSmplr [[sampler(0)]]) -{ - main0_out out = {}; - out.FragColor = in.vColor * uTex.sample(uTexSmplr, in.vTex); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/separate-image-sampler-argument.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/separate-image-sampler-argument.frag deleted file mode 100644 index e576b49e7e..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/separate-image-sampler-argument.frag +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_out -{ - float4 FragColor [[color(0)]]; -}; - -fragment main0_out main0(texture2d uDepth [[texture(0)]], sampler uSampler [[sampler(0)]]) -{ - main0_out out = {}; - out.FragColor = uDepth.sample(uSampler, float2(0.5)); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/swizzle.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/swizzle.frag deleted file mode 100644 index eb46111f00..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/swizzle.frag +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_in -{ - float2 vUV [[user(locn2)]]; - float3 vNormal [[user(locn1)]]; -}; - -struct main0_out -{ - float4 FragColor [[color(0)]]; -}; - -fragment main0_out main0(main0_in in [[stage_in]], texture2d samp [[texture(0)]], sampler sampSmplr [[sampler(0)]]) -{ - main0_out out = {}; - out.FragColor = float4(samp.sample(sampSmplr, in.vUV).xyz, 1.0); - out.FragColor = float4(samp.sample(sampSmplr, in.vUV).xz, 1.0, 4.0); - out.FragColor = float4(samp.sample(sampSmplr, in.vUV).xx, samp.sample(sampSmplr, (in.vUV + float2(0.100000001490116119384765625))).yy); - out.FragColor = float4(in.vNormal, 1.0); - out.FragColor = float4(in.vNormal + float3(1.7999999523162841796875), 1.0); - out.FragColor = float4(in.vUV, in.vUV + float2(1.7999999523162841796875)); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/texture-proj-shadow.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/texture-proj-shadow.frag deleted file mode 100644 index c31e6d9623..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/texture-proj-shadow.frag +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_in -{ - float2 vClip2 [[user(locn2)]]; - float4 vClip4 [[user(locn1)]]; - float3 vClip3 [[user(locn0)]]; -}; - -struct main0_out -{ - float FragColor [[color(0)]]; -}; - -fragment main0_out main0(main0_in in [[stage_in]], depth2d uShadow2D [[texture(0)]], sampler uShadow2DSmplr [[sampler(0)]], texture1d uSampler1D [[texture(1)]], sampler uSampler1DSmplr [[sampler(1)]], texture2d uSampler2D [[texture(2)]], sampler uSampler2DSmplr [[sampler(2)]], texture3d uSampler3D [[texture(3)]], sampler uSampler3DSmplr [[sampler(3)]]) -{ - main0_out out = {}; - float4 _20 = in.vClip4; - _20.z = in.vClip4.w; - out.FragColor = uShadow2D.sample_compare(uShadow2DSmplr, _20.xy / _20.z, in.vClip4.z); - out.FragColor = uSampler1D.sample(uSampler1DSmplr, in.vClip2.x / in.vClip2.y).x; - out.FragColor = uSampler2D.sample(uSampler2DSmplr, in.vClip3.xy / in.vClip3.z).x; - out.FragColor = uSampler3D.sample(uSampler3DSmplr, in.vClip4.xyz / in.vClip4.w).x; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/ubo_layout.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/ubo_layout.frag deleted file mode 100644 index 8c03e33b39..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/ubo_layout.frag +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include - -using namespace metal; - -struct Str -{ - float4x4 foo; -}; - -struct UBO1 -{ - Str foo; -}; - -struct UBO2 -{ - Str foo; -}; - -struct main0_out -{ - float4 FragColor [[color(0)]]; -}; - -fragment main0_out main0(constant UBO1& ubo1 [[buffer(0)]], constant UBO2& ubo0 [[buffer(1)]]) -{ - main0_out out = {}; - out.FragColor = transpose(ubo1.foo.foo)[0] + ubo0.foo.foo[0]; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/unary-enclose.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/unary-enclose.frag deleted file mode 100644 index 7437f1dfe8..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/unary-enclose.frag +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_in -{ - float4 vIn [[user(locn0)]]; -}; - -struct main0_out -{ - float4 FragColor [[color(0)]]; -}; - -fragment main0_out main0(main0_in in [[stage_in]]) -{ - main0_out out = {}; - out.FragColor = -(-in.vIn); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/legacy/vert/transpose.legacy.vert b/deps/SPIRV-Cross/reference/opt/shaders-msl/legacy/vert/transpose.legacy.vert deleted file mode 100644 index b28067e589..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/legacy/vert/transpose.legacy.vert +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include - -using namespace metal; - -struct Buffer -{ - float4x4 MVPRowMajor; - float4x4 MVPColMajor; - float4x4 M; -}; - -struct main0_in -{ - float4 Position [[attribute(0)]]; -}; - -struct main0_out -{ - float4 gl_Position [[position]]; -}; - -vertex main0_out main0(main0_in in [[stage_in]], constant Buffer& _13 [[buffer(0)]]) -{ - main0_out out = {}; - out.gl_Position = (((_13.M * (in.Position * _13.MVPRowMajor)) + (_13.M * (_13.MVPColMajor * in.Position))) + (_13.M * (_13.MVPRowMajor * in.Position))) + (_13.M * (in.Position * _13.MVPColMajor)); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/basic.vert b/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/basic.vert deleted file mode 100644 index 1592b5c5cf..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/basic.vert +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -using namespace metal; - -struct UBO -{ - float4x4 uMVP; -}; - -struct main0_in -{ - float3 aNormal [[attribute(1)]]; - float4 aVertex [[attribute(0)]]; -}; - -struct main0_out -{ - float3 vNormal [[user(locn0)]]; - float4 gl_Position [[position]]; -}; - -vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _16 [[buffer(0)]]) -{ - main0_out out = {}; - out.gl_Position = _16.uMVP * in.aVertex; - out.vNormal = in.aNormal; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/copy.flatten.vert b/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/copy.flatten.vert deleted file mode 100644 index dc87c849dc..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/copy.flatten.vert +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include - -using namespace metal; - -struct Light -{ - packed_float3 Position; - float Radius; - float4 Color; -}; - -struct UBO -{ - float4x4 uMVP; - Light lights[4]; -}; - -struct main0_in -{ - float3 aNormal [[attribute(1)]]; - float4 aVertex [[attribute(0)]]; -}; - -struct main0_out -{ - float4 vColor [[user(locn0)]]; - float4 gl_Position [[position]]; -}; - -vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _21 [[buffer(0)]]) -{ - main0_out out = {}; - out.gl_Position = _21.uMVP * in.aVertex; - out.vColor = float4(0.0); - for (int _103 = 0; _103 < 4; _103++) - { - float3 _68 = in.aVertex.xyz - _21.lights[_103].Position; - out.vColor += ((_21.lights[_103].Color * clamp(1.0 - (length(_68) / _21.lights[_103].Radius), 0.0, 1.0)) * dot(in.aNormal, normalize(_68))); - } - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/dynamic.flatten.vert b/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/dynamic.flatten.vert deleted file mode 100644 index eb38ab4fd1..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/dynamic.flatten.vert +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include - -using namespace metal; - -struct Light -{ - packed_float3 Position; - float Radius; - float4 Color; -}; - -struct UBO -{ - float4x4 uMVP; - Light lights[4]; -}; - -struct main0_in -{ - float3 aNormal [[attribute(1)]]; - float4 aVertex [[attribute(0)]]; -}; - -struct main0_out -{ - float4 vColor [[user(locn0)]]; - float4 gl_Position [[position]]; -}; - -vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _21 [[buffer(0)]]) -{ - main0_out out = {}; - out.gl_Position = _21.uMVP * in.aVertex; - out.vColor = float4(0.0); - for (int _82 = 0; _82 < 4; _82++) - { - float3 _54 = in.aVertex.xyz - _21.lights[_82].Position; - out.vColor += ((_21.lights[_82].Color * clamp(1.0 - (length(_54) / _21.lights[_82].Radius), 0.0, 1.0)) * dot(in.aNormal, normalize(_54))); - } - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/functions.vert b/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/functions.vert deleted file mode 100644 index 8ec2484c3e..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/functions.vert +++ /dev/null @@ -1,119 +0,0 @@ -#pragma clang diagnostic ignored "-Wmissing-prototypes" - -#include -#include - -using namespace metal; - -struct UBO -{ - float4x4 uMVP; - float3 rotDeg; - float3 rotRad; - int2 bits; -}; - -struct main0_in -{ - float3 aNormal [[attribute(1)]]; - float4 aVertex [[attribute(0)]]; -}; - -struct main0_out -{ - float3 vNormal [[user(locn0)]]; - float3 vRotDeg [[user(locn1)]]; - float3 vRotRad [[user(locn2)]]; - int2 vLSB [[user(locn3)]]; - int2 vMSB [[user(locn4)]]; - float4 gl_Position [[position]]; -}; - -// Implementation of the GLSL radians() function -template -T radians(T d) -{ - return d * 0.01745329251; -} - -// Implementation of the GLSL degrees() function -template -T degrees(T r) -{ - return r * 57.2957795131; -} - -// Implementation of the GLSL findLSB() function -template -T findLSB(T x) -{ - return select(ctz(x), T(-1), x == T(0)); -} - -// Implementation of the signed GLSL findMSB() function -template -T findSMSB(T x) -{ - T v = select(x, T(-1) - x, x < T(0)); - return select(clz(T(0)) - (clz(v) + T(1)), T(-1), v == T(0)); -} - -// 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; -} - -vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _18 [[buffer(0)]]) -{ - main0_out out = {}; - out.gl_Position = spvInverse4x4(_18.uMVP) * in.aVertex; - out.vNormal = in.aNormal; - out.vRotDeg = degrees(_18.rotRad); - out.vRotRad = radians(_18.rotDeg); - out.vLSB = findLSB(_18.bits); - out.vMSB = findSMSB(_18.bits); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/out_block.vert b/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/out_block.vert deleted file mode 100644 index 3ae18387a6..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/out_block.vert +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include - -using namespace metal; - -struct Transform -{ - float4x4 transform; -}; - -struct main0_in -{ - float4 color [[attribute(1)]]; - float3 position [[attribute(0)]]; -}; - -struct main0_out -{ - float4 VertexOut_color [[user(locn2)]]; - float4 VertexOut_color2 [[user(locn3)]]; - float4 gl_Position [[position]]; -}; - -vertex main0_out main0(main0_in in [[stage_in]], constant Transform& block [[buffer(0)]]) -{ - main0_out out = {}; - out.gl_Position = block.transform * float4(in.position, 1.0); - out.VertexOut_color = in.color; - out.VertexOut_color2 = in.color + float4(1.0); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/pointsize.vert b/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/pointsize.vert deleted file mode 100644 index faf828b4d3..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/pointsize.vert +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include - -using namespace metal; - -struct params -{ - float4x4 mvp; - float psize; -}; - -struct main0_in -{ - float4 color0 [[attribute(1)]]; - float4 position [[attribute(0)]]; -}; - -struct main0_out -{ - float4 color [[user(locn0)]]; - float4 gl_Position [[position]]; - float gl_PointSize [[point_size]]; -}; - -vertex main0_out main0(main0_in in [[stage_in]], constant params& _19 [[buffer(0)]]) -{ - main0_out out = {}; - out.gl_Position = _19.mvp * in.position; - out.gl_PointSize = _19.psize; - out.color = in.color0; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/texture_buffer.vert b/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/texture_buffer.vert deleted file mode 100644 index 690757b830..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/texture_buffer.vert +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_out -{ - float4 gl_Position [[position]]; -}; - -vertex main0_out main0(texture2d uSamp [[texture(0)]], texture2d uSampo [[texture(1)]]) -{ - main0_out out = {}; - out.gl_Position = uSamp.read(uint2(10, 0)) + uSampo.read(uint2(100, 0)); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/ubo.alignment.vert b/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/ubo.alignment.vert deleted file mode 100644 index 6e48ae0e42..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/ubo.alignment.vert +++ /dev/null @@ -1,38 +0,0 @@ -#include -#include - -using namespace metal; - -struct UBO -{ - float4x4 mvp; - float2 targSize; - char pad2[8]; - packed_float3 color; - float opacity; -}; - -struct main0_in -{ - float3 aNormal [[attribute(1)]]; - float4 aVertex [[attribute(0)]]; -}; - -struct main0_out -{ - float3 vNormal [[user(locn0)]]; - float3 vColor [[user(locn1)]]; - float2 vSize [[user(locn2)]]; - float4 gl_Position [[position]]; -}; - -vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _18 [[buffer(0)]]) -{ - main0_out out = {}; - out.gl_Position = _18.mvp * in.aVertex; - out.vNormal = in.aNormal; - out.vColor = _18.color * _18.opacity; - out.vSize = _18.targSize * _18.opacity; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/ubo.vert b/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/ubo.vert deleted file mode 100644 index 4a1adcd7f6..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/ubo.vert +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -using namespace metal; - -struct UBO -{ - float4x4 mvp; -}; - -struct main0_in -{ - float3 aNormal [[attribute(1)]]; - float4 aVertex [[attribute(0)]]; -}; - -struct main0_out -{ - float3 vNormal [[user(locn0)]]; - float4 gl_Position [[position]]; -}; - -vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _16 [[buffer(0)]]) -{ - main0_out out = {}; - out.gl_Position = _16.mvp * in.aVertex; - out.vNormal = in.aNormal; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/vulkan/frag/push-constant.vk.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/vulkan/frag/push-constant.vk.frag deleted file mode 100644 index bc97e3cc51..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/vulkan/frag/push-constant.vk.frag +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include - -using namespace metal; - -struct PushConstants -{ - float4 value0; - float4 value1; -}; - -struct main0_in -{ - float4 vColor [[user(locn0)]]; -}; - -struct main0_out -{ - float4 FragColor [[color(0)]]; -}; - -fragment main0_out main0(main0_in in [[stage_in]], constant PushConstants& push [[buffer(0)]]) -{ - main0_out out = {}; - out.FragColor = (in.vColor + push.value0) + push.value1; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/vulkan/frag/spec-constant.vk.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/vulkan/frag/spec-constant.vk.frag deleted file mode 100644 index aee290f5a2..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/vulkan/frag/spec-constant.vk.frag +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -using namespace metal; - -constant float a_tmp [[function_constant(1)]]; -constant float a = is_function_constant_defined(a_tmp) ? a_tmp : 1.0; -constant float b_tmp [[function_constant(2)]]; -constant float b = is_function_constant_defined(b_tmp) ? b_tmp : 2.0; - -struct main0_out -{ - float4 FragColor [[color(0)]]; -}; - -fragment main0_out main0() -{ - main0_out out = {}; - out.FragColor = float4(a + b); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/vulkan/vert/vulkan-vertex.vk.vert b/deps/SPIRV-Cross/reference/opt/shaders-msl/vulkan/vert/vulkan-vertex.vk.vert deleted file mode 100644 index 53e26e4a8e..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/vulkan/vert/vulkan-vertex.vk.vert +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_out -{ - float4 gl_Position [[position]]; -}; - -vertex main0_out main0(uint gl_VertexIndex [[vertex_id]], uint gl_InstanceIndex [[instance_id]]) -{ - main0_out out = {}; - out.gl_Position = float4(1.0, 2.0, 3.0, 4.0) * float(gl_VertexIndex + gl_InstanceIndex); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag b/deps/SPIRV-Cross/reference/opt/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag deleted file mode 100644 index d670898481..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag +++ /dev/null @@ -1,11 +0,0 @@ -#version 450 -#extension GL_AMD_shader_fragment_mask : require - -layout(binding = 0) uniform sampler2DMS t; - -void main() -{ - vec4 test2 = fragmentFetchAMD(t, 4u); - uint testi2 = fragmentMaskFetchAMD(t); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag.vk b/deps/SPIRV-Cross/reference/opt/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag.vk deleted file mode 100644 index 4aaf397a0f..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag.vk +++ /dev/null @@ -1,11 +0,0 @@ -#version 450 -#extension GL_AMD_shader_fragment_mask : require - -layout(input_attachment_index = 0, set = 0, binding = 0) uniform subpassInputMS t; - -void main() -{ - vec4 test2 = fragmentFetchAMD(t, 4u); - uint testi2 = fragmentMaskFetchAMD(t); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/amd/fs.invalid.frag b/deps/SPIRV-Cross/reference/opt/shaders/amd/fs.invalid.frag deleted file mode 100644 index 97e7bcd180..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/amd/fs.invalid.frag +++ /dev/null @@ -1,15 +0,0 @@ -#version 450 -#extension GL_AMD_shader_fragment_mask : require -#extension GL_AMD_shader_explicit_vertex_parameter : require - -uniform sampler2DMS texture1; - -layout(location = 0) in vec4 vary; - -void main() -{ - uint testi1 = fragmentMaskFetchAMD(texture1, ivec2(0)); - vec4 test1 = fragmentFetchAMD(texture1, ivec2(1), 2u); - vec4 pos = interpolateAtVertexAMD(vary, 0u); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/amd/gcn_shader.comp b/deps/SPIRV-Cross/reference/opt/shaders/amd/gcn_shader.comp deleted file mode 100644 index 85851de5f9..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/amd/gcn_shader.comp +++ /dev/null @@ -1,8 +0,0 @@ -#version 450 -#extension GL_ARB_gpu_shader_int64 : require -layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; - -void main() -{ -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/amd/shader_ballot.comp b/deps/SPIRV-Cross/reference/opt/shaders/amd/shader_ballot.comp deleted file mode 100644 index 8bdbfc9c0d..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/amd/shader_ballot.comp +++ /dev/null @@ -1,26 +0,0 @@ -#version 450 -#extension GL_ARB_gpu_shader_int64 : require -#extension GL_ARB_shader_ballot : require -#extension GL_AMD_shader_ballot : require -layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) buffer inputData -{ - float inputDataArray[]; -} _12; - -layout(binding = 1, std430) buffer outputData -{ - float outputDataArray[]; -} _74; - -void main() -{ - float _25 = _12.inputDataArray[gl_LocalInvocationID.x]; - bool _31 = _25 > 0.0; - if (_31) - { - _74.outputDataArray[mbcntAMD(packUint2x32(uvec2(unpackUint2x32(ballotARB(_31)).xy)))] = _25; - } -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/amd/shader_ballot_nonuniform_invocations.invalid.comp b/deps/SPIRV-Cross/reference/opt/shaders/amd/shader_ballot_nonuniform_invocations.invalid.comp deleted file mode 100644 index a14343ae12..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/amd/shader_ballot_nonuniform_invocations.invalid.comp +++ /dev/null @@ -1,11 +0,0 @@ -#version 450 -#extension GL_AMD_shader_ballot : require -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -void main() -{ - float addInvocations = addInvocationsNonUniformAMD(0.0); - int minInvocations = minInvocationsNonUniformAMD(1); - uint maxInvocations = uint(maxInvocationsNonUniformAMD(4)); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/amd/shader_group_vote.comp b/deps/SPIRV-Cross/reference/opt/shaders/amd/shader_group_vote.comp deleted file mode 100644 index 77ea03495f..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/amd/shader_group_vote.comp +++ /dev/null @@ -1,7 +0,0 @@ -#version 450 -layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; - -void main() -{ -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/amd/shader_trinary_minmax.comp b/deps/SPIRV-Cross/reference/opt/shaders/amd/shader_trinary_minmax.comp deleted file mode 100644 index 77ea03495f..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/amd/shader_trinary_minmax.comp +++ /dev/null @@ -1,7 +0,0 @@ -#version 450 -layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; - -void main() -{ -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/bitcast_iadd.asm.comp b/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/bitcast_iadd.asm.comp deleted file mode 100644 index bed2dffccb..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/bitcast_iadd.asm.comp +++ /dev/null @@ -1,27 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) restrict buffer _3_5 -{ - ivec4 _m0; - uvec4 _m1; -} _5; - -layout(binding = 1, std430) restrict buffer _4_6 -{ - uvec4 _m0; - ivec4 _m1; -} _6; - -void main() -{ - _6._m0 = _5._m1 + uvec4(_5._m0); - _6._m0 = uvec4(_5._m0) + _5._m1; - _6._m0 = _5._m1 + _5._m1; - _6._m0 = uvec4(_5._m0 + _5._m0); - _6._m1 = ivec4(_5._m1 + _5._m1); - _6._m1 = _5._m0 + _5._m0; - _6._m1 = ivec4(_5._m1) + _5._m0; - _6._m1 = _5._m0 + ivec4(_5._m1); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/bitcast_iequal.asm.comp b/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/bitcast_iequal.asm.comp deleted file mode 100644 index 79398b404b..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/bitcast_iequal.asm.comp +++ /dev/null @@ -1,31 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) buffer _3_5 -{ - ivec4 _m0; - uvec4 _m1; -} _5; - -layout(binding = 1, std430) buffer _4_6 -{ - uvec4 _m0; - ivec4 _m1; -} _6; - -void main() -{ - bvec4 _34 = equal(ivec4(_5._m1), _5._m0); - bvec4 _35 = equal(_5._m0, ivec4(_5._m1)); - bvec4 _36 = equal(_5._m1, _5._m1); - bvec4 _37 = equal(_5._m0, _5._m0); - _6._m0 = mix(uvec4(0u), uvec4(1u), _34); - _6._m0 = mix(uvec4(0u), uvec4(1u), _35); - _6._m0 = mix(uvec4(0u), uvec4(1u), _36); - _6._m0 = mix(uvec4(0u), uvec4(1u), _37); - _6._m1 = mix(ivec4(0), ivec4(1), _34); - _6._m1 = mix(ivec4(0), ivec4(1), _35); - _6._m1 = mix(ivec4(0), ivec4(1), _36); - _6._m1 = mix(ivec4(0), ivec4(1), _37); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/bitcast_sar.asm.comp b/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/bitcast_sar.asm.comp deleted file mode 100644 index 42a4ed0233..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/bitcast_sar.asm.comp +++ /dev/null @@ -1,27 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) buffer _3_5 -{ - ivec4 _m0; - uvec4 _m1; -} _5; - -layout(binding = 1, std430) buffer _4_6 -{ - uvec4 _m0; - ivec4 _m1; -} _6; - -void main() -{ - _6._m0 = uvec4(ivec4(_5._m1) >> _5._m0); - _6._m0 = uvec4(_5._m0 >> ivec4(_5._m1)); - _6._m0 = uvec4(ivec4(_5._m1) >> ivec4(_5._m1)); - _6._m0 = uvec4(_5._m0 >> _5._m0); - _6._m1 = ivec4(_5._m1) >> ivec4(_5._m1); - _6._m1 = _5._m0 >> _5._m0; - _6._m1 = ivec4(_5._m1) >> _5._m0; - _6._m1 = _5._m0 >> ivec4(_5._m1); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/bitcast_sdiv.asm.comp b/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/bitcast_sdiv.asm.comp deleted file mode 100644 index eeb97e14a2..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/bitcast_sdiv.asm.comp +++ /dev/null @@ -1,27 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) buffer _3_5 -{ - ivec4 _m0; - uvec4 _m1; -} _5; - -layout(binding = 1, std430) buffer _4_6 -{ - uvec4 _m0; - ivec4 _m1; -} _6; - -void main() -{ - _6._m0 = uvec4(ivec4(_5._m1) / _5._m0); - _6._m0 = uvec4(_5._m0 / ivec4(_5._m1)); - _6._m0 = uvec4(ivec4(_5._m1) / ivec4(_5._m1)); - _6._m0 = uvec4(_5._m0 / _5._m0); - _6._m1 = ivec4(_5._m1) / ivec4(_5._m1); - _6._m1 = _5._m0 / _5._m0; - _6._m1 = ivec4(_5._m1) / _5._m0; - _6._m1 = _5._m0 / ivec4(_5._m1); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/bitcast_slr.asm.comp b/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/bitcast_slr.asm.comp deleted file mode 100644 index 25245e63eb..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/bitcast_slr.asm.comp +++ /dev/null @@ -1,27 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) buffer _3_5 -{ - ivec4 _m0; - uvec4 _m1; -} _5; - -layout(binding = 1, std430) buffer _4_6 -{ - uvec4 _m0; - ivec4 _m1; -} _6; - -void main() -{ - _6._m0 = _5._m1 >> uvec4(_5._m0); - _6._m0 = uvec4(_5._m0) >> _5._m1; - _6._m0 = _5._m1 >> _5._m1; - _6._m0 = uvec4(_5._m0) >> uvec4(_5._m0); - _6._m1 = ivec4(_5._m1 >> _5._m1); - _6._m1 = ivec4(uvec4(_5._m0) >> uvec4(_5._m0)); - _6._m1 = ivec4(_5._m1 >> uvec4(_5._m0)); - _6._m1 = ivec4(uvec4(_5._m0) >> _5._m1); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/logical.asm.comp b/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/logical.asm.comp deleted file mode 100644 index 124652b322..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/logical.asm.comp +++ /dev/null @@ -1,7 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -void main() -{ -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/multiple-entry.asm.comp b/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/multiple-entry.asm.comp deleted file mode 100644 index 6418464f19..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/multiple-entry.asm.comp +++ /dev/null @@ -1,27 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) restrict buffer _6_8 -{ - ivec4 _m0; - uvec4 _m1; -} _8; - -layout(binding = 1, std430) restrict buffer _7_9 -{ - uvec4 _m0; - ivec4 _m1; -} _9; - -void main() -{ - _9._m0 = _8._m1 + uvec4(_8._m0); - _9._m0 = uvec4(_8._m0) + _8._m1; - _9._m0 = _8._m1 + _8._m1; - _9._m0 = uvec4(_8._m0 + _8._m0); - _9._m1 = ivec4(_8._m1 + _8._m1); - _9._m1 = _8._m0 + _8._m0; - _9._m1 = ivec4(_8._m1) + _8._m0; - _9._m1 = _8._m0 + ivec4(_8._m1); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/name-alias.asm.invalid.comp b/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/name-alias.asm.invalid.comp deleted file mode 100644 index 870b1df98d..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/name-alias.asm.invalid.comp +++ /dev/null @@ -1,37 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -struct alias -{ - vec3 alias[100]; -}; - -struct alias_1 -{ - vec4 alias; - vec2 alias_1[10]; - alias alias_2[2]; -}; - -struct alias_2 -{ - vec4 alias; - alias_1 alias_1; -}; - -layout(binding = 0, std430) buffer alias_3 -{ - alias_2 alias; -} alias_4; - -layout(binding = 1, std140) buffer alias_5 -{ - alias_2 alias; -} alias_6; - -void main() -{ - alias_2 alias_7 = alias_4.alias; - alias_6.alias = alias_7; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/quantize.asm.comp b/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/quantize.asm.comp deleted file mode 100644 index c089213800..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/quantize.asm.comp +++ /dev/null @@ -1,19 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) buffer SSBO0 -{ - float scalar; - vec2 vec2_val; - vec3 vec3_val; - vec4 vec4_val; -} _4; - -void main() -{ - _4.scalar = unpackHalf2x16(packHalf2x16(vec2(_4.scalar))).x; - _4.vec2_val = unpackHalf2x16(packHalf2x16(_4.vec2_val)); - _4.vec3_val = vec3(unpackHalf2x16(packHalf2x16(_4.vec3_val.xy)), unpackHalf2x16(packHalf2x16(_4.vec3_val.zz)).x); - _4.vec4_val = vec4(unpackHalf2x16(packHalf2x16(_4.vec4_val.xy)), unpackHalf2x16(packHalf2x16(_4.vec4_val.zw))); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/specialization-constant-workgroup.asm.comp b/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/specialization-constant-workgroup.asm.comp deleted file mode 100644 index 1b2285a8da..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/specialization-constant-workgroup.asm.comp +++ /dev/null @@ -1,13 +0,0 @@ -#version 310 es -layout(local_size_x = 9, local_size_y = 20, local_size_z = 4) in; - -layout(binding = 0, std430) buffer SSBO -{ - float a; -} _4; - -void main() -{ - _4.a += 1.0; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/storage-buffer-basic.asm.comp b/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/storage-buffer-basic.asm.comp deleted file mode 100644 index 3de823fb10..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/storage-buffer-basic.asm.comp +++ /dev/null @@ -1,18 +0,0 @@ -#version 450 -layout(local_size_x = 1, local_size_y = 2, local_size_z = 3) in; - -layout(binding = 0, std430) buffer _6_8 -{ - float _m0[]; -} _8; - -layout(binding = 1, std430) buffer _6_9 -{ - float _m0[]; -} _9; - -void main() -{ - _8._m0[gl_WorkGroupID.x] = _9._m0[gl_WorkGroupID.x] + _8._m0[gl_WorkGroupID.x]; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/composite-construct-struct-no-swizzle.asm.frag b/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/composite-construct-struct-no-swizzle.asm.frag deleted file mode 100644 index 23af17026c..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/composite-construct-struct-no-swizzle.asm.frag +++ /dev/null @@ -1,18 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -struct SwizzleTest -{ - float a; - float b; -}; - -layout(location = 0) in vec2 foo; -layout(location = 0) out float FooOut; - -void main() -{ - FooOut = foo.x + foo.y; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/default-member-names.asm.frag b/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/default-member-names.asm.frag deleted file mode 100644 index 2cf68fd201..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/default-member-names.asm.frag +++ /dev/null @@ -1,33 +0,0 @@ -#version 450 - -struct _9 -{ - float _m0; -}; - -struct _10 -{ - float _m0; - float _m1; - float _m2; - float _m3; - float _m4; - float _m5; - float _m6; - float _m7; - float _m8; - float _m9; - float _m10; - float _m11; - _9 _m12; -}; - -layout(location = 0) out vec4 _3; - -_10 _51; - -void main() -{ - _3 = vec4(_51._m0, _51._m1, _51._m2, _51._m3); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/hlsl-sample-cmp-level-zero-cube.asm.frag b/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/hlsl-sample-cmp-level-zero-cube.asm.frag deleted file mode 100644 index 924b6f656c..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/hlsl-sample-cmp-level-zero-cube.asm.frag +++ /dev/null @@ -1,11 +0,0 @@ -#version 450 - -uniform samplerCubeShadow SPIRV_Cross_CombinedpointLightShadowMapshadowSamplerPCF; - -layout(location = 0) out float _entryPointOutput; - -void main() -{ - _entryPointOutput = textureGrad(SPIRV_Cross_CombinedpointLightShadowMapshadowSamplerPCF, vec4(vec4(0.100000001490116119384765625, 0.100000001490116119384765625, 0.100000001490116119384765625, 0.5).xyz, 0.5), vec3(0.0), vec3(0.0)); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/hlsl-sample-cmp-level-zero.asm.frag b/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/hlsl-sample-cmp-level-zero.asm.frag deleted file mode 100644 index c4e3704e52..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/hlsl-sample-cmp-level-zero.asm.frag +++ /dev/null @@ -1,14 +0,0 @@ -#version 450 - -uniform sampler2DArrayShadow SPIRV_Cross_CombinedShadowMapShadowSamplerPCF; - -layout(location = 0) in vec2 texCoords; -layout(location = 1) in float cascadeIndex; -layout(location = 2) in float fragDepth; -layout(location = 0) out vec4 _entryPointOutput; - -void main() -{ - _entryPointOutput = vec4(textureGrad(SPIRV_Cross_CombinedShadowMapShadowSamplerPCF, vec4(vec4(texCoords, cascadeIndex, fragDepth).xyz, fragDepth), vec2(0.0), vec2(0.0))); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag b/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag deleted file mode 100644 index 98116cfdc7..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag +++ /dev/null @@ -1,227 +0,0 @@ -#version 450 - -struct VertexOutput -{ - vec4 HPosition; - vec4 Uv_EdgeDistance1; - vec4 UvStuds_EdgeDistance2; - vec4 Color; - vec4 LightPosition_Fog; - vec4 View_Depth; - vec4 Normal_SpecPower; - vec3 Tangent; - vec4 PosLightSpace_Reflectance; - float studIndex; -}; - -struct Surface -{ - vec3 albedo; - vec3 normal; - float specular; - float gloss; - float reflectance; - float opacity; -}; - -struct SurfaceInput -{ - vec4 Color; - vec2 Uv; - vec2 UvStuds; -}; - -struct Globals -{ - mat4 ViewProjection; - vec4 ViewRight; - vec4 ViewUp; - vec4 ViewDir; - vec3 CameraPosition; - vec3 AmbientColor; - vec3 Lamp0Color; - vec3 Lamp0Dir; - vec3 Lamp1Color; - vec4 FogParams; - vec3 FogColor; - vec4 LightBorder; - vec4 LightConfig0; - vec4 LightConfig1; - vec4 LightConfig2; - vec4 LightConfig3; - vec4 RefractionBias_FadeDistance_GlowFactor; - vec4 OutlineBrightness_ShadowInfo; - vec4 ShadowMatrix0; - vec4 ShadowMatrix1; - vec4 ShadowMatrix2; -}; - -struct Params -{ - vec4 LqmatFarTilingFactor; -}; - -layout(binding = 0, std140) uniform CB0 -{ - Globals CB0; -} _19; - -uniform sampler2D SPIRV_Cross_CombinedDiffuseMapTextureDiffuseMapSampler; -uniform sampler2D SPIRV_Cross_CombinedNormalMapTextureNormalMapSampler; -uniform sampler2D SPIRV_Cross_CombinedNormalDetailMapTextureNormalDetailMapSampler; -uniform sampler2D SPIRV_Cross_CombinedStudsMapTextureStudsMapSampler; -uniform sampler2D SPIRV_Cross_CombinedSpecularMapTextureSpecularMapSampler; -uniform sampler3D SPIRV_Cross_CombinedLightMapTextureLightMapSampler; -uniform sampler2D SPIRV_Cross_CombinedShadowMapTextureShadowMapSampler; -uniform samplerCube SPIRV_Cross_CombinedEnvironmentMapTextureEnvironmentMapSampler; - -layout(location = 0) in vec4 IN_Uv_EdgeDistance1; -layout(location = 1) in vec4 IN_UvStuds_EdgeDistance2; -layout(location = 2) in vec4 IN_Color; -layout(location = 3) in vec4 IN_LightPosition_Fog; -layout(location = 4) in vec4 IN_View_Depth; -layout(location = 5) in vec4 IN_Normal_SpecPower; -layout(location = 6) in vec3 IN_Tangent; -layout(location = 7) in vec4 IN_PosLightSpace_Reflectance; -layout(location = 8) in float IN_studIndex; -layout(location = 0) out vec4 _entryPointOutput; - -VertexOutput _121; -SurfaceInput _122; -vec2 _123; -vec4 _124; -Surface _125; -vec4 _192; -vec4 _219; -vec4 _297; - -void main() -{ - VertexOutput _128 = _121; - _128.HPosition = gl_FragCoord; - VertexOutput _130 = _128; - _130.Uv_EdgeDistance1 = IN_Uv_EdgeDistance1; - VertexOutput _132 = _130; - _132.UvStuds_EdgeDistance2 = IN_UvStuds_EdgeDistance2; - VertexOutput _134 = _132; - _134.Color = IN_Color; - VertexOutput _136 = _134; - _136.LightPosition_Fog = IN_LightPosition_Fog; - VertexOutput _138 = _136; - _138.View_Depth = IN_View_Depth; - VertexOutput _140 = _138; - _140.Normal_SpecPower = IN_Normal_SpecPower; - VertexOutput _142 = _140; - _142.Tangent = IN_Tangent; - VertexOutput _144 = _142; - _144.PosLightSpace_Reflectance = IN_PosLightSpace_Reflectance; - VertexOutput _146 = _144; - _146.studIndex = IN_studIndex; - SurfaceInput _147 = _122; - _147.Color = IN_Color; - SurfaceInput _149 = _147; - _149.Uv = IN_Uv_EdgeDistance1.xy; - SurfaceInput _151 = _149; - _151.UvStuds = IN_UvStuds_EdgeDistance2.xy; - SurfaceInput _156 = _151; - _156.UvStuds.y = (fract(_151.UvStuds.y) + IN_studIndex) * 0.25; - float _163 = _146.View_Depth.w * _19.CB0.RefractionBias_FadeDistance_GlowFactor.y; - float _165 = clamp(1.0 - _163, 0.0, 1.0); - vec2 _166 = IN_Uv_EdgeDistance1.xy * 1.0; - bool _173; - vec4 _193; - do - { - _173 = 0.0 == 0.0; - if (_173) - { - _193 = texture(SPIRV_Cross_CombinedDiffuseMapTextureDiffuseMapSampler, _166); - break; - } - else - { - float _180 = 1.0 / (1.0 - 0.0); - _193 = mix(texture(SPIRV_Cross_CombinedDiffuseMapTextureDiffuseMapSampler, _166 * 0.25), texture(SPIRV_Cross_CombinedDiffuseMapTextureDiffuseMapSampler, _166), vec4(clamp((clamp(1.0 - (_146.View_Depth.w * 0.00333332992158830165863037109375), 0.0, 1.0) * _180) - (0.0 * _180), 0.0, 1.0))); - break; - } - _193 = _192; - break; - } while (false); - vec4 _220; - do - { - if (_173) - { - _220 = texture(SPIRV_Cross_CombinedNormalMapTextureNormalMapSampler, _166); - break; - } - else - { - float _207 = 1.0 / (1.0 - 0.0); - _220 = mix(texture(SPIRV_Cross_CombinedNormalMapTextureNormalMapSampler, _166 * 0.25), texture(SPIRV_Cross_CombinedNormalMapTextureNormalMapSampler, _166), vec4(clamp((_165 * _207) - (0.0 * _207), 0.0, 1.0))); - break; - } - _220 = _219; - break; - } while (false); - vec2 _223 = vec2(1.0); - vec2 _224 = (_220.wy * 2.0) - _223; - vec3 _232 = vec3(_224, sqrt(clamp(1.0 + dot(-_224, _224), 0.0, 1.0))); - vec2 _240 = (texture(SPIRV_Cross_CombinedNormalDetailMapTextureNormalDetailMapSampler, _166 * 0.0).wy * 2.0) - _223; - vec2 _252 = _232.xy + (vec3(_240, sqrt(clamp(1.0 + dot(-_240, _240), 0.0, 1.0))).xy * 0.0); - vec3 _253 = vec3(_252.x, _252.y, _232.z); - vec2 _255 = _253.xy * _165; - vec3 _256 = vec3(_255.x, _255.y, _253.z); - vec3 _271 = ((IN_Color.xyz * (_193 * 1.0).xyz) * (1.0 + (_256.x * 0.300000011920928955078125))) * (texture(SPIRV_Cross_CombinedStudsMapTextureStudsMapSampler, _156.UvStuds).x * 2.0); - vec4 _298; - do - { - if (0.75 == 0.0) - { - _298 = texture(SPIRV_Cross_CombinedSpecularMapTextureSpecularMapSampler, _166); - break; - } - else - { - float _285 = 1.0 / (1.0 - 0.75); - _298 = mix(texture(SPIRV_Cross_CombinedSpecularMapTextureSpecularMapSampler, _166 * 0.25), texture(SPIRV_Cross_CombinedSpecularMapTextureSpecularMapSampler, _166), vec4(clamp((_165 * _285) - (0.75 * _285), 0.0, 1.0))); - break; - } - _298 = _297; - break; - } while (false); - vec2 _303 = mix(vec2(0.800000011920928955078125, 120.0), (_298.xy * vec2(2.0, 256.0)) + vec2(0.0, 0.00999999977648258209228515625), vec2(_165)); - Surface _304 = _125; - _304.albedo = _271; - Surface _305 = _304; - _305.normal = _256; - float _306 = _303.x; - Surface _307 = _305; - _307.specular = _306; - float _308 = _303.y; - Surface _309 = _307; - _309.gloss = _308; - float _312 = (_298.xy.y * _165) * 0.0; - Surface _313 = _309; - _313.reflectance = _312; - vec4 _318 = vec4(_271, _146.Color.w); - vec3 _329 = normalize(((IN_Tangent * _313.normal.x) + (cross(IN_Normal_SpecPower.xyz, IN_Tangent) * _313.normal.y)) + (IN_Normal_SpecPower.xyz * _313.normal.z)); - vec3 _332 = -_19.CB0.Lamp0Dir; - float _333 = dot(_329, _332); - float _357 = clamp(dot(step(_19.CB0.LightConfig3.xyz, abs(IN_LightPosition_Fog.xyz - _19.CB0.LightConfig2.xyz)), vec3(1.0)), 0.0, 1.0); - vec4 _368 = mix(texture(SPIRV_Cross_CombinedLightMapTextureLightMapSampler, IN_LightPosition_Fog.xyz.yzx - (IN_LightPosition_Fog.xyz.yzx * _357)), _19.CB0.LightBorder, vec4(_357)); - vec2 _376 = texture(SPIRV_Cross_CombinedShadowMapTextureShadowMapSampler, IN_PosLightSpace_Reflectance.xyz.xy).xy; - float _392 = (1.0 - (((step(_376.x, IN_PosLightSpace_Reflectance.xyz.z) * clamp(9.0 - (20.0 * abs(IN_PosLightSpace_Reflectance.xyz.z - 0.5)), 0.0, 1.0)) * _376.y) * _19.CB0.OutlineBrightness_ShadowInfo.w)) * _368.w; - vec3 _403 = mix(_318.xyz, texture(SPIRV_Cross_CombinedEnvironmentMapTextureEnvironmentMapSampler, reflect(-IN_View_Depth.xyz, _329)).xyz, vec3(_312)); - vec4 _404 = vec4(_403.x, _403.y, _403.z, _318.w); - vec3 _422 = (((_19.CB0.AmbientColor + (((_19.CB0.Lamp0Color * clamp(_333, 0.0, 1.0)) + (_19.CB0.Lamp1Color * max(-_333, 0.0))) * _392)) + _368.xyz) * _404.xyz) + (_19.CB0.Lamp0Color * (((step(0.0, _333) * _306) * _392) * pow(clamp(dot(_329, normalize(_332 + normalize(IN_View_Depth.xyz))), 0.0, 1.0), _308))); - vec4 _425 = vec4(_422.x, _422.y, _422.z, _124.w); - _425.w = _404.w; - vec2 _435 = min(IN_Uv_EdgeDistance1.wz, IN_UvStuds_EdgeDistance2.wz); - float _439 = min(_435.x, _435.y) / _163; - vec3 _445 = _425.xyz * clamp((clamp((_163 * _19.CB0.OutlineBrightness_ShadowInfo.x) + _19.CB0.OutlineBrightness_ShadowInfo.y, 0.0, 1.0) * (1.5 - _439)) + _439, 0.0, 1.0); - vec4 _446 = vec4(_445.x, _445.y, _445.z, _425.w); - vec3 _453 = mix(_19.CB0.FogColor, _446.xyz, vec3(clamp(_146.LightPosition_Fog.w, 0.0, 1.0))); - _entryPointOutput = vec4(_453.x, _453.y, _453.z, _446.w); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/invalidation.asm.frag b/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/invalidation.asm.frag deleted file mode 100644 index c0dc7b682b..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/invalidation.asm.frag +++ /dev/null @@ -1,11 +0,0 @@ -#version 450 - -layout(location = 0) in float v0; -layout(location = 1) in float v1; -layout(location = 0) out float FragColor; - -void main() -{ - FragColor = (v0 + v1) * v1; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag b/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag deleted file mode 100644 index 4fb4b75740..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag +++ /dev/null @@ -1,52 +0,0 @@ -#version 450 - -layout(binding = 0, std140) uniform Foo -{ - layout(row_major) mat4 lightVP[64]; - uint shadowCascadesNum; - int test; -} _11; - -layout(location = 0) in vec3 fragWorld; -layout(location = 0) out int _entryPointOutput; - -mat4 _152; -uint _155; - -int GetCascade(vec3 fragWorldPosition) -{ - mat4 _153; - _153 = _152; - uint _156; - mat4 _157; - for (uint _151 = 0u; _151 < _11.shadowCascadesNum; _151 = _156 + uint(1), _153 = _157) - { - mat4 _154; - _154 = _153; - for (;;) - { - if (_11.test == 0) - { - _156 = _151; - _157 = mat4(vec4(0.5, 0.0, 0.0, 0.0), vec4(0.0, 0.5, 0.0, 0.0), vec4(0.0, 0.0, 0.5, 0.0), vec4(0.0, 0.0, 0.0, 1.0)); - break; - } - _156 = _151; - _157 = mat4(vec4(1.0, 0.0, 0.0, 0.0), vec4(0.0, 1.0, 0.0, 0.0), vec4(0.0, 0.0, 1.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0)); - break; - } - vec4 _92 = (_157 * _11.lightVP[_156]) * vec4(fragWorldPosition, 1.0); - if ((((_92.z >= 0.0) && (_92.z <= 1.0)) && (max(_92.x, _92.y) <= 1.0)) && (min(_92.x, _92.y) >= 0.0)) - { - return int(_156); - } - } - return -1; -} - -void main() -{ - vec3 _123 = fragWorld; - _entryPointOutput = GetCascade(_123); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/multi-for-loop-init.asm.frag b/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/multi-for-loop-init.asm.frag deleted file mode 100644 index c41c77c701..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/multi-for-loop-init.asm.frag +++ /dev/null @@ -1,19 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(location = 0) out vec4 FragColor; -layout(location = 0) flat in mediump int counter; - -void main() -{ - FragColor = vec4(0.0); - int _53 = 0; - uint _54 = 1u; - for (; (_53 < 10) && (int(_54) < int(20u)); _53 += counter, _54 += uint(counter)) - { - FragColor += vec4(float(_53)); - FragColor += vec4(float(_54)); - } -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/op-constant-null.asm.frag b/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/op-constant-null.asm.frag deleted file mode 100644 index cb882cd7b1..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/op-constant-null.asm.frag +++ /dev/null @@ -1,17 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -struct D -{ - vec4 a; - float b; -}; - -layout(location = 0) out float FragColor; - -void main() -{ - FragColor = 0.0; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/phi-loop-variable.asm.frag b/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/phi-loop-variable.asm.frag deleted file mode 100644 index 786ac74de5..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/phi-loop-variable.asm.frag +++ /dev/null @@ -1,9 +0,0 @@ -#version 450 - -void main() -{ - for (int _22 = 35; _22 >= 0; _22--) - { - } -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/sampler-buffer-without-sampler.asm.frag b/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/sampler-buffer-without-sampler.asm.frag deleted file mode 100644 index 560a4e79b9..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/sampler-buffer-without-sampler.asm.frag +++ /dev/null @@ -1,13 +0,0 @@ -#version 450 - -layout(rgba32f) uniform writeonly imageBuffer RWTex; -uniform samplerBuffer Tex; - -layout(location = 0) out vec4 _entryPointOutput; - -void main() -{ - imageStore(RWTex, 20, vec4(1.0, 2.0, 3.0, 4.0)); - _entryPointOutput = texelFetch(Tex, 10); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/struct-composite-extract-swizzle.asm.frag b/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/struct-composite-extract-swizzle.asm.frag deleted file mode 100644 index b2473f4d03..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/struct-composite-extract-swizzle.asm.frag +++ /dev/null @@ -1,21 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -struct Foo -{ - float var1; - float var2; -}; - -layout(binding = 0) uniform mediump sampler2D uSampler; - -layout(location = 0) out vec4 FragColor; - -Foo _22; - -void main() -{ - FragColor = texture(uSampler, vec2(_22.var1, _22.var2)); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/temporary-phi-hoisting.asm.frag b/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/temporary-phi-hoisting.asm.frag deleted file mode 100644 index 3917594d98..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/temporary-phi-hoisting.asm.frag +++ /dev/null @@ -1,26 +0,0 @@ -#version 450 - -struct MyStruct -{ - vec4 color; -}; - -layout(std140) uniform MyStruct_CB -{ - MyStruct g_MyStruct[4]; -} _6; - -layout(location = 0) out vec4 _entryPointOutput; - -void main() -{ - vec3 _28; - _28 = vec3(0.0); - vec3 _29; - for (int _31 = 0; _31 < 4; _28 = _29, _31++) - { - _29 = _28 + _6.g_MyStruct[_31].color.xyz; - } - _entryPointOutput = vec4(_28, 1.0); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/undef-variable-store.asm.frag b/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/undef-variable-store.asm.frag deleted file mode 100644 index 23576ed850..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/undef-variable-store.asm.frag +++ /dev/null @@ -1,30 +0,0 @@ -#version 450 - -layout(location = 0) out vec4 _entryPointOutput; - -vec4 _38; -vec4 _50; - -void main() -{ - vec4 _51; - _51 = _50; - vec4 _52; - for (;;) - { - if (0.0 != 0.0) - { - _52 = vec4(1.0, 0.0, 0.0, 1.0); - break; - } - else - { - _52 = vec4(1.0, 1.0, 0.0, 1.0); - break; - } - _52 = _38; - break; - } - _entryPointOutput = _52; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/unreachable.asm.frag b/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/unreachable.asm.frag deleted file mode 100644 index d8126d752e..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/unreachable.asm.frag +++ /dev/null @@ -1,26 +0,0 @@ -#version 450 - -layout(location = 0) flat in int counter; -layout(location = 0) out vec4 FragColor; - -vec4 _21; - -void main() -{ - vec4 _33; - do - { - if (counter == 10) - { - _33 = vec4(10.0); - break; - } - else - { - _33 = vec4(30.0); - break; - } - } while (false); - FragColor = _33; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/vector-shuffle-oom.asm.frag b/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/vector-shuffle-oom.asm.frag deleted file mode 100644 index 1c211caa6d..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/vector-shuffle-oom.asm.frag +++ /dev/null @@ -1,316 +0,0 @@ -#version 450 - -struct _28 -{ - vec4 _m0; -}; - -layout(binding = 0, std140) uniform _6_7 -{ - vec4 _m0; - float _m1; - vec4 _m2; -} _7; - -layout(binding = 2, std140) uniform _10_11 -{ - vec3 _m0; - vec3 _m1; - float _m2; - vec3 _m3; - float _m4; - vec3 _m5; - float _m6; - vec3 _m7; - float _m8; - vec3 _m9; - float _m10; - vec3 _m11; - float _m12; - vec2 _m13; - vec2 _m14; - vec3 _m15; - float _m16; - float _m17; - float _m18; - float _m19; - float _m20; - vec4 _m21; - vec4 _m22; - layout(row_major) mat4 _m23; - vec4 _m24; -} _11; - -layout(binding = 1, std140) uniform _18_19 -{ - layout(row_major) mat4 _m0; - layout(row_major) mat4 _m1; - layout(row_major) mat4 _m2; - layout(row_major) mat4 _m3; - vec4 _m4; - vec4 _m5; - float _m6; - float _m7; - float _m8; - float _m9; - vec3 _m10; - float _m11; - vec3 _m12; - float _m13; - vec3 _m14; - float _m15; - vec3 _m16; - float _m17; - float _m18; - float _m19; - vec2 _m20; - vec2 _m21; - vec2 _m22; - vec4 _m23; - vec2 _m24; - vec2 _m25; - vec2 _m26; - vec3 _m27; - float _m28; - float _m29; - float _m30; - float _m31; - float _m32; - vec2 _m33; - float _m34; - float _m35; - vec3 _m36; - layout(row_major) mat4 _m37[2]; - vec4 _m38[2]; -} _19; - -uniform sampler2D SPIRV_Cross_Combined; -uniform sampler2D SPIRV_Cross_Combined_1; -uniform sampler2D SPIRV_Cross_Combined_2; - -layout(location = 0) out vec4 _5; - -_28 _74; - -void main() -{ - _28 _77 = _74; - _77._m0 = vec4(0.0); - vec2 _82 = gl_FragCoord.xy * _19._m23.xy; - vec4 _88 = _7._m2 * _7._m0.xyxy; - vec2 _97 = clamp(_82 + (vec3(0.0, -2.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - vec3 _109 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _97, 0.0).w * _7._m1, 0.0, 1.0); - vec4 _113 = textureLod(SPIRV_Cross_Combined_1, _97, 0.0); - vec3 _129; - if (_113.y > 0.0) - { - _129 = _109 + (textureLod(SPIRV_Cross_Combined_2, _97, 0.0).xyz * clamp(_113.y * _113.z, 0.0, 1.0)); - } - else - { - _129 = _109; - } - vec3 _133 = vec4(0.0).xyz + (_129 * 0.5); - vec4 _134 = vec4(_133.x, _133.y, _133.z, vec4(0.0).w); - _28 _135 = _77; - _135._m0 = _134; - vec2 _144 = clamp(_82 + (vec3(-1.0, -1.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - vec3 _156 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _144, 0.0).w * _7._m1, 0.0, 1.0); - vec4 _160 = textureLod(SPIRV_Cross_Combined_1, _144, 0.0); - vec3 _176; - if (_160.y > 0.0) - { - _176 = _156 + (textureLod(SPIRV_Cross_Combined_2, _144, 0.0).xyz * clamp(_160.y * _160.z, 0.0, 1.0)); - } - else - { - _176 = _156; - } - vec3 _180 = _134.xyz + (_176 * 0.5); - vec4 _181 = vec4(_180.x, _180.y, _180.z, _134.w); - _28 _182 = _135; - _182._m0 = _181; - vec2 _191 = clamp(_82 + (vec3(0.0, -1.0, 0.75).xy * _7._m0.xy), _88.xy, _88.zw); - vec3 _203 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _191, 0.0).w * _7._m1, 0.0, 1.0); - vec4 _207 = textureLod(SPIRV_Cross_Combined_1, _191, 0.0); - vec3 _223; - if (_207.y > 0.0) - { - _223 = _203 + (textureLod(SPIRV_Cross_Combined_2, _191, 0.0).xyz * clamp(_207.y * _207.z, 0.0, 1.0)); - } - else - { - _223 = _203; - } - vec3 _227 = _181.xyz + (_223 * 0.75); - vec4 _228 = vec4(_227.x, _227.y, _227.z, _181.w); - _28 _229 = _182; - _229._m0 = _228; - vec2 _238 = clamp(_82 + (vec3(1.0, -1.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - vec3 _250 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _238, 0.0).w * _7._m1, 0.0, 1.0); - vec4 _254 = textureLod(SPIRV_Cross_Combined_1, _238, 0.0); - vec3 _270; - if (_254.y > 0.0) - { - _270 = _250 + (textureLod(SPIRV_Cross_Combined_2, _238, 0.0).xyz * clamp(_254.y * _254.z, 0.0, 1.0)); - } - else - { - _270 = _250; - } - vec3 _274 = _228.xyz + (_270 * 0.5); - vec4 _275 = vec4(_274.x, _274.y, _274.z, _228.w); - _28 _276 = _229; - _276._m0 = _275; - vec2 _285 = clamp(_82 + (vec3(-2.0, 0.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - vec3 _297 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _285, 0.0).w * _7._m1, 0.0, 1.0); - vec4 _301 = textureLod(SPIRV_Cross_Combined_1, _285, 0.0); - vec3 _317; - if (_301.y > 0.0) - { - _317 = _297 + (textureLod(SPIRV_Cross_Combined_2, _285, 0.0).xyz * clamp(_301.y * _301.z, 0.0, 1.0)); - } - else - { - _317 = _297; - } - vec3 _321 = _275.xyz + (_317 * 0.5); - vec4 _322 = vec4(_321.x, _321.y, _321.z, _275.w); - _28 _323 = _276; - _323._m0 = _322; - vec2 _332 = clamp(_82 + (vec3(-1.0, 0.0, 0.75).xy * _7._m0.xy), _88.xy, _88.zw); - vec3 _344 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _332, 0.0).w * _7._m1, 0.0, 1.0); - vec4 _348 = textureLod(SPIRV_Cross_Combined_1, _332, 0.0); - vec3 _364; - if (_348.y > 0.0) - { - _364 = _344 + (textureLod(SPIRV_Cross_Combined_2, _332, 0.0).xyz * clamp(_348.y * _348.z, 0.0, 1.0)); - } - else - { - _364 = _344; - } - vec3 _368 = _322.xyz + (_364 * 0.75); - vec4 _369 = vec4(_368.x, _368.y, _368.z, _322.w); - _28 _370 = _323; - _370._m0 = _369; - vec2 _379 = clamp(_82 + (vec3(0.0, 0.0, 1.0).xy * _7._m0.xy), _88.xy, _88.zw); - vec3 _391 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _379, 0.0).w * _7._m1, 0.0, 1.0); - vec4 _395 = textureLod(SPIRV_Cross_Combined_1, _379, 0.0); - vec3 _411; - if (_395.y > 0.0) - { - _411 = _391 + (textureLod(SPIRV_Cross_Combined_2, _379, 0.0).xyz * clamp(_395.y * _395.z, 0.0, 1.0)); - } - else - { - _411 = _391; - } - vec3 _415 = _369.xyz + (_411 * 1.0); - vec4 _416 = vec4(_415.x, _415.y, _415.z, _369.w); - _28 _417 = _370; - _417._m0 = _416; - vec2 _426 = clamp(_82 + (vec3(1.0, 0.0, 0.75).xy * _7._m0.xy), _88.xy, _88.zw); - vec3 _438 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _426, 0.0).w * _7._m1, 0.0, 1.0); - vec4 _442 = textureLod(SPIRV_Cross_Combined_1, _426, 0.0); - vec3 _458; - if (_442.y > 0.0) - { - _458 = _438 + (textureLod(SPIRV_Cross_Combined_2, _426, 0.0).xyz * clamp(_442.y * _442.z, 0.0, 1.0)); - } - else - { - _458 = _438; - } - vec3 _462 = _416.xyz + (_458 * 0.75); - vec4 _463 = vec4(_462.x, _462.y, _462.z, _416.w); - _28 _464 = _417; - _464._m0 = _463; - vec2 _473 = clamp(_82 + (vec3(2.0, 0.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - vec3 _485 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _473, 0.0).w * _7._m1, 0.0, 1.0); - vec4 _489 = textureLod(SPIRV_Cross_Combined_1, _473, 0.0); - vec3 _505; - if (_489.y > 0.0) - { - _505 = _485 + (textureLod(SPIRV_Cross_Combined_2, _473, 0.0).xyz * clamp(_489.y * _489.z, 0.0, 1.0)); - } - else - { - _505 = _485; - } - vec3 _509 = _463.xyz + (_505 * 0.5); - vec4 _510 = vec4(_509.x, _509.y, _509.z, _463.w); - _28 _511 = _464; - _511._m0 = _510; - vec2 _520 = clamp(_82 + (vec3(-1.0, 1.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - vec3 _532 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _520, 0.0).w * _7._m1, 0.0, 1.0); - vec4 _536 = textureLod(SPIRV_Cross_Combined_1, _520, 0.0); - vec3 _552; - if (_536.y > 0.0) - { - _552 = _532 + (textureLod(SPIRV_Cross_Combined_2, _520, 0.0).xyz * clamp(_536.y * _536.z, 0.0, 1.0)); - } - else - { - _552 = _532; - } - vec3 _556 = _510.xyz + (_552 * 0.5); - vec4 _557 = vec4(_556.x, _556.y, _556.z, _510.w); - _28 _558 = _511; - _558._m0 = _557; - vec2 _567 = clamp(_82 + (vec3(0.0, 1.0, 0.75).xy * _7._m0.xy), _88.xy, _88.zw); - vec3 _579 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _567, 0.0).w * _7._m1, 0.0, 1.0); - vec4 _583 = textureLod(SPIRV_Cross_Combined_1, _567, 0.0); - vec3 _599; - if (_583.y > 0.0) - { - _599 = _579 + (textureLod(SPIRV_Cross_Combined_2, _567, 0.0).xyz * clamp(_583.y * _583.z, 0.0, 1.0)); - } - else - { - _599 = _579; - } - vec3 _603 = _557.xyz + (_599 * 0.75); - vec4 _604 = vec4(_603.x, _603.y, _603.z, _557.w); - _28 _605 = _558; - _605._m0 = _604; - vec2 _614 = clamp(_82 + (vec3(1.0, 1.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - vec3 _626 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _614, 0.0).w * _7._m1, 0.0, 1.0); - vec4 _630 = textureLod(SPIRV_Cross_Combined_1, _614, 0.0); - vec3 _646; - if (_630.y > 0.0) - { - _646 = _626 + (textureLod(SPIRV_Cross_Combined_2, _614, 0.0).xyz * clamp(_630.y * _630.z, 0.0, 1.0)); - } - else - { - _646 = _626; - } - vec3 _650 = _604.xyz + (_646 * 0.5); - vec4 _651 = vec4(_650.x, _650.y, _650.z, _604.w); - _28 _652 = _605; - _652._m0 = _651; - vec2 _661 = clamp(_82 + (vec3(0.0, 2.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - vec3 _673 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _661, 0.0).w * _7._m1, 0.0, 1.0); - vec4 _677 = textureLod(SPIRV_Cross_Combined_1, _661, 0.0); - vec3 _693; - if (_677.y > 0.0) - { - _693 = _673 + (textureLod(SPIRV_Cross_Combined_2, _661, 0.0).xyz * clamp(_677.y * _677.z, 0.0, 1.0)); - } - else - { - _693 = _673; - } - vec3 _697 = _651.xyz + (_693 * 0.5); - vec4 _698 = vec4(_697.x, _697.y, _697.z, _651.w); - _28 _699 = _652; - _699._m0 = _698; - vec3 _702 = _698.xyz / vec3(((((((((((((0.0 + 0.5) + 0.5) + 0.75) + 0.5) + 0.5) + 0.75) + 1.0) + 0.75) + 0.5) + 0.5) + 0.75) + 0.5) + 0.5); - _28 _704 = _699; - _704._m0 = vec4(_702.x, _702.y, _702.z, _698.w); - _28 _705 = _704; - _705._m0.w = 1.0; - _5 = _705._m0; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/asm/tesc/tess-fixed-input-array-builtin-array.asm.tesc b/deps/SPIRV-Cross/reference/opt/shaders/asm/tesc/tess-fixed-input-array-builtin-array.asm.tesc deleted file mode 100644 index dc43d91a9b..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/asm/tesc/tess-fixed-input-array-builtin-array.asm.tesc +++ /dev/null @@ -1,81 +0,0 @@ -#version 450 -layout(vertices = 3) out; - -struct VertexOutput -{ - vec4 pos; - vec2 uv; -}; - -struct HSOut -{ - vec4 pos; - vec2 uv; -}; - -struct HSConstantOut -{ - float EdgeTess[3]; - float InsideTess; -}; - -struct VertexOutput_1 -{ - vec2 uv; -}; - -struct HSOut_1 -{ - vec2 uv; -}; - -layout(location = 0) in VertexOutput_1 p[]; -layout(location = 0) out HSOut_1 _entryPointOutput[3]; - -void main() -{ - VertexOutput p_1[3]; - p_1[0].pos = gl_in[0].gl_Position; - p_1[0].uv = p[0].uv; - p_1[1].pos = gl_in[1].gl_Position; - p_1[1].uv = p[1].uv; - p_1[2].pos = gl_in[2].gl_Position; - p_1[2].uv = p[2].uv; - VertexOutput param[3] = p_1; - HSOut _158; - HSOut _197 = _158; - _197.pos = param[gl_InvocationID].pos; - HSOut _199 = _197; - _199.uv = param[gl_InvocationID].uv; - _158 = _199; - gl_out[gl_InvocationID].gl_Position = param[gl_InvocationID].pos; - _entryPointOutput[gl_InvocationID].uv = param[gl_InvocationID].uv; - barrier(); - if (int(gl_InvocationID) == 0) - { - VertexOutput param_1[3] = p_1; - vec2 _174 = vec2(1.0) + param_1[0].uv; - float _175 = _174.x; - HSConstantOut _169; - HSConstantOut _205 = _169; - _205.EdgeTess[0] = _175; - vec2 _180 = vec2(1.0) + param_1[0].uv; - float _181 = _180.x; - HSConstantOut _207 = _205; - _207.EdgeTess[1] = _181; - vec2 _186 = vec2(1.0) + param_1[0].uv; - float _187 = _186.x; - HSConstantOut _209 = _207; - _209.EdgeTess[2] = _187; - vec2 _192 = vec2(1.0) + param_1[0].uv; - float _193 = _192.x; - HSConstantOut _211 = _209; - _211.InsideTess = _193; - _169 = _211; - gl_TessLevelOuter[0] = _175; - gl_TessLevelOuter[1] = _181; - gl_TessLevelOuter[2] = _187; - gl_TessLevelInner[0] = _193; - } -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/asm/vert/empty-io.asm.vert b/deps/SPIRV-Cross/reference/opt/shaders/asm/vert/empty-io.asm.vert deleted file mode 100644 index 5286269337..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/asm/vert/empty-io.asm.vert +++ /dev/null @@ -1,19 +0,0 @@ -#version 450 - -struct VSInput -{ - vec4 position; -}; - -struct VSOutput -{ - vec4 position; -}; - -layout(location = 0) in vec4 position; - -void main() -{ - gl_Position = position; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/asm/vert/empty-struct-composite.asm.vert b/deps/SPIRV-Cross/reference/opt/shaders/asm/vert/empty-struct-composite.asm.vert deleted file mode 100644 index 05ce10adfa..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/asm/vert/empty-struct-composite.asm.vert +++ /dev/null @@ -1,6 +0,0 @@ -#version 450 - -void main() -{ -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/asm/vert/global-builtin.sso.asm.vert b/deps/SPIRV-Cross/reference/opt/shaders/asm/vert/global-builtin.sso.asm.vert deleted file mode 100644 index 2fc44c526e..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/asm/vert/global-builtin.sso.asm.vert +++ /dev/null @@ -1,26 +0,0 @@ -#version 450 - -out gl_PerVertex -{ - vec4 gl_Position; -}; - -struct VSOut -{ - float a; - vec4 pos; -}; - -struct VSOut_1 -{ - float a; -}; - -layout(location = 0) out VSOut_1 _entryPointOutput; - -void main() -{ - _entryPointOutput.a = 40.0; - gl_Position = vec4(1.0); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/comp/atomic.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/atomic.comp deleted file mode 100644 index 89b1351c0c..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/comp/atomic.comp +++ /dev/null @@ -1,49 +0,0 @@ -#version 310 es -#extension GL_OES_shader_image_atomic : require -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 2, std430) buffer SSBO -{ - uint u32; - int i32; -} ssbo; - -layout(binding = 0, r32ui) uniform highp uimage2D uImage; -layout(binding = 1, r32i) uniform highp iimage2D iImage; - -void main() -{ - uint _19 = imageAtomicAdd(uImage, ivec2(1, 5), 1u); - uint _27 = imageAtomicAdd(uImage, ivec2(1, 5), 1u); - imageStore(iImage, ivec2(1, 6), ivec4(int(_27))); - uint _32 = imageAtomicOr(uImage, ivec2(1, 5), 1u); - uint _34 = imageAtomicXor(uImage, ivec2(1, 5), 1u); - uint _36 = imageAtomicAnd(uImage, ivec2(1, 5), 1u); - uint _38 = imageAtomicMin(uImage, ivec2(1, 5), 1u); - uint _40 = imageAtomicMax(uImage, ivec2(1, 5), 1u); - uint _44 = imageAtomicCompSwap(uImage, ivec2(1, 5), 10u, 2u); - int _47 = imageAtomicAdd(iImage, ivec2(1, 6), 1); - int _49 = imageAtomicOr(iImage, ivec2(1, 6), 1); - int _51 = imageAtomicXor(iImage, ivec2(1, 6), 1); - int _53 = imageAtomicAnd(iImage, ivec2(1, 6), 1); - int _55 = imageAtomicMin(iImage, ivec2(1, 6), 1); - int _57 = imageAtomicMax(iImage, ivec2(1, 6), 1); - int _61 = imageAtomicCompSwap(iImage, ivec2(1, 5), 10, 2); - uint _68 = atomicAdd(ssbo.u32, 1u); - uint _70 = atomicOr(ssbo.u32, 1u); - uint _72 = atomicXor(ssbo.u32, 1u); - uint _74 = atomicAnd(ssbo.u32, 1u); - uint _76 = atomicMin(ssbo.u32, 1u); - uint _78 = atomicMax(ssbo.u32, 1u); - uint _80 = atomicExchange(ssbo.u32, 1u); - uint _82 = atomicCompSwap(ssbo.u32, 10u, 2u); - int _85 = atomicAdd(ssbo.i32, 1); - int _87 = atomicOr(ssbo.i32, 1); - int _89 = atomicXor(ssbo.i32, 1); - int _91 = atomicAnd(ssbo.i32, 1); - int _93 = atomicMin(ssbo.i32, 1); - int _95 = atomicMax(ssbo.i32, 1); - int _97 = atomicExchange(ssbo.i32, 1); - int _99 = atomicCompSwap(ssbo.i32, 10, 2); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/comp/bake_gradient.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/bake_gradient.comp deleted file mode 100644 index 0af4833926..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/comp/bake_gradient.comp +++ /dev/null @@ -1,23 +0,0 @@ -#version 310 es -layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in; - -layout(binding = 4, std140) uniform UBO -{ - vec4 uInvSize; - vec4 uScale; -} _46; - -layout(binding = 0) uniform mediump sampler2D uHeight; -layout(binding = 1) uniform mediump sampler2D uDisplacement; -layout(binding = 2, rgba16f) uniform writeonly mediump image2D iHeightDisplacement; -layout(binding = 3, rgba16f) uniform writeonly mediump image2D iGradJacobian; - -void main() -{ - vec4 _59 = (vec2(gl_GlobalInvocationID.xy) * _46.uInvSize.xy).xyxy + (_46.uInvSize * 0.5); - vec2 _157 = ((textureLodOffset(uDisplacement, _59.zw, 0.0, ivec2(1, 0)).xy - textureLodOffset(uDisplacement, _59.zw, 0.0, ivec2(-1, 0)).xy) * 0.60000002384185791015625) * _46.uScale.z; - vec2 _161 = ((textureLodOffset(uDisplacement, _59.zw, 0.0, ivec2(0, 1)).xy - textureLodOffset(uDisplacement, _59.zw, 0.0, ivec2(0, -1)).xy) * 0.60000002384185791015625) * _46.uScale.z; - imageStore(iHeightDisplacement, ivec2(gl_GlobalInvocationID.xy), vec4(textureLod(uHeight, _59.xy, 0.0).x, 0.0, 0.0, 0.0)); - imageStore(iGradJacobian, ivec2(gl_GlobalInvocationID.xy), vec4((_46.uScale.xy * 0.5) * vec2(textureLodOffset(uHeight, _59.xy, 0.0, ivec2(1, 0)).x - textureLodOffset(uHeight, _59.xy, 0.0, ivec2(-1, 0)).x, textureLodOffset(uHeight, _59.xy, 0.0, ivec2(0, 1)).x - textureLodOffset(uHeight, _59.xy, 0.0, ivec2(0, -1)).x), ((1.0 + _157.x) * (1.0 + _161.y)) - (_157.y * _161.x), 0.0)); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/comp/barriers.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/barriers.comp deleted file mode 100644 index a091497a49..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/comp/barriers.comp +++ /dev/null @@ -1,28 +0,0 @@ -#version 310 es -layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in; - -void main() -{ - memoryBarrierShared(); - memoryBarrier(); - memoryBarrierImage(); - memoryBarrierBuffer(); - groupMemoryBarrier(); - memoryBarrierShared(); - barrier(); - memoryBarrier(); - memoryBarrierShared(); - barrier(); - memoryBarrierImage(); - memoryBarrierShared(); - barrier(); - memoryBarrierBuffer(); - memoryBarrierShared(); - barrier(); - groupMemoryBarrier(); - memoryBarrierShared(); - barrier(); - memoryBarrierShared(); - barrier(); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/comp/basic.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/basic.comp deleted file mode 100644 index f025d53c6f..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/comp/basic.comp +++ /dev/null @@ -1,28 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) readonly buffer SSBO -{ - vec4 in_data[]; -} _23; - -layout(binding = 1, std430) writeonly buffer SSBO2 -{ - vec4 out_data[]; -} _45; - -layout(binding = 2, std430) buffer SSBO3 -{ - uint counter; -} _48; - -void main() -{ - vec4 _29 = _23.in_data[gl_GlobalInvocationID.x]; - if (dot(_29, vec4(1.0, 5.0, 6.0, 2.0)) > 8.19999980926513671875) - { - uint _52 = atomicAdd(_48.counter, 1u); - _45.out_data[_52] = _29; - } -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/comp/bitfield.noopt.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/bitfield.noopt.comp deleted file mode 100644 index 49bbddb0ab..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/comp/bitfield.noopt.comp +++ /dev/null @@ -1,19 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -void main() -{ - int signed_value = 0; - uint unsigned_value = 0u; - int s = bitfieldExtract(signed_value, 5, 20); - uint u = bitfieldExtract(unsigned_value, 6, 21); - s = bitfieldInsert(s, 40, 5, 4); - u = bitfieldInsert(u, 60u, 5, 4); - u = bitfieldReverse(u); - s = bitfieldReverse(s); - int v0 = bitCount(u); - int v1 = bitCount(s); - int v2 = findMSB(u); - int v3 = findLSB(s); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/comp/casts.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/casts.comp deleted file mode 100644 index 11ef36287b..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/comp/casts.comp +++ /dev/null @@ -1,18 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 1, std430) buffer SSBO1 -{ - ivec4 outputs[]; -} _21; - -layout(binding = 0, std430) buffer SSBO0 -{ - ivec4 inputs[]; -} _27; - -void main() -{ - _21.outputs[gl_GlobalInvocationID.x] = mix(ivec4(0), ivec4(1), notEqual((_27.inputs[gl_GlobalInvocationID.x] & ivec4(3)), ivec4(uvec4(0u)))); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/comp/cfg-preserve-parameter.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/cfg-preserve-parameter.comp deleted file mode 100644 index 124652b322..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/comp/cfg-preserve-parameter.comp +++ /dev/null @@ -1,7 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -void main() -{ -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/comp/cfg.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/cfg.comp deleted file mode 100644 index c2c7136bbd..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/comp/cfg.comp +++ /dev/null @@ -1,56 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) buffer SSBO -{ - float data; -} _11; - -float _180; - -void main() -{ - if (_11.data != 0.0) - { - _11.data = 10.0; - } - else - { - _11.data = 15.0; - } - switch (int(_11.data)) - { - case 0: - { - _11.data = 20.0; - break; - } - case 1: - { - _11.data = 30.0; - break; - } - } - switch (int(_11.data)) - { - case 0: - { - break; - } - case 1: - { - break; - } - } - float _181; - _181 = _180; - for (int _179 = 0; _179 < 20; _179++, _181 += 10.0) - { - } - _11.data = _181; - do - { - } while (_180 != 20.0); - _11.data = _180; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/comp/coherent-block.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/coherent-block.comp deleted file mode 100644 index bfab6bbea8..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/comp/coherent-block.comp +++ /dev/null @@ -1,13 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 1, std430) coherent restrict writeonly buffer SSBO -{ - vec4 value; -} _10; - -void main() -{ - _10.value = vec4(20.0); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/comp/coherent-image.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/coherent-image.comp deleted file mode 100644 index b3992f242e..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/comp/coherent-image.comp +++ /dev/null @@ -1,15 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 1, std430) coherent restrict writeonly buffer SSBO -{ - ivec4 value; -} _10; - -layout(binding = 3, r32i) uniform coherent restrict readonly mediump iimage2D uImage; - -void main() -{ - _10.value = imageLoad(uImage, ivec2(10)); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/comp/composite-construct.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/composite-construct.comp deleted file mode 100644 index 5371f7e528..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/comp/composite-construct.comp +++ /dev/null @@ -1,26 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -struct Composite -{ - vec4 a[2]; - vec4 b[2]; -}; - -layout(binding = 0, std430) buffer SSBO0 -{ - vec4 as[]; -} _41; - -layout(binding = 1, std430) buffer SSBO1 -{ - vec4 bs[]; -} _55; - -void main() -{ - vec4 _60[2] = vec4[](_41.as[gl_GlobalInvocationID.x], _55.bs[gl_GlobalInvocationID.x]); - vec4 param[3][2] = vec4[][](_60, vec4[](vec4(10.0), vec4(30.0)), _60); - _41.as[gl_GlobalInvocationID.x] = ((param[0][0] + param[2][1]) + param[0][1]) + param[1][0]; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/comp/culling.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/culling.comp deleted file mode 100644 index f4dea4b359..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/comp/culling.comp +++ /dev/null @@ -1,28 +0,0 @@ -#version 310 es -layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) readonly buffer SSBO -{ - float in_data[]; -} _22; - -layout(binding = 1, std430) writeonly buffer SSBO2 -{ - float out_data[]; -} _38; - -layout(binding = 2, std430) buffer SSBO3 -{ - uint count; -} _41; - -void main() -{ - float _28 = _22.in_data[gl_GlobalInvocationID.x]; - if (_28 > 12.0) - { - uint _45 = atomicAdd(_41.count, 1u); - _38.out_data[_45] = _28; - } -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/comp/defer-parens.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/defer-parens.comp deleted file mode 100644 index 51fa7f0abf..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/comp/defer-parens.comp +++ /dev/null @@ -1,19 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) buffer SSBO -{ - vec4 data; - int index; -} _13; - -void main() -{ - vec4 _17 = _13.data; - _13.data = vec4(_17.x, _17.yz + vec2(10.0), _17.w); - _13.data = (_17 + _17) + _17; - _13.data = (_17.yz + vec2(10.0)).xxyy; - _13.data = vec4((_17.yz + vec2(10.0)).y); - _13.data = vec4((_17.zw + vec2(10.0))[_13.index]); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/comp/dowhile.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/dowhile.comp deleted file mode 100644 index 61a3735d13..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/comp/dowhile.comp +++ /dev/null @@ -1,39 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) readonly buffer SSBO -{ - mat4 mvp; - vec4 in_data[]; -} _28; - -layout(binding = 1, std430) writeonly buffer SSBO2 -{ - vec4 out_data[]; -} _52; - -int i; - -void main() -{ - i = 0; - vec4 _56; - _56 = _28.in_data[gl_GlobalInvocationID.x]; - vec4 _42; - for (;;) - { - _42 = _28.mvp * _56; - i++; - if (i < 16) - { - _56 = _42; - continue; - } - else - { - break; - } - } - _52.out_data[gl_GlobalInvocationID.x] = _42; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/comp/generate_height.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/generate_height.comp deleted file mode 100644 index 1b5e0c3dc1..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/comp/generate_height.comp +++ /dev/null @@ -1,54 +0,0 @@ -#version 310 es -layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) readonly buffer Distribution -{ - vec2 distribution[]; -} _136; - -layout(binding = 2, std140) uniform UBO -{ - vec4 uModTime; -} _165; - -layout(binding = 1, std430) writeonly buffer HeightmapFFT -{ - uint heights[]; -} _224; - -void main() -{ - uvec2 _263 = uvec2(64u, 1u) * gl_NumWorkGroups.xy; - uvec2 _268 = _263 - gl_GlobalInvocationID.xy; - bvec2 _270 = equal(gl_GlobalInvocationID.xy, uvec2(0u)); - uint _470; - if (_270.x) - { - _470 = 0u; - } - else - { - _470 = _268.x; - } - uint _471; - if (_270.y) - { - _471 = 0u; - } - else - { - _471 = _268.y; - } - vec2 _296 = vec2(gl_GlobalInvocationID.xy); - vec2 _298 = vec2(_263); - float _308 = sqrt(9.81000041961669921875 * length(_165.uModTime.xy * mix(_296, _296 - _298, greaterThan(_296, _298 * 0.5)))) * _165.uModTime.z; - float _310 = cos(_308); - float _312 = sin(_308); - vec2 _315 = vec2(_310, _312); - vec2 _394 = _315.yy * (_136.distribution[(gl_GlobalInvocationID.xy.y * _263.x) + gl_GlobalInvocationID.xy.x]).yx; - vec2 _320 = vec2(_310, _312); - vec2 _420 = _320.yy * (_136.distribution[(_471 * _263.x) + _470]).yx; - vec2 _428 = ((_136.distribution[(_471 * _263.x) + _470]) * _320.xx) + vec2(-_420.x, _420.y); - _224.heights[(gl_GlobalInvocationID.xy.y * _263.x) + gl_GlobalInvocationID.xy.x] = packHalf2x16((((_136.distribution[(gl_GlobalInvocationID.xy.y * _263.x) + gl_GlobalInvocationID.xy.x]) * _315.xx) + vec2(-_394.x, _394.y)) + vec2(_428.x, -_428.y)); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/comp/image.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/image.comp deleted file mode 100644 index 8bd7dd06ab..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/comp/image.comp +++ /dev/null @@ -1,11 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, rgba8) uniform readonly mediump image2D uImageIn; -layout(binding = 1, rgba8) uniform writeonly mediump image2D uImageOut; - -void main() -{ - imageStore(uImageOut, ivec2(gl_GlobalInvocationID.xy), imageLoad(uImageIn, ivec2(gl_GlobalInvocationID.xy) + imageSize(uImageIn))); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/comp/inout-struct.invalid.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/inout-struct.invalid.comp deleted file mode 100644 index 640e25bb95..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/comp/inout-struct.invalid.comp +++ /dev/null @@ -1,65 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -struct Foo -{ - vec4 a; - vec4 b; - vec4 c; - vec4 d; -}; - -layout(binding = 1, std430) readonly buffer SSBO2 -{ - vec4 data[]; -} indata; - -layout(binding = 0, std430) writeonly buffer SSBO -{ - vec4 data[]; -} outdata; - -layout(binding = 2, std430) readonly buffer SSBO3 -{ - Foo foos[]; -} foobar; - -void baz(inout Foo foo) -{ - uint ident = gl_GlobalInvocationID.x; - foo.a = indata.data[(4u * ident) + 0u]; - foo.b = indata.data[(4u * ident) + 1u]; - foo.c = indata.data[(4u * ident) + 2u]; - foo.d = indata.data[(4u * ident) + 3u]; -} - -void meow(inout Foo foo) -{ - foo.a += vec4(10.0); - foo.b += vec4(20.0); - foo.c += vec4(30.0); - foo.d += vec4(40.0); -} - -vec4 bar(Foo foo) -{ - return ((foo.a + foo.b) + foo.c) + foo.d; -} - -void main() -{ - Foo param; - baz(param); - Foo foo = param; - Foo param_1 = foo; - meow(param_1); - foo = param_1; - Foo param_2 = foo; - Foo param_3; - param_3.a = foobar.foos[gl_GlobalInvocationID.x].a; - param_3.b = foobar.foos[gl_GlobalInvocationID.x].b; - param_3.c = foobar.foos[gl_GlobalInvocationID.x].c; - param_3.d = foobar.foos[gl_GlobalInvocationID.x].d; - outdata.data[gl_GlobalInvocationID.x] = bar(param_2) + bar(param_3); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/comp/insert.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/insert.comp deleted file mode 100644 index 5ff719449a..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/comp/insert.comp +++ /dev/null @@ -1,24 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) writeonly buffer SSBO -{ - vec4 out_data[]; -} _27; - -vec4 _52; - -void main() -{ - vec4 _45 = _52; - _45.x = 10.0; - vec4 _47 = _45; - _47.y = 30.0; - vec4 _49 = _47; - _49.z = 70.0; - vec4 _51 = _49; - _51.w = 90.0; - _27.out_data[gl_GlobalInvocationID.x] = _51; - _27.out_data[gl_GlobalInvocationID.x].y = 20.0; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/comp/loop.noopt.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/loop.noopt.comp deleted file mode 100644 index 049a30669c..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/comp/loop.noopt.comp +++ /dev/null @@ -1,105 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) readonly buffer SSBO -{ - mat4 mvp; - vec4 in_data[]; -} _24; - -layout(binding = 1, std430) writeonly buffer SSBO2 -{ - vec4 out_data[]; -} _177; - -void main() -{ - uint ident = gl_GlobalInvocationID.x; - vec4 idat = _24.in_data[ident]; - int k = 0; - uint i = 0u; - if (idat.y == 20.0) - { - do - { - k *= 2; - i++; - } while (i < ident); - } - switch (k) - { - case 10: - { - for (;;) - { - i++; - if (i > 10u) - { - break; - } - continue; - } - break; - } - default: - { - for (;;) - { - i += 2u; - if (i > 20u) - { - break; - } - continue; - } - break; - } - } - while (k < 10) - { - idat *= 2.0; - k++; - } - for (uint i_1 = 0u; i_1 < 16u; i_1++, k++) - { - for (uint j = 0u; j < 30u; j++) - { - idat = _24.mvp * idat; - } - } - k = 0; - for (;;) - { - k++; - if (k > 10) - { - k += 2; - } - else - { - k += 3; - continue; - } - k += 10; - continue; - } - k = 0; - do - { - k++; - } while (k > 10); - int l = 0; - for (;;) - { - if (l == 5) - { - l++; - continue; - } - idat += vec4(1.0); - l++; - continue; - } - _177.out_data[ident] = idat; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/comp/mat3.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/mat3.comp deleted file mode 100644 index b1c585b849..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/comp/mat3.comp +++ /dev/null @@ -1,13 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 1, std430) writeonly buffer SSBO2 -{ - mat3 out_data[]; -} _22; - -void main() -{ - _22.out_data[gl_GlobalInvocationID.x] = mat3(vec3(10.0), vec3(20.0), vec3(40.0)); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/comp/mod.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/mod.comp deleted file mode 100644 index d8ee0ff83a..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/comp/mod.comp +++ /dev/null @@ -1,20 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) readonly buffer SSBO -{ - vec4 in_data[]; -} _23; - -layout(binding = 1, std430) writeonly buffer SSBO2 -{ - vec4 out_data[]; -} _33; - -void main() -{ - _33.out_data[gl_GlobalInvocationID.x] = mod(_23.in_data[gl_GlobalInvocationID.x], _33.out_data[gl_GlobalInvocationID.x]); - _33.out_data[gl_GlobalInvocationID.x] = uintBitsToFloat(floatBitsToUint(_23.in_data[gl_GlobalInvocationID.x]) % floatBitsToUint(_33.out_data[gl_GlobalInvocationID.x])); - _33.out_data[gl_GlobalInvocationID.x] = intBitsToFloat(floatBitsToInt(_23.in_data[gl_GlobalInvocationID.x]) % floatBitsToInt(_33.out_data[gl_GlobalInvocationID.x])); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/comp/modf.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/modf.comp deleted file mode 100644 index 3c8ab6ecd7..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/comp/modf.comp +++ /dev/null @@ -1,20 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) readonly buffer SSBO -{ - vec4 in_data[]; -} _23; - -layout(binding = 1, std430) writeonly buffer SSBO2 -{ - vec4 out_data[]; -} _35; - -void main() -{ - vec4 i; - vec4 _31 = modf(_23.in_data[gl_GlobalInvocationID.x], i); - _35.out_data[gl_GlobalInvocationID.x] = _31; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/comp/read-write-only.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/read-write-only.comp deleted file mode 100644 index 06227ee2c6..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/comp/read-write-only.comp +++ /dev/null @@ -1,27 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 2, std430) restrict writeonly buffer SSBO2 -{ - vec4 data4; - vec4 data5; -} _10; - -layout(binding = 0, std430) readonly buffer SSBO0 -{ - vec4 data0; - vec4 data1; -} _15; - -layout(binding = 1, std430) restrict buffer SSBO1 -{ - vec4 data2; - vec4 data3; -} _21; - -void main() -{ - _10.data4 = _15.data0 + _21.data2; - _10.data5 = _15.data1 + _21.data3; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/comp/return.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/return.comp deleted file mode 100644 index ea41907a7b..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/comp/return.comp +++ /dev/null @@ -1,31 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 1, std430) writeonly buffer SSBO2 -{ - vec4 out_data[]; -} _27; - -int _69; - -void main() -{ - if (gl_GlobalInvocationID.x == 2u) - { - _27.out_data[gl_GlobalInvocationID.x] = vec4(20.0); - } - else - { - if (gl_GlobalInvocationID.x == 4u) - { - _27.out_data[gl_GlobalInvocationID.x] = vec4(10.0); - return; - } - } - for (int _68 = 0; _68 < 20; _68 = _69 + 1) - { - return; - } - _27.out_data[gl_GlobalInvocationID.x] = vec4(10.0); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/comp/rmw-opt.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/rmw-opt.comp deleted file mode 100644 index 7d4d24b29f..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/comp/rmw-opt.comp +++ /dev/null @@ -1,24 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) buffer SSBO -{ - int a; -} _9; - -void main() -{ - _9.a += 10; - _9.a -= 10; - _9.a *= 10; - _9.a /= 10; - _9.a = _9.a << 2; - _9.a = _9.a >> 3; - _9.a &= 40; - _9.a ^= 10; - _9.a %= 40; - _9.a |= 1; - bool _65 = false && true; - _9.a = int(_65 && (true || _65)); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/comp/shared.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/shared.comp deleted file mode 100644 index 66ec1c2cc7..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/comp/shared.comp +++ /dev/null @@ -1,23 +0,0 @@ -#version 310 es -layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) readonly buffer SSBO -{ - float in_data[]; -} _22; - -layout(binding = 1, std430) writeonly buffer SSBO2 -{ - float out_data[]; -} _44; - -shared float sShared[4]; - -void main() -{ - sShared[gl_LocalInvocationIndex] = _22.in_data[gl_GlobalInvocationID.x]; - memoryBarrierShared(); - barrier(); - _44.out_data[gl_GlobalInvocationID.x] = sShared[(4u - gl_LocalInvocationIndex) - 1u]; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/comp/ssbo-array.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/ssbo-array.comp deleted file mode 100644 index 6caf8f49f5..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/comp/ssbo-array.comp +++ /dev/null @@ -1,13 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) buffer SSBO -{ - vec4 data[]; -} ssbos[2]; - -void main() -{ - ssbos[1].data[gl_GlobalInvocationID.x] = ssbos[0].data[gl_GlobalInvocationID.x]; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/comp/struct-layout.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/struct-layout.comp deleted file mode 100644 index 0f73fa7fa9..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/comp/struct-layout.comp +++ /dev/null @@ -1,23 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -struct Foo -{ - mat4 m; -}; - -layout(binding = 1, std430) writeonly buffer SSBO2 -{ - Foo out_data[]; -} _23; - -layout(binding = 0, std430) readonly buffer SSBO -{ - Foo in_data[]; -} _30; - -void main() -{ - _23.out_data[gl_GlobalInvocationID.x].m = _30.in_data[gl_GlobalInvocationID.x].m * _30.in_data[gl_GlobalInvocationID.x].m; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/comp/struct-packing.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/struct-packing.comp deleted file mode 100644 index 3c30aa6088..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/comp/struct-packing.comp +++ /dev/null @@ -1,104 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -struct S0 -{ - vec2 a[1]; - float b; -}; - -struct S1 -{ - vec3 a; - float b; -}; - -struct S2 -{ - vec3 a[1]; - float b; -}; - -struct S3 -{ - vec2 a; - float b; -}; - -struct S4 -{ - vec2 c; -}; - -struct Content -{ - S0 m0s[1]; - S1 m1s[1]; - S2 m2s[1]; - S0 m0; - S1 m1; - S2 m2; - S3 m3; - float m4; - S4 m3s[8]; -}; - -layout(binding = 1, std430) buffer SSBO1 -{ - Content content; - Content content1[2]; - Content content2; - mat2 m0; - mat2 m1; - mat2x3 m2[4]; - mat3x2 m3; - layout(row_major) mat2 m4; - layout(row_major) mat2 m5[9]; - layout(row_major) mat2x3 m6[4][2]; - layout(row_major) mat3x2 m7; - float array[]; -} ssbo_430; - -layout(binding = 0, std140) buffer SSBO0 -{ - Content content; - Content content1[2]; - Content content2; - mat2 m0; - mat2 m1; - mat2x3 m2[4]; - mat3x2 m3; - layout(row_major) mat2 m4; - layout(row_major) mat2 m5[9]; - layout(row_major) mat2x3 m6[4][2]; - layout(row_major) mat3x2 m7; - float array[]; -} ssbo_140; - -void main() -{ - ssbo_430.content.m0s[0].a[0] = ssbo_140.content.m0s[0].a[0]; - ssbo_430.content.m0s[0].b = ssbo_140.content.m0s[0].b; - ssbo_430.content.m1s[0].a = ssbo_140.content.m1s[0].a; - ssbo_430.content.m1s[0].b = ssbo_140.content.m1s[0].b; - ssbo_430.content.m2s[0].a[0] = ssbo_140.content.m2s[0].a[0]; - ssbo_430.content.m2s[0].b = ssbo_140.content.m2s[0].b; - ssbo_430.content.m0.a[0] = ssbo_140.content.m0.a[0]; - ssbo_430.content.m0.b = ssbo_140.content.m0.b; - ssbo_430.content.m1.a = ssbo_140.content.m1.a; - ssbo_430.content.m1.b = ssbo_140.content.m1.b; - ssbo_430.content.m2.a[0] = ssbo_140.content.m2.a[0]; - ssbo_430.content.m2.b = ssbo_140.content.m2.b; - ssbo_430.content.m3.a = ssbo_140.content.m3.a; - ssbo_430.content.m3.b = ssbo_140.content.m3.b; - ssbo_430.content.m4 = ssbo_140.content.m4; - ssbo_430.content.m3s[0].c = ssbo_140.content.m3s[0].c; - ssbo_430.content.m3s[1].c = ssbo_140.content.m3s[1].c; - ssbo_430.content.m3s[2].c = ssbo_140.content.m3s[2].c; - ssbo_430.content.m3s[3].c = ssbo_140.content.m3s[3].c; - ssbo_430.content.m3s[4].c = ssbo_140.content.m3s[4].c; - 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; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/comp/torture-loop.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/torture-loop.comp deleted file mode 100644 index 8002984f18..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/comp/torture-loop.comp +++ /dev/null @@ -1,77 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) readonly buffer SSBO -{ - mat4 mvp; - vec4 in_data[]; -} _24; - -layout(binding = 1, std430) writeonly buffer SSBO2 -{ - vec4 out_data[]; -} _89; - -uint _98; - -void main() -{ - vec4 _93; - int _94; - _93 = _24.in_data[gl_GlobalInvocationID.x]; - _94 = 0; - int _48; - int _40; - vec4 _46; - for (;;) - { - _40 = _94 + 1; - if (_40 < 10) - { - _46 = _93 * 2.0; - _48 = _40 + 1; - _93 = _46; - _94 = _48; - continue; - } - else - { - break; - } - } - vec4 _95; - int _96; - _95 = _93; - _96 = _40; - vec4 _100; - uint _101; - uint _99; - for (uint _97 = 0u; _97 < 16u; _95 = _100, _96++, _97++, _99 = _101) - { - _100 = _95; - _101 = 0u; - vec4 _71; - for (; _101 < 30u; _100 = _71, _101++) - { - _71 = _24.mvp * _100; - } - } - int _102; - _102 = _96; - int _83; - for (;;) - { - _83 = _102 + 1; - if (_83 > 10) - { - _102 = _83; - continue; - } - else - { - break; - } - } - _89.out_data[gl_GlobalInvocationID.x] = _95; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/comp/type-alias.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/type-alias.comp deleted file mode 100644 index c0f57f4bda..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/comp/type-alias.comp +++ /dev/null @@ -1,33 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -struct S0 -{ - vec4 a; -}; - -struct S1 -{ - vec4 a; -}; - -layout(binding = 0, std430) buffer SSBO0 -{ - S0 s0s[]; -} _36; - -layout(binding = 1, std430) buffer SSBO1 -{ - S1 s1s[]; -} _55; - -layout(binding = 2, std430) buffer SSBO2 -{ - vec4 outputs[]; -} _66; - -void main() -{ - _66.outputs[gl_GlobalInvocationID.x] = _36.s0s[gl_GlobalInvocationID.x].a + _55.s1s[gl_GlobalInvocationID.x].a; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/comp/udiv.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/udiv.comp deleted file mode 100644 index 0c1f926ad0..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/comp/udiv.comp +++ /dev/null @@ -1,18 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) buffer SSBO2 -{ - uint outputs[]; -} _10; - -layout(binding = 0, std430) buffer SSBO -{ - uint inputs[]; -} _23; - -void main() -{ - _10.outputs[gl_GlobalInvocationID.x] = _23.inputs[gl_GlobalInvocationID.x] / 29u; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/comp/enhanced-layouts.comp b/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/comp/enhanced-layouts.comp deleted file mode 100644 index ba37ca237b..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/comp/enhanced-layouts.comp +++ /dev/null @@ -1,40 +0,0 @@ -#version 450 -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -struct Foo -{ - int a; - int b; - int c; -}; - -layout(binding = 1, std140) buffer SSBO1 -{ - layout(offset = 4) int a; - layout(offset = 8) int b; - layout(offset = 16) Foo foo; - layout(offset = 48) int c[8]; -} ssbo1; - -layout(binding = 2, std430) buffer SSBO2 -{ - layout(offset = 4) int a; - layout(offset = 8) int b; - layout(offset = 16) Foo foo; - layout(offset = 48) int c[8]; -} ssbo2; - -layout(binding = 0, std140) uniform UBO -{ - layout(offset = 4) int a; - layout(offset = 8) int b; - layout(offset = 16) Foo foo; - layout(offset = 48) int c[8]; -} ubo; - -void main() -{ - ssbo1.a = ssbo2.a; - ssbo1.b = ubo.b; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/comp/fp64.desktop.comp b/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/comp/fp64.desktop.comp deleted file mode 100644 index 3839a091f5..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/comp/fp64.desktop.comp +++ /dev/null @@ -1,63 +0,0 @@ -#version 450 -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -struct M0 -{ - double v; - dvec2 b[2]; - dmat2x3 c; - dmat3x2 d; -}; - -layout(binding = 0, std430) buffer SSBO0 -{ - dvec4 a; - M0 m0; - dmat4 b; -} ssbo_0; - -layout(binding = 1, std430) buffer SSBO1 -{ - dmat4 a; - dvec4 b; - M0 m0; -} ssbo_1; - -layout(binding = 2, std430) buffer SSBO2 -{ - double a[4]; - dvec2 b[4]; -} ssbo_2; - -layout(binding = 3, std140) buffer SSBO3 -{ - double a[4]; - dvec2 b[4]; -} ssbo_3; - -void main() -{ - ssbo_0.a += dvec4(10.0lf, 20.0lf, 30.0lf, 40.0lf); - ssbo_0.a += dvec4(20.0lf); - dvec4 _40 = ssbo_0.a; - ssbo_0.a = abs(_40); - ssbo_0.a = sign(_40); - ssbo_0.a = floor(_40); - ssbo_0.a = trunc(_40); - ssbo_0.a = round(_40); - ssbo_0.a = roundEven(_40); - ssbo_0.a = ceil(_40); - ssbo_0.a = fract(_40); - ssbo_0.a = mod(_40, dvec4(20.0lf)); - ssbo_0.a = mod(_40, _40); - ssbo_0.a = min(_40, _40); - ssbo_0.a = max(_40, _40); - ssbo_0.a = clamp(_40, _40, _40); - ssbo_0.a = mix(_40, _40, _40); - ssbo_0.a = step(_40, _40); - ssbo_0.a = smoothstep(_40, _40, _40); - ssbo_1.b.x += 1.0lf; - ssbo_2.b[0].x += 1.0lf; - ssbo_3.b[0].x += 1.0lf; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/comp/image-formats.desktop.noeliminate.comp b/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/comp/image-formats.desktop.noeliminate.comp deleted file mode 100644 index 37b2863558..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/comp/image-formats.desktop.noeliminate.comp +++ /dev/null @@ -1,7 +0,0 @@ -#version 450 -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -void main() -{ -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/comp/int64.desktop.comp b/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/comp/int64.desktop.comp deleted file mode 100644 index 702456b303..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/comp/int64.desktop.comp +++ /dev/null @@ -1,52 +0,0 @@ -#version 450 -#extension GL_ARB_gpu_shader_int64 : require -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -struct M0 -{ - int64_t v; - i64vec2 b[2]; - uint64_t c; - uint64_t d[5]; -}; - -layout(binding = 0, std430) buffer SSBO0 -{ - i64vec4 a; - M0 m0; -} ssbo_0; - -layout(binding = 1, std430) buffer SSBO1 -{ - u64vec4 b; - M0 m0; -} ssbo_1; - -layout(binding = 2, std430) buffer SSBO2 -{ - int64_t a[4]; - i64vec2 b[4]; -} ssbo_2; - -layout(binding = 3, std140) buffer SSBO3 -{ - int64_t a[4]; - i64vec2 b[4]; -} ssbo_3; - -void main() -{ - ssbo_0.a += i64vec4(10l, 20l, 30l, 40l); - ssbo_1.b += u64vec4(999999999999999999ul, 8888888888888888ul, 77777777777777777ul, 6666666666666666ul); - ssbo_0.a += i64vec4(20l); - ssbo_0.a = abs(ssbo_0.a + i64vec4(ssbo_1.b)); - ssbo_0.a += i64vec4(1l); - ssbo_1.b += u64vec4(i64vec4(1l)); - ssbo_0.a -= i64vec4(1l); - ssbo_1.b -= u64vec4(i64vec4(1l)); - ssbo_1.b = doubleBitsToUint64(int64BitsToDouble(ssbo_0.a)); - ssbo_0.a = doubleBitsToInt64(uint64BitsToDouble(ssbo_1.b)); - ssbo_2.a[0] += 1l; - ssbo_3.a[0] += 2l; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/hlsl-uav-block-alias.asm.frag b/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/hlsl-uav-block-alias.asm.frag deleted file mode 100644 index 2d0809fdbf..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/hlsl-uav-block-alias.asm.frag +++ /dev/null @@ -1,19 +0,0 @@ -#version 450 - -layout(binding = 0, std430) buffer Foobar -{ - vec4 _data[]; -} Foobar_1; - -layout(binding = 1, std430) buffer Foobaz -{ - vec4 _data[]; -} Foobaz_1; - -layout(location = 0) out vec4 _entryPointOutput; - -void main() -{ - _entryPointOutput = Foobar_1._data[0] + Foobaz_1._data[0]; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/image-ms.desktop.frag b/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/image-ms.desktop.frag deleted file mode 100644 index 1276981768..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/image-ms.desktop.frag +++ /dev/null @@ -1,12 +0,0 @@ -#version 450 - -layout(binding = 0, rgba8) uniform image2DMS uImage; -layout(binding = 1, rgba8) uniform image2DMSArray uImageArray; - -void main() -{ - vec4 _29 = imageLoad(uImageArray, ivec3(1, 2, 4), 3); - imageStore(uImage, ivec2(2, 3), 1, imageLoad(uImage, ivec2(1, 2), 2)); - imageStore(uImageArray, ivec3(2, 3, 7), 1, _29); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/image-query.desktop.frag b/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/image-query.desktop.frag deleted file mode 100644 index fa1ac0abae..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/image-query.desktop.frag +++ /dev/null @@ -1,16 +0,0 @@ -#version 450 - -layout(binding = 0) uniform sampler1D uSampler1D; -layout(binding = 1) uniform sampler2D uSampler2D; -layout(binding = 2) uniform sampler2DArray uSampler2DArray; -layout(binding = 3) uniform sampler3D uSampler3D; -layout(binding = 4) uniform samplerCube uSamplerCube; -layout(binding = 5) uniform samplerCubeArray uSamplerCubeArray; -layout(binding = 6) uniform samplerBuffer uSamplerBuffer; -layout(binding = 7) uniform sampler2DMS uSamplerMS; -layout(binding = 8) uniform sampler2DMSArray uSamplerMSArray; - -void main() -{ -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/in-block-qualifiers.frag b/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/in-block-qualifiers.frag deleted file mode 100644 index d4622801df..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/in-block-qualifiers.frag +++ /dev/null @@ -1,21 +0,0 @@ -#version 450 - -layout(location = 0) out vec4 FragColor; -layout(location = 0) in VertexData -{ - flat float f; - centroid vec4 g; - flat int h; - float i; -} vin; - -layout(location = 4) flat in float f; -layout(location = 5) centroid in vec4 g; -layout(location = 6) flat in int h; -layout(location = 7) sample in float i; - -void main() -{ - FragColor = ((((((vec4(vin.f) + vin.g) + vec4(float(vin.h))) + vec4(vin.i)) + vec4(f)) + g) + vec4(float(h))) + vec4(i); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/query-levels.desktop.frag b/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/query-levels.desktop.frag deleted file mode 100644 index 4a80cbf81f..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/query-levels.desktop.frag +++ /dev/null @@ -1,11 +0,0 @@ -#version 450 - -layout(binding = 0) uniform sampler2D uSampler; - -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = vec4(float(textureQueryLevels(uSampler))); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/query-lod.desktop.frag b/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/query-lod.desktop.frag deleted file mode 100644 index f43543b8c0..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/query-lod.desktop.frag +++ /dev/null @@ -1,12 +0,0 @@ -#version 450 - -layout(binding = 0) uniform sampler2D uSampler; - -layout(location = 0) out vec4 FragColor; -layout(location = 0) in vec2 vTexCoord; - -void main() -{ - FragColor = textureQueryLod(uSampler, vTexCoord).xyxy; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/sampler-ms-query.desktop.frag b/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/sampler-ms-query.desktop.frag deleted file mode 100644 index 4c30ed1529..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/sampler-ms-query.desktop.frag +++ /dev/null @@ -1,14 +0,0 @@ -#version 450 - -layout(binding = 0) uniform sampler2DMS uSampler; -layout(binding = 1) uniform sampler2DMSArray uSamplerArray; -layout(binding = 2, rgba8) uniform readonly writeonly image2DMS uImage; -layout(binding = 3, rgba8) uniform readonly writeonly image2DMSArray uImageArray; - -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = vec4(float(((textureSamples(uSampler) + textureSamples(uSamplerArray)) + imageSamples(uImage)) + imageSamples(uImageArray))); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/texture-proj-shadow.desktop.frag b/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/texture-proj-shadow.desktop.frag deleted file mode 100644 index d5e45bda43..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/texture-proj-shadow.desktop.frag +++ /dev/null @@ -1,26 +0,0 @@ -#version 450 - -layout(binding = 0) uniform sampler1DShadow uShadow1D; -layout(binding = 1) uniform sampler2DShadow uShadow2D; -layout(binding = 2) uniform sampler1D uSampler1D; -layout(binding = 3) uniform sampler2D uSampler2D; -layout(binding = 4) uniform sampler3D uSampler3D; - -layout(location = 0) out float FragColor; -layout(location = 1) in vec4 vClip4; -layout(location = 2) in vec2 vClip2; -layout(location = 0) in vec3 vClip3; - -void main() -{ - vec4 _20 = vClip4; - _20.y = vClip4.w; - FragColor = textureProj(uShadow1D, vec4(_20.x, 0.0, vClip4.z, _20.y)); - vec4 _30 = vClip4; - _30.z = vClip4.w; - FragColor = textureProj(uShadow2D, vec4(_30.xy, vClip4.z, _30.z)); - FragColor = textureProj(uSampler1D, vClip2).x; - FragColor = textureProj(uSampler2D, vClip3).x; - FragColor = textureProj(uSampler3D, vClip4).x; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/geom/basic.desktop.sso.geom b/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/geom/basic.desktop.sso.geom deleted file mode 100644 index f1afee69ec..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/geom/basic.desktop.sso.geom +++ /dev/null @@ -1,35 +0,0 @@ -#version 450 -layout(invocations = 4, triangles) in; -layout(max_vertices = 3, triangle_strip) out; - -in gl_PerVertex -{ - vec4 gl_Position; -} gl_in[]; - -out gl_PerVertex -{ - vec4 gl_Position; -}; - -layout(location = 0) out vec3 vNormal; -layout(location = 0) in VertexData -{ - vec3 normal; -} vin[3]; - - -void main() -{ - gl_Position = gl_in[0].gl_Position; - vNormal = vin[0].normal + vec3(float(gl_InvocationID)); - EmitVertex(); - gl_Position = gl_in[1].gl_Position; - vNormal = vin[1].normal + vec3(4.0 * float(gl_InvocationID)); - EmitVertex(); - gl_Position = gl_in[2].gl_Position; - vNormal = vin[2].normal + vec3(2.0 * float(gl_InvocationID)); - EmitVertex(); - EndPrimitive(); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/geom/viewport-index.desktop.geom b/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/geom/viewport-index.desktop.geom deleted file mode 100644 index 773aeb8bfd..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/geom/viewport-index.desktop.geom +++ /dev/null @@ -1,9 +0,0 @@ -#version 450 -layout(triangles) in; -layout(max_vertices = 4, triangle_strip) out; - -void main() -{ - gl_ViewportIndex = 1; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/tesc/basic.desktop.sso.tesc b/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/tesc/basic.desktop.sso.tesc deleted file mode 100644 index 5e958256af..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/tesc/basic.desktop.sso.tesc +++ /dev/null @@ -1,27 +0,0 @@ -#version 450 -layout(vertices = 1) out; - -in gl_PerVertex -{ - vec4 gl_Position; -} gl_in[gl_MaxPatchVertices]; - -out gl_PerVertex -{ - vec4 gl_Position; -} gl_out[1]; - -layout(location = 0) patch out vec3 vFoo; - -void main() -{ - gl_TessLevelInner[0] = 8.8999996185302734375; - gl_TessLevelInner[1] = 6.900000095367431640625; - gl_TessLevelOuter[0] = 8.8999996185302734375; - gl_TessLevelOuter[1] = 6.900000095367431640625; - gl_TessLevelOuter[2] = 3.900000095367431640625; - gl_TessLevelOuter[3] = 4.900000095367431640625; - vFoo = vec3(1.0); - gl_out[gl_InvocationID].gl_Position = gl_in[0].gl_Position + gl_in[1].gl_Position; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/tese/triangle.desktop.sso.tese b/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/tese/triangle.desktop.sso.tese deleted file mode 100644 index 31027dae80..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/tese/triangle.desktop.sso.tese +++ /dev/null @@ -1,18 +0,0 @@ -#version 450 -layout(triangles, cw, fractional_even_spacing) in; - -in gl_PerVertex -{ - vec4 gl_Position; -} gl_in[gl_MaxPatchVertices]; - -out gl_PerVertex -{ - vec4 gl_Position; -}; - -void main() -{ - gl_Position = ((gl_in[0].gl_Position * gl_TessCoord.x) + (gl_in[1].gl_Position * gl_TessCoord.y)) + (gl_in[2].gl_Position * gl_TessCoord.z); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/vert/basic.desktop.sso.vert b/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/vert/basic.desktop.sso.vert deleted file mode 100644 index 5f527e08c1..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/vert/basic.desktop.sso.vert +++ /dev/null @@ -1,22 +0,0 @@ -#version 450 - -out gl_PerVertex -{ - vec4 gl_Position; -}; - -layout(std140) uniform UBO -{ - mat4 uMVP; -} _16; - -layout(location = 0) in vec4 aVertex; -layout(location = 0) out vec3 vNormal; -layout(location = 1) in vec3 aNormal; - -void main() -{ - gl_Position = _16.uMVP * aVertex; - vNormal = aNormal; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/vert/clip-cull-distance.desktop.vert b/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/vert/clip-cull-distance.desktop.vert deleted file mode 100644 index 566809db23..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/vert/clip-cull-distance.desktop.vert +++ /dev/null @@ -1,11 +0,0 @@ -#version 450 - -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; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/vert/out-block-qualifiers.vert b/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/vert/out-block-qualifiers.vert deleted file mode 100644 index 7c731684bc..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/desktop-only/vert/out-block-qualifiers.vert +++ /dev/null @@ -1,27 +0,0 @@ -#version 450 - -layout(location = 0) out VertexData -{ - flat float f; - centroid vec4 g; - flat int h; - float i; -} vout; - -layout(location = 4) flat out float f; -layout(location = 5) centroid out vec4 g; -layout(location = 6) flat out int h; -layout(location = 7) out float i; - -void main() -{ - vout.f = 10.0; - vout.g = vec4(20.0); - vout.h = 20; - vout.i = 30.0; - f = 10.0; - g = vec4(20.0); - h = 20; - i = 30.0; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/flatten/array.flatten.vert b/deps/SPIRV-Cross/reference/opt/shaders/flatten/array.flatten.vert deleted file mode 100644 index de4eb3b78d..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/flatten/array.flatten.vert +++ /dev/null @@ -1,10 +0,0 @@ -#version 310 es - -uniform vec4 UBO[56]; -layout(location = 0) in vec4 aVertex; - -void main() -{ - gl_Position = ((mat4(UBO[40], UBO[41], UBO[42], UBO[43]) * aVertex) + UBO[55]) + ((UBO[50] + UBO[45]) + vec4(UBO[54].x)); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/flatten/basic.flatten.vert b/deps/SPIRV-Cross/reference/opt/shaders/flatten/basic.flatten.vert deleted file mode 100644 index f7eb758f2a..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/flatten/basic.flatten.vert +++ /dev/null @@ -1,13 +0,0 @@ -#version 310 es - -uniform vec4 UBO[4]; -layout(location = 0) in vec4 aVertex; -layout(location = 0) out vec3 vNormal; -layout(location = 1) in vec3 aNormal; - -void main() -{ - gl_Position = mat4(UBO[0], UBO[1], UBO[2], UBO[3]) * aVertex; - vNormal = aNormal; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/flatten/copy.flatten.vert b/deps/SPIRV-Cross/reference/opt/shaders/flatten/copy.flatten.vert deleted file mode 100644 index 59f0dc1b42..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/flatten/copy.flatten.vert +++ /dev/null @@ -1,25 +0,0 @@ -#version 310 es - -struct Light -{ - vec3 Position; - float Radius; - vec4 Color; -}; - -uniform vec4 UBO[12]; -layout(location = 0) in vec4 aVertex; -layout(location = 0) out vec4 vColor; -layout(location = 1) in vec3 aNormal; - -void main() -{ - gl_Position = mat4(UBO[0], UBO[1], UBO[2], UBO[3]) * aVertex; - vColor = vec4(0.0); - for (int _103 = 0; _103 < 4; _103++) - { - vec3 _68 = aVertex.xyz - Light(UBO[_103 * 2 + 4].xyz, UBO[_103 * 2 + 4].w, UBO[_103 * 2 + 5]).Position; - vColor += (((UBO[_103 * 2 + 5]) * clamp(1.0 - (length(_68) / Light(UBO[_103 * 2 + 4].xyz, UBO[_103 * 2 + 4].w, UBO[_103 * 2 + 5]).Radius), 0.0, 1.0)) * dot(aNormal, normalize(_68))); - } -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/flatten/dynamic.flatten.vert b/deps/SPIRV-Cross/reference/opt/shaders/flatten/dynamic.flatten.vert deleted file mode 100644 index c08f7445be..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/flatten/dynamic.flatten.vert +++ /dev/null @@ -1,25 +0,0 @@ -#version 310 es - -struct Light -{ - vec3 Position; - float Radius; - vec4 Color; -}; - -uniform vec4 UBO[12]; -layout(location = 0) in vec4 aVertex; -layout(location = 0) out vec4 vColor; -layout(location = 1) in vec3 aNormal; - -void main() -{ - gl_Position = mat4(UBO[0], UBO[1], UBO[2], UBO[3]) * aVertex; - vColor = vec4(0.0); - for (int _82 = 0; _82 < 4; _82++) - { - vec3 _54 = aVertex.xyz - (UBO[_82 * 2 + 4].xyz); - vColor += (((UBO[_82 * 2 + 5]) * clamp(1.0 - (length(_54) / (UBO[_82 * 2 + 4].w)), 0.0, 1.0)) * dot(aNormal, normalize(_54))); - } -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/flatten/matrixindex.flatten.vert b/deps/SPIRV-Cross/reference/opt/shaders/flatten/matrixindex.flatten.vert deleted file mode 100644 index f6d0fa486d..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/flatten/matrixindex.flatten.vert +++ /dev/null @@ -1,19 +0,0 @@ -#version 310 es - -uniform vec4 UBO[14]; -layout(location = 0) out vec4 oA; -layout(location = 1) out vec4 oB; -layout(location = 2) out vec4 oC; -layout(location = 3) out vec4 oD; -layout(location = 4) out vec4 oE; - -void main() -{ - gl_Position = vec4(0.0); - oA = UBO[1]; - oB = vec4(UBO[4].y, UBO[5].y, UBO[6].y, UBO[7].y); - oC = UBO[9]; - oD = vec4(UBO[10].x, UBO[11].x, UBO[12].x, UBO[13].x); - oE = vec4(UBO[1].z, UBO[6].y, UBO[9].z, UBO[12].y); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/flatten/multi-dimensional.desktop.flatten_dim.frag b/deps/SPIRV-Cross/reference/opt/shaders/flatten/multi-dimensional.desktop.flatten_dim.frag deleted file mode 100644 index 6ccede21a9..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/flatten/multi-dimensional.desktop.flatten_dim.frag +++ /dev/null @@ -1,34 +0,0 @@ -#version 450 - -layout(binding = 0) uniform sampler2D uTextures[2 * 3 * 1]; - -layout(location = 1) in vec2 vUV; -layout(location = 0) out vec4 FragColor; -layout(location = 0) flat in int vIndex; - -int _93; - -void main() -{ - vec4 values3[2 * 3 * 1]; - int _96; - int _97; - int _94; - int _95; - for (int _92 = 0; _92 < 2; _92++, _94 = _96, _95 = _97) - { - _96 = 0; - _97 = _95; - int _98; - for (; _96 < 3; _96++, _97 = _98) - { - _98 = 0; - for (; _98 < 1; _98++) - { - values3[_92 * 3 * 1 + _96 * 1 + _98] = texture(uTextures[_92 * 3 * 1 + _96 * 1 + _98], vUV); - } - } - } - FragColor = ((values3[1 * 3 * 1 + 2 * 1 + 0]) + (values3[0 * 3 * 1 + 2 * 1 + 0])) + (values3[(vIndex + 1) * 3 * 1 + 2 * 1 + vIndex]); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/flatten/multiindex.flatten.vert b/deps/SPIRV-Cross/reference/opt/shaders/flatten/multiindex.flatten.vert deleted file mode 100644 index 3850bf6c70..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/flatten/multiindex.flatten.vert +++ /dev/null @@ -1,10 +0,0 @@ -#version 310 es - -uniform vec4 UBO[15]; -layout(location = 0) in ivec2 aIndex; - -void main() -{ - gl_Position = UBO[aIndex.x * 5 + aIndex.y * 1 + 0]; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/flatten/push-constant.flatten.vert b/deps/SPIRV-Cross/reference/opt/shaders/flatten/push-constant.flatten.vert deleted file mode 100644 index 216c1f9d1b..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/flatten/push-constant.flatten.vert +++ /dev/null @@ -1,13 +0,0 @@ -#version 310 es - -uniform vec4 PushMe[6]; -layout(location = 1) in vec4 Pos; -layout(location = 0) out vec2 vRot; -layout(location = 0) in vec2 Rot; - -void main() -{ - gl_Position = mat4(PushMe[0], PushMe[1], PushMe[2], PushMe[3]) * Pos; - vRot = (mat2(PushMe[4].xy, PushMe[4].zw) * Rot) + vec2(PushMe[5].z); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/flatten/rowmajor.flatten.vert b/deps/SPIRV-Cross/reference/opt/shaders/flatten/rowmajor.flatten.vert deleted file mode 100644 index b74aa004b4..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/flatten/rowmajor.flatten.vert +++ /dev/null @@ -1,10 +0,0 @@ -#version 310 es - -uniform vec4 UBO[12]; -layout(location = 0) in vec4 aVertex; - -void main() -{ - gl_Position = (mat4(UBO[0], UBO[1], UBO[2], UBO[3]) * aVertex) + (aVertex * mat4(UBO[4], UBO[5], UBO[6], UBO[7])); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/flatten/struct.flatten.vert b/deps/SPIRV-Cross/reference/opt/shaders/flatten/struct.flatten.vert deleted file mode 100644 index 35db010c76..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/flatten/struct.flatten.vert +++ /dev/null @@ -1,22 +0,0 @@ -#version 310 es - -struct Light -{ - vec3 Position; - float Radius; - vec4 Color; -}; - -uniform vec4 UBO[6]; -layout(location = 0) in vec4 aVertex; -layout(location = 0) out vec4 vColor; -layout(location = 1) in vec3 aNormal; - -void main() -{ - gl_Position = mat4(UBO[0], UBO[1], UBO[2], UBO[3]) * aVertex; - vColor = vec4(0.0); - vec3 _39 = aVertex.xyz - UBO[4].xyz; - vColor += ((UBO[5] * clamp(1.0 - (length(_39) / UBO[4].w), 0.0, 1.0)) * dot(aNormal, normalize(_39))); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/flatten/struct.rowmajor.flatten.vert b/deps/SPIRV-Cross/reference/opt/shaders/flatten/struct.rowmajor.flatten.vert deleted file mode 100644 index 0dfa3b46ce..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/flatten/struct.rowmajor.flatten.vert +++ /dev/null @@ -1,20 +0,0 @@ -#version 310 es - -struct Foo -{ - mat3x4 MVP0; - mat3x4 MVP1; -}; - -uniform vec4 UBO[8]; -layout(location = 0) in vec4 v0; -layout(location = 1) in vec4 v1; -layout(location = 0) out vec3 V0; -layout(location = 1) out vec3 V1; - -void main() -{ - V0 = v0 * Foo(transpose(mat4x3(UBO[0].xyz, UBO[1].xyz, UBO[2].xyz, UBO[3].xyz)), transpose(mat4x3(UBO[4].xyz, UBO[5].xyz, UBO[6].xyz, UBO[7].xyz))).MVP0; - V1 = v1 * Foo(transpose(mat4x3(UBO[0].xyz, UBO[1].xyz, UBO[2].xyz, UBO[3].xyz)), transpose(mat4x3(UBO[4].xyz, UBO[5].xyz, UBO[6].xyz, UBO[7].xyz))).MVP1; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/flatten/swizzle.flatten.vert b/deps/SPIRV-Cross/reference/opt/shaders/flatten/swizzle.flatten.vert deleted file mode 100644 index 92afb475e6..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/flatten/swizzle.flatten.vert +++ /dev/null @@ -1,21 +0,0 @@ -#version 310 es - -uniform vec4 UBO[8]; -layout(location = 0) out vec4 oA; -layout(location = 1) out vec4 oB; -layout(location = 2) out vec4 oC; -layout(location = 3) out vec4 oD; -layout(location = 4) out vec4 oE; -layout(location = 5) out vec4 oF; - -void main() -{ - gl_Position = vec4(0.0); - oA = UBO[0]; - oB = vec4(UBO[1].xy, UBO[1].zw); - oC = vec4(UBO[2].x, UBO[3].xyz); - oD = vec4(UBO[4].xyz, UBO[4].w); - oE = vec4(UBO[5].x, UBO[5].y, UBO[5].z, UBO[5].w); - oF = vec4(UBO[6].x, UBO[6].zw, UBO[7].x); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/flatten/types.flatten.frag b/deps/SPIRV-Cross/reference/opt/shaders/flatten/types.flatten.frag deleted file mode 100644 index a74327d97b..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/flatten/types.flatten.frag +++ /dev/null @@ -1,14 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -uniform mediump ivec4 UBO1[2]; -uniform mediump uvec4 UBO2[2]; -uniform vec4 UBO0[2]; -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = ((((vec4(UBO1[0]) + vec4(UBO1[1])) + vec4(UBO2[0])) + vec4(UBO2[1])) + UBO0[0]) + UBO0[1]; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/frag/basic.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/basic.frag deleted file mode 100644 index 2a4e440421..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/frag/basic.frag +++ /dev/null @@ -1,15 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(binding = 0) uniform mediump sampler2D uTex; - -layout(location = 0) out vec4 FragColor; -layout(location = 0) in vec4 vColor; -layout(location = 1) in vec2 vTex; - -void main() -{ - FragColor = vColor * texture(uTex, vTex); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/frag/composite-extract-forced-temporary.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/composite-extract-forced-temporary.frag deleted file mode 100644 index eb59732fdc..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/frag/composite-extract-forced-temporary.frag +++ /dev/null @@ -1,16 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(binding = 0) uniform mediump sampler2D Texture; - -layout(location = 0) in vec2 vTexCoord; -layout(location = 0) out vec4 FragColor; - -void main() -{ - vec4 _19 = texture(Texture, vTexCoord); - float _22 = _19.x; - FragColor = vec4(_22 * _22); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/frag/constant-array.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/constant-array.frag deleted file mode 100644 index a6ffda0737..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/frag/constant-array.frag +++ /dev/null @@ -1,21 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -struct Foobar -{ - float a; - float b; -}; - -layout(location = 0) out vec4 FragColor; -layout(location = 0) flat in mediump int index; - -void main() -{ - highp vec4 indexable[3] = vec4[](vec4(1.0), vec4(2.0), vec4(3.0)); - highp vec4 indexable_1[2][2] = vec4[][](vec4[](vec4(1.0), vec4(2.0)), vec4[](vec4(8.0), vec4(10.0))); - Foobar indexable_2[2] = Foobar[](Foobar(10.0, 40.0), Foobar(90.0, 70.0)); - FragColor = ((indexable[index] + (indexable_1[index][index + 1])) + vec4(10.0 + 20.0)) + vec4(indexable_2[index].a + indexable_2[index].b); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/frag/eliminate-dead-variables.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/eliminate-dead-variables.frag deleted file mode 100644 index c97ae20f9a..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/frag/eliminate-dead-variables.frag +++ /dev/null @@ -1,14 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(binding = 0) uniform mediump sampler2D uSampler; - -layout(location = 0) out vec4 FragColor; -layout(location = 0) in vec2 vTexCoord; - -void main() -{ - FragColor = texture(uSampler, vTexCoord); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/frag/false-loop-init.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/false-loop-init.frag deleted file mode 100644 index 1db46c1bd5..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/frag/false-loop-init.frag +++ /dev/null @@ -1,28 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(location = 0) out vec4 result; -layout(location = 0) in vec4 accum; - -uint _49; - -void main() -{ - result = vec4(0.0); - uint _51; - uint _50; - for (int _48 = 0; _48 < 4; _48 += int(_51), _50 = _51) - { - if (accum.y > 10.0) - { - _51 = 40u; - } - else - { - _51 = 30u; - } - result += accum; - } -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/frag/flush_params.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/flush_params.frag deleted file mode 100644 index 5f386dffbb..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/frag/flush_params.frag +++ /dev/null @@ -1,16 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -struct Structy -{ - vec4 c; -}; - -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = vec4(10.0); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/frag/for-loop-init.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/for-loop-init.frag deleted file mode 100644 index 626d7c8d5e..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/frag/for-loop-init.frag +++ /dev/null @@ -1,51 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(location = 0) out mediump int FragColor; - -void main() -{ - FragColor = 16; - for (int _140 = 0; _140 < 25; _140++) - { - FragColor += 10; - } - for (int _141 = 1; _141 < 30; _141++) - { - FragColor += 11; - } - int _142; - _142 = 0; - for (; _142 < 20; _142++) - { - FragColor += 12; - } - mediump int _62 = _142 + 3; - FragColor += _62; - if (_62 == 40) - { - for (int _143 = 0; _143 < 40; _143++) - { - FragColor += 13; - } - return; - } - else - { - FragColor += _62; - } - ivec2 _144; - _144 = ivec2(0); - ivec2 _139; - for (; _144.x < 10; _139 = _144, _139.x = _144.x + 4, _144 = _139) - { - FragColor += _144.y; - } - for (int _145 = _62; _145 < 40; _145++) - { - FragColor += _145; - } - FragColor += _62; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/frag/frexp-modf.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/frexp-modf.frag deleted file mode 100644 index 25f3360aaa..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/frag/frexp-modf.frag +++ /dev/null @@ -1,33 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -struct ResType -{ - highp float _m0; - int _m1; -}; - -struct ResType_1 -{ - highp vec2 _m0; - ivec2 _m1; -}; - -layout(location = 0) in float v0; -layout(location = 1) in vec2 v1; -layout(location = 0) out float FragColor; - -void main() -{ - ResType _22; - _22._m0 = frexp(v0 + 1.0, _22._m1); - ResType_1 _35; - _35._m0 = frexp(v1, _35._m1); - float r0; - float _41 = modf(v0, r0); - vec2 r1; - vec2 _45 = modf(v1, r1); - FragColor = ((((_22._m0 + _35._m0.x) + _35._m0.y) + _41) + _45.x) + _45.y; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/frag/ground.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/ground.frag deleted file mode 100644 index aaca58c1cd..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/frag/ground.frag +++ /dev/null @@ -1,35 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(binding = 4, std140) uniform GlobalPSData -{ - vec4 g_CamPos; - vec4 g_SunDir; - vec4 g_SunColor; - vec4 g_ResolutionParams; - vec4 g_TimeParams; - vec4 g_FogColor_Distance; -} _101; - -layout(binding = 2) uniform mediump sampler2D TexNormalmap; - -layout(location = 3) out vec4 LightingOut; -layout(location = 2) out vec4 NormalOut; -layout(location = 1) out vec4 SpecularOut; -layout(location = 0) out vec4 AlbedoOut; -layout(location = 0) in vec2 TexCoord; -layout(location = 1) in vec3 EyeVec; - -void main() -{ - vec3 _68 = normalize((texture(TexNormalmap, TexCoord).xyz * 2.0) - vec3(1.0)); - float _113 = smoothstep(0.0, 0.1500000059604644775390625, (_101.g_CamPos.y + EyeVec.y) / 200.0); - float _125 = smoothstep(0.699999988079071044921875, 0.75, _68.y); - vec3 _130 = mix(vec3(0.100000001490116119384765625), mix(vec3(0.100000001490116119384765625, 0.300000011920928955078125, 0.100000001490116119384765625), vec3(0.800000011920928955078125), vec3(_113)), vec3(_125)); - LightingOut = vec4(0.0); - NormalOut = vec4((_68 * 0.5) + vec3(0.5), 0.0); - SpecularOut = vec4(1.0 - (_125 * _113), 0.0, 0.0, 0.0); - AlbedoOut = vec4(_130 * _130, 1.0); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/frag/image-load-store-uint-coord.asm.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/image-load-store-uint-coord.asm.frag deleted file mode 100644 index 5dfb4d0028..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/frag/image-load-store-uint-coord.asm.frag +++ /dev/null @@ -1,17 +0,0 @@ -#version 450 - -layout(binding = 1, rgba32f) uniform image2D RWIm; -layout(binding = 0, rgba32f) uniform writeonly imageBuffer RWBuf; -layout(binding = 1) uniform sampler2D ROIm; -layout(binding = 0) uniform samplerBuffer ROBuf; - -layout(location = 0) out vec4 _entryPointOutput; - -void main() -{ - imageStore(RWIm, ivec2(uvec2(10u)), vec4(10.0, 0.5, 8.0, 2.0)); - vec4 _69 = imageLoad(RWIm, ivec2(uvec2(30u))); - imageStore(RWBuf, int(80u), _69); - _entryPointOutput = (_69 + texelFetch(ROIm, ivec2(uvec2(50u, 60u)), 0)) + texelFetch(ROBuf, int(80u)); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/frag/mix.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/mix.frag deleted file mode 100644 index f1494e0775..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/frag/mix.frag +++ /dev/null @@ -1,18 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(location = 0) out vec4 FragColor; -layout(location = 0) in vec4 vIn0; -layout(location = 1) in vec4 vIn1; -layout(location = 2) in float vIn2; -layout(location = 3) in float vIn3; - -void main() -{ - FragColor = mix(vIn0, vIn1, bvec4(false, true, false, false)); - FragColor = vec4(true ? vIn3 : vIn2); - FragColor = mix(vIn1, vIn0, bvec4(true)); - FragColor = vec4(true ? vIn2 : vIn3); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/frag/partial-write-preserve.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/partial-write-preserve.frag deleted file mode 100644 index 527b661bcc..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/frag/partial-write-preserve.frag +++ /dev/null @@ -1,14 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -struct B -{ - float a; - float b; -}; - -void main() -{ -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/frag/pls.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/pls.frag deleted file mode 100644 index 1cafdbd365..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/frag/pls.frag +++ /dev/null @@ -1,21 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(location = 0) out vec4 PLSOut0; -layout(location = 0) in vec4 PLSIn0; -layout(location = 1) out vec4 PLSOut1; -layout(location = 1) in vec4 PLSIn1; -layout(location = 2) out vec4 PLSOut2; -layout(location = 2) in vec4 PLSIn2; -layout(location = 3) out vec4 PLSOut3; -layout(location = 3) in vec4 PLSIn3; - -void main() -{ - PLSOut0 = PLSIn0 * 2.0; - PLSOut1 = PLSIn1 * 6.0; - PLSOut2 = PLSIn2 * 7.0; - PLSOut3 = PLSIn3 * 4.0; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/frag/sample-parameter.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/sample-parameter.frag deleted file mode 100644 index 3c130e68d4..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/frag/sample-parameter.frag +++ /dev/null @@ -1,13 +0,0 @@ -#version 310 es -#extension GL_OES_sample_variables : require -precision mediump float; -precision highp int; - -layout(location = 0) out vec2 FragColor; - -void main() -{ - FragColor = (gl_SamplePosition + vec2(float(gl_SampleMaskIn[0]))) + vec2(float(gl_SampleID)); - gl_SampleMask[0] = 1; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/frag/sampler-ms-query.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/sampler-ms-query.frag deleted file mode 100644 index 4c30ed1529..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/frag/sampler-ms-query.frag +++ /dev/null @@ -1,14 +0,0 @@ -#version 450 - -layout(binding = 0) uniform sampler2DMS uSampler; -layout(binding = 1) uniform sampler2DMSArray uSamplerArray; -layout(binding = 2, rgba8) uniform readonly writeonly image2DMS uImage; -layout(binding = 3, rgba8) uniform readonly writeonly image2DMSArray uImageArray; - -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = vec4(float(((textureSamples(uSampler) + textureSamples(uSamplerArray)) + imageSamples(uImage)) + imageSamples(uImageArray))); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/frag/sampler-ms.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/sampler-ms.frag deleted file mode 100644 index d78b805d09..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/frag/sampler-ms.frag +++ /dev/null @@ -1,14 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(binding = 0) uniform mediump sampler2DMS uSampler; - -layout(location = 0) out vec4 FragColor; - -void main() -{ - ivec2 _17 = ivec2(gl_FragCoord.xy); - FragColor = ((texelFetch(uSampler, _17, 0) + texelFetch(uSampler, _17, 1)) + texelFetch(uSampler, _17, 2)) + texelFetch(uSampler, _17, 3); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/frag/sampler-proj.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/sampler-proj.frag deleted file mode 100644 index 865dec6c8b..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/frag/sampler-proj.frag +++ /dev/null @@ -1,16 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(binding = 0) uniform mediump sampler2D uTex; - -layout(location = 0) out vec4 FragColor; -layout(location = 0) in vec4 vTex; - -void main() -{ - highp vec4 _19 = vTex; - _19.z = vTex.w; - FragColor = textureProj(uTex, _19.xyz); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/frag/sampler.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/sampler.frag deleted file mode 100644 index 2a4e440421..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/frag/sampler.frag +++ /dev/null @@ -1,15 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(binding = 0) uniform mediump sampler2D uTex; - -layout(location = 0) out vec4 FragColor; -layout(location = 0) in vec4 vColor; -layout(location = 1) in vec2 vTex; - -void main() -{ - FragColor = vColor * texture(uTex, vTex); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/frag/swizzle.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/swizzle.frag deleted file mode 100644 index e619be2f48..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/frag/swizzle.frag +++ /dev/null @@ -1,20 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(location = 0) uniform mediump sampler2D samp; - -layout(location = 0) out vec4 FragColor; -layout(location = 2) in vec2 vUV; -layout(location = 1) in vec3 vNormal; - -void main() -{ - FragColor = vec4(texture(samp, vUV).xyz, 1.0); - FragColor = vec4(texture(samp, vUV).xz, 1.0, 4.0); - FragColor = vec4(texture(samp, vUV).xx, texture(samp, vUV + vec2(0.100000001490116119384765625)).yy); - FragColor = vec4(vNormal, 1.0); - FragColor = vec4(vNormal + vec3(1.7999999523162841796875), 1.0); - FragColor = vec4(vUV, vUV + vec2(1.7999999523162841796875)); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/frag/temporary.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/temporary.frag deleted file mode 100644 index ec9d3e4958..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/frag/temporary.frag +++ /dev/null @@ -1,14 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -uniform mediump sampler2D uTex; - -layout(location = 0) in vec2 vTex; -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = vec4(vTex.xxy, 1.0) + vec4(texture(uTex, vTex).xyz, 1.0); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/frag/ubo_layout.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/ubo_layout.frag deleted file mode 100644 index bc0b01c065..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/frag/ubo_layout.frag +++ /dev/null @@ -1,26 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -struct Str -{ - mat4 foo; -}; - -layout(binding = 0, std140) uniform UBO1 -{ - layout(row_major) Str foo; -} ubo1; - -layout(binding = 1, std140) uniform UBO2 -{ - Str foo; -} ubo0; - -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = ubo1.foo.foo[0] + ubo0.foo.foo[0]; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/frag/unary-enclose.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/unary-enclose.frag deleted file mode 100644 index 118787bdf9..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/frag/unary-enclose.frag +++ /dev/null @@ -1,12 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(location = 0) out vec4 FragColor; -layout(location = 0) in vec4 vIn; - -void main() -{ - FragColor = -(-vIn); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/geom/basic.geom b/deps/SPIRV-Cross/reference/opt/shaders/geom/basic.geom deleted file mode 100644 index 296ce5792c..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/geom/basic.geom +++ /dev/null @@ -1,26 +0,0 @@ -#version 310 es -#extension GL_EXT_geometry_shader : require -layout(invocations = 4, triangles) in; -layout(max_vertices = 3, triangle_strip) out; - -layout(location = 0) out vec3 vNormal; -layout(location = 0) in VertexData -{ - vec3 normal; -} vin[3]; - - -void main() -{ - gl_Position = gl_in[0].gl_Position; - vNormal = vin[0].normal + vec3(float(gl_InvocationID)); - EmitVertex(); - gl_Position = gl_in[1].gl_Position; - vNormal = vin[1].normal + vec3(4.0 * float(gl_InvocationID)); - EmitVertex(); - gl_Position = gl_in[2].gl_Position; - vNormal = vin[2].normal + vec3(2.0 * float(gl_InvocationID)); - EmitVertex(); - EndPrimitive(); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/geom/lines-adjacency.geom b/deps/SPIRV-Cross/reference/opt/shaders/geom/lines-adjacency.geom deleted file mode 100644 index 46a21e9fb0..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/geom/lines-adjacency.geom +++ /dev/null @@ -1,26 +0,0 @@ -#version 310 es -#extension GL_EXT_geometry_shader : require -layout(lines_adjacency) in; -layout(max_vertices = 3, line_strip) out; - -layout(location = 0) out vec3 vNormal; -layout(location = 0) in VertexData -{ - vec3 normal; -} vin[4]; - - -void main() -{ - gl_Position = gl_in[0].gl_Position; - vNormal = vin[0].normal; - EmitVertex(); - gl_Position = gl_in[1].gl_Position; - vNormal = vin[1].normal; - EmitVertex(); - gl_Position = gl_in[2].gl_Position; - vNormal = vin[2].normal; - EmitVertex(); - EndPrimitive(); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/geom/lines.geom b/deps/SPIRV-Cross/reference/opt/shaders/geom/lines.geom deleted file mode 100644 index c5aaa53d35..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/geom/lines.geom +++ /dev/null @@ -1,23 +0,0 @@ -#version 310 es -#extension GL_EXT_geometry_shader : require -layout(lines) in; -layout(max_vertices = 2, line_strip) out; - -layout(location = 0) out vec3 vNormal; -layout(location = 0) in VertexData -{ - vec3 normal; -} vin[2]; - - -void main() -{ - gl_Position = gl_in[0].gl_Position; - vNormal = vin[0].normal; - EmitVertex(); - gl_Position = gl_in[1].gl_Position; - vNormal = vin[1].normal; - EmitVertex(); - EndPrimitive(); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/geom/points.geom b/deps/SPIRV-Cross/reference/opt/shaders/geom/points.geom deleted file mode 100644 index 4d59137c3a..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/geom/points.geom +++ /dev/null @@ -1,26 +0,0 @@ -#version 310 es -#extension GL_EXT_geometry_shader : require -layout(points) in; -layout(max_vertices = 3, points) out; - -layout(location = 0) out vec3 vNormal; -layout(location = 0) in VertexData -{ - vec3 normal; -} vin[1]; - - -void main() -{ - gl_Position = gl_in[0].gl_Position; - vNormal = vin[0].normal; - EmitVertex(); - gl_Position = gl_in[0].gl_Position; - vNormal = vin[0].normal; - EmitVertex(); - gl_Position = gl_in[0].gl_Position; - vNormal = vin[0].normal; - EmitVertex(); - EndPrimitive(); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/geom/single-invocation.geom b/deps/SPIRV-Cross/reference/opt/shaders/geom/single-invocation.geom deleted file mode 100644 index fdccacc04f..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/geom/single-invocation.geom +++ /dev/null @@ -1,26 +0,0 @@ -#version 310 es -#extension GL_EXT_geometry_shader : require -layout(triangles) in; -layout(max_vertices = 3, triangle_strip) out; - -layout(location = 0) out vec3 vNormal; -layout(location = 0) in VertexData -{ - vec3 normal; -} vin[3]; - - -void main() -{ - gl_Position = gl_in[0].gl_Position; - vNormal = vin[0].normal; - EmitVertex(); - gl_Position = gl_in[1].gl_Position; - vNormal = vin[1].normal; - EmitVertex(); - gl_Position = gl_in[2].gl_Position; - vNormal = vin[2].normal; - EmitVertex(); - EndPrimitive(); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/geom/triangles-adjacency.geom b/deps/SPIRV-Cross/reference/opt/shaders/geom/triangles-adjacency.geom deleted file mode 100644 index e9e6857a1f..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/geom/triangles-adjacency.geom +++ /dev/null @@ -1,26 +0,0 @@ -#version 310 es -#extension GL_EXT_geometry_shader : require -layout(triangles_adjacency) in; -layout(max_vertices = 3, triangle_strip) out; - -layout(location = 0) out vec3 vNormal; -layout(location = 0) in VertexData -{ - vec3 normal; -} vin[6]; - - -void main() -{ - gl_Position = gl_in[0].gl_Position; - vNormal = vin[0].normal; - EmitVertex(); - gl_Position = gl_in[1].gl_Position; - vNormal = vin[1].normal; - EmitVertex(); - gl_Position = gl_in[2].gl_Position; - vNormal = vin[2].normal; - EmitVertex(); - EndPrimitive(); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/geom/triangles.geom b/deps/SPIRV-Cross/reference/opt/shaders/geom/triangles.geom deleted file mode 100644 index fdccacc04f..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/geom/triangles.geom +++ /dev/null @@ -1,26 +0,0 @@ -#version 310 es -#extension GL_EXT_geometry_shader : require -layout(triangles) in; -layout(max_vertices = 3, triangle_strip) out; - -layout(location = 0) out vec3 vNormal; -layout(location = 0) in VertexData -{ - vec3 normal; -} vin[3]; - - -void main() -{ - gl_Position = gl_in[0].gl_Position; - vNormal = vin[0].normal; - EmitVertex(); - gl_Position = gl_in[1].gl_Position; - vNormal = vin[1].normal; - EmitVertex(); - gl_Position = gl_in[2].gl_Position; - vNormal = vin[2].normal; - EmitVertex(); - EndPrimitive(); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/legacy/fragment/explicit-lod.legacy.frag b/deps/SPIRV-Cross/reference/opt/shaders/legacy/fragment/explicit-lod.legacy.frag deleted file mode 100644 index 6e8dbf1a9c..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/legacy/fragment/explicit-lod.legacy.frag +++ /dev/null @@ -1,12 +0,0 @@ -#version 100 -#extension GL_EXT_shader_texture_lod : require -precision mediump float; -precision highp int; - -uniform mediump sampler2D tex; - -void main() -{ - gl_FragData[0] = texture2DLodEXT(tex, vec2(0.4000000059604644775390625, 0.60000002384185791015625), 0.0); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/legacy/fragment/io-blocks.legacy.frag b/deps/SPIRV-Cross/reference/opt/shaders/legacy/fragment/io-blocks.legacy.frag deleted file mode 100644 index d5a60d53e9..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/legacy/fragment/io-blocks.legacy.frag +++ /dev/null @@ -1,12 +0,0 @@ -#version 100 -precision mediump float; -precision highp int; - -varying vec4 vin_color; -varying highp vec3 vin_normal; - -void main() -{ - gl_FragData[0] = vin_color + vin_normal.xyzz; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/legacy/fragment/struct-varying.legacy.frag b/deps/SPIRV-Cross/reference/opt/shaders/legacy/fragment/struct-varying.legacy.frag deleted file mode 100644 index e131f2e21c..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/legacy/fragment/struct-varying.legacy.frag +++ /dev/null @@ -1,18 +0,0 @@ -#version 100 -precision mediump float; -precision highp int; - -struct Inputs -{ - highp vec4 a; - highp vec2 b; -}; - -varying highp vec4 vin_a; -varying highp vec2 vin_b; - -void main() -{ - gl_FragData[0] = ((((Inputs(vin_a, vin_b).a + Inputs(vin_a, vin_b).b.xxyy) + Inputs(vin_a, vin_b).a) + Inputs(vin_a, vin_b).b.yyxx) + vin_a) + vin_b.xxyy; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/legacy/vert/implicit-lod.legacy.vert b/deps/SPIRV-Cross/reference/opt/shaders/legacy/vert/implicit-lod.legacy.vert deleted file mode 100644 index 6e44107448..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/legacy/vert/implicit-lod.legacy.vert +++ /dev/null @@ -1,9 +0,0 @@ -#version 100 - -uniform mediump sampler2D tex; - -void main() -{ - gl_Position = texture2D(tex, vec2(0.4000000059604644775390625, 0.60000002384185791015625)); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/legacy/vert/io-block.legacy.vert b/deps/SPIRV-Cross/reference/opt/shaders/legacy/vert/io-block.legacy.vert deleted file mode 100644 index 3c518dc79e..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/legacy/vert/io-block.legacy.vert +++ /dev/null @@ -1,13 +0,0 @@ -#version 100 - -attribute vec4 Position; -varying vec4 vout_color; -varying vec3 vout_normal; - -void main() -{ - gl_Position = Position; - vout_color = vec4(1.0); - vout_normal = vec3(0.5); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/legacy/vert/struct-varying.legacy.vert b/deps/SPIRV-Cross/reference/opt/shaders/legacy/vert/struct-varying.legacy.vert deleted file mode 100644 index 8520e2d562..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/legacy/vert/struct-varying.legacy.vert +++ /dev/null @@ -1,30 +0,0 @@ -#version 100 - -struct Output -{ - vec4 a; - vec2 b; -}; - -varying vec4 vout_a; -varying vec2 vout_b; - -void main() -{ - { - Output vout = Output(vec4(0.5), vec2(0.25)); - vout_a = vout.a; - vout_b = vout.b; - } - { - Output vout = Output(vec4(0.5), vec2(0.25)); - vout_a = vout.a; - vout_b = vout.b; - } - Output _22 = Output(vout_a, vout_b); - vout_a = _22.a; - vout_b = _22.b; - vout_a.x = 1.0; - vout_b.y = 1.0; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/legacy/vert/transpose.legacy.vert b/deps/SPIRV-Cross/reference/opt/shaders/legacy/vert/transpose.legacy.vert deleted file mode 100644 index 0d30c0e243..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/legacy/vert/transpose.legacy.vert +++ /dev/null @@ -1,18 +0,0 @@ -#version 100 - -struct Buffer -{ - mat4 MVPRowMajor; - mat4 MVPColMajor; - mat4 M; -}; - -uniform Buffer _13; - -attribute vec4 Position; - -void main() -{ - gl_Position = (((_13.M * (Position * _13.MVPRowMajor)) + (_13.M * (_13.MVPColMajor * Position))) + (_13.M * (_13.MVPRowMajor * Position))) + (_13.M * (Position * _13.MVPColMajor)); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/tesc/basic.tesc b/deps/SPIRV-Cross/reference/opt/shaders/tesc/basic.tesc deleted file mode 100644 index 6019151adb..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/tesc/basic.tesc +++ /dev/null @@ -1,17 +0,0 @@ -#version 310 es -#extension GL_EXT_tessellation_shader : require -layout(vertices = 1) out; - -layout(location = 0) patch out vec3 vFoo; - -void main() -{ - gl_TessLevelInner[0] = 8.8999996185302734375; - gl_TessLevelInner[1] = 6.900000095367431640625; - gl_TessLevelOuter[0] = 8.8999996185302734375; - gl_TessLevelOuter[1] = 6.900000095367431640625; - gl_TessLevelOuter[2] = 3.900000095367431640625; - gl_TessLevelOuter[3] = 4.900000095367431640625; - vFoo = vec3(1.0); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/tesc/water_tess.tesc b/deps/SPIRV-Cross/reference/opt/shaders/tesc/water_tess.tesc deleted file mode 100644 index 0320fff2ca..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/tesc/water_tess.tesc +++ /dev/null @@ -1,79 +0,0 @@ -#version 310 es -#extension GL_EXT_tessellation_shader : require -layout(vertices = 1) out; - -layout(std140) uniform UBO -{ - vec4 uScale; - vec3 uCamPos; - vec2 uPatchSize; - vec2 uMaxTessLevel; - float uDistanceMod; - vec4 uFrustum[6]; -} _41; - -layout(location = 1) patch out vec2 vOutPatchPosBase; -layout(location = 2) patch out vec4 vPatchLods; -layout(location = 0) in vec2 vPatchPosBase[]; - -void main() -{ - vec2 _430 = (vPatchPosBase[0] - vec2(10.0)) * _41.uScale.xy; - vec2 _440 = ((vPatchPosBase[0] + _41.uPatchSize) + vec2(10.0)) * _41.uScale.xy; - vec3 _445 = vec3(_430.x, -10.0, _430.y); - vec3 _450 = vec3(_440.x, 10.0, _440.y); - vec3 _454 = (_445 + _450) * 0.5; - float _459 = 0.5 * length(_450 - _445); - bool _515 = any(lessThanEqual(vec3(dot(_41.uFrustum[0], vec4(_454, 1.0)), dot(_41.uFrustum[1], vec4(_454, 1.0)), dot(_41.uFrustum[2], vec4(_454, 1.0))), vec3(-_459))); - bool _525; - if (!_515) - { - _525 = any(lessThanEqual(vec3(dot(_41.uFrustum[3], vec4(_454, 1.0)), dot(_41.uFrustum[4], vec4(_454, 1.0)), dot(_41.uFrustum[5], vec4(_454, 1.0))), vec3(-_459))); - } - else - { - _525 = _515; - } - if (!(!_525)) - { - gl_TessLevelOuter[0] = -1.0; - gl_TessLevelOuter[1] = -1.0; - gl_TessLevelOuter[2] = -1.0; - gl_TessLevelOuter[3] = -1.0; - gl_TessLevelInner[0] = -1.0; - gl_TessLevelInner[1] = -1.0; - } - else - { - vOutPatchPosBase = vPatchPosBase[0]; - vec2 _678 = (vPatchPosBase[0] + (vec2(-0.5) * _41.uPatchSize)) * _41.uScale.xy; - vec2 _706 = (vPatchPosBase[0] + (vec2(0.5, -0.5) * _41.uPatchSize)) * _41.uScale.xy; - float _725 = clamp(log2((length(_41.uCamPos - vec3(_706.x, 0.0, _706.y)) + 9.9999997473787516355514526367188e-05) * _41.uDistanceMod), 0.0, _41.uMaxTessLevel.x); - vec2 _734 = (vPatchPosBase[0] + (vec2(1.5, -0.5) * _41.uPatchSize)) * _41.uScale.xy; - vec2 _762 = (vPatchPosBase[0] + (vec2(-0.5, 0.5) * _41.uPatchSize)) * _41.uScale.xy; - float _781 = clamp(log2((length(_41.uCamPos - vec3(_762.x, 0.0, _762.y)) + 9.9999997473787516355514526367188e-05) * _41.uDistanceMod), 0.0, _41.uMaxTessLevel.x); - vec2 _790 = (vPatchPosBase[0] + (vec2(0.5) * _41.uPatchSize)) * _41.uScale.xy; - float _809 = clamp(log2((length(_41.uCamPos - vec3(_790.x, 0.0, _790.y)) + 9.9999997473787516355514526367188e-05) * _41.uDistanceMod), 0.0, _41.uMaxTessLevel.x); - vec2 _818 = (vPatchPosBase[0] + (vec2(1.5, 0.5) * _41.uPatchSize)) * _41.uScale.xy; - float _837 = clamp(log2((length(_41.uCamPos - vec3(_818.x, 0.0, _818.y)) + 9.9999997473787516355514526367188e-05) * _41.uDistanceMod), 0.0, _41.uMaxTessLevel.x); - vec2 _846 = (vPatchPosBase[0] + (vec2(-0.5, 1.5) * _41.uPatchSize)) * _41.uScale.xy; - vec2 _874 = (vPatchPosBase[0] + (vec2(0.5, 1.5) * _41.uPatchSize)) * _41.uScale.xy; - float _893 = clamp(log2((length(_41.uCamPos - vec3(_874.x, 0.0, _874.y)) + 9.9999997473787516355514526367188e-05) * _41.uDistanceMod), 0.0, _41.uMaxTessLevel.x); - vec2 _902 = (vPatchPosBase[0] + (vec2(1.5) * _41.uPatchSize)) * _41.uScale.xy; - float _612 = dot(vec4(_781, _809, clamp(log2((length(_41.uCamPos - vec3(_846.x, 0.0, _846.y)) + 9.9999997473787516355514526367188e-05) * _41.uDistanceMod), 0.0, _41.uMaxTessLevel.x), _893), vec4(0.25)); - float _618 = dot(vec4(clamp(log2((length(_41.uCamPos - vec3(_678.x, 0.0, _678.y)) + 9.9999997473787516355514526367188e-05) * _41.uDistanceMod), 0.0, _41.uMaxTessLevel.x), _725, _781, _809), vec4(0.25)); - float _624 = dot(vec4(_725, clamp(log2((length(_41.uCamPos - vec3(_734.x, 0.0, _734.y)) + 9.9999997473787516355514526367188e-05) * _41.uDistanceMod), 0.0, _41.uMaxTessLevel.x), _809, _837), vec4(0.25)); - float _630 = dot(vec4(_809, _837, _893, clamp(log2((length(_41.uCamPos - vec3(_902.x, 0.0, _902.y)) + 9.9999997473787516355514526367188e-05) * _41.uDistanceMod), 0.0, _41.uMaxTessLevel.x)), vec4(0.25)); - vec4 _631 = vec4(_612, _618, _624, _630); - vPatchLods = _631; - vec4 _928 = exp2(-min(_631, _631.yzwx)) * _41.uMaxTessLevel.y; - gl_TessLevelOuter[0] = _928.x; - gl_TessLevelOuter[1] = _928.y; - gl_TessLevelOuter[2] = _928.z; - gl_TessLevelOuter[3] = _928.w; - float _935 = _41.uMaxTessLevel.y * exp2(-min(min(min(_612, _618), min(_624, _630)), _809)); - gl_TessLevelInner[0] = _935; - gl_TessLevelInner[1] = _935; - } -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/tese/ccw.tese b/deps/SPIRV-Cross/reference/opt/shaders/tese/ccw.tese deleted file mode 100644 index a2a4508ac0..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/tese/ccw.tese +++ /dev/null @@ -1,9 +0,0 @@ -#version 310 es -#extension GL_EXT_tessellation_shader : require -layout(triangles, ccw, fractional_even_spacing) in; - -void main() -{ - gl_Position = vec4(1.0); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/tese/cw.tese b/deps/SPIRV-Cross/reference/opt/shaders/tese/cw.tese deleted file mode 100644 index 95781493d8..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/tese/cw.tese +++ /dev/null @@ -1,9 +0,0 @@ -#version 310 es -#extension GL_EXT_tessellation_shader : require -layout(triangles, cw, fractional_even_spacing) in; - -void main() -{ - gl_Position = vec4(1.0); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/tese/equal.tese b/deps/SPIRV-Cross/reference/opt/shaders/tese/equal.tese deleted file mode 100644 index 6d30518a30..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/tese/equal.tese +++ /dev/null @@ -1,9 +0,0 @@ -#version 310 es -#extension GL_EXT_tessellation_shader : require -layout(triangles, cw, equal_spacing) in; - -void main() -{ - gl_Position = vec4(1.0); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/tese/fractional_even.tese b/deps/SPIRV-Cross/reference/opt/shaders/tese/fractional_even.tese deleted file mode 100644 index 95781493d8..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/tese/fractional_even.tese +++ /dev/null @@ -1,9 +0,0 @@ -#version 310 es -#extension GL_EXT_tessellation_shader : require -layout(triangles, cw, fractional_even_spacing) in; - -void main() -{ - gl_Position = vec4(1.0); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/tese/fractional_odd.tese b/deps/SPIRV-Cross/reference/opt/shaders/tese/fractional_odd.tese deleted file mode 100644 index 608c19aba7..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/tese/fractional_odd.tese +++ /dev/null @@ -1,9 +0,0 @@ -#version 310 es -#extension GL_EXT_tessellation_shader : require -layout(triangles, cw, fractional_odd_spacing) in; - -void main() -{ - gl_Position = vec4(1.0); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/tese/line.tese b/deps/SPIRV-Cross/reference/opt/shaders/tese/line.tese deleted file mode 100644 index 8b6ad8da20..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/tese/line.tese +++ /dev/null @@ -1,9 +0,0 @@ -#version 310 es -#extension GL_EXT_tessellation_shader : require -layout(isolines, point_mode, fractional_even_spacing) in; - -void main() -{ - gl_Position = vec4(1.0); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/tese/triangle.tese b/deps/SPIRV-Cross/reference/opt/shaders/tese/triangle.tese deleted file mode 100644 index 95781493d8..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/tese/triangle.tese +++ /dev/null @@ -1,9 +0,0 @@ -#version 310 es -#extension GL_EXT_tessellation_shader : require -layout(triangles, cw, fractional_even_spacing) in; - -void main() -{ - gl_Position = vec4(1.0); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/tese/water_tess.tese b/deps/SPIRV-Cross/reference/opt/shaders/tese/water_tess.tese deleted file mode 100644 index 6efa9f0a69..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/tese/water_tess.tese +++ /dev/null @@ -1,37 +0,0 @@ -#version 310 es -#extension GL_EXT_tessellation_shader : require -layout(quads, cw, fractional_even_spacing) in; - -layout(binding = 1, std140) uniform UBO -{ - mat4 uMVP; - vec4 uScale; - vec2 uInvScale; - vec3 uCamPos; - vec2 uPatchSize; - vec2 uInvHeightmapSize; -} _31; - -layout(binding = 0) uniform mediump sampler2D uHeightmapDisplacement; - -layout(location = 0) patch in vec2 vOutPatchPosBase; -layout(location = 1) patch in vec4 vPatchLods; -layout(location = 1) out vec4 vGradNormalTex; -layout(location = 0) out vec3 vWorld; - -void main() -{ - vec2 _201 = vOutPatchPosBase + (gl_TessCoord.xy * _31.uPatchSize); - vec2 _214 = mix(vPatchLods.yx, vPatchLods.zw, vec2(gl_TessCoord.xy.x)); - float _221 = mix(_214.x, _214.y, gl_TessCoord.xy.y); - mediump float _223 = floor(_221); - mediump float _226 = _221 - _223; - vec2 _125 = _201 * _31.uInvHeightmapSize; - vec2 _141 = _31.uInvHeightmapSize * exp2(_223); - vGradNormalTex = vec4(_125 + (_31.uInvHeightmapSize * 0.5), _125 * _31.uScale.zw); - mediump vec3 _253 = mix(textureLod(uHeightmapDisplacement, _125 + (_141 * 0.5), _223).xyz, textureLod(uHeightmapDisplacement, _125 + (_141 * 1.0), _223 + 1.0).xyz, vec3(_226)); - vec2 _171 = (_201 * _31.uScale.xy) + _253.yz; - vWorld = vec3(_171.x, _253.x, _171.y); - gl_Position = _31.uMVP * vec4(vWorld, 1.0); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/vert/basic.vert b/deps/SPIRV-Cross/reference/opt/shaders/vert/basic.vert deleted file mode 100644 index 05504eb2f2..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/vert/basic.vert +++ /dev/null @@ -1,17 +0,0 @@ -#version 310 es - -layout(std140) uniform UBO -{ - mat4 uMVP; -} _16; - -layout(location = 0) in vec4 aVertex; -layout(location = 0) out vec3 vNormal; -layout(location = 1) in vec3 aNormal; - -void main() -{ - gl_Position = _16.uMVP * aVertex; - vNormal = aNormal; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/vert/ground.vert b/deps/SPIRV-Cross/reference/opt/shaders/vert/ground.vert deleted file mode 100644 index 790c4c8249..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/vert/ground.vert +++ /dev/null @@ -1,87 +0,0 @@ -#version 310 es - -struct PatchData -{ - vec4 Position; - vec4 LODs; -}; - -layout(binding = 0, std140) uniform PerPatch -{ - PatchData Patches[256]; -} _53; - -layout(binding = 2, std140) uniform GlobalGround -{ - vec4 GroundScale; - vec4 GroundPosition; - vec4 InvGroundSize_PatchScale; -} _156; - -layout(binding = 0, std140) uniform GlobalVSData -{ - vec4 g_ViewProj_Row0; - vec4 g_ViewProj_Row1; - vec4 g_ViewProj_Row2; - vec4 g_ViewProj_Row3; - vec4 g_CamPos; - vec4 g_CamRight; - vec4 g_CamUp; - vec4 g_CamFront; - vec4 g_SunDir; - vec4 g_SunColor; - vec4 g_TimeParams; - vec4 g_ResolutionParams; - vec4 g_CamAxisRight; - vec4 g_FogColor_Distance; - vec4 g_ShadowVP_Row0; - vec4 g_ShadowVP_Row1; - vec4 g_ShadowVP_Row2; - vec4 g_ShadowVP_Row3; -} _236; - -layout(binding = 1) uniform mediump sampler2D TexLOD; -layout(binding = 0) uniform mediump sampler2D TexHeightmap; - -layout(location = 1) in vec4 LODWeights; -uniform int SPIRV_Cross_BaseInstance; -layout(location = 0) in vec2 Position; -layout(location = 1) out vec3 EyeVec; -layout(location = 0) out vec2 TexCoord; - -void main() -{ - float _300 = all(equal(LODWeights, vec4(0.0))) ? _53.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].Position.w : dot(LODWeights, _53.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].LODs); - float _302 = floor(_300); - uint _307 = uint(_302); - uvec2 _309 = uvec2(Position); - uvec2 _316 = (uvec2(1u) << uvec2(_307, _307 + 1u)) - uvec2(1u); - uint _395; - if (_309.x < 32u) - { - _395 = _316.x; - } - else - { - _395 = 0u; - } - uint _396; - if (_309.y < 32u) - { - _396 = _316.y; - } - else - { - _396 = 0u; - } - vec4 _344 = vec4((_309 + uvec2(_395, _396)).xyxy & (~_316).xxyy); - vec2 _173 = ((_53.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].Position.xz * _156.InvGroundSize_PatchScale.zw) + mix(_344.xy, _344.zw, vec2(_300 - _302))) * _156.InvGroundSize_PatchScale.xy; - mediump float _360 = textureLod(TexLOD, _173, 0.0).x * 7.96875; - float _362 = floor(_360); - vec2 _185 = _156.InvGroundSize_PatchScale.xy * exp2(_362); - vec3 _230 = (vec3(_173.x, mix(textureLod(TexHeightmap, _173 + (_185 * 0.5), _362).x, textureLod(TexHeightmap, _173 + (_185 * 1.0), _362 + 1.0).x, _360 - _362), _173.y) * _156.GroundScale.xyz) + _156.GroundPosition.xyz; - EyeVec = _230 - _236.g_CamPos.xyz; - TexCoord = _173 + (_156.InvGroundSize_PatchScale.xy * 0.5); - gl_Position = (((_236.g_ViewProj_Row0 * _230.x) + (_236.g_ViewProj_Row1 * _230.y)) + (_236.g_ViewProj_Row2 * _230.z)) + _236.g_ViewProj_Row3; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/vert/ocean.vert b/deps/SPIRV-Cross/reference/opt/shaders/vert/ocean.vert deleted file mode 100644 index d37a0a8a4c..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/vert/ocean.vert +++ /dev/null @@ -1,117 +0,0 @@ -#version 310 es - -struct PatchData -{ - vec4 Position; - vec4 LODs; -}; - -layout(binding = 0, std140) uniform Offsets -{ - PatchData Patches[256]; -} _53; - -layout(binding = 4, std140) uniform GlobalOcean -{ - vec4 OceanScale; - vec4 OceanPosition; - vec4 InvOceanSize_PatchScale; - vec4 NormalTexCoordScale; -} _180; - -layout(binding = 0, std140) uniform GlobalVSData -{ - vec4 g_ViewProj_Row0; - vec4 g_ViewProj_Row1; - vec4 g_ViewProj_Row2; - vec4 g_ViewProj_Row3; - vec4 g_CamPos; - vec4 g_CamRight; - vec4 g_CamUp; - vec4 g_CamFront; - vec4 g_SunDir; - vec4 g_SunColor; - vec4 g_TimeParams; - vec4 g_ResolutionParams; - vec4 g_CamAxisRight; - vec4 g_FogColor_Distance; - vec4 g_ShadowVP_Row0; - vec4 g_ShadowVP_Row1; - vec4 g_ShadowVP_Row2; - vec4 g_ShadowVP_Row3; -} _273; - -layout(binding = 1) uniform mediump sampler2D TexLOD; -layout(binding = 0) uniform mediump sampler2D TexDisplacement; - -layout(location = 1) in vec4 LODWeights; -uniform int SPIRV_Cross_BaseInstance; -layout(location = 0) in vec4 Position; -layout(location = 0) out vec3 EyeVec; -layout(location = 1) out vec4 TexCoord; - -uvec4 _483; - -void main() -{ - float _350 = all(equal(LODWeights, vec4(0.0))) ? _53.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].Position.w : dot(LODWeights, _53.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].LODs); - float _352 = floor(_350); - uint _357 = uint(_352); - uvec4 _359 = uvec4(Position); - uvec2 _366 = (uvec2(1u) << uvec2(_357, _357 + 1u)) - uvec2(1u); - uint _482; - if (_359.x < 32u) - { - _482 = _366.x; - } - else - { - _482 = 0u; - } - uvec4 _445 = _483; - _445.x = _482; - uint _484; - if (_359.y < 32u) - { - _484 = _366.x; - } - else - { - _484 = 0u; - } - uvec4 _451 = _445; - _451.y = _484; - uint _485; - if (_359.x < 32u) - { - _485 = _366.y; - } - else - { - _485 = 0u; - } - uvec4 _457 = _451; - _457.z = _485; - uint _486; - if (_359.y < 32u) - { - _486 = _366.y; - } - else - { - _486 = 0u; - } - uvec4 _463 = _457; - _463.w = _486; - vec4 _415 = vec4((_359.xyxy + _463) & (~_366).xxyy); - vec2 _197 = ((_53.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].Position.xz * _180.InvOceanSize_PatchScale.zw) + mix(_415.xy, _415.zw, vec2(_350 - _352))) * _180.InvOceanSize_PatchScale.xy; - vec2 _204 = _197 * _180.NormalTexCoordScale.zw; - mediump float _431 = textureLod(TexLOD, _197, 0.0).x * 7.96875; - float _433 = floor(_431); - vec2 _220 = (_180.InvOceanSize_PatchScale.xy * exp2(_433)) * _180.NormalTexCoordScale.zw; - vec3 _267 = ((vec3(_197.x, 0.0, _197.y) + mix(textureLod(TexDisplacement, _204 + (_220 * 0.5), _433).yxz, textureLod(TexDisplacement, _204 + (_220 * 1.0), _433 + 1.0).yxz, vec3(_431 - _433))) * _180.OceanScale.xyz) + _180.OceanPosition.xyz; - EyeVec = _267 - _273.g_CamPos.xyz; - TexCoord = vec4(_204, _204 * _180.NormalTexCoordScale.xy) + ((_180.InvOceanSize_PatchScale.xyxy * 0.5) * _180.NormalTexCoordScale.zwzw); - gl_Position = (((_273.g_ViewProj_Row0 * _267.x) + (_273.g_ViewProj_Row1 * _267.y)) + (_273.g_ViewProj_Row2 * _267.z)) + _273.g_ViewProj_Row3; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/vert/texture_buffer.vert b/deps/SPIRV-Cross/reference/opt/shaders/vert/texture_buffer.vert deleted file mode 100644 index e9442ce119..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/vert/texture_buffer.vert +++ /dev/null @@ -1,11 +0,0 @@ -#version 310 es -#extension GL_OES_texture_buffer : require - -layout(binding = 4) uniform highp samplerBuffer uSamp; -layout(binding = 5, rgba32f) uniform readonly highp imageBuffer uSampo; - -void main() -{ - gl_Position = texelFetch(uSamp, 10) + imageLoad(uSampo, 100); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/vert/ubo.vert b/deps/SPIRV-Cross/reference/opt/shaders/vert/ubo.vert deleted file mode 100644 index 4e7236b290..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/vert/ubo.vert +++ /dev/null @@ -1,17 +0,0 @@ -#version 310 es - -layout(binding = 0, std140) uniform UBO -{ - mat4 mvp; -} _16; - -layout(location = 0) in vec4 aVertex; -layout(location = 0) out vec3 vNormal; -layout(location = 1) in vec3 aNormal; - -void main() -{ - gl_Position = _16.mvp * aVertex; - vNormal = aNormal; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag b/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag deleted file mode 100644 index f0729fdcdf..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag +++ /dev/null @@ -1,14 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -uniform mediump sampler2DShadow SPIRV_Cross_CombineduDepthuSampler; -uniform mediump sampler2D SPIRV_Cross_CombineduDepthuSampler1; - -layout(location = 0) out float FragColor; - -void main() -{ - FragColor = texture(SPIRV_Cross_CombineduDepthuSampler, vec3(vec3(1.0).xy, 1.0)) + texture(SPIRV_Cross_CombineduDepthuSampler1, vec2(1.0)).x; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag.vk b/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag.vk deleted file mode 100644 index b6ad1e39c4..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag.vk +++ /dev/null @@ -1,15 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(set = 0, binding = 2) uniform mediump texture2D uDepth; -layout(set = 0, binding = 0) uniform mediump samplerShadow uSampler; -layout(set = 0, binding = 1) uniform mediump sampler uSampler1; - -layout(location = 0) out float FragColor; - -void main() -{ - FragColor = texture(sampler2DShadow(uDepth, uSampler), vec3(vec3(1.0).xy, 1.0)) + texture(sampler2D(uDepth, uSampler1), vec2(1.0)).x; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/combined-texture-sampler.vk.frag b/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/combined-texture-sampler.vk.frag deleted file mode 100644 index 29c247d6d9..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/combined-texture-sampler.vk.frag +++ /dev/null @@ -1,17 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -uniform mediump sampler2D SPIRV_Cross_CombineduTexture0uSampler0; -uniform mediump sampler2D SPIRV_Cross_CombineduTexture1uSampler1; -uniform mediump sampler2D SPIRV_Cross_CombineduTexture1uSampler0; -uniform mediump sampler2D SPIRV_Cross_CombineduTexture0uSampler1; - -layout(location = 0) in vec2 vTex; -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = ((((texture(SPIRV_Cross_CombineduTexture0uSampler0, vTex) + texture(SPIRV_Cross_CombineduTexture1uSampler1, vTex)) + (texture(SPIRV_Cross_CombineduTexture0uSampler0, vTex) + texture(SPIRV_Cross_CombineduTexture1uSampler0, vTex))) + (texture(SPIRV_Cross_CombineduTexture0uSampler1, vTex) + texture(SPIRV_Cross_CombineduTexture1uSampler1, vTex))) + (texture(SPIRV_Cross_CombineduTexture0uSampler0, vTex) + texture(SPIRV_Cross_CombineduTexture0uSampler1, vTex))) + (texture(SPIRV_Cross_CombineduTexture1uSampler0, vTex) + texture(SPIRV_Cross_CombineduTexture1uSampler1, vTex)); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/combined-texture-sampler.vk.frag.vk b/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/combined-texture-sampler.vk.frag.vk deleted file mode 100644 index 7a543c4168..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/combined-texture-sampler.vk.frag.vk +++ /dev/null @@ -1,17 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(set = 0, binding = 2) uniform mediump texture2D uTexture0; -layout(set = 0, binding = 3) uniform mediump texture2D uTexture1; -layout(set = 0, binding = 0) uniform mediump sampler uSampler0; -layout(set = 0, binding = 1) uniform mediump sampler uSampler1; - -layout(location = 0) in vec2 vTex; -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = ((((texture(sampler2D(uTexture0, uSampler0), vTex) + texture(sampler2D(uTexture1, uSampler1), vTex)) + (texture(sampler2D(uTexture0, uSampler0), vTex) + texture(sampler2D(uTexture1, uSampler0), vTex))) + (texture(sampler2D(uTexture0, uSampler1), vTex) + texture(sampler2D(uTexture1, uSampler1), vTex))) + (texture(sampler2D(uTexture0, uSampler0), vTex) + texture(sampler2D(uTexture0, uSampler1), vTex))) + (texture(sampler2D(uTexture1, uSampler0), vTex) + texture(sampler2D(uTexture1, uSampler1), vTex)); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/desktop-mediump.vk.frag b/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/desktop-mediump.vk.frag deleted file mode 100644 index 8f7508ee8e..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/desktop-mediump.vk.frag +++ /dev/null @@ -1,12 +0,0 @@ -#version 450 - -layout(location = 0) out vec4 FragColor; -layout(location = 0) in vec4 F; -layout(location = 1) flat in ivec4 I; -layout(location = 2) flat in uvec4 U; - -void main() -{ - FragColor = (F + vec4(I)) + vec4(U); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/desktop-mediump.vk.frag.vk b/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/desktop-mediump.vk.frag.vk deleted file mode 100644 index 4c0506b110..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/desktop-mediump.vk.frag.vk +++ /dev/null @@ -1,12 +0,0 @@ -#version 450 - -layout(location = 0) out mediump vec4 FragColor; -layout(location = 0) in mediump vec4 F; -layout(location = 1) flat in mediump ivec4 I; -layout(location = 2) flat in mediump uvec4 U; - -void main() -{ - FragColor = (F + vec4(I)) + vec4(U); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/input-attachment-ms.vk.frag b/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/input-attachment-ms.vk.frag deleted file mode 100644 index ea460c1fae..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/input-attachment-ms.vk.frag +++ /dev/null @@ -1,12 +0,0 @@ -#version 450 - -layout(binding = 0) uniform sampler2DMS uSubpass0; -layout(binding = 1) uniform sampler2DMS uSubpass1; - -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = (texelFetch(uSubpass0, ivec2(gl_FragCoord.xy), 1) + texelFetch(uSubpass1, ivec2(gl_FragCoord.xy), 2)) + texelFetch(uSubpass0, ivec2(gl_FragCoord.xy), gl_SampleID); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/input-attachment-ms.vk.frag.vk b/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/input-attachment-ms.vk.frag.vk deleted file mode 100644 index 462df22a19..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/input-attachment-ms.vk.frag.vk +++ /dev/null @@ -1,12 +0,0 @@ -#version 450 - -layout(input_attachment_index = 0, set = 0, binding = 0) uniform subpassInputMS uSubpass0; -layout(input_attachment_index = 1, set = 0, binding = 1) uniform subpassInputMS uSubpass1; - -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = (subpassLoad(uSubpass0, 1) + subpassLoad(uSubpass1, 2)) + subpassLoad(uSubpass0, gl_SampleID); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/input-attachment.vk.frag b/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/input-attachment.vk.frag deleted file mode 100644 index 8d216b2c49..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/input-attachment.vk.frag +++ /dev/null @@ -1,14 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(binding = 0) uniform mediump sampler2D uSubpass0; -layout(binding = 1) uniform mediump sampler2D uSubpass1; - -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = texelFetch(uSubpass0, ivec2(gl_FragCoord.xy), 0) + texelFetch(uSubpass1, ivec2(gl_FragCoord.xy), 0); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/input-attachment.vk.frag.vk b/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/input-attachment.vk.frag.vk deleted file mode 100644 index c8b5d9a70d..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/input-attachment.vk.frag.vk +++ /dev/null @@ -1,14 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(input_attachment_index = 0, set = 0, binding = 0) uniform mediump subpassInput uSubpass0; -layout(input_attachment_index = 1, set = 0, binding = 1) uniform mediump subpassInput uSubpass1; - -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = subpassLoad(uSubpass0) + subpassLoad(uSubpass1); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/push-constant.vk.frag b/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/push-constant.vk.frag deleted file mode 100644 index c04a7ca488..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/push-constant.vk.frag +++ /dev/null @@ -1,20 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -struct PushConstants -{ - vec4 value0; - vec4 value1; -}; - -uniform PushConstants push; - -layout(location = 0) out vec4 FragColor; -layout(location = 0) in vec4 vColor; - -void main() -{ - FragColor = (vColor + push.value0) + push.value1; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/push-constant.vk.frag.vk b/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/push-constant.vk.frag.vk deleted file mode 100644 index 6cec90f19e..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/push-constant.vk.frag.vk +++ /dev/null @@ -1,18 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(push_constant, std430) uniform PushConstants -{ - vec4 value0; - vec4 value1; -} push; - -layout(location = 0) out vec4 FragColor; -layout(location = 0) in vec4 vColor; - -void main() -{ - FragColor = (vColor + push.value0) + push.value1; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/separate-sampler-texture.vk.frag b/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/separate-sampler-texture.vk.frag deleted file mode 100644 index a52d5bc77c..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/separate-sampler-texture.vk.frag +++ /dev/null @@ -1,20 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -uniform mediump sampler2D SPIRV_Cross_CombineduTextureuSampler; -uniform mediump sampler2DArray SPIRV_Cross_CombineduTextureArrayuSampler; -uniform mediump samplerCube SPIRV_Cross_CombineduTextureCubeuSampler; -uniform mediump sampler3D SPIRV_Cross_CombineduTexture3DuSampler; - -layout(location = 0) in vec2 vTex; -layout(location = 1) in vec3 vTex3; -layout(location = 0) out vec4 FragColor; - -void main() -{ - vec2 _54 = vec2(1.0) / vec2(textureSize(SPIRV_Cross_CombineduTextureuSampler, 0)); - vec2 _64 = vec2(1.0) / vec2(textureSize(SPIRV_Cross_CombineduTextureuSampler, 1)); - FragColor = (((texture(SPIRV_Cross_CombineduTextureuSampler, (vTex + _54) + _64) + texture(SPIRV_Cross_CombineduTextureuSampler, (vTex + _54) + _64)) + texture(SPIRV_Cross_CombineduTextureArrayuSampler, vTex3)) + texture(SPIRV_Cross_CombineduTextureCubeuSampler, vTex3)) + texture(SPIRV_Cross_CombineduTexture3DuSampler, vTex3); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/separate-sampler-texture.vk.frag.vk b/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/separate-sampler-texture.vk.frag.vk deleted file mode 100644 index 105ca76e44..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/separate-sampler-texture.vk.frag.vk +++ /dev/null @@ -1,21 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(set = 0, binding = 1) uniform mediump texture2D uTexture; -layout(set = 0, binding = 0) uniform mediump sampler uSampler; -layout(set = 0, binding = 4) uniform mediump texture2DArray uTextureArray; -layout(set = 0, binding = 3) uniform mediump textureCube uTextureCube; -layout(set = 0, binding = 2) uniform mediump texture3D uTexture3D; - -layout(location = 0) in vec2 vTex; -layout(location = 1) in vec3 vTex3; -layout(location = 0) out vec4 FragColor; - -void main() -{ - vec2 _54 = vec2(1.0) / vec2(textureSize(sampler2D(uTexture, uSampler), 0)); - vec2 _64 = vec2(1.0) / vec2(textureSize(sampler2D(uTexture, uSampler), 1)); - FragColor = (((texture(sampler2D(uTexture, uSampler), (vTex + _54) + _64) + texture(sampler2D(uTexture, uSampler), (vTex + _54) + _64)) + texture(sampler2DArray(uTextureArray, uSampler), vTex3)) + texture(samplerCube(uTextureCube, uSampler), vTex3)) + texture(sampler3D(uTexture3D, uSampler), vTex3); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/spec-constant.vk.frag b/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/spec-constant.vk.frag deleted file mode 100644 index 4f9b6f515f..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/spec-constant.vk.frag +++ /dev/null @@ -1,20 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -struct Foo -{ - float elems[(4 + 2)]; -}; - -layout(location = 0) out vec4 FragColor; - -float _146[(3 + 2)]; - -void main() -{ - float vec0[(3 + 3)][8]; - Foo foo; - FragColor = ((vec4(1.0 + 2.0) + vec4(vec0[0][0])) + vec4(_146[0])) + vec4(foo.elems[3]); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/spec-constant.vk.frag.vk b/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/spec-constant.vk.frag.vk deleted file mode 100644 index 0b74896aef..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/spec-constant.vk.frag.vk +++ /dev/null @@ -1,25 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(constant_id = 1) const float a = 1.0; -layout(constant_id = 2) const float b = 2.0; -layout(constant_id = 3) const int c = 3; -layout(constant_id = 4) const int d = 4; - -struct Foo -{ - float elems[(d + 2)]; -}; - -layout(location = 0) out vec4 FragColor; - -float _146[(c + 2)]; - -void main() -{ - float vec0[(c + 3)][8]; - Foo foo; - FragColor = ((vec4(a + b) + vec4(vec0[0][0])) + vec4(_146[0])) + vec4(foo.elems[c]); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/vert/multiview.nocompat.vk.vert b/deps/SPIRV-Cross/reference/opt/shaders/vulkan/vert/multiview.nocompat.vk.vert deleted file mode 100644 index 533738efc3..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/vert/multiview.nocompat.vk.vert +++ /dev/null @@ -1,15 +0,0 @@ -#version 310 es -#extension GL_OVR_multiview2 : require - -layout(binding = 0, std140) uniform MVPs -{ - mat4 MVP[2]; -} _19; - -layout(location = 0) in vec4 Position; - -void main() -{ - gl_Position = _19.MVP[gl_ViewID_OVR] * Position; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/vert/multiview.nocompat.vk.vert.vk b/deps/SPIRV-Cross/reference/opt/shaders/vulkan/vert/multiview.nocompat.vk.vert.vk deleted file mode 100644 index 90055473d9..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/vert/multiview.nocompat.vk.vert.vk +++ /dev/null @@ -1,15 +0,0 @@ -#version 310 es -#extension GL_EXT_multiview : require - -layout(set = 0, binding = 0, std140) uniform MVPs -{ - mat4 MVP[2]; -} _19; - -layout(location = 0) in vec4 Position; - -void main() -{ - gl_Position = _19.MVP[gl_ViewIndex] * Position; -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/vert/vulkan-vertex.vk.vert b/deps/SPIRV-Cross/reference/opt/shaders/vulkan/vert/vulkan-vertex.vk.vert deleted file mode 100644 index 60ba1882f8..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/vert/vulkan-vertex.vk.vert +++ /dev/null @@ -1,9 +0,0 @@ -#version 310 es - -uniform int SPIRV_Cross_BaseInstance; - -void main() -{ - gl_Position = vec4(1.0, 2.0, 3.0, 4.0) * float(gl_VertexID + (gl_InstanceID + SPIRV_Cross_BaseInstance)); -} - diff --git a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/vert/vulkan-vertex.vk.vert.vk b/deps/SPIRV-Cross/reference/opt/shaders/vulkan/vert/vulkan-vertex.vk.vert.vk deleted file mode 100644 index 8c4930d7a8..0000000000 --- a/deps/SPIRV-Cross/reference/opt/shaders/vulkan/vert/vulkan-vertex.vk.vert.vk +++ /dev/null @@ -1,7 +0,0 @@ -#version 310 es - -void main() -{ - gl_Position = vec4(1.0, 2.0, 3.0, 4.0) * float(gl_VertexIndex + gl_InstanceIndex); -} - diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/asm/comp/specialization-constant-workgroup.nofxc.asm.comp b/deps/SPIRV-Cross/reference/shaders-hlsl/asm/comp/specialization-constant-workgroup.nofxc.asm.comp deleted file mode 100644 index 8243347bf6..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/asm/comp/specialization-constant-workgroup.nofxc.asm.comp +++ /dev/null @@ -1,16 +0,0 @@ -static const uint _5 = 9u; -static const uint _6 = 4u; -static const uint3 gl_WorkGroupSize = uint3(_5, 20u, _6); - -RWByteAddressBuffer _4 : register(u0); - -void comp_main() -{ - _4.Store(0, asuint(asfloat(_4.Load(0)) + 1.0f)); -} - -[numthreads(9, 20, 4)] -void main() -{ - comp_main(); -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/asm/comp/storage-buffer-basic.nofxc.asm.comp b/deps/SPIRV-Cross/reference/shaders-hlsl/asm/comp/storage-buffer-basic.nofxc.asm.comp deleted file mode 100644 index 1887eaa88f..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/asm/comp/storage-buffer-basic.nofxc.asm.comp +++ /dev/null @@ -1,26 +0,0 @@ -static const uint _3 = 1u; -static const uint _4 = 3u; -static const uint3 gl_WorkGroupSize = uint3(_3, 2u, _4); - -RWByteAddressBuffer _8 : register(u0); -RWByteAddressBuffer _9 : register(u1); - -static uint3 gl_WorkGroupID; -struct SPIRV_Cross_Input -{ - uint3 gl_WorkGroupID : SV_GroupID; -}; - -static uint3 _22 = gl_WorkGroupSize; - -void comp_main() -{ - _8.Store(gl_WorkGroupID.x * 4 + 0, asuint(asfloat(_9.Load(gl_WorkGroupID.x * 4 + 0)) + asfloat(_8.Load(gl_WorkGroupID.x * 4 + 0)))); -} - -[numthreads(1, 2, 3)] -void main(SPIRV_Cross_Input stage_input) -{ - gl_WorkGroupID = stage_input.gl_WorkGroupID; - comp_main(); -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/asm/frag/cbuffer-stripped.asm.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/asm/frag/cbuffer-stripped.asm.frag deleted file mode 100644 index 851dfa1aa8..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/asm/frag/cbuffer-stripped.asm.frag +++ /dev/null @@ -1,31 +0,0 @@ -cbuffer _5 : register(b0) -{ - column_major float2x4 _5_m0 : packoffset(c0); - float4 _5_m1 : packoffset(c4); -}; - -static float2 _3; - -struct SPIRV_Cross_Output -{ - float2 _3 : SV_Target0; -}; - -float2 _23() -{ - float2 _25 = mul(_5_m0, _5_m1); - return _25; -} - -void frag_main() -{ - _3 = _23(); -} - -SPIRV_Cross_Output main() -{ - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output._3 = _3; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/asm/frag/unreachable.asm.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/asm/frag/unreachable.asm.frag deleted file mode 100644 index c2fa519df8..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/asm/frag/unreachable.asm.frag +++ /dev/null @@ -1,44 +0,0 @@ -static int counter; -static float4 FragColor; - -struct SPIRV_Cross_Input -{ - nointerpolation int counter : TEXCOORD0; -}; - -struct SPIRV_Cross_Output -{ - float4 FragColor : SV_Target0; -}; - -float4 _21; - -void frag_main() -{ - float4 _24; - _24 = _21; - float4 _33; - for (;;) - { - if (counter == 10) - { - _33 = 10.0f.xxxx; - break; - } - else - { - _33 = 30.0f.xxxx; - break; - } - } - FragColor = _33; -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - counter = stage_input.counter; - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/asm/vert/empty-struct-composite.asm.vert b/deps/SPIRV-Cross/reference/shaders-hlsl/asm/vert/empty-struct-composite.asm.vert deleted file mode 100644 index 103ff46a3f..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/asm/vert/empty-struct-composite.asm.vert +++ /dev/null @@ -1,8 +0,0 @@ -void vert_main() -{ -} - -void main() -{ - vert_main(); -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/asm/vert/vertex-id-instance-id.asm.vert b/deps/SPIRV-Cross/reference/shaders-hlsl/asm/vert/vertex-id-instance-id.asm.vert deleted file mode 100644 index 8d5e771fe4..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/asm/vert/vertex-id-instance-id.asm.vert +++ /dev/null @@ -1,28 +0,0 @@ -static float4 gl_Position; -static int gl_VertexID; -static int gl_InstanceID; -struct SPIRV_Cross_Input -{ - uint gl_VertexID : SV_VertexID; - uint gl_InstanceID : SV_InstanceID; -}; - -struct SPIRV_Cross_Output -{ - float4 gl_Position : SV_Position; -}; - -void vert_main() -{ - gl_Position = float(gl_VertexID + gl_InstanceID).xxxx; -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - gl_VertexID = int(stage_input.gl_VertexID); - gl_InstanceID = int(stage_input.gl_InstanceID); - vert_main(); - SPIRV_Cross_Output stage_output; - stage_output.gl_Position = gl_Position; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/comp/access-chains.comp b/deps/SPIRV-Cross/reference/shaders-hlsl/comp/access-chains.comp deleted file mode 100644 index 924e919124..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/comp/access-chains.comp +++ /dev/null @@ -1,21 +0,0 @@ -RWByteAddressBuffer wo : register(u1); -ByteAddressBuffer ro : register(t0); - -static uint3 gl_GlobalInvocationID; -struct SPIRV_Cross_Input -{ - uint3 gl_GlobalInvocationID : SV_DispatchThreadID; -}; - -void comp_main() -{ - wo.Store4(gl_GlobalInvocationID.x * 64 + 272, asuint(asfloat(ro.Load4(gl_GlobalInvocationID.x * 64 + 160)))); - wo.Store4(gl_GlobalInvocationID.x * 16 + 480, asuint(asfloat(ro.Load4(gl_GlobalInvocationID.x * 16 + 480)))); -} - -[numthreads(1, 1, 1)] -void main(SPIRV_Cross_Input stage_input) -{ - gl_GlobalInvocationID = stage_input.gl_GlobalInvocationID; - comp_main(); -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/comp/address-buffers.comp b/deps/SPIRV-Cross/reference/shaders-hlsl/comp/address-buffers.comp deleted file mode 100644 index a252fc8ae3..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/comp/address-buffers.comp +++ /dev/null @@ -1,15 +0,0 @@ -RWByteAddressBuffer WriteOnly : register(u2); -ByteAddressBuffer ReadOnly : register(t0); -RWByteAddressBuffer ReadWrite : register(u1); - -void comp_main() -{ - WriteOnly.Store4(0, asuint(asfloat(ReadOnly.Load4(0)))); - ReadWrite.Store4(0, asuint(asfloat(ReadWrite.Load4(0)) + 10.0f.xxxx)); -} - -[numthreads(1, 1, 1)] -void main() -{ - comp_main(); -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/comp/atomic.comp b/deps/SPIRV-Cross/reference/shaders-hlsl/comp/atomic.comp deleted file mode 100644 index 72e15bf77d..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/comp/atomic.comp +++ /dev/null @@ -1,89 +0,0 @@ -RWByteAddressBuffer ssbo : register(u2); -RWTexture2D uImage : register(u0); -RWTexture2D iImage : register(u1); - -groupshared int int_atomic; -groupshared uint uint_atomic; -groupshared int int_atomic_array[1]; -groupshared uint uint_atomic_array[1]; - -void comp_main() -{ - uint _19; - InterlockedAdd(uImage[int2(1, 5)], 1u, _19); - uint _27; - InterlockedAdd(uImage[int2(1, 5)], 1u, _27); - iImage[int2(1, 6)] = int(_27).x; - uint _32; - InterlockedOr(uImage[int2(1, 5)], 1u, _32); - uint _34; - InterlockedXor(uImage[int2(1, 5)], 1u, _34); - uint _36; - InterlockedAnd(uImage[int2(1, 5)], 1u, _36); - uint _38; - InterlockedMin(uImage[int2(1, 5)], 1u, _38); - uint _40; - InterlockedMax(uImage[int2(1, 5)], 1u, _40); - uint _44; - InterlockedCompareExchange(uImage[int2(1, 5)], 10u, 2u, _44); - int _47; - InterlockedAdd(iImage[int2(1, 6)], 1, _47); - int _49; - InterlockedOr(iImage[int2(1, 6)], 1, _49); - int _51; - InterlockedXor(iImage[int2(1, 6)], 1, _51); - int _53; - InterlockedAnd(iImage[int2(1, 6)], 1, _53); - int _55; - InterlockedMin(iImage[int2(1, 6)], 1, _55); - int _57; - InterlockedMax(iImage[int2(1, 6)], 1, _57); - int _61; - InterlockedCompareExchange(iImage[int2(1, 5)], 10, 2, _61); - uint _68; - ssbo.InterlockedAdd(0, 1u, _68); - uint _70; - ssbo.InterlockedOr(0, 1u, _70); - uint _72; - ssbo.InterlockedXor(0, 1u, _72); - uint _74; - ssbo.InterlockedAnd(0, 1u, _74); - uint _76; - ssbo.InterlockedMin(0, 1u, _76); - uint _78; - ssbo.InterlockedMax(0, 1u, _78); - uint _80; - ssbo.InterlockedExchange(0, 1u, _80); - uint _82; - ssbo.InterlockedCompareExchange(0, 10u, 2u, _82); - int _85; - ssbo.InterlockedAdd(4, 1, _85); - int _87; - ssbo.InterlockedOr(4, 1, _87); - int _89; - ssbo.InterlockedXor(4, 1, _89); - int _91; - ssbo.InterlockedAnd(4, 1, _91); - int _93; - ssbo.InterlockedMin(4, 1, _93); - int _95; - ssbo.InterlockedMax(4, 1, _95); - int _97; - ssbo.InterlockedExchange(4, 1, _97); - int _99; - ssbo.InterlockedCompareExchange(4, 10, 2, _99); - int _102; - InterlockedAdd(int_atomic, 10, _102); - uint _105; - InterlockedAdd(uint_atomic, 10u, _105); - int _110; - InterlockedAdd(int_atomic_array[0], 10, _110); - uint _115; - InterlockedAdd(uint_atomic_array[0], 10u, _115); -} - -[numthreads(1, 1, 1)] -void main() -{ - comp_main(); -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/comp/barriers.comp b/deps/SPIRV-Cross/reference/shaders-hlsl/comp/barriers.comp deleted file mode 100644 index 15af8ac11d..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/comp/barriers.comp +++ /dev/null @@ -1,81 +0,0 @@ -static const uint3 gl_WorkGroupSize = uint3(4u, 1u, 1u); - -void barrier_shared() -{ - GroupMemoryBarrier(); -} - -void full_barrier() -{ - AllMemoryBarrier(); -} - -void image_barrier() -{ - DeviceMemoryBarrier(); -} - -void buffer_barrier() -{ - DeviceMemoryBarrier(); -} - -void group_barrier() -{ - AllMemoryBarrier(); -} - -void barrier_shared_exec() -{ - GroupMemoryBarrierWithGroupSync(); -} - -void full_barrier_exec() -{ - AllMemoryBarrier(); - GroupMemoryBarrierWithGroupSync(); -} - -void image_barrier_exec() -{ - DeviceMemoryBarrier(); - GroupMemoryBarrierWithGroupSync(); -} - -void buffer_barrier_exec() -{ - DeviceMemoryBarrier(); - GroupMemoryBarrierWithGroupSync(); -} - -void group_barrier_exec() -{ - AllMemoryBarrier(); - GroupMemoryBarrierWithGroupSync(); -} - -void exec_barrier() -{ - GroupMemoryBarrierWithGroupSync(); -} - -void comp_main() -{ - barrier_shared(); - full_barrier(); - image_barrier(); - buffer_barrier(); - group_barrier(); - barrier_shared_exec(); - full_barrier_exec(); - image_barrier_exec(); - buffer_barrier_exec(); - group_barrier_exec(); - exec_barrier(); -} - -[numthreads(4, 1, 1)] -void main() -{ - comp_main(); -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/comp/bitfield.noopt.comp b/deps/SPIRV-Cross/reference/shaders-hlsl/comp/bitfield.noopt.comp deleted file mode 100644 index 6839d9569e..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/comp/bitfield.noopt.comp +++ /dev/null @@ -1,113 +0,0 @@ -uint SPIRV_Cross_bitfieldInsert(uint Base, uint Insert, uint Offset, uint Count) -{ - uint Mask = Count == 32 ? 0xffffffff : (((1u << Count) - 1) << (Offset & 31)); - return (Base & ~Mask) | ((Insert << Offset) & Mask); -} - -uint2 SPIRV_Cross_bitfieldInsert(uint2 Base, uint2 Insert, uint Offset, uint Count) -{ - uint Mask = Count == 32 ? 0xffffffff : (((1u << Count) - 1) << (Offset & 31)); - return (Base & ~Mask) | ((Insert << Offset) & Mask); -} - -uint3 SPIRV_Cross_bitfieldInsert(uint3 Base, uint3 Insert, uint Offset, uint Count) -{ - uint Mask = Count == 32 ? 0xffffffff : (((1u << Count) - 1) << (Offset & 31)); - return (Base & ~Mask) | ((Insert << Offset) & Mask); -} - -uint4 SPIRV_Cross_bitfieldInsert(uint4 Base, uint4 Insert, uint Offset, uint Count) -{ - uint Mask = Count == 32 ? 0xffffffff : (((1u << Count) - 1) << (Offset & 31)); - return (Base & ~Mask) | ((Insert << Offset) & Mask); -} - -uint SPIRV_Cross_bitfieldUExtract(uint Base, uint Offset, uint Count) -{ - uint Mask = Count == 32 ? 0xffffffff : ((1 << Count) - 1); - return (Base >> Offset) & Mask; -} - -uint2 SPIRV_Cross_bitfieldUExtract(uint2 Base, uint Offset, uint Count) -{ - uint Mask = Count == 32 ? 0xffffffff : ((1 << Count) - 1); - return (Base >> Offset) & Mask; -} - -uint3 SPIRV_Cross_bitfieldUExtract(uint3 Base, uint Offset, uint Count) -{ - uint Mask = Count == 32 ? 0xffffffff : ((1 << Count) - 1); - return (Base >> Offset) & Mask; -} - -uint4 SPIRV_Cross_bitfieldUExtract(uint4 Base, uint Offset, uint Count) -{ - uint Mask = Count == 32 ? 0xffffffff : ((1 << Count) - 1); - return (Base >> Offset) & Mask; -} - -int SPIRV_Cross_bitfieldSExtract(int Base, int Offset, int Count) -{ - int Mask = Count == 32 ? -1 : ((1 << Count) - 1); - int Masked = (Base >> Offset) & Mask; - int ExtendShift = (32 - Count) & 31; - return (Masked << ExtendShift) >> ExtendShift; -} - -int2 SPIRV_Cross_bitfieldSExtract(int2 Base, int Offset, int Count) -{ - int Mask = Count == 32 ? -1 : ((1 << Count) - 1); - int2 Masked = (Base >> Offset) & Mask; - int ExtendShift = (32 - Count) & 31; - return (Masked << ExtendShift) >> ExtendShift; -} - -int3 SPIRV_Cross_bitfieldSExtract(int3 Base, int Offset, int Count) -{ - int Mask = Count == 32 ? -1 : ((1 << Count) - 1); - int3 Masked = (Base >> Offset) & Mask; - int ExtendShift = (32 - Count) & 31; - return (Masked << ExtendShift) >> ExtendShift; -} - -int4 SPIRV_Cross_bitfieldSExtract(int4 Base, int Offset, int Count) -{ - int Mask = Count == 32 ? -1 : ((1 << Count) - 1); - int4 Masked = (Base >> Offset) & Mask; - int ExtendShift = (32 - Count) & 31; - return (Masked << ExtendShift) >> ExtendShift; -} - -void comp_main() -{ - int signed_value = 0; - uint unsigned_value = 0u; - int3 signed_values = int3(0, 0, 0); - uint3 unsigned_values = uint3(0u, 0u, 0u); - int s = SPIRV_Cross_bitfieldSExtract(signed_value, 5, 20); - uint u = SPIRV_Cross_bitfieldUExtract(unsigned_value, 6, 21); - s = int(SPIRV_Cross_bitfieldInsert(s, 40, 5, 4)); - u = SPIRV_Cross_bitfieldInsert(u, 60u, 5, 4); - u = reversebits(u); - s = reversebits(s); - int v0 = countbits(u); - int v1 = countbits(s); - int v2 = firstbithigh(u); - int v3 = firstbitlow(s); - int3 s_1 = SPIRV_Cross_bitfieldSExtract(signed_values, 5, 20); - uint3 u_1 = SPIRV_Cross_bitfieldUExtract(unsigned_values, 6, 21); - s_1 = int3(SPIRV_Cross_bitfieldInsert(s_1, int3(40, 40, 40), 5, 4)); - u_1 = SPIRV_Cross_bitfieldInsert(u_1, uint3(60u, 60u, 60u), 5, 4); - u_1 = reversebits(u_1); - s_1 = reversebits(s_1); - int3 v0_1 = countbits(u_1); - int3 v1_1 = countbits(s_1); - int3 v2_1 = firstbithigh(u_1); - int3 v3_1 = firstbitlow(s_1); -} - -[numthreads(1, 1, 1)] -void main() -{ - comp_main(); -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/comp/builtins.comp b/deps/SPIRV-Cross/reference/shaders-hlsl/comp/builtins.comp deleted file mode 100644 index 5d84883b2f..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/comp/builtins.comp +++ /dev/null @@ -1,32 +0,0 @@ -static const uint3 gl_WorkGroupSize = uint3(8u, 4u, 2u); - -static uint3 gl_WorkGroupID; -static uint3 gl_LocalInvocationID; -static uint3 gl_GlobalInvocationID; -static uint gl_LocalInvocationIndex; -struct SPIRV_Cross_Input -{ - uint3 gl_WorkGroupID : SV_GroupID; - uint3 gl_LocalInvocationID : SV_GroupThreadID; - uint3 gl_GlobalInvocationID : SV_DispatchThreadID; - uint gl_LocalInvocationIndex : SV_GroupIndex; -}; - -void comp_main() -{ - uint3 local_id = gl_LocalInvocationID; - uint3 global_id = gl_GlobalInvocationID; - uint local_index = gl_LocalInvocationIndex; - uint3 work_group_size = gl_WorkGroupSize; - uint3 work_group_id = gl_WorkGroupID; -} - -[numthreads(8, 4, 2)] -void main(SPIRV_Cross_Input stage_input) -{ - gl_WorkGroupID = stage_input.gl_WorkGroupID; - gl_LocalInvocationID = stage_input.gl_LocalInvocationID; - gl_GlobalInvocationID = stage_input.gl_GlobalInvocationID; - gl_LocalInvocationIndex = stage_input.gl_LocalInvocationIndex; - comp_main(); -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/comp/image.comp b/deps/SPIRV-Cross/reference/shaders-hlsl/comp/image.comp deleted file mode 100644 index c8504e636c..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/comp/image.comp +++ /dev/null @@ -1,71 +0,0 @@ -RWTexture2D uImageInF : register(u0); -RWTexture2D uImageOutF : register(u1); -RWTexture2D uImageInI : register(u2); -RWTexture2D uImageOutI : register(u3); -RWTexture2D uImageInU : register(u4); -RWTexture2D uImageOutU : register(u5); -RWBuffer uImageInBuffer : register(u6); -RWBuffer uImageOutBuffer : register(u7); -RWTexture2D uImageInF2 : register(u8); -RWTexture2D uImageOutF2 : register(u9); -RWTexture2D uImageInI2 : register(u10); -RWTexture2D uImageOutI2 : register(u11); -RWTexture2D uImageInU2 : register(u12); -RWTexture2D uImageOutU2 : register(u13); -RWBuffer uImageInBuffer2 : register(u14); -RWBuffer uImageOutBuffer2 : register(u15); -RWTexture2D uImageInF4 : register(u16); -RWTexture2D uImageOutF4 : register(u17); -RWTexture2D uImageInI4 : register(u18); -RWTexture2D uImageOutI4 : register(u19); -RWTexture2D uImageInU4 : register(u20); -RWTexture2D uImageOutU4 : register(u21); -RWBuffer uImageInBuffer4 : register(u22); -RWBuffer uImageOutBuffer4 : register(u23); -RWTexture2D uImageNoFmtF : register(u24); -RWTexture2D uImageNoFmtU : register(u25); -RWTexture2D uImageNoFmtI : register(u26); - -static uint3 gl_GlobalInvocationID; -struct SPIRV_Cross_Input -{ - uint3 gl_GlobalInvocationID : SV_DispatchThreadID; -}; - -void comp_main() -{ - float4 f = uImageInF[int2(gl_GlobalInvocationID.xy)].xxxx; - uImageOutF[int2(gl_GlobalInvocationID.xy)] = f.x; - int4 i = uImageInI[int2(gl_GlobalInvocationID.xy)].xxxx; - uImageOutI[int2(gl_GlobalInvocationID.xy)] = i.x; - uint4 u = uImageInU[int2(gl_GlobalInvocationID.xy)].xxxx; - uImageOutU[int2(gl_GlobalInvocationID.xy)] = u.x; - float4 b = uImageInBuffer[int(gl_GlobalInvocationID.x)].xxxx; - uImageOutBuffer[int(gl_GlobalInvocationID.x)] = b.x; - float4 f2 = uImageInF2[int2(gl_GlobalInvocationID.xy)].xyyy; - uImageOutF2[int2(gl_GlobalInvocationID.xy)] = f2.xy; - int4 i2 = uImageInI2[int2(gl_GlobalInvocationID.xy)].xyyy; - uImageOutI2[int2(gl_GlobalInvocationID.xy)] = i2.xy; - uint4 u2 = uImageInU2[int2(gl_GlobalInvocationID.xy)].xyyy; - uImageOutU2[int2(gl_GlobalInvocationID.xy)] = u2.xy; - float4 b2 = uImageInBuffer2[int(gl_GlobalInvocationID.x)].xyyy; - uImageOutBuffer2[int(gl_GlobalInvocationID.x)] = b2.xy; - float4 f4 = uImageInF4[int2(gl_GlobalInvocationID.xy)]; - uImageOutF4[int2(gl_GlobalInvocationID.xy)] = f4; - int4 i4 = uImageInI4[int2(gl_GlobalInvocationID.xy)]; - uImageOutI4[int2(gl_GlobalInvocationID.xy)] = i4; - uint4 u4 = uImageInU4[int2(gl_GlobalInvocationID.xy)]; - uImageOutU4[int2(gl_GlobalInvocationID.xy)] = u4; - float4 b4 = uImageInBuffer4[int(gl_GlobalInvocationID.x)]; - uImageOutBuffer4[int(gl_GlobalInvocationID.x)] = b4; - uImageNoFmtF[int2(gl_GlobalInvocationID.xy)] = b2; - uImageNoFmtU[int2(gl_GlobalInvocationID.xy)] = u4; - uImageNoFmtI[int2(gl_GlobalInvocationID.xy)] = i4; -} - -[numthreads(1, 1, 1)] -void main(SPIRV_Cross_Input stage_input) -{ - gl_GlobalInvocationID = stage_input.gl_GlobalInvocationID; - comp_main(); -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/comp/rwbuffer-matrix.comp b/deps/SPIRV-Cross/reference/shaders-hlsl/comp/rwbuffer-matrix.comp deleted file mode 100644 index 0e352f1f83..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/comp/rwbuffer-matrix.comp +++ /dev/null @@ -1,136 +0,0 @@ -RWByteAddressBuffer _28 : register(u0); -cbuffer _68 : register(b1) -{ - int _68_index0 : packoffset(c0); - int _68_index1 : packoffset(c0.y); -}; - -void row_to_col() -{ - float4x4 _55 = asfloat(uint4x4(_28.Load(64), _28.Load(80), _28.Load(96), _28.Load(112), _28.Load(68), _28.Load(84), _28.Load(100), _28.Load(116), _28.Load(72), _28.Load(88), _28.Load(104), _28.Load(120), _28.Load(76), _28.Load(92), _28.Load(108), _28.Load(124))); - _28.Store4(0, asuint(_55[0])); - _28.Store4(16, asuint(_55[1])); - _28.Store4(32, asuint(_55[2])); - _28.Store4(48, asuint(_55[3])); - float2x2 _58 = asfloat(uint2x2(_28.Load(144), _28.Load(152), _28.Load(148), _28.Load(156))); - _28.Store2(128, asuint(_58[0])); - _28.Store2(136, asuint(_58[1])); - float2x3 _61 = asfloat(uint2x3(_28.Load(192), _28.Load(200), _28.Load(208), _28.Load(196), _28.Load(204), _28.Load(212))); - _28.Store3(160, asuint(_61[0])); - _28.Store3(176, asuint(_61[1])); - float3x2 _64 = asfloat(uint3x2(_28.Load(240), _28.Load(256), _28.Load(244), _28.Load(260), _28.Load(248), _28.Load(264))); - _28.Store2(216, asuint(_64[0])); - _28.Store2(224, asuint(_64[1])); - _28.Store2(232, asuint(_64[2])); -} - -void col_to_row() -{ - float4x4 _34 = asfloat(uint4x4(_28.Load4(0), _28.Load4(16), _28.Load4(32), _28.Load4(48))); - _28.Store(64, asuint(_34[0].x)); - _28.Store(68, asuint(_34[1].x)); - _28.Store(72, asuint(_34[2].x)); - _28.Store(76, asuint(_34[3].x)); - _28.Store(80, asuint(_34[0].y)); - _28.Store(84, asuint(_34[1].y)); - _28.Store(88, asuint(_34[2].y)); - _28.Store(92, asuint(_34[3].y)); - _28.Store(96, asuint(_34[0].z)); - _28.Store(100, asuint(_34[1].z)); - _28.Store(104, asuint(_34[2].z)); - _28.Store(108, asuint(_34[3].z)); - _28.Store(112, asuint(_34[0].w)); - _28.Store(116, asuint(_34[1].w)); - _28.Store(120, asuint(_34[2].w)); - _28.Store(124, asuint(_34[3].w)); - float2x2 _40 = asfloat(uint2x2(_28.Load2(128), _28.Load2(136))); - _28.Store(144, asuint(_40[0].x)); - _28.Store(148, asuint(_40[1].x)); - _28.Store(152, asuint(_40[0].y)); - _28.Store(156, asuint(_40[1].y)); - float2x3 _46 = asfloat(uint2x3(_28.Load3(160), _28.Load3(176))); - _28.Store(192, asuint(_46[0].x)); - _28.Store(196, asuint(_46[1].x)); - _28.Store(200, asuint(_46[0].y)); - _28.Store(204, asuint(_46[1].y)); - _28.Store(208, asuint(_46[0].z)); - _28.Store(212, asuint(_46[1].z)); - float3x2 _52 = asfloat(uint3x2(_28.Load2(216), _28.Load2(224), _28.Load2(232))); - _28.Store(240, asuint(_52[0].x)); - _28.Store(244, asuint(_52[1].x)); - _28.Store(248, asuint(_52[2].x)); - _28.Store(256, asuint(_52[0].y)); - _28.Store(260, asuint(_52[1].y)); - _28.Store(264, asuint(_52[2].y)); -} - -void write_dynamic_index_row() -{ - _28.Store(_68_index0 * 4 + _68_index1 * 16 + 64, asuint(1.0f)); - _28.Store(_68_index0 * 4 + _68_index1 * 8 + 144, asuint(2.0f)); - _28.Store(_68_index0 * 4 + _68_index1 * 8 + 192, asuint(3.0f)); - _28.Store(_68_index0 * 4 + _68_index1 * 16 + 240, asuint(4.0f)); - _28.Store(_68_index0 * 4 + 64, asuint(1.0f.x)); - _28.Store(_68_index0 * 4 + 80, asuint(1.0f.xxxx.y)); - _28.Store(_68_index0 * 4 + 96, asuint(1.0f.xxxx.z)); - _28.Store(_68_index0 * 4 + 112, asuint(1.0f.xxxx.w)); - _28.Store(_68_index0 * 4 + 144, asuint(2.0f.x)); - _28.Store(_68_index0 * 4 + 152, asuint(2.0f.xx.y)); - _28.Store(_68_index0 * 4 + 192, asuint(3.0f.x)); - _28.Store(_68_index0 * 4 + 200, asuint(3.0f.xxx.y)); - _28.Store(_68_index0 * 4 + 208, asuint(3.0f.xxx.z)); - _28.Store(_68_index0 * 4 + 240, asuint(4.0f.x)); - _28.Store(_68_index0 * 4 + 256, asuint(4.0f.xx.y)); -} - -void write_dynamic_index_col() -{ - _28.Store(_68_index0 * 16 + _68_index1 * 4 + 0, asuint(1.0f)); - _28.Store(_68_index0 * 8 + _68_index1 * 4 + 128, asuint(2.0f)); - _28.Store(_68_index0 * 16 + _68_index1 * 4 + 160, asuint(3.0f)); - _28.Store(_68_index0 * 8 + _68_index1 * 4 + 216, asuint(4.0f)); - _28.Store4(_68_index0 * 16 + 0, asuint(1.0f.xxxx)); - _28.Store2(_68_index0 * 8 + 128, asuint(2.0f.xx)); - _28.Store3(_68_index0 * 16 + 160, asuint(3.0f.xxx)); - _28.Store2(_68_index0 * 8 + 216, asuint(4.0f.xx)); -} - -void read_dynamic_index_row() -{ - float a0 = asfloat(_28.Load(_68_index0 * 4 + _68_index1 * 16 + 64)); - float a1 = asfloat(_28.Load(_68_index0 * 4 + _68_index1 * 8 + 144)); - float a2 = asfloat(_28.Load(_68_index0 * 4 + _68_index1 * 8 + 192)); - float a3 = asfloat(_28.Load(_68_index0 * 4 + _68_index1 * 16 + 240)); - float4 v0 = asfloat(uint4(_28.Load(_68_index0 * 4 + 64), _28.Load(_68_index0 * 4 + 80), _28.Load(_68_index0 * 4 + 96), _28.Load(_68_index0 * 4 + 112))); - float2 v1 = asfloat(uint2(_28.Load(_68_index0 * 4 + 144), _28.Load(_68_index0 * 4 + 152))); - float3 v2 = asfloat(uint3(_28.Load(_68_index0 * 4 + 192), _28.Load(_68_index0 * 4 + 200), _28.Load(_68_index0 * 4 + 208))); - float2 v3 = asfloat(uint2(_28.Load(_68_index0 * 4 + 240), _28.Load(_68_index0 * 4 + 256))); -} - -void read_dynamic_index_col() -{ - float a0 = asfloat(_28.Load(_68_index0 * 16 + _68_index1 * 4 + 0)); - float a1 = asfloat(_28.Load(_68_index0 * 8 + _68_index1 * 4 + 128)); - float a2 = asfloat(_28.Load(_68_index0 * 16 + _68_index1 * 4 + 160)); - float a3 = asfloat(_28.Load(_68_index0 * 8 + _68_index1 * 4 + 216)); - float4 v0 = asfloat(_28.Load4(_68_index0 * 16 + 0)); - float2 v1 = asfloat(_28.Load2(_68_index0 * 8 + 128)); - float3 v2 = asfloat(_28.Load3(_68_index0 * 16 + 160)); - float2 v3 = asfloat(_28.Load2(_68_index0 * 8 + 216)); -} - -void comp_main() -{ - row_to_col(); - col_to_row(); - write_dynamic_index_row(); - write_dynamic_index_col(); - read_dynamic_index_row(); - read_dynamic_index_col(); -} - -[numthreads(1, 1, 1)] -void main() -{ - comp_main(); -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/comp/shared.comp b/deps/SPIRV-Cross/reference/shaders-hlsl/comp/shared.comp deleted file mode 100644 index 5d12900382..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/comp/shared.comp +++ /dev/null @@ -1,31 +0,0 @@ -static const uint3 gl_WorkGroupSize = uint3(4u, 1u, 1u); - -ByteAddressBuffer _22 : register(t0); -RWByteAddressBuffer _44 : register(u1); - -static uint3 gl_GlobalInvocationID; -static uint gl_LocalInvocationIndex; -struct SPIRV_Cross_Input -{ - uint3 gl_GlobalInvocationID : SV_DispatchThreadID; - uint gl_LocalInvocationIndex : SV_GroupIndex; -}; - -groupshared float sShared[4]; - -void comp_main() -{ - uint ident = gl_GlobalInvocationID.x; - float idata = asfloat(_22.Load(ident * 4 + 0)); - sShared[gl_LocalInvocationIndex] = idata; - GroupMemoryBarrierWithGroupSync(); - _44.Store(ident * 4 + 0, asuint(sShared[(4u - gl_LocalInvocationIndex) - 1u])); -} - -[numthreads(4, 1, 1)] -void main(SPIRV_Cross_Input stage_input) -{ - gl_GlobalInvocationID = stage_input.gl_GlobalInvocationID; - gl_LocalInvocationIndex = stage_input.gl_LocalInvocationIndex; - comp_main(); -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/comp/ssbo-array.comp b/deps/SPIRV-Cross/reference/shaders-hlsl/comp/ssbo-array.comp deleted file mode 100644 index 90927421c6..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/comp/ssbo-array.comp +++ /dev/null @@ -1,11 +0,0 @@ -RWByteAddressBuffer ssbo0 : register(u0); - -void comp_main() -{ -} - -[numthreads(1, 1, 1)] -void main() -{ - comp_main(); -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/basic.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/basic.frag deleted file mode 100644 index 6d067041c2..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/basic.frag +++ /dev/null @@ -1,32 +0,0 @@ -Texture2D uTex : register(t0); -SamplerState _uTex_sampler : register(s0); - -static float4 FragColor; -static float4 vColor; -static float2 vTex; - -struct SPIRV_Cross_Input -{ - float4 vColor : TEXCOORD0; - float2 vTex : TEXCOORD1; -}; - -struct SPIRV_Cross_Output -{ - float4 FragColor : SV_Target0; -}; - -void frag_main() -{ - FragColor = vColor * uTex.Sample(_uTex_sampler, vTex); -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - vColor = stage_input.vColor; - vTex = stage_input.vTex; - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/bit-conversions.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/bit-conversions.frag deleted file mode 100644 index 2ed359bfc7..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/bit-conversions.frag +++ /dev/null @@ -1,27 +0,0 @@ -static float2 value; -static float4 FragColor; - -struct SPIRV_Cross_Input -{ - float2 value : TEXCOORD0; -}; - -struct SPIRV_Cross_Output -{ - float4 FragColor : SV_Target0; -}; - -void frag_main() -{ - int i = asint(value.x); - FragColor = float4(1.0f, 0.0f, asfloat(i), 1.0f); -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - value = stage_input.value; - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/boolean-mix.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/boolean-mix.frag deleted file mode 100644 index f3e84898d6..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/boolean-mix.frag +++ /dev/null @@ -1,27 +0,0 @@ -static float2 FragColor; -static float2 x0; - -struct SPIRV_Cross_Input -{ - float2 x0 : TEXCOORD0; -}; - -struct SPIRV_Cross_Output -{ - float2 FragColor : SV_Target0; -}; - -void frag_main() -{ - bool2 _27 = (x0.x > x0.y).xx; - FragColor = float2(_27.x ? float2(1.0f, 0.0f).x : float2(0.0f, 1.0f).x, _27.y ? float2(1.0f, 0.0f).y : float2(0.0f, 1.0f).y); -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - x0 = stage_input.x0; - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/builtins.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/builtins.frag deleted file mode 100644 index 922eca7c2d..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/builtins.frag +++ /dev/null @@ -1,33 +0,0 @@ -static float4 gl_FragCoord; -static float gl_FragDepth; -static float4 FragColor; -static float4 vColor; - -struct SPIRV_Cross_Input -{ - float4 vColor : TEXCOORD0; - float4 gl_FragCoord : SV_Position; -}; - -struct SPIRV_Cross_Output -{ - float4 FragColor : SV_Target0; - float gl_FragDepth : SV_Depth; -}; - -void frag_main() -{ - FragColor = gl_FragCoord + vColor; - gl_FragDepth = 0.5f; -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - gl_FragCoord = stage_input.gl_FragCoord; - vColor = stage_input.vColor; - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.gl_FragDepth = gl_FragDepth; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/bvec-operations.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/bvec-operations.frag deleted file mode 100644 index 2398d8c6af..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/bvec-operations.frag +++ /dev/null @@ -1,29 +0,0 @@ -static float2 value; -static float4 FragColor; - -struct SPIRV_Cross_Input -{ - float2 value : TEXCOORD0; -}; - -struct SPIRV_Cross_Output -{ - float4 FragColor : SV_Target0; -}; - -void frag_main() -{ - bool2 _25 = bool2(value.x == 0.0f, value.y == 0.0f); - bool2 bools1 = bool2(!_25.x, !_25.y); - bool2 bools2 = bool2(value.x <= float2(1.5f, 0.5f).x, value.y <= float2(1.5f, 0.5f).y); - FragColor = float4(1.0f, 0.0f, float(bools1.x), float(bools2.x)); -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - value = stage_input.value; - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/combined-texture-sampler-parameter.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/combined-texture-sampler-parameter.frag deleted file mode 100644 index 7fcff423b3..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/combined-texture-sampler-parameter.frag +++ /dev/null @@ -1,44 +0,0 @@ -Texture2D uSampler : register(t0); -SamplerState _uSampler_sampler : register(s0); -Texture2D uSamplerShadow : register(t1); -SamplerComparisonState _uSamplerShadow_sampler : register(s1); - -static float FragColor; - -struct SPIRV_Cross_Output -{ - float FragColor : SV_Target0; -}; - -float4 samp2(Texture2D s, SamplerState _s_sampler) -{ - return s.Sample(_s_sampler, 1.0f.xx) + s.Load(int3(int2(10, 10), 0)); -} - -float4 samp3(Texture2D s, SamplerState _s_sampler) -{ - return samp2(s, _s_sampler); -} - -float samp4(Texture2D s, SamplerComparisonState _s_sampler) -{ - return s.SampleCmp(_s_sampler, 1.0f.xxx.xy, 1.0f.xxx.z); -} - -float samp(Texture2D s0, SamplerState _s0_sampler, Texture2D s1, SamplerComparisonState _s1_sampler) -{ - return samp3(s0, _s0_sampler).x + samp4(s1, _s1_sampler); -} - -void frag_main() -{ - FragColor = samp(uSampler, _uSampler_sampler, uSamplerShadow, _uSamplerShadow_sampler); -} - -SPIRV_Cross_Output main() -{ - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/combined-texture-sampler-shadow.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/combined-texture-sampler-shadow.frag deleted file mode 100644 index af5b0b5579..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/combined-texture-sampler-shadow.frag +++ /dev/null @@ -1,40 +0,0 @@ -Texture2D uDepth : register(t2); -SamplerComparisonState uSampler : register(s0); -SamplerState uSampler1 : register(s1); - -static float FragColor; - -struct SPIRV_Cross_Output -{ - float FragColor : SV_Target0; -}; - -float samp2(Texture2D t, SamplerComparisonState s) -{ - return t.SampleCmp(s, 1.0f.xxx.xy, 1.0f.xxx.z); -} - -float samp3(Texture2D t, SamplerState s) -{ - return t.Sample(s, 1.0f.xx).x; -} - -float samp(Texture2D t, SamplerComparisonState s, SamplerState s1) -{ - float r0 = samp2(t, s); - float r1 = samp3(t, s1); - return r0 + r1; -} - -void frag_main() -{ - FragColor = samp(uDepth, uSampler, uSampler1); -} - -SPIRV_Cross_Output main() -{ - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/constant-buffer-array.sm51.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/constant-buffer-array.sm51.frag deleted file mode 100644 index 7e613da1cf..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/constant-buffer-array.sm51.frag +++ /dev/null @@ -1,43 +0,0 @@ -struct CBO_1 -{ - float4 a; - float4 b; - float4 c; - float4 d; -}; - -ConstantBuffer cbo[2][4] : register(b4, space0); -cbuffer push -{ - float4 push_a : packoffset(c0); - float4 push_b : packoffset(c1); - float4 push_c : packoffset(c2); - float4 push_d : packoffset(c3); -}; - -static float4 FragColor; - -struct SPIRV_Cross_Output -{ - float4 FragColor : SV_Target0; -}; - -void frag_main() -{ - FragColor = cbo[1][2].a; - FragColor += cbo[1][2].b; - FragColor += cbo[1][2].c; - FragColor += cbo[1][2].d; - FragColor += push_a; - FragColor += push_b; - FragColor += push_c; - FragColor += push_d; -} - -SPIRV_Cross_Output main() -{ - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/early-fragment-test.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/early-fragment-test.frag deleted file mode 100644 index ae2569d5cf..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/early-fragment-test.frag +++ /dev/null @@ -1,9 +0,0 @@ -void frag_main() -{ -} - -[earlydepthstencil] -void main() -{ - frag_main(); -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/fp16-packing.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/fp16-packing.frag deleted file mode 100644 index d87828225f..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/fp16-packing.frag +++ /dev/null @@ -1,44 +0,0 @@ -static float2 FP32Out; -static uint FP16; -static uint FP16Out; -static float2 FP32; - -struct SPIRV_Cross_Input -{ - nointerpolation uint FP16 : TEXCOORD0; - nointerpolation float2 FP32 : TEXCOORD1; -}; - -struct SPIRV_Cross_Output -{ - float2 FP32Out : SV_Target0; - uint FP16Out : SV_Target1; -}; - -uint SPIRV_Cross_packHalf2x16(float2 value) -{ - uint2 Packed = f32tof16(value); - return Packed.x | (Packed.y << 16); -} - -float2 SPIRV_Cross_unpackHalf2x16(uint value) -{ - return f16tof32(uint2(value & 0xffff, value >> 16)); -} - -void frag_main() -{ - FP32Out = SPIRV_Cross_unpackHalf2x16(FP16); - FP16Out = SPIRV_Cross_packHalf2x16(FP32); -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - FP16 = stage_input.FP16; - FP32 = stage_input.FP32; - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FP32Out = FP32Out; - stage_output.FP16Out = FP16Out; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/image-query-selective.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/image-query-selective.frag deleted file mode 100644 index 25c12da669..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/image-query-selective.frag +++ /dev/null @@ -1,146 +0,0 @@ -Texture1D uSampler1DUint : register(t0); -SamplerState _uSampler1DUint_sampler : register(s0); -Texture1D uSampler1DInt : register(t0); -SamplerState _uSampler1DInt_sampler : register(s0); -Texture1D uSampler1DFloat : register(t0); -SamplerState _uSampler1DFloat_sampler : register(s0); -Texture2DArray uSampler2DArray : register(t2); -SamplerState _uSampler2DArray_sampler : register(s2); -Texture3D uSampler3D : register(t3); -SamplerState _uSampler3D_sampler : register(s3); -TextureCube uSamplerCube : register(t4); -SamplerState _uSamplerCube_sampler : register(s4); -TextureCubeArray uSamplerCubeArray : register(t5); -SamplerState _uSamplerCubeArray_sampler : register(s5); -Buffer uSamplerBuffer : register(t6); -Texture2DMS uSamplerMS : register(t7); -SamplerState _uSamplerMS_sampler : register(s7); -Texture2DMSArray uSamplerMSArray : register(t8); -SamplerState _uSamplerMSArray_sampler : register(s8); -Texture2D uSampler2D : register(t1); -SamplerState _uSampler2D_sampler : register(s1); - -uint SPIRV_Cross_textureSize(Texture1D Tex, uint Level, out uint Param) -{ - uint ret; - Tex.GetDimensions(Level, ret.x, Param); - return ret; -} - -uint SPIRV_Cross_textureSize(Texture1D Tex, uint Level, out uint Param) -{ - uint ret; - Tex.GetDimensions(Level, ret.x, Param); - return ret; -} - -uint SPIRV_Cross_textureSize(Texture1D Tex, uint Level, out uint Param) -{ - uint ret; - Tex.GetDimensions(Level, ret.x, Param); - return ret; -} - -uint2 SPIRV_Cross_textureSize(Texture2D Tex, uint Level, out uint Param) -{ - uint2 ret; - Tex.GetDimensions(Level, ret.x, ret.y, Param); - return ret; -} - -uint3 SPIRV_Cross_textureSize(Texture2DArray Tex, uint Level, out uint Param) -{ - uint3 ret; - Tex.GetDimensions(Level, ret.x, ret.y, ret.z, Param); - return ret; -} - -uint3 SPIRV_Cross_textureSize(Texture3D Tex, uint Level, out uint Param) -{ - uint3 ret; - Tex.GetDimensions(Level, ret.x, ret.y, ret.z, Param); - return ret; -} - -uint SPIRV_Cross_textureSize(Buffer Tex, uint Level, out uint Param) -{ - uint ret; - Tex.GetDimensions(ret.x); - Param = 0u; - return ret; -} - -uint2 SPIRV_Cross_textureSize(TextureCube Tex, uint Level, out uint Param) -{ - uint2 ret; - Tex.GetDimensions(Level, ret.x, ret.y, Param); - return ret; -} - -uint3 SPIRV_Cross_textureSize(TextureCubeArray Tex, uint Level, out uint Param) -{ - uint3 ret; - Tex.GetDimensions(Level, ret.x, ret.y, ret.z, Param); - return ret; -} - -uint2 SPIRV_Cross_textureSize(Texture2DMS Tex, uint Level, out uint Param) -{ - uint2 ret; - Tex.GetDimensions(ret.x, ret.y, Param); - return ret; -} - -uint3 SPIRV_Cross_textureSize(Texture2DMSArray Tex, uint Level, out uint Param) -{ - uint3 ret; - Tex.GetDimensions(ret.x, ret.y, ret.z, Param); - return ret; -} - -void frag_main() -{ - uint _17_dummy_parameter; - int a = int(SPIRV_Cross_textureSize(uSampler1DUint, uint(0), _17_dummy_parameter)); - uint _24_dummy_parameter; - a = int(SPIRV_Cross_textureSize(uSampler1DInt, uint(0), _24_dummy_parameter)); - uint _32_dummy_parameter; - a = int(SPIRV_Cross_textureSize(uSampler1DFloat, uint(0), _32_dummy_parameter)); - uint _42_dummy_parameter; - int3 c = int3(SPIRV_Cross_textureSize(uSampler2DArray, uint(0), _42_dummy_parameter)); - uint _50_dummy_parameter; - int3 d = int3(SPIRV_Cross_textureSize(uSampler3D, uint(0), _50_dummy_parameter)); - uint _60_dummy_parameter; - int2 e = int2(SPIRV_Cross_textureSize(uSamplerCube, uint(0), _60_dummy_parameter)); - uint _68_dummy_parameter; - int3 f = int3(SPIRV_Cross_textureSize(uSamplerCubeArray, uint(0), _68_dummy_parameter)); - uint _76_dummy_parameter; - int g = int(SPIRV_Cross_textureSize(uSamplerBuffer, 0u, _76_dummy_parameter)); - uint _84_dummy_parameter; - int2 h = int2(SPIRV_Cross_textureSize(uSamplerMS, 0u, _84_dummy_parameter)); - uint _92_dummy_parameter; - int3 i = int3(SPIRV_Cross_textureSize(uSamplerMSArray, 0u, _92_dummy_parameter)); - int _100; - SPIRV_Cross_textureSize(uSampler2D, 0u, _100); - int l1 = int(_100); - int _104; - SPIRV_Cross_textureSize(uSampler2DArray, 0u, _104); - int l2 = int(_104); - int _108; - SPIRV_Cross_textureSize(uSampler3D, 0u, _108); - int l3 = int(_108); - int _112; - SPIRV_Cross_textureSize(uSamplerCube, 0u, _112); - int l4 = int(_112); - int _116; - SPIRV_Cross_textureSize(uSamplerMS, 0u, _116); - int s0 = int(_116); - int _120; - SPIRV_Cross_textureSize(uSamplerMSArray, 0u, _120); - int s1 = int(_120); -} - -void main() -{ - frag_main(); -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/image-query.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/image-query.frag deleted file mode 100644 index 71cefc1030..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/image-query.frag +++ /dev/null @@ -1,132 +0,0 @@ -Texture1D uSampler1D : register(t0); -SamplerState _uSampler1D_sampler : register(s0); -Texture2D uSampler2D : register(t1); -SamplerState _uSampler2D_sampler : register(s1); -Texture2DArray uSampler2DArray : register(t2); -SamplerState _uSampler2DArray_sampler : register(s2); -Texture3D uSampler3D : register(t3); -SamplerState _uSampler3D_sampler : register(s3); -TextureCube uSamplerCube : register(t4); -SamplerState _uSamplerCube_sampler : register(s4); -TextureCubeArray uSamplerCubeArray : register(t5); -SamplerState _uSamplerCubeArray_sampler : register(s5); -Buffer uSamplerBuffer : register(t6); -Texture2DMS uSamplerMS : register(t7); -SamplerState _uSamplerMS_sampler : register(s7); -Texture2DMSArray uSamplerMSArray : register(t8); -SamplerState _uSamplerMSArray_sampler : register(s8); - -uint SPIRV_Cross_textureSize(Texture1D Tex, uint Level, out uint Param) -{ - uint ret; - Tex.GetDimensions(Level, ret.x, Param); - return ret; -} - -uint2 SPIRV_Cross_textureSize(Texture2D Tex, uint Level, out uint Param) -{ - uint2 ret; - Tex.GetDimensions(Level, ret.x, ret.y, Param); - return ret; -} - -uint3 SPIRV_Cross_textureSize(Texture2DArray Tex, uint Level, out uint Param) -{ - uint3 ret; - Tex.GetDimensions(Level, ret.x, ret.y, ret.z, Param); - return ret; -} - -uint3 SPIRV_Cross_textureSize(Texture3D Tex, uint Level, out uint Param) -{ - uint3 ret; - Tex.GetDimensions(Level, ret.x, ret.y, ret.z, Param); - return ret; -} - -uint SPIRV_Cross_textureSize(Buffer Tex, uint Level, out uint Param) -{ - uint ret; - Tex.GetDimensions(ret.x); - Param = 0u; - return ret; -} - -uint2 SPIRV_Cross_textureSize(TextureCube Tex, uint Level, out uint Param) -{ - uint2 ret; - Tex.GetDimensions(Level, ret.x, ret.y, Param); - return ret; -} - -uint3 SPIRV_Cross_textureSize(TextureCubeArray Tex, uint Level, out uint Param) -{ - uint3 ret; - Tex.GetDimensions(Level, ret.x, ret.y, ret.z, Param); - return ret; -} - -uint2 SPIRV_Cross_textureSize(Texture2DMS Tex, uint Level, out uint Param) -{ - uint2 ret; - Tex.GetDimensions(ret.x, ret.y, Param); - return ret; -} - -uint3 SPIRV_Cross_textureSize(Texture2DMSArray Tex, uint Level, out uint Param) -{ - uint3 ret; - Tex.GetDimensions(ret.x, ret.y, ret.z, Param); - return ret; -} - -void frag_main() -{ - uint _17_dummy_parameter; - int a = int(SPIRV_Cross_textureSize(uSampler1D, uint(0), _17_dummy_parameter)); - uint _27_dummy_parameter; - int2 b = int2(SPIRV_Cross_textureSize(uSampler2D, uint(0), _27_dummy_parameter)); - uint _37_dummy_parameter; - int3 c = int3(SPIRV_Cross_textureSize(uSampler2DArray, uint(0), _37_dummy_parameter)); - uint _45_dummy_parameter; - int3 d = int3(SPIRV_Cross_textureSize(uSampler3D, uint(0), _45_dummy_parameter)); - uint _53_dummy_parameter; - int2 e = int2(SPIRV_Cross_textureSize(uSamplerCube, uint(0), _53_dummy_parameter)); - uint _61_dummy_parameter; - int3 f = int3(SPIRV_Cross_textureSize(uSamplerCubeArray, uint(0), _61_dummy_parameter)); - uint _69_dummy_parameter; - int g = int(SPIRV_Cross_textureSize(uSamplerBuffer, 0u, _69_dummy_parameter)); - uint _77_dummy_parameter; - int2 h = int2(SPIRV_Cross_textureSize(uSamplerMS, 0u, _77_dummy_parameter)); - uint _85_dummy_parameter; - int3 i = int3(SPIRV_Cross_textureSize(uSamplerMSArray, 0u, _85_dummy_parameter)); - int _89; - SPIRV_Cross_textureSize(uSampler1D, 0u, _89); - int l0 = int(_89); - int _93; - SPIRV_Cross_textureSize(uSampler2D, 0u, _93); - int l1 = int(_93); - int _97; - SPIRV_Cross_textureSize(uSampler2DArray, 0u, _97); - int l2 = int(_97); - int _101; - SPIRV_Cross_textureSize(uSampler3D, 0u, _101); - int l3 = int(_101); - int _105; - SPIRV_Cross_textureSize(uSamplerCube, 0u, _105); - int l4 = int(_105); - int _109; - SPIRV_Cross_textureSize(uSamplerCubeArray, 0u, _109); - int l5 = int(_109); - int _113; - SPIRV_Cross_textureSize(uSamplerMS, 0u, _113); - int s0 = int(_113); - int _117; - SPIRV_Cross_textureSize(uSamplerMSArray, 0u, _117); - int s1 = int(_117); -} - -void main() -{ - frag_main(); -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/io-block.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/io-block.frag deleted file mode 100644 index 52c1f518bf..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/io-block.frag +++ /dev/null @@ -1,28 +0,0 @@ -static float4 FragColor; - -struct VertexOut -{ - float4 a : TEXCOORD1; - float4 b : TEXCOORD2; -}; - -static VertexOut _12; - -struct SPIRV_Cross_Output -{ - float4 FragColor : SV_Target0; -}; - -void frag_main() -{ - FragColor = _12.a + _12.b; -} - -SPIRV_Cross_Output main(in VertexOut stage_input_12) -{ - _12 = stage_input_12; - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/matrix-input.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/matrix-input.frag deleted file mode 100644 index 92d87d396e..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/matrix-input.frag +++ /dev/null @@ -1,26 +0,0 @@ -static float4 FragColor; -static float4x4 m; - -struct SPIRV_Cross_Input -{ - float4x4 m : TEXCOORD1; -}; - -struct SPIRV_Cross_Output -{ - float4 FragColor : SV_Target0; -}; - -void frag_main() -{ - FragColor = ((m[0] + m[1]) + m[2]) + m[3]; -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - m = stage_input.m; - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/mod.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/mod.frag deleted file mode 100644 index 1da8f21e45..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/mod.frag +++ /dev/null @@ -1,71 +0,0 @@ -static float4 a4; -static float4 b4; -static float3 a3; -static float3 b3; -static float2 a2; -static float2 b2; -static float a1; -static float b1; -static float4 FragColor; - -struct SPIRV_Cross_Input -{ - float4 a4 : TEXCOORD0; - float3 a3 : TEXCOORD1; - float2 a2 : TEXCOORD2; - float a1 : TEXCOORD3; - float4 b4 : TEXCOORD4; - float3 b3 : TEXCOORD5; - float2 b2 : TEXCOORD6; - float b1 : TEXCOORD7; -}; - -struct SPIRV_Cross_Output -{ - float4 FragColor : SV_Target0; -}; - -float mod(float x, float y) -{ - return x - y * floor(x / y); -} - -float2 mod(float2 x, float2 y) -{ - return x - y * floor(x / y); -} - -float3 mod(float3 x, float3 y) -{ - return x - y * floor(x / y); -} - -float4 mod(float4 x, float4 y) -{ - return x - y * floor(x / y); -} - -void frag_main() -{ - float4 m0 = mod(a4, b4); - float3 m1 = mod(a3, b3); - float2 m2 = mod(a2, b2); - float m3 = mod(a1, b1); - FragColor = ((m0 + m1.xyzx) + m2.xyxy) + m3.xxxx; -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - a4 = stage_input.a4; - b4 = stage_input.b4; - a3 = stage_input.a3; - b3 = stage_input.b3; - a2 = stage_input.a2; - b2 = stage_input.b2; - a1 = stage_input.a1; - b1 = stage_input.b1; - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/mrt.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/mrt.frag deleted file mode 100644 index e69e91196a..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/mrt.frag +++ /dev/null @@ -1,31 +0,0 @@ -static float4 RT0; -static float4 RT1; -static float4 RT2; -static float4 RT3; - -struct SPIRV_Cross_Output -{ - float4 RT0 : SV_Target0; - float4 RT1 : SV_Target1; - float4 RT2 : SV_Target2; - float4 RT3 : SV_Target3; -}; - -void frag_main() -{ - RT0 = 1.0f.xxxx; - RT1 = 2.0f.xxxx; - RT2 = 3.0f.xxxx; - RT3 = 4.0f.xxxx; -} - -SPIRV_Cross_Output main() -{ - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.RT0 = RT0; - stage_output.RT1 = RT1; - stage_output.RT2 = RT2; - stage_output.RT3 = RT3; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/no-return.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/no-return.frag deleted file mode 100644 index 3b50282fe0..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/no-return.frag +++ /dev/null @@ -1,8 +0,0 @@ -void frag_main() -{ -} - -void main() -{ - frag_main(); -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/no-return2.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/no-return2.frag deleted file mode 100644 index a22ffa7725..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/no-return2.frag +++ /dev/null @@ -1,17 +0,0 @@ -static float4 vColor; - -struct SPIRV_Cross_Input -{ - float4 vColor : TEXCOORD0; -}; - -void frag_main() -{ - float4 v = vColor; -} - -void main(SPIRV_Cross_Input stage_input) -{ - vColor = stage_input.vColor; - frag_main(); -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/partial-write-preserve.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/partial-write-preserve.frag deleted file mode 100644 index 4ed4d42747..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/partial-write-preserve.frag +++ /dev/null @@ -1,73 +0,0 @@ -struct B -{ - float a; - float b; -}; - -cbuffer _42 : register(b0) -{ - int _42_some_value : packoffset(c0); -}; - -void partial_inout(inout float4 x) -{ - x.x = 10.0f; -} - -void complete_inout(out float4 x) -{ - x = 50.0f.xxxx; -} - -void branchy_inout(inout float4 v) -{ - v.y = 20.0f; - if (_42_some_value == 20) - { - v = 50.0f.xxxx; - } -} - -void branchy_inout_2(out float4 v) -{ - if (_42_some_value == 20) - { - v = 50.0f.xxxx; - } - else - { - v = 70.0f.xxxx; - } - v.y = 20.0f; -} - -void partial_inout(inout B b) -{ - b.b = 40.0f; -} - -void frag_main() -{ - float4 a = 10.0f.xxxx; - float4 param = a; - partial_inout(param); - a = param; - float4 param_1; - complete_inout(param_1); - a = param_1; - float4 param_2 = a; - branchy_inout(param_2); - a = param_2; - float4 param_3; - branchy_inout_2(param_3); - a = param_3; - B b = { 10.0f, 20.0f }; - B param_4 = b; - partial_inout(param_4); - b = param_4; -} - -void main() -{ - frag_main(); -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/query-lod.desktop.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/query-lod.desktop.frag deleted file mode 100644 index fd95798bf4..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/query-lod.desktop.frag +++ /dev/null @@ -1,30 +0,0 @@ -Texture2D uSampler : register(t0); -SamplerState _uSampler_sampler : register(s0); - -static float4 FragColor; -static float2 vTexCoord; - -struct SPIRV_Cross_Input -{ - float2 vTexCoord : TEXCOORD0; -}; - -struct SPIRV_Cross_Output -{ - float4 FragColor : SV_Target0; -}; - -void frag_main() -{ - float _19_tmp = uSampler.CalculateLevelOfDetail(_uSampler_sampler, vTexCoord); - FragColor = float2(_19_tmp, _19_tmp).xyxy; -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - vTexCoord = stage_input.vTexCoord; - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/resources.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/resources.frag deleted file mode 100644 index 60b709e696..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/resources.frag +++ /dev/null @@ -1,42 +0,0 @@ -cbuffer cbuf : register(b3) -{ - float4 cbuf_a : packoffset(c0); -}; -cbuffer registers -{ - float4 registers_d : packoffset(c0); -}; -Texture2D uSampledImage : register(t4); -SamplerState _uSampledImage_sampler : register(s4); -Texture2D uTexture : register(t5); -SamplerState uSampler : register(s6); - -static float2 vTex; -static float4 FragColor; - -struct SPIRV_Cross_Input -{ - float2 vTex : TEXCOORD0; -}; - -struct SPIRV_Cross_Output -{ - float4 FragColor : SV_Target0; -}; - -void frag_main() -{ - float4 c0 = uSampledImage.Sample(_uSampledImage_sampler, vTex); - float4 c1 = uTexture.Sample(uSampler, vTex); - float4 c2 = cbuf_a + registers_d; - FragColor = (c0 + c1) + c2; -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - vTex = stage_input.vTex; - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/sample-cmp-level-zero.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/sample-cmp-level-zero.frag deleted file mode 100644 index b52b1df554..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/sample-cmp-level-zero.frag +++ /dev/null @@ -1,66 +0,0 @@ -Texture2D uSampler2D : register(t0); -SamplerComparisonState _uSampler2D_sampler : register(s0); -Texture2DArray uSampler2DArray : register(t1); -SamplerComparisonState _uSampler2DArray_sampler : register(s1); -TextureCube uSamplerCube : register(t2); -SamplerComparisonState _uSamplerCube_sampler : register(s2); -TextureCubeArray uSamplerCubeArray : register(t3); -SamplerComparisonState _uSamplerCubeArray_sampler : register(s3); - -static float3 vUVRef; -static float4 vDirRef; -static float FragColor; - -struct SPIRV_Cross_Input -{ - float3 vUVRef : TEXCOORD0; - float4 vDirRef : TEXCOORD1; -}; - -struct SPIRV_Cross_Output -{ - float FragColor : SV_Target0; -}; - -float SPIRV_Cross_projectTextureCoordinate(float2 coord) -{ - return coord.x / coord.y; -} - -float2 SPIRV_Cross_projectTextureCoordinate(float3 coord) -{ - return float2(coord.x, coord.y) / coord.z; -} - -float3 SPIRV_Cross_projectTextureCoordinate(float4 coord) -{ - return float3(coord.x, coord.y, coord.z) / coord.w; -} - -void frag_main() -{ - float s0 = uSampler2D.SampleCmp(_uSampler2D_sampler, vUVRef.xy, vUVRef.z, int2(-1, -1)); - float s1 = uSampler2DArray.SampleCmp(_uSampler2DArray_sampler, vDirRef.xyz, vDirRef.w, int2(-1, -1)); - float s2 = uSamplerCube.SampleCmp(_uSamplerCube_sampler, vDirRef.xyz, vDirRef.w); - float s3 = uSamplerCubeArray.SampleCmp(_uSamplerCubeArray_sampler, vDirRef, 0.5f); - float l0 = uSampler2D.SampleCmpLevelZero(_uSampler2D_sampler, vUVRef.xy, vUVRef.z, int2(-1, -1)); - float l1 = uSampler2DArray.SampleCmpLevelZero(_uSampler2DArray_sampler, vDirRef.xyz, vDirRef.w, int2(-1, -1)); - float l2 = uSamplerCube.SampleCmpLevelZero(_uSamplerCube_sampler, vDirRef.xyz, vDirRef.w); - float4 _80 = vDirRef; - _80.z = vDirRef.w; - float p0 = uSampler2D.SampleCmp(_uSampler2D_sampler, SPIRV_Cross_projectTextureCoordinate(_80.xyz), vDirRef.z, int2(1, 1)); - float4 _87 = vDirRef; - _87.z = vDirRef.w; - float p1 = uSampler2D.SampleCmpLevelZero(_uSampler2D_sampler, SPIRV_Cross_projectTextureCoordinate(_87.xyz), vDirRef.z, int2(1, 1)); - FragColor = (((((((s0 + s1) + s2) + s3) + l0) + l1) + l2) + p0) + p1; -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - vUVRef = stage_input.vUVRef; - vDirRef = stage_input.vDirRef; - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/sampler-array.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/sampler-array.frag deleted file mode 100644 index 7fc5e3f37e..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/sampler-array.frag +++ /dev/null @@ -1,43 +0,0 @@ -Texture2D uCombined[4] : register(t0); -SamplerState _uCombined_sampler[4] : register(s0); -Texture2D uTex[4] : register(t4); -SamplerState uSampler[4] : register(s8); -RWTexture2D uImage[8] : register(u12); - -static float4 gl_FragCoord; -static float2 vTex; -static int vIndex; - -struct SPIRV_Cross_Input -{ - float2 vTex : TEXCOORD0; - nointerpolation int vIndex : TEXCOORD1; - float4 gl_FragCoord : SV_Position; -}; - -float4 sample_in_function(Texture2D samp, SamplerState _samp_sampler) -{ - return samp.Sample(_samp_sampler, vTex); -} - -float4 sample_in_function2(Texture2D tex, SamplerState samp) -{ - return tex.Sample(samp, vTex); -} - -void frag_main() -{ - float4 color = uCombined[vIndex].Sample(_uCombined_sampler[vIndex], vTex); - color += uTex[vIndex].Sample(uSampler[vIndex], vTex); - color += sample_in_function(uCombined[vIndex + 1], _uCombined_sampler[vIndex + 1]); - color += sample_in_function2(uTex[vIndex + 1], uSampler[vIndex + 1]); - uImage[vIndex][int2(gl_FragCoord.xy)] = color; -} - -void main(SPIRV_Cross_Input stage_input) -{ - gl_FragCoord = stage_input.gl_FragCoord; - vTex = stage_input.vTex; - vIndex = stage_input.vIndex; - frag_main(); -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/spec-constant.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/spec-constant.frag deleted file mode 100644 index 70b029dc68..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/spec-constant.frag +++ /dev/null @@ -1,79 +0,0 @@ -static const float a = 1.0f; -static const float b = 2.0f; -static const int c = 3; -static const int d = 4; -static const uint e = 5u; -static const uint f = 6u; -static const bool g = false; -static const bool h = true; - -struct Foo -{ - float elems[(d + 2)]; -}; - -static float4 FragColor; - -struct SPIRV_Cross_Output -{ - float4 FragColor : SV_Target0; -}; - -void frag_main() -{ - float t0 = a; - float t1 = b; - uint c0 = (uint(c) + 0u); - int c1 = (-c); - int c2 = (~c); - int c3 = (c + d); - int c4 = (c - d); - int c5 = (c * d); - int c6 = (c / d); - uint c7 = (e / f); - int c8 = (c % d); - uint c9 = (e % f); - int c10 = (c >> d); - uint c11 = (e >> f); - int c12 = (c << d); - int c13 = (c | d); - int c14 = (c ^ d); - int c15 = (c & d); - bool c16 = (g || h); - bool c17 = (g && h); - bool c18 = (!g); - bool c19 = (g == h); - bool c20 = (g != h); - bool c21 = (c == d); - bool c22 = (c != d); - bool c23 = (c < d); - bool c24 = (e < f); - bool c25 = (c > d); - bool c26 = (e > f); - bool c27 = (c <= d); - bool c28 = (e <= f); - bool c29 = (c >= d); - bool c30 = (e >= f); - int c31 = c8 + c3; - int c32 = int(e + 0u); - bool c33 = (c != int(0u)); - bool c34 = (e != 0u); - int c35 = int(g); - uint c36 = uint(g); - float c37 = float(g); - float vec0[(c + 3)][8]; - vec0[0][0] = 10.0f; - float vec1[(c + 2)]; - vec1[0] = 20.0f; - Foo foo; - foo.elems[c] = 10.0f; - FragColor = (((t0 + t1).xxxx + vec0[0][0].xxxx) + vec1[0].xxxx) + foo.elems[c].xxxx; -} - -SPIRV_Cross_Output main() -{ - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/swizzle-scalar.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/swizzle-scalar.frag deleted file mode 100644 index ab310b82f2..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/swizzle-scalar.frag +++ /dev/null @@ -1,41 +0,0 @@ -static float4 Float; -static float vFloat; -static int4 Int; -static int vInt; -static float4 Float2; -static int4 Int2; - -struct SPIRV_Cross_Input -{ - nointerpolation float vFloat : TEXCOORD0; - nointerpolation int vInt : TEXCOORD1; -}; - -struct SPIRV_Cross_Output -{ - float4 Float : SV_Target0; - int4 Int : SV_Target1; - float4 Float2 : SV_Target2; - int4 Int2 : SV_Target3; -}; - -void frag_main() -{ - Float = vFloat.xxxx * 2.0f; - Int = vInt.xxxx * int4(2, 2, 2, 2); - Float2 = 10.0f.xxxx; - Int2 = int4(10, 10, 10, 10); -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - vFloat = stage_input.vFloat; - vInt = stage_input.vInt; - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.Float = Float; - stage_output.Int = Int; - stage_output.Float2 = Float2; - stage_output.Int2 = Int2; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/tex-sampling.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/tex-sampling.frag deleted file mode 100644 index 7e10bfdd24..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/tex-sampling.frag +++ /dev/null @@ -1,118 +0,0 @@ -Texture1D tex1d; -SamplerState _tex1d_sampler; -Texture2D tex2d; -SamplerState _tex2d_sampler; -Texture3D tex3d; -SamplerState _tex3d_sampler; -TextureCube texCube; -SamplerState _texCube_sampler; -Texture1D tex1dShadow; -SamplerComparisonState _tex1dShadow_sampler; -Texture2D tex2dShadow; -SamplerComparisonState _tex2dShadow_sampler; -TextureCube texCubeShadow; -SamplerComparisonState _texCubeShadow_sampler; -Texture1DArray tex1dArray; -SamplerState _tex1dArray_sampler; -Texture2DArray tex2dArray; -SamplerState _tex2dArray_sampler; -TextureCubeArray texCubeArray; -SamplerState _texCubeArray_sampler; -Texture2D separateTex2d; -SamplerState samplerNonDepth; -Texture2D separateTex2dDepth; -SamplerComparisonState samplerDepth; - -static float texCoord1d; -static float2 texCoord2d; -static float3 texCoord3d; -static float4 texCoord4d; -static float4 FragColor; - -struct SPIRV_Cross_Input -{ - float texCoord1d : TEXCOORD0; - float2 texCoord2d : TEXCOORD1; - float3 texCoord3d : TEXCOORD2; - float4 texCoord4d : TEXCOORD3; -}; - -struct SPIRV_Cross_Output -{ - float4 FragColor : SV_Target0; -}; - -float SPIRV_Cross_projectTextureCoordinate(float2 coord) -{ - return coord.x / coord.y; -} - -float2 SPIRV_Cross_projectTextureCoordinate(float3 coord) -{ - return float2(coord.x, coord.y) / coord.z; -} - -float3 SPIRV_Cross_projectTextureCoordinate(float4 coord) -{ - return float3(coord.x, coord.y, coord.z) / coord.w; -} - -void frag_main() -{ - float4 texcolor = tex1d.Sample(_tex1d_sampler, texCoord1d); - texcolor += tex1d.Sample(_tex1d_sampler, texCoord1d, 1); - texcolor += tex1d.SampleLevel(_tex1d_sampler, texCoord1d, 2.0f); - texcolor += tex1d.SampleGrad(_tex1d_sampler, texCoord1d, 1.0f, 2.0f); - texcolor += tex1d.Sample(_tex1d_sampler, SPIRV_Cross_projectTextureCoordinate(float2(texCoord1d, 2.0f))); - texcolor += tex1d.SampleBias(_tex1d_sampler, texCoord1d, 1.0f); - texcolor += tex2d.Sample(_tex2d_sampler, texCoord2d); - texcolor += tex2d.Sample(_tex2d_sampler, texCoord2d, int2(1, 2)); - texcolor += tex2d.SampleLevel(_tex2d_sampler, texCoord2d, 2.0f); - texcolor += tex2d.SampleGrad(_tex2d_sampler, texCoord2d, float2(1.0f, 2.0f), float2(3.0f, 4.0f)); - texcolor += tex2d.Sample(_tex2d_sampler, SPIRV_Cross_projectTextureCoordinate(float3(texCoord2d, 2.0f))); - texcolor += tex2d.SampleBias(_tex2d_sampler, texCoord2d, 1.0f); - texcolor += tex3d.Sample(_tex3d_sampler, texCoord3d); - texcolor += tex3d.Sample(_tex3d_sampler, texCoord3d, int3(1, 2, 3)); - texcolor += tex3d.SampleLevel(_tex3d_sampler, texCoord3d, 2.0f); - texcolor += tex3d.SampleGrad(_tex3d_sampler, texCoord3d, float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f)); - texcolor += tex3d.Sample(_tex3d_sampler, SPIRV_Cross_projectTextureCoordinate(float4(texCoord3d, 2.0f))); - texcolor += tex3d.SampleBias(_tex3d_sampler, texCoord3d, 1.0f); - texcolor += texCube.Sample(_texCube_sampler, texCoord3d); - texcolor += texCube.SampleLevel(_texCube_sampler, texCoord3d, 2.0f); - texcolor += texCube.SampleBias(_texCube_sampler, texCoord3d, 1.0f); - float3 _170 = float3(texCoord1d, 0.0f, 0.0f); - texcolor.w += tex1dShadow.SampleCmp(_tex1dShadow_sampler, _170.x, _170.z); - float3 _188 = float3(texCoord2d, 0.0f); - texcolor.w += tex2dShadow.SampleCmp(_tex2dShadow_sampler, _188.xy, _188.z); - float4 _204 = float4(texCoord3d, 0.0f); - texcolor.w += texCubeShadow.SampleCmp(_texCubeShadow_sampler, _204.xyz, _204.w); - texcolor += tex1dArray.Sample(_tex1dArray_sampler, texCoord2d); - texcolor += tex2dArray.Sample(_tex2dArray_sampler, texCoord3d); - texcolor += texCubeArray.Sample(_texCubeArray_sampler, texCoord4d); - texcolor += tex2d.GatherRed(_tex2d_sampler, texCoord2d); - texcolor += tex2d.GatherRed(_tex2d_sampler, texCoord2d); - texcolor += tex2d.GatherGreen(_tex2d_sampler, texCoord2d); - texcolor += tex2d.GatherBlue(_tex2d_sampler, texCoord2d); - texcolor += tex2d.GatherAlpha(_tex2d_sampler, texCoord2d); - texcolor += tex2d.GatherRed(_tex2d_sampler, texCoord2d, int2(1, 1)); - texcolor += tex2d.GatherRed(_tex2d_sampler, texCoord2d, int2(1, 1)); - texcolor += tex2d.GatherGreen(_tex2d_sampler, texCoord2d, int2(1, 1)); - texcolor += tex2d.GatherBlue(_tex2d_sampler, texCoord2d, int2(1, 1)); - texcolor += tex2d.GatherAlpha(_tex2d_sampler, texCoord2d, int2(1, 1)); - texcolor += tex2d.Load(int3(int2(1, 2), 0)); - texcolor += separateTex2d.Sample(samplerNonDepth, texCoord2d); - texcolor.w += separateTex2dDepth.SampleCmp(samplerDepth, texCoord3d.xy, texCoord3d.z); - FragColor = texcolor; -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - texCoord1d = stage_input.texCoord1d; - texCoord2d = stage_input.texCoord2d; - texCoord3d = stage_input.texCoord3d; - texCoord4d = stage_input.texCoord4d; - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/texture-proj-shadow.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/texture-proj-shadow.frag deleted file mode 100644 index 4beaa11761..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/texture-proj-shadow.frag +++ /dev/null @@ -1,66 +0,0 @@ -Texture1D uShadow1D : register(t0); -SamplerComparisonState _uShadow1D_sampler : register(s0); -Texture2D uShadow2D : register(t1); -SamplerComparisonState _uShadow2D_sampler : register(s1); -Texture1D uSampler1D : register(t2); -SamplerState _uSampler1D_sampler : register(s2); -Texture2D uSampler2D : register(t3); -SamplerState _uSampler2D_sampler : register(s3); -Texture3D uSampler3D : register(t4); -SamplerState _uSampler3D_sampler : register(s4); - -static float FragColor; -static float4 vClip4; -static float2 vClip2; -static float3 vClip3; - -struct SPIRV_Cross_Input -{ - float3 vClip3 : TEXCOORD0; - float4 vClip4 : TEXCOORD1; - float2 vClip2 : TEXCOORD2; -}; - -struct SPIRV_Cross_Output -{ - float FragColor : SV_Target0; -}; - -float SPIRV_Cross_projectTextureCoordinate(float2 coord) -{ - return coord.x / coord.y; -} - -float2 SPIRV_Cross_projectTextureCoordinate(float3 coord) -{ - return float2(coord.x, coord.y) / coord.z; -} - -float3 SPIRV_Cross_projectTextureCoordinate(float4 coord) -{ - return float3(coord.x, coord.y, coord.z) / coord.w; -} - -void frag_main() -{ - float4 _20 = vClip4; - _20.y = vClip4.w; - FragColor = uShadow1D.SampleCmp(_uShadow1D_sampler, SPIRV_Cross_projectTextureCoordinate(_20.xy), vClip4.z); - float4 _30 = vClip4; - _30.z = vClip4.w; - FragColor = uShadow2D.SampleCmp(_uShadow2D_sampler, SPIRV_Cross_projectTextureCoordinate(_30.xyz), vClip4.z); - FragColor = uSampler1D.Sample(_uSampler1D_sampler, SPIRV_Cross_projectTextureCoordinate(vClip2)).x; - FragColor = uSampler2D.Sample(_uSampler2D_sampler, SPIRV_Cross_projectTextureCoordinate(vClip3)).x; - FragColor = uSampler3D.Sample(_uSampler3D_sampler, SPIRV_Cross_projectTextureCoordinate(vClip4)).x; -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - vClip4 = stage_input.vClip4; - vClip2 = stage_input.vClip2; - vClip3 = stage_input.vClip3; - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/unary-enclose.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/unary-enclose.frag deleted file mode 100644 index 597c57f800..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/unary-enclose.frag +++ /dev/null @@ -1,32 +0,0 @@ -static float4 FragColor; -static float4 vIn; -static int4 vIn1; - -struct SPIRV_Cross_Input -{ - float4 vIn : TEXCOORD0; - nointerpolation int4 vIn1 : TEXCOORD1; -}; - -struct SPIRV_Cross_Output -{ - float4 FragColor : SV_Target0; -}; - -void frag_main() -{ - FragColor = -(-vIn); - int4 a = ~(~vIn1); - bool b = false; - b = !(!b); -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - vIn = stage_input.vIn; - vIn1 = stage_input.vIn1; - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/unorm-snorm-packing.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/unorm-snorm-packing.frag deleted file mode 100644 index 57b5950636..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/unorm-snorm-packing.frag +++ /dev/null @@ -1,109 +0,0 @@ -static float4 FP32Out; -static uint UNORM8; -static uint SNORM8; -static uint UNORM16; -static uint SNORM16; -static uint UNORM8Out; -static float4 FP32; -static uint SNORM8Out; -static uint UNORM16Out; -static uint SNORM16Out; - -struct SPIRV_Cross_Input -{ - nointerpolation uint SNORM8 : TEXCOORD0; - nointerpolation uint UNORM8 : TEXCOORD1; - nointerpolation uint SNORM16 : TEXCOORD2; - nointerpolation uint UNORM16 : TEXCOORD3; - nointerpolation float4 FP32 : TEXCOORD4; -}; - -struct SPIRV_Cross_Output -{ - float4 FP32Out : SV_Target0; - uint UNORM8Out : SV_Target1; - uint SNORM8Out : SV_Target2; - uint UNORM16Out : SV_Target3; - uint SNORM16Out : SV_Target4; -}; - -uint SPIRV_Cross_packUnorm4x8(float4 value) -{ - uint4 Packed = uint4(round(saturate(value) * 255.0)); - return Packed.x | (Packed.y << 8) | (Packed.z << 16) | (Packed.w << 24); -} - -float4 SPIRV_Cross_unpackUnorm4x8(uint value) -{ - uint4 Packed = uint4(value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, value >> 24); - return float4(Packed) / 255.0; -} - -uint SPIRV_Cross_packSnorm4x8(float4 value) -{ - int4 Packed = int4(round(clamp(value, -1.0, 1.0) * 127.0)) & 0xff; - return uint(Packed.x | (Packed.y << 8) | (Packed.z << 16) | (Packed.w << 24)); -} - -float4 SPIRV_Cross_unpackSnorm4x8(uint value) -{ - int SignedValue = int(value); - int4 Packed = int4(SignedValue << 24, SignedValue << 16, SignedValue << 8, SignedValue) >> 24; - return clamp(float4(Packed) / 127.0, -1.0, 1.0); -} - -uint SPIRV_Cross_packUnorm2x16(float2 value) -{ - uint2 Packed = uint2(round(saturate(value) * 65535.0)); - return Packed.x | (Packed.y << 16); -} - -float2 SPIRV_Cross_unpackUnorm2x16(uint value) -{ - uint2 Packed = uint2(value & 0xffff, value >> 16); - return float2(Packed) / 65535.0; -} - -uint SPIRV_Cross_packSnorm2x16(float2 value) -{ - int2 Packed = int2(round(clamp(value, -1.0, 1.0) * 32767.0)) & 0xffff; - return uint(Packed.x | (Packed.y << 16)); -} - -float2 SPIRV_Cross_unpackSnorm2x16(uint value) -{ - int SignedValue = int(value); - int2 Packed = int2(SignedValue << 16, SignedValue) >> 16; - return clamp(float2(Packed) / 32767.0, -1.0, 1.0); -} - -void frag_main() -{ - FP32Out = SPIRV_Cross_unpackUnorm4x8(UNORM8); - FP32Out = SPIRV_Cross_unpackSnorm4x8(SNORM8); - float2 _21 = SPIRV_Cross_unpackUnorm2x16(UNORM16); - FP32Out = float4(_21.x, _21.y, FP32Out.z, FP32Out.w); - float2 _26 = SPIRV_Cross_unpackSnorm2x16(SNORM16); - FP32Out = float4(_26.x, _26.y, FP32Out.z, FP32Out.w); - UNORM8Out = SPIRV_Cross_packUnorm4x8(FP32); - SNORM8Out = SPIRV_Cross_packSnorm4x8(FP32); - UNORM16Out = SPIRV_Cross_packUnorm2x16(FP32.xy); - SNORM16Out = SPIRV_Cross_packSnorm2x16(FP32.zw); -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - UNORM8 = stage_input.UNORM8; - SNORM8 = stage_input.SNORM8; - UNORM16 = stage_input.UNORM16; - SNORM16 = stage_input.SNORM16; - FP32 = stage_input.FP32; - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FP32Out = FP32Out; - stage_output.UNORM8Out = UNORM8Out; - stage_output.SNORM8Out = SNORM8Out; - stage_output.UNORM16Out = UNORM16Out; - stage_output.SNORM16Out = SNORM16Out; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/various-glsl-ops.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/various-glsl-ops.frag deleted file mode 100644 index f0b345482b..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/various-glsl-ops.frag +++ /dev/null @@ -1,28 +0,0 @@ -static float2 interpolant; -static float4 FragColor; - -struct SPIRV_Cross_Input -{ - float2 interpolant : TEXCOORD0; -}; - -struct SPIRV_Cross_Output -{ - float4 FragColor : SV_Target0; -}; - -void frag_main() -{ - float4 color = float4(0.0f, 0.0f, 0.0f, EvaluateAttributeSnapped(interpolant, 0.100000001490116119384765625f.xx).x); - color += float4(0.0f, 0.0f, 0.0f, ddx_coarse(interpolant.x)); - FragColor = color; -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - interpolant = stage_input.interpolant; - frag_main(); - SPIRV_Cross_Output stage_output; - stage_output.FragColor = FragColor; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/vert/basic.vert b/deps/SPIRV-Cross/reference/shaders-hlsl/vert/basic.vert deleted file mode 100644 index 5f0a5f3d1a..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/vert/basic.vert +++ /dev/null @@ -1,38 +0,0 @@ -cbuffer _16 -{ - row_major float4x4 _16_uMVP : packoffset(c0); -}; - -static float4 gl_Position; -static float4 aVertex; -static float3 vNormal; -static float3 aNormal; - -struct SPIRV_Cross_Input -{ - float4 aVertex : TEXCOORD0; - float3 aNormal : TEXCOORD1; -}; - -struct SPIRV_Cross_Output -{ - float3 vNormal : TEXCOORD0; - float4 gl_Position : SV_Position; -}; - -void vert_main() -{ - gl_Position = mul(aVertex, _16_uMVP); - vNormal = aNormal; -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - aVertex = stage_input.aVertex; - aNormal = stage_input.aNormal; - vert_main(); - SPIRV_Cross_Output stage_output; - stage_output.gl_Position = gl_Position; - stage_output.vNormal = vNormal; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/vert/instancing.vert b/deps/SPIRV-Cross/reference/shaders-hlsl/vert/instancing.vert deleted file mode 100644 index 48b2df20d3..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/vert/instancing.vert +++ /dev/null @@ -1,28 +0,0 @@ -static float4 gl_Position; -static int gl_VertexIndex; -static int gl_InstanceIndex; -struct SPIRV_Cross_Input -{ - uint gl_VertexIndex : SV_VertexID; - uint gl_InstanceIndex : SV_InstanceID; -}; - -struct SPIRV_Cross_Output -{ - float4 gl_Position : SV_Position; -}; - -void vert_main() -{ - gl_Position = float(gl_VertexIndex + gl_InstanceIndex).xxxx; -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - gl_VertexIndex = int(stage_input.gl_VertexIndex); - gl_InstanceIndex = int(stage_input.gl_InstanceIndex); - vert_main(); - SPIRV_Cross_Output stage_output; - stage_output.gl_Position = gl_Position; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/vert/locations.vert b/deps/SPIRV-Cross/reference/shaders-hlsl/vert/locations.vert deleted file mode 100644 index b06b204bdd..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/vert/locations.vert +++ /dev/null @@ -1,75 +0,0 @@ -struct Foo -{ - float3 a; - float3 b; - float3 c; -}; - -static float4 gl_Position; -static float4 Input2; -static float4 Input4; -static float4 Input0; -static float vLocation0; -static float vLocation1; -static float vLocation2[2]; -static Foo vLocation4; -static float vLocation9; - -struct VertexOut -{ - float3 color : TEXCOORD7; - float3 foo : TEXCOORD8; -}; - -static VertexOut vout; - -struct SPIRV_Cross_Input -{ - float4 Input0 : TEXCOORD0; - float4 Input2 : TEXCOORD2; - float4 Input4 : TEXCOORD4; -}; - -struct SPIRV_Cross_Output -{ - float vLocation0 : TEXCOORD0; - float vLocation1 : TEXCOORD1; - float vLocation2[2] : TEXCOORD2; - Foo vLocation4 : TEXCOORD4; - float vLocation9 : TEXCOORD9; - float4 gl_Position : SV_Position; -}; - -void vert_main() -{ - gl_Position = ((1.0f.xxxx + Input2) + Input4) + Input0; - vLocation0 = 0.0f; - vLocation1 = 1.0f; - vLocation2[0] = 2.0f; - vLocation2[1] = 2.0f; - Foo foo; - foo.a = 1.0f.xxx; - foo.b = 1.0f.xxx; - foo.c = 1.0f.xxx; - vLocation4 = foo; - vLocation9 = 9.0f; - vout.color = 2.0f.xxx; - vout.foo = 4.0f.xxx; -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input, out VertexOut stage_outputvout) -{ - Input2 = stage_input.Input2; - Input4 = stage_input.Input4; - Input0 = stage_input.Input0; - vert_main(); - stage_outputvout = vout; - SPIRV_Cross_Output stage_output; - stage_output.gl_Position = gl_Position; - stage_output.vLocation0 = vLocation0; - stage_output.vLocation1 = vLocation1; - stage_output.vLocation2 = vLocation2; - stage_output.vLocation4 = vLocation4; - stage_output.vLocation9 = vLocation9; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/vert/matrix-attribute.vert b/deps/SPIRV-Cross/reference/shaders-hlsl/vert/matrix-attribute.vert deleted file mode 100644 index a3d0eef56e..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/vert/matrix-attribute.vert +++ /dev/null @@ -1,35 +0,0 @@ -static float4 gl_Position; -static float4x4 m; -static float3 pos; - -struct SPIRV_Cross_Input -{ - float3 pos : TEXCOORD0; - float4 m_0 : TEXCOORD1_0; - float4 m_1 : TEXCOORD1_1; - float4 m_2 : TEXCOORD1_2; - float4 m_3 : TEXCOORD1_3; -}; - -struct SPIRV_Cross_Output -{ - float4 gl_Position : SV_Position; -}; - -void vert_main() -{ - gl_Position = mul(float4(pos, 1.0f), m); -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - m[0] = stage_input.m_0; - m[1] = stage_input.m_1; - m[2] = stage_input.m_2; - m[3] = stage_input.m_3; - pos = stage_input.pos; - vert_main(); - SPIRV_Cross_Output stage_output; - stage_output.gl_Position = gl_Position; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/vert/matrix-output.vert b/deps/SPIRV-Cross/reference/shaders-hlsl/vert/matrix-output.vert deleted file mode 100644 index dc776cb5ec..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/vert/matrix-output.vert +++ /dev/null @@ -1,23 +0,0 @@ -static float4 gl_Position; -static float4x4 m; - -struct SPIRV_Cross_Output -{ - float4x4 m : TEXCOORD0; - float4 gl_Position : SV_Position; -}; - -void vert_main() -{ - gl_Position = 1.0f.xxxx; - m = float4x4(float4(1.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 1.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 1.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 1.0f)); -} - -SPIRV_Cross_Output main() -{ - vert_main(); - SPIRV_Cross_Output stage_output; - stage_output.gl_Position = gl_Position; - stage_output.m = m; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/vert/no-input.vert b/deps/SPIRV-Cross/reference/shaders-hlsl/vert/no-input.vert deleted file mode 100644 index c98544dbe8..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/vert/no-input.vert +++ /dev/null @@ -1,18 +0,0 @@ -static float4 gl_Position; -struct SPIRV_Cross_Output -{ - float4 gl_Position : SV_Position; -}; - -void vert_main() -{ - gl_Position = 1.0f.xxxx; -} - -SPIRV_Cross_Output main() -{ - vert_main(); - SPIRV_Cross_Output stage_output; - stage_output.gl_Position = gl_Position; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/vert/point-size-compat.vert b/deps/SPIRV-Cross/reference/shaders-hlsl/vert/point-size-compat.vert deleted file mode 100644 index 83333d0be2..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/vert/point-size-compat.vert +++ /dev/null @@ -1,20 +0,0 @@ -static float4 gl_Position; -static float gl_PointSize; -struct SPIRV_Cross_Output -{ - float4 gl_Position : SV_Position; -}; - -void vert_main() -{ - gl_Position = 1.0f.xxxx; - gl_PointSize = 10.0f; -} - -SPIRV_Cross_Output main() -{ - vert_main(); - SPIRV_Cross_Output stage_output; - stage_output.gl_Position = gl_Position; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/vert/qualifiers.vert b/deps/SPIRV-Cross/reference/shaders-hlsl/vert/qualifiers.vert deleted file mode 100644 index 13ee2a8c1c..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/vert/qualifiers.vert +++ /dev/null @@ -1,50 +0,0 @@ -static float4 gl_Position; -static float vFlat; -static float vCentroid; -static float vSample; -static float vNoperspective; - -struct Block -{ - nointerpolation float vFlat : TEXCOORD4; - centroid float vCentroid : TEXCOORD5; - sample float vSample : TEXCOORD6; - noperspective float vNoperspective : TEXCOORD7; -}; - -static Block vout; - -struct SPIRV_Cross_Output -{ - nointerpolation float vFlat : TEXCOORD0; - centroid float vCentroid : TEXCOORD1; - sample float vSample : TEXCOORD2; - noperspective float vNoperspective : TEXCOORD3; - float4 gl_Position : SV_Position; -}; - -void vert_main() -{ - gl_Position = 1.0f.xxxx; - vFlat = 0.0f; - vCentroid = 1.0f; - vSample = 2.0f; - vNoperspective = 3.0f; - vout.vFlat = 0.0f; - vout.vCentroid = 1.0f; - vout.vSample = 2.0f; - vout.vNoperspective = 3.0f; -} - -SPIRV_Cross_Output main(out Block stage_outputvout) -{ - vert_main(); - stage_outputvout = vout; - SPIRV_Cross_Output stage_output; - stage_output.gl_Position = gl_Position; - stage_output.vFlat = vFlat; - stage_output.vCentroid = vCentroid; - stage_output.vSample = vSample; - stage_output.vNoperspective = vNoperspective; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/vert/sampler-buffers.vert b/deps/SPIRV-Cross/reference/shaders-hlsl/vert/sampler-buffers.vert deleted file mode 100644 index a4329dbf36..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/vert/sampler-buffers.vert +++ /dev/null @@ -1,27 +0,0 @@ -Buffer uFloatSampler : register(t1); -Buffer uIntSampler : register(t2); -Buffer uUintSampler : register(t3); - -static float4 gl_Position; -struct SPIRV_Cross_Output -{ - float4 gl_Position : SV_Position; -}; - -float4 sample_from_function(Buffer s0, Buffer s1, Buffer s2) -{ - return (s0.Load(20) + asfloat(s1.Load(40))) + asfloat(s2.Load(60)); -} - -void vert_main() -{ - gl_Position = sample_from_function(uFloatSampler, uIntSampler, uUintSampler); -} - -SPIRV_Cross_Output main() -{ - vert_main(); - SPIRV_Cross_Output stage_output; - stage_output.gl_Position = gl_Position; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/vert/struct-composite-decl.vert b/deps/SPIRV-Cross/reference/shaders-hlsl/vert/struct-composite-decl.vert deleted file mode 100644 index 5b2c5824fc..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/vert/struct-composite-decl.vert +++ /dev/null @@ -1,50 +0,0 @@ -struct VOut -{ - float4 a; - float4 b; - float4 c; - float4 d; -}; - -static VOut vout; -static float4 a; -static float4 b; -static float4 c; -static float4 d; - -struct SPIRV_Cross_Input -{ - float4 a : TEXCOORD0; - float4 b : TEXCOORD1; - float4 c : TEXCOORD2; - float4 d : TEXCOORD3; -}; - -struct SPIRV_Cross_Output -{ - VOut vout : TEXCOORD0; -}; - -void emit_result(VOut v) -{ - vout = v; -} - -void vert_main() -{ - VOut _26 = { a, b, c, d }; - VOut param = _26; - emit_result(param); -} - -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) -{ - a = stage_input.a; - b = stage_input.b; - c = stage_input.c; - d = stage_input.d; - vert_main(); - SPIRV_Cross_Output stage_output; - stage_output.vout = vout; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/vert/texture_buffer.vert b/deps/SPIRV-Cross/reference/shaders-hlsl/vert/texture_buffer.vert deleted file mode 100644 index 1c92f6fe65..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-hlsl/vert/texture_buffer.vert +++ /dev/null @@ -1,21 +0,0 @@ -Buffer uSamp : register(t4); -RWBuffer uSampo : register(u5); - -static float4 gl_Position; -struct SPIRV_Cross_Output -{ - float4 gl_Position : SV_Position; -}; - -void vert_main() -{ - gl_Position = uSamp.Load(10) + uSampo[100]; -} - -SPIRV_Cross_Output main() -{ - vert_main(); - SPIRV_Cross_Output stage_output; - stage_output.gl_Position = gl_Position; - return stage_output; -} diff --git a/deps/SPIRV-Cross/reference/shaders-msl-no-opt/vert/functions_nested.vert b/deps/SPIRV-Cross/reference/shaders-msl-no-opt/vert/functions_nested.vert deleted file mode 100644 index ff0f60dbef..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl-no-opt/vert/functions_nested.vert +++ /dev/null @@ -1,189 +0,0 @@ -#pragma clang diagnostic ignored "-Wmissing-prototypes" - -#include -#include - -using namespace metal; - -struct attr_desc -{ - int type; - int attribute_size; - int starting_offset; - int stride; - int swap_bytes; - int is_volatile; -}; - -struct VertexBuffer -{ - float4x4 scale_offset_mat; - uint vertex_base_index; - int4 input_attributes[16]; -}; - -struct VertexConstantsBuffer -{ - float4 vc[16]; -}; - -constant float4 _295 = {}; - -struct main0_out -{ - float4 tc0 [[user(locn0)]]; - float4 back_color [[user(locn10)]]; - float4 gl_Position [[position]]; -}; - -attr_desc fetch_desc(thread const int& location, constant VertexBuffer& v_227) -{ - int attribute_flags = v_227.input_attributes[location].w; - attr_desc result; - result.type = v_227.input_attributes[location].x; - result.attribute_size = v_227.input_attributes[location].y; - result.starting_offset = v_227.input_attributes[location].z; - result.stride = attribute_flags & 255; - result.swap_bytes = (attribute_flags >> 8) & 1; - result.is_volatile = (attribute_flags >> 9) & 1; - return result; -} - -uint get_bits(thread const uint4& v, thread const int& swap) -{ - if (swap != 0) - { - return ((v.w | (v.z << uint(8))) | (v.y << uint(16))) | (v.x << uint(24)); - } - return ((v.x | (v.y << uint(8))) | (v.z << uint(16))) | (v.w << uint(24)); -} - -float4 fetch_attr(thread const attr_desc& desc, thread const int& vertex_id, thread const texture2d input_stream) -{ - float4 result = float4(0.0, 0.0, 0.0, 1.0); - bool reverse_order = false; - int first_byte = (vertex_id * desc.stride) + desc.starting_offset; - for (int n = 0; n < 4; n++) - { - if (n == desc.attribute_size) - { - break; - } - uint4 tmp; - switch (desc.type) - { - case 0: - { - int _131 = first_byte; - first_byte = _131 + 1; - tmp.x = input_stream.read(uint2(_131, 0)).x; - int _138 = first_byte; - first_byte = _138 + 1; - tmp.y = input_stream.read(uint2(_138, 0)).x; - uint4 param = tmp; - int param_1 = desc.swap_bytes; - result[n] = float(get_bits(param, param_1)); - break; - } - case 1: - { - int _156 = first_byte; - first_byte = _156 + 1; - tmp.x = input_stream.read(uint2(_156, 0)).x; - int _163 = first_byte; - first_byte = _163 + 1; - tmp.y = input_stream.read(uint2(_163, 0)).x; - int _170 = first_byte; - first_byte = _170 + 1; - tmp.z = input_stream.read(uint2(_170, 0)).x; - int _177 = first_byte; - first_byte = _177 + 1; - tmp.w = input_stream.read(uint2(_177, 0)).x; - uint4 param_2 = tmp; - int param_3 = desc.swap_bytes; - result[n] = as_type(get_bits(param_2, param_3)); - break; - } - case 2: - { - int _195 = first_byte; - first_byte = _195 + 1; - result[n] = float(input_stream.read(uint2(_195, 0)).x); - reverse_order = desc.swap_bytes != 0; - break; - } - } - } - float4 _209; - if (reverse_order) - { - _209 = result.wzyx; - } - else - { - _209 = result; - } - return _209; -} - -float4 read_location(thread const int& location, constant VertexBuffer& v_227, thread uint& gl_VertexIndex, thread texture2d buff_in_2, thread texture2d buff_in_1) -{ - int param = location; - attr_desc desc = fetch_desc(param, v_227); - int vertex_id = gl_VertexIndex - int(v_227.vertex_base_index); - if (desc.is_volatile != 0) - { - attr_desc param_1 = desc; - int param_2 = vertex_id; - return fetch_attr(param_1, param_2, buff_in_2); - } - else - { - attr_desc param_3 = desc; - int param_4 = vertex_id; - return fetch_attr(param_3, param_4, buff_in_1); - } -} - -void vs_adjust(thread float4& dst_reg0, thread float4& dst_reg1, thread float4& dst_reg7, constant VertexBuffer& v_227, thread uint& gl_VertexIndex, thread texture2d buff_in_2, thread texture2d buff_in_1, constant VertexConstantsBuffer& v_309) -{ - int param = 3; - float4 in_diff_color = read_location(param, v_227, gl_VertexIndex, buff_in_2, buff_in_1); - int param_1 = 0; - float4 in_pos = read_location(param_1, v_227, gl_VertexIndex, buff_in_2, buff_in_1); - int param_2 = 8; - float4 in_tc0 = read_location(param_2, v_227, gl_VertexIndex, buff_in_2, buff_in_1); - dst_reg1 = in_diff_color * v_309.vc[13]; - float4 tmp0; - tmp0.x = float4(dot(float4(in_pos.xyz, 1.0), v_309.vc[4])).x; - tmp0.y = float4(dot(float4(in_pos.xyz, 1.0), v_309.vc[5])).y; - tmp0.z = float4(dot(float4(in_pos.xyz, 1.0), v_309.vc[6])).z; - float4 tmp1; - tmp1 = float4(in_tc0.xy.x, in_tc0.xy.y, tmp1.z, tmp1.w); - tmp1.z = v_309.vc[15].x; - dst_reg7.y = float4(dot(float4(tmp1.xyz, 1.0), v_309.vc[8])).y; - dst_reg7.x = float4(dot(float4(tmp1.xyz, 1.0), v_309.vc[7])).x; - dst_reg0.y = float4(dot(float4(tmp0.xyz, 1.0), v_309.vc[1])).y; - dst_reg0.x = float4(dot(float4(tmp0.xyz, 1.0), v_309.vc[0])).x; -} - -vertex main0_out main0(constant VertexBuffer& v_227 [[buffer(0)]], uint gl_VertexIndex [[vertex_id]], texture2d buff_in_2 [[texture(0)]], texture2d buff_in_1 [[texture(1)]], constant VertexConstantsBuffer& v_309 [[buffer(1)]]) -{ - main0_out out = {}; - float4 dst_reg0 = float4(0.0, 0.0, 0.0, 1.0); - float4 dst_reg1 = float4(0.0); - float4 dst_reg7 = float4(0.0); - float4 param = dst_reg0; - float4 param_1 = dst_reg1; - float4 param_2 = dst_reg7; - vs_adjust(param, param_1, param_2, v_227, gl_VertexIndex, buff_in_2, buff_in_1, v_309); - dst_reg0 = param; - dst_reg1 = param_1; - dst_reg7 = param_2; - out.gl_Position = dst_reg0; - out.back_color = dst_reg1; - out.tc0 = dst_reg7; - out.gl_Position *= v_227.scale_offset_mat; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/asm/comp/bitcast_iadd.asm.comp b/deps/SPIRV-Cross/reference/shaders-msl/asm/comp/bitcast_iadd.asm.comp deleted file mode 100644 index 47ce85f8fc..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/asm/comp/bitcast_iadd.asm.comp +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include - -using namespace metal; - -struct _3 -{ - int4 _m0; - uint4 _m1; -}; - -struct _4 -{ - uint4 _m0; - int4 _m1; -}; - -kernel void main0(device _3& _5 [[buffer(0)]], device _4& _6 [[buffer(1)]]) -{ - _6._m0 = _5._m1 + uint4(_5._m0); - _6._m0 = uint4(_5._m0) + _5._m1; - _6._m0 = _5._m1 + _5._m1; - _6._m0 = uint4(_5._m0 + _5._m0); - _6._m1 = int4(_5._m1 + _5._m1); - _6._m1 = _5._m0 + _5._m0; - _6._m1 = int4(_5._m1) + _5._m0; - _6._m1 = _5._m0 + int4(_5._m1); -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/asm/comp/bitcast_sar.asm.comp b/deps/SPIRV-Cross/reference/shaders-msl/asm/comp/bitcast_sar.asm.comp deleted file mode 100644 index 20d6fe9e9d..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/asm/comp/bitcast_sar.asm.comp +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include - -using namespace metal; - -struct _3 -{ - int4 _m0; - uint4 _m1; -}; - -struct _4 -{ - uint4 _m0; - int4 _m1; -}; - -kernel void main0(device _3& _5 [[buffer(0)]], device _4& _6 [[buffer(1)]]) -{ - _6._m0 = uint4(int4(_5._m1) >> _5._m0); - _6._m0 = uint4(_5._m0 >> int4(_5._m1)); - _6._m0 = uint4(int4(_5._m1) >> int4(_5._m1)); - _6._m0 = uint4(_5._m0 >> _5._m0); - _6._m1 = int4(_5._m1) >> int4(_5._m1); - _6._m1 = _5._m0 >> _5._m0; - _6._m1 = int4(_5._m1) >> _5._m0; - _6._m1 = _5._m0 >> int4(_5._m1); -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/asm/comp/bitcast_sdiv.asm.comp b/deps/SPIRV-Cross/reference/shaders-msl/asm/comp/bitcast_sdiv.asm.comp deleted file mode 100644 index f18b318bbb..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/asm/comp/bitcast_sdiv.asm.comp +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include - -using namespace metal; - -struct _3 -{ - int4 _m0; - uint4 _m1; -}; - -struct _4 -{ - uint4 _m0; - int4 _m1; -}; - -kernel void main0(device _3& _5 [[buffer(0)]], device _4& _6 [[buffer(1)]]) -{ - _6._m0 = uint4(int4(_5._m1) / _5._m0); - _6._m0 = uint4(_5._m0 / int4(_5._m1)); - _6._m0 = uint4(int4(_5._m1) / int4(_5._m1)); - _6._m0 = uint4(_5._m0 / _5._m0); - _6._m1 = int4(_5._m1) / int4(_5._m1); - _6._m1 = _5._m0 / _5._m0; - _6._m1 = int4(_5._m1) / _5._m0; - _6._m1 = _5._m0 / int4(_5._m1); -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/asm/comp/bitcast_slr.asm.comp b/deps/SPIRV-Cross/reference/shaders-msl/asm/comp/bitcast_slr.asm.comp deleted file mode 100644 index 9fd60bef26..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/asm/comp/bitcast_slr.asm.comp +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include - -using namespace metal; - -struct _3 -{ - int4 _m0; - uint4 _m1; -}; - -struct _4 -{ - uint4 _m0; - int4 _m1; -}; - -kernel void main0(device _3& _5 [[buffer(0)]], device _4& _6 [[buffer(1)]]) -{ - _6._m0 = _5._m1 >> uint4(_5._m0); - _6._m0 = uint4(_5._m0) >> _5._m1; - _6._m0 = _5._m1 >> _5._m1; - _6._m0 = uint4(_5._m0) >> uint4(_5._m0); - _6._m1 = int4(_5._m1 >> _5._m1); - _6._m1 = int4(uint4(_5._m0) >> uint4(_5._m0)); - _6._m1 = int4(_5._m1 >> uint4(_5._m0)); - _6._m1 = int4(uint4(_5._m0) >> _5._m1); -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/asm/comp/multiple-entry.asm.comp b/deps/SPIRV-Cross/reference/shaders-msl/asm/comp/multiple-entry.asm.comp deleted file mode 100644 index 7652733268..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/asm/comp/multiple-entry.asm.comp +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include - -using namespace metal; - -struct _6 -{ - int4 _m0; - uint4 _m1; -}; - -struct _7 -{ - uint4 _m0; - int4 _m1; -}; - -kernel void main0(device _6& _8 [[buffer(0)]], device _7& _9 [[buffer(1)]]) -{ - _9._m0 = _8._m1 + uint4(_8._m0); - _9._m0 = uint4(_8._m0) + _8._m1; - _9._m0 = _8._m1 + _8._m1; - _9._m0 = uint4(_8._m0 + _8._m0); - _9._m1 = int4(_8._m1 + _8._m1); - _9._m1 = _8._m0 + _8._m0; - _9._m1 = int4(_8._m1) + _8._m0; - _9._m1 = _8._m0 + int4(_8._m1); -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/asm/comp/quantize.asm.comp b/deps/SPIRV-Cross/reference/shaders-msl/asm/comp/quantize.asm.comp deleted file mode 100644 index 1839ec7a3b..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/asm/comp/quantize.asm.comp +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include - -using namespace metal; - -struct SSBO0 -{ - float scalar; - float2 vec2_val; - float3 vec3_val; - float4 vec4_val; -}; - -kernel void main0(device SSBO0& _4 [[buffer(0)]]) -{ - _4.scalar = float(half(_4.scalar)); - _4.vec2_val = float2(half2(_4.vec2_val)); - _4.vec3_val = float3(half3(_4.vec3_val)); - _4.vec4_val = float4(half4(_4.vec4_val)); -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/asm/comp/specialization-constant-workgroup.asm.comp b/deps/SPIRV-Cross/reference/shaders-msl/asm/comp/specialization-constant-workgroup.asm.comp deleted file mode 100644 index 5802ddac90..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/asm/comp/specialization-constant-workgroup.asm.comp +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include - -using namespace metal; - -constant uint _5_tmp [[function_constant(10)]]; -constant uint _5 = is_function_constant_defined(_5_tmp) ? _5_tmp : 9u; -constant uint _6_tmp [[function_constant(12)]]; -constant uint _6 = is_function_constant_defined(_6_tmp) ? _6_tmp : 4u; -constant uint3 gl_WorkGroupSize = uint3(_5, 20u, _6); - -struct SSBO -{ - float a; -}; - -kernel void main0(device SSBO& _4 [[buffer(0)]]) -{ - _4.a += 1.0; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/asm/comp/storage-buffer-basic.asm.comp b/deps/SPIRV-Cross/reference/shaders-msl/asm/comp/storage-buffer-basic.asm.comp deleted file mode 100644 index 19d753afa7..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/asm/comp/storage-buffer-basic.asm.comp +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -using namespace metal; - -constant uint _3_tmp [[function_constant(0)]]; -constant uint _3 = is_function_constant_defined(_3_tmp) ? _3_tmp : 1u; -constant uint _4_tmp [[function_constant(2)]]; -constant uint _4 = is_function_constant_defined(_4_tmp) ? _4_tmp : 3u; -constant uint3 gl_WorkGroupSize = uint3(_3, 2u, _4); - -struct _6 -{ - float _m0[1]; -}; - -kernel void main0(uint3 gl_WorkGroupID [[threadgroup_position_in_grid]], device _6& _8 [[buffer(0)]], device _6& _9 [[buffer(1)]]) -{ - uint3 _23 = gl_WorkGroupSize; - _8._m0[gl_WorkGroupID.x] = _9._m0[gl_WorkGroupID.x] + _8._m0[gl_WorkGroupID.x]; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/asm/frag/default-member-names.asm.frag b/deps/SPIRV-Cross/reference/shaders-msl/asm/frag/default-member-names.asm.frag deleted file mode 100644 index 3628c4eaae..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/asm/frag/default-member-names.asm.frag +++ /dev/null @@ -1,40 +0,0 @@ -#include -#include - -using namespace metal; - -struct _9 -{ - float _m0; -}; - -struct _10 -{ - float _m0; - float _m1; - float _m2; - float _m3; - float _m4; - float _m5; - float _m6; - float _m7; - float _m8; - float _m9; - float _m10; - float _m11; - _9 _m12; -}; - -struct main0_out -{ - float4 m_3 [[color(0)]]; -}; - -fragment main0_out main0() -{ - main0_out out = {}; - _10 _21; - out.m_3 = float4(_21._m0, _21._m1, _21._m2, _21._m3); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag b/deps/SPIRV-Cross/reference/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag deleted file mode 100644 index 98a1674865..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag +++ /dev/null @@ -1,235 +0,0 @@ -#include -#include - -using namespace metal; - -struct VertexOutput -{ - float4 HPosition; - float4 Uv_EdgeDistance1; - float4 UvStuds_EdgeDistance2; - float4 Color; - float4 LightPosition_Fog; - float4 View_Depth; - float4 Normal_SpecPower; - float3 Tangent; - float4 PosLightSpace_Reflectance; - float studIndex; -}; - -struct Surface -{ - float3 albedo; - float3 normal; - float specular; - float gloss; - float reflectance; - float opacity; -}; - -struct SurfaceInput -{ - float4 Color; - float2 Uv; - float2 UvStuds; -}; - -struct Globals -{ - float4x4 ViewProjection; - float4 ViewRight; - float4 ViewUp; - float4 ViewDir; - float3 CameraPosition; - float3 AmbientColor; - float3 Lamp0Color; - float3 Lamp0Dir; - float3 Lamp1Color; - float4 FogParams; - float3 FogColor; - float4 LightBorder; - float4 LightConfig0; - float4 LightConfig1; - float4 LightConfig2; - float4 LightConfig3; - float4 RefractionBias_FadeDistance_GlowFactor; - float4 OutlineBrightness_ShadowInfo; - float4 ShadowMatrix0; - float4 ShadowMatrix1; - float4 ShadowMatrix2; -}; - -struct Params -{ - float4 LqmatFarTilingFactor; -}; - -struct CB0 -{ - Globals CB0; -}; - -struct CB2 -{ - Params CB2; -}; - -constant VertexOutput _121 = {}; -constant SurfaceInput _122 = {}; -constant float2 _123 = {}; -constant float4 _124 = {}; -constant Surface _125 = {}; -constant float4 _192 = {}; -constant float4 _219 = {}; -constant float4 _297 = {}; - -struct main0_in -{ - float IN_studIndex [[user(locn8)]]; - float4 IN_PosLightSpace_Reflectance [[user(locn7)]]; - float3 IN_Tangent [[user(locn6)]]; - float4 IN_Normal_SpecPower [[user(locn5)]]; - float4 IN_View_Depth [[user(locn4)]]; - float4 IN_LightPosition_Fog [[user(locn3)]]; - float4 IN_Color [[user(locn2)]]; - float4 IN_UvStuds_EdgeDistance2 [[user(locn1)]]; - float4 IN_Uv_EdgeDistance1 [[user(locn0)]]; -}; - -struct main0_out -{ - float4 _entryPointOutput [[color(0)]]; -}; - -fragment main0_out main0(main0_in in [[stage_in]], float4 gl_FragCoord [[position]], constant CB0& _19 [[buffer(0)]], texture3d LightMapTexture [[texture(0)]], sampler LightMapSampler [[sampler(0)]], sampler ShadowMapSampler [[sampler(1)]], texture2d ShadowMapTexture [[texture(1)]], texturecube EnvironmentMapTexture [[texture(2)]], sampler EnvironmentMapSampler [[sampler(2)]], sampler DiffuseMapSampler [[sampler(3)]], texture2d DiffuseMapTexture [[texture(3)]], sampler NormalMapSampler [[sampler(4)]], texture2d NormalMapTexture [[texture(4)]], texture2d NormalDetailMapTexture [[texture(5)]], sampler NormalDetailMapSampler [[sampler(5)]], texture2d StudsMapTexture [[texture(6)]], sampler StudsMapSampler [[sampler(6)]], sampler SpecularMapSampler [[sampler(7)]], texture2d SpecularMapTexture [[texture(7)]]) -{ - main0_out out = {}; - VertexOutput _128 = _121; - _128.HPosition = gl_FragCoord; - VertexOutput _130 = _128; - _130.Uv_EdgeDistance1 = in.IN_Uv_EdgeDistance1; - VertexOutput _132 = _130; - _132.UvStuds_EdgeDistance2 = in.IN_UvStuds_EdgeDistance2; - VertexOutput _134 = _132; - _134.Color = in.IN_Color; - VertexOutput _136 = _134; - _136.LightPosition_Fog = in.IN_LightPosition_Fog; - VertexOutput _138 = _136; - _138.View_Depth = in.IN_View_Depth; - VertexOutput _140 = _138; - _140.Normal_SpecPower = in.IN_Normal_SpecPower; - VertexOutput _142 = _140; - _142.Tangent = in.IN_Tangent; - VertexOutput _144 = _142; - _144.PosLightSpace_Reflectance = in.IN_PosLightSpace_Reflectance; - VertexOutput _146 = _144; - _146.studIndex = in.IN_studIndex; - SurfaceInput _147 = _122; - _147.Color = in.IN_Color; - SurfaceInput _149 = _147; - _149.Uv = in.IN_Uv_EdgeDistance1.xy; - SurfaceInput _151 = _149; - _151.UvStuds = in.IN_UvStuds_EdgeDistance2.xy; - SurfaceInput _156 = _151; - _156.UvStuds.y = (fract(_151.UvStuds.y) + in.IN_studIndex) * 0.25; - float _163 = _146.View_Depth.w * _19.CB0.RefractionBias_FadeDistance_GlowFactor.y; - float _165 = clamp(1.0 - _163, 0.0, 1.0); - float2 _166 = in.IN_Uv_EdgeDistance1.xy * 1.0; - bool _173; - float4 _193; - do - { - _173 = 0.0 == 0.0; - if (_173) - { - _193 = DiffuseMapTexture.sample(DiffuseMapSampler, _166); - break; - } - else - { - float _180 = 1.0 / (1.0 - 0.0); - _193 = mix(DiffuseMapTexture.sample(DiffuseMapSampler, (_166 * 0.25)), DiffuseMapTexture.sample(DiffuseMapSampler, _166), float4(clamp((clamp(1.0 - (_146.View_Depth.w * 0.00333332992158830165863037109375), 0.0, 1.0) * _180) - (0.0 * _180), 0.0, 1.0))); - break; - } - _193 = _192; - break; - } while (false); - float4 _220; - do - { - if (_173) - { - _220 = NormalMapTexture.sample(NormalMapSampler, _166); - break; - } - else - { - float _207 = 1.0 / (1.0 - 0.0); - _220 = mix(NormalMapTexture.sample(NormalMapSampler, (_166 * 0.25)), NormalMapTexture.sample(NormalMapSampler, _166), float4(clamp((_165 * _207) - (0.0 * _207), 0.0, 1.0))); - break; - } - _220 = _219; - break; - } while (false); - float2 _223 = float2(1.0); - float2 _224 = (_220.wy * 2.0) - _223; - float3 _232 = float3(_224, sqrt(clamp(1.0 + dot(-_224, _224), 0.0, 1.0))); - float2 _240 = (NormalDetailMapTexture.sample(NormalDetailMapSampler, (_166 * 0.0)).wy * 2.0) - _223; - float2 _252 = _232.xy + (float3(_240, sqrt(clamp(1.0 + dot(-_240, _240), 0.0, 1.0))).xy * 0.0); - float3 _253 = float3(_252.x, _252.y, _232.z); - float2 _255 = _253.xy * _165; - float3 _256 = float3(_255.x, _255.y, _253.z); - float3 _271 = ((in.IN_Color.xyz * (_193 * 1.0).xyz) * (1.0 + (_256.x * 0.300000011920928955078125))) * (StudsMapTexture.sample(StudsMapSampler, _156.UvStuds).x * 2.0); - float4 _298; - do - { - if (0.75 == 0.0) - { - _298 = SpecularMapTexture.sample(SpecularMapSampler, _166); - break; - } - else - { - float _285 = 1.0 / (1.0 - 0.75); - _298 = mix(SpecularMapTexture.sample(SpecularMapSampler, (_166 * 0.25)), SpecularMapTexture.sample(SpecularMapSampler, _166), float4(clamp((_165 * _285) - (0.75 * _285), 0.0, 1.0))); - break; - } - _298 = _297; - break; - } while (false); - float2 _303 = mix(float2(0.800000011920928955078125, 120.0), (_298.xy * float2(2.0, 256.0)) + float2(0.0, 0.00999999977648258209228515625), float2(_165)); - Surface _304 = _125; - _304.albedo = _271; - Surface _305 = _304; - _305.normal = _256; - float _306 = _303.x; - Surface _307 = _305; - _307.specular = _306; - float _308 = _303.y; - Surface _309 = _307; - _309.gloss = _308; - float _312 = (_298.xy.y * _165) * 0.0; - Surface _313 = _309; - _313.reflectance = _312; - float4 _318 = float4(_271, _146.Color.w); - float3 _329 = normalize(((in.IN_Tangent * _313.normal.x) + (cross(in.IN_Normal_SpecPower.xyz, in.IN_Tangent) * _313.normal.y)) + (in.IN_Normal_SpecPower.xyz * _313.normal.z)); - float3 _332 = -_19.CB0.Lamp0Dir; - float _333 = dot(_329, _332); - float _357 = clamp(dot(step(_19.CB0.LightConfig3.xyz, abs(in.IN_LightPosition_Fog.xyz - _19.CB0.LightConfig2.xyz)), float3(1.0)), 0.0, 1.0); - float4 _368 = mix(LightMapTexture.sample(LightMapSampler, (in.IN_LightPosition_Fog.xyz.yzx - (in.IN_LightPosition_Fog.xyz.yzx * _357))), _19.CB0.LightBorder, float4(_357)); - float2 _376 = ShadowMapTexture.sample(ShadowMapSampler, in.IN_PosLightSpace_Reflectance.xyz.xy).xy; - float _392 = (1.0 - (((step(_376.x, in.IN_PosLightSpace_Reflectance.xyz.z) * clamp(9.0 - (20.0 * abs(in.IN_PosLightSpace_Reflectance.xyz.z - 0.5)), 0.0, 1.0)) * _376.y) * _19.CB0.OutlineBrightness_ShadowInfo.w)) * _368.w; - float3 _403 = mix(_318.xyz, EnvironmentMapTexture.sample(EnvironmentMapSampler, reflect(-in.IN_View_Depth.xyz, _329)).xyz, float3(_312)); - float4 _404 = float4(_403.x, _403.y, _403.z, _318.w); - float3 _422 = (((_19.CB0.AmbientColor + (((_19.CB0.Lamp0Color * clamp(_333, 0.0, 1.0)) + (_19.CB0.Lamp1Color * max(-_333, 0.0))) * _392)) + _368.xyz) * _404.xyz) + (_19.CB0.Lamp0Color * (((step(0.0, _333) * _306) * _392) * pow(clamp(dot(_329, normalize(_332 + normalize(in.IN_View_Depth.xyz))), 0.0, 1.0), _308))); - float4 _425 = float4(_422.x, _422.y, _422.z, _124.w); - _425.w = _404.w; - float2 _435 = min(in.IN_Uv_EdgeDistance1.wz, in.IN_UvStuds_EdgeDistance2.wz); - float _439 = min(_435.x, _435.y) / _163; - float3 _445 = _425.xyz * clamp((clamp((_163 * _19.CB0.OutlineBrightness_ShadowInfo.x) + _19.CB0.OutlineBrightness_ShadowInfo.y, 0.0, 1.0) * (1.5 - _439)) + _439, 0.0, 1.0); - float4 _446 = float4(_445.x, _445.y, _445.z, _425.w); - float3 _453 = mix(_19.CB0.FogColor, _446.xyz, float3(clamp(_146.LightPosition_Fog.w, 0.0, 1.0))); - out._entryPointOutput = float4(_453.x, _453.y, _453.z, _446.w); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/asm/frag/op-constant-null.asm.frag b/deps/SPIRV-Cross/reference/shaders-msl/asm/frag/op-constant-null.asm.frag deleted file mode 100644 index 588e7d1572..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/asm/frag/op-constant-null.asm.frag +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include - -using namespace metal; - -struct D -{ - float4 a; - float b; -}; - -struct main0_out -{ - float FragColor [[color(0)]]; -}; - -fragment main0_out main0() -{ - main0_out out = {}; - float a = 0.0; - float4 b = float4(0.0); - float2x3 c = float2x3(float3(0.0), float3(0.0)); - D d = {float4(0.0), 0.0}; - float4 e[4] = {float4(0.0), float4(0.0), float4(0.0), float4(0.0)}; - out.FragColor = a; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/asm/frag/phi-loop-variable.asm.frag b/deps/SPIRV-Cross/reference/shaders-msl/asm/frag/phi-loop-variable.asm.frag deleted file mode 100644 index 036774d661..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/asm/frag/phi-loop-variable.asm.frag +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include - -using namespace metal; - -fragment void main0() -{ - for (int _22 = 35; _22 >= 0; _22--) - { - } -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/asm/frag/undef-variable-store.asm.frag b/deps/SPIRV-Cross/reference/shaders-msl/asm/frag/undef-variable-store.asm.frag deleted file mode 100644 index 2cefeb6693..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/asm/frag/undef-variable-store.asm.frag +++ /dev/null @@ -1,37 +0,0 @@ -#include -#include - -using namespace metal; - -constant float4 _38 = {}; -constant float4 _47 = {}; - -struct main0_out -{ - float4 _entryPointOutput [[color(0)]]; -}; - -fragment main0_out main0() -{ - main0_out out = {}; - float4 _27; - do - { - float2 _26 = float2(0.0); - if (_26.x != 0.0) - { - _27 = float4(1.0, 0.0, 0.0, 1.0); - break; - } - else - { - _27 = float4(1.0, 1.0, 0.0, 1.0); - break; - } - _27 = _38; - break; - } while (false); - out._entryPointOutput = _27; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/asm/frag/unreachable.asm.frag b/deps/SPIRV-Cross/reference/shaders-msl/asm/frag/unreachable.asm.frag deleted file mode 100644 index 7a98487221..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/asm/frag/unreachable.asm.frag +++ /dev/null @@ -1,40 +0,0 @@ -#include -#include - -using namespace metal; - -constant float4 _21 = {}; - -struct main0_in -{ - int counter [[user(locn0)]]; -}; - -struct main0_out -{ - float4 FragColor [[color(0)]]; -}; - -fragment main0_out main0(main0_in in [[stage_in]]) -{ - main0_out out = {}; - float4 _24; - _24 = _21; - float4 _33; - for (;;) - { - if (in.counter == 10) - { - _33 = float4(10.0); - break; - } - else - { - _33 = float4(30.0); - break; - } - } - out.FragColor = _33; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag b/deps/SPIRV-Cross/reference/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag deleted file mode 100644 index 17cd528d41..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag +++ /dev/null @@ -1,321 +0,0 @@ -#include -#include - -using namespace metal; - -struct _28 -{ - float4 _m0; -}; - -struct _6 -{ - float4 _m0; - float _m1; - float4 _m2; -}; - -struct _10 -{ - float3 _m0; - packed_float3 _m1; - float _m2; - packed_float3 _m3; - float _m4; - packed_float3 _m5; - float _m6; - packed_float3 _m7; - float _m8; - packed_float3 _m9; - float _m10; - packed_float3 _m11; - float _m12; - float2 _m13; - float2 _m14; - packed_float3 _m15; - float _m16; - float _m17; - float _m18; - float _m19; - float _m20; - float4 _m21; - float4 _m22; - float4x4 _m23; - float4 _m24; -}; - -struct _18 -{ - float4x4 _m0; - float4x4 _m1; - float4x4 _m2; - float4x4 _m3; - float4 _m4; - float4 _m5; - float _m6; - float _m7; - float _m8; - float _m9; - packed_float3 _m10; - float _m11; - packed_float3 _m12; - float _m13; - packed_float3 _m14; - float _m15; - packed_float3 _m16; - float _m17; - float _m18; - float _m19; - float2 _m20; - float2 _m21; - float2 _m22; - float4 _m23; - float2 _m24; - float2 _m25; - float2 _m26; - char pad27[8]; - packed_float3 _m27; - float _m28; - float _m29; - float _m30; - float _m31; - float _m32; - float2 _m33; - float _m34; - float _m35; - float3 _m36; - float4x4 _m37[2]; - float4 _m38[2]; -}; - -constant _28 _74 = {}; - -struct main0_out -{ - float4 m_5 [[color(0)]]; -}; - -fragment main0_out main0(float4 gl_FragCoord [[position]], constant _6& _7 [[buffer(0)]], texture2d _8 [[texture(0)]], sampler _9 [[sampler(0)]], constant _10& _11 [[buffer(1)]], texture2d _12 [[texture(1)]], sampler _13 [[sampler(1)]], texture2d _14 [[texture(2)]], sampler _15 [[sampler(2)]], constant _18& _19 [[buffer(2)]]) -{ - main0_out out = {}; - _28 _77 = _74; - _77._m0 = float4(0.0); - float2 _82 = gl_FragCoord.xy * _19._m23.xy; - float4 _88 = _7._m2 * _7._m0.xyxy; - float2 _97 = clamp(_82 + (float3(0.0, -2.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - float3 _109 = _11._m5 * clamp(_8.sample(_9, _97, level(0.0)).w * _7._m1, 0.0, 1.0); - float4 _113 = _12.sample(_13, _97, level(0.0)); - float3 _129; - if (_113.y > 0.0) - { - _129 = _109 + (_14.sample(_15, _97, level(0.0)).xyz * clamp(_113.y * _113.z, 0.0, 1.0)); - } - else - { - _129 = _109; - } - float3 _133 = float4(0.0).xyz + (_129 * 0.5); - float4 _134 = float4(_133.x, _133.y, _133.z, float4(0.0).w); - _28 _135 = _77; - _135._m0 = _134; - float2 _144 = clamp(_82 + (float3(-1.0, -1.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - float3 _156 = _11._m5 * clamp(_8.sample(_9, _144, level(0.0)).w * _7._m1, 0.0, 1.0); - float4 _160 = _12.sample(_13, _144, level(0.0)); - float3 _176; - if (_160.y > 0.0) - { - _176 = _156 + (_14.sample(_15, _144, level(0.0)).xyz * clamp(_160.y * _160.z, 0.0, 1.0)); - } - else - { - _176 = _156; - } - float3 _180 = _134.xyz + (_176 * 0.5); - float4 _181 = float4(_180.x, _180.y, _180.z, _134.w); - _28 _182 = _135; - _182._m0 = _181; - float2 _191 = clamp(_82 + (float3(0.0, -1.0, 0.75).xy * _7._m0.xy), _88.xy, _88.zw); - float3 _203 = _11._m5 * clamp(_8.sample(_9, _191, level(0.0)).w * _7._m1, 0.0, 1.0); - float4 _207 = _12.sample(_13, _191, level(0.0)); - float3 _223; - if (_207.y > 0.0) - { - _223 = _203 + (_14.sample(_15, _191, level(0.0)).xyz * clamp(_207.y * _207.z, 0.0, 1.0)); - } - else - { - _223 = _203; - } - float3 _227 = _181.xyz + (_223 * 0.75); - float4 _228 = float4(_227.x, _227.y, _227.z, _181.w); - _28 _229 = _182; - _229._m0 = _228; - float2 _238 = clamp(_82 + (float3(1.0, -1.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - float3 _250 = _11._m5 * clamp(_8.sample(_9, _238, level(0.0)).w * _7._m1, 0.0, 1.0); - float4 _254 = _12.sample(_13, _238, level(0.0)); - float3 _270; - if (_254.y > 0.0) - { - _270 = _250 + (_14.sample(_15, _238, level(0.0)).xyz * clamp(_254.y * _254.z, 0.0, 1.0)); - } - else - { - _270 = _250; - } - float3 _274 = _228.xyz + (_270 * 0.5); - float4 _275 = float4(_274.x, _274.y, _274.z, _228.w); - _28 _276 = _229; - _276._m0 = _275; - float2 _285 = clamp(_82 + (float3(-2.0, 0.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - float3 _297 = _11._m5 * clamp(_8.sample(_9, _285, level(0.0)).w * _7._m1, 0.0, 1.0); - float4 _301 = _12.sample(_13, _285, level(0.0)); - float3 _317; - if (_301.y > 0.0) - { - _317 = _297 + (_14.sample(_15, _285, level(0.0)).xyz * clamp(_301.y * _301.z, 0.0, 1.0)); - } - else - { - _317 = _297; - } - float3 _321 = _275.xyz + (_317 * 0.5); - float4 _322 = float4(_321.x, _321.y, _321.z, _275.w); - _28 _323 = _276; - _323._m0 = _322; - float2 _332 = clamp(_82 + (float3(-1.0, 0.0, 0.75).xy * _7._m0.xy), _88.xy, _88.zw); - float3 _344 = _11._m5 * clamp(_8.sample(_9, _332, level(0.0)).w * _7._m1, 0.0, 1.0); - float4 _348 = _12.sample(_13, _332, level(0.0)); - float3 _364; - if (_348.y > 0.0) - { - _364 = _344 + (_14.sample(_15, _332, level(0.0)).xyz * clamp(_348.y * _348.z, 0.0, 1.0)); - } - else - { - _364 = _344; - } - float3 _368 = _322.xyz + (_364 * 0.75); - float4 _369 = float4(_368.x, _368.y, _368.z, _322.w); - _28 _370 = _323; - _370._m0 = _369; - float2 _379 = clamp(_82 + (float3(0.0, 0.0, 1.0).xy * _7._m0.xy), _88.xy, _88.zw); - float3 _391 = _11._m5 * clamp(_8.sample(_9, _379, level(0.0)).w * _7._m1, 0.0, 1.0); - float4 _395 = _12.sample(_13, _379, level(0.0)); - float3 _411; - if (_395.y > 0.0) - { - _411 = _391 + (_14.sample(_15, _379, level(0.0)).xyz * clamp(_395.y * _395.z, 0.0, 1.0)); - } - else - { - _411 = _391; - } - float3 _415 = _369.xyz + (_411 * 1.0); - float4 _416 = float4(_415.x, _415.y, _415.z, _369.w); - _28 _417 = _370; - _417._m0 = _416; - float2 _426 = clamp(_82 + (float3(1.0, 0.0, 0.75).xy * _7._m0.xy), _88.xy, _88.zw); - float3 _438 = _11._m5 * clamp(_8.sample(_9, _426, level(0.0)).w * _7._m1, 0.0, 1.0); - float4 _442 = _12.sample(_13, _426, level(0.0)); - float3 _458; - if (_442.y > 0.0) - { - _458 = _438 + (_14.sample(_15, _426, level(0.0)).xyz * clamp(_442.y * _442.z, 0.0, 1.0)); - } - else - { - _458 = _438; - } - float3 _462 = _416.xyz + (_458 * 0.75); - float4 _463 = float4(_462.x, _462.y, _462.z, _416.w); - _28 _464 = _417; - _464._m0 = _463; - float2 _473 = clamp(_82 + (float3(2.0, 0.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - float3 _485 = _11._m5 * clamp(_8.sample(_9, _473, level(0.0)).w * _7._m1, 0.0, 1.0); - float4 _489 = _12.sample(_13, _473, level(0.0)); - float3 _505; - if (_489.y > 0.0) - { - _505 = _485 + (_14.sample(_15, _473, level(0.0)).xyz * clamp(_489.y * _489.z, 0.0, 1.0)); - } - else - { - _505 = _485; - } - float3 _509 = _463.xyz + (_505 * 0.5); - float4 _510 = float4(_509.x, _509.y, _509.z, _463.w); - _28 _511 = _464; - _511._m0 = _510; - float2 _520 = clamp(_82 + (float3(-1.0, 1.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - float3 _532 = _11._m5 * clamp(_8.sample(_9, _520, level(0.0)).w * _7._m1, 0.0, 1.0); - float4 _536 = _12.sample(_13, _520, level(0.0)); - float3 _552; - if (_536.y > 0.0) - { - _552 = _532 + (_14.sample(_15, _520, level(0.0)).xyz * clamp(_536.y * _536.z, 0.0, 1.0)); - } - else - { - _552 = _532; - } - float3 _556 = _510.xyz + (_552 * 0.5); - float4 _557 = float4(_556.x, _556.y, _556.z, _510.w); - _28 _558 = _511; - _558._m0 = _557; - float2 _567 = clamp(_82 + (float3(0.0, 1.0, 0.75).xy * _7._m0.xy), _88.xy, _88.zw); - float3 _579 = _11._m5 * clamp(_8.sample(_9, _567, level(0.0)).w * _7._m1, 0.0, 1.0); - float4 _583 = _12.sample(_13, _567, level(0.0)); - float3 _599; - if (_583.y > 0.0) - { - _599 = _579 + (_14.sample(_15, _567, level(0.0)).xyz * clamp(_583.y * _583.z, 0.0, 1.0)); - } - else - { - _599 = _579; - } - float3 _603 = _557.xyz + (_599 * 0.75); - float4 _604 = float4(_603.x, _603.y, _603.z, _557.w); - _28 _605 = _558; - _605._m0 = _604; - float2 _614 = clamp(_82 + (float3(1.0, 1.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - float3 _626 = _11._m5 * clamp(_8.sample(_9, _614, level(0.0)).w * _7._m1, 0.0, 1.0); - float4 _630 = _12.sample(_13, _614, level(0.0)); - float3 _646; - if (_630.y > 0.0) - { - _646 = _626 + (_14.sample(_15, _614, level(0.0)).xyz * clamp(_630.y * _630.z, 0.0, 1.0)); - } - else - { - _646 = _626; - } - float3 _650 = _604.xyz + (_646 * 0.5); - float4 _651 = float4(_650.x, _650.y, _650.z, _604.w); - _28 _652 = _605; - _652._m0 = _651; - float2 _661 = clamp(_82 + (float3(0.0, 2.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - float3 _673 = _11._m5 * clamp(_8.sample(_9, _661, level(0.0)).w * _7._m1, 0.0, 1.0); - float4 _677 = _12.sample(_13, _661, level(0.0)); - float3 _693; - if (_677.y > 0.0) - { - _693 = _673 + (_14.sample(_15, _661, level(0.0)).xyz * clamp(_677.y * _677.z, 0.0, 1.0)); - } - else - { - _693 = _673; - } - float3 _697 = _651.xyz + (_693 * 0.5); - float4 _698 = float4(_697.x, _697.y, _697.z, _651.w); - _28 _699 = _652; - _699._m0 = _698; - float3 _702 = _698.xyz / float3(((((((((((((0.0 + 0.5) + 0.5) + 0.75) + 0.5) + 0.5) + 0.75) + 1.0) + 0.75) + 0.5) + 0.5) + 0.75) + 0.5) + 0.5); - _28 _704 = _699; - _704._m0 = float4(_702.x, _702.y, _702.z, _698.w); - _28 _705 = _704; - _705._m0.w = 1.0; - out.m_5 = _705._m0; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/asm/vert/empty-struct-composite.asm.vert b/deps/SPIRV-Cross/reference/shaders-msl/asm/vert/empty-struct-composite.asm.vert deleted file mode 100644 index 9e024c2095..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/asm/vert/empty-struct-composite.asm.vert +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include - -using namespace metal; - -vertex void main0() -{ -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/comp/atomic.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/atomic.comp deleted file mode 100644 index 90a39ec643..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/comp/atomic.comp +++ /dev/null @@ -1,36 +0,0 @@ -#pragma clang diagnostic ignored "-Wunused-variable" - -#include -#include -#include - -using namespace metal; - -struct SSBO -{ - uint u32; - int i32; -}; - -kernel void main0(device SSBO& ssbo [[buffer(0)]]) -{ - uint _16 = atomic_fetch_add_explicit((volatile device atomic_uint*)&(ssbo.u32), 1u, memory_order_relaxed); - uint _18 = atomic_fetch_or_explicit((volatile device atomic_uint*)&(ssbo.u32), 1u, memory_order_relaxed); - uint _20 = atomic_fetch_xor_explicit((volatile device atomic_uint*)&(ssbo.u32), 1u, memory_order_relaxed); - uint _22 = atomic_fetch_and_explicit((volatile device atomic_uint*)&(ssbo.u32), 1u, memory_order_relaxed); - uint _24 = atomic_fetch_min_explicit((volatile device atomic_uint*)&(ssbo.u32), 1u, memory_order_relaxed); - uint _26 = atomic_fetch_max_explicit((volatile device atomic_uint*)&(ssbo.u32), 1u, memory_order_relaxed); - uint _28 = atomic_exchange_explicit((volatile device atomic_uint*)&(ssbo.u32), 1u, memory_order_relaxed); - uint _30 = 10u; - uint _32 = atomic_compare_exchange_weak_explicit((volatile device atomic_uint*)&(ssbo.u32), &(_30), 2u, memory_order_relaxed, memory_order_relaxed); - int _36 = atomic_fetch_add_explicit((volatile device atomic_int*)&(ssbo.i32), 1, memory_order_relaxed); - int _38 = atomic_fetch_or_explicit((volatile device atomic_int*)&(ssbo.i32), 1, memory_order_relaxed); - int _40 = atomic_fetch_xor_explicit((volatile device atomic_int*)&(ssbo.i32), 1, memory_order_relaxed); - int _42 = atomic_fetch_and_explicit((volatile device atomic_int*)&(ssbo.i32), 1, memory_order_relaxed); - int _44 = atomic_fetch_min_explicit((volatile device atomic_int*)&(ssbo.i32), 1, memory_order_relaxed); - int _46 = atomic_fetch_max_explicit((volatile device atomic_int*)&(ssbo.i32), 1, memory_order_relaxed); - int _48 = atomic_exchange_explicit((volatile device atomic_int*)&(ssbo.i32), 1, memory_order_relaxed); - int _50 = 10; - int _52 = atomic_compare_exchange_weak_explicit((volatile device atomic_int*)&(ssbo.i32), &(_50), 2, memory_order_relaxed, memory_order_relaxed); -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/comp/bake_gradient.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/bake_gradient.comp deleted file mode 100644 index 1118f18f8e..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/comp/bake_gradient.comp +++ /dev/null @@ -1,40 +0,0 @@ -#pragma clang diagnostic ignored "-Wmissing-prototypes" - -#include -#include - -using namespace metal; - -constant uint3 gl_WorkGroupSize = uint3(8u, 8u, 1u); - -struct UBO -{ - float4 uInvSize; - float4 uScale; -}; - -float jacobian(thread const float2& dDdx, thread const float2& dDdy) -{ - return ((1.0 + dDdx.x) * (1.0 + dDdy.y)) - (dDdx.y * dDdy.x); -} - -kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], constant UBO& _46 [[buffer(0)]], texture2d uHeight [[texture(0)]], sampler uHeightSmplr [[sampler(0)]], texture2d uDisplacement [[texture(1)]], sampler uDisplacementSmplr [[sampler(1)]], texture2d iHeightDisplacement [[texture(2)]], texture2d iGradJacobian [[texture(3)]]) -{ - float4 uv = (float2(gl_GlobalInvocationID.xy) * _46.uInvSize.xy).xyxy + (_46.uInvSize * 0.5); - float h = uHeight.sample(uHeightSmplr, uv.xy, level(0.0)).x; - float x0 = uHeight.sample(uHeightSmplr, uv.xy, level(0.0), int2(-1, 0)).x; - float x1 = uHeight.sample(uHeightSmplr, uv.xy, level(0.0), int2(1, 0)).x; - float y0 = uHeight.sample(uHeightSmplr, uv.xy, level(0.0), int2(0, -1)).x; - float y1 = uHeight.sample(uHeightSmplr, uv.xy, level(0.0), int2(0, 1)).x; - float2 grad = (_46.uScale.xy * 0.5) * float2(x1 - x0, y1 - y0); - float2 displacement = uDisplacement.sample(uDisplacementSmplr, uv.zw, level(0.0)).xy * 1.2000000476837158203125; - float2 dDdx = (uDisplacement.sample(uDisplacementSmplr, uv.zw, level(0.0), int2(1, 0)).xy - uDisplacement.sample(uDisplacementSmplr, uv.zw, level(0.0), int2(-1, 0)).xy) * 0.60000002384185791015625; - float2 dDdy = (uDisplacement.sample(uDisplacementSmplr, uv.zw, level(0.0), int2(0, 1)).xy - uDisplacement.sample(uDisplacementSmplr, uv.zw, level(0.0), int2(0, -1)).xy) * 0.60000002384185791015625; - float2 param = dDdx * _46.uScale.z; - float2 param_1 = dDdy * _46.uScale.z; - float j = jacobian(param, param_1); - displacement = float2(0.0); - iHeightDisplacement.write(float4(h, displacement, 0.0), uint2(int2(gl_GlobalInvocationID.xy))); - iGradJacobian.write(float4(grad, j, 0.0), uint2(int2(gl_GlobalInvocationID.xy))); -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/comp/barriers.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/barriers.comp deleted file mode 100644 index 3b8474c757..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/comp/barriers.comp +++ /dev/null @@ -1,67 +0,0 @@ -#pragma clang diagnostic ignored "-Wmissing-prototypes" - -#include -#include - -using namespace metal; - -constant uint3 gl_WorkGroupSize = uint3(4u, 1u, 1u); - -void barrier_shared() -{ - threadgroup_barrier(mem_flags::mem_threadgroup); -} - -void full_barrier() -{ - threadgroup_barrier(mem_flags::mem_threadgroup); -} - -void buffer_barrier() -{ - threadgroup_barrier(mem_flags::mem_none); -} - -void group_barrier() -{ - threadgroup_barrier(mem_flags::mem_threadgroup); -} - -void barrier_shared_exec() -{ - threadgroup_barrier(mem_flags::mem_threadgroup); -} - -void full_barrier_exec() -{ - threadgroup_barrier(mem_flags::mem_threadgroup); -} - -void buffer_barrier_exec() -{ - threadgroup_barrier(mem_flags::mem_none); -} - -void group_barrier_exec() -{ - threadgroup_barrier(mem_flags::mem_threadgroup); -} - -void exec_barrier() -{ - threadgroup_barrier(mem_flags::mem_threadgroup); -} - -kernel void main0() -{ - barrier_shared(); - full_barrier(); - buffer_barrier(); - group_barrier(); - barrier_shared_exec(); - full_barrier_exec(); - buffer_barrier_exec(); - group_barrier_exec(); - exec_barrier(); -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/comp/basic.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/basic.comp deleted file mode 100644 index 2c34c3543c..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/comp/basic.comp +++ /dev/null @@ -1,34 +0,0 @@ -#pragma clang diagnostic ignored "-Wunused-variable" - -#include -#include -#include - -using namespace metal; - -struct SSBO -{ - float4 in_data[1]; -}; - -struct SSBO2 -{ - float4 out_data[1]; -}; - -struct SSBO3 -{ - uint counter; -}; - -kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _23 [[buffer(0)]], device SSBO2& _45 [[buffer(1)]], device SSBO3& _48 [[buffer(2)]]) -{ - uint ident = gl_GlobalInvocationID.x; - float4 idata = _23.in_data[ident]; - if (dot(idata, float4(1.0, 5.0, 6.0, 2.0)) > 8.19999980926513671875) - { - uint _52 = atomic_fetch_add_explicit((volatile device atomic_uint*)&(_48.counter), 1u, memory_order_relaxed); - _45.out_data[_52] = idata; - } -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/comp/bitfield.noopt.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/bitfield.noopt.comp deleted file mode 100644 index 62ef02c997..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/comp/bitfield.noopt.comp +++ /dev/null @@ -1,47 +0,0 @@ -#pragma clang diagnostic ignored "-Wmissing-prototypes" - -#include -#include - -using namespace metal; - -// Implementation of the GLSL findLSB() function -template -T findLSB(T x) -{ - return select(ctz(x), T(-1), x == T(0)); -} - -// Implementation of the signed GLSL findMSB() function -template -T findSMSB(T x) -{ - T v = select(x, T(-1) - x, x < T(0)); - return select(clz(T(0)) - (clz(v) + T(1)), T(-1), v == T(0)); -} - -// Implementation of the unsigned GLSL findMSB() function -template -T findUMSB(T x) -{ - return select(clz(T(0)) - (clz(x) + T(1)), T(-1), x == T(0)); -} - -kernel void main0() -{ - int signed_value = 0; - uint unsigned_value = 0u; - int s = extract_bits(signed_value, 5, 20); - uint u = extract_bits(unsigned_value, 6, 21); - s = insert_bits(s, 40, 5, 4); - u = insert_bits(u, 60u, 5, 4); - u = reverse_bits(u); - s = reverse_bits(s); - int v0 = popcount(u); - int v1 = popcount(s); - int v2 = findUMSB(u); - int v3 = findSMSB(s); - int v4 = findLSB(u); - int v5 = findLSB(s); -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/comp/builtins.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/builtins.comp deleted file mode 100644 index 4330d57831..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/comp/builtins.comp +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include - -using namespace metal; - -constant uint3 gl_WorkGroupSize = uint3(8u, 4u, 2u); - -kernel void main0(uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]], uint3 gl_NumWorkGroups [[threadgroups_per_grid]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]]) -{ - uint3 local_id = gl_LocalInvocationID; - uint3 global_id = gl_GlobalInvocationID; - uint local_index = gl_LocalInvocationIndex; - uint3 work_group_size = gl_WorkGroupSize; - uint3 num_work_groups = gl_NumWorkGroups; - uint3 work_group_id = gl_WorkGroupID; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/comp/cfg-preserve-parameter.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/cfg-preserve-parameter.comp deleted file mode 100644 index d65beee5d2..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/comp/cfg-preserve-parameter.comp +++ /dev/null @@ -1,78 +0,0 @@ -#pragma clang diagnostic ignored "-Wmissing-prototypes" - -#include -#include - -using namespace metal; - -void out_test_0(thread const int& cond, thread int& i) -{ - if (cond == 0) - { - i = 40; - } - else - { - i = 60; - } -} - -void out_test_1(thread const int& cond, thread int& i) -{ - switch (cond) - { - case 40: - { - i = 40; - break; - } - default: - { - i = 70; - break; - } - } -} - -void inout_test_0(thread const int& cond, thread int& i) -{ - if (cond == 0) - { - i = 40; - } -} - -void inout_test_1(thread const int& cond, thread int& i) -{ - switch (cond) - { - case 40: - { - i = 40; - break; - } - } -} - -kernel void main0() -{ - int cond = 40; - int i = 50; - int param = cond; - int param_1 = i; - out_test_0(param, param_1); - i = param_1; - int param_2 = cond; - int param_3 = i; - out_test_1(param_2, param_3); - i = param_3; - int param_4 = cond; - int param_5 = i; - inout_test_0(param_4, param_5); - i = param_5; - int param_6 = cond; - int param_7 = i; - inout_test_1(param_6, param_7); - i = param_7; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/comp/coherent-block.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/coherent-block.comp deleted file mode 100644 index bec9b218c7..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/comp/coherent-block.comp +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include - -using namespace metal; - -struct SSBO -{ - float4 value; -}; - -kernel void main0(device SSBO& _10 [[buffer(0)]]) -{ - _10.value = float4(20.0); -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/comp/coherent-image.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/coherent-image.comp deleted file mode 100644 index 0fe044fb9a..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/comp/coherent-image.comp +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include - -using namespace metal; - -struct SSBO -{ - int4 value; -}; - -kernel void main0(device SSBO& _10 [[buffer(0)]], texture2d uImage [[texture(0)]]) -{ - _10.value = uImage.read(uint2(int2(10))); -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/comp/culling.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/culling.comp deleted file mode 100644 index 7eb6fe864e..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/comp/culling.comp +++ /dev/null @@ -1,36 +0,0 @@ -#pragma clang diagnostic ignored "-Wunused-variable" - -#include -#include -#include - -using namespace metal; - -constant uint3 gl_WorkGroupSize = uint3(4u, 1u, 1u); - -struct SSBO -{ - float in_data[1]; -}; - -struct SSBO2 -{ - float out_data[1]; -}; - -struct SSBO3 -{ - uint count; -}; - -kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _22 [[buffer(0)]], device SSBO2& _38 [[buffer(1)]], device SSBO3& _41 [[buffer(2)]]) -{ - uint ident = gl_GlobalInvocationID.x; - float idata = _22.in_data[ident]; - if (idata > 12.0) - { - uint _45 = atomic_fetch_add_explicit((volatile device atomic_uint*)&(_41.count), 1u, memory_order_relaxed); - _38.out_data[_45] = idata; - } -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/comp/defer-parens.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/defer-parens.comp deleted file mode 100644 index 76dce77734..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/comp/defer-parens.comp +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -using namespace metal; - -struct SSBO -{ - float4 data; - int index; -}; - -kernel void main0(device SSBO& _13 [[buffer(0)]]) -{ - float4 d = _13.data; - _13.data = float4(d.x, d.yz + float2(10.0), d.w); - _13.data = (d + d) + d; - _13.data = (d.yz + float2(10.0)).xxyy; - float t = (d.yz + float2(10.0)).y; - _13.data = float4(t); - t = (d.zw + float2(10.0))[_13.index]; - _13.data = float4(t); -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/comp/dowhile.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/dowhile.comp deleted file mode 100644 index ff772941a4..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/comp/dowhile.comp +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include - -using namespace metal; - -struct SSBO -{ - float4x4 mvp; - float4 in_data[1]; -}; - -struct SSBO2 -{ - float4 out_data[1]; -}; - -kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _28 [[buffer(0)]], device SSBO2& _52 [[buffer(1)]]) -{ - uint ident = gl_GlobalInvocationID.x; - int i = 0; - float4 idat = _28.in_data[ident]; - do - { - idat = _28.mvp * idat; - i++; - } while (i < 16); - _52.out_data[ident] = idat; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/comp/functions.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/functions.comp deleted file mode 100644 index 6127a39ca7..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/comp/functions.comp +++ /dev/null @@ -1,18 +0,0 @@ -#pragma clang diagnostic ignored "-Wmissing-prototypes" - -#include -#include - -using namespace metal; - -void myfunc(threadgroup int* foo) -{ - foo[0] = 13; -} - -kernel void main0() -{ - threadgroup int foo[1337]; - myfunc(foo); -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/comp/global-invocation-id-writable-ssbo-in-function.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/global-invocation-id-writable-ssbo-in-function.comp deleted file mode 100644 index 1b525c1f90..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/comp/global-invocation-id-writable-ssbo-in-function.comp +++ /dev/null @@ -1,31 +0,0 @@ -#pragma clang diagnostic ignored "-Wmissing-prototypes" - -#include -#include - -using namespace metal; - -struct myBlock -{ - int a; - float b[1]; -}; - -// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() -template -Tx mod(Tx x, Ty y) -{ - return x - y * floor(x / y); -} - -float getB(device myBlock& myStorage, thread uint3& gl_GlobalInvocationID) -{ - return myStorage.b[gl_GlobalInvocationID.x]; -} - -kernel void main0(device myBlock& myStorage [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) -{ - myStorage.a = (myStorage.a + 1) % 256; - myStorage.b[gl_GlobalInvocationID.x] = mod(getB(myStorage, gl_GlobalInvocationID) + 0.0199999995529651641845703125, 1.0); -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/comp/global-invocation-id.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/global-invocation-id.comp deleted file mode 100644 index fe0212ec3f..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/comp/global-invocation-id.comp +++ /dev/null @@ -1,26 +0,0 @@ -#pragma clang diagnostic ignored "-Wmissing-prototypes" - -#include -#include - -using namespace metal; - -struct myBlock -{ - int a; - float b[1]; -}; - -// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() -template -Tx mod(Tx x, Ty y) -{ - return x - y * floor(x / y); -} - -kernel void main0(device myBlock& myStorage [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) -{ - myStorage.a = (myStorage.a + 1) % 256; - myStorage.b[gl_GlobalInvocationID.x] = mod(myStorage.b[gl_GlobalInvocationID.x] + 0.0199999995529651641845703125, 1.0); -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/comp/image.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/image.comp deleted file mode 100644 index 85b48da797..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/comp/image.comp +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include - -using namespace metal; - -kernel void main0(texture2d uImageIn [[texture(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], texture2d uImageOut [[texture(1)]]) -{ - float4 v = uImageIn.read(uint2((int2(gl_GlobalInvocationID.xy) + int2(uImageIn.get_width(), uImageIn.get_height())))); - uImageOut.write(v, uint2(int2(gl_GlobalInvocationID.xy))); -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/comp/insert.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/insert.comp deleted file mode 100644 index 0f56a65153..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/comp/insert.comp +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include - -using namespace metal; - -struct SSBO -{ - float4 out_data[1]; -}; - -kernel void main0(device SSBO& _27 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) -{ - float4 v; - v.x = 10.0; - v.y = 30.0; - v.z = 70.0; - v.w = 90.0; - _27.out_data[gl_GlobalInvocationID.x] = v; - _27.out_data[gl_GlobalInvocationID.x].y = 20.0; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/comp/local-invocation-id.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/local-invocation-id.comp deleted file mode 100644 index 772e5e0d86..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/comp/local-invocation-id.comp +++ /dev/null @@ -1,26 +0,0 @@ -#pragma clang diagnostic ignored "-Wmissing-prototypes" - -#include -#include - -using namespace metal; - -struct myBlock -{ - int a; - float b[1]; -}; - -// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() -template -Tx mod(Tx x, Ty y) -{ - return x - y * floor(x / y); -} - -kernel void main0(device myBlock& myStorage [[buffer(0)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]]) -{ - myStorage.a = (myStorage.a + 1) % 256; - myStorage.b[gl_LocalInvocationID.x] = mod(myStorage.b[gl_LocalInvocationID.x] + 0.0199999995529651641845703125, 1.0); -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/comp/local-invocation-index.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/local-invocation-index.comp deleted file mode 100644 index 41adbdca5c..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/comp/local-invocation-index.comp +++ /dev/null @@ -1,26 +0,0 @@ -#pragma clang diagnostic ignored "-Wmissing-prototypes" - -#include -#include - -using namespace metal; - -struct myBlock -{ - int a; - float b[1]; -}; - -// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() -template -Tx mod(Tx x, Ty y) -{ - return x - y * floor(x / y); -} - -kernel void main0(device myBlock& myStorage [[buffer(0)]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]]) -{ - myStorage.a = (myStorage.a + 1) % 256; - myStorage.b[gl_LocalInvocationIndex] = mod(myStorage.b[gl_LocalInvocationIndex] + 0.0199999995529651641845703125, 1.0); -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/comp/loop.noopt.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/loop.noopt.comp deleted file mode 100644 index 55d850d191..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/comp/loop.noopt.comp +++ /dev/null @@ -1,107 +0,0 @@ -#include -#include - -using namespace metal; - -struct SSBO -{ - float4x4 mvp; - float4 in_data[1]; -}; - -struct SSBO2 -{ - float4 out_data[1]; -}; - -kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _24 [[buffer(0)]], device SSBO2& _177 [[buffer(1)]]) -{ - uint ident = gl_GlobalInvocationID.x; - float4 idat = _24.in_data[ident]; - int k = 0; - uint i = 0u; - if (idat.y == 20.0) - { - do - { - k *= 2; - i++; - } while (i < ident); - } - switch (k) - { - case 10: - { - for (;;) - { - i++; - if (i > 10u) - { - break; - } - continue; - } - break; - } - default: - { - for (;;) - { - i += 2u; - if (i > 20u) - { - break; - } - continue; - } - break; - } - } - while (k < 10) - { - idat *= 2.0; - k++; - } - for (uint i_1 = 0u; i_1 < 16u; i_1++, k++) - { - for (uint j = 0u; j < 30u; j++) - { - idat = _24.mvp * idat; - } - } - k = 0; - for (;;) - { - k++; - if (k > 10) - { - k += 2; - } - else - { - k += 3; - continue; - } - k += 10; - continue; - } - k = 0; - do - { - k++; - } while (k > 10); - int l = 0; - for (;;) - { - if (l == 5) - { - l++; - continue; - } - idat += float4(1.0); - l++; - continue; - } - _177.out_data[ident] = idat; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/comp/mat3.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/mat3.comp deleted file mode 100644 index 4a315ce72c..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/comp/mat3.comp +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include - -using namespace metal; - -struct SSBO2 -{ - float3x3 out_data[1]; -}; - -kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO2& _22 [[buffer(0)]]) -{ - uint ident = gl_GlobalInvocationID.x; - _22.out_data[ident] = float3x3(float3(10.0), float3(20.0), float3(40.0)); -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/comp/mod.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/mod.comp deleted file mode 100644 index 9d13a2edd2..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/comp/mod.comp +++ /dev/null @@ -1,35 +0,0 @@ -#pragma clang diagnostic ignored "-Wmissing-prototypes" - -#include -#include - -using namespace metal; - -struct SSBO -{ - float4 in_data[1]; -}; - -struct SSBO2 -{ - float4 out_data[1]; -}; - -// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() -template -Tx mod(Tx x, Ty y) -{ - return x - y * floor(x / y); -} - -kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _23 [[buffer(0)]], device SSBO2& _33 [[buffer(1)]]) -{ - uint ident = gl_GlobalInvocationID.x; - float4 v = mod(_23.in_data[ident], _33.out_data[ident]); - _33.out_data[ident] = v; - uint4 vu = as_type(_23.in_data[ident]) % as_type(_33.out_data[ident]); - _33.out_data[ident] = as_type(vu); - int4 vi = as_type(_23.in_data[ident]) % as_type(_33.out_data[ident]); - _33.out_data[ident] = as_type(vi); -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/comp/modf.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/modf.comp deleted file mode 100644 index b358e9478c..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/comp/modf.comp +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include - -using namespace metal; - -struct SSBO -{ - float4 in_data[1]; -}; - -struct SSBO2 -{ - float4 out_data[1]; -}; - -kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _23 [[buffer(0)]], device SSBO2& _35 [[buffer(1)]]) -{ - uint ident = gl_GlobalInvocationID.x; - float4 i; - float4 _31 = modf(_23.in_data[ident], i); - float4 v = _31; - _35.out_data[ident] = v; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/comp/read-write-only.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/read-write-only.comp deleted file mode 100644 index ba53b334ba..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/comp/read-write-only.comp +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include - -using namespace metal; - -struct SSBO2 -{ - float4 data4; - float4 data5; -}; - -struct SSBO0 -{ - float4 data0; - float4 data1; -}; - -struct SSBO1 -{ - float4 data2; - float4 data3; -}; - -kernel void main0(device SSBO2& _10 [[buffer(0)]], device SSBO0& _15 [[buffer(1)]], device SSBO1& _21 [[buffer(2)]]) -{ - _10.data4 = _15.data0 + _21.data2; - _10.data5 = _15.data1 + _21.data3; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/comp/return.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/return.comp deleted file mode 100644 index 24e498c1f4..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/comp/return.comp +++ /dev/null @@ -1,36 +0,0 @@ -#include -#include - -using namespace metal; - -struct SSBO2 -{ - float4 out_data[1]; -}; - -kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO2& _27 [[buffer(0)]]) -{ - uint ident = gl_GlobalInvocationID.x; - if (ident == 2u) - { - _27.out_data[ident] = float4(20.0); - } - else - { - if (ident == 4u) - { - _27.out_data[ident] = float4(10.0); - return; - } - } - for (int i = 0; i < 20; i++) - { - if (i == 10) - { - break; - } - return; - } - _27.out_data[ident] = float4(10.0); -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/comp/rmw-opt.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/rmw-opt.comp deleted file mode 100644 index 060f9f9c71..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/comp/rmw-opt.comp +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include - -using namespace metal; - -struct SSBO -{ - int a; -}; - -kernel void main0(device SSBO& _9 [[buffer(0)]]) -{ - _9.a += 10; - _9.a -= 10; - _9.a *= 10; - _9.a /= 10; - _9.a = _9.a << 2; - _9.a = _9.a >> 3; - _9.a &= 40; - _9.a ^= 10; - _9.a %= 40; - _9.a |= 1; - bool c = false; - bool d = true; - c = c && d; - d = d || c; - _9.a = int(c && d); -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/comp/shared.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/shared.comp deleted file mode 100644 index 20f9538bd2..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/comp/shared.comp +++ /dev/null @@ -1,27 +0,0 @@ -#include -#include - -using namespace metal; - -constant uint3 gl_WorkGroupSize = uint3(4u, 1u, 1u); - -struct SSBO -{ - float in_data[1]; -}; - -struct SSBO2 -{ - float out_data[1]; -}; - -kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _22 [[buffer(0)]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]], device SSBO2& _44 [[buffer(1)]]) -{ - uint ident = gl_GlobalInvocationID.x; - float idata = _22.in_data[ident]; - threadgroup float sShared[4]; - sShared[gl_LocalInvocationIndex] = idata; - threadgroup_barrier(mem_flags::mem_threadgroup); - _44.out_data[ident] = sShared[(4u - gl_LocalInvocationIndex) - 1u]; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/comp/struct-layout.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/struct-layout.comp deleted file mode 100644 index 27714ef09c..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/comp/struct-layout.comp +++ /dev/null @@ -1,26 +0,0 @@ -#include -#include - -using namespace metal; - -struct Foo -{ - float4x4 m; -}; - -struct SSBO2 -{ - Foo out_data[1]; -}; - -struct SSBO -{ - Foo in_data[1]; -}; - -kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO2& _23 [[buffer(0)]], device SSBO& _30 [[buffer(1)]]) -{ - uint ident = gl_GlobalInvocationID.x; - _23.out_data[ident].m = _30.in_data[ident].m * _30.in_data[ident].m; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/comp/struct-packing.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/struct-packing.comp deleted file mode 100644 index cf626ce63f..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/comp/struct-packing.comp +++ /dev/null @@ -1,100 +0,0 @@ -#include -#include - -using namespace metal; - -struct S0 -{ - float2 a[1]; - float b; -}; - -struct S1 -{ - packed_float3 a; - float b; -}; - -struct S2 -{ - float3 a[1]; - float b; -}; - -struct S3 -{ - float2 a; - float b; -}; - -struct S4 -{ - float2 c; -}; - -struct Content -{ - S0 m0s[1]; - S1 m1s[1]; - S2 m2s[1]; - S0 m0; - S1 m1; - S2 m2; - S3 m3; - char pad7[4]; - float m4; - S4 m3s[8]; -}; - -struct SSBO1 -{ - Content content; - Content content1[2]; - Content content2; - char pad3[8]; - float2x2 m0; - float2x2 m1; - float2x3 m2[4]; - float3x2 m3; - float2x2 m4; - float2x2 m5[9]; - float2x3 m6[4][2]; - float3x2 m7; - float array[1]; -}; - -struct SSBO0 -{ - Content content; - Content content1[2]; - Content content2; - float array[1]; -}; - -kernel void main0(device SSBO1& ssbo_430 [[buffer(0)]], device SSBO0& ssbo_140 [[buffer(1)]]) -{ - ssbo_430.content.m0s[0].a[0] = ssbo_140.content.m0s[0].a[0]; - ssbo_430.content.m0s[0].b = ssbo_140.content.m0s[0].b; - ssbo_430.content.m1s[0].a = ssbo_140.content.m1s[0].a; - ssbo_430.content.m1s[0].b = ssbo_140.content.m1s[0].b; - ssbo_430.content.m2s[0].a[0] = ssbo_140.content.m2s[0].a[0]; - ssbo_430.content.m2s[0].b = ssbo_140.content.m2s[0].b; - ssbo_430.content.m0.a[0] = ssbo_140.content.m0.a[0]; - ssbo_430.content.m0.b = ssbo_140.content.m0.b; - ssbo_430.content.m1.a = ssbo_140.content.m1.a; - ssbo_430.content.m1.b = ssbo_140.content.m1.b; - ssbo_430.content.m2.a[0] = ssbo_140.content.m2.a[0]; - ssbo_430.content.m2.b = ssbo_140.content.m2.b; - ssbo_430.content.m3.a = ssbo_140.content.m3.a; - ssbo_430.content.m3.b = ssbo_140.content.m3.b; - ssbo_430.content.m4 = ssbo_140.content.m4; - ssbo_430.content.m3s[0].c = ssbo_140.content.m3s[0].c; - ssbo_430.content.m3s[1].c = ssbo_140.content.m3s[1].c; - ssbo_430.content.m3s[2].c = ssbo_140.content.m3s[2].c; - ssbo_430.content.m3s[3].c = ssbo_140.content.m3s[3].c; - ssbo_430.content.m3s[4].c = ssbo_140.content.m3s[4].c; - 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; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/comp/torture-loop.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/torture-loop.comp deleted file mode 100644 index 759af12685..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/comp/torture-loop.comp +++ /dev/null @@ -1,51 +0,0 @@ -#include -#include - -using namespace metal; - -struct SSBO -{ - float4x4 mvp; - float4 in_data[1]; -}; - -struct SSBO2 -{ - float4 out_data[1]; -}; - -kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _24 [[buffer(0)]], device SSBO2& _89 [[buffer(1)]]) -{ - uint ident = gl_GlobalInvocationID.x; - float4 idat = _24.in_data[ident]; - int k = 0; - for (;;) - { - int _39 = k; - int _40 = _39 + 1; - k = _40; - if (_40 < 10) - { - idat *= 2.0; - k++; - continue; - } - else - { - break; - } - } - for (uint i = 0u; i < 16u; i++, k++) - { - for (uint j = 0u; j < 30u; j++) - { - idat = _24.mvp * idat; - } - } - do - { - k++; - } while (k > 10); - _89.out_data[ident] = idat; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/comp/type-alias.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/type-alias.comp deleted file mode 100644 index e47c2ba946..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/comp/type-alias.comp +++ /dev/null @@ -1,53 +0,0 @@ -#pragma clang diagnostic ignored "-Wmissing-prototypes" - -#include -#include - -using namespace metal; - -struct S0 -{ - float4 a; -}; - -struct S1 -{ - float4 a; -}; - -struct SSBO0 -{ - S0 s0s[1]; -}; - -struct SSBO1 -{ - S1 s1s[1]; -}; - -struct SSBO2 -{ - float4 outputs[1]; -}; - -float4 overload(thread const S0& s0) -{ - return s0.a; -} - -float4 overload(thread const S1& s1) -{ - return s1.a; -} - -kernel void main0(device SSBO0& _36 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO1& _55 [[buffer(1)]], device SSBO2& _66 [[buffer(2)]]) -{ - S0 s0; - s0.a = _36.s0s[gl_GlobalInvocationID.x].a; - S1 s1; - s1.a = _55.s1s[gl_GlobalInvocationID.x].a; - S0 param = s0; - S1 param_1 = s1; - _66.outputs[gl_GlobalInvocationID.x] = overload(param) + overload(param_1); -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/comp/udiv.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/udiv.comp deleted file mode 100644 index ed82369b99..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/comp/udiv.comp +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include - -using namespace metal; - -struct SSBO2 -{ - uint outputs[1]; -}; - -struct SSBO -{ - uint inputs[1]; -}; - -kernel void main0(device SSBO2& _10 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _23 [[buffer(1)]]) -{ - _10.outputs[gl_GlobalInvocationID.x] = _23.inputs[gl_GlobalInvocationID.x] / 29u; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/comp/writable-ssbo.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/writable-ssbo.comp deleted file mode 100644 index 9dc53b6dd5..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/comp/writable-ssbo.comp +++ /dev/null @@ -1,26 +0,0 @@ -#pragma clang diagnostic ignored "-Wmissing-prototypes" - -#include -#include - -using namespace metal; - -struct myBlock -{ - int a; - float b; -}; - -// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() -template -Tx mod(Tx x, Ty y) -{ - return x - y * floor(x / y); -} - -kernel void main0(device myBlock& myStorage [[buffer(0)]]) -{ - myStorage.a = (myStorage.a + 1) % 256; - myStorage.b = mod(myStorage.b + 0.0199999995529651641845703125, 1.0); -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/desktop-only/frag/image-ms.desktop.frag b/deps/SPIRV-Cross/reference/shaders-msl/desktop-only/frag/image-ms.desktop.frag deleted file mode 100644 index 7957b209d6..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/desktop-only/frag/image-ms.desktop.frag +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include - -using namespace metal; - -fragment void main0(texture2d_ms uImageMS [[texture(0)]], texture2d_array uImageArray [[texture(1)]], texture2d uImage [[texture(2)]]) -{ - float4 a = uImageMS.read(uint2(int2(1, 2)), 2); - float4 b = uImageArray.read(uint2(int3(1, 2, 4).xy), uint(int3(1, 2, 4).z)); - uImage.write(a, uint2(int2(2, 3))); - uImageArray.write(b, uint2(int3(2, 3, 7).xy), uint(int3(2, 3, 7).z)); -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/desktop-only/frag/query-levels.desktop.frag b/deps/SPIRV-Cross/reference/shaders-msl/desktop-only/frag/query-levels.desktop.frag deleted file mode 100644 index 922796b749..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/desktop-only/frag/query-levels.desktop.frag +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_out -{ - float4 FragColor [[color(0)]]; -}; - -fragment main0_out main0(texture2d uSampler [[texture(0)]], sampler uSamplerSmplr [[sampler(0)]]) -{ - main0_out out = {}; - out.FragColor = float4(float(int(uSampler.get_num_mip_levels()))); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/desktop-only/frag/sampler-ms-query.desktop.frag b/deps/SPIRV-Cross/reference/shaders-msl/desktop-only/frag/sampler-ms-query.desktop.frag deleted file mode 100644 index 4d2eee11c5..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/desktop-only/frag/sampler-ms-query.desktop.frag +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_out -{ - float4 FragColor [[color(0)]]; -}; - -fragment main0_out main0(texture2d_ms uSampler [[texture(0)]], sampler uSamplerSmplr [[sampler(0)]], texture2d_ms uSamplerArray [[texture(1)]], sampler uSamplerArraySmplr [[sampler(1)]], texture2d_ms uImage [[texture(2)]], texture2d_ms uImageArray [[texture(3)]]) -{ - main0_out out = {}; - out.FragColor = float4(float(((int(uSampler.get_num_samples()) + int(uSamplerArray.get_num_samples())) + int(uImage.get_num_samples())) + int(uImageArray.get_num_samples()))); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/desktop-only/vert/basic.desktop.sso.vert b/deps/SPIRV-Cross/reference/shaders-msl/desktop-only/vert/basic.desktop.sso.vert deleted file mode 100644 index 1592b5c5cf..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/desktop-only/vert/basic.desktop.sso.vert +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -using namespace metal; - -struct UBO -{ - float4x4 uMVP; -}; - -struct main0_in -{ - float3 aNormal [[attribute(1)]]; - float4 aVertex [[attribute(0)]]; -}; - -struct main0_out -{ - float3 vNormal [[user(locn0)]]; - float4 gl_Position [[position]]; -}; - -vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _16 [[buffer(0)]]) -{ - main0_out out = {}; - out.gl_Position = _16.uMVP * in.aVertex; - out.vNormal = in.aNormal; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/desktop-only/vert/clip-cull-distance.desktop.vert b/deps/SPIRV-Cross/reference/shaders-msl/desktop-only/vert/clip-cull-distance.desktop.vert deleted file mode 100644 index 32f0d9aa0d..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/desktop-only/vert/clip-cull-distance.desktop.vert +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_out -{ - float4 gl_Position [[position]]; - float gl_ClipDistance [[clip_distance]] [2]; - float gl_CullDistance[2]; -}; - -vertex main0_out main0() -{ - main0_out out = {}; - out.gl_Position = float4(10.0); - out.gl_ClipDistance[0] = 1.0; - out.gl_ClipDistance[1] = 4.0; - out.gl_CullDistance[0] = 4.0; - out.gl_CullDistance[1] = 9.0; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/flatten/basic.flatten.vert b/deps/SPIRV-Cross/reference/shaders-msl/flatten/basic.flatten.vert deleted file mode 100644 index 1592b5c5cf..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/flatten/basic.flatten.vert +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -using namespace metal; - -struct UBO -{ - float4x4 uMVP; -}; - -struct main0_in -{ - float3 aNormal [[attribute(1)]]; - float4 aVertex [[attribute(0)]]; -}; - -struct main0_out -{ - float3 vNormal [[user(locn0)]]; - float4 gl_Position [[position]]; -}; - -vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _16 [[buffer(0)]]) -{ - main0_out out = {}; - out.gl_Position = _16.uMVP * in.aVertex; - out.vNormal = in.aNormal; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/flatten/multiindex.flatten.vert b/deps/SPIRV-Cross/reference/shaders-msl/flatten/multiindex.flatten.vert deleted file mode 100644 index 84c4b408b2..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/flatten/multiindex.flatten.vert +++ /dev/null @@ -1,27 +0,0 @@ -#include -#include - -using namespace metal; - -struct UBO -{ - float4 Data[3][5]; -}; - -struct main0_in -{ - int2 aIndex [[attribute(0)]]; -}; - -struct main0_out -{ - float4 gl_Position [[position]]; -}; - -vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _20 [[buffer(0)]]) -{ - main0_out out = {}; - out.gl_Position = _20.Data[in.aIndex.x][in.aIndex.y]; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/flatten/push-constant.flatten.vert b/deps/SPIRV-Cross/reference/shaders-msl/flatten/push-constant.flatten.vert deleted file mode 100644 index 83def9c0bb..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/flatten/push-constant.flatten.vert +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include - -using namespace metal; - -struct PushMe -{ - float4x4 MVP; - float2x2 Rot; - float Arr[4]; -}; - -struct main0_in -{ - float4 Pos [[attribute(1)]]; - float2 Rot [[attribute(0)]]; -}; - -struct main0_out -{ - float2 vRot [[user(locn0)]]; - float4 gl_Position [[position]]; -}; - -vertex main0_out main0(main0_in in [[stage_in]], constant PushMe& registers [[buffer(0)]]) -{ - main0_out out = {}; - out.gl_Position = registers.MVP * in.Pos; - out.vRot = (registers.Rot * in.Rot) + float2(registers.Arr[2]); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/flatten/rowmajor.flatten.vert b/deps/SPIRV-Cross/reference/shaders-msl/flatten/rowmajor.flatten.vert deleted file mode 100644 index 3ea6d78b8a..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/flatten/rowmajor.flatten.vert +++ /dev/null @@ -1,38 +0,0 @@ -#pragma clang diagnostic ignored "-Wmissing-prototypes" - -#include -#include - -using namespace metal; - -struct UBO -{ - float4x4 uMVPR; - float4x4 uMVPC; - float2x4 uMVP; -}; - -struct main0_in -{ - float4 aVertex [[attribute(0)]]; -}; - -struct main0_out -{ - float4 gl_Position [[position]]; -}; - -// Implementation of a conversion of matrix content from RowMajor to ColumnMajor organization. -float2x4 spvConvertFromRowMajor2x4(float2x4 m) -{ - return float2x4(float4(m[0][0], m[0][2], m[1][0], m[1][2]), float4(m[0][1], m[0][3], m[1][1], m[1][3])); -} - -vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _18 [[buffer(0)]]) -{ - main0_out out = {}; - float2 v = in.aVertex * spvConvertFromRowMajor2x4(_18.uMVP); - out.gl_Position = (_18.uMVPR * in.aVertex) + (in.aVertex * _18.uMVPC); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/flatten/struct.flatten.vert b/deps/SPIRV-Cross/reference/shaders-msl/flatten/struct.flatten.vert deleted file mode 100644 index 75f58e1e29..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/flatten/struct.flatten.vert +++ /dev/null @@ -1,40 +0,0 @@ -#include -#include - -using namespace metal; - -struct Light -{ - packed_float3 Position; - float Radius; - float4 Color; -}; - -struct UBO -{ - float4x4 uMVP; - Light light; -}; - -struct main0_in -{ - float3 aNormal [[attribute(1)]]; - float4 aVertex [[attribute(0)]]; -}; - -struct main0_out -{ - float4 vColor [[user(locn0)]]; - float4 gl_Position [[position]]; -}; - -vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _18 [[buffer(0)]]) -{ - main0_out out = {}; - out.gl_Position = _18.uMVP * in.aVertex; - out.vColor = float4(0.0); - float3 L = in.aVertex.xyz - _18.light.Position; - out.vColor += ((_18.light.Color * clamp(1.0 - (length(L) / _18.light.Radius), 0.0, 1.0)) * dot(in.aNormal, normalize(L))); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/flatten/swizzle.flatten.vert b/deps/SPIRV-Cross/reference/shaders-msl/flatten/swizzle.flatten.vert deleted file mode 100644 index 53fc21f99e..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/flatten/swizzle.flatten.vert +++ /dev/null @@ -1,47 +0,0 @@ -#include -#include - -using namespace metal; - -struct UBO -{ - float4 A; - float2 B0; - float2 B1; - float C0; - float3 C1; - packed_float3 D0; - float D1; - float E0; - float E1; - float E2; - float E3; - float F0; - float2 F1; - float F2; -}; - -struct main0_out -{ - float4 oA [[user(locn0)]]; - float4 oB [[user(locn1)]]; - float4 oC [[user(locn2)]]; - float4 oD [[user(locn3)]]; - float4 oE [[user(locn4)]]; - float4 oF [[user(locn5)]]; - float4 gl_Position [[position]]; -}; - -vertex main0_out main0(constant UBO& _22 [[buffer(0)]]) -{ - main0_out out = {}; - out.gl_Position = float4(0.0); - out.oA = _22.A; - out.oB = float4(_22.B0, _22.B1); - out.oC = float4(_22.C0, _22.C1) + float4(_22.C1.xy, _22.C1.z, _22.C0); - out.oD = float4(_22.D0, _22.D1) + float4(float3(_22.D0).xy, float3(_22.D0).z, _22.D1); - out.oE = float4(_22.E0, _22.E1, _22.E2, _22.E3); - out.oF = float4(_22.F0, _22.F1, _22.F2); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/flatten/types.flatten.frag b/deps/SPIRV-Cross/reference/shaders-msl/flatten/types.flatten.frag deleted file mode 100644 index cee53d9e58..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/flatten/types.flatten.frag +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include - -using namespace metal; - -struct UBO1 -{ - int4 c; - int4 d; -}; - -struct UBO2 -{ - uint4 e; - uint4 f; -}; - -struct UBO0 -{ - float4 a; - float4 b; -}; - -struct main0_out -{ - float4 FragColor [[color(0)]]; -}; - -fragment main0_out main0(constant UBO1& _14 [[buffer(0)]], constant UBO2& _29 [[buffer(1)]], constant UBO0& _41 [[buffer(2)]]) -{ - main0_out out = {}; - out.FragColor = ((((float4(_14.c) + float4(_14.d)) + float4(_29.e)) + float4(_29.f)) + _41.a) + _41.b; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/frag/basic.frag b/deps/SPIRV-Cross/reference/shaders-msl/frag/basic.frag deleted file mode 100644 index 4d33ee7bca..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/frag/basic.frag +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_in -{ - float2 vTex [[user(locn1)]]; - float4 vColor [[user(locn0)]]; -}; - -struct main0_out -{ - float4 FragColor [[color(0)]]; -}; - -fragment main0_out main0(main0_in in [[stage_in]], texture2d uTex [[texture(0)]], sampler uTexSmplr [[sampler(0)]]) -{ - main0_out out = {}; - out.FragColor = in.vColor * uTex.sample(uTexSmplr, in.vTex); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/frag/bitcasting.frag b/deps/SPIRV-Cross/reference/shaders-msl/frag/bitcasting.frag deleted file mode 100644 index fcbced0efe..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/frag/bitcasting.frag +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_in -{ - float4 VertGeom [[user(locn0)]]; -}; - -struct main0_out -{ - float4 FragColor0 [[color(0)]]; - float4 FragColor1 [[color(1)]]; -}; - -fragment main0_out main0(main0_in in [[stage_in]], texture2d TextureBase [[texture(0)]], sampler TextureBaseSmplr [[sampler(0)]], texture2d TextureDetail [[texture(1)]], sampler TextureDetailSmplr [[sampler(1)]]) -{ - main0_out out = {}; - float4 texSample0 = TextureBase.sample(TextureBaseSmplr, in.VertGeom.xy); - float4 texSample1 = TextureDetail.sample(TextureDetailSmplr, in.VertGeom.xy, int2(3, 2)); - int4 iResult0 = as_type(texSample0); - int4 iResult1 = as_type(texSample1); - out.FragColor0 = as_type(iResult0) * as_type(iResult1); - uint4 uResult0 = as_type(texSample0); - uint4 uResult1 = as_type(texSample1); - out.FragColor1 = as_type(uResult0) * as_type(uResult1); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/frag/builtins.frag b/deps/SPIRV-Cross/reference/shaders-msl/frag/builtins.frag deleted file mode 100644 index 9283d1a66b..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/frag/builtins.frag +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_in -{ - float4 vColor [[user(locn0)]]; -}; - -struct main0_out -{ - float4 FragColor [[color(0)]]; - float gl_FragDepth [[depth(any)]]; -}; - -fragment main0_out main0(main0_in in [[stage_in]], float4 gl_FragCoord [[position]]) -{ - main0_out out = {}; - out.FragColor = gl_FragCoord + in.vColor; - out.gl_FragDepth = 0.5; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/frag/composite-extract-forced-temporary.frag b/deps/SPIRV-Cross/reference/shaders-msl/frag/composite-extract-forced-temporary.frag deleted file mode 100644 index 2d68f01299..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/frag/composite-extract-forced-temporary.frag +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_in -{ - float2 vTexCoord [[user(locn0)]]; -}; - -struct main0_out -{ - float4 FragColor [[color(0)]]; -}; - -fragment main0_out main0(main0_in in [[stage_in]], texture2d Texture [[texture(0)]], sampler TextureSmplr [[sampler(0)]]) -{ - main0_out out = {}; - float f = Texture.sample(TextureSmplr, in.vTexCoord).x; - out.FragColor = float4(f * f); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/frag/constant-array.frag b/deps/SPIRV-Cross/reference/shaders-msl/frag/constant-array.frag deleted file mode 100644 index 15aa8fdce2..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/frag/constant-array.frag +++ /dev/null @@ -1,40 +0,0 @@ -#pragma clang diagnostic ignored "-Wmissing-prototypes" - -#include -#include - -using namespace metal; - -struct Foobar -{ - float a; - float b; -}; - -struct main0_in -{ - int index [[user(locn0)]]; -}; - -struct main0_out -{ - float4 FragColor [[color(0)]]; -}; - -float4 resolve(thread const Foobar& f) -{ - return float4(f.a + f.b); -} - -fragment main0_out main0(main0_in in [[stage_in]]) -{ - main0_out out = {}; - float4 indexable[3] = {float4(1.0), float4(2.0), float4(3.0)}; - float4 indexable_1[2][2] = {{float4(1.0), float4(2.0)}, {float4(8.0), float4(10.0)}}; - Foobar param = {10.0, 20.0}; - Foobar indexable_2[2] = {{10.0, 40.0}, {90.0, 70.0}}; - Foobar param_1 = indexable_2[in.index]; - out.FragColor = ((indexable[in.index] + (indexable_1[in.index][in.index + 1])) + resolve(param)) + resolve(param_1); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/frag/false-loop-init.frag b/deps/SPIRV-Cross/reference/shaders-msl/frag/false-loop-init.frag deleted file mode 100644 index e0792474b5..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/frag/false-loop-init.frag +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_in -{ - float4 accum [[user(locn0)]]; -}; - -struct main0_out -{ - float4 result [[color(0)]]; -}; - -fragment main0_out main0(main0_in in [[stage_in]]) -{ - main0_out out = {}; - out.result = float4(0.0); - uint j; - for (int i = 0; i < 4; i += int(j)) - { - if (in.accum.y > 10.0) - { - j = 40u; - } - else - { - j = 30u; - } - out.result += in.accum; - } - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/frag/flush_params.frag b/deps/SPIRV-Cross/reference/shaders-msl/frag/flush_params.frag deleted file mode 100644 index e2f2a48cb2..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/frag/flush_params.frag +++ /dev/null @@ -1,38 +0,0 @@ -#pragma clang diagnostic ignored "-Wmissing-prototypes" - -#include -#include - -using namespace metal; - -struct Structy -{ - float4 c; -}; - -struct main0_out -{ - float4 FragColor [[color(0)]]; -}; - -void foo2(thread Structy& f) -{ - f.c = float4(10.0); -} - -Structy foo() -{ - Structy param; - foo2(param); - Structy f = param; - return f; -} - -fragment main0_out main0() -{ - main0_out out = {}; - Structy s = foo(); - out.FragColor = s.c; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/frag/for-loop-init.frag b/deps/SPIRV-Cross/reference/shaders-msl/frag/for-loop-init.frag deleted file mode 100644 index 9f3191b971..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/frag/for-loop-init.frag +++ /dev/null @@ -1,58 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_out -{ - int FragColor [[color(0)]]; -}; - -fragment main0_out main0() -{ - main0_out out = {}; - out.FragColor = 16; - for (int i = 0; i < 25; i++) - { - out.FragColor += 10; - } - for (int i_1 = 1, j = 4; i_1 < 30; i_1++, j += 4) - { - out.FragColor += 11; - } - int k = 0; - for (; k < 20; k++) - { - out.FragColor += 12; - } - k += 3; - out.FragColor += k; - int l; - if (k == 40) - { - l = 0; - for (; l < 40; l++) - { - out.FragColor += 13; - } - return out; - } - else - { - l = k; - out.FragColor += l; - } - int2 i_2 = int2(0); - for (; i_2.x < 10; i_2.x += 4) - { - out.FragColor += i_2.y; - } - int o = k; - for (int m = k; m < 40; m++) - { - out.FragColor += m; - } - out.FragColor += o; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/frag/in_block.frag b/deps/SPIRV-Cross/reference/shaders-msl/frag/in_block.frag deleted file mode 100644 index 43b4a05897..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/frag/in_block.frag +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_in -{ - float4 VertexOut_color2 [[user(locn3)]]; - float4 VertexOut_color [[user(locn2)]]; -}; - -struct main0_out -{ - float4 FragColor [[color(0)]]; -}; - -fragment main0_out main0(main0_in in [[stage_in]]) -{ - main0_out out = {}; - out.FragColor = in.VertexOut_color + in.VertexOut_color2; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/frag/in_block_assign.noopt.frag b/deps/SPIRV-Cross/reference/shaders-msl/frag/in_block_assign.noopt.frag deleted file mode 100644 index d06863d99c..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/frag/in_block_assign.noopt.frag +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -using namespace metal; - -struct VOUT -{ - float4 a; -}; - -struct main0_in -{ - float4 VOUT_a [[user(locn0)]]; -}; - -struct main0_out -{ - float4 FragColor [[color(0)]]; -}; - -fragment main0_out main0(main0_in in [[stage_in]]) -{ - main0_out out = {}; - VOUT tmp; - tmp.a = in.VOUT_a; - tmp.a += float4(1.0); - out.FragColor = tmp.a; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/frag/mix.frag b/deps/SPIRV-Cross/reference/shaders-msl/frag/mix.frag deleted file mode 100644 index 2d35766621..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/frag/mix.frag +++ /dev/null @@ -1,31 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_in -{ - float vIn3 [[user(locn3)]]; - float vIn2 [[user(locn2)]]; - float4 vIn1 [[user(locn1)]]; - float4 vIn0 [[user(locn0)]]; -}; - -struct main0_out -{ - float4 FragColor [[color(0)]]; -}; - -fragment main0_out main0(main0_in in [[stage_in]]) -{ - main0_out out = {}; - bool4 l = bool4(false, true, false, false); - out.FragColor = float4(l.x ? in.vIn1.x : in.vIn0.x, l.y ? in.vIn1.y : in.vIn0.y, l.z ? in.vIn1.z : in.vIn0.z, l.w ? in.vIn1.w : in.vIn0.w); - bool f = true; - out.FragColor = float4(f ? in.vIn3 : in.vIn2); - bool4 _37 = bool4(f); - out.FragColor = float4(_37.x ? in.vIn0.x : in.vIn1.x, _37.y ? in.vIn0.y : in.vIn1.y, _37.z ? in.vIn0.z : in.vIn1.z, _37.w ? in.vIn0.w : in.vIn1.w); - out.FragColor = float4(f ? in.vIn2 : in.vIn3); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/frag/pls.frag b/deps/SPIRV-Cross/reference/shaders-msl/frag/pls.frag deleted file mode 100644 index 42b5d2bf59..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/frag/pls.frag +++ /dev/null @@ -1,31 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_in -{ - float4 PLSIn3 [[user(locn3)]]; - float4 PLSIn2 [[user(locn2)]]; - float4 PLSIn1 [[user(locn1)]]; - float4 PLSIn0 [[user(locn0)]]; -}; - -struct main0_out -{ - float4 PLSOut0 [[color(0)]]; - float4 PLSOut1 [[color(1)]]; - float4 PLSOut2 [[color(2)]]; - float4 PLSOut3 [[color(3)]]; -}; - -fragment main0_out main0(main0_in in [[stage_in]]) -{ - main0_out out = {}; - out.PLSOut0 = in.PLSIn0 * 2.0; - out.PLSOut1 = in.PLSIn1 * 6.0; - out.PLSOut2 = in.PLSIn2 * 7.0; - out.PLSOut3 = in.PLSIn3 * 4.0; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/frag/sampler-ms.frag b/deps/SPIRV-Cross/reference/shaders-msl/frag/sampler-ms.frag deleted file mode 100644 index 6b5e20d720..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/frag/sampler-ms.frag +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_out -{ - float4 FragColor [[color(0)]]; -}; - -fragment main0_out main0(float4 gl_FragCoord [[position]], texture2d_ms uSampler [[texture(0)]], sampler uSamplerSmplr [[sampler(0)]]) -{ - main0_out out = {}; - int2 coord = int2(gl_FragCoord.xy); - out.FragColor = ((uSampler.read(uint2(coord), 0) + uSampler.read(uint2(coord), 1)) + uSampler.read(uint2(coord), 2)) + uSampler.read(uint2(coord), 3); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/frag/sampler.frag b/deps/SPIRV-Cross/reference/shaders-msl/frag/sampler.frag deleted file mode 100644 index 5d23492905..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/frag/sampler.frag +++ /dev/null @@ -1,31 +0,0 @@ -#pragma clang diagnostic ignored "-Wmissing-prototypes" - -#include -#include - -using namespace metal; - -struct main0_in -{ - float2 vTex [[user(locn1)]]; - float4 vColor [[user(locn0)]]; -}; - -struct main0_out -{ - float4 FragColor [[color(0)]]; -}; - -float4 sample_texture(thread const texture2d tex, thread const sampler& texSmplr, thread const float2& uv) -{ - return tex.sample(texSmplr, uv); -} - -fragment main0_out main0(main0_in in [[stage_in]], texture2d uTex [[texture(0)]], sampler uTexSmplr [[sampler(0)]]) -{ - main0_out out = {}; - float2 param = in.vTex; - out.FragColor = in.vColor * sample_texture(uTex, uTexSmplr, param); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/frag/separate-image-sampler-argument.frag b/deps/SPIRV-Cross/reference/shaders-msl/frag/separate-image-sampler-argument.frag deleted file mode 100644 index 46c0524ab7..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/frag/separate-image-sampler-argument.frag +++ /dev/null @@ -1,24 +0,0 @@ -#pragma clang diagnostic ignored "-Wmissing-prototypes" - -#include -#include - -using namespace metal; - -struct main0_out -{ - float4 FragColor [[color(0)]]; -}; - -float4 samp(thread const texture2d t, thread const sampler s) -{ - return t.sample(s, float2(0.5)); -} - -fragment main0_out main0(texture2d uDepth [[texture(0)]], sampler uSampler [[sampler(0)]]) -{ - main0_out out = {}; - out.FragColor = samp(uDepth, uSampler); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/frag/swizzle.frag b/deps/SPIRV-Cross/reference/shaders-msl/frag/swizzle.frag deleted file mode 100644 index eb46111f00..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/frag/swizzle.frag +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_in -{ - float2 vUV [[user(locn2)]]; - float3 vNormal [[user(locn1)]]; -}; - -struct main0_out -{ - float4 FragColor [[color(0)]]; -}; - -fragment main0_out main0(main0_in in [[stage_in]], texture2d samp [[texture(0)]], sampler sampSmplr [[sampler(0)]]) -{ - main0_out out = {}; - out.FragColor = float4(samp.sample(sampSmplr, in.vUV).xyz, 1.0); - out.FragColor = float4(samp.sample(sampSmplr, in.vUV).xz, 1.0, 4.0); - out.FragColor = float4(samp.sample(sampSmplr, in.vUV).xx, samp.sample(sampSmplr, (in.vUV + float2(0.100000001490116119384765625))).yy); - out.FragColor = float4(in.vNormal, 1.0); - out.FragColor = float4(in.vNormal + float3(1.7999999523162841796875), 1.0); - out.FragColor = float4(in.vUV, in.vUV + float2(1.7999999523162841796875)); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/frag/texture-proj-shadow.frag b/deps/SPIRV-Cross/reference/shaders-msl/frag/texture-proj-shadow.frag deleted file mode 100644 index c31e6d9623..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/frag/texture-proj-shadow.frag +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_in -{ - float2 vClip2 [[user(locn2)]]; - float4 vClip4 [[user(locn1)]]; - float3 vClip3 [[user(locn0)]]; -}; - -struct main0_out -{ - float FragColor [[color(0)]]; -}; - -fragment main0_out main0(main0_in in [[stage_in]], depth2d uShadow2D [[texture(0)]], sampler uShadow2DSmplr [[sampler(0)]], texture1d uSampler1D [[texture(1)]], sampler uSampler1DSmplr [[sampler(1)]], texture2d uSampler2D [[texture(2)]], sampler uSampler2DSmplr [[sampler(2)]], texture3d uSampler3D [[texture(3)]], sampler uSampler3DSmplr [[sampler(3)]]) -{ - main0_out out = {}; - float4 _20 = in.vClip4; - _20.z = in.vClip4.w; - out.FragColor = uShadow2D.sample_compare(uShadow2DSmplr, _20.xy / _20.z, in.vClip4.z); - out.FragColor = uSampler1D.sample(uSampler1DSmplr, in.vClip2.x / in.vClip2.y).x; - out.FragColor = uSampler2D.sample(uSampler2DSmplr, in.vClip3.xy / in.vClip3.z).x; - out.FragColor = uSampler3D.sample(uSampler3DSmplr, in.vClip4.xyz / in.vClip4.w).x; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/frag/ubo_layout.frag b/deps/SPIRV-Cross/reference/shaders-msl/frag/ubo_layout.frag deleted file mode 100644 index 8c03e33b39..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/frag/ubo_layout.frag +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include - -using namespace metal; - -struct Str -{ - float4x4 foo; -}; - -struct UBO1 -{ - Str foo; -}; - -struct UBO2 -{ - Str foo; -}; - -struct main0_out -{ - float4 FragColor [[color(0)]]; -}; - -fragment main0_out main0(constant UBO1& ubo1 [[buffer(0)]], constant UBO2& ubo0 [[buffer(1)]]) -{ - main0_out out = {}; - out.FragColor = transpose(ubo1.foo.foo)[0] + ubo0.foo.foo[0]; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/frag/unary-enclose.frag b/deps/SPIRV-Cross/reference/shaders-msl/frag/unary-enclose.frag deleted file mode 100644 index 5a80f4d77c..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/frag/unary-enclose.frag +++ /dev/null @@ -1,26 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_in -{ - int4 vIn1 [[user(locn1)]]; - float4 vIn [[user(locn0)]]; -}; - -struct main0_out -{ - float4 FragColor [[color(0)]]; -}; - -fragment main0_out main0(main0_in in [[stage_in]]) -{ - main0_out out = {}; - out.FragColor = -(-in.vIn); - int4 a = ~(~in.vIn1); - bool b = false; - b = !(!b); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/legacy/vert/transpose.legacy.vert b/deps/SPIRV-Cross/reference/shaders-msl/legacy/vert/transpose.legacy.vert deleted file mode 100644 index ad9ed8d7fd..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/legacy/vert/transpose.legacy.vert +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include - -using namespace metal; - -struct Buffer -{ - float4x4 MVPRowMajor; - float4x4 MVPColMajor; - float4x4 M; -}; - -struct main0_in -{ - float4 Position [[attribute(0)]]; -}; - -struct main0_out -{ - float4 gl_Position [[position]]; -}; - -vertex main0_out main0(main0_in in [[stage_in]], constant Buffer& _13 [[buffer(0)]]) -{ - main0_out out = {}; - float4 c0 = _13.M * (in.Position * _13.MVPRowMajor); - float4 c1 = _13.M * (_13.MVPColMajor * in.Position); - float4 c2 = _13.M * (_13.MVPRowMajor * in.Position); - float4 c3 = _13.M * (in.Position * _13.MVPColMajor); - out.gl_Position = ((c0 + c1) + c2) + c3; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/vert/basic.vert b/deps/SPIRV-Cross/reference/shaders-msl/vert/basic.vert deleted file mode 100644 index 1592b5c5cf..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/vert/basic.vert +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -using namespace metal; - -struct UBO -{ - float4x4 uMVP; -}; - -struct main0_in -{ - float3 aNormal [[attribute(1)]]; - float4 aVertex [[attribute(0)]]; -}; - -struct main0_out -{ - float3 vNormal [[user(locn0)]]; - float4 gl_Position [[position]]; -}; - -vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _16 [[buffer(0)]]) -{ - main0_out out = {}; - out.gl_Position = _16.uMVP * in.aVertex; - out.vNormal = in.aNormal; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/vert/copy.flatten.vert b/deps/SPIRV-Cross/reference/shaders-msl/vert/copy.flatten.vert deleted file mode 100644 index 9ae5fcdb17..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/vert/copy.flatten.vert +++ /dev/null @@ -1,47 +0,0 @@ -#include -#include - -using namespace metal; - -struct Light -{ - packed_float3 Position; - float Radius; - float4 Color; -}; - -struct UBO -{ - float4x4 uMVP; - Light lights[4]; -}; - -struct main0_in -{ - float3 aNormal [[attribute(1)]]; - float4 aVertex [[attribute(0)]]; -}; - -struct main0_out -{ - float4 vColor [[user(locn0)]]; - float4 gl_Position [[position]]; -}; - -vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _21 [[buffer(0)]]) -{ - main0_out out = {}; - out.gl_Position = _21.uMVP * in.aVertex; - out.vColor = float4(0.0); - for (int i = 0; i < 4; i++) - { - Light light; - light.Position = _21.lights[i].Position; - light.Radius = _21.lights[i].Radius; - light.Color = _21.lights[i].Color; - float3 L = in.aVertex.xyz - light.Position; - out.vColor += ((_21.lights[i].Color * clamp(1.0 - (length(L) / light.Radius), 0.0, 1.0)) * dot(in.aNormal, normalize(L))); - } - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/vert/dynamic.flatten.vert b/deps/SPIRV-Cross/reference/shaders-msl/vert/dynamic.flatten.vert deleted file mode 100644 index 696966ca0b..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/vert/dynamic.flatten.vert +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include - -using namespace metal; - -struct Light -{ - packed_float3 Position; - float Radius; - float4 Color; -}; - -struct UBO -{ - float4x4 uMVP; - Light lights[4]; -}; - -struct main0_in -{ - float3 aNormal [[attribute(1)]]; - float4 aVertex [[attribute(0)]]; -}; - -struct main0_out -{ - float4 vColor [[user(locn0)]]; - float4 gl_Position [[position]]; -}; - -vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _21 [[buffer(0)]]) -{ - main0_out out = {}; - out.gl_Position = _21.uMVP * in.aVertex; - out.vColor = float4(0.0); - for (int i = 0; i < 4; i++) - { - float3 L = in.aVertex.xyz - _21.lights[i].Position; - out.vColor += ((_21.lights[i].Color * clamp(1.0 - (length(L) / _21.lights[i].Radius), 0.0, 1.0)) * dot(in.aNormal, normalize(L))); - } - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/vert/functions.vert b/deps/SPIRV-Cross/reference/shaders-msl/vert/functions.vert deleted file mode 100644 index 8ec2484c3e..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/vert/functions.vert +++ /dev/null @@ -1,119 +0,0 @@ -#pragma clang diagnostic ignored "-Wmissing-prototypes" - -#include -#include - -using namespace metal; - -struct UBO -{ - float4x4 uMVP; - float3 rotDeg; - float3 rotRad; - int2 bits; -}; - -struct main0_in -{ - float3 aNormal [[attribute(1)]]; - float4 aVertex [[attribute(0)]]; -}; - -struct main0_out -{ - float3 vNormal [[user(locn0)]]; - float3 vRotDeg [[user(locn1)]]; - float3 vRotRad [[user(locn2)]]; - int2 vLSB [[user(locn3)]]; - int2 vMSB [[user(locn4)]]; - float4 gl_Position [[position]]; -}; - -// Implementation of the GLSL radians() function -template -T radians(T d) -{ - return d * 0.01745329251; -} - -// Implementation of the GLSL degrees() function -template -T degrees(T r) -{ - return r * 57.2957795131; -} - -// Implementation of the GLSL findLSB() function -template -T findLSB(T x) -{ - return select(ctz(x), T(-1), x == T(0)); -} - -// Implementation of the signed GLSL findMSB() function -template -T findSMSB(T x) -{ - T v = select(x, T(-1) - x, x < T(0)); - return select(clz(T(0)) - (clz(v) + T(1)), T(-1), v == T(0)); -} - -// 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; -} - -vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _18 [[buffer(0)]]) -{ - main0_out out = {}; - out.gl_Position = spvInverse4x4(_18.uMVP) * in.aVertex; - out.vNormal = in.aNormal; - out.vRotDeg = degrees(_18.rotRad); - out.vRotRad = radians(_18.rotDeg); - out.vLSB = findLSB(_18.bits); - out.vMSB = findSMSB(_18.bits); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/vert/out_block.vert b/deps/SPIRV-Cross/reference/shaders-msl/vert/out_block.vert deleted file mode 100644 index 3ae18387a6..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/vert/out_block.vert +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include - -using namespace metal; - -struct Transform -{ - float4x4 transform; -}; - -struct main0_in -{ - float4 color [[attribute(1)]]; - float3 position [[attribute(0)]]; -}; - -struct main0_out -{ - float4 VertexOut_color [[user(locn2)]]; - float4 VertexOut_color2 [[user(locn3)]]; - float4 gl_Position [[position]]; -}; - -vertex main0_out main0(main0_in in [[stage_in]], constant Transform& block [[buffer(0)]]) -{ - main0_out out = {}; - out.gl_Position = block.transform * float4(in.position, 1.0); - out.VertexOut_color = in.color; - out.VertexOut_color2 = in.color + float4(1.0); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/vert/pointsize.vert b/deps/SPIRV-Cross/reference/shaders-msl/vert/pointsize.vert deleted file mode 100644 index faf828b4d3..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/vert/pointsize.vert +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include - -using namespace metal; - -struct params -{ - float4x4 mvp; - float psize; -}; - -struct main0_in -{ - float4 color0 [[attribute(1)]]; - float4 position [[attribute(0)]]; -}; - -struct main0_out -{ - float4 color [[user(locn0)]]; - float4 gl_Position [[position]]; - float gl_PointSize [[point_size]]; -}; - -vertex main0_out main0(main0_in in [[stage_in]], constant params& _19 [[buffer(0)]]) -{ - main0_out out = {}; - out.gl_Position = _19.mvp * in.position; - out.gl_PointSize = _19.psize; - out.color = in.color0; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/vert/texture_buffer.vert b/deps/SPIRV-Cross/reference/shaders-msl/vert/texture_buffer.vert deleted file mode 100644 index 690757b830..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/vert/texture_buffer.vert +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_out -{ - float4 gl_Position [[position]]; -}; - -vertex main0_out main0(texture2d uSamp [[texture(0)]], texture2d uSampo [[texture(1)]]) -{ - main0_out out = {}; - out.gl_Position = uSamp.read(uint2(10, 0)) + uSampo.read(uint2(100, 0)); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/vert/ubo.alignment.vert b/deps/SPIRV-Cross/reference/shaders-msl/vert/ubo.alignment.vert deleted file mode 100644 index 6e48ae0e42..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/vert/ubo.alignment.vert +++ /dev/null @@ -1,38 +0,0 @@ -#include -#include - -using namespace metal; - -struct UBO -{ - float4x4 mvp; - float2 targSize; - char pad2[8]; - packed_float3 color; - float opacity; -}; - -struct main0_in -{ - float3 aNormal [[attribute(1)]]; - float4 aVertex [[attribute(0)]]; -}; - -struct main0_out -{ - float3 vNormal [[user(locn0)]]; - float3 vColor [[user(locn1)]]; - float2 vSize [[user(locn2)]]; - float4 gl_Position [[position]]; -}; - -vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _18 [[buffer(0)]]) -{ - main0_out out = {}; - out.gl_Position = _18.mvp * in.aVertex; - out.vNormal = in.aNormal; - out.vColor = _18.color * _18.opacity; - out.vSize = _18.targSize * _18.opacity; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/vert/ubo.vert b/deps/SPIRV-Cross/reference/shaders-msl/vert/ubo.vert deleted file mode 100644 index 4a1adcd7f6..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/vert/ubo.vert +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -using namespace metal; - -struct UBO -{ - float4x4 mvp; -}; - -struct main0_in -{ - float3 aNormal [[attribute(1)]]; - float4 aVertex [[attribute(0)]]; -}; - -struct main0_out -{ - float3 vNormal [[user(locn0)]]; - float4 gl_Position [[position]]; -}; - -vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _16 [[buffer(0)]]) -{ - main0_out out = {}; - out.gl_Position = _16.mvp * in.aVertex; - out.vNormal = in.aNormal; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/vulkan/frag/push-constant.vk.frag b/deps/SPIRV-Cross/reference/shaders-msl/vulkan/frag/push-constant.vk.frag deleted file mode 100644 index bc97e3cc51..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/vulkan/frag/push-constant.vk.frag +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include - -using namespace metal; - -struct PushConstants -{ - float4 value0; - float4 value1; -}; - -struct main0_in -{ - float4 vColor [[user(locn0)]]; -}; - -struct main0_out -{ - float4 FragColor [[color(0)]]; -}; - -fragment main0_out main0(main0_in in [[stage_in]], constant PushConstants& push [[buffer(0)]]) -{ - main0_out out = {}; - out.FragColor = (in.vColor + push.value0) + push.value1; - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/vulkan/frag/spec-constant.vk.frag b/deps/SPIRV-Cross/reference/shaders-msl/vulkan/frag/spec-constant.vk.frag deleted file mode 100644 index 47dabb1771..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/vulkan/frag/spec-constant.vk.frag +++ /dev/null @@ -1,74 +0,0 @@ -#include -#include - -using namespace metal; - -constant float a_tmp [[function_constant(1)]]; -constant float a = is_function_constant_defined(a_tmp) ? a_tmp : 1.0; -constant float b_tmp [[function_constant(2)]]; -constant float b = is_function_constant_defined(b_tmp) ? b_tmp : 2.0; -constant int c_tmp [[function_constant(3)]]; -constant int c = is_function_constant_defined(c_tmp) ? c_tmp : 3; -constant int d_tmp [[function_constant(4)]]; -constant int d = is_function_constant_defined(d_tmp) ? d_tmp : 4; -constant uint e_tmp [[function_constant(5)]]; -constant uint e = is_function_constant_defined(e_tmp) ? e_tmp : 5u; -constant uint f_tmp [[function_constant(6)]]; -constant uint f = is_function_constant_defined(f_tmp) ? f_tmp : 6u; -constant bool g_tmp [[function_constant(7)]]; -constant bool g = is_function_constant_defined(g_tmp) ? g_tmp : false; -constant bool h_tmp [[function_constant(8)]]; -constant bool h = is_function_constant_defined(h_tmp) ? h_tmp : true; - -struct main0_out -{ - float4 FragColor [[color(0)]]; -}; - -fragment main0_out main0() -{ - main0_out out = {}; - float t0 = a; - float t1 = b; - uint c0 = (uint(c) + 0u); - int c1 = (-c); - int c2 = (~c); - int c3 = (c + d); - int c4 = (c - d); - int c5 = (c * d); - int c6 = (c / d); - uint c7 = (e / f); - int c8 = (c % d); - uint c9 = (e % f); - int c10 = (c >> d); - uint c11 = (e >> f); - int c12 = (c << d); - int c13 = (c | d); - int c14 = (c ^ d); - int c15 = (c & d); - bool c16 = (g || h); - bool c17 = (g && h); - bool c18 = (!g); - bool c19 = (g == h); - bool c20 = (g != h); - bool c21 = (c == d); - bool c22 = (c != d); - bool c23 = (c < d); - bool c24 = (e < f); - bool c25 = (c > d); - bool c26 = (e > f); - bool c27 = (c <= d); - bool c28 = (e <= f); - bool c29 = (c >= d); - bool c30 = (e >= f); - int c31 = c8 + c3; - int c32 = int(e + 0u); - bool c33 = (c != int(0u)); - bool c34 = (e != 0u); - int c35 = int(g); - uint c36 = uint(g); - float c37 = float(g); - out.FragColor = float4(t0 + t1); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders-msl/vulkan/vert/vulkan-vertex.vk.vert b/deps/SPIRV-Cross/reference/shaders-msl/vulkan/vert/vulkan-vertex.vk.vert deleted file mode 100644 index 53e26e4a8e..0000000000 --- a/deps/SPIRV-Cross/reference/shaders-msl/vulkan/vert/vulkan-vertex.vk.vert +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_out -{ - float4 gl_Position [[position]]; -}; - -vertex main0_out main0(uint gl_VertexIndex [[vertex_id]], uint gl_InstanceIndex [[instance_id]]) -{ - main0_out out = {}; - out.gl_Position = float4(1.0, 2.0, 3.0, 4.0) * float(gl_VertexIndex + gl_InstanceIndex); - return out; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag b/deps/SPIRV-Cross/reference/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag deleted file mode 100644 index d670898481..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag +++ /dev/null @@ -1,11 +0,0 @@ -#version 450 -#extension GL_AMD_shader_fragment_mask : require - -layout(binding = 0) uniform sampler2DMS t; - -void main() -{ - vec4 test2 = fragmentFetchAMD(t, 4u); - uint testi2 = fragmentMaskFetchAMD(t); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag.vk b/deps/SPIRV-Cross/reference/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag.vk deleted file mode 100644 index 4aaf397a0f..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag.vk +++ /dev/null @@ -1,11 +0,0 @@ -#version 450 -#extension GL_AMD_shader_fragment_mask : require - -layout(input_attachment_index = 0, set = 0, binding = 0) uniform subpassInputMS t; - -void main() -{ - vec4 test2 = fragmentFetchAMD(t, 4u); - uint testi2 = fragmentMaskFetchAMD(t); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/amd/fs.invalid.frag b/deps/SPIRV-Cross/reference/shaders/amd/fs.invalid.frag deleted file mode 100644 index 97e7bcd180..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/amd/fs.invalid.frag +++ /dev/null @@ -1,15 +0,0 @@ -#version 450 -#extension GL_AMD_shader_fragment_mask : require -#extension GL_AMD_shader_explicit_vertex_parameter : require - -uniform sampler2DMS texture1; - -layout(location = 0) in vec4 vary; - -void main() -{ - uint testi1 = fragmentMaskFetchAMD(texture1, ivec2(0)); - vec4 test1 = fragmentFetchAMD(texture1, ivec2(1), 2u); - vec4 pos = interpolateAtVertexAMD(vary, 0u); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/amd/gcn_shader.comp b/deps/SPIRV-Cross/reference/shaders/amd/gcn_shader.comp deleted file mode 100644 index 1c0c5ae38b..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/amd/gcn_shader.comp +++ /dev/null @@ -1,12 +0,0 @@ -#version 450 -#extension GL_ARB_gpu_shader_int64 : require -#extension GL_AMD_gcn_shader : require -layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; - -void main() -{ - float cubeFace = cubeFaceIndexAMD(vec3(0.0)); - vec2 cubeFaceCoord = cubeFaceCoordAMD(vec3(1.0)); - uint64_t time = timeAMD(); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/amd/shader_ballot.comp b/deps/SPIRV-Cross/reference/shaders/amd/shader_ballot.comp deleted file mode 100644 index 64ac64d0d2..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/amd/shader_ballot.comp +++ /dev/null @@ -1,32 +0,0 @@ -#version 450 -#extension GL_ARB_gpu_shader_int64 : require -#extension GL_ARB_shader_ballot : require -#extension GL_AMD_shader_ballot : require -layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) buffer inputData -{ - float inputDataArray[]; -} _12; - -layout(binding = 1, std430) buffer outputData -{ - float outputDataArray[]; -} _74; - -void main() -{ - float thisLaneData = _12.inputDataArray[gl_LocalInvocationID.x]; - bool laneActive = thisLaneData > 0.0; - uint thisLaneOutputSlot = mbcntAMD(packUint2x32(uvec2(unpackUint2x32(ballotARB(laneActive)).xy))); - int firstInvocation = readFirstInvocationARB(1); - int invocation = readInvocationARB(1, 0u); - vec3 swizzleInvocations = swizzleInvocationsAMD(vec3(0.0, 2.0, 1.0), uvec4(3u)); - vec3 swizzelInvocationsMasked = swizzleInvocationsMaskedAMD(vec3(0.0, 2.0, 1.0), uvec3(2u)); - vec3 writeInvocation = writeInvocationAMD(swizzleInvocations, swizzelInvocationsMasked, 0u); - if (laneActive) - { - _74.outputDataArray[thisLaneOutputSlot] = thisLaneData; - } -} - diff --git a/deps/SPIRV-Cross/reference/shaders/amd/shader_ballot_nonuniform_invocations.invalid.comp b/deps/SPIRV-Cross/reference/shaders/amd/shader_ballot_nonuniform_invocations.invalid.comp deleted file mode 100644 index a14343ae12..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/amd/shader_ballot_nonuniform_invocations.invalid.comp +++ /dev/null @@ -1,11 +0,0 @@ -#version 450 -#extension GL_AMD_shader_ballot : require -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -void main() -{ - float addInvocations = addInvocationsNonUniformAMD(0.0); - int minInvocations = minInvocationsNonUniformAMD(1); - uint maxInvocations = uint(maxInvocationsNonUniformAMD(4)); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/amd/shader_group_vote.comp b/deps/SPIRV-Cross/reference/shaders/amd/shader_group_vote.comp deleted file mode 100644 index 007d9f9841..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/amd/shader_group_vote.comp +++ /dev/null @@ -1,18 +0,0 @@ -#version 450 -#extension GL_ARB_shader_group_vote : require -layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) buffer inputData -{ - float inputDataArray[]; -} _12; - -void main() -{ - float thisLaneData = _12.inputDataArray[gl_LocalInvocationID.x]; - bool laneActive = thisLaneData > 0.0; - bool allInvocations = allInvocationsARB(laneActive); - bool anyInvocations = anyInvocationARB(laneActive); - bool allInvocationsEqual = allInvocationsEqualARB(laneActive); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/amd/shader_trinary_minmax.comp b/deps/SPIRV-Cross/reference/shaders/amd/shader_trinary_minmax.comp deleted file mode 100644 index ece39b7106..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/amd/shader_trinary_minmax.comp +++ /dev/null @@ -1,11 +0,0 @@ -#version 450 -#extension GL_AMD_shader_trinary_minmax : require -layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; - -void main() -{ - int t11 = min3(0, 3, 2); - int t12 = max3(0, 3, 2); - int t13 = mid3(0, 3, 2); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/asm/comp/bitcast_iadd.asm.comp b/deps/SPIRV-Cross/reference/shaders/asm/comp/bitcast_iadd.asm.comp deleted file mode 100644 index bed2dffccb..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/asm/comp/bitcast_iadd.asm.comp +++ /dev/null @@ -1,27 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) restrict buffer _3_5 -{ - ivec4 _m0; - uvec4 _m1; -} _5; - -layout(binding = 1, std430) restrict buffer _4_6 -{ - uvec4 _m0; - ivec4 _m1; -} _6; - -void main() -{ - _6._m0 = _5._m1 + uvec4(_5._m0); - _6._m0 = uvec4(_5._m0) + _5._m1; - _6._m0 = _5._m1 + _5._m1; - _6._m0 = uvec4(_5._m0 + _5._m0); - _6._m1 = ivec4(_5._m1 + _5._m1); - _6._m1 = _5._m0 + _5._m0; - _6._m1 = ivec4(_5._m1) + _5._m0; - _6._m1 = _5._m0 + ivec4(_5._m1); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/asm/comp/bitcast_iequal.asm.comp b/deps/SPIRV-Cross/reference/shaders/asm/comp/bitcast_iequal.asm.comp deleted file mode 100644 index 79398b404b..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/asm/comp/bitcast_iequal.asm.comp +++ /dev/null @@ -1,31 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) buffer _3_5 -{ - ivec4 _m0; - uvec4 _m1; -} _5; - -layout(binding = 1, std430) buffer _4_6 -{ - uvec4 _m0; - ivec4 _m1; -} _6; - -void main() -{ - bvec4 _34 = equal(ivec4(_5._m1), _5._m0); - bvec4 _35 = equal(_5._m0, ivec4(_5._m1)); - bvec4 _36 = equal(_5._m1, _5._m1); - bvec4 _37 = equal(_5._m0, _5._m0); - _6._m0 = mix(uvec4(0u), uvec4(1u), _34); - _6._m0 = mix(uvec4(0u), uvec4(1u), _35); - _6._m0 = mix(uvec4(0u), uvec4(1u), _36); - _6._m0 = mix(uvec4(0u), uvec4(1u), _37); - _6._m1 = mix(ivec4(0), ivec4(1), _34); - _6._m1 = mix(ivec4(0), ivec4(1), _35); - _6._m1 = mix(ivec4(0), ivec4(1), _36); - _6._m1 = mix(ivec4(0), ivec4(1), _37); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/asm/comp/bitcast_sar.asm.comp b/deps/SPIRV-Cross/reference/shaders/asm/comp/bitcast_sar.asm.comp deleted file mode 100644 index 42a4ed0233..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/asm/comp/bitcast_sar.asm.comp +++ /dev/null @@ -1,27 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) buffer _3_5 -{ - ivec4 _m0; - uvec4 _m1; -} _5; - -layout(binding = 1, std430) buffer _4_6 -{ - uvec4 _m0; - ivec4 _m1; -} _6; - -void main() -{ - _6._m0 = uvec4(ivec4(_5._m1) >> _5._m0); - _6._m0 = uvec4(_5._m0 >> ivec4(_5._m1)); - _6._m0 = uvec4(ivec4(_5._m1) >> ivec4(_5._m1)); - _6._m0 = uvec4(_5._m0 >> _5._m0); - _6._m1 = ivec4(_5._m1) >> ivec4(_5._m1); - _6._m1 = _5._m0 >> _5._m0; - _6._m1 = ivec4(_5._m1) >> _5._m0; - _6._m1 = _5._m0 >> ivec4(_5._m1); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/asm/comp/bitcast_sdiv.asm.comp b/deps/SPIRV-Cross/reference/shaders/asm/comp/bitcast_sdiv.asm.comp deleted file mode 100644 index eeb97e14a2..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/asm/comp/bitcast_sdiv.asm.comp +++ /dev/null @@ -1,27 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) buffer _3_5 -{ - ivec4 _m0; - uvec4 _m1; -} _5; - -layout(binding = 1, std430) buffer _4_6 -{ - uvec4 _m0; - ivec4 _m1; -} _6; - -void main() -{ - _6._m0 = uvec4(ivec4(_5._m1) / _5._m0); - _6._m0 = uvec4(_5._m0 / ivec4(_5._m1)); - _6._m0 = uvec4(ivec4(_5._m1) / ivec4(_5._m1)); - _6._m0 = uvec4(_5._m0 / _5._m0); - _6._m1 = ivec4(_5._m1) / ivec4(_5._m1); - _6._m1 = _5._m0 / _5._m0; - _6._m1 = ivec4(_5._m1) / _5._m0; - _6._m1 = _5._m0 / ivec4(_5._m1); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/asm/comp/bitcast_slr.asm.comp b/deps/SPIRV-Cross/reference/shaders/asm/comp/bitcast_slr.asm.comp deleted file mode 100644 index 25245e63eb..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/asm/comp/bitcast_slr.asm.comp +++ /dev/null @@ -1,27 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) buffer _3_5 -{ - ivec4 _m0; - uvec4 _m1; -} _5; - -layout(binding = 1, std430) buffer _4_6 -{ - uvec4 _m0; - ivec4 _m1; -} _6; - -void main() -{ - _6._m0 = _5._m1 >> uvec4(_5._m0); - _6._m0 = uvec4(_5._m0) >> _5._m1; - _6._m0 = _5._m1 >> _5._m1; - _6._m0 = uvec4(_5._m0) >> uvec4(_5._m0); - _6._m1 = ivec4(_5._m1 >> _5._m1); - _6._m1 = ivec4(uvec4(_5._m0) >> uvec4(_5._m0)); - _6._m1 = ivec4(_5._m1 >> uvec4(_5._m0)); - _6._m1 = ivec4(uvec4(_5._m0) >> _5._m1); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/asm/comp/logical.asm.comp b/deps/SPIRV-Cross/reference/shaders/asm/comp/logical.asm.comp deleted file mode 100644 index 9ae25f78a9..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/asm/comp/logical.asm.comp +++ /dev/null @@ -1,56 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) buffer SSBO0 -{ - float a; - vec2 b; - vec3 c; - vec4 d; -} s0; - -layout(binding = 1, std430) buffer SSBO1 -{ - float a; - vec2 b; - vec3 c; - vec4 d; -} s1; - -bool and(bool a, bool b) -{ - return !((a && b) || b); -} - -bvec2 and(bvec2 a, bvec2 b) -{ - bvec2 _98 = bvec2(a.x && b.x, a.y && b.y); - return not(bvec2(_98.x || b.x, _98.y || b.y)); -} - -bvec3 and(bvec3 a, bvec3 b) -{ - return bvec3(a.x && b.x, a.y && b.y, a.z && b.z); -} - -bvec4 and(bvec4 a, bvec4 b) -{ - return bvec4(a.x && b.x, a.y && b.y, a.z && b.z, a.w && b.w); -} - -void main() -{ - bool param = isinf(s0.a); - bool param_1 = isnan(s1.a); - bool b0 = and(param, param_1); - bvec2 param_2 = isinf(s0.b); - bvec2 param_3 = isnan(s1.b); - bvec2 b1 = and(param_2, param_3); - bvec3 param_4 = isinf(s0.c); - bvec3 param_5 = isnan(s1.c); - bvec3 b2 = and(param_4, param_5); - bvec4 param_6 = isinf(s0.d); - bvec4 param_7 = isnan(s1.d); - bvec4 b3 = and(param_6, param_7); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/asm/comp/multiple-entry.asm.comp b/deps/SPIRV-Cross/reference/shaders/asm/comp/multiple-entry.asm.comp deleted file mode 100644 index 6418464f19..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/asm/comp/multiple-entry.asm.comp +++ /dev/null @@ -1,27 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) restrict buffer _6_8 -{ - ivec4 _m0; - uvec4 _m1; -} _8; - -layout(binding = 1, std430) restrict buffer _7_9 -{ - uvec4 _m0; - ivec4 _m1; -} _9; - -void main() -{ - _9._m0 = _8._m1 + uvec4(_8._m0); - _9._m0 = uvec4(_8._m0) + _8._m1; - _9._m0 = _8._m1 + _8._m1; - _9._m0 = uvec4(_8._m0 + _8._m0); - _9._m1 = ivec4(_8._m1 + _8._m1); - _9._m1 = _8._m0 + _8._m0; - _9._m1 = ivec4(_8._m1) + _8._m0; - _9._m1 = _8._m0 + ivec4(_8._m1); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/asm/comp/name-alias.asm.invalid.comp b/deps/SPIRV-Cross/reference/shaders/asm/comp/name-alias.asm.invalid.comp deleted file mode 100644 index 870b1df98d..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/asm/comp/name-alias.asm.invalid.comp +++ /dev/null @@ -1,37 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -struct alias -{ - vec3 alias[100]; -}; - -struct alias_1 -{ - vec4 alias; - vec2 alias_1[10]; - alias alias_2[2]; -}; - -struct alias_2 -{ - vec4 alias; - alias_1 alias_1; -}; - -layout(binding = 0, std430) buffer alias_3 -{ - alias_2 alias; -} alias_4; - -layout(binding = 1, std140) buffer alias_5 -{ - alias_2 alias; -} alias_6; - -void main() -{ - alias_2 alias_7 = alias_4.alias; - alias_6.alias = alias_7; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/asm/comp/quantize.asm.comp b/deps/SPIRV-Cross/reference/shaders/asm/comp/quantize.asm.comp deleted file mode 100644 index c089213800..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/asm/comp/quantize.asm.comp +++ /dev/null @@ -1,19 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) buffer SSBO0 -{ - float scalar; - vec2 vec2_val; - vec3 vec3_val; - vec4 vec4_val; -} _4; - -void main() -{ - _4.scalar = unpackHalf2x16(packHalf2x16(vec2(_4.scalar))).x; - _4.vec2_val = unpackHalf2x16(packHalf2x16(_4.vec2_val)); - _4.vec3_val = vec3(unpackHalf2x16(packHalf2x16(_4.vec3_val.xy)), unpackHalf2x16(packHalf2x16(_4.vec3_val.zz)).x); - _4.vec4_val = vec4(unpackHalf2x16(packHalf2x16(_4.vec4_val.xy)), unpackHalf2x16(packHalf2x16(_4.vec4_val.zw))); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/asm/comp/specialization-constant-workgroup.asm.comp b/deps/SPIRV-Cross/reference/shaders/asm/comp/specialization-constant-workgroup.asm.comp deleted file mode 100644 index 1b2285a8da..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/asm/comp/specialization-constant-workgroup.asm.comp +++ /dev/null @@ -1,13 +0,0 @@ -#version 310 es -layout(local_size_x = 9, local_size_y = 20, local_size_z = 4) in; - -layout(binding = 0, std430) buffer SSBO -{ - float a; -} _4; - -void main() -{ - _4.a += 1.0; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/asm/comp/storage-buffer-basic.asm.comp b/deps/SPIRV-Cross/reference/shaders/asm/comp/storage-buffer-basic.asm.comp deleted file mode 100644 index a2210eb169..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/asm/comp/storage-buffer-basic.asm.comp +++ /dev/null @@ -1,20 +0,0 @@ -#version 450 -layout(local_size_x = 1, local_size_y = 2, local_size_z = 3) in; - -layout(binding = 0, std430) buffer _6_8 -{ - float _m0[]; -} _8; - -layout(binding = 1, std430) buffer _6_9 -{ - float _m0[]; -} _9; - -uvec3 _22 = gl_WorkGroupSize; - -void main() -{ - _8._m0[gl_WorkGroupID.x] = _9._m0[gl_WorkGroupID.x] + _8._m0[gl_WorkGroupID.x]; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/asm/frag/composite-construct-struct-no-swizzle.asm.frag b/deps/SPIRV-Cross/reference/shaders/asm/frag/composite-construct-struct-no-swizzle.asm.frag deleted file mode 100644 index c64818d2bf..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/asm/frag/composite-construct-struct-no-swizzle.asm.frag +++ /dev/null @@ -1,19 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -struct SwizzleTest -{ - float a; - float b; -}; - -layout(location = 0) in vec2 foo; -layout(location = 0) out float FooOut; - -void main() -{ - SwizzleTest _22 = SwizzleTest(foo.x, foo.y); - FooOut = _22.a + _22.b; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/asm/frag/default-member-names.asm.frag b/deps/SPIRV-Cross/reference/shaders/asm/frag/default-member-names.asm.frag deleted file mode 100644 index 57d4536c9b..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/asm/frag/default-member-names.asm.frag +++ /dev/null @@ -1,32 +0,0 @@ -#version 450 - -struct _9 -{ - float _m0; -}; - -struct _10 -{ - float _m0; - float _m1; - float _m2; - float _m3; - float _m4; - float _m5; - float _m6; - float _m7; - float _m8; - float _m9; - float _m10; - float _m11; - _9 _m12; -}; - -layout(location = 0) out vec4 _3; - -void main() -{ - _10 _21; - _3 = vec4(_21._m0, _21._m1, _21._m2, _21._m3); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/asm/frag/hlsl-sample-cmp-level-zero-cube.asm.frag b/deps/SPIRV-Cross/reference/shaders/asm/frag/hlsl-sample-cmp-level-zero-cube.asm.frag deleted file mode 100644 index 3585285eb6..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/asm/frag/hlsl-sample-cmp-level-zero-cube.asm.frag +++ /dev/null @@ -1,17 +0,0 @@ -#version 450 - -uniform samplerCubeShadow SPIRV_Cross_CombinedpointLightShadowMapshadowSamplerPCF; - -layout(location = 0) out float _entryPointOutput; - -float _main() -{ - vec4 _33 = vec4(vec3(0.100000001490116119384765625), 0.5); - return textureGrad(SPIRV_Cross_CombinedpointLightShadowMapshadowSamplerPCF, vec4(_33.xyz, _33.w), vec3(0.0), vec3(0.0)); -} - -void main() -{ - _entryPointOutput = _main(); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/asm/frag/hlsl-sample-cmp-level-zero.asm.frag b/deps/SPIRV-Cross/reference/shaders/asm/frag/hlsl-sample-cmp-level-zero.asm.frag deleted file mode 100644 index 63856ddd46..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/asm/frag/hlsl-sample-cmp-level-zero.asm.frag +++ /dev/null @@ -1,27 +0,0 @@ -#version 450 - -uniform sampler2DArrayShadow SPIRV_Cross_CombinedShadowMapShadowSamplerPCF; - -layout(location = 0) in vec2 texCoords; -layout(location = 1) in float cascadeIndex; -layout(location = 2) in float fragDepth; -layout(location = 0) out vec4 _entryPointOutput; - -vec4 _main(vec2 texCoords_1, float cascadeIndex_1, float fragDepth_1) -{ - vec4 _60 = vec4(vec3(texCoords_1, cascadeIndex_1), fragDepth_1); - float c = textureGrad(SPIRV_Cross_CombinedShadowMapShadowSamplerPCF, vec4(_60.xyz, _60.w), vec2(0.0), vec2(0.0)); - return vec4(c, c, c, c); -} - -void main() -{ - vec2 texCoords_1 = texCoords; - float cascadeIndex_1 = cascadeIndex; - float fragDepth_1 = fragDepth; - vec2 param = texCoords_1; - float param_1 = cascadeIndex_1; - float param_2 = fragDepth_1; - _entryPointOutput = _main(param, param_1, param_2); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag b/deps/SPIRV-Cross/reference/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag deleted file mode 100644 index 98116cfdc7..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag +++ /dev/null @@ -1,227 +0,0 @@ -#version 450 - -struct VertexOutput -{ - vec4 HPosition; - vec4 Uv_EdgeDistance1; - vec4 UvStuds_EdgeDistance2; - vec4 Color; - vec4 LightPosition_Fog; - vec4 View_Depth; - vec4 Normal_SpecPower; - vec3 Tangent; - vec4 PosLightSpace_Reflectance; - float studIndex; -}; - -struct Surface -{ - vec3 albedo; - vec3 normal; - float specular; - float gloss; - float reflectance; - float opacity; -}; - -struct SurfaceInput -{ - vec4 Color; - vec2 Uv; - vec2 UvStuds; -}; - -struct Globals -{ - mat4 ViewProjection; - vec4 ViewRight; - vec4 ViewUp; - vec4 ViewDir; - vec3 CameraPosition; - vec3 AmbientColor; - vec3 Lamp0Color; - vec3 Lamp0Dir; - vec3 Lamp1Color; - vec4 FogParams; - vec3 FogColor; - vec4 LightBorder; - vec4 LightConfig0; - vec4 LightConfig1; - vec4 LightConfig2; - vec4 LightConfig3; - vec4 RefractionBias_FadeDistance_GlowFactor; - vec4 OutlineBrightness_ShadowInfo; - vec4 ShadowMatrix0; - vec4 ShadowMatrix1; - vec4 ShadowMatrix2; -}; - -struct Params -{ - vec4 LqmatFarTilingFactor; -}; - -layout(binding = 0, std140) uniform CB0 -{ - Globals CB0; -} _19; - -uniform sampler2D SPIRV_Cross_CombinedDiffuseMapTextureDiffuseMapSampler; -uniform sampler2D SPIRV_Cross_CombinedNormalMapTextureNormalMapSampler; -uniform sampler2D SPIRV_Cross_CombinedNormalDetailMapTextureNormalDetailMapSampler; -uniform sampler2D SPIRV_Cross_CombinedStudsMapTextureStudsMapSampler; -uniform sampler2D SPIRV_Cross_CombinedSpecularMapTextureSpecularMapSampler; -uniform sampler3D SPIRV_Cross_CombinedLightMapTextureLightMapSampler; -uniform sampler2D SPIRV_Cross_CombinedShadowMapTextureShadowMapSampler; -uniform samplerCube SPIRV_Cross_CombinedEnvironmentMapTextureEnvironmentMapSampler; - -layout(location = 0) in vec4 IN_Uv_EdgeDistance1; -layout(location = 1) in vec4 IN_UvStuds_EdgeDistance2; -layout(location = 2) in vec4 IN_Color; -layout(location = 3) in vec4 IN_LightPosition_Fog; -layout(location = 4) in vec4 IN_View_Depth; -layout(location = 5) in vec4 IN_Normal_SpecPower; -layout(location = 6) in vec3 IN_Tangent; -layout(location = 7) in vec4 IN_PosLightSpace_Reflectance; -layout(location = 8) in float IN_studIndex; -layout(location = 0) out vec4 _entryPointOutput; - -VertexOutput _121; -SurfaceInput _122; -vec2 _123; -vec4 _124; -Surface _125; -vec4 _192; -vec4 _219; -vec4 _297; - -void main() -{ - VertexOutput _128 = _121; - _128.HPosition = gl_FragCoord; - VertexOutput _130 = _128; - _130.Uv_EdgeDistance1 = IN_Uv_EdgeDistance1; - VertexOutput _132 = _130; - _132.UvStuds_EdgeDistance2 = IN_UvStuds_EdgeDistance2; - VertexOutput _134 = _132; - _134.Color = IN_Color; - VertexOutput _136 = _134; - _136.LightPosition_Fog = IN_LightPosition_Fog; - VertexOutput _138 = _136; - _138.View_Depth = IN_View_Depth; - VertexOutput _140 = _138; - _140.Normal_SpecPower = IN_Normal_SpecPower; - VertexOutput _142 = _140; - _142.Tangent = IN_Tangent; - VertexOutput _144 = _142; - _144.PosLightSpace_Reflectance = IN_PosLightSpace_Reflectance; - VertexOutput _146 = _144; - _146.studIndex = IN_studIndex; - SurfaceInput _147 = _122; - _147.Color = IN_Color; - SurfaceInput _149 = _147; - _149.Uv = IN_Uv_EdgeDistance1.xy; - SurfaceInput _151 = _149; - _151.UvStuds = IN_UvStuds_EdgeDistance2.xy; - SurfaceInput _156 = _151; - _156.UvStuds.y = (fract(_151.UvStuds.y) + IN_studIndex) * 0.25; - float _163 = _146.View_Depth.w * _19.CB0.RefractionBias_FadeDistance_GlowFactor.y; - float _165 = clamp(1.0 - _163, 0.0, 1.0); - vec2 _166 = IN_Uv_EdgeDistance1.xy * 1.0; - bool _173; - vec4 _193; - do - { - _173 = 0.0 == 0.0; - if (_173) - { - _193 = texture(SPIRV_Cross_CombinedDiffuseMapTextureDiffuseMapSampler, _166); - break; - } - else - { - float _180 = 1.0 / (1.0 - 0.0); - _193 = mix(texture(SPIRV_Cross_CombinedDiffuseMapTextureDiffuseMapSampler, _166 * 0.25), texture(SPIRV_Cross_CombinedDiffuseMapTextureDiffuseMapSampler, _166), vec4(clamp((clamp(1.0 - (_146.View_Depth.w * 0.00333332992158830165863037109375), 0.0, 1.0) * _180) - (0.0 * _180), 0.0, 1.0))); - break; - } - _193 = _192; - break; - } while (false); - vec4 _220; - do - { - if (_173) - { - _220 = texture(SPIRV_Cross_CombinedNormalMapTextureNormalMapSampler, _166); - break; - } - else - { - float _207 = 1.0 / (1.0 - 0.0); - _220 = mix(texture(SPIRV_Cross_CombinedNormalMapTextureNormalMapSampler, _166 * 0.25), texture(SPIRV_Cross_CombinedNormalMapTextureNormalMapSampler, _166), vec4(clamp((_165 * _207) - (0.0 * _207), 0.0, 1.0))); - break; - } - _220 = _219; - break; - } while (false); - vec2 _223 = vec2(1.0); - vec2 _224 = (_220.wy * 2.0) - _223; - vec3 _232 = vec3(_224, sqrt(clamp(1.0 + dot(-_224, _224), 0.0, 1.0))); - vec2 _240 = (texture(SPIRV_Cross_CombinedNormalDetailMapTextureNormalDetailMapSampler, _166 * 0.0).wy * 2.0) - _223; - vec2 _252 = _232.xy + (vec3(_240, sqrt(clamp(1.0 + dot(-_240, _240), 0.0, 1.0))).xy * 0.0); - vec3 _253 = vec3(_252.x, _252.y, _232.z); - vec2 _255 = _253.xy * _165; - vec3 _256 = vec3(_255.x, _255.y, _253.z); - vec3 _271 = ((IN_Color.xyz * (_193 * 1.0).xyz) * (1.0 + (_256.x * 0.300000011920928955078125))) * (texture(SPIRV_Cross_CombinedStudsMapTextureStudsMapSampler, _156.UvStuds).x * 2.0); - vec4 _298; - do - { - if (0.75 == 0.0) - { - _298 = texture(SPIRV_Cross_CombinedSpecularMapTextureSpecularMapSampler, _166); - break; - } - else - { - float _285 = 1.0 / (1.0 - 0.75); - _298 = mix(texture(SPIRV_Cross_CombinedSpecularMapTextureSpecularMapSampler, _166 * 0.25), texture(SPIRV_Cross_CombinedSpecularMapTextureSpecularMapSampler, _166), vec4(clamp((_165 * _285) - (0.75 * _285), 0.0, 1.0))); - break; - } - _298 = _297; - break; - } while (false); - vec2 _303 = mix(vec2(0.800000011920928955078125, 120.0), (_298.xy * vec2(2.0, 256.0)) + vec2(0.0, 0.00999999977648258209228515625), vec2(_165)); - Surface _304 = _125; - _304.albedo = _271; - Surface _305 = _304; - _305.normal = _256; - float _306 = _303.x; - Surface _307 = _305; - _307.specular = _306; - float _308 = _303.y; - Surface _309 = _307; - _309.gloss = _308; - float _312 = (_298.xy.y * _165) * 0.0; - Surface _313 = _309; - _313.reflectance = _312; - vec4 _318 = vec4(_271, _146.Color.w); - vec3 _329 = normalize(((IN_Tangent * _313.normal.x) + (cross(IN_Normal_SpecPower.xyz, IN_Tangent) * _313.normal.y)) + (IN_Normal_SpecPower.xyz * _313.normal.z)); - vec3 _332 = -_19.CB0.Lamp0Dir; - float _333 = dot(_329, _332); - float _357 = clamp(dot(step(_19.CB0.LightConfig3.xyz, abs(IN_LightPosition_Fog.xyz - _19.CB0.LightConfig2.xyz)), vec3(1.0)), 0.0, 1.0); - vec4 _368 = mix(texture(SPIRV_Cross_CombinedLightMapTextureLightMapSampler, IN_LightPosition_Fog.xyz.yzx - (IN_LightPosition_Fog.xyz.yzx * _357)), _19.CB0.LightBorder, vec4(_357)); - vec2 _376 = texture(SPIRV_Cross_CombinedShadowMapTextureShadowMapSampler, IN_PosLightSpace_Reflectance.xyz.xy).xy; - float _392 = (1.0 - (((step(_376.x, IN_PosLightSpace_Reflectance.xyz.z) * clamp(9.0 - (20.0 * abs(IN_PosLightSpace_Reflectance.xyz.z - 0.5)), 0.0, 1.0)) * _376.y) * _19.CB0.OutlineBrightness_ShadowInfo.w)) * _368.w; - vec3 _403 = mix(_318.xyz, texture(SPIRV_Cross_CombinedEnvironmentMapTextureEnvironmentMapSampler, reflect(-IN_View_Depth.xyz, _329)).xyz, vec3(_312)); - vec4 _404 = vec4(_403.x, _403.y, _403.z, _318.w); - vec3 _422 = (((_19.CB0.AmbientColor + (((_19.CB0.Lamp0Color * clamp(_333, 0.0, 1.0)) + (_19.CB0.Lamp1Color * max(-_333, 0.0))) * _392)) + _368.xyz) * _404.xyz) + (_19.CB0.Lamp0Color * (((step(0.0, _333) * _306) * _392) * pow(clamp(dot(_329, normalize(_332 + normalize(IN_View_Depth.xyz))), 0.0, 1.0), _308))); - vec4 _425 = vec4(_422.x, _422.y, _422.z, _124.w); - _425.w = _404.w; - vec2 _435 = min(IN_Uv_EdgeDistance1.wz, IN_UvStuds_EdgeDistance2.wz); - float _439 = min(_435.x, _435.y) / _163; - vec3 _445 = _425.xyz * clamp((clamp((_163 * _19.CB0.OutlineBrightness_ShadowInfo.x) + _19.CB0.OutlineBrightness_ShadowInfo.y, 0.0, 1.0) * (1.5 - _439)) + _439, 0.0, 1.0); - vec4 _446 = vec4(_445.x, _445.y, _445.z, _425.w); - vec3 _453 = mix(_19.CB0.FogColor, _446.xyz, vec3(clamp(_146.LightPosition_Fog.w, 0.0, 1.0))); - _entryPointOutput = vec4(_453.x, _453.y, _453.z, _446.w); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/asm/frag/invalidation.asm.frag b/deps/SPIRV-Cross/reference/shaders/asm/frag/invalidation.asm.frag deleted file mode 100644 index db1181804c..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/asm/frag/invalidation.asm.frag +++ /dev/null @@ -1,15 +0,0 @@ -#version 450 - -layout(location = 0) in float v0; -layout(location = 1) in float v1; -layout(location = 0) out float FragColor; - -void main() -{ - float a = v0; - float b = v1; - float _17 = a; - a = v1; - FragColor = (_17 + b) * b; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag b/deps/SPIRV-Cross/reference/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag deleted file mode 100644 index e1edccff69..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag +++ /dev/null @@ -1,48 +0,0 @@ -#version 450 - -layout(binding = 0, std140) uniform Foo -{ - layout(row_major) mat4 lightVP[64]; - uint shadowCascadesNum; - int test; -} _11; - -layout(location = 0) in vec3 fragWorld; -layout(location = 0) out int _entryPointOutput; - -mat4 GetClip2TexMatrix() -{ - if (_11.test == 0) - { - return mat4(vec4(0.5, 0.0, 0.0, 0.0), vec4(0.0, 0.5, 0.0, 0.0), vec4(0.0, 0.0, 0.5, 0.0), vec4(0.0, 0.0, 0.0, 1.0)); - } - return mat4(vec4(1.0, 0.0, 0.0, 0.0), vec4(0.0, 1.0, 0.0, 0.0), vec4(0.0, 0.0, 1.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0)); -} - -int GetCascade(vec3 fragWorldPosition) -{ - for (uint cascadeIndex = 0u; cascadeIndex < _11.shadowCascadesNum; cascadeIndex++) - { - mat4 worldToShadowMap = GetClip2TexMatrix() * _11.lightVP[cascadeIndex]; - vec4 fragShadowMapPos = worldToShadowMap * vec4(fragWorldPosition, 1.0); - if ((((fragShadowMapPos.z >= 0.0) && (fragShadowMapPos.z <= 1.0)) && (max(fragShadowMapPos.x, fragShadowMapPos.y) <= 1.0)) && (min(fragShadowMapPos.x, fragShadowMapPos.y) >= 0.0)) - { - return int(cascadeIndex); - } - } - return -1; -} - -int _main(vec3 fragWorld_1) -{ - vec3 param = fragWorld_1; - return GetCascade(param); -} - -void main() -{ - vec3 fragWorld_1 = fragWorld; - vec3 param = fragWorld_1; - _entryPointOutput = _main(param); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/asm/frag/multi-for-loop-init.asm.frag b/deps/SPIRV-Cross/reference/shaders/asm/frag/multi-for-loop-init.asm.frag deleted file mode 100644 index b5f30a2471..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/asm/frag/multi-for-loop-init.asm.frag +++ /dev/null @@ -1,19 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(location = 0) out vec4 FragColor; -layout(location = 0) flat in mediump int counter; - -void main() -{ - FragColor = vec4(0.0); - mediump int i = 0; - mediump uint j = 1u; - for (; (i < 10) && (int(j) < int(20u)); i += counter, j += uint(counter)) - { - FragColor += vec4(float(i)); - FragColor += vec4(float(j)); - } -} - diff --git a/deps/SPIRV-Cross/reference/shaders/asm/frag/op-constant-null.asm.frag b/deps/SPIRV-Cross/reference/shaders/asm/frag/op-constant-null.asm.frag deleted file mode 100644 index c4ae981f64..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/asm/frag/op-constant-null.asm.frag +++ /dev/null @@ -1,22 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -struct D -{ - vec4 a; - float b; -}; - -layout(location = 0) out float FragColor; - -void main() -{ - float a = 0.0; - vec4 b = vec4(0.0); - mat2x3 c = mat2x3(vec3(0.0), vec3(0.0)); - D d = D(vec4(0.0), 0.0); - vec4 e[4] = vec4[](vec4(0.0), vec4(0.0), vec4(0.0), vec4(0.0)); - FragColor = a; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/asm/frag/phi-loop-variable.asm.frag b/deps/SPIRV-Cross/reference/shaders/asm/frag/phi-loop-variable.asm.frag deleted file mode 100644 index 786ac74de5..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/asm/frag/phi-loop-variable.asm.frag +++ /dev/null @@ -1,9 +0,0 @@ -#version 450 - -void main() -{ - for (int _22 = 35; _22 >= 0; _22--) - { - } -} - diff --git a/deps/SPIRV-Cross/reference/shaders/asm/frag/sampler-buffer-without-sampler.asm.frag b/deps/SPIRV-Cross/reference/shaders/asm/frag/sampler-buffer-without-sampler.asm.frag deleted file mode 100644 index a4cf078308..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/asm/frag/sampler-buffer-without-sampler.asm.frag +++ /dev/null @@ -1,20 +0,0 @@ -#version 450 - -layout(rgba32f) uniform writeonly imageBuffer RWTex; -uniform samplerBuffer Tex; - -layout(location = 0) out vec4 _entryPointOutput; - -vec4 _main() -{ - vec4 storeTemp = vec4(1.0, 2.0, 3.0, 4.0); - imageStore(RWTex, 20, storeTemp); - return texelFetch(Tex, 10); -} - -void main() -{ - vec4 _28 = _main(); - _entryPointOutput = _28; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/asm/frag/struct-composite-extract-swizzle.asm.frag b/deps/SPIRV-Cross/reference/shaders/asm/frag/struct-composite-extract-swizzle.asm.frag deleted file mode 100644 index b2473f4d03..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/asm/frag/struct-composite-extract-swizzle.asm.frag +++ /dev/null @@ -1,21 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -struct Foo -{ - float var1; - float var2; -}; - -layout(binding = 0) uniform mediump sampler2D uSampler; - -layout(location = 0) out vec4 FragColor; - -Foo _22; - -void main() -{ - FragColor = texture(uSampler, vec2(_22.var1, _22.var2)); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/asm/frag/temporary-phi-hoisting.asm.frag b/deps/SPIRV-Cross/reference/shaders/asm/frag/temporary-phi-hoisting.asm.frag deleted file mode 100644 index 3917594d98..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/asm/frag/temporary-phi-hoisting.asm.frag +++ /dev/null @@ -1,26 +0,0 @@ -#version 450 - -struct MyStruct -{ - vec4 color; -}; - -layout(std140) uniform MyStruct_CB -{ - MyStruct g_MyStruct[4]; -} _6; - -layout(location = 0) out vec4 _entryPointOutput; - -void main() -{ - vec3 _28; - _28 = vec3(0.0); - vec3 _29; - for (int _31 = 0; _31 < 4; _28 = _29, _31++) - { - _29 = _28 + _6.g_MyStruct[_31].color.xyz; - } - _entryPointOutput = vec4(_28, 1.0); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/asm/frag/undef-variable-store.asm.frag b/deps/SPIRV-Cross/reference/shaders/asm/frag/undef-variable-store.asm.frag deleted file mode 100644 index 26ad568ad0..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/asm/frag/undef-variable-store.asm.frag +++ /dev/null @@ -1,29 +0,0 @@ -#version 450 - -layout(location = 0) out vec4 _entryPointOutput; - -vec4 _38; -vec4 _47; - -void main() -{ - vec4 _27; - do - { - vec2 _26 = vec2(0.0); - if (_26.x != 0.0) - { - _27 = vec4(1.0, 0.0, 0.0, 1.0); - break; - } - else - { - _27 = vec4(1.0, 1.0, 0.0, 1.0); - break; - } - _27 = _38; - break; - } while (false); - _entryPointOutput = _27; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/asm/frag/unreachable.asm.frag b/deps/SPIRV-Cross/reference/shaders/asm/frag/unreachable.asm.frag deleted file mode 100644 index 8bc88b9f0a..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/asm/frag/unreachable.asm.frag +++ /dev/null @@ -1,28 +0,0 @@ -#version 450 - -layout(location = 0) flat in int counter; -layout(location = 0) out vec4 FragColor; - -vec4 _21; - -void main() -{ - vec4 _24; - _24 = _21; - vec4 _33; - for (;;) - { - if (counter == 10) - { - _33 = vec4(10.0); - break; - } - else - { - _33 = vec4(30.0); - break; - } - } - FragColor = _33; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/asm/frag/vector-shuffle-oom.asm.frag b/deps/SPIRV-Cross/reference/shaders/asm/frag/vector-shuffle-oom.asm.frag deleted file mode 100644 index 1c211caa6d..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/asm/frag/vector-shuffle-oom.asm.frag +++ /dev/null @@ -1,316 +0,0 @@ -#version 450 - -struct _28 -{ - vec4 _m0; -}; - -layout(binding = 0, std140) uniform _6_7 -{ - vec4 _m0; - float _m1; - vec4 _m2; -} _7; - -layout(binding = 2, std140) uniform _10_11 -{ - vec3 _m0; - vec3 _m1; - float _m2; - vec3 _m3; - float _m4; - vec3 _m5; - float _m6; - vec3 _m7; - float _m8; - vec3 _m9; - float _m10; - vec3 _m11; - float _m12; - vec2 _m13; - vec2 _m14; - vec3 _m15; - float _m16; - float _m17; - float _m18; - float _m19; - float _m20; - vec4 _m21; - vec4 _m22; - layout(row_major) mat4 _m23; - vec4 _m24; -} _11; - -layout(binding = 1, std140) uniform _18_19 -{ - layout(row_major) mat4 _m0; - layout(row_major) mat4 _m1; - layout(row_major) mat4 _m2; - layout(row_major) mat4 _m3; - vec4 _m4; - vec4 _m5; - float _m6; - float _m7; - float _m8; - float _m9; - vec3 _m10; - float _m11; - vec3 _m12; - float _m13; - vec3 _m14; - float _m15; - vec3 _m16; - float _m17; - float _m18; - float _m19; - vec2 _m20; - vec2 _m21; - vec2 _m22; - vec4 _m23; - vec2 _m24; - vec2 _m25; - vec2 _m26; - vec3 _m27; - float _m28; - float _m29; - float _m30; - float _m31; - float _m32; - vec2 _m33; - float _m34; - float _m35; - vec3 _m36; - layout(row_major) mat4 _m37[2]; - vec4 _m38[2]; -} _19; - -uniform sampler2D SPIRV_Cross_Combined; -uniform sampler2D SPIRV_Cross_Combined_1; -uniform sampler2D SPIRV_Cross_Combined_2; - -layout(location = 0) out vec4 _5; - -_28 _74; - -void main() -{ - _28 _77 = _74; - _77._m0 = vec4(0.0); - vec2 _82 = gl_FragCoord.xy * _19._m23.xy; - vec4 _88 = _7._m2 * _7._m0.xyxy; - vec2 _97 = clamp(_82 + (vec3(0.0, -2.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - vec3 _109 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _97, 0.0).w * _7._m1, 0.0, 1.0); - vec4 _113 = textureLod(SPIRV_Cross_Combined_1, _97, 0.0); - vec3 _129; - if (_113.y > 0.0) - { - _129 = _109 + (textureLod(SPIRV_Cross_Combined_2, _97, 0.0).xyz * clamp(_113.y * _113.z, 0.0, 1.0)); - } - else - { - _129 = _109; - } - vec3 _133 = vec4(0.0).xyz + (_129 * 0.5); - vec4 _134 = vec4(_133.x, _133.y, _133.z, vec4(0.0).w); - _28 _135 = _77; - _135._m0 = _134; - vec2 _144 = clamp(_82 + (vec3(-1.0, -1.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - vec3 _156 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _144, 0.0).w * _7._m1, 0.0, 1.0); - vec4 _160 = textureLod(SPIRV_Cross_Combined_1, _144, 0.0); - vec3 _176; - if (_160.y > 0.0) - { - _176 = _156 + (textureLod(SPIRV_Cross_Combined_2, _144, 0.0).xyz * clamp(_160.y * _160.z, 0.0, 1.0)); - } - else - { - _176 = _156; - } - vec3 _180 = _134.xyz + (_176 * 0.5); - vec4 _181 = vec4(_180.x, _180.y, _180.z, _134.w); - _28 _182 = _135; - _182._m0 = _181; - vec2 _191 = clamp(_82 + (vec3(0.0, -1.0, 0.75).xy * _7._m0.xy), _88.xy, _88.zw); - vec3 _203 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _191, 0.0).w * _7._m1, 0.0, 1.0); - vec4 _207 = textureLod(SPIRV_Cross_Combined_1, _191, 0.0); - vec3 _223; - if (_207.y > 0.0) - { - _223 = _203 + (textureLod(SPIRV_Cross_Combined_2, _191, 0.0).xyz * clamp(_207.y * _207.z, 0.0, 1.0)); - } - else - { - _223 = _203; - } - vec3 _227 = _181.xyz + (_223 * 0.75); - vec4 _228 = vec4(_227.x, _227.y, _227.z, _181.w); - _28 _229 = _182; - _229._m0 = _228; - vec2 _238 = clamp(_82 + (vec3(1.0, -1.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - vec3 _250 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _238, 0.0).w * _7._m1, 0.0, 1.0); - vec4 _254 = textureLod(SPIRV_Cross_Combined_1, _238, 0.0); - vec3 _270; - if (_254.y > 0.0) - { - _270 = _250 + (textureLod(SPIRV_Cross_Combined_2, _238, 0.0).xyz * clamp(_254.y * _254.z, 0.0, 1.0)); - } - else - { - _270 = _250; - } - vec3 _274 = _228.xyz + (_270 * 0.5); - vec4 _275 = vec4(_274.x, _274.y, _274.z, _228.w); - _28 _276 = _229; - _276._m0 = _275; - vec2 _285 = clamp(_82 + (vec3(-2.0, 0.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - vec3 _297 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _285, 0.0).w * _7._m1, 0.0, 1.0); - vec4 _301 = textureLod(SPIRV_Cross_Combined_1, _285, 0.0); - vec3 _317; - if (_301.y > 0.0) - { - _317 = _297 + (textureLod(SPIRV_Cross_Combined_2, _285, 0.0).xyz * clamp(_301.y * _301.z, 0.0, 1.0)); - } - else - { - _317 = _297; - } - vec3 _321 = _275.xyz + (_317 * 0.5); - vec4 _322 = vec4(_321.x, _321.y, _321.z, _275.w); - _28 _323 = _276; - _323._m0 = _322; - vec2 _332 = clamp(_82 + (vec3(-1.0, 0.0, 0.75).xy * _7._m0.xy), _88.xy, _88.zw); - vec3 _344 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _332, 0.0).w * _7._m1, 0.0, 1.0); - vec4 _348 = textureLod(SPIRV_Cross_Combined_1, _332, 0.0); - vec3 _364; - if (_348.y > 0.0) - { - _364 = _344 + (textureLod(SPIRV_Cross_Combined_2, _332, 0.0).xyz * clamp(_348.y * _348.z, 0.0, 1.0)); - } - else - { - _364 = _344; - } - vec3 _368 = _322.xyz + (_364 * 0.75); - vec4 _369 = vec4(_368.x, _368.y, _368.z, _322.w); - _28 _370 = _323; - _370._m0 = _369; - vec2 _379 = clamp(_82 + (vec3(0.0, 0.0, 1.0).xy * _7._m0.xy), _88.xy, _88.zw); - vec3 _391 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _379, 0.0).w * _7._m1, 0.0, 1.0); - vec4 _395 = textureLod(SPIRV_Cross_Combined_1, _379, 0.0); - vec3 _411; - if (_395.y > 0.0) - { - _411 = _391 + (textureLod(SPIRV_Cross_Combined_2, _379, 0.0).xyz * clamp(_395.y * _395.z, 0.0, 1.0)); - } - else - { - _411 = _391; - } - vec3 _415 = _369.xyz + (_411 * 1.0); - vec4 _416 = vec4(_415.x, _415.y, _415.z, _369.w); - _28 _417 = _370; - _417._m0 = _416; - vec2 _426 = clamp(_82 + (vec3(1.0, 0.0, 0.75).xy * _7._m0.xy), _88.xy, _88.zw); - vec3 _438 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _426, 0.0).w * _7._m1, 0.0, 1.0); - vec4 _442 = textureLod(SPIRV_Cross_Combined_1, _426, 0.0); - vec3 _458; - if (_442.y > 0.0) - { - _458 = _438 + (textureLod(SPIRV_Cross_Combined_2, _426, 0.0).xyz * clamp(_442.y * _442.z, 0.0, 1.0)); - } - else - { - _458 = _438; - } - vec3 _462 = _416.xyz + (_458 * 0.75); - vec4 _463 = vec4(_462.x, _462.y, _462.z, _416.w); - _28 _464 = _417; - _464._m0 = _463; - vec2 _473 = clamp(_82 + (vec3(2.0, 0.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - vec3 _485 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _473, 0.0).w * _7._m1, 0.0, 1.0); - vec4 _489 = textureLod(SPIRV_Cross_Combined_1, _473, 0.0); - vec3 _505; - if (_489.y > 0.0) - { - _505 = _485 + (textureLod(SPIRV_Cross_Combined_2, _473, 0.0).xyz * clamp(_489.y * _489.z, 0.0, 1.0)); - } - else - { - _505 = _485; - } - vec3 _509 = _463.xyz + (_505 * 0.5); - vec4 _510 = vec4(_509.x, _509.y, _509.z, _463.w); - _28 _511 = _464; - _511._m0 = _510; - vec2 _520 = clamp(_82 + (vec3(-1.0, 1.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - vec3 _532 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _520, 0.0).w * _7._m1, 0.0, 1.0); - vec4 _536 = textureLod(SPIRV_Cross_Combined_1, _520, 0.0); - vec3 _552; - if (_536.y > 0.0) - { - _552 = _532 + (textureLod(SPIRV_Cross_Combined_2, _520, 0.0).xyz * clamp(_536.y * _536.z, 0.0, 1.0)); - } - else - { - _552 = _532; - } - vec3 _556 = _510.xyz + (_552 * 0.5); - vec4 _557 = vec4(_556.x, _556.y, _556.z, _510.w); - _28 _558 = _511; - _558._m0 = _557; - vec2 _567 = clamp(_82 + (vec3(0.0, 1.0, 0.75).xy * _7._m0.xy), _88.xy, _88.zw); - vec3 _579 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _567, 0.0).w * _7._m1, 0.0, 1.0); - vec4 _583 = textureLod(SPIRV_Cross_Combined_1, _567, 0.0); - vec3 _599; - if (_583.y > 0.0) - { - _599 = _579 + (textureLod(SPIRV_Cross_Combined_2, _567, 0.0).xyz * clamp(_583.y * _583.z, 0.0, 1.0)); - } - else - { - _599 = _579; - } - vec3 _603 = _557.xyz + (_599 * 0.75); - vec4 _604 = vec4(_603.x, _603.y, _603.z, _557.w); - _28 _605 = _558; - _605._m0 = _604; - vec2 _614 = clamp(_82 + (vec3(1.0, 1.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - vec3 _626 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _614, 0.0).w * _7._m1, 0.0, 1.0); - vec4 _630 = textureLod(SPIRV_Cross_Combined_1, _614, 0.0); - vec3 _646; - if (_630.y > 0.0) - { - _646 = _626 + (textureLod(SPIRV_Cross_Combined_2, _614, 0.0).xyz * clamp(_630.y * _630.z, 0.0, 1.0)); - } - else - { - _646 = _626; - } - vec3 _650 = _604.xyz + (_646 * 0.5); - vec4 _651 = vec4(_650.x, _650.y, _650.z, _604.w); - _28 _652 = _605; - _652._m0 = _651; - vec2 _661 = clamp(_82 + (vec3(0.0, 2.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - vec3 _673 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _661, 0.0).w * _7._m1, 0.0, 1.0); - vec4 _677 = textureLod(SPIRV_Cross_Combined_1, _661, 0.0); - vec3 _693; - if (_677.y > 0.0) - { - _693 = _673 + (textureLod(SPIRV_Cross_Combined_2, _661, 0.0).xyz * clamp(_677.y * _677.z, 0.0, 1.0)); - } - else - { - _693 = _673; - } - vec3 _697 = _651.xyz + (_693 * 0.5); - vec4 _698 = vec4(_697.x, _697.y, _697.z, _651.w); - _28 _699 = _652; - _699._m0 = _698; - vec3 _702 = _698.xyz / vec3(((((((((((((0.0 + 0.5) + 0.5) + 0.75) + 0.5) + 0.5) + 0.75) + 1.0) + 0.75) + 0.5) + 0.5) + 0.75) + 0.5) + 0.5); - _28 _704 = _699; - _704._m0 = vec4(_702.x, _702.y, _702.z, _698.w); - _28 _705 = _704; - _705._m0.w = 1.0; - _5 = _705._m0; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/asm/tesc/tess-fixed-input-array-builtin-array.asm.tesc b/deps/SPIRV-Cross/reference/shaders/asm/tesc/tess-fixed-input-array-builtin-array.asm.tesc deleted file mode 100644 index 8cb7a4e64c..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/asm/tesc/tess-fixed-input-array-builtin-array.asm.tesc +++ /dev/null @@ -1,79 +0,0 @@ -#version 450 -layout(vertices = 3) out; - -struct VertexOutput -{ - vec4 pos; - vec2 uv; -}; - -struct HSOut -{ - vec4 pos; - vec2 uv; -}; - -struct HSConstantOut -{ - float EdgeTess[3]; - float InsideTess; -}; - -struct VertexOutput_1 -{ - vec2 uv; -}; - -struct HSOut_1 -{ - vec2 uv; -}; - -layout(location = 0) in VertexOutput_1 p[]; -layout(location = 0) out HSOut_1 _entryPointOutput[3]; - -HSOut _hs_main(VertexOutput p_1[3], uint i) -{ - HSOut _output; - _output.pos = p_1[i].pos; - _output.uv = p_1[i].uv; - return _output; -} - -HSConstantOut PatchHS(VertexOutput _patch[3]) -{ - HSConstantOut _output; - _output.EdgeTess[0] = (vec2(1.0) + _patch[0].uv).x; - _output.EdgeTess[1] = (vec2(1.0) + _patch[0].uv).x; - _output.EdgeTess[2] = (vec2(1.0) + _patch[0].uv).x; - _output.InsideTess = (vec2(1.0) + _patch[0].uv).x; - return _output; -} - -void main() -{ - VertexOutput p_1[3]; - p_1[0].pos = gl_in[0].gl_Position; - p_1[0].uv = p[0].uv; - p_1[1].pos = gl_in[1].gl_Position; - p_1[1].uv = p[1].uv; - p_1[2].pos = gl_in[2].gl_Position; - p_1[2].uv = p[2].uv; - uint i = gl_InvocationID; - VertexOutput param[3] = p_1; - uint param_1 = i; - HSOut flattenTemp = _hs_main(param, param_1); - gl_out[gl_InvocationID].gl_Position = flattenTemp.pos; - _entryPointOutput[gl_InvocationID].uv = flattenTemp.uv; - barrier(); - if (int(gl_InvocationID) == 0) - { - VertexOutput param_2[3] = p_1; - HSConstantOut _patchConstantResult = PatchHS(param_2); - gl_TessLevelOuter[0] = _patchConstantResult.EdgeTess[0]; - gl_TessLevelOuter[1] = _patchConstantResult.EdgeTess[1]; - gl_TessLevelOuter[2] = _patchConstantResult.EdgeTess[2]; - gl_TessLevelInner[0] = _patchConstantResult.InsideTess; - } -} - diff --git a/deps/SPIRV-Cross/reference/shaders/asm/vert/empty-io.asm.vert b/deps/SPIRV-Cross/reference/shaders/asm/vert/empty-io.asm.vert deleted file mode 100644 index e1a56d9d4c..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/asm/vert/empty-io.asm.vert +++ /dev/null @@ -1,29 +0,0 @@ -#version 450 - -struct VSInput -{ - vec4 position; -}; - -struct VSOutput -{ - vec4 position; -}; - -layout(location = 0) in vec4 position; - -VSOutput _main(VSInput _input) -{ - VSOutput _out; - _out.position = _input.position; - return _out; -} - -void main() -{ - VSInput _input; - _input.position = position; - VSInput param = _input; - gl_Position = _main(param).position; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/asm/vert/empty-struct-composite.asm.vert b/deps/SPIRV-Cross/reference/shaders/asm/vert/empty-struct-composite.asm.vert deleted file mode 100644 index 05ce10adfa..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/asm/vert/empty-struct-composite.asm.vert +++ /dev/null @@ -1,6 +0,0 @@ -#version 450 - -void main() -{ -} - diff --git a/deps/SPIRV-Cross/reference/shaders/asm/vert/global-builtin.sso.asm.vert b/deps/SPIRV-Cross/reference/shaders/asm/vert/global-builtin.sso.asm.vert deleted file mode 100644 index 7578827019..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/asm/vert/global-builtin.sso.asm.vert +++ /dev/null @@ -1,35 +0,0 @@ -#version 450 - -out gl_PerVertex -{ - vec4 gl_Position; -}; - -struct VSOut -{ - float a; - vec4 pos; -}; - -struct VSOut_1 -{ - float a; -}; - -layout(location = 0) out VSOut_1 _entryPointOutput; - -VSOut _main() -{ - VSOut vout; - vout.a = 40.0; - vout.pos = vec4(1.0); - return vout; -} - -void main() -{ - VSOut flattenTemp = _main(); - _entryPointOutput.a = flattenTemp.a; - gl_Position = flattenTemp.pos; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/comp/atomic.comp b/deps/SPIRV-Cross/reference/shaders/comp/atomic.comp deleted file mode 100644 index 89b1351c0c..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/comp/atomic.comp +++ /dev/null @@ -1,49 +0,0 @@ -#version 310 es -#extension GL_OES_shader_image_atomic : require -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 2, std430) buffer SSBO -{ - uint u32; - int i32; -} ssbo; - -layout(binding = 0, r32ui) uniform highp uimage2D uImage; -layout(binding = 1, r32i) uniform highp iimage2D iImage; - -void main() -{ - uint _19 = imageAtomicAdd(uImage, ivec2(1, 5), 1u); - uint _27 = imageAtomicAdd(uImage, ivec2(1, 5), 1u); - imageStore(iImage, ivec2(1, 6), ivec4(int(_27))); - uint _32 = imageAtomicOr(uImage, ivec2(1, 5), 1u); - uint _34 = imageAtomicXor(uImage, ivec2(1, 5), 1u); - uint _36 = imageAtomicAnd(uImage, ivec2(1, 5), 1u); - uint _38 = imageAtomicMin(uImage, ivec2(1, 5), 1u); - uint _40 = imageAtomicMax(uImage, ivec2(1, 5), 1u); - uint _44 = imageAtomicCompSwap(uImage, ivec2(1, 5), 10u, 2u); - int _47 = imageAtomicAdd(iImage, ivec2(1, 6), 1); - int _49 = imageAtomicOr(iImage, ivec2(1, 6), 1); - int _51 = imageAtomicXor(iImage, ivec2(1, 6), 1); - int _53 = imageAtomicAnd(iImage, ivec2(1, 6), 1); - int _55 = imageAtomicMin(iImage, ivec2(1, 6), 1); - int _57 = imageAtomicMax(iImage, ivec2(1, 6), 1); - int _61 = imageAtomicCompSwap(iImage, ivec2(1, 5), 10, 2); - uint _68 = atomicAdd(ssbo.u32, 1u); - uint _70 = atomicOr(ssbo.u32, 1u); - uint _72 = atomicXor(ssbo.u32, 1u); - uint _74 = atomicAnd(ssbo.u32, 1u); - uint _76 = atomicMin(ssbo.u32, 1u); - uint _78 = atomicMax(ssbo.u32, 1u); - uint _80 = atomicExchange(ssbo.u32, 1u); - uint _82 = atomicCompSwap(ssbo.u32, 10u, 2u); - int _85 = atomicAdd(ssbo.i32, 1); - int _87 = atomicOr(ssbo.i32, 1); - int _89 = atomicXor(ssbo.i32, 1); - int _91 = atomicAnd(ssbo.i32, 1); - int _93 = atomicMin(ssbo.i32, 1); - int _95 = atomicMax(ssbo.i32, 1); - int _97 = atomicExchange(ssbo.i32, 1); - int _99 = atomicCompSwap(ssbo.i32, 10, 2); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/comp/bake_gradient.comp b/deps/SPIRV-Cross/reference/shaders/comp/bake_gradient.comp deleted file mode 100644 index 7b0bb34c64..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/comp/bake_gradient.comp +++ /dev/null @@ -1,39 +0,0 @@ -#version 310 es -layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in; - -layout(binding = 4, std140) uniform UBO -{ - vec4 uInvSize; - vec4 uScale; -} _46; - -layout(binding = 0) uniform mediump sampler2D uHeight; -layout(binding = 1) uniform mediump sampler2D uDisplacement; -layout(binding = 2, rgba16f) uniform writeonly mediump image2D iHeightDisplacement; -layout(binding = 3, rgba16f) uniform writeonly mediump image2D iGradJacobian; - -mediump float jacobian(mediump vec2 dDdx, mediump vec2 dDdy) -{ - return ((1.0 + dDdx.x) * (1.0 + dDdy.y)) - (dDdx.y * dDdy.x); -} - -void main() -{ - vec4 uv = (vec2(gl_GlobalInvocationID.xy) * _46.uInvSize.xy).xyxy + (_46.uInvSize * 0.5); - float h = textureLod(uHeight, uv.xy, 0.0).x; - float x0 = textureLodOffset(uHeight, uv.xy, 0.0, ivec2(-1, 0)).x; - float x1 = textureLodOffset(uHeight, uv.xy, 0.0, ivec2(1, 0)).x; - float y0 = textureLodOffset(uHeight, uv.xy, 0.0, ivec2(0, -1)).x; - float y1 = textureLodOffset(uHeight, uv.xy, 0.0, ivec2(0, 1)).x; - vec2 grad = (_46.uScale.xy * 0.5) * vec2(x1 - x0, y1 - y0); - vec2 displacement = textureLod(uDisplacement, uv.zw, 0.0).xy * 1.2000000476837158203125; - vec2 dDdx = (textureLodOffset(uDisplacement, uv.zw, 0.0, ivec2(1, 0)).xy - textureLodOffset(uDisplacement, uv.zw, 0.0, ivec2(-1, 0)).xy) * 0.60000002384185791015625; - vec2 dDdy = (textureLodOffset(uDisplacement, uv.zw, 0.0, ivec2(0, 1)).xy - textureLodOffset(uDisplacement, uv.zw, 0.0, ivec2(0, -1)).xy) * 0.60000002384185791015625; - vec2 param = dDdx * _46.uScale.z; - vec2 param_1 = dDdy * _46.uScale.z; - float j = jacobian(param, param_1); - displacement = vec2(0.0); - imageStore(iHeightDisplacement, ivec2(gl_GlobalInvocationID.xy), vec4(h, displacement, 0.0)); - imageStore(iGradJacobian, ivec2(gl_GlobalInvocationID.xy), vec4(grad, j, 0.0)); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/comp/barriers.comp b/deps/SPIRV-Cross/reference/shaders/comp/barriers.comp deleted file mode 100644 index a1b975de83..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/comp/barriers.comp +++ /dev/null @@ -1,83 +0,0 @@ -#version 310 es -layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in; - -void barrier_shared() -{ - memoryBarrierShared(); -} - -void full_barrier() -{ - memoryBarrier(); -} - -void image_barrier() -{ - memoryBarrierImage(); -} - -void buffer_barrier() -{ - memoryBarrierBuffer(); -} - -void group_barrier() -{ - groupMemoryBarrier(); -} - -void barrier_shared_exec() -{ - memoryBarrierShared(); - barrier(); -} - -void full_barrier_exec() -{ - memoryBarrier(); - memoryBarrierShared(); - barrier(); -} - -void image_barrier_exec() -{ - memoryBarrierImage(); - memoryBarrierShared(); - barrier(); -} - -void buffer_barrier_exec() -{ - memoryBarrierBuffer(); - memoryBarrierShared(); - barrier(); -} - -void group_barrier_exec() -{ - groupMemoryBarrier(); - memoryBarrierShared(); - barrier(); -} - -void exec_barrier() -{ - memoryBarrierShared(); - barrier(); -} - -void main() -{ - barrier_shared(); - full_barrier(); - image_barrier(); - buffer_barrier(); - group_barrier(); - barrier_shared_exec(); - full_barrier_exec(); - image_barrier_exec(); - buffer_barrier_exec(); - group_barrier_exec(); - exec_barrier(); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/comp/basic.comp b/deps/SPIRV-Cross/reference/shaders/comp/basic.comp deleted file mode 100644 index 1485089951..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/comp/basic.comp +++ /dev/null @@ -1,29 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) readonly buffer SSBO -{ - vec4 in_data[]; -} _23; - -layout(binding = 1, std430) writeonly buffer SSBO2 -{ - vec4 out_data[]; -} _45; - -layout(binding = 2, std430) buffer SSBO3 -{ - uint counter; -} _48; - -void main() -{ - uint ident = gl_GlobalInvocationID.x; - vec4 idata = _23.in_data[ident]; - if (dot(idata, vec4(1.0, 5.0, 6.0, 2.0)) > 8.19999980926513671875) - { - uint _52 = atomicAdd(_48.counter, 1u); - _45.out_data[_52] = idata; - } -} - diff --git a/deps/SPIRV-Cross/reference/shaders/comp/bitfield.noopt.comp b/deps/SPIRV-Cross/reference/shaders/comp/bitfield.noopt.comp deleted file mode 100644 index 49bbddb0ab..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/comp/bitfield.noopt.comp +++ /dev/null @@ -1,19 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -void main() -{ - int signed_value = 0; - uint unsigned_value = 0u; - int s = bitfieldExtract(signed_value, 5, 20); - uint u = bitfieldExtract(unsigned_value, 6, 21); - s = bitfieldInsert(s, 40, 5, 4); - u = bitfieldInsert(u, 60u, 5, 4); - u = bitfieldReverse(u); - s = bitfieldReverse(s); - int v0 = bitCount(u); - int v1 = bitCount(s); - int v2 = findMSB(u); - int v3 = findLSB(s); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/comp/casts.comp b/deps/SPIRV-Cross/reference/shaders/comp/casts.comp deleted file mode 100644 index 973668676a..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/comp/casts.comp +++ /dev/null @@ -1,19 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 1, std430) buffer SSBO1 -{ - ivec4 outputs[]; -} _21; - -layout(binding = 0, std430) buffer SSBO0 -{ - ivec4 inputs[]; -} _27; - -void main() -{ - uint ident = gl_GlobalInvocationID.x; - _21.outputs[ident] = mix(ivec4(0), ivec4(1), notEqual((_27.inputs[ident] & ivec4(3)), ivec4(uvec4(0u)))); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/comp/cfg-preserve-parameter.comp b/deps/SPIRV-Cross/reference/shaders/comp/cfg-preserve-parameter.comp deleted file mode 100644 index 72bde44a90..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/comp/cfg-preserve-parameter.comp +++ /dev/null @@ -1,74 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -void out_test_0(int cond, out int i) -{ - if (cond == 0) - { - i = 40; - } - else - { - i = 60; - } -} - -void out_test_1(int cond, out int i) -{ - switch (cond) - { - case 40: - { - i = 40; - break; - } - default: - { - i = 70; - break; - } - } -} - -void inout_test_0(int cond, inout int i) -{ - if (cond == 0) - { - i = 40; - } -} - -void inout_test_1(int cond, inout int i) -{ - switch (cond) - { - case 40: - { - i = 40; - break; - } - } -} - -void main() -{ - int cond = 40; - int i = 50; - int param = cond; - int param_1 = i; - out_test_0(param, param_1); - i = param_1; - int param_2 = cond; - int param_3 = i; - out_test_1(param_2, param_3); - i = param_3; - int param_4 = cond; - int param_5 = i; - inout_test_0(param_4, param_5); - i = param_5; - int param_6 = cond; - int param_7 = i; - inout_test_1(param_6, param_7); - i = param_7; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/comp/cfg.comp b/deps/SPIRV-Cross/reference/shaders/comp/cfg.comp deleted file mode 100644 index 77ad312cda..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/comp/cfg.comp +++ /dev/null @@ -1,81 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) buffer SSBO -{ - float data; -} _11; - -void test() -{ - if (_11.data != 0.0) - { - float tmp = 10.0; - _11.data = tmp; - } - else - { - float tmp_1 = 15.0; - _11.data = tmp_1; - } - if (_11.data != 0.0) - { - float e; - if (_11.data != 5.0) - { - if (_11.data != 6.0) - { - e = 10.0; - } - } - else - { - e = 20.0; - } - } - switch (int(_11.data)) - { - case 0: - { - float tmp_2 = 20.0; - _11.data = tmp_2; - break; - } - case 1: - { - float tmp_3 = 30.0; - _11.data = tmp_3; - break; - } - } - float f; - switch (int(_11.data)) - { - case 0: - { - f = 30.0; - break; - } - case 1: - { - f = 40.0; - break; - } - } - float h; - for (int i = 0; i < 20; i++, h += 10.0) - { - } - _11.data = h; - float m; - do - { - } while (m != 20.0); - _11.data = m; -} - -void main() -{ - test(); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/comp/coherent-block.comp b/deps/SPIRV-Cross/reference/shaders/comp/coherent-block.comp deleted file mode 100644 index bfab6bbea8..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/comp/coherent-block.comp +++ /dev/null @@ -1,13 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 1, std430) coherent restrict writeonly buffer SSBO -{ - vec4 value; -} _10; - -void main() -{ - _10.value = vec4(20.0); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/comp/coherent-image.comp b/deps/SPIRV-Cross/reference/shaders/comp/coherent-image.comp deleted file mode 100644 index b3992f242e..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/comp/coherent-image.comp +++ /dev/null @@ -1,15 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 1, std430) coherent restrict writeonly buffer SSBO -{ - ivec4 value; -} _10; - -layout(binding = 3, r32i) uniform coherent restrict readonly mediump iimage2D uImage; - -void main() -{ - _10.value = imageLoad(uImage, ivec2(10)); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/comp/composite-construct.comp b/deps/SPIRV-Cross/reference/shaders/comp/composite-construct.comp deleted file mode 100644 index 91bb5348f5..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/comp/composite-construct.comp +++ /dev/null @@ -1,38 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -struct Composite -{ - vec4 a[2]; - vec4 b[2]; -}; - -layout(binding = 0, std430) buffer SSBO0 -{ - vec4 as[]; -} _41; - -layout(binding = 1, std430) buffer SSBO1 -{ - vec4 bs[]; -} _55; - -vec4 summe(vec4 values[3][2]) -{ - return ((values[0][0] + values[2][1]) + values[0][1]) + values[1][0]; -} - -void main() -{ - vec4 values[2] = vec4[](_41.as[gl_GlobalInvocationID.x], _55.bs[gl_GlobalInvocationID.x]); - vec4 const_values[2] = vec4[](vec4(10.0), vec4(30.0)); - vec4 copy_values[2] = const_values; - vec4 copy_values2[2] = values; - vec4 param[3][2] = vec4[][](values, copy_values, copy_values2); - _41.as[gl_GlobalInvocationID.x] = summe(param); - Composite c = Composite(values, copy_values); - float arrayofarray[2][3] = float[][](float[](1.0, 1.0, 1.0), float[](2.0, 2.0, 2.0)); - float b = 10.0; - float values_scalar[4] = float[](b, b, b, b); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/comp/culling.comp b/deps/SPIRV-Cross/reference/shaders/comp/culling.comp deleted file mode 100644 index fd83bfcb5b..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/comp/culling.comp +++ /dev/null @@ -1,29 +0,0 @@ -#version 310 es -layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) readonly buffer SSBO -{ - float in_data[]; -} _22; - -layout(binding = 1, std430) writeonly buffer SSBO2 -{ - float out_data[]; -} _38; - -layout(binding = 2, std430) buffer SSBO3 -{ - uint count; -} _41; - -void main() -{ - uint ident = gl_GlobalInvocationID.x; - float idata = _22.in_data[ident]; - if (idata > 12.0) - { - uint _45 = atomicAdd(_41.count, 1u); - _38.out_data[_45] = idata; - } -} - diff --git a/deps/SPIRV-Cross/reference/shaders/comp/defer-parens.comp b/deps/SPIRV-Cross/reference/shaders/comp/defer-parens.comp deleted file mode 100644 index cf98529316..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/comp/defer-parens.comp +++ /dev/null @@ -1,21 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) buffer SSBO -{ - vec4 data; - int index; -} _13; - -void main() -{ - vec4 d = _13.data; - _13.data = vec4(d.x, d.yz + vec2(10.0), d.w); - _13.data = (d + d) + d; - _13.data = (d.yz + vec2(10.0)).xxyy; - float t = (d.yz + vec2(10.0)).y; - _13.data = vec4(t); - t = (d.zw + vec2(10.0))[_13.index]; - _13.data = vec4(t); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/comp/dowhile.comp b/deps/SPIRV-Cross/reference/shaders/comp/dowhile.comp deleted file mode 100644 index e717961abd..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/comp/dowhile.comp +++ /dev/null @@ -1,29 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) readonly buffer SSBO -{ - mat4 mvp; - vec4 in_data[]; -} _28; - -layout(binding = 1, std430) writeonly buffer SSBO2 -{ - vec4 out_data[]; -} _52; - -int i; - -void main() -{ - uint ident = gl_GlobalInvocationID.x; - i = 0; - vec4 idat = _28.in_data[ident]; - do - { - idat = _28.mvp * idat; - i++; - } while (i < 16); - _52.out_data[ident] = idat; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/comp/generate_height.comp b/deps/SPIRV-Cross/reference/shaders/comp/generate_height.comp deleted file mode 100644 index 30ec624cfb..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/comp/generate_height.comp +++ /dev/null @@ -1,96 +0,0 @@ -#version 310 es -layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) readonly buffer Distribution -{ - vec2 distribution[]; -} _136; - -layout(binding = 2, std140) uniform UBO -{ - vec4 uModTime; -} _165; - -layout(binding = 1, std430) writeonly buffer HeightmapFFT -{ - uint heights[]; -} _224; - -uvec2 workaround_mix(uvec2 a, uvec2 b, bvec2 sel) -{ - uint _83; - if (sel.x) - { - _83 = b.x; - } - else - { - _83 = a.x; - } - uint _93 = _83; - uint _94; - if (sel.y) - { - _94 = b.y; - } - else - { - _94 = a.y; - } - return uvec2(_93, _94); -} - -vec2 alias(vec2 i, vec2 N) -{ - return mix(i, i - N, greaterThan(i, N * 0.5)); -} - -vec2 cmul(vec2 a, vec2 b) -{ - vec2 r3 = a.yx; - vec2 r1 = b.xx; - vec2 R0 = a * r1; - vec2 r2 = b.yy; - vec2 R1 = r2 * r3; - return R0 + vec2(-R1.x, R1.y); -} - -uint pack2(vec2 v) -{ - return packHalf2x16(v); -} - -void generate_heightmap() -{ - uvec2 N = uvec2(64u, 1u) * gl_NumWorkGroups.xy; - uvec2 i = gl_GlobalInvocationID.xy; - uvec2 param = N - i; - uvec2 param_1 = uvec2(0u); - bvec2 param_2 = equal(i, uvec2(0u)); - uvec2 wi = workaround_mix(param, param_1, param_2); - vec2 a = _136.distribution[(i.y * N.x) + i.x]; - vec2 b = _136.distribution[(wi.y * N.x) + wi.x]; - vec2 param_3 = vec2(i); - vec2 param_4 = vec2(N); - vec2 k = _165.uModTime.xy * alias(param_3, param_4); - float k_len = length(k); - float w = sqrt(9.81000041961669921875 * k_len) * _165.uModTime.z; - float cw = cos(w); - float sw = sin(w); - vec2 param_5 = a; - vec2 param_6 = vec2(cw, sw); - a = cmul(param_5, param_6); - vec2 param_7 = b; - vec2 param_8 = vec2(cw, sw); - b = cmul(param_7, param_8); - b = vec2(b.x, -b.y); - vec2 res = a + b; - vec2 param_9 = res; - _224.heights[(i.y * N.x) + i.x] = pack2(param_9); -} - -void main() -{ - generate_heightmap(); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/comp/image.comp b/deps/SPIRV-Cross/reference/shaders/comp/image.comp deleted file mode 100644 index b2bf0d65bb..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/comp/image.comp +++ /dev/null @@ -1,12 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, rgba8) uniform readonly mediump image2D uImageIn; -layout(binding = 1, rgba8) uniform writeonly mediump image2D uImageOut; - -void main() -{ - vec4 v = imageLoad(uImageIn, ivec2(gl_GlobalInvocationID.xy) + imageSize(uImageIn)); - imageStore(uImageOut, ivec2(gl_GlobalInvocationID.xy), v); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/comp/inout-struct.invalid.comp b/deps/SPIRV-Cross/reference/shaders/comp/inout-struct.invalid.comp deleted file mode 100644 index 640e25bb95..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/comp/inout-struct.invalid.comp +++ /dev/null @@ -1,65 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -struct Foo -{ - vec4 a; - vec4 b; - vec4 c; - vec4 d; -}; - -layout(binding = 1, std430) readonly buffer SSBO2 -{ - vec4 data[]; -} indata; - -layout(binding = 0, std430) writeonly buffer SSBO -{ - vec4 data[]; -} outdata; - -layout(binding = 2, std430) readonly buffer SSBO3 -{ - Foo foos[]; -} foobar; - -void baz(inout Foo foo) -{ - uint ident = gl_GlobalInvocationID.x; - foo.a = indata.data[(4u * ident) + 0u]; - foo.b = indata.data[(4u * ident) + 1u]; - foo.c = indata.data[(4u * ident) + 2u]; - foo.d = indata.data[(4u * ident) + 3u]; -} - -void meow(inout Foo foo) -{ - foo.a += vec4(10.0); - foo.b += vec4(20.0); - foo.c += vec4(30.0); - foo.d += vec4(40.0); -} - -vec4 bar(Foo foo) -{ - return ((foo.a + foo.b) + foo.c) + foo.d; -} - -void main() -{ - Foo param; - baz(param); - Foo foo = param; - Foo param_1 = foo; - meow(param_1); - foo = param_1; - Foo param_2 = foo; - Foo param_3; - param_3.a = foobar.foos[gl_GlobalInvocationID.x].a; - param_3.b = foobar.foos[gl_GlobalInvocationID.x].b; - param_3.c = foobar.foos[gl_GlobalInvocationID.x].c; - param_3.d = foobar.foos[gl_GlobalInvocationID.x].d; - outdata.data[gl_GlobalInvocationID.x] = bar(param_2) + bar(param_3); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/comp/insert.comp b/deps/SPIRV-Cross/reference/shaders/comp/insert.comp deleted file mode 100644 index cbe1e27f45..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/comp/insert.comp +++ /dev/null @@ -1,19 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) writeonly buffer SSBO -{ - vec4 out_data[]; -} _27; - -void main() -{ - vec4 v; - v.x = 10.0; - v.y = 30.0; - v.z = 70.0; - v.w = 90.0; - _27.out_data[gl_GlobalInvocationID.x] = v; - _27.out_data[gl_GlobalInvocationID.x].y = 20.0; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/comp/loop.noopt.comp b/deps/SPIRV-Cross/reference/shaders/comp/loop.noopt.comp deleted file mode 100644 index 049a30669c..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/comp/loop.noopt.comp +++ /dev/null @@ -1,105 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) readonly buffer SSBO -{ - mat4 mvp; - vec4 in_data[]; -} _24; - -layout(binding = 1, std430) writeonly buffer SSBO2 -{ - vec4 out_data[]; -} _177; - -void main() -{ - uint ident = gl_GlobalInvocationID.x; - vec4 idat = _24.in_data[ident]; - int k = 0; - uint i = 0u; - if (idat.y == 20.0) - { - do - { - k *= 2; - i++; - } while (i < ident); - } - switch (k) - { - case 10: - { - for (;;) - { - i++; - if (i > 10u) - { - break; - } - continue; - } - break; - } - default: - { - for (;;) - { - i += 2u; - if (i > 20u) - { - break; - } - continue; - } - break; - } - } - while (k < 10) - { - idat *= 2.0; - k++; - } - for (uint i_1 = 0u; i_1 < 16u; i_1++, k++) - { - for (uint j = 0u; j < 30u; j++) - { - idat = _24.mvp * idat; - } - } - k = 0; - for (;;) - { - k++; - if (k > 10) - { - k += 2; - } - else - { - k += 3; - continue; - } - k += 10; - continue; - } - k = 0; - do - { - k++; - } while (k > 10); - int l = 0; - for (;;) - { - if (l == 5) - { - l++; - continue; - } - idat += vec4(1.0); - l++; - continue; - } - _177.out_data[ident] = idat; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/comp/mat3.comp b/deps/SPIRV-Cross/reference/shaders/comp/mat3.comp deleted file mode 100644 index 2b050f5d01..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/comp/mat3.comp +++ /dev/null @@ -1,14 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 1, std430) writeonly buffer SSBO2 -{ - mat3 out_data[]; -} _22; - -void main() -{ - uint ident = gl_GlobalInvocationID.x; - _22.out_data[ident] = mat3(vec3(10.0), vec3(20.0), vec3(40.0)); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/comp/mod.comp b/deps/SPIRV-Cross/reference/shaders/comp/mod.comp deleted file mode 100644 index 4be0c5f7f4..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/comp/mod.comp +++ /dev/null @@ -1,24 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) readonly buffer SSBO -{ - vec4 in_data[]; -} _23; - -layout(binding = 1, std430) writeonly buffer SSBO2 -{ - vec4 out_data[]; -} _33; - -void main() -{ - uint ident = gl_GlobalInvocationID.x; - vec4 v = mod(_23.in_data[ident], _33.out_data[ident]); - _33.out_data[ident] = v; - uvec4 vu = floatBitsToUint(_23.in_data[ident]) % floatBitsToUint(_33.out_data[ident]); - _33.out_data[ident] = uintBitsToFloat(vu); - ivec4 vi = floatBitsToInt(_23.in_data[ident]) % floatBitsToInt(_33.out_data[ident]); - _33.out_data[ident] = intBitsToFloat(vi); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/comp/modf.comp b/deps/SPIRV-Cross/reference/shaders/comp/modf.comp deleted file mode 100644 index c92149bf94..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/comp/modf.comp +++ /dev/null @@ -1,22 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) readonly buffer SSBO -{ - vec4 in_data[]; -} _23; - -layout(binding = 1, std430) writeonly buffer SSBO2 -{ - vec4 out_data[]; -} _35; - -void main() -{ - uint ident = gl_GlobalInvocationID.x; - vec4 i; - vec4 _31 = modf(_23.in_data[ident], i); - vec4 v = _31; - _35.out_data[ident] = v; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/comp/read-write-only.comp b/deps/SPIRV-Cross/reference/shaders/comp/read-write-only.comp deleted file mode 100644 index 06227ee2c6..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/comp/read-write-only.comp +++ /dev/null @@ -1,27 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 2, std430) restrict writeonly buffer SSBO2 -{ - vec4 data4; - vec4 data5; -} _10; - -layout(binding = 0, std430) readonly buffer SSBO0 -{ - vec4 data0; - vec4 data1; -} _15; - -layout(binding = 1, std430) restrict buffer SSBO1 -{ - vec4 data2; - vec4 data3; -} _21; - -void main() -{ - _10.data4 = _15.data0 + _21.data2; - _10.data5 = _15.data1 + _21.data3; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/comp/return.comp b/deps/SPIRV-Cross/reference/shaders/comp/return.comp deleted file mode 100644 index 4be20e93e4..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/comp/return.comp +++ /dev/null @@ -1,34 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 1, std430) writeonly buffer SSBO2 -{ - vec4 out_data[]; -} _27; - -void main() -{ - uint ident = gl_GlobalInvocationID.x; - if (ident == 2u) - { - _27.out_data[ident] = vec4(20.0); - } - else - { - if (ident == 4u) - { - _27.out_data[ident] = vec4(10.0); - return; - } - } - for (int i = 0; i < 20; i++) - { - if (i == 10) - { - break; - } - return; - } - _27.out_data[ident] = vec4(10.0); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/comp/rmw-opt.comp b/deps/SPIRV-Cross/reference/shaders/comp/rmw-opt.comp deleted file mode 100644 index e3fba7810d..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/comp/rmw-opt.comp +++ /dev/null @@ -1,27 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) buffer SSBO -{ - int a; -} _9; - -void main() -{ - _9.a += 10; - _9.a -= 10; - _9.a *= 10; - _9.a /= 10; - _9.a = _9.a << 2; - _9.a = _9.a >> 3; - _9.a &= 40; - _9.a ^= 10; - _9.a %= 40; - _9.a |= 1; - bool c = false; - bool d = true; - c = c && d; - d = d || c; - _9.a = int(c && d); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/comp/shared.comp b/deps/SPIRV-Cross/reference/shaders/comp/shared.comp deleted file mode 100644 index d0987a6528..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/comp/shared.comp +++ /dev/null @@ -1,25 +0,0 @@ -#version 310 es -layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) readonly buffer SSBO -{ - float in_data[]; -} _22; - -layout(binding = 1, std430) writeonly buffer SSBO2 -{ - float out_data[]; -} _44; - -shared float sShared[4]; - -void main() -{ - uint ident = gl_GlobalInvocationID.x; - float idata = _22.in_data[ident]; - sShared[gl_LocalInvocationIndex] = idata; - memoryBarrierShared(); - barrier(); - _44.out_data[ident] = sShared[(4u - gl_LocalInvocationIndex) - 1u]; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/comp/ssbo-array.comp b/deps/SPIRV-Cross/reference/shaders/comp/ssbo-array.comp deleted file mode 100644 index e773bd093c..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/comp/ssbo-array.comp +++ /dev/null @@ -1,14 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) buffer SSBO -{ - vec4 data[]; -} ssbos[2]; - -void main() -{ - uint ident = gl_GlobalInvocationID.x; - ssbos[1].data[ident] = ssbos[0].data[ident]; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/comp/struct-layout.comp b/deps/SPIRV-Cross/reference/shaders/comp/struct-layout.comp deleted file mode 100644 index 4feea8be54..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/comp/struct-layout.comp +++ /dev/null @@ -1,24 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -struct Foo -{ - mat4 m; -}; - -layout(binding = 1, std430) writeonly buffer SSBO2 -{ - Foo out_data[]; -} _23; - -layout(binding = 0, std430) readonly buffer SSBO -{ - Foo in_data[]; -} _30; - -void main() -{ - uint ident = gl_GlobalInvocationID.x; - _23.out_data[ident].m = _30.in_data[ident].m * _30.in_data[ident].m; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/comp/struct-packing.comp b/deps/SPIRV-Cross/reference/shaders/comp/struct-packing.comp deleted file mode 100644 index 3c30aa6088..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/comp/struct-packing.comp +++ /dev/null @@ -1,104 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -struct S0 -{ - vec2 a[1]; - float b; -}; - -struct S1 -{ - vec3 a; - float b; -}; - -struct S2 -{ - vec3 a[1]; - float b; -}; - -struct S3 -{ - vec2 a; - float b; -}; - -struct S4 -{ - vec2 c; -}; - -struct Content -{ - S0 m0s[1]; - S1 m1s[1]; - S2 m2s[1]; - S0 m0; - S1 m1; - S2 m2; - S3 m3; - float m4; - S4 m3s[8]; -}; - -layout(binding = 1, std430) buffer SSBO1 -{ - Content content; - Content content1[2]; - Content content2; - mat2 m0; - mat2 m1; - mat2x3 m2[4]; - mat3x2 m3; - layout(row_major) mat2 m4; - layout(row_major) mat2 m5[9]; - layout(row_major) mat2x3 m6[4][2]; - layout(row_major) mat3x2 m7; - float array[]; -} ssbo_430; - -layout(binding = 0, std140) buffer SSBO0 -{ - Content content; - Content content1[2]; - Content content2; - mat2 m0; - mat2 m1; - mat2x3 m2[4]; - mat3x2 m3; - layout(row_major) mat2 m4; - layout(row_major) mat2 m5[9]; - layout(row_major) mat2x3 m6[4][2]; - layout(row_major) mat3x2 m7; - float array[]; -} ssbo_140; - -void main() -{ - ssbo_430.content.m0s[0].a[0] = ssbo_140.content.m0s[0].a[0]; - ssbo_430.content.m0s[0].b = ssbo_140.content.m0s[0].b; - ssbo_430.content.m1s[0].a = ssbo_140.content.m1s[0].a; - ssbo_430.content.m1s[0].b = ssbo_140.content.m1s[0].b; - ssbo_430.content.m2s[0].a[0] = ssbo_140.content.m2s[0].a[0]; - ssbo_430.content.m2s[0].b = ssbo_140.content.m2s[0].b; - ssbo_430.content.m0.a[0] = ssbo_140.content.m0.a[0]; - ssbo_430.content.m0.b = ssbo_140.content.m0.b; - ssbo_430.content.m1.a = ssbo_140.content.m1.a; - ssbo_430.content.m1.b = ssbo_140.content.m1.b; - ssbo_430.content.m2.a[0] = ssbo_140.content.m2.a[0]; - ssbo_430.content.m2.b = ssbo_140.content.m2.b; - ssbo_430.content.m3.a = ssbo_140.content.m3.a; - ssbo_430.content.m3.b = ssbo_140.content.m3.b; - ssbo_430.content.m4 = ssbo_140.content.m4; - ssbo_430.content.m3s[0].c = ssbo_140.content.m3s[0].c; - ssbo_430.content.m3s[1].c = ssbo_140.content.m3s[1].c; - ssbo_430.content.m3s[2].c = ssbo_140.content.m3s[2].c; - ssbo_430.content.m3s[3].c = ssbo_140.content.m3s[3].c; - ssbo_430.content.m3s[4].c = ssbo_140.content.m3s[4].c; - 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; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/comp/torture-loop.comp b/deps/SPIRV-Cross/reference/shaders/comp/torture-loop.comp deleted file mode 100644 index 645af5c374..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/comp/torture-loop.comp +++ /dev/null @@ -1,49 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) readonly buffer SSBO -{ - mat4 mvp; - vec4 in_data[]; -} _24; - -layout(binding = 1, std430) writeonly buffer SSBO2 -{ - vec4 out_data[]; -} _89; - -void main() -{ - uint ident = gl_GlobalInvocationID.x; - vec4 idat = _24.in_data[ident]; - int k = 0; - for (;;) - { - int _39 = k; - int _40 = _39 + 1; - k = _40; - if (_40 < 10) - { - idat *= 2.0; - k++; - continue; - } - else - { - break; - } - } - for (uint i = 0u; i < 16u; i++, k++) - { - for (uint j = 0u; j < 30u; j++) - { - idat = _24.mvp * idat; - } - } - do - { - k++; - } while (k > 10); - _89.out_data[ident] = idat; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/comp/type-alias.comp b/deps/SPIRV-Cross/reference/shaders/comp/type-alias.comp deleted file mode 100644 index 51f3792e1a..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/comp/type-alias.comp +++ /dev/null @@ -1,49 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -struct S0 -{ - vec4 a; -}; - -struct S1 -{ - vec4 a; -}; - -layout(binding = 0, std430) buffer SSBO0 -{ - S0 s0s[]; -} _36; - -layout(binding = 1, std430) buffer SSBO1 -{ - S1 s1s[]; -} _55; - -layout(binding = 2, std430) buffer SSBO2 -{ - vec4 outputs[]; -} _66; - -vec4 overload(S0 s0) -{ - return s0.a; -} - -vec4 overload(S1 s1) -{ - return s1.a; -} - -void main() -{ - S0 s0; - s0.a = _36.s0s[gl_GlobalInvocationID.x].a; - S1 s1; - s1.a = _55.s1s[gl_GlobalInvocationID.x].a; - S0 param = s0; - S1 param_1 = s1; - _66.outputs[gl_GlobalInvocationID.x] = overload(param) + overload(param_1); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/comp/udiv.comp b/deps/SPIRV-Cross/reference/shaders/comp/udiv.comp deleted file mode 100644 index 0c1f926ad0..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/comp/udiv.comp +++ /dev/null @@ -1,18 +0,0 @@ -#version 310 es -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, std430) buffer SSBO2 -{ - uint outputs[]; -} _10; - -layout(binding = 0, std430) buffer SSBO -{ - uint inputs[]; -} _23; - -void main() -{ - _10.outputs[gl_GlobalInvocationID.x] = _23.inputs[gl_GlobalInvocationID.x] / 29u; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/desktop-only/comp/enhanced-layouts.comp b/deps/SPIRV-Cross/reference/shaders/desktop-only/comp/enhanced-layouts.comp deleted file mode 100644 index ba37ca237b..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/desktop-only/comp/enhanced-layouts.comp +++ /dev/null @@ -1,40 +0,0 @@ -#version 450 -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -struct Foo -{ - int a; - int b; - int c; -}; - -layout(binding = 1, std140) buffer SSBO1 -{ - layout(offset = 4) int a; - layout(offset = 8) int b; - layout(offset = 16) Foo foo; - layout(offset = 48) int c[8]; -} ssbo1; - -layout(binding = 2, std430) buffer SSBO2 -{ - layout(offset = 4) int a; - layout(offset = 8) int b; - layout(offset = 16) Foo foo; - layout(offset = 48) int c[8]; -} ssbo2; - -layout(binding = 0, std140) uniform UBO -{ - layout(offset = 4) int a; - layout(offset = 8) int b; - layout(offset = 16) Foo foo; - layout(offset = 48) int c[8]; -} ubo; - -void main() -{ - ssbo1.a = ssbo2.a; - ssbo1.b = ubo.b; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/desktop-only/comp/fp64.desktop.comp b/deps/SPIRV-Cross/reference/shaders/desktop-only/comp/fp64.desktop.comp deleted file mode 100644 index 18869eda52..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/desktop-only/comp/fp64.desktop.comp +++ /dev/null @@ -1,84 +0,0 @@ -#version 450 -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -struct M0 -{ - double v; - dvec2 b[2]; - dmat2x3 c; - dmat3x2 d; -}; - -layout(binding = 0, std430) buffer SSBO0 -{ - dvec4 a; - M0 m0; - dmat4 b; -} ssbo_0; - -layout(binding = 1, std430) buffer SSBO1 -{ - dmat4 a; - dvec4 b; - M0 m0; -} ssbo_1; - -layout(binding = 2, std430) buffer SSBO2 -{ - double a[4]; - dvec2 b[4]; -} ssbo_2; - -layout(binding = 3, std140) buffer SSBO3 -{ - double a[4]; - dvec2 b[4]; -} ssbo_3; - -void main() -{ - ssbo_0.a += dvec4(10.0lf, 20.0lf, 30.0lf, 40.0lf); - ssbo_0.a += dvec4(20.0lf); - dvec4 a = ssbo_0.a; - dmat4 amat = ssbo_0.b; - ssbo_0.a = abs(a); - ssbo_0.a = sign(a); - ssbo_0.a = floor(a); - ssbo_0.a = trunc(a); - ssbo_0.a = round(a); - ssbo_0.a = roundEven(a); - ssbo_0.a = ceil(a); - ssbo_0.a = fract(a); - ssbo_0.a = mod(a, dvec4(20.0lf)); - ssbo_0.a = mod(a, a); - ssbo_0.a = min(a, a); - ssbo_0.a = max(a, a); - ssbo_0.a = clamp(a, a, a); - ssbo_0.a = mix(a, a, a); - ssbo_0.a = step(a, a); - ssbo_0.a = smoothstep(a, a, a); - bvec4 b = isnan(a); - bvec4 c = isinf(a); - double f = packDouble2x32(uvec2(10u, 40u)); - uvec2 g = unpackDouble2x32(f); - double d = length(a); - d = distance(a, a); - d = dot(a, a); - dvec3 e = cross(a.xyz, a.yzw); - a = faceforward(a, a, a); - a = reflect(a, a); - a = refract(a, a, a.x); - dmat4 l = dmat4(amat[0] * amat[0], amat[1] * amat[1], amat[2] * amat[2], amat[3] * amat[3]); - l = outerProduct(a, a); - l = transpose(l); - double m = determinant(l); - l = inverse(l); - bvec4 k = lessThan(a, a); - k = lessThanEqual(a, a); - k = greaterThan(a, a); - k = greaterThanEqual(a, a); - ssbo_1.b.x += 1.0lf; - ssbo_2.b[0].x += 1.0lf; - ssbo_3.b[0].x += 1.0lf; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/desktop-only/comp/image-formats.desktop.noeliminate.comp b/deps/SPIRV-Cross/reference/shaders/desktop-only/comp/image-formats.desktop.noeliminate.comp deleted file mode 100644 index 7a0797578b..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/desktop-only/comp/image-formats.desktop.noeliminate.comp +++ /dev/null @@ -1,47 +0,0 @@ -#version 450 -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 0, rgba32f) uniform readonly writeonly image2D uImg00; -layout(binding = 1, rgba16f) uniform readonly writeonly image2D uImg01; -layout(binding = 2, rg32f) uniform readonly writeonly image2D uImg02; -layout(binding = 3, rg16f) uniform readonly writeonly image2D uImg03; -layout(binding = 4, r11f_g11f_b10f) uniform readonly writeonly image2D uImg04; -layout(binding = 5, r32f) uniform readonly writeonly image2D uImg05; -layout(binding = 6, r16f) uniform readonly writeonly image2D uImg06; -layout(binding = 7, rgba16) uniform readonly writeonly image2D uImg07; -layout(binding = 8, rgb10_a2) uniform readonly writeonly image2D uImg08; -layout(binding = 9, rgba8) uniform readonly writeonly image2D uImg09; -layout(binding = 10, rg16) uniform readonly writeonly image2D uImg10; -layout(binding = 11, rg8) uniform readonly writeonly image2D uImg11; -layout(binding = 12, r16) uniform readonly writeonly image2D uImg12; -layout(binding = 13, r8) uniform readonly writeonly image2D uImg13; -layout(binding = 14, rgba16_snorm) uniform readonly writeonly image2D uImg14; -layout(binding = 15, rgba8_snorm) uniform readonly writeonly image2D uImg15; -layout(binding = 16, rg16_snorm) uniform readonly writeonly image2D uImg16; -layout(binding = 17, rg8_snorm) uniform readonly writeonly image2D uImg17; -layout(binding = 18, r16_snorm) uniform readonly writeonly image2D uImg18; -layout(binding = 19, r8_snorm) uniform readonly writeonly image2D uImg19; -layout(binding = 20, rgba32i) uniform readonly writeonly iimage2D uImage20; -layout(binding = 21, rgba16i) uniform readonly writeonly iimage2D uImage21; -layout(binding = 22, rgba8i) uniform readonly writeonly iimage2D uImage22; -layout(binding = 23, rg32i) uniform readonly writeonly iimage2D uImage23; -layout(binding = 24, rg16i) uniform readonly writeonly iimage2D uImage24; -layout(binding = 25, rg8i) uniform readonly writeonly iimage2D uImage25; -layout(binding = 26, r32i) uniform readonly writeonly iimage2D uImage26; -layout(binding = 27, r16i) uniform readonly writeonly iimage2D uImage27; -layout(binding = 28, r8i) uniform readonly writeonly iimage2D uImage28; -layout(binding = 29, rgba32ui) uniform readonly writeonly uimage2D uImage29; -layout(binding = 30, rgba16ui) uniform readonly writeonly uimage2D uImage30; -layout(binding = 31, rgb10_a2ui) uniform readonly writeonly uimage2D uImage31; -layout(binding = 32, rgba8ui) uniform readonly writeonly uimage2D uImage32; -layout(binding = 33, rg32ui) uniform readonly writeonly uimage2D uImage33; -layout(binding = 34, rg16ui) uniform readonly writeonly uimage2D uImage34; -layout(binding = 35, rg8ui) uniform readonly writeonly uimage2D uImage35; -layout(binding = 36, r32ui) uniform readonly writeonly uimage2D uImage36; -layout(binding = 37, r16ui) uniform readonly writeonly uimage2D uImage37; -layout(binding = 38, r8ui) uniform readonly writeonly uimage2D uImage38; - -void main() -{ -} - diff --git a/deps/SPIRV-Cross/reference/shaders/desktop-only/comp/int64.desktop.comp b/deps/SPIRV-Cross/reference/shaders/desktop-only/comp/int64.desktop.comp deleted file mode 100644 index 702456b303..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/desktop-only/comp/int64.desktop.comp +++ /dev/null @@ -1,52 +0,0 @@ -#version 450 -#extension GL_ARB_gpu_shader_int64 : require -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -struct M0 -{ - int64_t v; - i64vec2 b[2]; - uint64_t c; - uint64_t d[5]; -}; - -layout(binding = 0, std430) buffer SSBO0 -{ - i64vec4 a; - M0 m0; -} ssbo_0; - -layout(binding = 1, std430) buffer SSBO1 -{ - u64vec4 b; - M0 m0; -} ssbo_1; - -layout(binding = 2, std430) buffer SSBO2 -{ - int64_t a[4]; - i64vec2 b[4]; -} ssbo_2; - -layout(binding = 3, std140) buffer SSBO3 -{ - int64_t a[4]; - i64vec2 b[4]; -} ssbo_3; - -void main() -{ - ssbo_0.a += i64vec4(10l, 20l, 30l, 40l); - ssbo_1.b += u64vec4(999999999999999999ul, 8888888888888888ul, 77777777777777777ul, 6666666666666666ul); - ssbo_0.a += i64vec4(20l); - ssbo_0.a = abs(ssbo_0.a + i64vec4(ssbo_1.b)); - ssbo_0.a += i64vec4(1l); - ssbo_1.b += u64vec4(i64vec4(1l)); - ssbo_0.a -= i64vec4(1l); - ssbo_1.b -= u64vec4(i64vec4(1l)); - ssbo_1.b = doubleBitsToUint64(int64BitsToDouble(ssbo_0.a)); - ssbo_0.a = doubleBitsToInt64(uint64BitsToDouble(ssbo_1.b)); - ssbo_2.a[0] += 1l; - ssbo_3.a[0] += 2l; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/desktop-only/frag/hlsl-uav-block-alias.asm.frag b/deps/SPIRV-Cross/reference/shaders/desktop-only/frag/hlsl-uav-block-alias.asm.frag deleted file mode 100644 index 70843a8563..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/desktop-only/frag/hlsl-uav-block-alias.asm.frag +++ /dev/null @@ -1,24 +0,0 @@ -#version 450 - -layout(binding = 0, std430) buffer Foobar -{ - vec4 _data[]; -} Foobar_1; - -layout(binding = 1, std430) buffer Foobaz -{ - vec4 _data[]; -} Foobaz_1; - -layout(location = 0) out vec4 _entryPointOutput; - -vec4 _main() -{ - return Foobar_1._data[0] + Foobaz_1._data[0]; -} - -void main() -{ - _entryPointOutput = _main(); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/desktop-only/frag/image-ms.desktop.frag b/deps/SPIRV-Cross/reference/shaders/desktop-only/frag/image-ms.desktop.frag deleted file mode 100644 index 24644be170..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/desktop-only/frag/image-ms.desktop.frag +++ /dev/null @@ -1,13 +0,0 @@ -#version 450 - -layout(binding = 0, rgba8) uniform image2DMS uImage; -layout(binding = 1, rgba8) uniform image2DMSArray uImageArray; - -void main() -{ - vec4 a = imageLoad(uImage, ivec2(1, 2), 2); - vec4 b = imageLoad(uImageArray, ivec3(1, 2, 4), 3); - imageStore(uImage, ivec2(2, 3), 1, a); - imageStore(uImageArray, ivec3(2, 3, 7), 1, b); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/desktop-only/frag/image-query.desktop.frag b/deps/SPIRV-Cross/reference/shaders/desktop-only/frag/image-query.desktop.frag deleted file mode 100644 index 6f36d5db3b..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/desktop-only/frag/image-query.desktop.frag +++ /dev/null @@ -1,53 +0,0 @@ -#version 450 - -layout(binding = 0) uniform sampler1D uSampler1D; -layout(binding = 1) uniform sampler2D uSampler2D; -layout(binding = 2) uniform sampler2DArray uSampler2DArray; -layout(binding = 3) uniform sampler3D uSampler3D; -layout(binding = 4) uniform samplerCube uSamplerCube; -layout(binding = 5) uniform samplerCubeArray uSamplerCubeArray; -layout(binding = 6) uniform samplerBuffer uSamplerBuffer; -layout(binding = 7) uniform sampler2DMS uSamplerMS; -layout(binding = 8) uniform sampler2DMSArray uSamplerMSArray; -layout(binding = 9, r32f) uniform readonly writeonly image1D uImage1D; -layout(binding = 10, r32f) uniform readonly writeonly image2D uImage2D; -layout(binding = 11, r32f) uniform readonly writeonly image2DArray uImage2DArray; -layout(binding = 12, r32f) uniform readonly writeonly image3D uImage3D; -layout(binding = 13, r32f) uniform readonly writeonly imageCube uImageCube; -layout(binding = 14, r32f) uniform readonly writeonly imageCubeArray uImageCubeArray; -layout(binding = 15, r32f) uniform readonly writeonly imageBuffer uImageBuffer; -layout(binding = 16, r32f) uniform readonly writeonly image2DMS uImageMS; -layout(binding = 17, r32f) uniform readonly writeonly image2DMSArray uImageMSArray; - -void main() -{ - int a = textureSize(uSampler1D, 0); - ivec2 b = textureSize(uSampler2D, 0); - ivec3 c = textureSize(uSampler2DArray, 0); - ivec3 d = textureSize(uSampler3D, 0); - ivec2 e = textureSize(uSamplerCube, 0); - ivec3 f = textureSize(uSamplerCubeArray, 0); - int g = textureSize(uSamplerBuffer); - ivec2 h = textureSize(uSamplerMS); - ivec3 i = textureSize(uSamplerMSArray); - int l0 = textureQueryLevels(uSampler1D); - int l1 = textureQueryLevels(uSampler2D); - int l2 = textureQueryLevels(uSampler2DArray); - int l3 = textureQueryLevels(uSampler3D); - int l4 = textureQueryLevels(uSamplerCube); - int l5 = textureQueryLevels(uSamplerCubeArray); - a = imageSize(uImage1D); - b = imageSize(uImage2D); - c = imageSize(uImage2DArray); - d = imageSize(uImage3D); - e = imageSize(uImageCube); - f = imageSize(uImageCubeArray); - g = imageSize(uImageBuffer); - h = imageSize(uImageMS); - i = imageSize(uImageMSArray); - int s0 = textureSamples(uSamplerMS); - int s1 = textureSamples(uSamplerMSArray); - int s2 = imageSamples(uImageMS); - int s3 = imageSamples(uImageMSArray); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/desktop-only/frag/in-block-qualifiers.frag b/deps/SPIRV-Cross/reference/shaders/desktop-only/frag/in-block-qualifiers.frag deleted file mode 100644 index d4622801df..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/desktop-only/frag/in-block-qualifiers.frag +++ /dev/null @@ -1,21 +0,0 @@ -#version 450 - -layout(location = 0) out vec4 FragColor; -layout(location = 0) in VertexData -{ - flat float f; - centroid vec4 g; - flat int h; - float i; -} vin; - -layout(location = 4) flat in float f; -layout(location = 5) centroid in vec4 g; -layout(location = 6) flat in int h; -layout(location = 7) sample in float i; - -void main() -{ - FragColor = ((((((vec4(vin.f) + vin.g) + vec4(float(vin.h))) + vec4(vin.i)) + vec4(f)) + g) + vec4(float(h))) + vec4(i); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/desktop-only/frag/query-levels.desktop.frag b/deps/SPIRV-Cross/reference/shaders/desktop-only/frag/query-levels.desktop.frag deleted file mode 100644 index 4a80cbf81f..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/desktop-only/frag/query-levels.desktop.frag +++ /dev/null @@ -1,11 +0,0 @@ -#version 450 - -layout(binding = 0) uniform sampler2D uSampler; - -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = vec4(float(textureQueryLevels(uSampler))); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/desktop-only/frag/query-lod.desktop.frag b/deps/SPIRV-Cross/reference/shaders/desktop-only/frag/query-lod.desktop.frag deleted file mode 100644 index f43543b8c0..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/desktop-only/frag/query-lod.desktop.frag +++ /dev/null @@ -1,12 +0,0 @@ -#version 450 - -layout(binding = 0) uniform sampler2D uSampler; - -layout(location = 0) out vec4 FragColor; -layout(location = 0) in vec2 vTexCoord; - -void main() -{ - FragColor = textureQueryLod(uSampler, vTexCoord).xyxy; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/desktop-only/frag/sampler-ms-query.desktop.frag b/deps/SPIRV-Cross/reference/shaders/desktop-only/frag/sampler-ms-query.desktop.frag deleted file mode 100644 index 4c30ed1529..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/desktop-only/frag/sampler-ms-query.desktop.frag +++ /dev/null @@ -1,14 +0,0 @@ -#version 450 - -layout(binding = 0) uniform sampler2DMS uSampler; -layout(binding = 1) uniform sampler2DMSArray uSamplerArray; -layout(binding = 2, rgba8) uniform readonly writeonly image2DMS uImage; -layout(binding = 3, rgba8) uniform readonly writeonly image2DMSArray uImageArray; - -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = vec4(float(((textureSamples(uSampler) + textureSamples(uSamplerArray)) + imageSamples(uImage)) + imageSamples(uImageArray))); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/desktop-only/frag/texture-proj-shadow.desktop.frag b/deps/SPIRV-Cross/reference/shaders/desktop-only/frag/texture-proj-shadow.desktop.frag deleted file mode 100644 index d5e45bda43..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/desktop-only/frag/texture-proj-shadow.desktop.frag +++ /dev/null @@ -1,26 +0,0 @@ -#version 450 - -layout(binding = 0) uniform sampler1DShadow uShadow1D; -layout(binding = 1) uniform sampler2DShadow uShadow2D; -layout(binding = 2) uniform sampler1D uSampler1D; -layout(binding = 3) uniform sampler2D uSampler2D; -layout(binding = 4) uniform sampler3D uSampler3D; - -layout(location = 0) out float FragColor; -layout(location = 1) in vec4 vClip4; -layout(location = 2) in vec2 vClip2; -layout(location = 0) in vec3 vClip3; - -void main() -{ - vec4 _20 = vClip4; - _20.y = vClip4.w; - FragColor = textureProj(uShadow1D, vec4(_20.x, 0.0, vClip4.z, _20.y)); - vec4 _30 = vClip4; - _30.z = vClip4.w; - FragColor = textureProj(uShadow2D, vec4(_30.xy, vClip4.z, _30.z)); - FragColor = textureProj(uSampler1D, vClip2).x; - FragColor = textureProj(uSampler2D, vClip3).x; - FragColor = textureProj(uSampler3D, vClip4).x; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/desktop-only/geom/basic.desktop.sso.geom b/deps/SPIRV-Cross/reference/shaders/desktop-only/geom/basic.desktop.sso.geom deleted file mode 100644 index f1afee69ec..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/desktop-only/geom/basic.desktop.sso.geom +++ /dev/null @@ -1,35 +0,0 @@ -#version 450 -layout(invocations = 4, triangles) in; -layout(max_vertices = 3, triangle_strip) out; - -in gl_PerVertex -{ - vec4 gl_Position; -} gl_in[]; - -out gl_PerVertex -{ - vec4 gl_Position; -}; - -layout(location = 0) out vec3 vNormal; -layout(location = 0) in VertexData -{ - vec3 normal; -} vin[3]; - - -void main() -{ - gl_Position = gl_in[0].gl_Position; - vNormal = vin[0].normal + vec3(float(gl_InvocationID)); - EmitVertex(); - gl_Position = gl_in[1].gl_Position; - vNormal = vin[1].normal + vec3(4.0 * float(gl_InvocationID)); - EmitVertex(); - gl_Position = gl_in[2].gl_Position; - vNormal = vin[2].normal + vec3(2.0 * float(gl_InvocationID)); - EmitVertex(); - EndPrimitive(); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/desktop-only/geom/viewport-index.desktop.geom b/deps/SPIRV-Cross/reference/shaders/desktop-only/geom/viewport-index.desktop.geom deleted file mode 100644 index 773aeb8bfd..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/desktop-only/geom/viewport-index.desktop.geom +++ /dev/null @@ -1,9 +0,0 @@ -#version 450 -layout(triangles) in; -layout(max_vertices = 4, triangle_strip) out; - -void main() -{ - gl_ViewportIndex = 1; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/desktop-only/tesc/basic.desktop.sso.tesc b/deps/SPIRV-Cross/reference/shaders/desktop-only/tesc/basic.desktop.sso.tesc deleted file mode 100644 index 5e958256af..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/desktop-only/tesc/basic.desktop.sso.tesc +++ /dev/null @@ -1,27 +0,0 @@ -#version 450 -layout(vertices = 1) out; - -in gl_PerVertex -{ - vec4 gl_Position; -} gl_in[gl_MaxPatchVertices]; - -out gl_PerVertex -{ - vec4 gl_Position; -} gl_out[1]; - -layout(location = 0) patch out vec3 vFoo; - -void main() -{ - gl_TessLevelInner[0] = 8.8999996185302734375; - gl_TessLevelInner[1] = 6.900000095367431640625; - gl_TessLevelOuter[0] = 8.8999996185302734375; - gl_TessLevelOuter[1] = 6.900000095367431640625; - gl_TessLevelOuter[2] = 3.900000095367431640625; - gl_TessLevelOuter[3] = 4.900000095367431640625; - vFoo = vec3(1.0); - gl_out[gl_InvocationID].gl_Position = gl_in[0].gl_Position + gl_in[1].gl_Position; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/desktop-only/tese/triangle.desktop.sso.tese b/deps/SPIRV-Cross/reference/shaders/desktop-only/tese/triangle.desktop.sso.tese deleted file mode 100644 index 31027dae80..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/desktop-only/tese/triangle.desktop.sso.tese +++ /dev/null @@ -1,18 +0,0 @@ -#version 450 -layout(triangles, cw, fractional_even_spacing) in; - -in gl_PerVertex -{ - vec4 gl_Position; -} gl_in[gl_MaxPatchVertices]; - -out gl_PerVertex -{ - vec4 gl_Position; -}; - -void main() -{ - gl_Position = ((gl_in[0].gl_Position * gl_TessCoord.x) + (gl_in[1].gl_Position * gl_TessCoord.y)) + (gl_in[2].gl_Position * gl_TessCoord.z); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/desktop-only/vert/basic.desktop.sso.vert b/deps/SPIRV-Cross/reference/shaders/desktop-only/vert/basic.desktop.sso.vert deleted file mode 100644 index 5f527e08c1..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/desktop-only/vert/basic.desktop.sso.vert +++ /dev/null @@ -1,22 +0,0 @@ -#version 450 - -out gl_PerVertex -{ - vec4 gl_Position; -}; - -layout(std140) uniform UBO -{ - mat4 uMVP; -} _16; - -layout(location = 0) in vec4 aVertex; -layout(location = 0) out vec3 vNormal; -layout(location = 1) in vec3 aNormal; - -void main() -{ - gl_Position = _16.uMVP * aVertex; - vNormal = aNormal; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/desktop-only/vert/clip-cull-distance.desktop.vert b/deps/SPIRV-Cross/reference/shaders/desktop-only/vert/clip-cull-distance.desktop.vert deleted file mode 100644 index 566809db23..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/desktop-only/vert/clip-cull-distance.desktop.vert +++ /dev/null @@ -1,11 +0,0 @@ -#version 450 - -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; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/desktop-only/vert/out-block-qualifiers.vert b/deps/SPIRV-Cross/reference/shaders/desktop-only/vert/out-block-qualifiers.vert deleted file mode 100644 index 7c731684bc..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/desktop-only/vert/out-block-qualifiers.vert +++ /dev/null @@ -1,27 +0,0 @@ -#version 450 - -layout(location = 0) out VertexData -{ - flat float f; - centroid vec4 g; - flat int h; - float i; -} vout; - -layout(location = 4) flat out float f; -layout(location = 5) centroid out vec4 g; -layout(location = 6) flat out int h; -layout(location = 7) out float i; - -void main() -{ - vout.f = 10.0; - vout.g = vec4(20.0); - vout.h = 20; - vout.i = 30.0; - f = 10.0; - g = vec4(20.0); - h = 20; - i = 30.0; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/flatten/array.flatten.vert b/deps/SPIRV-Cross/reference/shaders/flatten/array.flatten.vert deleted file mode 100644 index 5afde34c55..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/flatten/array.flatten.vert +++ /dev/null @@ -1,12 +0,0 @@ -#version 310 es - -uniform vec4 UBO[56]; -layout(location = 0) in vec4 aVertex; - -void main() -{ - vec4 a4 = UBO[23]; - vec4 offset = (UBO[50] + UBO[45]) + vec4(UBO[54].x); - gl_Position = ((mat4(UBO[40], UBO[41], UBO[42], UBO[43]) * aVertex) + UBO[55]) + offset; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/flatten/basic.flatten.vert b/deps/SPIRV-Cross/reference/shaders/flatten/basic.flatten.vert deleted file mode 100644 index f7eb758f2a..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/flatten/basic.flatten.vert +++ /dev/null @@ -1,13 +0,0 @@ -#version 310 es - -uniform vec4 UBO[4]; -layout(location = 0) in vec4 aVertex; -layout(location = 0) out vec3 vNormal; -layout(location = 1) in vec3 aNormal; - -void main() -{ - gl_Position = mat4(UBO[0], UBO[1], UBO[2], UBO[3]) * aVertex; - vNormal = aNormal; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/flatten/copy.flatten.vert b/deps/SPIRV-Cross/reference/shaders/flatten/copy.flatten.vert deleted file mode 100644 index 2bdd723886..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/flatten/copy.flatten.vert +++ /dev/null @@ -1,29 +0,0 @@ -#version 310 es - -struct Light -{ - vec3 Position; - float Radius; - vec4 Color; -}; - -uniform vec4 UBO[12]; -layout(location = 0) in vec4 aVertex; -layout(location = 0) out vec4 vColor; -layout(location = 1) in vec3 aNormal; - -void main() -{ - gl_Position = mat4(UBO[0], UBO[1], UBO[2], UBO[3]) * aVertex; - vColor = vec4(0.0); - for (int i = 0; i < 4; i++) - { - Light light; - light.Position = Light(UBO[i * 2 + 4].xyz, UBO[i * 2 + 4].w, UBO[i * 2 + 5]).Position; - light.Radius = Light(UBO[i * 2 + 4].xyz, UBO[i * 2 + 4].w, UBO[i * 2 + 5]).Radius; - light.Color = Light(UBO[i * 2 + 4].xyz, UBO[i * 2 + 4].w, UBO[i * 2 + 5]).Color; - vec3 L = aVertex.xyz - light.Position; - vColor += (((UBO[i * 2 + 5]) * clamp(1.0 - (length(L) / light.Radius), 0.0, 1.0)) * dot(aNormal, normalize(L))); - } -} - diff --git a/deps/SPIRV-Cross/reference/shaders/flatten/dynamic.flatten.vert b/deps/SPIRV-Cross/reference/shaders/flatten/dynamic.flatten.vert deleted file mode 100644 index 6214ca450a..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/flatten/dynamic.flatten.vert +++ /dev/null @@ -1,25 +0,0 @@ -#version 310 es - -struct Light -{ - vec3 Position; - float Radius; - vec4 Color; -}; - -uniform vec4 UBO[12]; -layout(location = 0) in vec4 aVertex; -layout(location = 0) out vec4 vColor; -layout(location = 1) in vec3 aNormal; - -void main() -{ - gl_Position = mat4(UBO[0], UBO[1], UBO[2], UBO[3]) * aVertex; - vColor = vec4(0.0); - for (int i = 0; i < 4; i++) - { - vec3 L = aVertex.xyz - (UBO[i * 2 + 4].xyz); - vColor += (((UBO[i * 2 + 5]) * clamp(1.0 - (length(L) / (UBO[i * 2 + 4].w)), 0.0, 1.0)) * dot(aNormal, normalize(L))); - } -} - diff --git a/deps/SPIRV-Cross/reference/shaders/flatten/matrixindex.flatten.vert b/deps/SPIRV-Cross/reference/shaders/flatten/matrixindex.flatten.vert deleted file mode 100644 index f6d0fa486d..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/flatten/matrixindex.flatten.vert +++ /dev/null @@ -1,19 +0,0 @@ -#version 310 es - -uniform vec4 UBO[14]; -layout(location = 0) out vec4 oA; -layout(location = 1) out vec4 oB; -layout(location = 2) out vec4 oC; -layout(location = 3) out vec4 oD; -layout(location = 4) out vec4 oE; - -void main() -{ - gl_Position = vec4(0.0); - oA = UBO[1]; - oB = vec4(UBO[4].y, UBO[5].y, UBO[6].y, UBO[7].y); - oC = UBO[9]; - oD = vec4(UBO[10].x, UBO[11].x, UBO[12].x, UBO[13].x); - oE = vec4(UBO[1].z, UBO[6].y, UBO[9].z, UBO[12].y); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/flatten/multi-dimensional.desktop.flatten_dim.frag b/deps/SPIRV-Cross/reference/shaders/flatten/multi-dimensional.desktop.flatten_dim.frag deleted file mode 100644 index 21c3363ca6..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/flatten/multi-dimensional.desktop.flatten_dim.frag +++ /dev/null @@ -1,24 +0,0 @@ -#version 450 - -layout(binding = 0) uniform sampler2D uTextures[2 * 3 * 1]; - -layout(location = 1) in vec2 vUV; -layout(location = 0) out vec4 FragColor; -layout(location = 0) flat in int vIndex; - -void main() -{ - vec4 values3[2 * 3 * 1]; - for (int z = 0; z < 2; z++) - { - for (int y = 0; y < 3; y++) - { - for (int x = 0; x < 1; x++) - { - values3[z * 3 * 1 + y * 1 + x] = texture(uTextures[z * 3 * 1 + y * 1 + x], vUV); - } - } - } - FragColor = ((values3[1 * 3 * 1 + 2 * 1 + 0]) + (values3[0 * 3 * 1 + 2 * 1 + 0])) + (values3[(vIndex + 1) * 3 * 1 + 2 * 1 + vIndex]); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/flatten/multiindex.flatten.vert b/deps/SPIRV-Cross/reference/shaders/flatten/multiindex.flatten.vert deleted file mode 100644 index 3850bf6c70..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/flatten/multiindex.flatten.vert +++ /dev/null @@ -1,10 +0,0 @@ -#version 310 es - -uniform vec4 UBO[15]; -layout(location = 0) in ivec2 aIndex; - -void main() -{ - gl_Position = UBO[aIndex.x * 5 + aIndex.y * 1 + 0]; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/flatten/push-constant.flatten.vert b/deps/SPIRV-Cross/reference/shaders/flatten/push-constant.flatten.vert deleted file mode 100644 index 216c1f9d1b..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/flatten/push-constant.flatten.vert +++ /dev/null @@ -1,13 +0,0 @@ -#version 310 es - -uniform vec4 PushMe[6]; -layout(location = 1) in vec4 Pos; -layout(location = 0) out vec2 vRot; -layout(location = 0) in vec2 Rot; - -void main() -{ - gl_Position = mat4(PushMe[0], PushMe[1], PushMe[2], PushMe[3]) * Pos; - vRot = (mat2(PushMe[4].xy, PushMe[4].zw) * Rot) + vec2(PushMe[5].z); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/flatten/rowmajor.flatten.vert b/deps/SPIRV-Cross/reference/shaders/flatten/rowmajor.flatten.vert deleted file mode 100644 index 721c4905c0..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/flatten/rowmajor.flatten.vert +++ /dev/null @@ -1,11 +0,0 @@ -#version 310 es - -uniform vec4 UBO[12]; -layout(location = 0) in vec4 aVertex; - -void main() -{ - vec2 v = mat4x2(UBO[8].xy, UBO[9].xy, UBO[10].xy, UBO[11].xy) * aVertex; - gl_Position = (mat4(UBO[0], UBO[1], UBO[2], UBO[3]) * aVertex) + (aVertex * mat4(UBO[4], UBO[5], UBO[6], UBO[7])); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/flatten/struct.flatten.vert b/deps/SPIRV-Cross/reference/shaders/flatten/struct.flatten.vert deleted file mode 100644 index 3468d52929..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/flatten/struct.flatten.vert +++ /dev/null @@ -1,22 +0,0 @@ -#version 310 es - -struct Light -{ - vec3 Position; - float Radius; - vec4 Color; -}; - -uniform vec4 UBO[6]; -layout(location = 0) in vec4 aVertex; -layout(location = 0) out vec4 vColor; -layout(location = 1) in vec3 aNormal; - -void main() -{ - gl_Position = mat4(UBO[0], UBO[1], UBO[2], UBO[3]) * aVertex; - vColor = vec4(0.0); - vec3 L = aVertex.xyz - UBO[4].xyz; - vColor += ((UBO[5] * clamp(1.0 - (length(L) / UBO[4].w), 0.0, 1.0)) * dot(aNormal, normalize(L))); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/flatten/struct.rowmajor.flatten.vert b/deps/SPIRV-Cross/reference/shaders/flatten/struct.rowmajor.flatten.vert deleted file mode 100644 index a40aea08af..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/flatten/struct.rowmajor.flatten.vert +++ /dev/null @@ -1,25 +0,0 @@ -#version 310 es - -struct Foo -{ - mat3x4 MVP0; - mat3x4 MVP1; -}; - -uniform vec4 UBO[8]; -layout(location = 0) in vec4 v0; -layout(location = 1) in vec4 v1; -layout(location = 0) out vec3 V0; -layout(location = 1) out vec3 V1; - -void main() -{ - Foo f; - f.MVP0 = Foo(transpose(mat4x3(UBO[0].xyz, UBO[1].xyz, UBO[2].xyz, UBO[3].xyz)), transpose(mat4x3(UBO[4].xyz, UBO[5].xyz, UBO[6].xyz, UBO[7].xyz))).MVP0; - f.MVP1 = Foo(transpose(mat4x3(UBO[0].xyz, UBO[1].xyz, UBO[2].xyz, UBO[3].xyz)), transpose(mat4x3(UBO[4].xyz, UBO[5].xyz, UBO[6].xyz, UBO[7].xyz))).MVP1; - vec3 a = v0 * f.MVP0; - vec3 b = v1 * f.MVP1; - V0 = a; - V1 = b; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/flatten/swizzle.flatten.vert b/deps/SPIRV-Cross/reference/shaders/flatten/swizzle.flatten.vert deleted file mode 100644 index 92afb475e6..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/flatten/swizzle.flatten.vert +++ /dev/null @@ -1,21 +0,0 @@ -#version 310 es - -uniform vec4 UBO[8]; -layout(location = 0) out vec4 oA; -layout(location = 1) out vec4 oB; -layout(location = 2) out vec4 oC; -layout(location = 3) out vec4 oD; -layout(location = 4) out vec4 oE; -layout(location = 5) out vec4 oF; - -void main() -{ - gl_Position = vec4(0.0); - oA = UBO[0]; - oB = vec4(UBO[1].xy, UBO[1].zw); - oC = vec4(UBO[2].x, UBO[3].xyz); - oD = vec4(UBO[4].xyz, UBO[4].w); - oE = vec4(UBO[5].x, UBO[5].y, UBO[5].z, UBO[5].w); - oF = vec4(UBO[6].x, UBO[6].zw, UBO[7].x); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/flatten/types.flatten.frag b/deps/SPIRV-Cross/reference/shaders/flatten/types.flatten.frag deleted file mode 100644 index a74327d97b..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/flatten/types.flatten.frag +++ /dev/null @@ -1,14 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -uniform mediump ivec4 UBO1[2]; -uniform mediump uvec4 UBO2[2]; -uniform vec4 UBO0[2]; -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = ((((vec4(UBO1[0]) + vec4(UBO1[1])) + vec4(UBO2[0])) + vec4(UBO2[1])) + UBO0[0]) + UBO0[1]; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/frag/basic.frag b/deps/SPIRV-Cross/reference/shaders/frag/basic.frag deleted file mode 100644 index 2a4e440421..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/frag/basic.frag +++ /dev/null @@ -1,15 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(binding = 0) uniform mediump sampler2D uTex; - -layout(location = 0) out vec4 FragColor; -layout(location = 0) in vec4 vColor; -layout(location = 1) in vec2 vTex; - -void main() -{ - FragColor = vColor * texture(uTex, vTex); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/frag/composite-extract-forced-temporary.frag b/deps/SPIRV-Cross/reference/shaders/frag/composite-extract-forced-temporary.frag deleted file mode 100644 index e4384f559e..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/frag/composite-extract-forced-temporary.frag +++ /dev/null @@ -1,15 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(binding = 0) uniform mediump sampler2D Texture; - -layout(location = 0) in vec2 vTexCoord; -layout(location = 0) out vec4 FragColor; - -void main() -{ - float f = texture(Texture, vTexCoord).x; - FragColor = vec4(f * f); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/frag/constant-array.frag b/deps/SPIRV-Cross/reference/shaders/frag/constant-array.frag deleted file mode 100644 index 4da9b8948b..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/frag/constant-array.frag +++ /dev/null @@ -1,28 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -struct Foobar -{ - float a; - float b; -}; - -layout(location = 0) out vec4 FragColor; -layout(location = 0) flat in mediump int index; - -vec4 resolve(Foobar f) -{ - return vec4(f.a + f.b); -} - -void main() -{ - highp vec4 indexable[3] = vec4[](vec4(1.0), vec4(2.0), vec4(3.0)); - highp vec4 indexable_1[2][2] = vec4[][](vec4[](vec4(1.0), vec4(2.0)), vec4[](vec4(8.0), vec4(10.0))); - Foobar param = Foobar(10.0, 20.0); - Foobar indexable_2[2] = Foobar[](Foobar(10.0, 40.0), Foobar(90.0, 70.0)); - Foobar param_1 = indexable_2[index]; - FragColor = ((indexable[index] + (indexable_1[index][index + 1])) + resolve(param)) + resolve(param_1); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/frag/false-loop-init.frag b/deps/SPIRV-Cross/reference/shaders/frag/false-loop-init.frag deleted file mode 100644 index b0ed5577d3..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/frag/false-loop-init.frag +++ /dev/null @@ -1,25 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(location = 0) out vec4 result; -layout(location = 0) in vec4 accum; - -void main() -{ - result = vec4(0.0); - mediump uint j; - for (mediump int i = 0; i < 4; i += int(j)) - { - if (accum.y > 10.0) - { - j = 40u; - } - else - { - j = 30u; - } - result += accum; - } -} - diff --git a/deps/SPIRV-Cross/reference/shaders/frag/flush_params.frag b/deps/SPIRV-Cross/reference/shaders/frag/flush_params.frag deleted file mode 100644 index b4b36ff90d..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/frag/flush_params.frag +++ /dev/null @@ -1,30 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -struct Structy -{ - vec4 c; -}; - -layout(location = 0) out vec4 FragColor; - -void foo2(inout Structy f) -{ - f.c = vec4(10.0); -} - -Structy foo() -{ - Structy param; - foo2(param); - Structy f = param; - return f; -} - -void main() -{ - Structy s = foo(); - FragColor = s.c; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/frag/for-loop-init.frag b/deps/SPIRV-Cross/reference/shaders/frag/for-loop-init.frag deleted file mode 100644 index 7c22e5c785..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/frag/for-loop-init.frag +++ /dev/null @@ -1,52 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(location = 0) out mediump int FragColor; - -void main() -{ - FragColor = 16; - for (mediump int i = 0; i < 25; i++) - { - FragColor += 10; - } - for (mediump int i_1 = 1, j = 4; i_1 < 30; i_1++, j += 4) - { - FragColor += 11; - } - mediump int k = 0; - for (; k < 20; k++) - { - FragColor += 12; - } - k += 3; - FragColor += k; - mediump int l; - if (k == 40) - { - l = 0; - for (; l < 40; l++) - { - FragColor += 13; - } - return; - } - else - { - l = k; - FragColor += l; - } - mediump ivec2 i_2 = ivec2(0); - for (; i_2.x < 10; i_2.x += 4) - { - FragColor += i_2.y; - } - mediump int o = k; - for (mediump int m = k; m < 40; m++) - { - FragColor += m; - } - FragColor += o; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/frag/frexp-modf.frag b/deps/SPIRV-Cross/reference/shaders/frag/frexp-modf.frag deleted file mode 100644 index e495bb3169..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/frag/frexp-modf.frag +++ /dev/null @@ -1,43 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -struct ResType -{ - highp float _m0; - int _m1; -}; - -struct ResType_1 -{ - highp vec2 _m0; - ivec2 _m1; -}; - -layout(location = 0) in float v0; -layout(location = 1) in vec2 v1; -layout(location = 0) out float FragColor; - -void main() -{ - ResType _16; - _16._m0 = frexp(v0, _16._m1); - mediump int e0 = _16._m1; - float f0 = _16._m0; - ResType _22; - _22._m0 = frexp(v0 + 1.0, _22._m1); - e0 = _22._m1; - f0 = _22._m0; - ResType_1 _35; - _35._m0 = frexp(v1, _35._m1); - mediump ivec2 e1 = _35._m1; - vec2 f1 = _35._m0; - float r0; - float _41 = modf(v0, r0); - float m0 = _41; - vec2 r1; - vec2 _45 = modf(v1, r1); - vec2 m1 = _45; - FragColor = ((((f0 + f1.x) + f1.y) + m0) + m1.x) + m1.y; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/frag/ground.frag b/deps/SPIRV-Cross/reference/shaders/frag/ground.frag deleted file mode 100644 index 4d998d5689..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/frag/ground.frag +++ /dev/null @@ -1,62 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(binding = 4, std140) uniform GlobalPSData -{ - vec4 g_CamPos; - vec4 g_SunDir; - vec4 g_SunColor; - vec4 g_ResolutionParams; - vec4 g_TimeParams; - vec4 g_FogColor_Distance; -} _101; - -layout(binding = 2) uniform mediump sampler2D TexNormalmap; - -layout(location = 3) out vec4 LightingOut; -layout(location = 2) out vec4 NormalOut; -layout(location = 1) out vec4 SpecularOut; -layout(location = 0) out vec4 AlbedoOut; -layout(location = 0) in vec2 TexCoord; -layout(location = 1) in vec3 EyeVec; - -float saturate(float x) -{ - return clamp(x, 0.0, 1.0); -} - -void Resolve(vec3 Albedo, vec3 Normal, float Roughness, float Metallic) -{ - LightingOut = vec4(0.0); - NormalOut = vec4((Normal * 0.5) + vec3(0.5), 0.0); - SpecularOut = vec4(Roughness, Metallic, 0.0, 0.0); - AlbedoOut = vec4(Albedo, 1.0); -} - -void main() -{ - vec3 Normal = (texture(TexNormalmap, TexCoord).xyz * 2.0) - vec3(1.0); - Normal = normalize(Normal); - highp float param = length(EyeVec) / 1000.0; - vec2 scatter_uv; - scatter_uv.x = saturate(param); - vec3 nEye = normalize(EyeVec); - scatter_uv.y = 0.0; - vec3 Color = vec3(0.100000001490116119384765625, 0.300000011920928955078125, 0.100000001490116119384765625); - vec3 grass = vec3(0.100000001490116119384765625, 0.300000011920928955078125, 0.100000001490116119384765625); - vec3 dirt = vec3(0.100000001490116119384765625); - vec3 snow = vec3(0.800000011920928955078125); - float grass_snow = smoothstep(0.0, 0.1500000059604644775390625, (_101.g_CamPos.y + EyeVec.y) / 200.0); - vec3 base = mix(grass, snow, vec3(grass_snow)); - float edge = smoothstep(0.699999988079071044921875, 0.75, Normal.y); - Color = mix(dirt, base, vec3(edge)); - Color *= Color; - float Roughness = 1.0 - (edge * grass_snow); - highp vec3 param_1 = Color; - highp vec3 param_2 = Normal; - highp float param_3 = Roughness; - highp float param_4 = 0.0; - Resolve(param_1, param_2, param_3, param_4); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/frag/image-load-store-uint-coord.asm.frag b/deps/SPIRV-Cross/reference/shaders/frag/image-load-store-uint-coord.asm.frag deleted file mode 100644 index 414dd956af..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/frag/image-load-store-uint-coord.asm.frag +++ /dev/null @@ -1,26 +0,0 @@ -#version 450 - -layout(binding = 1, rgba32f) uniform image2D RWIm; -layout(binding = 0, rgba32f) uniform writeonly imageBuffer RWBuf; -layout(binding = 1) uniform sampler2D ROIm; -layout(binding = 0) uniform samplerBuffer ROBuf; - -layout(location = 0) out vec4 _entryPointOutput; - -vec4 _main() -{ - vec4 storeTemp = vec4(10.0, 0.5, 8.0, 2.0); - imageStore(RWIm, ivec2(uvec2(10u)), storeTemp); - vec4 v = imageLoad(RWIm, ivec2(uvec2(30u))); - imageStore(RWBuf, int(80u), v); - v += texelFetch(ROIm, ivec2(uvec2(50u, 60u)), 0); - v += texelFetch(ROBuf, int(80u)); - return v; -} - -void main() -{ - vec4 _45 = _main(); - _entryPointOutput = _45; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/frag/mix.frag b/deps/SPIRV-Cross/reference/shaders/frag/mix.frag deleted file mode 100644 index 2b288dff02..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/frag/mix.frag +++ /dev/null @@ -1,20 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(location = 0) out vec4 FragColor; -layout(location = 0) in vec4 vIn0; -layout(location = 1) in vec4 vIn1; -layout(location = 2) in float vIn2; -layout(location = 3) in float vIn3; - -void main() -{ - bvec4 l = bvec4(false, true, false, false); - FragColor = mix(vIn0, vIn1, l); - bool f = true; - FragColor = vec4(f ? vIn3 : vIn2); - FragColor = mix(vIn1, vIn0, bvec4(f)); - FragColor = vec4(f ? vIn2 : vIn3); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/frag/partial-write-preserve.frag b/deps/SPIRV-Cross/reference/shaders/frag/partial-write-preserve.frag deleted file mode 100644 index cf8a83cf0c..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/frag/partial-write-preserve.frag +++ /dev/null @@ -1,109 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -struct B -{ - float a; - float b; -}; - -layout(binding = 0, std140) uniform UBO -{ - mediump int some_value; -} _51; - -void partial_inout(inout vec4 x) -{ - x.x = 10.0; -} - -void complete_inout(out vec4 x) -{ - x = vec4(50.0); -} - -void branchy_inout(inout vec4 v) -{ - v.y = 20.0; - if (_51.some_value == 20) - { - v = vec4(50.0); - } -} - -void branchy_inout_2(out vec4 v) -{ - if (_51.some_value == 20) - { - v = vec4(50.0); - } - else - { - v = vec4(70.0); - } - v.y = 20.0; -} - -void partial_inout(inout B b) -{ - b.b = 40.0; -} - -void complete_inout(out B b) -{ - b = B(100.0, 200.0); -} - -void branchy_inout(inout B b) -{ - b.b = 20.0; - if (_51.some_value == 20) - { - b = B(10.0, 40.0); - } -} - -void branchy_inout_2(out B b) -{ - if (_51.some_value == 20) - { - b = B(10.0, 40.0); - } - else - { - b = B(70.0, 70.0); - } - b.b = 20.0; -} - -void main() -{ - vec4 a = vec4(10.0); - highp vec4 param = a; - partial_inout(param); - a = param; - highp vec4 param_1; - complete_inout(param_1); - a = param_1; - highp vec4 param_2 = a; - branchy_inout(param_2); - a = param_2; - highp vec4 param_3; - branchy_inout_2(param_3); - a = param_3; - B b = B(10.0, 20.0); - B param_4 = b; - partial_inout(param_4); - b = param_4; - B param_5; - complete_inout(param_5); - b = param_5; - B param_6 = b; - branchy_inout(param_6); - b = param_6; - B param_7; - branchy_inout_2(param_7); - b = param_7; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/frag/pls.frag b/deps/SPIRV-Cross/reference/shaders/frag/pls.frag deleted file mode 100644 index 1cafdbd365..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/frag/pls.frag +++ /dev/null @@ -1,21 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(location = 0) out vec4 PLSOut0; -layout(location = 0) in vec4 PLSIn0; -layout(location = 1) out vec4 PLSOut1; -layout(location = 1) in vec4 PLSIn1; -layout(location = 2) out vec4 PLSOut2; -layout(location = 2) in vec4 PLSIn2; -layout(location = 3) out vec4 PLSOut3; -layout(location = 3) in vec4 PLSIn3; - -void main() -{ - PLSOut0 = PLSIn0 * 2.0; - PLSOut1 = PLSIn1 * 6.0; - PLSOut2 = PLSIn2 * 7.0; - PLSOut3 = PLSIn3 * 4.0; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/frag/sample-parameter.frag b/deps/SPIRV-Cross/reference/shaders/frag/sample-parameter.frag deleted file mode 100644 index 3c130e68d4..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/frag/sample-parameter.frag +++ /dev/null @@ -1,13 +0,0 @@ -#version 310 es -#extension GL_OES_sample_variables : require -precision mediump float; -precision highp int; - -layout(location = 0) out vec2 FragColor; - -void main() -{ - FragColor = (gl_SamplePosition + vec2(float(gl_SampleMaskIn[0]))) + vec2(float(gl_SampleID)); - gl_SampleMask[0] = 1; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/frag/sampler-ms.frag b/deps/SPIRV-Cross/reference/shaders/frag/sampler-ms.frag deleted file mode 100644 index dbab3fb819..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/frag/sampler-ms.frag +++ /dev/null @@ -1,14 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(binding = 0) uniform mediump sampler2DMS uSampler; - -layout(location = 0) out vec4 FragColor; - -void main() -{ - ivec2 coord = ivec2(gl_FragCoord.xy); - FragColor = ((texelFetch(uSampler, coord, 0) + texelFetch(uSampler, coord, 1)) + texelFetch(uSampler, coord, 2)) + texelFetch(uSampler, coord, 3); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/frag/sampler-proj.frag b/deps/SPIRV-Cross/reference/shaders/frag/sampler-proj.frag deleted file mode 100644 index 865dec6c8b..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/frag/sampler-proj.frag +++ /dev/null @@ -1,16 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(binding = 0) uniform mediump sampler2D uTex; - -layout(location = 0) out vec4 FragColor; -layout(location = 0) in vec4 vTex; - -void main() -{ - highp vec4 _19 = vTex; - _19.z = vTex.w; - FragColor = textureProj(uTex, _19.xyz); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/frag/sampler.frag b/deps/SPIRV-Cross/reference/shaders/frag/sampler.frag deleted file mode 100644 index 0ec200c714..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/frag/sampler.frag +++ /dev/null @@ -1,21 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(binding = 0) uniform mediump sampler2D uTex; - -layout(location = 0) out vec4 FragColor; -layout(location = 0) in vec4 vColor; -layout(location = 1) in vec2 vTex; - -vec4 sample_texture(mediump sampler2D tex, vec2 uv) -{ - return texture(tex, uv); -} - -void main() -{ - highp vec2 param = vTex; - FragColor = vColor * sample_texture(uTex, param); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/frag/swizzle.frag b/deps/SPIRV-Cross/reference/shaders/frag/swizzle.frag deleted file mode 100644 index e619be2f48..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/frag/swizzle.frag +++ /dev/null @@ -1,20 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(location = 0) uniform mediump sampler2D samp; - -layout(location = 0) out vec4 FragColor; -layout(location = 2) in vec2 vUV; -layout(location = 1) in vec3 vNormal; - -void main() -{ - FragColor = vec4(texture(samp, vUV).xyz, 1.0); - FragColor = vec4(texture(samp, vUV).xz, 1.0, 4.0); - FragColor = vec4(texture(samp, vUV).xx, texture(samp, vUV + vec2(0.100000001490116119384765625)).yy); - FragColor = vec4(vNormal, 1.0); - FragColor = vec4(vNormal + vec3(1.7999999523162841796875), 1.0); - FragColor = vec4(vUV, vUV + vec2(1.7999999523162841796875)); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/frag/ubo_layout.frag b/deps/SPIRV-Cross/reference/shaders/frag/ubo_layout.frag deleted file mode 100644 index bc0b01c065..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/frag/ubo_layout.frag +++ /dev/null @@ -1,26 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -struct Str -{ - mat4 foo; -}; - -layout(binding = 0, std140) uniform UBO1 -{ - layout(row_major) Str foo; -} ubo1; - -layout(binding = 1, std140) uniform UBO2 -{ - Str foo; -} ubo0; - -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = ubo1.foo.foo[0] + ubo0.foo.foo[0]; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/frag/unary-enclose.frag b/deps/SPIRV-Cross/reference/shaders/frag/unary-enclose.frag deleted file mode 100644 index 3006e86cb5..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/frag/unary-enclose.frag +++ /dev/null @@ -1,16 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(location = 0) out vec4 FragColor; -layout(location = 0) in vec4 vIn; -layout(location = 1) flat in mediump ivec4 vIn1; - -void main() -{ - FragColor = -(-vIn); - mediump ivec4 a = ~(~vIn1); - bool b = false; - b = !(!b); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/geom/basic.geom b/deps/SPIRV-Cross/reference/shaders/geom/basic.geom deleted file mode 100644 index 296ce5792c..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/geom/basic.geom +++ /dev/null @@ -1,26 +0,0 @@ -#version 310 es -#extension GL_EXT_geometry_shader : require -layout(invocations = 4, triangles) in; -layout(max_vertices = 3, triangle_strip) out; - -layout(location = 0) out vec3 vNormal; -layout(location = 0) in VertexData -{ - vec3 normal; -} vin[3]; - - -void main() -{ - gl_Position = gl_in[0].gl_Position; - vNormal = vin[0].normal + vec3(float(gl_InvocationID)); - EmitVertex(); - gl_Position = gl_in[1].gl_Position; - vNormal = vin[1].normal + vec3(4.0 * float(gl_InvocationID)); - EmitVertex(); - gl_Position = gl_in[2].gl_Position; - vNormal = vin[2].normal + vec3(2.0 * float(gl_InvocationID)); - EmitVertex(); - EndPrimitive(); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/geom/lines-adjacency.geom b/deps/SPIRV-Cross/reference/shaders/geom/lines-adjacency.geom deleted file mode 100644 index 46a21e9fb0..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/geom/lines-adjacency.geom +++ /dev/null @@ -1,26 +0,0 @@ -#version 310 es -#extension GL_EXT_geometry_shader : require -layout(lines_adjacency) in; -layout(max_vertices = 3, line_strip) out; - -layout(location = 0) out vec3 vNormal; -layout(location = 0) in VertexData -{ - vec3 normal; -} vin[4]; - - -void main() -{ - gl_Position = gl_in[0].gl_Position; - vNormal = vin[0].normal; - EmitVertex(); - gl_Position = gl_in[1].gl_Position; - vNormal = vin[1].normal; - EmitVertex(); - gl_Position = gl_in[2].gl_Position; - vNormal = vin[2].normal; - EmitVertex(); - EndPrimitive(); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/geom/lines.geom b/deps/SPIRV-Cross/reference/shaders/geom/lines.geom deleted file mode 100644 index c5aaa53d35..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/geom/lines.geom +++ /dev/null @@ -1,23 +0,0 @@ -#version 310 es -#extension GL_EXT_geometry_shader : require -layout(lines) in; -layout(max_vertices = 2, line_strip) out; - -layout(location = 0) out vec3 vNormal; -layout(location = 0) in VertexData -{ - vec3 normal; -} vin[2]; - - -void main() -{ - gl_Position = gl_in[0].gl_Position; - vNormal = vin[0].normal; - EmitVertex(); - gl_Position = gl_in[1].gl_Position; - vNormal = vin[1].normal; - EmitVertex(); - EndPrimitive(); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/geom/points.geom b/deps/SPIRV-Cross/reference/shaders/geom/points.geom deleted file mode 100644 index 4d59137c3a..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/geom/points.geom +++ /dev/null @@ -1,26 +0,0 @@ -#version 310 es -#extension GL_EXT_geometry_shader : require -layout(points) in; -layout(max_vertices = 3, points) out; - -layout(location = 0) out vec3 vNormal; -layout(location = 0) in VertexData -{ - vec3 normal; -} vin[1]; - - -void main() -{ - gl_Position = gl_in[0].gl_Position; - vNormal = vin[0].normal; - EmitVertex(); - gl_Position = gl_in[0].gl_Position; - vNormal = vin[0].normal; - EmitVertex(); - gl_Position = gl_in[0].gl_Position; - vNormal = vin[0].normal; - EmitVertex(); - EndPrimitive(); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/geom/single-invocation.geom b/deps/SPIRV-Cross/reference/shaders/geom/single-invocation.geom deleted file mode 100644 index fdccacc04f..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/geom/single-invocation.geom +++ /dev/null @@ -1,26 +0,0 @@ -#version 310 es -#extension GL_EXT_geometry_shader : require -layout(triangles) in; -layout(max_vertices = 3, triangle_strip) out; - -layout(location = 0) out vec3 vNormal; -layout(location = 0) in VertexData -{ - vec3 normal; -} vin[3]; - - -void main() -{ - gl_Position = gl_in[0].gl_Position; - vNormal = vin[0].normal; - EmitVertex(); - gl_Position = gl_in[1].gl_Position; - vNormal = vin[1].normal; - EmitVertex(); - gl_Position = gl_in[2].gl_Position; - vNormal = vin[2].normal; - EmitVertex(); - EndPrimitive(); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/geom/triangles-adjacency.geom b/deps/SPIRV-Cross/reference/shaders/geom/triangles-adjacency.geom deleted file mode 100644 index e9e6857a1f..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/geom/triangles-adjacency.geom +++ /dev/null @@ -1,26 +0,0 @@ -#version 310 es -#extension GL_EXT_geometry_shader : require -layout(triangles_adjacency) in; -layout(max_vertices = 3, triangle_strip) out; - -layout(location = 0) out vec3 vNormal; -layout(location = 0) in VertexData -{ - vec3 normal; -} vin[6]; - - -void main() -{ - gl_Position = gl_in[0].gl_Position; - vNormal = vin[0].normal; - EmitVertex(); - gl_Position = gl_in[1].gl_Position; - vNormal = vin[1].normal; - EmitVertex(); - gl_Position = gl_in[2].gl_Position; - vNormal = vin[2].normal; - EmitVertex(); - EndPrimitive(); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/geom/triangles.geom b/deps/SPIRV-Cross/reference/shaders/geom/triangles.geom deleted file mode 100644 index fdccacc04f..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/geom/triangles.geom +++ /dev/null @@ -1,26 +0,0 @@ -#version 310 es -#extension GL_EXT_geometry_shader : require -layout(triangles) in; -layout(max_vertices = 3, triangle_strip) out; - -layout(location = 0) out vec3 vNormal; -layout(location = 0) in VertexData -{ - vec3 normal; -} vin[3]; - - -void main() -{ - gl_Position = gl_in[0].gl_Position; - vNormal = vin[0].normal; - EmitVertex(); - gl_Position = gl_in[1].gl_Position; - vNormal = vin[1].normal; - EmitVertex(); - gl_Position = gl_in[2].gl_Position; - vNormal = vin[2].normal; - EmitVertex(); - EndPrimitive(); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/legacy/fragment/explicit-lod.legacy.frag b/deps/SPIRV-Cross/reference/shaders/legacy/fragment/explicit-lod.legacy.frag deleted file mode 100644 index 6e8dbf1a9c..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/legacy/fragment/explicit-lod.legacy.frag +++ /dev/null @@ -1,12 +0,0 @@ -#version 100 -#extension GL_EXT_shader_texture_lod : require -precision mediump float; -precision highp int; - -uniform mediump sampler2D tex; - -void main() -{ - gl_FragData[0] = texture2DLodEXT(tex, vec2(0.4000000059604644775390625, 0.60000002384185791015625), 0.0); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/legacy/fragment/io-blocks.legacy.frag b/deps/SPIRV-Cross/reference/shaders/legacy/fragment/io-blocks.legacy.frag deleted file mode 100644 index d5a60d53e9..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/legacy/fragment/io-blocks.legacy.frag +++ /dev/null @@ -1,12 +0,0 @@ -#version 100 -precision mediump float; -precision highp int; - -varying vec4 vin_color; -varying highp vec3 vin_normal; - -void main() -{ - gl_FragData[0] = vin_color + vin_normal.xyzz; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/legacy/fragment/struct-varying.legacy.frag b/deps/SPIRV-Cross/reference/shaders/legacy/fragment/struct-varying.legacy.frag deleted file mode 100644 index 81b95dd816..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/legacy/fragment/struct-varying.legacy.frag +++ /dev/null @@ -1,22 +0,0 @@ -#version 100 -precision mediump float; -precision highp int; - -struct Inputs -{ - highp vec4 a; - highp vec2 b; -}; - -varying highp vec4 vin_a; -varying highp vec2 vin_b; - -void main() -{ - Inputs v0 = Inputs(vin_a, vin_b); - Inputs v1 = Inputs(vin_a, vin_b); - highp vec4 a = vin_a; - highp vec4 b = vin_b.xxyy; - gl_FragData[0] = ((((v0.a + v0.b.xxyy) + v1.a) + v1.b.yyxx) + a) + b; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/legacy/vert/implicit-lod.legacy.vert b/deps/SPIRV-Cross/reference/shaders/legacy/vert/implicit-lod.legacy.vert deleted file mode 100644 index 6e44107448..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/legacy/vert/implicit-lod.legacy.vert +++ /dev/null @@ -1,9 +0,0 @@ -#version 100 - -uniform mediump sampler2D tex; - -void main() -{ - gl_Position = texture2D(tex, vec2(0.4000000059604644775390625, 0.60000002384185791015625)); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/legacy/vert/io-block.legacy.vert b/deps/SPIRV-Cross/reference/shaders/legacy/vert/io-block.legacy.vert deleted file mode 100644 index 3c518dc79e..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/legacy/vert/io-block.legacy.vert +++ /dev/null @@ -1,13 +0,0 @@ -#version 100 - -attribute vec4 Position; -varying vec4 vout_color; -varying vec3 vout_normal; - -void main() -{ - gl_Position = Position; - vout_color = vec4(1.0); - vout_normal = vec3(0.5); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/legacy/vert/struct-varying.legacy.vert b/deps/SPIRV-Cross/reference/shaders/legacy/vert/struct-varying.legacy.vert deleted file mode 100644 index 261e986034..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/legacy/vert/struct-varying.legacy.vert +++ /dev/null @@ -1,32 +0,0 @@ -#version 100 - -struct Output -{ - vec4 a; - vec2 b; -}; - -varying vec4 vout_a; -varying vec2 vout_b; - -void main() -{ - Output s = Output(vec4(0.5), vec2(0.25)); - { - Output vout = s; - vout_a = vout.a; - vout_b = vout.b; - } - { - Output vout = s; - vout_a = vout.a; - vout_b = vout.b; - } - Output tmp = Output(vout_a, vout_b); - vout_a = tmp.a; - vout_b = tmp.b; - vout_a.x = 1.0; - vout_b.y = 1.0; - float c = vout_a.x; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/legacy/vert/transpose.legacy.vert b/deps/SPIRV-Cross/reference/shaders/legacy/vert/transpose.legacy.vert deleted file mode 100644 index c73d1a11d9..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/legacy/vert/transpose.legacy.vert +++ /dev/null @@ -1,22 +0,0 @@ -#version 100 - -struct Buffer -{ - mat4 MVPRowMajor; - mat4 MVPColMajor; - mat4 M; -}; - -uniform Buffer _13; - -attribute vec4 Position; - -void main() -{ - vec4 c0 = _13.M * (Position * _13.MVPRowMajor); - vec4 c1 = _13.M * (_13.MVPColMajor * Position); - vec4 c2 = _13.M * (_13.MVPRowMajor * Position); - vec4 c3 = _13.M * (Position * _13.MVPColMajor); - gl_Position = ((c0 + c1) + c2) + c3; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/tesc/basic.tesc b/deps/SPIRV-Cross/reference/shaders/tesc/basic.tesc deleted file mode 100644 index 6019151adb..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/tesc/basic.tesc +++ /dev/null @@ -1,17 +0,0 @@ -#version 310 es -#extension GL_EXT_tessellation_shader : require -layout(vertices = 1) out; - -layout(location = 0) patch out vec3 vFoo; - -void main() -{ - gl_TessLevelInner[0] = 8.8999996185302734375; - gl_TessLevelInner[1] = 6.900000095367431640625; - gl_TessLevelOuter[0] = 8.8999996185302734375; - gl_TessLevelOuter[1] = 6.900000095367431640625; - gl_TessLevelOuter[2] = 3.900000095367431640625; - gl_TessLevelOuter[3] = 4.900000095367431640625; - vFoo = vec3(1.0); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/tesc/water_tess.tesc b/deps/SPIRV-Cross/reference/shaders/tesc/water_tess.tesc deleted file mode 100644 index 26611b8b25..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/tesc/water_tess.tesc +++ /dev/null @@ -1,117 +0,0 @@ -#version 310 es -#extension GL_EXT_tessellation_shader : require -layout(vertices = 1) out; - -layout(std140) uniform UBO -{ - vec4 uScale; - vec3 uCamPos; - vec2 uPatchSize; - vec2 uMaxTessLevel; - float uDistanceMod; - vec4 uFrustum[6]; -} _41; - -layout(location = 1) patch out vec2 vOutPatchPosBase; -layout(location = 2) patch out vec4 vPatchLods; -layout(location = 0) in vec2 vPatchPosBase[]; - -bool frustum_cull(vec2 p0) -{ - vec2 min_xz = (p0 - vec2(10.0)) * _41.uScale.xy; - vec2 max_xz = ((p0 + _41.uPatchSize) + vec2(10.0)) * _41.uScale.xy; - vec3 bb_min = vec3(min_xz.x, -10.0, min_xz.y); - vec3 bb_max = vec3(max_xz.x, 10.0, max_xz.y); - vec3 center = (bb_min + bb_max) * 0.5; - float radius = 0.5 * length(bb_max - bb_min); - vec3 f0 = vec3(dot(_41.uFrustum[0], vec4(center, 1.0)), dot(_41.uFrustum[1], vec4(center, 1.0)), dot(_41.uFrustum[2], vec4(center, 1.0))); - vec3 f1 = vec3(dot(_41.uFrustum[3], vec4(center, 1.0)), dot(_41.uFrustum[4], vec4(center, 1.0)), dot(_41.uFrustum[5], vec4(center, 1.0))); - vec3 _199 = f0; - bool _205 = any(lessThanEqual(_199, vec3(-radius))); - bool _215; - if (!_205) - { - _215 = any(lessThanEqual(f1, vec3(-radius))); - } - else - { - _215 = _205; - } - return !_215; -} - -float lod_factor(vec2 pos_) -{ - vec2 pos = pos_ * _41.uScale.xy; - vec3 dist_to_cam = _41.uCamPos - vec3(pos.x, 0.0, pos.y); - float level = log2((length(dist_to_cam) + 9.9999997473787516355514526367188e-05) * _41.uDistanceMod); - return clamp(level, 0.0, _41.uMaxTessLevel.x); -} - -vec4 tess_level(vec4 lod) -{ - return exp2(-lod) * _41.uMaxTessLevel.y; -} - -float tess_level(float lod) -{ - return _41.uMaxTessLevel.y * exp2(-lod); -} - -void compute_tess_levels(vec2 p0) -{ - vOutPatchPosBase = p0; - vec2 param = p0 + (vec2(-0.5) * _41.uPatchSize); - float l00 = lod_factor(param); - vec2 param_1 = p0 + (vec2(0.5, -0.5) * _41.uPatchSize); - float l10 = lod_factor(param_1); - vec2 param_2 = p0 + (vec2(1.5, -0.5) * _41.uPatchSize); - float l20 = lod_factor(param_2); - vec2 param_3 = p0 + (vec2(-0.5, 0.5) * _41.uPatchSize); - float l01 = lod_factor(param_3); - vec2 param_4 = p0 + (vec2(0.5) * _41.uPatchSize); - float l11 = lod_factor(param_4); - vec2 param_5 = p0 + (vec2(1.5, 0.5) * _41.uPatchSize); - float l21 = lod_factor(param_5); - vec2 param_6 = p0 + (vec2(-0.5, 1.5) * _41.uPatchSize); - float l02 = lod_factor(param_6); - vec2 param_7 = p0 + (vec2(0.5, 1.5) * _41.uPatchSize); - float l12 = lod_factor(param_7); - vec2 param_8 = p0 + (vec2(1.5) * _41.uPatchSize); - float l22 = lod_factor(param_8); - vec4 lods = vec4(dot(vec4(l01, l11, l02, l12), vec4(0.25)), dot(vec4(l00, l10, l01, l11), vec4(0.25)), dot(vec4(l10, l20, l11, l21), vec4(0.25)), dot(vec4(l11, l21, l12, l22), vec4(0.25))); - vPatchLods = lods; - vec4 outer_lods = min(lods, lods.yzwx); - vec4 param_9 = outer_lods; - vec4 levels = tess_level(param_9); - gl_TessLevelOuter[0] = levels.x; - gl_TessLevelOuter[1] = levels.y; - gl_TessLevelOuter[2] = levels.z; - gl_TessLevelOuter[3] = levels.w; - float min_lod = min(min(lods.x, lods.y), min(lods.z, lods.w)); - float param_10 = min(min_lod, l11); - float inner = tess_level(param_10); - gl_TessLevelInner[0] = inner; - gl_TessLevelInner[1] = inner; -} - -void main() -{ - vec2 p0 = vPatchPosBase[0]; - vec2 param = p0; - if (!frustum_cull(param)) - { - gl_TessLevelOuter[0] = -1.0; - gl_TessLevelOuter[1] = -1.0; - gl_TessLevelOuter[2] = -1.0; - gl_TessLevelOuter[3] = -1.0; - gl_TessLevelInner[0] = -1.0; - gl_TessLevelInner[1] = -1.0; - } - else - { - vec2 param_1 = p0; - compute_tess_levels(param_1); - } -} - diff --git a/deps/SPIRV-Cross/reference/shaders/tese/ccw.tese b/deps/SPIRV-Cross/reference/shaders/tese/ccw.tese deleted file mode 100644 index a2a4508ac0..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/tese/ccw.tese +++ /dev/null @@ -1,9 +0,0 @@ -#version 310 es -#extension GL_EXT_tessellation_shader : require -layout(triangles, ccw, fractional_even_spacing) in; - -void main() -{ - gl_Position = vec4(1.0); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/tese/cw.tese b/deps/SPIRV-Cross/reference/shaders/tese/cw.tese deleted file mode 100644 index 95781493d8..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/tese/cw.tese +++ /dev/null @@ -1,9 +0,0 @@ -#version 310 es -#extension GL_EXT_tessellation_shader : require -layout(triangles, cw, fractional_even_spacing) in; - -void main() -{ - gl_Position = vec4(1.0); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/tese/equal.tese b/deps/SPIRV-Cross/reference/shaders/tese/equal.tese deleted file mode 100644 index 6d30518a30..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/tese/equal.tese +++ /dev/null @@ -1,9 +0,0 @@ -#version 310 es -#extension GL_EXT_tessellation_shader : require -layout(triangles, cw, equal_spacing) in; - -void main() -{ - gl_Position = vec4(1.0); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/tese/fractional_even.tese b/deps/SPIRV-Cross/reference/shaders/tese/fractional_even.tese deleted file mode 100644 index 95781493d8..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/tese/fractional_even.tese +++ /dev/null @@ -1,9 +0,0 @@ -#version 310 es -#extension GL_EXT_tessellation_shader : require -layout(triangles, cw, fractional_even_spacing) in; - -void main() -{ - gl_Position = vec4(1.0); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/tese/fractional_odd.tese b/deps/SPIRV-Cross/reference/shaders/tese/fractional_odd.tese deleted file mode 100644 index 608c19aba7..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/tese/fractional_odd.tese +++ /dev/null @@ -1,9 +0,0 @@ -#version 310 es -#extension GL_EXT_tessellation_shader : require -layout(triangles, cw, fractional_odd_spacing) in; - -void main() -{ - gl_Position = vec4(1.0); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/tese/line.tese b/deps/SPIRV-Cross/reference/shaders/tese/line.tese deleted file mode 100644 index 8b6ad8da20..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/tese/line.tese +++ /dev/null @@ -1,9 +0,0 @@ -#version 310 es -#extension GL_EXT_tessellation_shader : require -layout(isolines, point_mode, fractional_even_spacing) in; - -void main() -{ - gl_Position = vec4(1.0); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/tese/triangle.tese b/deps/SPIRV-Cross/reference/shaders/tese/triangle.tese deleted file mode 100644 index 95781493d8..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/tese/triangle.tese +++ /dev/null @@ -1,9 +0,0 @@ -#version 310 es -#extension GL_EXT_tessellation_shader : require -layout(triangles, cw, fractional_even_spacing) in; - -void main() -{ - gl_Position = vec4(1.0); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/tese/water_tess.tese b/deps/SPIRV-Cross/reference/shaders/tese/water_tess.tese deleted file mode 100644 index e743ed3e9c..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/tese/water_tess.tese +++ /dev/null @@ -1,61 +0,0 @@ -#version 310 es -#extension GL_EXT_tessellation_shader : require -layout(quads, cw, fractional_even_spacing) in; - -layout(binding = 1, std140) uniform UBO -{ - mat4 uMVP; - vec4 uScale; - vec2 uInvScale; - vec3 uCamPos; - vec2 uPatchSize; - vec2 uInvHeightmapSize; -} _31; - -layout(binding = 0) uniform mediump sampler2D uHeightmapDisplacement; - -layout(location = 0) patch in vec2 vOutPatchPosBase; -layout(location = 1) patch in vec4 vPatchLods; -layout(location = 1) out vec4 vGradNormalTex; -layout(location = 0) out vec3 vWorld; - -vec2 lerp_vertex(vec2 tess_coord) -{ - return vOutPatchPosBase + (tess_coord * _31.uPatchSize); -} - -mediump vec2 lod_factor(vec2 tess_coord) -{ - mediump vec2 x = mix(vPatchLods.yx, vPatchLods.zw, vec2(tess_coord.x)); - mediump float level = mix(x.x, x.y, tess_coord.y); - mediump float floor_level = floor(level); - mediump float fract_level = level - floor_level; - return vec2(floor_level, fract_level); -} - -mediump vec3 sample_height_displacement(vec2 uv, vec2 off, mediump vec2 lod) -{ - return mix(textureLod(uHeightmapDisplacement, uv + (off * 0.5), lod.x).xyz, textureLod(uHeightmapDisplacement, uv + (off * 1.0), lod.x + 1.0).xyz, vec3(lod.y)); -} - -void main() -{ - vec2 tess_coord = gl_TessCoord.xy; - vec2 param = tess_coord; - vec2 pos = lerp_vertex(param); - vec2 param_1 = tess_coord; - mediump vec2 lod = lod_factor(param_1); - vec2 tex = pos * _31.uInvHeightmapSize; - pos *= _31.uScale.xy; - mediump float delta_mod = exp2(lod.x); - vec2 off = _31.uInvHeightmapSize * delta_mod; - vGradNormalTex = vec4(tex + (_31.uInvHeightmapSize * 0.5), tex * _31.uScale.zw); - vec2 param_2 = tex; - vec2 param_3 = off; - vec2 param_4 = lod; - vec3 height_displacement = sample_height_displacement(param_2, param_3, param_4); - pos += height_displacement.yz; - vWorld = vec3(pos.x, height_displacement.x, pos.y); - gl_Position = _31.uMVP * vec4(vWorld, 1.0); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/vert/basic.vert b/deps/SPIRV-Cross/reference/shaders/vert/basic.vert deleted file mode 100644 index 05504eb2f2..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/vert/basic.vert +++ /dev/null @@ -1,17 +0,0 @@ -#version 310 es - -layout(std140) uniform UBO -{ - mat4 uMVP; -} _16; - -layout(location = 0) in vec4 aVertex; -layout(location = 0) out vec3 vNormal; -layout(location = 1) in vec3 aNormal; - -void main() -{ - gl_Position = _16.uMVP * aVertex; - vNormal = aNormal; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/vert/ground.vert b/deps/SPIRV-Cross/reference/shaders/vert/ground.vert deleted file mode 100644 index b028cc34c6..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/vert/ground.vert +++ /dev/null @@ -1,110 +0,0 @@ -#version 310 es - -struct PatchData -{ - vec4 Position; - vec4 LODs; -}; - -layout(binding = 0, std140) uniform PerPatch -{ - PatchData Patches[256]; -} _53; - -layout(binding = 2, std140) uniform GlobalGround -{ - vec4 GroundScale; - vec4 GroundPosition; - vec4 InvGroundSize_PatchScale; -} _156; - -layout(binding = 0, std140) uniform GlobalVSData -{ - vec4 g_ViewProj_Row0; - vec4 g_ViewProj_Row1; - vec4 g_ViewProj_Row2; - vec4 g_ViewProj_Row3; - vec4 g_CamPos; - vec4 g_CamRight; - vec4 g_CamUp; - vec4 g_CamFront; - vec4 g_SunDir; - vec4 g_SunColor; - vec4 g_TimeParams; - vec4 g_ResolutionParams; - vec4 g_CamAxisRight; - vec4 g_FogColor_Distance; - vec4 g_ShadowVP_Row0; - vec4 g_ShadowVP_Row1; - vec4 g_ShadowVP_Row2; - vec4 g_ShadowVP_Row3; -} _236; - -layout(binding = 1) uniform mediump sampler2D TexLOD; -layout(binding = 0) uniform mediump sampler2D TexHeightmap; - -layout(location = 1) in vec4 LODWeights; -uniform int SPIRV_Cross_BaseInstance; -layout(location = 0) in vec2 Position; -layout(location = 1) out vec3 EyeVec; -layout(location = 0) out vec2 TexCoord; - -vec2 warp_position() -{ - float vlod = dot(LODWeights, _53.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].LODs); - vlod = all(equal(LODWeights, vec4(0.0))) ? _53.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].Position.w : vlod; - float floor_lod = floor(vlod); - float fract_lod = vlod - floor_lod; - uint ufloor_lod = uint(floor_lod); - uvec2 uPosition = uvec2(Position); - uvec2 mask = (uvec2(1u) << uvec2(ufloor_lod, ufloor_lod + 1u)) - uvec2(1u); - uint _106; - if (uPosition.x < 32u) - { - _106 = mask.x; - } - else - { - _106 = 0u; - } - uint _116 = _106; - uint _117; - if (uPosition.y < 32u) - { - _117 = mask.y; - } - else - { - _117 = 0u; - } - uvec2 rounding = uvec2(_116, _117); - vec4 lower_upper_snapped = vec4((uPosition + rounding).xyxy & (~mask).xxyy); - return mix(lower_upper_snapped.xy, lower_upper_snapped.zw, vec2(fract_lod)); -} - -vec2 lod_factor(vec2 uv) -{ - float level = textureLod(TexLOD, uv, 0.0).x * 7.96875; - float floor_level = floor(level); - float fract_level = level - floor_level; - return vec2(floor_level, fract_level); -} - -void main() -{ - vec2 PatchPos = _53.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].Position.xz * _156.InvGroundSize_PatchScale.zw; - vec2 WarpedPos = warp_position(); - vec2 VertexPos = PatchPos + WarpedPos; - vec2 NormalizedPos = VertexPos * _156.InvGroundSize_PatchScale.xy; - vec2 param = NormalizedPos; - vec2 lod = lod_factor(param); - vec2 Offset = _156.InvGroundSize_PatchScale.xy * exp2(lod.x); - float Elevation = mix(textureLod(TexHeightmap, NormalizedPos + (Offset * 0.5), lod.x).x, textureLod(TexHeightmap, NormalizedPos + (Offset * 1.0), lod.x + 1.0).x, lod.y); - vec3 WorldPos = vec3(NormalizedPos.x, Elevation, NormalizedPos.y); - WorldPos *= _156.GroundScale.xyz; - WorldPos += _156.GroundPosition.xyz; - EyeVec = WorldPos - _236.g_CamPos.xyz; - TexCoord = NormalizedPos + (_156.InvGroundSize_PatchScale.xy * 0.5); - gl_Position = (((_236.g_ViewProj_Row0 * WorldPos.x) + (_236.g_ViewProj_Row1 * WorldPos.y)) + (_236.g_ViewProj_Row2 * WorldPos.z)) + _236.g_ViewProj_Row3; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/vert/ocean.vert b/deps/SPIRV-Cross/reference/shaders/vert/ocean.vert deleted file mode 100644 index d77a29fcbf..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/vert/ocean.vert +++ /dev/null @@ -1,133 +0,0 @@ -#version 310 es - -struct PatchData -{ - vec4 Position; - vec4 LODs; -}; - -layout(binding = 0, std140) uniform Offsets -{ - PatchData Patches[256]; -} _53; - -layout(binding = 4, std140) uniform GlobalOcean -{ - vec4 OceanScale; - vec4 OceanPosition; - vec4 InvOceanSize_PatchScale; - vec4 NormalTexCoordScale; -} _180; - -layout(binding = 0, std140) uniform GlobalVSData -{ - vec4 g_ViewProj_Row0; - vec4 g_ViewProj_Row1; - vec4 g_ViewProj_Row2; - vec4 g_ViewProj_Row3; - vec4 g_CamPos; - vec4 g_CamRight; - vec4 g_CamUp; - vec4 g_CamFront; - vec4 g_SunDir; - vec4 g_SunColor; - vec4 g_TimeParams; - vec4 g_ResolutionParams; - vec4 g_CamAxisRight; - vec4 g_FogColor_Distance; - vec4 g_ShadowVP_Row0; - vec4 g_ShadowVP_Row1; - vec4 g_ShadowVP_Row2; - vec4 g_ShadowVP_Row3; -} _273; - -layout(binding = 1) uniform mediump sampler2D TexLOD; -layout(binding = 0) uniform mediump sampler2D TexDisplacement; - -layout(location = 1) in vec4 LODWeights; -uniform int SPIRV_Cross_BaseInstance; -layout(location = 0) in vec4 Position; -layout(location = 0) out vec3 EyeVec; -layout(location = 1) out vec4 TexCoord; - -vec2 warp_position() -{ - float vlod = dot(LODWeights, _53.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].LODs); - vlod = all(equal(LODWeights, vec4(0.0))) ? _53.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].Position.w : vlod; - float floor_lod = floor(vlod); - float fract_lod = vlod - floor_lod; - uint ufloor_lod = uint(floor_lod); - uvec4 uPosition = uvec4(Position); - uvec2 mask = (uvec2(1u) << uvec2(ufloor_lod, ufloor_lod + 1u)) - uvec2(1u); - uint _107; - if (uPosition.x < 32u) - { - _107 = mask.x; - } - else - { - _107 = 0u; - } - uvec4 rounding; - rounding.x = _107; - uint _119; - if (uPosition.y < 32u) - { - _119 = mask.x; - } - else - { - _119 = 0u; - } - rounding.y = _119; - uint _130; - if (uPosition.x < 32u) - { - _130 = mask.y; - } - else - { - _130 = 0u; - } - rounding.z = _130; - uint _142; - if (uPosition.y < 32u) - { - _142 = mask.y; - } - else - { - _142 = 0u; - } - rounding.w = _142; - vec4 lower_upper_snapped = vec4((uPosition.xyxy + rounding) & (~mask).xxyy); - return mix(lower_upper_snapped.xy, lower_upper_snapped.zw, vec2(fract_lod)); -} - -vec2 lod_factor(vec2 uv) -{ - float level = textureLod(TexLOD, uv, 0.0).x * 7.96875; - float floor_level = floor(level); - float fract_level = level - floor_level; - return vec2(floor_level, fract_level); -} - -void main() -{ - vec2 PatchPos = _53.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].Position.xz * _180.InvOceanSize_PatchScale.zw; - vec2 WarpedPos = warp_position(); - vec2 VertexPos = PatchPos + WarpedPos; - vec2 NormalizedPos = VertexPos * _180.InvOceanSize_PatchScale.xy; - vec2 NormalizedTex = NormalizedPos * _180.NormalTexCoordScale.zw; - vec2 param = NormalizedPos; - vec2 lod = lod_factor(param); - vec2 Offset = (_180.InvOceanSize_PatchScale.xy * exp2(lod.x)) * _180.NormalTexCoordScale.zw; - vec3 Displacement = mix(textureLod(TexDisplacement, NormalizedTex + (Offset * 0.5), lod.x).yxz, textureLod(TexDisplacement, NormalizedTex + (Offset * 1.0), lod.x + 1.0).yxz, vec3(lod.y)); - vec3 WorldPos = vec3(NormalizedPos.x, 0.0, NormalizedPos.y) + Displacement; - WorldPos *= _180.OceanScale.xyz; - WorldPos += _180.OceanPosition.xyz; - EyeVec = WorldPos - _273.g_CamPos.xyz; - TexCoord = vec4(NormalizedTex, NormalizedTex * _180.NormalTexCoordScale.xy) + ((_180.InvOceanSize_PatchScale.xyxy * 0.5) * _180.NormalTexCoordScale.zwzw); - gl_Position = (((_273.g_ViewProj_Row0 * WorldPos.x) + (_273.g_ViewProj_Row1 * WorldPos.y)) + (_273.g_ViewProj_Row2 * WorldPos.z)) + _273.g_ViewProj_Row3; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/vert/texture_buffer.vert b/deps/SPIRV-Cross/reference/shaders/vert/texture_buffer.vert deleted file mode 100644 index e9442ce119..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/vert/texture_buffer.vert +++ /dev/null @@ -1,11 +0,0 @@ -#version 310 es -#extension GL_OES_texture_buffer : require - -layout(binding = 4) uniform highp samplerBuffer uSamp; -layout(binding = 5, rgba32f) uniform readonly highp imageBuffer uSampo; - -void main() -{ - gl_Position = texelFetch(uSamp, 10) + imageLoad(uSampo, 100); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/vert/ubo.vert b/deps/SPIRV-Cross/reference/shaders/vert/ubo.vert deleted file mode 100644 index 4e7236b290..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/vert/ubo.vert +++ /dev/null @@ -1,17 +0,0 @@ -#version 310 es - -layout(binding = 0, std140) uniform UBO -{ - mat4 mvp; -} _16; - -layout(location = 0) in vec4 aVertex; -layout(location = 0) out vec3 vNormal; -layout(location = 1) in vec3 aNormal; - -void main() -{ - gl_Position = _16.mvp * aVertex; - vNormal = aNormal; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag b/deps/SPIRV-Cross/reference/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag deleted file mode 100644 index af64fb87aa..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag +++ /dev/null @@ -1,31 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -uniform mediump sampler2DShadow SPIRV_Cross_CombineduDepthuSampler; -uniform mediump sampler2D SPIRV_Cross_CombineduDepthuSampler1; - -layout(location = 0) out float FragColor; - -float samp2(mediump sampler2DShadow SPIRV_Cross_Combinedts) -{ - return texture(SPIRV_Cross_Combinedts, vec3(vec3(1.0).xy, vec3(1.0).z)); -} - -float samp3(mediump sampler2D SPIRV_Cross_Combinedts) -{ - return texture(SPIRV_Cross_Combinedts, vec2(1.0)).x; -} - -float samp(mediump sampler2DShadow SPIRV_Cross_Combinedts, mediump sampler2D SPIRV_Cross_Combinedts1) -{ - float r0 = samp2(SPIRV_Cross_Combinedts); - float r1 = samp3(SPIRV_Cross_Combinedts1); - return r0 + r1; -} - -void main() -{ - FragColor = samp(SPIRV_Cross_CombineduDepthuSampler, SPIRV_Cross_CombineduDepthuSampler1); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag.vk b/deps/SPIRV-Cross/reference/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag.vk deleted file mode 100644 index f475ae53a9..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag.vk +++ /dev/null @@ -1,32 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(set = 0, binding = 2) uniform mediump texture2D uDepth; -layout(set = 0, binding = 0) uniform mediump samplerShadow uSampler; -layout(set = 0, binding = 1) uniform mediump sampler uSampler1; - -layout(location = 0) out float FragColor; - -float samp2(mediump texture2D t, mediump samplerShadow s) -{ - return texture(sampler2DShadow(t, s), vec3(vec3(1.0).xy, vec3(1.0).z)); -} - -float samp3(mediump texture2D t, mediump sampler s) -{ - return texture(sampler2D(t, s), vec2(1.0)).x; -} - -float samp(mediump texture2D t, mediump samplerShadow s, mediump sampler s1) -{ - float r0 = samp2(t, s); - float r1 = samp3(t, s1); - return r0 + r1; -} - -void main() -{ - FragColor = samp(uDepth, uSampler, uSampler1); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/vulkan/frag/combined-texture-sampler.vk.frag b/deps/SPIRV-Cross/reference/shaders/vulkan/frag/combined-texture-sampler.vk.frag deleted file mode 100644 index 5b9c0ddadf..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/vulkan/frag/combined-texture-sampler.vk.frag +++ /dev/null @@ -1,48 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -uniform mediump sampler2D SPIRV_Cross_CombineduTexture0uSampler0; -uniform mediump sampler2D SPIRV_Cross_CombineduTexture1uSampler1; -uniform mediump sampler2D SPIRV_Cross_CombineduTexture1uSampler0; -uniform mediump sampler2D SPIRV_Cross_CombineduTexture0uSampler1; - -layout(location = 0) in vec2 vTex; -layout(location = 0) out vec4 FragColor; - -vec4 sample_dual(mediump sampler2D SPIRV_Cross_Combinedtexsamp) -{ - return texture(SPIRV_Cross_Combinedtexsamp, vTex); -} - -vec4 sample_duals() -{ - vec4 a = sample_dual(SPIRV_Cross_CombineduTexture0uSampler0); - vec4 b = sample_dual(SPIRV_Cross_CombineduTexture1uSampler1); - return a + b; -} - -vec4 sample_global_tex(mediump sampler2D SPIRV_Cross_CombineduTexture0samp, mediump sampler2D SPIRV_Cross_CombineduTexture1samp) -{ - vec4 a = texture(SPIRV_Cross_CombineduTexture0samp, vTex); - vec4 b = sample_dual(SPIRV_Cross_CombineduTexture1samp); - return a + b; -} - -vec4 sample_global_sampler(mediump sampler2D SPIRV_Cross_CombinedtexuSampler0, mediump sampler2D SPIRV_Cross_CombinedtexuSampler1) -{ - vec4 a = texture(SPIRV_Cross_CombinedtexuSampler0, vTex); - vec4 b = sample_dual(SPIRV_Cross_CombinedtexuSampler1); - return a + b; -} - -void main() -{ - vec4 c0 = sample_duals(); - vec4 c1 = sample_global_tex(SPIRV_Cross_CombineduTexture0uSampler0, SPIRV_Cross_CombineduTexture1uSampler0); - vec4 c2 = sample_global_tex(SPIRV_Cross_CombineduTexture0uSampler1, SPIRV_Cross_CombineduTexture1uSampler1); - vec4 c3 = sample_global_sampler(SPIRV_Cross_CombineduTexture0uSampler0, SPIRV_Cross_CombineduTexture0uSampler1); - vec4 c4 = sample_global_sampler(SPIRV_Cross_CombineduTexture1uSampler0, SPIRV_Cross_CombineduTexture1uSampler1); - FragColor = (((c0 + c1) + c2) + c3) + c4; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/vulkan/frag/combined-texture-sampler.vk.frag.vk b/deps/SPIRV-Cross/reference/shaders/vulkan/frag/combined-texture-sampler.vk.frag.vk deleted file mode 100644 index ae8df4c925..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/vulkan/frag/combined-texture-sampler.vk.frag.vk +++ /dev/null @@ -1,48 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(set = 0, binding = 2) uniform mediump texture2D uTexture0; -layout(set = 0, binding = 3) uniform mediump texture2D uTexture1; -layout(set = 0, binding = 0) uniform mediump sampler uSampler0; -layout(set = 0, binding = 1) uniform mediump sampler uSampler1; - -layout(location = 0) in vec2 vTex; -layout(location = 0) out vec4 FragColor; - -vec4 sample_dual(mediump sampler samp, mediump texture2D tex) -{ - return texture(sampler2D(tex, samp), vTex); -} - -vec4 sample_duals() -{ - vec4 a = sample_dual(uSampler0, uTexture0); - vec4 b = sample_dual(uSampler1, uTexture1); - return a + b; -} - -vec4 sample_global_tex(mediump sampler samp) -{ - vec4 a = texture(sampler2D(uTexture0, samp), vTex); - vec4 b = sample_dual(samp, uTexture1); - return a + b; -} - -vec4 sample_global_sampler(mediump texture2D tex) -{ - vec4 a = texture(sampler2D(tex, uSampler0), vTex); - vec4 b = sample_dual(uSampler1, tex); - return a + b; -} - -void main() -{ - vec4 c0 = sample_duals(); - vec4 c1 = sample_global_tex(uSampler0); - vec4 c2 = sample_global_tex(uSampler1); - vec4 c3 = sample_global_sampler(uTexture0); - vec4 c4 = sample_global_sampler(uTexture1); - FragColor = (((c0 + c1) + c2) + c3) + c4; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/vulkan/frag/desktop-mediump.vk.frag b/deps/SPIRV-Cross/reference/shaders/vulkan/frag/desktop-mediump.vk.frag deleted file mode 100644 index 8f7508ee8e..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/vulkan/frag/desktop-mediump.vk.frag +++ /dev/null @@ -1,12 +0,0 @@ -#version 450 - -layout(location = 0) out vec4 FragColor; -layout(location = 0) in vec4 F; -layout(location = 1) flat in ivec4 I; -layout(location = 2) flat in uvec4 U; - -void main() -{ - FragColor = (F + vec4(I)) + vec4(U); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/vulkan/frag/desktop-mediump.vk.frag.vk b/deps/SPIRV-Cross/reference/shaders/vulkan/frag/desktop-mediump.vk.frag.vk deleted file mode 100644 index 4c0506b110..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/vulkan/frag/desktop-mediump.vk.frag.vk +++ /dev/null @@ -1,12 +0,0 @@ -#version 450 - -layout(location = 0) out mediump vec4 FragColor; -layout(location = 0) in mediump vec4 F; -layout(location = 1) flat in mediump ivec4 I; -layout(location = 2) flat in mediump uvec4 U; - -void main() -{ - FragColor = (F + vec4(I)) + vec4(U); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/vulkan/frag/input-attachment-ms.vk.frag b/deps/SPIRV-Cross/reference/shaders/vulkan/frag/input-attachment-ms.vk.frag deleted file mode 100644 index ea460c1fae..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/vulkan/frag/input-attachment-ms.vk.frag +++ /dev/null @@ -1,12 +0,0 @@ -#version 450 - -layout(binding = 0) uniform sampler2DMS uSubpass0; -layout(binding = 1) uniform sampler2DMS uSubpass1; - -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = (texelFetch(uSubpass0, ivec2(gl_FragCoord.xy), 1) + texelFetch(uSubpass1, ivec2(gl_FragCoord.xy), 2)) + texelFetch(uSubpass0, ivec2(gl_FragCoord.xy), gl_SampleID); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/vulkan/frag/input-attachment-ms.vk.frag.vk b/deps/SPIRV-Cross/reference/shaders/vulkan/frag/input-attachment-ms.vk.frag.vk deleted file mode 100644 index 462df22a19..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/vulkan/frag/input-attachment-ms.vk.frag.vk +++ /dev/null @@ -1,12 +0,0 @@ -#version 450 - -layout(input_attachment_index = 0, set = 0, binding = 0) uniform subpassInputMS uSubpass0; -layout(input_attachment_index = 1, set = 0, binding = 1) uniform subpassInputMS uSubpass1; - -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = (subpassLoad(uSubpass0, 1) + subpassLoad(uSubpass1, 2)) + subpassLoad(uSubpass0, gl_SampleID); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/vulkan/frag/input-attachment.vk.frag b/deps/SPIRV-Cross/reference/shaders/vulkan/frag/input-attachment.vk.frag deleted file mode 100644 index 8d216b2c49..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/vulkan/frag/input-attachment.vk.frag +++ /dev/null @@ -1,14 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(binding = 0) uniform mediump sampler2D uSubpass0; -layout(binding = 1) uniform mediump sampler2D uSubpass1; - -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = texelFetch(uSubpass0, ivec2(gl_FragCoord.xy), 0) + texelFetch(uSubpass1, ivec2(gl_FragCoord.xy), 0); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/vulkan/frag/input-attachment.vk.frag.vk b/deps/SPIRV-Cross/reference/shaders/vulkan/frag/input-attachment.vk.frag.vk deleted file mode 100644 index c8b5d9a70d..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/vulkan/frag/input-attachment.vk.frag.vk +++ /dev/null @@ -1,14 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(input_attachment_index = 0, set = 0, binding = 0) uniform mediump subpassInput uSubpass0; -layout(input_attachment_index = 1, set = 0, binding = 1) uniform mediump subpassInput uSubpass1; - -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = subpassLoad(uSubpass0) + subpassLoad(uSubpass1); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/vulkan/frag/push-constant.frag.vk b/deps/SPIRV-Cross/reference/shaders/vulkan/frag/push-constant.frag.vk deleted file mode 100644 index 748a028678..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/vulkan/frag/push-constant.frag.vk +++ /dev/null @@ -1,18 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(push_constant, std430) uniform PushConstants -{ - vec4 value0; - vec4 value1; -} push; - -layout(location = 0) out vec4 FragColor; -layout(location = 0) in vec4 vColor; - -void main() -{ - FragColor = ((vColor + push.value0) + push.value1); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/vulkan/frag/push-constant.vk.frag b/deps/SPIRV-Cross/reference/shaders/vulkan/frag/push-constant.vk.frag deleted file mode 100644 index c04a7ca488..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/vulkan/frag/push-constant.vk.frag +++ /dev/null @@ -1,20 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -struct PushConstants -{ - vec4 value0; - vec4 value1; -}; - -uniform PushConstants push; - -layout(location = 0) out vec4 FragColor; -layout(location = 0) in vec4 vColor; - -void main() -{ - FragColor = (vColor + push.value0) + push.value1; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/vulkan/frag/push-constant.vk.frag.vk b/deps/SPIRV-Cross/reference/shaders/vulkan/frag/push-constant.vk.frag.vk deleted file mode 100644 index 6cec90f19e..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/vulkan/frag/push-constant.vk.frag.vk +++ /dev/null @@ -1,18 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(push_constant, std430) uniform PushConstants -{ - vec4 value0; - vec4 value1; -} push; - -layout(location = 0) out vec4 FragColor; -layout(location = 0) in vec4 vColor; - -void main() -{ - FragColor = (vColor + push.value0) + push.value1; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/vulkan/frag/separate-sampler-texture.vk.frag b/deps/SPIRV-Cross/reference/shaders/vulkan/frag/separate-sampler-texture.vk.frag deleted file mode 100644 index 78477cfbae..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/vulkan/frag/separate-sampler-texture.vk.frag +++ /dev/null @@ -1,37 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -uniform mediump sampler2D SPIRV_Cross_CombineduTextureuSampler; -uniform mediump sampler2DArray SPIRV_Cross_CombineduTextureArrayuSampler; -uniform mediump samplerCube SPIRV_Cross_CombineduTextureCubeuSampler; -uniform mediump sampler3D SPIRV_Cross_CombineduTexture3DuSampler; - -layout(location = 0) in vec2 vTex; -layout(location = 1) in vec3 vTex3; -layout(location = 0) out vec4 FragColor; - -vec4 sample_func(vec2 uv, mediump sampler2D SPIRV_Cross_CombineduTexturesamp) -{ - return texture(SPIRV_Cross_CombineduTexturesamp, uv); -} - -vec4 sample_func_dual(vec2 uv, mediump sampler2D SPIRV_Cross_Combinedtexsamp) -{ - return texture(SPIRV_Cross_Combinedtexsamp, uv); -} - -void main() -{ - vec2 off = vec2(1.0) / vec2(textureSize(SPIRV_Cross_CombineduTextureuSampler, 0)); - vec2 off2 = vec2(1.0) / vec2(textureSize(SPIRV_Cross_CombineduTextureuSampler, 1)); - highp vec2 param = (vTex + off) + off2; - vec4 c0 = sample_func(param, SPIRV_Cross_CombineduTextureuSampler); - highp vec2 param_1 = (vTex + off) + off2; - vec4 c1 = sample_func_dual(param_1, SPIRV_Cross_CombineduTextureuSampler); - vec4 c2 = texture(SPIRV_Cross_CombineduTextureArrayuSampler, vTex3); - vec4 c3 = texture(SPIRV_Cross_CombineduTextureCubeuSampler, vTex3); - vec4 c4 = texture(SPIRV_Cross_CombineduTexture3DuSampler, vTex3); - FragColor = (((c0 + c1) + c2) + c3) + c4; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/vulkan/frag/separate-sampler-texture.vk.frag.vk b/deps/SPIRV-Cross/reference/shaders/vulkan/frag/separate-sampler-texture.vk.frag.vk deleted file mode 100644 index cfa2f39616..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/vulkan/frag/separate-sampler-texture.vk.frag.vk +++ /dev/null @@ -1,38 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(set = 0, binding = 1) uniform mediump texture2D uTexture; -layout(set = 0, binding = 0) uniform mediump sampler uSampler; -layout(set = 0, binding = 4) uniform mediump texture2DArray uTextureArray; -layout(set = 0, binding = 3) uniform mediump textureCube uTextureCube; -layout(set = 0, binding = 2) uniform mediump texture3D uTexture3D; - -layout(location = 0) in vec2 vTex; -layout(location = 1) in vec3 vTex3; -layout(location = 0) out vec4 FragColor; - -vec4 sample_func(mediump sampler samp, vec2 uv) -{ - return texture(sampler2D(uTexture, samp), uv); -} - -vec4 sample_func_dual(mediump sampler samp, mediump texture2D tex, vec2 uv) -{ - return texture(sampler2D(tex, samp), uv); -} - -void main() -{ - vec2 off = vec2(1.0) / vec2(textureSize(sampler2D(uTexture, uSampler), 0)); - vec2 off2 = vec2(1.0) / vec2(textureSize(sampler2D(uTexture, uSampler), 1)); - highp vec2 param = (vTex + off) + off2; - vec4 c0 = sample_func(uSampler, param); - highp vec2 param_1 = (vTex + off) + off2; - vec4 c1 = sample_func_dual(uSampler, uTexture, param_1); - vec4 c2 = texture(sampler2DArray(uTextureArray, uSampler), vTex3); - vec4 c3 = texture(samplerCube(uTextureCube, uSampler), vTex3); - vec4 c4 = texture(sampler3D(uTexture3D, uSampler), vTex3); - FragColor = (((c0 + c1) + c2) + c3) + c4; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/vulkan/frag/spec-constant.vk.frag b/deps/SPIRV-Cross/reference/shaders/vulkan/frag/spec-constant.vk.frag deleted file mode 100644 index 7976042a85..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/vulkan/frag/spec-constant.vk.frag +++ /dev/null @@ -1,59 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -struct Foo -{ - float elems[(4 + 2)]; -}; - -layout(location = 0) out vec4 FragColor; - -void main() -{ - float t0 = 1.0; - float t1 = 2.0; - mediump uint c0 = (uint(3) + 0u); - mediump int c1 = (-3); - mediump int c2 = (~3); - mediump int c3 = (3 + 4); - mediump int c4 = (3 - 4); - mediump int c5 = (3 * 4); - mediump int c6 = (3 / 4); - mediump uint c7 = (5u / 6u); - mediump int c8 = (3 % 4); - mediump uint c9 = (5u % 6u); - mediump int c10 = (3 >> 4); - mediump uint c11 = (5u >> 6u); - mediump int c12 = (3 << 4); - mediump int c13 = (3 | 4); - mediump int c14 = (3 ^ 4); - mediump int c15 = (3 & 4); - bool c16 = (false || true); - bool c17 = (false && true); - bool c18 = (!false); - bool c19 = (false == true); - bool c20 = (false != true); - bool c21 = (3 == 4); - bool c22 = (3 != 4); - bool c23 = (3 < 4); - bool c24 = (5u < 6u); - bool c25 = (3 > 4); - bool c26 = (5u > 6u); - bool c27 = (3 <= 4); - bool c28 = (5u <= 6u); - bool c29 = (3 >= 4); - bool c30 = (5u >= 6u); - mediump int c31 = c8 + c3; - mediump int c32 = int(5u + 0u); - bool c33 = (3 != int(0u)); - bool c34 = (5u != 0u); - mediump int c35 = int(false); - mediump uint c36 = uint(false); - float c37 = float(false); - float vec0[(3 + 3)][8]; - float vec1[(3 + 2)]; - Foo foo; - FragColor = ((vec4(t0 + t1) + vec4(vec0[0][0])) + vec4(vec1[0])) + vec4(foo.elems[3]); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/vulkan/frag/spec-constant.vk.frag.vk b/deps/SPIRV-Cross/reference/shaders/vulkan/frag/spec-constant.vk.frag.vk deleted file mode 100644 index d0765cc8bd..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/vulkan/frag/spec-constant.vk.frag.vk +++ /dev/null @@ -1,68 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(constant_id = 1) const float a = 1.0; -layout(constant_id = 2) const float b = 2.0; -layout(constant_id = 3) const int c = 3; -layout(constant_id = 4) const int d = 4; -layout(constant_id = 5) const uint e = 5u; -layout(constant_id = 6) const uint f = 6u; -layout(constant_id = 7) const bool g = false; -layout(constant_id = 8) const bool h = true; - -struct Foo -{ - float elems[(d + 2)]; -}; - -layout(location = 0) out vec4 FragColor; - -void main() -{ - float t0 = a; - float t1 = b; - mediump uint c0 = (uint(c) + 0u); - mediump int c1 = (-c); - mediump int c2 = (~c); - mediump int c3 = (c + d); - mediump int c4 = (c - d); - mediump int c5 = (c * d); - mediump int c6 = (c / d); - mediump uint c7 = (e / f); - mediump int c8 = (c % d); - mediump uint c9 = (e % f); - mediump int c10 = (c >> d); - mediump uint c11 = (e >> f); - mediump int c12 = (c << d); - mediump int c13 = (c | d); - mediump int c14 = (c ^ d); - mediump int c15 = (c & d); - bool c16 = (g || h); - bool c17 = (g && h); - bool c18 = (!g); - bool c19 = (g == h); - bool c20 = (g != h); - bool c21 = (c == d); - bool c22 = (c != d); - bool c23 = (c < d); - bool c24 = (e < f); - bool c25 = (c > d); - bool c26 = (e > f); - bool c27 = (c <= d); - bool c28 = (e <= f); - bool c29 = (c >= d); - bool c30 = (e >= f); - mediump int c31 = c8 + c3; - mediump int c32 = int(e + 0u); - bool c33 = (c != int(0u)); - bool c34 = (e != 0u); - mediump int c35 = int(g); - mediump uint c36 = uint(g); - float c37 = float(g); - float vec0[(c + 3)][8]; - float vec1[(c + 2)]; - Foo foo; - FragColor = ((vec4(t0 + t1) + vec4(vec0[0][0])) + vec4(vec1[0])) + vec4(foo.elems[c]); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/vulkan/vert/multiview.nocompat.vk.vert b/deps/SPIRV-Cross/reference/shaders/vulkan/vert/multiview.nocompat.vk.vert deleted file mode 100644 index 533738efc3..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/vulkan/vert/multiview.nocompat.vk.vert +++ /dev/null @@ -1,15 +0,0 @@ -#version 310 es -#extension GL_OVR_multiview2 : require - -layout(binding = 0, std140) uniform MVPs -{ - mat4 MVP[2]; -} _19; - -layout(location = 0) in vec4 Position; - -void main() -{ - gl_Position = _19.MVP[gl_ViewID_OVR] * Position; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/vulkan/vert/multiview.nocompat.vk.vert.vk b/deps/SPIRV-Cross/reference/shaders/vulkan/vert/multiview.nocompat.vk.vert.vk deleted file mode 100644 index 90055473d9..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/vulkan/vert/multiview.nocompat.vk.vert.vk +++ /dev/null @@ -1,15 +0,0 @@ -#version 310 es -#extension GL_EXT_multiview : require - -layout(set = 0, binding = 0, std140) uniform MVPs -{ - mat4 MVP[2]; -} _19; - -layout(location = 0) in vec4 Position; - -void main() -{ - gl_Position = _19.MVP[gl_ViewIndex] * Position; -} - diff --git a/deps/SPIRV-Cross/reference/shaders/vulkan/vert/vulkan-vertex.vert b/deps/SPIRV-Cross/reference/shaders/vulkan/vert/vulkan-vertex.vert deleted file mode 100644 index 8de2b111ef..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/vulkan/vert/vulkan-vertex.vert +++ /dev/null @@ -1,9 +0,0 @@ -#version 310 es - -uniform int SPIRV_Cross_BaseInstance; - -void main() -{ - gl_Position = (vec4(1.0, 2.0, 3.0, 4.0) * float((gl_VertexID + (gl_InstanceID + SPIRV_Cross_BaseInstance)))); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/vulkan/vert/vulkan-vertex.vert.vk b/deps/SPIRV-Cross/reference/shaders/vulkan/vert/vulkan-vertex.vert.vk deleted file mode 100644 index 9ee3cc0997..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/vulkan/vert/vulkan-vertex.vert.vk +++ /dev/null @@ -1,7 +0,0 @@ -#version 310 es - -void main() -{ - gl_Position = (vec4(1.0, 2.0, 3.0, 4.0) * float((gl_VertexIndex + gl_InstanceIndex))); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/vulkan/vert/vulkan-vertex.vk.vert b/deps/SPIRV-Cross/reference/shaders/vulkan/vert/vulkan-vertex.vk.vert deleted file mode 100644 index 60ba1882f8..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/vulkan/vert/vulkan-vertex.vk.vert +++ /dev/null @@ -1,9 +0,0 @@ -#version 310 es - -uniform int SPIRV_Cross_BaseInstance; - -void main() -{ - gl_Position = vec4(1.0, 2.0, 3.0, 4.0) * float(gl_VertexID + (gl_InstanceID + SPIRV_Cross_BaseInstance)); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/vulkan/vert/vulkan-vertex.vk.vert.vk b/deps/SPIRV-Cross/reference/shaders/vulkan/vert/vulkan-vertex.vk.vert.vk deleted file mode 100644 index 8c4930d7a8..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/vulkan/vert/vulkan-vertex.vk.vert.vk +++ /dev/null @@ -1,7 +0,0 @@ -#version 310 es - -void main() -{ - gl_Position = vec4(1.0, 2.0, 3.0, 4.0) * float(gl_VertexIndex + gl_InstanceIndex); -} - diff --git a/deps/SPIRV-Cross/samples/cpp/Makefile b/deps/SPIRV-Cross/samples/cpp/Makefile deleted file mode 100644 index 225bb3d57d..0000000000 --- a/deps/SPIRV-Cross/samples/cpp/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -SOURCES := $(wildcard *.comp) -SPIRV := $(SOURCES:.comp=.spv) -CPP_INTERFACE := $(SOURCES:.comp=.spv.cpp) -CPP_DRIVER := $(SOURCES:.comp=.cpp) -EXECUTABLES := $(SOURCES:.comp=.shader) -OBJECTS := $(CPP_DRIVER:.cpp=.o) $(CPP_INTERFACE:.cpp=.o) - -CXXFLAGS += -std=c++11 -I../../include -I. -LDFLAGS += -pthread -lm - -all: $(EXECUTABLES) - -%.spv: %.comp - glslangValidator -V -o $@ $< - -%.spv.cpp: %.spv - ../../spirv-cross --cpp --output $@ $< - -%.o: %.cpp - $(CXX) -c -o $@ $< $(CXXFLAGS) - -%.shader: %.o %.spv.o - $(CXX) -o $@ $^ $(LDFLAGS) - -clean: - $(RM) -f $(EXECUTABLES) $(SPIRV) $(CPP_INTERFACE) $(OBJECTS) - -.PHONY: clean diff --git a/deps/SPIRV-Cross/samples/cpp/atomics.comp b/deps/SPIRV-Cross/samples/cpp/atomics.comp deleted file mode 100644 index 0bf6d2ad01..0000000000 --- a/deps/SPIRV-Cross/samples/cpp/atomics.comp +++ /dev/null @@ -1,29 +0,0 @@ -#version 310 es -layout(local_size_x = 64) in; - -layout(set = 0, binding = 0, std430) readonly buffer SSBO0 -{ - float inputs[]; -}; - -layout(set = 0, binding = 1, std430) writeonly buffer SSBO1 -{ - float outputs[]; -}; - -layout(set = 0, binding = 2, std430) buffer SSBO2 -{ - uint counter; -}; - -void main() -{ - // Builds a tightly packed list of all values less than 10.0. - // The output order is random. - float value = inputs[gl_GlobalInvocationID.x]; - if (value < 10.0) - { - uint output_index = atomicAdd(counter, 1u); - outputs[output_index] = value; - } -} diff --git a/deps/SPIRV-Cross/samples/cpp/atomics.cpp b/deps/SPIRV-Cross/samples/cpp/atomics.cpp deleted file mode 100644 index 89351a5ae5..0000000000 --- a/deps/SPIRV-Cross/samples/cpp/atomics.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2015-2017 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "spirv_cross/external_interface.h" -#include - -#ifndef GLM_SWIZZLE -#define GLM_SWIZZLE -#endif - -#ifndef GLM_FORCE_RADIANS -#define GLM_FORCE_RADIANS -#endif - -#include -using namespace glm; - -int main() -{ - // First, we get the C interface to the shader. - // This can be loaded from a dynamic library, or as here, - // linked in as a static library. - auto *iface = spirv_cross_get_interface(); - - // Create an instance of the shader interface. - auto *shader = iface->construct(); - -// Build some input data for our compute shader. -#define NUM_WORKGROUPS 4 - float a[64 * NUM_WORKGROUPS]; - float b[64 * NUM_WORKGROUPS] = {}; - uint32_t counter = 0; - - for (int i = 0; i < 64 * NUM_WORKGROUPS; i++) - { - a[i] = i * 0.46f; - } - - void *aptr = a; - void *bptr = b; - void *cptr = &counter; - - // Bind resources to the shader. - // For resources like samplers and buffers, we provide a list of pointers, - // since UBOs, SSBOs and samplers can be arrays, and can point to different types, - // which is especially true for samplers. - spirv_cross_set_resource(shader, 0, 0, &aptr, sizeof(aptr)); - spirv_cross_set_resource(shader, 0, 1, &bptr, sizeof(bptr)); - spirv_cross_set_resource(shader, 0, 2, &cptr, sizeof(cptr)); - - // We also have to set builtins. - // The relevant builtins will depend on the shader, - // but for compute, there are few builtins, which are gl_NumWorkGroups and gl_WorkGroupID. - // LocalInvocationID and GlobalInvocationID are inferred when executing the invocation. - uvec3 num_workgroups(NUM_WORKGROUPS, 1, 1); - uvec3 work_group_id(0, 0, 0); - spirv_cross_set_builtin(shader, SPIRV_CROSS_BUILTIN_NUM_WORK_GROUPS, &num_workgroups, sizeof(num_workgroups)); - spirv_cross_set_builtin(shader, SPIRV_CROSS_BUILTIN_WORK_GROUP_ID, &work_group_id, sizeof(work_group_id)); - - // Execute 4 work groups. - for (unsigned i = 0; i < NUM_WORKGROUPS; i++) - { - work_group_id.x = i; - iface->invoke(shader); - } - - // Call destructor. - iface->destruct(shader); - - // Verify our output. - // TODO: Implement a test framework that asserts results computed. - fprintf(stderr, "Counter = %u\n", counter); - for (unsigned i = 0; i < counter; i++) - { - fprintf(stderr, "[%3u] = %.1f\n", i, b[i]); - } -} diff --git a/deps/SPIRV-Cross/samples/cpp/multiply.comp b/deps/SPIRV-Cross/samples/cpp/multiply.comp deleted file mode 100644 index 1ac7869ad0..0000000000 --- a/deps/SPIRV-Cross/samples/cpp/multiply.comp +++ /dev/null @@ -1,22 +0,0 @@ -#version 310 es -layout(local_size_x = 64) in; - -layout(set = 0, binding = 0, std430) readonly buffer SSBO0 -{ - vec4 a[]; -}; - -layout(set = 0, binding = 1, std430) readonly buffer SSBO1 -{ - vec4 b[]; -}; - -layout(set = 0, binding = 2, std430) buffer SSBO2 -{ - vec4 c[]; -}; - -void main() -{ - c[gl_GlobalInvocationID.x] = a[gl_GlobalInvocationID.x] * b[gl_GlobalInvocationID.x]; -} diff --git a/deps/SPIRV-Cross/samples/cpp/multiply.cpp b/deps/SPIRV-Cross/samples/cpp/multiply.cpp deleted file mode 100644 index daa1fc6477..0000000000 --- a/deps/SPIRV-Cross/samples/cpp/multiply.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2015-2017 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "spirv_cross/external_interface.h" -#include - -#ifndef GLM_SWIZZLE -#define GLM_SWIZZLE -#endif - -#ifndef GLM_FORCE_RADIANS -#define GLM_FORCE_RADIANS -#endif - -#include -using namespace glm; - -int main() -{ - // First, we get the C interface to the shader. - // This can be loaded from a dynamic library, or as here, - // linked in as a static library. - auto *iface = spirv_cross_get_interface(); - - // Create an instance of the shader interface. - auto *shader = iface->construct(); - -// Build some input data for our compute shader. -#define NUM_WORKGROUPS 4 - vec4 a[64 * NUM_WORKGROUPS]; - vec4 b[64 * NUM_WORKGROUPS]; - vec4 c[64 * NUM_WORKGROUPS] = {}; - - for (int i = 0; i < 64 * NUM_WORKGROUPS; i++) - { - a[i] = vec4(100 + i, 101 + i, 102 + i, 103 + i); - b[i] = vec4(100 - i, 99 - i, 98 - i, 97 - i); - } - - void *aptr = a; - void *bptr = b; - void *cptr = c; - - // Bind resources to the shader. - // For resources like samplers and buffers, we provide a list of pointers, - // since UBOs, SSBOs and samplers can be arrays, and can point to different types, - // which is especially true for samplers. - spirv_cross_set_resource(shader, 0, 0, &aptr, sizeof(aptr)); - spirv_cross_set_resource(shader, 0, 1, &bptr, sizeof(bptr)); - spirv_cross_set_resource(shader, 0, 2, &cptr, sizeof(cptr)); - - // We also have to set builtins. - // The relevant builtins will depend on the shader, - // but for compute, there are few builtins, which are gl_NumWorkGroups and gl_WorkGroupID. - // LocalInvocationID and GlobalInvocationID are inferred when executing the invocation. - uvec3 num_workgroups(NUM_WORKGROUPS, 1, 1); - uvec3 work_group_id(0, 0, 0); - spirv_cross_set_builtin(shader, SPIRV_CROSS_BUILTIN_NUM_WORK_GROUPS, &num_workgroups, sizeof(num_workgroups)); - spirv_cross_set_builtin(shader, SPIRV_CROSS_BUILTIN_WORK_GROUP_ID, &work_group_id, sizeof(work_group_id)); - - // Execute 4 work groups. - for (unsigned i = 0; i < NUM_WORKGROUPS; i++) - { - work_group_id.x = i; - iface->invoke(shader); - } - - // Call destructor. - iface->destruct(shader); - - // Verify our output. - // TODO: Implement a test framework that asserts results computed. - for (unsigned i = 0; i < 64 * NUM_WORKGROUPS; i++) - { - fprintf(stderr, "(%.1f, %.1f, %.1f, %.1f) * (%.1f, %.1f, %.1f, %.1f) => (%.1f, %.1f, %.1f, %.1f)\n", a[i].x, - a[i].y, a[i].z, a[i].w, b[i].x, b[i].y, b[i].z, b[i].w, c[i].x, c[i].y, c[i].z, c[i].w); - } -} diff --git a/deps/SPIRV-Cross/samples/cpp/shared.comp b/deps/SPIRV-Cross/samples/cpp/shared.comp deleted file mode 100644 index 7d59060aa9..0000000000 --- a/deps/SPIRV-Cross/samples/cpp/shared.comp +++ /dev/null @@ -1,36 +0,0 @@ -#version 310 es -layout(local_size_x = 64) in; - -layout(set = 0, binding = 0, std430) readonly buffer SSBO0 -{ - float inputs[]; -}; - -layout(set = 0, binding = 1, std430) writeonly buffer SSBO1 -{ - float outputs[]; -}; - -shared float tmp[gl_WorkGroupSize.x]; - -void main() -{ - uint local = gl_LocalInvocationIndex; - uint work_group = gl_WorkGroupID.x; - - // Does a trivial parallel reduction through shared memory. - tmp[local] = inputs[work_group * gl_WorkGroupSize.x * 2u + local] + inputs[work_group * gl_WorkGroupSize.x * 2u + local + gl_WorkGroupSize.x]; - memoryBarrierShared(); - barrier(); - - for (uint limit = 32u; limit > 1u; limit >>= 1u) - { - if (local < limit) - tmp[local] = tmp[local] + tmp[local + limit]; - memoryBarrierShared(); - barrier(); - } - - if (local == 0u) - outputs[work_group] = tmp[0] + tmp[1]; -} diff --git a/deps/SPIRV-Cross/samples/cpp/shared.cpp b/deps/SPIRV-Cross/samples/cpp/shared.cpp deleted file mode 100644 index 5be62d681f..0000000000 --- a/deps/SPIRV-Cross/samples/cpp/shared.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2015-2017 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "spirv_cross/external_interface.h" -#include - -#ifndef GLM_SWIZZLE -#define GLM_SWIZZLE -#endif - -#ifndef GLM_FORCE_RADIANS -#define GLM_FORCE_RADIANS -#endif - -#include -using namespace glm; - -int main() -{ - // First, we get the C interface to the shader. - // This can be loaded from a dynamic library, or as here, - // linked in as a static library. - auto *iface = spirv_cross_get_interface(); - - // Create an instance of the shader interface. - auto *shader = iface->construct(); - -// Build some input data for our compute shader. -#define NUM_WORKGROUPS 4 - float a[128 * NUM_WORKGROUPS]; - float b[NUM_WORKGROUPS] = {}; - - for (int i = 0; i < 128 * NUM_WORKGROUPS; i++) - { - a[i] = float(i); - } - - void *aptr = a; - void *bptr = b; - - // Bind resources to the shader. - // For resources like samplers and buffers, we provide a list of pointers, - // since UBOs, SSBOs and samplers can be arrays, and can point to different types, - // which is especially true for samplers. - spirv_cross_set_resource(shader, 0, 0, &aptr, sizeof(aptr)); - spirv_cross_set_resource(shader, 0, 1, &bptr, sizeof(bptr)); - - // We also have to set builtins. - // The relevant builtins will depend on the shader, - // but for compute, there are few builtins, which are gl_NumWorkGroups and gl_WorkGroupID. - // LocalInvocationID and GlobalInvocationID are inferred when executing the invocation. - uvec3 num_workgroups(NUM_WORKGROUPS, 1, 1); - uvec3 work_group_id(0, 0, 0); - spirv_cross_set_builtin(shader, SPIRV_CROSS_BUILTIN_NUM_WORK_GROUPS, &num_workgroups, sizeof(num_workgroups)); - spirv_cross_set_builtin(shader, SPIRV_CROSS_BUILTIN_WORK_GROUP_ID, &work_group_id, sizeof(work_group_id)); - - // Execute 4 work groups. - for (unsigned i = 0; i < NUM_WORKGROUPS; i++) - { - work_group_id.x = i; - iface->invoke(shader); - } - - // Call destructor. - iface->destruct(shader); - - // Verify our output. - // TODO: Implement a test framework that asserts results computed. - for (unsigned i = 0; i < NUM_WORKGROUPS; i++) - { - float expected_sum = 0.0f; - for (unsigned j = i * 128; j < (i + 1) * 128; j++) - expected_sum += a[j]; - fprintf(stderr, "Sum in workgroup #%u = %.1f, expected %.1f\n", i, b[i], expected_sum); - } -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/asm/comp/specialization-constant-workgroup.nofxc.asm.comp b/deps/SPIRV-Cross/shaders-hlsl/asm/comp/specialization-constant-workgroup.nofxc.asm.comp deleted file mode 100644 index 188e3fec36..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/asm/comp/specialization-constant-workgroup.nofxc.asm.comp +++ /dev/null @@ -1,47 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 1 -; Bound: 24 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint GLCompute %main "main" - OpExecutionMode %main LocalSize 1 20 1 - OpSource ESSL 310 - OpName %main "main" - OpName %SSBO "SSBO" - OpMemberName %SSBO 0 "a" - OpName %_ "" - OpMemberDecorate %SSBO 0 Offset 0 - OpDecorate %SSBO BufferBlock - OpDecorate %_ DescriptorSet 0 - OpDecorate %_ Binding 0 - OpDecorate %19 SpecId 10 - OpDecorate %21 SpecId 12 - OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 - %SSBO = OpTypeStruct %float -%_ptr_Uniform_SSBO = OpTypePointer Uniform %SSBO - %_ = OpVariable %_ptr_Uniform_SSBO Uniform - %int = OpTypeInt 32 1 - %int_0 = OpConstant %int 0 - %float_1 = OpConstant %float 1 -%_ptr_Uniform_float = OpTypePointer Uniform %float - %uint = OpTypeInt 32 0 - %19 = OpSpecConstant %uint 9 - %uint_20 = OpConstant %uint 20 - %21 = OpSpecConstant %uint 4 - %v3uint = OpTypeVector %uint 3 -%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %19 %uint_20 %21 - %main = OpFunction %void None %3 - %5 = OpLabel - %14 = OpAccessChain %_ptr_Uniform_float %_ %int_0 - %15 = OpLoad %float %14 - %16 = OpFAdd %float %15 %float_1 - %17 = OpAccessChain %_ptr_Uniform_float %_ %int_0 - OpStore %17 %16 - OpReturn - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders-hlsl/asm/comp/storage-buffer-basic.nofxc.asm.comp b/deps/SPIRV-Cross/shaders-hlsl/asm/comp/storage-buffer-basic.nofxc.asm.comp deleted file mode 100644 index edb1a05e54..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/asm/comp/storage-buffer-basic.nofxc.asm.comp +++ /dev/null @@ -1,57 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Codeplay; 0 -; Bound: 31 -; Schema: 0 - OpCapability Shader - OpCapability VariablePointers - OpExtension "SPV_KHR_storage_buffer_storage_class" - OpExtension "SPV_KHR_variable_pointers" - OpMemoryModel Logical GLSL450 - OpEntryPoint GLCompute %22 "main" %gl_WorkGroupID - OpSource OpenCL_C 120 - OpDecorate %15 SpecId 0 - ;OpDecorate %16 SpecId 1 - OpDecorate %17 SpecId 2 - OpDecorate %_runtimearr_float ArrayStride 4 - OpMemberDecorate %_struct_4 0 Offset 0 - OpDecorate %_struct_4 Block - OpDecorate %gl_WorkGroupID BuiltIn WorkgroupId - OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize - OpDecorate %20 DescriptorSet 0 - OpDecorate %20 Binding 0 - OpDecorate %21 DescriptorSet 0 - OpDecorate %21 Binding 1 - %float = OpTypeFloat 32 -%_ptr_StorageBuffer_float = OpTypePointer StorageBuffer %float -%_runtimearr_float = OpTypeRuntimeArray %float - %_struct_4 = OpTypeStruct %_runtimearr_float -%_ptr_StorageBuffer__struct_4 = OpTypePointer StorageBuffer %_struct_4 - %uint = OpTypeInt 32 0 - %void = OpTypeVoid - %8 = OpTypeFunction %void - %v3uint = OpTypeVector %uint 3 -%_ptr_Input_v3uint = OpTypePointer Input %v3uint -%_ptr_Input_uint = OpTypePointer Input %uint -%_ptr_Private_v3uint = OpTypePointer Private %v3uint - %uint_0 = OpConstant %uint 0 -%gl_WorkGroupID = OpVariable %_ptr_Input_v3uint Input - %15 = OpSpecConstant %uint 1 - %16 = OpConstant %uint 2 - %17 = OpSpecConstant %uint 3 -%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %15 %16 %17 - %19 = OpVariable %_ptr_Private_v3uint Private %gl_WorkGroupSize - %20 = OpVariable %_ptr_StorageBuffer__struct_4 StorageBuffer - %21 = OpVariable %_ptr_StorageBuffer__struct_4 StorageBuffer - %22 = OpFunction %void None %8 - %23 = OpLabel - %24 = OpAccessChain %_ptr_Input_uint %gl_WorkGroupID %uint_0 - %25 = OpLoad %uint %24 - %26 = OpAccessChain %_ptr_StorageBuffer_float %21 %uint_0 %25 - %27 = OpLoad %float %26 - %28 = OpAccessChain %_ptr_StorageBuffer_float %20 %uint_0 %25 - %29 = OpLoad %float %28 - %30 = OpFAdd %float %27 %29 - OpStore %28 %30 - OpReturn - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders-hlsl/asm/frag/cbuffer-stripped.asm.frag b/deps/SPIRV-Cross/shaders-hlsl/asm/frag/cbuffer-stripped.asm.frag deleted file mode 100644 index d778034b5f..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/asm/frag/cbuffer-stripped.asm.frag +++ /dev/null @@ -1,55 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 1 -; Bound: 34 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %main "main" %_entryPointOutput - OpExecutionMode %main OriginUpperLeft - OpSource HLSL 500 - OpMemberDecorate %UBO 0 RowMajor - OpMemberDecorate %UBO 0 Offset 0 - OpMemberDecorate %UBO 0 MatrixStride 16 - OpMemberDecorate %UBO 1 Offset 64 - OpDecorate %UBO Block - OpDecorate %_ DescriptorSet 0 - OpDecorate %_ Binding 0 - OpDecorate %_entryPointOutput Location 0 - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 - %v2float = OpTypeVector %float 2 - %8 = OpTypeFunction %v2float -%_ptr_Function_v2float = OpTypePointer Function %v2float - %v4float = OpTypeVector %float 4 -%mat2v4float = OpTypeMatrix %v4float 2 - %UBO = OpTypeStruct %mat2v4float %v4float -%_ptr_Uniform_UBO = OpTypePointer Uniform %UBO - %_ = OpVariable %_ptr_Uniform_UBO Uniform - %int = OpTypeInt 32 1 - %int_1 = OpConstant %int 1 -%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float - %int_0 = OpConstant %int 0 -%_ptr_Uniform_mat2v4float = OpTypePointer Uniform %mat2v4float -%_ptr_Output_v2float = OpTypePointer Output %v2float -%_entryPointOutput = OpVariable %_ptr_Output_v2float Output - %main = OpFunction %void None %3 - %5 = OpLabel - %33 = OpFunctionCall %v2float %_main_ - OpStore %_entryPointOutput %33 - OpReturn - OpFunctionEnd - %_main_ = OpFunction %v2float None %8 - %10 = OpLabel - %a0 = OpVariable %_ptr_Function_v2float Function - %21 = OpAccessChain %_ptr_Uniform_v4float %_ %int_1 - %22 = OpLoad %v4float %21 - %25 = OpAccessChain %_ptr_Uniform_mat2v4float %_ %int_0 - %26 = OpLoad %mat2v4float %25 - %27 = OpVectorTimesMatrix %v2float %22 %26 - OpStore %a0 %27 - %28 = OpLoad %v2float %a0 - OpReturnValue %28 - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders-hlsl/asm/frag/unreachable.asm.frag b/deps/SPIRV-Cross/shaders-hlsl/asm/frag/unreachable.asm.frag deleted file mode 100644 index e2ce2eb56a..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/asm/frag/unreachable.asm.frag +++ /dev/null @@ -1,61 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 3 -; Bound: 47 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %main "main" %counter %FragColor - OpExecutionMode %main OriginUpperLeft - OpSource GLSL 450 - OpName %main "main" - OpName %counter "counter" - OpName %FragColor "FragColor" - OpDecorate %counter Flat - OpDecorate %counter Location 0 - OpDecorate %FragColor Location 0 - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 - %v4float = OpTypeVector %float 4 - %8 = OpTypeFunction %v4float - %int = OpTypeInt 32 1 -%_ptr_Input_int = OpTypePointer Input %int - %counter = OpVariable %_ptr_Input_int Input - %int_10 = OpConstant %int 10 - %bool = OpTypeBool - %float_10 = OpConstant %float 10 - %21 = OpConstantComposite %v4float %float_10 %float_10 %float_10 %float_10 - %float_30 = OpConstant %float 30 - %25 = OpConstantComposite %v4float %float_30 %float_30 %float_30 %float_30 -%_ptr_Output_v4float = OpTypePointer Output %v4float - %FragColor = OpVariable %_ptr_Output_v4float Output -%_ptr_Function_v4float = OpTypePointer Function %v4float - %false = OpConstantFalse %bool - %44 = OpUndef %v4float - %main = OpFunction %void None %3 - %5 = OpLabel - OpBranch %33 - %33 = OpLabel - %45 = OpPhi %v4float %44 %5 %44 %35 - OpLoopMerge %34 %35 None - OpBranch %36 - %36 = OpLabel - %37 = OpLoad %int %counter - %38 = OpIEqual %bool %37 %int_10 - OpSelectionMerge %39 None - OpBranchConditional %38 %40 %41 - %40 = OpLabel - OpBranch %34 - %41 = OpLabel - OpBranch %34 - %39 = OpLabel - OpUnreachable - %35 = OpLabel - OpBranchConditional %false %33 %34 - %34 = OpLabel - %46 = OpPhi %v4float %21 %40 %25 %41 %44 %35 - OpStore %FragColor %46 - OpReturn - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders-hlsl/asm/vert/empty-struct-composite.asm.vert b/deps/SPIRV-Cross/shaders-hlsl/asm/vert/empty-struct-composite.asm.vert deleted file mode 100644 index 37a2d87937..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/asm/vert/empty-struct-composite.asm.vert +++ /dev/null @@ -1,37 +0,0 @@ -; SPIR-V -; Version: 1.1 -; Generator: Google rspirv; 0 -; Bound: 17 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Vertex %2 "main" - OpExecutionMode %2 OriginUpperLeft - OpName %Test "Test" - OpName %t "t" - OpName %retvar "retvar" - OpName %main "main" - OpName %retvar_0 "retvar" - %void = OpTypeVoid - %6 = OpTypeFunction %void - %Test = OpTypeStruct -%_ptr_Function_Test = OpTypePointer Function %Test -%_ptr_Function_void = OpTypePointer Function %void - %2 = OpFunction %void None %6 - %7 = OpLabel - %t = OpVariable %_ptr_Function_Test Function - %retvar = OpVariable %_ptr_Function_void Function - OpBranch %4 - %4 = OpLabel - %13 = OpCompositeConstruct %Test - OpStore %t %13 - OpReturn - OpFunctionEnd - %main = OpFunction %void None %6 - %15 = OpLabel - %retvar_0 = OpVariable %_ptr_Function_void Function - OpBranch %14 - %14 = OpLabel - OpReturn - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders-hlsl/asm/vert/vertex-id-instance-id.asm.vert b/deps/SPIRV-Cross/shaders-hlsl/asm/vert/vertex-id-instance-id.asm.vert deleted file mode 100644 index 85acc47ff2..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/asm/vert/vertex-id-instance-id.asm.vert +++ /dev/null @@ -1,53 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 2 -; Bound: 26 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Vertex %main "main" %_ %gl_VertexID %gl_InstanceID - OpSource GLSL 450 - OpName %main "main" - OpName %gl_PerVertex "gl_PerVertex" - OpMemberName %gl_PerVertex 0 "gl_Position" - OpMemberName %gl_PerVertex 1 "gl_PointSize" - OpMemberName %gl_PerVertex 2 "gl_ClipDistance" - OpMemberName %gl_PerVertex 3 "gl_CullDistance" - OpName %_ "" - OpName %gl_VertexID "gl_VertexID" - OpName %gl_InstanceID "gl_InstanceID" - OpMemberDecorate %gl_PerVertex 0 BuiltIn Position - OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize - OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance - OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance - OpDecorate %gl_PerVertex Block - OpDecorate %gl_VertexID BuiltIn VertexId - OpDecorate %gl_InstanceID BuiltIn InstanceId - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 - %v4float = OpTypeVector %float 4 - %uint = OpTypeInt 32 0 - %uint_1 = OpConstant %uint 1 -%_arr_float_uint_1 = OpTypeArray %float %uint_1 -%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1 -%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex - %_ = OpVariable %_ptr_Output_gl_PerVertex Output - %int = OpTypeInt 32 1 - %int_0 = OpConstant %int 0 -%_ptr_Input_int = OpTypePointer Input %int -%gl_VertexID = OpVariable %_ptr_Input_int Input -%gl_InstanceID = OpVariable %_ptr_Input_int Input -%_ptr_Output_v4float = OpTypePointer Output %v4float - %main = OpFunction %void None %3 - %5 = OpLabel - %18 = OpLoad %int %gl_VertexID - %20 = OpLoad %int %gl_InstanceID - %21 = OpIAdd %int %18 %20 - %22 = OpConvertSToF %float %21 - %23 = OpCompositeConstruct %v4float %22 %22 %22 %22 - %25 = OpAccessChain %_ptr_Output_v4float %_ %int_0 - OpStore %25 %23 - OpReturn - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders-hlsl/comp/access-chains.comp b/deps/SPIRV-Cross/shaders-hlsl/comp/access-chains.comp deleted file mode 100644 index 639f3cac15..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/comp/access-chains.comp +++ /dev/null @@ -1,24 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -// TODO: Read structs, matrices and arrays. - -layout(std430, binding = 0) readonly buffer SSBO -{ - vec4 a[3][2][4]; - float b[3][2][4]; - vec4 unsized[]; -} ro; - -layout(std430, binding = 1) writeonly buffer SSBO1 -{ - vec4 c[3][2][4]; - float d[3][2][4]; - vec4 unsized[]; -} wo; - -void main() -{ - wo.c[2][gl_GlobalInvocationID.x][1] = ro.a[1][gl_GlobalInvocationID.x][2]; - wo.unsized[gl_GlobalInvocationID.x] = ro.unsized[gl_GlobalInvocationID.x]; -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/comp/address-buffers.comp b/deps/SPIRV-Cross/shaders-hlsl/comp/address-buffers.comp deleted file mode 100644 index 3ba582ccd6..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/comp/address-buffers.comp +++ /dev/null @@ -1,23 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -layout(binding = 0, std430) readonly buffer ReadOnlyBuffer -{ - vec4 ro; -} ReadOnly; - -layout(binding = 1, std430) buffer ReadWriteBuffer -{ - vec4 rw; -} ReadWrite; - -layout(binding = 2, std430) buffer WriteOnlyBuffer -{ - vec4 wo; -} WriteOnly; - -void main() -{ - WriteOnly.wo = ReadOnly.ro; - ReadWrite.rw += 10.0; -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/comp/atomic.comp b/deps/SPIRV-Cross/shaders-hlsl/comp/atomic.comp deleted file mode 100644 index 6f69ec725c..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/comp/atomic.comp +++ /dev/null @@ -1,66 +0,0 @@ -#version 310 es -#extension GL_OES_shader_image_atomic : require -layout(local_size_x = 1) in; - -layout(r32ui, binding = 0) uniform highp uimage2D uImage; -layout(r32i, binding = 1) uniform highp iimage2D iImage; -layout(binding = 2, std430) buffer SSBO -{ - uint u32; - int i32; -} ssbo; - -shared int int_atomic; -shared uint uint_atomic; -shared int int_atomic_array[1]; -shared uint uint_atomic_array[1]; - -void main() -{ - imageAtomicAdd(uImage, ivec2(1, 5), 1u); - - // Test that we do not invalidate OpImage variables which are loaded from UniformConstant - // address space. - imageStore(iImage, ivec2(1, 6), ivec4(imageAtomicAdd(uImage, ivec2(1, 5), 1u))); - - imageAtomicOr(uImage, ivec2(1, 5), 1u); - imageAtomicXor(uImage, ivec2(1, 5), 1u); - imageAtomicAnd(uImage, ivec2(1, 5), 1u); - imageAtomicMin(uImage, ivec2(1, 5), 1u); - imageAtomicMax(uImage, ivec2(1, 5), 1u); - //imageAtomicExchange(uImage, ivec2(1, 5), 1u); - imageAtomicCompSwap(uImage, ivec2(1, 5), 10u, 2u); - - imageAtomicAdd(iImage, ivec2(1, 6), 1); - imageAtomicOr(iImage, ivec2(1, 6), 1); - imageAtomicXor(iImage, ivec2(1, 6), 1); - imageAtomicAnd(iImage, ivec2(1, 6), 1); - imageAtomicMin(iImage, ivec2(1, 6), 1); - imageAtomicMax(iImage, ivec2(1, 6), 1); - //imageAtomicExchange(iImage, ivec2(1, 5), 1u); - imageAtomicCompSwap(iImage, ivec2(1, 5), 10, 2); - - atomicAdd(ssbo.u32, 1u); - atomicOr(ssbo.u32, 1u); - atomicXor(ssbo.u32, 1u); - atomicAnd(ssbo.u32, 1u); - atomicMin(ssbo.u32, 1u); - atomicMax(ssbo.u32, 1u); - atomicExchange(ssbo.u32, 1u); - atomicCompSwap(ssbo.u32, 10u, 2u); - - atomicAdd(ssbo.i32, 1); - atomicOr(ssbo.i32, 1); - atomicXor(ssbo.i32, 1); - atomicAnd(ssbo.i32, 1); - atomicMin(ssbo.i32, 1); - atomicMax(ssbo.i32, 1); - atomicExchange(ssbo.i32, 1); - atomicCompSwap(ssbo.i32, 10, 2); - - atomicAdd(int_atomic, 10); - atomicAdd(uint_atomic, 10u); - atomicAdd(int_atomic_array[0], 10); - atomicAdd(uint_atomic_array[0], 10u); -} - diff --git a/deps/SPIRV-Cross/shaders-hlsl/comp/barriers.comp b/deps/SPIRV-Cross/shaders-hlsl/comp/barriers.comp deleted file mode 100644 index 7e0ea42d4e..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/comp/barriers.comp +++ /dev/null @@ -1,79 +0,0 @@ -#version 310 es -layout(local_size_x = 4) in; - -void barrier_shared() -{ - memoryBarrierShared(); -} - -void full_barrier() -{ - memoryBarrier(); -} - -void image_barrier() -{ - memoryBarrierImage(); -} - -void buffer_barrier() -{ - memoryBarrierBuffer(); -} - -void group_barrier() -{ - groupMemoryBarrier(); -} - -void barrier_shared_exec() -{ - memoryBarrierShared(); - barrier(); -} - -void full_barrier_exec() -{ - memoryBarrier(); - barrier(); -} - -void image_barrier_exec() -{ - memoryBarrierImage(); - barrier(); -} - -void buffer_barrier_exec() -{ - memoryBarrierBuffer(); - barrier(); -} - -void group_barrier_exec() -{ - groupMemoryBarrier(); - barrier(); -} - -void exec_barrier() -{ - barrier(); -} - -void main() -{ - barrier_shared(); - full_barrier(); - image_barrier(); - buffer_barrier(); - group_barrier(); - - barrier_shared_exec(); - full_barrier_exec(); - image_barrier_exec(); - buffer_barrier_exec(); - group_barrier_exec(); - - exec_barrier(); -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/comp/bitfield.noopt.comp b/deps/SPIRV-Cross/shaders-hlsl/comp/bitfield.noopt.comp deleted file mode 100644 index a2ef9aa0b7..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/comp/bitfield.noopt.comp +++ /dev/null @@ -1,44 +0,0 @@ -#version 310 es - -void main() -{ - int signed_value = 0; - uint unsigned_value = 0u; - - ivec3 signed_values = ivec3(0); - uvec3 unsigned_values = uvec3(0u); - - { - int s = bitfieldExtract(signed_value, 5, 20); - uint u = bitfieldExtract(unsigned_value, 6, 21); - - s = bitfieldInsert(s, 40, 5, 4); - u = bitfieldInsert(u, 60u, 5, 4); - - u = bitfieldReverse(u); - s = bitfieldReverse(s); - - int v0 = bitCount(u); - int v1 = bitCount(s); - - int v2 = findMSB(u); - int v3 = findLSB(s); - } - - { - ivec3 s = bitfieldExtract(signed_values, 5, 20); - uvec3 u = bitfieldExtract(unsigned_values, 6, 21); - - s = bitfieldInsert(s, ivec3(40), 5, 4); - u = bitfieldInsert(u, uvec3(60u), 5, 4); - - u = bitfieldReverse(u); - s = bitfieldReverse(s); - - ivec3 v0 = bitCount(u); - ivec3 v1 = bitCount(s); - - ivec3 v2 = findMSB(u); - ivec3 v3 = findLSB(s); - } -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/comp/builtins.comp b/deps/SPIRV-Cross/shaders-hlsl/comp/builtins.comp deleted file mode 100644 index b41cb53913..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/comp/builtins.comp +++ /dev/null @@ -1,11 +0,0 @@ -#version 310 es -layout(local_size_x = 8, local_size_y = 4, local_size_z = 2) in; - -void main() -{ - uvec3 local_id = gl_LocalInvocationID; - uvec3 global_id = gl_GlobalInvocationID; - uint local_index = gl_LocalInvocationIndex; - uvec3 work_group_size = gl_WorkGroupSize; - uvec3 work_group_id = gl_WorkGroupID; -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/comp/image.comp b/deps/SPIRV-Cross/shaders-hlsl/comp/image.comp deleted file mode 100644 index 1d3c8b4c65..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/comp/image.comp +++ /dev/null @@ -1,77 +0,0 @@ -#version 450 -layout(local_size_x = 1) in; - -layout(r32f, binding = 0) uniform readonly image2D uImageInF; -layout(r32f, binding = 1) uniform writeonly image2D uImageOutF; -layout(r32i, binding = 2) uniform readonly iimage2D uImageInI; -layout(r32i, binding = 3) uniform writeonly iimage2D uImageOutI; -layout(r32ui, binding = 4) uniform readonly uimage2D uImageInU; -layout(r32ui, binding = 5) uniform writeonly uimage2D uImageOutU; -layout(r32f, binding = 6) uniform readonly imageBuffer uImageInBuffer; -layout(r32f, binding = 7) uniform writeonly imageBuffer uImageOutBuffer; - -layout(rg32f, binding = 8) uniform readonly image2D uImageInF2; -layout(rg32f, binding = 9) uniform writeonly image2D uImageOutF2; -layout(rg32i, binding = 10) uniform readonly iimage2D uImageInI2; -layout(rg32i, binding = 11) uniform writeonly iimage2D uImageOutI2; -layout(rg32ui, binding = 12) uniform readonly uimage2D uImageInU2; -layout(rg32ui, binding = 13) uniform writeonly uimage2D uImageOutU2; -layout(rg32f, binding = 14) uniform readonly imageBuffer uImageInBuffer2; -layout(rg32f, binding = 15) uniform writeonly imageBuffer uImageOutBuffer2; - -layout(rgba32f, binding = 16) uniform readonly image2D uImageInF4; -layout(rgba32f, binding = 17) uniform writeonly image2D uImageOutF4; -layout(rgba32i, binding = 18) uniform readonly iimage2D uImageInI4; -layout(rgba32i, binding = 19) uniform writeonly iimage2D uImageOutI4; -layout(rgba32ui, binding = 20) uniform readonly uimage2D uImageInU4; -layout(rgba32ui, binding = 21) uniform writeonly uimage2D uImageOutU4; -layout(rgba32f, binding = 22) uniform readonly imageBuffer uImageInBuffer4; -layout(rgba32f, binding = 23) uniform writeonly imageBuffer uImageOutBuffer4; - -layout(binding = 24) uniform writeonly image2D uImageNoFmtF; -layout(binding = 25) uniform writeonly uimage2D uImageNoFmtU; -layout(binding = 26) uniform writeonly iimage2D uImageNoFmtI; - -void main() -{ - vec4 f = imageLoad(uImageInF, ivec2(gl_GlobalInvocationID.xy)); - imageStore(uImageOutF, ivec2(gl_GlobalInvocationID.xy), f); - - ivec4 i = imageLoad(uImageInI, ivec2(gl_GlobalInvocationID.xy)); - imageStore(uImageOutI, ivec2(gl_GlobalInvocationID.xy), i); - - uvec4 u = imageLoad(uImageInU, ivec2(gl_GlobalInvocationID.xy)); - imageStore(uImageOutU, ivec2(gl_GlobalInvocationID.xy), u); - - vec4 b = imageLoad(uImageInBuffer, int(gl_GlobalInvocationID.x)); - imageStore(uImageOutBuffer, int(gl_GlobalInvocationID.x), b); - - vec4 f2 = imageLoad(uImageInF2, ivec2(gl_GlobalInvocationID.xy)); - imageStore(uImageOutF2, ivec2(gl_GlobalInvocationID.xy), f2); - - ivec4 i2 = imageLoad(uImageInI2, ivec2(gl_GlobalInvocationID.xy)); - imageStore(uImageOutI2, ivec2(gl_GlobalInvocationID.xy), i2); - - uvec4 u2 = imageLoad(uImageInU2, ivec2(gl_GlobalInvocationID.xy)); - imageStore(uImageOutU2, ivec2(gl_GlobalInvocationID.xy), u2); - - vec4 b2 = imageLoad(uImageInBuffer2, int(gl_GlobalInvocationID.x)); - imageStore(uImageOutBuffer2, int(gl_GlobalInvocationID.x), b2); - - vec4 f4 = imageLoad(uImageInF4, ivec2(gl_GlobalInvocationID.xy)); - imageStore(uImageOutF4, ivec2(gl_GlobalInvocationID.xy), f4); - - ivec4 i4 = imageLoad(uImageInI4, ivec2(gl_GlobalInvocationID.xy)); - imageStore(uImageOutI4, ivec2(gl_GlobalInvocationID.xy), i4); - - uvec4 u4 = imageLoad(uImageInU4, ivec2(gl_GlobalInvocationID.xy)); - imageStore(uImageOutU4, ivec2(gl_GlobalInvocationID.xy), u4); - - vec4 b4 = imageLoad(uImageInBuffer4, int(gl_GlobalInvocationID.x)); - imageStore(uImageOutBuffer4, int(gl_GlobalInvocationID.x), b4); - - imageStore(uImageNoFmtF, ivec2(gl_GlobalInvocationID.xy), b2); - imageStore(uImageNoFmtU, ivec2(gl_GlobalInvocationID.xy), u4); - imageStore(uImageNoFmtI, ivec2(gl_GlobalInvocationID.xy), i4); -} - diff --git a/deps/SPIRV-Cross/shaders-hlsl/comp/rwbuffer-matrix.comp b/deps/SPIRV-Cross/shaders-hlsl/comp/rwbuffer-matrix.comp deleted file mode 100644 index 0e722e0a51..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/comp/rwbuffer-matrix.comp +++ /dev/null @@ -1,104 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -layout(std140, binding = 1) uniform UBO -{ - int index0; - int index1; -}; - -layout(binding = 0, std430) buffer SSBO -{ - layout(column_major) mat4 mcol; - layout(row_major) mat4 mrow; - - layout(column_major) mat2 mcol2x2; - layout(row_major) mat2 mrow2x2; - - layout(column_major) mat2x3 mcol2x3; - layout(row_major) mat2x3 mrow2x3; - - layout(column_major) mat3x2 mcol3x2; - layout(row_major) mat3x2 mrow3x2; -}; - -void col_to_row() -{ - // Load column-major, store row-major. - mrow = mcol; - mrow2x2 = mcol2x2; - mrow2x3 = mcol2x3; - mrow3x2 = mcol3x2; -} - -void row_to_col() -{ - // Load row-major, store column-major. - mcol = mrow; - mcol2x2 = mrow2x2; - mcol2x3 = mrow2x3; - mcol3x2 = mrow3x2; -} - -void write_dynamic_index_row() -{ - mrow[index0][index1] = 1.0; - mrow2x2[index0][index1] = 2.0; - mrow2x3[index0][index1] = 3.0; - mrow3x2[index0][index1] = 4.0; - - mrow[index0] = vec4(1.0); - mrow2x2[index0] = vec2(2.0); - mrow2x3[index0] = vec3(3.0); - mrow3x2[index0] = vec2(4.0); -} - -void write_dynamic_index_col() -{ - mcol[index0][index1] = 1.0; - mcol2x2[index0][index1] = 2.0; - mcol2x3[index0][index1] = 3.0; - mcol3x2[index0][index1] = 4.0; - - mcol[index0] = vec4(1.0); - mcol2x2[index0] = vec2(2.0); - mcol2x3[index0] = vec3(3.0); - mcol3x2[index0] = vec2(4.0); -} - -void read_dynamic_index_row() -{ - float a0 = mrow[index0][index1]; - float a1 = mrow2x2[index0][index1]; - float a2 = mrow2x3[index0][index1]; - float a3 = mrow3x2[index0][index1]; - - vec4 v0 = mrow[index0]; - vec2 v1 = mrow2x2[index0]; - vec3 v2 = mrow2x3[index0]; - vec2 v3 = mrow3x2[index0]; -} - -void read_dynamic_index_col() -{ - float a0 = mcol[index0][index1]; - float a1 = mcol2x2[index0][index1]; - float a2 = mcol2x3[index0][index1]; - float a3 = mcol3x2[index0][index1]; - - vec4 v0 = mcol[index0]; - vec2 v1 = mcol2x2[index0]; - vec3 v2 = mcol2x3[index0]; - vec2 v3 = mcol3x2[index0]; -} - -void main() -{ - row_to_col(); - col_to_row(); - write_dynamic_index_row(); - write_dynamic_index_col(); - read_dynamic_index_row(); - read_dynamic_index_col(); -} - diff --git a/deps/SPIRV-Cross/shaders-hlsl/comp/shared.comp b/deps/SPIRV-Cross/shaders-hlsl/comp/shared.comp deleted file mode 100644 index 4deff93597..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/comp/shared.comp +++ /dev/null @@ -1,27 +0,0 @@ -#version 310 es -layout(local_size_x = 4) in; - -shared float sShared[gl_WorkGroupSize.x]; - -layout(std430, binding = 0) readonly buffer SSBO -{ - float in_data[]; -}; - -layout(std430, binding = 1) writeonly buffer SSBO2 -{ - float out_data[]; -}; - -void main() -{ - uint ident = gl_GlobalInvocationID.x; - float idata = in_data[ident]; - - sShared[gl_LocalInvocationIndex] = idata; - memoryBarrierShared(); - barrier(); - - out_data[ident] = sShared[gl_WorkGroupSize.x - gl_LocalInvocationIndex - 1u]; -} - diff --git a/deps/SPIRV-Cross/shaders-hlsl/comp/ssbo-array.comp b/deps/SPIRV-Cross/shaders-hlsl/comp/ssbo-array.comp deleted file mode 100644 index 38b56e9a0a..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/comp/ssbo-array.comp +++ /dev/null @@ -1,29 +0,0 @@ -#version 450 -layout(local_size_x = 1) in; - -layout(binding = 0, std430) buffer SSBO0 -{ - vec4 a; -} ssbo0; - -// Does not seem to work in glslang yet in HLSL output, disable for now. -#if 0 -layout(binding = 1, std430) buffer SSBO1 -{ - vec4 b; -} ssbo1[2]; - -layout(binding = 2, std430) buffer SSBO2 -{ - vec4 c; -} ssbo2[3][3]; -#endif - -void main() -{ -#if 0 - ssbo1[1].b = ssbo0.a; - ssbo2[1][2].c = ssbo0.a; -#endif -} - diff --git a/deps/SPIRV-Cross/shaders-hlsl/frag/basic.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/basic.frag deleted file mode 100644 index dd9a8f8507..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/frag/basic.frag +++ /dev/null @@ -1,13 +0,0 @@ -#version 310 es -precision mediump float; - -layout(location = 0) in vec4 vColor; -layout(location = 1) in vec2 vTex; -layout(binding = 0) uniform sampler2D uTex; -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = vColor * texture(uTex, vTex); -} - diff --git a/deps/SPIRV-Cross/shaders-hlsl/frag/bit-conversions.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/bit-conversions.frag deleted file mode 100644 index faacdc0f15..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/frag/bit-conversions.frag +++ /dev/null @@ -1,12 +0,0 @@ -#version 310 es -precision mediump float; - -layout(location = 0) in vec2 value; - -layout(location = 0) out vec4 FragColor; - -void main() -{ - int i = floatBitsToInt(value.x); - FragColor = vec4(1.0, 0.0, intBitsToFloat(i), 1.0); -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/frag/boolean-mix.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/boolean-mix.frag deleted file mode 100644 index 9fd8ab3475..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/frag/boolean-mix.frag +++ /dev/null @@ -1,10 +0,0 @@ -#version 310 es -precision mediump float; - -layout(location = 0) in vec2 x0; -layout(location = 0) out vec2 FragColor; - -void main() -{ - FragColor = x0.x > x0.y ? vec2(1.0, 0.0) : vec2(0.0, 1.0); -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/frag/builtins.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/builtins.frag deleted file mode 100644 index 99e6e2df5b..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/frag/builtins.frag +++ /dev/null @@ -1,11 +0,0 @@ -#version 310 es -precision mediump float; - -layout(location = 0) out vec4 FragColor; -layout(location = 0) in vec4 vColor; - -void main() -{ - FragColor = gl_FragCoord + vColor; - gl_FragDepth = 0.5; -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/frag/bvec-operations.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/bvec-operations.frag deleted file mode 100644 index 7221604d9a..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/frag/bvec-operations.frag +++ /dev/null @@ -1,13 +0,0 @@ -#version 310 es -precision mediump float; - -layout(location = 0) in vec2 value; - -layout(location = 0) out vec4 FragColor; - -void main() -{ - bvec2 bools1 = not(bvec2(value.x == 0.0, value.y == 0.0)); - bvec2 bools2 = lessThanEqual(value, vec2(1.5, 0.5)); - FragColor = vec4(1.0, 0.0, bools1.x ? 1.0 : 0.0, bools2.x ? 1.0 : 0.0); -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/frag/combined-texture-sampler-parameter.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/combined-texture-sampler-parameter.frag deleted file mode 100644 index e5721b9026..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/frag/combined-texture-sampler-parameter.frag +++ /dev/null @@ -1,31 +0,0 @@ -#version 310 es -precision mediump float; - -layout(set = 0, binding = 0) uniform mediump sampler2D uSampler; -layout(set = 0, binding = 1) uniform mediump sampler2DShadow uSamplerShadow; -layout(location = 0) out float FragColor; - -vec4 samp2(sampler2D s) -{ - return texture(s, vec2(1.0)) + texelFetch(s, ivec2(10), 0); -} - -vec4 samp3(sampler2D s) -{ - return samp2(s); -} - -float samp4(mediump sampler2DShadow s) -{ - return texture(s, vec3(1.0)); -} - -float samp(sampler2D s0, mediump sampler2DShadow s1) -{ - return samp3(s0).x + samp4(s1); -} - -void main() -{ - FragColor = samp(uSampler, uSamplerShadow); -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/frag/combined-texture-sampler-shadow.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/combined-texture-sampler-shadow.frag deleted file mode 100644 index 2fabb5ea8a..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/frag/combined-texture-sampler-shadow.frag +++ /dev/null @@ -1,29 +0,0 @@ -#version 310 es -precision mediump float; - -layout(set = 0, binding = 0) uniform mediump samplerShadow uSampler; -layout(set = 0, binding = 1) uniform mediump sampler uSampler1; -layout(set = 0, binding = 2) uniform texture2D uDepth; -layout(location = 0) out float FragColor; - -float samp2(texture2D t, mediump samplerShadow s) -{ - return texture(sampler2DShadow(t, s), vec3(1.0)); -} - -float samp3(texture2D t, mediump sampler s) -{ - return texture(sampler2D(t, s), vec2(1.0)).x; -} - -float samp(texture2D t, mediump samplerShadow s, mediump sampler s1) -{ - float r0 = samp2(t, s); - float r1 = samp3(t, s1); - return r0 + r1; -} - -void main() -{ - FragColor = samp(uDepth, uSampler, uSampler1); -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/frag/constant-buffer-array.sm51.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/constant-buffer-array.sm51.frag deleted file mode 100644 index d60002a0f2..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/frag/constant-buffer-array.sm51.frag +++ /dev/null @@ -1,32 +0,0 @@ -#version 450 - -layout(std140, binding = 4) uniform CBO -{ - vec4 a; - vec4 b; - vec4 c; - vec4 d; -} cbo[2][4]; - -layout(std430, push_constant) uniform PushMe -{ - vec4 a; - vec4 b; - vec4 c; - vec4 d; -} push; - -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = cbo[1][2].a; - FragColor += cbo[1][2].b; - FragColor += cbo[1][2].c; - FragColor += cbo[1][2].d; - FragColor += push.a; - FragColor += push.b; - FragColor += push.c; - FragColor += push.d; -} - diff --git a/deps/SPIRV-Cross/shaders-hlsl/frag/early-fragment-test.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/early-fragment-test.frag deleted file mode 100644 index 9f84e09880..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/frag/early-fragment-test.frag +++ /dev/null @@ -1,7 +0,0 @@ -#version 420 - -layout(early_fragment_tests) in; - -void main() -{ -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/frag/fp16-packing.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/fp16-packing.frag deleted file mode 100644 index 98ca24e2f8..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/frag/fp16-packing.frag +++ /dev/null @@ -1,12 +0,0 @@ -#version 450 - -layout(location = 0) flat in uint FP16; -layout(location = 1) flat in vec2 FP32; -layout(location = 0) out vec2 FP32Out; -layout(location = 1) out uint FP16Out; - -void main() -{ - FP32Out = unpackHalf2x16(FP16); - FP16Out = packHalf2x16(FP32); -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/frag/image-query-selective.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/image-query-selective.frag deleted file mode 100644 index bb595bcb9b..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/frag/image-query-selective.frag +++ /dev/null @@ -1,35 +0,0 @@ -#version 450 - -layout(binding = 0) uniform usampler1D uSampler1DUint; -layout(binding = 0) uniform isampler1D uSampler1DInt; -layout(binding = 0) uniform sampler1D uSampler1DFloat; -layout(binding = 1) uniform sampler2D uSampler2D; -layout(binding = 2) uniform isampler2DArray uSampler2DArray; -layout(binding = 3) uniform sampler3D uSampler3D; -layout(binding = 4) uniform samplerCube uSamplerCube; -layout(binding = 5) uniform usamplerCubeArray uSamplerCubeArray; -layout(binding = 6) uniform samplerBuffer uSamplerBuffer; -layout(binding = 7) uniform isampler2DMS uSamplerMS; -layout(binding = 8) uniform sampler2DMSArray uSamplerMSArray; - -void main() -{ - int a = textureSize(uSampler1DUint, 0); - a = textureSize(uSampler1DInt, 0); - a = textureSize(uSampler1DFloat, 0); - - ivec3 c = textureSize(uSampler2DArray, 0); - ivec3 d = textureSize(uSampler3D, 0); - ivec2 e = textureSize(uSamplerCube, 0); - ivec3 f = textureSize(uSamplerCubeArray, 0); - int g = textureSize(uSamplerBuffer); - ivec2 h = textureSize(uSamplerMS); - ivec3 i = textureSize(uSamplerMSArray); - - int l1 = textureQueryLevels(uSampler2D); - int l2 = textureQueryLevels(uSampler2DArray); - int l3 = textureQueryLevels(uSampler3D); - int l4 = textureQueryLevels(uSamplerCube); - int s0 = textureSamples(uSamplerMS); - int s1 = textureSamples(uSamplerMSArray); -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/frag/image-query.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/image-query.frag deleted file mode 100644 index 8e840fba11..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/frag/image-query.frag +++ /dev/null @@ -1,33 +0,0 @@ -#version 450 - -layout(binding = 0) uniform sampler1D uSampler1D; -layout(binding = 1) uniform sampler2D uSampler2D; -layout(binding = 2) uniform sampler2DArray uSampler2DArray; -layout(binding = 3) uniform sampler3D uSampler3D; -layout(binding = 4) uniform samplerCube uSamplerCube; -layout(binding = 5) uniform samplerCubeArray uSamplerCubeArray; -layout(binding = 6) uniform samplerBuffer uSamplerBuffer; -layout(binding = 7) uniform sampler2DMS uSamplerMS; -layout(binding = 8) uniform sampler2DMSArray uSamplerMSArray; - -void main() -{ - int a = textureSize(uSampler1D, 0); - ivec2 b = textureSize(uSampler2D, 0); - ivec3 c = textureSize(uSampler2DArray, 0); - ivec3 d = textureSize(uSampler3D, 0); - ivec2 e = textureSize(uSamplerCube, 0); - ivec3 f = textureSize(uSamplerCubeArray, 0); - int g = textureSize(uSamplerBuffer); - ivec2 h = textureSize(uSamplerMS); - ivec3 i = textureSize(uSamplerMSArray); - - int l0 = textureQueryLevels(uSampler1D); - int l1 = textureQueryLevels(uSampler2D); - int l2 = textureQueryLevels(uSampler2DArray); - int l3 = textureQueryLevels(uSampler3D); - int l4 = textureQueryLevels(uSamplerCube); - int l5 = textureQueryLevels(uSamplerCubeArray); - int s0 = textureSamples(uSamplerMS); - int s1 = textureSamples(uSamplerMSArray); -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/frag/io-block.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/io-block.frag deleted file mode 100644 index 1e3e3d77e8..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/frag/io-block.frag +++ /dev/null @@ -1,16 +0,0 @@ -#version 310 es -#extension GL_EXT_shader_io_blocks : require -precision mediump float; - -layout(location = 1) in VertexOut -{ - vec4 a; - vec4 b; -}; - -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = a + b; -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/frag/matrix-input.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/matrix-input.frag deleted file mode 100644 index ffe242cec2..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/frag/matrix-input.frag +++ /dev/null @@ -1,9 +0,0 @@ -#version 450 - -layout(location = 0) out vec4 FragColor; -layout(location = 1) in mat4 m; - -void main() -{ - FragColor = m[0] + m[1] + m[2] + m[3]; -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/frag/mod.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/mod.frag deleted file mode 100644 index 32edb61841..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/frag/mod.frag +++ /dev/null @@ -1,22 +0,0 @@ -#version 310 es -precision mediump float; - -layout(location = 0) in vec4 a4; -layout(location = 1) in vec3 a3; -layout(location = 2) in vec2 a2; -layout(location = 3) in float a1; -layout(location = 4) in vec4 b4; -layout(location = 5) in vec3 b3; -layout(location = 6) in vec2 b2; -layout(location = 7) in float b1; - -layout(location = 0) out vec4 FragColor; - -void main() -{ - vec4 m0 = mod(a4, b4); - vec3 m1 = mod(a3, b3); - vec2 m2 = mod(a2, b2); - float m3 = mod(a1, b1); - FragColor = m0 + m1.xyzx + m2.xyxy + m3; -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/frag/mrt.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/mrt.frag deleted file mode 100644 index 77a2bb29c7..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/frag/mrt.frag +++ /dev/null @@ -1,15 +0,0 @@ -#version 310 es -precision mediump float; - -layout(location = 0) out vec4 RT0; -layout(location = 1) out vec4 RT1; -layout(location = 2) out vec4 RT2; -layout(location = 3) out vec4 RT3; - -void main() -{ - RT0 = vec4(1.0); - RT1 = vec4(2.0); - RT2 = vec4(3.0); - RT3 = vec4(4.0); -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/frag/no-return.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/no-return.frag deleted file mode 100644 index f0ef8702ce..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/frag/no-return.frag +++ /dev/null @@ -1,5 +0,0 @@ -#version 310 es - -void main() -{ -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/frag/no-return2.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/no-return2.frag deleted file mode 100644 index 46bf9fbf20..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/frag/no-return2.frag +++ /dev/null @@ -1,9 +0,0 @@ -#version 310 es -precision mediump float; - -layout(location = 0) in vec4 vColor; - -void main() -{ - vec4 v = vColor; -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/frag/partial-write-preserve.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/partial-write-preserve.frag deleted file mode 100644 index f30270b91b..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/frag/partial-write-preserve.frag +++ /dev/null @@ -1,64 +0,0 @@ -#version 310 es -precision mediump float; - -layout(std140, binding = 0) uniform UBO -{ - int some_value; -}; - -struct B -{ - float a; - float b; -}; - -void partial_inout(inout vec4 x) -{ - x.x = 10.0; -} - -void partial_inout(inout B b) -{ - b.b = 40.0; -} - -// Make a complete write, but only conditionally ... -void branchy_inout(inout vec4 v) -{ - v.y = 20.0; - if (some_value == 20) - { - v = vec4(50.0); - } -} - -void branchy_inout_2(out vec4 v) -{ - if (some_value == 20) - { - v = vec4(50.0); - } - else - { - v = vec4(70.0); - } - v.y = 20.0; -} - -void complete_inout(out vec4 x) -{ - x = vec4(50.0); -} - -void main() -{ - vec4 a = vec4(10.0); - partial_inout(a); - complete_inout(a); - branchy_inout(a); - branchy_inout_2(a); - - B b = B(10.0, 20.0); - partial_inout(b); -} - diff --git a/deps/SPIRV-Cross/shaders-hlsl/frag/query-lod.desktop.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/query-lod.desktop.frag deleted file mode 100644 index 0cb160402f..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/frag/query-lod.desktop.frag +++ /dev/null @@ -1,10 +0,0 @@ -#version 450 - -layout(location = 0) in vec2 vTexCoord; -layout(binding = 0) uniform sampler2D uSampler; -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = textureQueryLod(uSampler, vTexCoord).xyxy; -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/frag/resources.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/resources.frag deleted file mode 100644 index 16178bfd77..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/frag/resources.frag +++ /dev/null @@ -1,27 +0,0 @@ -#version 310 es -precision mediump float; - -layout(binding = 3, std140) uniform CBuffer -{ - vec4 a; -} cbuf; - -layout(binding = 4) uniform sampler2D uSampledImage; -layout(binding = 5) uniform mediump texture2D uTexture; -layout(binding = 6) uniform mediump sampler uSampler; - -layout(location = 0) out vec4 FragColor; -layout(location = 0) in vec2 vTex; - -layout(std430, push_constant) uniform PushMe -{ - vec4 d; -} registers; - -void main() -{ - vec4 c0 = texture(uSampledImage, vTex); - vec4 c1 = texture(sampler2D(uTexture, uSampler), vTex); - vec4 c2 = cbuf.a + registers.d; - FragColor = c0 + c1 + c2; -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/frag/sample-cmp-level-zero.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/sample-cmp-level-zero.frag deleted file mode 100644 index c40d742eeb..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/frag/sample-cmp-level-zero.frag +++ /dev/null @@ -1,27 +0,0 @@ -#version 450 - -layout(location = 0) out float FragColor; -layout(binding = 0) uniform sampler2DShadow uSampler2D; -layout(binding = 1) uniform sampler2DArrayShadow uSampler2DArray; -layout(binding = 2) uniform samplerCubeShadow uSamplerCube; -layout(binding = 3) uniform samplerCubeArrayShadow uSamplerCubeArray; - -layout(location = 0) in vec3 vUVRef; -layout(location = 1) in vec4 vDirRef; - -void main() -{ - float s0 = textureOffset(uSampler2D, vUVRef, ivec2(-1)); - float s1 = textureOffset(uSampler2DArray, vDirRef, ivec2(-1)); - float s2 = texture(uSamplerCube, vDirRef); - float s3 = texture(uSamplerCubeArray, vDirRef, 0.5); - - float l0 = textureLodOffset(uSampler2D, vUVRef, 0.0, ivec2(-1)); - float l1 = textureGradOffset(uSampler2DArray, vDirRef, vec2(0.0), vec2(0.0), ivec2(-1)); - float l2 = textureGrad(uSamplerCube, vDirRef, vec3(0.0), vec3(0.0)); - - float p0 = textureProjOffset(uSampler2D, vDirRef, ivec2(+1)); - float p1 = textureProjLodOffset(uSampler2D, vDirRef, 0.0, ivec2(+1)); - - FragColor = s0 + s1 + s2 + s3 + l0 + l1 + l2 + p0 + p1; -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/frag/sampler-array.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/sampler-array.frag deleted file mode 100644 index 75910ed163..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/frag/sampler-array.frag +++ /dev/null @@ -1,28 +0,0 @@ -#version 450 - -layout(binding = 0) uniform sampler2D uCombined[4]; -layout(binding = 4) uniform texture2D uTex[4]; -layout(binding = 8) uniform sampler uSampler[4]; -layout(binding = 12, rgba32f) uniform writeonly image2D uImage[8]; -layout(location = 0) in vec2 vTex; -layout(location = 1) flat in int vIndex; - -vec4 sample_in_function(sampler2D samp) -{ - return texture(samp, vTex); -} - -vec4 sample_in_function2(texture2D tex, sampler samp) -{ - return texture(sampler2D(tex, samp), vTex); -} - -void main() -{ - vec4 color = texture(uCombined[vIndex], vTex); - color += texture(sampler2D(uTex[vIndex], uSampler[vIndex]), vTex); - color += sample_in_function(uCombined[vIndex + 1]); - color += sample_in_function2(uTex[vIndex + 1], uSampler[vIndex + 1]); - - imageStore(uImage[vIndex], ivec2(gl_FragCoord.xy), color); -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/frag/spec-constant.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/spec-constant.frag deleted file mode 100644 index a6c8d94e78..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/frag/spec-constant.frag +++ /dev/null @@ -1,80 +0,0 @@ -#version 310 es -precision mediump float; - -layout(location = 0) out vec4 FragColor; -layout(constant_id = 1) const float a = 1.0; -layout(constant_id = 2) const float b = 2.0; -layout(constant_id = 3) const int c = 3; -layout(constant_id = 4) const int d = 4; -layout(constant_id = 5) const uint e = 5u; -layout(constant_id = 6) const uint f = 6u; -layout(constant_id = 7) const bool g = false; -layout(constant_id = 8) const bool h = true; -// glslang doesn't seem to support partial spec constants or composites yet, so only test the basics. - -struct Foo -{ - float elems[d + 2]; -}; - -void main() -{ - float t0 = a; - float t1 = b; - - uint c0 = uint(c); // OpIAdd with different types. - // FConvert, float-to-double. - int c1 = -c; // SNegate - int c2 = ~c; // OpNot - int c3 = c + d; // OpIAdd - int c4 = c - d; // OpISub - int c5 = c * d; // OpIMul - int c6 = c / d; // OpSDiv - uint c7 = e / f; // OpUDiv - int c8 = c % d; // OpSMod - uint c9 = e % f; // OpUMod - // TODO: OpSRem, any way to access this in GLSL? - int c10 = c >> d; // OpShiftRightArithmetic - uint c11 = e >> f; // OpShiftRightLogical - int c12 = c << d; // OpShiftLeftLogical - int c13 = c | d; // OpBitwiseOr - int c14 = c ^ d; // OpBitwiseXor - int c15 = c & d; // OpBitwiseAnd - // VectorShuffle, CompositeExtract, CompositeInsert, not testable atm. - bool c16 = g || h; // OpLogicalOr - bool c17 = g && h; // OpLogicalAnd - bool c18 = !g; // OpLogicalNot - bool c19 = g == h; // OpLogicalEqual - bool c20 = g != h; // OpLogicalNotEqual - // OpSelect not testable atm. - bool c21 = c == d; // OpIEqual - bool c22 = c != d; // OpINotEqual - bool c23 = c < d; // OpSLessThan - bool c24 = e < f; // OpULessThan - bool c25 = c > d; // OpSGreaterThan - bool c26 = e > f; // OpUGreaterThan - bool c27 = c <= d; // OpSLessThanEqual - bool c28 = e <= f; // OpULessThanEqual - bool c29 = c >= d; // OpSGreaterThanEqual - bool c30 = e >= f; // OpUGreaterThanEqual - // OpQuantizeToF16 not testable atm. - - int c31 = c8 + c3; - - int c32 = int(e); // OpIAdd with different types. - bool c33 = bool(c); // int -> bool - bool c34 = bool(e); // uint -> bool - int c35 = int(g); // bool -> int - uint c36 = uint(g); // bool -> uint - float c37 = float(g); // bool -> float - - // Flexible sized arrays with spec constants and spec constant ops. - float vec0[c + 3][8]; - float vec1[c + 2]; - vec0[0][0] = 10.0; - vec1[0] = 20.0; - - Foo foo; - foo.elems[c] = 10.0; - FragColor = vec4(t0 + t1) + vec0[0][0] + vec1[0] + foo.elems[c]; -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/frag/swizzle-scalar.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/swizzle-scalar.frag deleted file mode 100644 index c27524f7a6..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/frag/swizzle-scalar.frag +++ /dev/null @@ -1,16 +0,0 @@ -#version 450 - -layout(location = 0) flat in float vFloat; -layout(location = 1) flat in int vInt; -layout(location = 0) out vec4 Float; -layout(location = 1) out ivec4 Int; -layout(location = 2) out vec4 Float2; -layout(location = 3) out ivec4 Int2; - -void main() -{ - Float = vec4(vFloat) * 2.0; - Int = ivec4(vInt) * 2; - Float2 = vec4(10.0); - Int2 = ivec4(10); -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/frag/tex-sampling.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/tex-sampling.frag deleted file mode 100644 index 4a386c0d33..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/frag/tex-sampling.frag +++ /dev/null @@ -1,81 +0,0 @@ -#version 450 - -uniform sampler1D tex1d; -uniform sampler2D tex2d; -uniform sampler3D tex3d; -uniform samplerCube texCube; - -uniform sampler1DShadow tex1dShadow; -uniform sampler2DShadow tex2dShadow; -uniform samplerCubeShadow texCubeShadow; - -uniform sampler1DArray tex1dArray; -uniform sampler2DArray tex2dArray; -uniform samplerCubeArray texCubeArray; - -uniform samplerShadow samplerDepth; -uniform sampler samplerNonDepth; -uniform texture2D separateTex2d; -uniform texture2D separateTex2dDepth; - -layout(location = 0) in float texCoord1d; -layout(location = 1) in vec2 texCoord2d; -layout(location = 2) in vec3 texCoord3d; -layout(location = 3) in vec4 texCoord4d; - -layout(location = 0) out vec4 FragColor; - -void main() -{ - vec4 texcolor = texture(tex1d, texCoord1d); - texcolor += textureOffset(tex1d, texCoord1d, 1); - texcolor += textureLod(tex1d, texCoord1d, 2); - texcolor += textureGrad(tex1d, texCoord1d, 1.0, 2.0); - texcolor += textureProj(tex1d, vec2(texCoord1d, 2.0)); - texcolor += texture(tex1d, texCoord1d, 1.0); - - texcolor += texture(tex2d, texCoord2d); - texcolor += textureOffset(tex2d, texCoord2d, ivec2(1, 2)); - texcolor += textureLod(tex2d, texCoord2d, 2); - texcolor += textureGrad(tex2d, texCoord2d, vec2(1.0, 2.0), vec2(3.0, 4.0)); - texcolor += textureProj(tex2d, vec3(texCoord2d, 2.0)); - texcolor += texture(tex2d, texCoord2d, 1.0); - - texcolor += texture(tex3d, texCoord3d); - texcolor += textureOffset(tex3d, texCoord3d, ivec3(1, 2, 3)); - texcolor += textureLod(tex3d, texCoord3d, 2); - texcolor += textureGrad(tex3d, texCoord3d, vec3(1.0, 2.0, 3.0), vec3(4.0, 5.0, 6.0)); - texcolor += textureProj(tex3d, vec4(texCoord3d, 2.0)); - texcolor += texture(tex3d, texCoord3d, 1.0); - - texcolor += texture(texCube, texCoord3d); - texcolor += textureLod(texCube, texCoord3d, 2); - texcolor += texture(texCube, texCoord3d, 1.0); - - texcolor.a += texture(tex1dShadow, vec3(texCoord1d, 0.0, 0.0)); - texcolor.a += texture(tex2dShadow, vec3(texCoord2d, 0.0)); - texcolor.a += texture(texCubeShadow, vec4(texCoord3d, 0.0)); - - texcolor += texture(tex1dArray, texCoord2d); - texcolor += texture(tex2dArray, texCoord3d); - texcolor += texture(texCubeArray, texCoord4d); - - texcolor += textureGather(tex2d, texCoord2d); - texcolor += textureGather(tex2d, texCoord2d, 0); - texcolor += textureGather(tex2d, texCoord2d, 1); - texcolor += textureGather(tex2d, texCoord2d, 2); - texcolor += textureGather(tex2d, texCoord2d, 3); - - texcolor += textureGatherOffset(tex2d, texCoord2d, ivec2(1, 1)); - texcolor += textureGatherOffset(tex2d, texCoord2d, ivec2(1, 1), 0); - texcolor += textureGatherOffset(tex2d, texCoord2d, ivec2(1, 1), 1); - texcolor += textureGatherOffset(tex2d, texCoord2d, ivec2(1, 1), 2); - texcolor += textureGatherOffset(tex2d, texCoord2d, ivec2(1, 1), 3); - - texcolor += texelFetch(tex2d, ivec2(1, 2), 0); - - texcolor += texture(sampler2D(separateTex2d, samplerNonDepth), texCoord2d); - texcolor.a += texture(sampler2DShadow(separateTex2dDepth, samplerDepth), texCoord3d); - - FragColor = texcolor; -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/frag/texture-proj-shadow.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/texture-proj-shadow.frag deleted file mode 100644 index 0c4cf8f5a8..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/frag/texture-proj-shadow.frag +++ /dev/null @@ -1,21 +0,0 @@ -#version 450 - -layout(binding = 0) uniform sampler1DShadow uShadow1D; -layout(binding = 1) uniform sampler2DShadow uShadow2D; -layout(binding = 2) uniform sampler1D uSampler1D; -layout(binding = 3) uniform sampler2D uSampler2D; -layout(binding = 4) uniform sampler3D uSampler3D; - -layout(location = 0) out float FragColor; -layout(location = 0) in vec3 vClip3; -layout(location = 1) in vec4 vClip4; -layout(location = 2) in vec2 vClip2; - -void main() -{ - FragColor = textureProj(uShadow1D, vClip4); - FragColor = textureProj(uShadow2D, vClip4); - FragColor = textureProj(uSampler1D, vClip2).x; - FragColor = textureProj(uSampler2D, vClip3).x; - FragColor = textureProj(uSampler3D, vClip4).x; -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/frag/unary-enclose.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/unary-enclose.frag deleted file mode 100644 index ea502e1de8..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/frag/unary-enclose.frag +++ /dev/null @@ -1,15 +0,0 @@ -#version 310 es -precision mediump float; - -layout(location = 0) out vec4 FragColor; -layout(location = 0) in vec4 vIn; -layout(location = 1) flat in ivec4 vIn1; - -void main() -{ - FragColor = +(-(-vIn)); - ivec4 a = ~(~vIn1); - - bool b = false; - b = !!b; -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/frag/unorm-snorm-packing.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/unorm-snorm-packing.frag deleted file mode 100644 index c0a01aaf8b..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/frag/unorm-snorm-packing.frag +++ /dev/null @@ -1,24 +0,0 @@ -#version 450 - -layout(location = 0) flat in uint SNORM8; -layout(location = 1) flat in uint UNORM8; -layout(location = 2) flat in uint SNORM16; -layout(location = 3) flat in uint UNORM16; -layout(location = 4) flat in vec4 FP32; -layout(location = 0) out vec4 FP32Out; -layout(location = 1) out uint UNORM8Out; -layout(location = 2) out uint SNORM8Out; -layout(location = 3) out uint UNORM16Out; -layout(location = 4) out uint SNORM16Out; - -void main() -{ - FP32Out = unpackUnorm4x8(UNORM8); - FP32Out = unpackSnorm4x8(SNORM8); - FP32Out.xy = unpackUnorm2x16(UNORM16); - FP32Out.xy = unpackSnorm2x16(SNORM16); - UNORM8Out = packUnorm4x8(FP32); - SNORM8Out = packSnorm4x8(FP32); - UNORM16Out = packUnorm2x16(FP32.xy); - SNORM16Out = packSnorm2x16(FP32.zw); -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/frag/various-glsl-ops.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/various-glsl-ops.frag deleted file mode 100644 index 0d4af80a6e..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/frag/various-glsl-ops.frag +++ /dev/null @@ -1,17 +0,0 @@ -#version 450 - -layout(location = 0) in vec2 interpolant; - -layout(location = 0) out vec4 FragColor; - -void main() -{ - vec4 color = vec4(0.0, 0.0, 0.0, interpolateAtOffset(interpolant, vec2(0.1, 0.1))); - - // glslang's HLSL parser currently fails here - //color += vec4(0.0, 0.0, 0.0, interpolateAtSample(interpolant, gl_SampleID)); - //color += vec4(0.0, 0.0, 0.0, interpolateAtCentroid(interpolant)); - - color += vec4(0.0, 0.0, 0.0, dFdxCoarse(interpolant.x)); - FragColor = color; -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/vert/basic.vert b/deps/SPIRV-Cross/shaders-hlsl/vert/basic.vert deleted file mode 100644 index f03114feef..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/vert/basic.vert +++ /dev/null @@ -1,15 +0,0 @@ -#version 310 es - -layout(std140) uniform UBO -{ - uniform mat4 uMVP; -}; -layout(location = 0) in vec4 aVertex; -layout(location = 1) in vec3 aNormal; -layout(location = 0) out vec3 vNormal; - -void main() -{ - gl_Position = uMVP * aVertex; - vNormal = aNormal; -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/vert/instancing.vert b/deps/SPIRV-Cross/shaders-hlsl/vert/instancing.vert deleted file mode 100644 index 0e62ef6b0e..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/vert/instancing.vert +++ /dev/null @@ -1,6 +0,0 @@ -#version 310 es - -void main() -{ - gl_Position = vec4(float(gl_VertexIndex + gl_InstanceIndex)); -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/vert/locations.vert b/deps/SPIRV-Cross/shaders-hlsl/vert/locations.vert deleted file mode 100644 index df1a44e923..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/vert/locations.vert +++ /dev/null @@ -1,51 +0,0 @@ -#version 310 es -#extension GL_EXT_shader_io_blocks : require - -struct Foo -{ - vec3 a; - vec3 b; - vec3 c; -}; - -// This will lock to input location 2. -layout(location = 2) in vec4 Input2; -// This will lock to input location 4. -layout(location = 4) in vec4 Input4; -// This will pick first available, which is 0. -layout(location = 0) in vec4 Input0; - -// Locks output 0. -layout(location = 0) out float vLocation0; -// Locks output 1. -layout(location = 1) out float vLocation1; -// Picks first available two locations, so, 2 and 3. -layout(location = 2) out float vLocation2[2]; -// Picks first available location, 4. -layout(location = 4) out Foo vLocation4; -// Picks first available location 9. -layout(location = 9) out float vLocation9; - -// Locks location 7 and 8. -layout(location = 7) out VertexOut -{ - vec3 color; - vec3 foo; -} vout; - -void main() -{ - gl_Position = vec4(1.0) + Input2 + Input4 + Input0; - vLocation0 = 0.0; - vLocation1 = 1.0; - vLocation2[0] = 2.0; - vLocation2[1] = 2.0; - Foo foo; - foo.a = vec3(1.0); - foo.b = vec3(1.0); - foo.c = vec3(1.0); - vLocation4 = foo; - vLocation9 = 9.0; - vout.color = vec3(2.0); - vout.foo = vec3(4.0); -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/vert/matrix-attribute.vert b/deps/SPIRV-Cross/shaders-hlsl/vert/matrix-attribute.vert deleted file mode 100644 index 8a1393f8d6..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/vert/matrix-attribute.vert +++ /dev/null @@ -1,9 +0,0 @@ -#version 310 es - -layout(location = 0) in vec3 pos; -layout(location = 1) in mat4 m; - -void main() -{ - gl_Position = m * vec4(pos, 1.0); -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/vert/matrix-output.vert b/deps/SPIRV-Cross/shaders-hlsl/vert/matrix-output.vert deleted file mode 100644 index 1151d4bd32..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/vert/matrix-output.vert +++ /dev/null @@ -1,9 +0,0 @@ -#version 450 - -layout(location = 0) out mat4 m; - -void main() -{ - gl_Position = vec4(1.0); - m = mat4(1.0); -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/vert/no-input.vert b/deps/SPIRV-Cross/shaders-hlsl/vert/no-input.vert deleted file mode 100644 index 8de8e816a0..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/vert/no-input.vert +++ /dev/null @@ -1,6 +0,0 @@ -#version 310 es - -void main() -{ - gl_Position = vec4(1.0); -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/vert/point-size-compat.vert b/deps/SPIRV-Cross/shaders-hlsl/vert/point-size-compat.vert deleted file mode 100644 index 64eff36315..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/vert/point-size-compat.vert +++ /dev/null @@ -1,8 +0,0 @@ -#version 310 es - -void main() -{ - gl_Position = vec4(1.0); - gl_PointSize = 10.0; -} - diff --git a/deps/SPIRV-Cross/shaders-hlsl/vert/qualifiers.vert b/deps/SPIRV-Cross/shaders-hlsl/vert/qualifiers.vert deleted file mode 100644 index 080a70915c..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/vert/qualifiers.vert +++ /dev/null @@ -1,27 +0,0 @@ -#version 450 - -layout(location = 0) flat out float vFlat; -layout(location = 1) centroid out float vCentroid; -layout(location = 2) sample out float vSample; -layout(location = 3) noperspective out float vNoperspective; - -layout(location = 4) out Block -{ - flat float vFlat; - centroid float vCentroid; - sample float vSample; - noperspective float vNoperspective; -} vout; - -void main() -{ - gl_Position = vec4(1.0); - vFlat = 0.0; - vCentroid = 1.0; - vSample = 2.0; - vNoperspective = 3.0; - vout.vFlat = 0.0; - vout.vCentroid = 1.0; - vout.vSample = 2.0; - vout.vNoperspective = 3.0; -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/vert/sampler-buffers.vert b/deps/SPIRV-Cross/shaders-hlsl/vert/sampler-buffers.vert deleted file mode 100644 index dccbf77849..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/vert/sampler-buffers.vert +++ /dev/null @@ -1,17 +0,0 @@ -#version 450 - -layout(binding = 1) uniform samplerBuffer uFloatSampler; -layout(binding = 2) uniform isamplerBuffer uIntSampler; -layout(binding = 3) uniform usamplerBuffer uUintSampler; - -vec4 sample_from_function(samplerBuffer s0, isamplerBuffer s1, usamplerBuffer s2) -{ - return texelFetch(s0, 20) + - intBitsToFloat(texelFetch(s1, 40)) + - uintBitsToFloat(texelFetch(s2, 60)); -} - -void main() -{ - gl_Position = sample_from_function(uFloatSampler, uIntSampler, uUintSampler); -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/vert/struct-composite-decl.vert b/deps/SPIRV-Cross/shaders-hlsl/vert/struct-composite-decl.vert deleted file mode 100644 index c527fdf518..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/vert/struct-composite-decl.vert +++ /dev/null @@ -1,26 +0,0 @@ -#version 310 es - -layout(location = 0) in vec4 a; -layout(location = 1) in vec4 b; -layout(location = 2) in vec4 c; -layout(location = 3) in vec4 d; - -struct VOut -{ - vec4 a; - vec4 b; - vec4 c; - vec4 d; -}; - -layout(location = 0) out VOut vout; - -void emit_result(VOut v) -{ - vout = v; -} - -void main() -{ - emit_result(VOut(a, b, c, d)); -} diff --git a/deps/SPIRV-Cross/shaders-hlsl/vert/texture_buffer.vert b/deps/SPIRV-Cross/shaders-hlsl/vert/texture_buffer.vert deleted file mode 100644 index b071e0c966..0000000000 --- a/deps/SPIRV-Cross/shaders-hlsl/vert/texture_buffer.vert +++ /dev/null @@ -1,9 +0,0 @@ -#version 450 - -layout(binding = 4) uniform samplerBuffer uSamp; -layout(rgba32f, binding = 5) uniform readonly imageBuffer uSampo; - -void main() -{ - gl_Position = texelFetch(uSamp, 10) + imageLoad(uSampo, 100); -} diff --git a/deps/SPIRV-Cross/shaders-msl-no-opt/vert/functions_nested.vert b/deps/SPIRV-Cross/shaders-msl-no-opt/vert/functions_nested.vert deleted file mode 100644 index 2eec5ac551..0000000000 --- a/deps/SPIRV-Cross/shaders-msl-no-opt/vert/functions_nested.vert +++ /dev/null @@ -1,132 +0,0 @@ -#version 450 -#extension GL_ARB_separate_shader_objects : enable - -layout(std140, set = 0, binding = 0) uniform VertexBuffer -{ - mat4 scale_offset_mat; - uint vertex_base_index; - ivec4 input_attributes[16]; -}; -layout(set=0, binding=3) uniform usamplerBuffer buff_in_1; -layout(set=0, binding=4) uniform usamplerBuffer buff_in_2; - -layout(location=10) out vec4 back_color; -layout(location=0) out vec4 tc0; - -layout(std140, set=0, binding = 1) uniform VertexConstantsBuffer -{ - vec4 vc[16]; -}; - -struct attr_desc -{ - int type; - int attribute_size; - int starting_offset; - int stride; - int swap_bytes; - int is_volatile; -}; - -uint get_bits(uvec4 v, int swap) -{ - if (swap != 0) return (v.w | v.z << 8 | v.y << 16 | v.x << 24); - return (v.x | v.y << 8 | v.z << 16 | v.w << 24); -} - -vec4 fetch_attr(attr_desc desc, int vertex_id, usamplerBuffer input_stream) -{ - vec4 result = vec4(0.0f, 0.0f, 0.0f, 1.0f); - uvec4 tmp; - uint bits; - bool reverse_order = false; - - int first_byte = (vertex_id * desc.stride) + desc.starting_offset; - for (int n = 0; n < 4; n++) - { - if (n == desc.attribute_size) break; - - switch (desc.type) - { - case 0: - //signed normalized 16-bit - tmp.x = texelFetch(input_stream, first_byte++).x; - tmp.y = texelFetch(input_stream, first_byte++).x; - result[n] = get_bits(tmp, desc.swap_bytes); - break; - case 1: - //float - tmp.x = texelFetch(input_stream, first_byte++).x; - tmp.y = texelFetch(input_stream, first_byte++).x; - tmp.z = texelFetch(input_stream, first_byte++).x; - tmp.w = texelFetch(input_stream, first_byte++).x; - result[n] = uintBitsToFloat(get_bits(tmp, desc.swap_bytes)); - break; - case 2: - //unsigned byte - result[n] = texelFetch(input_stream, first_byte++).x; - reverse_order = (desc.swap_bytes != 0); - break; - } - } - - return (reverse_order)? result.wzyx: result; -} - -attr_desc fetch_desc(int location) -{ - attr_desc result; - int attribute_flags = input_attributes[location].w; - result.type = input_attributes[location].x; - result.attribute_size = input_attributes[location].y; - result.starting_offset = input_attributes[location].z; - result.stride = attribute_flags & 0xFF; - result.swap_bytes = (attribute_flags >> 8) & 0x1; - result.is_volatile = (attribute_flags >> 9) & 0x1; - return result; -} - -vec4 read_location(int location) -{ - attr_desc desc = fetch_desc(location); - - int vertex_id = gl_VertexIndex - int(vertex_base_index); - if (desc.is_volatile != 0) - return fetch_attr(desc, vertex_id, buff_in_2); - else - return fetch_attr(desc, vertex_id, buff_in_1); -} - -void vs_adjust(inout vec4 dst_reg0, inout vec4 dst_reg1, inout vec4 dst_reg7) -{ - vec4 tmp0; - vec4 tmp1; - vec4 in_diff_color= read_location(3); - vec4 in_pos= read_location(0); - vec4 in_tc0= read_location(8); - dst_reg1 = (in_diff_color * vc[13]); - tmp0.x = vec4(dot(vec4(in_pos.xyzx.xyz, 1.0), vc[4])).x; - tmp0.y = vec4(dot(vec4(in_pos.xyzx.xyz, 1.0), vc[5])).y; - tmp0.z = vec4(dot(vec4(in_pos.xyzx.xyz, 1.0), vc[6])).z; - tmp1.xy = in_tc0.xyxx.xy; - tmp1.z = vc[15].xxxx.z; - dst_reg7.y = vec4(dot(vec4(tmp1.xyzx.xyz, 1.0), vc[8])).y; - dst_reg7.x = vec4(dot(vec4(tmp1.xyzx.xyz, 1.0), vc[7])).x; - dst_reg0.y = vec4(dot(vec4(tmp0.xyzx.xyz, 1.0), vc[1])).y; - dst_reg0.x = vec4(dot(vec4(tmp0.xyzx.xyz, 1.0), vc[0])).x; -} - -void main () -{ - vec4 dst_reg0= vec4(0.0f, 0.0f, 0.0f, 1.0f); - vec4 dst_reg1= vec4(0.0, 0.0, 0.0, 0.0); - vec4 dst_reg7= vec4(0.0, 0.0, 0.0, 0.0); - - vs_adjust(dst_reg0, dst_reg1, dst_reg7); - - gl_Position = dst_reg0; - back_color = dst_reg1; - tc0 = dst_reg7; - gl_Position = gl_Position * scale_offset_mat; -} - diff --git a/deps/SPIRV-Cross/shaders-msl/asm/comp/bitcast_iadd.asm.comp b/deps/SPIRV-Cross/shaders-msl/asm/comp/bitcast_iadd.asm.comp deleted file mode 100644 index 3b31ab2851..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/asm/comp/bitcast_iadd.asm.comp +++ /dev/null @@ -1,79 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 1 -; Bound: 30 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint GLCompute %func "main" - OpExecutionMode %func LocalSize 1 1 1 - OpSource ESSL 310 - OpSourceExtension "GL_GOOGLE_cpp_style_line_directive" - OpSourceExtension "GL_GOOGLE_include_directive" - OpMemberDecorate %input_struct 0 Offset 0 - OpMemberDecorate %input_struct 1 Offset 16 - OpMemberDecorate %output_struct 0 Offset 0 - OpMemberDecorate %output_struct 1 Offset 16 - OpDecorate %input_struct BufferBlock - OpDecorate %inputs DescriptorSet 0 - OpDecorate %inputs Binding 0 - OpDecorate %inputs Restrict - OpDecorate %output_struct BufferBlock - OpDecorate %outputs DescriptorSet 0 - OpDecorate %outputs Binding 1 - OpDecorate %outputs Restrict - - %void = OpTypeVoid - %main_func = OpTypeFunction %void - - %uint = OpTypeInt 32 0 - %uvec4 = OpTypeVector %uint 4 - - %int = OpTypeInt 32 1 - %ivec4 = OpTypeVector %int 4 - - %ivec4_ptr = OpTypePointer Uniform %ivec4 - %uvec4_ptr = OpTypePointer Uniform %uvec4 - - %zero = OpConstant %int 0 - %one = OpConstant %int 1 - - %input_struct = OpTypeStruct %ivec4 %uvec4 - %input_struct_ptr = OpTypePointer Uniform %input_struct - %inputs = OpVariable %input_struct_ptr Uniform - %output_struct = OpTypeStruct %uvec4 %ivec4 - %output_struct_ptr = OpTypePointer Uniform %output_struct - %outputs = OpVariable %output_struct_ptr Uniform - - %func = OpFunction %void None %main_func - %block = OpLabel - - %input1_ptr = OpAccessChain %ivec4_ptr %inputs %zero - %input0_ptr = OpAccessChain %uvec4_ptr %inputs %one - %input1 = OpLoad %ivec4 %input1_ptr - %input0 = OpLoad %uvec4 %input0_ptr - - %output_ptr_uvec4 = OpAccessChain %uvec4_ptr %outputs %zero - %output_ptr_ivec4 = OpAccessChain %ivec4_ptr %outputs %one - -; Test all variants of IAdd - %result_iadd_0 = OpIAdd %uvec4 %input0 %input1 - %result_iadd_1 = OpIAdd %uvec4 %input1 %input0 - %result_iadd_2 = OpIAdd %uvec4 %input0 %input0 - %result_iadd_3 = OpIAdd %uvec4 %input1 %input1 - %result_iadd_4 = OpIAdd %ivec4 %input0 %input0 - %result_iadd_5 = OpIAdd %ivec4 %input1 %input1 - %result_iadd_6 = OpIAdd %ivec4 %input0 %input1 - %result_iadd_7 = OpIAdd %ivec4 %input1 %input0 - OpStore %output_ptr_uvec4 %result_iadd_0 - OpStore %output_ptr_uvec4 %result_iadd_1 - OpStore %output_ptr_uvec4 %result_iadd_2 - OpStore %output_ptr_uvec4 %result_iadd_3 - OpStore %output_ptr_ivec4 %result_iadd_4 - OpStore %output_ptr_ivec4 %result_iadd_5 - OpStore %output_ptr_ivec4 %result_iadd_6 - OpStore %output_ptr_ivec4 %result_iadd_7 - - OpReturn - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders-msl/asm/comp/bitcast_sar.asm.comp b/deps/SPIRV-Cross/shaders-msl/asm/comp/bitcast_sar.asm.comp deleted file mode 100644 index 64f19fc349..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/asm/comp/bitcast_sar.asm.comp +++ /dev/null @@ -1,77 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 1 -; Bound: 30 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint GLCompute %func "main" - OpExecutionMode %func LocalSize 1 1 1 - OpSource ESSL 310 - OpSourceExtension "GL_GOOGLE_cpp_style_line_directive" - OpSourceExtension "GL_GOOGLE_include_directive" - OpMemberDecorate %input_struct 0 Offset 0 - OpMemberDecorate %input_struct 1 Offset 16 - OpMemberDecorate %output_struct 0 Offset 0 - OpMemberDecorate %output_struct 1 Offset 16 - OpDecorate %input_struct BufferBlock - OpDecorate %inputs DescriptorSet 0 - OpDecorate %inputs Binding 0 - OpDecorate %output_struct BufferBlock - OpDecorate %outputs DescriptorSet 0 - OpDecorate %outputs Binding 1 - - %void = OpTypeVoid - %main_func = OpTypeFunction %void - - %uint = OpTypeInt 32 0 - %uvec4 = OpTypeVector %uint 4 - - %int = OpTypeInt 32 1 - %ivec4 = OpTypeVector %int 4 - - %ivec4_ptr = OpTypePointer Uniform %ivec4 - %uvec4_ptr = OpTypePointer Uniform %uvec4 - - %zero = OpConstant %int 0 - %one = OpConstant %int 1 - - %input_struct = OpTypeStruct %ivec4 %uvec4 - %input_struct_ptr = OpTypePointer Uniform %input_struct - %inputs = OpVariable %input_struct_ptr Uniform - %output_struct = OpTypeStruct %uvec4 %ivec4 - %output_struct_ptr = OpTypePointer Uniform %output_struct - %outputs = OpVariable %output_struct_ptr Uniform - - %func = OpFunction %void None %main_func - %block = OpLabel - - %input1_ptr = OpAccessChain %ivec4_ptr %inputs %zero - %input0_ptr = OpAccessChain %uvec4_ptr %inputs %one - %input1 = OpLoad %ivec4 %input1_ptr - %input0 = OpLoad %uvec4 %input0_ptr - - %output_ptr_uvec4 = OpAccessChain %uvec4_ptr %outputs %zero - %output_ptr_ivec4 = OpAccessChain %ivec4_ptr %outputs %one - -; Test all variants of ShiftRightArithmetic - %result_iadd_0 = OpShiftRightArithmetic %uvec4 %input0 %input1 - %result_iadd_1 = OpShiftRightArithmetic %uvec4 %input1 %input0 - %result_iadd_2 = OpShiftRightArithmetic %uvec4 %input0 %input0 - %result_iadd_3 = OpShiftRightArithmetic %uvec4 %input1 %input1 - %result_iadd_4 = OpShiftRightArithmetic %ivec4 %input0 %input0 - %result_iadd_5 = OpShiftRightArithmetic %ivec4 %input1 %input1 - %result_iadd_6 = OpShiftRightArithmetic %ivec4 %input0 %input1 - %result_iadd_7 = OpShiftRightArithmetic %ivec4 %input1 %input0 - OpStore %output_ptr_uvec4 %result_iadd_0 - OpStore %output_ptr_uvec4 %result_iadd_1 - OpStore %output_ptr_uvec4 %result_iadd_2 - OpStore %output_ptr_uvec4 %result_iadd_3 - OpStore %output_ptr_ivec4 %result_iadd_4 - OpStore %output_ptr_ivec4 %result_iadd_5 - OpStore %output_ptr_ivec4 %result_iadd_6 - OpStore %output_ptr_ivec4 %result_iadd_7 - - OpReturn - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders-msl/asm/comp/bitcast_sdiv.asm.comp b/deps/SPIRV-Cross/shaders-msl/asm/comp/bitcast_sdiv.asm.comp deleted file mode 100644 index ab73ec83df..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/asm/comp/bitcast_sdiv.asm.comp +++ /dev/null @@ -1,77 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 1 -; Bound: 30 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint GLCompute %func "main" - OpExecutionMode %func LocalSize 1 1 1 - OpSource ESSL 310 - OpSourceExtension "GL_GOOGLE_cpp_style_line_directive" - OpSourceExtension "GL_GOOGLE_include_directive" - OpMemberDecorate %input_struct 0 Offset 0 - OpMemberDecorate %input_struct 1 Offset 16 - OpMemberDecorate %output_struct 0 Offset 0 - OpMemberDecorate %output_struct 1 Offset 16 - OpDecorate %input_struct BufferBlock - OpDecorate %inputs DescriptorSet 0 - OpDecorate %inputs Binding 0 - OpDecorate %output_struct BufferBlock - OpDecorate %outputs DescriptorSet 0 - OpDecorate %outputs Binding 1 - - %void = OpTypeVoid - %main_func = OpTypeFunction %void - - %uint = OpTypeInt 32 0 - %uvec4 = OpTypeVector %uint 4 - - %int = OpTypeInt 32 1 - %ivec4 = OpTypeVector %int 4 - - %ivec4_ptr = OpTypePointer Uniform %ivec4 - %uvec4_ptr = OpTypePointer Uniform %uvec4 - - %zero = OpConstant %int 0 - %one = OpConstant %int 1 - - %input_struct = OpTypeStruct %ivec4 %uvec4 - %input_struct_ptr = OpTypePointer Uniform %input_struct - %inputs = OpVariable %input_struct_ptr Uniform - %output_struct = OpTypeStruct %uvec4 %ivec4 - %output_struct_ptr = OpTypePointer Uniform %output_struct - %outputs = OpVariable %output_struct_ptr Uniform - - %func = OpFunction %void None %main_func - %block = OpLabel - - %input1_ptr = OpAccessChain %ivec4_ptr %inputs %zero - %input0_ptr = OpAccessChain %uvec4_ptr %inputs %one - %input1 = OpLoad %ivec4 %input1_ptr - %input0 = OpLoad %uvec4 %input0_ptr - - %output_ptr_uvec4 = OpAccessChain %uvec4_ptr %outputs %zero - %output_ptr_ivec4 = OpAccessChain %ivec4_ptr %outputs %one - -; Test all variants of SDiv - %result_iadd_0 = OpSDiv %uvec4 %input0 %input1 - %result_iadd_1 = OpSDiv %uvec4 %input1 %input0 - %result_iadd_2 = OpSDiv %uvec4 %input0 %input0 - %result_iadd_3 = OpSDiv %uvec4 %input1 %input1 - %result_iadd_4 = OpSDiv %ivec4 %input0 %input0 - %result_iadd_5 = OpSDiv %ivec4 %input1 %input1 - %result_iadd_6 = OpSDiv %ivec4 %input0 %input1 - %result_iadd_7 = OpSDiv %ivec4 %input1 %input0 - OpStore %output_ptr_uvec4 %result_iadd_0 - OpStore %output_ptr_uvec4 %result_iadd_1 - OpStore %output_ptr_uvec4 %result_iadd_2 - OpStore %output_ptr_uvec4 %result_iadd_3 - OpStore %output_ptr_ivec4 %result_iadd_4 - OpStore %output_ptr_ivec4 %result_iadd_5 - OpStore %output_ptr_ivec4 %result_iadd_6 - OpStore %output_ptr_ivec4 %result_iadd_7 - - OpReturn - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders-msl/asm/comp/bitcast_slr.asm.comp b/deps/SPIRV-Cross/shaders-msl/asm/comp/bitcast_slr.asm.comp deleted file mode 100644 index 6741f5cb58..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/asm/comp/bitcast_slr.asm.comp +++ /dev/null @@ -1,77 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 1 -; Bound: 30 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint GLCompute %func "main" - OpExecutionMode %func LocalSize 1 1 1 - OpSource ESSL 310 - OpSourceExtension "GL_GOOGLE_cpp_style_line_directive" - OpSourceExtension "GL_GOOGLE_include_directive" - OpMemberDecorate %input_struct 0 Offset 0 - OpMemberDecorate %input_struct 1 Offset 16 - OpMemberDecorate %output_struct 0 Offset 0 - OpMemberDecorate %output_struct 1 Offset 16 - OpDecorate %input_struct BufferBlock - OpDecorate %inputs DescriptorSet 0 - OpDecorate %inputs Binding 0 - OpDecorate %output_struct BufferBlock - OpDecorate %outputs DescriptorSet 0 - OpDecorate %outputs Binding 1 - - %void = OpTypeVoid - %main_func = OpTypeFunction %void - - %uint = OpTypeInt 32 0 - %uvec4 = OpTypeVector %uint 4 - - %int = OpTypeInt 32 1 - %ivec4 = OpTypeVector %int 4 - - %ivec4_ptr = OpTypePointer Uniform %ivec4 - %uvec4_ptr = OpTypePointer Uniform %uvec4 - - %zero = OpConstant %int 0 - %one = OpConstant %int 1 - - %input_struct = OpTypeStruct %ivec4 %uvec4 - %input_struct_ptr = OpTypePointer Uniform %input_struct - %inputs = OpVariable %input_struct_ptr Uniform - %output_struct = OpTypeStruct %uvec4 %ivec4 - %output_struct_ptr = OpTypePointer Uniform %output_struct - %outputs = OpVariable %output_struct_ptr Uniform - - %func = OpFunction %void None %main_func - %block = OpLabel - - %input1_ptr = OpAccessChain %ivec4_ptr %inputs %zero - %input0_ptr = OpAccessChain %uvec4_ptr %inputs %one - %input1 = OpLoad %ivec4 %input1_ptr - %input0 = OpLoad %uvec4 %input0_ptr - - %output_ptr_uvec4 = OpAccessChain %uvec4_ptr %outputs %zero - %output_ptr_ivec4 = OpAccessChain %ivec4_ptr %outputs %one - -; Test all variants of ShiftRightLogical - %result_iadd_0 = OpShiftRightLogical %uvec4 %input0 %input1 - %result_iadd_1 = OpShiftRightLogical %uvec4 %input1 %input0 - %result_iadd_2 = OpShiftRightLogical %uvec4 %input0 %input0 - %result_iadd_3 = OpShiftRightLogical %uvec4 %input1 %input1 - %result_iadd_4 = OpShiftRightLogical %ivec4 %input0 %input0 - %result_iadd_5 = OpShiftRightLogical %ivec4 %input1 %input1 - %result_iadd_6 = OpShiftRightLogical %ivec4 %input0 %input1 - %result_iadd_7 = OpShiftRightLogical %ivec4 %input1 %input0 - OpStore %output_ptr_uvec4 %result_iadd_0 - OpStore %output_ptr_uvec4 %result_iadd_1 - OpStore %output_ptr_uvec4 %result_iadd_2 - OpStore %output_ptr_uvec4 %result_iadd_3 - OpStore %output_ptr_ivec4 %result_iadd_4 - OpStore %output_ptr_ivec4 %result_iadd_5 - OpStore %output_ptr_ivec4 %result_iadd_6 - OpStore %output_ptr_ivec4 %result_iadd_7 - - OpReturn - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders-msl/asm/comp/multiple-entry.asm.comp b/deps/SPIRV-Cross/shaders-msl/asm/comp/multiple-entry.asm.comp deleted file mode 100644 index 0cfb5543d1..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/asm/comp/multiple-entry.asm.comp +++ /dev/null @@ -1,97 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 1 -; Bound: 30 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %func_alt "main2" %frag_in %frag_out - OpEntryPoint GLCompute %func "main" - OpExecutionMode %func LocalSize 1 1 1 - OpSource ESSL 310 - OpSourceExtension "GL_GOOGLE_cpp_style_line_directive" - OpSourceExtension "GL_GOOGLE_include_directive" - OpMemberDecorate %input_struct 0 Offset 0 - OpMemberDecorate %input_struct 1 Offset 16 - OpMemberDecorate %output_struct 0 Offset 0 - OpMemberDecorate %output_struct 1 Offset 16 - OpDecorate %input_struct BufferBlock - OpDecorate %inputs DescriptorSet 0 - OpDecorate %inputs Binding 0 - OpDecorate %inputs Restrict - OpDecorate %output_struct BufferBlock - OpDecorate %outputs DescriptorSet 0 - OpDecorate %outputs Binding 1 - OpDecorate %outputs Restrict - OpDecorate %frag_in Location 0 - OpDecorate %frag_out Location 0 - - %void = OpTypeVoid - %main_func = OpTypeFunction %void - - %uint = OpTypeInt 32 0 - %uvec4 = OpTypeVector %uint 4 - - %int = OpTypeInt 32 1 - %ivec4 = OpTypeVector %int 4 - - %ivec4_ptr = OpTypePointer Uniform %ivec4 - %uvec4_ptr = OpTypePointer Uniform %uvec4 - - %float = OpTypeFloat 32 - %vec4 = OpTypeVector %float 4 - %vec4_input_ptr = OpTypePointer Input %vec4 - %vec4_output_ptr = OpTypePointer Output %vec4 - - %zero = OpConstant %int 0 - %one = OpConstant %int 1 - - %input_struct = OpTypeStruct %ivec4 %uvec4 - %input_struct_ptr = OpTypePointer Uniform %input_struct - %inputs = OpVariable %input_struct_ptr Uniform - %output_struct = OpTypeStruct %uvec4 %ivec4 - %output_struct_ptr = OpTypePointer Uniform %output_struct - %outputs = OpVariable %output_struct_ptr Uniform - - %frag_in = OpVariable %vec4_input_ptr Input - %frag_out = OpVariable %vec4_output_ptr Output - - %func = OpFunction %void None %main_func - %block = OpLabel - - %input1_ptr = OpAccessChain %ivec4_ptr %inputs %zero - %input0_ptr = OpAccessChain %uvec4_ptr %inputs %one - %input1 = OpLoad %ivec4 %input1_ptr - %input0 = OpLoad %uvec4 %input0_ptr - - %output_ptr_uvec4 = OpAccessChain %uvec4_ptr %outputs %zero - %output_ptr_ivec4 = OpAccessChain %ivec4_ptr %outputs %one - -; Test all variants of IAdd - %result_iadd_0 = OpIAdd %uvec4 %input0 %input1 - %result_iadd_1 = OpIAdd %uvec4 %input1 %input0 - %result_iadd_2 = OpIAdd %uvec4 %input0 %input0 - %result_iadd_3 = OpIAdd %uvec4 %input1 %input1 - %result_iadd_4 = OpIAdd %ivec4 %input0 %input0 - %result_iadd_5 = OpIAdd %ivec4 %input1 %input1 - %result_iadd_6 = OpIAdd %ivec4 %input0 %input1 - %result_iadd_7 = OpIAdd %ivec4 %input1 %input0 - OpStore %output_ptr_uvec4 %result_iadd_0 - OpStore %output_ptr_uvec4 %result_iadd_1 - OpStore %output_ptr_uvec4 %result_iadd_2 - OpStore %output_ptr_uvec4 %result_iadd_3 - OpStore %output_ptr_ivec4 %result_iadd_4 - OpStore %output_ptr_ivec4 %result_iadd_5 - OpStore %output_ptr_ivec4 %result_iadd_6 - OpStore %output_ptr_ivec4 %result_iadd_7 - - OpReturn - OpFunctionEnd - - %func_alt = OpFunction %void None %main_func - %block_alt = OpLabel - %frag_input_value = OpLoad %vec4 %frag_in - OpStore %frag_out %frag_input_value - OpReturn - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders-msl/asm/comp/quantize.asm.comp b/deps/SPIRV-Cross/shaders-msl/asm/comp/quantize.asm.comp deleted file mode 100644 index f5afc6570c..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/asm/comp/quantize.asm.comp +++ /dev/null @@ -1,67 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 1 -; Bound: 38 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint GLCompute %4 "main" - OpExecutionMode %4 LocalSize 1 1 1 - OpSource ESSL 310 - OpName %4 "main" - OpName %10 "SSBO0" - OpMemberName %10 0 "scalar" - OpMemberName %10 1 "vec2_val" - OpMemberName %10 2 "vec3_val" - OpMemberName %10 3 "vec4_val" - OpName %12 "" - OpMemberDecorate %10 0 Offset 0 - OpMemberDecorate %10 1 Offset 8 - OpMemberDecorate %10 2 Offset 16 - OpMemberDecorate %10 3 Offset 32 - OpDecorate %10 BufferBlock - OpDecorate %12 DescriptorSet 0 - OpDecorate %12 Binding 0 - %2 = OpTypeVoid - %3 = OpTypeFunction %2 - %6 = OpTypeFloat 32 - %7 = OpTypeVector %6 2 - %8 = OpTypeVector %6 3 - %9 = OpTypeVector %6 4 - %10 = OpTypeStruct %6 %7 %8 %9 - %11 = OpTypePointer Uniform %10 - %12 = OpVariable %11 Uniform - %13 = OpTypeInt 32 1 - %14 = OpConstant %13 0 - %15 = OpTypePointer Uniform %6 - %20 = OpConstant %13 1 - %21 = OpTypePointer Uniform %7 - %26 = OpConstant %13 2 - %27 = OpTypePointer Uniform %8 - %32 = OpConstant %13 3 - %33 = OpTypePointer Uniform %9 - %4 = OpFunction %2 None %3 - %5 = OpLabel - %16 = OpAccessChain %15 %12 %14 - %17 = OpLoad %6 %16 - %18 = OpQuantizeToF16 %6 %17 - %19 = OpAccessChain %15 %12 %14 - OpStore %19 %18 - %22 = OpAccessChain %21 %12 %20 - %23 = OpLoad %7 %22 - %24 = OpQuantizeToF16 %7 %23 - %25 = OpAccessChain %21 %12 %20 - OpStore %25 %24 - %28 = OpAccessChain %27 %12 %26 - %29 = OpLoad %8 %28 - %30 = OpQuantizeToF16 %8 %29 - %31 = OpAccessChain %27 %12 %26 - OpStore %31 %30 - %34 = OpAccessChain %33 %12 %32 - %35 = OpLoad %9 %34 - %36 = OpQuantizeToF16 %9 %35 - %37 = OpAccessChain %33 %12 %32 - OpStore %37 %36 - OpReturn - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders-msl/asm/comp/specialization-constant-workgroup.asm.comp b/deps/SPIRV-Cross/shaders-msl/asm/comp/specialization-constant-workgroup.asm.comp deleted file mode 100644 index 188e3fec36..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/asm/comp/specialization-constant-workgroup.asm.comp +++ /dev/null @@ -1,47 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 1 -; Bound: 24 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint GLCompute %main "main" - OpExecutionMode %main LocalSize 1 20 1 - OpSource ESSL 310 - OpName %main "main" - OpName %SSBO "SSBO" - OpMemberName %SSBO 0 "a" - OpName %_ "" - OpMemberDecorate %SSBO 0 Offset 0 - OpDecorate %SSBO BufferBlock - OpDecorate %_ DescriptorSet 0 - OpDecorate %_ Binding 0 - OpDecorate %19 SpecId 10 - OpDecorate %21 SpecId 12 - OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 - %SSBO = OpTypeStruct %float -%_ptr_Uniform_SSBO = OpTypePointer Uniform %SSBO - %_ = OpVariable %_ptr_Uniform_SSBO Uniform - %int = OpTypeInt 32 1 - %int_0 = OpConstant %int 0 - %float_1 = OpConstant %float 1 -%_ptr_Uniform_float = OpTypePointer Uniform %float - %uint = OpTypeInt 32 0 - %19 = OpSpecConstant %uint 9 - %uint_20 = OpConstant %uint 20 - %21 = OpSpecConstant %uint 4 - %v3uint = OpTypeVector %uint 3 -%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %19 %uint_20 %21 - %main = OpFunction %void None %3 - %5 = OpLabel - %14 = OpAccessChain %_ptr_Uniform_float %_ %int_0 - %15 = OpLoad %float %14 - %16 = OpFAdd %float %15 %float_1 - %17 = OpAccessChain %_ptr_Uniform_float %_ %int_0 - OpStore %17 %16 - OpReturn - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders-msl/asm/comp/storage-buffer-basic.asm.comp b/deps/SPIRV-Cross/shaders-msl/asm/comp/storage-buffer-basic.asm.comp deleted file mode 100644 index bdf2027a80..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/asm/comp/storage-buffer-basic.asm.comp +++ /dev/null @@ -1,58 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Codeplay; 0 -; Bound: 31 -; Schema: 0 - OpCapability Shader - OpCapability VariablePointers - OpExtension "SPV_KHR_storage_buffer_storage_class" - OpExtension "SPV_KHR_variable_pointers" - OpMemoryModel Logical GLSL450 - OpEntryPoint GLCompute %22 "main" %gl_WorkGroupID - OpSource OpenCL_C 120 - OpDecorate %15 SpecId 0 - ;OpDecorate %16 SpecId 1 - OpDecorate %17 SpecId 2 - OpDecorate %_runtimearr_float ArrayStride 4 - OpMemberDecorate %_struct_4 0 Offset 0 - OpDecorate %_struct_4 Block - OpDecorate %gl_WorkGroupID BuiltIn WorkgroupId - OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize - OpDecorate %20 DescriptorSet 0 - OpDecorate %20 Binding 0 - OpDecorate %21 DescriptorSet 0 - OpDecorate %21 Binding 1 - %float = OpTypeFloat 32 - %uint = OpTypeInt 32 0 - %size1 = OpConstant %uint 1 -%_ptr_StorageBuffer_float = OpTypePointer StorageBuffer %float -%_runtimearr_float = OpTypeArray %float %size1 ; Runtime arrays do not work yet in MSL. - %_struct_4 = OpTypeStruct %_runtimearr_float -%_ptr_StorageBuffer__struct_4 = OpTypePointer StorageBuffer %_struct_4 - %void = OpTypeVoid - %8 = OpTypeFunction %void - %v3uint = OpTypeVector %uint 3 -%_ptr_Input_v3uint = OpTypePointer Input %v3uint -%_ptr_Input_uint = OpTypePointer Input %uint -%_ptr_Private_v3uint = OpTypePointer Private %v3uint - %uint_0 = OpConstant %uint 0 -%gl_WorkGroupID = OpVariable %_ptr_Input_v3uint Input - %15 = OpSpecConstant %uint 1 - %16 = OpConstant %uint 2 - %17 = OpSpecConstant %uint 3 -%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %15 %16 %17 - %19 = OpVariable %_ptr_Private_v3uint Private %gl_WorkGroupSize - %20 = OpVariable %_ptr_StorageBuffer__struct_4 StorageBuffer - %21 = OpVariable %_ptr_StorageBuffer__struct_4 StorageBuffer - %22 = OpFunction %void None %8 - %23 = OpLabel - %24 = OpAccessChain %_ptr_Input_uint %gl_WorkGroupID %uint_0 - %25 = OpLoad %uint %24 - %26 = OpAccessChain %_ptr_StorageBuffer_float %21 %uint_0 %25 - %27 = OpLoad %float %26 - %28 = OpAccessChain %_ptr_StorageBuffer_float %20 %uint_0 %25 - %29 = OpLoad %float %28 - %30 = OpFAdd %float %27 %29 - OpStore %28 %30 - OpReturn - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders-msl/asm/frag/default-member-names.asm.frag b/deps/SPIRV-Cross/shaders-msl/asm/frag/default-member-names.asm.frag deleted file mode 100644 index 4d616fe493..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/asm/frag/default-member-names.asm.frag +++ /dev/null @@ -1,57 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 1 -; Bound: 43 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %2 "main" %3 - OpExecutionMode %2 OriginLowerLeft - OpDecorate %3 Location 0 - %void = OpTypeVoid - %9 = OpTypeFunction %void - %float = OpTypeFloat 32 - %v4float = OpTypeVector %float 4 - %12 = OpTypeFunction %v4float - %_struct_5 = OpTypeStruct %float - %_struct_6 = OpTypeStruct %float %float %float %float %float %float %float %float %float %float %float %float %_struct_5 -%_ptr_Function__struct_6 = OpTypePointer Function %_struct_6 - %int = OpTypeInt 32 1 - %int_0 = OpConstant %int 0 -%_ptr_Function_float = OpTypePointer Function %float - %int_1 = OpConstant %int 1 - %int_2 = OpConstant %int 2 - %int_3 = OpConstant %int 3 -%_ptr_Output_v4float = OpTypePointer Output %v4float - %3 = OpVariable %_ptr_Output_v4float Output -%_ptr_Function_v4float = OpTypePointer Function %v4float - %2 = OpFunction %void None %9 - %22 = OpLabel - %23 = OpVariable %_ptr_Function__struct_6 Function - %24 = OpAccessChain %_ptr_Function_float %23 %int_0 - %25 = OpLoad %float %24 - %26 = OpAccessChain %_ptr_Function_float %23 %int_1 - %27 = OpLoad %float %26 - %28 = OpAccessChain %_ptr_Function_float %23 %int_2 - %29 = OpLoad %float %28 - %30 = OpAccessChain %_ptr_Function_float %23 %int_3 - %31 = OpLoad %float %30 - %32 = OpCompositeConstruct %v4float %25 %27 %29 %31 - OpStore %3 %32 - OpReturn - OpFunctionEnd - %4 = OpFunction %v4float None %12 - %33 = OpLabel - %7 = OpVariable %_ptr_Function__struct_6 Function - %34 = OpAccessChain %_ptr_Function_float %7 %int_0 - %35 = OpLoad %float %34 - %36 = OpAccessChain %_ptr_Function_float %7 %int_1 - %37 = OpLoad %float %36 - %38 = OpAccessChain %_ptr_Function_float %7 %int_2 - %39 = OpLoad %float %38 - %40 = OpAccessChain %_ptr_Function_float %7 %int_3 - %41 = OpLoad %float %40 - %42 = OpCompositeConstruct %v4float %35 %37 %39 %41 - OpReturnValue %42 - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag b/deps/SPIRV-Cross/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag deleted file mode 100644 index 8b09e5b68f..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag +++ /dev/null @@ -1,646 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 3 -; Bound: 1532 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %main "main" %IN_HPosition %IN_Uv_EdgeDistance1 %IN_UvStuds_EdgeDistance2 %IN_Color %IN_LightPosition_Fog %IN_View_Depth %IN_Normal_SpecPower %IN_Tangent %IN_PosLightSpace_Reflectance %IN_studIndex %_entryPointOutput - OpExecutionMode %main OriginUpperLeft - OpSource HLSL 500 - OpName %main "main" - OpName %VertexOutput "VertexOutput" - OpMemberName %VertexOutput 0 "HPosition" - OpMemberName %VertexOutput 1 "Uv_EdgeDistance1" - OpMemberName %VertexOutput 2 "UvStuds_EdgeDistance2" - OpMemberName %VertexOutput 3 "Color" - OpMemberName %VertexOutput 4 "LightPosition_Fog" - OpMemberName %VertexOutput 5 "View_Depth" - OpMemberName %VertexOutput 6 "Normal_SpecPower" - OpMemberName %VertexOutput 7 "Tangent" - OpMemberName %VertexOutput 8 "PosLightSpace_Reflectance" - OpMemberName %VertexOutput 9 "studIndex" - OpName %Surface "Surface" - OpMemberName %Surface 0 "albedo" - OpMemberName %Surface 1 "normal" - OpMemberName %Surface 2 "specular" - OpMemberName %Surface 3 "gloss" - OpMemberName %Surface 4 "reflectance" - OpMemberName %Surface 5 "opacity" - OpName %SurfaceInput "SurfaceInput" - OpMemberName %SurfaceInput 0 "Color" - OpMemberName %SurfaceInput 1 "Uv" - OpMemberName %SurfaceInput 2 "UvStuds" - OpName %Globals "Globals" - OpMemberName %Globals 0 "ViewProjection" - OpMemberName %Globals 1 "ViewRight" - OpMemberName %Globals 2 "ViewUp" - OpMemberName %Globals 3 "ViewDir" - OpMemberName %Globals 4 "CameraPosition" - OpMemberName %Globals 5 "AmbientColor" - OpMemberName %Globals 6 "Lamp0Color" - OpMemberName %Globals 7 "Lamp0Dir" - OpMemberName %Globals 8 "Lamp1Color" - OpMemberName %Globals 9 "FogParams" - OpMemberName %Globals 10 "FogColor" - OpMemberName %Globals 11 "LightBorder" - OpMemberName %Globals 12 "LightConfig0" - OpMemberName %Globals 13 "LightConfig1" - OpMemberName %Globals 14 "LightConfig2" - OpMemberName %Globals 15 "LightConfig3" - OpMemberName %Globals 16 "RefractionBias_FadeDistance_GlowFactor" - OpMemberName %Globals 17 "OutlineBrightness_ShadowInfo" - OpMemberName %Globals 18 "ShadowMatrix0" - OpMemberName %Globals 19 "ShadowMatrix1" - OpMemberName %Globals 20 "ShadowMatrix2" - OpName %CB0 "CB0" - OpMemberName %CB0 0 "CB0" - OpName %_ "" - OpName %LightMapTexture "LightMapTexture" - OpName %LightMapSampler "LightMapSampler" - OpName %ShadowMapSampler "ShadowMapSampler" - OpName %ShadowMapTexture "ShadowMapTexture" - OpName %EnvironmentMapTexture "EnvironmentMapTexture" - OpName %EnvironmentMapSampler "EnvironmentMapSampler" - OpName %IN_HPosition "IN.HPosition" - OpName %IN_Uv_EdgeDistance1 "IN.Uv_EdgeDistance1" - OpName %IN_UvStuds_EdgeDistance2 "IN.UvStuds_EdgeDistance2" - OpName %IN_Color "IN.Color" - OpName %IN_LightPosition_Fog "IN.LightPosition_Fog" - OpName %IN_View_Depth "IN.View_Depth" - OpName %IN_Normal_SpecPower "IN.Normal_SpecPower" - OpName %IN_Tangent "IN.Tangent" - OpName %IN_PosLightSpace_Reflectance "IN.PosLightSpace_Reflectance" - OpName %IN_studIndex "IN.studIndex" - OpName %_entryPointOutput "@entryPointOutput" - OpName %DiffuseMapSampler "DiffuseMapSampler" - OpName %DiffuseMapTexture "DiffuseMapTexture" - OpName %NormalMapSampler "NormalMapSampler" - OpName %NormalMapTexture "NormalMapTexture" - OpName %NormalDetailMapTexture "NormalDetailMapTexture" - OpName %NormalDetailMapSampler "NormalDetailMapSampler" - OpName %StudsMapTexture "StudsMapTexture" - OpName %StudsMapSampler "StudsMapSampler" - OpName %SpecularMapSampler "SpecularMapSampler" - OpName %SpecularMapTexture "SpecularMapTexture" - OpName %Params "Params" - OpMemberName %Params 0 "LqmatFarTilingFactor" - OpName %CB2 "CB2" - OpMemberName %CB2 0 "CB2" - OpMemberDecorate %Globals 0 ColMajor - OpMemberDecorate %Globals 0 Offset 0 - OpMemberDecorate %Globals 0 MatrixStride 16 - OpMemberDecorate %Globals 1 Offset 64 - OpMemberDecorate %Globals 2 Offset 80 - OpMemberDecorate %Globals 3 Offset 96 - OpMemberDecorate %Globals 4 Offset 112 - OpMemberDecorate %Globals 5 Offset 128 - OpMemberDecorate %Globals 6 Offset 144 - OpMemberDecorate %Globals 7 Offset 160 - OpMemberDecorate %Globals 8 Offset 176 - OpMemberDecorate %Globals 9 Offset 192 - OpMemberDecorate %Globals 10 Offset 208 - OpMemberDecorate %Globals 11 Offset 224 - OpMemberDecorate %Globals 12 Offset 240 - OpMemberDecorate %Globals 13 Offset 256 - OpMemberDecorate %Globals 14 Offset 272 - OpMemberDecorate %Globals 15 Offset 288 - OpMemberDecorate %Globals 16 Offset 304 - OpMemberDecorate %Globals 17 Offset 320 - OpMemberDecorate %Globals 18 Offset 336 - OpMemberDecorate %Globals 19 Offset 352 - OpMemberDecorate %Globals 20 Offset 368 - OpMemberDecorate %CB0 0 Offset 0 - OpDecorate %CB0 Block - OpDecorate %_ DescriptorSet 0 - OpDecorate %_ Binding 0 - OpDecorate %LightMapTexture DescriptorSet 1 - OpDecorate %LightMapTexture Binding 6 - OpDecorate %LightMapSampler DescriptorSet 1 - OpDecorate %LightMapSampler Binding 6 - OpDecorate %ShadowMapSampler DescriptorSet 1 - OpDecorate %ShadowMapSampler Binding 1 - OpDecorate %ShadowMapTexture DescriptorSet 1 - OpDecorate %ShadowMapTexture Binding 1 - OpDecorate %EnvironmentMapTexture DescriptorSet 1 - OpDecorate %EnvironmentMapTexture Binding 2 - OpDecorate %EnvironmentMapSampler DescriptorSet 1 - OpDecorate %EnvironmentMapSampler Binding 2 - OpDecorate %IN_HPosition BuiltIn FragCoord - OpDecorate %IN_Uv_EdgeDistance1 Location 0 - OpDecorate %IN_UvStuds_EdgeDistance2 Location 1 - OpDecorate %IN_Color Location 2 - OpDecorate %IN_LightPosition_Fog Location 3 - OpDecorate %IN_View_Depth Location 4 - OpDecorate %IN_Normal_SpecPower Location 5 - OpDecorate %IN_Tangent Location 6 - OpDecorate %IN_PosLightSpace_Reflectance Location 7 - OpDecorate %IN_studIndex Location 8 - OpDecorate %_entryPointOutput Location 0 - OpDecorate %DiffuseMapSampler DescriptorSet 1 - OpDecorate %DiffuseMapSampler Binding 3 - OpDecorate %DiffuseMapTexture DescriptorSet 1 - OpDecorate %DiffuseMapTexture Binding 3 - OpDecorate %NormalMapSampler DescriptorSet 1 - OpDecorate %NormalMapSampler Binding 4 - OpDecorate %NormalMapTexture DescriptorSet 1 - OpDecorate %NormalMapTexture Binding 4 - OpDecorate %NormalDetailMapTexture DescriptorSet 1 - OpDecorate %NormalDetailMapTexture Binding 8 - OpDecorate %NormalDetailMapSampler DescriptorSet 1 - OpDecorate %NormalDetailMapSampler Binding 8 - OpDecorate %StudsMapTexture DescriptorSet 1 - OpDecorate %StudsMapTexture Binding 0 - OpDecorate %StudsMapSampler DescriptorSet 1 - OpDecorate %StudsMapSampler Binding 0 - OpDecorate %SpecularMapSampler DescriptorSet 1 - OpDecorate %SpecularMapSampler Binding 5 - OpDecorate %SpecularMapTexture DescriptorSet 1 - OpDecorate %SpecularMapTexture Binding 5 - OpMemberDecorate %Params 0 Offset 0 - OpMemberDecorate %CB2 0 Offset 0 - OpDecorate %CB2 Block - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 -%_ptr_Function_float = OpTypePointer Function %float - %8 = OpTypeFunction %float %_ptr_Function_float - %v4float = OpTypeVector %float 4 -%_ptr_Function_v4float = OpTypePointer Function %v4float - %v3float = OpTypeVector %float 3 - %18 = OpTypeFunction %v3float %_ptr_Function_v4float -%_ptr_Function_v3float = OpTypePointer Function %v3float - %23 = OpTypeFunction %v4float %_ptr_Function_v3float - %27 = OpTypeFunction %float %_ptr_Function_v3float - %31 = OpTypeFunction %float %_ptr_Function_float %_ptr_Function_float - %36 = OpTypeSampler -%_ptr_Function_36 = OpTypePointer Function %36 - %38 = OpTypeImage %float 2D 0 0 0 1 Unknown -%_ptr_Function_38 = OpTypePointer Function %38 - %40 = OpTypeFunction %float %_ptr_Function_36 %_ptr_Function_38 %_ptr_Function_v3float %_ptr_Function_float -%VertexOutput = OpTypeStruct %v4float %v4float %v4float %v4float %v4float %v4float %v4float %v3float %v4float %float -%_ptr_Function_VertexOutput = OpTypePointer Function %VertexOutput - %Surface = OpTypeStruct %v3float %v3float %float %float %float %float - %50 = OpTypeFunction %Surface %_ptr_Function_VertexOutput - %54 = OpTypeFunction %v4float %_ptr_Function_VertexOutput - %v2float = OpTypeVector %float 2 -%_ptr_Function_v2float = OpTypePointer Function %v2float - %60 = OpTypeFunction %v4float %_ptr_Function_36 %_ptr_Function_38 %_ptr_Function_v2float %_ptr_Function_float %_ptr_Function_float -%SurfaceInput = OpTypeStruct %v4float %v2float %v2float -%_ptr_Function_SurfaceInput = OpTypePointer Function %SurfaceInput - %70 = OpTypeFunction %Surface %_ptr_Function_SurfaceInput %_ptr_Function_v2float - %float_0 = OpConstant %float 0 - %float_1 = OpConstant %float 1 - %float_2 = OpConstant %float 2 -%mat4v4float = OpTypeMatrix %v4float 4 - %Globals = OpTypeStruct %mat4v4float %v4float %v4float %v4float %v3float %v3float %v3float %v3float %v3float %v4float %v3float %v4float %v4float %v4float %v4float %v4float %v4float %v4float %v4float %v4float %v4float - %CB0 = OpTypeStruct %Globals -%_ptr_Uniform_CB0 = OpTypePointer Uniform %CB0 - %_ = OpVariable %_ptr_Uniform_CB0 Uniform - %int = OpTypeInt 32 1 - %int_0 = OpConstant %int 0 - %int_15 = OpConstant %int 15 -%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float - %int_14 = OpConstant %int 14 - %128 = OpConstantComposite %v3float %float_1 %float_1 %float_1 - %133 = OpTypeImage %float 3D 0 0 0 1 Unknown -%_ptr_UniformConstant_133 = OpTypePointer UniformConstant %133 -%LightMapTexture = OpVariable %_ptr_UniformConstant_133 UniformConstant -%_ptr_UniformConstant_36 = OpTypePointer UniformConstant %36 -%LightMapSampler = OpVariable %_ptr_UniformConstant_36 UniformConstant - %140 = OpTypeSampledImage %133 - %int_11 = OpConstant %int 11 - %uint = OpTypeInt 32 0 - %float_9 = OpConstant %float 9 - %float_20 = OpConstant %float 20 - %float_0_5 = OpConstant %float 0.5 - %183 = OpTypeSampledImage %38 - %uint_0 = OpConstant %uint 0 - %uint_1 = OpConstant %uint 1 - %int_17 = OpConstant %int 17 - %uint_3 = OpConstant %uint 3 -%_ptr_Uniform_float = OpTypePointer Uniform %float - %float_0_25 = OpConstant %float 0.25 - %int_5 = OpConstant %int 5 -%float_0_00333333 = OpConstant %float 0.00333333 - %int_16 = OpConstant %int 16 -%_ptr_Function_Surface = OpTypePointer Function %Surface - %int_6 = OpConstant %int 6 - %int_7 = OpConstant %int 7 -%_ptr_Uniform_v3float = OpTypePointer Uniform %v3float - %int_8 = OpConstant %int 8 -%ShadowMapSampler = OpVariable %_ptr_UniformConstant_36 UniformConstant -%_ptr_UniformConstant_38 = OpTypePointer UniformConstant %38 -%ShadowMapTexture = OpVariable %_ptr_UniformConstant_38 UniformConstant - %367 = OpTypeImage %float Cube 0 0 0 1 Unknown -%_ptr_UniformConstant_367 = OpTypePointer UniformConstant %367 -%EnvironmentMapTexture = OpVariable %_ptr_UniformConstant_367 UniformConstant -%EnvironmentMapSampler = OpVariable %_ptr_UniformConstant_36 UniformConstant - %373 = OpTypeSampledImage %367 - %float_1_5 = OpConstant %float 1.5 - %int_10 = OpConstant %int 10 -%_ptr_Input_v4float = OpTypePointer Input %v4float -%IN_HPosition = OpVariable %_ptr_Input_v4float Input -%IN_Uv_EdgeDistance1 = OpVariable %_ptr_Input_v4float Input -%IN_UvStuds_EdgeDistance2 = OpVariable %_ptr_Input_v4float Input - %IN_Color = OpVariable %_ptr_Input_v4float Input -%IN_LightPosition_Fog = OpVariable %_ptr_Input_v4float Input -%IN_View_Depth = OpVariable %_ptr_Input_v4float Input -%IN_Normal_SpecPower = OpVariable %_ptr_Input_v4float Input -%_ptr_Input_v3float = OpTypePointer Input %v3float - %IN_Tangent = OpVariable %_ptr_Input_v3float Input -%IN_PosLightSpace_Reflectance = OpVariable %_ptr_Input_v4float Input -%_ptr_Input_float = OpTypePointer Input %float -%IN_studIndex = OpVariable %_ptr_Input_float Input -%_ptr_Output_v4float = OpTypePointer Output %v4float -%_entryPointOutput = OpVariable %_ptr_Output_v4float Output - %bool = OpTypeBool -%DiffuseMapSampler = OpVariable %_ptr_UniformConstant_36 UniformConstant -%DiffuseMapTexture = OpVariable %_ptr_UniformConstant_38 UniformConstant -%NormalMapSampler = OpVariable %_ptr_UniformConstant_36 UniformConstant -%NormalMapTexture = OpVariable %_ptr_UniformConstant_38 UniformConstant -%NormalDetailMapTexture = OpVariable %_ptr_UniformConstant_38 UniformConstant -%NormalDetailMapSampler = OpVariable %_ptr_UniformConstant_36 UniformConstant - %float_0_3 = OpConstant %float 0.3 -%StudsMapTexture = OpVariable %_ptr_UniformConstant_38 UniformConstant -%StudsMapSampler = OpVariable %_ptr_UniformConstant_36 UniformConstant -%SpecularMapSampler = OpVariable %_ptr_UniformConstant_36 UniformConstant -%SpecularMapTexture = OpVariable %_ptr_UniformConstant_38 UniformConstant - %float_0_75 = OpConstant %float 0.75 - %float_256 = OpConstant %float 256 - %689 = OpConstantComposite %v2float %float_2 %float_256 - %float_0_01 = OpConstant %float 0.01 - %692 = OpConstantComposite %v2float %float_0 %float_0_01 - %float_0_8 = OpConstant %float 0.8 - %float_120 = OpConstant %float 120 - %697 = OpConstantComposite %v2float %float_0_8 %float_120 - %Params = OpTypeStruct %v4float - %CB2 = OpTypeStruct %Params -%_ptr_Uniform_CB2 = OpTypePointer Uniform %CB2 - %false = OpConstantFalse %bool - %1509 = OpUndef %VertexOutput - %1510 = OpUndef %SurfaceInput - %1511 = OpUndef %v2float - %1512 = OpUndef %v4float - %1531 = OpUndef %Surface - %main = OpFunction %void None %3 - %5 = OpLabel - %501 = OpLoad %v4float %IN_HPosition - %1378 = OpCompositeInsert %VertexOutput %501 %1509 0 - %504 = OpLoad %v4float %IN_Uv_EdgeDistance1 - %1380 = OpCompositeInsert %VertexOutput %504 %1378 1 - %507 = OpLoad %v4float %IN_UvStuds_EdgeDistance2 - %1382 = OpCompositeInsert %VertexOutput %507 %1380 2 - %510 = OpLoad %v4float %IN_Color - %1384 = OpCompositeInsert %VertexOutput %510 %1382 3 - %513 = OpLoad %v4float %IN_LightPosition_Fog - %1386 = OpCompositeInsert %VertexOutput %513 %1384 4 - %516 = OpLoad %v4float %IN_View_Depth - %1388 = OpCompositeInsert %VertexOutput %516 %1386 5 - %519 = OpLoad %v4float %IN_Normal_SpecPower - %1390 = OpCompositeInsert %VertexOutput %519 %1388 6 - %523 = OpLoad %v3float %IN_Tangent - %1392 = OpCompositeInsert %VertexOutput %523 %1390 7 - %526 = OpLoad %v4float %IN_PosLightSpace_Reflectance - %1394 = OpCompositeInsert %VertexOutput %526 %1392 8 - %530 = OpLoad %float %IN_studIndex - %1396 = OpCompositeInsert %VertexOutput %530 %1394 9 - %1400 = OpCompositeInsert %SurfaceInput %510 %1510 0 - %954 = OpVectorShuffle %v2float %504 %504 0 1 - %1404 = OpCompositeInsert %SurfaceInput %954 %1400 1 - %958 = OpVectorShuffle %v2float %507 %507 0 1 - %1408 = OpCompositeInsert %SurfaceInput %958 %1404 2 - %1410 = OpCompositeExtract %float %1408 2 1 - %962 = OpExtInst %float %1 Fract %1410 - %965 = OpFAdd %float %962 %530 - %966 = OpFMul %float %965 %float_0_25 - %1414 = OpCompositeInsert %SurfaceInput %966 %1408 2 1 - %1416 = OpCompositeExtract %float %1396 5 3 - %970 = OpFMul %float %1416 %float_0_00333333 - %971 = OpFSub %float %float_1 %970 - %987 = OpExtInst %float %1 FClamp %971 %float_0 %float_1 - %976 = OpAccessChain %_ptr_Uniform_float %_ %int_0 %int_16 %uint_1 - %977 = OpLoad %float %976 - %978 = OpFMul %float %1416 %977 - %979 = OpFSub %float %float_1 %978 - %990 = OpExtInst %float %1 FClamp %979 %float_0 %float_1 - %1024 = OpVectorTimesScalar %v2float %954 %float_1 - %1029 = OpLoad %36 %DiffuseMapSampler - %1030 = OpLoad %38 %DiffuseMapTexture - OpBranch %1119 - %1119 = OpLabel - OpLoopMerge %1120 %1121 None - OpBranch %1122 - %1122 = OpLabel - %1124 = OpFOrdEqual %bool %float_0 %float_0 - OpSelectionMerge %1125 None - OpBranchConditional %1124 %1126 %1127 - %1126 = OpLabel - %1130 = OpSampledImage %183 %1030 %1029 - %1132 = OpImageSampleImplicitLod %v4float %1130 %1024 - OpBranch %1120 - %1127 = OpLabel - %1134 = OpFSub %float %float_1 %float_0 - %1135 = OpFDiv %float %float_1 %1134 - %1138 = OpSampledImage %183 %1030 %1029 - %1140 = OpVectorTimesScalar %v2float %1024 %float_0_25 - %1141 = OpImageSampleImplicitLod %v4float %1138 %1140 - %1144 = OpSampledImage %183 %1030 %1029 - %1146 = OpImageSampleImplicitLod %v4float %1144 %1024 - %1149 = OpFMul %float %987 %1135 - %1152 = OpFMul %float %float_0 %1135 - %1153 = OpFSub %float %1149 %1152 - %1161 = OpExtInst %float %1 FClamp %1153 %float_0 %float_1 - %1155 = OpCompositeConstruct %v4float %1161 %1161 %1161 %1161 - %1156 = OpExtInst %v4float %1 FMix %1141 %1146 %1155 - OpBranch %1120 - %1125 = OpLabel - %1157 = OpUndef %v4float - OpBranch %1120 - %1121 = OpLabel - OpBranchConditional %false %1119 %1120 - %1120 = OpLabel - %1517 = OpPhi %v4float %1132 %1126 %1156 %1127 %1157 %1125 %1512 %1121 - %1035 = OpVectorTimesScalar %v4float %1517 %float_1 - %1036 = OpLoad %36 %NormalMapSampler - %1037 = OpLoad %38 %NormalMapTexture - OpBranch %1165 - %1165 = OpLabel - OpLoopMerge %1166 %1167 None - OpBranch %1168 - %1168 = OpLabel - OpSelectionMerge %1171 None - OpBranchConditional %1124 %1172 %1173 - %1172 = OpLabel - %1176 = OpSampledImage %183 %1037 %1036 - %1178 = OpImageSampleImplicitLod %v4float %1176 %1024 - OpBranch %1166 - %1173 = OpLabel - %1180 = OpFSub %float %float_1 %float_0 - %1181 = OpFDiv %float %float_1 %1180 - %1184 = OpSampledImage %183 %1037 %1036 - %1186 = OpVectorTimesScalar %v2float %1024 %float_0_25 - %1187 = OpImageSampleImplicitLod %v4float %1184 %1186 - %1190 = OpSampledImage %183 %1037 %1036 - %1192 = OpImageSampleImplicitLod %v4float %1190 %1024 - %1195 = OpFMul %float %990 %1181 - %1198 = OpFMul %float %float_0 %1181 - %1199 = OpFSub %float %1195 %1198 - %1206 = OpExtInst %float %1 FClamp %1199 %float_0 %float_1 - %1201 = OpCompositeConstruct %v4float %1206 %1206 %1206 %1206 - %1202 = OpExtInst %v4float %1 FMix %1187 %1192 %1201 - OpBranch %1166 - %1171 = OpLabel - %1203 = OpUndef %v4float - OpBranch %1166 - %1167 = OpLabel - OpBranchConditional %false %1165 %1166 - %1166 = OpLabel - %1523 = OpPhi %v4float %1178 %1172 %1202 %1173 %1203 %1171 %1512 %1167 - %1210 = OpVectorShuffle %v2float %1523 %1523 3 1 - %1211 = OpVectorTimesScalar %v2float %1210 %float_2 - %1212 = OpCompositeConstruct %v2float %float_1 %float_1 - %1213 = OpFSub %v2float %1211 %1212 - %1216 = OpFNegate %v2float %1213 - %1218 = OpDot %float %1216 %1213 - %1219 = OpFAdd %float %float_1 %1218 - %1220 = OpExtInst %float %1 FClamp %1219 %float_0 %float_1 - %1221 = OpExtInst %float %1 Sqrt %1220 - %1222 = OpCompositeExtract %float %1213 0 - %1223 = OpCompositeExtract %float %1213 1 - %1224 = OpCompositeConstruct %v3float %1222 %1223 %1221 - %1042 = OpLoad %38 %NormalDetailMapTexture - %1043 = OpLoad %36 %NormalDetailMapSampler - %1044 = OpSampledImage %183 %1042 %1043 - %1046 = OpVectorTimesScalar %v2float %1024 %float_0 - %1047 = OpImageSampleImplicitLod %v4float %1044 %1046 - %1228 = OpVectorShuffle %v2float %1047 %1047 3 1 - %1229 = OpVectorTimesScalar %v2float %1228 %float_2 - %1231 = OpFSub %v2float %1229 %1212 - %1234 = OpFNegate %v2float %1231 - %1236 = OpDot %float %1234 %1231 - %1237 = OpFAdd %float %float_1 %1236 - %1238 = OpExtInst %float %1 FClamp %1237 %float_0 %float_1 - %1239 = OpExtInst %float %1 Sqrt %1238 - %1240 = OpCompositeExtract %float %1231 0 - %1241 = OpCompositeExtract %float %1231 1 - %1242 = OpCompositeConstruct %v3float %1240 %1241 %1239 - %1050 = OpVectorShuffle %v2float %1242 %1242 0 1 - %1051 = OpVectorTimesScalar %v2float %1050 %float_0 - %1053 = OpVectorShuffle %v2float %1224 %1224 0 1 - %1054 = OpFAdd %v2float %1053 %1051 - %1056 = OpVectorShuffle %v3float %1224 %1054 3 4 2 - %1059 = OpVectorShuffle %v2float %1056 %1056 0 1 - %1060 = OpVectorTimesScalar %v2float %1059 %990 - %1062 = OpVectorShuffle %v3float %1056 %1060 3 4 2 - %1430 = OpCompositeExtract %float %1062 0 - %1065 = OpFMul %float %1430 %float_0_3 - %1066 = OpFAdd %float %float_1 %1065 - %1069 = OpVectorShuffle %v3float %510 %510 0 1 2 - %1071 = OpVectorShuffle %v3float %1035 %1035 0 1 2 - %1072 = OpFMul %v3float %1069 %1071 - %1074 = OpVectorTimesScalar %v3float %1072 %1066 - %1075 = OpLoad %38 %StudsMapTexture - %1076 = OpLoad %36 %StudsMapSampler - %1077 = OpSampledImage %183 %1075 %1076 - %1434 = OpCompositeExtract %v2float %1414 2 - %1080 = OpImageSampleImplicitLod %v4float %1077 %1434 - %1436 = OpCompositeExtract %float %1080 0 - %1083 = OpFMul %float %1436 %float_2 - %1085 = OpVectorTimesScalar %v3float %1074 %1083 - %1086 = OpLoad %36 %SpecularMapSampler - %1087 = OpLoad %38 %SpecularMapTexture - OpBranch %1246 - %1246 = OpLabel - OpLoopMerge %1247 %1248 None - OpBranch %1249 - %1249 = OpLabel - %1251 = OpFOrdEqual %bool %float_0_75 %float_0 - OpSelectionMerge %1252 None - OpBranchConditional %1251 %1253 %1254 - %1253 = OpLabel - %1257 = OpSampledImage %183 %1087 %1086 - %1259 = OpImageSampleImplicitLod %v4float %1257 %1024 - OpBranch %1247 - %1254 = OpLabel - %1261 = OpFSub %float %float_1 %float_0_75 - %1262 = OpFDiv %float %float_1 %1261 - %1265 = OpSampledImage %183 %1087 %1086 - %1267 = OpVectorTimesScalar %v2float %1024 %float_0_25 - %1268 = OpImageSampleImplicitLod %v4float %1265 %1267 - %1271 = OpSampledImage %183 %1087 %1086 - %1273 = OpImageSampleImplicitLod %v4float %1271 %1024 - %1276 = OpFMul %float %990 %1262 - %1279 = OpFMul %float %float_0_75 %1262 - %1280 = OpFSub %float %1276 %1279 - %1287 = OpExtInst %float %1 FClamp %1280 %float_0 %float_1 - %1282 = OpCompositeConstruct %v4float %1287 %1287 %1287 %1287 - %1283 = OpExtInst %v4float %1 FMix %1268 %1273 %1282 - OpBranch %1247 - %1252 = OpLabel - %1284 = OpUndef %v4float - OpBranch %1247 - %1248 = OpLabel - OpBranchConditional %false %1246 %1247 - %1247 = OpLabel - %1530 = OpPhi %v4float %1259 %1253 %1283 %1254 %1284 %1252 %1512 %1248 - %1091 = OpVectorShuffle %v2float %1530 %1530 0 1 - %1093 = OpFMul %v2float %1091 %689 - %1094 = OpFAdd %v2float %1093 %692 - %1097 = OpCompositeConstruct %v2float %990 %990 - %1098 = OpExtInst %v2float %1 FMix %697 %1094 %1097 - %1438 = OpCompositeInsert %Surface %1085 %1531 0 - %1440 = OpCompositeInsert %Surface %1062 %1438 1 - %1442 = OpCompositeExtract %float %1098 0 - %1444 = OpCompositeInsert %Surface %1442 %1440 2 - %1446 = OpCompositeExtract %float %1098 1 - %1448 = OpCompositeInsert %Surface %1446 %1444 3 - %1450 = OpCompositeExtract %float %1091 1 - %1112 = OpFMul %float %1450 %990 - %1113 = OpFMul %float %1112 %float_0 - %1452 = OpCompositeInsert %Surface %1113 %1448 4 - %1456 = OpCompositeExtract %float %1396 3 3 - %764 = OpCompositeExtract %float %1085 0 - %765 = OpCompositeExtract %float %1085 1 - %766 = OpCompositeExtract %float %1085 2 - %767 = OpCompositeConstruct %v4float %764 %765 %766 %1456 - %770 = OpVectorShuffle %v3float %519 %519 0 1 2 - %773 = OpExtInst %v3float %1 Cross %770 %523 - %1462 = OpCompositeExtract %float %1452 1 0 - %778 = OpVectorTimesScalar %v3float %523 %1462 - %1466 = OpCompositeExtract %float %1452 1 1 - %782 = OpVectorTimesScalar %v3float %773 %1466 - %783 = OpFAdd %v3float %778 %782 - %1468 = OpCompositeExtract %float %1452 1 2 - %789 = OpVectorTimesScalar %v3float %770 %1468 - %790 = OpFAdd %v3float %783 %789 - %791 = OpExtInst %v3float %1 Normalize %790 - %793 = OpAccessChain %_ptr_Uniform_v3float %_ %int_0 %int_7 - %794 = OpLoad %v3float %793 - %795 = OpFNegate %v3float %794 - %796 = OpDot %float %791 %795 - %1290 = OpExtInst %float %1 FClamp %796 %float_0 %float_1 - %799 = OpAccessChain %_ptr_Uniform_v3float %_ %int_0 %int_6 - %800 = OpLoad %v3float %799 - %801 = OpVectorTimesScalar %v3float %800 %1290 - %803 = OpFNegate %float %796 - %804 = OpExtInst %float %1 FMax %803 %float_0 - %805 = OpAccessChain %_ptr_Uniform_v3float %_ %int_0 %int_8 - %806 = OpLoad %v3float %805 - %807 = OpVectorTimesScalar %v3float %806 %804 - %808 = OpFAdd %v3float %801 %807 - %810 = OpExtInst %float %1 Step %float_0 %796 - %813 = OpFMul %float %810 %1442 - %820 = OpVectorShuffle %v3float %513 %513 0 1 2 - %1296 = OpAccessChain %_ptr_Uniform_v4float %_ %int_0 %int_15 - %1297 = OpLoad %v4float %1296 - %1298 = OpVectorShuffle %v3float %1297 %1297 0 1 2 - %1300 = OpAccessChain %_ptr_Uniform_v4float %_ %int_0 %int_14 - %1301 = OpLoad %v4float %1300 - %1302 = OpVectorShuffle %v3float %1301 %1301 0 1 2 - %1303 = OpFSub %v3float %820 %1302 - %1304 = OpExtInst %v3float %1 FAbs %1303 - %1305 = OpExtInst %v3float %1 Step %1298 %1304 - %1307 = OpDot %float %1305 %128 - %1328 = OpExtInst %float %1 FClamp %1307 %float_0 %float_1 - %1309 = OpLoad %133 %LightMapTexture - %1310 = OpLoad %36 %LightMapSampler - %1311 = OpSampledImage %140 %1309 %1310 - %1313 = OpVectorShuffle %v3float %820 %820 1 2 0 - %1317 = OpVectorTimesScalar %v3float %1313 %1328 - %1318 = OpFSub %v3float %1313 %1317 - %1319 = OpImageSampleImplicitLod %v4float %1311 %1318 - %1321 = OpAccessChain %_ptr_Uniform_v4float %_ %int_0 %int_11 - %1322 = OpLoad %v4float %1321 - %1324 = OpCompositeConstruct %v4float %1328 %1328 %1328 %1328 - %1325 = OpExtInst %v4float %1 FMix %1319 %1322 %1324 - %822 = OpLoad %36 %ShadowMapSampler - %823 = OpLoad %38 %ShadowMapTexture - %826 = OpVectorShuffle %v3float %526 %526 0 1 2 - %1482 = OpCompositeExtract %float %1325 3 - %1337 = OpSampledImage %183 %823 %822 - %1339 = OpVectorShuffle %v2float %826 %826 0 1 - %1340 = OpImageSampleImplicitLod %v4float %1337 %1339 - %1341 = OpVectorShuffle %v2float %1340 %1340 0 1 - %1484 = OpCompositeExtract %float %826 2 - %1486 = OpCompositeExtract %float %1341 0 - %1363 = OpExtInst %float %1 Step %1486 %1484 - %1365 = OpFSub %float %1484 %float_0_5 - %1366 = OpExtInst %float %1 FAbs %1365 - %1367 = OpFMul %float %float_20 %1366 - %1368 = OpFSub %float %float_9 %1367 - %1369 = OpExtInst %float %1 FClamp %1368 %float_0 %float_1 - %1370 = OpFMul %float %1363 %1369 - %1488 = OpCompositeExtract %float %1341 1 - %1350 = OpFMul %float %1370 %1488 - %1351 = OpAccessChain %_ptr_Uniform_float %_ %int_0 %int_17 %uint_3 - %1352 = OpLoad %float %1351 - %1353 = OpFMul %float %1350 %1352 - %1354 = OpFSub %float %float_1 %1353 - %1356 = OpFMul %float %1354 %1482 - %830 = OpLoad %367 %EnvironmentMapTexture - %831 = OpLoad %36 %EnvironmentMapSampler - %832 = OpSampledImage %373 %830 %831 - %835 = OpVectorShuffle %v3float %516 %516 0 1 2 - %836 = OpFNegate %v3float %835 - %838 = OpExtInst %v3float %1 Reflect %836 %791 - %839 = OpImageSampleImplicitLod %v4float %832 %838 - %840 = OpVectorShuffle %v3float %839 %839 0 1 2 - %842 = OpVectorShuffle %v3float %767 %767 0 1 2 - %845 = OpCompositeConstruct %v3float %1113 %1113 %1113 - %846 = OpExtInst %v3float %1 FMix %842 %840 %845 - %848 = OpVectorShuffle %v4float %767 %846 4 5 6 3 - %849 = OpAccessChain %_ptr_Uniform_v3float %_ %int_0 %int_5 - %850 = OpLoad %v3float %849 - %853 = OpVectorTimesScalar %v3float %808 %1356 - %854 = OpFAdd %v3float %850 %853 - %856 = OpVectorShuffle %v3float %1325 %1325 0 1 2 - %857 = OpFAdd %v3float %854 %856 - %859 = OpVectorShuffle %v3float %848 %848 0 1 2 - %860 = OpFMul %v3float %857 %859 - %865 = OpFMul %float %813 %1356 - %873 = OpExtInst %v3float %1 Normalize %835 - %874 = OpFAdd %v3float %795 %873 - %875 = OpExtInst %v3float %1 Normalize %874 - %876 = OpDot %float %791 %875 - %877 = OpExtInst %float %1 FClamp %876 %float_0 %float_1 - %879 = OpExtInst %float %1 Pow %877 %1446 - %880 = OpFMul %float %865 %879 - %881 = OpVectorTimesScalar %v3float %800 %880 - %884 = OpFAdd %v3float %860 %881 - %886 = OpVectorShuffle %v4float %1512 %884 4 5 6 3 - %1494 = OpCompositeExtract %float %848 3 - %1496 = OpCompositeInsert %v4float %1494 %886 3 - %896 = OpAccessChain %_ptr_Uniform_float %_ %int_0 %int_17 %uint_0 - %897 = OpLoad %float %896 - %898 = OpFMul %float %978 %897 - %899 = OpAccessChain %_ptr_Uniform_float %_ %int_0 %int_17 %uint_1 - %900 = OpLoad %float %899 - %901 = OpFAdd %float %898 %900 - %1373 = OpExtInst %float %1 FClamp %901 %float_0 %float_1 - %905 = OpVectorShuffle %v2float %504 %504 3 2 - %908 = OpVectorShuffle %v2float %507 %507 3 2 - %909 = OpExtInst %v2float %1 FMin %905 %908 - %1504 = OpCompositeExtract %float %909 0 - %1506 = OpCompositeExtract %float %909 1 - %914 = OpExtInst %float %1 FMin %1504 %1506 - %916 = OpFDiv %float %914 %978 - %919 = OpFSub %float %float_1_5 %916 - %920 = OpFMul %float %1373 %919 - %922 = OpFAdd %float %920 %916 - %1376 = OpExtInst %float %1 FClamp %922 %float_0 %float_1 - %925 = OpVectorShuffle %v3float %1496 %1496 0 1 2 - %926 = OpVectorTimesScalar %v3float %925 %1376 - %928 = OpVectorShuffle %v4float %1496 %926 4 5 6 3 - %1508 = OpCompositeExtract %float %1396 4 3 - %931 = OpExtInst %float %1 FClamp %1508 %float_0 %float_1 - %932 = OpAccessChain %_ptr_Uniform_v3float %_ %int_0 %int_10 - %933 = OpLoad %v3float %932 - %935 = OpVectorShuffle %v3float %928 %928 0 1 2 - %937 = OpCompositeConstruct %v3float %931 %931 %931 - %938 = OpExtInst %v3float %1 FMix %933 %935 %937 - %940 = OpVectorShuffle %v4float %928 %938 4 5 6 3 - OpStore %_entryPointOutput %940 - OpReturn - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders-msl/asm/frag/op-constant-null.asm.frag b/deps/SPIRV-Cross/shaders-msl/asm/frag/op-constant-null.asm.frag deleted file mode 100644 index 61d2e579c8..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/asm/frag/op-constant-null.asm.frag +++ /dev/null @@ -1,85 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 1 -; Bound: 45 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %main "main" %FragColor - OpExecutionMode %main OriginUpperLeft - OpSource ESSL 310 - OpName %main "main" - OpName %a "a" - OpName %b "b" - OpName %c "c" - OpName %D "D" - OpMemberName %D 0 "a" - OpMemberName %D 1 "b" - OpName %d "d" - OpName %e "e" - OpName %FragColor "FragColor" - OpDecorate %a RelaxedPrecision - OpDecorate %b RelaxedPrecision - OpDecorate %c RelaxedPrecision - OpMemberDecorate %D 0 RelaxedPrecision - OpMemberDecorate %D 1 RelaxedPrecision - OpDecorate %e RelaxedPrecision - OpDecorate %FragColor RelaxedPrecision - OpDecorate %FragColor Location 0 - OpDecorate %44 RelaxedPrecision - OpDecorate %float_1 RelaxedPrecision - OpDecorate %14 RelaxedPrecision - OpDecorate %23 RelaxedPrecision - OpDecorate %41 RelaxedPrecision - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 -%_ptr_Function_float = OpTypePointer Function %float - %float_1 = OpConstantNull %float - %v4float = OpTypeVector %float 4 -%_ptr_Function_v4float = OpTypePointer Function %v4float - %float_2 = OpConstantNull %float - %14 = OpConstantNull %v4float - %v3float = OpTypeVector %float 3 -%mat2v3float = OpTypeMatrix %v3float 2 -%_ptr_Function_mat2v3float = OpTypePointer Function %mat2v3float - %float_4 = OpConstantNull %float - %20 = OpConstantNull %v3float - %float_5 = OpConstantNull %float - %22 = OpConstantNull %v3float - %23 = OpConstantNull %mat2v3float - %D = OpTypeStruct %v4float %float -%_ptr_Function_D = OpTypePointer Function %D - %27 = OpConstantNull %D - %uint = OpTypeInt 32 0 - %uint_4 = OpConstant %uint 4 -%_arr_v4float_uint_4 = OpTypeArray %v4float %uint_4 -%_ptr_Function__arr_v4float_uint_4 = OpTypePointer Function %_arr_v4float_uint_4 - %float_10 = OpConstantNull %float - %34 = OpConstantNull %v4float - %float_11 = OpConstantNull %float - %36 = OpConstantNull %v4float - %float_12 = OpConstantNull %float - %38 = OpConstantNull %v4float - %float_13 = OpConstantNull %float - %40 = OpConstantNull %v4float - %41 = OpConstantNull %_arr_v4float_uint_4 -%_ptr_Output_float = OpTypePointer Output %float - %FragColor = OpVariable %_ptr_Output_float Output - %main = OpFunction %void None %3 - %5 = OpLabel - %a = OpVariable %_ptr_Function_float Function - %b = OpVariable %_ptr_Function_v4float Function - %c = OpVariable %_ptr_Function_mat2v3float Function - %d = OpVariable %_ptr_Function_D Function - %e = OpVariable %_ptr_Function__arr_v4float_uint_4 Function - OpStore %a %float_1 - OpStore %b %14 - OpStore %c %23 - OpStore %d %27 - OpStore %e %41 - %44 = OpLoad %float %a - OpStore %FragColor %44 - OpReturn - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders-msl/asm/frag/phi-loop-variable.asm.frag b/deps/SPIRV-Cross/shaders-msl/asm/frag/phi-loop-variable.asm.frag deleted file mode 100644 index 74c46b4af8..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/asm/frag/phi-loop-variable.asm.frag +++ /dev/null @@ -1,71 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 1 -; Bound: 59 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %4 "main" - OpExecutionMode %4 OriginUpperLeft - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 - %v2float = OpTypeVector %float 2 -%mat2v2float = OpTypeMatrix %v2float 2 -%_ptr_Function_mat2v2float = OpTypePointer Function %mat2v2float - %v3float = OpTypeVector %float 3 - %11 = OpTypeFunction %v3float %_ptr_Function_mat2v2float -%_ptr_Function_v3float = OpTypePointer Function %v3float - %float_1 = OpConstant %float 1 - %18 = OpConstantComposite %v3float %float_1 %float_1 %float_1 - %int = OpTypeInt 32 1 -%_ptr_Function_int = OpTypePointer Function %int - %int_35 = OpConstant %int 35 - %int_0 = OpConstant %int 0 - %bool = OpTypeBool - %int_1 = OpConstant %int 1 - %4 = OpFunction %void None %3 - %5 = OpLabel - OpBranch %48 - %48 = OpLabel - %58 = OpPhi %int %int_35 %5 %56 %50 - OpLoopMerge %49 %50 None - OpBranch %51 - %51 = OpLabel - %53 = OpSGreaterThanEqual %bool %58 %int_0 - OpBranchConditional %53 %54 %49 - %54 = OpLabel - OpBranch %50 - %50 = OpLabel - %56 = OpISub %int %58 %int_1 - OpBranch %48 - %49 = OpLabel - OpReturn - OpFunctionEnd - %13 = OpFunction %v3float None %11 - %12 = OpFunctionParameter %_ptr_Function_mat2v2float - %14 = OpLabel - %16 = OpVariable %_ptr_Function_v3float Function - %21 = OpVariable %_ptr_Function_int Function - OpStore %16 %18 - OpStore %21 %int_35 - OpBranch %23 - %23 = OpLabel - OpLoopMerge %25 %26 None - OpBranch %27 - %27 = OpLabel - %28 = OpLoad %int %21 - %31 = OpSGreaterThanEqual %bool %28 %int_0 - OpBranchConditional %31 %24 %25 - %24 = OpLabel - OpBranch %26 - %26 = OpLabel - %32 = OpLoad %int %21 - %34 = OpISub %int %32 %int_1 - OpStore %21 %34 - OpBranch %23 - %25 = OpLabel - %35 = OpLoad %v3float %16 - OpReturnValue %35 - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders-msl/asm/frag/undef-variable-store.asm.frag b/deps/SPIRV-Cross/shaders-msl/asm/frag/undef-variable-store.asm.frag deleted file mode 100644 index 966c2d9d5a..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/asm/frag/undef-variable-store.asm.frag +++ /dev/null @@ -1,85 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 1 -; Bound: 50 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %fragmentProgram "main" %_entryPointOutput - OpExecutionMode %fragmentProgram OriginUpperLeft - OpSource HLSL 500 - OpName %fragmentProgram "fragmentProgram" - OpName %_fragmentProgram_ "@fragmentProgram(" - OpName %uv "uv" - OpName %_entryPointOutput "@entryPointOutput" - OpDecorate %_entryPointOutput Location 0 - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 - %v4float = OpTypeVector %float 4 - %8 = OpTypeFunction %v4float - %v2float = OpTypeVector %float 2 -%_ptr_Function_v2float = OpTypePointer Function %v2float - %float_0 = OpConstant %float 0 - %15 = OpConstantComposite %v2float %float_0 %float_0 - %uint = OpTypeInt 32 0 - %uint_0 = OpConstant %uint 0 -%_ptr_Function_float = OpTypePointer Function %float - %bool = OpTypeBool - %float_1 = OpConstant %float 1 - %26 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1 - %29 = OpConstantComposite %v4float %float_1 %float_1 %float_0 %float_1 -%_ptr_Output_v4float = OpTypePointer Output %v4float -%_entryPointOutput = OpVariable %_ptr_Output_v4float Output -%_ptr_Function_v4float = OpTypePointer Function %v4float - %false = OpConstantFalse %bool -%fragmentProgram = OpFunction %void None %3 - %5 = OpLabel - %35 = OpVariable %_ptr_Function_v2float Function - %37 = OpVariable %_ptr_Function_v4float Function - OpBranch %38 - %38 = OpLabel - OpLoopMerge %39 %40 None - OpBranch %41 - %41 = OpLabel - OpStore %35 %15 - %42 = OpAccessChain %_ptr_Function_float %35 %uint_0 - %43 = OpLoad %float %42 - %44 = OpFOrdNotEqual %bool %43 %float_0 - OpSelectionMerge %45 None - OpBranchConditional %44 %46 %47 - %46 = OpLabel - OpStore %37 %26 - OpBranch %39 - %47 = OpLabel - OpStore %37 %29 - OpBranch %39 - %45 = OpLabel - %48 = OpUndef %v4float - OpStore %37 %48 - OpBranch %39 - %40 = OpLabel - OpBranchConditional %false %38 %39 - %39 = OpLabel - %34 = OpLoad %v4float %37 - OpStore %_entryPointOutput %34 - OpReturn - OpFunctionEnd -%_fragmentProgram_ = OpFunction %v4float None %8 - %10 = OpLabel - %uv = OpVariable %_ptr_Function_v2float Function - OpStore %uv %15 - %19 = OpAccessChain %_ptr_Function_float %uv %uint_0 - %20 = OpLoad %float %19 - %22 = OpFOrdNotEqual %bool %20 %float_0 - OpSelectionMerge %24 None - OpBranchConditional %22 %23 %28 - %23 = OpLabel - OpReturnValue %26 - %28 = OpLabel - OpReturnValue %29 - %24 = OpLabel - %31 = OpUndef %v4float - OpReturnValue %31 - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders-msl/asm/frag/unreachable.asm.frag b/deps/SPIRV-Cross/shaders-msl/asm/frag/unreachable.asm.frag deleted file mode 100644 index e2ce2eb56a..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/asm/frag/unreachable.asm.frag +++ /dev/null @@ -1,61 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 3 -; Bound: 47 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %main "main" %counter %FragColor - OpExecutionMode %main OriginUpperLeft - OpSource GLSL 450 - OpName %main "main" - OpName %counter "counter" - OpName %FragColor "FragColor" - OpDecorate %counter Flat - OpDecorate %counter Location 0 - OpDecorate %FragColor Location 0 - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 - %v4float = OpTypeVector %float 4 - %8 = OpTypeFunction %v4float - %int = OpTypeInt 32 1 -%_ptr_Input_int = OpTypePointer Input %int - %counter = OpVariable %_ptr_Input_int Input - %int_10 = OpConstant %int 10 - %bool = OpTypeBool - %float_10 = OpConstant %float 10 - %21 = OpConstantComposite %v4float %float_10 %float_10 %float_10 %float_10 - %float_30 = OpConstant %float 30 - %25 = OpConstantComposite %v4float %float_30 %float_30 %float_30 %float_30 -%_ptr_Output_v4float = OpTypePointer Output %v4float - %FragColor = OpVariable %_ptr_Output_v4float Output -%_ptr_Function_v4float = OpTypePointer Function %v4float - %false = OpConstantFalse %bool - %44 = OpUndef %v4float - %main = OpFunction %void None %3 - %5 = OpLabel - OpBranch %33 - %33 = OpLabel - %45 = OpPhi %v4float %44 %5 %44 %35 - OpLoopMerge %34 %35 None - OpBranch %36 - %36 = OpLabel - %37 = OpLoad %int %counter - %38 = OpIEqual %bool %37 %int_10 - OpSelectionMerge %39 None - OpBranchConditional %38 %40 %41 - %40 = OpLabel - OpBranch %34 - %41 = OpLabel - OpBranch %34 - %39 = OpLabel - OpUnreachable - %35 = OpLabel - OpBranchConditional %false %33 %34 - %34 = OpLabel - %46 = OpPhi %v4float %21 %40 %25 %41 %44 %35 - OpStore %FragColor %46 - OpReturn - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag b/deps/SPIRV-Cross/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag deleted file mode 100644 index d60c6f52d4..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag +++ /dev/null @@ -1,886 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 2 -; Bound: 25007 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %5663 "main" %5800 %gl_FragCoord %4317 - OpExecutionMode %5663 OriginUpperLeft - OpMemberDecorate %_struct_1116 0 Offset 0 - OpMemberDecorate %_struct_1116 1 Offset 16 - OpMemberDecorate %_struct_1116 2 Offset 32 - OpDecorate %_struct_1116 Block - OpDecorate %22044 DescriptorSet 0 - OpDecorate %22044 Binding 0 - OpDecorate %5785 DescriptorSet 0 - OpDecorate %5785 Binding 140 - OpDecorate %5688 DescriptorSet 0 - OpDecorate %5688 Binding 60 - OpMemberDecorate %_struct_994 0 Offset 0 - OpMemberDecorate %_struct_994 1 Offset 16 - OpMemberDecorate %_struct_994 2 Offset 28 - OpMemberDecorate %_struct_994 3 Offset 32 - OpMemberDecorate %_struct_994 4 Offset 44 - OpMemberDecorate %_struct_994 5 Offset 48 - OpMemberDecorate %_struct_994 6 Offset 60 - OpMemberDecorate %_struct_994 7 Offset 64 - OpMemberDecorate %_struct_994 8 Offset 76 - OpMemberDecorate %_struct_994 9 Offset 80 - OpMemberDecorate %_struct_994 10 Offset 92 - OpMemberDecorate %_struct_994 11 Offset 96 - OpMemberDecorate %_struct_994 12 Offset 108 - OpMemberDecorate %_struct_994 13 Offset 112 - OpMemberDecorate %_struct_994 14 Offset 120 - OpMemberDecorate %_struct_994 15 Offset 128 - OpMemberDecorate %_struct_994 16 Offset 140 - OpMemberDecorate %_struct_994 17 Offset 144 - OpMemberDecorate %_struct_994 18 Offset 148 - OpMemberDecorate %_struct_994 19 Offset 152 - OpMemberDecorate %_struct_994 20 Offset 156 - OpMemberDecorate %_struct_994 21 Offset 160 - OpMemberDecorate %_struct_994 22 Offset 176 - OpMemberDecorate %_struct_994 23 RowMajor - OpMemberDecorate %_struct_994 23 Offset 192 - OpMemberDecorate %_struct_994 23 MatrixStride 16 - OpMemberDecorate %_struct_994 24 Offset 256 - OpDecorate %_struct_994 Block - OpDecorate %12348 DescriptorSet 0 - OpDecorate %12348 Binding 2 - OpDecorate %3312 DescriptorSet 0 - OpDecorate %3312 Binding 142 - OpDecorate %4646 DescriptorSet 0 - OpDecorate %4646 Binding 62 - OpDecorate %4862 DescriptorSet 0 - OpDecorate %4862 Binding 141 - OpDecorate %3594 DescriptorSet 0 - OpDecorate %3594 Binding 61 - OpDecorate %_arr_mat4v4float_uint_2 ArrayStride 64 - OpDecorate %_arr_v4float_uint_2 ArrayStride 16 - OpMemberDecorate %_struct_408 0 RowMajor - OpMemberDecorate %_struct_408 0 Offset 0 - OpMemberDecorate %_struct_408 0 MatrixStride 16 - OpMemberDecorate %_struct_408 1 RowMajor - OpMemberDecorate %_struct_408 1 Offset 64 - OpMemberDecorate %_struct_408 1 MatrixStride 16 - OpMemberDecorate %_struct_408 2 RowMajor - OpMemberDecorate %_struct_408 2 Offset 128 - OpMemberDecorate %_struct_408 2 MatrixStride 16 - OpMemberDecorate %_struct_408 3 RowMajor - OpMemberDecorate %_struct_408 3 Offset 192 - OpMemberDecorate %_struct_408 3 MatrixStride 16 - OpMemberDecorate %_struct_408 4 Offset 256 - OpMemberDecorate %_struct_408 5 Offset 272 - OpMemberDecorate %_struct_408 6 Offset 288 - OpMemberDecorate %_struct_408 7 Offset 292 - OpMemberDecorate %_struct_408 8 Offset 296 - OpMemberDecorate %_struct_408 9 Offset 300 - OpMemberDecorate %_struct_408 10 Offset 304 - OpMemberDecorate %_struct_408 11 Offset 316 - OpMemberDecorate %_struct_408 12 Offset 320 - OpMemberDecorate %_struct_408 13 Offset 332 - OpMemberDecorate %_struct_408 14 Offset 336 - OpMemberDecorate %_struct_408 15 Offset 348 - OpMemberDecorate %_struct_408 16 Offset 352 - OpMemberDecorate %_struct_408 17 Offset 364 - OpMemberDecorate %_struct_408 18 Offset 368 - OpMemberDecorate %_struct_408 19 Offset 372 - OpMemberDecorate %_struct_408 20 Offset 376 - OpMemberDecorate %_struct_408 21 Offset 384 - OpMemberDecorate %_struct_408 22 Offset 392 - OpMemberDecorate %_struct_408 23 Offset 400 - OpMemberDecorate %_struct_408 24 Offset 416 - OpMemberDecorate %_struct_408 25 Offset 424 - OpMemberDecorate %_struct_408 26 Offset 432 - OpMemberDecorate %_struct_408 27 Offset 448 - OpMemberDecorate %_struct_408 28 Offset 460 - OpMemberDecorate %_struct_408 29 Offset 464 - OpMemberDecorate %_struct_408 30 Offset 468 - OpMemberDecorate %_struct_408 31 Offset 472 - OpMemberDecorate %_struct_408 32 Offset 476 - OpMemberDecorate %_struct_408 33 Offset 480 - OpMemberDecorate %_struct_408 34 Offset 488 - OpMemberDecorate %_struct_408 35 Offset 492 - OpMemberDecorate %_struct_408 36 Offset 496 - OpMemberDecorate %_struct_408 37 RowMajor - OpMemberDecorate %_struct_408 37 Offset 512 - OpMemberDecorate %_struct_408 37 MatrixStride 16 - OpMemberDecorate %_struct_408 38 Offset 640 - OpDecorate %_struct_408 Block - OpDecorate %15259 DescriptorSet 0 - OpDecorate %15259 Binding 1 - OpDecorate %5800 Location 0 - OpDecorate %gl_FragCoord BuiltIn FragCoord - OpDecorate %4317 Location 0 - OpMemberDecorate %_struct_1395 0 Offset 0 - OpMemberDecorate %_struct_1395 1 Offset 16 - OpMemberDecorate %_struct_1395 2 Offset 32 - OpMemberDecorate %_struct_1395 3 Offset 40 - OpMemberDecorate %_struct_1395 4 Offset 48 - OpMemberDecorate %_struct_1395 5 Offset 60 - OpMemberDecorate %_struct_1395 6 Offset 64 - OpMemberDecorate %_struct_1395 7 Offset 76 - OpMemberDecorate %_struct_1395 8 Offset 80 - OpMemberDecorate %_struct_1395 9 Offset 96 - OpMemberDecorate %_struct_1395 10 Offset 112 - OpMemberDecorate %_struct_1395 11 Offset 128 - OpMemberDecorate %_struct_1395 12 Offset 140 - OpMemberDecorate %_struct_1395 13 Offset 144 - OpMemberDecorate %_struct_1395 14 Offset 156 - OpMemberDecorate %_struct_1395 15 Offset 160 - OpMemberDecorate %_struct_1395 16 Offset 176 - OpMemberDecorate %_struct_1395 17 Offset 192 - OpMemberDecorate %_struct_1395 18 Offset 204 - OpMemberDecorate %_struct_1395 19 Offset 208 - OpMemberDecorate %_struct_1395 20 Offset 224 - OpDecorate %_struct_1395 Block - OpMemberDecorate %_struct_1018 0 Offset 0 - OpDecorate %_struct_1018 Block - %void = OpTypeVoid - %1282 = OpTypeFunction %void - %float = OpTypeFloat 32 - %v2float = OpTypeVector %float 2 - %v4float = OpTypeVector %float 4 - %v3float = OpTypeVector %float 3 -%_struct_1017 = OpTypeStruct %v4float -%_struct_1116 = OpTypeStruct %v4float %float %v4float -%_ptr_Uniform__struct_1116 = OpTypePointer Uniform %_struct_1116 - %22044 = OpVariable %_ptr_Uniform__struct_1116 Uniform - %int = OpTypeInt 32 1 - %int_0 = OpConstant %int 0 -%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float - %150 = OpTypeImage %float 2D 0 0 0 1 Unknown -%_ptr_UniformConstant_150 = OpTypePointer UniformConstant %150 - %5785 = OpVariable %_ptr_UniformConstant_150 UniformConstant - %508 = OpTypeSampler -%_ptr_UniformConstant_508 = OpTypePointer UniformConstant %508 - %5688 = OpVariable %_ptr_UniformConstant_508 UniformConstant - %510 = OpTypeSampledImage %150 - %float_0 = OpConstant %float 0 - %uint = OpTypeInt 32 0 - %int_1 = OpConstant %int 1 -%_ptr_Uniform_float = OpTypePointer Uniform %float - %float_1 = OpConstant %float 1 -%mat4v4float = OpTypeMatrix %v4float 4 -%_struct_994 = OpTypeStruct %v3float %v3float %float %v3float %float %v3float %float %v3float %float %v3float %float %v3float %float %v2float %v2float %v3float %float %float %float %float %float %v4float %v4float %mat4v4float %v4float -%_ptr_Uniform__struct_994 = OpTypePointer Uniform %_struct_994 - %12348 = OpVariable %_ptr_Uniform__struct_994 Uniform - %int_5 = OpConstant %int 5 -%_ptr_Uniform_v3float = OpTypePointer Uniform %v3float - %3312 = OpVariable %_ptr_UniformConstant_150 UniformConstant - %4646 = OpVariable %_ptr_UniformConstant_508 UniformConstant - %bool = OpTypeBool - %4862 = OpVariable %_ptr_UniformConstant_150 UniformConstant - %3594 = OpVariable %_ptr_UniformConstant_508 UniformConstant - %uint_2 = OpConstant %uint 2 - %2938 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0 -%_arr_mat4v4float_uint_2 = OpTypeArray %mat4v4float %uint_2 -%_arr_v4float_uint_2 = OpTypeArray %v4float %uint_2 -%_struct_408 = OpTypeStruct %mat4v4float %mat4v4float %mat4v4float %mat4v4float %v4float %v4float %float %float %float %float %v3float %float %v3float %float %v3float %float %v3float %float %float %float %v2float %v2float %v2float %v4float %v2float %v2float %v2float %v3float %float %float %float %float %float %v2float %float %float %v3float %_arr_mat4v4float_uint_2 %_arr_v4float_uint_2 -%_ptr_Uniform__struct_408 = OpTypePointer Uniform %_struct_408 - %15259 = OpVariable %_ptr_Uniform__struct_408 Uniform - %int_23 = OpConstant %int 23 - %int_2 = OpConstant %int 2 - %float_n2 = OpConstant %float -2 - %float_0_5 = OpConstant %float 0.5 - %1196 = OpConstantComposite %v3float %float_0 %float_n2 %float_0_5 - %float_n1 = OpConstant %float -1 - %836 = OpConstantComposite %v3float %float_n1 %float_n1 %float_0_5 - %float_0_75 = OpConstant %float 0.75 - %1367 = OpConstantComposite %v3float %float_0 %float_n1 %float_0_75 - %141 = OpConstantComposite %v3float %float_1 %float_n1 %float_0_5 - %38 = OpConstantComposite %v3float %float_n2 %float_0 %float_0_5 - %95 = OpConstantComposite %v3float %float_n1 %float_0 %float_0_75 - %626 = OpConstantComposite %v3float %float_0 %float_0 %float_1 - %2411 = OpConstantComposite %v3float %float_1 %float_0 %float_0_75 - %float_2 = OpConstant %float 2 - %2354 = OpConstantComposite %v3float %float_2 %float_0 %float_0_5 - %837 = OpConstantComposite %v3float %float_n1 %float_1 %float_0_5 - %1368 = OpConstantComposite %v3float %float_0 %float_1 %float_0_75 - %142 = OpConstantComposite %v3float %float_1 %float_1 %float_0_5 - %1197 = OpConstantComposite %v3float %float_0 %float_2 %float_0_5 -%_ptr_Input_v2float = OpTypePointer Input %v2float - %5800 = OpVariable %_ptr_Input_v2float Input -%_ptr_Input_v4float = OpTypePointer Input %v4float -%gl_FragCoord = OpVariable %_ptr_Input_v4float Input -%_ptr_Output_v4float = OpTypePointer Output %v4float - %4317 = OpVariable %_ptr_Output_v4float Output -%_struct_1395 = OpTypeStruct %v4float %v4float %v2float %v2float %v3float %float %v3float %float %v4float %v4float %v4float %v3float %float %v3float %float %v3float %v4float %v3float %float %v3float %v2float -%_struct_1018 = OpTypeStruct %v4float - %10264 = OpUndef %_struct_1017 - %5663 = OpFunction %void None %1282 - %25006 = OpLabel - %17463 = OpLoad %v4float %gl_FragCoord - %13863 = OpCompositeInsert %_struct_1017 %2938 %10264 0 - %22969 = OpVectorShuffle %v2float %17463 %17463 0 1 - %13206 = OpAccessChain %_ptr_Uniform_v4float %15259 %int_23 - %10343 = OpLoad %v4float %13206 - %7422 = OpVectorShuffle %v2float %10343 %10343 0 1 - %19927 = OpFMul %v2float %22969 %7422 - %18174 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_2 - %16206 = OpLoad %v4float %18174 - %20420 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 - %21354 = OpLoad %v4float %20420 - %7688 = OpVectorShuffle %v4float %21354 %21354 0 1 0 1 - %17581 = OpFMul %v4float %16206 %7688 - %10673 = OpVectorShuffle %v2float %1196 %1196 0 1 - %18824 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 - %10344 = OpLoad %v4float %18824 - %8638 = OpVectorShuffle %v2float %10344 %10344 0 1 - %9197 = OpFMul %v2float %10673 %8638 - %18505 = OpFAdd %v2float %19927 %9197 - %7011 = OpVectorShuffle %v2float %17581 %17581 0 1 - %21058 = OpVectorShuffle %v2float %17581 %17581 2 3 - %13149 = OpExtInst %v2float %1 FClamp %18505 %7011 %21058 - %23584 = OpLoad %150 %5785 - %10339 = OpLoad %508 %5688 - %12147 = OpSampledImage %510 %23584 %10339 - %15371 = OpImageSampleExplicitLod %v4float %12147 %13149 Lod %float_0 - %15266 = OpCompositeExtract %float %15371 3 - %12116 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 - %12972 = OpLoad %float %12116 - %15710 = OpFMul %float %15266 %12972 - %15279 = OpExtInst %float %1 FClamp %15710 %float_0 %float_1 - %22213 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 - %11756 = OpLoad %v3float %22213 - %12103 = OpVectorTimesScalar %v3float %11756 %15279 - %15516 = OpLoad %150 %3312 - %24569 = OpLoad %508 %4646 - %12148 = OpSampledImage %510 %15516 %24569 - %17670 = OpImageSampleExplicitLod %v4float %12148 %13149 Lod %float_0 - %16938 = OpCompositeExtract %float %17670 1 - %14185 = OpFOrdGreaterThan %bool %16938 %float_0 - OpSelectionMerge %22307 DontFlatten - OpBranchConditional %14185 %12821 %22307 - %12821 = OpLabel - %13239 = OpLoad %150 %4862 - %19960 = OpLoad %508 %3594 - %12149 = OpSampledImage %510 %13239 %19960 - %15675 = OpImageSampleExplicitLod %v4float %12149 %13149 Lod %float_0 - %13866 = OpCompositeExtract %float %17670 1 - %12427 = OpCompositeExtract %float %17670 2 - %23300 = OpFMul %float %13866 %12427 - %17612 = OpExtInst %float %1 FClamp %23300 %float_0 %float_1 - %20291 = OpVectorShuffle %v3float %15675 %15675 0 1 2 - %11186 = OpVectorTimesScalar %v3float %20291 %17612 - %15293 = OpFAdd %v3float %12103 %11186 - OpBranch %22307 - %22307 = OpLabel - %7719 = OpPhi %v3float %12103 %25006 %15293 %12821 - %23399 = OpVectorTimesScalar %v3float %7719 %float_0_5 - %9339 = OpFAdd %float %float_0 %float_0_5 - %16235 = OpVectorShuffle %v3float %2938 %2938 0 1 2 - %22177 = OpFAdd %v3float %16235 %23399 - %15527 = OpVectorShuffle %v4float %2938 %22177 4 5 6 3 - %6434 = OpCompositeInsert %_struct_1017 %15527 %13863 0 - %24572 = OpVectorShuffle %v2float %836 %836 0 1 - %13207 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 - %10345 = OpLoad %v4float %13207 - %8639 = OpVectorShuffle %v2float %10345 %10345 0 1 - %9198 = OpFMul %v2float %24572 %8639 - %18506 = OpFAdd %v2float %19927 %9198 - %7012 = OpVectorShuffle %v2float %17581 %17581 0 1 - %21059 = OpVectorShuffle %v2float %17581 %17581 2 3 - %13150 = OpExtInst %v2float %1 FClamp %18506 %7012 %21059 - %23585 = OpLoad %150 %5785 - %10340 = OpLoad %508 %5688 - %12150 = OpSampledImage %510 %23585 %10340 - %15372 = OpImageSampleExplicitLod %v4float %12150 %13150 Lod %float_0 - %15267 = OpCompositeExtract %float %15372 3 - %12117 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 - %12973 = OpLoad %float %12117 - %15711 = OpFMul %float %15267 %12973 - %15280 = OpExtInst %float %1 FClamp %15711 %float_0 %float_1 - %22214 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 - %11757 = OpLoad %v3float %22214 - %12104 = OpVectorTimesScalar %v3float %11757 %15280 - %15517 = OpLoad %150 %3312 - %24570 = OpLoad %508 %4646 - %12151 = OpSampledImage %510 %15517 %24570 - %17671 = OpImageSampleExplicitLod %v4float %12151 %13150 Lod %float_0 - %16939 = OpCompositeExtract %float %17671 1 - %14186 = OpFOrdGreaterThan %bool %16939 %float_0 - OpSelectionMerge %22308 DontFlatten - OpBranchConditional %14186 %12822 %22308 - %12822 = OpLabel - %13240 = OpLoad %150 %4862 - %19961 = OpLoad %508 %3594 - %12152 = OpSampledImage %510 %13240 %19961 - %15676 = OpImageSampleExplicitLod %v4float %12152 %13150 Lod %float_0 - %13867 = OpCompositeExtract %float %17671 1 - %12428 = OpCompositeExtract %float %17671 2 - %23301 = OpFMul %float %13867 %12428 - %17613 = OpExtInst %float %1 FClamp %23301 %float_0 %float_1 - %20292 = OpVectorShuffle %v3float %15676 %15676 0 1 2 - %11187 = OpVectorTimesScalar %v3float %20292 %17613 - %15294 = OpFAdd %v3float %12104 %11187 - OpBranch %22308 - %22308 = OpLabel - %7720 = OpPhi %v3float %12104 %22307 %15294 %12822 - %23400 = OpVectorTimesScalar %v3float %7720 %float_0_5 - %9340 = OpFAdd %float %9339 %float_0_5 - %16236 = OpVectorShuffle %v3float %15527 %15527 0 1 2 - %22178 = OpFAdd %v3float %16236 %23400 - %15528 = OpVectorShuffle %v4float %15527 %22178 4 5 6 3 - %6435 = OpCompositeInsert %_struct_1017 %15528 %6434 0 - %24573 = OpVectorShuffle %v2float %1367 %1367 0 1 - %13208 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 - %10346 = OpLoad %v4float %13208 - %8640 = OpVectorShuffle %v2float %10346 %10346 0 1 - %9199 = OpFMul %v2float %24573 %8640 - %18507 = OpFAdd %v2float %19927 %9199 - %7013 = OpVectorShuffle %v2float %17581 %17581 0 1 - %21060 = OpVectorShuffle %v2float %17581 %17581 2 3 - %13151 = OpExtInst %v2float %1 FClamp %18507 %7013 %21060 - %23586 = OpLoad %150 %5785 - %10341 = OpLoad %508 %5688 - %12153 = OpSampledImage %510 %23586 %10341 - %15373 = OpImageSampleExplicitLod %v4float %12153 %13151 Lod %float_0 - %15268 = OpCompositeExtract %float %15373 3 - %12118 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 - %12974 = OpLoad %float %12118 - %15712 = OpFMul %float %15268 %12974 - %15281 = OpExtInst %float %1 FClamp %15712 %float_0 %float_1 - %22215 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 - %11758 = OpLoad %v3float %22215 - %12105 = OpVectorTimesScalar %v3float %11758 %15281 - %15518 = OpLoad %150 %3312 - %24571 = OpLoad %508 %4646 - %12154 = OpSampledImage %510 %15518 %24571 - %17672 = OpImageSampleExplicitLod %v4float %12154 %13151 Lod %float_0 - %16940 = OpCompositeExtract %float %17672 1 - %14187 = OpFOrdGreaterThan %bool %16940 %float_0 - OpSelectionMerge %22309 DontFlatten - OpBranchConditional %14187 %12823 %22309 - %12823 = OpLabel - %13241 = OpLoad %150 %4862 - %19962 = OpLoad %508 %3594 - %12155 = OpSampledImage %510 %13241 %19962 - %15677 = OpImageSampleExplicitLod %v4float %12155 %13151 Lod %float_0 - %13868 = OpCompositeExtract %float %17672 1 - %12429 = OpCompositeExtract %float %17672 2 - %23302 = OpFMul %float %13868 %12429 - %17614 = OpExtInst %float %1 FClamp %23302 %float_0 %float_1 - %20293 = OpVectorShuffle %v3float %15677 %15677 0 1 2 - %11188 = OpVectorTimesScalar %v3float %20293 %17614 - %15295 = OpFAdd %v3float %12105 %11188 - OpBranch %22309 - %22309 = OpLabel - %7721 = OpPhi %v3float %12105 %22308 %15295 %12823 - %23401 = OpVectorTimesScalar %v3float %7721 %float_0_75 - %9341 = OpFAdd %float %9340 %float_0_75 - %16237 = OpVectorShuffle %v3float %15528 %15528 0 1 2 - %22179 = OpFAdd %v3float %16237 %23401 - %15529 = OpVectorShuffle %v4float %15528 %22179 4 5 6 3 - %6436 = OpCompositeInsert %_struct_1017 %15529 %6435 0 - %24574 = OpVectorShuffle %v2float %141 %141 0 1 - %13209 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 - %10347 = OpLoad %v4float %13209 - %8641 = OpVectorShuffle %v2float %10347 %10347 0 1 - %9200 = OpFMul %v2float %24574 %8641 - %18508 = OpFAdd %v2float %19927 %9200 - %7014 = OpVectorShuffle %v2float %17581 %17581 0 1 - %21061 = OpVectorShuffle %v2float %17581 %17581 2 3 - %13152 = OpExtInst %v2float %1 FClamp %18508 %7014 %21061 - %23587 = OpLoad %150 %5785 - %10342 = OpLoad %508 %5688 - %12156 = OpSampledImage %510 %23587 %10342 - %15374 = OpImageSampleExplicitLod %v4float %12156 %13152 Lod %float_0 - %15269 = OpCompositeExtract %float %15374 3 - %12119 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 - %12975 = OpLoad %float %12119 - %15713 = OpFMul %float %15269 %12975 - %15282 = OpExtInst %float %1 FClamp %15713 %float_0 %float_1 - %22216 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 - %11759 = OpLoad %v3float %22216 - %12106 = OpVectorTimesScalar %v3float %11759 %15282 - %15519 = OpLoad %150 %3312 - %24575 = OpLoad %508 %4646 - %12157 = OpSampledImage %510 %15519 %24575 - %17673 = OpImageSampleExplicitLod %v4float %12157 %13152 Lod %float_0 - %16941 = OpCompositeExtract %float %17673 1 - %14188 = OpFOrdGreaterThan %bool %16941 %float_0 - OpSelectionMerge %22310 DontFlatten - OpBranchConditional %14188 %12824 %22310 - %12824 = OpLabel - %13242 = OpLoad %150 %4862 - %19963 = OpLoad %508 %3594 - %12158 = OpSampledImage %510 %13242 %19963 - %15678 = OpImageSampleExplicitLod %v4float %12158 %13152 Lod %float_0 - %13869 = OpCompositeExtract %float %17673 1 - %12430 = OpCompositeExtract %float %17673 2 - %23303 = OpFMul %float %13869 %12430 - %17615 = OpExtInst %float %1 FClamp %23303 %float_0 %float_1 - %20294 = OpVectorShuffle %v3float %15678 %15678 0 1 2 - %11189 = OpVectorTimesScalar %v3float %20294 %17615 - %15296 = OpFAdd %v3float %12106 %11189 - OpBranch %22310 - %22310 = OpLabel - %7722 = OpPhi %v3float %12106 %22309 %15296 %12824 - %23402 = OpVectorTimesScalar %v3float %7722 %float_0_5 - %9342 = OpFAdd %float %9341 %float_0_5 - %16238 = OpVectorShuffle %v3float %15529 %15529 0 1 2 - %22180 = OpFAdd %v3float %16238 %23402 - %15530 = OpVectorShuffle %v4float %15529 %22180 4 5 6 3 - %6437 = OpCompositeInsert %_struct_1017 %15530 %6436 0 - %24576 = OpVectorShuffle %v2float %38 %38 0 1 - %13210 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 - %10348 = OpLoad %v4float %13210 - %8642 = OpVectorShuffle %v2float %10348 %10348 0 1 - %9201 = OpFMul %v2float %24576 %8642 - %18509 = OpFAdd %v2float %19927 %9201 - %7015 = OpVectorShuffle %v2float %17581 %17581 0 1 - %21062 = OpVectorShuffle %v2float %17581 %17581 2 3 - %13153 = OpExtInst %v2float %1 FClamp %18509 %7015 %21062 - %23588 = OpLoad %150 %5785 - %10349 = OpLoad %508 %5688 - %12159 = OpSampledImage %510 %23588 %10349 - %15375 = OpImageSampleExplicitLod %v4float %12159 %13153 Lod %float_0 - %15270 = OpCompositeExtract %float %15375 3 - %12120 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 - %12976 = OpLoad %float %12120 - %15714 = OpFMul %float %15270 %12976 - %15283 = OpExtInst %float %1 FClamp %15714 %float_0 %float_1 - %22217 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 - %11760 = OpLoad %v3float %22217 - %12107 = OpVectorTimesScalar %v3float %11760 %15283 - %15520 = OpLoad %150 %3312 - %24577 = OpLoad %508 %4646 - %12160 = OpSampledImage %510 %15520 %24577 - %17674 = OpImageSampleExplicitLod %v4float %12160 %13153 Lod %float_0 - %16942 = OpCompositeExtract %float %17674 1 - %14189 = OpFOrdGreaterThan %bool %16942 %float_0 - OpSelectionMerge %22311 DontFlatten - OpBranchConditional %14189 %12825 %22311 - %12825 = OpLabel - %13243 = OpLoad %150 %4862 - %19964 = OpLoad %508 %3594 - %12161 = OpSampledImage %510 %13243 %19964 - %15679 = OpImageSampleExplicitLod %v4float %12161 %13153 Lod %float_0 - %13870 = OpCompositeExtract %float %17674 1 - %12431 = OpCompositeExtract %float %17674 2 - %23304 = OpFMul %float %13870 %12431 - %17616 = OpExtInst %float %1 FClamp %23304 %float_0 %float_1 - %20295 = OpVectorShuffle %v3float %15679 %15679 0 1 2 - %11190 = OpVectorTimesScalar %v3float %20295 %17616 - %15297 = OpFAdd %v3float %12107 %11190 - OpBranch %22311 - %22311 = OpLabel - %7723 = OpPhi %v3float %12107 %22310 %15297 %12825 - %23403 = OpVectorTimesScalar %v3float %7723 %float_0_5 - %9343 = OpFAdd %float %9342 %float_0_5 - %16239 = OpVectorShuffle %v3float %15530 %15530 0 1 2 - %22181 = OpFAdd %v3float %16239 %23403 - %15531 = OpVectorShuffle %v4float %15530 %22181 4 5 6 3 - %6438 = OpCompositeInsert %_struct_1017 %15531 %6437 0 - %24578 = OpVectorShuffle %v2float %95 %95 0 1 - %13211 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 - %10350 = OpLoad %v4float %13211 - %8643 = OpVectorShuffle %v2float %10350 %10350 0 1 - %9202 = OpFMul %v2float %24578 %8643 - %18510 = OpFAdd %v2float %19927 %9202 - %7016 = OpVectorShuffle %v2float %17581 %17581 0 1 - %21063 = OpVectorShuffle %v2float %17581 %17581 2 3 - %13154 = OpExtInst %v2float %1 FClamp %18510 %7016 %21063 - %23589 = OpLoad %150 %5785 - %10351 = OpLoad %508 %5688 - %12162 = OpSampledImage %510 %23589 %10351 - %15376 = OpImageSampleExplicitLod %v4float %12162 %13154 Lod %float_0 - %15271 = OpCompositeExtract %float %15376 3 - %12121 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 - %12977 = OpLoad %float %12121 - %15715 = OpFMul %float %15271 %12977 - %15284 = OpExtInst %float %1 FClamp %15715 %float_0 %float_1 - %22218 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 - %11761 = OpLoad %v3float %22218 - %12108 = OpVectorTimesScalar %v3float %11761 %15284 - %15521 = OpLoad %150 %3312 - %24579 = OpLoad %508 %4646 - %12163 = OpSampledImage %510 %15521 %24579 - %17675 = OpImageSampleExplicitLod %v4float %12163 %13154 Lod %float_0 - %16943 = OpCompositeExtract %float %17675 1 - %14190 = OpFOrdGreaterThan %bool %16943 %float_0 - OpSelectionMerge %22312 DontFlatten - OpBranchConditional %14190 %12826 %22312 - %12826 = OpLabel - %13244 = OpLoad %150 %4862 - %19965 = OpLoad %508 %3594 - %12164 = OpSampledImage %510 %13244 %19965 - %15680 = OpImageSampleExplicitLod %v4float %12164 %13154 Lod %float_0 - %13871 = OpCompositeExtract %float %17675 1 - %12432 = OpCompositeExtract %float %17675 2 - %23305 = OpFMul %float %13871 %12432 - %17617 = OpExtInst %float %1 FClamp %23305 %float_0 %float_1 - %20296 = OpVectorShuffle %v3float %15680 %15680 0 1 2 - %11191 = OpVectorTimesScalar %v3float %20296 %17617 - %15298 = OpFAdd %v3float %12108 %11191 - OpBranch %22312 - %22312 = OpLabel - %7724 = OpPhi %v3float %12108 %22311 %15298 %12826 - %23404 = OpVectorTimesScalar %v3float %7724 %float_0_75 - %9344 = OpFAdd %float %9343 %float_0_75 - %16240 = OpVectorShuffle %v3float %15531 %15531 0 1 2 - %22182 = OpFAdd %v3float %16240 %23404 - %15532 = OpVectorShuffle %v4float %15531 %22182 4 5 6 3 - %6439 = OpCompositeInsert %_struct_1017 %15532 %6438 0 - %24580 = OpVectorShuffle %v2float %626 %626 0 1 - %13212 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 - %10352 = OpLoad %v4float %13212 - %8644 = OpVectorShuffle %v2float %10352 %10352 0 1 - %9203 = OpFMul %v2float %24580 %8644 - %18511 = OpFAdd %v2float %19927 %9203 - %7017 = OpVectorShuffle %v2float %17581 %17581 0 1 - %21064 = OpVectorShuffle %v2float %17581 %17581 2 3 - %13155 = OpExtInst %v2float %1 FClamp %18511 %7017 %21064 - %23590 = OpLoad %150 %5785 - %10353 = OpLoad %508 %5688 - %12165 = OpSampledImage %510 %23590 %10353 - %15377 = OpImageSampleExplicitLod %v4float %12165 %13155 Lod %float_0 - %15272 = OpCompositeExtract %float %15377 3 - %12122 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 - %12978 = OpLoad %float %12122 - %15716 = OpFMul %float %15272 %12978 - %15285 = OpExtInst %float %1 FClamp %15716 %float_0 %float_1 - %22219 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 - %11762 = OpLoad %v3float %22219 - %12109 = OpVectorTimesScalar %v3float %11762 %15285 - %15522 = OpLoad %150 %3312 - %24581 = OpLoad %508 %4646 - %12166 = OpSampledImage %510 %15522 %24581 - %17676 = OpImageSampleExplicitLod %v4float %12166 %13155 Lod %float_0 - %16944 = OpCompositeExtract %float %17676 1 - %14191 = OpFOrdGreaterThan %bool %16944 %float_0 - OpSelectionMerge %22313 DontFlatten - OpBranchConditional %14191 %12827 %22313 - %12827 = OpLabel - %13245 = OpLoad %150 %4862 - %19966 = OpLoad %508 %3594 - %12167 = OpSampledImage %510 %13245 %19966 - %15681 = OpImageSampleExplicitLod %v4float %12167 %13155 Lod %float_0 - %13872 = OpCompositeExtract %float %17676 1 - %12433 = OpCompositeExtract %float %17676 2 - %23306 = OpFMul %float %13872 %12433 - %17618 = OpExtInst %float %1 FClamp %23306 %float_0 %float_1 - %20297 = OpVectorShuffle %v3float %15681 %15681 0 1 2 - %11192 = OpVectorTimesScalar %v3float %20297 %17618 - %15299 = OpFAdd %v3float %12109 %11192 - OpBranch %22313 - %22313 = OpLabel - %7725 = OpPhi %v3float %12109 %22312 %15299 %12827 - %23405 = OpVectorTimesScalar %v3float %7725 %float_1 - %9345 = OpFAdd %float %9344 %float_1 - %16241 = OpVectorShuffle %v3float %15532 %15532 0 1 2 - %22183 = OpFAdd %v3float %16241 %23405 - %15533 = OpVectorShuffle %v4float %15532 %22183 4 5 6 3 - %6440 = OpCompositeInsert %_struct_1017 %15533 %6439 0 - %24582 = OpVectorShuffle %v2float %2411 %2411 0 1 - %13213 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 - %10354 = OpLoad %v4float %13213 - %8645 = OpVectorShuffle %v2float %10354 %10354 0 1 - %9204 = OpFMul %v2float %24582 %8645 - %18512 = OpFAdd %v2float %19927 %9204 - %7018 = OpVectorShuffle %v2float %17581 %17581 0 1 - %21065 = OpVectorShuffle %v2float %17581 %17581 2 3 - %13156 = OpExtInst %v2float %1 FClamp %18512 %7018 %21065 - %23591 = OpLoad %150 %5785 - %10355 = OpLoad %508 %5688 - %12168 = OpSampledImage %510 %23591 %10355 - %15378 = OpImageSampleExplicitLod %v4float %12168 %13156 Lod %float_0 - %15273 = OpCompositeExtract %float %15378 3 - %12123 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 - %12979 = OpLoad %float %12123 - %15717 = OpFMul %float %15273 %12979 - %15286 = OpExtInst %float %1 FClamp %15717 %float_0 %float_1 - %22220 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 - %11763 = OpLoad %v3float %22220 - %12110 = OpVectorTimesScalar %v3float %11763 %15286 - %15523 = OpLoad %150 %3312 - %24583 = OpLoad %508 %4646 - %12169 = OpSampledImage %510 %15523 %24583 - %17677 = OpImageSampleExplicitLod %v4float %12169 %13156 Lod %float_0 - %16945 = OpCompositeExtract %float %17677 1 - %14192 = OpFOrdGreaterThan %bool %16945 %float_0 - OpSelectionMerge %22314 DontFlatten - OpBranchConditional %14192 %12828 %22314 - %12828 = OpLabel - %13246 = OpLoad %150 %4862 - %19967 = OpLoad %508 %3594 - %12170 = OpSampledImage %510 %13246 %19967 - %15682 = OpImageSampleExplicitLod %v4float %12170 %13156 Lod %float_0 - %13873 = OpCompositeExtract %float %17677 1 - %12434 = OpCompositeExtract %float %17677 2 - %23307 = OpFMul %float %13873 %12434 - %17619 = OpExtInst %float %1 FClamp %23307 %float_0 %float_1 - %20298 = OpVectorShuffle %v3float %15682 %15682 0 1 2 - %11193 = OpVectorTimesScalar %v3float %20298 %17619 - %15300 = OpFAdd %v3float %12110 %11193 - OpBranch %22314 - %22314 = OpLabel - %7726 = OpPhi %v3float %12110 %22313 %15300 %12828 - %23406 = OpVectorTimesScalar %v3float %7726 %float_0_75 - %9346 = OpFAdd %float %9345 %float_0_75 - %16242 = OpVectorShuffle %v3float %15533 %15533 0 1 2 - %22184 = OpFAdd %v3float %16242 %23406 - %15534 = OpVectorShuffle %v4float %15533 %22184 4 5 6 3 - %6441 = OpCompositeInsert %_struct_1017 %15534 %6440 0 - %24584 = OpVectorShuffle %v2float %2354 %2354 0 1 - %13214 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 - %10356 = OpLoad %v4float %13214 - %8646 = OpVectorShuffle %v2float %10356 %10356 0 1 - %9205 = OpFMul %v2float %24584 %8646 - %18513 = OpFAdd %v2float %19927 %9205 - %7019 = OpVectorShuffle %v2float %17581 %17581 0 1 - %21066 = OpVectorShuffle %v2float %17581 %17581 2 3 - %13157 = OpExtInst %v2float %1 FClamp %18513 %7019 %21066 - %23592 = OpLoad %150 %5785 - %10357 = OpLoad %508 %5688 - %12171 = OpSampledImage %510 %23592 %10357 - %15379 = OpImageSampleExplicitLod %v4float %12171 %13157 Lod %float_0 - %15274 = OpCompositeExtract %float %15379 3 - %12124 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 - %12980 = OpLoad %float %12124 - %15718 = OpFMul %float %15274 %12980 - %15287 = OpExtInst %float %1 FClamp %15718 %float_0 %float_1 - %22221 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 - %11764 = OpLoad %v3float %22221 - %12111 = OpVectorTimesScalar %v3float %11764 %15287 - %15524 = OpLoad %150 %3312 - %24585 = OpLoad %508 %4646 - %12172 = OpSampledImage %510 %15524 %24585 - %17678 = OpImageSampleExplicitLod %v4float %12172 %13157 Lod %float_0 - %16946 = OpCompositeExtract %float %17678 1 - %14193 = OpFOrdGreaterThan %bool %16946 %float_0 - OpSelectionMerge %22315 DontFlatten - OpBranchConditional %14193 %12829 %22315 - %12829 = OpLabel - %13247 = OpLoad %150 %4862 - %19968 = OpLoad %508 %3594 - %12173 = OpSampledImage %510 %13247 %19968 - %15683 = OpImageSampleExplicitLod %v4float %12173 %13157 Lod %float_0 - %13874 = OpCompositeExtract %float %17678 1 - %12435 = OpCompositeExtract %float %17678 2 - %23308 = OpFMul %float %13874 %12435 - %17620 = OpExtInst %float %1 FClamp %23308 %float_0 %float_1 - %20299 = OpVectorShuffle %v3float %15683 %15683 0 1 2 - %11194 = OpVectorTimesScalar %v3float %20299 %17620 - %15301 = OpFAdd %v3float %12111 %11194 - OpBranch %22315 - %22315 = OpLabel - %7727 = OpPhi %v3float %12111 %22314 %15301 %12829 - %23407 = OpVectorTimesScalar %v3float %7727 %float_0_5 - %9347 = OpFAdd %float %9346 %float_0_5 - %16243 = OpVectorShuffle %v3float %15534 %15534 0 1 2 - %22185 = OpFAdd %v3float %16243 %23407 - %15535 = OpVectorShuffle %v4float %15534 %22185 4 5 6 3 - %6442 = OpCompositeInsert %_struct_1017 %15535 %6441 0 - %24586 = OpVectorShuffle %v2float %837 %837 0 1 - %13215 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 - %10358 = OpLoad %v4float %13215 - %8647 = OpVectorShuffle %v2float %10358 %10358 0 1 - %9206 = OpFMul %v2float %24586 %8647 - %18514 = OpFAdd %v2float %19927 %9206 - %7020 = OpVectorShuffle %v2float %17581 %17581 0 1 - %21067 = OpVectorShuffle %v2float %17581 %17581 2 3 - %13158 = OpExtInst %v2float %1 FClamp %18514 %7020 %21067 - %23593 = OpLoad %150 %5785 - %10359 = OpLoad %508 %5688 - %12174 = OpSampledImage %510 %23593 %10359 - %15380 = OpImageSampleExplicitLod %v4float %12174 %13158 Lod %float_0 - %15275 = OpCompositeExtract %float %15380 3 - %12125 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 - %12981 = OpLoad %float %12125 - %15719 = OpFMul %float %15275 %12981 - %15288 = OpExtInst %float %1 FClamp %15719 %float_0 %float_1 - %22222 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 - %11765 = OpLoad %v3float %22222 - %12112 = OpVectorTimesScalar %v3float %11765 %15288 - %15525 = OpLoad %150 %3312 - %24587 = OpLoad %508 %4646 - %12175 = OpSampledImage %510 %15525 %24587 - %17679 = OpImageSampleExplicitLod %v4float %12175 %13158 Lod %float_0 - %16947 = OpCompositeExtract %float %17679 1 - %14194 = OpFOrdGreaterThan %bool %16947 %float_0 - OpSelectionMerge %22316 DontFlatten - OpBranchConditional %14194 %12830 %22316 - %12830 = OpLabel - %13248 = OpLoad %150 %4862 - %19969 = OpLoad %508 %3594 - %12176 = OpSampledImage %510 %13248 %19969 - %15684 = OpImageSampleExplicitLod %v4float %12176 %13158 Lod %float_0 - %13875 = OpCompositeExtract %float %17679 1 - %12436 = OpCompositeExtract %float %17679 2 - %23309 = OpFMul %float %13875 %12436 - %17621 = OpExtInst %float %1 FClamp %23309 %float_0 %float_1 - %20300 = OpVectorShuffle %v3float %15684 %15684 0 1 2 - %11195 = OpVectorTimesScalar %v3float %20300 %17621 - %15302 = OpFAdd %v3float %12112 %11195 - OpBranch %22316 - %22316 = OpLabel - %7728 = OpPhi %v3float %12112 %22315 %15302 %12830 - %23408 = OpVectorTimesScalar %v3float %7728 %float_0_5 - %9348 = OpFAdd %float %9347 %float_0_5 - %16244 = OpVectorShuffle %v3float %15535 %15535 0 1 2 - %22186 = OpFAdd %v3float %16244 %23408 - %15536 = OpVectorShuffle %v4float %15535 %22186 4 5 6 3 - %6443 = OpCompositeInsert %_struct_1017 %15536 %6442 0 - %24588 = OpVectorShuffle %v2float %1368 %1368 0 1 - %13216 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 - %10360 = OpLoad %v4float %13216 - %8648 = OpVectorShuffle %v2float %10360 %10360 0 1 - %9207 = OpFMul %v2float %24588 %8648 - %18515 = OpFAdd %v2float %19927 %9207 - %7021 = OpVectorShuffle %v2float %17581 %17581 0 1 - %21068 = OpVectorShuffle %v2float %17581 %17581 2 3 - %13159 = OpExtInst %v2float %1 FClamp %18515 %7021 %21068 - %23594 = OpLoad %150 %5785 - %10361 = OpLoad %508 %5688 - %12177 = OpSampledImage %510 %23594 %10361 - %15381 = OpImageSampleExplicitLod %v4float %12177 %13159 Lod %float_0 - %15276 = OpCompositeExtract %float %15381 3 - %12126 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 - %12982 = OpLoad %float %12126 - %15720 = OpFMul %float %15276 %12982 - %15289 = OpExtInst %float %1 FClamp %15720 %float_0 %float_1 - %22223 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 - %11766 = OpLoad %v3float %22223 - %12113 = OpVectorTimesScalar %v3float %11766 %15289 - %15526 = OpLoad %150 %3312 - %24589 = OpLoad %508 %4646 - %12178 = OpSampledImage %510 %15526 %24589 - %17680 = OpImageSampleExplicitLod %v4float %12178 %13159 Lod %float_0 - %16948 = OpCompositeExtract %float %17680 1 - %14195 = OpFOrdGreaterThan %bool %16948 %float_0 - OpSelectionMerge %22317 DontFlatten - OpBranchConditional %14195 %12831 %22317 - %12831 = OpLabel - %13249 = OpLoad %150 %4862 - %19970 = OpLoad %508 %3594 - %12179 = OpSampledImage %510 %13249 %19970 - %15685 = OpImageSampleExplicitLod %v4float %12179 %13159 Lod %float_0 - %13876 = OpCompositeExtract %float %17680 1 - %12437 = OpCompositeExtract %float %17680 2 - %23310 = OpFMul %float %13876 %12437 - %17622 = OpExtInst %float %1 FClamp %23310 %float_0 %float_1 - %20301 = OpVectorShuffle %v3float %15685 %15685 0 1 2 - %11196 = OpVectorTimesScalar %v3float %20301 %17622 - %15303 = OpFAdd %v3float %12113 %11196 - OpBranch %22317 - %22317 = OpLabel - %7729 = OpPhi %v3float %12113 %22316 %15303 %12831 - %23409 = OpVectorTimesScalar %v3float %7729 %float_0_75 - %9349 = OpFAdd %float %9348 %float_0_75 - %16245 = OpVectorShuffle %v3float %15536 %15536 0 1 2 - %22187 = OpFAdd %v3float %16245 %23409 - %15537 = OpVectorShuffle %v4float %15536 %22187 4 5 6 3 - %6444 = OpCompositeInsert %_struct_1017 %15537 %6443 0 - %24590 = OpVectorShuffle %v2float %142 %142 0 1 - %13217 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 - %10362 = OpLoad %v4float %13217 - %8649 = OpVectorShuffle %v2float %10362 %10362 0 1 - %9208 = OpFMul %v2float %24590 %8649 - %18516 = OpFAdd %v2float %19927 %9208 - %7022 = OpVectorShuffle %v2float %17581 %17581 0 1 - %21069 = OpVectorShuffle %v2float %17581 %17581 2 3 - %13160 = OpExtInst %v2float %1 FClamp %18516 %7022 %21069 - %23595 = OpLoad %150 %5785 - %10363 = OpLoad %508 %5688 - %12180 = OpSampledImage %510 %23595 %10363 - %15382 = OpImageSampleExplicitLod %v4float %12180 %13160 Lod %float_0 - %15277 = OpCompositeExtract %float %15382 3 - %12127 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 - %12983 = OpLoad %float %12127 - %15721 = OpFMul %float %15277 %12983 - %15290 = OpExtInst %float %1 FClamp %15721 %float_0 %float_1 - %22224 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 - %11767 = OpLoad %v3float %22224 - %12114 = OpVectorTimesScalar %v3float %11767 %15290 - %15538 = OpLoad %150 %3312 - %24591 = OpLoad %508 %4646 - %12181 = OpSampledImage %510 %15538 %24591 - %17681 = OpImageSampleExplicitLod %v4float %12181 %13160 Lod %float_0 - %16949 = OpCompositeExtract %float %17681 1 - %14196 = OpFOrdGreaterThan %bool %16949 %float_0 - OpSelectionMerge %22318 DontFlatten - OpBranchConditional %14196 %12832 %22318 - %12832 = OpLabel - %13250 = OpLoad %150 %4862 - %19971 = OpLoad %508 %3594 - %12182 = OpSampledImage %510 %13250 %19971 - %15686 = OpImageSampleExplicitLod %v4float %12182 %13160 Lod %float_0 - %13877 = OpCompositeExtract %float %17681 1 - %12438 = OpCompositeExtract %float %17681 2 - %23311 = OpFMul %float %13877 %12438 - %17623 = OpExtInst %float %1 FClamp %23311 %float_0 %float_1 - %20302 = OpVectorShuffle %v3float %15686 %15686 0 1 2 - %11197 = OpVectorTimesScalar %v3float %20302 %17623 - %15304 = OpFAdd %v3float %12114 %11197 - OpBranch %22318 - %22318 = OpLabel - %7730 = OpPhi %v3float %12114 %22317 %15304 %12832 - %23410 = OpVectorTimesScalar %v3float %7730 %float_0_5 - %9350 = OpFAdd %float %9349 %float_0_5 - %16246 = OpVectorShuffle %v3float %15537 %15537 0 1 2 - %22188 = OpFAdd %v3float %16246 %23410 - %15539 = OpVectorShuffle %v4float %15537 %22188 4 5 6 3 - %6445 = OpCompositeInsert %_struct_1017 %15539 %6444 0 - %24592 = OpVectorShuffle %v2float %1197 %1197 0 1 - %13218 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 - %10364 = OpLoad %v4float %13218 - %8650 = OpVectorShuffle %v2float %10364 %10364 0 1 - %9209 = OpFMul %v2float %24592 %8650 - %18517 = OpFAdd %v2float %19927 %9209 - %7023 = OpVectorShuffle %v2float %17581 %17581 0 1 - %21070 = OpVectorShuffle %v2float %17581 %17581 2 3 - %13161 = OpExtInst %v2float %1 FClamp %18517 %7023 %21070 - %23596 = OpLoad %150 %5785 - %10365 = OpLoad %508 %5688 - %12183 = OpSampledImage %510 %23596 %10365 - %15383 = OpImageSampleExplicitLod %v4float %12183 %13161 Lod %float_0 - %15278 = OpCompositeExtract %float %15383 3 - %12128 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 - %12984 = OpLoad %float %12128 - %15722 = OpFMul %float %15278 %12984 - %15291 = OpExtInst %float %1 FClamp %15722 %float_0 %float_1 - %22225 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 - %11768 = OpLoad %v3float %22225 - %12115 = OpVectorTimesScalar %v3float %11768 %15291 - %15540 = OpLoad %150 %3312 - %24593 = OpLoad %508 %4646 - %12184 = OpSampledImage %510 %15540 %24593 - %17682 = OpImageSampleExplicitLod %v4float %12184 %13161 Lod %float_0 - %16950 = OpCompositeExtract %float %17682 1 - %14197 = OpFOrdGreaterThan %bool %16950 %float_0 - OpSelectionMerge %22319 DontFlatten - OpBranchConditional %14197 %12833 %22319 - %12833 = OpLabel - %13251 = OpLoad %150 %4862 - %19972 = OpLoad %508 %3594 - %12185 = OpSampledImage %510 %13251 %19972 - %15687 = OpImageSampleExplicitLod %v4float %12185 %13161 Lod %float_0 - %13878 = OpCompositeExtract %float %17682 1 - %12439 = OpCompositeExtract %float %17682 2 - %23312 = OpFMul %float %13878 %12439 - %17624 = OpExtInst %float %1 FClamp %23312 %float_0 %float_1 - %20303 = OpVectorShuffle %v3float %15687 %15687 0 1 2 - %11198 = OpVectorTimesScalar %v3float %20303 %17624 - %15305 = OpFAdd %v3float %12115 %11198 - OpBranch %22319 - %22319 = OpLabel - %7731 = OpPhi %v3float %12115 %22318 %15305 %12833 - %23411 = OpVectorTimesScalar %v3float %7731 %float_0_5 - %9351 = OpFAdd %float %9350 %float_0_5 - %16247 = OpVectorShuffle %v3float %15539 %15539 0 1 2 - %22189 = OpFAdd %v3float %16247 %23411 - %15541 = OpVectorShuffle %v4float %15539 %22189 4 5 6 3 - %6719 = OpCompositeInsert %_struct_1017 %15541 %6445 0 - %23412 = OpVectorShuffle %v3float %15541 %15541 0 1 2 - %10833 = OpCompositeConstruct %v3float %9351 %9351 %9351 - %13750 = OpFDiv %v3float %23412 %10833 - %24033 = OpVectorShuffle %v4float %15541 %13750 4 5 6 3 - %8636 = OpCompositeInsert %_struct_1017 %24033 %6719 0 - %16315 = OpCompositeInsert %_struct_1017 %float_1 %8636 0 3 - %11544 = OpCompositeExtract %v4float %16315 0 - OpStore %4317 %11544 - OpReturn - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders-msl/asm/vert/empty-struct-composite.asm.vert b/deps/SPIRV-Cross/shaders-msl/asm/vert/empty-struct-composite.asm.vert deleted file mode 100644 index 37a2d87937..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/asm/vert/empty-struct-composite.asm.vert +++ /dev/null @@ -1,37 +0,0 @@ -; SPIR-V -; Version: 1.1 -; Generator: Google rspirv; 0 -; Bound: 17 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Vertex %2 "main" - OpExecutionMode %2 OriginUpperLeft - OpName %Test "Test" - OpName %t "t" - OpName %retvar "retvar" - OpName %main "main" - OpName %retvar_0 "retvar" - %void = OpTypeVoid - %6 = OpTypeFunction %void - %Test = OpTypeStruct -%_ptr_Function_Test = OpTypePointer Function %Test -%_ptr_Function_void = OpTypePointer Function %void - %2 = OpFunction %void None %6 - %7 = OpLabel - %t = OpVariable %_ptr_Function_Test Function - %retvar = OpVariable %_ptr_Function_void Function - OpBranch %4 - %4 = OpLabel - %13 = OpCompositeConstruct %Test - OpStore %t %13 - OpReturn - OpFunctionEnd - %main = OpFunction %void None %6 - %15 = OpLabel - %retvar_0 = OpVariable %_ptr_Function_void Function - OpBranch %14 - %14 = OpLabel - OpReturn - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders-msl/comp/atomic.comp b/deps/SPIRV-Cross/shaders-msl/comp/atomic.comp deleted file mode 100644 index 417284d5de..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/comp/atomic.comp +++ /dev/null @@ -1,33 +0,0 @@ -#version 310 es -#extension GL_OES_shader_image_atomic : require -layout(local_size_x = 1) in; - -layout(r32ui, binding = 0) uniform highp uimage2D uImage; -layout(r32i, binding = 1) uniform highp iimage2D iImage; -layout(binding = 2, std430) buffer SSBO -{ - uint u32; - int i32; -} ssbo; - -void main() -{ - atomicAdd(ssbo.u32, 1u); - atomicOr(ssbo.u32, 1u); - atomicXor(ssbo.u32, 1u); - atomicAnd(ssbo.u32, 1u); - atomicMin(ssbo.u32, 1u); - atomicMax(ssbo.u32, 1u); - atomicExchange(ssbo.u32, 1u); - atomicCompSwap(ssbo.u32, 10u, 2u); - - atomicAdd(ssbo.i32, 1); - atomicOr(ssbo.i32, 1); - atomicXor(ssbo.i32, 1); - atomicAnd(ssbo.i32, 1); - atomicMin(ssbo.i32, 1); - atomicMax(ssbo.i32, 1); - atomicExchange(ssbo.i32, 1); - atomicCompSwap(ssbo.i32, 10, 2); -} - diff --git a/deps/SPIRV-Cross/shaders-msl/comp/barriers.comp b/deps/SPIRV-Cross/shaders-msl/comp/barriers.comp deleted file mode 100644 index c49b626363..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/comp/barriers.comp +++ /dev/null @@ -1,83 +0,0 @@ -#version 310 es -layout(local_size_x = 4) in; - -void barrier_shared() -{ - memoryBarrierShared(); -} - -void full_barrier() -{ - memoryBarrier(); -} - -#if 0 -void image_barrier() -{ - memoryBarrierImage(); -} -#endif - -void buffer_barrier() -{ - memoryBarrierBuffer(); -} - -void group_barrier() -{ - groupMemoryBarrier(); -} - -void barrier_shared_exec() -{ - memoryBarrierShared(); - barrier(); -} - -void full_barrier_exec() -{ - memoryBarrier(); - barrier(); -} - -#if 0 -void image_barrier_exec() -{ - memoryBarrierImage(); - barrier(); -} -#endif - -void buffer_barrier_exec() -{ - memoryBarrierBuffer(); - barrier(); -} - -void group_barrier_exec() -{ - groupMemoryBarrier(); - barrier(); -} - -void exec_barrier() -{ - barrier(); -} - -void main() -{ - barrier_shared(); - full_barrier(); - //image_barrier(); - buffer_barrier(); - group_barrier(); - - barrier_shared_exec(); - full_barrier_exec(); - //image_barrier_exec(); - buffer_barrier_exec(); - group_barrier_exec(); - - exec_barrier(); -} diff --git a/deps/SPIRV-Cross/shaders-msl/comp/basic.comp b/deps/SPIRV-Cross/shaders-msl/comp/basic.comp deleted file mode 100644 index f9bf55670f..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/comp/basic.comp +++ /dev/null @@ -1,28 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -layout(std430, binding = 0) readonly buffer SSBO -{ - vec4 in_data[]; -}; - -layout(std430, binding = 1) writeonly buffer SSBO2 -{ - vec4 out_data[]; -}; - -layout(std430, binding = 2) buffer SSBO3 -{ - uint counter; -}; - -void main() -{ - uint ident = gl_GlobalInvocationID.x; - vec4 idata = in_data[ident]; - if (dot(idata, vec4(1.0, 5.0, 6.0, 2.0)) > 8.2) - { - out_data[atomicAdd(counter, 1u)] = idata; - } -} - diff --git a/deps/SPIRV-Cross/shaders-msl/comp/bitfield.noopt.comp b/deps/SPIRV-Cross/shaders-msl/comp/bitfield.noopt.comp deleted file mode 100644 index 0cac0b257c..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/comp/bitfield.noopt.comp +++ /dev/null @@ -1,23 +0,0 @@ -#version 310 es - -void main() -{ - int signed_value = 0; - uint unsigned_value = 0u; - - int s = bitfieldExtract(signed_value, 5, 20); - uint u = bitfieldExtract(unsigned_value, 6, 21); - s = bitfieldInsert(s, 40, 5, 4); - u = bitfieldInsert(u, 60u, 5, 4); - - u = bitfieldReverse(u); - s = bitfieldReverse(s); - - int v0 = bitCount(u); - int v1 = bitCount(s); - - int v2 = findMSB(u); - int v3 = findMSB(s); - int v4 = findLSB(u); - int v5 = findLSB(s); -} diff --git a/deps/SPIRV-Cross/shaders-msl/comp/builtins.comp b/deps/SPIRV-Cross/shaders-msl/comp/builtins.comp deleted file mode 100644 index 88bb5951e4..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/comp/builtins.comp +++ /dev/null @@ -1,12 +0,0 @@ -#version 310 es -layout(local_size_x = 8, local_size_y = 4, local_size_z = 2) in; - -void main() -{ - uvec3 local_id = gl_LocalInvocationID; - uvec3 global_id = gl_GlobalInvocationID; - uint local_index = gl_LocalInvocationIndex; - uvec3 work_group_size = gl_WorkGroupSize; - uvec3 num_work_groups = gl_NumWorkGroups; - uvec3 work_group_id = gl_WorkGroupID; -} diff --git a/deps/SPIRV-Cross/shaders-msl/comp/cfg-preserve-parameter.comp b/deps/SPIRV-Cross/shaders-msl/comp/cfg-preserve-parameter.comp deleted file mode 100644 index 9ef9092005..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/comp/cfg-preserve-parameter.comp +++ /dev/null @@ -1,54 +0,0 @@ -#version 310 es - -// We write in all paths (and no reads), so should just be out. -void out_test_0(int cond, inout int i) -{ - if (cond == 0) - i = 40; - else - i = 60; -} - -// We write in all paths (and no reads), so should just be out. -void out_test_1(int cond, inout int i) -{ - switch (cond) - { - case 40: - i = 40; - break; - - default: - i = 70; - break; - } -} - -// We don't write in all paths, so should be inout. -void inout_test_0(int cond, inout int i) -{ - if (cond == 0) - i = 40; -} - -void inout_test_1(int cond, inout int i) -{ - switch (cond) - { - case 40: - i = 40; - break; - } -} - - -void main() -{ - int cond = 40; - int i = 50; - - out_test_0(cond, i); - out_test_1(cond, i); - inout_test_0(cond, i); - inout_test_1(cond, i); -} diff --git a/deps/SPIRV-Cross/shaders-msl/comp/coherent-block.comp b/deps/SPIRV-Cross/shaders-msl/comp/coherent-block.comp deleted file mode 100644 index 0a174e8ef0..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/comp/coherent-block.comp +++ /dev/null @@ -1,12 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -layout(binding = 1) coherent restrict writeonly buffer SSBO -{ - vec4 value; -}; - -void main() -{ - value = vec4(20.0); -} diff --git a/deps/SPIRV-Cross/shaders-msl/comp/coherent-image.comp b/deps/SPIRV-Cross/shaders-msl/comp/coherent-image.comp deleted file mode 100644 index fd6e280182..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/comp/coherent-image.comp +++ /dev/null @@ -1,14 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -layout(binding = 1) coherent restrict writeonly buffer SSBO -{ - ivec4 value; -}; - -layout(r32i, binding = 3) coherent readonly restrict uniform mediump iimage2D uImage; - -void main() -{ - value = imageLoad(uImage, ivec2(10)); -} diff --git a/deps/SPIRV-Cross/shaders-msl/comp/culling.comp b/deps/SPIRV-Cross/shaders-msl/comp/culling.comp deleted file mode 100644 index 9f8331b10b..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/comp/culling.comp +++ /dev/null @@ -1,26 +0,0 @@ -#version 310 es -layout(local_size_x = 4) in; - -layout(std430, binding = 0) readonly buffer SSBO -{ - float in_data[]; -}; - -layout(std430, binding = 1) writeonly buffer SSBO2 -{ - float out_data[]; -}; - -layout(std430, binding = 2) buffer SSBO3 -{ - uint count; -}; - -void main() -{ - uint ident = gl_GlobalInvocationID.x; - float idata = in_data[ident]; - if (idata > 12.0) - out_data[atomicAdd(count, 1u)] = idata; -} - diff --git a/deps/SPIRV-Cross/shaders-msl/comp/defer-parens.comp b/deps/SPIRV-Cross/shaders-msl/comp/defer-parens.comp deleted file mode 100644 index 4e8ea6b399..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/comp/defer-parens.comp +++ /dev/null @@ -1,30 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -layout(binding = 0, std430) buffer SSBO -{ - vec4 data; - int index; -}; - -void main() -{ - // Tests defer-parens behavior where a binary expression is OpCompositeExtracted chained together - // with an OpCompositeConstruct optimization. - vec4 d = data; - data = vec4(d.x, d.yz + 10.0, d.w); - - // Verify binary ops. - data = d + d + d; - - // Verify swizzles. - data = (d.yz + 10.0).xxyy; - - // OpCompositeExtract - float t = (d.yz + 10.0).y; - data = vec4(t); - - // OpVectorExtractDynamic - t = (d.zw + 10.0)[index]; - data = vec4(t); -} diff --git a/deps/SPIRV-Cross/shaders-msl/comp/dowhile.comp b/deps/SPIRV-Cross/shaders-msl/comp/dowhile.comp deleted file mode 100644 index 709db75a17..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/comp/dowhile.comp +++ /dev/null @@ -1,31 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -layout(std430, binding = 0) readonly buffer SSBO -{ - mat4 mvp; - vec4 in_data[]; -}; - -layout(std430, binding = 1) writeonly buffer SSBO2 -{ - vec4 out_data[]; -}; - -int i; - -void main() -{ - uint ident = gl_GlobalInvocationID.x; - - i = 0; - vec4 idat = in_data[ident]; - do - { - idat = mvp * idat; - i++; - } while(i < 16); - - out_data[ident] = idat; -} - diff --git a/deps/SPIRV-Cross/shaders-msl/comp/functions.comp b/deps/SPIRV-Cross/shaders-msl/comp/functions.comp deleted file mode 100644 index 478c8ebe83..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/comp/functions.comp +++ /dev/null @@ -1,12 +0,0 @@ -#version 450 -shared int foo[1337]; - -void myfunc() -{ - foo[0]=13; -} - -void main() -{ - myfunc(); -} diff --git a/deps/SPIRV-Cross/shaders-msl/comp/global-invocation-id-writable-ssbo-in-function.comp b/deps/SPIRV-Cross/shaders-msl/comp/global-invocation-id-writable-ssbo-in-function.comp deleted file mode 100644 index 2fe074df7c..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/comp/global-invocation-id-writable-ssbo-in-function.comp +++ /dev/null @@ -1,12 +0,0 @@ -#version 450 -layout(set = 0, binding = 0) buffer myBlock { - int a; - float b[1]; -} myStorage; -float getB() { - return myStorage.b[gl_GlobalInvocationID.x]; -} -void main() { - myStorage.a = (myStorage.a + 1) % 256; - myStorage.b[gl_GlobalInvocationID.x] = mod((getB() + 0.02), 1.0); -} diff --git a/deps/SPIRV-Cross/shaders-msl/comp/global-invocation-id.comp b/deps/SPIRV-Cross/shaders-msl/comp/global-invocation-id.comp deleted file mode 100644 index f484637e1f..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/comp/global-invocation-id.comp +++ /dev/null @@ -1,9 +0,0 @@ -#version 450 -layout(set = 0, binding = 0) buffer myBlock { - int a; - float b[1]; -} myStorage; -void main() { - myStorage.a = (myStorage.a + 1) % 256; - myStorage.b[gl_GlobalInvocationID.x] = mod((myStorage.b[gl_GlobalInvocationID.x] + 0.02), 1.0); -} diff --git a/deps/SPIRV-Cross/shaders-msl/comp/image.comp b/deps/SPIRV-Cross/shaders-msl/comp/image.comp deleted file mode 100644 index e375534a51..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/comp/image.comp +++ /dev/null @@ -1,12 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -layout(rgba8, binding = 0) uniform readonly mediump image2D uImageIn; -layout(rgba8, binding = 1) uniform writeonly mediump image2D uImageOut; - -void main() -{ - vec4 v = imageLoad(uImageIn, ivec2(gl_GlobalInvocationID.xy) + imageSize(uImageIn)); - imageStore(uImageOut, ivec2(gl_GlobalInvocationID.xy), v); -} - diff --git a/deps/SPIRV-Cross/shaders-msl/comp/insert.comp b/deps/SPIRV-Cross/shaders-msl/comp/insert.comp deleted file mode 100644 index 07c1f8d7aa..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/comp/insert.comp +++ /dev/null @@ -1,18 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -layout(std430, binding = 0) writeonly buffer SSBO -{ - vec4 out_data[]; -}; - -void main() -{ - vec4 v; - v.x = 10.0; - v.y = 30.0; - v.z = 70.0; - v.w = 90.0; - out_data[gl_GlobalInvocationID.x] = v; - out_data[gl_GlobalInvocationID.x].y = 20.0; -} diff --git a/deps/SPIRV-Cross/shaders-msl/comp/local-invocation-id.comp b/deps/SPIRV-Cross/shaders-msl/comp/local-invocation-id.comp deleted file mode 100644 index 281700f197..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/comp/local-invocation-id.comp +++ /dev/null @@ -1,9 +0,0 @@ -#version 450 -layout(set = 0, binding = 0) buffer myBlock { - int a; - float b[1]; -} myStorage; -void main() { - myStorage.a = (myStorage.a + 1) % 256; - myStorage.b[gl_LocalInvocationID.x] = mod((myStorage.b[gl_LocalInvocationID.x] + 0.02), 1.0); -} diff --git a/deps/SPIRV-Cross/shaders-msl/comp/local-invocation-index.comp b/deps/SPIRV-Cross/shaders-msl/comp/local-invocation-index.comp deleted file mode 100644 index 68942da8e1..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/comp/local-invocation-index.comp +++ /dev/null @@ -1,9 +0,0 @@ -#version 450 -layout(set = 0, binding = 0) buffer myBlock { - int a; - float b[1]; -} myStorage; -void main() { - myStorage.a = (myStorage.a + 1) % 256; - myStorage.b[gl_LocalInvocationIndex.x] = mod((myStorage.b[gl_LocalInvocationIndex.x] + 0.02), 1.0); -} diff --git a/deps/SPIRV-Cross/shaders-msl/comp/loop.noopt.comp b/deps/SPIRV-Cross/shaders-msl/comp/loop.noopt.comp deleted file mode 100644 index 6d6c324243..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/comp/loop.noopt.comp +++ /dev/null @@ -1,98 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -layout(std430, binding = 0) readonly buffer SSBO -{ - mat4 mvp; - vec4 in_data[]; -}; - -layout(std430, binding = 1) writeonly buffer SSBO2 -{ - vec4 out_data[]; -}; - -void main() -{ - uint ident = gl_GlobalInvocationID.x; - vec4 idat = in_data[ident]; - - int k = 0; - uint i = 0u; - - if (idat.y == 20.0) - { - do - { - k = k * 2; - i++; - } while (i < ident); - } - - switch (k) - { - case 10: - for (;;) - { - i++; - if (i > 10u) - break; - } - break; - - default: - for (;;) - { - i += 2u; - if (i > 20u) - break; - } - break; - } - - while (k < 10) - { - idat *= 2.0; - k++; - } - - for (uint i = 0u; i < 16u; i++, k++) - for (uint j = 0u; j < 30u; j++) - idat = mvp * idat; - - k = 0; - for (;;) - { - k++; - if (k > 10) - { - k += 2; - } - else - { - k += 3; - continue; - } - - k += 10; - } - - k = 0; - do - { - k++; - } while (k > 10); - - int l = 0; - for (;; l++) - { - if (l == 5) - { - continue; - } - - idat += 1.0; - } - out_data[ident] = idat; -} - diff --git a/deps/SPIRV-Cross/shaders-msl/comp/mat3.comp b/deps/SPIRV-Cross/shaders-msl/comp/mat3.comp deleted file mode 100644 index 7c5bb1e4f5..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/comp/mat3.comp +++ /dev/null @@ -1,14 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -layout(std430, binding = 1) writeonly buffer SSBO2 -{ - mat3 out_data[]; -}; - -void main() -{ - uint ident = gl_GlobalInvocationID.x; - out_data[ident] = mat3(vec3(10.0), vec3(20.0), vec3(40.0)); -} - diff --git a/deps/SPIRV-Cross/shaders-msl/comp/mod.comp b/deps/SPIRV-Cross/shaders-msl/comp/mod.comp deleted file mode 100644 index 1631456e30..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/comp/mod.comp +++ /dev/null @@ -1,26 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -layout(std430, binding = 0) readonly buffer SSBO -{ - vec4 in_data[]; -}; - -layout(std430, binding = 1) writeonly buffer SSBO2 -{ - vec4 out_data[]; -}; - -void main() -{ - uint ident = gl_GlobalInvocationID.x; - vec4 v = mod(in_data[ident], out_data[ident]); - out_data[ident] = v; - - uvec4 vu = floatBitsToUint(in_data[ident]) % floatBitsToUint(out_data[ident]); - out_data[ident] = uintBitsToFloat(vu); - - ivec4 vi = floatBitsToInt(in_data[ident]) % floatBitsToInt(out_data[ident]); - out_data[ident] = intBitsToFloat(vi); -} - diff --git a/deps/SPIRV-Cross/shaders-msl/comp/modf.comp b/deps/SPIRV-Cross/shaders-msl/comp/modf.comp deleted file mode 100644 index edadefcf05..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/comp/modf.comp +++ /dev/null @@ -1,23 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -layout(std430, binding = 0) readonly buffer SSBO -{ - vec4 in_data[]; -}; - -layout(std430, binding = 1) writeonly buffer SSBO2 -{ - vec4 out_data[]; -}; - -void main() -{ - uint ident = gl_GlobalInvocationID.x; - vec4 i; - //vec4 v = frexp(in_data[ident], i); - //out_data[ident] = ldexp(v, i); - vec4 v = modf(in_data[ident], i); - out_data[ident] = v; -} - diff --git a/deps/SPIRV-Cross/shaders-msl/comp/read-write-only.comp b/deps/SPIRV-Cross/shaders-msl/comp/read-write-only.comp deleted file mode 100644 index b224b6f121..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/comp/read-write-only.comp +++ /dev/null @@ -1,26 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -layout(binding = 0, std430) readonly buffer SSBO0 -{ - vec4 data0; - vec4 data1; -}; - -layout(binding = 1, std430) restrict buffer SSBO1 -{ - vec4 data2; - vec4 data3; -}; - -layout(binding = 2, std430) restrict writeonly buffer SSBO2 -{ - vec4 data4; - vec4 data5; -}; - -void main() -{ - data4 = data0 + data2; - data5 = data1 + data3; -} diff --git a/deps/SPIRV-Cross/shaders-msl/comp/return.comp b/deps/SPIRV-Cross/shaders-msl/comp/return.comp deleted file mode 100644 index 617f437182..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/comp/return.comp +++ /dev/null @@ -1,33 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -layout(std430, binding = 1) writeonly buffer SSBO2 -{ - vec4 out_data[]; -}; - -void main() -{ - uint ident = gl_GlobalInvocationID.x; - - if (ident == 2u) - { - out_data[ident] = vec4(20.0); - } - else if (ident == 4u) - { - out_data[ident] = vec4(10.0); - return; - } - - for (int i = 0; i < 20; i++) - { - if (i == 10) - break; - - return; - } - - out_data[ident] = vec4(10.0); -} - diff --git a/deps/SPIRV-Cross/shaders-msl/comp/rmw-opt.comp b/deps/SPIRV-Cross/shaders-msl/comp/rmw-opt.comp deleted file mode 100644 index a6e1e7fe75..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/comp/rmw-opt.comp +++ /dev/null @@ -1,27 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -layout(std430, binding = 0) buffer SSBO -{ - int a; -}; - -void main() -{ - a += 10; - a -= 10; - a *= 10; - a /= 10; - a <<= 2; - a >>= 3; - a &= 40; - a ^= 10; - a %= 40; - a |= 1; - - bool c = false; - bool d = true; - c = c && d; - d = d || c; - a = c && d ? 1 : 0; -} diff --git a/deps/SPIRV-Cross/shaders-msl/comp/shared.comp b/deps/SPIRV-Cross/shaders-msl/comp/shared.comp deleted file mode 100644 index 4deff93597..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/comp/shared.comp +++ /dev/null @@ -1,27 +0,0 @@ -#version 310 es -layout(local_size_x = 4) in; - -shared float sShared[gl_WorkGroupSize.x]; - -layout(std430, binding = 0) readonly buffer SSBO -{ - float in_data[]; -}; - -layout(std430, binding = 1) writeonly buffer SSBO2 -{ - float out_data[]; -}; - -void main() -{ - uint ident = gl_GlobalInvocationID.x; - float idata = in_data[ident]; - - sShared[gl_LocalInvocationIndex] = idata; - memoryBarrierShared(); - barrier(); - - out_data[ident] = sShared[gl_WorkGroupSize.x - gl_LocalInvocationIndex - 1u]; -} - diff --git a/deps/SPIRV-Cross/shaders-msl/comp/struct-layout.comp b/deps/SPIRV-Cross/shaders-msl/comp/struct-layout.comp deleted file mode 100644 index 5a2b7802df..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/comp/struct-layout.comp +++ /dev/null @@ -1,24 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -struct Foo -{ - mat4 m; -}; - -layout(std430, binding = 0) readonly buffer SSBO -{ - Foo in_data[]; -}; - -layout(std430, binding = 1) writeonly buffer SSBO2 -{ - Foo out_data[]; -}; - -void main() -{ - uint ident = gl_GlobalInvocationID.x; - out_data[ident].m = in_data[ident].m * in_data[ident].m; -} - diff --git a/deps/SPIRV-Cross/shaders-msl/comp/struct-packing.comp b/deps/SPIRV-Cross/shaders-msl/comp/struct-packing.comp deleted file mode 100644 index 04b933dd18..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/comp/struct-packing.comp +++ /dev/null @@ -1,76 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -struct S0 -{ - vec2 a[1]; - float b; -}; - -struct S1 -{ - vec3 a; - float b; -}; - -struct S2 -{ - vec3 a[1]; - float b; -}; - -struct S3 -{ - vec2 a; - float b; -}; - -struct S4 -{ - vec2 c; -}; - -struct Content -{ - S0 m0s[1]; - S1 m1s[1]; - S2 m2s[1]; - S0 m0; - S1 m1; - S2 m2; - S3 m3; - float m4; - - S4 m3s[8]; -}; - -layout(binding = 1, std430) buffer SSBO1 -{ - Content content; - Content content1[2]; - Content content2; - - layout(column_major) mat2 m0; - layout(column_major) mat2 m1; - layout(column_major) mat2x3 m2[4]; - layout(column_major) mat3x2 m3; - layout(row_major) mat2 m4; - layout(row_major) mat2 m5[9]; - layout(row_major) mat2x3 m6[4][2]; - layout(row_major) mat3x2 m7; - float array[]; -} ssbo_430; - -layout(binding = 0, std140) buffer SSBO0 -{ - Content content; - Content content1[2]; - Content content2; - float array[]; -} ssbo_140; - -void main() -{ - ssbo_430.content = ssbo_140.content; -} - diff --git a/deps/SPIRV-Cross/shaders-msl/comp/torture-loop.comp b/deps/SPIRV-Cross/shaders-msl/comp/torture-loop.comp deleted file mode 100644 index 54a1221a15..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/comp/torture-loop.comp +++ /dev/null @@ -1,40 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -layout(std430, binding = 0) readonly buffer SSBO -{ - mat4 mvp; - vec4 in_data[]; -}; - -layout(std430, binding = 1) writeonly buffer SSBO2 -{ - vec4 out_data[]; -}; - -void main() -{ - uint ident = gl_GlobalInvocationID.x; - vec4 idat = in_data[ident]; - - int k = 0; - - // Continue with side effects. - while (++k < 10) - { - idat *= 2.0; - k++; - } - - // Again used here ... - for (uint i = 0u; i < 16u; i++, k++) - for (uint j = 0u; j < 30u; j++) - idat = mvp * idat; - - do - { - k++; - } while (k > 10); - out_data[ident] = idat; -} - diff --git a/deps/SPIRV-Cross/shaders-msl/comp/type-alias.comp b/deps/SPIRV-Cross/shaders-msl/comp/type-alias.comp deleted file mode 100644 index 343d350a2f..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/comp/type-alias.comp +++ /dev/null @@ -1,45 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -struct S0 -{ - vec4 a; -}; - -struct S1 -{ - vec4 a; -}; - -vec4 overload(S0 s0) -{ - return s0.a; -} - -vec4 overload(S1 s1) -{ - return s1.a; -} - -layout(std430, binding = 0) buffer SSBO0 -{ - S0 s0s[]; -}; - -layout(std430, binding = 1) buffer SSBO1 -{ - S1 s1s[]; -}; - -layout(std430, binding = 2) buffer SSBO2 -{ - vec4 outputs[]; -}; - - -void main() -{ - S0 s0 = s0s[gl_GlobalInvocationID.x]; - S1 s1 = s1s[gl_GlobalInvocationID.x]; - outputs[gl_GlobalInvocationID.x] = overload(s0) + overload(s1); -} diff --git a/deps/SPIRV-Cross/shaders-msl/comp/udiv.comp b/deps/SPIRV-Cross/shaders-msl/comp/udiv.comp deleted file mode 100644 index 33fe564f07..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/comp/udiv.comp +++ /dev/null @@ -1,17 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -layout(std430, binding = 0) buffer SSBO -{ - uint inputs[]; -}; - -layout(std430, binding = 0) buffer SSBO2 -{ - uint outputs[]; -}; - -void main() -{ - outputs[gl_GlobalInvocationID.x] = inputs[gl_GlobalInvocationID.x] / 29u; -} diff --git a/deps/SPIRV-Cross/shaders-msl/comp/writable-ssbo.comp b/deps/SPIRV-Cross/shaders-msl/comp/writable-ssbo.comp deleted file mode 100644 index 1d5128ce8a..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/comp/writable-ssbo.comp +++ /dev/null @@ -1,9 +0,0 @@ -#version 450 -layout(set = 0, binding = 0) buffer myBlock { - int a; - float b; -} myStorage; -void main() { - myStorage.a = (myStorage.a + 1) % 256; - myStorage.b = mod((myStorage.b + 0.02), 1.0); -} diff --git a/deps/SPIRV-Cross/shaders-msl/desktop-only/frag/image-ms.desktop.frag b/deps/SPIRV-Cross/shaders-msl/desktop-only/frag/image-ms.desktop.frag deleted file mode 100644 index e145cb8f00..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/desktop-only/frag/image-ms.desktop.frag +++ /dev/null @@ -1,13 +0,0 @@ -#version 450 - -layout(rgba8, binding = 0) uniform image2D uImage; -layout(rgba8, binding = 1) uniform image2DArray uImageArray; -layout(rgba8, binding = 2) uniform image2DMS uImageMS; - -void main() -{ - vec4 a = imageLoad(uImageMS, ivec2(1, 2), 2); - vec4 b = imageLoad(uImageArray, ivec3(1, 2, 4)); - imageStore(uImage, ivec2(2, 3), a); - imageStore(uImageArray, ivec3(2, 3, 7), b); -} diff --git a/deps/SPIRV-Cross/shaders-msl/desktop-only/frag/query-levels.desktop.frag b/deps/SPIRV-Cross/shaders-msl/desktop-only/frag/query-levels.desktop.frag deleted file mode 100644 index 4a80cbf81f..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/desktop-only/frag/query-levels.desktop.frag +++ /dev/null @@ -1,11 +0,0 @@ -#version 450 - -layout(binding = 0) uniform sampler2D uSampler; - -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = vec4(float(textureQueryLevels(uSampler))); -} - diff --git a/deps/SPIRV-Cross/shaders-msl/desktop-only/frag/sampler-ms-query.desktop.frag b/deps/SPIRV-Cross/shaders-msl/desktop-only/frag/sampler-ms-query.desktop.frag deleted file mode 100644 index 4c30ed1529..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/desktop-only/frag/sampler-ms-query.desktop.frag +++ /dev/null @@ -1,14 +0,0 @@ -#version 450 - -layout(binding = 0) uniform sampler2DMS uSampler; -layout(binding = 1) uniform sampler2DMSArray uSamplerArray; -layout(binding = 2, rgba8) uniform readonly writeonly image2DMS uImage; -layout(binding = 3, rgba8) uniform readonly writeonly image2DMSArray uImageArray; - -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = vec4(float(((textureSamples(uSampler) + textureSamples(uSamplerArray)) + imageSamples(uImage)) + imageSamples(uImageArray))); -} - diff --git a/deps/SPIRV-Cross/shaders-msl/desktop-only/vert/basic.desktop.sso.vert b/deps/SPIRV-Cross/shaders-msl/desktop-only/vert/basic.desktop.sso.vert deleted file mode 100644 index 9ddab08cda..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/desktop-only/vert/basic.desktop.sso.vert +++ /dev/null @@ -1,20 +0,0 @@ -#version 450 - -out gl_PerVertex -{ - vec4 gl_Position; -}; - -layout(std140) uniform UBO -{ - mat4 uMVP; -}; -layout(location = 0) in vec4 aVertex; -layout(location = 1) in vec3 aNormal; -layout(location = 0) out vec3 vNormal; - -void main() -{ - gl_Position = uMVP * aVertex; - vNormal = aNormal; -} diff --git a/deps/SPIRV-Cross/shaders-msl/desktop-only/vert/clip-cull-distance.desktop.vert b/deps/SPIRV-Cross/shaders-msl/desktop-only/vert/clip-cull-distance.desktop.vert deleted file mode 100644 index 9e4a0b7ac9..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/desktop-only/vert/clip-cull-distance.desktop.vert +++ /dev/null @@ -1,10 +0,0 @@ -#version 450 - -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; -} diff --git a/deps/SPIRV-Cross/shaders-msl/flatten/basic.flatten.vert b/deps/SPIRV-Cross/shaders-msl/flatten/basic.flatten.vert deleted file mode 100644 index e60a9067b1..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/flatten/basic.flatten.vert +++ /dev/null @@ -1,16 +0,0 @@ -#version 310 es - -layout(std140) uniform UBO -{ - mat4 uMVP; -}; - -layout(location = 0) in vec4 aVertex; -layout(location = 1) in vec3 aNormal; -layout(location = 0) out vec3 vNormal; - -void main() -{ - gl_Position = uMVP * aVertex; - vNormal = aNormal; -} diff --git a/deps/SPIRV-Cross/shaders-msl/flatten/multiindex.flatten.vert b/deps/SPIRV-Cross/shaders-msl/flatten/multiindex.flatten.vert deleted file mode 100644 index 0b471d86e0..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/flatten/multiindex.flatten.vert +++ /dev/null @@ -1,13 +0,0 @@ -#version 310 es - -layout(std140) uniform UBO -{ - vec4 Data[3][5]; -}; - -layout(location = 0) in ivec2 aIndex; - -void main() -{ - gl_Position = Data[aIndex.x][aIndex.y]; -} diff --git a/deps/SPIRV-Cross/shaders-msl/flatten/push-constant.flatten.vert b/deps/SPIRV-Cross/shaders-msl/flatten/push-constant.flatten.vert deleted file mode 100644 index c7b1b42e1b..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/flatten/push-constant.flatten.vert +++ /dev/null @@ -1,17 +0,0 @@ -#version 310 es - -layout(push_constant, std430) uniform PushMe -{ - mat4 MVP; - mat2 Rot; // The MatrixStride will be 8 here. - float Arr[4]; -} registers; - -layout(location = 0) in vec2 Rot; -layout(location = 1) in vec4 Pos; -layout(location = 0) out vec2 vRot; -void main() -{ - gl_Position = registers.MVP * Pos; - vRot = registers.Rot * Rot + registers.Arr[2]; // Constant access should work even if array stride is just 4 here. -} diff --git a/deps/SPIRV-Cross/shaders-msl/flatten/rowmajor.flatten.vert b/deps/SPIRV-Cross/shaders-msl/flatten/rowmajor.flatten.vert deleted file mode 100644 index 88c468c8f2..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/flatten/rowmajor.flatten.vert +++ /dev/null @@ -1,16 +0,0 @@ -#version 310 es - -layout(std140) uniform UBO -{ - layout(column_major) mat4 uMVPR; - layout(row_major) mat4 uMVPC; - layout(row_major) mat2x4 uMVP; -}; - -layout(location = 0) in vec4 aVertex; - -void main() -{ - vec2 v = aVertex * uMVP; - gl_Position = uMVPR * aVertex + uMVPC * aVertex; -} diff --git a/deps/SPIRV-Cross/shaders-msl/flatten/struct.flatten.vert b/deps/SPIRV-Cross/shaders-msl/flatten/struct.flatten.vert deleted file mode 100644 index 936bb41b85..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/flatten/struct.flatten.vert +++ /dev/null @@ -1,30 +0,0 @@ -#version 310 es - -struct Light -{ - vec3 Position; - float Radius; - - vec4 Color; -}; - -layout(std140) uniform UBO -{ - mat4 uMVP; - - Light light; -}; - -layout(location = 0) in vec4 aVertex; -layout(location = 1) in vec3 aNormal; -layout(location = 0) out vec4 vColor; - -void main() -{ - gl_Position = uMVP * aVertex; - - vColor = vec4(0.0); - - vec3 L = aVertex.xyz - light.Position; - vColor += dot(aNormal, normalize(L)) * (clamp(1.0 - length(L) / light.Radius, 0.0, 1.0) * light.Color); -} diff --git a/deps/SPIRV-Cross/shaders-msl/flatten/swizzle.flatten.vert b/deps/SPIRV-Cross/shaders-msl/flatten/swizzle.flatten.vert deleted file mode 100644 index e310cdf336..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/flatten/swizzle.flatten.vert +++ /dev/null @@ -1,47 +0,0 @@ -#version 310 es - -// comments note the 16b alignment boundaries (see GL spec 7.6.2.2 Standard Uniform Block Layout) -layout(std140) uniform UBO -{ - // 16b boundary - vec4 A; - // 16b boundary - vec2 B0; - vec2 B1; - // 16b boundary - float C0; - // 16b boundary (vec3 is aligned to 16b) - vec3 C1; - // 16b boundary - vec3 D0; - float D1; - // 16b boundary - float E0; - float E1; - float E2; - float E3; - // 16b boundary - float F0; - vec2 F1; - // 16b boundary (vec2 before us is aligned to 8b) - float F2; -}; - -layout(location = 0) out vec4 oA; -layout(location = 1) out vec4 oB; -layout(location = 2) out vec4 oC; -layout(location = 3) out vec4 oD; -layout(location = 4) out vec4 oE; -layout(location = 5) out vec4 oF; - -void main() -{ - gl_Position = vec4(0.0); - - oA = A; - oB = vec4(B0, B1); - oC = vec4(C0, C1) + vec4(C1.xy, C1.z, C0); // not packed - oD = vec4(D0, D1) + vec4(D0.xy, D0.z, D1); // packed - must convert for swizzle - oE = vec4(E0, E1, E2, E3); - oF = vec4(F0, F1, F2); -} diff --git a/deps/SPIRV-Cross/shaders-msl/flatten/types.flatten.frag b/deps/SPIRV-Cross/shaders-msl/flatten/types.flatten.frag deleted file mode 100644 index faab5b7e05..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/flatten/types.flatten.frag +++ /dev/null @@ -1,27 +0,0 @@ -#version 310 es -precision mediump float; - -layout(std140, binding = 0) uniform UBO0 -{ - vec4 a; - vec4 b; -}; - -layout(std140, binding = 0) uniform UBO1 -{ - ivec4 c; - ivec4 d; -}; - -layout(std140, binding = 0) uniform UBO2 -{ - uvec4 e; - uvec4 f; -}; - -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = vec4(c) + vec4(d) + vec4(e) + vec4(f) + a + b; -} diff --git a/deps/SPIRV-Cross/shaders-msl/frag/basic.frag b/deps/SPIRV-Cross/shaders-msl/frag/basic.frag deleted file mode 100644 index dd9a8f8507..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/frag/basic.frag +++ /dev/null @@ -1,13 +0,0 @@ -#version 310 es -precision mediump float; - -layout(location = 0) in vec4 vColor; -layout(location = 1) in vec2 vTex; -layout(binding = 0) uniform sampler2D uTex; -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = vColor * texture(uTex, vTex); -} - diff --git a/deps/SPIRV-Cross/shaders-msl/frag/bitcasting.frag b/deps/SPIRV-Cross/shaders-msl/frag/bitcasting.frag deleted file mode 100644 index 5dac78ef33..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/frag/bitcasting.frag +++ /dev/null @@ -1,24 +0,0 @@ -#version 310 es -precision mediump float; - -layout(binding = 0) uniform sampler2D TextureBase; -layout(binding = 1) uniform sampler2D TextureDetail; - -layout(location = 0) in vec4 VertGeom; - -layout(location = 0) out vec4 FragColor0; -layout(location = 1) out vec4 FragColor1; - -void main() -{ - vec4 texSample0 = texture(TextureBase, VertGeom.xy); - vec4 texSample1 = textureOffset(TextureDetail, VertGeom.xy, ivec2(3, 2)); - - ivec4 iResult0 = floatBitsToInt(texSample0); - ivec4 iResult1 = floatBitsToInt(texSample1); - FragColor0 = (intBitsToFloat(iResult0) * intBitsToFloat(iResult1)); - - uvec4 uResult0 = floatBitsToUint(texSample0); - uvec4 uResult1 = floatBitsToUint(texSample1); - FragColor1 = (uintBitsToFloat(uResult0) * uintBitsToFloat(uResult1)); -} \ No newline at end of file diff --git a/deps/SPIRV-Cross/shaders-msl/frag/builtins.frag b/deps/SPIRV-Cross/shaders-msl/frag/builtins.frag deleted file mode 100644 index 99e6e2df5b..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/frag/builtins.frag +++ /dev/null @@ -1,11 +0,0 @@ -#version 310 es -precision mediump float; - -layout(location = 0) out vec4 FragColor; -layout(location = 0) in vec4 vColor; - -void main() -{ - FragColor = gl_FragCoord + vColor; - gl_FragDepth = 0.5; -} diff --git a/deps/SPIRV-Cross/shaders-msl/frag/composite-extract-forced-temporary.frag b/deps/SPIRV-Cross/shaders-msl/frag/composite-extract-forced-temporary.frag deleted file mode 100644 index 35fdbe8624..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/frag/composite-extract-forced-temporary.frag +++ /dev/null @@ -1,11 +0,0 @@ -#version 310 es -precision mediump float; -layout(binding = 0) uniform sampler2D Texture; -layout(location = 0) out vec4 FragColor; -layout(location = 0) in vec2 vTexCoord; - -void main() -{ - float f = texture(Texture, vTexCoord).x; - FragColor = vec4(f * f); -} diff --git a/deps/SPIRV-Cross/shaders-msl/frag/constant-array.frag b/deps/SPIRV-Cross/shaders-msl/frag/constant-array.frag deleted file mode 100644 index b862cb1dbf..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/frag/constant-array.frag +++ /dev/null @@ -1,21 +0,0 @@ -#version 310 es -precision mediump float; -layout(location = 0) out vec4 FragColor; - -layout(location = 0) flat in int index; - -struct Foobar { float a; float b; }; - -vec4 resolve(Foobar f) -{ - return vec4(f.a + f.b); -} - -void main() -{ - const vec4 foo[3] = vec4[](vec4(1.0), vec4(2.0), vec4(3.0)); - const vec4 foobars[2][2] = vec4[][](vec4[](vec4(1.0), vec4(2.0)), vec4[](vec4(8.0), vec4(10.0))); - const Foobar foos[2] = Foobar[](Foobar(10.0, 40.0), Foobar(90.0, 70.0)); - - FragColor = foo[index] + foobars[index][index + 1] + resolve(Foobar(10.0, 20.0)) + resolve(foos[index]); -} diff --git a/deps/SPIRV-Cross/shaders-msl/frag/false-loop-init.frag b/deps/SPIRV-Cross/shaders-msl/frag/false-loop-init.frag deleted file mode 100644 index 7ce5b52bd7..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/frag/false-loop-init.frag +++ /dev/null @@ -1,19 +0,0 @@ -#version 310 es -precision mediump float; - -layout(location = 0) in vec4 accum; -layout(location = 0) out vec4 result; - -void main() -{ - result = vec4(0.0); - uint j; - for (int i = 0; i < 4; i += int(j)) - { - if (accum.y > 10.0) - j = 40u; - else - j = 30u; - result += accum; - } -} diff --git a/deps/SPIRV-Cross/shaders-msl/frag/flush_params.frag b/deps/SPIRV-Cross/shaders-msl/frag/flush_params.frag deleted file mode 100644 index 8a26ad3a28..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/frag/flush_params.frag +++ /dev/null @@ -1,27 +0,0 @@ -#version 310 es -precision mediump float; - -layout(location = 0) out vec4 FragColor; - -struct Structy -{ - vec4 c; -}; - -void foo2(out Structy f) -{ - f.c = vec4(10.0); -} - -Structy foo() -{ - Structy f; - foo2(f); - return f; -} - -void main() -{ - Structy s = foo(); - FragColor = s.c; -} diff --git a/deps/SPIRV-Cross/shaders-msl/frag/for-loop-init.frag b/deps/SPIRV-Cross/shaders-msl/frag/for-loop-init.frag deleted file mode 100644 index 0cde26765e..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/frag/for-loop-init.frag +++ /dev/null @@ -1,52 +0,0 @@ -#version 310 es -precision mediump float; -layout(location = 0) out int FragColor; - -void main() -{ - FragColor = 16; - - // Basic loop variable. - for (int i = 0; i < 25; i++) - FragColor += 10; - - // Multiple loop variables. - for (int i = 1, j = 4; i < 30; i++, j += 4) - FragColor += 11; - - // A potential loop variables, but we access it outside the loop, - // so cannot be one. - int k = 0; - for (; k < 20; k++) - FragColor += 12; - k += 3; - FragColor += k; - - // Potential loop variables, but the dominator is not trivial. - int l; - if (k == 40) - { - for (l = 0; l < 40; l++) - FragColor += 13; - return; - } - else - { - l = k; - FragColor += l; - } - - // Vectors cannot be loop variables - for (ivec2 i = ivec2(0); i.x < 10; i.x += 4) - { - FragColor += i.y; - } - - // Check that static expressions can be used before the loop header. - int m = 0; - m = k; - int o = m; - for (; m < 40; m++) - FragColor += m; - FragColor += o; -} diff --git a/deps/SPIRV-Cross/shaders-msl/frag/in_block.frag b/deps/SPIRV-Cross/shaders-msl/frag/in_block.frag deleted file mode 100644 index 59b97074ec..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/frag/in_block.frag +++ /dev/null @@ -1,14 +0,0 @@ -#version 450 - -layout(location = 2) in VertexOut -{ - vec4 color; - vec4 color2; -} inputs; - -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = inputs.color + inputs.color2; -} diff --git a/deps/SPIRV-Cross/shaders-msl/frag/in_block_assign.noopt.frag b/deps/SPIRV-Cross/shaders-msl/frag/in_block_assign.noopt.frag deleted file mode 100644 index 760a3ba2d3..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/frag/in_block_assign.noopt.frag +++ /dev/null @@ -1,16 +0,0 @@ -#version 450 - -struct VOUT -{ - vec4 a; -}; - -layout(location = 0) in VOUT Clip; -layout(location = 0) out vec4 FragColor; - -void main() -{ - VOUT tmp = Clip; - tmp.a += 1.0; - FragColor = tmp.a; -} diff --git a/deps/SPIRV-Cross/shaders-msl/frag/mix.frag b/deps/SPIRV-Cross/shaders-msl/frag/mix.frag deleted file mode 100644 index a5d589dd08..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/frag/mix.frag +++ /dev/null @@ -1,20 +0,0 @@ -#version 310 es -precision mediump float; - -layout(location = 0) in vec4 vIn0; -layout(location = 1) in vec4 vIn1; -layout(location = 2) in float vIn2; -layout(location = 3) in float vIn3; -layout(location = 0) out vec4 FragColor; - -void main() -{ - bvec4 l = bvec4(false, true, false, false); - FragColor = mix(vIn0, vIn1, l); - - bool f = true; - FragColor = vec4(mix(vIn2, vIn3, f)); - - FragColor = f ? vIn0 : vIn1; - FragColor = vec4(f ? vIn2 : vIn3); -} diff --git a/deps/SPIRV-Cross/shaders-msl/frag/pls.frag b/deps/SPIRV-Cross/shaders-msl/frag/pls.frag deleted file mode 100644 index e3863e4e0e..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/frag/pls.frag +++ /dev/null @@ -1,20 +0,0 @@ -#version 310 es -precision mediump float; - -layout(location = 0) in vec4 PLSIn0; -layout(location = 1) in vec4 PLSIn1; -layout(location = 2) in vec4 PLSIn2; -layout(location = 3) in vec4 PLSIn3; - -layout(location = 0) out vec4 PLSOut0; -layout(location = 1) out vec4 PLSOut1; -layout(location = 2) out vec4 PLSOut2; -layout(location = 3) out vec4 PLSOut3; - -void main() -{ - PLSOut0 = 2.0 * PLSIn0; - PLSOut1 = 6.0 * PLSIn1; - PLSOut2 = 7.0 * PLSIn2; - PLSOut3 = 4.0 * PLSIn3; -} diff --git a/deps/SPIRV-Cross/shaders-msl/frag/sampler-ms.frag b/deps/SPIRV-Cross/shaders-msl/frag/sampler-ms.frag deleted file mode 100644 index 6593928271..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/frag/sampler-ms.frag +++ /dev/null @@ -1,16 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(binding = 0) uniform mediump sampler2DMS uSampler; -layout(location = 0) out vec4 FragColor; - -void main() -{ - ivec2 coord = ivec2(gl_FragCoord.xy); - FragColor = - texelFetch(uSampler, coord, 0) + - texelFetch(uSampler, coord, 1) + - texelFetch(uSampler, coord, 2) + - texelFetch(uSampler, coord, 3); -} diff --git a/deps/SPIRV-Cross/shaders-msl/frag/sampler.frag b/deps/SPIRV-Cross/shaders-msl/frag/sampler.frag deleted file mode 100644 index e38f76886a..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/frag/sampler.frag +++ /dev/null @@ -1,18 +0,0 @@ -#version 310 es -precision mediump float; - -layout(location = 0) in vec4 vColor; -layout(location = 1) in vec2 vTex; -layout(binding = 0) uniform sampler2D uTex; -layout(location = 0) out vec4 FragColor; - -vec4 sample_texture(sampler2D tex, vec2 uv) -{ - return texture(tex, uv); -} - -void main() -{ - FragColor = vColor * sample_texture(uTex, vTex); -} - diff --git a/deps/SPIRV-Cross/shaders-msl/frag/separate-image-sampler-argument.frag b/deps/SPIRV-Cross/shaders-msl/frag/separate-image-sampler-argument.frag deleted file mode 100644 index 0475b019d2..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/frag/separate-image-sampler-argument.frag +++ /dev/null @@ -1,16 +0,0 @@ -#version 310 es -precision mediump float; - -layout(set = 0, binding = 0) uniform mediump sampler uSampler; -layout(set = 0, binding = 1) uniform mediump texture2D uDepth; -layout(location = 0) out vec4 FragColor; - -vec4 samp(texture2D t, mediump sampler s) -{ - return texture(sampler2D(t, s), vec2(0.5)); -} - -void main() -{ - FragColor = samp(uDepth, uSampler); -} diff --git a/deps/SPIRV-Cross/shaders-msl/frag/swizzle.frag b/deps/SPIRV-Cross/shaders-msl/frag/swizzle.frag deleted file mode 100644 index 271ba6cb64..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/frag/swizzle.frag +++ /dev/null @@ -1,17 +0,0 @@ -#version 310 es -precision mediump float; - -layout(location = 0) uniform sampler2D samp; -layout(location = 0) out vec4 FragColor; -layout(location = 1) in vec3 vNormal; -layout(location = 2) in vec2 vUV; - -void main() -{ - FragColor = vec4(texture(samp, vUV).xyz, 1.0); - FragColor = vec4(texture(samp, vUV).xz, 1.0, 4.0); - FragColor = vec4(texture(samp, vUV).xx, texture(samp, vUV + vec2(0.1)).yy); - FragColor = vec4(vNormal, 1.0); - FragColor = vec4(vNormal + 1.8, 1.0); - FragColor = vec4(vUV, vUV + 1.8); -} diff --git a/deps/SPIRV-Cross/shaders-msl/frag/texture-proj-shadow.frag b/deps/SPIRV-Cross/shaders-msl/frag/texture-proj-shadow.frag deleted file mode 100644 index 547532e648..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/frag/texture-proj-shadow.frag +++ /dev/null @@ -1,19 +0,0 @@ -#version 450 - -layout(binding = 1) uniform sampler2DShadow uShadow2D; -layout(binding = 2) uniform sampler1D uSampler1D; -layout(binding = 3) uniform sampler2D uSampler2D; -layout(binding = 4) uniform sampler3D uSampler3D; - -layout(location = 0) out float FragColor; -layout(location = 0) in vec3 vClip3; -layout(location = 1) in vec4 vClip4; -layout(location = 2) in vec2 vClip2; - -void main() -{ - FragColor = textureProj(uShadow2D, vClip4); - FragColor = textureProj(uSampler1D, vClip2).x; - FragColor = textureProj(uSampler2D, vClip3).x; - FragColor = textureProj(uSampler3D, vClip4).x; -} diff --git a/deps/SPIRV-Cross/shaders-msl/frag/ubo_layout.frag b/deps/SPIRV-Cross/shaders-msl/frag/ubo_layout.frag deleted file mode 100644 index 80f9f16d3d..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/frag/ubo_layout.frag +++ /dev/null @@ -1,24 +0,0 @@ -#version 310 es -precision mediump float; - -layout(location = 0) out vec4 FragColor; - -struct Str -{ - mat4 foo; -}; - -layout(binding = 0, std140) uniform UBO1 -{ - layout(row_major) Str foo; -} ubo1; - -layout(binding = 1, std140) uniform UBO2 -{ - layout(column_major) Str foo; -} ubo0; - -void main() -{ - FragColor = ubo1.foo.foo[0] + ubo0.foo.foo[0]; -} diff --git a/deps/SPIRV-Cross/shaders-msl/frag/unary-enclose.frag b/deps/SPIRV-Cross/shaders-msl/frag/unary-enclose.frag deleted file mode 100644 index ea502e1de8..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/frag/unary-enclose.frag +++ /dev/null @@ -1,15 +0,0 @@ -#version 310 es -precision mediump float; - -layout(location = 0) out vec4 FragColor; -layout(location = 0) in vec4 vIn; -layout(location = 1) flat in ivec4 vIn1; - -void main() -{ - FragColor = +(-(-vIn)); - ivec4 a = ~(~vIn1); - - bool b = false; - b = !!b; -} diff --git a/deps/SPIRV-Cross/shaders-msl/legacy/vert/transpose.legacy.vert b/deps/SPIRV-Cross/shaders-msl/legacy/vert/transpose.legacy.vert deleted file mode 100644 index 84f618262a..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/legacy/vert/transpose.legacy.vert +++ /dev/null @@ -1,20 +0,0 @@ -#version 310 es - -uniform Buffer -{ - layout(row_major) mat4 MVPRowMajor; - layout(column_major) mat4 MVPColMajor; - mat4 M; -}; - -layout(location = 0) in vec4 Position; - -void main() -{ - vec4 c0 = M * (MVPRowMajor * Position); - vec4 c1 = M * (MVPColMajor * Position); - vec4 c2 = M * (Position * MVPRowMajor); - vec4 c3 = M * (Position * MVPColMajor); - gl_Position = c0 + c1 + c2 + c3; -} - diff --git a/deps/SPIRV-Cross/shaders-msl/vert/basic.vert b/deps/SPIRV-Cross/shaders-msl/vert/basic.vert deleted file mode 100644 index 8191dc2d0f..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/vert/basic.vert +++ /dev/null @@ -1,17 +0,0 @@ -#version 310 es - -layout(std140) uniform UBO -{ - uniform mat4 uMVP; -}; - -layout(location = 0) in vec4 aVertex; -layout(location = 1) in vec3 aNormal; - -layout(location = 0) out vec3 vNormal; - -void main() -{ - gl_Position = uMVP * aVertex; - vNormal = aNormal; -} diff --git a/deps/SPIRV-Cross/shaders-msl/vert/copy.flatten.vert b/deps/SPIRV-Cross/shaders-msl/vert/copy.flatten.vert deleted file mode 100644 index 4f1b8805e7..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/vert/copy.flatten.vert +++ /dev/null @@ -1,34 +0,0 @@ -#version 310 es - -struct Light -{ - vec3 Position; - float Radius; - - vec4 Color; -}; - -layout(std140) uniform UBO -{ - mat4 uMVP; - - Light lights[4]; -}; - -layout(location = 0) in vec4 aVertex; -layout(location = 1) in vec3 aNormal; -layout(location = 0) out vec4 vColor; - -void main() -{ - gl_Position = uMVP * aVertex; - - vColor = vec4(0.0); - - for (int i = 0; i < 4; ++i) - { - Light light = lights[i]; - vec3 L = aVertex.xyz - light.Position; - vColor += dot(aNormal, normalize(L)) * (clamp(1.0 - length(L) / light.Radius, 0.0, 1.0) * lights[i].Color); - } -} diff --git a/deps/SPIRV-Cross/shaders-msl/vert/dynamic.flatten.vert b/deps/SPIRV-Cross/shaders-msl/vert/dynamic.flatten.vert deleted file mode 100644 index a341d45288..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/vert/dynamic.flatten.vert +++ /dev/null @@ -1,33 +0,0 @@ -#version 310 es - -struct Light -{ - vec3 Position; - float Radius; - - vec4 Color; -}; - -layout(std140) uniform UBO -{ - mat4 uMVP; - - Light lights[4]; -}; - -layout(location = 0) in vec4 aVertex; -layout(location = 1) in vec3 aNormal; -layout(location = 0) out vec4 vColor; - -void main() -{ - gl_Position = uMVP * aVertex; - - vColor = vec4(0.0); - - for (int i = 0; i < 4; ++i) - { - vec3 L = aVertex.xyz - lights[i].Position; - vColor += dot(aNormal, normalize(L)) * (clamp(1.0 - length(L) / lights[i].Radius, 0.0, 1.0) * lights[i].Color); - } -} diff --git a/deps/SPIRV-Cross/shaders-msl/vert/functions.vert b/deps/SPIRV-Cross/shaders-msl/vert/functions.vert deleted file mode 100644 index b92074f465..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/vert/functions.vert +++ /dev/null @@ -1,28 +0,0 @@ -#version 310 es - -layout(std140) uniform UBO -{ - uniform mat4 uMVP; - uniform vec3 rotDeg; - uniform vec3 rotRad; - uniform ivec2 bits; -}; - -layout(location = 0) in vec4 aVertex; -layout(location = 1) in vec3 aNormal; - -layout(location = 0) out vec3 vNormal; -layout(location = 1) out vec3 vRotDeg; -layout(location = 2) out vec3 vRotRad; -layout(location = 3) out ivec2 vLSB; -layout(location = 4) out ivec2 vMSB; - -void main() -{ - gl_Position = inverse(uMVP) * aVertex; - vNormal = aNormal; - vRotDeg = degrees(rotRad); - vRotRad = radians(rotDeg); - vLSB = findLSB(bits); - vMSB = findMSB(bits); -} diff --git a/deps/SPIRV-Cross/shaders-msl/vert/out_block.vert b/deps/SPIRV-Cross/shaders-msl/vert/out_block.vert deleted file mode 100644 index d7a50c783d..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/vert/out_block.vert +++ /dev/null @@ -1,22 +0,0 @@ -#version 450 - -uniform Transform -{ - mat4 transform; -} block; - -layout(location = 0) in vec3 position; -layout(location = 1) in vec4 color; - -layout(location = 2) out VertexOut -{ - vec4 color; - vec4 color2; -} outputs; - -void main() -{ - gl_Position = block.transform * vec4(position, 1.0); - outputs.color = color; - outputs.color2 = color + vec4(1.0); -} diff --git a/deps/SPIRV-Cross/shaders-msl/vert/pointsize.vert b/deps/SPIRV-Cross/shaders-msl/vert/pointsize.vert deleted file mode 100644 index 0fc7136387..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/vert/pointsize.vert +++ /dev/null @@ -1,15 +0,0 @@ -#version 450 -uniform params { - mat4 mvp; - float psize; -}; - -layout(location = 0) in vec4 position; -layout(location = 1) in vec4 color0; -layout(location = 0) out vec4 color; - -void main() { - gl_Position = mvp * position; - gl_PointSize = psize; - color = color0; -} diff --git a/deps/SPIRV-Cross/shaders-msl/vert/texture_buffer.vert b/deps/SPIRV-Cross/shaders-msl/vert/texture_buffer.vert deleted file mode 100644 index 6bc7ddfae2..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/vert/texture_buffer.vert +++ /dev/null @@ -1,10 +0,0 @@ -#version 310 es -#extension GL_OES_texture_buffer : require - -layout(binding = 4) uniform highp samplerBuffer uSamp; -layout(rgba32f, binding = 5) uniform readonly highp imageBuffer uSampo; - -void main() -{ - gl_Position = texelFetch(uSamp, 10) + imageLoad(uSampo, 100); -} diff --git a/deps/SPIRV-Cross/shaders-msl/vert/ubo.alignment.vert b/deps/SPIRV-Cross/shaders-msl/vert/ubo.alignment.vert deleted file mode 100644 index 2e9d16df43..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/vert/ubo.alignment.vert +++ /dev/null @@ -1,23 +0,0 @@ -#version 310 es - -layout(binding = 0, std140) uniform UBO -{ - mat4 mvp; - vec2 targSize; - vec3 color; // vec3 following vec2 should cause MSL to add pad if float3 is packed - float opacity; // Single float following vec3 should cause MSL float3 to pack -}; - -layout(location = 0) in vec4 aVertex; -layout(location = 1) in vec3 aNormal; -layout(location = 0) out vec3 vNormal; -layout(location = 1) out vec3 vColor; -layout(location = 2) out vec2 vSize; - -void main() -{ - gl_Position = mvp * aVertex; - vNormal = aNormal; - vColor = color * opacity; - vSize = targSize * opacity; -} diff --git a/deps/SPIRV-Cross/shaders-msl/vert/ubo.vert b/deps/SPIRV-Cross/shaders-msl/vert/ubo.vert deleted file mode 100644 index 82e4626e12..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/vert/ubo.vert +++ /dev/null @@ -1,16 +0,0 @@ -#version 310 es - -layout(binding = 0, std140) uniform UBO -{ - mat4 mvp; -}; - -layout(location = 0) in vec4 aVertex; -layout(location = 1) in vec3 aNormal; -layout(location = 0) out vec3 vNormal; - -void main() -{ - gl_Position = mvp * aVertex; - vNormal = aNormal; -} diff --git a/deps/SPIRV-Cross/shaders-msl/vulkan/frag/push-constant.vk.frag b/deps/SPIRV-Cross/shaders-msl/vulkan/frag/push-constant.vk.frag deleted file mode 100644 index 6180faba31..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/vulkan/frag/push-constant.vk.frag +++ /dev/null @@ -1,16 +0,0 @@ -#version 310 es -precision mediump float; - -layout(push_constant, std430) uniform PushConstants -{ - vec4 value0; - vec4 value1; -} push; - -layout(location = 0) in vec4 vColor; -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = vColor + push.value0 + push.value1; -} diff --git a/deps/SPIRV-Cross/shaders-msl/vulkan/frag/spec-constant.vk.frag b/deps/SPIRV-Cross/shaders-msl/vulkan/frag/spec-constant.vk.frag deleted file mode 100644 index 3cb75da5c0..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/vulkan/frag/spec-constant.vk.frag +++ /dev/null @@ -1,67 +0,0 @@ -#version 310 es -precision mediump float; - -layout(location = 0) out vec4 FragColor; -layout(constant_id = 1) const float a = 1.0; -layout(constant_id = 2) const float b = 2.0; -layout(constant_id = 3) const int c = 3; -layout(constant_id = 4) const int d = 4; -layout(constant_id = 5) const uint e = 5u; -layout(constant_id = 6) const uint f = 6u; -layout(constant_id = 7) const bool g = false; -layout(constant_id = 8) const bool h = true; -// glslang doesn't seem to support partial spec constants or composites yet, so only test the basics. - -void main() -{ - float t0 = a; - float t1 = b; - - uint c0 = uint(c); // OpIAdd with different types. - // FConvert, float-to-double. - int c1 = -c; // SNegate - int c2 = ~c; // OpNot - int c3 = c + d; // OpIAdd - int c4 = c - d; // OpISub - int c5 = c * d; // OpIMul - int c6 = c / d; // OpSDiv - uint c7 = e / f; // OpUDiv - int c8 = c % d; // OpSMod - uint c9 = e % f; // OpUMod - // TODO: OpSRem, any way to access this in GLSL? - int c10 = c >> d; // OpShiftRightArithmetic - uint c11 = e >> f; // OpShiftRightLogical - int c12 = c << d; // OpShiftLeftLogical - int c13 = c | d; // OpBitwiseOr - int c14 = c ^ d; // OpBitwiseXor - int c15 = c & d; // OpBitwiseAnd - // VectorShuffle, CompositeExtract, CompositeInsert, not testable atm. - bool c16 = g || h; // OpLogicalOr - bool c17 = g && h; // OpLogicalAnd - bool c18 = !g; // OpLogicalNot - bool c19 = g == h; // OpLogicalEqual - bool c20 = g != h; // OpLogicalNotEqual - // OpSelect not testable atm. - bool c21 = c == d; // OpIEqual - bool c22 = c != d; // OpINotEqual - bool c23 = c < d; // OpSLessThan - bool c24 = e < f; // OpULessThan - bool c25 = c > d; // OpSGreaterThan - bool c26 = e > f; // OpUGreaterThan - bool c27 = c <= d; // OpSLessThanEqual - bool c28 = e <= f; // OpULessThanEqual - bool c29 = c >= d; // OpSGreaterThanEqual - bool c30 = e >= f; // OpUGreaterThanEqual - // OpQuantizeToF16 not testable atm. - - int c31 = c8 + c3; - - int c32 = int(e); // OpIAdd with different types. - bool c33 = bool(c); // int -> bool - bool c34 = bool(e); // uint -> bool - int c35 = int(g); // bool -> int - uint c36 = uint(g); // bool -> uint - float c37 = float(g); // bool -> float - - FragColor = vec4(t0 + t1); -} diff --git a/deps/SPIRV-Cross/shaders-msl/vulkan/vert/vulkan-vertex.vk.vert b/deps/SPIRV-Cross/shaders-msl/vulkan/vert/vulkan-vertex.vk.vert deleted file mode 100644 index 4d0438ace6..0000000000 --- a/deps/SPIRV-Cross/shaders-msl/vulkan/vert/vulkan-vertex.vk.vert +++ /dev/null @@ -1,6 +0,0 @@ -#version 310 es - -void main() -{ - gl_Position = float(gl_VertexIndex + gl_InstanceIndex) * vec4(1.0, 2.0, 3.0, 4.0); -} diff --git a/deps/SPIRV-Cross/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag b/deps/SPIRV-Cross/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag deleted file mode 100644 index a3f03664ca..0000000000 --- a/deps/SPIRV-Cross/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag +++ /dev/null @@ -1,10 +0,0 @@ -#version 450 -#extension GL_AMD_shader_fragment_mask : require - -layout(input_attachment_index = 0, binding = 0) uniform subpassInputMS t; - -void main () -{ - vec4 test2 = fragmentFetchAMD(t, 4); - uint testi2 = fragmentMaskFetchAMD(t); -} diff --git a/deps/SPIRV-Cross/shaders/amd/fs.invalid.frag b/deps/SPIRV-Cross/shaders/amd/fs.invalid.frag deleted file mode 100644 index 8cbd73e336..0000000000 --- a/deps/SPIRV-Cross/shaders/amd/fs.invalid.frag +++ /dev/null @@ -1,14 +0,0 @@ -#version 450 -#extension GL_AMD_shader_fragment_mask : require -#extension GL_AMD_shader_explicit_vertex_parameter : require - -uniform sampler2DMS texture1; -layout(location = 0) in vec4 vary; - -void main() -{ - uint testi1 = fragmentMaskFetchAMD(texture1, ivec2(0)); - vec4 test1 = fragmentFetchAMD(texture1, ivec2(1), 2); - - vec4 pos = interpolateAtVertexAMD(vary, 0u); -} diff --git a/deps/SPIRV-Cross/shaders/amd/gcn_shader.comp b/deps/SPIRV-Cross/shaders/amd/gcn_shader.comp deleted file mode 100644 index 037cdde6b6..0000000000 --- a/deps/SPIRV-Cross/shaders/amd/gcn_shader.comp +++ /dev/null @@ -1,13 +0,0 @@ -#version 450 -#extension GL_AMD_gcn_shader : require -#extension GL_ARB_gpu_shader_int64 : require - -layout (local_size_x = 64) in; - -void main () -{ - float cubeFace = cubeFaceIndexAMD(vec3(0.0)); - vec2 cubeFaceCoord = cubeFaceCoordAMD(vec3(1.0)); - - uint64_t time = timeAMD(); -} diff --git a/deps/SPIRV-Cross/shaders/amd/shader_ballot.comp b/deps/SPIRV-Cross/shaders/amd/shader_ballot.comp deleted file mode 100644 index d2a7271128..0000000000 --- a/deps/SPIRV-Cross/shaders/amd/shader_ballot.comp +++ /dev/null @@ -1,33 +0,0 @@ -#version 450 -#extension GL_AMD_shader_ballot : require -#extension GL_ARB_shader_ballot : require - -layout (local_size_x = 64) in; -layout (std430, binding = 0) buffer inputData -{ - float inputDataArray[]; -}; - -layout (std430, binding = 1) buffer outputData -{ - float outputDataArray[]; -}; - -void main () -{ - float thisLaneData = inputDataArray [gl_LocalInvocationID.x]; - bool laneActive = (thisLaneData > 0); - - uint thisLaneOutputSlot = mbcntAMD (ballotARB (laneActive)); - - int firstInvocation = readFirstInvocationARB(1); - int invocation = readInvocationARB(1, 0); - - vec3 swizzleInvocations = swizzleInvocationsAMD(vec3(0.0, 2.0, 1.0), uvec4(3)); - vec3 swizzelInvocationsMasked = swizzleInvocationsMaskedAMD(vec3(0.0, 2.0, 1.0), uvec3(2)); - vec3 writeInvocation = writeInvocationAMD(swizzleInvocations, swizzelInvocationsMasked, 0); - - if (laneActive) { - outputDataArray[thisLaneOutputSlot] = thisLaneData; - } -} diff --git a/deps/SPIRV-Cross/shaders/amd/shader_ballot_nonuniform_invocations.invalid.comp b/deps/SPIRV-Cross/shaders/amd/shader_ballot_nonuniform_invocations.invalid.comp deleted file mode 100644 index afcc31d99e..0000000000 --- a/deps/SPIRV-Cross/shaders/amd/shader_ballot_nonuniform_invocations.invalid.comp +++ /dev/null @@ -1,9 +0,0 @@ -#version 450 -#extension GL_AMD_shader_ballot : require - -void main () -{ - float addInvocations = addInvocationsNonUniformAMD(0.0); - int minInvocations = minInvocationsNonUniformAMD(1); - uint maxInvocations = maxInvocationsNonUniformAMD(4); -} diff --git a/deps/SPIRV-Cross/shaders/amd/shader_group_vote.comp b/deps/SPIRV-Cross/shaders/amd/shader_group_vote.comp deleted file mode 100644 index d24aa92f84..0000000000 --- a/deps/SPIRV-Cross/shaders/amd/shader_group_vote.comp +++ /dev/null @@ -1,18 +0,0 @@ -#version 450 -#extension GL_ARB_shader_group_vote : require - -layout (local_size_x = 64) in; -layout (std430, binding = 0) buffer inputData -{ - float inputDataArray[]; -}; - -void main () -{ - float thisLaneData = inputDataArray [gl_LocalInvocationID.x]; - bool laneActive = (thisLaneData > 0); - - bool allInvocations = allInvocationsARB(laneActive); - bool anyInvocations = anyInvocationARB(laneActive); - bool allInvocationsEqual = allInvocationsEqualARB(laneActive); -} diff --git a/deps/SPIRV-Cross/shaders/amd/shader_trinary_minmax.comp b/deps/SPIRV-Cross/shaders/amd/shader_trinary_minmax.comp deleted file mode 100644 index f836146a17..0000000000 --- a/deps/SPIRV-Cross/shaders/amd/shader_trinary_minmax.comp +++ /dev/null @@ -1,11 +0,0 @@ -#version 450 -#extension GL_AMD_shader_trinary_minmax : require - -layout (local_size_x = 64) in; - -void main () -{ - int t11 = min3(0, 3, 2); - int t12 = max3(0, 3, 2); - int t13 = mid3(0, 3, 2); -} diff --git a/deps/SPIRV-Cross/shaders/asm/comp/bitcast_iadd.asm.comp b/deps/SPIRV-Cross/shaders/asm/comp/bitcast_iadd.asm.comp deleted file mode 100644 index 3b31ab2851..0000000000 --- a/deps/SPIRV-Cross/shaders/asm/comp/bitcast_iadd.asm.comp +++ /dev/null @@ -1,79 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 1 -; Bound: 30 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint GLCompute %func "main" - OpExecutionMode %func LocalSize 1 1 1 - OpSource ESSL 310 - OpSourceExtension "GL_GOOGLE_cpp_style_line_directive" - OpSourceExtension "GL_GOOGLE_include_directive" - OpMemberDecorate %input_struct 0 Offset 0 - OpMemberDecorate %input_struct 1 Offset 16 - OpMemberDecorate %output_struct 0 Offset 0 - OpMemberDecorate %output_struct 1 Offset 16 - OpDecorate %input_struct BufferBlock - OpDecorate %inputs DescriptorSet 0 - OpDecorate %inputs Binding 0 - OpDecorate %inputs Restrict - OpDecorate %output_struct BufferBlock - OpDecorate %outputs DescriptorSet 0 - OpDecorate %outputs Binding 1 - OpDecorate %outputs Restrict - - %void = OpTypeVoid - %main_func = OpTypeFunction %void - - %uint = OpTypeInt 32 0 - %uvec4 = OpTypeVector %uint 4 - - %int = OpTypeInt 32 1 - %ivec4 = OpTypeVector %int 4 - - %ivec4_ptr = OpTypePointer Uniform %ivec4 - %uvec4_ptr = OpTypePointer Uniform %uvec4 - - %zero = OpConstant %int 0 - %one = OpConstant %int 1 - - %input_struct = OpTypeStruct %ivec4 %uvec4 - %input_struct_ptr = OpTypePointer Uniform %input_struct - %inputs = OpVariable %input_struct_ptr Uniform - %output_struct = OpTypeStruct %uvec4 %ivec4 - %output_struct_ptr = OpTypePointer Uniform %output_struct - %outputs = OpVariable %output_struct_ptr Uniform - - %func = OpFunction %void None %main_func - %block = OpLabel - - %input1_ptr = OpAccessChain %ivec4_ptr %inputs %zero - %input0_ptr = OpAccessChain %uvec4_ptr %inputs %one - %input1 = OpLoad %ivec4 %input1_ptr - %input0 = OpLoad %uvec4 %input0_ptr - - %output_ptr_uvec4 = OpAccessChain %uvec4_ptr %outputs %zero - %output_ptr_ivec4 = OpAccessChain %ivec4_ptr %outputs %one - -; Test all variants of IAdd - %result_iadd_0 = OpIAdd %uvec4 %input0 %input1 - %result_iadd_1 = OpIAdd %uvec4 %input1 %input0 - %result_iadd_2 = OpIAdd %uvec4 %input0 %input0 - %result_iadd_3 = OpIAdd %uvec4 %input1 %input1 - %result_iadd_4 = OpIAdd %ivec4 %input0 %input0 - %result_iadd_5 = OpIAdd %ivec4 %input1 %input1 - %result_iadd_6 = OpIAdd %ivec4 %input0 %input1 - %result_iadd_7 = OpIAdd %ivec4 %input1 %input0 - OpStore %output_ptr_uvec4 %result_iadd_0 - OpStore %output_ptr_uvec4 %result_iadd_1 - OpStore %output_ptr_uvec4 %result_iadd_2 - OpStore %output_ptr_uvec4 %result_iadd_3 - OpStore %output_ptr_ivec4 %result_iadd_4 - OpStore %output_ptr_ivec4 %result_iadd_5 - OpStore %output_ptr_ivec4 %result_iadd_6 - OpStore %output_ptr_ivec4 %result_iadd_7 - - OpReturn - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders/asm/comp/bitcast_iequal.asm.comp b/deps/SPIRV-Cross/shaders/asm/comp/bitcast_iequal.asm.comp deleted file mode 100644 index c98f52c5ad..0000000000 --- a/deps/SPIRV-Cross/shaders/asm/comp/bitcast_iequal.asm.comp +++ /dev/null @@ -1,90 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 1 -; Bound: 30 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint GLCompute %func "main" - OpExecutionMode %func LocalSize 1 1 1 - OpSource ESSL 310 - OpSourceExtension "GL_GOOGLE_cpp_style_line_directive" - OpSourceExtension "GL_GOOGLE_include_directive" - OpMemberDecorate %input_struct 0 Offset 0 - OpMemberDecorate %input_struct 1 Offset 16 - OpMemberDecorate %output_struct 0 Offset 0 - OpMemberDecorate %output_struct 1 Offset 16 - OpDecorate %input_struct BufferBlock - OpDecorate %inputs DescriptorSet 0 - OpDecorate %inputs Binding 0 - OpDecorate %output_struct BufferBlock - OpDecorate %outputs DescriptorSet 0 - OpDecorate %outputs Binding 1 - - %void = OpTypeVoid - %main_func = OpTypeFunction %void - - %uint = OpTypeInt 32 0 - %uvec4 = OpTypeVector %uint 4 - - %int = OpTypeInt 32 1 - %ivec4 = OpTypeVector %int 4 - %bool = OpTypeBool - %bvec4 = OpTypeVector %bool 4 - - %ivec4_ptr = OpTypePointer Uniform %ivec4 - %uvec4_ptr = OpTypePointer Uniform %uvec4 - - %zero = OpConstant %int 0 - %one = OpConstant %int 1 - %uone = OpConstant %uint 1 - %uzero = OpConstant %uint 0 - %uvec41 = OpConstantComposite %uvec4 %uone %uone %uone %uone - %ivec41 = OpConstantComposite %ivec4 %one %one %one %one - %uvec40 = OpConstantComposite %uvec4 %uzero %uzero %uzero %uzero - %ivec40 = OpConstantComposite %ivec4 %zero %zero %zero %zero - - %input_struct = OpTypeStruct %ivec4 %uvec4 - %input_struct_ptr = OpTypePointer Uniform %input_struct - %inputs = OpVariable %input_struct_ptr Uniform - %output_struct = OpTypeStruct %uvec4 %ivec4 - %output_struct_ptr = OpTypePointer Uniform %output_struct - %outputs = OpVariable %output_struct_ptr Uniform - - %func = OpFunction %void None %main_func - %block = OpLabel - - %input1_ptr = OpAccessChain %ivec4_ptr %inputs %zero - %input0_ptr = OpAccessChain %uvec4_ptr %inputs %one - %input1 = OpLoad %ivec4 %input1_ptr - %input0 = OpLoad %uvec4 %input0_ptr - - %output_ptr_uvec4 = OpAccessChain %uvec4_ptr %outputs %zero - %output_ptr_ivec4 = OpAccessChain %ivec4_ptr %outputs %one - -; Test all variants of IEqual - %result_iequal0 = OpIEqual %bvec4 %input0 %input1 - %result_iequal1 = OpIEqual %bvec4 %input1 %input0 - %result_iequal2 = OpIEqual %bvec4 %input0 %input0 - %result_iequal3 = OpIEqual %bvec4 %input1 %input1 - %result_0 = OpSelect %uvec4 %result_iequal0 %uvec41 %uvec40 - %result_1 = OpSelect %uvec4 %result_iequal1 %uvec41 %uvec40 - %result_2 = OpSelect %uvec4 %result_iequal2 %uvec41 %uvec40 - %result_3 = OpSelect %uvec4 %result_iequal3 %uvec41 %uvec40 - %result_4 = OpSelect %ivec4 %result_iequal0 %ivec41 %ivec40 - %result_5 = OpSelect %ivec4 %result_iequal1 %ivec41 %ivec40 - %result_6 = OpSelect %ivec4 %result_iequal2 %ivec41 %ivec40 - %result_7 = OpSelect %ivec4 %result_iequal3 %ivec41 %ivec40 - - OpStore %output_ptr_uvec4 %result_0 - OpStore %output_ptr_uvec4 %result_1 - OpStore %output_ptr_uvec4 %result_2 - OpStore %output_ptr_uvec4 %result_3 - OpStore %output_ptr_ivec4 %result_4 - OpStore %output_ptr_ivec4 %result_5 - OpStore %output_ptr_ivec4 %result_6 - OpStore %output_ptr_ivec4 %result_7 - - OpReturn - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders/asm/comp/bitcast_sar.asm.comp b/deps/SPIRV-Cross/shaders/asm/comp/bitcast_sar.asm.comp deleted file mode 100644 index 64f19fc349..0000000000 --- a/deps/SPIRV-Cross/shaders/asm/comp/bitcast_sar.asm.comp +++ /dev/null @@ -1,77 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 1 -; Bound: 30 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint GLCompute %func "main" - OpExecutionMode %func LocalSize 1 1 1 - OpSource ESSL 310 - OpSourceExtension "GL_GOOGLE_cpp_style_line_directive" - OpSourceExtension "GL_GOOGLE_include_directive" - OpMemberDecorate %input_struct 0 Offset 0 - OpMemberDecorate %input_struct 1 Offset 16 - OpMemberDecorate %output_struct 0 Offset 0 - OpMemberDecorate %output_struct 1 Offset 16 - OpDecorate %input_struct BufferBlock - OpDecorate %inputs DescriptorSet 0 - OpDecorate %inputs Binding 0 - OpDecorate %output_struct BufferBlock - OpDecorate %outputs DescriptorSet 0 - OpDecorate %outputs Binding 1 - - %void = OpTypeVoid - %main_func = OpTypeFunction %void - - %uint = OpTypeInt 32 0 - %uvec4 = OpTypeVector %uint 4 - - %int = OpTypeInt 32 1 - %ivec4 = OpTypeVector %int 4 - - %ivec4_ptr = OpTypePointer Uniform %ivec4 - %uvec4_ptr = OpTypePointer Uniform %uvec4 - - %zero = OpConstant %int 0 - %one = OpConstant %int 1 - - %input_struct = OpTypeStruct %ivec4 %uvec4 - %input_struct_ptr = OpTypePointer Uniform %input_struct - %inputs = OpVariable %input_struct_ptr Uniform - %output_struct = OpTypeStruct %uvec4 %ivec4 - %output_struct_ptr = OpTypePointer Uniform %output_struct - %outputs = OpVariable %output_struct_ptr Uniform - - %func = OpFunction %void None %main_func - %block = OpLabel - - %input1_ptr = OpAccessChain %ivec4_ptr %inputs %zero - %input0_ptr = OpAccessChain %uvec4_ptr %inputs %one - %input1 = OpLoad %ivec4 %input1_ptr - %input0 = OpLoad %uvec4 %input0_ptr - - %output_ptr_uvec4 = OpAccessChain %uvec4_ptr %outputs %zero - %output_ptr_ivec4 = OpAccessChain %ivec4_ptr %outputs %one - -; Test all variants of ShiftRightArithmetic - %result_iadd_0 = OpShiftRightArithmetic %uvec4 %input0 %input1 - %result_iadd_1 = OpShiftRightArithmetic %uvec4 %input1 %input0 - %result_iadd_2 = OpShiftRightArithmetic %uvec4 %input0 %input0 - %result_iadd_3 = OpShiftRightArithmetic %uvec4 %input1 %input1 - %result_iadd_4 = OpShiftRightArithmetic %ivec4 %input0 %input0 - %result_iadd_5 = OpShiftRightArithmetic %ivec4 %input1 %input1 - %result_iadd_6 = OpShiftRightArithmetic %ivec4 %input0 %input1 - %result_iadd_7 = OpShiftRightArithmetic %ivec4 %input1 %input0 - OpStore %output_ptr_uvec4 %result_iadd_0 - OpStore %output_ptr_uvec4 %result_iadd_1 - OpStore %output_ptr_uvec4 %result_iadd_2 - OpStore %output_ptr_uvec4 %result_iadd_3 - OpStore %output_ptr_ivec4 %result_iadd_4 - OpStore %output_ptr_ivec4 %result_iadd_5 - OpStore %output_ptr_ivec4 %result_iadd_6 - OpStore %output_ptr_ivec4 %result_iadd_7 - - OpReturn - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders/asm/comp/bitcast_sdiv.asm.comp b/deps/SPIRV-Cross/shaders/asm/comp/bitcast_sdiv.asm.comp deleted file mode 100644 index ab73ec83df..0000000000 --- a/deps/SPIRV-Cross/shaders/asm/comp/bitcast_sdiv.asm.comp +++ /dev/null @@ -1,77 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 1 -; Bound: 30 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint GLCompute %func "main" - OpExecutionMode %func LocalSize 1 1 1 - OpSource ESSL 310 - OpSourceExtension "GL_GOOGLE_cpp_style_line_directive" - OpSourceExtension "GL_GOOGLE_include_directive" - OpMemberDecorate %input_struct 0 Offset 0 - OpMemberDecorate %input_struct 1 Offset 16 - OpMemberDecorate %output_struct 0 Offset 0 - OpMemberDecorate %output_struct 1 Offset 16 - OpDecorate %input_struct BufferBlock - OpDecorate %inputs DescriptorSet 0 - OpDecorate %inputs Binding 0 - OpDecorate %output_struct BufferBlock - OpDecorate %outputs DescriptorSet 0 - OpDecorate %outputs Binding 1 - - %void = OpTypeVoid - %main_func = OpTypeFunction %void - - %uint = OpTypeInt 32 0 - %uvec4 = OpTypeVector %uint 4 - - %int = OpTypeInt 32 1 - %ivec4 = OpTypeVector %int 4 - - %ivec4_ptr = OpTypePointer Uniform %ivec4 - %uvec4_ptr = OpTypePointer Uniform %uvec4 - - %zero = OpConstant %int 0 - %one = OpConstant %int 1 - - %input_struct = OpTypeStruct %ivec4 %uvec4 - %input_struct_ptr = OpTypePointer Uniform %input_struct - %inputs = OpVariable %input_struct_ptr Uniform - %output_struct = OpTypeStruct %uvec4 %ivec4 - %output_struct_ptr = OpTypePointer Uniform %output_struct - %outputs = OpVariable %output_struct_ptr Uniform - - %func = OpFunction %void None %main_func - %block = OpLabel - - %input1_ptr = OpAccessChain %ivec4_ptr %inputs %zero - %input0_ptr = OpAccessChain %uvec4_ptr %inputs %one - %input1 = OpLoad %ivec4 %input1_ptr - %input0 = OpLoad %uvec4 %input0_ptr - - %output_ptr_uvec4 = OpAccessChain %uvec4_ptr %outputs %zero - %output_ptr_ivec4 = OpAccessChain %ivec4_ptr %outputs %one - -; Test all variants of SDiv - %result_iadd_0 = OpSDiv %uvec4 %input0 %input1 - %result_iadd_1 = OpSDiv %uvec4 %input1 %input0 - %result_iadd_2 = OpSDiv %uvec4 %input0 %input0 - %result_iadd_3 = OpSDiv %uvec4 %input1 %input1 - %result_iadd_4 = OpSDiv %ivec4 %input0 %input0 - %result_iadd_5 = OpSDiv %ivec4 %input1 %input1 - %result_iadd_6 = OpSDiv %ivec4 %input0 %input1 - %result_iadd_7 = OpSDiv %ivec4 %input1 %input0 - OpStore %output_ptr_uvec4 %result_iadd_0 - OpStore %output_ptr_uvec4 %result_iadd_1 - OpStore %output_ptr_uvec4 %result_iadd_2 - OpStore %output_ptr_uvec4 %result_iadd_3 - OpStore %output_ptr_ivec4 %result_iadd_4 - OpStore %output_ptr_ivec4 %result_iadd_5 - OpStore %output_ptr_ivec4 %result_iadd_6 - OpStore %output_ptr_ivec4 %result_iadd_7 - - OpReturn - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders/asm/comp/bitcast_slr.asm.comp b/deps/SPIRV-Cross/shaders/asm/comp/bitcast_slr.asm.comp deleted file mode 100644 index 6741f5cb58..0000000000 --- a/deps/SPIRV-Cross/shaders/asm/comp/bitcast_slr.asm.comp +++ /dev/null @@ -1,77 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 1 -; Bound: 30 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint GLCompute %func "main" - OpExecutionMode %func LocalSize 1 1 1 - OpSource ESSL 310 - OpSourceExtension "GL_GOOGLE_cpp_style_line_directive" - OpSourceExtension "GL_GOOGLE_include_directive" - OpMemberDecorate %input_struct 0 Offset 0 - OpMemberDecorate %input_struct 1 Offset 16 - OpMemberDecorate %output_struct 0 Offset 0 - OpMemberDecorate %output_struct 1 Offset 16 - OpDecorate %input_struct BufferBlock - OpDecorate %inputs DescriptorSet 0 - OpDecorate %inputs Binding 0 - OpDecorate %output_struct BufferBlock - OpDecorate %outputs DescriptorSet 0 - OpDecorate %outputs Binding 1 - - %void = OpTypeVoid - %main_func = OpTypeFunction %void - - %uint = OpTypeInt 32 0 - %uvec4 = OpTypeVector %uint 4 - - %int = OpTypeInt 32 1 - %ivec4 = OpTypeVector %int 4 - - %ivec4_ptr = OpTypePointer Uniform %ivec4 - %uvec4_ptr = OpTypePointer Uniform %uvec4 - - %zero = OpConstant %int 0 - %one = OpConstant %int 1 - - %input_struct = OpTypeStruct %ivec4 %uvec4 - %input_struct_ptr = OpTypePointer Uniform %input_struct - %inputs = OpVariable %input_struct_ptr Uniform - %output_struct = OpTypeStruct %uvec4 %ivec4 - %output_struct_ptr = OpTypePointer Uniform %output_struct - %outputs = OpVariable %output_struct_ptr Uniform - - %func = OpFunction %void None %main_func - %block = OpLabel - - %input1_ptr = OpAccessChain %ivec4_ptr %inputs %zero - %input0_ptr = OpAccessChain %uvec4_ptr %inputs %one - %input1 = OpLoad %ivec4 %input1_ptr - %input0 = OpLoad %uvec4 %input0_ptr - - %output_ptr_uvec4 = OpAccessChain %uvec4_ptr %outputs %zero - %output_ptr_ivec4 = OpAccessChain %ivec4_ptr %outputs %one - -; Test all variants of ShiftRightLogical - %result_iadd_0 = OpShiftRightLogical %uvec4 %input0 %input1 - %result_iadd_1 = OpShiftRightLogical %uvec4 %input1 %input0 - %result_iadd_2 = OpShiftRightLogical %uvec4 %input0 %input0 - %result_iadd_3 = OpShiftRightLogical %uvec4 %input1 %input1 - %result_iadd_4 = OpShiftRightLogical %ivec4 %input0 %input0 - %result_iadd_5 = OpShiftRightLogical %ivec4 %input1 %input1 - %result_iadd_6 = OpShiftRightLogical %ivec4 %input0 %input1 - %result_iadd_7 = OpShiftRightLogical %ivec4 %input1 %input0 - OpStore %output_ptr_uvec4 %result_iadd_0 - OpStore %output_ptr_uvec4 %result_iadd_1 - OpStore %output_ptr_uvec4 %result_iadd_2 - OpStore %output_ptr_uvec4 %result_iadd_3 - OpStore %output_ptr_ivec4 %result_iadd_4 - OpStore %output_ptr_ivec4 %result_iadd_5 - OpStore %output_ptr_ivec4 %result_iadd_6 - OpStore %output_ptr_ivec4 %result_iadd_7 - - OpReturn - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders/asm/comp/logical.asm.comp b/deps/SPIRV-Cross/shaders/asm/comp/logical.asm.comp deleted file mode 100644 index 4174e77f3d..0000000000 --- a/deps/SPIRV-Cross/shaders/asm/comp/logical.asm.comp +++ /dev/null @@ -1,191 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 1 -; Bound: 152 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint GLCompute %main "main" - OpExecutionMode %main LocalSize 1 1 1 - OpSource ESSL 310 - OpName %main "main" - OpName %and_b1_b1_ "and(b1;b1;" - OpName %a "a" - OpName %b "b" - OpName %and_vb2_vb2_ "and(vb2;vb2;" - OpName %a_0 "a" - OpName %b_0 "b" - OpName %and_vb3_vb3_ "and(vb3;vb3;" - OpName %a_1 "a" - OpName %b_1 "b" - OpName %and_vb4_vb4_ "and(vb4;vb4;" - OpName %a_2 "a" - OpName %b_2 "b" - OpName %b0 "b0" - OpName %SSBO0 "SSBO0" - OpMemberName %SSBO0 0 "a" - OpMemberName %SSBO0 1 "b" - OpMemberName %SSBO0 2 "c" - OpMemberName %SSBO0 3 "d" - OpName %s0 "s0" - OpName %SSBO1 "SSBO1" - OpMemberName %SSBO1 0 "a" - OpMemberName %SSBO1 1 "b" - OpMemberName %SSBO1 2 "c" - OpMemberName %SSBO1 3 "d" - OpName %s1 "s1" - OpName %param "param" - OpName %param_0 "param" - OpName %b1 "b1" - OpName %param_1 "param" - OpName %param_2 "param" - OpName %b2 "b2" - OpName %param_3 "param" - OpName %param_4 "param" - OpName %b3 "b3" - OpName %param_5 "param" - OpName %param_6 "param" - OpMemberDecorate %SSBO0 0 Offset 0 - OpMemberDecorate %SSBO0 1 Offset 8 - OpMemberDecorate %SSBO0 2 Offset 16 - OpMemberDecorate %SSBO0 3 Offset 32 - OpDecorate %SSBO0 BufferBlock - OpDecorate %s0 DescriptorSet 0 - OpDecorate %s0 Binding 0 - OpMemberDecorate %SSBO1 0 Offset 0 - OpMemberDecorate %SSBO1 1 Offset 8 - OpMemberDecorate %SSBO1 2 Offset 16 - OpMemberDecorate %SSBO1 3 Offset 32 - OpDecorate %SSBO1 BufferBlock - OpDecorate %s1 DescriptorSet 0 - OpDecorate %s1 Binding 1 - %void = OpTypeVoid - %3 = OpTypeFunction %void - %bool = OpTypeBool -%_ptr_Function_bool = OpTypePointer Function %bool - %8 = OpTypeFunction %bool %_ptr_Function_bool %_ptr_Function_bool - %v2bool = OpTypeVector %bool 2 -%_ptr_Function_v2bool = OpTypePointer Function %v2bool - %15 = OpTypeFunction %v2bool %_ptr_Function_v2bool %_ptr_Function_v2bool - %v3bool = OpTypeVector %bool 3 -%_ptr_Function_v3bool = OpTypePointer Function %v3bool - %22 = OpTypeFunction %v3bool %_ptr_Function_v3bool %_ptr_Function_v3bool - %v4bool = OpTypeVector %bool 4 -%_ptr_Function_v4bool = OpTypePointer Function %v4bool - %29 = OpTypeFunction %v4bool %_ptr_Function_v4bool %_ptr_Function_v4bool - %float = OpTypeFloat 32 - %v2float = OpTypeVector %float 2 - %v3float = OpTypeVector %float 3 - %v4float = OpTypeVector %float 4 - %SSBO0 = OpTypeStruct %float %v2float %v3float %v4float -%_ptr_Uniform_SSBO0 = OpTypePointer Uniform %SSBO0 - %s0 = OpVariable %_ptr_Uniform_SSBO0 Uniform - %int = OpTypeInt 32 1 - %102 = OpConstant %int 0 -%_ptr_Uniform_float = OpTypePointer Uniform %float - %SSBO1 = OpTypeStruct %float %v2float %v3float %v4float -%_ptr_Uniform_SSBO1 = OpTypePointer Uniform %SSBO1 - %s1 = OpVariable %_ptr_Uniform_SSBO1 Uniform - %117 = OpConstant %int 1 -%_ptr_Uniform_v2float = OpTypePointer Uniform %v2float - %129 = OpConstant %int 2 -%_ptr_Uniform_v3float = OpTypePointer Uniform %v3float - %141 = OpConstant %int 3 -%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float - %main = OpFunction %void None %3 - %5 = OpLabel - %b0 = OpVariable %_ptr_Function_bool Function - %param = OpVariable %_ptr_Function_bool Function - %param_0 = OpVariable %_ptr_Function_bool Function - %b1 = OpVariable %_ptr_Function_v2bool Function - %param_1 = OpVariable %_ptr_Function_v2bool Function - %param_2 = OpVariable %_ptr_Function_v2bool Function - %b2 = OpVariable %_ptr_Function_v3bool Function - %param_3 = OpVariable %_ptr_Function_v3bool Function - %param_4 = OpVariable %_ptr_Function_v3bool Function - %b3 = OpVariable %_ptr_Function_v4bool Function - %param_5 = OpVariable %_ptr_Function_v4bool Function - %param_6 = OpVariable %_ptr_Function_v4bool Function - %104 = OpAccessChain %_ptr_Uniform_float %s0 %102 - %105 = OpLoad %float %104 - %106 = OpIsInf %bool %105 - %110 = OpAccessChain %_ptr_Uniform_float %s1 %102 - %111 = OpLoad %float %110 - %112 = OpIsNan %bool %111 - OpStore %param %106 - OpStore %param_0 %112 - %115 = OpFunctionCall %bool %and_b1_b1_ %param %param_0 - OpStore %b0 %115 - %119 = OpAccessChain %_ptr_Uniform_v2float %s0 %117 - %120 = OpLoad %v2float %119 - %121 = OpIsInf %v2bool %120 - %122 = OpAccessChain %_ptr_Uniform_v2float %s1 %117 - %123 = OpLoad %v2float %122 - %124 = OpIsNan %v2bool %123 - OpStore %param_1 %121 - OpStore %param_2 %124 - %127 = OpFunctionCall %v2bool %and_vb2_vb2_ %param_1 %param_2 - OpStore %b1 %127 - %131 = OpAccessChain %_ptr_Uniform_v3float %s0 %129 - %132 = OpLoad %v3float %131 - %133 = OpIsInf %v3bool %132 - %134 = OpAccessChain %_ptr_Uniform_v3float %s1 %129 - %135 = OpLoad %v3float %134 - %136 = OpIsNan %v3bool %135 - OpStore %param_3 %133 - OpStore %param_4 %136 - %139 = OpFunctionCall %v3bool %and_vb3_vb3_ %param_3 %param_4 - OpStore %b2 %139 - %143 = OpAccessChain %_ptr_Uniform_v4float %s0 %141 - %144 = OpLoad %v4float %143 - %145 = OpIsInf %v4bool %144 - %146 = OpAccessChain %_ptr_Uniform_v4float %s1 %141 - %147 = OpLoad %v4float %146 - %148 = OpIsNan %v4bool %147 - OpStore %param_5 %145 - OpStore %param_6 %148 - %151 = OpFunctionCall %v4bool %and_vb4_vb4_ %param_5 %param_6 - OpStore %b3 %151 - OpReturn - OpFunctionEnd - %and_b1_b1_ = OpFunction %bool None %8 - %a = OpFunctionParameter %_ptr_Function_bool - %b = OpFunctionParameter %_ptr_Function_bool - %12 = OpLabel - %34 = OpLoad %bool %a - %35 = OpLoad %bool %b - %36 = OpLogicalAnd %bool %34 %35 - %37 = OpLogicalOr %bool %36 %35 - %38 = OpLogicalNot %bool %37 - OpReturnValue %38 - OpFunctionEnd -%and_vb2_vb2_ = OpFunction %v2bool None %15 - %a_0 = OpFunctionParameter %_ptr_Function_v2bool - %b_0 = OpFunctionParameter %_ptr_Function_v2bool - %19 = OpLabel - %39 = OpLoad %v2bool %a_0 - %41 = OpLoad %v2bool %b_0 - %48 = OpLogicalAnd %v2bool %39 %41 - %49 = OpLogicalOr %v2bool %48 %41 - %50 = OpLogicalNot %v2bool %49 - OpReturnValue %50 - OpFunctionEnd -%and_vb3_vb3_ = OpFunction %v3bool None %22 - %a_1 = OpFunctionParameter %_ptr_Function_v3bool - %b_1 = OpFunctionParameter %_ptr_Function_v3bool - %26 = OpLabel - %52 = OpLoad %v3bool %a_1 - %54 = OpLoad %v3bool %b_1 - %66 = OpLogicalAnd %v3bool %52 %54 - OpReturnValue %66 - OpFunctionEnd -%and_vb4_vb4_ = OpFunction %v4bool None %29 - %a_2 = OpFunctionParameter %_ptr_Function_v4bool - %b_2 = OpFunctionParameter %_ptr_Function_v4bool - %33 = OpLabel - %70 = OpLoad %v4bool %a_2 - %72 = OpLoad %v4bool %b_2 - %74 = OpLogicalAnd %v4bool %70 %72 - OpReturnValue %74 - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders/asm/comp/multiple-entry.asm.comp b/deps/SPIRV-Cross/shaders/asm/comp/multiple-entry.asm.comp deleted file mode 100644 index 0cfb5543d1..0000000000 --- a/deps/SPIRV-Cross/shaders/asm/comp/multiple-entry.asm.comp +++ /dev/null @@ -1,97 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 1 -; Bound: 30 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %func_alt "main2" %frag_in %frag_out - OpEntryPoint GLCompute %func "main" - OpExecutionMode %func LocalSize 1 1 1 - OpSource ESSL 310 - OpSourceExtension "GL_GOOGLE_cpp_style_line_directive" - OpSourceExtension "GL_GOOGLE_include_directive" - OpMemberDecorate %input_struct 0 Offset 0 - OpMemberDecorate %input_struct 1 Offset 16 - OpMemberDecorate %output_struct 0 Offset 0 - OpMemberDecorate %output_struct 1 Offset 16 - OpDecorate %input_struct BufferBlock - OpDecorate %inputs DescriptorSet 0 - OpDecorate %inputs Binding 0 - OpDecorate %inputs Restrict - OpDecorate %output_struct BufferBlock - OpDecorate %outputs DescriptorSet 0 - OpDecorate %outputs Binding 1 - OpDecorate %outputs Restrict - OpDecorate %frag_in Location 0 - OpDecorate %frag_out Location 0 - - %void = OpTypeVoid - %main_func = OpTypeFunction %void - - %uint = OpTypeInt 32 0 - %uvec4 = OpTypeVector %uint 4 - - %int = OpTypeInt 32 1 - %ivec4 = OpTypeVector %int 4 - - %ivec4_ptr = OpTypePointer Uniform %ivec4 - %uvec4_ptr = OpTypePointer Uniform %uvec4 - - %float = OpTypeFloat 32 - %vec4 = OpTypeVector %float 4 - %vec4_input_ptr = OpTypePointer Input %vec4 - %vec4_output_ptr = OpTypePointer Output %vec4 - - %zero = OpConstant %int 0 - %one = OpConstant %int 1 - - %input_struct = OpTypeStruct %ivec4 %uvec4 - %input_struct_ptr = OpTypePointer Uniform %input_struct - %inputs = OpVariable %input_struct_ptr Uniform - %output_struct = OpTypeStruct %uvec4 %ivec4 - %output_struct_ptr = OpTypePointer Uniform %output_struct - %outputs = OpVariable %output_struct_ptr Uniform - - %frag_in = OpVariable %vec4_input_ptr Input - %frag_out = OpVariable %vec4_output_ptr Output - - %func = OpFunction %void None %main_func - %block = OpLabel - - %input1_ptr = OpAccessChain %ivec4_ptr %inputs %zero - %input0_ptr = OpAccessChain %uvec4_ptr %inputs %one - %input1 = OpLoad %ivec4 %input1_ptr - %input0 = OpLoad %uvec4 %input0_ptr - - %output_ptr_uvec4 = OpAccessChain %uvec4_ptr %outputs %zero - %output_ptr_ivec4 = OpAccessChain %ivec4_ptr %outputs %one - -; Test all variants of IAdd - %result_iadd_0 = OpIAdd %uvec4 %input0 %input1 - %result_iadd_1 = OpIAdd %uvec4 %input1 %input0 - %result_iadd_2 = OpIAdd %uvec4 %input0 %input0 - %result_iadd_3 = OpIAdd %uvec4 %input1 %input1 - %result_iadd_4 = OpIAdd %ivec4 %input0 %input0 - %result_iadd_5 = OpIAdd %ivec4 %input1 %input1 - %result_iadd_6 = OpIAdd %ivec4 %input0 %input1 - %result_iadd_7 = OpIAdd %ivec4 %input1 %input0 - OpStore %output_ptr_uvec4 %result_iadd_0 - OpStore %output_ptr_uvec4 %result_iadd_1 - OpStore %output_ptr_uvec4 %result_iadd_2 - OpStore %output_ptr_uvec4 %result_iadd_3 - OpStore %output_ptr_ivec4 %result_iadd_4 - OpStore %output_ptr_ivec4 %result_iadd_5 - OpStore %output_ptr_ivec4 %result_iadd_6 - OpStore %output_ptr_ivec4 %result_iadd_7 - - OpReturn - OpFunctionEnd - - %func_alt = OpFunction %void None %main_func - %block_alt = OpLabel - %frag_input_value = OpLoad %vec4 %frag_in - OpStore %frag_out %frag_input_value - OpReturn - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders/asm/comp/name-alias.asm.invalid.comp b/deps/SPIRV-Cross/shaders/asm/comp/name-alias.asm.invalid.comp deleted file mode 100644 index f9bc6dbb67..0000000000 --- a/deps/SPIRV-Cross/shaders/asm/comp/name-alias.asm.invalid.comp +++ /dev/null @@ -1,124 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 1 -; Bound: 48 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint GLCompute %4 "main" - OpExecutionMode %4 LocalSize 1 1 1 - OpSource ESSL 310 - OpName %4 "alias" - OpName %15 "alias" - OpMemberName %15 0 "alias" - OpName %18 "alias" - OpMemberName %18 0 "alias" - OpMemberName %18 1 "alias" - OpMemberName %18 2 "alias" - OpName %19 "alias" - OpMemberName %19 0 "alias" - OpMemberName %19 1 "alias" - OpName %21 "alias" - OpName %24 "alias" - OpMemberName %24 0 "alias" - OpName %26 "alias" - OpMemberName %26 0 "alias" - OpMemberName %26 1 "alias" - OpMemberName %26 2 "alias" - OpName %27 "alias" - OpMemberName %27 0 "alias" - OpMemberName %27 1 "alias" - OpName %28 "alias" - OpMemberName %28 0 "alias" - OpName %30 "alias" - OpName %38 "alias" - OpMemberName %38 0 "alias" - OpName %40 "alias" - OpMemberName %40 0 "alias" - OpMemberName %40 1 "alias" - OpMemberName %40 2 "alias" - OpName %41 "alias" - OpMemberName %41 0 "alias" - OpMemberName %41 1 "alias" - OpName %42 "alias" - OpMemberName %42 0 "alias" - OpName %44 "alias" - OpDecorate %22 ArrayStride 8 - OpDecorate %23 ArrayStride 16 - OpMemberDecorate %24 0 Offset 0 - OpDecorate %25 ArrayStride 1600 - OpMemberDecorate %26 0 Offset 0 - OpMemberDecorate %26 1 Offset 16 - OpMemberDecorate %26 2 Offset 96 - OpMemberDecorate %27 0 Offset 0 - OpMemberDecorate %27 1 Offset 16 - OpMemberDecorate %28 0 Offset 0 - OpDecorate %28 BufferBlock - OpDecorate %30 DescriptorSet 0 - OpDecorate %30 Binding 0 - OpDecorate %36 ArrayStride 16 - OpDecorate %37 ArrayStride 16 - OpMemberDecorate %38 0 Offset 0 - OpDecorate %39 ArrayStride 1600 - OpMemberDecorate %40 0 Offset 0 - OpMemberDecorate %40 1 Offset 16 - OpMemberDecorate %40 2 Offset 176 - OpMemberDecorate %41 0 Offset 0 - OpMemberDecorate %41 1 Offset 16 - OpMemberDecorate %42 0 Offset 0 - OpDecorate %42 BufferBlock - OpDecorate %44 DescriptorSet 0 - OpDecorate %44 Binding 1 - %2 = OpTypeVoid - %3 = OpTypeFunction %2 - %6 = OpTypeFloat 32 - %7 = OpTypeVector %6 4 - %8 = OpTypeVector %6 2 - %9 = OpTypeInt 32 0 - %10 = OpConstant %9 10 - %11 = OpTypeArray %8 %10 - %12 = OpTypeVector %6 3 - %13 = OpConstant %9 100 - %14 = OpTypeArray %12 %13 - %15 = OpTypeStruct %14 - %16 = OpConstant %9 2 - %17 = OpTypeArray %15 %16 - %18 = OpTypeStruct %7 %11 %17 - %19 = OpTypeStruct %7 %18 - %20 = OpTypePointer Function %19 - %22 = OpTypeArray %8 %10 - %23 = OpTypeArray %12 %13 - %24 = OpTypeStruct %23 - %25 = OpTypeArray %24 %16 - %26 = OpTypeStruct %7 %22 %25 - %27 = OpTypeStruct %7 %26 - %28 = OpTypeStruct %27 - %29 = OpTypePointer Uniform %28 - %30 = OpVariable %29 Uniform - %31 = OpTypeInt 32 1 - %32 = OpConstant %31 0 - %33 = OpTypePointer Uniform %27 - %36 = OpTypeArray %8 %10 - %37 = OpTypeArray %12 %13 - %38 = OpTypeStruct %37 - %39 = OpTypeArray %38 %16 - %40 = OpTypeStruct %7 %36 %39 - %41 = OpTypeStruct %7 %40 - %42 = OpTypeStruct %41 - %43 = OpTypePointer Uniform %42 - %44 = OpVariable %43 Uniform - %46 = OpTypePointer Uniform %41 - %4 = OpFunction %2 None %3 - %5 = OpLabel - %21 = OpVariable %20 Function - %34 = OpAccessChain %33 %30 %32 - %35 = OpLoad %27 %34 -; This shader has an illegal aliased store for testing purposes. spirv-val is not run for this shader. - OpStore %21 %35 - %45 = OpLoad %19 %21 - %47 = OpAccessChain %46 %44 %32 -; This shader has an illegal aliased store for testing purposes. spirv-val is not run for this shader. - OpStore %47 %45 - OpReturn - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders/asm/comp/quantize.asm.comp b/deps/SPIRV-Cross/shaders/asm/comp/quantize.asm.comp deleted file mode 100644 index f5afc6570c..0000000000 --- a/deps/SPIRV-Cross/shaders/asm/comp/quantize.asm.comp +++ /dev/null @@ -1,67 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 1 -; Bound: 38 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint GLCompute %4 "main" - OpExecutionMode %4 LocalSize 1 1 1 - OpSource ESSL 310 - OpName %4 "main" - OpName %10 "SSBO0" - OpMemberName %10 0 "scalar" - OpMemberName %10 1 "vec2_val" - OpMemberName %10 2 "vec3_val" - OpMemberName %10 3 "vec4_val" - OpName %12 "" - OpMemberDecorate %10 0 Offset 0 - OpMemberDecorate %10 1 Offset 8 - OpMemberDecorate %10 2 Offset 16 - OpMemberDecorate %10 3 Offset 32 - OpDecorate %10 BufferBlock - OpDecorate %12 DescriptorSet 0 - OpDecorate %12 Binding 0 - %2 = OpTypeVoid - %3 = OpTypeFunction %2 - %6 = OpTypeFloat 32 - %7 = OpTypeVector %6 2 - %8 = OpTypeVector %6 3 - %9 = OpTypeVector %6 4 - %10 = OpTypeStruct %6 %7 %8 %9 - %11 = OpTypePointer Uniform %10 - %12 = OpVariable %11 Uniform - %13 = OpTypeInt 32 1 - %14 = OpConstant %13 0 - %15 = OpTypePointer Uniform %6 - %20 = OpConstant %13 1 - %21 = OpTypePointer Uniform %7 - %26 = OpConstant %13 2 - %27 = OpTypePointer Uniform %8 - %32 = OpConstant %13 3 - %33 = OpTypePointer Uniform %9 - %4 = OpFunction %2 None %3 - %5 = OpLabel - %16 = OpAccessChain %15 %12 %14 - %17 = OpLoad %6 %16 - %18 = OpQuantizeToF16 %6 %17 - %19 = OpAccessChain %15 %12 %14 - OpStore %19 %18 - %22 = OpAccessChain %21 %12 %20 - %23 = OpLoad %7 %22 - %24 = OpQuantizeToF16 %7 %23 - %25 = OpAccessChain %21 %12 %20 - OpStore %25 %24 - %28 = OpAccessChain %27 %12 %26 - %29 = OpLoad %8 %28 - %30 = OpQuantizeToF16 %8 %29 - %31 = OpAccessChain %27 %12 %26 - OpStore %31 %30 - %34 = OpAccessChain %33 %12 %32 - %35 = OpLoad %9 %34 - %36 = OpQuantizeToF16 %9 %35 - %37 = OpAccessChain %33 %12 %32 - OpStore %37 %36 - OpReturn - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders/asm/comp/specialization-constant-workgroup.asm.comp b/deps/SPIRV-Cross/shaders/asm/comp/specialization-constant-workgroup.asm.comp deleted file mode 100644 index 188e3fec36..0000000000 --- a/deps/SPIRV-Cross/shaders/asm/comp/specialization-constant-workgroup.asm.comp +++ /dev/null @@ -1,47 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 1 -; Bound: 24 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint GLCompute %main "main" - OpExecutionMode %main LocalSize 1 20 1 - OpSource ESSL 310 - OpName %main "main" - OpName %SSBO "SSBO" - OpMemberName %SSBO 0 "a" - OpName %_ "" - OpMemberDecorate %SSBO 0 Offset 0 - OpDecorate %SSBO BufferBlock - OpDecorate %_ DescriptorSet 0 - OpDecorate %_ Binding 0 - OpDecorate %19 SpecId 10 - OpDecorate %21 SpecId 12 - OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 - %SSBO = OpTypeStruct %float -%_ptr_Uniform_SSBO = OpTypePointer Uniform %SSBO - %_ = OpVariable %_ptr_Uniform_SSBO Uniform - %int = OpTypeInt 32 1 - %int_0 = OpConstant %int 0 - %float_1 = OpConstant %float 1 -%_ptr_Uniform_float = OpTypePointer Uniform %float - %uint = OpTypeInt 32 0 - %19 = OpSpecConstant %uint 9 - %uint_20 = OpConstant %uint 20 - %21 = OpSpecConstant %uint 4 - %v3uint = OpTypeVector %uint 3 -%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %19 %uint_20 %21 - %main = OpFunction %void None %3 - %5 = OpLabel - %14 = OpAccessChain %_ptr_Uniform_float %_ %int_0 - %15 = OpLoad %float %14 - %16 = OpFAdd %float %15 %float_1 - %17 = OpAccessChain %_ptr_Uniform_float %_ %int_0 - OpStore %17 %16 - OpReturn - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders/asm/comp/storage-buffer-basic.asm.comp b/deps/SPIRV-Cross/shaders/asm/comp/storage-buffer-basic.asm.comp deleted file mode 100644 index edb1a05e54..0000000000 --- a/deps/SPIRV-Cross/shaders/asm/comp/storage-buffer-basic.asm.comp +++ /dev/null @@ -1,57 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Codeplay; 0 -; Bound: 31 -; Schema: 0 - OpCapability Shader - OpCapability VariablePointers - OpExtension "SPV_KHR_storage_buffer_storage_class" - OpExtension "SPV_KHR_variable_pointers" - OpMemoryModel Logical GLSL450 - OpEntryPoint GLCompute %22 "main" %gl_WorkGroupID - OpSource OpenCL_C 120 - OpDecorate %15 SpecId 0 - ;OpDecorate %16 SpecId 1 - OpDecorate %17 SpecId 2 - OpDecorate %_runtimearr_float ArrayStride 4 - OpMemberDecorate %_struct_4 0 Offset 0 - OpDecorate %_struct_4 Block - OpDecorate %gl_WorkGroupID BuiltIn WorkgroupId - OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize - OpDecorate %20 DescriptorSet 0 - OpDecorate %20 Binding 0 - OpDecorate %21 DescriptorSet 0 - OpDecorate %21 Binding 1 - %float = OpTypeFloat 32 -%_ptr_StorageBuffer_float = OpTypePointer StorageBuffer %float -%_runtimearr_float = OpTypeRuntimeArray %float - %_struct_4 = OpTypeStruct %_runtimearr_float -%_ptr_StorageBuffer__struct_4 = OpTypePointer StorageBuffer %_struct_4 - %uint = OpTypeInt 32 0 - %void = OpTypeVoid - %8 = OpTypeFunction %void - %v3uint = OpTypeVector %uint 3 -%_ptr_Input_v3uint = OpTypePointer Input %v3uint -%_ptr_Input_uint = OpTypePointer Input %uint -%_ptr_Private_v3uint = OpTypePointer Private %v3uint - %uint_0 = OpConstant %uint 0 -%gl_WorkGroupID = OpVariable %_ptr_Input_v3uint Input - %15 = OpSpecConstant %uint 1 - %16 = OpConstant %uint 2 - %17 = OpSpecConstant %uint 3 -%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %15 %16 %17 - %19 = OpVariable %_ptr_Private_v3uint Private %gl_WorkGroupSize - %20 = OpVariable %_ptr_StorageBuffer__struct_4 StorageBuffer - %21 = OpVariable %_ptr_StorageBuffer__struct_4 StorageBuffer - %22 = OpFunction %void None %8 - %23 = OpLabel - %24 = OpAccessChain %_ptr_Input_uint %gl_WorkGroupID %uint_0 - %25 = OpLoad %uint %24 - %26 = OpAccessChain %_ptr_StorageBuffer_float %21 %uint_0 %25 - %27 = OpLoad %float %26 - %28 = OpAccessChain %_ptr_StorageBuffer_float %20 %uint_0 %25 - %29 = OpLoad %float %28 - %30 = OpFAdd %float %27 %29 - OpStore %28 %30 - OpReturn - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders/asm/frag/composite-construct-struct-no-swizzle.asm.frag b/deps/SPIRV-Cross/shaders/asm/frag/composite-construct-struct-no-swizzle.asm.frag deleted file mode 100644 index f33c48617a..0000000000 --- a/deps/SPIRV-Cross/shaders/asm/frag/composite-construct-struct-no-swizzle.asm.frag +++ /dev/null @@ -1,51 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 3 -; Bound: 39 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %main "main" %foo %FooOut - OpExecutionMode %main OriginUpperLeft - OpSource ESSL 310 - OpName %main "main" - OpName %foo "foo" - OpName %SwizzleTest "SwizzleTest" - OpMemberName %SwizzleTest 0 "a" - OpMemberName %SwizzleTest 1 "b" - OpName %FooOut "FooOut" - OpDecorate %foo RelaxedPrecision - OpDecorate %foo Location 0 - OpDecorate %12 RelaxedPrecision - OpMemberDecorate %SwizzleTest 0 RelaxedPrecision - OpMemberDecorate %SwizzleTest 1 RelaxedPrecision - OpDecorate %FooOut RelaxedPrecision - OpDecorate %FooOut Location 0 - OpDecorate %34 RelaxedPrecision - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 - %v2float = OpTypeVector %float 2 -%_ptr_Function_v2float = OpTypePointer Function %v2float -%_ptr_Input_v2float = OpTypePointer Input %v2float - %foo = OpVariable %_ptr_Input_v2float Input -%SwizzleTest = OpTypeStruct %float %float -%_ptr_Function_SwizzleTest = OpTypePointer Function %SwizzleTest - %uint = OpTypeInt 32 0 -%_ptr_Function_float = OpTypePointer Function %float -%_ptr_Output_float = OpTypePointer Output %float - %FooOut = OpVariable %_ptr_Output_float Output - %int = OpTypeInt 32 1 - %main = OpFunction %void None %3 - %5 = OpLabel - %12 = OpLoad %v2float %foo - %36 = OpCompositeExtract %float %12 0 - %38 = OpCompositeExtract %float %12 1 - %test0 = OpCompositeConstruct %SwizzleTest %36 %38 - %new0 = OpCompositeExtract %float %test0 0 - %new1 = OpCompositeExtract %float %test0 1 - %34 = OpFAdd %float %new0 %new1 - OpStore %FooOut %34 - OpReturn - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders/asm/frag/default-member-names.asm.frag b/deps/SPIRV-Cross/shaders/asm/frag/default-member-names.asm.frag deleted file mode 100644 index 4d616fe493..0000000000 --- a/deps/SPIRV-Cross/shaders/asm/frag/default-member-names.asm.frag +++ /dev/null @@ -1,57 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 1 -; Bound: 43 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %2 "main" %3 - OpExecutionMode %2 OriginLowerLeft - OpDecorate %3 Location 0 - %void = OpTypeVoid - %9 = OpTypeFunction %void - %float = OpTypeFloat 32 - %v4float = OpTypeVector %float 4 - %12 = OpTypeFunction %v4float - %_struct_5 = OpTypeStruct %float - %_struct_6 = OpTypeStruct %float %float %float %float %float %float %float %float %float %float %float %float %_struct_5 -%_ptr_Function__struct_6 = OpTypePointer Function %_struct_6 - %int = OpTypeInt 32 1 - %int_0 = OpConstant %int 0 -%_ptr_Function_float = OpTypePointer Function %float - %int_1 = OpConstant %int 1 - %int_2 = OpConstant %int 2 - %int_3 = OpConstant %int 3 -%_ptr_Output_v4float = OpTypePointer Output %v4float - %3 = OpVariable %_ptr_Output_v4float Output -%_ptr_Function_v4float = OpTypePointer Function %v4float - %2 = OpFunction %void None %9 - %22 = OpLabel - %23 = OpVariable %_ptr_Function__struct_6 Function - %24 = OpAccessChain %_ptr_Function_float %23 %int_0 - %25 = OpLoad %float %24 - %26 = OpAccessChain %_ptr_Function_float %23 %int_1 - %27 = OpLoad %float %26 - %28 = OpAccessChain %_ptr_Function_float %23 %int_2 - %29 = OpLoad %float %28 - %30 = OpAccessChain %_ptr_Function_float %23 %int_3 - %31 = OpLoad %float %30 - %32 = OpCompositeConstruct %v4float %25 %27 %29 %31 - OpStore %3 %32 - OpReturn - OpFunctionEnd - %4 = OpFunction %v4float None %12 - %33 = OpLabel - %7 = OpVariable %_ptr_Function__struct_6 Function - %34 = OpAccessChain %_ptr_Function_float %7 %int_0 - %35 = OpLoad %float %34 - %36 = OpAccessChain %_ptr_Function_float %7 %int_1 - %37 = OpLoad %float %36 - %38 = OpAccessChain %_ptr_Function_float %7 %int_2 - %39 = OpLoad %float %38 - %40 = OpAccessChain %_ptr_Function_float %7 %int_3 - %41 = OpLoad %float %40 - %42 = OpCompositeConstruct %v4float %35 %37 %39 %41 - OpReturnValue %42 - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders/asm/frag/hlsl-sample-cmp-level-zero-cube.asm.frag b/deps/SPIRV-Cross/shaders/asm/frag/hlsl-sample-cmp-level-zero-cube.asm.frag deleted file mode 100644 index 2be18cfeeb..0000000000 --- a/deps/SPIRV-Cross/shaders/asm/frag/hlsl-sample-cmp-level-zero-cube.asm.frag +++ /dev/null @@ -1,58 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 1 -; Bound: 38 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %main "main" %_entryPointOutput - OpExecutionMode %main OriginUpperLeft - OpSource HLSL 500 - OpName %main "main" - OpName %_main_ "@main(" - OpName %pointLightShadowMap "pointLightShadowMap" - OpName %shadowSamplerPCF "shadowSamplerPCF" - OpName %_entryPointOutput "@entryPointOutput" - OpDecorate %pointLightShadowMap DescriptorSet 0 - OpDecorate %shadowSamplerPCF DescriptorSet 0 - OpDecorate %_entryPointOutput Location 0 - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 - %7 = OpTypeFunction %float - %10 = OpTypeImage %float Cube 0 0 0 1 Unknown -%_ptr_UniformConstant_10 = OpTypePointer UniformConstant %10 -%pointLightShadowMap = OpVariable %_ptr_UniformConstant_10 UniformConstant - %14 = OpTypeSampler -%_ptr_UniformConstant_14 = OpTypePointer UniformConstant %14 -%shadowSamplerPCF = OpVariable %_ptr_UniformConstant_14 UniformConstant - %18 = OpTypeImage %float Cube 1 0 0 1 Unknown - %19 = OpTypeSampledImage %18 - %v3float = OpTypeVector %float 3 - %float_0_1 = OpConstant %float 0.1 - %23 = OpConstantComposite %v3float %float_0_1 %float_0_1 %float_0_1 - %float_0_5 = OpConstant %float 0.5 - %v4float = OpTypeVector %float 4 - %float_0 = OpConstant %float 0 -%_ptr_Output_float = OpTypePointer Output %float -%_entryPointOutput = OpVariable %_ptr_Output_float Output - %main = OpFunction %void None %3 - %5 = OpLabel - %37 = OpFunctionCall %float %_main_ - OpStore %_entryPointOutput %37 - OpReturn - OpFunctionEnd - %_main_ = OpFunction %float None %7 - %9 = OpLabel - %13 = OpLoad %10 %pointLightShadowMap - %17 = OpLoad %14 %shadowSamplerPCF - %20 = OpSampledImage %19 %13 %17 - %26 = OpCompositeExtract %float %23 0 - %27 = OpCompositeExtract %float %23 1 - %28 = OpCompositeExtract %float %23 2 - %29 = OpCompositeConstruct %v4float %26 %27 %28 %float_0_5 - %31 = OpCompositeExtract %float %29 3 - %32 = OpImageSampleDrefExplicitLod %float %20 %29 %31 Lod %float_0 - OpReturnValue %32 - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders/asm/frag/hlsl-sample-cmp-level-zero.asm.frag b/deps/SPIRV-Cross/shaders/asm/frag/hlsl-sample-cmp-level-zero.asm.frag deleted file mode 100644 index 34fb6e834b..0000000000 --- a/deps/SPIRV-Cross/shaders/asm/frag/hlsl-sample-cmp-level-zero.asm.frag +++ /dev/null @@ -1,113 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 1 -; Bound: 70 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %main "main" %texCoords_1 %cascadeIndex_1 %fragDepth_1 %_entryPointOutput - OpExecutionMode %main OriginUpperLeft - OpSource HLSL 500 - OpName %main "main" - OpName %_main_vf2_f1_f1_ "@main(vf2;f1;f1;" - OpName %texCoords "texCoords" - OpName %cascadeIndex "cascadeIndex" - OpName %fragDepth "fragDepth" - OpName %c "c" - OpName %ShadowMap "ShadowMap" - OpName %ShadowSamplerPCF "ShadowSamplerPCF" - OpName %texCoords_0 "texCoords" - OpName %texCoords_1 "texCoords" - OpName %cascadeIndex_0 "cascadeIndex" - OpName %cascadeIndex_1 "cascadeIndex" - OpName %fragDepth_0 "fragDepth" - OpName %fragDepth_1 "fragDepth" - OpName %_entryPointOutput "@entryPointOutput" - OpName %param "param" - OpName %param_0 "param" - OpName %param_1 "param" - OpDecorate %ShadowMap DescriptorSet 0 - OpDecorate %ShadowSamplerPCF DescriptorSet 0 - OpDecorate %texCoords_1 Location 0 - OpDecorate %cascadeIndex_1 Location 1 - OpDecorate %fragDepth_1 Location 2 - OpDecorate %_entryPointOutput Location 0 - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 - %v2float = OpTypeVector %float 2 -%_ptr_Function_v2float = OpTypePointer Function %v2float -%_ptr_Function_float = OpTypePointer Function %float - %v4float = OpTypeVector %float 4 - %11 = OpTypeFunction %v4float %_ptr_Function_v2float %_ptr_Function_float %_ptr_Function_float - %18 = OpTypeImage %float 2D 0 1 0 1 Unknown -%_ptr_UniformConstant_18 = OpTypePointer UniformConstant %18 - %ShadowMap = OpVariable %_ptr_UniformConstant_18 UniformConstant - %22 = OpTypeSampler -%_ptr_UniformConstant_22 = OpTypePointer UniformConstant %22 -%ShadowSamplerPCF = OpVariable %_ptr_UniformConstant_22 UniformConstant - %26 = OpTypeImage %float 2D 1 1 0 1 Unknown - %27 = OpTypeSampledImage %26 - %v3float = OpTypeVector %float 3 - %float_0 = OpConstant %float 0 -%_ptr_Input_v2float = OpTypePointer Input %v2float -%texCoords_1 = OpVariable %_ptr_Input_v2float Input -%_ptr_Input_float = OpTypePointer Input %float -%cascadeIndex_1 = OpVariable %_ptr_Input_float Input -%fragDepth_1 = OpVariable %_ptr_Input_float Input -%_ptr_Output_v4float = OpTypePointer Output %v4float -%_entryPointOutput = OpVariable %_ptr_Output_v4float Output - %main = OpFunction %void None %3 - %5 = OpLabel -%texCoords_0 = OpVariable %_ptr_Function_v2float Function -%cascadeIndex_0 = OpVariable %_ptr_Function_float Function -%fragDepth_0 = OpVariable %_ptr_Function_float Function - %param = OpVariable %_ptr_Function_v2float Function - %param_0 = OpVariable %_ptr_Function_float Function - %param_1 = OpVariable %_ptr_Function_float Function - %53 = OpLoad %v2float %texCoords_1 - OpStore %texCoords_0 %53 - %57 = OpLoad %float %cascadeIndex_1 - OpStore %cascadeIndex_0 %57 - %60 = OpLoad %float %fragDepth_1 - OpStore %fragDepth_0 %60 - %64 = OpLoad %v2float %texCoords_0 - OpStore %param %64 - %66 = OpLoad %float %cascadeIndex_0 - OpStore %param_0 %66 - %68 = OpLoad %float %fragDepth_0 - OpStore %param_1 %68 - %69 = OpFunctionCall %v4float %_main_vf2_f1_f1_ %param %param_0 %param_1 - OpStore %_entryPointOutput %69 - OpReturn - OpFunctionEnd -%_main_vf2_f1_f1_ = OpFunction %v4float None %11 - %texCoords = OpFunctionParameter %_ptr_Function_v2float -%cascadeIndex = OpFunctionParameter %_ptr_Function_float - %fragDepth = OpFunctionParameter %_ptr_Function_float - %16 = OpLabel - %c = OpVariable %_ptr_Function_float Function - %21 = OpLoad %18 %ShadowMap - %25 = OpLoad %22 %ShadowSamplerPCF - %28 = OpSampledImage %27 %21 %25 - %29 = OpLoad %v2float %texCoords - %30 = OpLoad %float %cascadeIndex - %32 = OpCompositeExtract %float %29 0 - %33 = OpCompositeExtract %float %29 1 - %34 = OpCompositeConstruct %v3float %32 %33 %30 - %35 = OpLoad %float %fragDepth - %36 = OpCompositeExtract %float %34 0 - %37 = OpCompositeExtract %float %34 1 - %38 = OpCompositeExtract %float %34 2 - %39 = OpCompositeConstruct %v4float %36 %37 %38 %35 - %41 = OpCompositeExtract %float %39 3 - %42 = OpImageSampleDrefExplicitLod %float %28 %39 %41 Lod %float_0 - OpStore %c %42 - %43 = OpLoad %float %c - %44 = OpLoad %float %c - %45 = OpLoad %float %c - %46 = OpLoad %float %c - %47 = OpCompositeConstruct %v4float %43 %44 %45 %46 - OpReturnValue %47 - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag b/deps/SPIRV-Cross/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag deleted file mode 100644 index 8b09e5b68f..0000000000 --- a/deps/SPIRV-Cross/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag +++ /dev/null @@ -1,646 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 3 -; Bound: 1532 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %main "main" %IN_HPosition %IN_Uv_EdgeDistance1 %IN_UvStuds_EdgeDistance2 %IN_Color %IN_LightPosition_Fog %IN_View_Depth %IN_Normal_SpecPower %IN_Tangent %IN_PosLightSpace_Reflectance %IN_studIndex %_entryPointOutput - OpExecutionMode %main OriginUpperLeft - OpSource HLSL 500 - OpName %main "main" - OpName %VertexOutput "VertexOutput" - OpMemberName %VertexOutput 0 "HPosition" - OpMemberName %VertexOutput 1 "Uv_EdgeDistance1" - OpMemberName %VertexOutput 2 "UvStuds_EdgeDistance2" - OpMemberName %VertexOutput 3 "Color" - OpMemberName %VertexOutput 4 "LightPosition_Fog" - OpMemberName %VertexOutput 5 "View_Depth" - OpMemberName %VertexOutput 6 "Normal_SpecPower" - OpMemberName %VertexOutput 7 "Tangent" - OpMemberName %VertexOutput 8 "PosLightSpace_Reflectance" - OpMemberName %VertexOutput 9 "studIndex" - OpName %Surface "Surface" - OpMemberName %Surface 0 "albedo" - OpMemberName %Surface 1 "normal" - OpMemberName %Surface 2 "specular" - OpMemberName %Surface 3 "gloss" - OpMemberName %Surface 4 "reflectance" - OpMemberName %Surface 5 "opacity" - OpName %SurfaceInput "SurfaceInput" - OpMemberName %SurfaceInput 0 "Color" - OpMemberName %SurfaceInput 1 "Uv" - OpMemberName %SurfaceInput 2 "UvStuds" - OpName %Globals "Globals" - OpMemberName %Globals 0 "ViewProjection" - OpMemberName %Globals 1 "ViewRight" - OpMemberName %Globals 2 "ViewUp" - OpMemberName %Globals 3 "ViewDir" - OpMemberName %Globals 4 "CameraPosition" - OpMemberName %Globals 5 "AmbientColor" - OpMemberName %Globals 6 "Lamp0Color" - OpMemberName %Globals 7 "Lamp0Dir" - OpMemberName %Globals 8 "Lamp1Color" - OpMemberName %Globals 9 "FogParams" - OpMemberName %Globals 10 "FogColor" - OpMemberName %Globals 11 "LightBorder" - OpMemberName %Globals 12 "LightConfig0" - OpMemberName %Globals 13 "LightConfig1" - OpMemberName %Globals 14 "LightConfig2" - OpMemberName %Globals 15 "LightConfig3" - OpMemberName %Globals 16 "RefractionBias_FadeDistance_GlowFactor" - OpMemberName %Globals 17 "OutlineBrightness_ShadowInfo" - OpMemberName %Globals 18 "ShadowMatrix0" - OpMemberName %Globals 19 "ShadowMatrix1" - OpMemberName %Globals 20 "ShadowMatrix2" - OpName %CB0 "CB0" - OpMemberName %CB0 0 "CB0" - OpName %_ "" - OpName %LightMapTexture "LightMapTexture" - OpName %LightMapSampler "LightMapSampler" - OpName %ShadowMapSampler "ShadowMapSampler" - OpName %ShadowMapTexture "ShadowMapTexture" - OpName %EnvironmentMapTexture "EnvironmentMapTexture" - OpName %EnvironmentMapSampler "EnvironmentMapSampler" - OpName %IN_HPosition "IN.HPosition" - OpName %IN_Uv_EdgeDistance1 "IN.Uv_EdgeDistance1" - OpName %IN_UvStuds_EdgeDistance2 "IN.UvStuds_EdgeDistance2" - OpName %IN_Color "IN.Color" - OpName %IN_LightPosition_Fog "IN.LightPosition_Fog" - OpName %IN_View_Depth "IN.View_Depth" - OpName %IN_Normal_SpecPower "IN.Normal_SpecPower" - OpName %IN_Tangent "IN.Tangent" - OpName %IN_PosLightSpace_Reflectance "IN.PosLightSpace_Reflectance" - OpName %IN_studIndex "IN.studIndex" - OpName %_entryPointOutput "@entryPointOutput" - OpName %DiffuseMapSampler "DiffuseMapSampler" - OpName %DiffuseMapTexture "DiffuseMapTexture" - OpName %NormalMapSampler "NormalMapSampler" - OpName %NormalMapTexture "NormalMapTexture" - OpName %NormalDetailMapTexture "NormalDetailMapTexture" - OpName %NormalDetailMapSampler "NormalDetailMapSampler" - OpName %StudsMapTexture "StudsMapTexture" - OpName %StudsMapSampler "StudsMapSampler" - OpName %SpecularMapSampler "SpecularMapSampler" - OpName %SpecularMapTexture "SpecularMapTexture" - OpName %Params "Params" - OpMemberName %Params 0 "LqmatFarTilingFactor" - OpName %CB2 "CB2" - OpMemberName %CB2 0 "CB2" - OpMemberDecorate %Globals 0 ColMajor - OpMemberDecorate %Globals 0 Offset 0 - OpMemberDecorate %Globals 0 MatrixStride 16 - OpMemberDecorate %Globals 1 Offset 64 - OpMemberDecorate %Globals 2 Offset 80 - OpMemberDecorate %Globals 3 Offset 96 - OpMemberDecorate %Globals 4 Offset 112 - OpMemberDecorate %Globals 5 Offset 128 - OpMemberDecorate %Globals 6 Offset 144 - OpMemberDecorate %Globals 7 Offset 160 - OpMemberDecorate %Globals 8 Offset 176 - OpMemberDecorate %Globals 9 Offset 192 - OpMemberDecorate %Globals 10 Offset 208 - OpMemberDecorate %Globals 11 Offset 224 - OpMemberDecorate %Globals 12 Offset 240 - OpMemberDecorate %Globals 13 Offset 256 - OpMemberDecorate %Globals 14 Offset 272 - OpMemberDecorate %Globals 15 Offset 288 - OpMemberDecorate %Globals 16 Offset 304 - OpMemberDecorate %Globals 17 Offset 320 - OpMemberDecorate %Globals 18 Offset 336 - OpMemberDecorate %Globals 19 Offset 352 - OpMemberDecorate %Globals 20 Offset 368 - OpMemberDecorate %CB0 0 Offset 0 - OpDecorate %CB0 Block - OpDecorate %_ DescriptorSet 0 - OpDecorate %_ Binding 0 - OpDecorate %LightMapTexture DescriptorSet 1 - OpDecorate %LightMapTexture Binding 6 - OpDecorate %LightMapSampler DescriptorSet 1 - OpDecorate %LightMapSampler Binding 6 - OpDecorate %ShadowMapSampler DescriptorSet 1 - OpDecorate %ShadowMapSampler Binding 1 - OpDecorate %ShadowMapTexture DescriptorSet 1 - OpDecorate %ShadowMapTexture Binding 1 - OpDecorate %EnvironmentMapTexture DescriptorSet 1 - OpDecorate %EnvironmentMapTexture Binding 2 - OpDecorate %EnvironmentMapSampler DescriptorSet 1 - OpDecorate %EnvironmentMapSampler Binding 2 - OpDecorate %IN_HPosition BuiltIn FragCoord - OpDecorate %IN_Uv_EdgeDistance1 Location 0 - OpDecorate %IN_UvStuds_EdgeDistance2 Location 1 - OpDecorate %IN_Color Location 2 - OpDecorate %IN_LightPosition_Fog Location 3 - OpDecorate %IN_View_Depth Location 4 - OpDecorate %IN_Normal_SpecPower Location 5 - OpDecorate %IN_Tangent Location 6 - OpDecorate %IN_PosLightSpace_Reflectance Location 7 - OpDecorate %IN_studIndex Location 8 - OpDecorate %_entryPointOutput Location 0 - OpDecorate %DiffuseMapSampler DescriptorSet 1 - OpDecorate %DiffuseMapSampler Binding 3 - OpDecorate %DiffuseMapTexture DescriptorSet 1 - OpDecorate %DiffuseMapTexture Binding 3 - OpDecorate %NormalMapSampler DescriptorSet 1 - OpDecorate %NormalMapSampler Binding 4 - OpDecorate %NormalMapTexture DescriptorSet 1 - OpDecorate %NormalMapTexture Binding 4 - OpDecorate %NormalDetailMapTexture DescriptorSet 1 - OpDecorate %NormalDetailMapTexture Binding 8 - OpDecorate %NormalDetailMapSampler DescriptorSet 1 - OpDecorate %NormalDetailMapSampler Binding 8 - OpDecorate %StudsMapTexture DescriptorSet 1 - OpDecorate %StudsMapTexture Binding 0 - OpDecorate %StudsMapSampler DescriptorSet 1 - OpDecorate %StudsMapSampler Binding 0 - OpDecorate %SpecularMapSampler DescriptorSet 1 - OpDecorate %SpecularMapSampler Binding 5 - OpDecorate %SpecularMapTexture DescriptorSet 1 - OpDecorate %SpecularMapTexture Binding 5 - OpMemberDecorate %Params 0 Offset 0 - OpMemberDecorate %CB2 0 Offset 0 - OpDecorate %CB2 Block - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 -%_ptr_Function_float = OpTypePointer Function %float - %8 = OpTypeFunction %float %_ptr_Function_float - %v4float = OpTypeVector %float 4 -%_ptr_Function_v4float = OpTypePointer Function %v4float - %v3float = OpTypeVector %float 3 - %18 = OpTypeFunction %v3float %_ptr_Function_v4float -%_ptr_Function_v3float = OpTypePointer Function %v3float - %23 = OpTypeFunction %v4float %_ptr_Function_v3float - %27 = OpTypeFunction %float %_ptr_Function_v3float - %31 = OpTypeFunction %float %_ptr_Function_float %_ptr_Function_float - %36 = OpTypeSampler -%_ptr_Function_36 = OpTypePointer Function %36 - %38 = OpTypeImage %float 2D 0 0 0 1 Unknown -%_ptr_Function_38 = OpTypePointer Function %38 - %40 = OpTypeFunction %float %_ptr_Function_36 %_ptr_Function_38 %_ptr_Function_v3float %_ptr_Function_float -%VertexOutput = OpTypeStruct %v4float %v4float %v4float %v4float %v4float %v4float %v4float %v3float %v4float %float -%_ptr_Function_VertexOutput = OpTypePointer Function %VertexOutput - %Surface = OpTypeStruct %v3float %v3float %float %float %float %float - %50 = OpTypeFunction %Surface %_ptr_Function_VertexOutput - %54 = OpTypeFunction %v4float %_ptr_Function_VertexOutput - %v2float = OpTypeVector %float 2 -%_ptr_Function_v2float = OpTypePointer Function %v2float - %60 = OpTypeFunction %v4float %_ptr_Function_36 %_ptr_Function_38 %_ptr_Function_v2float %_ptr_Function_float %_ptr_Function_float -%SurfaceInput = OpTypeStruct %v4float %v2float %v2float -%_ptr_Function_SurfaceInput = OpTypePointer Function %SurfaceInput - %70 = OpTypeFunction %Surface %_ptr_Function_SurfaceInput %_ptr_Function_v2float - %float_0 = OpConstant %float 0 - %float_1 = OpConstant %float 1 - %float_2 = OpConstant %float 2 -%mat4v4float = OpTypeMatrix %v4float 4 - %Globals = OpTypeStruct %mat4v4float %v4float %v4float %v4float %v3float %v3float %v3float %v3float %v3float %v4float %v3float %v4float %v4float %v4float %v4float %v4float %v4float %v4float %v4float %v4float %v4float - %CB0 = OpTypeStruct %Globals -%_ptr_Uniform_CB0 = OpTypePointer Uniform %CB0 - %_ = OpVariable %_ptr_Uniform_CB0 Uniform - %int = OpTypeInt 32 1 - %int_0 = OpConstant %int 0 - %int_15 = OpConstant %int 15 -%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float - %int_14 = OpConstant %int 14 - %128 = OpConstantComposite %v3float %float_1 %float_1 %float_1 - %133 = OpTypeImage %float 3D 0 0 0 1 Unknown -%_ptr_UniformConstant_133 = OpTypePointer UniformConstant %133 -%LightMapTexture = OpVariable %_ptr_UniformConstant_133 UniformConstant -%_ptr_UniformConstant_36 = OpTypePointer UniformConstant %36 -%LightMapSampler = OpVariable %_ptr_UniformConstant_36 UniformConstant - %140 = OpTypeSampledImage %133 - %int_11 = OpConstant %int 11 - %uint = OpTypeInt 32 0 - %float_9 = OpConstant %float 9 - %float_20 = OpConstant %float 20 - %float_0_5 = OpConstant %float 0.5 - %183 = OpTypeSampledImage %38 - %uint_0 = OpConstant %uint 0 - %uint_1 = OpConstant %uint 1 - %int_17 = OpConstant %int 17 - %uint_3 = OpConstant %uint 3 -%_ptr_Uniform_float = OpTypePointer Uniform %float - %float_0_25 = OpConstant %float 0.25 - %int_5 = OpConstant %int 5 -%float_0_00333333 = OpConstant %float 0.00333333 - %int_16 = OpConstant %int 16 -%_ptr_Function_Surface = OpTypePointer Function %Surface - %int_6 = OpConstant %int 6 - %int_7 = OpConstant %int 7 -%_ptr_Uniform_v3float = OpTypePointer Uniform %v3float - %int_8 = OpConstant %int 8 -%ShadowMapSampler = OpVariable %_ptr_UniformConstant_36 UniformConstant -%_ptr_UniformConstant_38 = OpTypePointer UniformConstant %38 -%ShadowMapTexture = OpVariable %_ptr_UniformConstant_38 UniformConstant - %367 = OpTypeImage %float Cube 0 0 0 1 Unknown -%_ptr_UniformConstant_367 = OpTypePointer UniformConstant %367 -%EnvironmentMapTexture = OpVariable %_ptr_UniformConstant_367 UniformConstant -%EnvironmentMapSampler = OpVariable %_ptr_UniformConstant_36 UniformConstant - %373 = OpTypeSampledImage %367 - %float_1_5 = OpConstant %float 1.5 - %int_10 = OpConstant %int 10 -%_ptr_Input_v4float = OpTypePointer Input %v4float -%IN_HPosition = OpVariable %_ptr_Input_v4float Input -%IN_Uv_EdgeDistance1 = OpVariable %_ptr_Input_v4float Input -%IN_UvStuds_EdgeDistance2 = OpVariable %_ptr_Input_v4float Input - %IN_Color = OpVariable %_ptr_Input_v4float Input -%IN_LightPosition_Fog = OpVariable %_ptr_Input_v4float Input -%IN_View_Depth = OpVariable %_ptr_Input_v4float Input -%IN_Normal_SpecPower = OpVariable %_ptr_Input_v4float Input -%_ptr_Input_v3float = OpTypePointer Input %v3float - %IN_Tangent = OpVariable %_ptr_Input_v3float Input -%IN_PosLightSpace_Reflectance = OpVariable %_ptr_Input_v4float Input -%_ptr_Input_float = OpTypePointer Input %float -%IN_studIndex = OpVariable %_ptr_Input_float Input -%_ptr_Output_v4float = OpTypePointer Output %v4float -%_entryPointOutput = OpVariable %_ptr_Output_v4float Output - %bool = OpTypeBool -%DiffuseMapSampler = OpVariable %_ptr_UniformConstant_36 UniformConstant -%DiffuseMapTexture = OpVariable %_ptr_UniformConstant_38 UniformConstant -%NormalMapSampler = OpVariable %_ptr_UniformConstant_36 UniformConstant -%NormalMapTexture = OpVariable %_ptr_UniformConstant_38 UniformConstant -%NormalDetailMapTexture = OpVariable %_ptr_UniformConstant_38 UniformConstant -%NormalDetailMapSampler = OpVariable %_ptr_UniformConstant_36 UniformConstant - %float_0_3 = OpConstant %float 0.3 -%StudsMapTexture = OpVariable %_ptr_UniformConstant_38 UniformConstant -%StudsMapSampler = OpVariable %_ptr_UniformConstant_36 UniformConstant -%SpecularMapSampler = OpVariable %_ptr_UniformConstant_36 UniformConstant -%SpecularMapTexture = OpVariable %_ptr_UniformConstant_38 UniformConstant - %float_0_75 = OpConstant %float 0.75 - %float_256 = OpConstant %float 256 - %689 = OpConstantComposite %v2float %float_2 %float_256 - %float_0_01 = OpConstant %float 0.01 - %692 = OpConstantComposite %v2float %float_0 %float_0_01 - %float_0_8 = OpConstant %float 0.8 - %float_120 = OpConstant %float 120 - %697 = OpConstantComposite %v2float %float_0_8 %float_120 - %Params = OpTypeStruct %v4float - %CB2 = OpTypeStruct %Params -%_ptr_Uniform_CB2 = OpTypePointer Uniform %CB2 - %false = OpConstantFalse %bool - %1509 = OpUndef %VertexOutput - %1510 = OpUndef %SurfaceInput - %1511 = OpUndef %v2float - %1512 = OpUndef %v4float - %1531 = OpUndef %Surface - %main = OpFunction %void None %3 - %5 = OpLabel - %501 = OpLoad %v4float %IN_HPosition - %1378 = OpCompositeInsert %VertexOutput %501 %1509 0 - %504 = OpLoad %v4float %IN_Uv_EdgeDistance1 - %1380 = OpCompositeInsert %VertexOutput %504 %1378 1 - %507 = OpLoad %v4float %IN_UvStuds_EdgeDistance2 - %1382 = OpCompositeInsert %VertexOutput %507 %1380 2 - %510 = OpLoad %v4float %IN_Color - %1384 = OpCompositeInsert %VertexOutput %510 %1382 3 - %513 = OpLoad %v4float %IN_LightPosition_Fog - %1386 = OpCompositeInsert %VertexOutput %513 %1384 4 - %516 = OpLoad %v4float %IN_View_Depth - %1388 = OpCompositeInsert %VertexOutput %516 %1386 5 - %519 = OpLoad %v4float %IN_Normal_SpecPower - %1390 = OpCompositeInsert %VertexOutput %519 %1388 6 - %523 = OpLoad %v3float %IN_Tangent - %1392 = OpCompositeInsert %VertexOutput %523 %1390 7 - %526 = OpLoad %v4float %IN_PosLightSpace_Reflectance - %1394 = OpCompositeInsert %VertexOutput %526 %1392 8 - %530 = OpLoad %float %IN_studIndex - %1396 = OpCompositeInsert %VertexOutput %530 %1394 9 - %1400 = OpCompositeInsert %SurfaceInput %510 %1510 0 - %954 = OpVectorShuffle %v2float %504 %504 0 1 - %1404 = OpCompositeInsert %SurfaceInput %954 %1400 1 - %958 = OpVectorShuffle %v2float %507 %507 0 1 - %1408 = OpCompositeInsert %SurfaceInput %958 %1404 2 - %1410 = OpCompositeExtract %float %1408 2 1 - %962 = OpExtInst %float %1 Fract %1410 - %965 = OpFAdd %float %962 %530 - %966 = OpFMul %float %965 %float_0_25 - %1414 = OpCompositeInsert %SurfaceInput %966 %1408 2 1 - %1416 = OpCompositeExtract %float %1396 5 3 - %970 = OpFMul %float %1416 %float_0_00333333 - %971 = OpFSub %float %float_1 %970 - %987 = OpExtInst %float %1 FClamp %971 %float_0 %float_1 - %976 = OpAccessChain %_ptr_Uniform_float %_ %int_0 %int_16 %uint_1 - %977 = OpLoad %float %976 - %978 = OpFMul %float %1416 %977 - %979 = OpFSub %float %float_1 %978 - %990 = OpExtInst %float %1 FClamp %979 %float_0 %float_1 - %1024 = OpVectorTimesScalar %v2float %954 %float_1 - %1029 = OpLoad %36 %DiffuseMapSampler - %1030 = OpLoad %38 %DiffuseMapTexture - OpBranch %1119 - %1119 = OpLabel - OpLoopMerge %1120 %1121 None - OpBranch %1122 - %1122 = OpLabel - %1124 = OpFOrdEqual %bool %float_0 %float_0 - OpSelectionMerge %1125 None - OpBranchConditional %1124 %1126 %1127 - %1126 = OpLabel - %1130 = OpSampledImage %183 %1030 %1029 - %1132 = OpImageSampleImplicitLod %v4float %1130 %1024 - OpBranch %1120 - %1127 = OpLabel - %1134 = OpFSub %float %float_1 %float_0 - %1135 = OpFDiv %float %float_1 %1134 - %1138 = OpSampledImage %183 %1030 %1029 - %1140 = OpVectorTimesScalar %v2float %1024 %float_0_25 - %1141 = OpImageSampleImplicitLod %v4float %1138 %1140 - %1144 = OpSampledImage %183 %1030 %1029 - %1146 = OpImageSampleImplicitLod %v4float %1144 %1024 - %1149 = OpFMul %float %987 %1135 - %1152 = OpFMul %float %float_0 %1135 - %1153 = OpFSub %float %1149 %1152 - %1161 = OpExtInst %float %1 FClamp %1153 %float_0 %float_1 - %1155 = OpCompositeConstruct %v4float %1161 %1161 %1161 %1161 - %1156 = OpExtInst %v4float %1 FMix %1141 %1146 %1155 - OpBranch %1120 - %1125 = OpLabel - %1157 = OpUndef %v4float - OpBranch %1120 - %1121 = OpLabel - OpBranchConditional %false %1119 %1120 - %1120 = OpLabel - %1517 = OpPhi %v4float %1132 %1126 %1156 %1127 %1157 %1125 %1512 %1121 - %1035 = OpVectorTimesScalar %v4float %1517 %float_1 - %1036 = OpLoad %36 %NormalMapSampler - %1037 = OpLoad %38 %NormalMapTexture - OpBranch %1165 - %1165 = OpLabel - OpLoopMerge %1166 %1167 None - OpBranch %1168 - %1168 = OpLabel - OpSelectionMerge %1171 None - OpBranchConditional %1124 %1172 %1173 - %1172 = OpLabel - %1176 = OpSampledImage %183 %1037 %1036 - %1178 = OpImageSampleImplicitLod %v4float %1176 %1024 - OpBranch %1166 - %1173 = OpLabel - %1180 = OpFSub %float %float_1 %float_0 - %1181 = OpFDiv %float %float_1 %1180 - %1184 = OpSampledImage %183 %1037 %1036 - %1186 = OpVectorTimesScalar %v2float %1024 %float_0_25 - %1187 = OpImageSampleImplicitLod %v4float %1184 %1186 - %1190 = OpSampledImage %183 %1037 %1036 - %1192 = OpImageSampleImplicitLod %v4float %1190 %1024 - %1195 = OpFMul %float %990 %1181 - %1198 = OpFMul %float %float_0 %1181 - %1199 = OpFSub %float %1195 %1198 - %1206 = OpExtInst %float %1 FClamp %1199 %float_0 %float_1 - %1201 = OpCompositeConstruct %v4float %1206 %1206 %1206 %1206 - %1202 = OpExtInst %v4float %1 FMix %1187 %1192 %1201 - OpBranch %1166 - %1171 = OpLabel - %1203 = OpUndef %v4float - OpBranch %1166 - %1167 = OpLabel - OpBranchConditional %false %1165 %1166 - %1166 = OpLabel - %1523 = OpPhi %v4float %1178 %1172 %1202 %1173 %1203 %1171 %1512 %1167 - %1210 = OpVectorShuffle %v2float %1523 %1523 3 1 - %1211 = OpVectorTimesScalar %v2float %1210 %float_2 - %1212 = OpCompositeConstruct %v2float %float_1 %float_1 - %1213 = OpFSub %v2float %1211 %1212 - %1216 = OpFNegate %v2float %1213 - %1218 = OpDot %float %1216 %1213 - %1219 = OpFAdd %float %float_1 %1218 - %1220 = OpExtInst %float %1 FClamp %1219 %float_0 %float_1 - %1221 = OpExtInst %float %1 Sqrt %1220 - %1222 = OpCompositeExtract %float %1213 0 - %1223 = OpCompositeExtract %float %1213 1 - %1224 = OpCompositeConstruct %v3float %1222 %1223 %1221 - %1042 = OpLoad %38 %NormalDetailMapTexture - %1043 = OpLoad %36 %NormalDetailMapSampler - %1044 = OpSampledImage %183 %1042 %1043 - %1046 = OpVectorTimesScalar %v2float %1024 %float_0 - %1047 = OpImageSampleImplicitLod %v4float %1044 %1046 - %1228 = OpVectorShuffle %v2float %1047 %1047 3 1 - %1229 = OpVectorTimesScalar %v2float %1228 %float_2 - %1231 = OpFSub %v2float %1229 %1212 - %1234 = OpFNegate %v2float %1231 - %1236 = OpDot %float %1234 %1231 - %1237 = OpFAdd %float %float_1 %1236 - %1238 = OpExtInst %float %1 FClamp %1237 %float_0 %float_1 - %1239 = OpExtInst %float %1 Sqrt %1238 - %1240 = OpCompositeExtract %float %1231 0 - %1241 = OpCompositeExtract %float %1231 1 - %1242 = OpCompositeConstruct %v3float %1240 %1241 %1239 - %1050 = OpVectorShuffle %v2float %1242 %1242 0 1 - %1051 = OpVectorTimesScalar %v2float %1050 %float_0 - %1053 = OpVectorShuffle %v2float %1224 %1224 0 1 - %1054 = OpFAdd %v2float %1053 %1051 - %1056 = OpVectorShuffle %v3float %1224 %1054 3 4 2 - %1059 = OpVectorShuffle %v2float %1056 %1056 0 1 - %1060 = OpVectorTimesScalar %v2float %1059 %990 - %1062 = OpVectorShuffle %v3float %1056 %1060 3 4 2 - %1430 = OpCompositeExtract %float %1062 0 - %1065 = OpFMul %float %1430 %float_0_3 - %1066 = OpFAdd %float %float_1 %1065 - %1069 = OpVectorShuffle %v3float %510 %510 0 1 2 - %1071 = OpVectorShuffle %v3float %1035 %1035 0 1 2 - %1072 = OpFMul %v3float %1069 %1071 - %1074 = OpVectorTimesScalar %v3float %1072 %1066 - %1075 = OpLoad %38 %StudsMapTexture - %1076 = OpLoad %36 %StudsMapSampler - %1077 = OpSampledImage %183 %1075 %1076 - %1434 = OpCompositeExtract %v2float %1414 2 - %1080 = OpImageSampleImplicitLod %v4float %1077 %1434 - %1436 = OpCompositeExtract %float %1080 0 - %1083 = OpFMul %float %1436 %float_2 - %1085 = OpVectorTimesScalar %v3float %1074 %1083 - %1086 = OpLoad %36 %SpecularMapSampler - %1087 = OpLoad %38 %SpecularMapTexture - OpBranch %1246 - %1246 = OpLabel - OpLoopMerge %1247 %1248 None - OpBranch %1249 - %1249 = OpLabel - %1251 = OpFOrdEqual %bool %float_0_75 %float_0 - OpSelectionMerge %1252 None - OpBranchConditional %1251 %1253 %1254 - %1253 = OpLabel - %1257 = OpSampledImage %183 %1087 %1086 - %1259 = OpImageSampleImplicitLod %v4float %1257 %1024 - OpBranch %1247 - %1254 = OpLabel - %1261 = OpFSub %float %float_1 %float_0_75 - %1262 = OpFDiv %float %float_1 %1261 - %1265 = OpSampledImage %183 %1087 %1086 - %1267 = OpVectorTimesScalar %v2float %1024 %float_0_25 - %1268 = OpImageSampleImplicitLod %v4float %1265 %1267 - %1271 = OpSampledImage %183 %1087 %1086 - %1273 = OpImageSampleImplicitLod %v4float %1271 %1024 - %1276 = OpFMul %float %990 %1262 - %1279 = OpFMul %float %float_0_75 %1262 - %1280 = OpFSub %float %1276 %1279 - %1287 = OpExtInst %float %1 FClamp %1280 %float_0 %float_1 - %1282 = OpCompositeConstruct %v4float %1287 %1287 %1287 %1287 - %1283 = OpExtInst %v4float %1 FMix %1268 %1273 %1282 - OpBranch %1247 - %1252 = OpLabel - %1284 = OpUndef %v4float - OpBranch %1247 - %1248 = OpLabel - OpBranchConditional %false %1246 %1247 - %1247 = OpLabel - %1530 = OpPhi %v4float %1259 %1253 %1283 %1254 %1284 %1252 %1512 %1248 - %1091 = OpVectorShuffle %v2float %1530 %1530 0 1 - %1093 = OpFMul %v2float %1091 %689 - %1094 = OpFAdd %v2float %1093 %692 - %1097 = OpCompositeConstruct %v2float %990 %990 - %1098 = OpExtInst %v2float %1 FMix %697 %1094 %1097 - %1438 = OpCompositeInsert %Surface %1085 %1531 0 - %1440 = OpCompositeInsert %Surface %1062 %1438 1 - %1442 = OpCompositeExtract %float %1098 0 - %1444 = OpCompositeInsert %Surface %1442 %1440 2 - %1446 = OpCompositeExtract %float %1098 1 - %1448 = OpCompositeInsert %Surface %1446 %1444 3 - %1450 = OpCompositeExtract %float %1091 1 - %1112 = OpFMul %float %1450 %990 - %1113 = OpFMul %float %1112 %float_0 - %1452 = OpCompositeInsert %Surface %1113 %1448 4 - %1456 = OpCompositeExtract %float %1396 3 3 - %764 = OpCompositeExtract %float %1085 0 - %765 = OpCompositeExtract %float %1085 1 - %766 = OpCompositeExtract %float %1085 2 - %767 = OpCompositeConstruct %v4float %764 %765 %766 %1456 - %770 = OpVectorShuffle %v3float %519 %519 0 1 2 - %773 = OpExtInst %v3float %1 Cross %770 %523 - %1462 = OpCompositeExtract %float %1452 1 0 - %778 = OpVectorTimesScalar %v3float %523 %1462 - %1466 = OpCompositeExtract %float %1452 1 1 - %782 = OpVectorTimesScalar %v3float %773 %1466 - %783 = OpFAdd %v3float %778 %782 - %1468 = OpCompositeExtract %float %1452 1 2 - %789 = OpVectorTimesScalar %v3float %770 %1468 - %790 = OpFAdd %v3float %783 %789 - %791 = OpExtInst %v3float %1 Normalize %790 - %793 = OpAccessChain %_ptr_Uniform_v3float %_ %int_0 %int_7 - %794 = OpLoad %v3float %793 - %795 = OpFNegate %v3float %794 - %796 = OpDot %float %791 %795 - %1290 = OpExtInst %float %1 FClamp %796 %float_0 %float_1 - %799 = OpAccessChain %_ptr_Uniform_v3float %_ %int_0 %int_6 - %800 = OpLoad %v3float %799 - %801 = OpVectorTimesScalar %v3float %800 %1290 - %803 = OpFNegate %float %796 - %804 = OpExtInst %float %1 FMax %803 %float_0 - %805 = OpAccessChain %_ptr_Uniform_v3float %_ %int_0 %int_8 - %806 = OpLoad %v3float %805 - %807 = OpVectorTimesScalar %v3float %806 %804 - %808 = OpFAdd %v3float %801 %807 - %810 = OpExtInst %float %1 Step %float_0 %796 - %813 = OpFMul %float %810 %1442 - %820 = OpVectorShuffle %v3float %513 %513 0 1 2 - %1296 = OpAccessChain %_ptr_Uniform_v4float %_ %int_0 %int_15 - %1297 = OpLoad %v4float %1296 - %1298 = OpVectorShuffle %v3float %1297 %1297 0 1 2 - %1300 = OpAccessChain %_ptr_Uniform_v4float %_ %int_0 %int_14 - %1301 = OpLoad %v4float %1300 - %1302 = OpVectorShuffle %v3float %1301 %1301 0 1 2 - %1303 = OpFSub %v3float %820 %1302 - %1304 = OpExtInst %v3float %1 FAbs %1303 - %1305 = OpExtInst %v3float %1 Step %1298 %1304 - %1307 = OpDot %float %1305 %128 - %1328 = OpExtInst %float %1 FClamp %1307 %float_0 %float_1 - %1309 = OpLoad %133 %LightMapTexture - %1310 = OpLoad %36 %LightMapSampler - %1311 = OpSampledImage %140 %1309 %1310 - %1313 = OpVectorShuffle %v3float %820 %820 1 2 0 - %1317 = OpVectorTimesScalar %v3float %1313 %1328 - %1318 = OpFSub %v3float %1313 %1317 - %1319 = OpImageSampleImplicitLod %v4float %1311 %1318 - %1321 = OpAccessChain %_ptr_Uniform_v4float %_ %int_0 %int_11 - %1322 = OpLoad %v4float %1321 - %1324 = OpCompositeConstruct %v4float %1328 %1328 %1328 %1328 - %1325 = OpExtInst %v4float %1 FMix %1319 %1322 %1324 - %822 = OpLoad %36 %ShadowMapSampler - %823 = OpLoad %38 %ShadowMapTexture - %826 = OpVectorShuffle %v3float %526 %526 0 1 2 - %1482 = OpCompositeExtract %float %1325 3 - %1337 = OpSampledImage %183 %823 %822 - %1339 = OpVectorShuffle %v2float %826 %826 0 1 - %1340 = OpImageSampleImplicitLod %v4float %1337 %1339 - %1341 = OpVectorShuffle %v2float %1340 %1340 0 1 - %1484 = OpCompositeExtract %float %826 2 - %1486 = OpCompositeExtract %float %1341 0 - %1363 = OpExtInst %float %1 Step %1486 %1484 - %1365 = OpFSub %float %1484 %float_0_5 - %1366 = OpExtInst %float %1 FAbs %1365 - %1367 = OpFMul %float %float_20 %1366 - %1368 = OpFSub %float %float_9 %1367 - %1369 = OpExtInst %float %1 FClamp %1368 %float_0 %float_1 - %1370 = OpFMul %float %1363 %1369 - %1488 = OpCompositeExtract %float %1341 1 - %1350 = OpFMul %float %1370 %1488 - %1351 = OpAccessChain %_ptr_Uniform_float %_ %int_0 %int_17 %uint_3 - %1352 = OpLoad %float %1351 - %1353 = OpFMul %float %1350 %1352 - %1354 = OpFSub %float %float_1 %1353 - %1356 = OpFMul %float %1354 %1482 - %830 = OpLoad %367 %EnvironmentMapTexture - %831 = OpLoad %36 %EnvironmentMapSampler - %832 = OpSampledImage %373 %830 %831 - %835 = OpVectorShuffle %v3float %516 %516 0 1 2 - %836 = OpFNegate %v3float %835 - %838 = OpExtInst %v3float %1 Reflect %836 %791 - %839 = OpImageSampleImplicitLod %v4float %832 %838 - %840 = OpVectorShuffle %v3float %839 %839 0 1 2 - %842 = OpVectorShuffle %v3float %767 %767 0 1 2 - %845 = OpCompositeConstruct %v3float %1113 %1113 %1113 - %846 = OpExtInst %v3float %1 FMix %842 %840 %845 - %848 = OpVectorShuffle %v4float %767 %846 4 5 6 3 - %849 = OpAccessChain %_ptr_Uniform_v3float %_ %int_0 %int_5 - %850 = OpLoad %v3float %849 - %853 = OpVectorTimesScalar %v3float %808 %1356 - %854 = OpFAdd %v3float %850 %853 - %856 = OpVectorShuffle %v3float %1325 %1325 0 1 2 - %857 = OpFAdd %v3float %854 %856 - %859 = OpVectorShuffle %v3float %848 %848 0 1 2 - %860 = OpFMul %v3float %857 %859 - %865 = OpFMul %float %813 %1356 - %873 = OpExtInst %v3float %1 Normalize %835 - %874 = OpFAdd %v3float %795 %873 - %875 = OpExtInst %v3float %1 Normalize %874 - %876 = OpDot %float %791 %875 - %877 = OpExtInst %float %1 FClamp %876 %float_0 %float_1 - %879 = OpExtInst %float %1 Pow %877 %1446 - %880 = OpFMul %float %865 %879 - %881 = OpVectorTimesScalar %v3float %800 %880 - %884 = OpFAdd %v3float %860 %881 - %886 = OpVectorShuffle %v4float %1512 %884 4 5 6 3 - %1494 = OpCompositeExtract %float %848 3 - %1496 = OpCompositeInsert %v4float %1494 %886 3 - %896 = OpAccessChain %_ptr_Uniform_float %_ %int_0 %int_17 %uint_0 - %897 = OpLoad %float %896 - %898 = OpFMul %float %978 %897 - %899 = OpAccessChain %_ptr_Uniform_float %_ %int_0 %int_17 %uint_1 - %900 = OpLoad %float %899 - %901 = OpFAdd %float %898 %900 - %1373 = OpExtInst %float %1 FClamp %901 %float_0 %float_1 - %905 = OpVectorShuffle %v2float %504 %504 3 2 - %908 = OpVectorShuffle %v2float %507 %507 3 2 - %909 = OpExtInst %v2float %1 FMin %905 %908 - %1504 = OpCompositeExtract %float %909 0 - %1506 = OpCompositeExtract %float %909 1 - %914 = OpExtInst %float %1 FMin %1504 %1506 - %916 = OpFDiv %float %914 %978 - %919 = OpFSub %float %float_1_5 %916 - %920 = OpFMul %float %1373 %919 - %922 = OpFAdd %float %920 %916 - %1376 = OpExtInst %float %1 FClamp %922 %float_0 %float_1 - %925 = OpVectorShuffle %v3float %1496 %1496 0 1 2 - %926 = OpVectorTimesScalar %v3float %925 %1376 - %928 = OpVectorShuffle %v4float %1496 %926 4 5 6 3 - %1508 = OpCompositeExtract %float %1396 4 3 - %931 = OpExtInst %float %1 FClamp %1508 %float_0 %float_1 - %932 = OpAccessChain %_ptr_Uniform_v3float %_ %int_0 %int_10 - %933 = OpLoad %v3float %932 - %935 = OpVectorShuffle %v3float %928 %928 0 1 2 - %937 = OpCompositeConstruct %v3float %931 %931 %931 - %938 = OpExtInst %v3float %1 FMix %933 %935 %937 - %940 = OpVectorShuffle %v4float %928 %938 4 5 6 3 - OpStore %_entryPointOutput %940 - OpReturn - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders/asm/frag/invalidation.asm.frag b/deps/SPIRV-Cross/shaders/asm/frag/invalidation.asm.frag deleted file mode 100644 index 8e753d50fe..0000000000 --- a/deps/SPIRV-Cross/shaders/asm/frag/invalidation.asm.frag +++ /dev/null @@ -1,46 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 1 -; Bound: 28 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %4 "main" %v0 %v1 %FragColor - OpExecutionMode %4 OriginUpperLeft - OpSource GLSL 450 - OpName %4 "main" - OpName %a "a" - OpName %v0 "v0" - OpName %b "b" - OpName %v1 "v1" - OpName %FragColor "FragColor" - OpDecorate %v0 Location 0 - OpDecorate %v1 Location 1 - OpDecorate %FragColor Location 0 - %2 = OpTypeVoid - %3 = OpTypeFunction %2 - %float = OpTypeFloat 32 - %pfloat = OpTypePointer Function %float - %9 = OpTypePointer Input %float - %v0 = OpVariable %9 Input - %v1 = OpVariable %9 Input - %25 = OpTypePointer Output %float - %FragColor = OpVariable %25 Output - %4 = OpFunction %2 None %3 - %5 = OpLabel - %a = OpVariable %pfloat Function - %b = OpVariable %pfloat Function - %v0_tmp = OpLoad %float %v0 - %v1_tmp = OpLoad %float %v1 - OpStore %a %v0_tmp - OpStore %b %v1_tmp - - %a_tmp = OpLoad %float %a - %b_tmp = OpLoad %float %b - %res = OpFAdd %float %a_tmp %b_tmp - %res1 = OpFMul %float %res %b_tmp - OpStore %a %v1_tmp - OpStore %FragColor %res1 - OpReturn - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag b/deps/SPIRV-Cross/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag deleted file mode 100644 index fa53940b14..0000000000 --- a/deps/SPIRV-Cross/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag +++ /dev/null @@ -1,190 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 2 -; Bound: 131 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %main "main" %fragWorld_1 %_entryPointOutput - OpExecutionMode %main OriginUpperLeft - OpSource HLSL 500 - OpName %main "main" - OpName %GetClip2TexMatrix_ "GetClip2TexMatrix(" - OpName %GetCascade_vf3_ "GetCascade(vf3;" - OpName %fragWorldPosition "fragWorldPosition" - OpName %_main_vf3_ "@main(vf3;" - OpName %fragWorld "fragWorld" - OpName %Foo "Foo" - OpMemberName %Foo 0 "lightVP" - OpMemberName %Foo 1 "shadowCascadesNum" - OpMemberName %Foo 2 "test" - OpName %_ "" - OpName %cascadeIndex "cascadeIndex" - OpName %worldToShadowMap "worldToShadowMap" - OpName %fragShadowMapPos "fragShadowMapPos" - OpName %param "param" - OpName %fragWorld_0 "fragWorld" - OpName %fragWorld_1 "fragWorld" - OpName %_entryPointOutput "@entryPointOutput" - OpName %param_0 "param" - OpDecorate %_arr_mat4v4float_uint_64 ArrayStride 64 - OpMemberDecorate %Foo 0 RowMajor - OpMemberDecorate %Foo 0 Offset 0 - OpMemberDecorate %Foo 0 MatrixStride 16 - OpMemberDecorate %Foo 1 Offset 4096 - OpMemberDecorate %Foo 2 Offset 4100 - OpDecorate %Foo Block - OpDecorate %_ DescriptorSet 0 - OpDecorate %_ Binding 0 - OpDecorate %fragWorld_1 Location 0 - OpDecorate %_entryPointOutput Location 0 - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 - %v4float = OpTypeVector %float 4 -%mat4v4float = OpTypeMatrix %v4float 4 - %9 = OpTypeFunction %mat4v4float - %v3float = OpTypeVector %float 3 -%_ptr_Function_v3float = OpTypePointer Function %v3float - %int = OpTypeInt 32 1 - %15 = OpTypeFunction %int %_ptr_Function_v3float - %uint = OpTypeInt 32 0 - %uint_64 = OpConstant %uint 64 -%_arr_mat4v4float_uint_64 = OpTypeArray %mat4v4float %uint_64 - %Foo = OpTypeStruct %_arr_mat4v4float_uint_64 %uint %int -%_ptr_Uniform_Foo = OpTypePointer Uniform %Foo - %_ = OpVariable %_ptr_Uniform_Foo Uniform - %int_2 = OpConstant %int 2 -%_ptr_Uniform_int = OpTypePointer Uniform %int - %int_0 = OpConstant %int 0 - %bool = OpTypeBool - %float_0_5 = OpConstant %float 0.5 - %float_0 = OpConstant %float 0 - %39 = OpConstantComposite %v4float %float_0_5 %float_0 %float_0 %float_0 - %40 = OpConstantComposite %v4float %float_0 %float_0_5 %float_0 %float_0 - %41 = OpConstantComposite %v4float %float_0 %float_0 %float_0_5 %float_0 - %float_1 = OpConstant %float 1 - %43 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_1 - %44 = OpConstantComposite %mat4v4float %39 %40 %41 %43 - %46 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_0 - %47 = OpConstantComposite %v4float %float_0 %float_1 %float_0 %float_0 - %48 = OpConstantComposite %v4float %float_0 %float_0 %float_1 %float_0 - %49 = OpConstantComposite %mat4v4float %46 %47 %48 %43 -%_ptr_Function_uint = OpTypePointer Function %uint - %uint_0 = OpConstant %uint 0 - %int_1 = OpConstant %int 1 -%_ptr_Uniform_uint = OpTypePointer Uniform %uint -%_ptr_Function_mat4v4float = OpTypePointer Function %mat4v4float -%_ptr_Uniform_mat4v4float = OpTypePointer Uniform %mat4v4float -%_ptr_Function_v4float = OpTypePointer Function %v4float - %uint_2 = OpConstant %uint 2 -%_ptr_Function_float = OpTypePointer Function %float - %uint_1 = OpConstant %uint 1 - %int_n1 = OpConstant %int -1 -%_ptr_Input_v3float = OpTypePointer Input %v3float -%fragWorld_1 = OpVariable %_ptr_Input_v3float Input -%_ptr_Output_int = OpTypePointer Output %int -%_entryPointOutput = OpVariable %_ptr_Output_int Output - %main = OpFunction %void None %3 - %5 = OpLabel -%fragWorld_0 = OpVariable %_ptr_Function_v3float Function - %param_0 = OpVariable %_ptr_Function_v3float Function - %125 = OpLoad %v3float %fragWorld_1 - OpStore %fragWorld_0 %125 - %129 = OpLoad %v3float %fragWorld_0 - OpStore %param_0 %129 - %130 = OpFunctionCall %int %_main_vf3_ %param_0 - OpStore %_entryPointOutput %130 - OpReturn - OpFunctionEnd -%GetClip2TexMatrix_ = OpFunction %mat4v4float None %9 - %11 = OpLabel - %30 = OpAccessChain %_ptr_Uniform_int %_ %int_2 - %31 = OpLoad %int %30 - %34 = OpIEqual %bool %31 %int_0 - OpSelectionMerge %36 None - OpBranchConditional %34 %35 %36 - %35 = OpLabel - OpReturnValue %44 - %36 = OpLabel - OpReturnValue %49 - OpFunctionEnd -%GetCascade_vf3_ = OpFunction %int None %15 -%fragWorldPosition = OpFunctionParameter %_ptr_Function_v3float - %18 = OpLabel -%cascadeIndex = OpVariable %_ptr_Function_uint Function -%worldToShadowMap = OpVariable %_ptr_Function_mat4v4float Function -%fragShadowMapPos = OpVariable %_ptr_Function_v4float Function - OpStore %cascadeIndex %uint_0 - OpBranch %55 - %55 = OpLabel - OpLoopMerge %57 %58 Unroll - OpBranch %59 - %59 = OpLabel - %60 = OpLoad %uint %cascadeIndex - %63 = OpAccessChain %_ptr_Uniform_uint %_ %int_1 - %64 = OpLoad %uint %63 - %65 = OpULessThan %bool %60 %64 - OpBranchConditional %65 %56 %57 - %56 = OpLabel - %68 = OpFunctionCall %mat4v4float %GetClip2TexMatrix_ - %69 = OpLoad %uint %cascadeIndex - %71 = OpAccessChain %_ptr_Uniform_mat4v4float %_ %int_0 %69 - %72 = OpLoad %mat4v4float %71 - %73 = OpMatrixTimesMatrix %mat4v4float %68 %72 - OpStore %worldToShadowMap %73 - %76 = OpLoad %mat4v4float %worldToShadowMap - %77 = OpLoad %v3float %fragWorldPosition - %78 = OpCompositeExtract %float %77 0 - %79 = OpCompositeExtract %float %77 1 - %80 = OpCompositeExtract %float %77 2 - %81 = OpCompositeConstruct %v4float %78 %79 %80 %float_1 - %82 = OpMatrixTimesVector %v4float %76 %81 - OpStore %fragShadowMapPos %82 - %85 = OpAccessChain %_ptr_Function_float %fragShadowMapPos %uint_2 - %86 = OpLoad %float %85 - %87 = OpFOrdGreaterThanEqual %bool %86 %float_0 - %88 = OpAccessChain %_ptr_Function_float %fragShadowMapPos %uint_2 - %89 = OpLoad %float %88 - %90 = OpFOrdLessThanEqual %bool %89 %float_1 - %91 = OpLogicalAnd %bool %87 %90 - %92 = OpAccessChain %_ptr_Function_float %fragShadowMapPos %uint_0 - %93 = OpLoad %float %92 - %95 = OpAccessChain %_ptr_Function_float %fragShadowMapPos %uint_1 - %96 = OpLoad %float %95 - %97 = OpExtInst %float %1 FMax %93 %96 - %98 = OpFOrdLessThanEqual %bool %97 %float_1 - %99 = OpLogicalAnd %bool %91 %98 - %100 = OpAccessChain %_ptr_Function_float %fragShadowMapPos %uint_0 - %101 = OpLoad %float %100 - %102 = OpAccessChain %_ptr_Function_float %fragShadowMapPos %uint_1 - %103 = OpLoad %float %102 - %104 = OpExtInst %float %1 FMin %101 %103 - %105 = OpFOrdGreaterThanEqual %bool %104 %float_0 - %106 = OpLogicalAnd %bool %99 %105 - OpSelectionMerge %108 None - OpBranchConditional %106 %107 %108 - %107 = OpLabel - %109 = OpLoad %uint %cascadeIndex - %110 = OpBitcast %int %109 - OpReturnValue %110 - %108 = OpLabel - OpBranch %58 - %58 = OpLabel - %112 = OpLoad %uint %cascadeIndex - %113 = OpIAdd %uint %112 %int_1 - OpStore %cascadeIndex %113 - OpBranch %55 - %57 = OpLabel - OpReturnValue %int_n1 - OpFunctionEnd - %_main_vf3_ = OpFunction %int None %15 - %fragWorld = OpFunctionParameter %_ptr_Function_v3float - %21 = OpLabel - %param = OpVariable %_ptr_Function_v3float Function - %118 = OpLoad %v3float %fragWorld - OpStore %param %118 - %119 = OpFunctionCall %int %GetCascade_vf3_ %param - OpReturnValue %119 - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders/asm/frag/multi-for-loop-init.asm.frag b/deps/SPIRV-Cross/shaders/asm/frag/multi-for-loop-init.asm.frag deleted file mode 100644 index d74f7ce568..0000000000 --- a/deps/SPIRV-Cross/shaders/asm/frag/multi-for-loop-init.asm.frag +++ /dev/null @@ -1,111 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 3 -; Bound: 52 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %main "main" %FragColor %counter %ucounter - OpExecutionMode %main OriginUpperLeft - OpSource ESSL 310 - OpName %main "main" - OpName %FragColor "FragColor" - OpName %i "i" - OpName %j "j" - OpName %counter "counter" - OpName %ucounter "ucounter" - OpDecorate %FragColor RelaxedPrecision - OpDecorate %FragColor Location 0 - OpDecorate %i RelaxedPrecision - OpDecorate %j RelaxedPrecision - OpDecorate %23 RelaxedPrecision - OpDecorate %27 RelaxedPrecision - OpDecorate %31 RelaxedPrecision - OpDecorate %32 RelaxedPrecision - OpDecorate %33 RelaxedPrecision - OpDecorate %34 RelaxedPrecision - OpDecorate %35 RelaxedPrecision - OpDecorate %36 RelaxedPrecision - OpDecorate %37 RelaxedPrecision - OpDecorate %38 RelaxedPrecision - OpDecorate %39 RelaxedPrecision - OpDecorate %40 RelaxedPrecision - OpDecorate %counter RelaxedPrecision - OpDecorate %counter Flat - OpDecorate %counter Location 0 - OpDecorate %43 RelaxedPrecision - OpDecorate %44 RelaxedPrecision - OpDecorate %45 RelaxedPrecision - OpDecorate %46 RelaxedPrecision - OpDecorate %47 RelaxedPrecision - OpDecorate %48 RelaxedPrecision - OpDecorate %ucounter RelaxedPrecision - OpDecorate %ucounter Flat - OpDecorate %ucounter Location 1 - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 - %v4float = OpTypeVector %float 4 -%_ptr_Output_v4float = OpTypePointer Output %v4float - %FragColor = OpVariable %_ptr_Output_v4float Output - %float_0 = OpConstant %float 0 - %11 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0 - %int = OpTypeInt 32 1 -%_ptr_Function_int = OpTypePointer Function %int - %uint = OpTypeInt 32 0 -%_ptr_Function_uint = OpTypePointer Function %uint - %int_0 = OpConstant %int 0 - %int_1 = OpConstant %uint 1 - %int_10 = OpConstant %int 10 - %bool = OpTypeBool - %int_20 = OpConstant %uint 20 -%_ptr_Input_int = OpTypePointer Input %int - %counter = OpVariable %_ptr_Input_int Input -%_ptr_Input_uint = OpTypePointer Input %uint - %ucounter = OpVariable %_ptr_Input_uint Input - %main = OpFunction %void None %3 - %5 = OpLabel - %i = OpVariable %_ptr_Function_int Function - %j = OpVariable %_ptr_Function_uint Function - OpStore %FragColor %11 - OpStore %i %int_0 - OpStore %j %int_1 - OpBranch %18 - %18 = OpLabel - OpLoopMerge %20 %21 None - OpBranch %22 - %22 = OpLabel - %23 = OpLoad %int %i - %26 = OpSLessThan %bool %23 %int_10 - %27 = OpLoad %uint %j - %29 = OpSLessThan %bool %27 %int_20 - %30 = OpLogicalAnd %bool %26 %29 - OpBranchConditional %30 %19 %20 - %19 = OpLabel - %31 = OpLoad %int %i - %32 = OpConvertSToF %float %31 - %33 = OpCompositeConstruct %v4float %32 %32 %32 %32 - %34 = OpLoad %v4float %FragColor - %35 = OpFAdd %v4float %34 %33 - OpStore %FragColor %35 - %36 = OpLoad %uint %j - %37 = OpConvertUToF %float %36 - %38 = OpCompositeConstruct %v4float %37 %37 %37 %37 - %39 = OpLoad %v4float %FragColor - %40 = OpFAdd %v4float %39 %38 - OpStore %FragColor %40 - OpBranch %21 - %21 = OpLabel - %43 = OpLoad %int %counter - %44 = OpLoad %int %i - %45 = OpIAdd %int %44 %43 - OpStore %i %45 - %46 = OpLoad %int %counter - %47 = OpLoad %uint %j - %48 = OpIAdd %uint %47 %46 - OpStore %j %48 - OpBranch %18 - %20 = OpLabel - OpReturn - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders/asm/frag/op-constant-null.asm.frag b/deps/SPIRV-Cross/shaders/asm/frag/op-constant-null.asm.frag deleted file mode 100644 index 61d2e579c8..0000000000 --- a/deps/SPIRV-Cross/shaders/asm/frag/op-constant-null.asm.frag +++ /dev/null @@ -1,85 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 1 -; Bound: 45 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %main "main" %FragColor - OpExecutionMode %main OriginUpperLeft - OpSource ESSL 310 - OpName %main "main" - OpName %a "a" - OpName %b "b" - OpName %c "c" - OpName %D "D" - OpMemberName %D 0 "a" - OpMemberName %D 1 "b" - OpName %d "d" - OpName %e "e" - OpName %FragColor "FragColor" - OpDecorate %a RelaxedPrecision - OpDecorate %b RelaxedPrecision - OpDecorate %c RelaxedPrecision - OpMemberDecorate %D 0 RelaxedPrecision - OpMemberDecorate %D 1 RelaxedPrecision - OpDecorate %e RelaxedPrecision - OpDecorate %FragColor RelaxedPrecision - OpDecorate %FragColor Location 0 - OpDecorate %44 RelaxedPrecision - OpDecorate %float_1 RelaxedPrecision - OpDecorate %14 RelaxedPrecision - OpDecorate %23 RelaxedPrecision - OpDecorate %41 RelaxedPrecision - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 -%_ptr_Function_float = OpTypePointer Function %float - %float_1 = OpConstantNull %float - %v4float = OpTypeVector %float 4 -%_ptr_Function_v4float = OpTypePointer Function %v4float - %float_2 = OpConstantNull %float - %14 = OpConstantNull %v4float - %v3float = OpTypeVector %float 3 -%mat2v3float = OpTypeMatrix %v3float 2 -%_ptr_Function_mat2v3float = OpTypePointer Function %mat2v3float - %float_4 = OpConstantNull %float - %20 = OpConstantNull %v3float - %float_5 = OpConstantNull %float - %22 = OpConstantNull %v3float - %23 = OpConstantNull %mat2v3float - %D = OpTypeStruct %v4float %float -%_ptr_Function_D = OpTypePointer Function %D - %27 = OpConstantNull %D - %uint = OpTypeInt 32 0 - %uint_4 = OpConstant %uint 4 -%_arr_v4float_uint_4 = OpTypeArray %v4float %uint_4 -%_ptr_Function__arr_v4float_uint_4 = OpTypePointer Function %_arr_v4float_uint_4 - %float_10 = OpConstantNull %float - %34 = OpConstantNull %v4float - %float_11 = OpConstantNull %float - %36 = OpConstantNull %v4float - %float_12 = OpConstantNull %float - %38 = OpConstantNull %v4float - %float_13 = OpConstantNull %float - %40 = OpConstantNull %v4float - %41 = OpConstantNull %_arr_v4float_uint_4 -%_ptr_Output_float = OpTypePointer Output %float - %FragColor = OpVariable %_ptr_Output_float Output - %main = OpFunction %void None %3 - %5 = OpLabel - %a = OpVariable %_ptr_Function_float Function - %b = OpVariable %_ptr_Function_v4float Function - %c = OpVariable %_ptr_Function_mat2v3float Function - %d = OpVariable %_ptr_Function_D Function - %e = OpVariable %_ptr_Function__arr_v4float_uint_4 Function - OpStore %a %float_1 - OpStore %b %14 - OpStore %c %23 - OpStore %d %27 - OpStore %e %41 - %44 = OpLoad %float %a - OpStore %FragColor %44 - OpReturn - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders/asm/frag/phi-loop-variable.asm.frag b/deps/SPIRV-Cross/shaders/asm/frag/phi-loop-variable.asm.frag deleted file mode 100644 index 74c46b4af8..0000000000 --- a/deps/SPIRV-Cross/shaders/asm/frag/phi-loop-variable.asm.frag +++ /dev/null @@ -1,71 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 1 -; Bound: 59 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %4 "main" - OpExecutionMode %4 OriginUpperLeft - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 - %v2float = OpTypeVector %float 2 -%mat2v2float = OpTypeMatrix %v2float 2 -%_ptr_Function_mat2v2float = OpTypePointer Function %mat2v2float - %v3float = OpTypeVector %float 3 - %11 = OpTypeFunction %v3float %_ptr_Function_mat2v2float -%_ptr_Function_v3float = OpTypePointer Function %v3float - %float_1 = OpConstant %float 1 - %18 = OpConstantComposite %v3float %float_1 %float_1 %float_1 - %int = OpTypeInt 32 1 -%_ptr_Function_int = OpTypePointer Function %int - %int_35 = OpConstant %int 35 - %int_0 = OpConstant %int 0 - %bool = OpTypeBool - %int_1 = OpConstant %int 1 - %4 = OpFunction %void None %3 - %5 = OpLabel - OpBranch %48 - %48 = OpLabel - %58 = OpPhi %int %int_35 %5 %56 %50 - OpLoopMerge %49 %50 None - OpBranch %51 - %51 = OpLabel - %53 = OpSGreaterThanEqual %bool %58 %int_0 - OpBranchConditional %53 %54 %49 - %54 = OpLabel - OpBranch %50 - %50 = OpLabel - %56 = OpISub %int %58 %int_1 - OpBranch %48 - %49 = OpLabel - OpReturn - OpFunctionEnd - %13 = OpFunction %v3float None %11 - %12 = OpFunctionParameter %_ptr_Function_mat2v2float - %14 = OpLabel - %16 = OpVariable %_ptr_Function_v3float Function - %21 = OpVariable %_ptr_Function_int Function - OpStore %16 %18 - OpStore %21 %int_35 - OpBranch %23 - %23 = OpLabel - OpLoopMerge %25 %26 None - OpBranch %27 - %27 = OpLabel - %28 = OpLoad %int %21 - %31 = OpSGreaterThanEqual %bool %28 %int_0 - OpBranchConditional %31 %24 %25 - %24 = OpLabel - OpBranch %26 - %26 = OpLabel - %32 = OpLoad %int %21 - %34 = OpISub %int %32 %int_1 - OpStore %21 %34 - OpBranch %23 - %25 = OpLabel - %35 = OpLoad %v3float %16 - OpReturnValue %35 - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders/asm/frag/sampler-buffer-without-sampler.asm.frag b/deps/SPIRV-Cross/shaders/asm/frag/sampler-buffer-without-sampler.asm.frag deleted file mode 100644 index 9c08fc2830..0000000000 --- a/deps/SPIRV-Cross/shaders/asm/frag/sampler-buffer-without-sampler.asm.frag +++ /dev/null @@ -1,59 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 1 -; Bound: 36 -; Schema: 0 - OpCapability Shader - OpCapability SampledBuffer - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %main "main" %_entryPointOutput - OpExecutionMode %main OriginUpperLeft - OpName %main "main" - OpName %_main_ "@main(" - OpName %storeTemp "storeTemp" - OpName %RWTex "RWTex" - OpName %Tex "Tex" - OpName %_entryPointOutput "@entryPointOutput" - OpDecorate %RWTex DescriptorSet 0 - OpDecorate %Tex DescriptorSet 0 - OpDecorate %_entryPointOutput Location 0 - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 - %v4float = OpTypeVector %float 4 - %8 = OpTypeFunction %v4float -%_ptr_Function_v4float = OpTypePointer Function %v4float - %13 = OpConstant %float 1 - %14 = OpConstant %float 2 - %15 = OpConstant %float 3 - %16 = OpConstant %float 4 - %17 = OpConstantComposite %v4float %13 %14 %15 %16 - %18 = OpTypeImage %float Buffer 0 0 0 2 Rgba32f -%_ptr_UniformConstant_18 = OpTypePointer UniformConstant %18 - %RWTex = OpVariable %_ptr_UniformConstant_18 UniformConstant - %int = OpTypeInt 32 1 - %23 = OpConstant %int 20 - %25 = OpTypeImage %float Buffer 0 0 0 1 Rgba32f -%_ptr_UniformConstant_25 = OpTypePointer UniformConstant %25 - %Tex = OpVariable %_ptr_UniformConstant_25 UniformConstant - %29 = OpConstant %int 10 -%_ptr_Output_v4float = OpTypePointer Output %v4float -%_entryPointOutput = OpVariable %_ptr_Output_v4float Output - %main = OpFunction %void None %3 - %5 = OpLabel - %35 = OpFunctionCall %v4float %_main_ - OpStore %_entryPointOutput %35 - OpReturn - OpFunctionEnd - %_main_ = OpFunction %v4float None %8 - %10 = OpLabel - %storeTemp = OpVariable %_ptr_Function_v4float Function - OpStore %storeTemp %17 - %21 = OpLoad %18 %RWTex - %24 = OpLoad %v4float %storeTemp - OpImageWrite %21 %23 %24 - %28 = OpLoad %25 %Tex - %30 = OpImageFetch %v4float %28 %29 - OpReturnValue %30 - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders/asm/frag/struct-composite-extract-swizzle.asm.frag b/deps/SPIRV-Cross/shaders/asm/frag/struct-composite-extract-swizzle.asm.frag deleted file mode 100644 index 33bd1c9163..0000000000 --- a/deps/SPIRV-Cross/shaders/asm/frag/struct-composite-extract-swizzle.asm.frag +++ /dev/null @@ -1,55 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 1 -; Bound: 34 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %main "main" %FragColor - OpExecutionMode %main OriginUpperLeft - OpSource ESSL 310 - OpName %main "main" - OpName %FragColor "FragColor" - OpName %uSampler "uSampler" - OpName %Foo "Foo" - OpMemberName %Foo 0 "var1" - OpMemberName %Foo 1 "var2" - OpName %foo "foo" - OpDecorate %FragColor RelaxedPrecision - OpDecorate %FragColor Location 0 - OpDecorate %uSampler RelaxedPrecision - OpDecorate %uSampler DescriptorSet 0 - OpDecorate %uSampler Binding 0 - OpDecorate %14 RelaxedPrecision - OpMemberDecorate %Foo 0 RelaxedPrecision - OpMemberDecorate %Foo 1 RelaxedPrecision - OpDecorate %27 RelaxedPrecision - OpDecorate %28 RelaxedPrecision - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 - %v4float = OpTypeVector %float 4 -%_ptr_Output_v4float = OpTypePointer Output %v4float - %FragColor = OpVariable %_ptr_Output_v4float Output - %10 = OpTypeImage %float 2D 0 0 0 1 Unknown - %11 = OpTypeSampledImage %10 -%_ptr_UniformConstant_11 = OpTypePointer UniformConstant %11 - %uSampler = OpVariable %_ptr_UniformConstant_11 UniformConstant - %Foo = OpTypeStruct %float %float -%_ptr_Function_Foo = OpTypePointer Function %Foo - %int = OpTypeInt 32 1 -%_ptr_Function_float = OpTypePointer Function %float - %v2float = OpTypeVector %float 2 - %33 = OpUndef %Foo - %main = OpFunction %void None %3 - %5 = OpLabel - %foo = OpVariable %_ptr_Function_Foo Function - %14 = OpLoad %11 %uSampler - %30 = OpCompositeExtract %float %33 0 - %32 = OpCompositeExtract %float %33 1 - %27 = OpCompositeConstruct %v2float %30 %32 - %28 = OpImageSampleImplicitLod %v4float %14 %27 - OpStore %FragColor %28 - OpReturn - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders/asm/frag/temporary-phi-hoisting.asm.frag b/deps/SPIRV-Cross/shaders/asm/frag/temporary-phi-hoisting.asm.frag deleted file mode 100644 index 7cedcd5819..0000000000 --- a/deps/SPIRV-Cross/shaders/asm/frag/temporary-phi-hoisting.asm.frag +++ /dev/null @@ -1,75 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 1 -; Bound: 87 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %main "main" %_entryPointOutput - OpExecutionMode %main OriginUpperLeft - OpSource HLSL 500 - OpName %main "main" - OpName %MyStruct "MyStruct" - OpMemberName %MyStruct 0 "color" - OpName %MyStruct_CB "MyStruct_CB" - OpMemberName %MyStruct_CB 0 "g_MyStruct" - OpName %_ "" - OpName %_entryPointOutput "@entryPointOutput" - OpMemberDecorate %MyStruct 0 Offset 0 - OpDecorate %_arr_MyStruct_uint_4 ArrayStride 16 - OpMemberDecorate %MyStruct_CB 0 Offset 0 - OpDecorate %MyStruct_CB Block - OpDecorate %_ DescriptorSet 0 - OpDecorate %_entryPointOutput Location 0 - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 - %v4float = OpTypeVector %float 4 - %v3float = OpTypeVector %float 3 - %float_0 = OpConstant %float 0 - %15 = OpConstantComposite %v3float %float_0 %float_0 %float_0 - %int = OpTypeInt 32 1 - %int_0 = OpConstant %int 0 - %int_4 = OpConstant %int 4 - %bool = OpTypeBool - %MyStruct = OpTypeStruct %v4float - %uint = OpTypeInt 32 0 - %uint_4 = OpConstant %uint 4 -%_arr_MyStruct_uint_4 = OpTypeArray %MyStruct %uint_4 -%MyStruct_CB = OpTypeStruct %_arr_MyStruct_uint_4 -%_ptr_Uniform_MyStruct_CB = OpTypePointer Uniform %MyStruct_CB - %_ = OpVariable %_ptr_Uniform_MyStruct_CB Uniform -%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float - %int_1 = OpConstant %int 1 - %float_1 = OpConstant %float 1 -%_ptr_Output_v4float = OpTypePointer Output %v4float -%_entryPointOutput = OpVariable %_ptr_Output_v4float Output - %main = OpFunction %void None %3 - %5 = OpLabel - OpBranch %64 - %64 = OpLabel - %85 = OpPhi %v3float %15 %5 %77 %66 - %86 = OpPhi %int %int_0 %5 %79 %66 - OpLoopMerge %65 %66 None - OpBranch %67 - %67 = OpLabel - %69 = OpSLessThan %bool %86 %int_4 - OpBranchConditional %69 %70 %65 - %70 = OpLabel - %72 = OpAccessChain %_ptr_Uniform_v4float %_ %int_0 %86 %int_0 - %73 = OpLoad %v4float %72 - %74 = OpVectorShuffle %v3float %73 %73 0 1 2 - %77 = OpFAdd %v3float %85 %74 - OpBranch %66 - %66 = OpLabel - %79 = OpIAdd %int %86 %int_1 - OpBranch %64 - %65 = OpLabel - %81 = OpCompositeExtract %float %85 0 - %82 = OpCompositeExtract %float %85 1 - %83 = OpCompositeExtract %float %85 2 - %84 = OpCompositeConstruct %v4float %81 %82 %83 %float_1 - OpStore %_entryPointOutput %84 - OpReturn - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders/asm/frag/undef-variable-store.asm.frag b/deps/SPIRV-Cross/shaders/asm/frag/undef-variable-store.asm.frag deleted file mode 100644 index 966c2d9d5a..0000000000 --- a/deps/SPIRV-Cross/shaders/asm/frag/undef-variable-store.asm.frag +++ /dev/null @@ -1,85 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 1 -; Bound: 50 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %fragmentProgram "main" %_entryPointOutput - OpExecutionMode %fragmentProgram OriginUpperLeft - OpSource HLSL 500 - OpName %fragmentProgram "fragmentProgram" - OpName %_fragmentProgram_ "@fragmentProgram(" - OpName %uv "uv" - OpName %_entryPointOutput "@entryPointOutput" - OpDecorate %_entryPointOutput Location 0 - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 - %v4float = OpTypeVector %float 4 - %8 = OpTypeFunction %v4float - %v2float = OpTypeVector %float 2 -%_ptr_Function_v2float = OpTypePointer Function %v2float - %float_0 = OpConstant %float 0 - %15 = OpConstantComposite %v2float %float_0 %float_0 - %uint = OpTypeInt 32 0 - %uint_0 = OpConstant %uint 0 -%_ptr_Function_float = OpTypePointer Function %float - %bool = OpTypeBool - %float_1 = OpConstant %float 1 - %26 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1 - %29 = OpConstantComposite %v4float %float_1 %float_1 %float_0 %float_1 -%_ptr_Output_v4float = OpTypePointer Output %v4float -%_entryPointOutput = OpVariable %_ptr_Output_v4float Output -%_ptr_Function_v4float = OpTypePointer Function %v4float - %false = OpConstantFalse %bool -%fragmentProgram = OpFunction %void None %3 - %5 = OpLabel - %35 = OpVariable %_ptr_Function_v2float Function - %37 = OpVariable %_ptr_Function_v4float Function - OpBranch %38 - %38 = OpLabel - OpLoopMerge %39 %40 None - OpBranch %41 - %41 = OpLabel - OpStore %35 %15 - %42 = OpAccessChain %_ptr_Function_float %35 %uint_0 - %43 = OpLoad %float %42 - %44 = OpFOrdNotEqual %bool %43 %float_0 - OpSelectionMerge %45 None - OpBranchConditional %44 %46 %47 - %46 = OpLabel - OpStore %37 %26 - OpBranch %39 - %47 = OpLabel - OpStore %37 %29 - OpBranch %39 - %45 = OpLabel - %48 = OpUndef %v4float - OpStore %37 %48 - OpBranch %39 - %40 = OpLabel - OpBranchConditional %false %38 %39 - %39 = OpLabel - %34 = OpLoad %v4float %37 - OpStore %_entryPointOutput %34 - OpReturn - OpFunctionEnd -%_fragmentProgram_ = OpFunction %v4float None %8 - %10 = OpLabel - %uv = OpVariable %_ptr_Function_v2float Function - OpStore %uv %15 - %19 = OpAccessChain %_ptr_Function_float %uv %uint_0 - %20 = OpLoad %float %19 - %22 = OpFOrdNotEqual %bool %20 %float_0 - OpSelectionMerge %24 None - OpBranchConditional %22 %23 %28 - %23 = OpLabel - OpReturnValue %26 - %28 = OpLabel - OpReturnValue %29 - %24 = OpLabel - %31 = OpUndef %v4float - OpReturnValue %31 - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders/asm/frag/unreachable.asm.frag b/deps/SPIRV-Cross/shaders/asm/frag/unreachable.asm.frag deleted file mode 100644 index e2ce2eb56a..0000000000 --- a/deps/SPIRV-Cross/shaders/asm/frag/unreachable.asm.frag +++ /dev/null @@ -1,61 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 3 -; Bound: 47 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %main "main" %counter %FragColor - OpExecutionMode %main OriginUpperLeft - OpSource GLSL 450 - OpName %main "main" - OpName %counter "counter" - OpName %FragColor "FragColor" - OpDecorate %counter Flat - OpDecorate %counter Location 0 - OpDecorate %FragColor Location 0 - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 - %v4float = OpTypeVector %float 4 - %8 = OpTypeFunction %v4float - %int = OpTypeInt 32 1 -%_ptr_Input_int = OpTypePointer Input %int - %counter = OpVariable %_ptr_Input_int Input - %int_10 = OpConstant %int 10 - %bool = OpTypeBool - %float_10 = OpConstant %float 10 - %21 = OpConstantComposite %v4float %float_10 %float_10 %float_10 %float_10 - %float_30 = OpConstant %float 30 - %25 = OpConstantComposite %v4float %float_30 %float_30 %float_30 %float_30 -%_ptr_Output_v4float = OpTypePointer Output %v4float - %FragColor = OpVariable %_ptr_Output_v4float Output -%_ptr_Function_v4float = OpTypePointer Function %v4float - %false = OpConstantFalse %bool - %44 = OpUndef %v4float - %main = OpFunction %void None %3 - %5 = OpLabel - OpBranch %33 - %33 = OpLabel - %45 = OpPhi %v4float %44 %5 %44 %35 - OpLoopMerge %34 %35 None - OpBranch %36 - %36 = OpLabel - %37 = OpLoad %int %counter - %38 = OpIEqual %bool %37 %int_10 - OpSelectionMerge %39 None - OpBranchConditional %38 %40 %41 - %40 = OpLabel - OpBranch %34 - %41 = OpLabel - OpBranch %34 - %39 = OpLabel - OpUnreachable - %35 = OpLabel - OpBranchConditional %false %33 %34 - %34 = OpLabel - %46 = OpPhi %v4float %21 %40 %25 %41 %44 %35 - OpStore %FragColor %46 - OpReturn - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders/asm/frag/vector-shuffle-oom.asm.frag b/deps/SPIRV-Cross/shaders/asm/frag/vector-shuffle-oom.asm.frag deleted file mode 100644 index d60c6f52d4..0000000000 --- a/deps/SPIRV-Cross/shaders/asm/frag/vector-shuffle-oom.asm.frag +++ /dev/null @@ -1,886 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 2 -; Bound: 25007 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %5663 "main" %5800 %gl_FragCoord %4317 - OpExecutionMode %5663 OriginUpperLeft - OpMemberDecorate %_struct_1116 0 Offset 0 - OpMemberDecorate %_struct_1116 1 Offset 16 - OpMemberDecorate %_struct_1116 2 Offset 32 - OpDecorate %_struct_1116 Block - OpDecorate %22044 DescriptorSet 0 - OpDecorate %22044 Binding 0 - OpDecorate %5785 DescriptorSet 0 - OpDecorate %5785 Binding 140 - OpDecorate %5688 DescriptorSet 0 - OpDecorate %5688 Binding 60 - OpMemberDecorate %_struct_994 0 Offset 0 - OpMemberDecorate %_struct_994 1 Offset 16 - OpMemberDecorate %_struct_994 2 Offset 28 - OpMemberDecorate %_struct_994 3 Offset 32 - OpMemberDecorate %_struct_994 4 Offset 44 - OpMemberDecorate %_struct_994 5 Offset 48 - OpMemberDecorate %_struct_994 6 Offset 60 - OpMemberDecorate %_struct_994 7 Offset 64 - OpMemberDecorate %_struct_994 8 Offset 76 - OpMemberDecorate %_struct_994 9 Offset 80 - OpMemberDecorate %_struct_994 10 Offset 92 - OpMemberDecorate %_struct_994 11 Offset 96 - OpMemberDecorate %_struct_994 12 Offset 108 - OpMemberDecorate %_struct_994 13 Offset 112 - OpMemberDecorate %_struct_994 14 Offset 120 - OpMemberDecorate %_struct_994 15 Offset 128 - OpMemberDecorate %_struct_994 16 Offset 140 - OpMemberDecorate %_struct_994 17 Offset 144 - OpMemberDecorate %_struct_994 18 Offset 148 - OpMemberDecorate %_struct_994 19 Offset 152 - OpMemberDecorate %_struct_994 20 Offset 156 - OpMemberDecorate %_struct_994 21 Offset 160 - OpMemberDecorate %_struct_994 22 Offset 176 - OpMemberDecorate %_struct_994 23 RowMajor - OpMemberDecorate %_struct_994 23 Offset 192 - OpMemberDecorate %_struct_994 23 MatrixStride 16 - OpMemberDecorate %_struct_994 24 Offset 256 - OpDecorate %_struct_994 Block - OpDecorate %12348 DescriptorSet 0 - OpDecorate %12348 Binding 2 - OpDecorate %3312 DescriptorSet 0 - OpDecorate %3312 Binding 142 - OpDecorate %4646 DescriptorSet 0 - OpDecorate %4646 Binding 62 - OpDecorate %4862 DescriptorSet 0 - OpDecorate %4862 Binding 141 - OpDecorate %3594 DescriptorSet 0 - OpDecorate %3594 Binding 61 - OpDecorate %_arr_mat4v4float_uint_2 ArrayStride 64 - OpDecorate %_arr_v4float_uint_2 ArrayStride 16 - OpMemberDecorate %_struct_408 0 RowMajor - OpMemberDecorate %_struct_408 0 Offset 0 - OpMemberDecorate %_struct_408 0 MatrixStride 16 - OpMemberDecorate %_struct_408 1 RowMajor - OpMemberDecorate %_struct_408 1 Offset 64 - OpMemberDecorate %_struct_408 1 MatrixStride 16 - OpMemberDecorate %_struct_408 2 RowMajor - OpMemberDecorate %_struct_408 2 Offset 128 - OpMemberDecorate %_struct_408 2 MatrixStride 16 - OpMemberDecorate %_struct_408 3 RowMajor - OpMemberDecorate %_struct_408 3 Offset 192 - OpMemberDecorate %_struct_408 3 MatrixStride 16 - OpMemberDecorate %_struct_408 4 Offset 256 - OpMemberDecorate %_struct_408 5 Offset 272 - OpMemberDecorate %_struct_408 6 Offset 288 - OpMemberDecorate %_struct_408 7 Offset 292 - OpMemberDecorate %_struct_408 8 Offset 296 - OpMemberDecorate %_struct_408 9 Offset 300 - OpMemberDecorate %_struct_408 10 Offset 304 - OpMemberDecorate %_struct_408 11 Offset 316 - OpMemberDecorate %_struct_408 12 Offset 320 - OpMemberDecorate %_struct_408 13 Offset 332 - OpMemberDecorate %_struct_408 14 Offset 336 - OpMemberDecorate %_struct_408 15 Offset 348 - OpMemberDecorate %_struct_408 16 Offset 352 - OpMemberDecorate %_struct_408 17 Offset 364 - OpMemberDecorate %_struct_408 18 Offset 368 - OpMemberDecorate %_struct_408 19 Offset 372 - OpMemberDecorate %_struct_408 20 Offset 376 - OpMemberDecorate %_struct_408 21 Offset 384 - OpMemberDecorate %_struct_408 22 Offset 392 - OpMemberDecorate %_struct_408 23 Offset 400 - OpMemberDecorate %_struct_408 24 Offset 416 - OpMemberDecorate %_struct_408 25 Offset 424 - OpMemberDecorate %_struct_408 26 Offset 432 - OpMemberDecorate %_struct_408 27 Offset 448 - OpMemberDecorate %_struct_408 28 Offset 460 - OpMemberDecorate %_struct_408 29 Offset 464 - OpMemberDecorate %_struct_408 30 Offset 468 - OpMemberDecorate %_struct_408 31 Offset 472 - OpMemberDecorate %_struct_408 32 Offset 476 - OpMemberDecorate %_struct_408 33 Offset 480 - OpMemberDecorate %_struct_408 34 Offset 488 - OpMemberDecorate %_struct_408 35 Offset 492 - OpMemberDecorate %_struct_408 36 Offset 496 - OpMemberDecorate %_struct_408 37 RowMajor - OpMemberDecorate %_struct_408 37 Offset 512 - OpMemberDecorate %_struct_408 37 MatrixStride 16 - OpMemberDecorate %_struct_408 38 Offset 640 - OpDecorate %_struct_408 Block - OpDecorate %15259 DescriptorSet 0 - OpDecorate %15259 Binding 1 - OpDecorate %5800 Location 0 - OpDecorate %gl_FragCoord BuiltIn FragCoord - OpDecorate %4317 Location 0 - OpMemberDecorate %_struct_1395 0 Offset 0 - OpMemberDecorate %_struct_1395 1 Offset 16 - OpMemberDecorate %_struct_1395 2 Offset 32 - OpMemberDecorate %_struct_1395 3 Offset 40 - OpMemberDecorate %_struct_1395 4 Offset 48 - OpMemberDecorate %_struct_1395 5 Offset 60 - OpMemberDecorate %_struct_1395 6 Offset 64 - OpMemberDecorate %_struct_1395 7 Offset 76 - OpMemberDecorate %_struct_1395 8 Offset 80 - OpMemberDecorate %_struct_1395 9 Offset 96 - OpMemberDecorate %_struct_1395 10 Offset 112 - OpMemberDecorate %_struct_1395 11 Offset 128 - OpMemberDecorate %_struct_1395 12 Offset 140 - OpMemberDecorate %_struct_1395 13 Offset 144 - OpMemberDecorate %_struct_1395 14 Offset 156 - OpMemberDecorate %_struct_1395 15 Offset 160 - OpMemberDecorate %_struct_1395 16 Offset 176 - OpMemberDecorate %_struct_1395 17 Offset 192 - OpMemberDecorate %_struct_1395 18 Offset 204 - OpMemberDecorate %_struct_1395 19 Offset 208 - OpMemberDecorate %_struct_1395 20 Offset 224 - OpDecorate %_struct_1395 Block - OpMemberDecorate %_struct_1018 0 Offset 0 - OpDecorate %_struct_1018 Block - %void = OpTypeVoid - %1282 = OpTypeFunction %void - %float = OpTypeFloat 32 - %v2float = OpTypeVector %float 2 - %v4float = OpTypeVector %float 4 - %v3float = OpTypeVector %float 3 -%_struct_1017 = OpTypeStruct %v4float -%_struct_1116 = OpTypeStruct %v4float %float %v4float -%_ptr_Uniform__struct_1116 = OpTypePointer Uniform %_struct_1116 - %22044 = OpVariable %_ptr_Uniform__struct_1116 Uniform - %int = OpTypeInt 32 1 - %int_0 = OpConstant %int 0 -%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float - %150 = OpTypeImage %float 2D 0 0 0 1 Unknown -%_ptr_UniformConstant_150 = OpTypePointer UniformConstant %150 - %5785 = OpVariable %_ptr_UniformConstant_150 UniformConstant - %508 = OpTypeSampler -%_ptr_UniformConstant_508 = OpTypePointer UniformConstant %508 - %5688 = OpVariable %_ptr_UniformConstant_508 UniformConstant - %510 = OpTypeSampledImage %150 - %float_0 = OpConstant %float 0 - %uint = OpTypeInt 32 0 - %int_1 = OpConstant %int 1 -%_ptr_Uniform_float = OpTypePointer Uniform %float - %float_1 = OpConstant %float 1 -%mat4v4float = OpTypeMatrix %v4float 4 -%_struct_994 = OpTypeStruct %v3float %v3float %float %v3float %float %v3float %float %v3float %float %v3float %float %v3float %float %v2float %v2float %v3float %float %float %float %float %float %v4float %v4float %mat4v4float %v4float -%_ptr_Uniform__struct_994 = OpTypePointer Uniform %_struct_994 - %12348 = OpVariable %_ptr_Uniform__struct_994 Uniform - %int_5 = OpConstant %int 5 -%_ptr_Uniform_v3float = OpTypePointer Uniform %v3float - %3312 = OpVariable %_ptr_UniformConstant_150 UniformConstant - %4646 = OpVariable %_ptr_UniformConstant_508 UniformConstant - %bool = OpTypeBool - %4862 = OpVariable %_ptr_UniformConstant_150 UniformConstant - %3594 = OpVariable %_ptr_UniformConstant_508 UniformConstant - %uint_2 = OpConstant %uint 2 - %2938 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0 -%_arr_mat4v4float_uint_2 = OpTypeArray %mat4v4float %uint_2 -%_arr_v4float_uint_2 = OpTypeArray %v4float %uint_2 -%_struct_408 = OpTypeStruct %mat4v4float %mat4v4float %mat4v4float %mat4v4float %v4float %v4float %float %float %float %float %v3float %float %v3float %float %v3float %float %v3float %float %float %float %v2float %v2float %v2float %v4float %v2float %v2float %v2float %v3float %float %float %float %float %float %v2float %float %float %v3float %_arr_mat4v4float_uint_2 %_arr_v4float_uint_2 -%_ptr_Uniform__struct_408 = OpTypePointer Uniform %_struct_408 - %15259 = OpVariable %_ptr_Uniform__struct_408 Uniform - %int_23 = OpConstant %int 23 - %int_2 = OpConstant %int 2 - %float_n2 = OpConstant %float -2 - %float_0_5 = OpConstant %float 0.5 - %1196 = OpConstantComposite %v3float %float_0 %float_n2 %float_0_5 - %float_n1 = OpConstant %float -1 - %836 = OpConstantComposite %v3float %float_n1 %float_n1 %float_0_5 - %float_0_75 = OpConstant %float 0.75 - %1367 = OpConstantComposite %v3float %float_0 %float_n1 %float_0_75 - %141 = OpConstantComposite %v3float %float_1 %float_n1 %float_0_5 - %38 = OpConstantComposite %v3float %float_n2 %float_0 %float_0_5 - %95 = OpConstantComposite %v3float %float_n1 %float_0 %float_0_75 - %626 = OpConstantComposite %v3float %float_0 %float_0 %float_1 - %2411 = OpConstantComposite %v3float %float_1 %float_0 %float_0_75 - %float_2 = OpConstant %float 2 - %2354 = OpConstantComposite %v3float %float_2 %float_0 %float_0_5 - %837 = OpConstantComposite %v3float %float_n1 %float_1 %float_0_5 - %1368 = OpConstantComposite %v3float %float_0 %float_1 %float_0_75 - %142 = OpConstantComposite %v3float %float_1 %float_1 %float_0_5 - %1197 = OpConstantComposite %v3float %float_0 %float_2 %float_0_5 -%_ptr_Input_v2float = OpTypePointer Input %v2float - %5800 = OpVariable %_ptr_Input_v2float Input -%_ptr_Input_v4float = OpTypePointer Input %v4float -%gl_FragCoord = OpVariable %_ptr_Input_v4float Input -%_ptr_Output_v4float = OpTypePointer Output %v4float - %4317 = OpVariable %_ptr_Output_v4float Output -%_struct_1395 = OpTypeStruct %v4float %v4float %v2float %v2float %v3float %float %v3float %float %v4float %v4float %v4float %v3float %float %v3float %float %v3float %v4float %v3float %float %v3float %v2float -%_struct_1018 = OpTypeStruct %v4float - %10264 = OpUndef %_struct_1017 - %5663 = OpFunction %void None %1282 - %25006 = OpLabel - %17463 = OpLoad %v4float %gl_FragCoord - %13863 = OpCompositeInsert %_struct_1017 %2938 %10264 0 - %22969 = OpVectorShuffle %v2float %17463 %17463 0 1 - %13206 = OpAccessChain %_ptr_Uniform_v4float %15259 %int_23 - %10343 = OpLoad %v4float %13206 - %7422 = OpVectorShuffle %v2float %10343 %10343 0 1 - %19927 = OpFMul %v2float %22969 %7422 - %18174 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_2 - %16206 = OpLoad %v4float %18174 - %20420 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 - %21354 = OpLoad %v4float %20420 - %7688 = OpVectorShuffle %v4float %21354 %21354 0 1 0 1 - %17581 = OpFMul %v4float %16206 %7688 - %10673 = OpVectorShuffle %v2float %1196 %1196 0 1 - %18824 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 - %10344 = OpLoad %v4float %18824 - %8638 = OpVectorShuffle %v2float %10344 %10344 0 1 - %9197 = OpFMul %v2float %10673 %8638 - %18505 = OpFAdd %v2float %19927 %9197 - %7011 = OpVectorShuffle %v2float %17581 %17581 0 1 - %21058 = OpVectorShuffle %v2float %17581 %17581 2 3 - %13149 = OpExtInst %v2float %1 FClamp %18505 %7011 %21058 - %23584 = OpLoad %150 %5785 - %10339 = OpLoad %508 %5688 - %12147 = OpSampledImage %510 %23584 %10339 - %15371 = OpImageSampleExplicitLod %v4float %12147 %13149 Lod %float_0 - %15266 = OpCompositeExtract %float %15371 3 - %12116 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 - %12972 = OpLoad %float %12116 - %15710 = OpFMul %float %15266 %12972 - %15279 = OpExtInst %float %1 FClamp %15710 %float_0 %float_1 - %22213 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 - %11756 = OpLoad %v3float %22213 - %12103 = OpVectorTimesScalar %v3float %11756 %15279 - %15516 = OpLoad %150 %3312 - %24569 = OpLoad %508 %4646 - %12148 = OpSampledImage %510 %15516 %24569 - %17670 = OpImageSampleExplicitLod %v4float %12148 %13149 Lod %float_0 - %16938 = OpCompositeExtract %float %17670 1 - %14185 = OpFOrdGreaterThan %bool %16938 %float_0 - OpSelectionMerge %22307 DontFlatten - OpBranchConditional %14185 %12821 %22307 - %12821 = OpLabel - %13239 = OpLoad %150 %4862 - %19960 = OpLoad %508 %3594 - %12149 = OpSampledImage %510 %13239 %19960 - %15675 = OpImageSampleExplicitLod %v4float %12149 %13149 Lod %float_0 - %13866 = OpCompositeExtract %float %17670 1 - %12427 = OpCompositeExtract %float %17670 2 - %23300 = OpFMul %float %13866 %12427 - %17612 = OpExtInst %float %1 FClamp %23300 %float_0 %float_1 - %20291 = OpVectorShuffle %v3float %15675 %15675 0 1 2 - %11186 = OpVectorTimesScalar %v3float %20291 %17612 - %15293 = OpFAdd %v3float %12103 %11186 - OpBranch %22307 - %22307 = OpLabel - %7719 = OpPhi %v3float %12103 %25006 %15293 %12821 - %23399 = OpVectorTimesScalar %v3float %7719 %float_0_5 - %9339 = OpFAdd %float %float_0 %float_0_5 - %16235 = OpVectorShuffle %v3float %2938 %2938 0 1 2 - %22177 = OpFAdd %v3float %16235 %23399 - %15527 = OpVectorShuffle %v4float %2938 %22177 4 5 6 3 - %6434 = OpCompositeInsert %_struct_1017 %15527 %13863 0 - %24572 = OpVectorShuffle %v2float %836 %836 0 1 - %13207 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 - %10345 = OpLoad %v4float %13207 - %8639 = OpVectorShuffle %v2float %10345 %10345 0 1 - %9198 = OpFMul %v2float %24572 %8639 - %18506 = OpFAdd %v2float %19927 %9198 - %7012 = OpVectorShuffle %v2float %17581 %17581 0 1 - %21059 = OpVectorShuffle %v2float %17581 %17581 2 3 - %13150 = OpExtInst %v2float %1 FClamp %18506 %7012 %21059 - %23585 = OpLoad %150 %5785 - %10340 = OpLoad %508 %5688 - %12150 = OpSampledImage %510 %23585 %10340 - %15372 = OpImageSampleExplicitLod %v4float %12150 %13150 Lod %float_0 - %15267 = OpCompositeExtract %float %15372 3 - %12117 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 - %12973 = OpLoad %float %12117 - %15711 = OpFMul %float %15267 %12973 - %15280 = OpExtInst %float %1 FClamp %15711 %float_0 %float_1 - %22214 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 - %11757 = OpLoad %v3float %22214 - %12104 = OpVectorTimesScalar %v3float %11757 %15280 - %15517 = OpLoad %150 %3312 - %24570 = OpLoad %508 %4646 - %12151 = OpSampledImage %510 %15517 %24570 - %17671 = OpImageSampleExplicitLod %v4float %12151 %13150 Lod %float_0 - %16939 = OpCompositeExtract %float %17671 1 - %14186 = OpFOrdGreaterThan %bool %16939 %float_0 - OpSelectionMerge %22308 DontFlatten - OpBranchConditional %14186 %12822 %22308 - %12822 = OpLabel - %13240 = OpLoad %150 %4862 - %19961 = OpLoad %508 %3594 - %12152 = OpSampledImage %510 %13240 %19961 - %15676 = OpImageSampleExplicitLod %v4float %12152 %13150 Lod %float_0 - %13867 = OpCompositeExtract %float %17671 1 - %12428 = OpCompositeExtract %float %17671 2 - %23301 = OpFMul %float %13867 %12428 - %17613 = OpExtInst %float %1 FClamp %23301 %float_0 %float_1 - %20292 = OpVectorShuffle %v3float %15676 %15676 0 1 2 - %11187 = OpVectorTimesScalar %v3float %20292 %17613 - %15294 = OpFAdd %v3float %12104 %11187 - OpBranch %22308 - %22308 = OpLabel - %7720 = OpPhi %v3float %12104 %22307 %15294 %12822 - %23400 = OpVectorTimesScalar %v3float %7720 %float_0_5 - %9340 = OpFAdd %float %9339 %float_0_5 - %16236 = OpVectorShuffle %v3float %15527 %15527 0 1 2 - %22178 = OpFAdd %v3float %16236 %23400 - %15528 = OpVectorShuffle %v4float %15527 %22178 4 5 6 3 - %6435 = OpCompositeInsert %_struct_1017 %15528 %6434 0 - %24573 = OpVectorShuffle %v2float %1367 %1367 0 1 - %13208 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 - %10346 = OpLoad %v4float %13208 - %8640 = OpVectorShuffle %v2float %10346 %10346 0 1 - %9199 = OpFMul %v2float %24573 %8640 - %18507 = OpFAdd %v2float %19927 %9199 - %7013 = OpVectorShuffle %v2float %17581 %17581 0 1 - %21060 = OpVectorShuffle %v2float %17581 %17581 2 3 - %13151 = OpExtInst %v2float %1 FClamp %18507 %7013 %21060 - %23586 = OpLoad %150 %5785 - %10341 = OpLoad %508 %5688 - %12153 = OpSampledImage %510 %23586 %10341 - %15373 = OpImageSampleExplicitLod %v4float %12153 %13151 Lod %float_0 - %15268 = OpCompositeExtract %float %15373 3 - %12118 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 - %12974 = OpLoad %float %12118 - %15712 = OpFMul %float %15268 %12974 - %15281 = OpExtInst %float %1 FClamp %15712 %float_0 %float_1 - %22215 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 - %11758 = OpLoad %v3float %22215 - %12105 = OpVectorTimesScalar %v3float %11758 %15281 - %15518 = OpLoad %150 %3312 - %24571 = OpLoad %508 %4646 - %12154 = OpSampledImage %510 %15518 %24571 - %17672 = OpImageSampleExplicitLod %v4float %12154 %13151 Lod %float_0 - %16940 = OpCompositeExtract %float %17672 1 - %14187 = OpFOrdGreaterThan %bool %16940 %float_0 - OpSelectionMerge %22309 DontFlatten - OpBranchConditional %14187 %12823 %22309 - %12823 = OpLabel - %13241 = OpLoad %150 %4862 - %19962 = OpLoad %508 %3594 - %12155 = OpSampledImage %510 %13241 %19962 - %15677 = OpImageSampleExplicitLod %v4float %12155 %13151 Lod %float_0 - %13868 = OpCompositeExtract %float %17672 1 - %12429 = OpCompositeExtract %float %17672 2 - %23302 = OpFMul %float %13868 %12429 - %17614 = OpExtInst %float %1 FClamp %23302 %float_0 %float_1 - %20293 = OpVectorShuffle %v3float %15677 %15677 0 1 2 - %11188 = OpVectorTimesScalar %v3float %20293 %17614 - %15295 = OpFAdd %v3float %12105 %11188 - OpBranch %22309 - %22309 = OpLabel - %7721 = OpPhi %v3float %12105 %22308 %15295 %12823 - %23401 = OpVectorTimesScalar %v3float %7721 %float_0_75 - %9341 = OpFAdd %float %9340 %float_0_75 - %16237 = OpVectorShuffle %v3float %15528 %15528 0 1 2 - %22179 = OpFAdd %v3float %16237 %23401 - %15529 = OpVectorShuffle %v4float %15528 %22179 4 5 6 3 - %6436 = OpCompositeInsert %_struct_1017 %15529 %6435 0 - %24574 = OpVectorShuffle %v2float %141 %141 0 1 - %13209 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 - %10347 = OpLoad %v4float %13209 - %8641 = OpVectorShuffle %v2float %10347 %10347 0 1 - %9200 = OpFMul %v2float %24574 %8641 - %18508 = OpFAdd %v2float %19927 %9200 - %7014 = OpVectorShuffle %v2float %17581 %17581 0 1 - %21061 = OpVectorShuffle %v2float %17581 %17581 2 3 - %13152 = OpExtInst %v2float %1 FClamp %18508 %7014 %21061 - %23587 = OpLoad %150 %5785 - %10342 = OpLoad %508 %5688 - %12156 = OpSampledImage %510 %23587 %10342 - %15374 = OpImageSampleExplicitLod %v4float %12156 %13152 Lod %float_0 - %15269 = OpCompositeExtract %float %15374 3 - %12119 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 - %12975 = OpLoad %float %12119 - %15713 = OpFMul %float %15269 %12975 - %15282 = OpExtInst %float %1 FClamp %15713 %float_0 %float_1 - %22216 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 - %11759 = OpLoad %v3float %22216 - %12106 = OpVectorTimesScalar %v3float %11759 %15282 - %15519 = OpLoad %150 %3312 - %24575 = OpLoad %508 %4646 - %12157 = OpSampledImage %510 %15519 %24575 - %17673 = OpImageSampleExplicitLod %v4float %12157 %13152 Lod %float_0 - %16941 = OpCompositeExtract %float %17673 1 - %14188 = OpFOrdGreaterThan %bool %16941 %float_0 - OpSelectionMerge %22310 DontFlatten - OpBranchConditional %14188 %12824 %22310 - %12824 = OpLabel - %13242 = OpLoad %150 %4862 - %19963 = OpLoad %508 %3594 - %12158 = OpSampledImage %510 %13242 %19963 - %15678 = OpImageSampleExplicitLod %v4float %12158 %13152 Lod %float_0 - %13869 = OpCompositeExtract %float %17673 1 - %12430 = OpCompositeExtract %float %17673 2 - %23303 = OpFMul %float %13869 %12430 - %17615 = OpExtInst %float %1 FClamp %23303 %float_0 %float_1 - %20294 = OpVectorShuffle %v3float %15678 %15678 0 1 2 - %11189 = OpVectorTimesScalar %v3float %20294 %17615 - %15296 = OpFAdd %v3float %12106 %11189 - OpBranch %22310 - %22310 = OpLabel - %7722 = OpPhi %v3float %12106 %22309 %15296 %12824 - %23402 = OpVectorTimesScalar %v3float %7722 %float_0_5 - %9342 = OpFAdd %float %9341 %float_0_5 - %16238 = OpVectorShuffle %v3float %15529 %15529 0 1 2 - %22180 = OpFAdd %v3float %16238 %23402 - %15530 = OpVectorShuffle %v4float %15529 %22180 4 5 6 3 - %6437 = OpCompositeInsert %_struct_1017 %15530 %6436 0 - %24576 = OpVectorShuffle %v2float %38 %38 0 1 - %13210 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 - %10348 = OpLoad %v4float %13210 - %8642 = OpVectorShuffle %v2float %10348 %10348 0 1 - %9201 = OpFMul %v2float %24576 %8642 - %18509 = OpFAdd %v2float %19927 %9201 - %7015 = OpVectorShuffle %v2float %17581 %17581 0 1 - %21062 = OpVectorShuffle %v2float %17581 %17581 2 3 - %13153 = OpExtInst %v2float %1 FClamp %18509 %7015 %21062 - %23588 = OpLoad %150 %5785 - %10349 = OpLoad %508 %5688 - %12159 = OpSampledImage %510 %23588 %10349 - %15375 = OpImageSampleExplicitLod %v4float %12159 %13153 Lod %float_0 - %15270 = OpCompositeExtract %float %15375 3 - %12120 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 - %12976 = OpLoad %float %12120 - %15714 = OpFMul %float %15270 %12976 - %15283 = OpExtInst %float %1 FClamp %15714 %float_0 %float_1 - %22217 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 - %11760 = OpLoad %v3float %22217 - %12107 = OpVectorTimesScalar %v3float %11760 %15283 - %15520 = OpLoad %150 %3312 - %24577 = OpLoad %508 %4646 - %12160 = OpSampledImage %510 %15520 %24577 - %17674 = OpImageSampleExplicitLod %v4float %12160 %13153 Lod %float_0 - %16942 = OpCompositeExtract %float %17674 1 - %14189 = OpFOrdGreaterThan %bool %16942 %float_0 - OpSelectionMerge %22311 DontFlatten - OpBranchConditional %14189 %12825 %22311 - %12825 = OpLabel - %13243 = OpLoad %150 %4862 - %19964 = OpLoad %508 %3594 - %12161 = OpSampledImage %510 %13243 %19964 - %15679 = OpImageSampleExplicitLod %v4float %12161 %13153 Lod %float_0 - %13870 = OpCompositeExtract %float %17674 1 - %12431 = OpCompositeExtract %float %17674 2 - %23304 = OpFMul %float %13870 %12431 - %17616 = OpExtInst %float %1 FClamp %23304 %float_0 %float_1 - %20295 = OpVectorShuffle %v3float %15679 %15679 0 1 2 - %11190 = OpVectorTimesScalar %v3float %20295 %17616 - %15297 = OpFAdd %v3float %12107 %11190 - OpBranch %22311 - %22311 = OpLabel - %7723 = OpPhi %v3float %12107 %22310 %15297 %12825 - %23403 = OpVectorTimesScalar %v3float %7723 %float_0_5 - %9343 = OpFAdd %float %9342 %float_0_5 - %16239 = OpVectorShuffle %v3float %15530 %15530 0 1 2 - %22181 = OpFAdd %v3float %16239 %23403 - %15531 = OpVectorShuffle %v4float %15530 %22181 4 5 6 3 - %6438 = OpCompositeInsert %_struct_1017 %15531 %6437 0 - %24578 = OpVectorShuffle %v2float %95 %95 0 1 - %13211 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 - %10350 = OpLoad %v4float %13211 - %8643 = OpVectorShuffle %v2float %10350 %10350 0 1 - %9202 = OpFMul %v2float %24578 %8643 - %18510 = OpFAdd %v2float %19927 %9202 - %7016 = OpVectorShuffle %v2float %17581 %17581 0 1 - %21063 = OpVectorShuffle %v2float %17581 %17581 2 3 - %13154 = OpExtInst %v2float %1 FClamp %18510 %7016 %21063 - %23589 = OpLoad %150 %5785 - %10351 = OpLoad %508 %5688 - %12162 = OpSampledImage %510 %23589 %10351 - %15376 = OpImageSampleExplicitLod %v4float %12162 %13154 Lod %float_0 - %15271 = OpCompositeExtract %float %15376 3 - %12121 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 - %12977 = OpLoad %float %12121 - %15715 = OpFMul %float %15271 %12977 - %15284 = OpExtInst %float %1 FClamp %15715 %float_0 %float_1 - %22218 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 - %11761 = OpLoad %v3float %22218 - %12108 = OpVectorTimesScalar %v3float %11761 %15284 - %15521 = OpLoad %150 %3312 - %24579 = OpLoad %508 %4646 - %12163 = OpSampledImage %510 %15521 %24579 - %17675 = OpImageSampleExplicitLod %v4float %12163 %13154 Lod %float_0 - %16943 = OpCompositeExtract %float %17675 1 - %14190 = OpFOrdGreaterThan %bool %16943 %float_0 - OpSelectionMerge %22312 DontFlatten - OpBranchConditional %14190 %12826 %22312 - %12826 = OpLabel - %13244 = OpLoad %150 %4862 - %19965 = OpLoad %508 %3594 - %12164 = OpSampledImage %510 %13244 %19965 - %15680 = OpImageSampleExplicitLod %v4float %12164 %13154 Lod %float_0 - %13871 = OpCompositeExtract %float %17675 1 - %12432 = OpCompositeExtract %float %17675 2 - %23305 = OpFMul %float %13871 %12432 - %17617 = OpExtInst %float %1 FClamp %23305 %float_0 %float_1 - %20296 = OpVectorShuffle %v3float %15680 %15680 0 1 2 - %11191 = OpVectorTimesScalar %v3float %20296 %17617 - %15298 = OpFAdd %v3float %12108 %11191 - OpBranch %22312 - %22312 = OpLabel - %7724 = OpPhi %v3float %12108 %22311 %15298 %12826 - %23404 = OpVectorTimesScalar %v3float %7724 %float_0_75 - %9344 = OpFAdd %float %9343 %float_0_75 - %16240 = OpVectorShuffle %v3float %15531 %15531 0 1 2 - %22182 = OpFAdd %v3float %16240 %23404 - %15532 = OpVectorShuffle %v4float %15531 %22182 4 5 6 3 - %6439 = OpCompositeInsert %_struct_1017 %15532 %6438 0 - %24580 = OpVectorShuffle %v2float %626 %626 0 1 - %13212 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 - %10352 = OpLoad %v4float %13212 - %8644 = OpVectorShuffle %v2float %10352 %10352 0 1 - %9203 = OpFMul %v2float %24580 %8644 - %18511 = OpFAdd %v2float %19927 %9203 - %7017 = OpVectorShuffle %v2float %17581 %17581 0 1 - %21064 = OpVectorShuffle %v2float %17581 %17581 2 3 - %13155 = OpExtInst %v2float %1 FClamp %18511 %7017 %21064 - %23590 = OpLoad %150 %5785 - %10353 = OpLoad %508 %5688 - %12165 = OpSampledImage %510 %23590 %10353 - %15377 = OpImageSampleExplicitLod %v4float %12165 %13155 Lod %float_0 - %15272 = OpCompositeExtract %float %15377 3 - %12122 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 - %12978 = OpLoad %float %12122 - %15716 = OpFMul %float %15272 %12978 - %15285 = OpExtInst %float %1 FClamp %15716 %float_0 %float_1 - %22219 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 - %11762 = OpLoad %v3float %22219 - %12109 = OpVectorTimesScalar %v3float %11762 %15285 - %15522 = OpLoad %150 %3312 - %24581 = OpLoad %508 %4646 - %12166 = OpSampledImage %510 %15522 %24581 - %17676 = OpImageSampleExplicitLod %v4float %12166 %13155 Lod %float_0 - %16944 = OpCompositeExtract %float %17676 1 - %14191 = OpFOrdGreaterThan %bool %16944 %float_0 - OpSelectionMerge %22313 DontFlatten - OpBranchConditional %14191 %12827 %22313 - %12827 = OpLabel - %13245 = OpLoad %150 %4862 - %19966 = OpLoad %508 %3594 - %12167 = OpSampledImage %510 %13245 %19966 - %15681 = OpImageSampleExplicitLod %v4float %12167 %13155 Lod %float_0 - %13872 = OpCompositeExtract %float %17676 1 - %12433 = OpCompositeExtract %float %17676 2 - %23306 = OpFMul %float %13872 %12433 - %17618 = OpExtInst %float %1 FClamp %23306 %float_0 %float_1 - %20297 = OpVectorShuffle %v3float %15681 %15681 0 1 2 - %11192 = OpVectorTimesScalar %v3float %20297 %17618 - %15299 = OpFAdd %v3float %12109 %11192 - OpBranch %22313 - %22313 = OpLabel - %7725 = OpPhi %v3float %12109 %22312 %15299 %12827 - %23405 = OpVectorTimesScalar %v3float %7725 %float_1 - %9345 = OpFAdd %float %9344 %float_1 - %16241 = OpVectorShuffle %v3float %15532 %15532 0 1 2 - %22183 = OpFAdd %v3float %16241 %23405 - %15533 = OpVectorShuffle %v4float %15532 %22183 4 5 6 3 - %6440 = OpCompositeInsert %_struct_1017 %15533 %6439 0 - %24582 = OpVectorShuffle %v2float %2411 %2411 0 1 - %13213 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 - %10354 = OpLoad %v4float %13213 - %8645 = OpVectorShuffle %v2float %10354 %10354 0 1 - %9204 = OpFMul %v2float %24582 %8645 - %18512 = OpFAdd %v2float %19927 %9204 - %7018 = OpVectorShuffle %v2float %17581 %17581 0 1 - %21065 = OpVectorShuffle %v2float %17581 %17581 2 3 - %13156 = OpExtInst %v2float %1 FClamp %18512 %7018 %21065 - %23591 = OpLoad %150 %5785 - %10355 = OpLoad %508 %5688 - %12168 = OpSampledImage %510 %23591 %10355 - %15378 = OpImageSampleExplicitLod %v4float %12168 %13156 Lod %float_0 - %15273 = OpCompositeExtract %float %15378 3 - %12123 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 - %12979 = OpLoad %float %12123 - %15717 = OpFMul %float %15273 %12979 - %15286 = OpExtInst %float %1 FClamp %15717 %float_0 %float_1 - %22220 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 - %11763 = OpLoad %v3float %22220 - %12110 = OpVectorTimesScalar %v3float %11763 %15286 - %15523 = OpLoad %150 %3312 - %24583 = OpLoad %508 %4646 - %12169 = OpSampledImage %510 %15523 %24583 - %17677 = OpImageSampleExplicitLod %v4float %12169 %13156 Lod %float_0 - %16945 = OpCompositeExtract %float %17677 1 - %14192 = OpFOrdGreaterThan %bool %16945 %float_0 - OpSelectionMerge %22314 DontFlatten - OpBranchConditional %14192 %12828 %22314 - %12828 = OpLabel - %13246 = OpLoad %150 %4862 - %19967 = OpLoad %508 %3594 - %12170 = OpSampledImage %510 %13246 %19967 - %15682 = OpImageSampleExplicitLod %v4float %12170 %13156 Lod %float_0 - %13873 = OpCompositeExtract %float %17677 1 - %12434 = OpCompositeExtract %float %17677 2 - %23307 = OpFMul %float %13873 %12434 - %17619 = OpExtInst %float %1 FClamp %23307 %float_0 %float_1 - %20298 = OpVectorShuffle %v3float %15682 %15682 0 1 2 - %11193 = OpVectorTimesScalar %v3float %20298 %17619 - %15300 = OpFAdd %v3float %12110 %11193 - OpBranch %22314 - %22314 = OpLabel - %7726 = OpPhi %v3float %12110 %22313 %15300 %12828 - %23406 = OpVectorTimesScalar %v3float %7726 %float_0_75 - %9346 = OpFAdd %float %9345 %float_0_75 - %16242 = OpVectorShuffle %v3float %15533 %15533 0 1 2 - %22184 = OpFAdd %v3float %16242 %23406 - %15534 = OpVectorShuffle %v4float %15533 %22184 4 5 6 3 - %6441 = OpCompositeInsert %_struct_1017 %15534 %6440 0 - %24584 = OpVectorShuffle %v2float %2354 %2354 0 1 - %13214 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 - %10356 = OpLoad %v4float %13214 - %8646 = OpVectorShuffle %v2float %10356 %10356 0 1 - %9205 = OpFMul %v2float %24584 %8646 - %18513 = OpFAdd %v2float %19927 %9205 - %7019 = OpVectorShuffle %v2float %17581 %17581 0 1 - %21066 = OpVectorShuffle %v2float %17581 %17581 2 3 - %13157 = OpExtInst %v2float %1 FClamp %18513 %7019 %21066 - %23592 = OpLoad %150 %5785 - %10357 = OpLoad %508 %5688 - %12171 = OpSampledImage %510 %23592 %10357 - %15379 = OpImageSampleExplicitLod %v4float %12171 %13157 Lod %float_0 - %15274 = OpCompositeExtract %float %15379 3 - %12124 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 - %12980 = OpLoad %float %12124 - %15718 = OpFMul %float %15274 %12980 - %15287 = OpExtInst %float %1 FClamp %15718 %float_0 %float_1 - %22221 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 - %11764 = OpLoad %v3float %22221 - %12111 = OpVectorTimesScalar %v3float %11764 %15287 - %15524 = OpLoad %150 %3312 - %24585 = OpLoad %508 %4646 - %12172 = OpSampledImage %510 %15524 %24585 - %17678 = OpImageSampleExplicitLod %v4float %12172 %13157 Lod %float_0 - %16946 = OpCompositeExtract %float %17678 1 - %14193 = OpFOrdGreaterThan %bool %16946 %float_0 - OpSelectionMerge %22315 DontFlatten - OpBranchConditional %14193 %12829 %22315 - %12829 = OpLabel - %13247 = OpLoad %150 %4862 - %19968 = OpLoad %508 %3594 - %12173 = OpSampledImage %510 %13247 %19968 - %15683 = OpImageSampleExplicitLod %v4float %12173 %13157 Lod %float_0 - %13874 = OpCompositeExtract %float %17678 1 - %12435 = OpCompositeExtract %float %17678 2 - %23308 = OpFMul %float %13874 %12435 - %17620 = OpExtInst %float %1 FClamp %23308 %float_0 %float_1 - %20299 = OpVectorShuffle %v3float %15683 %15683 0 1 2 - %11194 = OpVectorTimesScalar %v3float %20299 %17620 - %15301 = OpFAdd %v3float %12111 %11194 - OpBranch %22315 - %22315 = OpLabel - %7727 = OpPhi %v3float %12111 %22314 %15301 %12829 - %23407 = OpVectorTimesScalar %v3float %7727 %float_0_5 - %9347 = OpFAdd %float %9346 %float_0_5 - %16243 = OpVectorShuffle %v3float %15534 %15534 0 1 2 - %22185 = OpFAdd %v3float %16243 %23407 - %15535 = OpVectorShuffle %v4float %15534 %22185 4 5 6 3 - %6442 = OpCompositeInsert %_struct_1017 %15535 %6441 0 - %24586 = OpVectorShuffle %v2float %837 %837 0 1 - %13215 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 - %10358 = OpLoad %v4float %13215 - %8647 = OpVectorShuffle %v2float %10358 %10358 0 1 - %9206 = OpFMul %v2float %24586 %8647 - %18514 = OpFAdd %v2float %19927 %9206 - %7020 = OpVectorShuffle %v2float %17581 %17581 0 1 - %21067 = OpVectorShuffle %v2float %17581 %17581 2 3 - %13158 = OpExtInst %v2float %1 FClamp %18514 %7020 %21067 - %23593 = OpLoad %150 %5785 - %10359 = OpLoad %508 %5688 - %12174 = OpSampledImage %510 %23593 %10359 - %15380 = OpImageSampleExplicitLod %v4float %12174 %13158 Lod %float_0 - %15275 = OpCompositeExtract %float %15380 3 - %12125 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 - %12981 = OpLoad %float %12125 - %15719 = OpFMul %float %15275 %12981 - %15288 = OpExtInst %float %1 FClamp %15719 %float_0 %float_1 - %22222 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 - %11765 = OpLoad %v3float %22222 - %12112 = OpVectorTimesScalar %v3float %11765 %15288 - %15525 = OpLoad %150 %3312 - %24587 = OpLoad %508 %4646 - %12175 = OpSampledImage %510 %15525 %24587 - %17679 = OpImageSampleExplicitLod %v4float %12175 %13158 Lod %float_0 - %16947 = OpCompositeExtract %float %17679 1 - %14194 = OpFOrdGreaterThan %bool %16947 %float_0 - OpSelectionMerge %22316 DontFlatten - OpBranchConditional %14194 %12830 %22316 - %12830 = OpLabel - %13248 = OpLoad %150 %4862 - %19969 = OpLoad %508 %3594 - %12176 = OpSampledImage %510 %13248 %19969 - %15684 = OpImageSampleExplicitLod %v4float %12176 %13158 Lod %float_0 - %13875 = OpCompositeExtract %float %17679 1 - %12436 = OpCompositeExtract %float %17679 2 - %23309 = OpFMul %float %13875 %12436 - %17621 = OpExtInst %float %1 FClamp %23309 %float_0 %float_1 - %20300 = OpVectorShuffle %v3float %15684 %15684 0 1 2 - %11195 = OpVectorTimesScalar %v3float %20300 %17621 - %15302 = OpFAdd %v3float %12112 %11195 - OpBranch %22316 - %22316 = OpLabel - %7728 = OpPhi %v3float %12112 %22315 %15302 %12830 - %23408 = OpVectorTimesScalar %v3float %7728 %float_0_5 - %9348 = OpFAdd %float %9347 %float_0_5 - %16244 = OpVectorShuffle %v3float %15535 %15535 0 1 2 - %22186 = OpFAdd %v3float %16244 %23408 - %15536 = OpVectorShuffle %v4float %15535 %22186 4 5 6 3 - %6443 = OpCompositeInsert %_struct_1017 %15536 %6442 0 - %24588 = OpVectorShuffle %v2float %1368 %1368 0 1 - %13216 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 - %10360 = OpLoad %v4float %13216 - %8648 = OpVectorShuffle %v2float %10360 %10360 0 1 - %9207 = OpFMul %v2float %24588 %8648 - %18515 = OpFAdd %v2float %19927 %9207 - %7021 = OpVectorShuffle %v2float %17581 %17581 0 1 - %21068 = OpVectorShuffle %v2float %17581 %17581 2 3 - %13159 = OpExtInst %v2float %1 FClamp %18515 %7021 %21068 - %23594 = OpLoad %150 %5785 - %10361 = OpLoad %508 %5688 - %12177 = OpSampledImage %510 %23594 %10361 - %15381 = OpImageSampleExplicitLod %v4float %12177 %13159 Lod %float_0 - %15276 = OpCompositeExtract %float %15381 3 - %12126 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 - %12982 = OpLoad %float %12126 - %15720 = OpFMul %float %15276 %12982 - %15289 = OpExtInst %float %1 FClamp %15720 %float_0 %float_1 - %22223 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 - %11766 = OpLoad %v3float %22223 - %12113 = OpVectorTimesScalar %v3float %11766 %15289 - %15526 = OpLoad %150 %3312 - %24589 = OpLoad %508 %4646 - %12178 = OpSampledImage %510 %15526 %24589 - %17680 = OpImageSampleExplicitLod %v4float %12178 %13159 Lod %float_0 - %16948 = OpCompositeExtract %float %17680 1 - %14195 = OpFOrdGreaterThan %bool %16948 %float_0 - OpSelectionMerge %22317 DontFlatten - OpBranchConditional %14195 %12831 %22317 - %12831 = OpLabel - %13249 = OpLoad %150 %4862 - %19970 = OpLoad %508 %3594 - %12179 = OpSampledImage %510 %13249 %19970 - %15685 = OpImageSampleExplicitLod %v4float %12179 %13159 Lod %float_0 - %13876 = OpCompositeExtract %float %17680 1 - %12437 = OpCompositeExtract %float %17680 2 - %23310 = OpFMul %float %13876 %12437 - %17622 = OpExtInst %float %1 FClamp %23310 %float_0 %float_1 - %20301 = OpVectorShuffle %v3float %15685 %15685 0 1 2 - %11196 = OpVectorTimesScalar %v3float %20301 %17622 - %15303 = OpFAdd %v3float %12113 %11196 - OpBranch %22317 - %22317 = OpLabel - %7729 = OpPhi %v3float %12113 %22316 %15303 %12831 - %23409 = OpVectorTimesScalar %v3float %7729 %float_0_75 - %9349 = OpFAdd %float %9348 %float_0_75 - %16245 = OpVectorShuffle %v3float %15536 %15536 0 1 2 - %22187 = OpFAdd %v3float %16245 %23409 - %15537 = OpVectorShuffle %v4float %15536 %22187 4 5 6 3 - %6444 = OpCompositeInsert %_struct_1017 %15537 %6443 0 - %24590 = OpVectorShuffle %v2float %142 %142 0 1 - %13217 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 - %10362 = OpLoad %v4float %13217 - %8649 = OpVectorShuffle %v2float %10362 %10362 0 1 - %9208 = OpFMul %v2float %24590 %8649 - %18516 = OpFAdd %v2float %19927 %9208 - %7022 = OpVectorShuffle %v2float %17581 %17581 0 1 - %21069 = OpVectorShuffle %v2float %17581 %17581 2 3 - %13160 = OpExtInst %v2float %1 FClamp %18516 %7022 %21069 - %23595 = OpLoad %150 %5785 - %10363 = OpLoad %508 %5688 - %12180 = OpSampledImage %510 %23595 %10363 - %15382 = OpImageSampleExplicitLod %v4float %12180 %13160 Lod %float_0 - %15277 = OpCompositeExtract %float %15382 3 - %12127 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 - %12983 = OpLoad %float %12127 - %15721 = OpFMul %float %15277 %12983 - %15290 = OpExtInst %float %1 FClamp %15721 %float_0 %float_1 - %22224 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 - %11767 = OpLoad %v3float %22224 - %12114 = OpVectorTimesScalar %v3float %11767 %15290 - %15538 = OpLoad %150 %3312 - %24591 = OpLoad %508 %4646 - %12181 = OpSampledImage %510 %15538 %24591 - %17681 = OpImageSampleExplicitLod %v4float %12181 %13160 Lod %float_0 - %16949 = OpCompositeExtract %float %17681 1 - %14196 = OpFOrdGreaterThan %bool %16949 %float_0 - OpSelectionMerge %22318 DontFlatten - OpBranchConditional %14196 %12832 %22318 - %12832 = OpLabel - %13250 = OpLoad %150 %4862 - %19971 = OpLoad %508 %3594 - %12182 = OpSampledImage %510 %13250 %19971 - %15686 = OpImageSampleExplicitLod %v4float %12182 %13160 Lod %float_0 - %13877 = OpCompositeExtract %float %17681 1 - %12438 = OpCompositeExtract %float %17681 2 - %23311 = OpFMul %float %13877 %12438 - %17623 = OpExtInst %float %1 FClamp %23311 %float_0 %float_1 - %20302 = OpVectorShuffle %v3float %15686 %15686 0 1 2 - %11197 = OpVectorTimesScalar %v3float %20302 %17623 - %15304 = OpFAdd %v3float %12114 %11197 - OpBranch %22318 - %22318 = OpLabel - %7730 = OpPhi %v3float %12114 %22317 %15304 %12832 - %23410 = OpVectorTimesScalar %v3float %7730 %float_0_5 - %9350 = OpFAdd %float %9349 %float_0_5 - %16246 = OpVectorShuffle %v3float %15537 %15537 0 1 2 - %22188 = OpFAdd %v3float %16246 %23410 - %15539 = OpVectorShuffle %v4float %15537 %22188 4 5 6 3 - %6445 = OpCompositeInsert %_struct_1017 %15539 %6444 0 - %24592 = OpVectorShuffle %v2float %1197 %1197 0 1 - %13218 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 - %10364 = OpLoad %v4float %13218 - %8650 = OpVectorShuffle %v2float %10364 %10364 0 1 - %9209 = OpFMul %v2float %24592 %8650 - %18517 = OpFAdd %v2float %19927 %9209 - %7023 = OpVectorShuffle %v2float %17581 %17581 0 1 - %21070 = OpVectorShuffle %v2float %17581 %17581 2 3 - %13161 = OpExtInst %v2float %1 FClamp %18517 %7023 %21070 - %23596 = OpLoad %150 %5785 - %10365 = OpLoad %508 %5688 - %12183 = OpSampledImage %510 %23596 %10365 - %15383 = OpImageSampleExplicitLod %v4float %12183 %13161 Lod %float_0 - %15278 = OpCompositeExtract %float %15383 3 - %12128 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 - %12984 = OpLoad %float %12128 - %15722 = OpFMul %float %15278 %12984 - %15291 = OpExtInst %float %1 FClamp %15722 %float_0 %float_1 - %22225 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 - %11768 = OpLoad %v3float %22225 - %12115 = OpVectorTimesScalar %v3float %11768 %15291 - %15540 = OpLoad %150 %3312 - %24593 = OpLoad %508 %4646 - %12184 = OpSampledImage %510 %15540 %24593 - %17682 = OpImageSampleExplicitLod %v4float %12184 %13161 Lod %float_0 - %16950 = OpCompositeExtract %float %17682 1 - %14197 = OpFOrdGreaterThan %bool %16950 %float_0 - OpSelectionMerge %22319 DontFlatten - OpBranchConditional %14197 %12833 %22319 - %12833 = OpLabel - %13251 = OpLoad %150 %4862 - %19972 = OpLoad %508 %3594 - %12185 = OpSampledImage %510 %13251 %19972 - %15687 = OpImageSampleExplicitLod %v4float %12185 %13161 Lod %float_0 - %13878 = OpCompositeExtract %float %17682 1 - %12439 = OpCompositeExtract %float %17682 2 - %23312 = OpFMul %float %13878 %12439 - %17624 = OpExtInst %float %1 FClamp %23312 %float_0 %float_1 - %20303 = OpVectorShuffle %v3float %15687 %15687 0 1 2 - %11198 = OpVectorTimesScalar %v3float %20303 %17624 - %15305 = OpFAdd %v3float %12115 %11198 - OpBranch %22319 - %22319 = OpLabel - %7731 = OpPhi %v3float %12115 %22318 %15305 %12833 - %23411 = OpVectorTimesScalar %v3float %7731 %float_0_5 - %9351 = OpFAdd %float %9350 %float_0_5 - %16247 = OpVectorShuffle %v3float %15539 %15539 0 1 2 - %22189 = OpFAdd %v3float %16247 %23411 - %15541 = OpVectorShuffle %v4float %15539 %22189 4 5 6 3 - %6719 = OpCompositeInsert %_struct_1017 %15541 %6445 0 - %23412 = OpVectorShuffle %v3float %15541 %15541 0 1 2 - %10833 = OpCompositeConstruct %v3float %9351 %9351 %9351 - %13750 = OpFDiv %v3float %23412 %10833 - %24033 = OpVectorShuffle %v4float %15541 %13750 4 5 6 3 - %8636 = OpCompositeInsert %_struct_1017 %24033 %6719 0 - %16315 = OpCompositeInsert %_struct_1017 %float_1 %8636 0 3 - %11544 = OpCompositeExtract %v4float %16315 0 - OpStore %4317 %11544 - OpReturn - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders/asm/tesc/tess-fixed-input-array-builtin-array.asm.tesc b/deps/SPIRV-Cross/shaders/asm/tesc/tess-fixed-input-array-builtin-array.asm.tesc deleted file mode 100644 index 0fd4dce256..0000000000 --- a/deps/SPIRV-Cross/shaders/asm/tesc/tess-fixed-input-array-builtin-array.asm.tesc +++ /dev/null @@ -1,248 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 2 -; Bound: 162 -; Schema: 0 - OpCapability Tessellation - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint TessellationControl %hs_main "main" %p_pos %p_1 %i_1 %_entryPointOutput_pos %_entryPointOutput %_patchConstantOutput_EdgeTess %_patchConstantOutput_InsideTess - OpExecutionMode %hs_main OutputVertices 3 - OpExecutionMode %hs_main Triangles - OpExecutionMode %hs_main SpacingFractionalOdd - OpExecutionMode %hs_main VertexOrderCw - OpSource HLSL 500 - OpName %hs_main "hs_main" - OpName %VertexOutput "VertexOutput" - OpMemberName %VertexOutput 0 "pos" - OpMemberName %VertexOutput 1 "uv" - OpName %HSOut "HSOut" - OpMemberName %HSOut 0 "pos" - OpMemberName %HSOut 1 "uv" - OpName %_hs_main_struct_VertexOutput_vf4_vf21_3__u1_ "@hs_main(struct-VertexOutput-vf4-vf21[3];u1;" - OpName %p "p" - OpName %i "i" - OpName %HSConstantOut "HSConstantOut" - OpMemberName %HSConstantOut 0 "EdgeTess" - OpMemberName %HSConstantOut 1 "InsideTess" - OpName %PatchHS_struct_VertexOutput_vf4_vf21_3__ "PatchHS(struct-VertexOutput-vf4-vf21[3];" - OpName %patch "patch" - OpName %output "output" - OpName %p_0 "p" - OpName %p_pos "p.pos" - OpName %VertexOutput_0 "VertexOutput" - OpMemberName %VertexOutput_0 0 "uv" - OpName %p_1 "p" - OpName %i_0 "i" - OpName %i_1 "i" - OpName %flattenTemp "flattenTemp" - OpName %param "param" - OpName %param_0 "param" - OpName %_entryPointOutput_pos "@entryPointOutput.pos" - OpName %HSOut_0 "HSOut" - OpMemberName %HSOut_0 0 "uv" - OpName %_entryPointOutput "@entryPointOutput" - OpName %_patchConstantResult "@patchConstantResult" - OpName %param_1 "param" - OpName %_patchConstantOutput_EdgeTess "@patchConstantOutput.EdgeTess" - OpName %_patchConstantOutput_InsideTess "@patchConstantOutput.InsideTess" - OpName %output_0 "output" - OpDecorate %p_pos BuiltIn Position - OpDecorate %p_1 Location 0 - OpDecorate %i_1 BuiltIn InvocationId - OpDecorate %_entryPointOutput_pos BuiltIn Position - OpDecorate %_entryPointOutput Location 0 - OpDecorate %_patchConstantOutput_EdgeTess Patch - OpDecorate %_patchConstantOutput_EdgeTess BuiltIn TessLevelOuter - OpDecorate %_patchConstantOutput_InsideTess Patch - OpDecorate %_patchConstantOutput_InsideTess BuiltIn TessLevelInner - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 - %v4float = OpTypeVector %float 4 - %v2float = OpTypeVector %float 2 -%VertexOutput = OpTypeStruct %v4float %v2float - %uint = OpTypeInt 32 0 - %uint_3 = OpConstant %uint 3 -%_arr_VertexOutput_uint_3 = OpTypeArray %VertexOutput %uint_3 -%_ptr_Function__arr_VertexOutput_uint_3 = OpTypePointer Function %_arr_VertexOutput_uint_3 -%_ptr_Function_uint = OpTypePointer Function %uint - %HSOut = OpTypeStruct %v4float %v2float - %16 = OpTypeFunction %HSOut %_ptr_Function__arr_VertexOutput_uint_3 %_ptr_Function_uint -%_arr_float_uint_3 = OpTypeArray %float %uint_3 -%HSConstantOut = OpTypeStruct %_arr_float_uint_3 %float - %23 = OpTypeFunction %HSConstantOut %_ptr_Function__arr_VertexOutput_uint_3 -%_ptr_Function_HSOut = OpTypePointer Function %HSOut - %int = OpTypeInt 32 1 - %int_0 = OpConstant %int 0 -%_ptr_Function_v4float = OpTypePointer Function %v4float - %int_1 = OpConstant %int 1 -%_ptr_Function_v2float = OpTypePointer Function %v2float -%_arr_v4float_uint_3 = OpTypeArray %v4float %uint_3 -%_ptr_Input__arr_v4float_uint_3 = OpTypePointer Input %_arr_v4float_uint_3 - %p_pos = OpVariable %_ptr_Input__arr_v4float_uint_3 Input -%_ptr_Input_v4float = OpTypePointer Input %v4float -%VertexOutput_0 = OpTypeStruct %v2float -%_arr_VertexOutput_0_uint_3 = OpTypeArray %VertexOutput_0 %uint_3 -%_ptr_Input__arr_VertexOutput_0_uint_3 = OpTypePointer Input %_arr_VertexOutput_0_uint_3 - %p_1 = OpVariable %_ptr_Input__arr_VertexOutput_0_uint_3 Input -%_ptr_Input_v2float = OpTypePointer Input %v2float - %int_2 = OpConstant %int 2 -%_ptr_Input_uint = OpTypePointer Input %uint - %i_1 = OpVariable %_ptr_Input_uint Input -%_ptr_Output__arr_v4float_uint_3 = OpTypePointer Output %_arr_v4float_uint_3 -%_entryPointOutput_pos = OpVariable %_ptr_Output__arr_v4float_uint_3 Output -%_ptr_Output_v4float = OpTypePointer Output %v4float - %HSOut_0 = OpTypeStruct %v2float -%_arr_HSOut_0_uint_3 = OpTypeArray %HSOut_0 %uint_3 -%_ptr_Output__arr_HSOut_0_uint_3 = OpTypePointer Output %_arr_HSOut_0_uint_3 -%_entryPointOutput = OpVariable %_ptr_Output__arr_HSOut_0_uint_3 Output -%_ptr_Output_v2float = OpTypePointer Output %v2float - %uint_2 = OpConstant %uint 2 - %uint_1 = OpConstant %uint 1 - %uint_0 = OpConstant %uint 0 - %bool = OpTypeBool -%_ptr_Function_HSConstantOut = OpTypePointer Function %HSConstantOut - %uint_4 = OpConstant %uint 4 -%_arr_float_uint_4 = OpTypeArray %float %uint_4 -%_ptr_Output__arr_float_uint_4 = OpTypePointer Output %_arr_float_uint_4 -%_patchConstantOutput_EdgeTess = OpVariable %_ptr_Output__arr_float_uint_4 Output -%_ptr_Function_float = OpTypePointer Function %float -%_ptr_Output_float = OpTypePointer Output %float -%_arr_float_uint_2 = OpTypeArray %float %uint_2 -%_ptr_Output__arr_float_uint_2 = OpTypePointer Output %_arr_float_uint_2 -%_patchConstantOutput_InsideTess = OpVariable %_ptr_Output__arr_float_uint_2 Output - %float_1 = OpConstant %float 1 - %hs_main = OpFunction %void None %3 - %5 = OpLabel - %p_0 = OpVariable %_ptr_Function__arr_VertexOutput_uint_3 Function - %i_0 = OpVariable %_ptr_Function_uint Function -%flattenTemp = OpVariable %_ptr_Function_HSOut Function - %param = OpVariable %_ptr_Function__arr_VertexOutput_uint_3 Function - %param_0 = OpVariable %_ptr_Function_uint Function -%_patchConstantResult = OpVariable %_ptr_Function_HSConstantOut Function - %param_1 = OpVariable %_ptr_Function__arr_VertexOutput_uint_3 Function - %50 = OpAccessChain %_ptr_Input_v4float %p_pos %int_0 - %51 = OpLoad %v4float %50 - %52 = OpAccessChain %_ptr_Function_v4float %p_0 %int_0 %int_0 - OpStore %52 %51 - %58 = OpAccessChain %_ptr_Input_v2float %p_1 %int_0 %int_0 - %59 = OpLoad %v2float %58 - %60 = OpAccessChain %_ptr_Function_v2float %p_0 %int_0 %int_1 - OpStore %60 %59 - %61 = OpAccessChain %_ptr_Input_v4float %p_pos %int_1 - %62 = OpLoad %v4float %61 - %63 = OpAccessChain %_ptr_Function_v4float %p_0 %int_1 %int_0 - OpStore %63 %62 - %64 = OpAccessChain %_ptr_Input_v2float %p_1 %int_1 %int_0 - %65 = OpLoad %v2float %64 - %66 = OpAccessChain %_ptr_Function_v2float %p_0 %int_1 %int_1 - OpStore %66 %65 - %68 = OpAccessChain %_ptr_Input_v4float %p_pos %int_2 - %69 = OpLoad %v4float %68 - %70 = OpAccessChain %_ptr_Function_v4float %p_0 %int_2 %int_0 - OpStore %70 %69 - %71 = OpAccessChain %_ptr_Input_v2float %p_1 %int_2 %int_0 - %72 = OpLoad %v2float %71 - %73 = OpAccessChain %_ptr_Function_v2float %p_0 %int_2 %int_1 - OpStore %73 %72 - %77 = OpLoad %uint %i_1 - OpStore %i_0 %77 - %80 = OpLoad %_arr_VertexOutput_uint_3 %p_0 - OpStore %param %80 - %82 = OpLoad %uint %i_0 - OpStore %param_0 %82 - %83 = OpFunctionCall %HSOut %_hs_main_struct_VertexOutput_vf4_vf21_3__u1_ %param %param_0 - OpStore %flattenTemp %83 - %86 = OpAccessChain %_ptr_Function_v4float %flattenTemp %int_0 - %87 = OpLoad %v4float %86 - %94 = OpLoad %uint %i_1 - %89 = OpAccessChain %_ptr_Output_v4float %_entryPointOutput_pos %94 - OpStore %89 %87 - %95 = OpAccessChain %_ptr_Function_v2float %flattenTemp %int_1 - %96 = OpLoad %v2float %95 - %98 = OpAccessChain %_ptr_Output_v2float %_entryPointOutput %94 %int_0 - OpStore %98 %96 - OpControlBarrier %uint_2 %uint_1 %uint_0 - %102 = OpLoad %uint %i_1 - %104 = OpIEqual %bool %102 %int_0 - OpSelectionMerge %106 None - OpBranchConditional %104 %105 %106 - %105 = OpLabel - %110 = OpLoad %_arr_VertexOutput_uint_3 %p_0 - OpStore %param_1 %110 - %111 = OpFunctionCall %HSConstantOut %PatchHS_struct_VertexOutput_vf4_vf21_3__ %param_1 - OpStore %_patchConstantResult %111 - %117 = OpAccessChain %_ptr_Function_float %_patchConstantResult %int_0 %int_0 - %118 = OpLoad %float %117 - %120 = OpAccessChain %_ptr_Output_float %_patchConstantOutput_EdgeTess %int_0 - OpStore %120 %118 - %121 = OpAccessChain %_ptr_Function_float %_patchConstantResult %int_0 %int_1 - %122 = OpLoad %float %121 - %123 = OpAccessChain %_ptr_Output_float %_patchConstantOutput_EdgeTess %int_1 - OpStore %123 %122 - %124 = OpAccessChain %_ptr_Function_float %_patchConstantResult %int_0 %int_2 - %125 = OpLoad %float %124 - %126 = OpAccessChain %_ptr_Output_float %_patchConstantOutput_EdgeTess %int_2 - OpStore %126 %125 - %130 = OpAccessChain %_ptr_Function_float %_patchConstantResult %int_1 - %131 = OpLoad %float %130 - %132 = OpAccessChain %_ptr_Output_float %_patchConstantOutput_InsideTess %int_0 - OpStore %132 %131 - OpBranch %106 - %106 = OpLabel - OpReturn - OpFunctionEnd -%_hs_main_struct_VertexOutput_vf4_vf21_3__u1_ = OpFunction %HSOut None %16 - %p = OpFunctionParameter %_ptr_Function__arr_VertexOutput_uint_3 - %i = OpFunctionParameter %_ptr_Function_uint - %20 = OpLabel - %output = OpVariable %_ptr_Function_HSOut Function - %31 = OpLoad %uint %i - %33 = OpAccessChain %_ptr_Function_v4float %p %31 %int_0 - %34 = OpLoad %v4float %33 - %35 = OpAccessChain %_ptr_Function_v4float %output %int_0 - OpStore %35 %34 - %37 = OpLoad %uint %i - %39 = OpAccessChain %_ptr_Function_v2float %p %37 %int_1 - %40 = OpLoad %v2float %39 - %41 = OpAccessChain %_ptr_Function_v2float %output %int_1 - OpStore %41 %40 - %42 = OpLoad %HSOut %output - OpReturnValue %42 - OpFunctionEnd -%PatchHS_struct_VertexOutput_vf4_vf21_3__ = OpFunction %HSConstantOut None %23 - %patch = OpFunctionParameter %_ptr_Function__arr_VertexOutput_uint_3 - %26 = OpLabel - %output_0 = OpVariable %_ptr_Function_HSConstantOut Function - %135 = OpAccessChain %_ptr_Function_v2float %patch %int_0 %int_1 - %136 = OpLoad %v2float %135 - %137 = OpCompositeConstruct %v2float %float_1 %float_1 - %138 = OpFAdd %v2float %137 %136 - %139 = OpCompositeExtract %float %138 0 - %140 = OpAccessChain %_ptr_Function_float %output_0 %int_0 %int_0 - OpStore %140 %139 - %141 = OpAccessChain %_ptr_Function_v2float %patch %int_0 %int_1 - %142 = OpLoad %v2float %141 - %143 = OpCompositeConstruct %v2float %float_1 %float_1 - %144 = OpFAdd %v2float %143 %142 - %145 = OpCompositeExtract %float %144 0 - %146 = OpAccessChain %_ptr_Function_float %output_0 %int_0 %int_1 - OpStore %146 %145 - %147 = OpAccessChain %_ptr_Function_v2float %patch %int_0 %int_1 - %148 = OpLoad %v2float %147 - %149 = OpCompositeConstruct %v2float %float_1 %float_1 - %150 = OpFAdd %v2float %149 %148 - %151 = OpCompositeExtract %float %150 0 - %152 = OpAccessChain %_ptr_Function_float %output_0 %int_0 %int_2 - OpStore %152 %151 - %153 = OpAccessChain %_ptr_Function_v2float %patch %int_0 %int_1 - %154 = OpLoad %v2float %153 - %155 = OpCompositeConstruct %v2float %float_1 %float_1 - %156 = OpFAdd %v2float %155 %154 - %157 = OpCompositeExtract %float %156 0 - %158 = OpAccessChain %_ptr_Function_float %output_0 %int_1 - OpStore %158 %157 - %159 = OpLoad %HSConstantOut %output_0 - OpReturnValue %159 - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders/asm/vert/empty-io.asm.vert b/deps/SPIRV-Cross/shaders/asm/vert/empty-io.asm.vert deleted file mode 100644 index 0ba6cb7963..0000000000 --- a/deps/SPIRV-Cross/shaders/asm/vert/empty-io.asm.vert +++ /dev/null @@ -1,70 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 1 -; Bound: 40 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Vertex %main "main" %position %_entryPointOutput_position %_entryPointOutput - OpName %main "main" - OpName %VSInput "VSInput" - OpMemberName %VSInput 0 "position" - OpName %VSOutput "VSOutput" - OpMemberName %VSOutput 0 "position" - OpName %_main_struct_VSInput_vf41_ "@main(struct-VSInput-vf41;" - OpName %_input "_input" - OpName %_out "_out" - OpName %_input_0 "_input" - OpName %position "position" - OpName %_entryPointOutput_position "@entryPointOutput_position" - OpName %param "param" - OpName %VSOutput_0 "VSOutput" - OpName %_entryPointOutput "@entryPointOutput" - OpDecorate %position Location 0 - OpDecorate %_entryPointOutput_position BuiltIn Position - OpDecorate %_entryPointOutput Location 0 - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 - %v4float = OpTypeVector %float 4 - %VSInput = OpTypeStruct %v4float -%_ptr_Function_VSInput = OpTypePointer Function %VSInput - %VSOutput = OpTypeStruct %v4float - %11 = OpTypeFunction %VSOutput %_ptr_Function_VSInput -%_ptr_Function_VSOutput = OpTypePointer Function %VSOutput - %int = OpTypeInt 32 1 - %18 = OpConstant %int 0 -%_ptr_Function_v4float = OpTypePointer Function %v4float -%_ptr_Input_v4float = OpTypePointer Input %v4float - %position = OpVariable %_ptr_Input_v4float Input -%_ptr_Output_v4float = OpTypePointer Output %v4float -%_entryPointOutput_position = OpVariable %_ptr_Output_v4float Output - %VSOutput_0 = OpTypeStruct -%_ptr_Output_VSOutput_0 = OpTypePointer Output %VSOutput_0 -%_entryPointOutput = OpVariable %_ptr_Output_VSOutput_0 Output - %main = OpFunction %void None %3 - %5 = OpLabel - %_input_0 = OpVariable %_ptr_Function_VSInput Function - %param = OpVariable %_ptr_Function_VSInput Function - %29 = OpLoad %v4float %position - %30 = OpAccessChain %_ptr_Function_v4float %_input_0 %18 - OpStore %30 %29 - %34 = OpLoad %VSInput %_input_0 - OpStore %param %34 - %35 = OpFunctionCall %VSOutput %_main_struct_VSInput_vf41_ %param - %36 = OpCompositeExtract %v4float %35 0 - OpStore %_entryPointOutput_position %36 - OpReturn - OpFunctionEnd -%_main_struct_VSInput_vf41_ = OpFunction %VSOutput None %11 - %_input = OpFunctionParameter %_ptr_Function_VSInput - %14 = OpLabel - %_out = OpVariable %_ptr_Function_VSOutput Function - %20 = OpAccessChain %_ptr_Function_v4float %_input %18 - %21 = OpLoad %v4float %20 - %22 = OpAccessChain %_ptr_Function_v4float %_out %18 - OpStore %22 %21 - %23 = OpLoad %VSOutput %_out - OpReturnValue %23 - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders/asm/vert/empty-struct-composite.asm.vert b/deps/SPIRV-Cross/shaders/asm/vert/empty-struct-composite.asm.vert deleted file mode 100644 index 37a2d87937..0000000000 --- a/deps/SPIRV-Cross/shaders/asm/vert/empty-struct-composite.asm.vert +++ /dev/null @@ -1,37 +0,0 @@ -; SPIR-V -; Version: 1.1 -; Generator: Google rspirv; 0 -; Bound: 17 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Vertex %2 "main" - OpExecutionMode %2 OriginUpperLeft - OpName %Test "Test" - OpName %t "t" - OpName %retvar "retvar" - OpName %main "main" - OpName %retvar_0 "retvar" - %void = OpTypeVoid - %6 = OpTypeFunction %void - %Test = OpTypeStruct -%_ptr_Function_Test = OpTypePointer Function %Test -%_ptr_Function_void = OpTypePointer Function %void - %2 = OpFunction %void None %6 - %7 = OpLabel - %t = OpVariable %_ptr_Function_Test Function - %retvar = OpVariable %_ptr_Function_void Function - OpBranch %4 - %4 = OpLabel - %13 = OpCompositeConstruct %Test - OpStore %t %13 - OpReturn - OpFunctionEnd - %main = OpFunction %void None %6 - %15 = OpLabel - %retvar_0 = OpVariable %_ptr_Function_void Function - OpBranch %14 - %14 = OpLabel - OpReturn - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders/asm/vert/global-builtin.sso.asm.vert b/deps/SPIRV-Cross/shaders/asm/vert/global-builtin.sso.asm.vert deleted file mode 100644 index d7306deb24..0000000000 --- a/deps/SPIRV-Cross/shaders/asm/vert/global-builtin.sso.asm.vert +++ /dev/null @@ -1,68 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 1 -; Bound: 40 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Vertex %main "main" %_entryPointOutput %_entryPointOutput_pos - OpSource HLSL 500 - OpName %main "main" - OpName %VSOut "VSOut" - OpMemberName %VSOut 0 "a" - OpMemberName %VSOut 1 "pos" - OpName %_main_ "@main(" - OpName %vout "vout" - OpName %flattenTemp "flattenTemp" - OpName %VSOut_0 "VSOut" - OpMemberName %VSOut_0 0 "a" - OpName %_entryPointOutput "@entryPointOutput" - OpName %_entryPointOutput_pos "@entryPointOutput_pos" - OpDecorate %_entryPointOutput Location 0 - OpDecorate %_entryPointOutput_pos BuiltIn Position - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 - %v4float = OpTypeVector %float 4 - %VSOut = OpTypeStruct %float %v4float - %9 = OpTypeFunction %VSOut -%_ptr_Function_VSOut = OpTypePointer Function %VSOut - %int = OpTypeInt 32 1 - %int_0 = OpConstant %int 0 - %float_40 = OpConstant %float 40 -%_ptr_Function_float = OpTypePointer Function %float - %int_1 = OpConstant %int 1 - %float_1 = OpConstant %float 1 - %21 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 -%_ptr_Function_v4float = OpTypePointer Function %v4float - %VSOut_0 = OpTypeStruct %float -%_ptr_Output_VSOut_0 = OpTypePointer Output %VSOut_0 -%_entryPointOutput = OpVariable %_ptr_Output_VSOut_0 Output -%_ptr_Output_float = OpTypePointer Output %float -%_ptr_Output_v4float = OpTypePointer Output %v4float -%_entryPointOutput_pos = OpVariable %_ptr_Output_v4float Output - %main = OpFunction %void None %3 - %5 = OpLabel -%flattenTemp = OpVariable %_ptr_Function_VSOut Function - %28 = OpFunctionCall %VSOut %_main_ - OpStore %flattenTemp %28 - %32 = OpAccessChain %_ptr_Function_float %flattenTemp %int_0 - %33 = OpLoad %float %32 - %35 = OpAccessChain %_ptr_Output_float %_entryPointOutput %int_0 - OpStore %35 %33 - %38 = OpAccessChain %_ptr_Function_v4float %flattenTemp %int_1 - %39 = OpLoad %v4float %38 - OpStore %_entryPointOutput_pos %39 - OpReturn - OpFunctionEnd - %_main_ = OpFunction %VSOut None %9 - %11 = OpLabel - %vout = OpVariable %_ptr_Function_VSOut Function - %18 = OpAccessChain %_ptr_Function_float %vout %int_0 - OpStore %18 %float_40 - %23 = OpAccessChain %_ptr_Function_v4float %vout %int_1 - OpStore %23 %21 - %24 = OpLoad %VSOut %vout - OpReturnValue %24 - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders/comp/atomic.comp b/deps/SPIRV-Cross/shaders/comp/atomic.comp deleted file mode 100644 index 703256d879..0000000000 --- a/deps/SPIRV-Cross/shaders/comp/atomic.comp +++ /dev/null @@ -1,56 +0,0 @@ -#version 310 es -#extension GL_OES_shader_image_atomic : require -layout(local_size_x = 1) in; - -layout(r32ui, binding = 0) uniform highp uimage2D uImage; -layout(r32i, binding = 1) uniform highp iimage2D iImage; -layout(binding = 2, std430) buffer SSBO -{ - uint u32; - int i32; -} ssbo; - -void main() -{ - imageAtomicAdd(uImage, ivec2(1, 5), 1u); - - // Test that we do not invalidate OpImage variables which are loaded from UniformConstant - // address space. - imageStore(iImage, ivec2(1, 6), ivec4(imageAtomicAdd(uImage, ivec2(1, 5), 1u))); - - imageAtomicOr(uImage, ivec2(1, 5), 1u); - imageAtomicXor(uImage, ivec2(1, 5), 1u); - imageAtomicAnd(uImage, ivec2(1, 5), 1u); - imageAtomicMin(uImage, ivec2(1, 5), 1u); - imageAtomicMax(uImage, ivec2(1, 5), 1u); - //imageAtomicExchange(uImage, ivec2(1, 5), 1u); - imageAtomicCompSwap(uImage, ivec2(1, 5), 10u, 2u); - - imageAtomicAdd(iImage, ivec2(1, 6), 1); - imageAtomicOr(iImage, ivec2(1, 6), 1); - imageAtomicXor(iImage, ivec2(1, 6), 1); - imageAtomicAnd(iImage, ivec2(1, 6), 1); - imageAtomicMin(iImage, ivec2(1, 6), 1); - imageAtomicMax(iImage, ivec2(1, 6), 1); - //imageAtomicExchange(iImage, ivec2(1, 5), 1u); - imageAtomicCompSwap(iImage, ivec2(1, 5), 10, 2); - - atomicAdd(ssbo.u32, 1u); - atomicOr(ssbo.u32, 1u); - atomicXor(ssbo.u32, 1u); - atomicAnd(ssbo.u32, 1u); - atomicMin(ssbo.u32, 1u); - atomicMax(ssbo.u32, 1u); - atomicExchange(ssbo.u32, 1u); - atomicCompSwap(ssbo.u32, 10u, 2u); - - atomicAdd(ssbo.i32, 1); - atomicOr(ssbo.i32, 1); - atomicXor(ssbo.i32, 1); - atomicAnd(ssbo.i32, 1); - atomicMin(ssbo.i32, 1); - atomicMax(ssbo.i32, 1); - atomicExchange(ssbo.i32, 1); - atomicCompSwap(ssbo.i32, 10, 2); -} - diff --git a/deps/SPIRV-Cross/shaders/comp/bake_gradient.comp b/deps/SPIRV-Cross/shaders/comp/bake_gradient.comp deleted file mode 100644 index 4885ff00bc..0000000000 --- a/deps/SPIRV-Cross/shaders/comp/bake_gradient.comp +++ /dev/null @@ -1,55 +0,0 @@ -#version 310 es - -layout(local_size_x = 8, local_size_y = 8) in; - -layout(binding = 0) uniform sampler2D uHeight; -layout(binding = 1) uniform sampler2D uDisplacement; -layout(rgba16f, binding = 2) uniform writeonly mediump image2D iHeightDisplacement; -layout(rgba16f, binding = 3) uniform writeonly mediump image2D iGradJacobian; - -layout(binding = 4) uniform UBO -{ - vec4 uInvSize; - vec4 uScale; -}; - -mediump float jacobian(mediump vec2 dDdx, mediump vec2 dDdy) -{ - return (1.0 + dDdx.x) * (1.0 + dDdy.y) - dDdx.y * dDdy.x; -} -#define LAMBDA 1.2 - -void main() -{ - vec4 uv = (vec2(gl_GlobalInvocationID.xy) * uInvSize.xy).xyxy + 0.5 * uInvSize; - - float h = textureLod(uHeight, uv.xy, 0.0).x; - - // Compute the heightmap gradient by simple differentiation. - float x0 = textureLodOffset(uHeight, uv.xy, 0.0, ivec2(-1, 0)).x; - float x1 = textureLodOffset(uHeight, uv.xy, 0.0, ivec2(+1, 0)).x; - float y0 = textureLodOffset(uHeight, uv.xy, 0.0, ivec2(0, -1)).x; - float y1 = textureLodOffset(uHeight, uv.xy, 0.0, ivec2(0, +1)).x; - vec2 grad = uScale.xy * 0.5 * vec2(x1 - x0, y1 - y0); - - // Displacement map must be sampled with a different offset since it's a smaller texture. - vec2 displacement = LAMBDA * textureLod(uDisplacement, uv.zw, 0.0).xy; - - // Compute jacobian. - vec2 dDdx = 0.5 * LAMBDA * ( - textureLodOffset(uDisplacement, uv.zw, 0.0, ivec2(+1, 0)).xy - - textureLodOffset(uDisplacement, uv.zw, 0.0, ivec2(-1, 0)).xy); - vec2 dDdy = 0.5 * LAMBDA * ( - textureLodOffset(uDisplacement, uv.zw, 0.0, ivec2(0, +1)).xy - - textureLodOffset(uDisplacement, uv.zw, 0.0, ivec2(0, -1)).xy); - float j = jacobian(dDdx * uScale.z, dDdy * uScale.z); - - displacement = vec2(0.0); - - // Read by vertex shader/tess shader. - imageStore(iHeightDisplacement, ivec2(gl_GlobalInvocationID.xy), vec4(h, displacement, 0.0)); - - // Read by fragment shader. - imageStore(iGradJacobian, ivec2(gl_GlobalInvocationID.xy), vec4(grad, j, 0.0)); -} - diff --git a/deps/SPIRV-Cross/shaders/comp/barriers.comp b/deps/SPIRV-Cross/shaders/comp/barriers.comp deleted file mode 100644 index 7e0ea42d4e..0000000000 --- a/deps/SPIRV-Cross/shaders/comp/barriers.comp +++ /dev/null @@ -1,79 +0,0 @@ -#version 310 es -layout(local_size_x = 4) in; - -void barrier_shared() -{ - memoryBarrierShared(); -} - -void full_barrier() -{ - memoryBarrier(); -} - -void image_barrier() -{ - memoryBarrierImage(); -} - -void buffer_barrier() -{ - memoryBarrierBuffer(); -} - -void group_barrier() -{ - groupMemoryBarrier(); -} - -void barrier_shared_exec() -{ - memoryBarrierShared(); - barrier(); -} - -void full_barrier_exec() -{ - memoryBarrier(); - barrier(); -} - -void image_barrier_exec() -{ - memoryBarrierImage(); - barrier(); -} - -void buffer_barrier_exec() -{ - memoryBarrierBuffer(); - barrier(); -} - -void group_barrier_exec() -{ - groupMemoryBarrier(); - barrier(); -} - -void exec_barrier() -{ - barrier(); -} - -void main() -{ - barrier_shared(); - full_barrier(); - image_barrier(); - buffer_barrier(); - group_barrier(); - - barrier_shared_exec(); - full_barrier_exec(); - image_barrier_exec(); - buffer_barrier_exec(); - group_barrier_exec(); - - exec_barrier(); -} diff --git a/deps/SPIRV-Cross/shaders/comp/basic.comp b/deps/SPIRV-Cross/shaders/comp/basic.comp deleted file mode 100644 index f9bf55670f..0000000000 --- a/deps/SPIRV-Cross/shaders/comp/basic.comp +++ /dev/null @@ -1,28 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -layout(std430, binding = 0) readonly buffer SSBO -{ - vec4 in_data[]; -}; - -layout(std430, binding = 1) writeonly buffer SSBO2 -{ - vec4 out_data[]; -}; - -layout(std430, binding = 2) buffer SSBO3 -{ - uint counter; -}; - -void main() -{ - uint ident = gl_GlobalInvocationID.x; - vec4 idata = in_data[ident]; - if (dot(idata, vec4(1.0, 5.0, 6.0, 2.0)) > 8.2) - { - out_data[atomicAdd(counter, 1u)] = idata; - } -} - diff --git a/deps/SPIRV-Cross/shaders/comp/bitfield.noopt.comp b/deps/SPIRV-Cross/shaders/comp/bitfield.noopt.comp deleted file mode 100644 index d75b556b62..0000000000 --- a/deps/SPIRV-Cross/shaders/comp/bitfield.noopt.comp +++ /dev/null @@ -1,21 +0,0 @@ -#version 310 es - -void main() -{ - int signed_value = 0; - uint unsigned_value = 0u; - - int s = bitfieldExtract(signed_value, 5, 20); - uint u = bitfieldExtract(unsigned_value, 6, 21); - s = bitfieldInsert(s, 40, 5, 4); - u = bitfieldInsert(u, 60u, 5, 4); - - u = bitfieldReverse(u); - s = bitfieldReverse(s); - - int v0 = bitCount(u); - int v1 = bitCount(s); - - int v2 = findMSB(u); - int v3 = findLSB(s); -} diff --git a/deps/SPIRV-Cross/shaders/comp/casts.comp b/deps/SPIRV-Cross/shaders/comp/casts.comp deleted file mode 100644 index 6be539d7be..0000000000 --- a/deps/SPIRV-Cross/shaders/comp/casts.comp +++ /dev/null @@ -1,18 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -layout(binding = 0, std430) buffer SSBO0 -{ - ivec4 inputs[]; -}; - -layout(binding = 1, std430) buffer SSBO1 -{ - ivec4 outputs[]; -}; - -void main() -{ - uint ident = gl_GlobalInvocationID.x; - outputs[ident] = ivec4(bvec4(inputs[ident] & 0x3)); -} diff --git a/deps/SPIRV-Cross/shaders/comp/cfg-preserve-parameter.comp b/deps/SPIRV-Cross/shaders/comp/cfg-preserve-parameter.comp deleted file mode 100644 index 9ef9092005..0000000000 --- a/deps/SPIRV-Cross/shaders/comp/cfg-preserve-parameter.comp +++ /dev/null @@ -1,54 +0,0 @@ -#version 310 es - -// We write in all paths (and no reads), so should just be out. -void out_test_0(int cond, inout int i) -{ - if (cond == 0) - i = 40; - else - i = 60; -} - -// We write in all paths (and no reads), so should just be out. -void out_test_1(int cond, inout int i) -{ - switch (cond) - { - case 40: - i = 40; - break; - - default: - i = 70; - break; - } -} - -// We don't write in all paths, so should be inout. -void inout_test_0(int cond, inout int i) -{ - if (cond == 0) - i = 40; -} - -void inout_test_1(int cond, inout int i) -{ - switch (cond) - { - case 40: - i = 40; - break; - } -} - - -void main() -{ - int cond = 40; - int i = 50; - - out_test_0(cond, i); - out_test_1(cond, i); - inout_test_0(cond, i); - inout_test_1(cond, i); -} diff --git a/deps/SPIRV-Cross/shaders/comp/cfg.comp b/deps/SPIRV-Cross/shaders/comp/cfg.comp deleted file mode 100644 index 4f4e6c0ea8..0000000000 --- a/deps/SPIRV-Cross/shaders/comp/cfg.comp +++ /dev/null @@ -1,91 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -layout(std430, binding = 0) buffer SSBO -{ - float data; -}; - -void test() -{ - // Test that variables local to a scope stay local. - if (data != 0.0) - { - float tmp = 10.0; - data = tmp; - } - else - { - float tmp = 15.0; - data = tmp; - } - - // Test that variable access propagates up to dominator - if (data != 0.0) - { - float e; - if (data != 5.0) - { - if (data != 6.0) - e = 10.0; - } - else - e = 20.0; - } - - // Test that variables local to a switch block stay local. - switch (int(data)) - { - case 0: - { - float tmp = 20.0; - data = tmp; - break; - } - - case 1: - { - float tmp = 30.0; - data = tmp; - break; - } - } - - // Check that multibranches propagate up to dominator. - float f; - switch (int(data)) - { - case 0: - { - f = 30.0; - break; - } - - case 1: - { - f = 40.0; - break; - } - } - - // Check that loops work. - // Interesting case here is propagating variable access from the continue block. - float h; - for (int i = 0; i < 20; i++, h += 10.0) - ; - data = h; - - // Do the same with do-while, gotta test all the hard cases. - float m; - do - { - } while (m != 20.0); - data = m; -} - -void main() -{ - // Test that we do the CFG analysis for all functions. - test(); -} - diff --git a/deps/SPIRV-Cross/shaders/comp/coherent-block.comp b/deps/SPIRV-Cross/shaders/comp/coherent-block.comp deleted file mode 100644 index 0a174e8ef0..0000000000 --- a/deps/SPIRV-Cross/shaders/comp/coherent-block.comp +++ /dev/null @@ -1,12 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -layout(binding = 1) coherent restrict writeonly buffer SSBO -{ - vec4 value; -}; - -void main() -{ - value = vec4(20.0); -} diff --git a/deps/SPIRV-Cross/shaders/comp/coherent-image.comp b/deps/SPIRV-Cross/shaders/comp/coherent-image.comp deleted file mode 100644 index fd6e280182..0000000000 --- a/deps/SPIRV-Cross/shaders/comp/coherent-image.comp +++ /dev/null @@ -1,14 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -layout(binding = 1) coherent restrict writeonly buffer SSBO -{ - ivec4 value; -}; - -layout(r32i, binding = 3) coherent readonly restrict uniform mediump iimage2D uImage; - -void main() -{ - value = imageLoad(uImage, ivec2(10)); -} diff --git a/deps/SPIRV-Cross/shaders/comp/composite-construct.comp b/deps/SPIRV-Cross/shaders/comp/composite-construct.comp deleted file mode 100644 index 859c56f51f..0000000000 --- a/deps/SPIRV-Cross/shaders/comp/composite-construct.comp +++ /dev/null @@ -1,40 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -layout(std430, binding = 0) buffer SSBO0 -{ - vec4 as[]; -}; - -layout(std430, binding = 1) buffer SSBO1 -{ - vec4 bs[]; -}; - -vec4 summe(vec4 values[3][2]) -{ - return values[0][0] + values[2][1] + values[0][1] + values[1][0]; -} - -struct Composite -{ - vec4 a[2]; - vec4 b[2]; -}; - -void main() -{ - vec4 values[2] = vec4[](as[gl_GlobalInvocationID.x], bs[gl_GlobalInvocationID.x]); - vec4 const_values[2] = vec4[](vec4(10.0), vec4(30.0)); - vec4 copy_values[2]; - copy_values = const_values; - vec4 copy_values2[2] = values; - as[gl_GlobalInvocationID.x] = summe(vec4[][](values, copy_values, copy_values2)); - - Composite c = Composite(values, copy_values); - - float arrayofarray[2][3] = float[][](float[](1.0, 1.0, 1.0), float[](2.0, 2.0, 2.0)); - - float b = 10.0; - float values_scalar[4] = float[](b, b, b, b); -} diff --git a/deps/SPIRV-Cross/shaders/comp/culling.comp b/deps/SPIRV-Cross/shaders/comp/culling.comp deleted file mode 100644 index 9f8331b10b..0000000000 --- a/deps/SPIRV-Cross/shaders/comp/culling.comp +++ /dev/null @@ -1,26 +0,0 @@ -#version 310 es -layout(local_size_x = 4) in; - -layout(std430, binding = 0) readonly buffer SSBO -{ - float in_data[]; -}; - -layout(std430, binding = 1) writeonly buffer SSBO2 -{ - float out_data[]; -}; - -layout(std430, binding = 2) buffer SSBO3 -{ - uint count; -}; - -void main() -{ - uint ident = gl_GlobalInvocationID.x; - float idata = in_data[ident]; - if (idata > 12.0) - out_data[atomicAdd(count, 1u)] = idata; -} - diff --git a/deps/SPIRV-Cross/shaders/comp/defer-parens.comp b/deps/SPIRV-Cross/shaders/comp/defer-parens.comp deleted file mode 100644 index 4e8ea6b399..0000000000 --- a/deps/SPIRV-Cross/shaders/comp/defer-parens.comp +++ /dev/null @@ -1,30 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -layout(binding = 0, std430) buffer SSBO -{ - vec4 data; - int index; -}; - -void main() -{ - // Tests defer-parens behavior where a binary expression is OpCompositeExtracted chained together - // with an OpCompositeConstruct optimization. - vec4 d = data; - data = vec4(d.x, d.yz + 10.0, d.w); - - // Verify binary ops. - data = d + d + d; - - // Verify swizzles. - data = (d.yz + 10.0).xxyy; - - // OpCompositeExtract - float t = (d.yz + 10.0).y; - data = vec4(t); - - // OpVectorExtractDynamic - t = (d.zw + 10.0)[index]; - data = vec4(t); -} diff --git a/deps/SPIRV-Cross/shaders/comp/dowhile.comp b/deps/SPIRV-Cross/shaders/comp/dowhile.comp deleted file mode 100644 index 709db75a17..0000000000 --- a/deps/SPIRV-Cross/shaders/comp/dowhile.comp +++ /dev/null @@ -1,31 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -layout(std430, binding = 0) readonly buffer SSBO -{ - mat4 mvp; - vec4 in_data[]; -}; - -layout(std430, binding = 1) writeonly buffer SSBO2 -{ - vec4 out_data[]; -}; - -int i; - -void main() -{ - uint ident = gl_GlobalInvocationID.x; - - i = 0; - vec4 idat = in_data[ident]; - do - { - idat = mvp * idat; - i++; - } while(i < 16); - - out_data[ident] = idat; -} - diff --git a/deps/SPIRV-Cross/shaders/comp/generate_height.comp b/deps/SPIRV-Cross/shaders/comp/generate_height.comp deleted file mode 100644 index 16cef4de78..0000000000 --- a/deps/SPIRV-Cross/shaders/comp/generate_height.comp +++ /dev/null @@ -1,97 +0,0 @@ -#version 310 es - -layout(local_size_x = 64) in; - -layout(std430, binding = 0) readonly buffer Distribution -{ - vec2 distribution[]; -}; - -layout(std430, binding = 1) writeonly buffer HeightmapFFT -{ - uint heights[]; -}; - -layout(binding = 2, std140) uniform UBO -{ - vec4 uModTime; -}; - -vec2 alias(vec2 i, vec2 N) -{ - return mix(i, i - N, greaterThan(i, 0.5 * N)); -} - -vec4 cmul(vec4 a, vec4 b) -{ - vec4 r3 = a.yxwz; - vec4 r1 = b.xxzz; - vec4 R0 = a * r1; - vec4 r2 = b.yyww; - vec4 R1 = r2 * r3; - return R0 + vec4(-R1.x, R1.y, -R1.z, R1.w); -} - -vec2 cmul(vec2 a, vec2 b) -{ - vec2 r3 = a.yx; - vec2 r1 = b.xx; - vec2 R0 = a * r1; - vec2 r2 = b.yy; - vec2 R1 = r2 * r3; - return R0 + vec2(-R1.x, R1.y); -} - -uint pack2(vec2 v) -{ - return packHalf2x16(v); -} - -uvec2 pack4(vec4 v) -{ - return uvec2(packHalf2x16(v.xy), packHalf2x16(v.zw)); -} - -uvec2 workaround_mix(uvec2 a, uvec2 b, bvec2 sel) -{ - return uvec2(sel.x ? b.x : a.x, sel.y ? b.y : a.y); -} - -void generate_heightmap() -{ - uvec2 N = gl_WorkGroupSize.xy * gl_NumWorkGroups.xy; - uvec2 i = gl_GlobalInvocationID.xy; - // Pick out the negative frequency variant. - uvec2 wi = workaround_mix(N - i, uvec2(0u), equal(i, uvec2(0u))); - - // Pick out positive and negative travelling waves. - vec2 a = distribution[i.y * N.x + i.x]; - vec2 b = distribution[wi.y * N.x + wi.x]; - - vec2 k = uModTime.xy * alias(vec2(i), vec2(N)); - float k_len = length(k); - - const float G = 9.81; - - // If this sample runs for hours on end, the cosines of very large numbers will eventually become unstable. - // It is fairly easy to fix this by wrapping uTime, - // and quantizing w such that wrapping uTime does not change the result. - // See Tessendorf's paper for how to do it. - // The sqrt(G * k_len) factor represents how fast ocean waves at different frequencies propagate. - float w = sqrt(G * k_len) * uModTime.z; - float cw = cos(w); - float sw = sin(w); - - // Complex multiply to rotate our frequency samples. - a = cmul(a, vec2(cw, sw)); - b = cmul(b, vec2(cw, sw)); - b = vec2(b.x, -b.y); // Complex conjugate since we picked a frequency with the opposite direction. - vec2 res = a + b; // Sum up forward and backwards travelling waves. - heights[i.y * N.x + i.x] = pack2(res); -} - -void main() -{ - generate_heightmap(); -} - diff --git a/deps/SPIRV-Cross/shaders/comp/image.comp b/deps/SPIRV-Cross/shaders/comp/image.comp deleted file mode 100644 index e375534a51..0000000000 --- a/deps/SPIRV-Cross/shaders/comp/image.comp +++ /dev/null @@ -1,12 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -layout(rgba8, binding = 0) uniform readonly mediump image2D uImageIn; -layout(rgba8, binding = 1) uniform writeonly mediump image2D uImageOut; - -void main() -{ - vec4 v = imageLoad(uImageIn, ivec2(gl_GlobalInvocationID.xy) + imageSize(uImageIn)); - imageStore(uImageOut, ivec2(gl_GlobalInvocationID.xy), v); -} - diff --git a/deps/SPIRV-Cross/shaders/comp/inout-struct.invalid.comp b/deps/SPIRV-Cross/shaders/comp/inout-struct.invalid.comp deleted file mode 100644 index c1de959743..0000000000 --- a/deps/SPIRV-Cross/shaders/comp/inout-struct.invalid.comp +++ /dev/null @@ -1,55 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -layout(std430, binding = 0) writeonly buffer SSBO -{ - vec4 data[]; -} outdata; - -layout(std430, binding = 1) readonly buffer SSBO2 -{ - vec4 data[]; -} indata; - -struct Foo -{ - vec4 a; - vec4 b; - vec4 c; - vec4 d; -}; - -layout(std430, binding = 2) readonly buffer SSBO3 -{ - Foo foos[]; -} foobar; - -vec4 bar(Foo foo) -{ - return foo.a + foo.b + foo.c + foo.d; -} - -void baz(out Foo foo) -{ - uint ident = gl_GlobalInvocationID.x; - foo.a = indata.data[4u * ident + 0u]; - foo.b = indata.data[4u * ident + 1u]; - foo.c = indata.data[4u * ident + 2u]; - foo.d = indata.data[4u * ident + 3u]; -} - -void meow(inout Foo foo) -{ - foo.a += 10.0; - foo.b += 20.0; - foo.c += 30.0; - foo.d += 40.0; -} - -void main() -{ - Foo foo; - baz(foo); - meow(foo); - outdata.data[gl_GlobalInvocationID.x] = bar(foo) + bar(foobar.foos[gl_GlobalInvocationID.x]); -} diff --git a/deps/SPIRV-Cross/shaders/comp/insert.comp b/deps/SPIRV-Cross/shaders/comp/insert.comp deleted file mode 100644 index 07c1f8d7aa..0000000000 --- a/deps/SPIRV-Cross/shaders/comp/insert.comp +++ /dev/null @@ -1,18 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -layout(std430, binding = 0) writeonly buffer SSBO -{ - vec4 out_data[]; -}; - -void main() -{ - vec4 v; - v.x = 10.0; - v.y = 30.0; - v.z = 70.0; - v.w = 90.0; - out_data[gl_GlobalInvocationID.x] = v; - out_data[gl_GlobalInvocationID.x].y = 20.0; -} diff --git a/deps/SPIRV-Cross/shaders/comp/loop.noopt.comp b/deps/SPIRV-Cross/shaders/comp/loop.noopt.comp deleted file mode 100644 index 6d6c324243..0000000000 --- a/deps/SPIRV-Cross/shaders/comp/loop.noopt.comp +++ /dev/null @@ -1,98 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -layout(std430, binding = 0) readonly buffer SSBO -{ - mat4 mvp; - vec4 in_data[]; -}; - -layout(std430, binding = 1) writeonly buffer SSBO2 -{ - vec4 out_data[]; -}; - -void main() -{ - uint ident = gl_GlobalInvocationID.x; - vec4 idat = in_data[ident]; - - int k = 0; - uint i = 0u; - - if (idat.y == 20.0) - { - do - { - k = k * 2; - i++; - } while (i < ident); - } - - switch (k) - { - case 10: - for (;;) - { - i++; - if (i > 10u) - break; - } - break; - - default: - for (;;) - { - i += 2u; - if (i > 20u) - break; - } - break; - } - - while (k < 10) - { - idat *= 2.0; - k++; - } - - for (uint i = 0u; i < 16u; i++, k++) - for (uint j = 0u; j < 30u; j++) - idat = mvp * idat; - - k = 0; - for (;;) - { - k++; - if (k > 10) - { - k += 2; - } - else - { - k += 3; - continue; - } - - k += 10; - } - - k = 0; - do - { - k++; - } while (k > 10); - - int l = 0; - for (;; l++) - { - if (l == 5) - { - continue; - } - - idat += 1.0; - } - out_data[ident] = idat; -} - diff --git a/deps/SPIRV-Cross/shaders/comp/mat3.comp b/deps/SPIRV-Cross/shaders/comp/mat3.comp deleted file mode 100644 index 7c5bb1e4f5..0000000000 --- a/deps/SPIRV-Cross/shaders/comp/mat3.comp +++ /dev/null @@ -1,14 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -layout(std430, binding = 1) writeonly buffer SSBO2 -{ - mat3 out_data[]; -}; - -void main() -{ - uint ident = gl_GlobalInvocationID.x; - out_data[ident] = mat3(vec3(10.0), vec3(20.0), vec3(40.0)); -} - diff --git a/deps/SPIRV-Cross/shaders/comp/mod.comp b/deps/SPIRV-Cross/shaders/comp/mod.comp deleted file mode 100644 index 1631456e30..0000000000 --- a/deps/SPIRV-Cross/shaders/comp/mod.comp +++ /dev/null @@ -1,26 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -layout(std430, binding = 0) readonly buffer SSBO -{ - vec4 in_data[]; -}; - -layout(std430, binding = 1) writeonly buffer SSBO2 -{ - vec4 out_data[]; -}; - -void main() -{ - uint ident = gl_GlobalInvocationID.x; - vec4 v = mod(in_data[ident], out_data[ident]); - out_data[ident] = v; - - uvec4 vu = floatBitsToUint(in_data[ident]) % floatBitsToUint(out_data[ident]); - out_data[ident] = uintBitsToFloat(vu); - - ivec4 vi = floatBitsToInt(in_data[ident]) % floatBitsToInt(out_data[ident]); - out_data[ident] = intBitsToFloat(vi); -} - diff --git a/deps/SPIRV-Cross/shaders/comp/modf.comp b/deps/SPIRV-Cross/shaders/comp/modf.comp deleted file mode 100644 index edadefcf05..0000000000 --- a/deps/SPIRV-Cross/shaders/comp/modf.comp +++ /dev/null @@ -1,23 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -layout(std430, binding = 0) readonly buffer SSBO -{ - vec4 in_data[]; -}; - -layout(std430, binding = 1) writeonly buffer SSBO2 -{ - vec4 out_data[]; -}; - -void main() -{ - uint ident = gl_GlobalInvocationID.x; - vec4 i; - //vec4 v = frexp(in_data[ident], i); - //out_data[ident] = ldexp(v, i); - vec4 v = modf(in_data[ident], i); - out_data[ident] = v; -} - diff --git a/deps/SPIRV-Cross/shaders/comp/read-write-only.comp b/deps/SPIRV-Cross/shaders/comp/read-write-only.comp deleted file mode 100644 index b224b6f121..0000000000 --- a/deps/SPIRV-Cross/shaders/comp/read-write-only.comp +++ /dev/null @@ -1,26 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -layout(binding = 0, std430) readonly buffer SSBO0 -{ - vec4 data0; - vec4 data1; -}; - -layout(binding = 1, std430) restrict buffer SSBO1 -{ - vec4 data2; - vec4 data3; -}; - -layout(binding = 2, std430) restrict writeonly buffer SSBO2 -{ - vec4 data4; - vec4 data5; -}; - -void main() -{ - data4 = data0 + data2; - data5 = data1 + data3; -} diff --git a/deps/SPIRV-Cross/shaders/comp/return.comp b/deps/SPIRV-Cross/shaders/comp/return.comp deleted file mode 100644 index 617f437182..0000000000 --- a/deps/SPIRV-Cross/shaders/comp/return.comp +++ /dev/null @@ -1,33 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -layout(std430, binding = 1) writeonly buffer SSBO2 -{ - vec4 out_data[]; -}; - -void main() -{ - uint ident = gl_GlobalInvocationID.x; - - if (ident == 2u) - { - out_data[ident] = vec4(20.0); - } - else if (ident == 4u) - { - out_data[ident] = vec4(10.0); - return; - } - - for (int i = 0; i < 20; i++) - { - if (i == 10) - break; - - return; - } - - out_data[ident] = vec4(10.0); -} - diff --git a/deps/SPIRV-Cross/shaders/comp/rmw-opt.comp b/deps/SPIRV-Cross/shaders/comp/rmw-opt.comp deleted file mode 100644 index a6e1e7fe75..0000000000 --- a/deps/SPIRV-Cross/shaders/comp/rmw-opt.comp +++ /dev/null @@ -1,27 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -layout(std430, binding = 0) buffer SSBO -{ - int a; -}; - -void main() -{ - a += 10; - a -= 10; - a *= 10; - a /= 10; - a <<= 2; - a >>= 3; - a &= 40; - a ^= 10; - a %= 40; - a |= 1; - - bool c = false; - bool d = true; - c = c && d; - d = d || c; - a = c && d ? 1 : 0; -} diff --git a/deps/SPIRV-Cross/shaders/comp/shared.comp b/deps/SPIRV-Cross/shaders/comp/shared.comp deleted file mode 100644 index 4deff93597..0000000000 --- a/deps/SPIRV-Cross/shaders/comp/shared.comp +++ /dev/null @@ -1,27 +0,0 @@ -#version 310 es -layout(local_size_x = 4) in; - -shared float sShared[gl_WorkGroupSize.x]; - -layout(std430, binding = 0) readonly buffer SSBO -{ - float in_data[]; -}; - -layout(std430, binding = 1) writeonly buffer SSBO2 -{ - float out_data[]; -}; - -void main() -{ - uint ident = gl_GlobalInvocationID.x; - float idata = in_data[ident]; - - sShared[gl_LocalInvocationIndex] = idata; - memoryBarrierShared(); - barrier(); - - out_data[ident] = sShared[gl_WorkGroupSize.x - gl_LocalInvocationIndex - 1u]; -} - diff --git a/deps/SPIRV-Cross/shaders/comp/ssbo-array.comp b/deps/SPIRV-Cross/shaders/comp/ssbo-array.comp deleted file mode 100644 index da0eae0889..0000000000 --- a/deps/SPIRV-Cross/shaders/comp/ssbo-array.comp +++ /dev/null @@ -1,14 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -layout(std430, binding = 0) buffer SSBO -{ - vec4 data[]; -} ssbos[2]; - -void main() -{ - uint ident = gl_GlobalInvocationID.x; - ssbos[1].data[ident] = ssbos[0].data[ident]; -} - diff --git a/deps/SPIRV-Cross/shaders/comp/struct-layout.comp b/deps/SPIRV-Cross/shaders/comp/struct-layout.comp deleted file mode 100644 index 5a2b7802df..0000000000 --- a/deps/SPIRV-Cross/shaders/comp/struct-layout.comp +++ /dev/null @@ -1,24 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -struct Foo -{ - mat4 m; -}; - -layout(std430, binding = 0) readonly buffer SSBO -{ - Foo in_data[]; -}; - -layout(std430, binding = 1) writeonly buffer SSBO2 -{ - Foo out_data[]; -}; - -void main() -{ - uint ident = gl_GlobalInvocationID.x; - out_data[ident].m = in_data[ident].m * in_data[ident].m; -} - diff --git a/deps/SPIRV-Cross/shaders/comp/struct-packing.comp b/deps/SPIRV-Cross/shaders/comp/struct-packing.comp deleted file mode 100644 index 53a54e4927..0000000000 --- a/deps/SPIRV-Cross/shaders/comp/struct-packing.comp +++ /dev/null @@ -1,86 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -struct S0 -{ - vec2 a[1]; - float b; -}; - -struct S1 -{ - vec3 a; - float b; -}; - -struct S2 -{ - vec3 a[1]; - float b; -}; - -struct S3 -{ - vec2 a; - float b; -}; - -struct S4 -{ - vec2 c; -}; - -struct Content -{ - S0 m0s[1]; - S1 m1s[1]; - S2 m2s[1]; - S0 m0; - S1 m1; - S2 m2; - S3 m3; - float m4; - - S4 m3s[8]; -}; - -layout(binding = 1, std430) buffer SSBO1 -{ - Content content; - Content content1[2]; - Content content2; - - layout(column_major) mat2 m0; - layout(column_major) mat2 m1; - layout(column_major) mat2x3 m2[4]; - layout(column_major) mat3x2 m3; - layout(row_major) mat2 m4; - layout(row_major) mat2 m5[9]; - layout(row_major) mat2x3 m6[4][2]; - layout(row_major) mat3x2 m7; - float array[]; -} ssbo_430; - -layout(binding = 0, std140) buffer SSBO0 -{ - Content content; - Content content1[2]; - Content content2; - - layout(column_major) mat2 m0; - layout(column_major) mat2 m1; - layout(column_major) mat2x3 m2[4]; - layout(column_major) mat3x2 m3; - layout(row_major) mat2 m4; - layout(row_major) mat2 m5[9]; - layout(row_major) mat2x3 m6[4][2]; - layout(row_major) mat3x2 m7; - - float array[]; -} ssbo_140; - -void main() -{ - ssbo_430.content = ssbo_140.content; -} - diff --git a/deps/SPIRV-Cross/shaders/comp/torture-loop.comp b/deps/SPIRV-Cross/shaders/comp/torture-loop.comp deleted file mode 100644 index 54a1221a15..0000000000 --- a/deps/SPIRV-Cross/shaders/comp/torture-loop.comp +++ /dev/null @@ -1,40 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -layout(std430, binding = 0) readonly buffer SSBO -{ - mat4 mvp; - vec4 in_data[]; -}; - -layout(std430, binding = 1) writeonly buffer SSBO2 -{ - vec4 out_data[]; -}; - -void main() -{ - uint ident = gl_GlobalInvocationID.x; - vec4 idat = in_data[ident]; - - int k = 0; - - // Continue with side effects. - while (++k < 10) - { - idat *= 2.0; - k++; - } - - // Again used here ... - for (uint i = 0u; i < 16u; i++, k++) - for (uint j = 0u; j < 30u; j++) - idat = mvp * idat; - - do - { - k++; - } while (k > 10); - out_data[ident] = idat; -} - diff --git a/deps/SPIRV-Cross/shaders/comp/type-alias.comp b/deps/SPIRV-Cross/shaders/comp/type-alias.comp deleted file mode 100644 index 343d350a2f..0000000000 --- a/deps/SPIRV-Cross/shaders/comp/type-alias.comp +++ /dev/null @@ -1,45 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -struct S0 -{ - vec4 a; -}; - -struct S1 -{ - vec4 a; -}; - -vec4 overload(S0 s0) -{ - return s0.a; -} - -vec4 overload(S1 s1) -{ - return s1.a; -} - -layout(std430, binding = 0) buffer SSBO0 -{ - S0 s0s[]; -}; - -layout(std430, binding = 1) buffer SSBO1 -{ - S1 s1s[]; -}; - -layout(std430, binding = 2) buffer SSBO2 -{ - vec4 outputs[]; -}; - - -void main() -{ - S0 s0 = s0s[gl_GlobalInvocationID.x]; - S1 s1 = s1s[gl_GlobalInvocationID.x]; - outputs[gl_GlobalInvocationID.x] = overload(s0) + overload(s1); -} diff --git a/deps/SPIRV-Cross/shaders/comp/udiv.comp b/deps/SPIRV-Cross/shaders/comp/udiv.comp deleted file mode 100644 index 33fe564f07..0000000000 --- a/deps/SPIRV-Cross/shaders/comp/udiv.comp +++ /dev/null @@ -1,17 +0,0 @@ -#version 310 es -layout(local_size_x = 1) in; - -layout(std430, binding = 0) buffer SSBO -{ - uint inputs[]; -}; - -layout(std430, binding = 0) buffer SSBO2 -{ - uint outputs[]; -}; - -void main() -{ - outputs[gl_GlobalInvocationID.x] = inputs[gl_GlobalInvocationID.x] / 29u; -} diff --git a/deps/SPIRV-Cross/shaders/desktop-only/comp/enhanced-layouts.comp b/deps/SPIRV-Cross/shaders/desktop-only/comp/enhanced-layouts.comp deleted file mode 100644 index 470b73e9bd..0000000000 --- a/deps/SPIRV-Cross/shaders/desktop-only/comp/enhanced-layouts.comp +++ /dev/null @@ -1,39 +0,0 @@ -#version 450 - -struct Foo -{ - int a; - int b; - int c; -}; - -layout(std140, binding = 0) uniform UBO -{ - layout(offset = 4) int a; - layout(offset = 8) int b; - layout(offset = 16) Foo foo; - layout(offset = 48) int c[8]; -} ubo; - -layout(std140, binding = 1) buffer SSBO1 -{ - layout(offset = 4) int a; - layout(offset = 8) int b; - layout(offset = 16) Foo foo; - layout(offset = 48) int c[8]; -} ssbo1; - -layout(std430, binding = 2) buffer SSBO2 -{ - layout(offset = 4) int a; - layout(offset = 8) int b; - layout(offset = 16) Foo foo; - layout(offset = 48) int c[8]; -} ssbo2; - -void main() -{ - ssbo1.a = ssbo2.a; - ssbo1.b = ubo.b; -} - diff --git a/deps/SPIRV-Cross/shaders/desktop-only/comp/fp64.desktop.comp b/deps/SPIRV-Cross/shaders/desktop-only/comp/fp64.desktop.comp deleted file mode 100644 index dd488a3077..0000000000 --- a/deps/SPIRV-Cross/shaders/desktop-only/comp/fp64.desktop.comp +++ /dev/null @@ -1,91 +0,0 @@ -#version 450 -layout(local_size_x = 1) in; - -struct M0 -{ - double v; - dvec2 b[2]; - dmat2x3 c; - dmat3x2 d; -}; - -// Test buffer layout handling. -layout(std430, binding = 0) buffer SSBO0 -{ - dvec4 a; - M0 m0; - dmat4 b; -} ssbo_0; - -layout(std430, binding = 1) buffer SSBO1 -{ - dmat4 a; - dvec4 b; - M0 m0; -} ssbo_1; - -layout(std430, binding = 2) buffer SSBO2 -{ - double a[4]; - dvec2 b[4]; -} ssbo_2; - -layout(std140, binding = 3) buffer SSBO3 -{ - double a[4]; - dvec2 b[4]; -} ssbo_3; - -void main() -{ - ssbo_0.a += dvec4(10, 20, 30, 40); - ssbo_0.a += 20; - - dvec4 a = ssbo_0.a; - dmat4 amat = ssbo_0.b; - - ssbo_0.a = abs(a); - ssbo_0.a = sign(a); - ssbo_0.a = floor(a); - ssbo_0.a = trunc(a); - ssbo_0.a = round(a); - ssbo_0.a = roundEven(a); - ssbo_0.a = ceil(a); - ssbo_0.a = fract(a); - ssbo_0.a = mod(a, 20.0); - ssbo_0.a = mod(a, a); - ssbo_0.a = min(a, a); - ssbo_0.a = max(a, a); - ssbo_0.a = clamp(a, a, a); - ssbo_0.a = mix(a, a, a); - ssbo_0.a = step(a, a); - ssbo_0.a = smoothstep(a, a, a); - bvec4 b = isnan(a); - bvec4 c = isinf(a); - - double f = packDouble2x32(uvec2(10, 40)); - uvec2 g = unpackDouble2x32(f); - - double d = length(a); - d = distance(a, a); - d = dot(a, a); - dvec3 e = cross(a.xyz, a.yzw); - a = faceforward(a, a, a); - a = reflect(a, a); - a = refract(a, a, a.x); - - dmat4 l = matrixCompMult(amat, amat); - l = outerProduct(a, a); - l = transpose(l); - double m = determinant(l); - l = inverse(l); - - bvec4 k = lessThan(a, a); - k = lessThanEqual(a, a); - k = greaterThan(a, a); - k = greaterThanEqual(a, a); - - ssbo_1.b.x += 1.0lf; - ssbo_2.b[0].x += 1.0lf; - ssbo_3.b[0].x += 1.0lf; -} diff --git a/deps/SPIRV-Cross/shaders/desktop-only/comp/image-formats.desktop.noeliminate.comp b/deps/SPIRV-Cross/shaders/desktop-only/comp/image-formats.desktop.noeliminate.comp deleted file mode 100644 index 5a70623c85..0000000000 --- a/deps/SPIRV-Cross/shaders/desktop-only/comp/image-formats.desktop.noeliminate.comp +++ /dev/null @@ -1,48 +0,0 @@ -#version 450 -layout(local_size_x = 1) in; - -layout(rgba32f, binding = 0) uniform image2D uImg00; -layout(rgba16f, binding = 1) uniform image2D uImg01; -layout(rg32f, binding = 2) uniform image2D uImg02; -layout(rg16f, binding = 3) uniform image2D uImg03; -layout(r11f_g11f_b10f, binding = 4) uniform image2D uImg04; -layout(r32f, binding = 5) uniform image2D uImg05; -layout(r16f, binding = 6) uniform image2D uImg06; -layout(rgba16, binding = 7) uniform image2D uImg07; -layout(rgb10_a2, binding = 8) uniform image2D uImg08; -layout(rgba8, binding = 9) uniform image2D uImg09; -layout(rg16, binding = 10) uniform image2D uImg10; -layout(rg8, binding = 11) uniform image2D uImg11; -layout(r16, binding = 12) uniform image2D uImg12; -layout(r8, binding = 13) uniform image2D uImg13; -layout(rgba16_snorm, binding = 14) uniform image2D uImg14; -layout(rgba8_snorm, binding = 15) uniform image2D uImg15; -layout(rg16_snorm, binding = 16) uniform image2D uImg16; -layout(rg8_snorm, binding = 17) uniform image2D uImg17; -layout(r16_snorm, binding = 18) uniform image2D uImg18; -layout(r8_snorm, binding = 19) uniform image2D uImg19; - -layout(rgba32i, binding = 20) uniform iimage2D uImage20; -layout(rgba16i, binding = 21) uniform iimage2D uImage21; -layout(rgba8i, binding = 22) uniform iimage2D uImage22; -layout(rg32i, binding = 23) uniform iimage2D uImage23; -layout(rg16i, binding = 24) uniform iimage2D uImage24; -layout(rg8i, binding = 25) uniform iimage2D uImage25; -layout(r32i, binding = 26) uniform iimage2D uImage26; -layout(r16i, binding = 27) uniform iimage2D uImage27; -layout(r8i, binding = 28) uniform iimage2D uImage28; - -layout(rgba32ui, binding = 29) uniform uimage2D uImage29; -layout(rgba16ui, binding = 30) uniform uimage2D uImage30; -layout(rgb10_a2ui, binding = 31) uniform uimage2D uImage31; -layout(rgba8ui, binding = 32) uniform uimage2D uImage32; -layout(rg32ui, binding = 33) uniform uimage2D uImage33; -layout(rg16ui, binding = 34) uniform uimage2D uImage34; -layout(rg8ui, binding = 35) uniform uimage2D uImage35; -layout(r32ui, binding = 36) uniform uimage2D uImage36; -layout(r16ui, binding = 37) uniform uimage2D uImage37; -layout(r8ui, binding = 38) uniform uimage2D uImage38; - -void main() -{ -} diff --git a/deps/SPIRV-Cross/shaders/desktop-only/comp/int64.desktop.comp b/deps/SPIRV-Cross/shaders/desktop-only/comp/int64.desktop.comp deleted file mode 100644 index 81004d4ad6..0000000000 --- a/deps/SPIRV-Cross/shaders/desktop-only/comp/int64.desktop.comp +++ /dev/null @@ -1,55 +0,0 @@ -#version 450 -#extension GL_ARB_gpu_shader_int64 : require -layout(local_size_x = 1) in; - -struct M0 -{ - int64_t v; - i64vec2 b[2]; - uint64_t c; - uint64_t d[5]; -}; - -// Test buffer layout handling. -layout(std430, binding = 0) buffer SSBO0 -{ - i64vec4 a; - M0 m0; -} ssbo_0; - -layout(std430, binding = 1) buffer SSBO1 -{ - u64vec4 b; - M0 m0; -} ssbo_1; - -layout(std430, binding = 2) buffer SSBO2 -{ - int64_t a[4]; - i64vec2 b[4]; -} ssbo_2; - -layout(std140, binding = 3) buffer SSBO3 -{ - int64_t a[4]; - i64vec2 b[4]; -} ssbo_3; - -void main() -{ - ssbo_0.a += i64vec4(10, 20, 30, 40); - ssbo_1.b += u64vec4(999999999999999999ul, 8888888888888888ul, 77777777777777777ul, 6666666666666666ul); - ssbo_0.a += 20; - ssbo_0.a = abs(ssbo_0.a + i64vec4(ssbo_1.b)); - - ssbo_0.a++; - ssbo_1.b++; - ssbo_0.a--; - ssbo_1.b--; - - ssbo_1.b = doubleBitsToUint64(int64BitsToDouble(ssbo_0.a)); - ssbo_0.a = doubleBitsToInt64(uint64BitsToDouble(ssbo_1.b)); - - ssbo_2.a[0] += 1l; - ssbo_3.a[0] += 2l; -} diff --git a/deps/SPIRV-Cross/shaders/desktop-only/frag/hlsl-uav-block-alias.asm.frag b/deps/SPIRV-Cross/shaders/desktop-only/frag/hlsl-uav-block-alias.asm.frag deleted file mode 100644 index 1c6dd7b8b7..0000000000 --- a/deps/SPIRV-Cross/shaders/desktop-only/frag/hlsl-uav-block-alias.asm.frag +++ /dev/null @@ -1,56 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 2 -; Bound: 29 -; Schema: 0 - OpCapability Shader - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %main "main" %_entryPointOutput - OpExecutionMode %main OriginUpperLeft - OpSource HLSL 500 - OpName %main "main" - OpName %_main_ "@main(" - OpName %Foobar "Foobar" - OpMemberName %Foobar 0 "@data" - OpName %Foobar_0 "Foobar" - OpName %Foobaz "Foobaz" - OpName %_entryPointOutput "@entryPointOutput" - OpDecorate %_runtimearr_v4float ArrayStride 16 - OpMemberDecorate %Foobar 0 Offset 0 - OpDecorate %Foobar BufferBlock - OpDecorate %Foobar_0 DescriptorSet 0 - OpDecorate %Foobar_0 Binding 0 - OpDecorate %Foobaz DescriptorSet 0 - OpDecorate %Foobaz Binding 1 - OpDecorate %_entryPointOutput Location 0 - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 - %v4float = OpTypeVector %float 4 - %8 = OpTypeFunction %v4float -%_runtimearr_v4float = OpTypeRuntimeArray %v4float - %Foobar = OpTypeStruct %_runtimearr_v4float -%_ptr_Uniform_Foobar = OpTypePointer Uniform %Foobar - %Foobar_0 = OpVariable %_ptr_Uniform_Foobar Uniform - %int = OpTypeInt 32 1 - %int_0 = OpConstant %int 0 -%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float - %Foobaz = OpVariable %_ptr_Uniform_Foobar Uniform -%_ptr_Output_v4float = OpTypePointer Output %v4float -%_entryPointOutput = OpVariable %_ptr_Output_v4float Output - %main = OpFunction %void None %3 - %5 = OpLabel - %28 = OpFunctionCall %v4float %_main_ - OpStore %_entryPointOutput %28 - OpReturn - OpFunctionEnd - %_main_ = OpFunction %v4float None %8 - %10 = OpLabel - %18 = OpAccessChain %_ptr_Uniform_v4float %Foobar_0 %int_0 %int_0 - %19 = OpLoad %v4float %18 - %21 = OpAccessChain %_ptr_Uniform_v4float %Foobaz %int_0 %int_0 - %22 = OpLoad %v4float %21 - %23 = OpFAdd %v4float %19 %22 - OpReturnValue %23 - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders/desktop-only/frag/image-ms.desktop.frag b/deps/SPIRV-Cross/shaders/desktop-only/frag/image-ms.desktop.frag deleted file mode 100644 index d3acc3081a..0000000000 --- a/deps/SPIRV-Cross/shaders/desktop-only/frag/image-ms.desktop.frag +++ /dev/null @@ -1,12 +0,0 @@ -#version 450 - -layout(rgba8, binding = 0) uniform image2DMS uImage; -layout(rgba8, binding = 1) uniform image2DMSArray uImageArray; - -void main() -{ - vec4 a = imageLoad(uImage, ivec2(1, 2), 2); - vec4 b = imageLoad(uImageArray, ivec3(1, 2, 4), 3); - imageStore(uImage, ivec2(2, 3), 1, a); - imageStore(uImageArray, ivec3(2, 3, 7), 1, b); -} diff --git a/deps/SPIRV-Cross/shaders/desktop-only/frag/image-query.desktop.frag b/deps/SPIRV-Cross/shaders/desktop-only/frag/image-query.desktop.frag deleted file mode 100644 index a5cbe011e2..0000000000 --- a/deps/SPIRV-Cross/shaders/desktop-only/frag/image-query.desktop.frag +++ /dev/null @@ -1,56 +0,0 @@ -#version 450 - -layout(binding = 0) uniform sampler1D uSampler1D; -layout(binding = 1) uniform sampler2D uSampler2D; -layout(binding = 2) uniform sampler2DArray uSampler2DArray; -layout(binding = 3) uniform sampler3D uSampler3D; -layout(binding = 4) uniform samplerCube uSamplerCube; -layout(binding = 5) uniform samplerCubeArray uSamplerCubeArray; -layout(binding = 6) uniform samplerBuffer uSamplerBuffer; -layout(binding = 7) uniform sampler2DMS uSamplerMS; -layout(binding = 8) uniform sampler2DMSArray uSamplerMSArray; - -layout(r32f, binding = 9) uniform image1D uImage1D; -layout(r32f, binding = 10) uniform image2D uImage2D; -layout(r32f, binding = 11) uniform image2DArray uImage2DArray; -layout(r32f, binding = 12) uniform image3D uImage3D; -layout(r32f, binding = 13) uniform imageCube uImageCube; -layout(r32f, binding = 14) uniform imageCubeArray uImageCubeArray; -layout(r32f, binding = 15) uniform imageBuffer uImageBuffer; -layout(r32f, binding = 16) uniform image2DMS uImageMS; -layout(r32f, binding = 17) uniform image2DMSArray uImageMSArray; - -void main() -{ - int a = textureSize(uSampler1D, 0); - ivec2 b = textureSize(uSampler2D, 0); - ivec3 c = textureSize(uSampler2DArray, 0); - ivec3 d = textureSize(uSampler3D, 0); - ivec2 e = textureSize(uSamplerCube, 0); - ivec3 f = textureSize(uSamplerCubeArray, 0); - int g = textureSize(uSamplerBuffer); - ivec2 h = textureSize(uSamplerMS); - ivec3 i = textureSize(uSamplerMSArray); - - int l0 = textureQueryLevels(uSampler1D); - int l1 = textureQueryLevels(uSampler2D); - int l2 = textureQueryLevels(uSampler2DArray); - int l3 = textureQueryLevels(uSampler3D); - int l4 = textureQueryLevels(uSamplerCube); - int l5 = textureQueryLevels(uSamplerCubeArray); - - a = imageSize(uImage1D); - b = imageSize(uImage2D); - c = imageSize(uImage2DArray); - d = imageSize(uImage3D); - e = imageSize(uImageCube); - f = imageSize(uImageCubeArray); - g = imageSize(uImageBuffer); - h = imageSize(uImageMS); - i = imageSize(uImageMSArray); - - int s0 = textureSamples(uSamplerMS); - int s1 = textureSamples(uSamplerMSArray); - int s2 = imageSamples(uImageMS); - int s3 = imageSamples(uImageMSArray); -} diff --git a/deps/SPIRV-Cross/shaders/desktop-only/frag/in-block-qualifiers.frag b/deps/SPIRV-Cross/shaders/desktop-only/frag/in-block-qualifiers.frag deleted file mode 100644 index f22096e6d1..0000000000 --- a/deps/SPIRV-Cross/shaders/desktop-only/frag/in-block-qualifiers.frag +++ /dev/null @@ -1,20 +0,0 @@ -#version 450 - -layout(location = 0) in VertexData { - flat float f; - centroid vec4 g; - flat int h; - float i; -} vin; - -layout(location = 4) in flat float f; -layout(location = 5) in centroid vec4 g; -layout(location = 6) in flat int h; -layout(location = 7) in sample float i; - -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = vin.f + vin.g + float(vin.h) + vin.i + f + g + float(h) + i; -} diff --git a/deps/SPIRV-Cross/shaders/desktop-only/frag/query-levels.desktop.frag b/deps/SPIRV-Cross/shaders/desktop-only/frag/query-levels.desktop.frag deleted file mode 100644 index 3a6977611b..0000000000 --- a/deps/SPIRV-Cross/shaders/desktop-only/frag/query-levels.desktop.frag +++ /dev/null @@ -1,9 +0,0 @@ -#version 450 - -layout(binding = 0) uniform sampler2D uSampler; -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = vec4(textureQueryLevels(uSampler)); -} diff --git a/deps/SPIRV-Cross/shaders/desktop-only/frag/query-lod.desktop.frag b/deps/SPIRV-Cross/shaders/desktop-only/frag/query-lod.desktop.frag deleted file mode 100644 index 0cb160402f..0000000000 --- a/deps/SPIRV-Cross/shaders/desktop-only/frag/query-lod.desktop.frag +++ /dev/null @@ -1,10 +0,0 @@ -#version 450 - -layout(location = 0) in vec2 vTexCoord; -layout(binding = 0) uniform sampler2D uSampler; -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = textureQueryLod(uSampler, vTexCoord).xyxy; -} diff --git a/deps/SPIRV-Cross/shaders/desktop-only/frag/sampler-ms-query.desktop.frag b/deps/SPIRV-Cross/shaders/desktop-only/frag/sampler-ms-query.desktop.frag deleted file mode 100644 index f707ed5c41..0000000000 --- a/deps/SPIRV-Cross/shaders/desktop-only/frag/sampler-ms-query.desktop.frag +++ /dev/null @@ -1,17 +0,0 @@ -#version 450 - -layout(location = 0) out vec4 FragColor; -layout(binding = 0) uniform sampler2DMS uSampler; -layout(binding = 1) uniform sampler2DMSArray uSamplerArray; -layout(rgba8, binding = 2) uniform image2DMS uImage; -layout(rgba8, binding = 3) uniform image2DMSArray uImageArray; - -void main() -{ - FragColor = - vec4( - textureSamples(uSampler) + - textureSamples(uSamplerArray) + - imageSamples(uImage) + - imageSamples(uImageArray)); -} diff --git a/deps/SPIRV-Cross/shaders/desktop-only/frag/texture-proj-shadow.desktop.frag b/deps/SPIRV-Cross/shaders/desktop-only/frag/texture-proj-shadow.desktop.frag deleted file mode 100644 index 0c4cf8f5a8..0000000000 --- a/deps/SPIRV-Cross/shaders/desktop-only/frag/texture-proj-shadow.desktop.frag +++ /dev/null @@ -1,21 +0,0 @@ -#version 450 - -layout(binding = 0) uniform sampler1DShadow uShadow1D; -layout(binding = 1) uniform sampler2DShadow uShadow2D; -layout(binding = 2) uniform sampler1D uSampler1D; -layout(binding = 3) uniform sampler2D uSampler2D; -layout(binding = 4) uniform sampler3D uSampler3D; - -layout(location = 0) out float FragColor; -layout(location = 0) in vec3 vClip3; -layout(location = 1) in vec4 vClip4; -layout(location = 2) in vec2 vClip2; - -void main() -{ - FragColor = textureProj(uShadow1D, vClip4); - FragColor = textureProj(uShadow2D, vClip4); - FragColor = textureProj(uSampler1D, vClip2).x; - FragColor = textureProj(uSampler2D, vClip3).x; - FragColor = textureProj(uSampler3D, vClip4).x; -} diff --git a/deps/SPIRV-Cross/shaders/desktop-only/geom/basic.desktop.sso.geom b/deps/SPIRV-Cross/shaders/desktop-only/geom/basic.desktop.sso.geom deleted file mode 100644 index f3d331dd15..0000000000 --- a/deps/SPIRV-Cross/shaders/desktop-only/geom/basic.desktop.sso.geom +++ /dev/null @@ -1,37 +0,0 @@ -#version 450 - -layout(triangles, invocations = 4) in; -layout(triangle_strip, max_vertices = 3) out; - -in gl_PerVertex -{ - vec4 gl_Position; -} gl_in[]; - -out gl_PerVertex -{ - vec4 gl_Position; -}; - -layout(location = 0) in VertexData { - vec3 normal; -} vin[]; - -layout(location = 0) out vec3 vNormal; - -void main() -{ - gl_Position = gl_in[0].gl_Position; - vNormal = vin[0].normal + float(gl_InvocationID); - EmitVertex(); - - gl_Position = gl_in[1].gl_Position; - vNormal = vin[1].normal + 4.0 * float(gl_InvocationID); - EmitVertex(); - - gl_Position = gl_in[2].gl_Position; - vNormal = vin[2].normal + 2.0 * float(gl_InvocationID); - EmitVertex(); - - EndPrimitive(); -} diff --git a/deps/SPIRV-Cross/shaders/desktop-only/geom/viewport-index.desktop.geom b/deps/SPIRV-Cross/shaders/desktop-only/geom/viewport-index.desktop.geom deleted file mode 100644 index e02e81daf6..0000000000 --- a/deps/SPIRV-Cross/shaders/desktop-only/geom/viewport-index.desktop.geom +++ /dev/null @@ -1,11 +0,0 @@ -#version 450 - -layout(triangles) in; -layout(triangle_strip) out; -layout(max_vertices = 4) out; - -void main() -{ - gl_ViewportIndex = 1; -} - diff --git a/deps/SPIRV-Cross/shaders/desktop-only/tesc/basic.desktop.sso.tesc b/deps/SPIRV-Cross/shaders/desktop-only/tesc/basic.desktop.sso.tesc deleted file mode 100644 index 8ff739b0af..0000000000 --- a/deps/SPIRV-Cross/shaders/desktop-only/tesc/basic.desktop.sso.tesc +++ /dev/null @@ -1,28 +0,0 @@ -#version 450 -layout(vertices = 1) out; - -in gl_PerVertex -{ - vec4 gl_Position; -} gl_in[gl_MaxPatchVertices]; - -out gl_PerVertex -{ - vec4 gl_Position; -} gl_out[1]; - -layout(location = 0) patch out vec3 vFoo; - - -void main() -{ - gl_TessLevelInner[0] = 8.9; - gl_TessLevelInner[1] = 6.9; - gl_TessLevelOuter[0] = 8.9; - gl_TessLevelOuter[1] = 6.9; - gl_TessLevelOuter[2] = 3.9; - gl_TessLevelOuter[3] = 4.9; - vFoo = vec3(1.0); - - gl_out[gl_InvocationID].gl_Position = gl_in[0].gl_Position + gl_in[1].gl_Position; -} diff --git a/deps/SPIRV-Cross/shaders/desktop-only/tese/triangle.desktop.sso.tese b/deps/SPIRV-Cross/shaders/desktop-only/tese/triangle.desktop.sso.tese deleted file mode 100644 index c964fbe263..0000000000 --- a/deps/SPIRV-Cross/shaders/desktop-only/tese/triangle.desktop.sso.tese +++ /dev/null @@ -1,22 +0,0 @@ -#version 450 - -layout(cw, triangles, fractional_even_spacing) in; - -in gl_PerVertex -{ - vec4 gl_Position; -} gl_in[gl_MaxPatchVertices]; - -out gl_PerVertex -{ - vec4 gl_Position; -}; - -void main() -{ - gl_Position = - gl_in[0].gl_Position * gl_TessCoord.x + - gl_in[1].gl_Position * gl_TessCoord.y + - gl_in[2].gl_Position * gl_TessCoord.z; -} - diff --git a/deps/SPIRV-Cross/shaders/desktop-only/vert/basic.desktop.sso.vert b/deps/SPIRV-Cross/shaders/desktop-only/vert/basic.desktop.sso.vert deleted file mode 100644 index 9ddab08cda..0000000000 --- a/deps/SPIRV-Cross/shaders/desktop-only/vert/basic.desktop.sso.vert +++ /dev/null @@ -1,20 +0,0 @@ -#version 450 - -out gl_PerVertex -{ - vec4 gl_Position; -}; - -layout(std140) uniform UBO -{ - mat4 uMVP; -}; -layout(location = 0) in vec4 aVertex; -layout(location = 1) in vec3 aNormal; -layout(location = 0) out vec3 vNormal; - -void main() -{ - gl_Position = uMVP * aVertex; - vNormal = aNormal; -} diff --git a/deps/SPIRV-Cross/shaders/desktop-only/vert/clip-cull-distance.desktop.vert b/deps/SPIRV-Cross/shaders/desktop-only/vert/clip-cull-distance.desktop.vert deleted file mode 100644 index 9e4a0b7ac9..0000000000 --- a/deps/SPIRV-Cross/shaders/desktop-only/vert/clip-cull-distance.desktop.vert +++ /dev/null @@ -1,10 +0,0 @@ -#version 450 - -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; -} diff --git a/deps/SPIRV-Cross/shaders/desktop-only/vert/out-block-qualifiers.vert b/deps/SPIRV-Cross/shaders/desktop-only/vert/out-block-qualifiers.vert deleted file mode 100644 index c1e409fb4c..0000000000 --- a/deps/SPIRV-Cross/shaders/desktop-only/vert/out-block-qualifiers.vert +++ /dev/null @@ -1,26 +0,0 @@ -#version 450 - -layout(location = 0) out VertexData { - flat float f; - centroid vec4 g; - flat int h; - float i; -} vout; - -layout(location = 4) out flat float f; -layout(location = 5) out centroid vec4 g; -layout(location = 6) out flat int h; -layout(location = 7) out float i; - -void main() -{ - vout.f = 10.0; - vout.g = vec4(20.0); - vout.h = 20; - vout.i = 30.0; - - f = 10.0; - g = vec4(20.0); - h = 20; - i = 30.0; -} diff --git a/deps/SPIRV-Cross/shaders/flatten/array.flatten.vert b/deps/SPIRV-Cross/shaders/flatten/array.flatten.vert deleted file mode 100644 index fa6da076c9..0000000000 --- a/deps/SPIRV-Cross/shaders/flatten/array.flatten.vert +++ /dev/null @@ -1,19 +0,0 @@ -#version 310 es - -layout(std140) uniform UBO -{ - vec4 A4[5][4][2]; - mat4 uMVP; - vec4 A1[2]; - vec4 A2[2][3]; - float A3[3]; - vec4 Offset; -}; -layout(location = 0) in vec4 aVertex; - -void main() -{ - vec4 a4 = A4[2][3][1]; // 2 * (4 * 2) + 3 * 2 + 1 = 16 + 6 + 1 = 23. - vec4 offset = A2[1][1] + A1[1] + A3[2]; - gl_Position = uMVP * aVertex + Offset + offset; -} diff --git a/deps/SPIRV-Cross/shaders/flatten/basic.flatten.vert b/deps/SPIRV-Cross/shaders/flatten/basic.flatten.vert deleted file mode 100644 index e60a9067b1..0000000000 --- a/deps/SPIRV-Cross/shaders/flatten/basic.flatten.vert +++ /dev/null @@ -1,16 +0,0 @@ -#version 310 es - -layout(std140) uniform UBO -{ - mat4 uMVP; -}; - -layout(location = 0) in vec4 aVertex; -layout(location = 1) in vec3 aNormal; -layout(location = 0) out vec3 vNormal; - -void main() -{ - gl_Position = uMVP * aVertex; - vNormal = aNormal; -} diff --git a/deps/SPIRV-Cross/shaders/flatten/copy.flatten.vert b/deps/SPIRV-Cross/shaders/flatten/copy.flatten.vert deleted file mode 100644 index 4f1b8805e7..0000000000 --- a/deps/SPIRV-Cross/shaders/flatten/copy.flatten.vert +++ /dev/null @@ -1,34 +0,0 @@ -#version 310 es - -struct Light -{ - vec3 Position; - float Radius; - - vec4 Color; -}; - -layout(std140) uniform UBO -{ - mat4 uMVP; - - Light lights[4]; -}; - -layout(location = 0) in vec4 aVertex; -layout(location = 1) in vec3 aNormal; -layout(location = 0) out vec4 vColor; - -void main() -{ - gl_Position = uMVP * aVertex; - - vColor = vec4(0.0); - - for (int i = 0; i < 4; ++i) - { - Light light = lights[i]; - vec3 L = aVertex.xyz - light.Position; - vColor += dot(aNormal, normalize(L)) * (clamp(1.0 - length(L) / light.Radius, 0.0, 1.0) * lights[i].Color); - } -} diff --git a/deps/SPIRV-Cross/shaders/flatten/dynamic.flatten.vert b/deps/SPIRV-Cross/shaders/flatten/dynamic.flatten.vert deleted file mode 100644 index a341d45288..0000000000 --- a/deps/SPIRV-Cross/shaders/flatten/dynamic.flatten.vert +++ /dev/null @@ -1,33 +0,0 @@ -#version 310 es - -struct Light -{ - vec3 Position; - float Radius; - - vec4 Color; -}; - -layout(std140) uniform UBO -{ - mat4 uMVP; - - Light lights[4]; -}; - -layout(location = 0) in vec4 aVertex; -layout(location = 1) in vec3 aNormal; -layout(location = 0) out vec4 vColor; - -void main() -{ - gl_Position = uMVP * aVertex; - - vColor = vec4(0.0); - - for (int i = 0; i < 4; ++i) - { - vec3 L = aVertex.xyz - lights[i].Position; - vColor += dot(aNormal, normalize(L)) * (clamp(1.0 - length(L) / lights[i].Radius, 0.0, 1.0) * lights[i].Color); - } -} diff --git a/deps/SPIRV-Cross/shaders/flatten/matrixindex.flatten.vert b/deps/SPIRV-Cross/shaders/flatten/matrixindex.flatten.vert deleted file mode 100644 index 0ee7838432..0000000000 --- a/deps/SPIRV-Cross/shaders/flatten/matrixindex.flatten.vert +++ /dev/null @@ -1,25 +0,0 @@ -#version 310 es - -layout(std140) uniform UBO -{ - layout(column_major) mat4 M1C; - layout(row_major) mat4 M1R; - layout(column_major) mat2x4 M2C; - layout(row_major) mat2x4 M2R; -}; - -layout(location = 0) out vec4 oA; -layout(location = 1) out vec4 oB; -layout(location = 2) out vec4 oC; -layout(location = 3) out vec4 oD; -layout(location = 4) out vec4 oE; - -void main() -{ - gl_Position = vec4(0.0); - oA = M1C[1]; - oB = M1R[1]; - oC = M2C[1]; - oD = M2R[0]; - oE = vec4(M1C[1][2], M1R[1][2], M2C[1][2], M2R[1][2]); -} diff --git a/deps/SPIRV-Cross/shaders/flatten/multi-dimensional.desktop.flatten_dim.frag b/deps/SPIRV-Cross/shaders/flatten/multi-dimensional.desktop.flatten_dim.frag deleted file mode 100644 index 24b2ff1d2a..0000000000 --- a/deps/SPIRV-Cross/shaders/flatten/multi-dimensional.desktop.flatten_dim.frag +++ /dev/null @@ -1,18 +0,0 @@ -#version 450 - -layout(location = 0) out vec4 FragColor; -layout(binding = 0) uniform sampler2D uTextures[2][3][1]; -layout(location = 0) flat in int vIndex; -layout(location = 1) in vec2 vUV; - -void main() -{ - vec4 values3[2][3][1]; - - for (int z = 0; z < 2; z++) - for (int y = 0; y < 3; y++) - for (int x = 0; x < 1; x++) - values3[z][y][x] = texture(uTextures[z][y][x], vUV); - - FragColor = values3[1][2][0] + values3[0][2][0] + values3[vIndex + 1][2][vIndex]; -} diff --git a/deps/SPIRV-Cross/shaders/flatten/multiindex.flatten.vert b/deps/SPIRV-Cross/shaders/flatten/multiindex.flatten.vert deleted file mode 100644 index 0b471d86e0..0000000000 --- a/deps/SPIRV-Cross/shaders/flatten/multiindex.flatten.vert +++ /dev/null @@ -1,13 +0,0 @@ -#version 310 es - -layout(std140) uniform UBO -{ - vec4 Data[3][5]; -}; - -layout(location = 0) in ivec2 aIndex; - -void main() -{ - gl_Position = Data[aIndex.x][aIndex.y]; -} diff --git a/deps/SPIRV-Cross/shaders/flatten/push-constant.flatten.vert b/deps/SPIRV-Cross/shaders/flatten/push-constant.flatten.vert deleted file mode 100644 index c7b1b42e1b..0000000000 --- a/deps/SPIRV-Cross/shaders/flatten/push-constant.flatten.vert +++ /dev/null @@ -1,17 +0,0 @@ -#version 310 es - -layout(push_constant, std430) uniform PushMe -{ - mat4 MVP; - mat2 Rot; // The MatrixStride will be 8 here. - float Arr[4]; -} registers; - -layout(location = 0) in vec2 Rot; -layout(location = 1) in vec4 Pos; -layout(location = 0) out vec2 vRot; -void main() -{ - gl_Position = registers.MVP * Pos; - vRot = registers.Rot * Rot + registers.Arr[2]; // Constant access should work even if array stride is just 4 here. -} diff --git a/deps/SPIRV-Cross/shaders/flatten/rowmajor.flatten.vert b/deps/SPIRV-Cross/shaders/flatten/rowmajor.flatten.vert deleted file mode 100644 index 88c468c8f2..0000000000 --- a/deps/SPIRV-Cross/shaders/flatten/rowmajor.flatten.vert +++ /dev/null @@ -1,16 +0,0 @@ -#version 310 es - -layout(std140) uniform UBO -{ - layout(column_major) mat4 uMVPR; - layout(row_major) mat4 uMVPC; - layout(row_major) mat2x4 uMVP; -}; - -layout(location = 0) in vec4 aVertex; - -void main() -{ - vec2 v = aVertex * uMVP; - gl_Position = uMVPR * aVertex + uMVPC * aVertex; -} diff --git a/deps/SPIRV-Cross/shaders/flatten/struct.flatten.vert b/deps/SPIRV-Cross/shaders/flatten/struct.flatten.vert deleted file mode 100644 index 936bb41b85..0000000000 --- a/deps/SPIRV-Cross/shaders/flatten/struct.flatten.vert +++ /dev/null @@ -1,30 +0,0 @@ -#version 310 es - -struct Light -{ - vec3 Position; - float Radius; - - vec4 Color; -}; - -layout(std140) uniform UBO -{ - mat4 uMVP; - - Light light; -}; - -layout(location = 0) in vec4 aVertex; -layout(location = 1) in vec3 aNormal; -layout(location = 0) out vec4 vColor; - -void main() -{ - gl_Position = uMVP * aVertex; - - vColor = vec4(0.0); - - vec3 L = aVertex.xyz - light.Position; - vColor += dot(aNormal, normalize(L)) * (clamp(1.0 - length(L) / light.Radius, 0.0, 1.0) * light.Color); -} diff --git a/deps/SPIRV-Cross/shaders/flatten/struct.rowmajor.flatten.vert b/deps/SPIRV-Cross/shaders/flatten/struct.rowmajor.flatten.vert deleted file mode 100644 index 231389b8f4..0000000000 --- a/deps/SPIRV-Cross/shaders/flatten/struct.rowmajor.flatten.vert +++ /dev/null @@ -1,26 +0,0 @@ -#version 310 es - -struct Foo -{ - mat3x4 MVP0; - mat3x4 MVP1; -}; - -layout(std140, binding = 0) uniform UBO -{ - layout(row_major) Foo foo; -}; - -layout(location = 0) in vec4 v0; -layout(location = 1) in vec4 v1; -layout(location = 0) out vec3 V0; -layout(location = 1) out vec3 V1; - -void main() -{ - Foo f = foo; - vec3 a = v0 * f.MVP0; - vec3 b = v1 * f.MVP1; - V0 = a; - V1 = b; -} diff --git a/deps/SPIRV-Cross/shaders/flatten/swizzle.flatten.vert b/deps/SPIRV-Cross/shaders/flatten/swizzle.flatten.vert deleted file mode 100644 index fafff7734e..0000000000 --- a/deps/SPIRV-Cross/shaders/flatten/swizzle.flatten.vert +++ /dev/null @@ -1,47 +0,0 @@ -#version 310 es - -// comments note the 16b alignment boundaries (see GL spec 7.6.2.2 Standard Uniform Block Layout) -layout(std140, binding = 0) uniform UBO -{ - // 16b boundary - vec4 A; - // 16b boundary - vec2 B0; - vec2 B1; - // 16b boundary - float C0; - // 16b boundary (vec3 is aligned to 16b) - vec3 C1; - // 16b boundary - vec3 D0; - float D1; - // 16b boundary - float E0; - float E1; - float E2; - float E3; - // 16b boundary - float F0; - vec2 F1; - // 16b boundary (vec2 before us is aligned to 8b) - float F2; -}; - -layout(location = 0) out vec4 oA; -layout(location = 1) out vec4 oB; -layout(location = 2) out vec4 oC; -layout(location = 3) out vec4 oD; -layout(location = 4) out vec4 oE; -layout(location = 5) out vec4 oF; - -void main() -{ - gl_Position = vec4(0.0); - - oA = A; - oB = vec4(B0, B1); - oC = vec4(C0, C1); - oD = vec4(D0, D1); - oE = vec4(E0, E1, E2, E3); - oF = vec4(F0, F1, F2); -} diff --git a/deps/SPIRV-Cross/shaders/flatten/types.flatten.frag b/deps/SPIRV-Cross/shaders/flatten/types.flatten.frag deleted file mode 100644 index faab5b7e05..0000000000 --- a/deps/SPIRV-Cross/shaders/flatten/types.flatten.frag +++ /dev/null @@ -1,27 +0,0 @@ -#version 310 es -precision mediump float; - -layout(std140, binding = 0) uniform UBO0 -{ - vec4 a; - vec4 b; -}; - -layout(std140, binding = 0) uniform UBO1 -{ - ivec4 c; - ivec4 d; -}; - -layout(std140, binding = 0) uniform UBO2 -{ - uvec4 e; - uvec4 f; -}; - -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = vec4(c) + vec4(d) + vec4(e) + vec4(f) + a + b; -} diff --git a/deps/SPIRV-Cross/shaders/frag/basic.frag b/deps/SPIRV-Cross/shaders/frag/basic.frag deleted file mode 100644 index dd9a8f8507..0000000000 --- a/deps/SPIRV-Cross/shaders/frag/basic.frag +++ /dev/null @@ -1,13 +0,0 @@ -#version 310 es -precision mediump float; - -layout(location = 0) in vec4 vColor; -layout(location = 1) in vec2 vTex; -layout(binding = 0) uniform sampler2D uTex; -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = vColor * texture(uTex, vTex); -} - diff --git a/deps/SPIRV-Cross/shaders/frag/composite-extract-forced-temporary.frag b/deps/SPIRV-Cross/shaders/frag/composite-extract-forced-temporary.frag deleted file mode 100644 index 35fdbe8624..0000000000 --- a/deps/SPIRV-Cross/shaders/frag/composite-extract-forced-temporary.frag +++ /dev/null @@ -1,11 +0,0 @@ -#version 310 es -precision mediump float; -layout(binding = 0) uniform sampler2D Texture; -layout(location = 0) out vec4 FragColor; -layout(location = 0) in vec2 vTexCoord; - -void main() -{ - float f = texture(Texture, vTexCoord).x; - FragColor = vec4(f * f); -} diff --git a/deps/SPIRV-Cross/shaders/frag/constant-array.frag b/deps/SPIRV-Cross/shaders/frag/constant-array.frag deleted file mode 100644 index b862cb1dbf..0000000000 --- a/deps/SPIRV-Cross/shaders/frag/constant-array.frag +++ /dev/null @@ -1,21 +0,0 @@ -#version 310 es -precision mediump float; -layout(location = 0) out vec4 FragColor; - -layout(location = 0) flat in int index; - -struct Foobar { float a; float b; }; - -vec4 resolve(Foobar f) -{ - return vec4(f.a + f.b); -} - -void main() -{ - const vec4 foo[3] = vec4[](vec4(1.0), vec4(2.0), vec4(3.0)); - const vec4 foobars[2][2] = vec4[][](vec4[](vec4(1.0), vec4(2.0)), vec4[](vec4(8.0), vec4(10.0))); - const Foobar foos[2] = Foobar[](Foobar(10.0, 40.0), Foobar(90.0, 70.0)); - - FragColor = foo[index] + foobars[index][index + 1] + resolve(Foobar(10.0, 20.0)) + resolve(foos[index]); -} diff --git a/deps/SPIRV-Cross/shaders/frag/false-loop-init.frag b/deps/SPIRV-Cross/shaders/frag/false-loop-init.frag deleted file mode 100644 index 7ce5b52bd7..0000000000 --- a/deps/SPIRV-Cross/shaders/frag/false-loop-init.frag +++ /dev/null @@ -1,19 +0,0 @@ -#version 310 es -precision mediump float; - -layout(location = 0) in vec4 accum; -layout(location = 0) out vec4 result; - -void main() -{ - result = vec4(0.0); - uint j; - for (int i = 0; i < 4; i += int(j)) - { - if (accum.y > 10.0) - j = 40u; - else - j = 30u; - result += accum; - } -} diff --git a/deps/SPIRV-Cross/shaders/frag/flush_params.frag b/deps/SPIRV-Cross/shaders/frag/flush_params.frag deleted file mode 100644 index 8a26ad3a28..0000000000 --- a/deps/SPIRV-Cross/shaders/frag/flush_params.frag +++ /dev/null @@ -1,27 +0,0 @@ -#version 310 es -precision mediump float; - -layout(location = 0) out vec4 FragColor; - -struct Structy -{ - vec4 c; -}; - -void foo2(out Structy f) -{ - f.c = vec4(10.0); -} - -Structy foo() -{ - Structy f; - foo2(f); - return f; -} - -void main() -{ - Structy s = foo(); - FragColor = s.c; -} diff --git a/deps/SPIRV-Cross/shaders/frag/for-loop-init.frag b/deps/SPIRV-Cross/shaders/frag/for-loop-init.frag deleted file mode 100644 index 0cde26765e..0000000000 --- a/deps/SPIRV-Cross/shaders/frag/for-loop-init.frag +++ /dev/null @@ -1,52 +0,0 @@ -#version 310 es -precision mediump float; -layout(location = 0) out int FragColor; - -void main() -{ - FragColor = 16; - - // Basic loop variable. - for (int i = 0; i < 25; i++) - FragColor += 10; - - // Multiple loop variables. - for (int i = 1, j = 4; i < 30; i++, j += 4) - FragColor += 11; - - // A potential loop variables, but we access it outside the loop, - // so cannot be one. - int k = 0; - for (; k < 20; k++) - FragColor += 12; - k += 3; - FragColor += k; - - // Potential loop variables, but the dominator is not trivial. - int l; - if (k == 40) - { - for (l = 0; l < 40; l++) - FragColor += 13; - return; - } - else - { - l = k; - FragColor += l; - } - - // Vectors cannot be loop variables - for (ivec2 i = ivec2(0); i.x < 10; i.x += 4) - { - FragColor += i.y; - } - - // Check that static expressions can be used before the loop header. - int m = 0; - m = k; - int o = m; - for (; m < 40; m++) - FragColor += m; - FragColor += o; -} diff --git a/deps/SPIRV-Cross/shaders/frag/frexp-modf.frag b/deps/SPIRV-Cross/shaders/frag/frexp-modf.frag deleted file mode 100644 index 6a26a4175f..0000000000 --- a/deps/SPIRV-Cross/shaders/frag/frexp-modf.frag +++ /dev/null @@ -1,24 +0,0 @@ -#version 310 es -precision mediump float; - -layout(location = 0) out float FragColor; -layout(location = 0) in float v0; -layout(location = 1) in vec2 v1; - -void main() -{ - int e0; - float f0 = frexp(v0, e0); - f0 = frexp(v0 + 1.0, e0); - - ivec2 e1; - vec2 f1 = frexp(v1, e1); - - float r0; - float m0 = modf(v0, r0); - vec2 r1; - vec2 m1 = modf(v1, r1); - - FragColor = f0 + f1.x + f1.y + m0 + m1.x + m1.y; -} - diff --git a/deps/SPIRV-Cross/shaders/frag/ground.frag b/deps/SPIRV-Cross/shaders/frag/ground.frag deleted file mode 100755 index d1fcfd4907..0000000000 --- a/deps/SPIRV-Cross/shaders/frag/ground.frag +++ /dev/null @@ -1,162 +0,0 @@ -#version 310 es -precision mediump float; - -#define DEBUG_NONE 0 -#define DEBUG_DIFFUSE 1 -#define DEBUG_SPECULAR 2 -#define DEBUG_LIGHTING 3 -#define DEBUG_FOG 4 -#define DEBUG DEBUG_NONE - -#define FORWARD 0 -#define DEFERRED 1 -#define DEFERRED_VTEX 2 - -float saturate(float x) { return clamp(x, 0.0, 1.0); } - -layout(std140, binding = 4) uniform GlobalPSData -{ - vec4 g_CamPos; - vec4 g_SunDir; - vec4 g_SunColor; - vec4 g_ResolutionParams; - vec4 g_TimeParams; - vec4 g_FogColor_Distance; -}; - -vec4 ComputeFogFactor(vec3 WorldPos) -{ - vec4 FogData; - vec3 vEye = WorldPos - g_CamPos.xyz; - vec3 nEye = normalize(vEye); - FogData.w = exp(-dot(vEye, vEye) * g_FogColor_Distance.w * 0.75); - - float fog_sun_factor = pow(saturate(dot(nEye, g_SunDir.xyz)), 8.0); - FogData.xyz = mix(vec3(1.0, 1.0, 1.0), vec3(0.6, 0.6, 0.9), nEye.y * 0.5 + 0.5); - FogData.xyz = mix(FogData.xyz, vec3(0.95, 0.87, 0.78), fog_sun_factor); - return FogData; -} - -void ApplyFog(inout vec3 Color, vec4 FogData) -{ - Color = mix(FogData.xyz, Color, FogData.w); -} - -void ApplyLighting(inout mediump vec3 Color, mediump float DiffuseFactor) -{ - mediump vec3 DiffuseLight = g_SunColor.xyz * DiffuseFactor; - mediump vec3 AmbientLight = vec3(0.2, 0.35, 0.55) * 0.5; - mediump vec3 Lighting = DiffuseLight + AmbientLight; -#if DEBUG == DEBUG_LIGHTING - Color = Lighting; -#else - Color *= Lighting; -#endif -} - -#define SPECULAR 0 -#define GLOSSMAP 0 - -void ApplySpecular(inout mediump vec3 Color, mediump vec3 EyeVec, mediump vec3 Normal, mediump vec3 SpecularColor, mediump float Shininess, mediump float FresnelAmount) -{ - mediump vec3 HalfAngle = normalize(-EyeVec + g_SunDir.xyz); - - mediump float v_dot_h = saturate(dot(HalfAngle, -EyeVec)); - mediump float n_dot_l = saturate(dot(Normal, g_SunDir.xyz)); - mediump float n_dot_h = saturate(dot(Normal, HalfAngle)); - mediump float n_dot_v = saturate(dot(-EyeVec, Normal)); - mediump float h_dot_l = saturate(dot(g_SunDir.xyz, HalfAngle)); - - const mediump float roughness_value = 0.25; - - mediump float r_sq = roughness_value * roughness_value; - mediump float n_dot_h_sq = n_dot_h * n_dot_h; - mediump float roughness_a = 1.0 / (4.0 * r_sq * n_dot_h_sq * n_dot_h_sq); - mediump float roughness_b = n_dot_h_sq - 1.0; - mediump float roughness_c = r_sq * n_dot_h_sq; - mediump float roughness = saturate(roughness_a * exp(roughness_b / roughness_c)); - - FresnelAmount = 0.5; - mediump float fresnel_term = pow(1.0 - n_dot_v, 5.0) * (1.0 - FresnelAmount) + FresnelAmount; - - mediump float geo_numerator = 2.0 * n_dot_h; - mediump float geo_denominator = 1.0 / v_dot_h; - mediump float geo_term = min(1.0, min(n_dot_v, n_dot_l) * geo_numerator * geo_denominator); - -#if SPECULAR || GLOSSMAP - Color += SpecularColor * g_SunColor.xyz * fresnel_term * roughness * n_dot_l * geo_term / (n_dot_v * n_dot_l + 0.0001); -#endif - - //Color = vec3(0.025 * 1.0 / (n_dot_v * n_dot_l)); -} -layout(location = 0) in vec2 TexCoord; -layout(location = 1) in vec3 EyeVec; - -layout(binding = 2) uniform sampler2D TexNormalmap; -//layout(binding = 3) uniform sampler2D TexScatteringLUT; - -#define DIFFUSE_ONLY 0 -#define GLOBAL_RENDERER DEFERRED -#define OUTPUT_FEEDBACK_TEXTURE 0 - -#if DIFFUSE_ONLY -layout(location = 0) out vec4 ColorOut; -layout(location = 1) out vec4 NormalOut; -#else -layout(location = 0) out vec4 AlbedoOut; -layout(location = 1) out vec4 SpecularOut; -layout(location = 2) out vec4 NormalOut; -layout(location = 3) out vec4 LightingOut; -#endif - -void Resolve(vec3 Albedo, vec3 Normal, float Roughness, float Metallic) -{ -#if (GLOBAL_RENDERER == FORWARD) || OUTPUT_FEEDBACK_TEXTURE - float Lighting = saturate(dot(Normal, normalize(vec3(1.0, 0.5, 1.0)))); - ColorOut.xyz = Albedo * Lighting; - ColorOut.w = 1.0; -#elif DIFFUSE_ONLY - ColorOut = vec4(Albedo, 0.0); - NormalOut.xyz = Normal * 0.5 + 0.5; - NormalOut.w = 1.0; - - // linearize and map to 0..255 range - ColorOut.w = -0.003921569 / (gl_FragCoord.z - 1.003921569); - ColorOut.w = log2(1.0 + saturate(length(EyeVec.xyz) / 200.0)); - ColorOut.w -= 1.0 / 255.0; -#else - LightingOut = vec4(0.0); - NormalOut = vec4(Normal * 0.5 + 0.5, 0.0); - SpecularOut = vec4(Roughness, Metallic, 0.0, 0.0); - AlbedoOut = vec4(Albedo, 1.0); -#endif -} - -void main() -{ - vec3 Normal = texture(TexNormalmap, TexCoord).xyz * 2.0 - 1.0; - Normal = normalize(Normal); - - vec2 scatter_uv; - scatter_uv.x = saturate(length(EyeVec) / 1000.0); - - vec3 nEye = normalize(EyeVec); - scatter_uv.y = 0.0; //nEye.x * 0.5 + 0.5; - - vec3 Color = vec3(0.1, 0.3, 0.1); - vec3 grass = vec3(0.1, 0.3, 0.1); - vec3 dirt = vec3(0.1, 0.1, 0.1); - vec3 snow = vec3(0.8, 0.8, 0.8); - - float grass_snow = smoothstep(0.0, 0.15, (g_CamPos.y + EyeVec.y) / 200.0); - vec3 base = mix(grass, snow, grass_snow); - - float edge = smoothstep(0.7, 0.75, Normal.y); - Color = mix(dirt, base, edge); - Color *= Color; - - float Roughness = 1.0 - edge * grass_snow; - - Resolve(Color, Normal, Roughness, 0.0); -} - diff --git a/deps/SPIRV-Cross/shaders/frag/image-load-store-uint-coord.asm.frag b/deps/SPIRV-Cross/shaders/frag/image-load-store-uint-coord.asm.frag deleted file mode 100644 index a9bf1a7497..0000000000 --- a/deps/SPIRV-Cross/shaders/frag/image-load-store-uint-coord.asm.frag +++ /dev/null @@ -1,103 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 2 -; Bound: 63 -; Schema: 0 - OpCapability Shader - OpCapability SampledBuffer - OpCapability ImageBuffer - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %main "main" %_entryPointOutput - OpExecutionMode %main OriginUpperLeft - OpSource HLSL 500 - OpName %main "main" - OpName %_main_ "@main(" - OpName %storeTemp "storeTemp" - OpName %RWIm "RWIm" - OpName %v "v" - OpName %RWBuf "RWBuf" - OpName %ROIm "ROIm" - OpName %ROBuf "ROBuf" - OpName %_entryPointOutput "@entryPointOutput" - OpDecorate %RWIm DescriptorSet 0 - OpDecorate %RWIm Binding 1 - OpDecorate %RWBuf DescriptorSet 0 - OpDecorate %RWBuf Binding 0 - OpDecorate %ROIm DescriptorSet 0 - OpDecorate %ROIm Binding 1 - OpDecorate %ROBuf DescriptorSet 0 - OpDecorate %ROBuf Binding 0 - OpDecorate %_entryPointOutput Location 0 - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 - %v4float = OpTypeVector %float 4 - %8 = OpTypeFunction %v4float -%_ptr_Function_v4float = OpTypePointer Function %v4float - %float_10 = OpConstant %float 10 - %float_0_5 = OpConstant %float 0.5 - %float_8 = OpConstant %float 8 - %float_2 = OpConstant %float 2 - %17 = OpConstantComposite %v4float %float_10 %float_0_5 %float_8 %float_2 - %18 = OpTypeImage %float 2D 0 0 0 2 Rgba32f -%_ptr_UniformConstant_18 = OpTypePointer UniformConstant %18 - %RWIm = OpVariable %_ptr_UniformConstant_18 UniformConstant - %uint = OpTypeInt 32 0 - %v2uint = OpTypeVector %uint 2 - %uint_10 = OpConstant %uint 10 - %25 = OpConstantComposite %v2uint %uint_10 %uint_10 - %uint_30 = OpConstant %uint 30 - %30 = OpConstantComposite %v2uint %uint_30 %uint_30 - %32 = OpTypeImage %float Buffer 0 0 0 2 Rgba32f -%_ptr_UniformConstant_32 = OpTypePointer UniformConstant %32 - %RWBuf = OpVariable %_ptr_UniformConstant_32 UniformConstant - %uint_80 = OpConstant %uint 80 - %38 = OpTypeImage %float 2D 0 0 0 1 Unknown - %SampledImage = OpTypeSampledImage %38 -%_ptr_UniformConstant_38 = OpTypePointer UniformConstant %SampledImage - %ROIm = OpVariable %_ptr_UniformConstant_38 UniformConstant - %uint_50 = OpConstant %uint 50 - %uint_60 = OpConstant %uint 60 - %44 = OpConstantComposite %v2uint %uint_50 %uint_60 - %int = OpTypeInt 32 1 - %int_0 = OpConstant %int 0 - %50 = OpTypeImage %float Buffer 0 0 0 1 Rgba32f -%_ptr_UniformConstant_50 = OpTypePointer UniformConstant %50 - %ROBuf = OpVariable %_ptr_UniformConstant_50 UniformConstant -%_ptr_Output_v4float = OpTypePointer Output %v4float -%_entryPointOutput = OpVariable %_ptr_Output_v4float Output - %main = OpFunction %void None %3 - %5 = OpLabel - %62 = OpFunctionCall %v4float %_main_ - OpStore %_entryPointOutput %62 - OpReturn - OpFunctionEnd - %_main_ = OpFunction %v4float None %8 - %10 = OpLabel - %storeTemp = OpVariable %_ptr_Function_v4float Function - %v = OpVariable %_ptr_Function_v4float Function - OpStore %storeTemp %17 - %21 = OpLoad %18 %RWIm - %26 = OpLoad %v4float %storeTemp - OpImageWrite %21 %25 %26 - %28 = OpLoad %18 %RWIm - %31 = OpImageRead %v4float %28 %30 - OpStore %v %31 - %35 = OpLoad %32 %RWBuf - %37 = OpLoad %v4float %v - OpImageWrite %35 %uint_80 %37 - %41 = OpLoad %SampledImage %ROIm - %ROImage = OpImage %38 %41 - %47 = OpImageFetch %v4float %ROImage %44 Lod %int_0 - %48 = OpLoad %v4float %v - %49 = OpFAdd %v4float %48 %47 - OpStore %v %49 - %53 = OpLoad %50 %ROBuf - %54 = OpImageFetch %v4float %53 %uint_80 - %55 = OpLoad %v4float %v - %56 = OpFAdd %v4float %55 %54 - OpStore %v %56 - %57 = OpLoad %v4float %v - OpReturnValue %57 - OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders/frag/mix.frag b/deps/SPIRV-Cross/shaders/frag/mix.frag deleted file mode 100644 index a5d589dd08..0000000000 --- a/deps/SPIRV-Cross/shaders/frag/mix.frag +++ /dev/null @@ -1,20 +0,0 @@ -#version 310 es -precision mediump float; - -layout(location = 0) in vec4 vIn0; -layout(location = 1) in vec4 vIn1; -layout(location = 2) in float vIn2; -layout(location = 3) in float vIn3; -layout(location = 0) out vec4 FragColor; - -void main() -{ - bvec4 l = bvec4(false, true, false, false); - FragColor = mix(vIn0, vIn1, l); - - bool f = true; - FragColor = vec4(mix(vIn2, vIn3, f)); - - FragColor = f ? vIn0 : vIn1; - FragColor = vec4(f ? vIn2 : vIn3); -} diff --git a/deps/SPIRV-Cross/shaders/frag/partial-write-preserve.frag b/deps/SPIRV-Cross/shaders/frag/partial-write-preserve.frag deleted file mode 100644 index 227df95086..0000000000 --- a/deps/SPIRV-Cross/shaders/frag/partial-write-preserve.frag +++ /dev/null @@ -1,95 +0,0 @@ -#version 310 es -precision mediump float; - -layout(std140, binding = 0) uniform UBO -{ - int some_value; -}; - -struct B -{ - float a; - float b; -}; - -void partial_inout(inout vec4 x) -{ - x.x = 10.0; -} - -void partial_inout(inout B b) -{ - b.b = 40.0; -} - -// Make a complete write, but only conditionally ... -void branchy_inout(inout vec4 v) -{ - v.y = 20.0; - if (some_value == 20) - { - v = vec4(50.0); - } -} - -void branchy_inout(inout B b) -{ - b.b = 20.0; - if (some_value == 20) - { - b = B(10.0, 40.0); - } -} - -void branchy_inout_2(out vec4 v) -{ - if (some_value == 20) - { - v = vec4(50.0); - } - else - { - v = vec4(70.0); - } - v.y = 20.0; -} - -void branchy_inout_2(out B b) -{ - if (some_value == 20) - { - b = B(10.0, 40.0); - } - else - { - b = B(70.0, 70.0); - } - b.b = 20.0; -} - - -void complete_inout(out vec4 x) -{ - x = vec4(50.0); -} - -void complete_inout(out B b) -{ - b = B(100.0, 200.0); -} - -void main() -{ - vec4 a = vec4(10.0); - partial_inout(a); - complete_inout(a); - branchy_inout(a); - branchy_inout_2(a); - - B b = B(10.0, 20.0); - partial_inout(b); - complete_inout(b); - branchy_inout(b); - branchy_inout_2(b); -} - diff --git a/deps/SPIRV-Cross/shaders/frag/pls.frag b/deps/SPIRV-Cross/shaders/frag/pls.frag deleted file mode 100644 index e3863e4e0e..0000000000 --- a/deps/SPIRV-Cross/shaders/frag/pls.frag +++ /dev/null @@ -1,20 +0,0 @@ -#version 310 es -precision mediump float; - -layout(location = 0) in vec4 PLSIn0; -layout(location = 1) in vec4 PLSIn1; -layout(location = 2) in vec4 PLSIn2; -layout(location = 3) in vec4 PLSIn3; - -layout(location = 0) out vec4 PLSOut0; -layout(location = 1) out vec4 PLSOut1; -layout(location = 2) out vec4 PLSOut2; -layout(location = 3) out vec4 PLSOut3; - -void main() -{ - PLSOut0 = 2.0 * PLSIn0; - PLSOut1 = 6.0 * PLSIn1; - PLSOut2 = 7.0 * PLSIn2; - PLSOut3 = 4.0 * PLSIn3; -} diff --git a/deps/SPIRV-Cross/shaders/frag/sample-parameter.frag b/deps/SPIRV-Cross/shaders/frag/sample-parameter.frag deleted file mode 100644 index 8470bfd672..0000000000 --- a/deps/SPIRV-Cross/shaders/frag/sample-parameter.frag +++ /dev/null @@ -1,11 +0,0 @@ -#version 310 es -#extension GL_OES_sample_variables : require -precision mediump float; - -layout(location = 0) out vec2 FragColor; - -void main() -{ - FragColor = gl_SamplePosition + vec2(gl_SampleMaskIn[0]) + float(gl_SampleID); - gl_SampleMask[0] = 1; -} diff --git a/deps/SPIRV-Cross/shaders/frag/sampler-ms.frag b/deps/SPIRV-Cross/shaders/frag/sampler-ms.frag deleted file mode 100644 index 6593928271..0000000000 --- a/deps/SPIRV-Cross/shaders/frag/sampler-ms.frag +++ /dev/null @@ -1,16 +0,0 @@ -#version 310 es -precision mediump float; -precision highp int; - -layout(binding = 0) uniform mediump sampler2DMS uSampler; -layout(location = 0) out vec4 FragColor; - -void main() -{ - ivec2 coord = ivec2(gl_FragCoord.xy); - FragColor = - texelFetch(uSampler, coord, 0) + - texelFetch(uSampler, coord, 1) + - texelFetch(uSampler, coord, 2) + - texelFetch(uSampler, coord, 3); -} diff --git a/deps/SPIRV-Cross/shaders/frag/sampler-proj.frag b/deps/SPIRV-Cross/shaders/frag/sampler-proj.frag deleted file mode 100644 index 21fa5c0260..0000000000 --- a/deps/SPIRV-Cross/shaders/frag/sampler-proj.frag +++ /dev/null @@ -1,12 +0,0 @@ -#version 310 es -precision mediump float; - -layout(location = 0) in vec4 vTex; -layout(binding = 0) uniform sampler2D uTex; -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = textureProj(uTex, vTex); -} - diff --git a/deps/SPIRV-Cross/shaders/frag/sampler.frag b/deps/SPIRV-Cross/shaders/frag/sampler.frag deleted file mode 100644 index e38f76886a..0000000000 --- a/deps/SPIRV-Cross/shaders/frag/sampler.frag +++ /dev/null @@ -1,18 +0,0 @@ -#version 310 es -precision mediump float; - -layout(location = 0) in vec4 vColor; -layout(location = 1) in vec2 vTex; -layout(binding = 0) uniform sampler2D uTex; -layout(location = 0) out vec4 FragColor; - -vec4 sample_texture(sampler2D tex, vec2 uv) -{ - return texture(tex, uv); -} - -void main() -{ - FragColor = vColor * sample_texture(uTex, vTex); -} - diff --git a/deps/SPIRV-Cross/shaders/frag/swizzle.frag b/deps/SPIRV-Cross/shaders/frag/swizzle.frag deleted file mode 100644 index 271ba6cb64..0000000000 --- a/deps/SPIRV-Cross/shaders/frag/swizzle.frag +++ /dev/null @@ -1,17 +0,0 @@ -#version 310 es -precision mediump float; - -layout(location = 0) uniform sampler2D samp; -layout(location = 0) out vec4 FragColor; -layout(location = 1) in vec3 vNormal; -layout(location = 2) in vec2 vUV; - -void main() -{ - FragColor = vec4(texture(samp, vUV).xyz, 1.0); - FragColor = vec4(texture(samp, vUV).xz, 1.0, 4.0); - FragColor = vec4(texture(samp, vUV).xx, texture(samp, vUV + vec2(0.1)).yy); - FragColor = vec4(vNormal, 1.0); - FragColor = vec4(vNormal + 1.8, 1.0); - FragColor = vec4(vUV, vUV + 1.8); -} diff --git a/deps/SPIRV-Cross/shaders/frag/ubo_layout.frag b/deps/SPIRV-Cross/shaders/frag/ubo_layout.frag deleted file mode 100644 index 80f9f16d3d..0000000000 --- a/deps/SPIRV-Cross/shaders/frag/ubo_layout.frag +++ /dev/null @@ -1,24 +0,0 @@ -#version 310 es -precision mediump float; - -layout(location = 0) out vec4 FragColor; - -struct Str -{ - mat4 foo; -}; - -layout(binding = 0, std140) uniform UBO1 -{ - layout(row_major) Str foo; -} ubo1; - -layout(binding = 1, std140) uniform UBO2 -{ - layout(column_major) Str foo; -} ubo0; - -void main() -{ - FragColor = ubo1.foo.foo[0] + ubo0.foo.foo[0]; -} diff --git a/deps/SPIRV-Cross/shaders/frag/unary-enclose.frag b/deps/SPIRV-Cross/shaders/frag/unary-enclose.frag deleted file mode 100644 index ea502e1de8..0000000000 --- a/deps/SPIRV-Cross/shaders/frag/unary-enclose.frag +++ /dev/null @@ -1,15 +0,0 @@ -#version 310 es -precision mediump float; - -layout(location = 0) out vec4 FragColor; -layout(location = 0) in vec4 vIn; -layout(location = 1) flat in ivec4 vIn1; - -void main() -{ - FragColor = +(-(-vIn)); - ivec4 a = ~(~vIn1); - - bool b = false; - b = !!b; -} diff --git a/deps/SPIRV-Cross/shaders/geom/basic.geom b/deps/SPIRV-Cross/shaders/geom/basic.geom deleted file mode 100644 index 80b977d114..0000000000 --- a/deps/SPIRV-Cross/shaders/geom/basic.geom +++ /dev/null @@ -1,28 +0,0 @@ -#version 310 es -#extension GL_EXT_geometry_shader : require - -layout(triangles, invocations = 4) in; -layout(triangle_strip, max_vertices = 3) out; - -layout(location = 0) in VertexData { - vec3 normal; -} vin[]; - -layout(location = 0) out vec3 vNormal; - -void main() -{ - gl_Position = gl_in[0].gl_Position; - vNormal = vin[0].normal + float(gl_InvocationID); - EmitVertex(); - - gl_Position = gl_in[1].gl_Position; - vNormal = vin[1].normal + 4.0 * float(gl_InvocationID); - EmitVertex(); - - gl_Position = gl_in[2].gl_Position; - vNormal = vin[2].normal + 2.0 * float(gl_InvocationID); - EmitVertex(); - - EndPrimitive(); -} diff --git a/deps/SPIRV-Cross/shaders/geom/lines-adjacency.geom b/deps/SPIRV-Cross/shaders/geom/lines-adjacency.geom deleted file mode 100644 index 4c34440737..0000000000 --- a/deps/SPIRV-Cross/shaders/geom/lines-adjacency.geom +++ /dev/null @@ -1,28 +0,0 @@ -#version 310 es -#extension GL_EXT_geometry_shader : require - -layout(lines_adjacency) in; -layout(line_strip, max_vertices = 3) out; - -layout(location = 0) in VertexData { - vec3 normal; -} vin[]; - -layout(location = 0) out vec3 vNormal; - -void main() -{ - gl_Position = gl_in[0].gl_Position; - vNormal = vin[0].normal; - EmitVertex(); - - gl_Position = gl_in[1].gl_Position; - vNormal = vin[1].normal; - EmitVertex(); - - gl_Position = gl_in[2].gl_Position; - vNormal = vin[2].normal; - EmitVertex(); - - EndPrimitive(); -} diff --git a/deps/SPIRV-Cross/shaders/geom/lines.geom b/deps/SPIRV-Cross/shaders/geom/lines.geom deleted file mode 100644 index c751d5cda4..0000000000 --- a/deps/SPIRV-Cross/shaders/geom/lines.geom +++ /dev/null @@ -1,24 +0,0 @@ -#version 310 es -#extension GL_EXT_geometry_shader : require - -layout(lines) in; -layout(line_strip, max_vertices = 2) out; - -layout(location = 0) in VertexData { - vec3 normal; -} vin[]; - -layout(location = 0) out vec3 vNormal; - -void main() -{ - gl_Position = gl_in[0].gl_Position; - vNormal = vin[0].normal; - EmitVertex(); - - gl_Position = gl_in[1].gl_Position; - vNormal = vin[1].normal; - EmitVertex(); - - EndPrimitive(); -} diff --git a/deps/SPIRV-Cross/shaders/geom/points.geom b/deps/SPIRV-Cross/shaders/geom/points.geom deleted file mode 100644 index f7dce10d7f..0000000000 --- a/deps/SPIRV-Cross/shaders/geom/points.geom +++ /dev/null @@ -1,28 +0,0 @@ -#version 310 es -#extension GL_EXT_geometry_shader : require - -layout(points) in; -layout(points, max_vertices = 3) out; - -layout(location = 0) in VertexData { - vec3 normal; -} vin[]; - -layout(location = 0) out vec3 vNormal; - -void main() -{ - gl_Position = gl_in[0].gl_Position; - vNormal = vin[0].normal; - EmitVertex(); - - gl_Position = gl_in[0].gl_Position; - vNormal = vin[0].normal; - EmitVertex(); - - gl_Position = gl_in[0].gl_Position; - vNormal = vin[0].normal; - EmitVertex(); - - EndPrimitive(); -} diff --git a/deps/SPIRV-Cross/shaders/geom/single-invocation.geom b/deps/SPIRV-Cross/shaders/geom/single-invocation.geom deleted file mode 100644 index c3c8d1526f..0000000000 --- a/deps/SPIRV-Cross/shaders/geom/single-invocation.geom +++ /dev/null @@ -1,28 +0,0 @@ -#version 310 es -#extension GL_EXT_geometry_shader : require - -layout(triangles) in; -layout(triangle_strip, max_vertices = 3) out; - -layout(location = 0) in VertexData { - vec3 normal; -} vin[]; - -layout(location = 0) out vec3 vNormal; - -void main() -{ - gl_Position = gl_in[0].gl_Position; - vNormal = vin[0].normal; - EmitVertex(); - - gl_Position = gl_in[1].gl_Position; - vNormal = vin[1].normal; - EmitVertex(); - - gl_Position = gl_in[2].gl_Position; - vNormal = vin[2].normal; - EmitVertex(); - - EndPrimitive(); -} diff --git a/deps/SPIRV-Cross/shaders/geom/triangles-adjacency.geom b/deps/SPIRV-Cross/shaders/geom/triangles-adjacency.geom deleted file mode 100644 index 017cef7b52..0000000000 --- a/deps/SPIRV-Cross/shaders/geom/triangles-adjacency.geom +++ /dev/null @@ -1,28 +0,0 @@ -#version 310 es -#extension GL_EXT_geometry_shader : require - -layout(triangles_adjacency) in; -layout(triangle_strip, max_vertices = 3) out; - -layout(location = 0) in VertexData { - vec3 normal; -} vin[]; - -layout(location = 0) out vec3 vNormal; - -void main() -{ - gl_Position = gl_in[0].gl_Position; - vNormal = vin[0].normal; - EmitVertex(); - - gl_Position = gl_in[1].gl_Position; - vNormal = vin[1].normal; - EmitVertex(); - - gl_Position = gl_in[2].gl_Position; - vNormal = vin[2].normal; - EmitVertex(); - - EndPrimitive(); -} diff --git a/deps/SPIRV-Cross/shaders/geom/triangles.geom b/deps/SPIRV-Cross/shaders/geom/triangles.geom deleted file mode 100644 index c3c8d1526f..0000000000 --- a/deps/SPIRV-Cross/shaders/geom/triangles.geom +++ /dev/null @@ -1,28 +0,0 @@ -#version 310 es -#extension GL_EXT_geometry_shader : require - -layout(triangles) in; -layout(triangle_strip, max_vertices = 3) out; - -layout(location = 0) in VertexData { - vec3 normal; -} vin[]; - -layout(location = 0) out vec3 vNormal; - -void main() -{ - gl_Position = gl_in[0].gl_Position; - vNormal = vin[0].normal; - EmitVertex(); - - gl_Position = gl_in[1].gl_Position; - vNormal = vin[1].normal; - EmitVertex(); - - gl_Position = gl_in[2].gl_Position; - vNormal = vin[2].normal; - EmitVertex(); - - EndPrimitive(); -} diff --git a/deps/SPIRV-Cross/shaders/legacy/fragment/explicit-lod.legacy.frag b/deps/SPIRV-Cross/shaders/legacy/fragment/explicit-lod.legacy.frag deleted file mode 100644 index 5a2eeb9913..0000000000 --- a/deps/SPIRV-Cross/shaders/legacy/fragment/explicit-lod.legacy.frag +++ /dev/null @@ -1,12 +0,0 @@ -#version 310 es - -precision mediump float; - -uniform sampler2D tex; - -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = textureLod(tex, vec2(0.4, 0.6), 0.0); -} diff --git a/deps/SPIRV-Cross/shaders/legacy/fragment/io-blocks.legacy.frag b/deps/SPIRV-Cross/shaders/legacy/fragment/io-blocks.legacy.frag deleted file mode 100644 index 0a151dc2d6..0000000000 --- a/deps/SPIRV-Cross/shaders/legacy/fragment/io-blocks.legacy.frag +++ /dev/null @@ -1,16 +0,0 @@ -#version 310 es -#extension GL_EXT_shader_io_blocks : require -precision mediump float; - -layout(location = 1) in VertexOut -{ - vec4 color; - highp vec3 normal; -} vin; - -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = vin.color + vin.normal.xyzz; -} diff --git a/deps/SPIRV-Cross/shaders/legacy/fragment/struct-varying.legacy.frag b/deps/SPIRV-Cross/shaders/legacy/fragment/struct-varying.legacy.frag deleted file mode 100644 index 5df5c87704..0000000000 --- a/deps/SPIRV-Cross/shaders/legacy/fragment/struct-varying.legacy.frag +++ /dev/null @@ -1,25 +0,0 @@ -#version 310 es -precision highp float; - -struct Inputs -{ - vec4 a; - vec2 b; -}; - -layout(location = 0) in Inputs vin; -layout(location = 0) out vec4 FragColor; - -void main() -{ - // Read struct once. - Inputs v0 = vin; - // Read struct again. - Inputs v1 = vin; - - // Read members individually. - vec4 a = vin.a; - vec4 b = vin.b.xxyy; - - FragColor = v0.a + v0.b.xxyy + v1.a + v1.b.yyxx + a + b; -} diff --git a/deps/SPIRV-Cross/shaders/legacy/vert/implicit-lod.legacy.vert b/deps/SPIRV-Cross/shaders/legacy/vert/implicit-lod.legacy.vert deleted file mode 100644 index 1f32faebdc..0000000000 --- a/deps/SPIRV-Cross/shaders/legacy/vert/implicit-lod.legacy.vert +++ /dev/null @@ -1,8 +0,0 @@ -#version 310 es - -uniform sampler2D tex; - -void main() -{ - gl_Position = texture(tex, vec2(0.4, 0.6)); -} diff --git a/deps/SPIRV-Cross/shaders/legacy/vert/io-block.legacy.vert b/deps/SPIRV-Cross/shaders/legacy/vert/io-block.legacy.vert deleted file mode 100644 index 4fbc9347cf..0000000000 --- a/deps/SPIRV-Cross/shaders/legacy/vert/io-block.legacy.vert +++ /dev/null @@ -1,17 +0,0 @@ -#version 310 es -#extension GL_EXT_shader_io_blocks : require - -layout(location = 0) out VertexOut -{ - vec4 color; - vec3 normal; -} vout; - -layout(location = 0) in vec4 Position; - -void main() -{ - gl_Position = Position; - vout.color = vec4(1.0); - vout.normal = vec3(0.5); -} diff --git a/deps/SPIRV-Cross/shaders/legacy/vert/struct-varying.legacy.vert b/deps/SPIRV-Cross/shaders/legacy/vert/struct-varying.legacy.vert deleted file mode 100644 index 3f491be831..0000000000 --- a/deps/SPIRV-Cross/shaders/legacy/vert/struct-varying.legacy.vert +++ /dev/null @@ -1,33 +0,0 @@ -#version 310 es - -struct Output -{ - vec4 a; - vec2 b; -}; - -layout(location = 0) out Output vout; - -void main() -{ - Output s = Output(vec4(0.5), vec2(0.25)); - - // Write whole struct. - vout = s; - // Write whole struct again, checks for scoping. - vout = s; - - // Read it back. - Output tmp = vout; - - // Write elements individually. - vout.a = tmp.a; - vout.b = tmp.b; - - // Write individual elements. - vout.a.x = 1.0; - vout.b.y = 1.0; - - // Read individual elements. - float c = vout.a.x; -} diff --git a/deps/SPIRV-Cross/shaders/legacy/vert/transpose.legacy.vert b/deps/SPIRV-Cross/shaders/legacy/vert/transpose.legacy.vert deleted file mode 100644 index 84f618262a..0000000000 --- a/deps/SPIRV-Cross/shaders/legacy/vert/transpose.legacy.vert +++ /dev/null @@ -1,20 +0,0 @@ -#version 310 es - -uniform Buffer -{ - layout(row_major) mat4 MVPRowMajor; - layout(column_major) mat4 MVPColMajor; - mat4 M; -}; - -layout(location = 0) in vec4 Position; - -void main() -{ - vec4 c0 = M * (MVPRowMajor * Position); - vec4 c1 = M * (MVPColMajor * Position); - vec4 c2 = M * (Position * MVPRowMajor); - vec4 c3 = M * (Position * MVPColMajor); - gl_Position = c0 + c1 + c2 + c3; -} - diff --git a/deps/SPIRV-Cross/shaders/tesc/basic.tesc b/deps/SPIRV-Cross/shaders/tesc/basic.tesc deleted file mode 100644 index 0a41f98c83..0000000000 --- a/deps/SPIRV-Cross/shaders/tesc/basic.tesc +++ /dev/null @@ -1,17 +0,0 @@ -#version 310 es -#extension GL_EXT_tessellation_shader : require - -layout(location = 0) patch out vec3 vFoo; - -layout(vertices = 1) out; - -void main() -{ - gl_TessLevelInner[0] = 8.9; - gl_TessLevelInner[1] = 6.9; - gl_TessLevelOuter[0] = 8.9; - gl_TessLevelOuter[1] = 6.9; - gl_TessLevelOuter[2] = 3.9; - gl_TessLevelOuter[3] = 4.9; - vFoo = vec3(1.0); -} diff --git a/deps/SPIRV-Cross/shaders/tesc/water_tess.tesc b/deps/SPIRV-Cross/shaders/tesc/water_tess.tesc deleted file mode 100644 index 3ecdc3d1a9..0000000000 --- a/deps/SPIRV-Cross/shaders/tesc/water_tess.tesc +++ /dev/null @@ -1,115 +0,0 @@ -#version 310 es -#extension GL_EXT_tessellation_shader : require - -layout(vertices = 1) out; -layout(location = 0) in vec2 vPatchPosBase[]; - -layout(std140) uniform UBO -{ - vec4 uScale; - highp vec3 uCamPos; - vec2 uPatchSize; - vec2 uMaxTessLevel; - float uDistanceMod; - vec4 uFrustum[6]; -}; - -layout(location = 1) patch out vec2 vOutPatchPosBase; -layout(location = 2) patch out vec4 vPatchLods; - -float lod_factor(vec2 pos_) -{ - vec2 pos = pos_ * uScale.xy; - vec3 dist_to_cam = uCamPos - vec3(pos.x, 0.0, pos.y); - float level = log2((length(dist_to_cam) + 0.0001) * uDistanceMod); - return clamp(level, 0.0, uMaxTessLevel.x); -} - -float tess_level(float lod) -{ - return uMaxTessLevel.y * exp2(-lod); -} - -vec4 tess_level(vec4 lod) -{ - return uMaxTessLevel.y * exp2(-lod); -} - -// Guard band for vertex displacement. -#define GUARD_BAND 10.0 -bool frustum_cull(vec2 p0) -{ - vec2 min_xz = (p0 - GUARD_BAND) * uScale.xy; - vec2 max_xz = (p0 + uPatchSize + GUARD_BAND) * uScale.xy; - - vec3 bb_min = vec3(min_xz.x, -GUARD_BAND, min_xz.y); - vec3 bb_max = vec3(max_xz.x, +GUARD_BAND, max_xz.y); - vec3 center = 0.5 * (bb_min + bb_max); - float radius = 0.5 * length(bb_max - bb_min); - - vec3 f0 = vec3( - dot(uFrustum[0], vec4(center, 1.0)), - dot(uFrustum[1], vec4(center, 1.0)), - dot(uFrustum[2], vec4(center, 1.0))); - - vec3 f1 = vec3( - dot(uFrustum[3], vec4(center, 1.0)), - dot(uFrustum[4], vec4(center, 1.0)), - dot(uFrustum[5], vec4(center, 1.0))); - - return !(any(lessThanEqual(f0, vec3(-radius))) || any(lessThanEqual(f1, vec3(-radius)))); -} - -void compute_tess_levels(vec2 p0) -{ - vOutPatchPosBase = p0; - - float l00 = lod_factor(p0 + vec2(-0.5, -0.5) * uPatchSize); - float l10 = lod_factor(p0 + vec2(+0.5, -0.5) * uPatchSize); - float l20 = lod_factor(p0 + vec2(+1.5, -0.5) * uPatchSize); - float l01 = lod_factor(p0 + vec2(-0.5, +0.5) * uPatchSize); - float l11 = lod_factor(p0 + vec2(+0.5, +0.5) * uPatchSize); - float l21 = lod_factor(p0 + vec2(+1.5, +0.5) * uPatchSize); - float l02 = lod_factor(p0 + vec2(-0.5, +1.5) * uPatchSize); - float l12 = lod_factor(p0 + vec2(+0.5, +1.5) * uPatchSize); - float l22 = lod_factor(p0 + vec2(+1.5, +1.5) * uPatchSize); - - vec4 lods = vec4( - dot(vec4(l01, l11, l02, l12), vec4(0.25)), - dot(vec4(l00, l10, l01, l11), vec4(0.25)), - dot(vec4(l10, l20, l11, l21), vec4(0.25)), - dot(vec4(l11, l21, l12, l22), vec4(0.25))); - - vPatchLods = lods; - - vec4 outer_lods = min(lods.xyzw, lods.yzwx); - vec4 levels = tess_level(outer_lods); - gl_TessLevelOuter[0] = levels.x; - gl_TessLevelOuter[1] = levels.y; - gl_TessLevelOuter[2] = levels.z; - gl_TessLevelOuter[3] = levels.w; - - float min_lod = min(min(lods.x, lods.y), min(lods.z, lods.w)); - float inner = tess_level(min(min_lod, l11)); - gl_TessLevelInner[0] = inner; - gl_TessLevelInner[1] = inner; -} - -void main() -{ - vec2 p0 = vPatchPosBase[0]; - if (!frustum_cull(p0)) - { - gl_TessLevelOuter[0] = -1.0; - gl_TessLevelOuter[1] = -1.0; - gl_TessLevelOuter[2] = -1.0; - gl_TessLevelOuter[3] = -1.0; - gl_TessLevelInner[0] = -1.0; - gl_TessLevelInner[1] = -1.0; - } - else - { - compute_tess_levels(p0); - } -} - diff --git a/deps/SPIRV-Cross/shaders/tese/ccw.tese b/deps/SPIRV-Cross/shaders/tese/ccw.tese deleted file mode 100644 index 26e9cc698d..0000000000 --- a/deps/SPIRV-Cross/shaders/tese/ccw.tese +++ /dev/null @@ -1,10 +0,0 @@ -#version 310 es -#extension GL_EXT_tessellation_shader : require - -layout(ccw, triangles, fractional_even_spacing) in; - -void main() -{ - gl_Position = vec4(1.0); -} - diff --git a/deps/SPIRV-Cross/shaders/tese/cw.tese b/deps/SPIRV-Cross/shaders/tese/cw.tese deleted file mode 100644 index 6ce7c2d6d9..0000000000 --- a/deps/SPIRV-Cross/shaders/tese/cw.tese +++ /dev/null @@ -1,10 +0,0 @@ -#version 310 es -#extension GL_EXT_tessellation_shader : require - -layout(cw, triangles, fractional_even_spacing) in; - -void main() -{ - gl_Position = vec4(1.0); -} - diff --git a/deps/SPIRV-Cross/shaders/tese/equal.tese b/deps/SPIRV-Cross/shaders/tese/equal.tese deleted file mode 100644 index 08ab36ec23..0000000000 --- a/deps/SPIRV-Cross/shaders/tese/equal.tese +++ /dev/null @@ -1,10 +0,0 @@ -#version 310 es -#extension GL_EXT_tessellation_shader : require - -layout(cw, triangles, equal_spacing) in; - -void main() -{ - gl_Position = vec4(1.0); -} - diff --git a/deps/SPIRV-Cross/shaders/tese/fractional_even.tese b/deps/SPIRV-Cross/shaders/tese/fractional_even.tese deleted file mode 100644 index 6ce7c2d6d9..0000000000 --- a/deps/SPIRV-Cross/shaders/tese/fractional_even.tese +++ /dev/null @@ -1,10 +0,0 @@ -#version 310 es -#extension GL_EXT_tessellation_shader : require - -layout(cw, triangles, fractional_even_spacing) in; - -void main() -{ - gl_Position = vec4(1.0); -} - diff --git a/deps/SPIRV-Cross/shaders/tese/fractional_odd.tese b/deps/SPIRV-Cross/shaders/tese/fractional_odd.tese deleted file mode 100644 index a15a32926b..0000000000 --- a/deps/SPIRV-Cross/shaders/tese/fractional_odd.tese +++ /dev/null @@ -1,10 +0,0 @@ -#version 310 es -#extension GL_EXT_tessellation_shader : require - -layout(cw, triangles, fractional_odd_spacing) in; - -void main() -{ - gl_Position = vec4(1.0); -} - diff --git a/deps/SPIRV-Cross/shaders/tese/line.tese b/deps/SPIRV-Cross/shaders/tese/line.tese deleted file mode 100644 index b4237ef559..0000000000 --- a/deps/SPIRV-Cross/shaders/tese/line.tese +++ /dev/null @@ -1,10 +0,0 @@ -#version 310 es -#extension GL_EXT_tessellation_shader : require - -layout(isolines, point_mode, fractional_even_spacing) in; - -void main() -{ - gl_Position = vec4(1.0); -} - diff --git a/deps/SPIRV-Cross/shaders/tese/triangle.tese b/deps/SPIRV-Cross/shaders/tese/triangle.tese deleted file mode 100644 index 6ce7c2d6d9..0000000000 --- a/deps/SPIRV-Cross/shaders/tese/triangle.tese +++ /dev/null @@ -1,10 +0,0 @@ -#version 310 es -#extension GL_EXT_tessellation_shader : require - -layout(cw, triangles, fractional_even_spacing) in; - -void main() -{ - gl_Position = vec4(1.0); -} - diff --git a/deps/SPIRV-Cross/shaders/tese/water_tess.tese b/deps/SPIRV-Cross/shaders/tese/water_tess.tese deleted file mode 100644 index 32d6bc9391..0000000000 --- a/deps/SPIRV-Cross/shaders/tese/water_tess.tese +++ /dev/null @@ -1,65 +0,0 @@ -#version 310 es -#extension GL_EXT_tessellation_shader : require -precision highp int; - -layout(cw, quads, fractional_even_spacing) in; - -layout(location = 0) patch in vec2 vOutPatchPosBase; -layout(location = 1) patch in vec4 vPatchLods; - -layout(binding = 1, std140) uniform UBO -{ - mat4 uMVP; - vec4 uScale; - vec2 uInvScale; - vec3 uCamPos; - vec2 uPatchSize; - vec2 uInvHeightmapSize; -}; -layout(binding = 0) uniform mediump sampler2D uHeightmapDisplacement; - -layout(location = 0) highp out vec3 vWorld; -layout(location = 1) highp out vec4 vGradNormalTex; - -vec2 lerp_vertex(vec2 tess_coord) -{ - return vOutPatchPosBase + tess_coord * uPatchSize; -} - -mediump vec2 lod_factor(vec2 tess_coord) -{ - mediump vec2 x = mix(vPatchLods.yx, vPatchLods.zw, tess_coord.x); - mediump float level = mix(x.x, x.y, tess_coord.y); - mediump float floor_level = floor(level); - mediump float fract_level = level - floor_level; - return vec2(floor_level, fract_level); -} - -mediump vec3 sample_height_displacement(vec2 uv, vec2 off, mediump vec2 lod) -{ - return mix( - textureLod(uHeightmapDisplacement, uv + 0.5 * off, lod.x).xyz, - textureLod(uHeightmapDisplacement, uv + 1.0 * off, lod.x + 1.0).xyz, - lod.y); -} - -void main() -{ - vec2 tess_coord = gl_TessCoord.xy; - vec2 pos = lerp_vertex(tess_coord); - mediump vec2 lod = lod_factor(tess_coord); - - vec2 tex = pos * uInvHeightmapSize.xy; - pos *= uScale.xy; - - mediump float delta_mod = exp2(lod.x); - vec2 off = uInvHeightmapSize.xy * delta_mod; - - vGradNormalTex = vec4(tex + 0.5 * uInvHeightmapSize.xy, tex * uScale.zw); - vec3 height_displacement = sample_height_displacement(tex, off, lod); - - pos += height_displacement.yz; - vWorld = vec3(pos.x, height_displacement.x, pos.y); - gl_Position = uMVP * vec4(vWorld, 1.0); -} - diff --git a/deps/SPIRV-Cross/shaders/vert/basic.vert b/deps/SPIRV-Cross/shaders/vert/basic.vert deleted file mode 100644 index 2c75d44a43..0000000000 --- a/deps/SPIRV-Cross/shaders/vert/basic.vert +++ /dev/null @@ -1,16 +0,0 @@ -#version 310 es - -layout(std140) uniform UBO -{ - uniform mat4 uMVP; -}; - -layout(location = 0) in vec4 aVertex; -layout(location = 1) in vec3 aNormal; -layout(location = 0) out vec3 vNormal; - -void main() -{ - gl_Position = uMVP * aVertex; - vNormal = aNormal; -} diff --git a/deps/SPIRV-Cross/shaders/vert/ground.vert b/deps/SPIRV-Cross/shaders/vert/ground.vert deleted file mode 100755 index 2deeb5a94b..0000000000 --- a/deps/SPIRV-Cross/shaders/vert/ground.vert +++ /dev/null @@ -1,202 +0,0 @@ -#version 310 es - -#define YFLIP 0 -#define SPECULAR 0 -#define GLOSSMAP 0 - -#define DEBUG_NONE 0 -#define DEBUG_DIFFUSE 1 -#define DEBUG_SPECULAR 2 -#define DEBUG_LIGHTING 3 -#define DEBUG_FOG 4 -#define DEBUG DEBUG_NONE - -#define FORWARD 0 -#define DEFERRED 1 -#define DEFERRED_VTEX 2 - -float saturate(float x) { return clamp(x, 0.0, 1.0); } - -layout(std140, binding = 0) uniform GlobalVSData -{ - vec4 g_ViewProj_Row0; - vec4 g_ViewProj_Row1; - vec4 g_ViewProj_Row2; - vec4 g_ViewProj_Row3; - vec4 g_CamPos; - vec4 g_CamRight; - vec4 g_CamUp; - vec4 g_CamFront; - vec4 g_SunDir; - vec4 g_SunColor; - vec4 g_TimeParams; - vec4 g_ResolutionParams; - vec4 g_CamAxisRight; - vec4 g_FogColor_Distance; - vec4 g_ShadowVP_Row0; - vec4 g_ShadowVP_Row1; - vec4 g_ShadowVP_Row2; - vec4 g_ShadowVP_Row3; -}; - -vec4 ComputeFogFactor(vec3 WorldPos) -{ - vec4 FogData; - vec3 vEye = WorldPos - g_CamPos.xyz; - vec3 nEye = normalize(vEye); - FogData.w = exp(-dot(vEye, vEye) * g_FogColor_Distance.w * 0.75); - - float fog_sun_factor = pow(saturate(dot(nEye, g_SunDir.xyz)), 8.0); - FogData.xyz = mix(vec3(1.0, 1.0, 1.0), vec3(0.6, 0.6, 0.9), nEye.y * 0.5 + 0.5); - FogData.xyz = mix(FogData.xyz, vec3(0.95, 0.87, 0.78), fog_sun_factor); - return FogData; -} - -void ApplyFog(inout vec3 Color, vec4 FogData) -{ - Color = mix(FogData.xyz, Color, FogData.w); -} - -void ApplyLighting(inout mediump vec3 Color, mediump float DiffuseFactor) -{ - mediump vec3 DiffuseLight = g_SunColor.xyz * DiffuseFactor; - mediump vec3 AmbientLight = vec3(0.2, 0.35, 0.55) * 0.5; - mediump vec3 Lighting = DiffuseLight + AmbientLight; -#if DEBUG == DEBUG_LIGHTING - Color = Lighting; -#else - Color *= Lighting; -#endif -} - -#pragma VARIANT SPECULAR -#pragma VARIANT GLOSSMAP - -void ApplySpecular(inout mediump vec3 Color, mediump vec3 EyeVec, mediump vec3 Normal, mediump vec3 SpecularColor, mediump float Shininess, mediump float FresnelAmount) -{ - mediump vec3 HalfAngle = normalize(-EyeVec + g_SunDir.xyz); - - mediump float v_dot_h = saturate(dot(HalfAngle, -EyeVec)); - mediump float n_dot_l = saturate(dot(Normal, g_SunDir.xyz)); - mediump float n_dot_h = saturate(dot(Normal, HalfAngle)); - mediump float n_dot_v = saturate(dot(-EyeVec, Normal)); - mediump float h_dot_l = saturate(dot(g_SunDir.xyz, HalfAngle)); - - const mediump float roughness_value = 0.25; - - mediump float r_sq = roughness_value * roughness_value; - mediump float n_dot_h_sq = n_dot_h * n_dot_h; - mediump float roughness_a = 1.0 / (4.0 * r_sq * n_dot_h_sq * n_dot_h_sq); - mediump float roughness_b = n_dot_h_sq - 1.0; - mediump float roughness_c = r_sq * n_dot_h_sq; - mediump float roughness = saturate(roughness_a * exp(roughness_b / roughness_c)); - - FresnelAmount = 0.5; - mediump float fresnel_term = pow(1.0 - n_dot_v, 5.0) * (1.0 - FresnelAmount) + FresnelAmount; - - mediump float geo_numerator = 2.0 * n_dot_h; - mediump float geo_denominator = 1.0 / v_dot_h; - mediump float geo_term = min(1.0, min(n_dot_v, n_dot_l) * geo_numerator * geo_denominator); - -#if SPECULAR || GLOSSMAP - Color += SpecularColor * g_SunColor.xyz * fresnel_term * roughness * n_dot_l * geo_term / (n_dot_v * n_dot_l + 0.0001); -#endif - - //Color = vec3(0.025 * 1.0 / (n_dot_v * n_dot_l)); -} - -layout(location = 0) in vec2 Position; -layout(location = 1) in vec4 LODWeights; - -layout(location = 0) out vec2 TexCoord; -layout(location = 1) out vec3 EyeVec; - -layout(std140, binding = 2) uniform GlobalGround -{ - vec4 GroundScale; - vec4 GroundPosition; - vec4 InvGroundSize_PatchScale; -}; - -struct PatchData -{ - vec4 Position; - vec4 LODs; -}; - -layout(std140, binding = 0) uniform PerPatch -{ - PatchData Patches[256]; -}; - -layout(binding = 0) uniform sampler2D TexHeightmap; -layout(binding = 1) uniform sampler2D TexLOD; - -vec2 lod_factor(vec2 uv) -{ - float level = textureLod(TexLOD, uv, 0.0).x * (255.0 / 32.0); - float floor_level = floor(level); - float fract_level = level - floor_level; - return vec2(floor_level, fract_level); -} - -#ifdef VULKAN -#define INSTANCE_ID gl_InstanceIndex -#else -#define INSTANCE_ID gl_InstanceID -#endif - -vec2 warp_position() -{ - float vlod = dot(LODWeights, Patches[INSTANCE_ID].LODs); - vlod = mix(vlod, Patches[INSTANCE_ID].Position.w, all(equal(LODWeights, vec4(0.0)))); - -#ifdef DEBUG_LOD_HEIGHT - LODFactor = vec4(vlod); -#endif - - float floor_lod = floor(vlod); - float fract_lod = vlod - floor_lod; - uint ufloor_lod = uint(floor_lod); - -#ifdef DEBUG_LOD_HEIGHT - LODFactor = vec4(fract_lod); -#endif - - uvec2 uPosition = uvec2(Position); - uvec2 mask = (uvec2(1u) << uvec2(ufloor_lod, ufloor_lod + 1u)) - 1u; - //uvec2 rounding = mix(uvec2(0u), mask, lessThan(uPosition, uvec2(32u))); - - uvec2 rounding = uvec2( - uPosition.x < 32u ? mask.x : 0u, - uPosition.y < 32u ? mask.y : 0u); - - vec4 lower_upper_snapped = vec4((uPosition + rounding).xyxy & (~mask).xxyy); - return mix(lower_upper_snapped.xy, lower_upper_snapped.zw, fract_lod); -} - -void main() -{ - vec2 PatchPos = Patches[INSTANCE_ID].Position.xz * InvGroundSize_PatchScale.zw; - vec2 WarpedPos = warp_position(); - vec2 VertexPos = PatchPos + WarpedPos; - vec2 NormalizedPos = VertexPos * InvGroundSize_PatchScale.xy; - vec2 lod = lod_factor(NormalizedPos); - - vec2 Offset = exp2(lod.x) * InvGroundSize_PatchScale.xy; - - float Elevation = - mix(textureLod(TexHeightmap, NormalizedPos + 0.5 * Offset, lod.x).x, - textureLod(TexHeightmap, NormalizedPos + 1.0 * Offset, lod.x + 1.0).x, - lod.y); - - vec3 WorldPos = vec3(NormalizedPos.x, Elevation, NormalizedPos.y); - WorldPos *= GroundScale.xyz; - WorldPos += GroundPosition.xyz; - - EyeVec = WorldPos - g_CamPos.xyz; - TexCoord = NormalizedPos + 0.5 * InvGroundSize_PatchScale.xy; - - gl_Position = WorldPos.x * g_ViewProj_Row0 + WorldPos.y * g_ViewProj_Row1 + WorldPos.z * g_ViewProj_Row2 + g_ViewProj_Row3; -} - diff --git a/deps/SPIRV-Cross/shaders/vert/ocean.vert b/deps/SPIRV-Cross/shaders/vert/ocean.vert deleted file mode 100644 index 8a5677fa12..0000000000 --- a/deps/SPIRV-Cross/shaders/vert/ocean.vert +++ /dev/null @@ -1,200 +0,0 @@ -#version 310 es - -#define YFLIP 0 -#define SPECULAR 0 -#define GLOSSMAP 0 - -#define DEBUG_NONE 0 -#define DEBUG_DIFFUSE 1 -#define DEBUG_SPECULAR 2 -#define DEBUG_LIGHTING 3 -#define DEBUG_FOG 4 -#define DEBUG DEBUG_NONE - -#define FORWARD 0 -#define DEFERRED 1 -#define DEFERRED_VTEX 2 - -float saturate(float x) { return clamp(x, 0.0, 1.0); } - -layout(std140, binding = 0) uniform GlobalVSData -{ - vec4 g_ViewProj_Row0; - vec4 g_ViewProj_Row1; - vec4 g_ViewProj_Row2; - vec4 g_ViewProj_Row3; - vec4 g_CamPos; - vec4 g_CamRight; - vec4 g_CamUp; - vec4 g_CamFront; - vec4 g_SunDir; - vec4 g_SunColor; - vec4 g_TimeParams; - vec4 g_ResolutionParams; - vec4 g_CamAxisRight; - vec4 g_FogColor_Distance; - vec4 g_ShadowVP_Row0; - vec4 g_ShadowVP_Row1; - vec4 g_ShadowVP_Row2; - vec4 g_ShadowVP_Row3; -}; - -vec4 ComputeFogFactor(vec3 WorldPos) -{ - vec4 FogData; - vec3 vEye = WorldPos - g_CamPos.xyz; - vec3 nEye = normalize(vEye); - FogData.w = exp(-dot(vEye, vEye) * g_FogColor_Distance.w * 0.75); - - float fog_sun_factor = pow(saturate(dot(nEye, g_SunDir.xyz)), 8.0); - FogData.xyz = mix(vec3(1.0, 1.0, 1.0), vec3(0.6, 0.6, 0.9), nEye.y * 0.5 + 0.5); - FogData.xyz = mix(FogData.xyz, vec3(0.95, 0.87, 0.78), fog_sun_factor); - return FogData; -} - -void ApplyFog(inout vec3 Color, vec4 FogData) -{ - Color = mix(FogData.xyz, Color, FogData.w); -} - -void ApplyLighting(inout mediump vec3 Color, mediump float DiffuseFactor) -{ - mediump vec3 DiffuseLight = g_SunColor.xyz * DiffuseFactor; - mediump vec3 AmbientLight = vec3(0.2, 0.35, 0.55) * 0.5; - mediump vec3 Lighting = DiffuseLight + AmbientLight; -#if DEBUG == DEBUG_LIGHTING - Color = Lighting; -#else - Color *= Lighting; -#endif -} - -void ApplySpecular(inout mediump vec3 Color, mediump vec3 EyeVec, mediump vec3 Normal, mediump vec3 SpecularColor, mediump float Shininess, mediump float FresnelAmount) -{ - mediump vec3 HalfAngle = normalize(-EyeVec + g_SunDir.xyz); - - mediump float v_dot_h = saturate(dot(HalfAngle, -EyeVec)); - mediump float n_dot_l = saturate(dot(Normal, g_SunDir.xyz)); - mediump float n_dot_h = saturate(dot(Normal, HalfAngle)); - mediump float n_dot_v = saturate(dot(-EyeVec, Normal)); - mediump float h_dot_l = saturate(dot(g_SunDir.xyz, HalfAngle)); - - const mediump float roughness_value = 0.25; - - mediump float r_sq = roughness_value * roughness_value; - mediump float n_dot_h_sq = n_dot_h * n_dot_h; - mediump float roughness_a = 1.0 / (4.0 * r_sq * n_dot_h_sq * n_dot_h_sq); - mediump float roughness_b = n_dot_h_sq - 1.0; - mediump float roughness_c = r_sq * n_dot_h_sq; - mediump float roughness = saturate(roughness_a * exp(roughness_b / roughness_c)); - - FresnelAmount = 0.5; - mediump float fresnel_term = pow(1.0 - n_dot_v, 5.0) * (1.0 - FresnelAmount) + FresnelAmount; - - mediump float geo_numerator = 2.0 * n_dot_h; - mediump float geo_denominator = 1.0 / v_dot_h; - mediump float geo_term = min(1.0, min(n_dot_v, n_dot_l) * geo_numerator * geo_denominator); - -#if SPECULAR || GLOSSMAP - Color += SpecularColor * g_SunColor.xyz * fresnel_term * roughness * n_dot_l * geo_term / (n_dot_v * n_dot_l + 0.0001); -#endif - - //Color = vec3(0.025 * 1.0 / (n_dot_v * n_dot_l)); -} - - -precision highp int; - -layout(binding = 0) uniform mediump sampler2D TexDisplacement; -layout(binding = 1) uniform mediump sampler2D TexLOD; - -layout(location = 0) in vec4 Position; -layout(location = 1) in vec4 LODWeights; - -layout(location = 0) out highp vec3 EyeVec; -layout(location = 1) out highp vec4 TexCoord; - -layout(std140, binding = 4) uniform GlobalOcean -{ - vec4 OceanScale; - vec4 OceanPosition; - vec4 InvOceanSize_PatchScale; - vec4 NormalTexCoordScale; -}; - -struct PatchData -{ - vec4 Position; - vec4 LODs; -}; - -layout(std140, binding = 0) uniform Offsets -{ - PatchData Patches[256]; -}; - -vec2 lod_factor(vec2 uv) -{ - float level = textureLod(TexLOD, uv, 0.0).x * (255.0 / 32.0); - float floor_level = floor(level); - float fract_level = level - floor_level; - return vec2(floor_level, fract_level); -} - -#ifdef VULKAN -#define INSTANCE_ID gl_InstanceIndex -#else -#define INSTANCE_ID gl_InstanceID -#endif - -vec2 warp_position() -{ - float vlod = dot(LODWeights, Patches[INSTANCE_ID].LODs); - vlod = mix(vlod, Patches[INSTANCE_ID].Position.w, all(equal(LODWeights, vec4(0.0)))); - - float floor_lod = floor(vlod); - float fract_lod = vlod - floor_lod; - uint ufloor_lod = uint(floor_lod); - - uvec4 uPosition = uvec4(Position); - uvec2 mask = (uvec2(1u) << uvec2(ufloor_lod, ufloor_lod + 1u)) - 1u; - - uvec4 rounding; - rounding.x = uPosition.x < 32u ? mask.x : 0u; - rounding.y = uPosition.y < 32u ? mask.x : 0u; - rounding.z = uPosition.x < 32u ? mask.y : 0u; - rounding.w = uPosition.y < 32u ? mask.y : 0u; - - //rounding = uPosition.xyxy * mask.xxyy; - vec4 lower_upper_snapped = vec4((uPosition.xyxy + rounding) & (~mask).xxyy); - return mix(lower_upper_snapped.xy, lower_upper_snapped.zw, fract_lod); -} - -void main() -{ - vec2 PatchPos = Patches[INSTANCE_ID].Position.xz * InvOceanSize_PatchScale.zw; - vec2 WarpedPos = warp_position(); - vec2 VertexPos = PatchPos + WarpedPos; - vec2 NormalizedPos = VertexPos * InvOceanSize_PatchScale.xy; - vec2 NormalizedTex = NormalizedPos * NormalTexCoordScale.zw; - vec2 lod = lod_factor(NormalizedPos); - vec2 Offset = exp2(lod.x) * InvOceanSize_PatchScale.xy * NormalTexCoordScale.zw; - - vec3 Displacement = - mix(textureLod(TexDisplacement, NormalizedTex + 0.5 * Offset, lod.x).yxz, - textureLod(TexDisplacement, NormalizedTex + 1.0 * Offset, lod.x + 1.0).yxz, - lod.y); - - vec3 WorldPos = vec3(NormalizedPos.x, 0.0, NormalizedPos.y) + Displacement; - WorldPos *= OceanScale.xyz; - WorldPos += OceanPosition.xyz; - - EyeVec = WorldPos - g_CamPos.xyz; - TexCoord = vec4(NormalizedTex, NormalizedTex * NormalTexCoordScale.xy) + 0.5 * InvOceanSize_PatchScale.xyxy * NormalTexCoordScale.zwzw; - - gl_Position = WorldPos.x * g_ViewProj_Row0 + WorldPos.y * g_ViewProj_Row1 + WorldPos.z * g_ViewProj_Row2 + g_ViewProj_Row3; -#if YFLIP - gl_Position *= vec4(1.0, -1.0, 1.0, 1.0); -#endif -} - diff --git a/deps/SPIRV-Cross/shaders/vert/texture_buffer.vert b/deps/SPIRV-Cross/shaders/vert/texture_buffer.vert deleted file mode 100644 index 6bc7ddfae2..0000000000 --- a/deps/SPIRV-Cross/shaders/vert/texture_buffer.vert +++ /dev/null @@ -1,10 +0,0 @@ -#version 310 es -#extension GL_OES_texture_buffer : require - -layout(binding = 4) uniform highp samplerBuffer uSamp; -layout(rgba32f, binding = 5) uniform readonly highp imageBuffer uSampo; - -void main() -{ - gl_Position = texelFetch(uSamp, 10) + imageLoad(uSampo, 100); -} diff --git a/deps/SPIRV-Cross/shaders/vert/ubo.vert b/deps/SPIRV-Cross/shaders/vert/ubo.vert deleted file mode 100644 index 82e4626e12..0000000000 --- a/deps/SPIRV-Cross/shaders/vert/ubo.vert +++ /dev/null @@ -1,16 +0,0 @@ -#version 310 es - -layout(binding = 0, std140) uniform UBO -{ - mat4 mvp; -}; - -layout(location = 0) in vec4 aVertex; -layout(location = 1) in vec3 aNormal; -layout(location = 0) out vec3 vNormal; - -void main() -{ - gl_Position = mvp * aVertex; - vNormal = aNormal; -} diff --git a/deps/SPIRV-Cross/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag b/deps/SPIRV-Cross/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag deleted file mode 100644 index 2fabb5ea8a..0000000000 --- a/deps/SPIRV-Cross/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag +++ /dev/null @@ -1,29 +0,0 @@ -#version 310 es -precision mediump float; - -layout(set = 0, binding = 0) uniform mediump samplerShadow uSampler; -layout(set = 0, binding = 1) uniform mediump sampler uSampler1; -layout(set = 0, binding = 2) uniform texture2D uDepth; -layout(location = 0) out float FragColor; - -float samp2(texture2D t, mediump samplerShadow s) -{ - return texture(sampler2DShadow(t, s), vec3(1.0)); -} - -float samp3(texture2D t, mediump sampler s) -{ - return texture(sampler2D(t, s), vec2(1.0)).x; -} - -float samp(texture2D t, mediump samplerShadow s, mediump sampler s1) -{ - float r0 = samp2(t, s); - float r1 = samp3(t, s1); - return r0 + r1; -} - -void main() -{ - FragColor = samp(uDepth, uSampler, uSampler1); -} diff --git a/deps/SPIRV-Cross/shaders/vulkan/frag/combined-texture-sampler.vk.frag b/deps/SPIRV-Cross/shaders/vulkan/frag/combined-texture-sampler.vk.frag deleted file mode 100644 index b7de8d47e9..0000000000 --- a/deps/SPIRV-Cross/shaders/vulkan/frag/combined-texture-sampler.vk.frag +++ /dev/null @@ -1,47 +0,0 @@ -#version 310 es -precision mediump float; - -layout(set = 0, binding = 0) uniform mediump sampler uSampler0; -layout(set = 0, binding = 1) uniform mediump sampler uSampler1; -layout(set = 0, binding = 2) uniform mediump texture2D uTexture0; -layout(set = 0, binding = 3) uniform mediump texture2D uTexture1; - -layout(location = 0) out vec4 FragColor; -layout(location = 0) in vec2 vTex; - -vec4 sample_dual(mediump sampler samp, mediump texture2D tex) -{ - return texture(sampler2D(tex, samp), vTex); -} - -vec4 sample_global_tex(mediump sampler samp) -{ - vec4 a = texture(sampler2D(uTexture0, samp), vTex); - vec4 b = sample_dual(samp, uTexture1); - return a + b; -} - -vec4 sample_global_sampler(mediump texture2D tex) -{ - vec4 a = texture(sampler2D(tex, uSampler0), vTex); - vec4 b = sample_dual(uSampler1, tex); - return a + b; -} - -vec4 sample_duals() -{ - vec4 a = sample_dual(uSampler0, uTexture0); - vec4 b = sample_dual(uSampler1, uTexture1); - return a + b; -} - -void main() -{ - vec4 c0 = sample_duals(); - vec4 c1 = sample_global_tex(uSampler0); - vec4 c2 = sample_global_tex(uSampler1); - vec4 c3 = sample_global_sampler(uTexture0); - vec4 c4 = sample_global_sampler(uTexture1); - - FragColor = c0 + c1 + c2 + c3 + c4; -} diff --git a/deps/SPIRV-Cross/shaders/vulkan/frag/desktop-mediump.vk.frag b/deps/SPIRV-Cross/shaders/vulkan/frag/desktop-mediump.vk.frag deleted file mode 100644 index 23fe3d3da0..0000000000 --- a/deps/SPIRV-Cross/shaders/vulkan/frag/desktop-mediump.vk.frag +++ /dev/null @@ -1,11 +0,0 @@ -#version 450 - -layout(location = 0) in mediump vec4 F; -layout(location = 1) flat in mediump ivec4 I; -layout(location = 2) flat in mediump uvec4 U; -layout(location = 0) out mediump vec4 FragColor; - -void main() -{ - FragColor = F + vec4(I) + vec4(U); -} diff --git a/deps/SPIRV-Cross/shaders/vulkan/frag/input-attachment-ms.vk.frag b/deps/SPIRV-Cross/shaders/vulkan/frag/input-attachment-ms.vk.frag deleted file mode 100644 index e060738846..0000000000 --- a/deps/SPIRV-Cross/shaders/vulkan/frag/input-attachment-ms.vk.frag +++ /dev/null @@ -1,10 +0,0 @@ -#version 450 - -layout(input_attachment_index = 0, set = 0, binding = 0) uniform subpassInputMS uSubpass0; -layout(input_attachment_index = 1, set = 0, binding = 1) uniform subpassInputMS uSubpass1; -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = subpassLoad(uSubpass0, 1) + subpassLoad(uSubpass1, 2) + subpassLoad(uSubpass0, gl_SampleID); -} diff --git a/deps/SPIRV-Cross/shaders/vulkan/frag/input-attachment.vk.frag b/deps/SPIRV-Cross/shaders/vulkan/frag/input-attachment.vk.frag deleted file mode 100644 index f082d15b2a..0000000000 --- a/deps/SPIRV-Cross/shaders/vulkan/frag/input-attachment.vk.frag +++ /dev/null @@ -1,11 +0,0 @@ -#version 310 es -precision mediump float; - -layout(input_attachment_index = 0, set = 0, binding = 0) uniform mediump subpassInput uSubpass0; -layout(input_attachment_index = 1, set = 0, binding = 1) uniform mediump subpassInput uSubpass1; -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = subpassLoad(uSubpass0) + subpassLoad(uSubpass1); -} diff --git a/deps/SPIRV-Cross/shaders/vulkan/frag/push-constant.vk.frag b/deps/SPIRV-Cross/shaders/vulkan/frag/push-constant.vk.frag deleted file mode 100644 index 6180faba31..0000000000 --- a/deps/SPIRV-Cross/shaders/vulkan/frag/push-constant.vk.frag +++ /dev/null @@ -1,16 +0,0 @@ -#version 310 es -precision mediump float; - -layout(push_constant, std430) uniform PushConstants -{ - vec4 value0; - vec4 value1; -} push; - -layout(location = 0) in vec4 vColor; -layout(location = 0) out vec4 FragColor; - -void main() -{ - FragColor = vColor + push.value0 + push.value1; -} diff --git a/deps/SPIRV-Cross/shaders/vulkan/frag/separate-sampler-texture.vk.frag b/deps/SPIRV-Cross/shaders/vulkan/frag/separate-sampler-texture.vk.frag deleted file mode 100644 index cedf114ef8..0000000000 --- a/deps/SPIRV-Cross/shaders/vulkan/frag/separate-sampler-texture.vk.frag +++ /dev/null @@ -1,36 +0,0 @@ -#version 310 es -precision mediump float; - -layout(set = 0, binding = 0) uniform mediump sampler uSampler; -layout(set = 0, binding = 1) uniform mediump texture2D uTexture; -layout(set = 0, binding = 2) uniform mediump texture3D uTexture3D; -layout(set = 0, binding = 3) uniform mediump textureCube uTextureCube; -layout(set = 0, binding = 4) uniform mediump texture2DArray uTextureArray; - -layout(location = 0) out vec4 FragColor; -layout(location = 0) in vec2 vTex; -layout(location = 1) in vec3 vTex3; - -vec4 sample_func(mediump sampler samp, vec2 uv) -{ - return texture(sampler2D(uTexture, samp), uv); -} - -vec4 sample_func_dual(mediump sampler samp, mediump texture2D tex, vec2 uv) -{ - return texture(sampler2D(tex, samp), uv); -} - -void main() -{ - vec2 off = 1.0 / vec2(textureSize(sampler2D(uTexture, uSampler), 0)); - vec2 off2 = 1.0 / vec2(textureSize(sampler2D(uTexture, uSampler), 1)); - - vec4 c0 = sample_func(uSampler, vTex + off + off2); - vec4 c1 = sample_func_dual(uSampler, uTexture, vTex + off + off2); - vec4 c2 = texture(sampler2DArray(uTextureArray, uSampler), vTex3); - vec4 c3 = texture(samplerCube(uTextureCube, uSampler), vTex3); - vec4 c4 = texture(sampler3D(uTexture3D, uSampler), vTex3); - - FragColor = c0 + c1 + c2 + c3 + c4; -} diff --git a/deps/SPIRV-Cross/shaders/vulkan/frag/spec-constant.vk.frag b/deps/SPIRV-Cross/shaders/vulkan/frag/spec-constant.vk.frag deleted file mode 100644 index 2002c1272e..0000000000 --- a/deps/SPIRV-Cross/shaders/vulkan/frag/spec-constant.vk.frag +++ /dev/null @@ -1,77 +0,0 @@ -#version 310 es -precision mediump float; - -layout(location = 0) out vec4 FragColor; -layout(constant_id = 1) const float a = 1.0; -layout(constant_id = 2) const float b = 2.0; -layout(constant_id = 3) const int c = 3; -layout(constant_id = 4) const int d = 4; -layout(constant_id = 5) const uint e = 5u; -layout(constant_id = 6) const uint f = 6u; -layout(constant_id = 7) const bool g = false; -layout(constant_id = 8) const bool h = true; -// glslang doesn't seem to support partial spec constants or composites yet, so only test the basics. - -struct Foo -{ - float elems[d + 2]; -}; - -void main() -{ - float t0 = a; - float t1 = b; - - uint c0 = uint(c); // OpIAdd with different types. - // FConvert, float-to-double. - int c1 = -c; // SNegate - int c2 = ~c; // OpNot - int c3 = c + d; // OpIAdd - int c4 = c - d; // OpISub - int c5 = c * d; // OpIMul - int c6 = c / d; // OpSDiv - uint c7 = e / f; // OpUDiv - int c8 = c % d; // OpSMod - uint c9 = e % f; // OpUMod - // TODO: OpSRem, any way to access this in GLSL? - int c10 = c >> d; // OpShiftRightArithmetic - uint c11 = e >> f; // OpShiftRightLogical - int c12 = c << d; // OpShiftLeftLogical - int c13 = c | d; // OpBitwiseOr - int c14 = c ^ d; // OpBitwiseXor - int c15 = c & d; // OpBitwiseAnd - // VectorShuffle, CompositeExtract, CompositeInsert, not testable atm. - bool c16 = g || h; // OpLogicalOr - bool c17 = g && h; // OpLogicalAnd - bool c18 = !g; // OpLogicalNot - bool c19 = g == h; // OpLogicalEqual - bool c20 = g != h; // OpLogicalNotEqual - // OpSelect not testable atm. - bool c21 = c == d; // OpIEqual - bool c22 = c != d; // OpINotEqual - bool c23 = c < d; // OpSLessThan - bool c24 = e < f; // OpULessThan - bool c25 = c > d; // OpSGreaterThan - bool c26 = e > f; // OpUGreaterThan - bool c27 = c <= d; // OpSLessThanEqual - bool c28 = e <= f; // OpULessThanEqual - bool c29 = c >= d; // OpSGreaterThanEqual - bool c30 = e >= f; // OpUGreaterThanEqual - // OpQuantizeToF16 not testable atm. - - int c31 = c8 + c3; - - int c32 = int(e); // OpIAdd with different types. - bool c33 = bool(c); // int -> bool - bool c34 = bool(e); // uint -> bool - int c35 = int(g); // bool -> int - uint c36 = uint(g); // bool -> uint - float c37 = float(g); // bool -> float - - // Flexible sized arrays with spec constants and spec constant ops. - float vec0[c + 3][8]; - float vec1[c + 2]; - - Foo foo; - FragColor = vec4(t0 + t1) + vec0[0][0] + vec1[0] + foo.elems[c]; -} diff --git a/deps/SPIRV-Cross/shaders/vulkan/vert/multiview.nocompat.vk.vert b/deps/SPIRV-Cross/shaders/vulkan/vert/multiview.nocompat.vk.vert deleted file mode 100644 index eb1bc766f2..0000000000 --- a/deps/SPIRV-Cross/shaders/vulkan/vert/multiview.nocompat.vk.vert +++ /dev/null @@ -1,14 +0,0 @@ -#version 310 es -#extension GL_EXT_multiview : require - -layout(std140, binding = 0) uniform MVPs -{ - mat4 MVP[2]; -}; - -layout(location = 0) in vec4 Position; - -void main() -{ - gl_Position = MVP[gl_ViewIndex] * Position; -} diff --git a/deps/SPIRV-Cross/shaders/vulkan/vert/vulkan-vertex.vk.vert b/deps/SPIRV-Cross/shaders/vulkan/vert/vulkan-vertex.vk.vert deleted file mode 100644 index 4d0438ace6..0000000000 --- a/deps/SPIRV-Cross/shaders/vulkan/vert/vulkan-vertex.vk.vert +++ /dev/null @@ -1,6 +0,0 @@ -#version 310 es - -void main() -{ - gl_Position = float(gl_VertexIndex + gl_InstanceIndex) * vec4(1.0, 2.0, 3.0, 4.0); -} diff --git a/deps/SPIRV-Cross/spirv.hpp b/deps/SPIRV-Cross/spirv.hpp deleted file mode 100644 index efa1dbdf0e..0000000000 --- a/deps/SPIRV-Cross/spirv.hpp +++ /dev/null @@ -1,968 +0,0 @@ -// Copyright (c) 2014-2017 The Khronos Group Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and/or associated documentation files (the "Materials"), -// to deal in the Materials without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Materials, and to permit persons to whom the -// Materials are furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Materials. -// -// MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS -// STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND -// HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ -// -// THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM,OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS -// IN THE MATERIALS. - -// This header is automatically generated by the same tool that creates -// the Binary Section of the SPIR-V specification. - -// Enumeration tokens for SPIR-V, in various styles: -// C, C++, C++11, JSON, Lua, Python -// -// - C will have tokens with a "Spv" prefix, e.g.: SpvSourceLanguageGLSL -// - C++ will have tokens in the "spv" name space, e.g.: spv::SourceLanguageGLSL -// - C++11 will use enum classes in the spv namespace, e.g.: spv::SourceLanguage::GLSL -// - Lua will use tables, e.g.: spv.SourceLanguage.GLSL -// - Python will use dictionaries, e.g.: spv['SourceLanguage']['GLSL'] -// -// Some tokens act like mask values, which can be OR'd together, -// while others are mutually exclusive. The mask-like ones have -// "Mask" in their name, and a parallel enum that has the shift -// amount (1 << x) for each corresponding enumerant. - -#ifndef spirv_HPP -#define spirv_HPP - -namespace spv { - -typedef unsigned int Id; - -#define SPV_VERSION 0x10000 -#define SPV_REVISION 10 - -static const unsigned int MagicNumber = 0x07230203; -static const unsigned int Version = 0x00010000; -static const unsigned int Revision = 10; -static const unsigned int OpCodeMask = 0xffff; -static const unsigned int WordCountShift = 16; - -enum SourceLanguage { - SourceLanguageUnknown = 0, - SourceLanguageESSL = 1, - SourceLanguageGLSL = 2, - SourceLanguageOpenCL_C = 3, - SourceLanguageOpenCL_CPP = 4, - SourceLanguageHLSL = 5, - SourceLanguageMax = 0x7fffffff, -}; - -enum ExecutionModel { - ExecutionModelVertex = 0, - ExecutionModelTessellationControl = 1, - ExecutionModelTessellationEvaluation = 2, - ExecutionModelGeometry = 3, - ExecutionModelFragment = 4, - ExecutionModelGLCompute = 5, - ExecutionModelKernel = 6, - ExecutionModelMax = 0x7fffffff, -}; - -enum AddressingModel { - AddressingModelLogical = 0, - AddressingModelPhysical32 = 1, - AddressingModelPhysical64 = 2, - AddressingModelMax = 0x7fffffff, -}; - -enum MemoryModel { - MemoryModelSimple = 0, - MemoryModelGLSL450 = 1, - MemoryModelOpenCL = 2, - MemoryModelMax = 0x7fffffff, -}; - -enum ExecutionMode { - ExecutionModeInvocations = 0, - ExecutionModeSpacingEqual = 1, - ExecutionModeSpacingFractionalEven = 2, - ExecutionModeSpacingFractionalOdd = 3, - ExecutionModeVertexOrderCw = 4, - ExecutionModeVertexOrderCcw = 5, - ExecutionModePixelCenterInteger = 6, - ExecutionModeOriginUpperLeft = 7, - ExecutionModeOriginLowerLeft = 8, - ExecutionModeEarlyFragmentTests = 9, - ExecutionModePointMode = 10, - ExecutionModeXfb = 11, - ExecutionModeDepthReplacing = 12, - ExecutionModeDepthGreater = 14, - ExecutionModeDepthLess = 15, - ExecutionModeDepthUnchanged = 16, - ExecutionModeLocalSize = 17, - ExecutionModeLocalSizeHint = 18, - ExecutionModeInputPoints = 19, - ExecutionModeInputLines = 20, - ExecutionModeInputLinesAdjacency = 21, - ExecutionModeTriangles = 22, - ExecutionModeInputTrianglesAdjacency = 23, - ExecutionModeQuads = 24, - ExecutionModeIsolines = 25, - ExecutionModeOutputVertices = 26, - ExecutionModeOutputPoints = 27, - ExecutionModeOutputLineStrip = 28, - ExecutionModeOutputTriangleStrip = 29, - ExecutionModeVecTypeHint = 30, - ExecutionModeContractionOff = 31, - ExecutionModeMax = 0x7fffffff, -}; - -enum StorageClass { - StorageClassUniformConstant = 0, - StorageClassInput = 1, - StorageClassUniform = 2, - StorageClassOutput = 3, - StorageClassWorkgroup = 4, - StorageClassCrossWorkgroup = 5, - StorageClassPrivate = 6, - StorageClassFunction = 7, - StorageClassGeneric = 8, - StorageClassPushConstant = 9, - StorageClassAtomicCounter = 10, - StorageClassImage = 11, - StorageClassStorageBuffer = 12, - StorageClassMax = 0x7fffffff, -}; - -enum Dim { - Dim1D = 0, - Dim2D = 1, - Dim3D = 2, - DimCube = 3, - DimRect = 4, - DimBuffer = 5, - DimSubpassData = 6, - DimMax = 0x7fffffff, -}; - -enum SamplerAddressingMode { - SamplerAddressingModeNone = 0, - SamplerAddressingModeClampToEdge = 1, - SamplerAddressingModeClamp = 2, - SamplerAddressingModeRepeat = 3, - SamplerAddressingModeRepeatMirrored = 4, - SamplerAddressingModeMax = 0x7fffffff, -}; - -enum SamplerFilterMode { - SamplerFilterModeNearest = 0, - SamplerFilterModeLinear = 1, - SamplerFilterModeMax = 0x7fffffff, -}; - -enum ImageFormat { - ImageFormatUnknown = 0, - ImageFormatRgba32f = 1, - ImageFormatRgba16f = 2, - ImageFormatR32f = 3, - ImageFormatRgba8 = 4, - ImageFormatRgba8Snorm = 5, - ImageFormatRg32f = 6, - ImageFormatRg16f = 7, - ImageFormatR11fG11fB10f = 8, - ImageFormatR16f = 9, - ImageFormatRgba16 = 10, - ImageFormatRgb10A2 = 11, - ImageFormatRg16 = 12, - ImageFormatRg8 = 13, - ImageFormatR16 = 14, - ImageFormatR8 = 15, - ImageFormatRgba16Snorm = 16, - ImageFormatRg16Snorm = 17, - ImageFormatRg8Snorm = 18, - ImageFormatR16Snorm = 19, - ImageFormatR8Snorm = 20, - ImageFormatRgba32i = 21, - ImageFormatRgba16i = 22, - ImageFormatRgba8i = 23, - ImageFormatR32i = 24, - ImageFormatRg32i = 25, - ImageFormatRg16i = 26, - ImageFormatRg8i = 27, - ImageFormatR16i = 28, - ImageFormatR8i = 29, - ImageFormatRgba32ui = 30, - ImageFormatRgba16ui = 31, - ImageFormatRgba8ui = 32, - ImageFormatR32ui = 33, - ImageFormatRgb10a2ui = 34, - ImageFormatRg32ui = 35, - ImageFormatRg16ui = 36, - ImageFormatRg8ui = 37, - ImageFormatR16ui = 38, - ImageFormatR8ui = 39, - ImageFormatMax = 0x7fffffff, -}; - -enum ImageChannelOrder { - ImageChannelOrderR = 0, - ImageChannelOrderA = 1, - ImageChannelOrderRG = 2, - ImageChannelOrderRA = 3, - ImageChannelOrderRGB = 4, - ImageChannelOrderRGBA = 5, - ImageChannelOrderBGRA = 6, - ImageChannelOrderARGB = 7, - ImageChannelOrderIntensity = 8, - ImageChannelOrderLuminance = 9, - ImageChannelOrderRx = 10, - ImageChannelOrderRGx = 11, - ImageChannelOrderRGBx = 12, - ImageChannelOrderDepth = 13, - ImageChannelOrderDepthStencil = 14, - ImageChannelOrdersRGB = 15, - ImageChannelOrdersRGBx = 16, - ImageChannelOrdersRGBA = 17, - ImageChannelOrdersBGRA = 18, - ImageChannelOrderABGR = 19, - ImageChannelOrderMax = 0x7fffffff, -}; - -enum ImageChannelDataType { - ImageChannelDataTypeSnormInt8 = 0, - ImageChannelDataTypeSnormInt16 = 1, - ImageChannelDataTypeUnormInt8 = 2, - ImageChannelDataTypeUnormInt16 = 3, - ImageChannelDataTypeUnormShort565 = 4, - ImageChannelDataTypeUnormShort555 = 5, - ImageChannelDataTypeUnormInt101010 = 6, - ImageChannelDataTypeSignedInt8 = 7, - ImageChannelDataTypeSignedInt16 = 8, - ImageChannelDataTypeSignedInt32 = 9, - ImageChannelDataTypeUnsignedInt8 = 10, - ImageChannelDataTypeUnsignedInt16 = 11, - ImageChannelDataTypeUnsignedInt32 = 12, - ImageChannelDataTypeHalfFloat = 13, - ImageChannelDataTypeFloat = 14, - ImageChannelDataTypeUnormInt24 = 15, - ImageChannelDataTypeUnormInt101010_2 = 16, - ImageChannelDataTypeMax = 0x7fffffff, -}; - -enum ImageOperandsShift { - ImageOperandsBiasShift = 0, - ImageOperandsLodShift = 1, - ImageOperandsGradShift = 2, - ImageOperandsConstOffsetShift = 3, - ImageOperandsOffsetShift = 4, - ImageOperandsConstOffsetsShift = 5, - ImageOperandsSampleShift = 6, - ImageOperandsMinLodShift = 7, - ImageOperandsMax = 0x7fffffff, -}; - -enum ImageOperandsMask { - ImageOperandsMaskNone = 0, - ImageOperandsBiasMask = 0x00000001, - ImageOperandsLodMask = 0x00000002, - ImageOperandsGradMask = 0x00000004, - ImageOperandsConstOffsetMask = 0x00000008, - ImageOperandsOffsetMask = 0x00000010, - ImageOperandsConstOffsetsMask = 0x00000020, - ImageOperandsSampleMask = 0x00000040, - ImageOperandsMinLodMask = 0x00000080, -}; - -enum FPFastMathModeShift { - FPFastMathModeNotNaNShift = 0, - FPFastMathModeNotInfShift = 1, - FPFastMathModeNSZShift = 2, - FPFastMathModeAllowRecipShift = 3, - FPFastMathModeFastShift = 4, - FPFastMathModeMax = 0x7fffffff, -}; - -enum FPFastMathModeMask { - FPFastMathModeMaskNone = 0, - FPFastMathModeNotNaNMask = 0x00000001, - FPFastMathModeNotInfMask = 0x00000002, - FPFastMathModeNSZMask = 0x00000004, - FPFastMathModeAllowRecipMask = 0x00000008, - FPFastMathModeFastMask = 0x00000010, -}; - -enum FPRoundingMode { - FPRoundingModeRTE = 0, - FPRoundingModeRTZ = 1, - FPRoundingModeRTP = 2, - FPRoundingModeRTN = 3, - FPRoundingModeMax = 0x7fffffff, -}; - -enum LinkageType { - LinkageTypeExport = 0, - LinkageTypeImport = 1, - LinkageTypeMax = 0x7fffffff, -}; - -enum AccessQualifier { - AccessQualifierReadOnly = 0, - AccessQualifierWriteOnly = 1, - AccessQualifierReadWrite = 2, - AccessQualifierMax = 0x7fffffff, -}; - -enum FunctionParameterAttribute { - FunctionParameterAttributeZext = 0, - FunctionParameterAttributeSext = 1, - FunctionParameterAttributeByVal = 2, - FunctionParameterAttributeSret = 3, - FunctionParameterAttributeNoAlias = 4, - FunctionParameterAttributeNoCapture = 5, - FunctionParameterAttributeNoWrite = 6, - FunctionParameterAttributeNoReadWrite = 7, - FunctionParameterAttributeMax = 0x7fffffff, -}; - -enum Decoration { - DecorationRelaxedPrecision = 0, - DecorationSpecId = 1, - DecorationBlock = 2, - DecorationBufferBlock = 3, - DecorationRowMajor = 4, - DecorationColMajor = 5, - DecorationArrayStride = 6, - DecorationMatrixStride = 7, - DecorationGLSLShared = 8, - DecorationGLSLPacked = 9, - DecorationCPacked = 10, - DecorationBuiltIn = 11, - DecorationNoPerspective = 13, - DecorationFlat = 14, - DecorationPatch = 15, - DecorationCentroid = 16, - DecorationSample = 17, - DecorationInvariant = 18, - DecorationRestrict = 19, - DecorationAliased = 20, - DecorationVolatile = 21, - DecorationConstant = 22, - DecorationCoherent = 23, - DecorationNonWritable = 24, - DecorationNonReadable = 25, - DecorationUniform = 26, - DecorationSaturatedConversion = 28, - DecorationStream = 29, - DecorationLocation = 30, - DecorationComponent = 31, - DecorationIndex = 32, - DecorationBinding = 33, - DecorationDescriptorSet = 34, - DecorationOffset = 35, - DecorationXfbBuffer = 36, - DecorationXfbStride = 37, - DecorationFuncParamAttr = 38, - DecorationFPRoundingMode = 39, - DecorationFPFastMathMode = 40, - DecorationLinkageAttributes = 41, - DecorationNoContraction = 42, - DecorationInputAttachmentIndex = 43, - DecorationAlignment = 44, - DecorationOverrideCoverageNV = 5248, - DecorationPassthroughNV = 5250, - DecorationViewportRelativeNV = 5252, - DecorationSecondaryViewportRelativeNV = 5256, - DecorationMax = 0x7fffffff, -}; - -enum BuiltIn { - BuiltInPosition = 0, - BuiltInPointSize = 1, - BuiltInClipDistance = 3, - BuiltInCullDistance = 4, - BuiltInVertexId = 5, - BuiltInInstanceId = 6, - BuiltInPrimitiveId = 7, - BuiltInInvocationId = 8, - BuiltInLayer = 9, - BuiltInViewportIndex = 10, - BuiltInTessLevelOuter = 11, - BuiltInTessLevelInner = 12, - BuiltInTessCoord = 13, - BuiltInPatchVertices = 14, - BuiltInFragCoord = 15, - BuiltInPointCoord = 16, - BuiltInFrontFacing = 17, - BuiltInSampleId = 18, - BuiltInSamplePosition = 19, - BuiltInSampleMask = 20, - BuiltInFragDepth = 22, - BuiltInHelperInvocation = 23, - BuiltInNumWorkgroups = 24, - BuiltInWorkgroupSize = 25, - BuiltInWorkgroupId = 26, - BuiltInLocalInvocationId = 27, - BuiltInGlobalInvocationId = 28, - BuiltInLocalInvocationIndex = 29, - BuiltInWorkDim = 30, - BuiltInGlobalSize = 31, - BuiltInEnqueuedWorkgroupSize = 32, - BuiltInGlobalOffset = 33, - BuiltInGlobalLinearId = 34, - BuiltInSubgroupSize = 36, - BuiltInSubgroupMaxSize = 37, - BuiltInNumSubgroups = 38, - BuiltInNumEnqueuedSubgroups = 39, - BuiltInSubgroupId = 40, - BuiltInSubgroupLocalInvocationId = 41, - BuiltInVertexIndex = 42, - BuiltInInstanceIndex = 43, - BuiltInSubgroupEqMaskKHR = 4416, - BuiltInSubgroupGeMaskKHR = 4417, - BuiltInSubgroupGtMaskKHR = 4418, - BuiltInSubgroupLeMaskKHR = 4419, - BuiltInSubgroupLtMaskKHR = 4420, - BuiltInBaseVertex = 4424, - BuiltInBaseInstance = 4425, - BuiltInDrawIndex = 4426, - BuiltInDeviceIndex = 4438, - BuiltInViewIndex = 4440, - BuiltInViewportMaskNV = 5253, - BuiltInSecondaryPositionNV = 5257, - BuiltInSecondaryViewportMaskNV = 5258, - BuiltInPositionPerViewNV = 5261, - BuiltInViewportMaskPerViewNV = 5262, - BuiltInMax = 0x7fffffff, -}; - -enum SelectionControlShift { - SelectionControlFlattenShift = 0, - SelectionControlDontFlattenShift = 1, - SelectionControlMax = 0x7fffffff, -}; - -enum SelectionControlMask { - SelectionControlMaskNone = 0, - SelectionControlFlattenMask = 0x00000001, - SelectionControlDontFlattenMask = 0x00000002, -}; - -enum LoopControlShift { - LoopControlUnrollShift = 0, - LoopControlDontUnrollShift = 1, - LoopControlMax = 0x7fffffff, -}; - -enum LoopControlMask { - LoopControlMaskNone = 0, - LoopControlUnrollMask = 0x00000001, - LoopControlDontUnrollMask = 0x00000002, -}; - -enum FunctionControlShift { - FunctionControlInlineShift = 0, - FunctionControlDontInlineShift = 1, - FunctionControlPureShift = 2, - FunctionControlConstShift = 3, - FunctionControlMax = 0x7fffffff, -}; - -enum FunctionControlMask { - FunctionControlMaskNone = 0, - FunctionControlInlineMask = 0x00000001, - FunctionControlDontInlineMask = 0x00000002, - FunctionControlPureMask = 0x00000004, - FunctionControlConstMask = 0x00000008, -}; - -enum MemorySemanticsShift { - MemorySemanticsAcquireShift = 1, - MemorySemanticsReleaseShift = 2, - MemorySemanticsAcquireReleaseShift = 3, - MemorySemanticsSequentiallyConsistentShift = 4, - MemorySemanticsUniformMemoryShift = 6, - MemorySemanticsSubgroupMemoryShift = 7, - MemorySemanticsWorkgroupMemoryShift = 8, - MemorySemanticsCrossWorkgroupMemoryShift = 9, - MemorySemanticsAtomicCounterMemoryShift = 10, - MemorySemanticsImageMemoryShift = 11, - MemorySemanticsMax = 0x7fffffff, -}; - -enum MemorySemanticsMask { - MemorySemanticsMaskNone = 0, - MemorySemanticsAcquireMask = 0x00000002, - MemorySemanticsReleaseMask = 0x00000004, - MemorySemanticsAcquireReleaseMask = 0x00000008, - MemorySemanticsSequentiallyConsistentMask = 0x00000010, - MemorySemanticsUniformMemoryMask = 0x00000040, - MemorySemanticsSubgroupMemoryMask = 0x00000080, - MemorySemanticsWorkgroupMemoryMask = 0x00000100, - MemorySemanticsCrossWorkgroupMemoryMask = 0x00000200, - MemorySemanticsAtomicCounterMemoryMask = 0x00000400, - MemorySemanticsImageMemoryMask = 0x00000800, -}; - -enum MemoryAccessShift { - MemoryAccessVolatileShift = 0, - MemoryAccessAlignedShift = 1, - MemoryAccessNontemporalShift = 2, - MemoryAccessMax = 0x7fffffff, -}; - -enum MemoryAccessMask { - MemoryAccessMaskNone = 0, - MemoryAccessVolatileMask = 0x00000001, - MemoryAccessAlignedMask = 0x00000002, - MemoryAccessNontemporalMask = 0x00000004, -}; - -enum Scope { - ScopeCrossDevice = 0, - ScopeDevice = 1, - ScopeWorkgroup = 2, - ScopeSubgroup = 3, - ScopeInvocation = 4, - ScopeMax = 0x7fffffff, -}; - -enum GroupOperation { - GroupOperationReduce = 0, - GroupOperationInclusiveScan = 1, - GroupOperationExclusiveScan = 2, - GroupOperationMax = 0x7fffffff, -}; - -enum KernelEnqueueFlags { - KernelEnqueueFlagsNoWait = 0, - KernelEnqueueFlagsWaitKernel = 1, - KernelEnqueueFlagsWaitWorkGroup = 2, - KernelEnqueueFlagsMax = 0x7fffffff, -}; - -enum KernelProfilingInfoShift { - KernelProfilingInfoCmdExecTimeShift = 0, - KernelProfilingInfoMax = 0x7fffffff, -}; - -enum KernelProfilingInfoMask { - KernelProfilingInfoMaskNone = 0, - KernelProfilingInfoCmdExecTimeMask = 0x00000001, -}; - -enum Capability { - CapabilityMatrix = 0, - CapabilityShader = 1, - CapabilityGeometry = 2, - CapabilityTessellation = 3, - CapabilityAddresses = 4, - CapabilityLinkage = 5, - CapabilityKernel = 6, - CapabilityVector16 = 7, - CapabilityFloat16Buffer = 8, - CapabilityFloat16 = 9, - CapabilityFloat64 = 10, - CapabilityInt64 = 11, - CapabilityInt64Atomics = 12, - CapabilityImageBasic = 13, - CapabilityImageReadWrite = 14, - CapabilityImageMipmap = 15, - CapabilityPipes = 17, - CapabilityGroups = 18, - CapabilityDeviceEnqueue = 19, - CapabilityLiteralSampler = 20, - CapabilityAtomicStorage = 21, - CapabilityInt16 = 22, - CapabilityTessellationPointSize = 23, - CapabilityGeometryPointSize = 24, - CapabilityImageGatherExtended = 25, - CapabilityStorageImageMultisample = 27, - CapabilityUniformBufferArrayDynamicIndexing = 28, - CapabilitySampledImageArrayDynamicIndexing = 29, - CapabilityStorageBufferArrayDynamicIndexing = 30, - CapabilityStorageImageArrayDynamicIndexing = 31, - CapabilityClipDistance = 32, - CapabilityCullDistance = 33, - CapabilityImageCubeArray = 34, - CapabilitySampleRateShading = 35, - CapabilityImageRect = 36, - CapabilitySampledRect = 37, - CapabilityGenericPointer = 38, - CapabilityInt8 = 39, - CapabilityInputAttachment = 40, - CapabilitySparseResidency = 41, - CapabilityMinLod = 42, - CapabilitySampled1D = 43, - CapabilityImage1D = 44, - CapabilitySampledCubeArray = 45, - CapabilitySampledBuffer = 46, - CapabilityImageBuffer = 47, - CapabilityImageMSArray = 48, - CapabilityStorageImageExtendedFormats = 49, - CapabilityImageQuery = 50, - CapabilityDerivativeControl = 51, - CapabilityInterpolationFunction = 52, - CapabilityTransformFeedback = 53, - CapabilityGeometryStreams = 54, - CapabilityStorageImageReadWithoutFormat = 55, - CapabilityStorageImageWriteWithoutFormat = 56, - CapabilityMultiViewport = 57, - CapabilitySubgroupBallotKHR = 4423, - CapabilityDrawParameters = 4427, - CapabilitySubgroupVoteKHR = 4431, - CapabilityStorageBuffer16BitAccess = 4433, - CapabilityStorageUniformBufferBlock16 = 4433, - CapabilityStorageUniform16 = 4434, - CapabilityUniformAndStorageBuffer16BitAccess = 4434, - CapabilityStoragePushConstant16 = 4435, - CapabilityStorageInputOutput16 = 4436, - CapabilityDeviceGroup = 4437, - CapabilityMultiView = 4439, - CapabilityVariablePointersStorageBuffer = 4441, - CapabilityVariablePointers = 4442, - CapabilitySampleMaskOverrideCoverageNV = 5249, - CapabilityGeometryShaderPassthroughNV = 5251, - CapabilityShaderViewportIndexLayerNV = 5254, - CapabilityShaderViewportMaskNV = 5255, - CapabilityShaderStereoViewNV = 5259, - CapabilityPerViewAttributesNV = 5260, - CapabilityMax = 0x7fffffff, -}; - -enum Op { - OpNop = 0, - OpUndef = 1, - OpSourceContinued = 2, - OpSource = 3, - OpSourceExtension = 4, - OpName = 5, - OpMemberName = 6, - OpString = 7, - OpLine = 8, - OpExtension = 10, - OpExtInstImport = 11, - OpExtInst = 12, - OpMemoryModel = 14, - OpEntryPoint = 15, - OpExecutionMode = 16, - OpCapability = 17, - OpTypeVoid = 19, - OpTypeBool = 20, - OpTypeInt = 21, - OpTypeFloat = 22, - OpTypeVector = 23, - OpTypeMatrix = 24, - OpTypeImage = 25, - OpTypeSampler = 26, - OpTypeSampledImage = 27, - OpTypeArray = 28, - OpTypeRuntimeArray = 29, - OpTypeStruct = 30, - OpTypeOpaque = 31, - OpTypePointer = 32, - OpTypeFunction = 33, - OpTypeEvent = 34, - OpTypeDeviceEvent = 35, - OpTypeReserveId = 36, - OpTypeQueue = 37, - OpTypePipe = 38, - OpTypeForwardPointer = 39, - OpConstantTrue = 41, - OpConstantFalse = 42, - OpConstant = 43, - OpConstantComposite = 44, - OpConstantSampler = 45, - OpConstantNull = 46, - OpSpecConstantTrue = 48, - OpSpecConstantFalse = 49, - OpSpecConstant = 50, - OpSpecConstantComposite = 51, - OpSpecConstantOp = 52, - OpFunction = 54, - OpFunctionParameter = 55, - OpFunctionEnd = 56, - OpFunctionCall = 57, - OpVariable = 59, - OpImageTexelPointer = 60, - OpLoad = 61, - OpStore = 62, - OpCopyMemory = 63, - OpCopyMemorySized = 64, - OpAccessChain = 65, - OpInBoundsAccessChain = 66, - OpPtrAccessChain = 67, - OpArrayLength = 68, - OpGenericPtrMemSemantics = 69, - OpInBoundsPtrAccessChain = 70, - OpDecorate = 71, - OpMemberDecorate = 72, - OpDecorationGroup = 73, - OpGroupDecorate = 74, - OpGroupMemberDecorate = 75, - OpVectorExtractDynamic = 77, - OpVectorInsertDynamic = 78, - OpVectorShuffle = 79, - OpCompositeConstruct = 80, - OpCompositeExtract = 81, - OpCompositeInsert = 82, - OpCopyObject = 83, - OpTranspose = 84, - OpSampledImage = 86, - OpImageSampleImplicitLod = 87, - OpImageSampleExplicitLod = 88, - OpImageSampleDrefImplicitLod = 89, - OpImageSampleDrefExplicitLod = 90, - OpImageSampleProjImplicitLod = 91, - OpImageSampleProjExplicitLod = 92, - OpImageSampleProjDrefImplicitLod = 93, - OpImageSampleProjDrefExplicitLod = 94, - OpImageFetch = 95, - OpImageGather = 96, - OpImageDrefGather = 97, - OpImageRead = 98, - OpImageWrite = 99, - OpImage = 100, - OpImageQueryFormat = 101, - OpImageQueryOrder = 102, - OpImageQuerySizeLod = 103, - OpImageQuerySize = 104, - OpImageQueryLod = 105, - OpImageQueryLevels = 106, - OpImageQuerySamples = 107, - OpConvertFToU = 109, - OpConvertFToS = 110, - OpConvertSToF = 111, - OpConvertUToF = 112, - OpUConvert = 113, - OpSConvert = 114, - OpFConvert = 115, - OpQuantizeToF16 = 116, - OpConvertPtrToU = 117, - OpSatConvertSToU = 118, - OpSatConvertUToS = 119, - OpConvertUToPtr = 120, - OpPtrCastToGeneric = 121, - OpGenericCastToPtr = 122, - OpGenericCastToPtrExplicit = 123, - OpBitcast = 124, - OpSNegate = 126, - OpFNegate = 127, - OpIAdd = 128, - OpFAdd = 129, - OpISub = 130, - OpFSub = 131, - OpIMul = 132, - OpFMul = 133, - OpUDiv = 134, - OpSDiv = 135, - OpFDiv = 136, - OpUMod = 137, - OpSRem = 138, - OpSMod = 139, - OpFRem = 140, - OpFMod = 141, - OpVectorTimesScalar = 142, - OpMatrixTimesScalar = 143, - OpVectorTimesMatrix = 144, - OpMatrixTimesVector = 145, - OpMatrixTimesMatrix = 146, - OpOuterProduct = 147, - OpDot = 148, - OpIAddCarry = 149, - OpISubBorrow = 150, - OpUMulExtended = 151, - OpSMulExtended = 152, - OpAny = 154, - OpAll = 155, - OpIsNan = 156, - OpIsInf = 157, - OpIsFinite = 158, - OpIsNormal = 159, - OpSignBitSet = 160, - OpLessOrGreater = 161, - OpOrdered = 162, - OpUnordered = 163, - OpLogicalEqual = 164, - OpLogicalNotEqual = 165, - OpLogicalOr = 166, - OpLogicalAnd = 167, - OpLogicalNot = 168, - OpSelect = 169, - OpIEqual = 170, - OpINotEqual = 171, - OpUGreaterThan = 172, - OpSGreaterThan = 173, - OpUGreaterThanEqual = 174, - OpSGreaterThanEqual = 175, - OpULessThan = 176, - OpSLessThan = 177, - OpULessThanEqual = 178, - OpSLessThanEqual = 179, - OpFOrdEqual = 180, - OpFUnordEqual = 181, - OpFOrdNotEqual = 182, - OpFUnordNotEqual = 183, - OpFOrdLessThan = 184, - OpFUnordLessThan = 185, - OpFOrdGreaterThan = 186, - OpFUnordGreaterThan = 187, - OpFOrdLessThanEqual = 188, - OpFUnordLessThanEqual = 189, - OpFOrdGreaterThanEqual = 190, - OpFUnordGreaterThanEqual = 191, - OpShiftRightLogical = 194, - OpShiftRightArithmetic = 195, - OpShiftLeftLogical = 196, - OpBitwiseOr = 197, - OpBitwiseXor = 198, - OpBitwiseAnd = 199, - OpNot = 200, - OpBitFieldInsert = 201, - OpBitFieldSExtract = 202, - OpBitFieldUExtract = 203, - OpBitReverse = 204, - OpBitCount = 205, - OpDPdx = 207, - OpDPdy = 208, - OpFwidth = 209, - OpDPdxFine = 210, - OpDPdyFine = 211, - OpFwidthFine = 212, - OpDPdxCoarse = 213, - OpDPdyCoarse = 214, - OpFwidthCoarse = 215, - OpEmitVertex = 218, - OpEndPrimitive = 219, - OpEmitStreamVertex = 220, - OpEndStreamPrimitive = 221, - OpControlBarrier = 224, - OpMemoryBarrier = 225, - OpAtomicLoad = 227, - OpAtomicStore = 228, - OpAtomicExchange = 229, - OpAtomicCompareExchange = 230, - OpAtomicCompareExchangeWeak = 231, - OpAtomicIIncrement = 232, - OpAtomicIDecrement = 233, - OpAtomicIAdd = 234, - OpAtomicISub = 235, - OpAtomicSMin = 236, - OpAtomicUMin = 237, - OpAtomicSMax = 238, - OpAtomicUMax = 239, - OpAtomicAnd = 240, - OpAtomicOr = 241, - OpAtomicXor = 242, - OpPhi = 245, - OpLoopMerge = 246, - OpSelectionMerge = 247, - OpLabel = 248, - OpBranch = 249, - OpBranchConditional = 250, - OpSwitch = 251, - OpKill = 252, - OpReturn = 253, - OpReturnValue = 254, - OpUnreachable = 255, - OpLifetimeStart = 256, - OpLifetimeStop = 257, - OpGroupAsyncCopy = 259, - OpGroupWaitEvents = 260, - OpGroupAll = 261, - OpGroupAny = 262, - OpGroupBroadcast = 263, - OpGroupIAdd = 264, - OpGroupFAdd = 265, - OpGroupFMin = 266, - OpGroupUMin = 267, - OpGroupSMin = 268, - OpGroupFMax = 269, - OpGroupUMax = 270, - OpGroupSMax = 271, - OpReadPipe = 274, - OpWritePipe = 275, - OpReservedReadPipe = 276, - OpReservedWritePipe = 277, - OpReserveReadPipePackets = 278, - OpReserveWritePipePackets = 279, - OpCommitReadPipe = 280, - OpCommitWritePipe = 281, - OpIsValidReserveId = 282, - OpGetNumPipePackets = 283, - OpGetMaxPipePackets = 284, - OpGroupReserveReadPipePackets = 285, - OpGroupReserveWritePipePackets = 286, - OpGroupCommitReadPipe = 287, - OpGroupCommitWritePipe = 288, - OpEnqueueMarker = 291, - OpEnqueueKernel = 292, - OpGetKernelNDrangeSubGroupCount = 293, - OpGetKernelNDrangeMaxSubGroupSize = 294, - OpGetKernelWorkGroupSize = 295, - OpGetKernelPreferredWorkGroupSizeMultiple = 296, - OpRetainEvent = 297, - OpReleaseEvent = 298, - OpCreateUserEvent = 299, - OpIsValidEvent = 300, - OpSetUserEventStatus = 301, - OpCaptureEventProfilingInfo = 302, - OpGetDefaultQueue = 303, - OpBuildNDRange = 304, - OpImageSparseSampleImplicitLod = 305, - OpImageSparseSampleExplicitLod = 306, - OpImageSparseSampleDrefImplicitLod = 307, - OpImageSparseSampleDrefExplicitLod = 308, - OpImageSparseSampleProjImplicitLod = 309, - OpImageSparseSampleProjExplicitLod = 310, - OpImageSparseSampleProjDrefImplicitLod = 311, - OpImageSparseSampleProjDrefExplicitLod = 312, - OpImageSparseFetch = 313, - OpImageSparseGather = 314, - OpImageSparseDrefGather = 315, - OpImageSparseTexelsResident = 316, - OpNoLine = 317, - OpAtomicFlagTestAndSet = 318, - OpAtomicFlagClear = 319, - OpImageSparseRead = 320, - OpSubgroupBallotKHR = 4421, - OpSubgroupFirstInvocationKHR = 4422, - OpSubgroupAllKHR = 4428, - OpSubgroupAnyKHR = 4429, - OpSubgroupAllEqualKHR = 4430, - OpSubgroupReadInvocationKHR = 4432, - OpGroupIAddNonUniformAMD = 5000, - OpGroupFAddNonUniformAMD = 5001, - OpGroupFMinNonUniformAMD = 5002, - OpGroupUMinNonUniformAMD = 5003, - OpGroupSMinNonUniformAMD = 5004, - OpGroupFMaxNonUniformAMD = 5005, - OpGroupUMaxNonUniformAMD = 5006, - OpGroupSMaxNonUniformAMD = 5007, - OpFragmentMaskFetchAMD = 5011, - OpFragmentFetchAMD = 5012, - OpMax = 0x7fffffff, -}; - -// Overload operator| for mask bit combining - -inline ImageOperandsMask operator|(ImageOperandsMask a, ImageOperandsMask b) { return ImageOperandsMask(unsigned(a) | unsigned(b)); } -inline FPFastMathModeMask operator|(FPFastMathModeMask a, FPFastMathModeMask b) { return FPFastMathModeMask(unsigned(a) | unsigned(b)); } -inline SelectionControlMask operator|(SelectionControlMask a, SelectionControlMask b) { return SelectionControlMask(unsigned(a) | unsigned(b)); } -inline LoopControlMask operator|(LoopControlMask a, LoopControlMask b) { return LoopControlMask(unsigned(a) | unsigned(b)); } -inline FunctionControlMask operator|(FunctionControlMask a, FunctionControlMask b) { return FunctionControlMask(unsigned(a) | unsigned(b)); } -inline MemorySemanticsMask operator|(MemorySemanticsMask a, MemorySemanticsMask b) { return MemorySemanticsMask(unsigned(a) | unsigned(b)); } -inline MemoryAccessMask operator|(MemoryAccessMask a, MemoryAccessMask b) { return MemoryAccessMask(unsigned(a) | unsigned(b)); } -inline KernelProfilingInfoMask operator|(KernelProfilingInfoMask a, KernelProfilingInfoMask b) { return KernelProfilingInfoMask(unsigned(a) | unsigned(b)); } - -} // end namespace spv - -#endif // #ifndef spirv_HPP - diff --git a/deps/SPIRV-Cross/spirv_cfg.cpp b/deps/SPIRV-Cross/spirv_cfg.cpp deleted file mode 100644 index 815fdee682..0000000000 --- a/deps/SPIRV-Cross/spirv_cfg.cpp +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Copyright 2016-2017 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "spirv_cfg.hpp" -#include "spirv_cross.hpp" -#include -#include - -using namespace std; - -namespace spirv_cross -{ -CFG::CFG(Compiler &compiler_, const SPIRFunction &func_) - : compiler(compiler_) - , func(func_) -{ - preceding_edges.resize(compiler.get_current_id_bound()); - succeeding_edges.resize(compiler.get_current_id_bound()); - visit_order.resize(compiler.get_current_id_bound()); - immediate_dominators.resize(compiler.get_current_id_bound()); - - build_post_order_visit_order(); - build_immediate_dominators(); -} - -uint32_t CFG::find_common_dominator(uint32_t a, uint32_t b) const -{ - while (a != b) - { - if (visit_order[a] < visit_order[b]) - a = immediate_dominators[a]; - else - b = immediate_dominators[b]; - } - return a; -} - -void CFG::build_immediate_dominators() -{ - // Traverse the post-order in reverse and build up the immediate dominator tree. - fill(begin(immediate_dominators), end(immediate_dominators), 0); - immediate_dominators[func.entry_block] = func.entry_block; - - for (auto i = post_order.size(); i; i--) - { - uint32_t block = post_order[i - 1]; - auto &pred = preceding_edges[block]; - if (pred.empty()) // This is for the entry block, but we've already set up the dominators. - continue; - - for (auto &edge : pred) - { - if (immediate_dominators[block]) - { - assert(immediate_dominators[edge]); - immediate_dominators[block] = find_common_dominator(block, edge); - } - else - immediate_dominators[block] = edge; - } - } -} - -bool CFG::is_back_edge(uint32_t to) const -{ - // We have a back edge if the visit order is set with the temporary magic value 0. - // Crossing edges will have already been recorded with a visit order. - return visit_order[to] == 0; -} - -bool CFG::post_order_visit(uint32_t block_id) -{ - // If we have already branched to this block (back edge), stop recursion. - // If our branches are back-edges, we do not record them. - // We have to record crossing edges however. - if (visit_order[block_id] >= 0) - return !is_back_edge(block_id); - - // Block back-edges from recursively revisiting ourselves. - visit_order[block_id] = 0; - - // First visit our branch targets. - auto &block = compiler.get(block_id); - switch (block.terminator) - { - case SPIRBlock::Direct: - if (post_order_visit(block.next_block)) - add_branch(block_id, block.next_block); - break; - - case SPIRBlock::Select: - if (post_order_visit(block.true_block)) - add_branch(block_id, block.true_block); - if (post_order_visit(block.false_block)) - add_branch(block_id, block.false_block); - break; - - case SPIRBlock::MultiSelect: - for (auto &target : block.cases) - { - if (post_order_visit(target.block)) - add_branch(block_id, target.block); - } - if (block.default_block && post_order_visit(block.default_block)) - add_branch(block_id, block.default_block); - break; - - default: - break; - } - - // If this is a loop header, add an implied branch to the merge target. - // This is needed to avoid annoying cases with do { ... } while(false) loops often generated by inliners. - // To the CFG, this is linear control flow, but we risk picking the do/while scope as our dominating block. - // This makes sure that if we are accessing a variable outside the do/while, we choose the loop header as dominator. - if (block.merge == SPIRBlock::MergeLoop) - add_branch(block_id, block.merge_block); - - // Then visit ourselves. Start counting at one, to let 0 be a magic value for testing back vs. crossing edges. - visit_order[block_id] = ++visit_count; - post_order.push_back(block_id); - return true; -} - -void CFG::build_post_order_visit_order() -{ - uint32_t block = func.entry_block; - visit_count = 0; - fill(begin(visit_order), end(visit_order), -1); - post_order.clear(); - post_order_visit(block); -} - -void CFG::add_branch(uint32_t from, uint32_t to) -{ - const auto add_unique = [](vector &l, uint32_t value) { - auto itr = find(begin(l), end(l), value); - if (itr == end(l)) - l.push_back(value); - }; - add_unique(preceding_edges[to], from); - add_unique(succeeding_edges[from], to); -} - -DominatorBuilder::DominatorBuilder(const CFG &cfg_) - : cfg(cfg_) -{ -} - -void DominatorBuilder::add_block(uint32_t block) -{ - if (!cfg.get_immediate_dominator(block)) - { - // Unreachable block via the CFG, we will never emit this code anyways. - return; - } - - if (!dominator) - { - dominator = block; - return; - } - - if (block != dominator) - dominator = cfg.find_common_dominator(block, dominator); -} - -void DominatorBuilder::lift_continue_block_dominator() -{ - // It is possible for a continue block to be the dominator of a variable is only accessed inside the while block of a do-while loop. - // We cannot safely declare variables inside a continue block, so move any variable declared - // in a continue block to the entry block to simplify. - // It makes very little sense for a continue block to ever be a dominator, so fall back to the simplest - // solution. - - if (!dominator) - return; - - auto &block = cfg.get_compiler().get(dominator); - auto post_order = cfg.get_visit_order(dominator); - - // If we are branching to a block with a higher post-order traversal index (continue blocks), we have a problem - // since we cannot create sensible GLSL code for this, fallback to entry block. - bool back_edge_dominator = false; - switch (block.terminator) - { - case SPIRBlock::Direct: - if (cfg.get_visit_order(block.next_block) > post_order) - back_edge_dominator = true; - break; - - case SPIRBlock::Select: - if (cfg.get_visit_order(block.true_block) > post_order) - back_edge_dominator = true; - if (cfg.get_visit_order(block.false_block) > post_order) - back_edge_dominator = true; - break; - - case SPIRBlock::MultiSelect: - for (auto &target : block.cases) - { - if (cfg.get_visit_order(target.block) > post_order) - back_edge_dominator = true; - } - if (block.default_block && cfg.get_visit_order(block.default_block) > post_order) - back_edge_dominator = true; - break; - - default: - break; - } - - if (back_edge_dominator) - dominator = cfg.get_function().entry_block; -} -} diff --git a/deps/SPIRV-Cross/spirv_cfg.hpp b/deps/SPIRV-Cross/spirv_cfg.hpp deleted file mode 100644 index 3f7ec01d33..0000000000 --- a/deps/SPIRV-Cross/spirv_cfg.hpp +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright 2016-2017 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef SPIRV_CROSS_CFG_HPP -#define SPIRV_CROSS_CFG_HPP - -#include "spirv_common.hpp" -#include - -namespace spirv_cross -{ -class Compiler; -class CFG -{ -public: - CFG(Compiler &compiler, const SPIRFunction &function); - - Compiler &get_compiler() - { - return compiler; - } - - const Compiler &get_compiler() const - { - return compiler; - } - - const SPIRFunction &get_function() const - { - return func; - } - - uint32_t get_immediate_dominator(uint32_t block) const - { - return immediate_dominators[block]; - } - - uint32_t get_visit_order(uint32_t block) const - { - int v = visit_order[block]; - assert(v > 0); - return uint32_t(v); - } - - uint32_t find_common_dominator(uint32_t a, uint32_t b) const; - - const std::vector &get_preceding_edges(uint32_t block) const - { - return preceding_edges[block]; - } - - const std::vector &get_succeeding_edges(uint32_t block) const - { - return succeeding_edges[block]; - } - - template - void walk_from(std::unordered_set &seen_blocks, uint32_t block, const Op &op) const - { - if (seen_blocks.count(block)) - return; - seen_blocks.insert(block); - - op(block); - for (auto b : succeeding_edges[block]) - walk_from(seen_blocks, b, op); - } - -private: - Compiler &compiler; - const SPIRFunction &func; - std::vector> preceding_edges; - std::vector> succeeding_edges; - std::vector immediate_dominators; - std::vector visit_order; - std::vector post_order; - - void add_branch(uint32_t from, uint32_t to); - void build_post_order_visit_order(); - void build_immediate_dominators(); - bool post_order_visit(uint32_t block); - uint32_t visit_count = 0; - - bool is_back_edge(uint32_t to) const; -}; - -class DominatorBuilder -{ -public: - DominatorBuilder(const CFG &cfg); - - void add_block(uint32_t block); - uint32_t get_dominator() const - { - return dominator; - } - - void lift_continue_block_dominator(); - -private: - const CFG &cfg; - uint32_t dominator = 0; -}; -} - -#endif diff --git a/deps/SPIRV-Cross/spirv_common.hpp b/deps/SPIRV-Cross/spirv_common.hpp deleted file mode 100644 index eeb8532542..0000000000 --- a/deps/SPIRV-Cross/spirv_common.hpp +++ /dev/null @@ -1,1026 +0,0 @@ -/* - * Copyright 2015-2017 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef SPIRV_CROSS_COMMON_HPP -#define SPIRV_CROSS_COMMON_HPP - -#include "spirv.hpp" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace spirv_cross -{ - -#ifdef SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS -#ifndef _MSC_VER -[[noreturn]] -#endif - inline void - report_and_abort(const std::string &msg) -{ -#ifdef NDEBUG - (void)msg; -#else - fprintf(stderr, "There was a compiler error: %s\n", msg.c_str()); -#endif - fflush(stderr); - abort(); -} - -#define SPIRV_CROSS_THROW(x) report_and_abort(x) -#else -class CompilerError : public std::runtime_error -{ -public: - CompilerError(const std::string &str) - : std::runtime_error(str) - { - } -}; - -#define SPIRV_CROSS_THROW(x) throw CompilerError(x) -#endif - -#if __cplusplus >= 201402l -#define SPIRV_CROSS_DEPRECATED(reason) [[deprecated(reason)]] -#elif defined(__GNUC__) -#define SPIRV_CROSS_DEPRECATED(reason) __attribute__((deprecated)) -#elif defined(_MSC_VER) -#define SPIRV_CROSS_DEPRECATED(reason) __declspec(deprecated(reason)) -#else -#define SPIRV_CROSS_DEPRECATED(reason) -#endif - -namespace inner -{ -template -void join_helper(std::ostringstream &stream, T &&t) -{ - stream << std::forward(t); -} - -template -void join_helper(std::ostringstream &stream, T &&t, Ts &&... ts) -{ - stream << std::forward(t); - join_helper(stream, std::forward(ts)...); -} -} - -// Helper template to avoid lots of nasty string temporary munging. -template -std::string join(Ts &&... ts) -{ - std::ostringstream stream; - inner::join_helper(stream, std::forward(ts)...); - return stream.str(); -} - -inline std::string merge(const std::vector &list) -{ - std::string s; - for (auto &elem : list) - { - s += elem; - if (&elem != &list.back()) - s += ", "; - } - return s; -} - -template -inline std::string convert_to_string(T &&t) -{ - return std::to_string(std::forward(t)); -} - -// Allow implementations to set a convenient standard precision -#ifndef SPIRV_CROSS_FLT_FMT -#define SPIRV_CROSS_FLT_FMT "%.32g" -#endif - -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4996) -#endif - -inline std::string convert_to_string(float t) -{ - // std::to_string for floating point values is broken. - // Fallback to something more sane. - char buf[64]; - sprintf(buf, SPIRV_CROSS_FLT_FMT, t); - // Ensure that the literal is float. - if (!strchr(buf, '.') && !strchr(buf, 'e')) - strcat(buf, ".0"); - return buf; -} - -inline std::string convert_to_string(double t) -{ - // std::to_string for floating point values is broken. - // Fallback to something more sane. - char buf[64]; - sprintf(buf, SPIRV_CROSS_FLT_FMT, t); - // Ensure that the literal is float. - if (!strchr(buf, '.') && !strchr(buf, 'e')) - strcat(buf, ".0"); - return buf; -} - -#ifdef _MSC_VER -#pragma warning(pop) -#endif - -struct Instruction -{ - Instruction(const std::vector &spirv, uint32_t &index); - - uint16_t op; - uint16_t count; - uint32_t offset; - uint32_t length; -}; - -// Helper for Variant interface. -struct IVariant -{ - virtual ~IVariant() = default; - uint32_t self = 0; -}; - -enum Types -{ - TypeNone, - TypeType, - TypeVariable, - TypeConstant, - TypeFunction, - TypeFunctionPrototype, - TypePointer, - TypeBlock, - TypeExtension, - TypeExpression, - TypeConstantOp, - TypeCombinedImageSampler, - TypeAccessChain, - TypeUndef -}; - -struct SPIRUndef : IVariant -{ - enum - { - type = TypeUndef - }; - SPIRUndef(uint32_t basetype_) - : basetype(basetype_) - { - } - uint32_t basetype; -}; - -// This type is only used by backends which need to access the combined image and sampler IDs separately after -// the OpSampledImage opcode. -struct SPIRCombinedImageSampler : IVariant -{ - enum - { - type = TypeCombinedImageSampler - }; - SPIRCombinedImageSampler(uint32_t type_, uint32_t image_, uint32_t sampler_) - : combined_type(type_) - , image(image_) - , sampler(sampler_) - { - } - uint32_t combined_type; - uint32_t image; - uint32_t sampler; -}; - -struct SPIRConstantOp : IVariant -{ - enum - { - type = TypeConstantOp - }; - - SPIRConstantOp(uint32_t result_type, spv::Op op, const uint32_t *args, uint32_t length) - : opcode(op) - , arguments(args, args + length) - , basetype(result_type) - { - } - - spv::Op opcode; - std::vector arguments; - uint32_t basetype; -}; - -struct SPIRType : IVariant -{ - enum - { - type = TypeType - }; - - enum BaseType - { - Unknown, - Void, - Boolean, - Char, - Int, - UInt, - Int64, - UInt64, - AtomicCounter, - Float, - Double, - Struct, - Image, - SampledImage, - Sampler - }; - - // Scalar/vector/matrix support. - BaseType basetype = Unknown; - uint32_t width = 0; - uint32_t vecsize = 1; - uint32_t columns = 1; - - // Arrays, support array of arrays by having a vector of array sizes. - std::vector array; - - // Array elements can be either specialization constants or specialization ops. - // This array determines how to interpret the array size. - // If an element is true, the element is a literal, - // otherwise, it's an expression, which must be resolved on demand. - // The actual size is not really known until runtime. - std::vector array_size_literal; - - // Pointers - bool pointer = false; - spv::StorageClass storage = spv::StorageClassGeneric; - - std::vector member_types; - - struct ImageType - { - uint32_t type; - spv::Dim dim; - bool depth; - bool arrayed; - bool ms; - uint32_t sampled; - spv::ImageFormat format; - spv::AccessQualifier access; - } image; - - // Structs can be declared multiple times if they are used as part of interface blocks. - // We want to detect this so that we only emit the struct definition once. - // Since we cannot rely on OpName to be equal, we need to figure out aliases. - uint32_t type_alias = 0; - - // Denotes the type which this type is based on. - // Allows the backend to traverse how a complex type is built up during access chains. - uint32_t parent_type = 0; - - // Used in backends to avoid emitting members with conflicting names. - std::unordered_set member_name_cache; -}; - -struct SPIRExtension : IVariant -{ - enum - { - type = TypeExtension - }; - - enum Extension - { - Unsupported, - GLSL, - SPV_AMD_shader_ballot, - SPV_AMD_shader_explicit_vertex_parameter, - SPV_AMD_shader_trinary_minmax, - SPV_AMD_gcn_shader - }; - - SPIRExtension(Extension ext_) - : ext(ext_) - { - } - - Extension ext; -}; - -// SPIREntryPoint is not a variant since its IDs are used to decorate OpFunction, -// so in order to avoid conflicts, we can't stick them in the ids array. -struct SPIREntryPoint -{ - SPIREntryPoint(uint32_t self_, spv::ExecutionModel execution_model, const std::string &entry_name) - : self(self_) - , name(entry_name) - , orig_name(entry_name) - , model(execution_model) - { - } - SPIREntryPoint() = default; - - uint32_t self = 0; - std::string name; - std::string orig_name; - std::vector interface_variables; - - uint64_t flags = 0; - struct - { - uint32_t x = 0, y = 0, z = 0; - uint32_t constant = 0; // Workgroup size can be expressed as a constant/spec-constant instead. - } workgroup_size; - uint32_t invocations = 0; - uint32_t output_vertices = 0; - spv::ExecutionModel model; -}; - -struct SPIRExpression : IVariant -{ - enum - { - type = TypeExpression - }; - - // Only created by the backend target to avoid creating tons of temporaries. - SPIRExpression(std::string expr, uint32_t expression_type_, bool immutable_) - : expression(move(expr)) - , expression_type(expression_type_) - , immutable(immutable_) - { - } - - // If non-zero, prepend expression with to_expression(base_expression). - // Used in amortizing multiple calls to to_expression() - // where in certain cases that would quickly force a temporary when not needed. - uint32_t base_expression = 0; - - std::string expression; - uint32_t expression_type = 0; - - // If this expression is a forwarded load, - // allow us to reference the original variable. - uint32_t loaded_from = 0; - - // If this expression will never change, we can avoid lots of temporaries - // in high level source. - // An expression being immutable can be speculative, - // it is assumed that this is true almost always. - bool immutable = false; - - // Before use, this expression must be transposed. - // This is needed for targets which don't support row_major layouts. - bool need_transpose = false; - - // A list of expressions which this expression depends on. - std::vector expression_dependencies; -}; - -struct SPIRFunctionPrototype : IVariant -{ - enum - { - type = TypeFunctionPrototype - }; - - SPIRFunctionPrototype(uint32_t return_type_) - : return_type(return_type_) - { - } - - uint32_t return_type; - std::vector parameter_types; -}; - -struct SPIRBlock : IVariant -{ - enum - { - type = TypeBlock - }; - - enum Terminator - { - Unknown, - Direct, // Emit next block directly without a particular condition. - - Select, // Block ends with an if/else block. - MultiSelect, // Block ends with switch statement. - - Return, // Block ends with return. - Unreachable, // Noop - Kill // Discard - }; - - enum Merge - { - MergeNone, - MergeLoop, - MergeSelection - }; - - enum Method - { - MergeToSelectForLoop, - MergeToDirectForLoop - }; - - enum ContinueBlockType - { - ContinueNone, - - // Continue block is branchless and has at least one instruction. - ForLoop, - - // Noop continue block. - WhileLoop, - - // Continue block is conditional. - DoWhileLoop, - - // Highly unlikely that anything will use this, - // since it is really awkward/impossible to express in GLSL. - ComplexLoop - }; - - enum - { - NoDominator = 0xffffffffu - }; - - Terminator terminator = Unknown; - Merge merge = MergeNone; - uint32_t next_block = 0; - uint32_t merge_block = 0; - uint32_t continue_block = 0; - - uint32_t return_value = 0; // If 0, return nothing (void). - uint32_t condition = 0; - uint32_t true_block = 0; - uint32_t false_block = 0; - uint32_t default_block = 0; - - std::vector ops; - - struct Phi - { - uint32_t local_variable; // flush local variable ... - uint32_t parent; // If we're in from_block and want to branch into this block ... - uint32_t function_variable; // to this function-global "phi" variable first. - }; - - // Before entering this block flush out local variables to magical "phi" variables. - std::vector phi_variables; - - // Declare these temporaries before beginning the block. - // Used for handling complex continue blocks which have side effects. - std::vector> declare_temporary; - - struct Case - { - uint32_t value; - uint32_t block; - }; - std::vector cases; - - // If we have tried to optimize code for this block but failed, - // keep track of this. - bool disable_block_optimization = false; - - // If the continue block is complex, fallback to "dumb" for loops. - bool complex_continue = false; - - // The dominating block which this block might be within. - // Used in continue; blocks to determine if we really need to write continue. - uint32_t loop_dominator = 0; - - // All access to these variables are dominated by this block, - // so before branching anywhere we need to make sure that we declare these variables. - std::vector dominated_variables; - - // These are variables which should be declared in a for loop header, if we - // fail to use a classic for-loop, - // we remove these variables, and fall back to regular variables outside the loop. - std::vector loop_variables; -}; - -struct SPIRFunction : IVariant -{ - enum - { - type = TypeFunction - }; - - SPIRFunction(uint32_t return_type_, uint32_t function_type_) - : return_type(return_type_) - , function_type(function_type_) - { - } - - struct Parameter - { - uint32_t type; - uint32_t id; - uint32_t read_count; - uint32_t write_count; - - // Set to true if this parameter aliases a global variable, - // used mostly in Metal where global variables - // have to be passed down to functions as regular arguments. - // However, for this kind of variable, we should not care about - // read and write counts as access to the function arguments - // is not local to the function in question. - bool alias_global_variable; - }; - - // When calling a function, and we're remapping separate image samplers, - // resolve these arguments into combined image samplers and pass them - // as additional arguments in this order. - // It gets more complicated as functions can pull in their own globals - // and combine them with parameters, - // so we need to distinguish if something is local parameter index - // or a global ID. - struct CombinedImageSamplerParameter - { - uint32_t id; - uint32_t image_id; - uint32_t sampler_id; - bool global_image; - bool global_sampler; - bool depth; - }; - - uint32_t return_type; - uint32_t function_type; - std::vector arguments; - - // Can be used by backends to add magic arguments. - // Currently used by combined image/sampler implementation. - - std::vector shadow_arguments; - std::vector local_variables; - uint32_t entry_block = 0; - std::vector blocks; - std::vector combined_parameters; - - void add_local_variable(uint32_t id) - { - local_variables.push_back(id); - } - - void add_parameter(uint32_t parameter_type, uint32_t id, bool alias_global_variable = false) - { - // Arguments are read-only until proven otherwise. - arguments.push_back({ parameter_type, id, 0u, 0u, alias_global_variable }); - } - - bool active = false; - bool flush_undeclared = true; - bool do_combined_parameters = true; - bool analyzed_variable_scope = false; -}; - -struct SPIRAccessChain : IVariant -{ - enum - { - type = TypeAccessChain - }; - - SPIRAccessChain(uint32_t basetype_, spv::StorageClass storage_, std::string base_, std::string dynamic_index_, - int32_t static_index_) - : basetype(basetype_) - , storage(storage_) - , base(base_) - , dynamic_index(std::move(dynamic_index_)) - , static_index(static_index_) - { - } - - // The access chain represents an offset into a buffer. - // Some backends need more complicated handling of access chains to be able to use buffers, like HLSL - // which has no usable buffer type ala GLSL SSBOs. - // StructuredBuffer is too limited, so our only option is to deal with ByteAddressBuffer which works with raw addresses. - - uint32_t basetype; - spv::StorageClass storage; - std::string base; - std::string dynamic_index; - int32_t static_index; - - uint32_t loaded_from = 0; - uint32_t matrix_stride = 0; - bool row_major_matrix = false; - bool immutable = false; -}; - -struct SPIRVariable : IVariant -{ - enum - { - type = TypeVariable - }; - - SPIRVariable() = default; - SPIRVariable(uint32_t basetype_, spv::StorageClass storage_, uint32_t initializer_ = 0, uint32_t basevariable_ = 0) - : basetype(basetype_) - , storage(storage_) - , initializer(initializer_) - , basevariable(basevariable_) - { - } - - uint32_t basetype = 0; - spv::StorageClass storage = spv::StorageClassGeneric; - uint32_t decoration = 0; - uint32_t initializer = 0; - uint32_t basevariable = 0; - - std::vector dereference_chain; - bool compat_builtin = false; - - // If a variable is shadowed, we only statically assign to it - // and never actually emit a statement for it. - // When we read the variable as an expression, just forward - // shadowed_id as the expression. - bool statically_assigned = false; - uint32_t static_expression = 0; - - // Temporaries which can remain forwarded as long as this variable is not modified. - std::vector dependees; - bool forwardable = true; - - bool deferred_declaration = false; - bool phi_variable = false; - bool remapped_variable = false; - uint32_t remapped_components = 0; - - // The block which dominates all access to this variable. - uint32_t dominator = 0; - // If true, this variable is a loop variable, when accessing the variable - // outside a loop, - // we should statically forward it. - bool loop_variable = false; - // Set to true while we're inside the for loop. - bool loop_variable_enable = false; - - SPIRFunction::Parameter *parameter = nullptr; -}; - -struct SPIRConstant : IVariant -{ - enum - { - type = TypeConstant - }; - - union Constant { - uint32_t u32; - int32_t i32; - float f32; - - uint64_t u64; - int64_t i64; - double f64; - }; - - struct ConstantVector - { - Constant r[4]; - // If != 0, this element is a specialization constant, and we should keep track of it as such. - uint32_t id[4] = {}; - uint32_t vecsize = 1; - }; - - struct ConstantMatrix - { - ConstantVector c[4]; - // If != 0, this column is a specialization constant, and we should keep track of it as such. - uint32_t id[4] = {}; - uint32_t columns = 1; - }; - - inline uint32_t specialization_constant_id(uint32_t col, uint32_t row) const - { - return m.c[col].id[row]; - } - - inline uint32_t specialization_constant_id(uint32_t col) const - { - return m.id[col]; - } - - inline uint32_t scalar(uint32_t col = 0, uint32_t row = 0) const - { - return m.c[col].r[row].u32; - } - - inline float scalar_f32(uint32_t col = 0, uint32_t row = 0) const - { - return m.c[col].r[row].f32; - } - - inline int32_t scalar_i32(uint32_t col = 0, uint32_t row = 0) const - { - return m.c[col].r[row].i32; - } - - inline double scalar_f64(uint32_t col = 0, uint32_t row = 0) const - { - return m.c[col].r[row].f64; - } - - inline int64_t scalar_i64(uint32_t col = 0, uint32_t row = 0) const - { - return m.c[col].r[row].i64; - } - - inline uint64_t scalar_u64(uint32_t col = 0, uint32_t row = 0) const - { - return m.c[col].r[row].u64; - } - - inline const ConstantVector &vector() const - { - return m.c[0]; - } - - inline uint32_t vector_size() const - { - return m.c[0].vecsize; - } - - inline uint32_t columns() const - { - return m.columns; - } - - inline void make_null(const SPIRType &constant_type_) - { - std::memset(&m, 0, sizeof(m)); - m.columns = constant_type_.columns; - for (auto &c : m.c) - c.vecsize = constant_type_.vecsize; - } - - explicit SPIRConstant(uint32_t constant_type_) - : constant_type(constant_type_) - { - } - - SPIRConstant(uint32_t constant_type_, const uint32_t *elements, uint32_t num_elements, bool specialized) - : constant_type(constant_type_) - , specialization(specialized) - { - subconstants.insert(end(subconstants), elements, elements + num_elements); - specialization = specialized; - } - - // Construct scalar (32-bit). - SPIRConstant(uint32_t constant_type_, uint32_t v0, bool specialized) - : constant_type(constant_type_) - , specialization(specialized) - { - m.c[0].r[0].u32 = v0; - m.c[0].vecsize = 1; - m.columns = 1; - } - - // Construct scalar (64-bit). - SPIRConstant(uint32_t constant_type_, uint64_t v0, bool specialized) - : constant_type(constant_type_) - , specialization(specialized) - { - m.c[0].r[0].u64 = v0; - m.c[0].vecsize = 1; - m.columns = 1; - } - - // Construct vectors and matrices. - SPIRConstant(uint32_t constant_type_, const SPIRConstant *const *vector_elements, uint32_t num_elements, - bool specialized) - : constant_type(constant_type_) - , specialization(specialized) - { - bool matrix = vector_elements[0]->m.c[0].vecsize > 1; - - if (matrix) - { - m.columns = num_elements; - - for (uint32_t i = 0; i < num_elements; i++) - { - m.c[i] = vector_elements[i]->m.c[0]; - if (vector_elements[i]->specialization) - m.id[i] = vector_elements[i]->self; - } - } - else - { - m.c[0].vecsize = num_elements; - m.columns = 1; - - for (uint32_t i = 0; i < num_elements; i++) - { - m.c[0].r[i] = vector_elements[i]->m.c[0].r[0]; - if (vector_elements[i]->specialization) - m.c[0].id[i] = vector_elements[i]->self; - } - } - } - - uint32_t constant_type; - ConstantMatrix m; - bool specialization = false; // If this constant is a specialization constant (i.e. created with OpSpecConstant*). - bool is_used_as_array_length = - false; // If this constant is used as an array length which creates specialization restrictions on some backends. - - // For composites which are constant arrays, etc. - std::vector subconstants; -}; - -class Variant -{ -public: - // MSVC 2013 workaround, we shouldn't need these constructors. - Variant() = default; - Variant(Variant &&other) - { - *this = std::move(other); - } - Variant &operator=(Variant &&other) - { - if (this != &other) - { - holder = move(other.holder); - type = other.type; - other.type = TypeNone; - } - return *this; - } - - void set(std::unique_ptr val, uint32_t new_type) - { - holder = std::move(val); - if (type != TypeNone && type != new_type) - SPIRV_CROSS_THROW("Overwriting a variant with new type."); - type = new_type; - } - - template - T &get() - { - if (!holder) - SPIRV_CROSS_THROW("nullptr"); - if (T::type != type) - SPIRV_CROSS_THROW("Bad cast"); - return *static_cast(holder.get()); - } - - template - const T &get() const - { - if (!holder) - SPIRV_CROSS_THROW("nullptr"); - if (T::type != type) - SPIRV_CROSS_THROW("Bad cast"); - return *static_cast(holder.get()); - } - - uint32_t get_type() const - { - return type; - } - uint32_t get_id() const - { - return holder ? holder->self : 0; - } - bool empty() const - { - return !holder; - } - void reset() - { - holder.reset(); - type = TypeNone; - } - -private: - std::unique_ptr holder; - uint32_t type = TypeNone; -}; - -template -T &variant_get(Variant &var) -{ - return var.get(); -} - -template -const T &variant_get(const Variant &var) -{ - return var.get(); -} - -template -T &variant_set(Variant &var, P &&... args) -{ - auto uptr = std::unique_ptr(new T(std::forward

(args)...)); - auto ptr = uptr.get(); - var.set(std::move(uptr), T::type); - return *ptr; -} - -struct Meta -{ - struct Decoration - { - std::string alias; - std::string qualified_alias; - uint64_t decoration_flags = 0; - spv::BuiltIn builtin_type; - uint32_t location = 0; - uint32_t set = 0; - uint32_t binding = 0; - uint32_t offset = 0; - uint32_t array_stride = 0; - uint32_t matrix_stride = 0; - uint32_t input_attachment = 0; - uint32_t spec_id = 0; - bool builtin = false; - }; - - Decoration decoration; - std::vector members; - uint32_t sampler = 0; - - std::unordered_map decoration_word_offset; - - // Used when the parser has detected a candidate identifier which matches - // known "magic" counter buffers as emitted by HLSL frontends. - // We will need to match the identifiers by name later when reflecting resources. - // We could use the regular alias later, but the alias will be mangled when parsing SPIR-V because the identifier - // is not a valid identifier in any high-level language. - std::string hlsl_magic_counter_buffer_name; - bool hlsl_magic_counter_buffer_candidate = false; -}; - -// A user callback that remaps the type of any variable. -// var_name is the declared name of the variable. -// name_of_type is the textual name of the type which will be used in the code unless written to by the callback. -using VariableTypeRemapCallback = - std::function; - -class ClassicLocale -{ -public: - ClassicLocale() - { - old = std::locale::global(std::locale::classic()); - } - ~ClassicLocale() - { - std::locale::global(old); - } - -private: - std::locale old; -}; -} - -#endif diff --git a/deps/SPIRV-Cross/spirv_cpp.cpp b/deps/SPIRV-Cross/spirv_cpp.cpp deleted file mode 100644 index 45f6d6a273..0000000000 --- a/deps/SPIRV-Cross/spirv_cpp.cpp +++ /dev/null @@ -1,522 +0,0 @@ -/* - * Copyright 2015-2017 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "spirv_cpp.hpp" - -using namespace spv; -using namespace spirv_cross; -using namespace std; - -void CompilerCPP::emit_buffer_block(const SPIRVariable &var) -{ - add_resource_name(var.self); - - auto &type = get(var.basetype); - auto instance_name = to_name(var.self); - - uint32_t descriptor_set = meta[var.self].decoration.set; - uint32_t binding = meta[var.self].decoration.binding; - - emit_block_struct(type); - auto buffer_name = to_name(type.self); - - statement("internal::Resource<", buffer_name, type_to_array_glsl(type), "> ", instance_name, "__;"); - statement_no_indent("#define ", instance_name, " __res->", instance_name, "__.get()"); - resource_registrations.push_back( - join("s.register_resource(", instance_name, "__", ", ", descriptor_set, ", ", binding, ");")); - statement(""); -} - -void CompilerCPP::emit_interface_block(const SPIRVariable &var) -{ - add_resource_name(var.self); - - auto &type = get(var.basetype); - - const char *qual = var.storage == StorageClassInput ? "StageInput" : "StageOutput"; - const char *lowerqual = var.storage == StorageClassInput ? "stage_input" : "stage_output"; - auto instance_name = to_name(var.self); - uint32_t location = meta[var.self].decoration.location; - - string buffer_name; - auto flags = meta[type.self].decoration.decoration_flags; - if (flags & (1ull << DecorationBlock)) - { - emit_block_struct(type); - buffer_name = to_name(type.self); - } - else - buffer_name = type_to_glsl(type); - - statement("internal::", qual, "<", buffer_name, type_to_array_glsl(type), "> ", instance_name, "__;"); - statement_no_indent("#define ", instance_name, " __res->", instance_name, "__.get()"); - resource_registrations.push_back(join("s.register_", lowerqual, "(", instance_name, "__", ", ", location, ");")); - statement(""); -} - -void CompilerCPP::emit_shared(const SPIRVariable &var) -{ - add_resource_name(var.self); - - auto instance_name = to_name(var.self); - statement(CompilerGLSL::variable_decl(var), ";"); - statement_no_indent("#define ", instance_name, " __res->", instance_name); -} - -void CompilerCPP::emit_uniform(const SPIRVariable &var) -{ - add_resource_name(var.self); - - auto &type = get(var.basetype); - auto instance_name = to_name(var.self); - - uint32_t descriptor_set = meta[var.self].decoration.set; - uint32_t binding = meta[var.self].decoration.binding; - uint32_t location = meta[var.self].decoration.location; - - string type_name = type_to_glsl(type); - remap_variable_type_name(type, instance_name, type_name); - - if (type.basetype == SPIRType::Image || type.basetype == SPIRType::SampledImage || - type.basetype == SPIRType::AtomicCounter) - { - statement("internal::Resource<", type_name, type_to_array_glsl(type), "> ", instance_name, "__;"); - statement_no_indent("#define ", instance_name, " __res->", instance_name, "__.get()"); - resource_registrations.push_back( - join("s.register_resource(", instance_name, "__", ", ", descriptor_set, ", ", binding, ");")); - } - else - { - statement("internal::UniformConstant<", type_name, type_to_array_glsl(type), "> ", instance_name, "__;"); - statement_no_indent("#define ", instance_name, " __res->", instance_name, "__.get()"); - resource_registrations.push_back( - join("s.register_uniform_constant(", instance_name, "__", ", ", location, ");")); - } - - statement(""); -} - -void CompilerCPP::emit_push_constant_block(const SPIRVariable &var) -{ - add_resource_name(var.self); - - auto &type = get(var.basetype); - auto &flags = meta[var.self].decoration.decoration_flags; - if ((flags & (1ull << DecorationBinding)) || (flags & (1ull << DecorationDescriptorSet))) - SPIRV_CROSS_THROW("Push constant blocks cannot be compiled to GLSL with Binding or Set syntax. " - "Remap to location with reflection API first or disable these decorations."); - - emit_block_struct(type); - auto buffer_name = to_name(type.self); - auto instance_name = to_name(var.self); - - statement("internal::PushConstant<", buffer_name, type_to_array_glsl(type), "> ", instance_name, ";"); - statement_no_indent("#define ", instance_name, " __res->", instance_name, ".get()"); - resource_registrations.push_back(join("s.register_push_constant(", instance_name, "__", ");")); - statement(""); -} - -void CompilerCPP::emit_block_struct(SPIRType &type) -{ - // C++ can't do interface blocks, so we fake it by emitting a separate struct. - // However, these structs are not allowed to alias anything, so remove it before - // emitting the struct. - // - // The type we have here needs to be resolved to the non-pointer type so we can remove aliases. - auto &self = get(type.self); - self.type_alias = 0; - emit_struct(self); -} - -void CompilerCPP::emit_resources() -{ - // Output all basic struct types which are not Block or BufferBlock as these are declared inplace - // when such variables are instantiated. - for (auto &id : ids) - { - if (id.get_type() == TypeType) - { - auto &type = id.get(); - if (type.basetype == SPIRType::Struct && type.array.empty() && !type.pointer && - (meta[type.self].decoration.decoration_flags & - ((1ull << DecorationBlock) | (1ull << DecorationBufferBlock))) == 0) - { - emit_struct(type); - } - } - } - - statement("struct Resources : ", resource_type); - begin_scope(); - - // Output UBOs and SSBOs - for (auto &id : ids) - { - if (id.get_type() == TypeVariable) - { - auto &var = id.get(); - auto &type = get(var.basetype); - - if (var.storage != StorageClassFunction && type.pointer && type.storage == StorageClassUniform && - !is_hidden_variable(var) && - (meta[type.self].decoration.decoration_flags & - ((1ull << DecorationBlock) | (1ull << DecorationBufferBlock)))) - { - emit_buffer_block(var); - } - } - } - - // Output push constant blocks - for (auto &id : ids) - { - if (id.get_type() == TypeVariable) - { - auto &var = id.get(); - auto &type = get(var.basetype); - if (!is_hidden_variable(var) && var.storage != StorageClassFunction && type.pointer && - type.storage == StorageClassPushConstant) - { - emit_push_constant_block(var); - } - } - } - - // Output in/out interfaces. - for (auto &id : ids) - { - if (id.get_type() == TypeVariable) - { - auto &var = id.get(); - auto &type = get(var.basetype); - - if (var.storage != StorageClassFunction && !is_hidden_variable(var) && type.pointer && - (var.storage == StorageClassInput || var.storage == StorageClassOutput) && - interface_variable_exists_in_entry_point(var.self)) - { - emit_interface_block(var); - } - } - } - - // Output Uniform Constants (values, samplers, images, etc). - for (auto &id : ids) - { - if (id.get_type() == TypeVariable) - { - auto &var = id.get(); - auto &type = get(var.basetype); - - if (var.storage != StorageClassFunction && !is_hidden_variable(var) && type.pointer && - (type.storage == StorageClassUniformConstant || type.storage == StorageClassAtomicCounter)) - { - emit_uniform(var); - } - } - } - - // Global variables. - bool emitted = false; - for (auto global : global_variables) - { - auto &var = get(global); - if (var.storage == StorageClassWorkgroup) - { - emit_shared(var); - emitted = true; - } - } - - if (emitted) - statement(""); - - declare_undefined_values(); - - statement("inline void init(spirv_cross_shader& s)"); - begin_scope(); - statement(resource_type, "::init(s);"); - for (auto ® : resource_registrations) - statement(reg); - end_scope(); - resource_registrations.clear(); - - end_scope_decl(); - - statement(""); - statement("Resources* __res;"); - if (get_entry_point().model == ExecutionModelGLCompute) - statement("ComputePrivateResources __priv_res;"); - statement(""); - - // Emit regular globals which are allocated per invocation. - emitted = false; - for (auto global : global_variables) - { - auto &var = get(global); - if (var.storage == StorageClassPrivate) - { - if (var.storage == StorageClassWorkgroup) - emit_shared(var); - else - statement(CompilerGLSL::variable_decl(var), ";"); - emitted = true; - } - } - - if (emitted) - statement(""); -} - -string CompilerCPP::compile() -{ - // Force a classic "C" locale, reverts when function returns - ClassicLocale classic_locale; - - // Do not deal with ES-isms like precision, older extensions and such. - options.es = false; - options.version = 450; - backend.float_literal_suffix = true; - backend.double_literal_suffix = false; - backend.long_long_literal_suffix = true; - backend.uint32_t_literal_suffix = true; - backend.basic_int_type = "int32_t"; - backend.basic_uint_type = "uint32_t"; - backend.swizzle_is_function = true; - backend.shared_is_implied = true; - backend.flexible_member_array_supported = false; - backend.explicit_struct_type = true; - backend.use_initializer_list = true; - - update_active_builtins(); - - uint32_t pass_count = 0; - do - { - if (pass_count >= 3) - SPIRV_CROSS_THROW("Over 3 compilation loops detected. Must be a bug!"); - - resource_registrations.clear(); - reset(); - - // Move constructor for this type is broken on GCC 4.9 ... - buffer = unique_ptr(new ostringstream()); - - emit_header(); - emit_resources(); - - emit_function(get(entry_point), 0); - - pass_count++; - } while (force_recompile); - - // Match opening scope of emit_header(). - end_scope_decl(); - // namespace - end_scope(); - - // Emit C entry points - emit_c_linkage(); - - // Entry point in CPP is always main() for the time being. - get_entry_point().name = "main"; - - return buffer->str(); -} - -void CompilerCPP::emit_c_linkage() -{ - statement(""); - - statement("spirv_cross_shader_t *spirv_cross_construct(void)"); - begin_scope(); - statement("return new ", impl_type, "();"); - end_scope(); - - statement(""); - statement("void spirv_cross_destruct(spirv_cross_shader_t *shader)"); - begin_scope(); - statement("delete static_cast<", impl_type, "*>(shader);"); - end_scope(); - - statement(""); - statement("void spirv_cross_invoke(spirv_cross_shader_t *shader)"); - begin_scope(); - statement("static_cast<", impl_type, "*>(shader)->invoke();"); - end_scope(); - - statement(""); - statement("static const struct spirv_cross_interface vtable ="); - begin_scope(); - statement("spirv_cross_construct,"); - statement("spirv_cross_destruct,"); - statement("spirv_cross_invoke,"); - end_scope_decl(); - - statement(""); - statement("const struct spirv_cross_interface *", - interface_name.empty() ? string("spirv_cross_get_interface") : interface_name, "(void)"); - begin_scope(); - statement("return &vtable;"); - end_scope(); -} - -void CompilerCPP::emit_function_prototype(SPIRFunction &func, uint64_t) -{ - local_variable_names = resource_names; - string decl; - - auto &type = get(func.return_type); - decl += "inline "; - decl += type_to_glsl(type); - decl += " "; - - if (func.self == entry_point) - { - decl += "main"; - processing_entry_point = true; - } - else - decl += to_name(func.self); - - decl += "("; - for (auto &arg : func.arguments) - { - add_local_variable_name(arg.id); - - decl += argument_decl(arg); - if (&arg != &func.arguments.back()) - decl += ", "; - - // Hold a pointer to the parameter so we can invalidate the readonly field if needed. - auto *var = maybe_get(arg.id); - if (var) - var->parameter = &arg; - } - - decl += ")"; - statement(decl); -} - -string CompilerCPP::argument_decl(const SPIRFunction::Parameter &arg) -{ - auto &type = expression_type(arg.id); - bool constref = !type.pointer || arg.write_count == 0; - - auto &var = get(arg.id); - - string base = type_to_glsl(type); - string variable_name = to_name(var.self); - remap_variable_type_name(type, variable_name, base); - - for (uint32_t i = 0; i < type.array.size(); i++) - base = join("std::array<", base, ", ", to_array_size(type, i), ">"); - - return join(constref ? "const " : "", base, " &", variable_name); -} - -string CompilerCPP::variable_decl(const SPIRType &type, const string &name, uint32_t /* id */) -{ - string base = type_to_glsl(type); - remap_variable_type_name(type, name, base); - bool runtime = false; - - for (uint32_t i = 0; i < type.array.size(); i++) - { - auto &array = type.array[i]; - if (!array && type.array_size_literal[i]) - { - // Avoid using runtime arrays with std::array since this is undefined. - // Runtime arrays cannot be passed around as values, so this is fine. - runtime = true; - } - else - base = join("std::array<", base, ", ", to_array_size(type, i), ">"); - } - base += ' '; - return base + name + (runtime ? "[1]" : ""); -} - -void CompilerCPP::emit_header() -{ - auto &execution = get_entry_point(); - - statement("// This C++ shader is autogenerated by spirv-cross."); - statement("#include \"spirv_cross/internal_interface.hpp\""); - statement("#include \"spirv_cross/external_interface.h\""); - // Needed to properly implement GLSL-style arrays. - statement("#include "); - statement("#include "); - statement(""); - statement("using namespace spirv_cross;"); - statement("using namespace glm;"); - statement(""); - - statement("namespace Impl"); - begin_scope(); - - switch (execution.model) - { - case ExecutionModelGeometry: - case ExecutionModelTessellationControl: - case ExecutionModelTessellationEvaluation: - case ExecutionModelGLCompute: - case ExecutionModelFragment: - case ExecutionModelVertex: - statement("struct Shader"); - begin_scope(); - break; - - default: - SPIRV_CROSS_THROW("Unsupported execution model."); - } - - switch (execution.model) - { - case ExecutionModelGeometry: - impl_type = "GeometryShader"; - resource_type = "GeometryResources"; - break; - - case ExecutionModelVertex: - impl_type = "VertexShader"; - resource_type = "VertexResources"; - break; - - case ExecutionModelFragment: - impl_type = "FragmentShader"; - resource_type = "FragmentResources"; - break; - - case ExecutionModelGLCompute: - impl_type = join("ComputeShader"); - resource_type = "ComputeResources"; - break; - - case ExecutionModelTessellationControl: - impl_type = "TessControlShader"; - resource_type = "TessControlResources"; - break; - - case ExecutionModelTessellationEvaluation: - impl_type = "TessEvaluationShader"; - resource_type = "TessEvaluationResources"; - break; - - default: - SPIRV_CROSS_THROW("Unsupported execution model."); - } -} diff --git a/deps/SPIRV-Cross/spirv_cpp.hpp b/deps/SPIRV-Cross/spirv_cpp.hpp deleted file mode 100644 index a2576feb9d..0000000000 --- a/deps/SPIRV-Cross/spirv_cpp.hpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2015-2017 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef SPIRV_CROSS_CPP_HPP -#define SPIRV_CROSS_CPP_HPP - -#include "spirv_glsl.hpp" -#include -#include - -namespace spirv_cross -{ -class CompilerCPP : public CompilerGLSL -{ -public: - CompilerCPP(std::vector spirv_) - : CompilerGLSL(move(spirv_)) - { - } - - CompilerCPP(const uint32_t *ir, size_t word_count) - : CompilerGLSL(ir, word_count) - { - } - - std::string compile() override; - - // Sets a custom symbol name that can override - // spirv_cross_get_interface. - // - // Useful when several shader interfaces are linked - // statically into the same binary. - void set_interface_name(std::string name) - { - interface_name = std::move(name); - } - -private: - void emit_header() override; - void emit_c_linkage(); - void emit_function_prototype(SPIRFunction &func, uint64_t return_flags) override; - - void emit_resources(); - void emit_buffer_block(const SPIRVariable &type) override; - void emit_push_constant_block(const SPIRVariable &var) override; - void emit_interface_block(const SPIRVariable &type); - void emit_block_chain(SPIRBlock &block); - void emit_uniform(const SPIRVariable &var) override; - void emit_shared(const SPIRVariable &var); - void emit_block_struct(SPIRType &type); - std::string variable_decl(const SPIRType &type, const std::string &name, uint32_t id) override; - - std::string argument_decl(const SPIRFunction::Parameter &arg); - - std::vector resource_registrations; - std::string impl_type; - std::string resource_type; - uint32_t shared_counter = 0; - - std::string interface_name; -}; -} - -#endif diff --git a/deps/SPIRV-Cross/spirv_cross.cpp b/deps/SPIRV-Cross/spirv_cross.cpp deleted file mode 100644 index 26983a4358..0000000000 --- a/deps/SPIRV-Cross/spirv_cross.cpp +++ /dev/null @@ -1,3957 +0,0 @@ -/* - * Copyright 2015-2017 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "spirv_cross.hpp" -#include "GLSL.std.450.h" -#include "spirv_cfg.hpp" -#include -#include -#include - -using namespace std; -using namespace spv; -using namespace spirv_cross; - -#define log(...) fprintf(stderr, __VA_ARGS__) - -static string ensure_valid_identifier(const string &name, bool member) -{ - // Functions in glslangValidator are mangled with name( stuff. - // Normally, we would never see '(' in any legal identifiers, so just strip them out. - auto str = name.substr(0, name.find('(')); - - for (uint32_t i = 0; i < str.size(); i++) - { - auto &c = str[i]; - - if (member) - { - // _m variables are reserved by the internal implementation, - // otherwise, make sure the name is a valid identifier. - if (i == 0) - c = isalpha(c) ? c : '_'; - else if (i == 2 && str[0] == '_' && str[1] == 'm') - c = isalpha(c) ? c : '_'; - else - c = isalnum(c) ? c : '_'; - } - else - { - // _ variables are reserved by the internal implementation, - // otherwise, make sure the name is a valid identifier. - if (i == 0 || (str[0] == '_' && i == 1)) - c = isalpha(c) ? c : '_'; - else - c = isalnum(c) ? c : '_'; - } - } - return str; -} - -Instruction::Instruction(const vector &spirv, uint32_t &index) -{ - op = spirv[index] & 0xffff; - count = (spirv[index] >> 16) & 0xffff; - - if (count == 0) - SPIRV_CROSS_THROW("SPIR-V instructions cannot consume 0 words. Invalid SPIR-V file."); - - offset = index + 1; - length = count - 1; - - index += count; - - if (index > spirv.size()) - SPIRV_CROSS_THROW("SPIR-V instruction goes out of bounds."); -} - -Compiler::Compiler(vector ir) - : spirv(move(ir)) -{ - parse(); -} - -Compiler::Compiler(const uint32_t *ir, size_t word_count) - : spirv(ir, ir + word_count) -{ - parse(); -} - -string Compiler::compile() -{ - // Force a classic "C" locale, reverts when function returns - ClassicLocale classic_locale; - return ""; -} - -bool Compiler::variable_storage_is_aliased(const SPIRVariable &v) -{ - auto &type = get(v.basetype); - bool ssbo = v.storage == StorageClassStorageBuffer || - ((meta[type.self].decoration.decoration_flags & (1ull << DecorationBufferBlock)) != 0); - bool image = type.basetype == SPIRType::Image; - bool counter = type.basetype == SPIRType::AtomicCounter; - bool is_restrict = (meta[v.self].decoration.decoration_flags & (1ull << DecorationRestrict)) != 0; - return !is_restrict && (ssbo || image || counter); -} - -bool Compiler::block_is_pure(const SPIRBlock &block) -{ - for (auto &i : block.ops) - { - auto ops = stream(i); - auto op = static_cast(i.op); - - switch (op) - { - case OpFunctionCall: - { - uint32_t func = ops[2]; - if (!function_is_pure(get(func))) - return false; - break; - } - - case OpCopyMemory: - case OpStore: - { - auto &type = expression_type(ops[0]); - if (type.storage != StorageClassFunction) - return false; - break; - } - - case OpImageWrite: - return false; - - // Atomics are impure. - case OpAtomicLoad: - case OpAtomicStore: - case OpAtomicExchange: - case OpAtomicCompareExchange: - case OpAtomicCompareExchangeWeak: - case OpAtomicIIncrement: - case OpAtomicIDecrement: - case OpAtomicIAdd: - case OpAtomicISub: - case OpAtomicSMin: - case OpAtomicUMin: - case OpAtomicSMax: - case OpAtomicUMax: - case OpAtomicAnd: - case OpAtomicOr: - case OpAtomicXor: - return false; - - // Geometry shader builtins modify global state. - case OpEndPrimitive: - case OpEmitStreamVertex: - case OpEndStreamPrimitive: - case OpEmitVertex: - return false; - - // Barriers disallow any reordering, so we should treat blocks with barrier as writing. - case OpControlBarrier: - case OpMemoryBarrier: - return false; - - // OpExtInst is potentially impure depending on extension, but GLSL builtins are at least pure. - - default: - break; - } - } - - return true; -} - -string Compiler::to_name(uint32_t id, bool allow_alias) const -{ - if (allow_alias && ids.at(id).get_type() == TypeType) - { - // If this type is a simple alias, emit the - // name of the original type instead. - // We don't want to override the meta alias - // as that can be overridden by the reflection APIs after parse. - auto &type = get(id); - if (type.type_alias) - return to_name(type.type_alias); - } - - if (meta[id].decoration.alias.empty()) - return join("_", id); - else - return meta.at(id).decoration.alias; -} - -bool Compiler::function_is_pure(const SPIRFunction &func) -{ - for (auto block : func.blocks) - { - if (!block_is_pure(get(block))) - { - //fprintf(stderr, "Function %s is impure!\n", to_name(func.self).c_str()); - return false; - } - } - - //fprintf(stderr, "Function %s is pure!\n", to_name(func.self).c_str()); - return true; -} - -void Compiler::register_global_read_dependencies(const SPIRBlock &block, uint32_t id) -{ - for (auto &i : block.ops) - { - auto ops = stream(i); - auto op = static_cast(i.op); - - switch (op) - { - case OpFunctionCall: - { - uint32_t func = ops[2]; - register_global_read_dependencies(get(func), id); - break; - } - - case OpLoad: - case OpImageRead: - { - // If we're in a storage class which does not get invalidated, adding dependencies here is no big deal. - auto *var = maybe_get_backing_variable(ops[2]); - if (var && var->storage != StorageClassFunction) - { - auto &type = get(var->basetype); - - // InputTargets are immutable. - if (type.basetype != SPIRType::Image && type.image.dim != DimSubpassData) - var->dependees.push_back(id); - } - break; - } - - default: - break; - } - } -} - -void Compiler::register_global_read_dependencies(const SPIRFunction &func, uint32_t id) -{ - for (auto block : func.blocks) - register_global_read_dependencies(get(block), id); -} - -SPIRVariable *Compiler::maybe_get_backing_variable(uint32_t chain) -{ - auto *var = maybe_get(chain); - if (!var) - { - auto *cexpr = maybe_get(chain); - if (cexpr) - var = maybe_get(cexpr->loaded_from); - - auto *access_chain = maybe_get(chain); - if (access_chain) - var = maybe_get(access_chain->loaded_from); - } - - return var; -} - -void Compiler::register_read(uint32_t expr, uint32_t chain, bool forwarded) -{ - auto &e = get(expr); - auto *var = maybe_get_backing_variable(chain); - - if (var) - { - e.loaded_from = var->self; - - // If the backing variable is immutable, we do not need to depend on the variable. - if (forwarded && !is_immutable(var->self)) - var->dependees.push_back(e.self); - - // If we load from a parameter, make sure we create "inout" if we also write to the parameter. - // The default is "in" however, so we never invalidate our compilation by reading. - if (var && var->parameter) - var->parameter->read_count++; - } -} - -void Compiler::register_write(uint32_t chain) -{ - auto *var = maybe_get(chain); - if (!var) - { - // If we're storing through an access chain, invalidate the backing variable instead. - auto *expr = maybe_get(chain); - if (expr && expr->loaded_from) - var = maybe_get(expr->loaded_from); - - auto *access_chain = maybe_get(chain); - if (access_chain && access_chain->loaded_from) - var = maybe_get(access_chain->loaded_from); - } - - if (var) - { - // If our variable is in a storage class which can alias with other buffers, - // invalidate all variables which depend on aliased variables. - if (variable_storage_is_aliased(*var)) - flush_all_aliased_variables(); - else if (var) - flush_dependees(*var); - - // We tried to write to a parameter which is not marked with out qualifier, force a recompile. - if (var->parameter && var->parameter->write_count == 0) - { - var->parameter->write_count++; - force_recompile = true; - } - } -} - -void Compiler::flush_dependees(SPIRVariable &var) -{ - for (auto expr : var.dependees) - invalid_expressions.insert(expr); - var.dependees.clear(); -} - -void Compiler::flush_all_aliased_variables() -{ - for (auto aliased : aliased_variables) - flush_dependees(get(aliased)); -} - -void Compiler::flush_all_atomic_capable_variables() -{ - for (auto global : global_variables) - flush_dependees(get(global)); - flush_all_aliased_variables(); -} - -void Compiler::flush_all_active_variables() -{ - // Invalidate all temporaries we read from variables in this block since they were forwarded. - // Invalidate all temporaries we read from globals. - for (auto &v : current_function->local_variables) - flush_dependees(get(v)); - for (auto &arg : current_function->arguments) - flush_dependees(get(arg.id)); - for (auto global : global_variables) - flush_dependees(get(global)); - - flush_all_aliased_variables(); -} - -uint32_t Compiler::expression_type_id(uint32_t id) const -{ - switch (ids[id].get_type()) - { - case TypeVariable: - return get(id).basetype; - - case TypeExpression: - return get(id).expression_type; - - case TypeConstant: - return get(id).constant_type; - - case TypeConstantOp: - return get(id).basetype; - - case TypeUndef: - return get(id).basetype; - - case TypeCombinedImageSampler: - return get(id).combined_type; - - case TypeAccessChain: - return get(id).basetype; - - default: - SPIRV_CROSS_THROW("Cannot resolve expression type."); - } -} - -const SPIRType &Compiler::expression_type(uint32_t id) const -{ - return get(expression_type_id(id)); -} - -bool Compiler::expression_is_lvalue(uint32_t id) const -{ - auto &type = expression_type(id); - switch (type.basetype) - { - case SPIRType::SampledImage: - case SPIRType::Image: - case SPIRType::Sampler: - return false; - - default: - return true; - } -} - -bool Compiler::is_immutable(uint32_t id) const -{ - if (ids[id].get_type() == TypeVariable) - { - auto &var = get(id); - - // Anything we load from the UniformConstant address space is guaranteed to be immutable. - bool pointer_to_const = var.storage == StorageClassUniformConstant; - return pointer_to_const || var.phi_variable || !expression_is_lvalue(id); - } - else if (ids[id].get_type() == TypeAccessChain) - return get(id).immutable; - else if (ids[id].get_type() == TypeExpression) - return get(id).immutable; - else if (ids[id].get_type() == TypeConstant || ids[id].get_type() == TypeConstantOp || - ids[id].get_type() == TypeUndef) - return true; - else - return false; -} - -static inline bool storage_class_is_interface(spv::StorageClass storage) -{ - switch (storage) - { - case StorageClassInput: - case StorageClassOutput: - case StorageClassUniform: - case StorageClassUniformConstant: - case StorageClassAtomicCounter: - case StorageClassPushConstant: - case StorageClassStorageBuffer: - return true; - - default: - return false; - } -} - -bool Compiler::is_hidden_variable(const SPIRVariable &var, bool include_builtins) const -{ - if ((is_builtin_variable(var) && !include_builtins) || var.remapped_variable) - return true; - - // Combined image samplers are always considered active as they are "magic" variables. - if (find_if(begin(combined_image_samplers), end(combined_image_samplers), [&var](const CombinedImageSampler &samp) { - return samp.combined_id == var.self; - }) != end(combined_image_samplers)) - { - return false; - } - - bool hidden = false; - if (check_active_interface_variables && storage_class_is_interface(var.storage)) - hidden = active_interface_variables.find(var.self) == end(active_interface_variables); - return hidden; -} - -bool Compiler::is_builtin_variable(const SPIRVariable &var) const -{ - if (var.compat_builtin || meta[var.self].decoration.builtin) - return true; - - // We can have builtin structs as well. If one member of a struct is builtin, the struct must also be builtin. - for (auto &m : meta[get(var.basetype).self].members) - if (m.builtin) - return true; - - return false; -} - -bool Compiler::is_member_builtin(const SPIRType &type, uint32_t index, BuiltIn *builtin) const -{ - auto &memb = meta[type.self].members; - if (index < memb.size() && memb[index].builtin) - { - if (builtin) - *builtin = memb[index].builtin_type; - return true; - } - - return false; -} - -bool Compiler::is_scalar(const SPIRType &type) const -{ - return type.vecsize == 1 && type.columns == 1; -} - -bool Compiler::is_vector(const SPIRType &type) const -{ - return type.vecsize > 1 && type.columns == 1; -} - -bool Compiler::is_matrix(const SPIRType &type) const -{ - return type.vecsize > 1 && type.columns > 1; -} - -bool Compiler::is_array(const SPIRType &type) const -{ - return !type.array.empty(); -} - -ShaderResources Compiler::get_shader_resources() const -{ - return get_shader_resources(nullptr); -} - -ShaderResources Compiler::get_shader_resources(const unordered_set &active_variables) const -{ - return get_shader_resources(&active_variables); -} - -bool Compiler::InterfaceVariableAccessHandler::handle(Op opcode, const uint32_t *args, uint32_t length) -{ - uint32_t variable = 0; - switch (opcode) - { - // Need this first, otherwise, GCC complains about unhandled switch statements. - default: - break; - - case OpFunctionCall: - { - // Invalid SPIR-V. - if (length < 3) - return false; - - uint32_t count = length - 3; - args += 3; - for (uint32_t i = 0; i < count; i++) - { - auto *var = compiler.maybe_get(args[i]); - if (var && storage_class_is_interface(var->storage)) - variables.insert(args[i]); - } - break; - } - - case OpAtomicStore: - case OpStore: - // Invalid SPIR-V. - if (length < 1) - return false; - variable = args[0]; - break; - - case OpCopyMemory: - { - if (length < 2) - return false; - - auto *var = compiler.maybe_get(args[0]); - if (var && storage_class_is_interface(var->storage)) - variables.insert(variable); - - var = compiler.maybe_get(args[1]); - if (var && storage_class_is_interface(var->storage)) - variables.insert(variable); - break; - } - - case OpExtInst: - { - if (length < 5) - return false; - uint32_t extension_set = args[2]; - if (compiler.get(extension_set).ext == SPIRExtension::SPV_AMD_shader_explicit_vertex_parameter) - { - enum AMDShaderExplicitVertexParameter - { - InterpolateAtVertexAMD = 1 - }; - - auto op = static_cast(args[3]); - - switch (op) - { - case InterpolateAtVertexAMD: - { - auto *var = compiler.maybe_get(args[4]); - if (var && storage_class_is_interface(var->storage)) - variables.insert(args[4]); - break; - } - - default: - break; - } - } - break; - } - - case OpAccessChain: - case OpInBoundsAccessChain: - case OpLoad: - case OpCopyObject: - case OpImageTexelPointer: - case OpAtomicLoad: - case OpAtomicExchange: - case OpAtomicCompareExchange: - case OpAtomicCompareExchangeWeak: - case OpAtomicIIncrement: - case OpAtomicIDecrement: - case OpAtomicIAdd: - case OpAtomicISub: - case OpAtomicSMin: - case OpAtomicUMin: - case OpAtomicSMax: - case OpAtomicUMax: - case OpAtomicAnd: - case OpAtomicOr: - case OpAtomicXor: - // Invalid SPIR-V. - if (length < 3) - return false; - variable = args[2]; - break; - } - - if (variable) - { - auto *var = compiler.maybe_get(variable); - if (var && storage_class_is_interface(var->storage)) - variables.insert(variable); - } - return true; -} - -unordered_set Compiler::get_active_interface_variables() const -{ - // Traverse the call graph and find all interface variables which are in use. - unordered_set variables; - InterfaceVariableAccessHandler handler(*this, variables); - traverse_all_reachable_opcodes(get(entry_point), handler); - return variables; -} - -void Compiler::set_enabled_interface_variables(std::unordered_set active_variables) -{ - active_interface_variables = move(active_variables); - check_active_interface_variables = true; -} - -ShaderResources Compiler::get_shader_resources(const unordered_set *active_variables) const -{ - ShaderResources res; - - for (auto &id : ids) - { - if (id.get_type() != TypeVariable) - continue; - - auto &var = id.get(); - auto &type = get(var.basetype); - - // It is possible for uniform storage classes to be passed as function parameters, so detect - // that. To detect function parameters, check of StorageClass of variable is function scope. - if (var.storage == StorageClassFunction || !type.pointer || is_builtin_variable(var)) - continue; - - if (active_variables && active_variables->find(var.self) == end(*active_variables)) - continue; - - // Input - if (var.storage == StorageClassInput && interface_variable_exists_in_entry_point(var.self)) - { - if (meta[type.self].decoration.decoration_flags & (1ull << DecorationBlock)) - res.stage_inputs.push_back( - { var.self, var.basetype, type.self, get_remapped_declared_block_name(var.self) }); - else - res.stage_inputs.push_back({ var.self, var.basetype, type.self, meta[var.self].decoration.alias }); - } - // Subpass inputs - else if (var.storage == StorageClassUniformConstant && type.image.dim == DimSubpassData) - { - res.subpass_inputs.push_back({ var.self, var.basetype, type.self, meta[var.self].decoration.alias }); - } - // Outputs - else if (var.storage == StorageClassOutput && interface_variable_exists_in_entry_point(var.self)) - { - if (meta[type.self].decoration.decoration_flags & (1ull << DecorationBlock)) - res.stage_outputs.push_back( - { var.self, var.basetype, type.self, get_remapped_declared_block_name(var.self) }); - else - res.stage_outputs.push_back({ var.self, var.basetype, type.self, meta[var.self].decoration.alias }); - } - // UBOs - else if (type.storage == StorageClassUniform && - (meta[type.self].decoration.decoration_flags & (1ull << DecorationBlock))) - { - res.uniform_buffers.push_back( - { var.self, var.basetype, type.self, get_remapped_declared_block_name(var.self) }); - } - // Old way to declare SSBOs. - else if (type.storage == StorageClassUniform && - (meta[type.self].decoration.decoration_flags & (1ull << DecorationBufferBlock))) - { - res.storage_buffers.push_back( - { var.self, var.basetype, type.self, get_remapped_declared_block_name(var.self) }); - } - // Modern way to declare SSBOs. - else if (type.storage == StorageClassStorageBuffer) - { - res.storage_buffers.push_back( - { var.self, var.basetype, type.self, get_remapped_declared_block_name(var.self) }); - } - // Push constant blocks - else if (type.storage == StorageClassPushConstant) - { - // There can only be one push constant block, but keep the vector in case this restriction is lifted - // in the future. - res.push_constant_buffers.push_back({ var.self, var.basetype, type.self, meta[var.self].decoration.alias }); - } - // Images - else if (type.storage == StorageClassUniformConstant && type.basetype == SPIRType::Image && - type.image.sampled == 2) - { - res.storage_images.push_back({ var.self, var.basetype, type.self, meta[var.self].decoration.alias }); - } - // Separate images - else if (type.storage == StorageClassUniformConstant && type.basetype == SPIRType::Image && - type.image.sampled == 1) - { - res.separate_images.push_back({ var.self, var.basetype, type.self, meta[var.self].decoration.alias }); - } - // Separate samplers - else if (type.storage == StorageClassUniformConstant && type.basetype == SPIRType::Sampler) - { - res.separate_samplers.push_back({ var.self, var.basetype, type.self, meta[var.self].decoration.alias }); - } - // Textures - else if (type.storage == StorageClassUniformConstant && type.basetype == SPIRType::SampledImage) - { - res.sampled_images.push_back({ var.self, var.basetype, type.self, meta[var.self].decoration.alias }); - } - // Atomic counters - else if (type.storage == StorageClassAtomicCounter) - { - res.atomic_counters.push_back({ var.self, var.basetype, type.self, meta[var.self].decoration.alias }); - } - } - - return res; -} - -static inline uint32_t swap_endian(uint32_t v) -{ - return ((v >> 24) & 0x000000ffu) | ((v >> 8) & 0x0000ff00u) | ((v << 8) & 0x00ff0000u) | ((v << 24) & 0xff000000u); -} - -static string extract_string(const vector &spirv, uint32_t offset) -{ - string ret; - for (uint32_t i = offset; i < spirv.size(); i++) - { - uint32_t w = spirv[i]; - - for (uint32_t j = 0; j < 4; j++, w >>= 8) - { - char c = w & 0xff; - if (c == '\0') - return ret; - ret += c; - } - } - - SPIRV_CROSS_THROW("String was not terminated before EOF"); -} - -static bool is_valid_spirv_version(uint32_t version) -{ - switch (version) - { - // Allow v99 since it tends to just work. - case 99: - case 0x10000: // SPIR-V 1.0 - case 0x10100: // SPIR-V 1.1 - case 0x10200: // SPIR-V 1.2 - return true; - - default: - return false; - } -} - -void Compiler::parse() -{ - auto len = spirv.size(); - if (len < 5) - SPIRV_CROSS_THROW("SPIRV file too small."); - - auto s = spirv.data(); - - // Endian-swap if we need to. - if (s[0] == swap_endian(MagicNumber)) - transform(begin(spirv), end(spirv), begin(spirv), [](uint32_t c) { return swap_endian(c); }); - - if (s[0] != MagicNumber || !is_valid_spirv_version(s[1])) - SPIRV_CROSS_THROW("Invalid SPIRV format."); - - uint32_t bound = s[3]; - ids.resize(bound); - meta.resize(bound); - - uint32_t offset = 5; - while (offset < len) - inst.emplace_back(spirv, offset); - - for (auto &i : inst) - parse(i); - - if (current_function) - SPIRV_CROSS_THROW("Function was not terminated."); - if (current_block) - SPIRV_CROSS_THROW("Block was not terminated."); - - // Figure out specialization constants for work group sizes. - for (auto &id : ids) - { - if (id.get_type() == TypeConstant) - { - auto &c = id.get(); - if (meta[c.self].decoration.builtin && meta[c.self].decoration.builtin_type == BuiltInWorkgroupSize) - { - // In current SPIR-V, there can be just one constant like this. - // All entry points will receive the constant value. - for (auto &entry : entry_points) - { - entry.second.workgroup_size.constant = c.self; - entry.second.workgroup_size.x = c.scalar(0, 0); - entry.second.workgroup_size.y = c.scalar(0, 1); - entry.second.workgroup_size.z = c.scalar(0, 2); - } - } - } - } -} - -void Compiler::flatten_interface_block(uint32_t id) -{ - auto &var = get(id); - auto &type = get(var.basetype); - auto flags = meta.at(type.self).decoration.decoration_flags; - - if (!type.array.empty()) - SPIRV_CROSS_THROW("Type is array of UBOs."); - if (type.basetype != SPIRType::Struct) - SPIRV_CROSS_THROW("Type is not a struct."); - if ((flags & (1ull << DecorationBlock)) == 0) - SPIRV_CROSS_THROW("Type is not a block."); - if (type.member_types.empty()) - SPIRV_CROSS_THROW("Member list of struct is empty."); - - uint32_t t = type.member_types[0]; - for (auto &m : type.member_types) - if (t != m) - SPIRV_CROSS_THROW("Types in block differ."); - - auto &mtype = get(t); - if (!mtype.array.empty()) - SPIRV_CROSS_THROW("Member type cannot be arrays."); - if (mtype.basetype == SPIRType::Struct) - SPIRV_CROSS_THROW("Member type cannot be struct."); - - // Inherit variable name from interface block name. - meta.at(var.self).decoration.alias = meta.at(type.self).decoration.alias; - - auto storage = var.storage; - if (storage == StorageClassUniform) - storage = StorageClassUniformConstant; - - // Change type definition in-place into an array instead. - // Access chains will still work as-is. - uint32_t array_size = uint32_t(type.member_types.size()); - type = mtype; - type.array.push_back(array_size); - type.pointer = true; - type.storage = storage; - var.storage = storage; -} - -void Compiler::update_name_cache(unordered_set &cache, string &name) -{ - if (name.empty()) - return; - - if (cache.find(name) == end(cache)) - { - cache.insert(name); - return; - } - - uint32_t counter = 0; - auto tmpname = name; - - // If there is a collision (very rare), - // keep tacking on extra identifier until it's unique. - do - { - counter++; - name = tmpname + "_" + convert_to_string(counter); - } while (cache.find(name) != end(cache)); - cache.insert(name); -} - -void Compiler::set_name(uint32_t id, const std::string &name) -{ - auto &str = meta.at(id).decoration.alias; - str.clear(); - - if (name.empty()) - return; - - // glslang uses identifiers to pass along meaningful information - // about HLSL reflection. - auto &m = meta.at(id); - if (source.hlsl && name.size() >= 6 && name.find("@count") == name.size() - 6) - { - m.hlsl_magic_counter_buffer_candidate = true; - m.hlsl_magic_counter_buffer_name = name.substr(0, name.find("@count")); - } - else - { - m.hlsl_magic_counter_buffer_candidate = false; - m.hlsl_magic_counter_buffer_name.clear(); - } - - // Reserved for temporaries. - if (name[0] == '_' && name.size() >= 2 && isdigit(name[1])) - return; - - str = ensure_valid_identifier(name, false); -} - -const SPIRType &Compiler::get_type(uint32_t id) const -{ - return get(id); -} - -const SPIRType &Compiler::get_type_from_variable(uint32_t id) const -{ - return get(get(id).basetype); -} - -void Compiler::set_member_decoration(uint32_t id, uint32_t index, Decoration decoration, uint32_t argument) -{ - meta.at(id).members.resize(max(meta[id].members.size(), size_t(index) + 1)); - auto &dec = meta.at(id).members[index]; - dec.decoration_flags |= 1ull << decoration; - - switch (decoration) - { - case DecorationBuiltIn: - dec.builtin = true; - dec.builtin_type = static_cast(argument); - break; - - case DecorationLocation: - dec.location = argument; - break; - - case DecorationBinding: - dec.binding = argument; - break; - - case DecorationOffset: - dec.offset = argument; - break; - - case DecorationSpecId: - dec.spec_id = argument; - break; - - case DecorationMatrixStride: - dec.matrix_stride = argument; - break; - - default: - break; - } -} - -void Compiler::set_member_name(uint32_t id, uint32_t index, const std::string &name) -{ - meta.at(id).members.resize(max(meta[id].members.size(), size_t(index) + 1)); - - auto &str = meta.at(id).members[index].alias; - str.clear(); - if (name.empty()) - return; - - // Reserved for unnamed members. - if (name[0] == '_' && name.size() >= 3 && name[1] == 'm' && isdigit(name[2])) - return; - - str = ensure_valid_identifier(name, true); -} - -const std::string &Compiler::get_member_name(uint32_t id, uint32_t index) const -{ - auto &m = meta.at(id); - if (index >= m.members.size()) - { - static string empty; - return empty; - } - - return m.members[index].alias; -} - -void Compiler::set_member_qualified_name(uint32_t type_id, uint32_t index, const std::string &name) -{ - meta.at(type_id).members.resize(max(meta[type_id].members.size(), size_t(index) + 1)); - meta.at(type_id).members[index].qualified_alias = name; -} - -const std::string &Compiler::get_member_qualified_name(uint32_t type_id, uint32_t index) const -{ - const static string empty; - - auto &m = meta.at(type_id); - if (index < m.members.size()) - return m.members[index].qualified_alias; - else - return empty; -} - -uint32_t Compiler::get_member_decoration(uint32_t id, uint32_t index, Decoration decoration) const -{ - auto &m = meta.at(id); - if (index >= m.members.size()) - return 0; - - auto &dec = m.members[index]; - if (!(dec.decoration_flags & (1ull << decoration))) - return 0; - - switch (decoration) - { - case DecorationBuiltIn: - return dec.builtin_type; - case DecorationLocation: - return dec.location; - case DecorationBinding: - return dec.binding; - case DecorationOffset: - return dec.offset; - case DecorationSpecId: - return dec.spec_id; - default: - return 1; - } -} - -uint64_t Compiler::get_member_decoration_mask(uint32_t id, uint32_t index) const -{ - auto &m = meta.at(id); - if (index >= m.members.size()) - return 0; - - return m.members[index].decoration_flags; -} - -bool Compiler::has_member_decoration(uint32_t id, uint32_t index, Decoration decoration) const -{ - return get_member_decoration_mask(id, index) & (1ull << decoration); -} - -void Compiler::unset_member_decoration(uint32_t id, uint32_t index, Decoration decoration) -{ - auto &m = meta.at(id); - if (index >= m.members.size()) - return; - - auto &dec = m.members[index]; - - dec.decoration_flags &= ~(1ull << decoration); - switch (decoration) - { - case DecorationBuiltIn: - dec.builtin = false; - break; - - case DecorationLocation: - dec.location = 0; - break; - - case DecorationOffset: - dec.offset = 0; - break; - - case DecorationSpecId: - dec.spec_id = 0; - break; - - default: - break; - } -} - -void Compiler::set_decoration(uint32_t id, Decoration decoration, uint32_t argument) -{ - auto &dec = meta.at(id).decoration; - dec.decoration_flags |= 1ull << decoration; - - switch (decoration) - { - case DecorationBuiltIn: - dec.builtin = true; - dec.builtin_type = static_cast(argument); - break; - - case DecorationLocation: - dec.location = argument; - break; - - case DecorationOffset: - dec.offset = argument; - break; - - case DecorationArrayStride: - dec.array_stride = argument; - break; - - case DecorationMatrixStride: - dec.matrix_stride = argument; - break; - - case DecorationBinding: - dec.binding = argument; - break; - - case DecorationDescriptorSet: - dec.set = argument; - break; - - case DecorationInputAttachmentIndex: - dec.input_attachment = argument; - break; - - case DecorationSpecId: - dec.spec_id = argument; - break; - - default: - break; - } -} - -StorageClass Compiler::get_storage_class(uint32_t id) const -{ - return get(id).storage; -} - -const std::string &Compiler::get_name(uint32_t id) const -{ - return meta.at(id).decoration.alias; -} - -const std::string Compiler::get_fallback_name(uint32_t id) const -{ - return join("_", id); -} - -const std::string Compiler::get_block_fallback_name(uint32_t id) const -{ - auto &var = get(id); - if (get_name(id).empty()) - return join("_", get(var.basetype).self, "_", id); - else - return get_name(id); -} - -uint64_t Compiler::get_decoration_mask(uint32_t id) const -{ - auto &dec = meta.at(id).decoration; - return dec.decoration_flags; -} - -bool Compiler::has_decoration(uint32_t id, Decoration decoration) const -{ - return get_decoration_mask(id) & (1ull << decoration); -} - -uint32_t Compiler::get_decoration(uint32_t id, Decoration decoration) const -{ - auto &dec = meta.at(id).decoration; - if (!(dec.decoration_flags & (1ull << decoration))) - return 0; - - switch (decoration) - { - case DecorationBuiltIn: - return dec.builtin_type; - case DecorationLocation: - return dec.location; - case DecorationOffset: - return dec.offset; - case DecorationBinding: - return dec.binding; - case DecorationDescriptorSet: - return dec.set; - case DecorationInputAttachmentIndex: - return dec.input_attachment; - case DecorationSpecId: - return dec.spec_id; - case DecorationArrayStride: - return dec.array_stride; - case DecorationMatrixStride: - return dec.matrix_stride; - default: - return 1; - } -} - -void Compiler::unset_decoration(uint32_t id, Decoration decoration) -{ - auto &dec = meta.at(id).decoration; - dec.decoration_flags &= ~(1ull << decoration); - switch (decoration) - { - case DecorationBuiltIn: - dec.builtin = false; - break; - - case DecorationLocation: - dec.location = 0; - break; - - case DecorationOffset: - dec.offset = 0; - break; - - case DecorationBinding: - dec.binding = 0; - break; - - case DecorationDescriptorSet: - dec.set = 0; - break; - - case DecorationInputAttachmentIndex: - dec.input_attachment = 0; - break; - - case DecorationSpecId: - dec.spec_id = 0; - break; - - default: - break; - } -} - -bool Compiler::get_binary_offset_for_decoration(uint32_t id, spv::Decoration decoration, uint32_t &word_offset) const -{ - auto &word_offsets = meta.at(id).decoration_word_offset; - auto itr = word_offsets.find(decoration); - if (itr == end(word_offsets)) - return false; - - word_offset = itr->second; - return true; -} - -void Compiler::parse(const Instruction &instruction) -{ - auto ops = stream(instruction); - auto op = static_cast(instruction.op); - uint32_t length = instruction.length; - - switch (op) - { - case OpMemoryModel: - case OpSourceExtension: - case OpNop: - case OpLine: - case OpNoLine: - case OpString: - break; - - case OpSource: - { - auto lang = static_cast(ops[0]); - switch (lang) - { - case SourceLanguageESSL: - source.es = true; - source.version = ops[1]; - source.known = true; - source.hlsl = false; - break; - - case SourceLanguageGLSL: - source.es = false; - source.version = ops[1]; - source.known = true; - source.hlsl = false; - break; - - case SourceLanguageHLSL: - // For purposes of cross-compiling, this is GLSL 450. - source.es = false; - source.version = 450; - source.known = true; - source.hlsl = true; - break; - - default: - source.known = false; - break; - } - break; - } - - case OpUndef: - { - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - set(id, result_type); - break; - } - - case OpCapability: - { - uint32_t cap = ops[0]; - if (cap == CapabilityKernel) - SPIRV_CROSS_THROW("Kernel capability not supported."); - - declared_capabilities.push_back(static_cast(ops[0])); - break; - } - - case OpExtension: - { - auto ext = extract_string(spirv, instruction.offset); - declared_extensions.push_back(move(ext)); - break; - } - - case OpExtInstImport: - { - uint32_t id = ops[0]; - auto ext = extract_string(spirv, instruction.offset + 1); - if (ext == "GLSL.std.450") - set(id, SPIRExtension::GLSL); - else if (ext == "SPV_AMD_shader_ballot") - set(id, SPIRExtension::SPV_AMD_shader_ballot); - else if (ext == "SPV_AMD_shader_explicit_vertex_parameter") - set(id, SPIRExtension::SPV_AMD_shader_explicit_vertex_parameter); - else if (ext == "SPV_AMD_shader_trinary_minmax") - set(id, SPIRExtension::SPV_AMD_shader_trinary_minmax); - else if (ext == "SPV_AMD_gcn_shader") - set(id, SPIRExtension::SPV_AMD_gcn_shader); - else - set(id, SPIRExtension::Unsupported); - - // Other SPIR-V extensions currently not supported. - - break; - } - - case OpEntryPoint: - { - auto itr = - entry_points.insert(make_pair(ops[1], SPIREntryPoint(ops[1], static_cast(ops[0]), - extract_string(spirv, instruction.offset + 2)))); - auto &e = itr.first->second; - - // Strings need nul-terminator and consume the whole word. - uint32_t strlen_words = uint32_t((e.name.size() + 1 + 3) >> 2); - e.interface_variables.insert(end(e.interface_variables), ops + strlen_words + 2, ops + instruction.length); - - // Set the name of the entry point in case OpName is not provided later - set_name(ops[1], e.name); - - // If we don't have an entry, make the first one our "default". - if (!entry_point) - entry_point = ops[1]; - break; - } - - case OpExecutionMode: - { - auto &execution = entry_points[ops[0]]; - auto mode = static_cast(ops[1]); - execution.flags |= 1ull << mode; - - switch (mode) - { - case ExecutionModeInvocations: - execution.invocations = ops[2]; - break; - - case ExecutionModeLocalSize: - execution.workgroup_size.x = ops[2]; - execution.workgroup_size.y = ops[3]; - execution.workgroup_size.z = ops[4]; - break; - - case ExecutionModeOutputVertices: - execution.output_vertices = ops[2]; - break; - - default: - break; - } - break; - } - - case OpName: - { - uint32_t id = ops[0]; - set_name(id, extract_string(spirv, instruction.offset + 1)); - break; - } - - case OpMemberName: - { - uint32_t id = ops[0]; - uint32_t member = ops[1]; - set_member_name(id, member, extract_string(spirv, instruction.offset + 2)); - break; - } - - case OpDecorate: - { - uint32_t id = ops[0]; - - auto decoration = static_cast(ops[1]); - if (length >= 3) - { - meta[id].decoration_word_offset[decoration] = uint32_t(&ops[2] - spirv.data()); - set_decoration(id, decoration, ops[2]); - } - else - set_decoration(id, decoration); - - break; - } - - case OpMemberDecorate: - { - uint32_t id = ops[0]; - uint32_t member = ops[1]; - auto decoration = static_cast(ops[2]); - if (length >= 4) - set_member_decoration(id, member, decoration, ops[3]); - else - set_member_decoration(id, member, decoration); - break; - } - - // Build up basic types. - case OpTypeVoid: - { - uint32_t id = ops[0]; - auto &type = set(id); - type.basetype = SPIRType::Void; - break; - } - - case OpTypeBool: - { - uint32_t id = ops[0]; - auto &type = set(id); - type.basetype = SPIRType::Boolean; - type.width = 1; - break; - } - - case OpTypeFloat: - { - uint32_t id = ops[0]; - uint32_t width = ops[1]; - auto &type = set(id); - type.basetype = width > 32 ? SPIRType::Double : SPIRType::Float; - type.width = width; - break; - } - - case OpTypeInt: - { - uint32_t id = ops[0]; - uint32_t width = ops[1]; - auto &type = set(id); - type.basetype = - ops[2] ? (width > 32 ? SPIRType::Int64 : SPIRType::Int) : (width > 32 ? SPIRType::UInt64 : SPIRType::UInt); - type.width = width; - break; - } - - // Build composite types by "inheriting". - // NOTE: The self member is also copied! For pointers and array modifiers this is a good thing - // since we can refer to decorations on pointee classes which is needed for UBO/SSBO, I/O blocks in geometry/tess etc. - case OpTypeVector: - { - uint32_t id = ops[0]; - uint32_t vecsize = ops[2]; - - auto &base = get(ops[1]); - auto &vecbase = set(id); - - vecbase = base; - vecbase.vecsize = vecsize; - vecbase.self = id; - vecbase.parent_type = ops[1]; - break; - } - - case OpTypeMatrix: - { - uint32_t id = ops[0]; - uint32_t colcount = ops[2]; - - auto &base = get(ops[1]); - auto &matrixbase = set(id); - - matrixbase = base; - matrixbase.columns = colcount; - matrixbase.self = id; - matrixbase.parent_type = ops[1]; - break; - } - - case OpTypeArray: - { - uint32_t id = ops[0]; - auto &arraybase = set(id); - - uint32_t tid = ops[1]; - auto &base = get(tid); - - arraybase = base; - arraybase.parent_type = tid; - - uint32_t cid = ops[2]; - mark_used_as_array_length(cid); - auto *c = maybe_get(cid); - bool literal = c && !c->specialization; - - arraybase.array_size_literal.push_back(literal); - arraybase.array.push_back(literal ? c->scalar() : cid); - // Do NOT set arraybase.self! - break; - } - - case OpTypeRuntimeArray: - { - uint32_t id = ops[0]; - - auto &base = get(ops[1]); - auto &arraybase = set(id); - - arraybase = base; - arraybase.array.push_back(0); - arraybase.array_size_literal.push_back(true); - arraybase.parent_type = ops[1]; - // Do NOT set arraybase.self! - break; - } - - case OpTypeImage: - { - uint32_t id = ops[0]; - auto &type = set(id); - type.basetype = SPIRType::Image; - type.image.type = ops[1]; - type.image.dim = static_cast(ops[2]); - type.image.depth = ops[3] != 0; - type.image.arrayed = ops[4] != 0; - type.image.ms = ops[5] != 0; - type.image.sampled = ops[6]; - type.image.format = static_cast(ops[7]); - type.image.access = (length >= 9) ? static_cast(ops[8]) : AccessQualifierMax; - - if (type.image.sampled == 0) - SPIRV_CROSS_THROW("OpTypeImage Sampled parameter must not be zero."); - - break; - } - - case OpTypeSampledImage: - { - uint32_t id = ops[0]; - uint32_t imagetype = ops[1]; - auto &type = set(id); - type = get(imagetype); - type.basetype = SPIRType::SampledImage; - type.self = id; - break; - } - - case OpTypeSampler: - { - uint32_t id = ops[0]; - auto &type = set(id); - type.basetype = SPIRType::Sampler; - break; - } - - case OpTypePointer: - { - uint32_t id = ops[0]; - - auto &base = get(ops[2]); - auto &ptrbase = set(id); - - ptrbase = base; - if (ptrbase.pointer) - SPIRV_CROSS_THROW("Cannot make pointer-to-pointer type."); - ptrbase.pointer = true; - ptrbase.storage = static_cast(ops[1]); - - if (ptrbase.storage == StorageClassAtomicCounter) - ptrbase.basetype = SPIRType::AtomicCounter; - - ptrbase.parent_type = ops[2]; - - // Do NOT set ptrbase.self! - break; - } - - case OpTypeStruct: - { - uint32_t id = ops[0]; - auto &type = set(id); - type.basetype = SPIRType::Struct; - for (uint32_t i = 1; i < length; i++) - type.member_types.push_back(ops[i]); - - // Check if we have seen this struct type before, with just different - // decorations. - // - // Add workaround for issue #17 as well by looking at OpName for the struct - // types, which we shouldn't normally do. - // We should not normally have to consider type aliases like this to begin with - // however ... glslang issues #304, #307 cover this. - - // For stripped names, never consider struct type aliasing. - // We risk declaring the same struct multiple times, but type-punning is not allowed - // so this is safe. - bool consider_aliasing = !get_name(type.self).empty(); - if (consider_aliasing) - { - for (auto &other : global_struct_cache) - { - if (get_name(type.self) == get_name(other) && - types_are_logically_equivalent(type, get(other))) - { - type.type_alias = other; - break; - } - } - - if (type.type_alias == 0) - global_struct_cache.push_back(id); - } - break; - } - - case OpTypeFunction: - { - uint32_t id = ops[0]; - uint32_t ret = ops[1]; - - auto &func = set(id, ret); - for (uint32_t i = 2; i < length; i++) - func.parameter_types.push_back(ops[i]); - break; - } - - // Variable declaration - // All variables are essentially pointers with a storage qualifier. - case OpVariable: - { - uint32_t type = ops[0]; - uint32_t id = ops[1]; - auto storage = static_cast(ops[2]); - uint32_t initializer = length == 4 ? ops[3] : 0; - - if (storage == StorageClassFunction) - { - if (!current_function) - SPIRV_CROSS_THROW("No function currently in scope"); - current_function->add_local_variable(id); - } - else if (storage == StorageClassPrivate || storage == StorageClassWorkgroup || storage == StorageClassOutput) - { - global_variables.push_back(id); - } - - auto &var = set(id, type, storage, initializer); - - // hlsl based shaders don't have those decorations. force them and then reset when reading/writing images - auto &ttype = get(type); - if (ttype.basetype == SPIRType::BaseType::Image) - { - set_decoration(id, DecorationNonWritable); - set_decoration(id, DecorationNonReadable); - } - - if (variable_storage_is_aliased(var)) - aliased_variables.push_back(var.self); - - break; - } - - // OpPhi - // OpPhi is a fairly magical opcode. - // It selects temporary variables based on which parent block we *came from*. - // In high-level languages we can "de-SSA" by creating a function local, and flush out temporaries to this function-local - // variable to emulate SSA Phi. - case OpPhi: - { - if (!current_function) - SPIRV_CROSS_THROW("No function currently in scope"); - if (!current_block) - SPIRV_CROSS_THROW("No block currently in scope"); - - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - - // Instead of a temporary, create a new function-wide temporary with this ID instead. - auto &var = set(id, result_type, spv::StorageClassFunction); - var.phi_variable = true; - - current_function->add_local_variable(id); - - for (uint32_t i = 2; i + 2 <= length; i += 2) - current_block->phi_variables.push_back({ ops[i], ops[i + 1], id }); - break; - } - - // Constants - case OpSpecConstant: - case OpConstant: - { - uint32_t id = ops[1]; - auto &type = get(ops[0]); - - if (type.width > 32) - set(id, ops[0], ops[2] | (uint64_t(ops[3]) << 32), op == OpSpecConstant); - else - set(id, ops[0], ops[2], op == OpSpecConstant); - break; - } - - case OpSpecConstantFalse: - case OpConstantFalse: - { - uint32_t id = ops[1]; - set(id, ops[0], uint32_t(0), op == OpSpecConstantFalse); - break; - } - - case OpSpecConstantTrue: - case OpConstantTrue: - { - uint32_t id = ops[1]; - set(id, ops[0], uint32_t(1), op == OpSpecConstantTrue); - break; - } - - case OpConstantNull: - { - uint32_t id = ops[1]; - uint32_t type = ops[0]; - make_constant_null(id, type); - break; - } - - case OpSpecConstantComposite: - case OpConstantComposite: - { - uint32_t id = ops[1]; - uint32_t type = ops[0]; - - auto &ctype = get(type); - - // We can have constants which are structs and arrays. - // In this case, our SPIRConstant will be a list of other SPIRConstant ids which we - // can refer to. - if (ctype.basetype == SPIRType::Struct || !ctype.array.empty()) - { - set(id, type, ops + 2, length - 2, op == OpSpecConstantComposite); - } - else - { - uint32_t elements = length - 2; - if (elements > 4) - SPIRV_CROSS_THROW("OpConstantComposite only supports 1, 2, 3 and 4 elements."); - - const SPIRConstant *c[4]; - for (uint32_t i = 0; i < elements; i++) - c[i] = &get(ops[2 + i]); - set(id, type, c, elements, op == OpSpecConstantComposite); - } - break; - } - - // Functions - case OpFunction: - { - uint32_t res = ops[0]; - uint32_t id = ops[1]; - // Control - uint32_t type = ops[3]; - - if (current_function) - SPIRV_CROSS_THROW("Must end a function before starting a new one!"); - - current_function = &set(id, res, type); - break; - } - - case OpFunctionParameter: - { - uint32_t type = ops[0]; - uint32_t id = ops[1]; - - if (!current_function) - SPIRV_CROSS_THROW("Must be in a function!"); - - current_function->add_parameter(type, id); - set(id, type, StorageClassFunction); - break; - } - - case OpFunctionEnd: - { - if (current_block) - { - // Very specific error message, but seems to come up quite often. - SPIRV_CROSS_THROW( - "Cannot end a function before ending the current block.\n" - "Likely cause: If this SPIR-V was created from glslang HLSL, make sure the entry point is valid."); - } - current_function = nullptr; - break; - } - - // Blocks - case OpLabel: - { - // OpLabel always starts a block. - if (!current_function) - SPIRV_CROSS_THROW("Blocks cannot exist outside functions!"); - - uint32_t id = ops[0]; - - current_function->blocks.push_back(id); - if (!current_function->entry_block) - current_function->entry_block = id; - - if (current_block) - SPIRV_CROSS_THROW("Cannot start a block before ending the current block."); - - current_block = &set(id); - break; - } - - // Branch instructions end blocks. - case OpBranch: - { - if (!current_block) - SPIRV_CROSS_THROW("Trying to end a non-existing block."); - - uint32_t target = ops[0]; - current_block->terminator = SPIRBlock::Direct; - current_block->next_block = target; - current_block = nullptr; - break; - } - - case OpBranchConditional: - { - if (!current_block) - SPIRV_CROSS_THROW("Trying to end a non-existing block."); - - current_block->condition = ops[0]; - current_block->true_block = ops[1]; - current_block->false_block = ops[2]; - - current_block->terminator = SPIRBlock::Select; - current_block = nullptr; - break; - } - - case OpSwitch: - { - if (!current_block) - SPIRV_CROSS_THROW("Trying to end a non-existing block."); - - if (current_block->merge == SPIRBlock::MergeNone) - SPIRV_CROSS_THROW("Switch statement is not structured"); - - current_block->terminator = SPIRBlock::MultiSelect; - - current_block->condition = ops[0]; - current_block->default_block = ops[1]; - - for (uint32_t i = 2; i + 2 <= length; i += 2) - current_block->cases.push_back({ ops[i], ops[i + 1] }); - - // If we jump to next block, make it break instead since we're inside a switch case block at that point. - multiselect_merge_targets.insert(current_block->next_block); - - current_block = nullptr; - break; - } - - case OpKill: - { - if (!current_block) - SPIRV_CROSS_THROW("Trying to end a non-existing block."); - current_block->terminator = SPIRBlock::Kill; - current_block = nullptr; - break; - } - - case OpReturn: - { - if (!current_block) - SPIRV_CROSS_THROW("Trying to end a non-existing block."); - current_block->terminator = SPIRBlock::Return; - current_block = nullptr; - break; - } - - case OpReturnValue: - { - if (!current_block) - SPIRV_CROSS_THROW("Trying to end a non-existing block."); - current_block->terminator = SPIRBlock::Return; - current_block->return_value = ops[0]; - current_block = nullptr; - break; - } - - case OpUnreachable: - { - if (!current_block) - SPIRV_CROSS_THROW("Trying to end a non-existing block."); - current_block->terminator = SPIRBlock::Unreachable; - current_block = nullptr; - break; - } - - case OpSelectionMerge: - { - if (!current_block) - SPIRV_CROSS_THROW("Trying to modify a non-existing block."); - - current_block->next_block = ops[0]; - current_block->merge = SPIRBlock::MergeSelection; - selection_merge_targets.insert(current_block->next_block); - break; - } - - case OpLoopMerge: - { - if (!current_block) - SPIRV_CROSS_THROW("Trying to modify a non-existing block."); - - current_block->merge_block = ops[0]; - current_block->continue_block = ops[1]; - current_block->merge = SPIRBlock::MergeLoop; - - loop_blocks.insert(current_block->self); - loop_merge_targets.insert(current_block->merge_block); - - continue_block_to_loop_header[current_block->continue_block] = current_block->self; - - // Don't add loop headers to continue blocks, - // which would make it impossible branch into the loop header since - // they are treated as continues. - if (current_block->continue_block != current_block->self) - continue_blocks.insert(current_block->continue_block); - break; - } - - case OpSpecConstantOp: - { - if (length < 3) - SPIRV_CROSS_THROW("OpSpecConstantOp not enough arguments."); - - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - auto spec_op = static_cast(ops[2]); - - set(id, result_type, spec_op, ops + 3, length - 3); - break; - } - - // Actual opcodes. - default: - { - if (!current_block) - SPIRV_CROSS_THROW("Currently no block to insert opcode."); - - current_block->ops.push_back(instruction); - break; - } - } -} - -bool Compiler::block_is_loop_candidate(const SPIRBlock &block, SPIRBlock::Method method) const -{ - // Tried and failed. - if (block.disable_block_optimization || block.complex_continue) - return false; - - if (method == SPIRBlock::MergeToSelectForLoop) - { - // Try to detect common for loop pattern - // which the code backend can use to create cleaner code. - // for(;;) { if (cond) { some_body; } else { break; } } - // is the pattern we're looking for. - bool ret = block.terminator == SPIRBlock::Select && block.merge == SPIRBlock::MergeLoop && - block.true_block != block.merge_block && block.true_block != block.self && - block.false_block == block.merge_block; - - // If we have OpPhi which depends on branches which came from our own block, - // we need to flush phi variables in else block instead of a trivial break, - // so we cannot assume this is a for loop candidate. - if (ret) - { - for (auto &phi : block.phi_variables) - if (phi.parent == block.self) - return false; - - auto *merge = maybe_get(block.merge_block); - if (merge) - for (auto &phi : merge->phi_variables) - if (phi.parent == block.self) - return false; - } - return ret; - } - else if (method == SPIRBlock::MergeToDirectForLoop) - { - // Empty loop header that just sets up merge target - // and branches to loop body. - bool ret = block.terminator == SPIRBlock::Direct && block.merge == SPIRBlock::MergeLoop && block.ops.empty(); - - if (!ret) - return false; - - auto &child = get(block.next_block); - ret = child.terminator == SPIRBlock::Select && child.merge == SPIRBlock::MergeNone && - child.false_block == block.merge_block && child.true_block != block.merge_block && - child.true_block != block.self; - - // If we have OpPhi which depends on branches which came from our own block, - // we need to flush phi variables in else block instead of a trivial break, - // so we cannot assume this is a for loop candidate. - if (ret) - { - for (auto &phi : block.phi_variables) - if (phi.parent == block.self || phi.parent == child.self) - return false; - - for (auto &phi : child.phi_variables) - if (phi.parent == block.self) - return false; - - auto *merge = maybe_get(block.merge_block); - if (merge) - for (auto &phi : merge->phi_variables) - if (phi.parent == block.self || phi.parent == child.false_block) - return false; - } - - return ret; - } - else - return false; -} - -bool Compiler::block_is_outside_flow_control_from_block(const SPIRBlock &from, const SPIRBlock &to) -{ - auto *start = &from; - - if (start->self == to.self) - return true; - - // Break cycles. - if (is_continue(start->self)) - return false; - - // If our select block doesn't merge, we must break or continue in these blocks, - // so if continues occur branchless within these blocks, consider them branchless as well. - // This is typically used for loop control. - if (start->terminator == SPIRBlock::Select && start->merge == SPIRBlock::MergeNone && - (block_is_outside_flow_control_from_block(get(start->true_block), to) || - block_is_outside_flow_control_from_block(get(start->false_block), to))) - { - return true; - } - else if (start->merge_block && block_is_outside_flow_control_from_block(get(start->merge_block), to)) - { - return true; - } - else if (start->next_block && block_is_outside_flow_control_from_block(get(start->next_block), to)) - { - return true; - } - else - return false; -} - -bool Compiler::execution_is_noop(const SPIRBlock &from, const SPIRBlock &to) const -{ - if (!execution_is_branchless(from, to)) - return false; - - auto *start = &from; - for (;;) - { - if (start->self == to.self) - return true; - - if (!start->ops.empty()) - return false; - - start = &get(start->next_block); - } -} - -bool Compiler::execution_is_branchless(const SPIRBlock &from, const SPIRBlock &to) const -{ - auto *start = &from; - for (;;) - { - if (start->self == to.self) - return true; - - if (start->terminator == SPIRBlock::Direct && start->merge == SPIRBlock::MergeNone) - start = &get(start->next_block); - else - return false; - } -} - -SPIRBlock::ContinueBlockType Compiler::continue_block_type(const SPIRBlock &block) const -{ - // The block was deemed too complex during code emit, pick conservative fallback paths. - if (block.complex_continue) - return SPIRBlock::ComplexLoop; - - // In older glslang output continue block can be equal to the loop header. - // In this case, execution is clearly branchless, so just assume a while loop header here. - if (block.merge == SPIRBlock::MergeLoop) - return SPIRBlock::WhileLoop; - - auto &dominator = get(block.loop_dominator); - - if (execution_is_noop(block, dominator)) - return SPIRBlock::WhileLoop; - else if (execution_is_branchless(block, dominator)) - return SPIRBlock::ForLoop; - else - { - if (block.merge == SPIRBlock::MergeNone && block.terminator == SPIRBlock::Select && - block.true_block == dominator.self && block.false_block == dominator.merge_block) - { - return SPIRBlock::DoWhileLoop; - } - else - return SPIRBlock::ComplexLoop; - } -} - -bool Compiler::traverse_all_reachable_opcodes(const SPIRBlock &block, OpcodeHandler &handler) const -{ - handler.set_current_block(block); - - // Ideally, perhaps traverse the CFG instead of all blocks in order to eliminate dead blocks, - // but this shouldn't be a problem in practice unless the SPIR-V is doing insane things like recursing - // inside dead blocks ... - for (auto &i : block.ops) - { - auto ops = stream(i); - auto op = static_cast(i.op); - - if (!handler.handle(op, ops, i.length)) - return false; - - if (op == OpFunctionCall) - { - auto &func = get(ops[2]); - if (handler.follow_function_call(func)) - { - if (!handler.begin_function_scope(ops, i.length)) - return false; - if (!traverse_all_reachable_opcodes(get(ops[2]), handler)) - return false; - if (!handler.end_function_scope(ops, i.length)) - return false; - } - } - } - - return true; -} - -bool Compiler::traverse_all_reachable_opcodes(const SPIRFunction &func, OpcodeHandler &handler) const -{ - for (auto block : func.blocks) - if (!traverse_all_reachable_opcodes(get(block), handler)) - return false; - - return true; -} - -uint32_t Compiler::type_struct_member_offset(const SPIRType &type, uint32_t index) const -{ - // Decoration must be set in valid SPIR-V, otherwise throw. - auto &dec = meta[type.self].members.at(index); - if (dec.decoration_flags & (1ull << DecorationOffset)) - return dec.offset; - else - SPIRV_CROSS_THROW("Struct member does not have Offset set."); -} - -uint32_t Compiler::type_struct_member_array_stride(const SPIRType &type, uint32_t index) const -{ - // Decoration must be set in valid SPIR-V, otherwise throw. - // ArrayStride is part of the array type not OpMemberDecorate. - auto &dec = meta[type.member_types[index]].decoration; - if (dec.decoration_flags & (1ull << DecorationArrayStride)) - return dec.array_stride; - else - SPIRV_CROSS_THROW("Struct member does not have ArrayStride set."); -} - -uint32_t Compiler::type_struct_member_matrix_stride(const SPIRType &type, uint32_t index) const -{ - // Decoration must be set in valid SPIR-V, otherwise throw. - // MatrixStride is part of OpMemberDecorate. - auto &dec = meta[type.self].members[index]; - if (dec.decoration_flags & (1ull << DecorationMatrixStride)) - return dec.matrix_stride; - else - SPIRV_CROSS_THROW("Struct member does not have MatrixStride set."); -} - -size_t Compiler::get_declared_struct_size(const SPIRType &type) const -{ - uint32_t last = uint32_t(type.member_types.size() - 1); - size_t offset = type_struct_member_offset(type, last); - size_t size = get_declared_struct_member_size(type, last); - return offset + size; -} - -size_t Compiler::get_declared_struct_member_size(const SPIRType &struct_type, uint32_t index) const -{ - auto flags = get_member_decoration_mask(struct_type.self, index); - auto &type = get(struct_type.member_types[index]); - - switch (type.basetype) - { - case SPIRType::Unknown: - case SPIRType::Void: - case SPIRType::Boolean: // Bools are purely logical, and cannot be used for externally visible types. - case SPIRType::AtomicCounter: - case SPIRType::Image: - case SPIRType::SampledImage: - case SPIRType::Sampler: - SPIRV_CROSS_THROW("Querying size for object with opaque size."); - - default: - break; - } - - if (!type.array.empty()) - { - // For arrays, we can use ArrayStride to get an easy check. - return type_struct_member_array_stride(struct_type, index) * type.array.back(); - } - else if (type.basetype == SPIRType::Struct) - { - return get_declared_struct_size(type); - } - else - { - unsigned vecsize = type.vecsize; - unsigned columns = type.columns; - - // Vectors. - if (columns == 1) - { - size_t component_size = type.width / 8; - return vecsize * component_size; - } - else - { - uint32_t matrix_stride = type_struct_member_matrix_stride(struct_type, index); - - // Per SPIR-V spec, matrices must be tightly packed and aligned up for vec3 accesses. - if (flags & (1ull << DecorationRowMajor)) - return matrix_stride * vecsize; - else if (flags & (1ull << DecorationColMajor)) - return matrix_stride * columns; - else - SPIRV_CROSS_THROW("Either row-major or column-major must be declared for matrices."); - } - } -} - -bool Compiler::BufferAccessHandler::handle(Op opcode, const uint32_t *args, uint32_t length) -{ - if (opcode != OpAccessChain && opcode != OpInBoundsAccessChain) - return true; - - // Invalid SPIR-V. - if (length < 4) - return false; - - if (args[2] != id) - return true; - - // Don't bother traversing the entire access chain tree yet. - // If we access a struct member, assume we access the entire member. - uint32_t index = compiler.get(args[3]).scalar(); - - // Seen this index already. - if (seen.find(index) != end(seen)) - return true; - seen.insert(index); - - auto &type = compiler.expression_type(id); - uint32_t offset = compiler.type_struct_member_offset(type, index); - - size_t range; - // If we have another member in the struct, deduce the range by looking at the next member. - // This is okay since structs in SPIR-V can have padding, but Offset decoration must be - // monotonically increasing. - // Of course, this doesn't take into account if the SPIR-V for some reason decided to add - // very large amounts of padding, but that's not really a big deal. - if (index + 1 < type.member_types.size()) - { - range = compiler.type_struct_member_offset(type, index + 1) - offset; - } - else - { - // No padding, so just deduce it from the size of the member directly. - range = compiler.get_declared_struct_member_size(type, index); - } - - ranges.push_back({ index, offset, range }); - return true; -} - -std::vector Compiler::get_active_buffer_ranges(uint32_t id) const -{ - std::vector ranges; - BufferAccessHandler handler(*this, ranges, id); - traverse_all_reachable_opcodes(get(entry_point), handler); - return ranges; -} - -// Increase the number of IDs by the specified incremental amount. -// Returns the value of the first ID available for use in the expanded bound. -uint32_t Compiler::increase_bound_by(uint32_t incr_amount) -{ - auto curr_bound = ids.size(); - auto new_bound = curr_bound + incr_amount; - ids.resize(new_bound); - meta.resize(new_bound); - return uint32_t(curr_bound); -} - -bool Compiler::types_are_logically_equivalent(const SPIRType &a, const SPIRType &b) const -{ - if (a.basetype != b.basetype) - return false; - if (a.width != b.width) - return false; - if (a.vecsize != b.vecsize) - return false; - if (a.columns != b.columns) - return false; - if (a.array.size() != b.array.size()) - return false; - - size_t array_count = a.array.size(); - if (array_count && memcmp(a.array.data(), b.array.data(), array_count * sizeof(uint32_t)) != 0) - return false; - - if (a.basetype == SPIRType::Image || a.basetype == SPIRType::SampledImage) - { - if (memcmp(&a.image, &b.image, sizeof(SPIRType::Image)) != 0) - return false; - } - - if (a.member_types.size() != b.member_types.size()) - return false; - - size_t member_types = a.member_types.size(); - for (size_t i = 0; i < member_types; i++) - { - if (!types_are_logically_equivalent(get(a.member_types[i]), get(b.member_types[i]))) - return false; - } - - return true; -} - -uint64_t Compiler::get_execution_mode_mask() const -{ - return get_entry_point().flags; -} - -void Compiler::set_execution_mode(ExecutionMode mode, uint32_t arg0, uint32_t arg1, uint32_t arg2) -{ - auto &execution = get_entry_point(); - - execution.flags |= 1ull << mode; - switch (mode) - { - case ExecutionModeLocalSize: - execution.workgroup_size.x = arg0; - execution.workgroup_size.y = arg1; - execution.workgroup_size.z = arg2; - break; - - case ExecutionModeInvocations: - execution.invocations = arg0; - break; - - case ExecutionModeOutputVertices: - execution.output_vertices = arg0; - break; - - default: - break; - } -} - -void Compiler::unset_execution_mode(ExecutionMode mode) -{ - auto &execution = get_entry_point(); - execution.flags &= ~(1ull << mode); -} - -uint32_t Compiler::get_work_group_size_specialization_constants(SpecializationConstant &x, SpecializationConstant &y, - SpecializationConstant &z) const -{ - auto &execution = get_entry_point(); - x = { 0, 0 }; - y = { 0, 0 }; - z = { 0, 0 }; - - if (execution.workgroup_size.constant != 0) - { - auto &c = get(execution.workgroup_size.constant); - - if (c.m.c[0].id[0] != 0) - { - x.id = c.m.c[0].id[0]; - x.constant_id = get_decoration(c.m.c[0].id[0], DecorationSpecId); - } - - if (c.m.c[0].id[1] != 0) - { - y.id = c.m.c[0].id[1]; - y.constant_id = get_decoration(c.m.c[0].id[1], DecorationSpecId); - } - - if (c.m.c[0].id[2] != 0) - { - z.id = c.m.c[0].id[2]; - z.constant_id = get_decoration(c.m.c[0].id[2], DecorationSpecId); - } - } - - return execution.workgroup_size.constant; -} - -uint32_t Compiler::get_execution_mode_argument(spv::ExecutionMode mode, uint32_t index) const -{ - auto &execution = get_entry_point(); - switch (mode) - { - case ExecutionModeLocalSize: - switch (index) - { - case 0: - return execution.workgroup_size.x; - case 1: - return execution.workgroup_size.y; - case 2: - return execution.workgroup_size.z; - default: - return 0; - } - - case ExecutionModeInvocations: - return execution.invocations; - - case ExecutionModeOutputVertices: - return execution.output_vertices; - - default: - return 0; - } -} - -ExecutionModel Compiler::get_execution_model() const -{ - auto &execution = get_entry_point(); - return execution.model; -} - -void Compiler::set_remapped_variable_state(uint32_t id, bool remap_enable) -{ - get(id).remapped_variable = remap_enable; -} - -bool Compiler::get_remapped_variable_state(uint32_t id) const -{ - return get(id).remapped_variable; -} - -void Compiler::set_subpass_input_remapped_components(uint32_t id, uint32_t components) -{ - get(id).remapped_components = components; -} - -uint32_t Compiler::get_subpass_input_remapped_components(uint32_t id) const -{ - return get(id).remapped_components; -} - -void Compiler::inherit_expression_dependencies(uint32_t dst, uint32_t source_expression) -{ - // Don't inherit any expression dependencies if the expression in dst - // is not a forwarded temporary. - if (forwarded_temporaries.find(dst) == end(forwarded_temporaries) || - forced_temporaries.find(dst) != end(forced_temporaries)) - { - return; - } - - auto &e = get(dst); - auto *s = maybe_get(source_expression); - if (!s) - return; - - auto &e_deps = e.expression_dependencies; - auto &s_deps = s->expression_dependencies; - - // If we depend on a expression, we also depend on all sub-dependencies from source. - e_deps.push_back(source_expression); - e_deps.insert(end(e_deps), begin(s_deps), end(s_deps)); - - // Eliminate duplicated dependencies. - e_deps.erase(unique(begin(e_deps), end(e_deps)), end(e_deps)); -} - -vector Compiler::get_entry_points() const -{ - vector entries; - for (auto &entry : entry_points) - entries.push_back(entry.second.orig_name); - return entries; -} - -void Compiler::rename_entry_point(const std::string &old_name, const std::string &new_name) -{ - auto &entry = get_entry_point(old_name); - entry.orig_name = new_name; - entry.name = new_name; -} - -void Compiler::set_entry_point(const std::string &name) -{ - auto &entry = get_entry_point(name); - entry_point = entry.self; -} - -SPIREntryPoint &Compiler::get_entry_point(const std::string &name) -{ - auto itr = - find_if(begin(entry_points), end(entry_points), [&](const std::pair &entry) -> bool { - return entry.second.orig_name == name; - }); - - if (itr == end(entry_points)) - SPIRV_CROSS_THROW("Entry point does not exist."); - - return itr->second; -} - -const SPIREntryPoint &Compiler::get_entry_point(const std::string &name) const -{ - auto itr = - find_if(begin(entry_points), end(entry_points), [&](const std::pair &entry) -> bool { - return entry.second.orig_name == name; - }); - - if (itr == end(entry_points)) - SPIRV_CROSS_THROW("Entry point does not exist."); - - return itr->second; -} - -const string &Compiler::get_cleansed_entry_point_name(const std::string &name) const -{ - return get_entry_point(name).name; -} - -const SPIREntryPoint &Compiler::get_entry_point() const -{ - return entry_points.find(entry_point)->second; -} - -SPIREntryPoint &Compiler::get_entry_point() -{ - return entry_points.find(entry_point)->second; -} - -bool Compiler::interface_variable_exists_in_entry_point(uint32_t id) const -{ - auto &var = get(id); - if (var.storage != StorageClassInput && var.storage != StorageClassOutput && - var.storage != StorageClassUniformConstant) - SPIRV_CROSS_THROW("Only Input, Output variables and Uniform constants are part of a shader linking interface."); - - // This is to avoid potential problems with very old glslang versions which did - // not emit input/output interfaces properly. - // We can assume they only had a single entry point, and single entry point - // shaders could easily be assumed to use every interface variable anyways. - if (entry_points.size() <= 1) - return true; - - auto &execution = get_entry_point(); - return find(begin(execution.interface_variables), end(execution.interface_variables), id) != - end(execution.interface_variables); -} - -void Compiler::CombinedImageSamplerHandler::push_remap_parameters(const SPIRFunction &func, const uint32_t *args, - uint32_t length) -{ - // If possible, pipe through a remapping table so that parameters know - // which variables they actually bind to in this scope. - unordered_map remapping; - for (uint32_t i = 0; i < length; i++) - remapping[func.arguments[i].id] = remap_parameter(args[i]); - parameter_remapping.push(move(remapping)); -} - -void Compiler::CombinedImageSamplerHandler::pop_remap_parameters() -{ - parameter_remapping.pop(); -} - -uint32_t Compiler::CombinedImageSamplerHandler::remap_parameter(uint32_t id) -{ - auto *var = compiler.maybe_get_backing_variable(id); - if (var) - id = var->self; - - if (parameter_remapping.empty()) - return id; - - auto &remapping = parameter_remapping.top(); - auto itr = remapping.find(id); - if (itr != end(remapping)) - return itr->second; - else - return id; -} - -bool Compiler::CombinedImageSamplerHandler::begin_function_scope(const uint32_t *args, uint32_t length) -{ - if (length < 3) - return false; - - auto &callee = compiler.get(args[2]); - args += 3; - length -= 3; - push_remap_parameters(callee, args, length); - functions.push(&callee); - return true; -} - -bool Compiler::CombinedImageSamplerHandler::end_function_scope(const uint32_t *args, uint32_t length) -{ - if (length < 3) - return false; - - auto &callee = compiler.get(args[2]); - args += 3; - - // There are two types of cases we have to handle, - // a callee might call sampler2D(texture2D, sampler) directly where - // one or more parameters originate from parameters. - // Alternatively, we need to provide combined image samplers to our callees, - // and in this case we need to add those as well. - - pop_remap_parameters(); - - // Our callee has now been processed at least once. - // No point in doing it again. - callee.do_combined_parameters = false; - - auto ¶ms = functions.top()->combined_parameters; - functions.pop(); - if (functions.empty()) - return true; - - auto &caller = *functions.top(); - if (caller.do_combined_parameters) - { - for (auto ¶m : params) - { - uint32_t image_id = param.global_image ? param.image_id : args[param.image_id]; - uint32_t sampler_id = param.global_sampler ? param.sampler_id : args[param.sampler_id]; - - auto *i = compiler.maybe_get_backing_variable(image_id); - auto *s = compiler.maybe_get_backing_variable(sampler_id); - if (i) - image_id = i->self; - if (s) - sampler_id = s->self; - - register_combined_image_sampler(caller, image_id, sampler_id, param.depth); - } - } - - return true; -} - -void Compiler::CombinedImageSamplerHandler::register_combined_image_sampler(SPIRFunction &caller, uint32_t image_id, - uint32_t sampler_id, bool depth) -{ - // We now have a texture ID and a sampler ID which will either be found as a global - // or a parameter in our own function. If both are global, they will not need a parameter, - // otherwise, add it to our list. - SPIRFunction::CombinedImageSamplerParameter param = { - 0u, image_id, sampler_id, true, true, depth, - }; - - auto texture_itr = find_if(begin(caller.arguments), end(caller.arguments), - [image_id](const SPIRFunction::Parameter &p) { return p.id == image_id; }); - auto sampler_itr = find_if(begin(caller.arguments), end(caller.arguments), - [sampler_id](const SPIRFunction::Parameter &p) { return p.id == sampler_id; }); - - if (texture_itr != end(caller.arguments)) - { - param.global_image = false; - param.image_id = uint32_t(texture_itr - begin(caller.arguments)); - } - - if (sampler_itr != end(caller.arguments)) - { - param.global_sampler = false; - param.sampler_id = uint32_t(sampler_itr - begin(caller.arguments)); - } - - if (param.global_image && param.global_sampler) - return; - - auto itr = find_if(begin(caller.combined_parameters), end(caller.combined_parameters), - [¶m](const SPIRFunction::CombinedImageSamplerParameter &p) { - return param.image_id == p.image_id && param.sampler_id == p.sampler_id && - param.global_image == p.global_image && param.global_sampler == p.global_sampler; - }); - - if (itr == end(caller.combined_parameters)) - { - uint32_t id = compiler.increase_bound_by(3); - auto type_id = id + 0; - auto ptr_type_id = id + 1; - auto combined_id = id + 2; - auto &base = compiler.expression_type(image_id); - auto &type = compiler.set(type_id); - auto &ptr_type = compiler.set(ptr_type_id); - - type = base; - type.self = type_id; - type.basetype = SPIRType::SampledImage; - type.pointer = false; - type.storage = StorageClassGeneric; - type.image.depth = depth; - - ptr_type = type; - ptr_type.pointer = true; - ptr_type.storage = StorageClassUniformConstant; - - // Build new variable. - compiler.set(combined_id, ptr_type_id, StorageClassFunction, 0); - - // Inherit RelaxedPrecision (and potentially other useful flags if deemed relevant). - auto &new_flags = compiler.meta[combined_id].decoration.decoration_flags; - auto old_flags = compiler.meta[sampler_id].decoration.decoration_flags; - new_flags = old_flags & (1ull << DecorationRelaxedPrecision); - - param.id = combined_id; - - compiler.set_name(combined_id, - join("SPIRV_Cross_Combined", compiler.to_name(image_id), compiler.to_name(sampler_id))); - - caller.combined_parameters.push_back(param); - caller.shadow_arguments.push_back({ ptr_type_id, combined_id, 0u, 0u, true }); - } -} - -bool Compiler::CombinedImageSamplerHandler::handle(Op opcode, const uint32_t *args, uint32_t length) -{ - // We need to figure out where samplers and images are loaded from, so do only the bare bones compilation we need. - switch (opcode) - { - case OpLoad: - { - if (length < 3) - return false; - - uint32_t result_type = args[0]; - - auto &type = compiler.get(result_type); - bool separate_image = type.basetype == SPIRType::Image && type.image.sampled == 1; - bool separate_sampler = type.basetype == SPIRType::Sampler; - - // If not separate image or sampler, don't bother. - if (!separate_image && !separate_sampler) - return true; - - uint32_t id = args[1]; - uint32_t ptr = args[2]; - compiler.set(id, "", result_type, true); - compiler.register_read(id, ptr, true); - return true; - } - - case OpInBoundsAccessChain: - case OpAccessChain: - { - if (length < 3) - return false; - - // Technically, it is possible to have arrays of textures and arrays of samplers and combine them, but this becomes essentially - // impossible to implement, since we don't know which concrete sampler we are accessing. - // One potential way is to create a combinatorial explosion where N textures and M samplers are combined into N * M sampler2Ds, - // but this seems ridiculously complicated for a problem which is easy to work around. - // Checking access chains like this assumes we don't have samplers or textures inside uniform structs, but this makes no sense. - - auto &type = compiler.get(args[0]); - bool separate_image = type.basetype == SPIRType::Image && type.image.sampled == 1; - bool separate_sampler = type.basetype == SPIRType::Sampler; - if (separate_image) - SPIRV_CROSS_THROW("Attempting to use arrays or structs of separate images. This is not possible to " - "statically remap to plain GLSL."); - if (separate_sampler) - SPIRV_CROSS_THROW( - "Attempting to use arrays or structs of separate samplers. This is not possible to statically " - "remap to plain GLSL."); - return true; - } - - case OpSampledImage: - // Do it outside. - break; - - default: - return true; - } - - if (length < 4) - return false; - - // Registers sampler2D calls used in case they are parameters so - // that their callees know which combined image samplers to propagate down the call stack. - if (!functions.empty()) - { - auto &callee = *functions.top(); - if (callee.do_combined_parameters) - { - uint32_t image_id = args[2]; - - auto *image = compiler.maybe_get_backing_variable(image_id); - if (image) - image_id = image->self; - - uint32_t sampler_id = args[3]; - auto *sampler = compiler.maybe_get_backing_variable(sampler_id); - if (sampler) - sampler_id = sampler->self; - - auto &combined_type = compiler.get(args[0]); - register_combined_image_sampler(callee, image_id, sampler_id, combined_type.image.depth); - } - } - - // For function calls, we need to remap IDs which are function parameters into global variables. - // This information is statically known from the current place in the call stack. - // Function parameters are not necessarily pointers, so if we don't have a backing variable, remapping will know - // which backing variable the image/sample came from. - uint32_t image_id = remap_parameter(args[2]); - uint32_t sampler_id = remap_parameter(args[3]); - - auto itr = find_if(begin(compiler.combined_image_samplers), end(compiler.combined_image_samplers), - [image_id, sampler_id](const CombinedImageSampler &combined) { - return combined.image_id == image_id && combined.sampler_id == sampler_id; - }); - - if (itr == end(compiler.combined_image_samplers)) - { - auto id = compiler.increase_bound_by(2); - auto type_id = id + 0; - auto combined_id = id + 1; - auto sampled_type = args[0]; - - // Make a new type, pointer to OpTypeSampledImage, so we can make a variable of this type. - // We will probably have this type lying around, but it doesn't hurt to make duplicates for internal purposes. - auto &type = compiler.set(type_id); - auto &base = compiler.get(sampled_type); - type = base; - type.pointer = true; - type.storage = StorageClassUniformConstant; - - // Build new variable. - compiler.set(combined_id, type_id, StorageClassUniformConstant, 0); - - // Inherit RelaxedPrecision (and potentially other useful flags if deemed relevant). - auto &new_flags = compiler.meta[combined_id].decoration.decoration_flags; - auto old_flags = compiler.meta[sampler_id].decoration.decoration_flags; - new_flags = old_flags & (1ull << DecorationRelaxedPrecision); - - compiler.combined_image_samplers.push_back({ combined_id, image_id, sampler_id }); - } - - return true; -} - -void Compiler::build_combined_image_samplers() -{ - for (auto &id : ids) - { - if (id.get_type() == TypeFunction) - { - auto &func = id.get(); - func.combined_parameters.clear(); - func.shadow_arguments.clear(); - func.do_combined_parameters = true; - } - } - - combined_image_samplers.clear(); - CombinedImageSamplerHandler handler(*this); - traverse_all_reachable_opcodes(get(entry_point), handler); -} - -vector Compiler::get_specialization_constants() const -{ - vector spec_consts; - for (auto &id : ids) - { - if (id.get_type() == TypeConstant) - { - auto &c = id.get(); - if (c.specialization) - { - spec_consts.push_back({ c.self, get_decoration(c.self, DecorationSpecId) }); - } - } - } - return spec_consts; -} - -SPIRConstant &Compiler::get_constant(uint32_t id) -{ - return get(id); -} - -const SPIRConstant &Compiler::get_constant(uint32_t id) const -{ - return get(id); -} - -// Recursively marks any constants referenced by the specified constant instruction as being used -// as an array length. The id must be a constant instruction (SPIRConstant or SPIRConstantOp). -void Compiler::mark_used_as_array_length(uint32_t id) -{ - switch (ids[id].get_type()) - { - case TypeConstant: - get(id).is_used_as_array_length = true; - break; - - case TypeConstantOp: - { - auto &cop = get(id); - for (uint32_t arg_id : cop.arguments) - mark_used_as_array_length(arg_id); - } - - case TypeUndef: - return; - - default: - SPIRV_CROSS_THROW("Array lengths must be a constant instruction (OpConstant.. or OpSpecConstant...)."); - } -} - -static bool exists_unaccessed_path_to_return(const CFG &cfg, uint32_t block, const unordered_set &blocks) -{ - // This block accesses the variable. - if (blocks.find(block) != end(blocks)) - return false; - - // We are at the end of the CFG. - if (cfg.get_succeeding_edges(block).empty()) - return true; - - // If any of our successors have a path to the end, there exists a path from block. - for (auto &succ : cfg.get_succeeding_edges(block)) - if (exists_unaccessed_path_to_return(cfg, succ, blocks)) - return true; - - return false; -} - -void Compiler::analyze_parameter_preservation( - SPIRFunction &entry, const CFG &cfg, const unordered_map> &variable_to_blocks, - const unordered_map> &complete_write_blocks) -{ - for (auto &arg : entry.arguments) - { - // Non-pointers are always inputs. - auto &type = get(arg.type); - if (!type.pointer) - continue; - - // Opaque argument types are always in - bool potential_preserve; - switch (type.basetype) - { - case SPIRType::Sampler: - case SPIRType::Image: - case SPIRType::SampledImage: - case SPIRType::AtomicCounter: - potential_preserve = false; - break; - - default: - potential_preserve = true; - break; - } - - if (!potential_preserve) - continue; - - auto itr = variable_to_blocks.find(arg.id); - if (itr == end(variable_to_blocks)) - { - // Variable is never accessed. - continue; - } - - // We have accessed a variable, but there was no complete writes to that variable. - // We deduce that we must preserve the argument. - itr = complete_write_blocks.find(arg.id); - if (itr == end(complete_write_blocks)) - { - arg.read_count++; - continue; - } - - // If there is a path through the CFG where no block completely writes to the variable, the variable will be in an undefined state - // when the function returns. We therefore need to implicitly preserve the variable in case there are writers in the function. - // Major case here is if a function is - // void foo(int &var) { if (cond) var = 10; } - // Using read/write counts, we will think it's just an out variable, but it really needs to be inout, - // because if we don't write anything whatever we put into the function must return back to the caller. - if (exists_unaccessed_path_to_return(cfg, entry.entry_block, itr->second)) - arg.read_count++; - } -} - -void Compiler::analyze_variable_scope(SPIRFunction &entry) -{ - struct AccessHandler : OpcodeHandler - { - public: - AccessHandler(Compiler &compiler_, SPIRFunction &entry_) - : compiler(compiler_) - , entry(entry_) - { - } - - bool follow_function_call(const SPIRFunction &) - { - // Only analyze within this function. - return false; - } - - void set_current_block(const SPIRBlock &block) - { - current_block = █ - - // If we're branching to a block which uses OpPhi, in GLSL - // this will be a variable write when we branch, - // so we need to track access to these variables as well to - // have a complete picture. - const auto test_phi = [this, &block](uint32_t to) { - auto &next = compiler.get(to); - for (auto &phi : next.phi_variables) - { - if (phi.parent == block.self) - { - accessed_variables_to_block[phi.function_variable].insert(block.self); - // Phi variables are also accessed in our target branch block. - accessed_variables_to_block[phi.function_variable].insert(next.self); - - notify_variable_access(phi.local_variable, block.self); - } - } - }; - - switch (block.terminator) - { - case SPIRBlock::Direct: - notify_variable_access(block.condition, block.self); - test_phi(block.next_block); - break; - - case SPIRBlock::Select: - notify_variable_access(block.condition, block.self); - test_phi(block.true_block); - test_phi(block.false_block); - break; - - case SPIRBlock::MultiSelect: - notify_variable_access(block.condition, block.self); - for (auto &target : block.cases) - test_phi(target.block); - if (block.default_block) - test_phi(block.default_block); - break; - - default: - break; - } - } - - void notify_variable_access(uint32_t id, uint32_t block) - { - if (id_is_phi_variable(id)) - accessed_variables_to_block[id].insert(block); - else if (id_is_potential_temporary(id)) - accessed_temporaries_to_block[id].insert(block); - } - - bool id_is_phi_variable(uint32_t id) - { - if (id >= compiler.get_current_id_bound()) - return false; - auto *var = compiler.maybe_get(id); - return var && var->phi_variable; - } - - bool id_is_potential_temporary(uint32_t id) - { - if (id >= compiler.get_current_id_bound()) - return false; - - // Temporaries are not created before we start emitting code. - return compiler.ids[id].empty() || (compiler.ids[id].get_type() == TypeExpression); - } - - bool handle(spv::Op op, const uint32_t *args, uint32_t length) - { - // Keep track of the types of temporaries, so we can hoist them out as necessary. - uint32_t result_type, result_id; - if (compiler.instruction_to_result_type(result_type, result_id, op, args, length)) - result_id_to_type[result_id] = result_type; - - switch (op) - { - case OpStore: - { - if (length < 2) - return false; - - uint32_t ptr = args[0]; - auto *var = compiler.maybe_get_backing_variable(ptr); - if (var && var->storage == StorageClassFunction) - accessed_variables_to_block[var->self].insert(current_block->self); - - // If we store through an access chain, we have a partial write. - if (var && var->self == ptr && var->storage == StorageClassFunction) - complete_write_variables_to_block[var->self].insert(current_block->self); - - // Might try to store a Phi variable here. - notify_variable_access(args[1], current_block->self); - break; - } - - case OpAccessChain: - case OpInBoundsAccessChain: - { - if (length < 3) - return false; - - uint32_t ptr = args[2]; - auto *var = compiler.maybe_get(ptr); - if (var && var->storage == StorageClassFunction) - accessed_variables_to_block[var->self].insert(current_block->self); - - for (uint32_t i = 3; i < length; i++) - notify_variable_access(args[i], current_block->self); - - // The result of an access chain is a fixed expression and is not really considered a temporary. - break; - } - - case OpCopyMemory: - { - if (length < 2) - return false; - - uint32_t lhs = args[0]; - uint32_t rhs = args[1]; - auto *var = compiler.maybe_get_backing_variable(lhs); - if (var && var->storage == StorageClassFunction) - accessed_variables_to_block[var->self].insert(current_block->self); - - // If we store through an access chain, we have a partial write. - if (var->self == lhs) - complete_write_variables_to_block[var->self].insert(current_block->self); - - var = compiler.maybe_get_backing_variable(rhs); - if (var && var->storage == StorageClassFunction) - accessed_variables_to_block[var->self].insert(current_block->self); - break; - } - - case OpCopyObject: - { - if (length < 3) - return false; - - auto *var = compiler.maybe_get_backing_variable(args[2]); - if (var && var->storage == StorageClassFunction) - accessed_variables_to_block[var->self].insert(current_block->self); - - // Might try to copy a Phi variable here. - notify_variable_access(args[2], current_block->self); - break; - } - - case OpLoad: - { - if (length < 3) - return false; - uint32_t ptr = args[2]; - auto *var = compiler.maybe_get_backing_variable(ptr); - if (var && var->storage == StorageClassFunction) - accessed_variables_to_block[var->self].insert(current_block->self); - - // Loaded value is a temporary. - notify_variable_access(args[1], current_block->self); - break; - } - - case OpFunctionCall: - { - if (length < 3) - return false; - - length -= 3; - args += 3; - for (uint32_t i = 0; i < length; i++) - { - auto *var = compiler.maybe_get_backing_variable(args[i]); - if (var && var->storage == StorageClassFunction) - accessed_variables_to_block[var->self].insert(current_block->self); - - // Cannot easily prove if argument we pass to a function is completely written. - // Usually, functions write to a dummy variable, - // which is then copied to in full to the real argument. - - // Might try to copy a Phi variable here. - notify_variable_access(args[i], current_block->self); - } - - // Return value may be a temporary. - notify_variable_access(args[1], current_block->self); - break; - } - - case OpExtInst: - { - for (uint32_t i = 4; i < length; i++) - notify_variable_access(args[i], current_block->self); - notify_variable_access(args[1], current_block->self); - break; - } - - case OpArrayLength: - // Uses literals, but cannot be a phi variable, so ignore. - break; - - // Atomics shouldn't be able to access function-local variables. - // Some GLSL builtins access a pointer. - - case OpCompositeInsert: - case OpVectorShuffle: - // Specialize for opcode which contains literals. - for (uint32_t i = 1; i < 4; i++) - notify_variable_access(args[i], current_block->self); - break; - - case OpCompositeExtract: - // Specialize for opcode which contains literals. - for (uint32_t i = 1; i < 3; i++) - notify_variable_access(args[i], current_block->self); - break; - - default: - { - // Rather dirty way of figuring out where Phi variables are used. - // As long as only IDs are used, we can scan through instructions and try to find any evidence that - // the ID of a variable has been used. - // There are potential false positives here where a literal is used in-place of an ID, - // but worst case, it does not affect the correctness of the compile. - // Exhaustive analysis would be better here, but it's not worth it for now. - for (uint32_t i = 0; i < length; i++) - notify_variable_access(args[i], current_block->self); - break; - } - } - return true; - } - - Compiler &compiler; - SPIRFunction &entry; - std::unordered_map> accessed_variables_to_block; - std::unordered_map> accessed_temporaries_to_block; - std::unordered_map result_id_to_type; - std::unordered_map> complete_write_variables_to_block; - const SPIRBlock *current_block = nullptr; - } handler(*this, entry); - - // First, we map out all variable access within a function. - // Essentially a map of block -> { variables accessed in the basic block } - this->traverse_all_reachable_opcodes(entry, handler); - - // Compute the control flow graph for this function. - CFG cfg(*this, entry); - - // Analyze if there are parameters which need to be implicitly preserved with an "in" qualifier. - analyze_parameter_preservation(entry, cfg, handler.accessed_variables_to_block, - handler.complete_write_variables_to_block); - - unordered_map potential_loop_variables; - - // For each variable which is statically accessed. - for (auto &var : handler.accessed_variables_to_block) - { - DominatorBuilder builder(cfg); - auto &blocks = var.second; - auto &type = this->expression_type(var.first); - - // Figure out which block is dominating all accesses of those variables. - for (auto &block : blocks) - { - // If we're accessing a variable inside a continue block, this variable might be a loop variable. - // We can only use loop variables with scalars, as we cannot track static expressions for vectors. - if (this->is_continue(block)) - { - // Potentially awkward case to check for. - // We might have a variable inside a loop, which is touched by the continue block, - // but is not actually a loop variable. - // The continue block is dominated by the inner part of the loop, which does not make sense in high-level - // language output because it will be declared before the body, - // so we will have to lift the dominator up to the relevant loop header instead. - builder.add_block(continue_block_to_loop_header[block]); - - if (type.vecsize == 1 && type.columns == 1) - { - // The variable is used in multiple continue blocks, this is not a loop - // candidate, signal that by setting block to -1u. - auto &potential = potential_loop_variables[var.first]; - - if (potential == 0) - potential = block; - else - potential = ~(0u); - } - } - builder.add_block(block); - } - - builder.lift_continue_block_dominator(); - - // Add it to a per-block list of variables. - uint32_t dominating_block = builder.get_dominator(); - - // If all blocks here are dead code, this will be 0, so the variable in question - // will be completely eliminated. - if (dominating_block) - { - auto &block = this->get(dominating_block); - block.dominated_variables.push_back(var.first); - this->get(var.first).dominator = dominating_block; - } - } - - for (auto &var : handler.accessed_temporaries_to_block) - { - auto itr = handler.result_id_to_type.find(var.first); - - if (itr == end(handler.result_id_to_type)) - { - // We found a false positive ID being used, ignore. - // This should probably be an assert. - continue; - } - - DominatorBuilder builder(cfg); - - // Figure out which block is dominating all accesses of those temporaries. - auto &blocks = var.second; - for (auto &block : blocks) - { - builder.add_block(block); - - // If a temporary is used in more than one block, we might have to lift continue block - // access up to loop header like we did for variables. - if (blocks.size() != 1 && this->is_continue(block)) - builder.add_block(continue_block_to_loop_header[block]); - } - - uint32_t dominating_block = builder.get_dominator(); - if (dominating_block) - { - // If we touch a variable in the dominating block, this is the expected setup. - // SPIR-V normally mandates this, but we have extra cases for temporary use inside loops. - bool first_use_is_dominator = blocks.count(dominating_block) != 0; - - if (!first_use_is_dominator) - { - // This should be very rare, but if we try to declare a temporary inside a loop, - // and that temporary is used outside the loop as well (spirv-opt inliner likes this) - // we should actually emit the temporary outside the loop. - hoisted_temporaries.insert(var.first); - forced_temporaries.insert(var.first); - - auto &block_temporaries = get(dominating_block).declare_temporary; - block_temporaries.emplace_back(handler.result_id_to_type[var.first], var.first); - } - } - } - - unordered_set seen_blocks; - - // Now, try to analyze whether or not these variables are actually loop variables. - for (auto &loop_variable : potential_loop_variables) - { - auto &var = this->get(loop_variable.first); - auto dominator = var.dominator; - auto block = loop_variable.second; - - // The variable was accessed in multiple continue blocks, ignore. - if (block == ~(0u) || block == 0) - continue; - - // Dead code. - if (dominator == 0) - continue; - - uint32_t header = 0; - - // Find the loop header for this block. - for (auto b : this->loop_blocks) - { - auto &potential_header = this->get(b); - if (potential_header.continue_block == block) - { - header = b; - break; - } - } - - assert(header); - auto &header_block = this->get(header); - auto &blocks = handler.accessed_variables_to_block[loop_variable.first]; - - // If a loop variable is not used before the loop, it's probably not a loop variable. - bool has_accessed_variable = blocks.count(header) != 0; - - // Now, there are two conditions we need to meet for the variable to be a loop variable. - // 1. The dominating block must have a branch-free path to the loop header, - // this way we statically know which expression should be part of the loop variable initializer. - - // Walk from the dominator, if there is one straight edge connecting - // dominator and loop header, we statically know the loop initializer. - bool static_loop_init = true; - while (dominator != header) - { - if (blocks.count(dominator) != 0) - has_accessed_variable = true; - - auto &succ = cfg.get_succeeding_edges(dominator); - if (succ.size() != 1) - { - static_loop_init = false; - break; - } - - auto &pred = cfg.get_preceding_edges(succ.front()); - if (pred.size() != 1 || pred.front() != dominator) - { - static_loop_init = false; - break; - } - - dominator = succ.front(); - } - - if (!static_loop_init || !has_accessed_variable) - continue; - - // The second condition we need to meet is that no access after the loop - // merge can occur. Walk the CFG to see if we find anything. - - seen_blocks.clear(); - cfg.walk_from(seen_blocks, header_block.merge_block, [&](uint32_t walk_block) { - // We found a block which accesses the variable outside the loop. - if (blocks.find(walk_block) != end(blocks)) - static_loop_init = false; - }); - - if (!static_loop_init) - continue; - - // We have a loop variable. - header_block.loop_variables.push_back(loop_variable.first); - // Need to sort here as variables come from an unordered container, and pushing stuff in wrong order - // will break reproducability in regression runs. - sort(begin(header_block.loop_variables), end(header_block.loop_variables)); - this->get(loop_variable.first).loop_variable = true; - } -} - -uint64_t Compiler::get_buffer_block_flags(const SPIRVariable &var) -{ - auto &type = get(var.basetype); - assert(type.basetype == SPIRType::Struct); - - // Some flags like non-writable, non-readable are actually found - // as member decorations. If all members have a decoration set, propagate - // the decoration up as a regular variable decoration. - uint64_t base_flags = meta[var.self].decoration.decoration_flags; - - if (type.member_types.empty()) - return base_flags; - - uint64_t all_members_flag_mask = ~(0ull); - for (uint32_t i = 0; i < uint32_t(type.member_types.size()); i++) - all_members_flag_mask &= get_member_decoration_mask(type.self, i); - - return base_flags | all_members_flag_mask; -} - -bool Compiler::get_common_basic_type(const SPIRType &type, SPIRType::BaseType &base_type) -{ - if (type.basetype == SPIRType::Struct) - { - base_type = SPIRType::Unknown; - for (auto &member_type : type.member_types) - { - SPIRType::BaseType member_base; - if (!get_common_basic_type(get(member_type), member_base)) - return false; - - if (base_type == SPIRType::Unknown) - base_type = member_base; - else if (base_type != member_base) - return false; - } - return true; - } - else - { - base_type = type.basetype; - return true; - } -} - -bool Compiler::ActiveBuiltinHandler::handle(spv::Op opcode, const uint32_t *args, uint32_t length) -{ - const auto add_if_builtin = [&](uint32_t id) { - // Only handles variables here. - // Builtins which are part of a block are handled in AccessChain. - auto *var = compiler.maybe_get(id); - if (var && compiler.meta[id].decoration.builtin) - { - auto &type = compiler.get(var->basetype); - auto &flags = - type.storage == StorageClassInput ? compiler.active_input_builtins : compiler.active_output_builtins; - flags |= 1ull << compiler.meta[id].decoration.builtin_type; - } - }; - - switch (opcode) - { - case OpStore: - if (length < 1) - return false; - - add_if_builtin(args[0]); - break; - - case OpCopyMemory: - if (length < 2) - return false; - - add_if_builtin(args[0]); - add_if_builtin(args[1]); - break; - - case OpCopyObject: - case OpLoad: - if (length < 3) - return false; - - add_if_builtin(args[2]); - break; - - case OpFunctionCall: - { - if (length < 3) - return false; - - uint32_t count = length - 3; - args += 3; - for (uint32_t i = 0; i < count; i++) - add_if_builtin(args[i]); - break; - } - - case OpAccessChain: - case OpInBoundsAccessChain: - { - if (length < 4) - return false; - - // Only consider global variables, cannot consider variables in functions yet, or other - // access chains as they have not been created yet. - auto *var = compiler.maybe_get(args[2]); - if (!var) - break; - - // Required if we access chain into builtins like gl_GlobalInvocationID. - add_if_builtin(args[2]); - - auto *type = &compiler.get(var->basetype); - - // Start traversing type hierarchy at the proper non-pointer types. - while (type->pointer) - { - assert(type->parent_type); - type = &compiler.get(type->parent_type); - } - - auto &flags = - type->storage == StorageClassInput ? compiler.active_input_builtins : compiler.active_output_builtins; - - uint32_t count = length - 3; - args += 3; - for (uint32_t i = 0; i < count; i++) - { - // Arrays - if (!type->array.empty()) - { - type = &compiler.get(type->parent_type); - } - // Structs - else if (type->basetype == SPIRType::Struct) - { - uint32_t index = compiler.get(args[i]).scalar(); - - if (index < uint32_t(compiler.meta[type->self].members.size())) - { - auto &decorations = compiler.meta[type->self].members[index]; - if (decorations.builtin) - flags |= 1ull << decorations.builtin_type; - } - - type = &compiler.get(type->member_types[index]); - } - else - { - // No point in traversing further. We won't find any extra builtins. - break; - } - } - break; - } - - default: - break; - } - - return true; -} - -void Compiler::update_active_builtins() -{ - active_input_builtins = 0; - active_output_builtins = 0; - ActiveBuiltinHandler handler(*this); - traverse_all_reachable_opcodes(get(entry_point), handler); -} - -// Returns whether this shader uses a builtin of the storage class -bool Compiler::has_active_builtin(BuiltIn builtin, StorageClass storage) -{ - uint64_t flags; - switch (storage) - { - case StorageClassInput: - flags = active_input_builtins; - break; - case StorageClassOutput: - flags = active_output_builtins; - break; - - default: - return false; - } - return flags & (1ull << builtin); -} - -void Compiler::analyze_sampler_comparison_states() -{ - CombinedImageSamplerUsageHandler handler(*this); - traverse_all_reachable_opcodes(get(entry_point), handler); - comparison_samplers = move(handler.comparison_samplers); -} - -bool Compiler::CombinedImageSamplerUsageHandler::begin_function_scope(const uint32_t *args, uint32_t length) -{ - if (length < 3) - return false; - - auto &func = compiler.get(args[2]); - const auto *arg = &args[3]; - length -= 3; - - for (uint32_t i = 0; i < length; i++) - { - auto &argument = func.arguments[i]; - dependency_hierarchy[argument.id].insert(arg[i]); - } - - return true; -} - -void Compiler::CombinedImageSamplerUsageHandler::add_hierarchy_to_comparison_samplers(uint32_t sampler) -{ - // Traverse the variable dependency hierarchy and tag everything in its path with comparison samplers. - comparison_samplers.insert(sampler); - for (auto &samp : dependency_hierarchy[sampler]) - add_hierarchy_to_comparison_samplers(samp); -} - -bool Compiler::CombinedImageSamplerUsageHandler::handle(Op opcode, const uint32_t *args, uint32_t length) -{ - switch (opcode) - { - case OpAccessChain: - case OpInBoundsAccessChain: - case OpLoad: - { - if (length < 3) - return false; - dependency_hierarchy[args[1]].insert(args[2]); - break; - } - - case OpSampledImage: - { - if (length < 4) - return false; - - uint32_t result_type = args[0]; - auto &type = compiler.get(result_type); - if (type.image.depth) - { - // This sampler must be a SamplerComparisionState, and not a regular SamplerState. - uint32_t sampler = args[3]; - add_hierarchy_to_comparison_samplers(sampler); - } - return true; - } - - default: - break; - } - - return true; -} - -bool Compiler::buffer_is_hlsl_counter_buffer(uint32_t id) const -{ - if (meta.at(id).hlsl_magic_counter_buffer_candidate) - { - auto *var = maybe_get(id); - // Ensure that this is actually a buffer object. - return var && (var->storage == StorageClassStorageBuffer || - has_decoration(get(var->basetype).self, DecorationBufferBlock)); - } - else - return false; -} - -bool Compiler::buffer_get_hlsl_counter_buffer(uint32_t id, uint32_t &counter_id) const -{ - auto &name = get_name(id); - uint32_t id_bound = get_current_id_bound(); - for (uint32_t i = 0; i < id_bound; i++) - { - if (meta[i].hlsl_magic_counter_buffer_candidate && meta[i].hlsl_magic_counter_buffer_name == name) - { - auto *var = maybe_get(i); - // Ensure that this is actually a buffer object. - if (var && (var->storage == StorageClassStorageBuffer || - has_decoration(get(var->basetype).self, DecorationBufferBlock))) - { - counter_id = i; - return true; - } - } - } - return false; -} - -void Compiler::make_constant_null(uint32_t id, uint32_t type) -{ - auto &constant_type = get(type); - - if (!constant_type.array.empty()) - { - assert(constant_type.parent_type); - uint32_t parent_id = increase_bound_by(1); - make_constant_null(parent_id, constant_type.parent_type); - - if (!constant_type.array_size_literal.back()) - SPIRV_CROSS_THROW("Array size of OpConstantNull must be a literal."); - - vector elements(constant_type.array.back()); - for (uint32_t i = 0; i < constant_type.array.back(); i++) - elements[i] = parent_id; - set(id, type, elements.data(), uint32_t(elements.size()), false); - } - else if (!constant_type.member_types.empty()) - { - uint32_t member_ids = increase_bound_by(uint32_t(constant_type.member_types.size())); - vector elements(constant_type.member_types.size()); - for (uint32_t i = 0; i < constant_type.member_types.size(); i++) - { - make_constant_null(member_ids + i, constant_type.member_types[i]); - elements[i] = member_ids + i; - } - set(id, type, elements.data(), uint32_t(elements.size()), false); - } - else - { - auto &constant = set(id, type); - constant.make_null(constant_type); - } -} - -const std::vector &Compiler::get_declared_capabilities() const -{ - return declared_capabilities; -} - -const std::vector &Compiler::get_declared_extensions() const -{ - return declared_extensions; -} - -std::string Compiler::get_remapped_declared_block_name(uint32_t id) const -{ - auto itr = declared_block_names.find(id); - if (itr != end(declared_block_names)) - return itr->second; - else - { - auto &var = get(id); - auto &type = get(var.basetype); - auto &block_name = meta[type.self].decoration.alias; - return block_name.empty() ? get_block_fallback_name(id) : block_name; - } -} - -bool Compiler::instruction_to_result_type(uint32_t &result_type, uint32_t &result_id, spv::Op op, const uint32_t *args, - uint32_t length) -{ - // Most instructions follow the pattern of . - // There are some exceptions. - switch (op) - { - case OpStore: - case OpCopyMemory: - case OpCopyMemorySized: - case OpImageWrite: - case OpAtomicStore: - case OpAtomicFlagClear: - case OpEmitStreamVertex: - case OpEndStreamPrimitive: - case OpControlBarrier: - case OpMemoryBarrier: - case OpGroupWaitEvents: - case OpRetainEvent: - case OpReleaseEvent: - case OpSetUserEventStatus: - case OpCaptureEventProfilingInfo: - case OpCommitReadPipe: - case OpCommitWritePipe: - case OpGroupCommitReadPipe: - case OpGroupCommitWritePipe: - return false; - - default: - if (length > 1) - { - result_type = args[0]; - result_id = args[1]; - return true; - } - else - return false; - } -} diff --git a/deps/SPIRV-Cross/spirv_cross.hpp b/deps/SPIRV-Cross/spirv_cross.hpp deleted file mode 100644 index ce928f7eb9..0000000000 --- a/deps/SPIRV-Cross/spirv_cross.hpp +++ /dev/null @@ -1,753 +0,0 @@ -/* - * Copyright 2015-2017 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef SPIRV_CROSS_HPP -#define SPIRV_CROSS_HPP - -#include "spirv.hpp" -#include "spirv_common.hpp" - -namespace spirv_cross -{ -class CFG; -struct Resource -{ - // Resources are identified with their SPIR-V ID. - // This is the ID of the OpVariable. - uint32_t id; - - // The type ID of the variable which includes arrays and all type modifications. - // This type ID is not suitable for parsing OpMemberDecoration of a struct and other decorations in general - // since these modifications typically happen on the base_type_id. - uint32_t type_id; - - // The base type of the declared resource. - // This type is the base type which ignores pointers and arrays of the type_id. - // This is mostly useful to parse decorations of the underlying type. - // base_type_id can also be obtained with get_type(get_type(type_id).self). - uint32_t base_type_id; - - // The declared name (OpName) of the resource. - // For Buffer blocks, the name actually reflects the externally - // visible Block name. - // - // This name can be retrieved again by using either - // get_name(id) or get_name(base_type_id) depending if it's a buffer block or not. - // - // This name can be an empty string in which case get_fallback_name(id) can be - // used which obtains a suitable fallback identifier for an ID. - std::string name; -}; - -struct ShaderResources -{ - std::vector uniform_buffers; - std::vector storage_buffers; - std::vector stage_inputs; - std::vector stage_outputs; - std::vector subpass_inputs; - std::vector storage_images; - std::vector sampled_images; - std::vector atomic_counters; - - // There can only be one push constant block, - // but keep the vector in case this restriction is lifted in the future. - std::vector push_constant_buffers; - - // For Vulkan GLSL and HLSL source, - // these correspond to separate texture2D and samplers respectively. - std::vector separate_images; - std::vector separate_samplers; -}; - -struct CombinedImageSampler -{ - // The ID of the sampler2D variable. - uint32_t combined_id; - // The ID of the texture2D variable. - uint32_t image_id; - // The ID of the sampler variable. - uint32_t sampler_id; -}; - -struct SpecializationConstant -{ - // The ID of the specialization constant. - uint32_t id; - // The constant ID of the constant, used in Vulkan during pipeline creation. - uint32_t constant_id; -}; - -struct BufferRange -{ - unsigned index; - size_t offset; - size_t range; -}; - -enum BufferPackingStandard -{ - BufferPackingStd140, - BufferPackingStd430, - BufferPackingStd140EnhancedLayout, - BufferPackingStd430EnhancedLayout, - BufferPackingHLSLCbuffer, - BufferPackingHLSLCbufferPackOffset -}; - -class Compiler -{ -public: - friend class CFG; - friend class DominatorBuilder; - - // The constructor takes a buffer of SPIR-V words and parses it. - Compiler(std::vector ir); - Compiler(const uint32_t *ir, size_t word_count); - - virtual ~Compiler() = default; - - // After parsing, API users can modify the SPIR-V via reflection and call this - // to disassemble the SPIR-V into the desired langauage. - // Sub-classes actually implement this. - virtual std::string compile(); - - // Gets the identifier (OpName) of an ID. If not defined, an empty string will be returned. - const std::string &get_name(uint32_t id) const; - - // Applies a decoration to an ID. Effectively injects OpDecorate. - void set_decoration(uint32_t id, spv::Decoration decoration, uint32_t argument = 0); - - // Overrides the identifier OpName of an ID. - // Identifiers beginning with underscores or identifiers which contain double underscores - // are reserved by the implementation. - void set_name(uint32_t id, const std::string &name); - - // Gets a bitmask for the decorations which are applied to ID. - // I.e. (1ull << spv::DecorationFoo) | (1ull << spv::DecorationBar) - uint64_t get_decoration_mask(uint32_t id) const; - - // Returns whether the decoration has been applied to the ID. - bool has_decoration(uint32_t id, spv::Decoration decoration) const; - - // Gets the value for decorations which take arguments. - // If the decoration is a boolean (i.e. spv::DecorationNonWritable), - // 1 will be returned. - // If decoration doesn't exist or decoration is not recognized, - // 0 will be returned. - uint32_t get_decoration(uint32_t id, spv::Decoration decoration) const; - - // Removes the decoration for a an ID. - void unset_decoration(uint32_t id, spv::Decoration decoration); - - // Gets the SPIR-V type associated with ID. - // Mostly used with Resource::type_id and Resource::base_type_id to parse the underlying type of a resource. - const SPIRType &get_type(uint32_t id) const; - - // Gets the SPIR-V type of a variable. - const SPIRType &get_type_from_variable(uint32_t id) const; - - // Gets the underlying storage class for an OpVariable. - spv::StorageClass get_storage_class(uint32_t id) const; - - // If get_name() is an empty string, get the fallback name which will be used - // instead in the disassembled source. - virtual const std::string get_fallback_name(uint32_t id) const; - - // If get_name() of a Block struct is an empty string, get the fallback name. - // This needs to be per-variable as multiple variables can use the same block type. - virtual const std::string get_block_fallback_name(uint32_t id) const; - - // Given an OpTypeStruct in ID, obtain the identifier for member number "index". - // This may be an empty string. - const std::string &get_member_name(uint32_t id, uint32_t index) const; - - // Given an OpTypeStruct in ID, obtain the OpMemberDecoration for member number "index". - uint32_t get_member_decoration(uint32_t id, uint32_t index, spv::Decoration decoration) const; - - // Sets the member identifier for OpTypeStruct ID, member number "index". - void set_member_name(uint32_t id, uint32_t index, const std::string &name); - - // Returns the qualified member identifier for OpTypeStruct ID, member number "index", - // or an empty string if no qualified alias exists - const std::string &get_member_qualified_name(uint32_t type_id, uint32_t index) const; - - // Sets the qualified member identifier for OpTypeStruct ID, member number "index". - void set_member_qualified_name(uint32_t type_id, uint32_t index, const std::string &name); - - // Gets the decoration mask for a member of a struct, similar to get_decoration_mask. - uint64_t get_member_decoration_mask(uint32_t id, uint32_t index) const; - - // Returns whether the decoration has been applied to a member of a struct. - bool has_member_decoration(uint32_t id, uint32_t index, spv::Decoration decoration) const; - - // Similar to set_decoration, but for struct members. - void set_member_decoration(uint32_t id, uint32_t index, spv::Decoration decoration, uint32_t argument = 0); - - // Unsets a member decoration, similar to unset_decoration. - void unset_member_decoration(uint32_t id, uint32_t index, spv::Decoration decoration); - - // Gets the fallback name for a member, similar to get_fallback_name. - virtual const std::string get_fallback_member_name(uint32_t index) const - { - return join("_", index); - } - - // Returns a vector of which members of a struct are potentially in use by a - // SPIR-V shader. The granularity of this analysis is per-member of a struct. - // This can be used for Buffer (UBO), BufferBlock/StorageBuffer (SSBO) and PushConstant blocks. - // ID is the Resource::id obtained from get_shader_resources(). - std::vector get_active_buffer_ranges(uint32_t id) const; - - // Returns the effective size of a buffer block. - size_t get_declared_struct_size(const SPIRType &struct_type) const; - - // Returns the effective size of a buffer block struct member. - virtual size_t get_declared_struct_member_size(const SPIRType &struct_type, uint32_t index) const; - - // Legacy GLSL compatibility method. Deprecated in favor of CompilerGLSL::flatten_buffer_block - SPIRV_CROSS_DEPRECATED("Please use flatten_buffer_block instead.") void flatten_interface_block(uint32_t id); - - // Returns a set of all global variables which are statically accessed - // by the control flow graph from the current entry point. - // Only variables which change the interface for a shader are returned, that is, - // variables with storage class of Input, Output, Uniform, UniformConstant, PushConstant and AtomicCounter - // storage classes are returned. - // - // To use the returned set as the filter for which variables are used during compilation, - // this set can be moved to set_enabled_interface_variables(). - std::unordered_set get_active_interface_variables() const; - - // Sets the interface variables which are used during compilation. - // By default, all variables are used. - // Once set, compile() will only consider the set in active_variables. - void set_enabled_interface_variables(std::unordered_set active_variables); - - // Query shader resources, use ids with reflection interface to modify or query binding points, etc. - ShaderResources get_shader_resources() const; - - // Query shader resources, but only return the variables which are part of active_variables. - // E.g.: get_shader_resources(get_active_variables()) to only return the variables which are statically - // accessed. - ShaderResources get_shader_resources(const std::unordered_set &active_variables) const; - - // Remapped variables are considered built-in variables and a backend will - // not emit a declaration for this variable. - // This is mostly useful for making use of builtins which are dependent on extensions. - void set_remapped_variable_state(uint32_t id, bool remap_enable); - bool get_remapped_variable_state(uint32_t id) const; - - // For subpassInput variables which are remapped to plain variables, - // the number of components in the remapped - // variable must be specified as the backing type of subpass inputs are opaque. - void set_subpass_input_remapped_components(uint32_t id, uint32_t components); - uint32_t get_subpass_input_remapped_components(uint32_t id) const; - - // All operations work on the current entry point. - // Entry points can be swapped out with set_entry_point(). - // Entry points should be set right after the constructor completes as some reflection functions traverse the graph from the entry point. - // Resource reflection also depends on the entry point. - // By default, the current entry point is set to the first OpEntryPoint which appears in the SPIR-V module. - std::vector get_entry_points() const; - void set_entry_point(const std::string &name); - - // Renames an entry point from old_name to new_name. - // If old_name is currently selected as the current entry point, it will continue to be the current entry point, - // albeit with a new name. - // get_entry_points() is essentially invalidated at this point. - void rename_entry_point(const std::string &old_name, const std::string &new_name); - - // Returns the internal data structure for entry points to allow poking around. - const SPIREntryPoint &get_entry_point(const std::string &name) const; - SPIREntryPoint &get_entry_point(const std::string &name); - - // Some shader languages restrict the names that can be given to entry points, and the - // corresponding backend will automatically rename an entry point name, during the call - // to compile() if it is illegal. For example, the common entry point name main() is - // illegal in MSL, and is renamed to an alternate name by the MSL backend. - // Given the original entry point name contained in the SPIR-V, this function returns - // the name, as updated by the backend during the call to compile(). If the name is not - // illegal, and has not been renamed, or if this function is called before compile(), - // this function will simply return the same name. - const std::string &get_cleansed_entry_point_name(const std::string &name) const; - - // Query and modify OpExecutionMode. - uint64_t get_execution_mode_mask() const; - void unset_execution_mode(spv::ExecutionMode mode); - void set_execution_mode(spv::ExecutionMode mode, uint32_t arg0 = 0, uint32_t arg1 = 0, uint32_t arg2 = 0); - - // Gets argument for an execution mode (LocalSize, Invocations, OutputVertices). - // For LocalSize, the index argument is used to select the dimension (X = 0, Y = 1, Z = 2). - // For execution modes which do not have arguments, 0 is returned. - uint32_t get_execution_mode_argument(spv::ExecutionMode mode, uint32_t index = 0) const; - spv::ExecutionModel get_execution_model() const; - - // In SPIR-V, the compute work group size can be represented by a constant vector, in which case - // the LocalSize execution mode is ignored. - // - // This constant vector can be a constant vector, specialization constant vector, or partly specialized constant vector. - // To modify and query work group dimensions which are specialization constants, SPIRConstant values must be modified - // directly via get_constant() rather than using LocalSize directly. This function will return which constants should be modified. - // - // To modify dimensions which are *not* specialization constants, set_execution_mode should be used directly. - // Arguments to set_execution_mode which are specialization constants are effectively ignored during compilation. - // NOTE: This is somewhat different from how SPIR-V works. In SPIR-V, the constant vector will completely replace LocalSize, - // while in this interface, LocalSize is only ignored for specialization constants. - // - // The specialization constant will be written to x, y and z arguments. - // If the component is not a specialization constant, a zeroed out struct will be written. - // The return value is the constant ID of the builtin WorkGroupSize, but this is not expected to be useful - // for most use cases. - uint32_t get_work_group_size_specialization_constants(SpecializationConstant &x, SpecializationConstant &y, - SpecializationConstant &z) const; - - // Analyzes all separate image and samplers used from the currently selected entry point, - // and re-routes them all to a combined image sampler instead. - // This is required to "support" separate image samplers in targets which do not natively support - // this feature, like GLSL/ESSL. - // - // This must be called before compile() if such remapping is desired. - // This call will add new sampled images to the SPIR-V, - // so it will appear in reflection if get_shader_resources() is called after build_combined_image_samplers. - // - // If any image/sampler remapping was found, no separate image/samplers will appear in the decompiled output, - // but will still appear in reflection. - // - // The resulting samplers will be void of any decorations like name, descriptor sets and binding points, - // so this can be added before compile() if desired. - // - // Combined image samplers originating from this set are always considered active variables. - void build_combined_image_samplers(); - - // Gets a remapping for the combined image samplers. - const std::vector &get_combined_image_samplers() const - { - return combined_image_samplers; - } - - // Set a new variable type remap callback. - // The type remapping is designed to allow global interface variable to assume more special types. - // A typical example here is to remap sampler2D into samplerExternalOES, which currently isn't supported - // directly by SPIR-V. - // - // In compile() while emitting code, - // for every variable that is declared, including function parameters, the callback will be called - // and the API user has a chance to change the textual representation of the type used to declare the variable. - // The API user can detect special patterns in names to guide the remapping. - void set_variable_type_remap_callback(VariableTypeRemapCallback cb) - { - variable_remap_callback = std::move(cb); - } - - // API for querying which specialization constants exist. - // To modify a specialization constant before compile(), use get_constant(constant.id), - // then update constants directly in the SPIRConstant data structure. - // For composite types, the subconstants can be iterated over and modified. - // constant_type is the SPIRType for the specialization constant, - // which can be queried to determine which fields in the unions should be poked at. - std::vector get_specialization_constants() const; - SPIRConstant &get_constant(uint32_t id); - const SPIRConstant &get_constant(uint32_t id) const; - - uint32_t get_current_id_bound() const - { - return uint32_t(ids.size()); - } - - // API for querying buffer objects. - // The type passed in here should be the base type of a resource, i.e. - // get_type(resource.base_type_id) - // as decorations are set in the basic Block type. - // The type passed in here must have these decorations set, or an exception is raised. - // Only UBOs and SSBOs or sub-structs which are part of these buffer types will have these decorations set. - uint32_t type_struct_member_offset(const SPIRType &type, uint32_t index) const; - uint32_t type_struct_member_array_stride(const SPIRType &type, uint32_t index) const; - uint32_t type_struct_member_matrix_stride(const SPIRType &type, uint32_t index) const; - - // Gets the offset in SPIR-V words (uint32_t) for a decoration which was originally declared in the SPIR-V binary. - // The offset will point to one or more uint32_t literals which can be modified in-place before using the SPIR-V binary. - // Note that adding or removing decorations using the reflection API will not change the behavior of this function. - // If the decoration was declared, sets the word_offset to an offset into the provided SPIR-V binary buffer and returns true, - // otherwise, returns false. - // If the decoration does not have any value attached to it (e.g. DecorationRelaxedPrecision), this function will also return false. - bool get_binary_offset_for_decoration(uint32_t id, spv::Decoration decoration, uint32_t &word_offset) const; - - // HLSL counter buffer reflection interface. - // Append/Consume/Increment/Decrement in HLSL is implemented as two "neighbor" buffer objects where - // one buffer implements the storage, and a single buffer containing just a lone "int" implements the counter. - // To SPIR-V these will be exposed as two separate buffers, but glslang HLSL frontend emits a special indentifier - // which lets us link the two buffers together. - - // Queries if a variable ID is a counter buffer which "belongs" to a regular buffer object. - // NOTE: This query is purely based on OpName identifiers as found in the SPIR-V module, and will - // only return true if OpSource was reported HLSL. - // To rely on this functionality, ensure that the SPIR-V module is not stripped. - bool buffer_is_hlsl_counter_buffer(uint32_t id) const; - - // Queries if a buffer object has a neighbor "counter" buffer. - // If so, the ID of that counter buffer will be returned in counter_id. - // NOTE: This query is purely based on OpName identifiers as found in the SPIR-V module, and will - // only return true if OpSource was reported HLSL. - // To rely on this functionality, ensure that the SPIR-V module is not stripped. - bool buffer_get_hlsl_counter_buffer(uint32_t id, uint32_t &counter_id) const; - - // Gets the list of all SPIR-V Capabilities which were declared in the SPIR-V module. - const std::vector &get_declared_capabilities() const; - - // Gets the list of all SPIR-V extensions which were declared in the SPIR-V module. - const std::vector &get_declared_extensions() const; - - // When declaring buffer blocks in GLSL, the name declared in the GLSL source - // might not be the same as the name declared in the SPIR-V module due to naming conflicts. - // In this case, SPIRV-Cross needs to find a fallback-name, and it might only - // be possible to know this name after compiling to GLSL. - // This is particularly important for HLSL input and UAVs which tends to reuse the same block type - // for multiple distinct blocks. For these cases it is not possible to modify the name of the type itself - // because it might be unique. Instead, you can use this interface to check after compilation which - // name was actually used if your input SPIR-V tends to have this problem. - // For other names like remapped names for variables, etc, it's generally enough to query the name of the variables - // after compiling, block names are an exception to this rule. - // ID is the name of a variable as returned by Resource::id, and must be a variable with a Block-like type. - std::string get_remapped_declared_block_name(uint32_t id) const; - -protected: - const uint32_t *stream(const Instruction &instr) const - { - // If we're not going to use any arguments, just return nullptr. - // We want to avoid case where we return an out of range pointer - // that trips debug assertions on some platforms. - if (!instr.length) - return nullptr; - - if (instr.offset + instr.length > spirv.size()) - SPIRV_CROSS_THROW("Compiler::stream() out of range."); - return &spirv[instr.offset]; - } - std::vector spirv; - - std::vector inst; - std::vector ids; - std::vector meta; - - SPIRFunction *current_function = nullptr; - SPIRBlock *current_block = nullptr; - std::vector global_variables; - std::vector aliased_variables; - std::unordered_set active_interface_variables; - bool check_active_interface_variables = false; - - // If our IDs are out of range here as part of opcodes, throw instead of - // undefined behavior. - template - T &set(uint32_t id, P &&... args) - { - auto &var = variant_set(ids.at(id), std::forward

(args)...); - var.self = id; - return var; - } - - template - T &get(uint32_t id) - { - return variant_get(ids.at(id)); - } - - template - T *maybe_get(uint32_t id) - { - if (ids.at(id).get_type() == T::type) - return &get(id); - else - return nullptr; - } - - template - const T &get(uint32_t id) const - { - return variant_get(ids.at(id)); - } - - template - const T *maybe_get(uint32_t id) const - { - if (ids.at(id).get_type() == T::type) - return &get(id); - else - return nullptr; - } - - uint32_t entry_point = 0; - // Normally, we'd stick SPIREntryPoint in ids array, but it conflicts with SPIRFunction. - // Entry points can therefore be seen as some sort of meta structure. - std::unordered_map entry_points; - const SPIREntryPoint &get_entry_point() const; - SPIREntryPoint &get_entry_point(); - - struct Source - { - uint32_t version = 0; - bool es = false; - bool known = false; - bool hlsl = false; - - Source() = default; - } source; - - std::unordered_set loop_blocks; - std::unordered_set continue_blocks; - std::unordered_set loop_merge_targets; - std::unordered_set selection_merge_targets; - std::unordered_set multiselect_merge_targets; - std::unordered_map continue_block_to_loop_header; - - virtual std::string to_name(uint32_t id, bool allow_alias = true) const; - bool is_builtin_variable(const SPIRVariable &var) const; - bool is_hidden_variable(const SPIRVariable &var, bool include_builtins = false) const; - bool is_immutable(uint32_t id) const; - bool is_member_builtin(const SPIRType &type, uint32_t index, spv::BuiltIn *builtin) const; - bool is_scalar(const SPIRType &type) const; - bool is_vector(const SPIRType &type) const; - bool is_matrix(const SPIRType &type) const; - bool is_array(const SPIRType &type) const; - uint32_t expression_type_id(uint32_t id) const; - const SPIRType &expression_type(uint32_t id) const; - bool expression_is_lvalue(uint32_t id) const; - bool variable_storage_is_aliased(const SPIRVariable &var); - SPIRVariable *maybe_get_backing_variable(uint32_t chain); - void mark_used_as_array_length(uint32_t id); - - void register_read(uint32_t expr, uint32_t chain, bool forwarded); - void register_write(uint32_t chain); - - inline bool is_continue(uint32_t next) const - { - return continue_blocks.find(next) != end(continue_blocks); - } - - inline bool is_break(uint32_t next) const - { - return loop_merge_targets.find(next) != end(loop_merge_targets) || - multiselect_merge_targets.find(next) != end(multiselect_merge_targets); - } - - inline bool is_conditional(uint32_t next) const - { - return selection_merge_targets.find(next) != end(selection_merge_targets) && - multiselect_merge_targets.find(next) == end(multiselect_merge_targets); - } - - // Dependency tracking for temporaries read from variables. - void flush_dependees(SPIRVariable &var); - void flush_all_active_variables(); - void flush_all_atomic_capable_variables(); - void flush_all_aliased_variables(); - void register_global_read_dependencies(const SPIRBlock &func, uint32_t id); - void register_global_read_dependencies(const SPIRFunction &func, uint32_t id); - std::unordered_set invalid_expressions; - - void update_name_cache(std::unordered_set &cache, std::string &name); - - bool function_is_pure(const SPIRFunction &func); - bool block_is_pure(const SPIRBlock &block); - bool block_is_outside_flow_control_from_block(const SPIRBlock &from, const SPIRBlock &to); - - bool execution_is_branchless(const SPIRBlock &from, const SPIRBlock &to) const; - bool execution_is_noop(const SPIRBlock &from, const SPIRBlock &to) const; - SPIRBlock::ContinueBlockType continue_block_type(const SPIRBlock &continue_block) const; - - bool force_recompile = false; - - bool block_is_loop_candidate(const SPIRBlock &block, SPIRBlock::Method method) const; - - uint32_t increase_bound_by(uint32_t incr_amount); - - bool types_are_logically_equivalent(const SPIRType &a, const SPIRType &b) const; - void inherit_expression_dependencies(uint32_t dst, uint32_t source); - - // For proper multiple entry point support, allow querying if an Input or Output - // variable is part of that entry points interface. - bool interface_variable_exists_in_entry_point(uint32_t id) const; - - std::vector combined_image_samplers; - - void remap_variable_type_name(const SPIRType &type, const std::string &var_name, std::string &type_name) const - { - if (variable_remap_callback) - variable_remap_callback(type, var_name, type_name); - } - - void analyze_variable_scope(SPIRFunction &function); - - void parse(); - void parse(const Instruction &i); - - // Used internally to implement various traversals for queries. - struct OpcodeHandler - { - virtual ~OpcodeHandler() = default; - - // Return true if traversal should continue. - // If false, traversal will end immediately. - virtual bool handle(spv::Op opcode, const uint32_t *args, uint32_t length) = 0; - - virtual bool follow_function_call(const SPIRFunction &) - { - return true; - } - - virtual void set_current_block(const SPIRBlock &) - { - } - - virtual bool begin_function_scope(const uint32_t *, uint32_t) - { - return true; - } - - virtual bool end_function_scope(const uint32_t *, uint32_t) - { - return true; - } - }; - - struct BufferAccessHandler : OpcodeHandler - { - BufferAccessHandler(const Compiler &compiler_, std::vector &ranges_, uint32_t id_) - : compiler(compiler_) - , ranges(ranges_) - , id(id_) - { - } - - bool handle(spv::Op opcode, const uint32_t *args, uint32_t length) override; - - const Compiler &compiler; - std::vector &ranges; - uint32_t id; - - std::unordered_set seen; - }; - - struct InterfaceVariableAccessHandler : OpcodeHandler - { - InterfaceVariableAccessHandler(const Compiler &compiler_, std::unordered_set &variables_) - : compiler(compiler_) - , variables(variables_) - { - } - - bool handle(spv::Op opcode, const uint32_t *args, uint32_t length) override; - - const Compiler &compiler; - std::unordered_set &variables; - }; - - struct CombinedImageSamplerHandler : OpcodeHandler - { - CombinedImageSamplerHandler(Compiler &compiler_) - : compiler(compiler_) - { - } - bool handle(spv::Op opcode, const uint32_t *args, uint32_t length) override; - bool begin_function_scope(const uint32_t *args, uint32_t length) override; - bool end_function_scope(const uint32_t *args, uint32_t length) override; - - Compiler &compiler; - - // Each function in the call stack needs its own remapping for parameters so we can deduce which global variable each texture/sampler the parameter is statically bound to. - std::stack> parameter_remapping; - std::stack functions; - - uint32_t remap_parameter(uint32_t id); - void push_remap_parameters(const SPIRFunction &func, const uint32_t *args, uint32_t length); - void pop_remap_parameters(); - void register_combined_image_sampler(SPIRFunction &caller, uint32_t texture_id, uint32_t sampler_id, - bool depth); - }; - - struct ActiveBuiltinHandler : OpcodeHandler - { - ActiveBuiltinHandler(Compiler &compiler_) - : compiler(compiler_) - { - } - - bool handle(spv::Op opcode, const uint32_t *args, uint32_t length) override; - Compiler &compiler; - }; - - bool traverse_all_reachable_opcodes(const SPIRBlock &block, OpcodeHandler &handler) const; - bool traverse_all_reachable_opcodes(const SPIRFunction &block, OpcodeHandler &handler) const; - // This must be an ordered data structure so we always pick the same type aliases. - std::vector global_struct_cache; - - ShaderResources get_shader_resources(const std::unordered_set *active_variables) const; - - VariableTypeRemapCallback variable_remap_callback; - - uint64_t get_buffer_block_flags(const SPIRVariable &var); - bool get_common_basic_type(const SPIRType &type, SPIRType::BaseType &base_type); - - std::unordered_set forced_temporaries; - std::unordered_set forwarded_temporaries; - std::unordered_set hoisted_temporaries; - - uint64_t active_input_builtins = 0; - uint64_t active_output_builtins = 0; - // Traverses all reachable opcodes and sets active_builtins to a bitmask of all builtin variables which are accessed in the shader. - void update_active_builtins(); - bool has_active_builtin(spv::BuiltIn builtin, spv::StorageClass storage); - - void analyze_parameter_preservation( - SPIRFunction &entry, const CFG &cfg, - const std::unordered_map> &variable_to_blocks, - const std::unordered_map> &complete_write_blocks); - - // If a variable ID or parameter ID is found in this set, a sampler is actually a shadow/comparison sampler. - // SPIR-V does not support this distinction, so we must keep track of this information outside the type system. - // There might be unrelated IDs found in this set which do not correspond to actual variables. - // This set should only be queried for the existence of samplers which are already known to be variables or parameter IDs. - std::unordered_set comparison_samplers; - void analyze_sampler_comparison_states(); - struct CombinedImageSamplerUsageHandler : OpcodeHandler - { - CombinedImageSamplerUsageHandler(Compiler &compiler_) - : compiler(compiler_) - { - } - - bool begin_function_scope(const uint32_t *args, uint32_t length) override; - bool handle(spv::Op opcode, const uint32_t *args, uint32_t length) override; - Compiler &compiler; - - std::unordered_map> dependency_hierarchy; - std::unordered_set comparison_samplers; - - void add_hierarchy_to_comparison_samplers(uint32_t sampler); - }; - - void make_constant_null(uint32_t id, uint32_t type); - - std::vector declared_capabilities; - std::vector declared_extensions; - std::unordered_map declared_block_names; - - bool instruction_to_result_type(uint32_t &result_type, uint32_t &result_id, spv::Op op, const uint32_t *args, - uint32_t length); -}; -} - -#endif diff --git a/deps/SPIRV-Cross/spirv_glsl.cpp b/deps/SPIRV-Cross/spirv_glsl.cpp deleted file mode 100644 index ea80c20ce4..0000000000 --- a/deps/SPIRV-Cross/spirv_glsl.cpp +++ /dev/null @@ -1,8545 +0,0 @@ -/* - * Copyright 2015-2017 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "spirv_glsl.hpp" -#include "GLSL.std.450.h" -#include "spirv_common.hpp" -#include -#include -#include - -using namespace spv; -using namespace spirv_cross; -using namespace std; - -static bool packing_is_vec4_padded(BufferPackingStandard packing) -{ - switch (packing) - { - case BufferPackingHLSLCbuffer: - case BufferPackingHLSLCbufferPackOffset: - case BufferPackingStd140: - case BufferPackingStd140EnhancedLayout: - return true; - - default: - return false; - } -} - -static bool packing_is_hlsl(BufferPackingStandard packing) -{ - switch (packing) - { - case BufferPackingHLSLCbuffer: - case BufferPackingHLSLCbufferPackOffset: - return true; - - default: - return false; - } -} - -static bool packing_has_flexible_offset(BufferPackingStandard packing) -{ - switch (packing) - { - case BufferPackingStd140: - case BufferPackingStd430: - case BufferPackingHLSLCbuffer: - return false; - - default: - return true; - } -} - -static BufferPackingStandard packing_to_substruct_packing(BufferPackingStandard packing) -{ - switch (packing) - { - case BufferPackingStd140EnhancedLayout: - return BufferPackingStd140; - case BufferPackingStd430EnhancedLayout: - return BufferPackingStd430; - case BufferPackingHLSLCbufferPackOffset: - return BufferPackingHLSLCbuffer; - default: - return packing; - } -} - -// Sanitizes underscores for GLSL where multiple underscores in a row are not allowed. -string CompilerGLSL::sanitize_underscores(const string &str) -{ - string res; - res.reserve(str.size()); - - bool last_underscore = false; - for (auto c : str) - { - if (c == '_') - { - if (last_underscore) - continue; - - res += c; - last_underscore = true; - } - else - { - res += c; - last_underscore = false; - } - } - return res; -} - -// Returns true if an arithmetic operation does not change behavior depending on signedness. -static bool opcode_is_sign_invariant(Op opcode) -{ - switch (opcode) - { - case OpIEqual: - case OpINotEqual: - case OpISub: - case OpIAdd: - case OpIMul: - case OpShiftLeftLogical: - case OpBitwiseOr: - case OpBitwiseXor: - case OpBitwiseAnd: - return true; - - default: - return false; - } -} - -static const char *to_pls_layout(PlsFormat format) -{ - switch (format) - { - case PlsR11FG11FB10F: - return "layout(r11f_g11f_b10f) "; - case PlsR32F: - return "layout(r32f) "; - case PlsRG16F: - return "layout(rg16f) "; - case PlsRGB10A2: - return "layout(rgb10_a2) "; - case PlsRGBA8: - return "layout(rgba8) "; - case PlsRG16: - return "layout(rg16) "; - case PlsRGBA8I: - return "layout(rgba8i)"; - case PlsRG16I: - return "layout(rg16i) "; - case PlsRGB10A2UI: - return "layout(rgb10_a2ui) "; - case PlsRGBA8UI: - return "layout(rgba8ui) "; - case PlsRG16UI: - return "layout(rg16ui) "; - case PlsR32UI: - return "layout(r32ui) "; - default: - return ""; - } -} - -static SPIRType::BaseType pls_format_to_basetype(PlsFormat format) -{ - switch (format) - { - default: - case PlsR11FG11FB10F: - case PlsR32F: - case PlsRG16F: - case PlsRGB10A2: - case PlsRGBA8: - case PlsRG16: - return SPIRType::Float; - - case PlsRGBA8I: - case PlsRG16I: - return SPIRType::Int; - - case PlsRGB10A2UI: - case PlsRGBA8UI: - case PlsRG16UI: - case PlsR32UI: - return SPIRType::UInt; - } -} - -static uint32_t pls_format_to_components(PlsFormat format) -{ - switch (format) - { - default: - case PlsR32F: - case PlsR32UI: - return 1; - - case PlsRG16F: - case PlsRG16: - case PlsRG16UI: - case PlsRG16I: - return 2; - - case PlsR11FG11FB10F: - return 3; - - case PlsRGB10A2: - case PlsRGBA8: - case PlsRGBA8I: - case PlsRGB10A2UI: - case PlsRGBA8UI: - return 4; - } -} - -static const char *vector_swizzle(int vecsize, int index) -{ - static const char *swizzle[4][4] = { - { ".x", ".y", ".z", ".w" }, { ".xy", ".yz", ".zw" }, { ".xyz", ".yzw" }, { "" } - }; - - assert(vecsize >= 1 && vecsize <= 4); - assert(index >= 0 && index < 4); - assert(swizzle[vecsize - 1][index]); - - return swizzle[vecsize - 1][index]; -} - -void CompilerGLSL::reset() -{ - // We do some speculative optimizations which should pretty much always work out, - // but just in case the SPIR-V is rather weird, recompile until it's happy. - // This typically only means one extra pass. - force_recompile = false; - - // Clear invalid expression tracking. - invalid_expressions.clear(); - current_function = nullptr; - - // Clear temporary usage tracking. - expression_usage_counts.clear(); - forwarded_temporaries.clear(); - - resource_names.clear(); - - for (auto &id : ids) - { - if (id.get_type() == TypeVariable) - { - // Clear unflushed dependees. - id.get().dependees.clear(); - } - else if (id.get_type() == TypeExpression) - { - // And remove all expressions. - id.reset(); - } - else if (id.get_type() == TypeFunction) - { - // Reset active state for all functions. - id.get().active = false; - id.get().flush_undeclared = true; - } - } - - statement_count = 0; - indent = 0; -} - -void CompilerGLSL::remap_pls_variables() -{ - for (auto &input : pls_inputs) - { - auto &var = get(input.id); - - bool input_is_target = false; - if (var.storage == StorageClassUniformConstant) - { - auto &type = get(var.basetype); - input_is_target = type.image.dim == DimSubpassData; - } - - if (var.storage != StorageClassInput && !input_is_target) - SPIRV_CROSS_THROW("Can only use in and target variables for PLS inputs."); - var.remapped_variable = true; - } - - for (auto &output : pls_outputs) - { - auto &var = get(output.id); - if (var.storage != StorageClassOutput) - SPIRV_CROSS_THROW("Can only use out variables for PLS outputs."); - var.remapped_variable = true; - } -} - -void CompilerGLSL::find_static_extensions() -{ - for (auto &id : ids) - { - if (id.get_type() == TypeType) - { - auto &type = id.get(); - if (type.basetype == SPIRType::Double) - { - if (options.es) - SPIRV_CROSS_THROW("FP64 not supported in ES profile."); - if (!options.es && options.version < 400) - require_extension("GL_ARB_gpu_shader_fp64"); - } - - if (type.basetype == SPIRType::Int64 || type.basetype == SPIRType::UInt64) - { - if (options.es) - SPIRV_CROSS_THROW("64-bit integers not supported in ES profile."); - if (!options.es) - require_extension("GL_ARB_gpu_shader_int64"); - } - } - } - - auto &execution = get_entry_point(); - switch (execution.model) - { - case ExecutionModelGLCompute: - if (!options.es && options.version < 430) - require_extension("GL_ARB_compute_shader"); - if (options.es && options.version < 310) - SPIRV_CROSS_THROW("At least ESSL 3.10 required for compute shaders."); - break; - - case ExecutionModelGeometry: - if (options.es && options.version < 320) - require_extension("GL_EXT_geometry_shader"); - if (!options.es && options.version < 150) - require_extension("GL_ARB_geometry_shader4"); - - if ((execution.flags & (1ull << ExecutionModeInvocations)) && execution.invocations != 1) - { - // Instanced GS is part of 400 core or this extension. - if (!options.es && options.version < 400) - require_extension("GL_ARB_gpu_shader5"); - } - break; - - case ExecutionModelTessellationEvaluation: - case ExecutionModelTessellationControl: - if (options.es && options.version < 320) - require_extension("GL_EXT_tessellation_shader"); - if (!options.es && options.version < 400) - require_extension("GL_ARB_tessellation_shader"); - break; - - default: - break; - } - - if (!pls_inputs.empty() || !pls_outputs.empty()) - require_extension("GL_EXT_shader_pixel_local_storage"); - - if (options.separate_shader_objects && !options.es && options.version < 410) - require_extension("GL_ARB_separate_shader_objects"); -} - -string CompilerGLSL::compile() -{ - // Force a classic "C" locale, reverts when function returns - ClassicLocale classic_locale; - - if (options.vulkan_semantics) - backend.allow_precision_qualifiers = true; - backend.force_gl_in_out_block = true; - - // Scan the SPIR-V to find trivial uses of extensions. - find_static_extensions(); - fixup_image_load_store_access(); - update_active_builtins(); - analyze_sampler_comparison_states(); - - uint32_t pass_count = 0; - do - { - if (pass_count >= 3) - SPIRV_CROSS_THROW("Over 3 compilation loops detected. Must be a bug!"); - - reset(); - - // Move constructor for this type is broken on GCC 4.9 ... - buffer = unique_ptr(new ostringstream()); - - emit_header(); - emit_resources(); - - emit_function(get(entry_point), 0); - - pass_count++; - } while (force_recompile); - - // Entry point in GLSL is always main(). - get_entry_point().name = "main"; - - return buffer->str(); -} - -std::string CompilerGLSL::get_partial_source() -{ - return buffer ? buffer->str() : "No compiled source available yet."; -} - -void CompilerGLSL::emit_header() -{ - auto &execution = get_entry_point(); - statement("#version ", options.version, options.es && options.version > 100 ? " es" : ""); - - if (!options.es && options.version < 420) - { - // Needed for binding = # on UBOs, etc. - if (options.enable_420pack_extension) - { - statement("#ifdef GL_ARB_shading_language_420pack"); - statement("#extension GL_ARB_shading_language_420pack : require"); - statement("#endif"); - } - // Needed for: layout(early_fragment_tests) in; - if (execution.flags & (1ull << ExecutionModeEarlyFragmentTests)) - require_extension("GL_ARB_shader_image_load_store"); - } - - for (auto &ext : forced_extensions) - statement("#extension ", ext, " : require"); - - for (auto &header : header_lines) - statement(header); - - vector inputs; - vector outputs; - - switch (execution.model) - { - case ExecutionModelGeometry: - outputs.push_back(join("max_vertices = ", execution.output_vertices)); - if ((execution.flags & (1ull << ExecutionModeInvocations)) && execution.invocations != 1) - inputs.push_back(join("invocations = ", execution.invocations)); - if (execution.flags & (1ull << ExecutionModeInputPoints)) - inputs.push_back("points"); - if (execution.flags & (1ull << ExecutionModeInputLines)) - inputs.push_back("lines"); - if (execution.flags & (1ull << ExecutionModeInputLinesAdjacency)) - inputs.push_back("lines_adjacency"); - if (execution.flags & (1ull << ExecutionModeTriangles)) - inputs.push_back("triangles"); - if (execution.flags & (1ull << ExecutionModeInputTrianglesAdjacency)) - inputs.push_back("triangles_adjacency"); - if (execution.flags & (1ull << ExecutionModeOutputTriangleStrip)) - outputs.push_back("triangle_strip"); - if (execution.flags & (1ull << ExecutionModeOutputPoints)) - outputs.push_back("points"); - if (execution.flags & (1ull << ExecutionModeOutputLineStrip)) - outputs.push_back("line_strip"); - break; - - case ExecutionModelTessellationControl: - if (execution.flags & (1ull << ExecutionModeOutputVertices)) - outputs.push_back(join("vertices = ", execution.output_vertices)); - break; - - case ExecutionModelTessellationEvaluation: - if (execution.flags & (1ull << ExecutionModeQuads)) - inputs.push_back("quads"); - if (execution.flags & (1ull << ExecutionModeTriangles)) - inputs.push_back("triangles"); - if (execution.flags & (1ull << ExecutionModeIsolines)) - inputs.push_back("isolines"); - if (execution.flags & (1ull << ExecutionModePointMode)) - inputs.push_back("point_mode"); - - if ((execution.flags & (1ull << ExecutionModeIsolines)) == 0) - { - if (execution.flags & (1ull << ExecutionModeVertexOrderCw)) - inputs.push_back("cw"); - if (execution.flags & (1ull << ExecutionModeVertexOrderCcw)) - inputs.push_back("ccw"); - } - - if (execution.flags & (1ull << ExecutionModeSpacingFractionalEven)) - inputs.push_back("fractional_even_spacing"); - if (execution.flags & (1ull << ExecutionModeSpacingFractionalOdd)) - inputs.push_back("fractional_odd_spacing"); - if (execution.flags & (1ull << ExecutionModeSpacingEqual)) - inputs.push_back("equal_spacing"); - break; - - case ExecutionModelGLCompute: - { - if (execution.workgroup_size.constant != 0) - { - SpecializationConstant wg_x, wg_y, wg_z; - get_work_group_size_specialization_constants(wg_x, wg_y, wg_z); - - if (wg_x.id) - { - if (options.vulkan_semantics) - inputs.push_back(join("local_size_x_id = ", wg_x.constant_id)); - else - inputs.push_back(join("local_size_x = ", get(wg_x.id).scalar())); - } - else - inputs.push_back(join("local_size_x = ", execution.workgroup_size.x)); - - if (wg_y.id) - { - if (options.vulkan_semantics) - inputs.push_back(join("local_size_y_id = ", wg_y.constant_id)); - else - inputs.push_back(join("local_size_y = ", get(wg_y.id).scalar())); - } - else - inputs.push_back(join("local_size_y = ", execution.workgroup_size.y)); - - if (wg_z.id) - { - if (options.vulkan_semantics) - inputs.push_back(join("local_size_z_id = ", wg_z.constant_id)); - else - inputs.push_back(join("local_size_z = ", get(wg_z.id).scalar())); - } - else - inputs.push_back(join("local_size_z = ", execution.workgroup_size.z)); - } - else - { - inputs.push_back(join("local_size_x = ", execution.workgroup_size.x)); - inputs.push_back(join("local_size_y = ", execution.workgroup_size.y)); - inputs.push_back(join("local_size_z = ", execution.workgroup_size.z)); - } - break; - } - - case ExecutionModelFragment: - if (options.es) - { - switch (options.fragment.default_float_precision) - { - case Options::Lowp: - statement("precision lowp float;"); - break; - - case Options::Mediump: - statement("precision mediump float;"); - break; - - case Options::Highp: - statement("precision highp float;"); - break; - - default: - break; - } - - switch (options.fragment.default_int_precision) - { - case Options::Lowp: - statement("precision lowp int;"); - break; - - case Options::Mediump: - statement("precision mediump int;"); - break; - - case Options::Highp: - statement("precision highp int;"); - break; - - default: - break; - } - } - - if (execution.flags & (1ull << ExecutionModeEarlyFragmentTests)) - inputs.push_back("early_fragment_tests"); - if (execution.flags & (1ull << ExecutionModeDepthGreater)) - inputs.push_back("depth_greater"); - if (execution.flags & (1ull << ExecutionModeDepthLess)) - inputs.push_back("depth_less"); - - break; - - default: - break; - } - - if (!inputs.empty()) - statement("layout(", merge(inputs), ") in;"); - if (!outputs.empty()) - statement("layout(", merge(outputs), ") out;"); - - statement(""); -} - -bool CompilerGLSL::type_is_empty(const SPIRType &type) -{ - return type.basetype == SPIRType::Struct && type.member_types.empty(); -} - -void CompilerGLSL::emit_struct(SPIRType &type) -{ - // Struct types can be stamped out multiple times - // with just different offsets, matrix layouts, etc ... - // Type-punning with these types is legal, which complicates things - // when we are storing struct and array types in an SSBO for example. - if (type.type_alias != 0) - return; - - // Don't declare empty structs in GLSL, this is not allowed. - // Empty structs is a corner case of HLSL output, and only sensible thing to do is avoiding to declare - // these types. - if (type_is_empty(type)) - return; - - add_resource_name(type.self); - auto name = type_to_glsl(type); - - statement(!backend.explicit_struct_type ? "struct " : "", name); - begin_scope(); - - type.member_name_cache.clear(); - - uint32_t i = 0; - bool emitted = false; - for (auto &member : type.member_types) - { - add_member_name(type, i); - emit_struct_member(type, member, i); - i++; - emitted = true; - } - end_scope_decl(); - - if (emitted) - statement(""); -} - -uint64_t CompilerGLSL::combined_decoration_for_member(const SPIRType &type, uint32_t index) -{ - uint64_t flags = 0; - auto &memb = meta[type.self].members; - if (index >= memb.size()) - return 0; - auto &dec = memb[index]; - - // If our type is a struct, traverse all the members as well recursively. - flags |= dec.decoration_flags; - for (uint32_t i = 0; i < type.member_types.size(); i++) - flags |= combined_decoration_for_member(get(type.member_types[i]), i); - - return flags; -} - -string CompilerGLSL::to_interpolation_qualifiers(uint64_t flags) -{ - string res; - //if (flags & (1ull << DecorationSmooth)) - // res += "smooth "; - if (flags & (1ull << DecorationFlat)) - res += "flat "; - if (flags & (1ull << DecorationNoPerspective)) - res += "noperspective "; - if (flags & (1ull << DecorationCentroid)) - res += "centroid "; - if (flags & (1ull << DecorationPatch)) - res += "patch "; - if (flags & (1ull << DecorationSample)) - res += "sample "; - if (flags & (1ull << DecorationInvariant)) - res += "invariant "; - - return res; -} - -string CompilerGLSL::layout_for_member(const SPIRType &type, uint32_t index) -{ - if (is_legacy()) - return ""; - - bool is_block = (meta[type.self].decoration.decoration_flags & - ((1ull << DecorationBlock) | (1ull << DecorationBufferBlock))) != 0; - if (!is_block) - return ""; - - auto &memb = meta[type.self].members; - if (index >= memb.size()) - return ""; - auto &dec = memb[index]; - - vector attr; - - // We can only apply layouts on members in block interfaces. - // This is a bit problematic because in SPIR-V decorations are applied on the struct types directly. - // This is not supported on GLSL, so we have to make the assumption that if a struct within our buffer block struct - // has a decoration, it was originally caused by a top-level layout() qualifier in GLSL. - // - // We would like to go from (SPIR-V style): - // - // struct Foo { layout(row_major) mat4 matrix; }; - // buffer UBO { Foo foo; }; - // - // to - // - // struct Foo { mat4 matrix; }; // GLSL doesn't support any layout shenanigans in raw struct declarations. - // buffer UBO { layout(row_major) Foo foo; }; // Apply the layout on top-level. - auto flags = combined_decoration_for_member(type, index); - - if (flags & (1ull << DecorationRowMajor)) - attr.push_back("row_major"); - // We don't emit any global layouts, so column_major is default. - //if (flags & (1ull << DecorationColMajor)) - // attr.push_back("column_major"); - - if ((dec.decoration_flags & (1ull << DecorationLocation)) != 0 && can_use_io_location(type.storage)) - attr.push_back(join("location = ", dec.location)); - - // DecorationCPacked is set by layout_for_variable earlier to mark that we need to emit offset qualifiers. - // This is only done selectively in GLSL as needed. - if (has_decoration(type.self, DecorationCPacked) && (dec.decoration_flags & (1ull << DecorationOffset)) != 0) - attr.push_back(join("offset = ", dec.offset)); - - if (attr.empty()) - return ""; - - string res = "layout("; - res += merge(attr); - res += ") "; - return res; -} - -const char *CompilerGLSL::format_to_glsl(spv::ImageFormat format) -{ - auto check_desktop = [this] { - if (options.es) - SPIRV_CROSS_THROW("Attempting to use image format not supported in ES profile."); - }; - - switch (format) - { - case ImageFormatRgba32f: - return "rgba32f"; - case ImageFormatRgba16f: - return "rgba16f"; - case ImageFormatR32f: - return "r32f"; - case ImageFormatRgba8: - return "rgba8"; - case ImageFormatRgba8Snorm: - return "rgba8_snorm"; - case ImageFormatRg32f: - return "rg32f"; - case ImageFormatRg16f: - return "rg16f"; - - case ImageFormatRgba32i: - return "rgba32i"; - case ImageFormatRgba16i: - return "rgba16i"; - case ImageFormatR32i: - return "r32i"; - case ImageFormatRgba8i: - return "rgba8i"; - case ImageFormatRg32i: - return "rg32i"; - case ImageFormatRg16i: - return "rg16i"; - - case ImageFormatRgba32ui: - return "rgba32ui"; - case ImageFormatRgba16ui: - return "rgba16ui"; - case ImageFormatR32ui: - return "r32ui"; - case ImageFormatRgba8ui: - return "rgba8ui"; - case ImageFormatRg32ui: - return "rg32ui"; - case ImageFormatRg16ui: - return "rg16ui"; - - // Desktop-only formats - case ImageFormatR11fG11fB10f: - check_desktop(); - return "r11f_g11f_b10f"; - case ImageFormatR16f: - check_desktop(); - return "r16f"; - case ImageFormatRgb10A2: - check_desktop(); - return "rgb10_a2"; - case ImageFormatR8: - check_desktop(); - return "r8"; - case ImageFormatRg8: - check_desktop(); - return "rg8"; - case ImageFormatR16: - check_desktop(); - return "r16"; - case ImageFormatRg16: - check_desktop(); - return "rg16"; - case ImageFormatRgba16: - check_desktop(); - return "rgba16"; - case ImageFormatR16Snorm: - check_desktop(); - return "r16_snorm"; - case ImageFormatRg16Snorm: - check_desktop(); - return "rg16_snorm"; - case ImageFormatRgba16Snorm: - check_desktop(); - return "rgba16_snorm"; - case ImageFormatR8Snorm: - check_desktop(); - return "r8_snorm"; - case ImageFormatRg8Snorm: - check_desktop(); - return "rg8_snorm"; - - case ImageFormatR8ui: - check_desktop(); - return "r8ui"; - case ImageFormatRg8ui: - check_desktop(); - return "rg8ui"; - case ImageFormatR16ui: - check_desktop(); - return "r16ui"; - case ImageFormatRgb10a2ui: - check_desktop(); - return "rgb10_a2ui"; - - case ImageFormatR8i: - check_desktop(); - return "r8i"; - case ImageFormatRg8i: - check_desktop(); - return "rg8i"; - case ImageFormatR16i: - check_desktop(); - return "r16i"; - - default: - case ImageFormatUnknown: - return nullptr; - } -} - -uint32_t CompilerGLSL::type_to_packed_base_size(const SPIRType &type, BufferPackingStandard) -{ - switch (type.basetype) - { - case SPIRType::Double: - case SPIRType::Int64: - case SPIRType::UInt64: - return 8; - default: - return 4; - } -} - -uint32_t CompilerGLSL::type_to_packed_alignment(const SPIRType &type, uint64_t flags, BufferPackingStandard packing) -{ - const uint32_t base_alignment = type_to_packed_base_size(type, packing); - - if (!type.array.empty()) - { - uint32_t minimum_alignment = 1; - if (packing_is_vec4_padded(packing)) - minimum_alignment = 16; - - auto *tmp = &get(type.parent_type); - while (!tmp->array.empty()) - tmp = &get(tmp->parent_type); - - // Get the alignment of the base type, then maybe round up. - return max(minimum_alignment, type_to_packed_alignment(*tmp, flags, packing)); - } - - if (type.basetype == SPIRType::Struct) - { - // Rule 9. Structs alignments are maximum alignment of its members. - uint32_t alignment = 0; - for (uint32_t i = 0; i < type.member_types.size(); i++) - { - auto member_flags = meta[type.self].members.at(i).decoration_flags; - alignment = - max(alignment, type_to_packed_alignment(get(type.member_types[i]), member_flags, packing)); - } - - // In std140, struct alignment is rounded up to 16. - if (packing_is_vec4_padded(packing)) - alignment = max(alignment, 16u); - - return alignment; - } - else - { - // Vectors are *not* aligned in HLSL, but there's an extra rule where vectors cannot straddle - // a vec4, this is handled outside since that part knows our current offset. - if (type.columns == 1 && packing_is_hlsl(packing)) - return base_alignment; - - // From 7.6.2.2 in GL 4.5 core spec. - // Rule 1 - if (type.vecsize == 1 && type.columns == 1) - return base_alignment; - - // Rule 2 - if ((type.vecsize == 2 || type.vecsize == 4) && type.columns == 1) - return type.vecsize * base_alignment; - - // Rule 3 - if (type.vecsize == 3 && type.columns == 1) - return 4 * base_alignment; - - // Rule 4 implied. Alignment does not change in std430. - - // Rule 5. Column-major matrices are stored as arrays of - // vectors. - if ((flags & (1ull << DecorationColMajor)) && type.columns > 1) - { - if (packing_is_vec4_padded(packing)) - return 4 * base_alignment; - else if (type.vecsize == 3) - return 4 * base_alignment; - else - return type.vecsize * base_alignment; - } - - // Rule 6 implied. - - // Rule 7. - if ((flags & (1ull << DecorationRowMajor)) && type.vecsize > 1) - { - if (packing_is_vec4_padded(packing)) - return 4 * base_alignment; - else if (type.columns == 3) - return 4 * base_alignment; - else - return type.columns * base_alignment; - } - - // Rule 8 implied. - } - - SPIRV_CROSS_THROW("Did not find suitable rule for type. Bogus decorations?"); -} - -uint32_t CompilerGLSL::type_to_packed_array_stride(const SPIRType &type, uint64_t flags, BufferPackingStandard packing) -{ - // Array stride is equal to aligned size of the underlying type. - uint32_t parent = type.parent_type; - assert(parent); - - auto &tmp = get(parent); - - uint32_t size = type_to_packed_size(tmp, flags, packing); - if (tmp.array.empty()) - { - uint32_t alignment = type_to_packed_alignment(type, flags, packing); - return (size + alignment - 1) & ~(alignment - 1); - } - else - { - // For multidimensional arrays, array stride always matches size of subtype. - // The alignment cannot change because multidimensional arrays are basically N * M array elements. - return size; - } -} - -uint32_t CompilerGLSL::type_to_packed_size(const SPIRType &type, uint64_t flags, BufferPackingStandard packing) -{ - if (!type.array.empty()) - { - return to_array_size_literal(type, uint32_t(type.array.size()) - 1) * - type_to_packed_array_stride(type, flags, packing); - } - - const uint32_t base_alignment = type_to_packed_base_size(type, packing); - uint32_t size = 0; - - if (type.basetype == SPIRType::Struct) - { - uint32_t pad_alignment = 1; - - for (uint32_t i = 0; i < type.member_types.size(); i++) - { - auto member_flags = meta[type.self].members.at(i).decoration_flags; - auto &member_type = get(type.member_types[i]); - - uint32_t packed_alignment = type_to_packed_alignment(member_type, member_flags, packing); - uint32_t alignment = max(packed_alignment, pad_alignment); - - // The next member following a struct member is aligned to the base alignment of the struct that came before. - // GL 4.5 spec, 7.6.2.2. - if (member_type.basetype == SPIRType::Struct) - pad_alignment = packed_alignment; - else - pad_alignment = 1; - - size = (size + alignment - 1) & ~(alignment - 1); - size += type_to_packed_size(member_type, member_flags, packing); - } - } - else - { - if (type.columns == 1) - size = type.vecsize * base_alignment; - - if ((flags & (1ull << DecorationColMajor)) && type.columns > 1) - { - if (packing_is_vec4_padded(packing)) - size = type.columns * 4 * base_alignment; - else if (type.vecsize == 3) - size = type.columns * 4 * base_alignment; - else - size = type.columns * type.vecsize * base_alignment; - } - - if ((flags & (1ull << DecorationRowMajor)) && type.vecsize > 1) - { - if (packing_is_vec4_padded(packing)) - size = type.vecsize * 4 * base_alignment; - else if (type.columns == 3) - size = type.vecsize * 4 * base_alignment; - else - size = type.vecsize * type.columns * base_alignment; - } - } - - return size; -} - -bool CompilerGLSL::buffer_is_packing_standard(const SPIRType &type, BufferPackingStandard packing) -{ - // This is very tricky and error prone, but try to be exhaustive and correct here. - // SPIR-V doesn't directly say if we're using std430 or std140. - // SPIR-V communicates this using Offset and ArrayStride decorations (which is what really matters), - // so we have to try to infer whether or not the original GLSL source was std140 or std430 based on this information. - // We do not have to consider shared or packed since these layouts are not allowed in Vulkan SPIR-V (they are useless anyways, and custom offsets would do the same thing). - // - // It is almost certain that we're using std430, but it gets tricky with arrays in particular. - // We will assume std430, but infer std140 if we can prove the struct is not compliant with std430. - // - // The only two differences between std140 and std430 are related to padding alignment/array stride - // in arrays and structs. In std140 they take minimum vec4 alignment. - // std430 only removes the vec4 requirement. - - uint32_t offset = 0; - uint32_t pad_alignment = 1; - - for (uint32_t i = 0; i < type.member_types.size(); i++) - { - auto &memb_type = get(type.member_types[i]); - auto member_flags = meta[type.self].members.at(i).decoration_flags; - - // Verify alignment rules. - uint32_t packed_alignment = type_to_packed_alignment(memb_type, member_flags, packing); - uint32_t packed_size = type_to_packed_size(memb_type, member_flags, packing); - - if (packing_is_hlsl(packing)) - { - // If a member straddles across a vec4 boundary, alignment is actually vec4. - uint32_t begin_word = offset / 16; - uint32_t end_word = (offset + packed_size - 1) / 16; - if (begin_word != end_word) - packed_alignment = max(packed_alignment, 16u); - } - - uint32_t alignment = max(packed_alignment, pad_alignment); - offset = (offset + alignment - 1) & ~(alignment - 1); - - // The next member following a struct member is aligned to the base alignment of the struct that came before. - // GL 4.5 spec, 7.6.2.2. - if (memb_type.basetype == SPIRType::Struct) - pad_alignment = packed_alignment; - else - pad_alignment = 1; - - // We only care about offsets in std140, std430, etc ... - // For EnhancedLayout variants, we have the flexibility to choose our own offsets. - if (!packing_has_flexible_offset(packing)) - { - uint32_t actual_offset = type_struct_member_offset(type, i); - if (actual_offset != offset) // This cannot be the packing we're looking for. - return false; - } - - // Verify array stride rules. - if (!memb_type.array.empty() && - type_to_packed_array_stride(memb_type, member_flags, packing) != type_struct_member_array_stride(type, i)) - return false; - - // Verify that sub-structs also follow packing rules. - // We cannot use enhanced layouts on substructs, so they better be up to spec. - auto substruct_packing = packing_to_substruct_packing(packing); - - if (!memb_type.member_types.empty() && !buffer_is_packing_standard(memb_type, substruct_packing)) - return false; - - // Bump size. - offset += packed_size; - } - - return true; -} - -bool CompilerGLSL::can_use_io_location(StorageClass storage) -{ - // Location specifiers are must have in SPIR-V, but they aren't really supported in earlier versions of GLSL. - // Be very explicit here about how to solve the issue. - if ((get_execution_model() != ExecutionModelVertex && storage == StorageClassInput) || - (get_execution_model() != ExecutionModelFragment && storage == StorageClassOutput)) - { - if (!options.es && options.version < 410 && !options.separate_shader_objects) - return false; - else if (options.es && options.version < 310) - return false; - } - - if ((get_execution_model() == ExecutionModelVertex && storage == StorageClassInput) || - (get_execution_model() == ExecutionModelFragment && storage == StorageClassOutput)) - { - if (options.es && options.version < 300) - return false; - else if (!options.es && options.version < 330) - return false; - } - - return true; -} - -string CompilerGLSL::layout_for_variable(const SPIRVariable &var) -{ - // FIXME: Come up with a better solution for when to disable layouts. - // Having layouts depend on extensions as well as which types - // of layouts are used. For now, the simple solution is to just disable - // layouts for legacy versions. - if (is_legacy()) - return ""; - - vector attr; - - auto &dec = meta[var.self].decoration; - auto &type = get(var.basetype); - auto flags = dec.decoration_flags; - auto typeflags = meta[type.self].decoration.decoration_flags; - - if (options.vulkan_semantics && var.storage == StorageClassPushConstant) - attr.push_back("push_constant"); - - if (flags & (1ull << DecorationRowMajor)) - attr.push_back("row_major"); - if (flags & (1ull << DecorationColMajor)) - attr.push_back("column_major"); - - if (options.vulkan_semantics) - { - if (flags & (1ull << DecorationInputAttachmentIndex)) - attr.push_back(join("input_attachment_index = ", dec.input_attachment)); - } - - if ((flags & (1ull << DecorationLocation)) != 0 && can_use_io_location(var.storage)) - { - uint64_t combined_decoration = 0; - for (uint32_t i = 0; i < meta[type.self].members.size(); i++) - combined_decoration |= combined_decoration_for_member(type, i); - - // If our members have location decorations, we don't need to - // emit location decorations at the top as well (looks weird). - if ((combined_decoration & (1ull << DecorationLocation)) == 0) - attr.push_back(join("location = ", dec.location)); - } - - // set = 0 is the default. Do not emit set = decoration in regular GLSL output, but - // we should preserve it in Vulkan GLSL mode. - if (var.storage != StorageClassPushConstant) - { - if ((flags & (1ull << DecorationDescriptorSet)) && (dec.set != 0 || options.vulkan_semantics)) - attr.push_back(join("set = ", dec.set)); - } - - bool can_use_binding; - if (options.es) - can_use_binding = options.version >= 310; - else - can_use_binding = options.enable_420pack_extension || (options.version >= 420); - - if (can_use_binding && (flags & (1ull << DecorationBinding))) - attr.push_back(join("binding = ", dec.binding)); - - if (flags & (1ull << DecorationOffset)) - attr.push_back(join("offset = ", dec.offset)); - - bool push_constant_block = options.vulkan_semantics && var.storage == StorageClassPushConstant; - bool ssbo_block = var.storage == StorageClassStorageBuffer || - (var.storage == StorageClassUniform && (typeflags & (1ull << DecorationBufferBlock))); - - // Instead of adding explicit offsets for every element here, just assume we're using std140 or std430. - // If SPIR-V does not comply with either layout, we cannot really work around it. - if (var.storage == StorageClassUniform && (typeflags & (1ull << DecorationBlock))) - { - if (buffer_is_packing_standard(type, BufferPackingStd140)) - attr.push_back("std140"); - else if (buffer_is_packing_standard(type, BufferPackingStd140EnhancedLayout)) - { - attr.push_back("std140"); - // Fallback time. We might be able to use the ARB_enhanced_layouts to deal with this difference, - // however, we can only use layout(offset) on the block itself, not any substructs, so the substructs better be the appropriate layout. - // Enhanced layouts seem to always work in Vulkan GLSL, so no need for extensions there. - if (options.es && !options.vulkan_semantics) - SPIRV_CROSS_THROW("Push constant block cannot be expressed as neither std430 nor std140. ES-targets do " - "not support GL_ARB_enhanced_layouts."); - if (!options.es && !options.vulkan_semantics && options.version < 440) - require_extension("GL_ARB_enhanced_layouts"); - - // This is a very last minute to check for this, but use this unused decoration to mark that we should emit - // explicit offsets for this block type. - // layout_for_variable() will be called before the actual buffer emit. - // The alternative is a full pass before codegen where we deduce this decoration, - // but then we are just doing the exact same work twice, and more complexity. - set_decoration(type.self, DecorationCPacked); - } - else - { - SPIRV_CROSS_THROW("Uniform buffer cannot be expressed as std140, even with enhanced layouts. You can try " - "flattening this block to " - "support a more flexible layout."); - } - } - else if (push_constant_block || ssbo_block) - { - if (buffer_is_packing_standard(type, BufferPackingStd430)) - attr.push_back("std430"); - else if (buffer_is_packing_standard(type, BufferPackingStd140)) - attr.push_back("std140"); - else if (buffer_is_packing_standard(type, BufferPackingStd140EnhancedLayout)) - { - attr.push_back("std140"); - - // Fallback time. We might be able to use the ARB_enhanced_layouts to deal with this difference, - // however, we can only use layout(offset) on the block itself, not any substructs, so the substructs better be the appropriate layout. - // Enhanced layouts seem to always work in Vulkan GLSL, so no need for extensions there. - if (options.es && !options.vulkan_semantics) - SPIRV_CROSS_THROW("Push constant block cannot be expressed as neither std430 nor std140. ES-targets do " - "not support GL_ARB_enhanced_layouts."); - if (!options.es && !options.vulkan_semantics && options.version < 440) - require_extension("GL_ARB_enhanced_layouts"); - - set_decoration(type.self, DecorationCPacked); - } - else if (buffer_is_packing_standard(type, BufferPackingStd430EnhancedLayout)) - { - attr.push_back("std430"); - if (options.es && !options.vulkan_semantics) - SPIRV_CROSS_THROW("Push constant block cannot be expressed as neither std430 nor std140. ES-targets do " - "not support GL_ARB_enhanced_layouts."); - if (!options.es && !options.vulkan_semantics && options.version < 440) - require_extension("GL_ARB_enhanced_layouts"); - - set_decoration(type.self, DecorationCPacked); - } - else - { - SPIRV_CROSS_THROW("Buffer block cannot be expressed as neither std430 nor std140, even with enhanced " - "layouts. You can try flattening this block to support a more flexible layout."); - } - } - - // For images, the type itself adds a layout qualifer. - // Only emit the format for storage images. - if (type.basetype == SPIRType::Image && type.image.sampled == 2) - { - const char *fmt = format_to_glsl(type.image.format); - if (fmt) - attr.push_back(fmt); - } - - if (attr.empty()) - return ""; - - string res = "layout("; - res += merge(attr); - res += ") "; - return res; -} - -void CompilerGLSL::emit_push_constant_block(const SPIRVariable &var) -{ - if (flattened_buffer_blocks.count(var.self)) - emit_buffer_block_flattened(var); - else if (options.vulkan_semantics) - emit_push_constant_block_vulkan(var); - else - emit_push_constant_block_glsl(var); -} - -void CompilerGLSL::emit_push_constant_block_vulkan(const SPIRVariable &var) -{ - emit_buffer_block(var); -} - -void CompilerGLSL::emit_push_constant_block_glsl(const SPIRVariable &var) -{ - // OpenGL has no concept of push constant blocks, implement it as a uniform struct. - auto &type = get(var.basetype); - - auto &flags = meta[var.self].decoration.decoration_flags; - flags &= ~((1ull << DecorationBinding) | (1ull << DecorationDescriptorSet)); - -#if 0 - if (flags & ((1ull << DecorationBinding) | (1ull << DecorationDescriptorSet))) - SPIRV_CROSS_THROW("Push constant blocks cannot be compiled to GLSL with Binding or Set syntax. " - "Remap to location with reflection API first or disable these decorations."); -#endif - - // We're emitting the push constant block as a regular struct, so disable the block qualifier temporarily. - // Otherwise, we will end up emitting layout() qualifiers on naked structs which is not allowed. - auto &block_flags = meta[type.self].decoration.decoration_flags; - uint64_t block_flag = block_flags & (1ull << DecorationBlock); - block_flags &= ~block_flag; - - emit_struct(type); - - block_flags |= block_flag; - - emit_uniform(var); - statement(""); -} - -void CompilerGLSL::emit_buffer_block(const SPIRVariable &var) -{ - if (flattened_buffer_blocks.count(var.self)) - emit_buffer_block_flattened(var); - else if (is_legacy()) - emit_buffer_block_legacy(var); - else - emit_buffer_block_native(var); -} - -void CompilerGLSL::emit_buffer_block_legacy(const SPIRVariable &var) -{ - auto &type = get(var.basetype); - bool ssbo = var.storage == StorageClassStorageBuffer || - ((meta[type.self].decoration.decoration_flags & (1ull << DecorationBufferBlock)) != 0); - if (ssbo) - SPIRV_CROSS_THROW("SSBOs not supported in legacy targets."); - - // We're emitting the push constant block as a regular struct, so disable the block qualifier temporarily. - // Otherwise, we will end up emitting layout() qualifiers on naked structs which is not allowed. - auto &block_flags = meta[type.self].decoration.decoration_flags; - uint64_t block_flag = block_flags & (1ull << DecorationBlock); - block_flags &= ~block_flag; - emit_struct(type); - block_flags |= block_flag; - emit_uniform(var); - statement(""); -} - -void CompilerGLSL::emit_buffer_block_native(const SPIRVariable &var) -{ - auto &type = get(var.basetype); - - uint64_t flags = get_buffer_block_flags(var); - bool ssbo = var.storage == StorageClassStorageBuffer || - ((meta[type.self].decoration.decoration_flags & (1ull << DecorationBufferBlock)) != 0); - bool is_restrict = ssbo && (flags & (1ull << DecorationRestrict)) != 0; - bool is_writeonly = ssbo && (flags & (1ull << DecorationNonReadable)) != 0; - bool is_readonly = ssbo && (flags & (1ull << DecorationNonWritable)) != 0; - bool is_coherent = ssbo && (flags & (1ull << DecorationCoherent)) != 0; - - // Block names should never alias, but from HLSL input they kind of can because block types are reused for UAVs ... - auto buffer_name = to_name(type.self, false); - - // Shaders never use the block by interface name, so we don't - // have to track this other than updating name caches. - if (meta[type.self].decoration.alias.empty() || resource_names.find(buffer_name) != end(resource_names)) - buffer_name = get_block_fallback_name(var.self); - - // Make sure we get something unique. - add_variable(resource_names, buffer_name); - - // If for some reason buffer_name is an illegal name, make a final fallback to a workaround name. - // This cannot conflict with anything else, so we're safe now. - if (buffer_name.empty()) - buffer_name = join("_", get(var.basetype).self, "_", var.self); - - // Save for post-reflection later. - declared_block_names[var.self] = buffer_name; - - statement(layout_for_variable(var), is_coherent ? "coherent " : "", is_restrict ? "restrict " : "", - is_writeonly ? "writeonly " : "", is_readonly ? "readonly " : "", ssbo ? "buffer " : "uniform ", - buffer_name); - - begin_scope(); - - type.member_name_cache.clear(); - - uint32_t i = 0; - for (auto &member : type.member_types) - { - add_member_name(type, i); - emit_struct_member(type, member, i); - i++; - } - - add_resource_name(var.self); - end_scope_decl(to_name(var.self) + type_to_array_glsl(type)); - statement(""); -} - -void CompilerGLSL::emit_buffer_block_flattened(const SPIRVariable &var) -{ - auto &type = get(var.basetype); - - // Block names should never alias. - auto buffer_name = to_name(type.self, false); - size_t buffer_size = (get_declared_struct_size(type) + 15) / 16; - - SPIRType::BaseType basic_type; - if (get_common_basic_type(type, basic_type)) - { - SPIRType tmp; - tmp.basetype = basic_type; - tmp.vecsize = 4; - if (basic_type != SPIRType::Float && basic_type != SPIRType::Int && basic_type != SPIRType::UInt) - SPIRV_CROSS_THROW("Basic types in a flattened UBO must be float, int or uint."); - - auto flags = get_buffer_block_flags(var); - statement("uniform ", flags_to_precision_qualifiers_glsl(tmp, flags), type_to_glsl(tmp), " ", buffer_name, "[", - buffer_size, "];"); - } - else - SPIRV_CROSS_THROW("All basic types in a flattened block must be the same."); -} - -const char *CompilerGLSL::to_storage_qualifiers_glsl(const SPIRVariable &var) -{ - auto &execution = get_entry_point(); - - if (var.storage == StorageClassInput || var.storage == StorageClassOutput) - { - if (is_legacy() && execution.model == ExecutionModelVertex) - return var.storage == StorageClassInput ? "attribute " : "varying "; - else if (is_legacy() && execution.model == ExecutionModelFragment) - return "varying "; // Fragment outputs are renamed so they never hit this case. - else - return var.storage == StorageClassInput ? "in " : "out "; - } - else if (var.storage == StorageClassUniformConstant || var.storage == StorageClassUniform || - var.storage == StorageClassPushConstant) - { - return "uniform "; - } - - return ""; -} - -void CompilerGLSL::emit_flattened_io_block(const SPIRVariable &var, const char *qual) -{ - auto &type = get(var.basetype); - if (!type.array.empty()) - SPIRV_CROSS_THROW("Array of varying structs cannot be flattened to legacy-compatible varyings."); - - auto old_flags = meta[type.self].decoration.decoration_flags; - // Emit the members as if they are part of a block to get all qualifiers. - meta[type.self].decoration.decoration_flags |= 1ull << DecorationBlock; - - type.member_name_cache.clear(); - - uint32_t i = 0; - for (auto &member : type.member_types) - { - add_member_name(type, i); - auto &membertype = get(member); - - if (membertype.basetype == SPIRType::Struct) - SPIRV_CROSS_THROW("Cannot flatten struct inside structs in I/O variables."); - - // Pass in the varying qualifier here so it will appear in the correct declaration order. - // Replace member name while emitting it so it encodes both struct name and member name. - // Sanitize underscores because joining the two identifiers might create more than 1 underscore in a row, - // which is not allowed. - auto backup_name = get_member_name(type.self, i); - auto member_name = to_member_name(type, i); - set_member_name(type.self, i, sanitize_underscores(join(to_name(var.self), "_", member_name))); - emit_struct_member(type, member, i, qual); - // Restore member name. - set_member_name(type.self, i, member_name); - i++; - } - - meta[type.self].decoration.decoration_flags = old_flags; - - // Treat this variable as flattened from now on. - flattened_structs.insert(var.self); -} - -void CompilerGLSL::emit_interface_block(const SPIRVariable &var) -{ - auto &type = get(var.basetype); - - // Either make it plain in/out or in/out blocks depending on what shader is doing ... - bool block = (meta[type.self].decoration.decoration_flags & (1ull << DecorationBlock)) != 0; - const char *qual = to_storage_qualifiers_glsl(var); - - if (block) - { - // ESSL earlier than 310 and GLSL earlier than 150 did not support - // I/O variables which are struct types. - // To support this, flatten the struct into separate varyings instead. - if ((options.es && options.version < 310) || (!options.es && options.version < 150)) - { - // I/O blocks on ES require version 310 with Android Extension Pack extensions, or core version 320. - // On desktop, I/O blocks were introduced with geometry shaders in GL 3.2 (GLSL 150). - emit_flattened_io_block(var, qual); - } - else - { - if (options.es && options.version < 320) - { - // Geometry and tessellation extensions imply this extension. - if (!has_extension("GL_EXT_geometry_shader") && !has_extension("GL_EXT_tessellation_shader")) - require_extension("GL_EXT_shader_io_blocks"); - } - - // Block names should never alias. - auto block_name = to_name(type.self, false); - - // Shaders never use the block by interface name, so we don't - // have to track this other than updating name caches. - if (resource_names.find(block_name) != end(resource_names)) - block_name = get_fallback_name(type.self); - else - resource_names.insert(block_name); - - statement(layout_for_variable(var), qual, block_name); - begin_scope(); - - type.member_name_cache.clear(); - - uint32_t i = 0; - for (auto &member : type.member_types) - { - add_member_name(type, i); - emit_struct_member(type, member, i); - i++; - } - - add_resource_name(var.self); - end_scope_decl(join(to_name(var.self), type_to_array_glsl(type))); - statement(""); - } - } - else - { - // ESSL earlier than 310 and GLSL earlier than 150 did not support - // I/O variables which are struct types. - // To support this, flatten the struct into separate varyings instead. - if (type.basetype == SPIRType::Struct && - ((options.es && options.version < 310) || (!options.es && options.version < 150))) - { - emit_flattened_io_block(var, qual); - } - else - { - add_resource_name(var.self); - statement(layout_for_variable(var), variable_decl(var), ";"); - } - } -} - -void CompilerGLSL::emit_uniform(const SPIRVariable &var) -{ - auto &type = get(var.basetype); - if (type.basetype == SPIRType::Image && type.image.sampled == 2) - { - if (!options.es && options.version < 420) - require_extension("GL_ARB_shader_image_load_store"); - else if (options.es && options.version < 310) - SPIRV_CROSS_THROW("At least ESSL 3.10 required for shader image load store."); - } - - add_resource_name(var.self); - statement(layout_for_variable(var), variable_decl(var), ";"); -} - -void CompilerGLSL::emit_specialization_constant(const SPIRConstant &constant) -{ - auto &type = get(constant.constant_type); - auto name = to_name(constant.self); - - SpecializationConstant wg_x, wg_y, wg_z; - uint32_t workgroup_size_id = get_work_group_size_specialization_constants(wg_x, wg_y, wg_z); - - if (constant.self == workgroup_size_id || constant.self == wg_x.id || constant.self == wg_y.id || - constant.self == wg_z.id) - { - // These specialization constants are implicitly declared by emitting layout() in; - return; - } - - // Only scalars have constant IDs. - if (has_decoration(constant.self, DecorationSpecId)) - { - statement("layout(constant_id = ", get_decoration(constant.self, DecorationSpecId), ") const ", - variable_decl(type, name), " = ", constant_expression(constant), ";"); - } - else - { - statement("const ", variable_decl(type, name), " = ", constant_expression(constant), ";"); - } -} - -void CompilerGLSL::replace_illegal_names() -{ - // clang-format off - static const unordered_set keywords = { - "active", "asm", "atomic_uint", "attribute", "bool", "break", - "bvec2", "bvec3", "bvec4", "case", "cast", "centroid", "class", "coherent", "common", "const", "continue", "default", "discard", - "dmat2", "dmat2x2", "dmat2x3", "dmat2x4", "dmat3", "dmat3x2", "dmat3x3", "dmat3x4", "dmat4", "dmat4x2", "dmat4x3", "dmat4x4", - "do", "double", "dvec2", "dvec3", "dvec4", "else", "enum", "extern", "external", "false", "filter", "fixed", "flat", "float", - "for", "fvec2", "fvec3", "fvec4", "goto", "half", "highp", "hvec2", "hvec3", "hvec4", "if", "iimage1D", "iimage1DArray", - "iimage2D", "iimage2DArray", "iimage2DMS", "iimage2DMSArray", "iimage2DRect", "iimage3D", "iimageBuffer", "iimageCube", - "iimageCubeArray", "image1D", "image1DArray", "image2D", "image2DArray", "image2DMS", "image2DMSArray", "image2DRect", - "image3D", "imageBuffer", "imageCube", "imageCubeArray", "in", "inline", "inout", "input", "int", "interface", "invariant", - "isampler1D", "isampler1DArray", "isampler2D", "isampler2DArray", "isampler2DMS", "isampler2DMSArray", "isampler2DRect", - "isampler3D", "isamplerBuffer", "isamplerCube", "isamplerCubeArray", "ivec2", "ivec3", "ivec4", "layout", "long", "lowp", - "mat2", "mat2x2", "mat2x3", "mat2x4", "mat3", "mat3x2", "mat3x3", "mat3x4", "mat4", "mat4x2", "mat4x3", "mat4x4", "mediump", - "namespace", "noinline", "noperspective", "out", "output", "packed", "partition", "patch", "precision", "public", "readonly", - "resource", "restrict", "return", "row_major", "sample", "sampler1D", "sampler1DArray", "sampler1DArrayShadow", - "sampler1DShadow", "sampler2D", "sampler2DArray", "sampler2DArrayShadow", "sampler2DMS", "sampler2DMSArray", - "sampler2DRect", "sampler2DRectShadow", "sampler2DShadow", "sampler3D", "sampler3DRect", "samplerBuffer", - "samplerCube", "samplerCubeArray", "samplerCubeArrayShadow", "samplerCubeShadow", "short", "sizeof", "smooth", "static", - "struct", "subroutine", "superp", "switch", "template", "this", "true", "typedef", "uimage1D", "uimage1DArray", "uimage2D", - "uimage2DArray", "uimage2DMS", "uimage2DMSArray", "uimage2DRect", "uimage3D", "uimageBuffer", "uimageCube", - "uimageCubeArray", "uint", "uniform", "union", "unsigned", "usampler1D", "usampler1DArray", "usampler2D", "usampler2DArray", - "usampler2DMS", "usampler2DMSArray", "usampler2DRect", "usampler3D", "usamplerBuffer", "usamplerCube", - "usamplerCubeArray", "using", "uvec2", "uvec3", "uvec4", "varying", "vec2", "vec3", "vec4", "void", "volatile", "volatile", - "while", "writeonly", "texture" - }; - // clang-format on - - for (auto &id : ids) - { - if (id.get_type() == TypeVariable) - { - auto &var = id.get(); - if (!is_hidden_variable(var)) - { - auto &m = meta[var.self].decoration; - if (m.alias.compare(0, 3, "gl_") == 0 || keywords.find(m.alias) != end(keywords)) - m.alias = join("_", m.alias); - } - } - } -} - -void CompilerGLSL::replace_fragment_output(SPIRVariable &var) -{ - auto &m = meta[var.self].decoration; - uint32_t location = 0; - if (m.decoration_flags & (1ull << DecorationLocation)) - location = m.location; - - // If our variable is arrayed, we must not emit the array part of this as the SPIR-V will - // do the access chain part of this for us. - auto &type = get(var.basetype); - - if (type.array.empty()) - { - // Redirect the write to a specific render target in legacy GLSL. - m.alias = join("gl_FragData[", location, "]"); - - if (is_legacy_es() && location != 0) - require_extension("GL_EXT_draw_buffers"); - } - else if (type.array.size() == 1) - { - // If location is non-zero, we probably have to add an offset. - // This gets really tricky since we'd have to inject an offset in the access chain. - // FIXME: This seems like an extremely odd-ball case, so it's probably fine to leave it like this for now. - m.alias = "gl_FragData"; - if (location != 0) - SPIRV_CROSS_THROW("Arrayed output variable used, but location is not 0. " - "This is unimplemented in SPIRV-Cross."); - - if (is_legacy_es()) - require_extension("GL_EXT_draw_buffers"); - } - else - SPIRV_CROSS_THROW("Array-of-array output variable used. This cannot be implemented in legacy GLSL."); - - var.compat_builtin = true; // We don't want to declare this variable, but use the name as-is. -} - -void CompilerGLSL::replace_fragment_outputs() -{ - for (auto &id : ids) - { - if (id.get_type() == TypeVariable) - { - auto &var = id.get(); - auto &type = get(var.basetype); - - if (!is_builtin_variable(var) && !var.remapped_variable && type.pointer && - var.storage == StorageClassOutput) - replace_fragment_output(var); - } - } -} - -string CompilerGLSL::remap_swizzle(const SPIRType &out_type, uint32_t input_components, const string &expr) -{ - if (out_type.vecsize == input_components) - return expr; - else if (input_components == 1 && !backend.can_swizzle_scalar) - return join(type_to_glsl(out_type), "(", expr, ")"); - else - { - auto e = enclose_expression(expr) + "."; - // Just clamp the swizzle index if we have more outputs than inputs. - for (uint32_t c = 0; c < out_type.vecsize; c++) - e += index_to_swizzle(min(c, input_components - 1)); - if (backend.swizzle_is_function && out_type.vecsize > 1) - e += "()"; - - remove_duplicate_swizzle(e); - return e; - } -} - -void CompilerGLSL::emit_pls() -{ - auto &execution = get_entry_point(); - if (execution.model != ExecutionModelFragment) - SPIRV_CROSS_THROW("Pixel local storage only supported in fragment shaders."); - - if (!options.es) - SPIRV_CROSS_THROW("Pixel local storage only supported in OpenGL ES."); - - if (options.version < 300) - SPIRV_CROSS_THROW("Pixel local storage only supported in ESSL 3.0 and above."); - - if (!pls_inputs.empty()) - { - statement("__pixel_local_inEXT _PLSIn"); - begin_scope(); - for (auto &input : pls_inputs) - statement(pls_decl(input), ";"); - end_scope_decl(); - statement(""); - } - - if (!pls_outputs.empty()) - { - statement("__pixel_local_outEXT _PLSOut"); - begin_scope(); - for (auto &output : pls_outputs) - statement(pls_decl(output), ";"); - end_scope_decl(); - statement(""); - } -} - -void CompilerGLSL::fixup_image_load_store_access() -{ - for (auto &id : ids) - { - if (id.get_type() != TypeVariable) - continue; - - uint32_t var = id.get().self; - auto &vartype = expression_type(var); - if (vartype.basetype == SPIRType::Image) - { - // Older glslangValidator does not emit required qualifiers here. - // Solve this by making the image access as restricted as possible and loosen up if we need to. - // If any no-read/no-write flags are actually set, assume that the compiler knows what it's doing. - - auto &flags = meta.at(var).decoration.decoration_flags; - static const uint64_t NoWrite = 1ull << DecorationNonWritable; - static const uint64_t NoRead = 1ull << DecorationNonReadable; - if ((flags & (NoWrite | NoRead)) == 0) - flags |= NoRead | NoWrite; - } - } -} - -void CompilerGLSL::emit_declared_builtin_block(StorageClass storage, ExecutionModel model) -{ - uint64_t emitted_builtins = 0; - uint64_t global_builtins = 0; - const SPIRVariable *block_var = nullptr; - bool emitted_block = false; - bool builtin_array = false; - - for (auto &id : ids) - { - if (id.get_type() != TypeVariable) - continue; - - auto &var = id.get(); - auto &type = get(var.basetype); - bool block = has_decoration(type.self, DecorationBlock); - uint64_t builtins = 0; - - if (var.storage == storage && block && is_builtin_variable(var)) - { - for (auto &m : meta[type.self].members) - if (m.builtin) - builtins |= 1ull << m.builtin_type; - } - else if (var.storage == storage && !block && is_builtin_variable(var)) - { - // While we're at it, collect all declared global builtins (HLSL mostly ...). - auto &m = meta[var.self].decoration; - if (m.builtin) - global_builtins |= 1ull << m.builtin_type; - } - - if (!builtins) - continue; - - if (emitted_block) - SPIRV_CROSS_THROW("Cannot use more than one builtin I/O block."); - - emitted_builtins = builtins; - emitted_block = true; - builtin_array = !type.array.empty(); - block_var = &var; - } - - global_builtins &= (1ull << BuiltInPosition) | (1ull << BuiltInPointSize) | (1ull << BuiltInClipDistance) | - (1ull << BuiltInCullDistance); - - // Try to collect all other declared builtins. - if (!emitted_block) - emitted_builtins = global_builtins; - - // Can't declare an empty interface block. - if (!emitted_builtins) - return; - - if (storage == StorageClassOutput) - statement("out gl_PerVertex"); - else - statement("in gl_PerVertex"); - - begin_scope(); - if (emitted_builtins & (1ull << BuiltInPosition)) - statement("vec4 gl_Position;"); - if (emitted_builtins & (1ull << BuiltInPointSize)) - statement("float gl_PointSize;"); - if (emitted_builtins & (1ull << BuiltInClipDistance)) - statement("float gl_ClipDistance[];"); // TODO: Do we need a fixed array size here? - if (emitted_builtins & (1ull << BuiltInCullDistance)) - statement("float gl_CullDistance[];"); // TODO: Do we need a fixed array size here? - - bool tessellation = model == ExecutionModelTessellationEvaluation || model == ExecutionModelTessellationControl; - if (builtin_array) - { - // Make sure the array has a supported name in the code. - if (storage == StorageClassOutput) - set_name(block_var->self, "gl_out"); - else if (storage == StorageClassInput) - set_name(block_var->self, "gl_in"); - - if (model == ExecutionModelTessellationControl && storage == StorageClassOutput) - end_scope_decl(join(to_name(block_var->self), "[", get_entry_point().output_vertices, "]")); - else - end_scope_decl(join(to_name(block_var->self), tessellation ? "[gl_MaxPatchVertices]" : "[]")); - } - else - end_scope_decl(); - statement(""); -} - -void CompilerGLSL::declare_undefined_values() -{ - bool emitted = false; - for (auto &id : ids) - { - if (id.get_type() != TypeUndef) - continue; - - auto &undef = id.get(); - statement(variable_decl(get(undef.basetype), to_name(undef.self), undef.self), ";"); - emitted = true; - } - - if (emitted) - statement(""); -} - -void CompilerGLSL::emit_resources() -{ - auto &execution = get_entry_point(); - - replace_illegal_names(); - - // Legacy GL uses gl_FragData[], redeclare all fragment outputs - // with builtins. - if (execution.model == ExecutionModelFragment && is_legacy()) - replace_fragment_outputs(); - - // Emit PLS blocks if we have such variables. - if (!pls_inputs.empty() || !pls_outputs.empty()) - emit_pls(); - - // Emit custom gl_PerVertex for SSO compatibility. - if (options.separate_shader_objects && !options.es) - { - switch (execution.model) - { - case ExecutionModelGeometry: - case ExecutionModelTessellationControl: - case ExecutionModelTessellationEvaluation: - emit_declared_builtin_block(StorageClassInput, execution.model); - emit_declared_builtin_block(StorageClassOutput, execution.model); - break; - - case ExecutionModelVertex: - emit_declared_builtin_block(StorageClassOutput, execution.model); - break; - - default: - break; - } - } - - bool emitted = false; - - // If emitted Vulkan GLSL, - // emit specialization constants as actual floats, - // spec op expressions will redirect to the constant name. - // - // TODO: If we have the fringe case that we create a spec constant which depends on a struct type, - // we'll have to deal with that, but there's currently no known way to express that. - if (options.vulkan_semantics) - { - for (auto &id : ids) - { - if (id.get_type() == TypeConstant) - { - auto &c = id.get(); - if (!c.specialization) - continue; - - emit_specialization_constant(c); - emitted = true; - } - } - } - - if (emitted) - statement(""); - emitted = false; - - // Output all basic struct types which are not Block or BufferBlock as these are declared inplace - // when such variables are instantiated. - for (auto &id : ids) - { - if (id.get_type() == TypeType) - { - auto &type = id.get(); - if (type.basetype == SPIRType::Struct && type.array.empty() && !type.pointer && - (meta[type.self].decoration.decoration_flags & - ((1ull << DecorationBlock) | (1ull << DecorationBufferBlock))) == 0) - { - emit_struct(type); - } - } - } - - // Output UBOs and SSBOs - for (auto &id : ids) - { - if (id.get_type() == TypeVariable) - { - auto &var = id.get(); - auto &type = get(var.basetype); - - bool is_block_storage = type.storage == StorageClassStorageBuffer || type.storage == StorageClassUniform; - bool has_block_flags = (meta[type.self].decoration.decoration_flags & - ((1ull << DecorationBlock) | (1ull << DecorationBufferBlock))) != 0; - - if (var.storage != StorageClassFunction && type.pointer && is_block_storage && !is_hidden_variable(var) && - has_block_flags) - { - emit_buffer_block(var); - } - } - } - - // Output push constant blocks - for (auto &id : ids) - { - if (id.get_type() == TypeVariable) - { - auto &var = id.get(); - auto &type = get(var.basetype); - if (var.storage != StorageClassFunction && type.pointer && type.storage == StorageClassPushConstant && - !is_hidden_variable(var)) - { - emit_push_constant_block(var); - } - } - } - - bool skip_separate_image_sampler = !combined_image_samplers.empty() || !options.vulkan_semantics; - - // Output Uniform Constants (values, samplers, images, etc). - for (auto &id : ids) - { - if (id.get_type() == TypeVariable) - { - auto &var = id.get(); - auto &type = get(var.basetype); - - // If we're remapping separate samplers and images, only emit the combined samplers. - if (skip_separate_image_sampler) - { - // Sampler buffers are always used without a sampler, and they will also work in regular GL. - bool sampler_buffer = type.basetype == SPIRType::Image && type.image.dim == DimBuffer; - bool separate_image = type.basetype == SPIRType::Image && type.image.sampled == 1; - bool separate_sampler = type.basetype == SPIRType::Sampler; - if (!sampler_buffer && (separate_image || separate_sampler)) - continue; - } - - if (var.storage != StorageClassFunction && type.pointer && - (type.storage == StorageClassUniformConstant || type.storage == StorageClassAtomicCounter) && - !is_hidden_variable(var)) - { - emit_uniform(var); - emitted = true; - } - } - } - - if (emitted) - statement(""); - emitted = false; - - // Output in/out interfaces. - for (auto &id : ids) - { - if (id.get_type() == TypeVariable) - { - auto &var = id.get(); - auto &type = get(var.basetype); - - // HLSL output from glslang may emit interface variables which are "empty". - // Just avoid declaring them. - if (type_is_empty(type)) - continue; - - if (var.storage != StorageClassFunction && type.pointer && - (var.storage == StorageClassInput || var.storage == StorageClassOutput) && - interface_variable_exists_in_entry_point(var.self) && !is_hidden_variable(var)) - { - emit_interface_block(var); - emitted = true; - } - else if (is_builtin_variable(var)) - { - // For gl_InstanceIndex emulation on GLES, the API user needs to - // supply this uniform. - if (meta[var.self].decoration.builtin_type == BuiltInInstanceIndex && !options.vulkan_semantics) - { - statement("uniform int SPIRV_Cross_BaseInstance;"); - emitted = true; - } - } - } - } - - // Global variables. - for (auto global : global_variables) - { - auto &var = get(global); - if (var.storage != StorageClassOutput) - { - add_resource_name(var.self); - statement(variable_decl(var), ";"); - emitted = true; - } - } - - if (emitted) - statement(""); - - declare_undefined_values(); -} - -// Returns a string representation of the ID, usable as a function arg. -// Default is to simply return the expression representation fo the arg ID. -// Subclasses may override to modify the return value. -string CompilerGLSL::to_func_call_arg(uint32_t id) -{ - return to_expression(id); -} - -void CompilerGLSL::handle_invalid_expression(uint32_t id) -{ - // We tried to read an invalidated expression. - // This means we need another pass at compilation, but next time, force temporary variables so that they cannot be invalidated. - forced_temporaries.insert(id); - force_recompile = true; -} - -// Converts the format of the current expression from packed to unpacked, -// by wrapping the expression in a constructor of the appropriate type. -// GLSL does not support packed formats, so simply return the expression. -// Subclasses that do will override -string CompilerGLSL::unpack_expression_type(string expr_str, const SPIRType &) -{ - return expr_str; -} - -// Sometimes we proactively enclosed an expression where it turns out we might have not needed it after all. -void CompilerGLSL::strip_enclosed_expression(string &expr) -{ - if (expr.size() < 2 || expr.front() != '(' || expr.back() != ')') - return; - - // Have to make sure that our first and last parens actually enclose everything inside it. - uint32_t paren_count = 0; - for (auto &c : expr) - { - if (c == '(') - paren_count++; - else if (c == ')') - { - paren_count--; - - // If we hit 0 and this is not the final char, our first and final parens actually don't - // enclose the expression, and we cannot strip, e.g.: (a + b) * (c + d). - if (paren_count == 0 && &c != &expr.back()) - return; - } - } - expr.erase(expr.size() - 1, 1); - expr.erase(begin(expr)); -} - -string CompilerGLSL::enclose_expression(const string &expr) -{ - bool need_parens = false; - - // If the expression starts with a unary we need to enclose to deal with cases where we have back-to-back - // unary expressions. - if (!expr.empty()) - { - auto c = expr.front(); - if (c == '-' || c == '+' || c == '!' || c == '~') - need_parens = true; - } - - if (!need_parens) - { - uint32_t paren_count = 0; - for (auto c : expr) - { - if (c == '(') - paren_count++; - else if (c == ')') - { - assert(paren_count); - paren_count--; - } - else if (c == ' ' && paren_count == 0) - { - need_parens = true; - break; - } - } - assert(paren_count == 0); - } - - // If this expression contains any spaces which are not enclosed by parentheses, - // we need to enclose it so we can treat the whole string as an expression. - // This happens when two expressions have been part of a binary op earlier. - if (need_parens) - return join('(', expr, ')'); - else - return expr; -} - -// Just like to_expression except that we enclose the expression inside parentheses if needed. -string CompilerGLSL::to_enclosed_expression(uint32_t id) -{ - return enclose_expression(to_expression(id)); -} - -string CompilerGLSL::to_expression(uint32_t id) -{ - auto itr = invalid_expressions.find(id); - if (itr != end(invalid_expressions)) - handle_invalid_expression(id); - - if (ids[id].get_type() == TypeExpression) - { - // We might have a more complex chain of dependencies. - // A possible scenario is that we - // - // %1 = OpLoad - // %2 = OpDoSomething %1 %1. here %2 will have a dependency on %1. - // %3 = OpDoSomethingAgain %2 %2. Here %3 will lose the link to %1 since we don't propagate the dependencies like that. - // OpStore %1 %foo // Here we can invalidate %1, and hence all expressions which depend on %1. Only %2 will know since it's part of invalid_expressions. - // %4 = OpDoSomethingAnotherTime %3 %3 // If we forward all expressions we will see %1 expression after store, not before. - // - // However, we can propagate up a list of depended expressions when we used %2, so we can check if %2 is invalid when reading %3 after the store, - // and see that we should not forward reads of the original variable. - auto &expr = get(id); - for (uint32_t dep : expr.expression_dependencies) - if (invalid_expressions.find(dep) != end(invalid_expressions)) - handle_invalid_expression(dep); - } - - track_expression_read(id); - - switch (ids[id].get_type()) - { - case TypeExpression: - { - auto &e = get(id); - if (e.base_expression) - return to_enclosed_expression(e.base_expression) + e.expression; - else if (e.need_transpose) - return convert_row_major_matrix(e.expression, get(e.expression_type)); - else - { - if (force_recompile) - { - // During first compilation phase, certain expression patterns can trigger exponential growth of memory. - // Avoid this by returning dummy expressions during this phase. - // Do not use empty expressions here, because those are sentinels for other cases. - return "_"; - } - else - return e.expression; - } - } - - case TypeConstant: - { - auto &c = get(id); - - // WorkGroupSize may be a constant. - auto &dec = meta[c.self].decoration; - if (dec.builtin) - return builtin_to_glsl(dec.builtin_type, StorageClassGeneric); - else if (c.specialization && options.vulkan_semantics) - return to_name(id); - else - return constant_expression(c); - } - - case TypeConstantOp: - return constant_op_expression(get(id)); - - case TypeVariable: - { - auto &var = get(id); - // If we try to use a loop variable before the loop header, we have to redirect it to the static expression, - // the variable has not been declared yet. - if (var.statically_assigned || (var.loop_variable && !var.loop_variable_enable)) - return to_expression(var.static_expression); - else if (var.deferred_declaration) - { - var.deferred_declaration = false; - return variable_decl(var); - } - else if (flattened_structs.count(id)) - { - return load_flattened_struct(var); - } - else - { - auto &dec = meta[var.self].decoration; - if (dec.builtin) - return builtin_to_glsl(dec.builtin_type, var.storage); - else - return to_name(id); - } - } - - case TypeCombinedImageSampler: - // This type should never be taken the expression of directly. - // The intention is that texture sampling functions will extract the image and samplers - // separately and take their expressions as needed. - // GLSL does not use this type because OpSampledImage immediately creates a combined image sampler - // expression ala sampler2D(texture, sampler). - SPIRV_CROSS_THROW("Combined image samplers have no default expression representation."); - - case TypeAccessChain: - // We cannot express this type. They only have meaning in other OpAccessChains, OpStore or OpLoad. - SPIRV_CROSS_THROW("Access chains have no default expression representation."); - - default: - return to_name(id); - } -} - -string CompilerGLSL::constant_op_expression(const SPIRConstantOp &cop) -{ - auto &type = get(cop.basetype); - bool binary = false; - bool unary = false; - string op; - - // TODO: Find a clean way to reuse emit_instruction. - switch (cop.opcode) - { - case OpSConvert: - case OpUConvert: - case OpFConvert: - op = type_to_glsl_constructor(type); - break; - -#define BOP(opname, x) \ - case Op##opname: \ - binary = true; \ - op = x; \ - break - -#define UOP(opname, x) \ - case Op##opname: \ - unary = true; \ - op = x; \ - break - - UOP(SNegate, "-"); - UOP(Not, "~"); - BOP(IAdd, "+"); - BOP(ISub, "-"); - BOP(IMul, "*"); - BOP(SDiv, "/"); - BOP(UDiv, "/"); - BOP(UMod, "%"); - BOP(SMod, "%"); - BOP(ShiftRightLogical, ">>"); - BOP(ShiftRightArithmetic, ">>"); - BOP(ShiftLeftLogical, "<<"); - BOP(BitwiseOr, "|"); - BOP(BitwiseXor, "^"); - BOP(BitwiseAnd, "&"); - BOP(LogicalOr, "||"); - BOP(LogicalAnd, "&&"); - UOP(LogicalNot, "!"); - BOP(LogicalEqual, "=="); - BOP(LogicalNotEqual, "!="); - BOP(IEqual, "=="); - BOP(INotEqual, "!="); - BOP(ULessThan, "<"); - BOP(SLessThan, "<"); - BOP(ULessThanEqual, "<="); - BOP(SLessThanEqual, "<="); - BOP(UGreaterThan, ">"); - BOP(SGreaterThan, ">"); - BOP(UGreaterThanEqual, ">="); - BOP(SGreaterThanEqual, ">="); - - case OpSelect: - { - if (cop.arguments.size() < 3) - SPIRV_CROSS_THROW("Not enough arguments to OpSpecConstantOp."); - - // This one is pretty annoying. It's triggered from - // uint(bool), int(bool) from spec constants. - // In order to preserve its compile-time constness in Vulkan GLSL, - // we need to reduce the OpSelect expression back to this simplified model. - // If we cannot, fail. - if (!to_trivial_mix_op(type, op, cop.arguments[2], cop.arguments[1], cop.arguments[0])) - { - SPIRV_CROSS_THROW( - "Cannot implement specialization constant op OpSelect. " - "Need trivial select implementation which can be resolved to a simple cast from boolean."); - } - break; - } - - default: - // Some opcodes are unimplemented here, these are currently not possible to test from glslang. - SPIRV_CROSS_THROW("Unimplemented spec constant op."); - } - - SPIRType::BaseType input_type; - bool skip_cast_if_equal_type = opcode_is_sign_invariant(cop.opcode); - - switch (cop.opcode) - { - case OpIEqual: - case OpINotEqual: - input_type = SPIRType::Int; - break; - - default: - input_type = type.basetype; - break; - } - -#undef BOP -#undef UOP - if (binary) - { - if (cop.arguments.size() < 2) - SPIRV_CROSS_THROW("Not enough arguments to OpSpecConstantOp."); - - string cast_op0; - string cast_op1; - auto expected_type = binary_op_bitcast_helper(cast_op0, cast_op1, input_type, cop.arguments[0], - cop.arguments[1], skip_cast_if_equal_type); - - if (type.basetype != input_type && type.basetype != SPIRType::Boolean) - { - expected_type.basetype = input_type; - auto expr = bitcast_glsl_op(type, expected_type); - expr += '('; - expr += join(cast_op0, " ", op, " ", cast_op1); - expr += ')'; - return expr; - } - else - return join("(", cast_op0, " ", op, " ", cast_op1, ")"); - } - else if (unary) - { - if (cop.arguments.size() < 1) - SPIRV_CROSS_THROW("Not enough arguments to OpSpecConstantOp."); - - // Auto-bitcast to result type as needed. - // Works around various casting scenarios in glslang as there is no OpBitcast for specialization constants. - return join("(", op, bitcast_glsl(type, cop.arguments[0]), ")"); - } - else - { - if (cop.arguments.size() < 1) - SPIRV_CROSS_THROW("Not enough arguments to OpSpecConstantOp."); - return join(op, "(", to_expression(cop.arguments[0]), ")"); - } -} - -string CompilerGLSL::constant_expression(const SPIRConstant &c) -{ - if (!c.subconstants.empty()) - { - // Handles Arrays and structures. - string res; - if (backend.use_initializer_list) - res = "{ "; - else - res = type_to_glsl_constructor(get(c.constant_type)) + "("; - - for (auto &elem : c.subconstants) - { - auto &subc = get(elem); - if (subc.specialization && options.vulkan_semantics) - res += to_name(elem); - else - res += constant_expression(subc); - - if (&elem != &c.subconstants.back()) - res += ", "; - } - - res += backend.use_initializer_list ? " }" : ")"; - return res; - } - else if (c.columns() == 1) - { - return constant_expression_vector(c, 0); - } - else - { - string res = type_to_glsl(get(c.constant_type)) + "("; - for (uint32_t col = 0; col < c.columns(); col++) - { - if (options.vulkan_semantics && c.specialization_constant_id(col) != 0) - res += to_name(c.specialization_constant_id(col)); - else - res += constant_expression_vector(c, col); - - if (col + 1 < c.columns()) - res += ", "; - } - res += ")"; - return res; - } -} - -string CompilerGLSL::constant_expression_vector(const SPIRConstant &c, uint32_t vector) -{ - auto type = get(c.constant_type); - type.columns = 1; - - string res; - bool splat = backend.use_constructor_splatting && c.vector_size() > 1; - bool swizzle_splat = backend.can_swizzle_scalar && c.vector_size() > 1; - - if (type.basetype != SPIRType::Float && type.basetype != SPIRType::Double) - { - // Cannot swizzle literal integers as a special case. - swizzle_splat = false; - } - - if (splat || swizzle_splat) - { - // Cannot use constant splatting if we have specialization constants somewhere in the vector. - for (uint32_t i = 0; i < c.vector_size(); i++) - { - if (options.vulkan_semantics && c.specialization_constant_id(vector, i) != 0) - { - splat = false; - swizzle_splat = false; - break; - } - } - } - - if (splat || swizzle_splat) - { - if (type.width == 64) - { - uint64_t ident = c.scalar_u64(vector, 0); - for (uint32_t i = 1; i < c.vector_size(); i++) - { - if (ident != c.scalar_u64(vector, i)) - { - splat = false; - swizzle_splat = false; - break; - } - } - } - else - { - uint32_t ident = c.scalar(vector, 0); - for (uint32_t i = 1; i < c.vector_size(); i++) - { - if (ident != c.scalar(vector, i)) - { - splat = false; - swizzle_splat = false; - } - } - } - } - - if (c.vector_size() > 1 && !swizzle_splat) - res += type_to_glsl(type) + "("; - - switch (type.basetype) - { - case SPIRType::Float: - if (splat || swizzle_splat) - { - res += convert_to_string(c.scalar_f32(vector, 0)); - if (backend.float_literal_suffix) - res += "f"; - - if (swizzle_splat) - res = remap_swizzle(get(c.constant_type), 1, res); - } - else - { - for (uint32_t i = 0; i < c.vector_size(); i++) - { - if (options.vulkan_semantics && c.vector_size() > 1 && c.specialization_constant_id(vector, i) != 0) - res += to_name(c.specialization_constant_id(vector, i)); - else - res += convert_to_string(c.scalar_f32(vector, i)); - - if (backend.float_literal_suffix) - res += "f"; - if (i + 1 < c.vector_size()) - res += ", "; - } - } - break; - - case SPIRType::Double: - if (splat || swizzle_splat) - { - res += convert_to_string(c.scalar_f64(vector, 0)); - if (backend.double_literal_suffix) - res += "lf"; - - if (swizzle_splat) - res = remap_swizzle(get(c.constant_type), 1, res); - } - else - { - for (uint32_t i = 0; i < c.vector_size(); i++) - { - if (options.vulkan_semantics && c.vector_size() > 1 && c.specialization_constant_id(vector, i) != 0) - res += to_name(c.specialization_constant_id(vector, i)); - else - { - res += convert_to_string(c.scalar_f64(vector, i)); - if (backend.double_literal_suffix) - res += "lf"; - } - - if (i + 1 < c.vector_size()) - res += ", "; - } - } - break; - - case SPIRType::Int64: - if (splat) - { - res += convert_to_string(c.scalar_i64(vector, 0)); - if (backend.long_long_literal_suffix) - res += "ll"; - else - res += "l"; - } - else - { - for (uint32_t i = 0; i < c.vector_size(); i++) - { - if (options.vulkan_semantics && c.vector_size() > 1 && c.specialization_constant_id(vector, i) != 0) - res += to_name(c.specialization_constant_id(vector, i)); - else - { - res += convert_to_string(c.scalar_i64(vector, i)); - if (backend.long_long_literal_suffix) - res += "ll"; - else - res += "l"; - } - - if (i + 1 < c.vector_size()) - res += ", "; - } - } - break; - - case SPIRType::UInt64: - if (splat) - { - res += convert_to_string(c.scalar_u64(vector, 0)); - if (backend.long_long_literal_suffix) - res += "ull"; - else - res += "ul"; - } - else - { - for (uint32_t i = 0; i < c.vector_size(); i++) - { - if (options.vulkan_semantics && c.vector_size() > 1 && c.specialization_constant_id(vector, i) != 0) - res += to_name(c.specialization_constant_id(vector, i)); - else - { - res += convert_to_string(c.scalar_u64(vector, i)); - if (backend.long_long_literal_suffix) - res += "ull"; - else - res += "ul"; - } - - if (i + 1 < c.vector_size()) - res += ", "; - } - } - break; - - case SPIRType::UInt: - if (splat) - { - res += convert_to_string(c.scalar(vector, 0)); - if (backend.uint32_t_literal_suffix) - res += "u"; - } - else - { - for (uint32_t i = 0; i < c.vector_size(); i++) - { - if (options.vulkan_semantics && c.vector_size() > 1 && c.specialization_constant_id(vector, i) != 0) - res += to_name(c.specialization_constant_id(vector, i)); - else - { - res += convert_to_string(c.scalar(vector, i)); - if (backend.uint32_t_literal_suffix) - res += "u"; - } - - if (i + 1 < c.vector_size()) - res += ", "; - } - } - break; - - case SPIRType::Int: - if (splat) - res += convert_to_string(c.scalar_i32(vector, 0)); - else - { - for (uint32_t i = 0; i < c.vector_size(); i++) - { - if (options.vulkan_semantics && c.vector_size() > 1 && c.specialization_constant_id(vector, i) != 0) - res += to_name(c.specialization_constant_id(vector, i)); - else - res += convert_to_string(c.scalar_i32(vector, i)); - if (i + 1 < c.vector_size()) - res += ", "; - } - } - break; - - case SPIRType::Boolean: - if (splat) - res += c.scalar(vector, 0) ? "true" : "false"; - else - { - for (uint32_t i = 0; i < c.vector_size(); i++) - { - if (options.vulkan_semantics && c.vector_size() > 1 && c.specialization_constant_id(vector, i) != 0) - res += to_name(c.specialization_constant_id(vector, i)); - else - res += c.scalar(vector, i) ? "true" : "false"; - - if (i + 1 < c.vector_size()) - res += ", "; - } - } - break; - - default: - SPIRV_CROSS_THROW("Invalid constant expression basetype."); - } - - if (c.vector_size() > 1 && !swizzle_splat) - res += ")"; - - return res; -} - -string CompilerGLSL::declare_temporary(uint32_t result_type, uint32_t result_id) -{ - auto &type = get(result_type); - auto flags = meta[result_id].decoration.decoration_flags; - - // If we're declaring temporaries inside continue blocks, - // we must declare the temporary in the loop header so that the continue block can avoid declaring new variables. - if (current_continue_block && !hoisted_temporaries.count(result_id)) - { - auto &header = get(current_continue_block->loop_dominator); - if (find_if(begin(header.declare_temporary), end(header.declare_temporary), - [result_type, result_id](const pair &tmp) { - return tmp.first == result_type && tmp.second == result_id; - }) == end(header.declare_temporary)) - { - header.declare_temporary.emplace_back(result_type, result_id); - hoisted_temporaries.insert(result_id); - force_recompile = true; - } - - return join(to_name(result_id), " = "); - } - else if (hoisted_temporaries.count(result_id)) - { - // The temporary has already been declared earlier, so just "declare" the temporary by writing to it. - return join(to_name(result_id), " = "); - } - else - { - // The result_id has not been made into an expression yet, so use flags interface. - return join(flags_to_precision_qualifiers_glsl(type, flags), variable_decl(type, to_name(result_id)), " = "); - } -} - -bool CompilerGLSL::expression_is_forwarded(uint32_t id) -{ - return forwarded_temporaries.find(id) != end(forwarded_temporaries); -} - -SPIRExpression &CompilerGLSL::emit_op(uint32_t result_type, uint32_t result_id, const string &rhs, bool forwarding, - bool suppress_usage_tracking) -{ - if (forwarding && (forced_temporaries.find(result_id) == end(forced_temporaries))) - { - // Just forward it without temporary. - // If the forward is trivial, we do not force flushing to temporary for this expression. - if (!suppress_usage_tracking) - forwarded_temporaries.insert(result_id); - - return set(result_id, rhs, result_type, true); - } - else - { - // If expression isn't immutable, bind it to a temporary and make the new temporary immutable (they always are). - statement(declare_temporary(result_type, result_id), rhs, ";"); - return set(result_id, to_name(result_id), result_type, true); - } -} - -void CompilerGLSL::emit_unary_op(uint32_t result_type, uint32_t result_id, uint32_t op0, const char *op) -{ - bool forward = should_forward(op0); - emit_op(result_type, result_id, join(op, to_enclosed_expression(op0)), forward); - inherit_expression_dependencies(result_id, op0); -} - -void CompilerGLSL::emit_binary_op(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, const char *op) -{ - bool forward = should_forward(op0) && should_forward(op1); - emit_op(result_type, result_id, join(to_enclosed_expression(op0), " ", op, " ", to_enclosed_expression(op1)), - forward); - - inherit_expression_dependencies(result_id, op0); - inherit_expression_dependencies(result_id, op1); -} - -void CompilerGLSL::emit_unrolled_unary_op(uint32_t result_type, uint32_t result_id, uint32_t operand, const char *op) -{ - auto &type = get(result_type); - auto expr = type_to_glsl_constructor(type); - expr += '('; - for (uint32_t i = 0; i < type.vecsize; i++) - { - // Make sure to call to_expression multiple times to ensure - // that these expressions are properly flushed to temporaries if needed. - expr += op; - expr += to_enclosed_expression(operand); - expr += '.'; - expr += index_to_swizzle(i); - - if (i + 1 < type.vecsize) - expr += ", "; - } - expr += ')'; - emit_op(result_type, result_id, expr, should_forward(operand)); - - inherit_expression_dependencies(result_id, operand); -} - -void CompilerGLSL::emit_unrolled_binary_op(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, - const char *op) -{ - auto &type = get(result_type); - auto expr = type_to_glsl_constructor(type); - expr += '('; - for (uint32_t i = 0; i < type.vecsize; i++) - { - // Make sure to call to_expression multiple times to ensure - // that these expressions are properly flushed to temporaries if needed. - expr += to_enclosed_expression(op0); - expr += '.'; - expr += index_to_swizzle(i); - expr += ' '; - expr += op; - expr += ' '; - expr += to_enclosed_expression(op1); - expr += '.'; - expr += index_to_swizzle(i); - - if (i + 1 < type.vecsize) - expr += ", "; - } - expr += ')'; - emit_op(result_type, result_id, expr, should_forward(op0) && should_forward(op1)); - - inherit_expression_dependencies(result_id, op0); - inherit_expression_dependencies(result_id, op1); -} - -SPIRType CompilerGLSL::binary_op_bitcast_helper(string &cast_op0, string &cast_op1, SPIRType::BaseType &input_type, - uint32_t op0, uint32_t op1, bool skip_cast_if_equal_type) -{ - auto &type0 = expression_type(op0); - auto &type1 = expression_type(op1); - - // We have to bitcast if our inputs are of different type, or if our types are not equal to expected inputs. - // For some functions like OpIEqual and INotEqual, we don't care if inputs are of different types than expected - // since equality test is exactly the same. - bool cast = (type0.basetype != type1.basetype) || (!skip_cast_if_equal_type && type0.basetype != input_type); - - // Create a fake type so we can bitcast to it. - // We only deal with regular arithmetic types here like int, uints and so on. - SPIRType expected_type; - expected_type.basetype = input_type; - expected_type.vecsize = type0.vecsize; - expected_type.columns = type0.columns; - expected_type.width = type0.width; - - if (cast) - { - cast_op0 = bitcast_glsl(expected_type, op0); - cast_op1 = bitcast_glsl(expected_type, op1); - } - else - { - // If we don't cast, our actual input type is that of the first (or second) argument. - cast_op0 = to_enclosed_expression(op0); - cast_op1 = to_enclosed_expression(op1); - input_type = type0.basetype; - } - - return expected_type; -} - -void CompilerGLSL::emit_binary_op_cast(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, - const char *op, SPIRType::BaseType input_type, bool skip_cast_if_equal_type) -{ - string cast_op0, cast_op1; - auto expected_type = binary_op_bitcast_helper(cast_op0, cast_op1, input_type, op0, op1, skip_cast_if_equal_type); - auto &out_type = get(result_type); - - // We might have casted away from the result type, so bitcast again. - // For example, arithmetic right shift with uint inputs. - // Special case boolean outputs since relational opcodes output booleans instead of int/uint. - string expr; - if (out_type.basetype != input_type && out_type.basetype != SPIRType::Boolean) - { - expected_type.basetype = input_type; - expr = bitcast_glsl_op(out_type, expected_type); - expr += '('; - expr += join(cast_op0, " ", op, " ", cast_op1); - expr += ')'; - } - else - expr += join(cast_op0, " ", op, " ", cast_op1); - - emit_op(result_type, result_id, expr, should_forward(op0) && should_forward(op1)); -} - -void CompilerGLSL::emit_unary_func_op(uint32_t result_type, uint32_t result_id, uint32_t op0, const char *op) -{ - bool forward = should_forward(op0); - emit_op(result_type, result_id, join(op, "(", to_expression(op0), ")"), forward); - inherit_expression_dependencies(result_id, op0); -} - -void CompilerGLSL::emit_binary_func_op(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, - const char *op) -{ - bool forward = should_forward(op0) && should_forward(op1); - emit_op(result_type, result_id, join(op, "(", to_expression(op0), ", ", to_expression(op1), ")"), forward); - inherit_expression_dependencies(result_id, op0); - inherit_expression_dependencies(result_id, op1); -} - -void CompilerGLSL::emit_binary_func_op_cast(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, - const char *op, SPIRType::BaseType input_type, bool skip_cast_if_equal_type) -{ - string cast_op0, cast_op1; - auto expected_type = binary_op_bitcast_helper(cast_op0, cast_op1, input_type, op0, op1, skip_cast_if_equal_type); - auto &out_type = get(result_type); - - // Special case boolean outputs since relational opcodes output booleans instead of int/uint. - string expr; - if (out_type.basetype != input_type && out_type.basetype != SPIRType::Boolean) - { - expected_type.basetype = input_type; - expr = bitcast_glsl_op(out_type, expected_type); - expr += '('; - expr += join(op, "(", cast_op0, ", ", cast_op1, ")"); - expr += ')'; - } - else - { - expr += join(op, "(", cast_op0, ", ", cast_op1, ")"); - } - - emit_op(result_type, result_id, expr, should_forward(op0) && should_forward(op1)); -} - -void CompilerGLSL::emit_trinary_func_op(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, - uint32_t op2, const char *op) -{ - bool forward = should_forward(op0) && should_forward(op1) && should_forward(op2); - emit_op(result_type, result_id, - join(op, "(", to_expression(op0), ", ", to_expression(op1), ", ", to_expression(op2), ")"), forward); - - inherit_expression_dependencies(result_id, op0); - inherit_expression_dependencies(result_id, op1); - inherit_expression_dependencies(result_id, op2); -} - -void CompilerGLSL::emit_quaternary_func_op(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, - uint32_t op2, uint32_t op3, const char *op) -{ - bool forward = should_forward(op0) && should_forward(op1) && should_forward(op2) && should_forward(op3); - emit_op(result_type, result_id, - join(op, "(", to_expression(op0), ", ", to_expression(op1), ", ", to_expression(op2), ", ", - to_expression(op3), ")"), - forward); - - inherit_expression_dependencies(result_id, op0); - inherit_expression_dependencies(result_id, op1); - inherit_expression_dependencies(result_id, op2); - inherit_expression_dependencies(result_id, op3); -} - -// EXT_shader_texture_lod only concerns fragment shaders so lod tex functions -// are not allowed in ES 2 vertex shaders. But SPIR-V only supports lod tex -// functions in vertex shaders so we revert those back to plain calls when -// the lod is a constant value of zero. -bool CompilerGLSL::check_explicit_lod_allowed(uint32_t lod) -{ - auto &execution = get_entry_point(); - bool allowed = !is_legacy_es() || execution.model == ExecutionModelFragment; - if (!allowed && lod != 0) - { - auto *lod_constant = maybe_get(lod); - if (!lod_constant || lod_constant->scalar_f32() != 0.0f) - { - SPIRV_CROSS_THROW("Explicit lod not allowed in legacy ES non-fragment shaders."); - } - } - return allowed; -} - -string CompilerGLSL::legacy_tex_op(const std::string &op, const SPIRType &imgtype, uint32_t lod) -{ - const char *type; - switch (imgtype.image.dim) - { - case spv::Dim1D: - type = (imgtype.image.arrayed && !options.es) ? "1DArray" : "1D"; - break; - case spv::Dim2D: - type = (imgtype.image.arrayed && !options.es) ? "2DArray" : "2D"; - break; - case spv::Dim3D: - type = "3D"; - break; - case spv::DimCube: - type = "Cube"; - break; - case spv::DimBuffer: - type = "Buffer"; - break; - case spv::DimSubpassData: - type = "2D"; - break; - default: - type = ""; - break; - } - - bool use_explicit_lod = check_explicit_lod_allowed(lod); - - if (op == "textureLod" || op == "textureProjLod") - { - if (is_legacy_es()) - { - if (use_explicit_lod) - require_extension("GL_EXT_shader_texture_lod"); - } - else if (is_legacy()) - require_extension("GL_ARB_shader_texture_lod"); - } - - if (op == "texture") - return join("texture", type); - else if (op == "textureLod") - { - if (use_explicit_lod) - return join("texture", type, is_legacy_es() ? "LodEXT" : "Lod"); - else - return join("texture", type); - } - else if (op == "textureProj") - return join("texture", type, "Proj"); - else if (op == "textureProjLod") - { - if (use_explicit_lod) - return join("texture", type, is_legacy_es() ? "ProjLodEXT" : "ProjLod"); - else - return join("texture", type); - } - else - { - SPIRV_CROSS_THROW(join("Unsupported legacy texture op: ", op)); - } -} - -bool CompilerGLSL::to_trivial_mix_op(const SPIRType &type, string &op, uint32_t left, uint32_t right, uint32_t lerp) -{ - auto *cleft = maybe_get(left); - auto *cright = maybe_get(right); - auto &lerptype = expression_type(lerp); - - // If our targets aren't constants, we cannot use construction. - if (!cleft || !cright) - return false; - - // If our targets are spec constants, we cannot use construction. - if (cleft->specialization || cright->specialization) - return false; - - // We can only use trivial construction if we have a scalar - // (should be possible to do it for vectors as well, but that is overkill for now). - if (lerptype.basetype != SPIRType::Boolean || lerptype.vecsize > 1) - return false; - - // If our bool selects between 0 and 1, we can cast from bool instead, making our trivial constructor. - bool ret = false; - switch (type.basetype) - { - case SPIRType::Int: - case SPIRType::UInt: - ret = cleft->scalar() == 0 && cright->scalar() == 1; - break; - - case SPIRType::Float: - ret = cleft->scalar_f32() == 0.0f && cright->scalar_f32() == 1.0f; - break; - - case SPIRType::Double: - ret = cleft->scalar_f64() == 0.0 && cright->scalar_f64() == 1.0; - break; - - case SPIRType::Int64: - case SPIRType::UInt64: - ret = cleft->scalar_u64() == 0 && cright->scalar_u64() == 1; - break; - - default: - break; - } - - if (ret) - op = type_to_glsl_constructor(type); - return ret; -} - -void CompilerGLSL::emit_mix_op(uint32_t result_type, uint32_t id, uint32_t left, uint32_t right, uint32_t lerp) -{ - auto &lerptype = expression_type(lerp); - auto &restype = get(result_type); - - string mix_op; - bool has_boolean_mix = backend.boolean_mix_support && - ((options.es && options.version >= 310) || (!options.es && options.version >= 450)); - bool trivial_mix = to_trivial_mix_op(restype, mix_op, left, right, lerp); - - // Cannot use boolean mix when the lerp argument is just one boolean, - // fall back to regular trinary statements. - if (lerptype.vecsize == 1) - has_boolean_mix = false; - - // If we can reduce the mix to a simple cast, do so. - // This helps for cases like int(bool), uint(bool) which is implemented with - // OpSelect bool 1 0. - if (trivial_mix) - { - emit_unary_func_op(result_type, id, lerp, mix_op.c_str()); - } - else if (!has_boolean_mix && lerptype.basetype == SPIRType::Boolean) - { - // Boolean mix not supported on desktop without extension. - // Was added in OpenGL 4.5 with ES 3.1 compat. - // - // Could use GL_EXT_shader_integer_mix on desktop at least, - // but Apple doesn't support it. :( - // Just implement it as ternary expressions. - string expr; - if (lerptype.vecsize == 1) - expr = join(to_enclosed_expression(lerp), " ? ", to_enclosed_expression(right), " : ", - to_enclosed_expression(left)); - else - { - auto swiz = [this](uint32_t expression, uint32_t i) { - return join(to_enclosed_expression(expression), ".", index_to_swizzle(i)); - }; - - expr = type_to_glsl_constructor(restype); - expr += "("; - for (uint32_t i = 0; i < restype.vecsize; i++) - { - expr += swiz(lerp, i); - expr += " ? "; - expr += swiz(right, i); - expr += " : "; - expr += swiz(left, i); - if (i + 1 < restype.vecsize) - expr += ", "; - } - expr += ")"; - } - - emit_op(result_type, id, expr, should_forward(left) && should_forward(right) && should_forward(lerp)); - } - else - emit_trinary_func_op(result_type, id, left, right, lerp, "mix"); -} - -string CompilerGLSL::to_combined_image_sampler(uint32_t image_id, uint32_t samp_id) -{ - auto &args = current_function->arguments; - - // For GLSL and ESSL targets, we must enumerate all possible combinations for sampler2D(texture2D, sampler) and redirect - // all possible combinations into new sampler2D uniforms. - auto *image = maybe_get_backing_variable(image_id); - auto *samp = maybe_get_backing_variable(samp_id); - if (image) - image_id = image->self; - if (samp) - samp_id = samp->self; - - auto image_itr = find_if(begin(args), end(args), - [image_id](const SPIRFunction::Parameter ¶m) { return param.id == image_id; }); - - auto sampler_itr = find_if(begin(args), end(args), - [samp_id](const SPIRFunction::Parameter ¶m) { return param.id == samp_id; }); - - if (image_itr != end(args) || sampler_itr != end(args)) - { - // If any parameter originates from a parameter, we will find it in our argument list. - bool global_image = image_itr == end(args); - bool global_sampler = sampler_itr == end(args); - uint32_t iid = global_image ? image_id : uint32_t(image_itr - begin(args)); - uint32_t sid = global_sampler ? samp_id : uint32_t(sampler_itr - begin(args)); - - auto &combined = current_function->combined_parameters; - auto itr = find_if(begin(combined), end(combined), [=](const SPIRFunction::CombinedImageSamplerParameter &p) { - return p.global_image == global_image && p.global_sampler == global_sampler && p.image_id == iid && - p.sampler_id == sid; - }); - - if (itr != end(combined)) - return to_expression(itr->id); - else - { - SPIRV_CROSS_THROW( - "Cannot find mapping for combined sampler parameter, was build_combined_image_samplers() used " - "before compile() was called?"); - } - } - else - { - // For global sampler2D, look directly at the global remapping table. - auto &mapping = combined_image_samplers; - auto itr = find_if(begin(mapping), end(mapping), [image_id, samp_id](const CombinedImageSampler &combined) { - return combined.image_id == image_id && combined.sampler_id == samp_id; - }); - - if (itr != end(combined_image_samplers)) - return to_expression(itr->combined_id); - else - { - SPIRV_CROSS_THROW("Cannot find mapping for combined sampler, was build_combined_image_samplers() used " - "before compile() was called?"); - } - } -} - -void CompilerGLSL::emit_sampled_image_op(uint32_t result_type, uint32_t result_id, uint32_t image_id, uint32_t samp_id) -{ - if (options.vulkan_semantics && combined_image_samplers.empty()) - { - emit_binary_func_op(result_type, result_id, image_id, samp_id, - type_to_glsl(get(result_type)).c_str()); - } - else - emit_op(result_type, result_id, to_combined_image_sampler(image_id, samp_id), true); -} - -void CompilerGLSL::emit_texture_op(const Instruction &i) -{ - auto ops = stream(i); - auto op = static_cast(i.op); - uint32_t length = i.length; - - if (i.offset + length > spirv.size()) - SPIRV_CROSS_THROW("Compiler::parse() opcode out of range."); - - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - uint32_t img = ops[2]; - uint32_t coord = ops[3]; - uint32_t dref = 0; - uint32_t comp = 0; - bool gather = false; - bool proj = false; - bool fetch = false; - const uint32_t *opt = nullptr; - - switch (op) - { - case OpImageSampleDrefImplicitLod: - case OpImageSampleDrefExplicitLod: - dref = ops[4]; - opt = &ops[5]; - length -= 5; - break; - - case OpImageSampleProjDrefImplicitLod: - case OpImageSampleProjDrefExplicitLod: - dref = ops[4]; - opt = &ops[5]; - length -= 5; - proj = true; - break; - - case OpImageDrefGather: - dref = ops[4]; - opt = &ops[5]; - length -= 5; - gather = true; - break; - - case OpImageGather: - comp = ops[4]; - opt = &ops[5]; - length -= 5; - gather = true; - break; - - case OpImageFetch: - case OpImageRead: // Reads == fetches in Metal (other langs will not get here) - opt = &ops[4]; - length -= 4; - fetch = true; - break; - - case OpImageSampleProjImplicitLod: - case OpImageSampleProjExplicitLod: - opt = &ops[4]; - length -= 4; - proj = true; - break; - - default: - opt = &ops[4]; - length -= 4; - break; - } - - // Bypass pointers because we need the real image struct - auto &type = expression_type(img); - auto &imgtype = get(type.self); - - uint32_t coord_components = 0; - switch (imgtype.image.dim) - { - case spv::Dim1D: - coord_components = 1; - break; - case spv::Dim2D: - coord_components = 2; - break; - case spv::Dim3D: - coord_components = 3; - break; - case spv::DimCube: - coord_components = 3; - break; - case spv::DimBuffer: - coord_components = 1; - break; - default: - coord_components = 2; - break; - } - - if (proj) - coord_components++; - if (imgtype.image.arrayed) - coord_components++; - - uint32_t bias = 0; - uint32_t lod = 0; - uint32_t grad_x = 0; - uint32_t grad_y = 0; - uint32_t coffset = 0; - uint32_t offset = 0; - uint32_t coffsets = 0; - uint32_t sample = 0; - uint32_t flags = 0; - - if (length) - { - flags = *opt++; - length--; - } - - auto test = [&](uint32_t &v, uint32_t flag) { - if (length && (flags & flag)) - { - v = *opt++; - length--; - } - }; - - test(bias, ImageOperandsBiasMask); - test(lod, ImageOperandsLodMask); - test(grad_x, ImageOperandsGradMask); - test(grad_y, ImageOperandsGradMask); - test(coffset, ImageOperandsConstOffsetMask); - test(offset, ImageOperandsOffsetMask); - test(coffsets, ImageOperandsConstOffsetsMask); - test(sample, ImageOperandsSampleMask); - - string expr; - bool forward = false; - expr += to_function_name(img, imgtype, !!fetch, !!gather, !!proj, !!coffsets, (!!coffset || !!offset), - (!!grad_x || !!grad_y), !!dref, lod); - expr += "("; - expr += to_function_args(img, imgtype, fetch, gather, proj, coord, coord_components, dref, grad_x, grad_y, lod, - coffset, offset, bias, comp, sample, &forward); - expr += ")"; - - emit_op(result_type, id, expr, forward); -} - -// Returns the function name for a texture sampling function for the specified image and sampling characteristics. -// For some subclasses, the function is a method on the specified image. -string CompilerGLSL::to_function_name(uint32_t, const SPIRType &imgtype, bool is_fetch, bool is_gather, bool is_proj, - bool has_array_offsets, bool has_offset, bool has_grad, bool, uint32_t lod) -{ - string fname; - - // textureLod on sampler2DArrayShadow and samplerCubeShadow does not exist in GLSL for some reason. - // To emulate this, we will have to use textureGrad with a constant gradient of 0. - // The workaround will assert that the LOD is in fact constant 0, or we cannot emit correct code. - // This happens for HLSL SampleCmpLevelZero on Texture2DArray and TextureCube. - bool workaround_lod_array_shadow_as_grad = false; - if (((imgtype.image.arrayed && imgtype.image.dim == Dim2D) || imgtype.image.dim == DimCube) && - imgtype.image.depth && lod) - { - auto *constant_lod = maybe_get(lod); - if (!constant_lod || constant_lod->scalar_f32() != 0.0f) - SPIRV_CROSS_THROW( - "textureLod on sampler2DArrayShadow is not constant 0.0. This cannot be expressed in GLSL."); - workaround_lod_array_shadow_as_grad = true; - } - - if (is_fetch) - fname += "texelFetch"; - else - { - fname += "texture"; - - if (is_gather) - fname += "Gather"; - if (has_array_offsets) - fname += "Offsets"; - if (is_proj) - fname += "Proj"; - if (has_grad || workaround_lod_array_shadow_as_grad) - fname += "Grad"; - if (!!lod && !workaround_lod_array_shadow_as_grad) - fname += "Lod"; - } - - if (has_offset) - fname += "Offset"; - - return is_legacy() ? legacy_tex_op(fname, imgtype, lod) : fname; -} - -// Returns the function args for a texture sampling function for the specified image and sampling characteristics. -string CompilerGLSL::to_function_args(uint32_t img, const SPIRType &imgtype, bool, bool, bool is_proj, uint32_t coord, - uint32_t coord_components, uint32_t dref, uint32_t grad_x, uint32_t grad_y, - uint32_t lod, uint32_t coffset, uint32_t offset, uint32_t bias, uint32_t comp, - uint32_t sample, bool *p_forward) -{ - string farg_str = to_expression(img); - - bool swizz_func = backend.swizzle_is_function; - auto swizzle = [swizz_func](uint32_t comps, uint32_t in_comps) -> const char * { - if (comps == in_comps) - return ""; - - switch (comps) - { - case 1: - return ".x"; - case 2: - return swizz_func ? ".xy()" : ".xy"; - case 3: - return swizz_func ? ".xyz()" : ".xyz"; - default: - return ""; - } - }; - - bool forward = should_forward(coord); - - // The IR can give us more components than we need, so chop them off as needed. - auto swizzle_expr = swizzle(coord_components, expression_type(coord).vecsize); - // Only enclose the UV expression if needed. - auto coord_expr = (*swizzle_expr == '\0') ? to_expression(coord) : (to_enclosed_expression(coord) + swizzle_expr); - - // texelFetch only takes int, not uint. - auto &coord_type = expression_type(coord); - if (coord_type.basetype == SPIRType::UInt) - { - auto expected_type = coord_type; - expected_type.basetype = SPIRType::Int; - coord_expr = bitcast_expression(expected_type, coord_type.basetype, coord_expr); - } - - // textureLod on sampler2DArrayShadow and samplerCubeShadow does not exist in GLSL for some reason. - // To emulate this, we will have to use textureGrad with a constant gradient of 0. - // The workaround will assert that the LOD is in fact constant 0, or we cannot emit correct code. - // This happens for HLSL SampleCmpLevelZero on Texture2DArray and TextureCube. - bool workaround_lod_array_shadow_as_grad = - ((imgtype.image.arrayed && imgtype.image.dim == Dim2D) || imgtype.image.dim == DimCube) && - imgtype.image.depth && lod; - - if (dref) - { - forward = forward && should_forward(dref); - - // SPIR-V splits dref and coordinate. - if (coord_components == 4) // GLSL also splits the arguments in two. - { - farg_str += ", "; - farg_str += to_expression(coord); - farg_str += ", "; - farg_str += to_expression(dref); - } - else if (is_proj) - { - // Have to reshuffle so we get vec4(coord, dref, proj), special case. - // Other shading languages splits up the arguments for coord and compare value like SPIR-V. - // The coordinate type for textureProj shadow is always vec4 even for sampler1DShadow. - farg_str += ", vec4("; - - if (imgtype.image.dim == Dim1D) - { - // Could reuse coord_expr, but we will mess up the temporary usage checking. - farg_str += to_enclosed_expression(coord) + ".x"; - farg_str += ", "; - farg_str += "0.0, "; - farg_str += to_expression(dref); - farg_str += ", "; - farg_str += to_enclosed_expression(coord) + ".y)"; - } - else if (imgtype.image.dim == Dim2D) - { - // Could reuse coord_expr, but we will mess up the temporary usage checking. - farg_str += to_enclosed_expression(coord) + (swizz_func ? ".xy()" : ".xy"); - farg_str += ", "; - farg_str += to_expression(dref); - farg_str += ", "; - farg_str += to_enclosed_expression(coord) + ".z)"; - } - else - SPIRV_CROSS_THROW("Invalid type for textureProj with shadow."); - } - else - { - // Create a composite which merges coord/dref into a single vector. - auto type = expression_type(coord); - type.vecsize = coord_components + 1; - farg_str += ", "; - farg_str += type_to_glsl_constructor(type); - farg_str += "("; - farg_str += coord_expr; - farg_str += ", "; - farg_str += to_expression(dref); - farg_str += ")"; - } - } - else - { - farg_str += ", "; - farg_str += coord_expr; - } - - if (grad_x || grad_y) - { - forward = forward && should_forward(grad_x); - forward = forward && should_forward(grad_y); - farg_str += ", "; - farg_str += to_expression(grad_x); - farg_str += ", "; - farg_str += to_expression(grad_y); - } - - if (lod) - { - if (workaround_lod_array_shadow_as_grad) - { - // Implement textureGrad() instead. LOD == 0.0 is implemented as gradient of 0.0. - // Implementing this as plain texture() is not safe on some implementations. - if (imgtype.image.dim == Dim2D) - farg_str += ", vec2(0.0), vec2(0.0)"; - else if (imgtype.image.dim == DimCube) - farg_str += ", vec3(0.0), vec3(0.0)"; - } - else - { - if (check_explicit_lod_allowed(lod)) - { - forward = forward && should_forward(lod); - farg_str += ", "; - farg_str += to_expression(lod); - } - } - } - - if (coffset) - { - forward = forward && should_forward(coffset); - farg_str += ", "; - farg_str += to_expression(coffset); - } - else if (offset) - { - forward = forward && should_forward(offset); - farg_str += ", "; - farg_str += to_expression(offset); - } - - if (bias) - { - forward = forward && should_forward(bias); - farg_str += ", "; - farg_str += to_expression(bias); - } - - if (comp) - { - forward = forward && should_forward(comp); - farg_str += ", "; - farg_str += to_expression(comp); - } - - if (sample) - { - farg_str += ", "; - farg_str += to_expression(sample); - } - - *p_forward = forward; - - return farg_str; -} - -void CompilerGLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop, const uint32_t *args, uint32_t) -{ - GLSLstd450 op = static_cast(eop); - - switch (op) - { - // FP fiddling - case GLSLstd450Round: - emit_unary_func_op(result_type, id, args[0], "round"); - break; - - case GLSLstd450RoundEven: - if ((options.es && options.version >= 300) || (!options.es && options.version >= 130)) - emit_unary_func_op(result_type, id, args[0], "roundEven"); - else - SPIRV_CROSS_THROW("roundEven supported only in ESSL 300 and GLSL 130 and up."); - break; - - case GLSLstd450Trunc: - emit_unary_func_op(result_type, id, args[0], "trunc"); - break; - case GLSLstd450SAbs: - case GLSLstd450FAbs: - emit_unary_func_op(result_type, id, args[0], "abs"); - break; - case GLSLstd450SSign: - case GLSLstd450FSign: - emit_unary_func_op(result_type, id, args[0], "sign"); - break; - case GLSLstd450Floor: - emit_unary_func_op(result_type, id, args[0], "floor"); - break; - case GLSLstd450Ceil: - emit_unary_func_op(result_type, id, args[0], "ceil"); - break; - case GLSLstd450Fract: - emit_unary_func_op(result_type, id, args[0], "fract"); - break; - case GLSLstd450Radians: - emit_unary_func_op(result_type, id, args[0], "radians"); - break; - case GLSLstd450Degrees: - emit_unary_func_op(result_type, id, args[0], "degrees"); - break; - case GLSLstd450Fma: - emit_trinary_func_op(result_type, id, args[0], args[1], args[2], "fma"); - break; - case GLSLstd450Modf: - register_call_out_argument(args[1]); - forced_temporaries.insert(id); - emit_binary_func_op(result_type, id, args[0], args[1], "modf"); - break; - - case GLSLstd450ModfStruct: - { - forced_temporaries.insert(id); - auto &type = get(result_type); - auto flags = meta[id].decoration.decoration_flags; - statement(flags_to_precision_qualifiers_glsl(type, flags), variable_decl(type, to_name(id)), ";"); - set(id, to_name(id), result_type, true); - - statement(to_expression(id), ".", to_member_name(type, 0), " = ", "modf(", to_expression(args[0]), ", ", - to_expression(id), ".", to_member_name(type, 1), ");"); - break; - } - - // Minmax - case GLSLstd450FMin: - case GLSLstd450UMin: - case GLSLstd450SMin: - emit_binary_func_op(result_type, id, args[0], args[1], "min"); - break; - case GLSLstd450FMax: - case GLSLstd450UMax: - case GLSLstd450SMax: - emit_binary_func_op(result_type, id, args[0], args[1], "max"); - break; - case GLSLstd450FClamp: - case GLSLstd450UClamp: - case GLSLstd450SClamp: - emit_trinary_func_op(result_type, id, args[0], args[1], args[2], "clamp"); - break; - - // Trig - case GLSLstd450Sin: - emit_unary_func_op(result_type, id, args[0], "sin"); - break; - case GLSLstd450Cos: - emit_unary_func_op(result_type, id, args[0], "cos"); - break; - case GLSLstd450Tan: - emit_unary_func_op(result_type, id, args[0], "tan"); - break; - case GLSLstd450Asin: - emit_unary_func_op(result_type, id, args[0], "asin"); - break; - case GLSLstd450Acos: - emit_unary_func_op(result_type, id, args[0], "acos"); - break; - case GLSLstd450Atan: - emit_unary_func_op(result_type, id, args[0], "atan"); - break; - case GLSLstd450Sinh: - emit_unary_func_op(result_type, id, args[0], "sinh"); - break; - case GLSLstd450Cosh: - emit_unary_func_op(result_type, id, args[0], "cosh"); - break; - case GLSLstd450Tanh: - emit_unary_func_op(result_type, id, args[0], "tanh"); - break; - case GLSLstd450Asinh: - emit_unary_func_op(result_type, id, args[0], "asinh"); - break; - case GLSLstd450Acosh: - emit_unary_func_op(result_type, id, args[0], "acosh"); - break; - case GLSLstd450Atanh: - emit_unary_func_op(result_type, id, args[0], "atanh"); - break; - case GLSLstd450Atan2: - emit_binary_func_op(result_type, id, args[0], args[1], "atan"); - break; - - // Exponentials - case GLSLstd450Pow: - emit_binary_func_op(result_type, id, args[0], args[1], "pow"); - break; - case GLSLstd450Exp: - emit_unary_func_op(result_type, id, args[0], "exp"); - break; - case GLSLstd450Log: - emit_unary_func_op(result_type, id, args[0], "log"); - break; - case GLSLstd450Exp2: - emit_unary_func_op(result_type, id, args[0], "exp2"); - break; - case GLSLstd450Log2: - emit_unary_func_op(result_type, id, args[0], "log2"); - break; - case GLSLstd450Sqrt: - emit_unary_func_op(result_type, id, args[0], "sqrt"); - break; - case GLSLstd450InverseSqrt: - emit_unary_func_op(result_type, id, args[0], "inversesqrt"); - break; - - // Matrix math - case GLSLstd450Determinant: - emit_unary_func_op(result_type, id, args[0], "determinant"); - break; - case GLSLstd450MatrixInverse: - emit_unary_func_op(result_type, id, args[0], "inverse"); - break; - - // Lerping - case GLSLstd450FMix: - case GLSLstd450IMix: - { - emit_mix_op(result_type, id, args[0], args[1], args[2]); - break; - } - case GLSLstd450Step: - emit_binary_func_op(result_type, id, args[0], args[1], "step"); - break; - case GLSLstd450SmoothStep: - emit_trinary_func_op(result_type, id, args[0], args[1], args[2], "smoothstep"); - break; - - // Packing - case GLSLstd450Frexp: - register_call_out_argument(args[1]); - forced_temporaries.insert(id); - emit_binary_func_op(result_type, id, args[0], args[1], "frexp"); - break; - - case GLSLstd450FrexpStruct: - { - forced_temporaries.insert(id); - auto &type = get(result_type); - auto flags = meta[id].decoration.decoration_flags; - statement(flags_to_precision_qualifiers_glsl(type, flags), variable_decl(type, to_name(id)), ";"); - set(id, to_name(id), result_type, true); - - statement(to_expression(id), ".", to_member_name(type, 0), " = ", "frexp(", to_expression(args[0]), ", ", - to_expression(id), ".", to_member_name(type, 1), ");"); - break; - } - - case GLSLstd450Ldexp: - emit_binary_func_op(result_type, id, args[0], args[1], "ldexp"); - break; - case GLSLstd450PackSnorm4x8: - emit_unary_func_op(result_type, id, args[0], "packSnorm4x8"); - break; - case GLSLstd450PackUnorm4x8: - emit_unary_func_op(result_type, id, args[0], "packUnorm4x8"); - break; - case GLSLstd450PackSnorm2x16: - emit_unary_func_op(result_type, id, args[0], "packSnorm2x16"); - break; - case GLSLstd450PackUnorm2x16: - emit_unary_func_op(result_type, id, args[0], "packUnorm2x16"); - break; - case GLSLstd450PackHalf2x16: - emit_unary_func_op(result_type, id, args[0], "packHalf2x16"); - break; - case GLSLstd450UnpackSnorm4x8: - emit_unary_func_op(result_type, id, args[0], "unpackSnorm4x8"); - break; - case GLSLstd450UnpackUnorm4x8: - emit_unary_func_op(result_type, id, args[0], "unpackUnorm4x8"); - break; - case GLSLstd450UnpackSnorm2x16: - emit_unary_func_op(result_type, id, args[0], "unpackSnorm2x16"); - break; - case GLSLstd450UnpackUnorm2x16: - emit_unary_func_op(result_type, id, args[0], "unpackUnorm2x16"); - break; - case GLSLstd450UnpackHalf2x16: - emit_unary_func_op(result_type, id, args[0], "unpackHalf2x16"); - break; - - case GLSLstd450PackDouble2x32: - emit_unary_func_op(result_type, id, args[0], "packDouble2x32"); - break; - case GLSLstd450UnpackDouble2x32: - emit_unary_func_op(result_type, id, args[0], "unpackDouble2x32"); - break; - - // Vector math - case GLSLstd450Length: - emit_unary_func_op(result_type, id, args[0], "length"); - break; - case GLSLstd450Distance: - emit_binary_func_op(result_type, id, args[0], args[1], "distance"); - break; - case GLSLstd450Cross: - emit_binary_func_op(result_type, id, args[0], args[1], "cross"); - break; - case GLSLstd450Normalize: - emit_unary_func_op(result_type, id, args[0], "normalize"); - break; - case GLSLstd450FaceForward: - emit_trinary_func_op(result_type, id, args[0], args[1], args[2], "faceforward"); - break; - case GLSLstd450Reflect: - emit_binary_func_op(result_type, id, args[0], args[1], "reflect"); - break; - case GLSLstd450Refract: - emit_trinary_func_op(result_type, id, args[0], args[1], args[2], "refract"); - break; - - // Bit-fiddling - case GLSLstd450FindILsb: - emit_unary_func_op(result_type, id, args[0], "findLSB"); - break; - case GLSLstd450FindSMsb: - case GLSLstd450FindUMsb: - emit_unary_func_op(result_type, id, args[0], "findMSB"); - break; - - // Multisampled varying - case GLSLstd450InterpolateAtCentroid: - emit_unary_func_op(result_type, id, args[0], "interpolateAtCentroid"); - break; - case GLSLstd450InterpolateAtSample: - emit_binary_func_op(result_type, id, args[0], args[1], "interpolateAtSample"); - break; - case GLSLstd450InterpolateAtOffset: - emit_binary_func_op(result_type, id, args[0], args[1], "interpolateAtOffset"); - break; - - default: - statement("// unimplemented GLSL op ", eop); - break; - } -} - -void CompilerGLSL::emit_spv_amd_shader_ballot_op(uint32_t result_type, uint32_t id, uint32_t eop, const uint32_t *args, - uint32_t) -{ - require_extension("GL_AMD_shader_ballot"); - - enum AMDShaderBallot - { - SwizzleInvocationsAMD = 1, - SwizzleInvocationsMaskedAMD = 2, - WriteInvocationAMD = 3, - MbcntAMD = 4 - }; - - auto op = static_cast(eop); - - switch (op) - { - case SwizzleInvocationsAMD: - emit_binary_func_op(result_type, id, args[0], args[1], "swizzleInvocationsAMD"); - break; - - case SwizzleInvocationsMaskedAMD: - emit_binary_func_op(result_type, id, args[0], args[1], "swizzleInvocationsMaskedAMD"); - break; - - case WriteInvocationAMD: - emit_trinary_func_op(result_type, id, args[0], args[1], args[2], "writeInvocationAMD"); - break; - - case MbcntAMD: - emit_unary_func_op(result_type, id, args[0], "mbcntAMD"); - break; - - default: - statement("// unimplemented SPV AMD shader ballot op ", eop); - break; - } -} - -void CompilerGLSL::emit_spv_amd_shader_explicit_vertex_parameter_op(uint32_t result_type, uint32_t id, uint32_t eop, - const uint32_t *args, uint32_t) -{ - require_extension("GL_AMD_shader_explicit_vertex_parameter"); - - enum AMDShaderExplicitVertexParameter - { - InterpolateAtVertexAMD = 1 - }; - - auto op = static_cast(eop); - - switch (op) - { - case InterpolateAtVertexAMD: - emit_binary_func_op(result_type, id, args[0], args[1], "interpolateAtVertexAMD"); - break; - - default: - statement("// unimplemented SPV AMD shader explicit vertex parameter op ", eop); - break; - } -} - -void CompilerGLSL::emit_spv_amd_shader_trinary_minmax_op(uint32_t result_type, uint32_t id, uint32_t eop, - const uint32_t *args, uint32_t) -{ - require_extension("GL_AMD_shader_trinary_minmax"); - - enum AMDShaderTrinaryMinMax - { - FMin3AMD = 1, - UMin3AMD = 2, - SMin3AMD = 3, - FMax3AMD = 4, - UMax3AMD = 5, - SMax3AMD = 6, - FMid3AMD = 7, - UMid3AMD = 8, - SMid3AMD = 9 - }; - - auto op = static_cast(eop); - - switch (op) - { - case FMin3AMD: - case UMin3AMD: - case SMin3AMD: - emit_trinary_func_op(result_type, id, args[0], args[1], args[2], "min3"); - break; - - case FMax3AMD: - case UMax3AMD: - case SMax3AMD: - emit_trinary_func_op(result_type, id, args[0], args[1], args[2], "max3"); - break; - - case FMid3AMD: - case UMid3AMD: - case SMid3AMD: - emit_trinary_func_op(result_type, id, args[0], args[1], args[2], "mid3"); - break; - - default: - statement("// unimplemented SPV AMD shader trinary minmax op ", eop); - break; - } -} - -void CompilerGLSL::emit_spv_amd_gcn_shader_op(uint32_t result_type, uint32_t id, uint32_t eop, const uint32_t *args, - uint32_t) -{ - require_extension("GL_AMD_gcn_shader"); - - enum AMDGCNShader - { - CubeFaceIndexAMD = 1, - CubeFaceCoordAMD = 2, - TimeAMD = 3 - }; - - auto op = static_cast(eop); - - switch (op) - { - case CubeFaceIndexAMD: - emit_unary_func_op(result_type, id, args[0], "cubeFaceIndexAMD"); - break; - case CubeFaceCoordAMD: - emit_unary_func_op(result_type, id, args[0], "cubeFaceCoordAMD"); - break; - case TimeAMD: - { - string expr = "timeAMD()"; - emit_op(result_type, id, expr, true); - break; - } - - default: - statement("// unimplemented SPV AMD gcn shader op ", eop); - break; - } -} - -string CompilerGLSL::bitcast_glsl_op(const SPIRType &out_type, const SPIRType &in_type) -{ - if (out_type.basetype == SPIRType::UInt && in_type.basetype == SPIRType::Int) - return type_to_glsl(out_type); - else if (out_type.basetype == SPIRType::UInt64 && in_type.basetype == SPIRType::Int64) - return type_to_glsl(out_type); - else if (out_type.basetype == SPIRType::UInt && in_type.basetype == SPIRType::Float) - return "floatBitsToUint"; - else if (out_type.basetype == SPIRType::Int && in_type.basetype == SPIRType::UInt) - return type_to_glsl(out_type); - else if (out_type.basetype == SPIRType::Int64 && in_type.basetype == SPIRType::UInt64) - return type_to_glsl(out_type); - else if (out_type.basetype == SPIRType::Int && in_type.basetype == SPIRType::Float) - return "floatBitsToInt"; - else if (out_type.basetype == SPIRType::Float && in_type.basetype == SPIRType::UInt) - return "uintBitsToFloat"; - else if (out_type.basetype == SPIRType::Float && in_type.basetype == SPIRType::Int) - return "intBitsToFloat"; - else if (out_type.basetype == SPIRType::Int64 && in_type.basetype == SPIRType::Double) - return "doubleBitsToInt64"; - else if (out_type.basetype == SPIRType::UInt64 && in_type.basetype == SPIRType::Double) - return "doubleBitsToUint64"; - else if (out_type.basetype == SPIRType::Double && in_type.basetype == SPIRType::Int64) - return "int64BitsToDouble"; - else if (out_type.basetype == SPIRType::Double && in_type.basetype == SPIRType::UInt64) - return "uint64BitsToDouble"; - else if (out_type.basetype == SPIRType::UInt64 && in_type.basetype == SPIRType::UInt && in_type.vecsize == 2) - return "packUint2x32"; - else - return ""; -} - -string CompilerGLSL::bitcast_glsl(const SPIRType &result_type, uint32_t argument) -{ - auto op = bitcast_glsl_op(result_type, expression_type(argument)); - if (op.empty()) - return to_enclosed_expression(argument); - else - return join(op, "(", to_expression(argument), ")"); -} - -std::string CompilerGLSL::bitcast_expression(SPIRType::BaseType target_type, uint32_t arg) -{ - auto expr = to_expression(arg); - auto &src_type = expression_type(arg); - if (src_type.basetype != target_type) - { - auto target = src_type; - target.basetype = target_type; - expr = join(bitcast_glsl_op(target, src_type), "(", expr, ")"); - } - - return expr; -} - -std::string CompilerGLSL::bitcast_expression(const SPIRType &target_type, SPIRType::BaseType expr_type, - const std::string &expr) -{ - if (target_type.basetype == expr_type) - return expr; - - auto src_type = target_type; - src_type.basetype = expr_type; - return join(bitcast_glsl_op(target_type, src_type), "(", expr, ")"); -} - -string CompilerGLSL::builtin_to_glsl(BuiltIn builtin, StorageClass storage) -{ - switch (builtin) - { - case BuiltInPosition: - return "gl_Position"; - case BuiltInPointSize: - return "gl_PointSize"; - case BuiltInClipDistance: - return "gl_ClipDistance"; - case BuiltInCullDistance: - return "gl_CullDistance"; - case BuiltInVertexId: - if (options.vulkan_semantics) - SPIRV_CROSS_THROW( - "Cannot implement gl_VertexID in Vulkan GLSL. This shader was created with GL semantics."); - return "gl_VertexID"; - case BuiltInInstanceId: - if (options.vulkan_semantics) - SPIRV_CROSS_THROW( - "Cannot implement gl_InstanceID in Vulkan GLSL. This shader was created with GL semantics."); - return "gl_InstanceID"; - case BuiltInVertexIndex: - if (options.vulkan_semantics) - return "gl_VertexIndex"; - else - return "gl_VertexID"; // gl_VertexID already has the base offset applied. - case BuiltInInstanceIndex: - if (options.vulkan_semantics) - return "gl_InstanceIndex"; - else - return "(gl_InstanceID + SPIRV_Cross_BaseInstance)"; // ... but not gl_InstanceID. - case BuiltInPrimitiveId: - return "gl_PrimitiveID"; - case BuiltInInvocationId: - return "gl_InvocationID"; - case BuiltInLayer: - return "gl_Layer"; - case BuiltInViewportIndex: - return "gl_ViewportIndex"; - case BuiltInTessLevelOuter: - return "gl_TessLevelOuter"; - case BuiltInTessLevelInner: - return "gl_TessLevelInner"; - case BuiltInTessCoord: - return "gl_TessCoord"; - case BuiltInFragCoord: - return "gl_FragCoord"; - case BuiltInPointCoord: - return "gl_PointCoord"; - case BuiltInFrontFacing: - return "gl_FrontFacing"; - case BuiltInFragDepth: - return "gl_FragDepth"; - case BuiltInNumWorkgroups: - return "gl_NumWorkGroups"; - case BuiltInWorkgroupSize: - return "gl_WorkGroupSize"; - case BuiltInWorkgroupId: - return "gl_WorkGroupID"; - case BuiltInLocalInvocationId: - return "gl_LocalInvocationID"; - case BuiltInGlobalInvocationId: - return "gl_GlobalInvocationID"; - case BuiltInLocalInvocationIndex: - return "gl_LocalInvocationIndex"; - - case BuiltInSampleId: - if (options.es && options.version < 320) - require_extension("GL_OES_sample_variables"); - if (!options.es && options.version < 400) - SPIRV_CROSS_THROW("gl_SampleID not supported before GLSL 400."); - return "gl_SampleID"; - - case BuiltInSampleMask: - if (options.es && options.version < 320) - require_extension("GL_OES_sample_variables"); - if (!options.es && options.version < 400) - SPIRV_CROSS_THROW("gl_SampleMask/gl_SampleMaskIn not supported before GLSL 400."); - - if (storage == StorageClassInput) - return "gl_SampleMaskIn"; - else - return "gl_SampleMask"; - - case BuiltInSamplePosition: - if (options.es && options.version < 320) - require_extension("GL_OES_sample_variables"); - if (!options.es && options.version < 400) - SPIRV_CROSS_THROW("gl_SamplePosition not supported before GLSL 400."); - return "gl_SamplePosition"; - - case BuiltInViewIndex: - if (options.vulkan_semantics) - { - require_extension("GL_EXT_multiview"); - return "gl_ViewIndex"; - } - else - { - require_extension("GL_OVR_multiview2"); - return "gl_ViewID_OVR"; - } - - default: - return join("gl_BuiltIn_", convert_to_string(builtin)); - } -} - -const char *CompilerGLSL::index_to_swizzle(uint32_t index) -{ - switch (index) - { - case 0: - return "x"; - case 1: - return "y"; - case 2: - return "z"; - case 3: - return "w"; - default: - SPIRV_CROSS_THROW("Swizzle index out of range"); - } -} - -string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indices, uint32_t count, - bool index_is_literal, bool chain_only, bool *need_transpose, - bool *result_is_packed) -{ - string expr; - if (!chain_only) - expr = to_enclosed_expression(base); - - uint32_t type_id = expression_type_id(base); - const auto *type = &get(type_id); - - // Start traversing type hierarchy at the proper non-pointer types, - // but keep type_id referencing the original pointer for use below. - while (type->pointer) - { - assert(type->parent_type); - type = &get(type->parent_type); - } - - bool access_chain_is_arrayed = false; - bool row_major_matrix_needs_conversion = is_non_native_row_major_matrix(base); - bool vector_is_packed = false; - bool pending_array_enclose = false; - bool dimension_flatten = false; - - for (uint32_t i = 0; i < count; i++) - { - uint32_t index = indices[i]; - - // Arrays - if (!type->array.empty()) - { - // If we are flattening multidimensional arrays, only create opening bracket on first - // array index. - if (options.flatten_multidimensional_arrays && !pending_array_enclose) - { - dimension_flatten = type->array.size() > 1; - pending_array_enclose = dimension_flatten; - if (pending_array_enclose) - expr += "["; - } - - assert(type->parent_type); - - const auto append_index = [&]() { - expr += "["; - if (index_is_literal) - expr += convert_to_string(index); - else - expr += to_expression(index); - expr += "]"; - }; - - auto *var = maybe_get(base); - if (backend.force_gl_in_out_block && i == 0 && var && is_builtin_variable(*var) && - !has_decoration(type->self, DecorationBlock)) - { - // This deals with scenarios for tesc/geom where arrays of gl_Position[] are declared. - // Normally, these variables live in blocks when compiled from GLSL, - // but HLSL seems to just emit straight arrays here. - // We must pretend this access goes through gl_in/gl_out arrays - // to be able to access certain builtins as arrays. - auto builtin = meta[base].decoration.builtin_type; - switch (builtin) - { - // case BuiltInCullDistance: // These are already arrays, need to figure out rules for these in tess/geom. - // case BuiltInClipDistance: - case BuiltInPosition: - case BuiltInPointSize: - if (var->storage == StorageClassInput) - expr = join("gl_in[", to_expression(index), "].", expr); - else if (var->storage == StorageClassOutput) - expr = join("gl_out[", to_expression(index), "].", expr); - else - append_index(); - break; - - default: - append_index(); - break; - } - } - else if (options.flatten_multidimensional_arrays && dimension_flatten) - { - // If we are flattening multidimensional arrays, do manual stride computation. - auto &parent_type = get(type->parent_type); - - if (index_is_literal) - expr += convert_to_string(index); - else - expr += to_enclosed_expression(index); - - for (auto j = uint32_t(parent_type.array.size()); j; j--) - { - expr += " * "; - expr += enclose_expression(to_array_size(parent_type, j - 1)); - } - - if (parent_type.array.empty()) - pending_array_enclose = false; - else - expr += " + "; - - if (!pending_array_enclose) - expr += "]"; - } - else - { - append_index(); - } - - type_id = type->parent_type; - type = &get(type_id); - - access_chain_is_arrayed = true; - } - // For structs, the index refers to a constant, which indexes into the members. - // We also check if this member is a builtin, since we then replace the entire expression with the builtin one. - else if (type->basetype == SPIRType::Struct) - { - if (!index_is_literal) - index = get(index).scalar(); - - if (index >= type->member_types.size()) - SPIRV_CROSS_THROW("Member index is out of bounds!"); - - BuiltIn builtin; - if (is_member_builtin(*type, index, &builtin)) - { - // FIXME: We rely here on OpName on gl_in/gl_out to make this work properly. - // To make this properly work by omitting all OpName opcodes, - // we need to infer gl_in or gl_out based on the builtin, and stage. - if (access_chain_is_arrayed) - { - expr += "."; - expr += builtin_to_glsl(builtin, type->storage); - } - else - expr = builtin_to_glsl(builtin, type->storage); - } - else - { - // If the member has a qualified name, use it as the entire chain - string qual_mbr_name = get_member_qualified_name(type_id, index); - if (!qual_mbr_name.empty()) - expr = qual_mbr_name; - else - { - expr += "."; - expr += to_member_name(*type, index); - } - } - - vector_is_packed = member_is_packed_type(*type, index); - row_major_matrix_needs_conversion = member_is_non_native_row_major_matrix(*type, index); - type = &get(type->member_types[index]); - } - // Matrix -> Vector - else if (type->columns > 1) - { - if (row_major_matrix_needs_conversion) - { - expr = convert_row_major_matrix(expr, *type); - row_major_matrix_needs_conversion = false; - } - - expr += "["; - if (index_is_literal) - expr += convert_to_string(index); - else - expr += to_expression(index); - expr += "]"; - - type_id = type->parent_type; - type = &get(type_id); - } - // Vector -> Scalar - else if (type->vecsize > 1) - { - if (vector_is_packed) - { - expr = unpack_expression_type(expr, *type); - vector_is_packed = false; - } - - if (index_is_literal) - { - expr += "."; - expr += index_to_swizzle(index); - } - else if (ids[index].get_type() == TypeConstant) - { - auto &c = get(index); - expr += "."; - expr += index_to_swizzle(c.scalar()); - } - else - { - expr += "["; - expr += to_expression(index); - expr += "]"; - } - - type_id = type->parent_type; - type = &get(type_id); - } - else - SPIRV_CROSS_THROW("Cannot subdivide a scalar value!"); - } - - if (pending_array_enclose) - { - SPIRV_CROSS_THROW("Flattening of multidimensional arrays were enabled, " - "but the access chain was terminated in the middle of a multidimensional array. " - "This is not supported."); - } - - if (need_transpose) - *need_transpose = row_major_matrix_needs_conversion; - - if (result_is_packed) - *result_is_packed = vector_is_packed; - - return expr; -} - -string CompilerGLSL::to_flattened_struct_member(const SPIRVariable &var, uint32_t index) -{ - auto &type = get(var.basetype); - return sanitize_underscores(join(to_name(var.self), "_", to_member_name(type, index))); -} - -string CompilerGLSL::access_chain(uint32_t base, const uint32_t *indices, uint32_t count, const SPIRType &target_type, - bool *out_need_transpose, bool *result_is_packed) -{ - if (flattened_buffer_blocks.count(base)) - { - uint32_t matrix_stride = 0; - bool need_transpose = false; - flattened_access_chain_offset(expression_type(base), indices, count, 0, 16, &need_transpose, &matrix_stride); - - if (out_need_transpose) - *out_need_transpose = target_type.columns > 1 && need_transpose; - if (result_is_packed) - *result_is_packed = false; - - return flattened_access_chain(base, indices, count, target_type, 0, matrix_stride, need_transpose); - } - else if (flattened_structs.count(base) && count > 0) - { - auto chain = access_chain_internal(base, indices, count, false, true).substr(1); - if (out_need_transpose) - *out_need_transpose = false; - if (result_is_packed) - *result_is_packed = false; - return sanitize_underscores(join(to_name(base), "_", chain)); - } - else - { - return access_chain_internal(base, indices, count, false, false, out_need_transpose, result_is_packed); - } -} - -string CompilerGLSL::load_flattened_struct(SPIRVariable &var) -{ - auto expr = type_to_glsl_constructor(get(var.basetype)); - expr += '('; - - auto &type = get(var.basetype); - for (uint32_t i = 0; i < uint32_t(type.member_types.size()); i++) - { - if (i) - expr += ", "; - - // Flatten the varyings. - // Apply name transformation for flattened I/O blocks. - expr += to_flattened_struct_member(var, i); - } - expr += ')'; - return expr; -} - -void CompilerGLSL::store_flattened_struct(SPIRVariable &var, uint32_t value) -{ - // We're trying to store a structure which has been flattened. - // Need to copy members one by one. - auto rhs = to_expression(value); - - // Store result locally. - // Since we're declaring a variable potentially multiple times here, - // store the variable in an isolated scope. - begin_scope(); - statement(variable_decl_function_local(var), " = ", rhs, ";"); - - auto &type = get(var.basetype); - for (uint32_t i = 0; i < uint32_t(type.member_types.size()); i++) - { - // Flatten the varyings. - // Apply name transformation for flattened I/O blocks. - - auto lhs = sanitize_underscores(join(to_name(var.self), "_", to_member_name(type, i))); - rhs = join(to_name(var.self), ".", to_member_name(type, i)); - statement(lhs, " = ", rhs, ";"); - } - end_scope(); -} - -std::string CompilerGLSL::flattened_access_chain(uint32_t base, const uint32_t *indices, uint32_t count, - const SPIRType &target_type, uint32_t offset, uint32_t matrix_stride, - bool need_transpose) -{ - if (!target_type.array.empty()) - SPIRV_CROSS_THROW("Access chains that result in an array can not be flattened"); - else if (target_type.basetype == SPIRType::Struct) - return flattened_access_chain_struct(base, indices, count, target_type, offset); - else if (target_type.columns > 1) - return flattened_access_chain_matrix(base, indices, count, target_type, offset, matrix_stride, need_transpose); - else - return flattened_access_chain_vector(base, indices, count, target_type, offset, matrix_stride, need_transpose); -} - -std::string CompilerGLSL::flattened_access_chain_struct(uint32_t base, const uint32_t *indices, uint32_t count, - const SPIRType &target_type, uint32_t offset) -{ - std::string expr; - - expr += type_to_glsl_constructor(target_type); - expr += "("; - - for (uint32_t i = 0; i < uint32_t(target_type.member_types.size()); ++i) - { - if (i != 0) - expr += ", "; - - const SPIRType &member_type = get(target_type.member_types[i]); - uint32_t member_offset = type_struct_member_offset(target_type, i); - - // The access chain terminates at the struct, so we need to find matrix strides and row-major information - // ahead of time. - bool need_transpose = false; - uint32_t matrix_stride = 0; - if (member_type.columns > 1) - { - need_transpose = (combined_decoration_for_member(target_type, i) & (1ull << DecorationRowMajor)) != 0; - matrix_stride = type_struct_member_matrix_stride(target_type, i); - } - - auto tmp = flattened_access_chain(base, indices, count, member_type, offset + member_offset, matrix_stride, - need_transpose); - - // Cannot forward transpositions, so resolve them here. - if (need_transpose) - expr += convert_row_major_matrix(tmp, member_type); - else - expr += tmp; - } - - expr += ")"; - - return expr; -} - -std::string CompilerGLSL::flattened_access_chain_matrix(uint32_t base, const uint32_t *indices, uint32_t count, - const SPIRType &target_type, uint32_t offset, - uint32_t matrix_stride, bool need_transpose) -{ - assert(matrix_stride); - SPIRType tmp_type = target_type; - if (need_transpose) - swap(tmp_type.vecsize, tmp_type.columns); - - std::string expr; - - expr += type_to_glsl_constructor(tmp_type); - expr += "("; - - for (uint32_t i = 0; i < tmp_type.columns; i++) - { - if (i != 0) - expr += ", "; - - expr += flattened_access_chain_vector(base, indices, count, tmp_type, offset + i * matrix_stride, matrix_stride, - /* need_transpose= */ false); - } - - expr += ")"; - - return expr; -} - -std::string CompilerGLSL::flattened_access_chain_vector(uint32_t base, const uint32_t *indices, uint32_t count, - const SPIRType &target_type, uint32_t offset, - uint32_t matrix_stride, bool need_transpose) -{ - auto result = flattened_access_chain_offset(expression_type(base), indices, count, offset, 16); - - auto buffer_name = to_name(expression_type(base).self); - - if (need_transpose) - { - std::string expr; - - if (target_type.vecsize > 1) - { - expr += type_to_glsl_constructor(target_type); - expr += "("; - } - - for (uint32_t i = 0; i < target_type.vecsize; ++i) - { - if (i != 0) - expr += ", "; - - uint32_t component_offset = result.second + i * matrix_stride; - - assert(component_offset % (target_type.width / 8) == 0); - uint32_t index = component_offset / (target_type.width / 8); - - expr += buffer_name; - expr += "["; - expr += result.first; // this is a series of N1 * k1 + N2 * k2 + ... that is either empty or ends with a + - expr += convert_to_string(index / 4); - expr += "]"; - - expr += vector_swizzle(1, index % 4); - } - - if (target_type.vecsize > 1) - { - expr += ")"; - } - - return expr; - } - else - { - assert(result.second % (target_type.width / 8) == 0); - uint32_t index = result.second / (target_type.width / 8); - - std::string expr; - - expr += buffer_name; - expr += "["; - expr += result.first; // this is a series of N1 * k1 + N2 * k2 + ... that is either empty or ends with a + - expr += convert_to_string(index / 4); - expr += "]"; - - expr += vector_swizzle(target_type.vecsize, index % 4); - - return expr; - } -} - -std::pair CompilerGLSL::flattened_access_chain_offset(const SPIRType &basetype, - const uint32_t *indices, uint32_t count, - uint32_t offset, uint32_t word_stride, - bool *need_transpose, - uint32_t *out_matrix_stride) -{ - const auto *type = &basetype; - - // Start traversing type hierarchy at the proper non-pointer types. - while (type->pointer) - { - assert(type->parent_type); - type = &get(type->parent_type); - } - - // This holds the type of the current pointer which we are traversing through. - // We always start out from a struct type which is the block. - // This is primarily used to reflect the array strides and matrix strides later. - // For the first access chain index, type_id won't be needed, so just keep it as 0, it will be set - // accordingly as members of structs are accessed. - assert(type->basetype == SPIRType::Struct); - uint32_t type_id = 0; - - std::string expr; - - // Inherit matrix information in case we are access chaining a vector which might have come from a row major layout. - bool row_major_matrix_needs_conversion = need_transpose ? *need_transpose : false; - uint32_t matrix_stride = out_matrix_stride ? *out_matrix_stride : 0; - - for (uint32_t i = 0; i < count; i++) - { - uint32_t index = indices[i]; - - // Arrays - if (!type->array.empty()) - { - // Here, the type_id will be a type ID for the array type itself. - uint32_t array_stride = get_decoration(type_id, DecorationArrayStride); - if (!array_stride) - SPIRV_CROSS_THROW("SPIR-V does not define ArrayStride for buffer block."); - - auto *constant = maybe_get(index); - if (constant) - { - // Constant array access. - offset += constant->scalar() * array_stride; - } - else - { - // Dynamic array access. - if (array_stride % word_stride) - { - SPIRV_CROSS_THROW( - "Array stride for dynamic indexing must be divisible by the size of a 4-component vector. " - "Likely culprit here is a float or vec2 array inside a push constant block which is std430. " - "This cannot be flattened. Try using std140 layout instead."); - } - - expr += to_enclosed_expression(index); - expr += " * "; - expr += convert_to_string(array_stride / word_stride); - expr += " + "; - } - - uint32_t parent_type = type->parent_type; - type = &get(parent_type); - type_id = parent_type; - - // Type ID now refers to the array type with one less dimension. - } - // For structs, the index refers to a constant, which indexes into the members. - // We also check if this member is a builtin, since we then replace the entire expression with the builtin one. - else if (type->basetype == SPIRType::Struct) - { - index = get(index).scalar(); - - if (index >= type->member_types.size()) - SPIRV_CROSS_THROW("Member index is out of bounds!"); - - offset += type_struct_member_offset(*type, index); - type_id = type->member_types[index]; - - auto &struct_type = *type; - type = &get(type->member_types[index]); - - if (type->columns > 1) - { - matrix_stride = type_struct_member_matrix_stride(struct_type, index); - row_major_matrix_needs_conversion = - (combined_decoration_for_member(struct_type, index) & (1ull << DecorationRowMajor)) != 0; - } - else - row_major_matrix_needs_conversion = false; - } - // Matrix -> Vector - else if (type->columns > 1) - { - auto *constant = maybe_get(index); - if (constant) - { - index = get(index).scalar(); - offset += index * (row_major_matrix_needs_conversion ? (type->width / 8) : matrix_stride); - } - else - { - uint32_t indexing_stride = row_major_matrix_needs_conversion ? (type->width / 8) : matrix_stride; - // Dynamic array access. - if (indexing_stride % word_stride) - { - SPIRV_CROSS_THROW( - "Matrix stride for dynamic indexing must be divisible by the size of a 4-component vector. " - "Likely culprit here is a row-major matrix being accessed dynamically. " - "This cannot be flattened. Try using std140 layout instead."); - } - - expr += to_enclosed_expression(index); - expr += " * "; - expr += convert_to_string(indexing_stride / word_stride); - expr += " + "; - } - - uint32_t parent_type = type->parent_type; - type = &get(type->parent_type); - type_id = parent_type; - } - // Vector -> Scalar - else if (type->vecsize > 1) - { - auto *constant = maybe_get(index); - if (constant) - { - index = get(index).scalar(); - offset += index * (row_major_matrix_needs_conversion ? matrix_stride : (type->width / 8)); - } - else - { - uint32_t indexing_stride = row_major_matrix_needs_conversion ? matrix_stride : (type->width / 8); - - // Dynamic array access. - if (indexing_stride % word_stride) - { - SPIRV_CROSS_THROW( - "Stride for dynamic vector indexing must be divisible by the size of a 4-component vector. " - "This cannot be flattened in legacy targets."); - } - - expr += to_enclosed_expression(index); - expr += " * "; - expr += convert_to_string(indexing_stride / word_stride); - expr += " + "; - } - - uint32_t parent_type = type->parent_type; - type = &get(type->parent_type); - type_id = parent_type; - } - else - SPIRV_CROSS_THROW("Cannot subdivide a scalar value!"); - } - - if (need_transpose) - *need_transpose = row_major_matrix_needs_conversion; - if (out_matrix_stride) - *out_matrix_stride = matrix_stride; - - return std::make_pair(expr, offset); -} - -bool CompilerGLSL::should_forward(uint32_t id) -{ - // Immutable expression can always be forwarded. - // If not immutable, we can speculate about it by forwarding potentially mutable variables. - auto *var = maybe_get(id); - bool forward = var ? var->forwardable : false; - return (is_immutable(id) || forward) && !options.force_temporary; -} - -void CompilerGLSL::track_expression_read(uint32_t id) -{ - // If we try to read a forwarded temporary more than once we will stamp out possibly complex code twice. - // In this case, it's better to just bind the complex expression to the temporary and read that temporary twice. - if (expression_is_forwarded(id)) - { - auto &v = expression_usage_counts[id]; - v++; - - if (v >= 2) - { - //if (v == 2) - // fprintf(stderr, "ID %u was forced to temporary due to more than 1 expression use!\n", id); - - forced_temporaries.insert(id); - // Force a recompile after this pass to avoid forwarding this variable. - force_recompile = true; - } - } -} - -bool CompilerGLSL::args_will_forward(uint32_t id, const uint32_t *args, uint32_t num_args, bool pure) -{ - if (forced_temporaries.find(id) != end(forced_temporaries)) - return false; - - for (uint32_t i = 0; i < num_args; i++) - if (!should_forward(args[i])) - return false; - - // We need to forward globals as well. - if (!pure) - { - for (auto global : global_variables) - if (!should_forward(global)) - return false; - for (auto aliased : aliased_variables) - if (!should_forward(aliased)) - return false; - } - - return true; -} - -void CompilerGLSL::register_impure_function_call() -{ - // Impure functions can modify globals and aliased variables, so invalidate them as well. - for (auto global : global_variables) - flush_dependees(get(global)); - for (auto aliased : aliased_variables) - flush_dependees(get(aliased)); -} - -void CompilerGLSL::register_call_out_argument(uint32_t id) -{ - register_write(id); - - auto *var = maybe_get(id); - if (var) - flush_variable_declaration(var->self); -} - -string CompilerGLSL::variable_decl_function_local(SPIRVariable &var) -{ - // These variables are always function local, - // so make sure we emit the variable without storage qualifiers. - // Some backends will inject custom variables locally in a function - // with a storage qualifier which is not function-local. - auto old_storage = var.storage; - var.storage = StorageClassFunction; - auto expr = variable_decl(var); - var.storage = old_storage; - return expr; -} - -void CompilerGLSL::flush_variable_declaration(uint32_t id) -{ - auto *var = maybe_get(id); - if (var && var->deferred_declaration) - { - statement(variable_decl_function_local(*var), ";"); - var->deferred_declaration = false; - } -} - -bool CompilerGLSL::remove_duplicate_swizzle(string &op) -{ - auto pos = op.find_last_of('.'); - if (pos == string::npos || pos == 0) - return false; - - string final_swiz = op.substr(pos + 1, string::npos); - - if (backend.swizzle_is_function) - { - if (final_swiz.size() < 2) - return false; - - if (final_swiz.substr(final_swiz.size() - 2, string::npos) == "()") - final_swiz.erase(final_swiz.size() - 2, string::npos); - else - return false; - } - - // Check if final swizzle is of form .x, .xy, .xyz, .xyzw or similar. - // If so, and previous swizzle is of same length, - // we can drop the final swizzle altogether. - for (uint32_t i = 0; i < final_swiz.size(); i++) - { - static const char expected[] = { 'x', 'y', 'z', 'w' }; - if (i >= 4 || final_swiz[i] != expected[i]) - return false; - } - - auto prevpos = op.find_last_of('.', pos - 1); - if (prevpos == string::npos) - return false; - - prevpos++; - - // Make sure there are only swizzles here ... - for (auto i = prevpos; i < pos; i++) - { - if (op[i] < 'w' || op[i] > 'z') - { - // If swizzles are foo.xyz() like in C++ backend for example, check for that. - if (backend.swizzle_is_function && i + 2 == pos && op[i] == '(' && op[i + 1] == ')') - break; - return false; - } - } - - // If original swizzle is large enough, just carve out the components we need. - // E.g. foobar.wyx.xy will turn into foobar.wy. - if (pos - prevpos >= final_swiz.size()) - { - op.erase(prevpos + final_swiz.size(), string::npos); - - // Add back the function call ... - if (backend.swizzle_is_function) - op += "()"; - } - return true; -} - -// Optimizes away vector swizzles where we have something like -// vec3 foo; -// foo.xyz <-- swizzle expression does nothing. -// This is a very common pattern after OpCompositeCombine. -bool CompilerGLSL::remove_unity_swizzle(uint32_t base, string &op) -{ - auto pos = op.find_last_of('.'); - if (pos == string::npos || pos == 0) - return false; - - string final_swiz = op.substr(pos + 1, string::npos); - - if (backend.swizzle_is_function) - { - if (final_swiz.size() < 2) - return false; - - if (final_swiz.substr(final_swiz.size() - 2, string::npos) == "()") - final_swiz.erase(final_swiz.size() - 2, string::npos); - else - return false; - } - - // Check if final swizzle is of form .x, .xy, .xyz, .xyzw or similar. - // If so, and previous swizzle is of same length, - // we can drop the final swizzle altogether. - for (uint32_t i = 0; i < final_swiz.size(); i++) - { - static const char expected[] = { 'x', 'y', 'z', 'w' }; - if (i >= 4 || final_swiz[i] != expected[i]) - return false; - } - - auto &type = expression_type(base); - - // Sanity checking ... - assert(type.columns == 1 && type.array.empty()); - - if (type.vecsize == final_swiz.size()) - op.erase(pos, string::npos); - return true; -} - -string CompilerGLSL::build_composite_combiner(uint32_t return_type, const uint32_t *elems, uint32_t length) -{ - uint32_t base = 0; - string op; - string subop; - - // Can only merge swizzles for vectors. - auto &type = get(return_type); - bool can_apply_swizzle_opt = type.basetype != SPIRType::Struct && type.array.empty() && type.columns == 1; - bool swizzle_optimization = false; - - for (uint32_t i = 0; i < length; i++) - { - auto *e = maybe_get(elems[i]); - - // If we're merging another scalar which belongs to the same base - // object, just merge the swizzles to avoid triggering more than 1 expression read as much as possible! - if (can_apply_swizzle_opt && e && e->base_expression && e->base_expression == base) - { - // Only supposed to be used for vector swizzle -> scalar. - assert(!e->expression.empty() && e->expression.front() == '.'); - subop += e->expression.substr(1, string::npos); - swizzle_optimization = true; - } - else - { - // We'll likely end up with duplicated swizzles, e.g. - // foobar.xyz.xyz from patterns like - // OpVectorShuffle - // OpCompositeExtract x 3 - // OpCompositeConstruct 3x + other scalar. - // Just modify op in-place. - if (swizzle_optimization) - { - if (backend.swizzle_is_function) - subop += "()"; - - // Don't attempt to remove unity swizzling if we managed to remove duplicate swizzles. - // The base "foo" might be vec4, while foo.xyz is vec3 (OpVectorShuffle) and looks like a vec3 due to the .xyz tacked on. - // We only want to remove the swizzles if we're certain that the resulting base will be the same vecsize. - // Essentially, we can only remove one set of swizzles, since that's what we have control over ... - // Case 1: - // foo.yxz.xyz: Duplicate swizzle kicks in, giving foo.yxz, we are done. - // foo.yxz was the result of OpVectorShuffle and we don't know the type of foo. - // Case 2: - // foo.xyz: Duplicate swizzle won't kick in. - // If foo is vec3, we can remove xyz, giving just foo. - if (!remove_duplicate_swizzle(subop)) - remove_unity_swizzle(base, subop); - - // Strips away redundant parens if we created them during component extraction. - strip_enclosed_expression(subop); - swizzle_optimization = false; - op += subop; - } - else - op += subop; - - if (i) - op += ", "; - subop = to_expression(elems[i]); - } - - base = e ? e->base_expression : 0; - } - - if (swizzle_optimization) - { - if (backend.swizzle_is_function) - subop += "()"; - - if (!remove_duplicate_swizzle(subop)) - remove_unity_swizzle(base, subop); - // Strips away redundant parens if we created them during component extraction. - strip_enclosed_expression(subop); - } - - op += subop; - return op; -} - -bool CompilerGLSL::skip_argument(uint32_t id) const -{ - if (!combined_image_samplers.empty() || !options.vulkan_semantics) - { - auto &type = expression_type(id); - if (type.basetype == SPIRType::Sampler || (type.basetype == SPIRType::Image && type.image.sampled == 1)) - return true; - } - return false; -} - -bool CompilerGLSL::optimize_read_modify_write(const string &lhs, const string &rhs) -{ - // Do this with strings because we have a very clear pattern we can check for and it avoids - // adding lots of special cases to the code emission. - if (rhs.size() < lhs.size() + 3) - return false; - - auto index = rhs.find(lhs); - if (index != 0) - return false; - - // TODO: Shift operators, but it's not important for now. - auto op = rhs.find_first_of("+-/*%|&^", lhs.size() + 1); - if (op != lhs.size() + 1) - return false; - - // Check that the op is followed by space. This excludes && and ||. - if (rhs[op + 1] != ' ') - return false; - - char bop = rhs[op]; - auto expr = rhs.substr(lhs.size() + 3); - // Try to find increments and decrements. Makes it look neater as += 1, -= 1 is fairly rare to see in real code. - // Find some common patterns which are equivalent. - if ((bop == '+' || bop == '-') && (expr == "1" || expr == "uint(1)" || expr == "1u" || expr == "int(1u)")) - statement(lhs, bop, bop, ";"); - else - statement(lhs, " ", bop, "= ", expr, ";"); - return true; -} - -void CompilerGLSL::emit_block_instructions(const SPIRBlock &block) -{ - current_emitting_block = █ - for (auto &op : block.ops) - emit_instruction(op); - current_emitting_block = nullptr; -} - -void CompilerGLSL::emit_instruction(const Instruction &instruction) -{ - auto ops = stream(instruction); - auto opcode = static_cast(instruction.op); - uint32_t length = instruction.length; - -#define BOP(op) emit_binary_op(ops[0], ops[1], ops[2], ops[3], #op) -#define BOP_CAST(op, type) \ - emit_binary_op_cast(ops[0], ops[1], ops[2], ops[3], #op, type, opcode_is_sign_invariant(opcode)) -#define UOP(op) emit_unary_op(ops[0], ops[1], ops[2], #op) -#define QFOP(op) emit_quaternary_func_op(ops[0], ops[1], ops[2], ops[3], ops[4], ops[5], #op) -#define TFOP(op) emit_trinary_func_op(ops[0], ops[1], ops[2], ops[3], ops[4], #op) -#define BFOP(op) emit_binary_func_op(ops[0], ops[1], ops[2], ops[3], #op) -#define BFOP_CAST(op, type) \ - emit_binary_func_op_cast(ops[0], ops[1], ops[2], ops[3], #op, type, opcode_is_sign_invariant(opcode)) -#define BFOP(op) emit_binary_func_op(ops[0], ops[1], ops[2], ops[3], #op) -#define UFOP(op) emit_unary_func_op(ops[0], ops[1], ops[2], #op) - - switch (opcode) - { - // Dealing with memory - case OpLoad: - { - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - uint32_t ptr = ops[2]; - - flush_variable_declaration(ptr); - - // If we're loading from memory that cannot be changed by the shader, - // just forward the expression directly to avoid needless temporaries. - // If an expression is mutable and forwardable, we speculate that it is immutable. - bool forward = should_forward(ptr) && forced_temporaries.find(id) == end(forced_temporaries); - - // If loading a non-native row-major matrix, mark the expression as need_transpose. - bool need_transpose = false; - bool old_need_transpose = false; - - auto *ptr_expression = maybe_get(ptr); - if (ptr_expression && ptr_expression->need_transpose) - { - old_need_transpose = true; - ptr_expression->need_transpose = false; - need_transpose = true; - } - else if (is_non_native_row_major_matrix(ptr)) - need_transpose = true; - - auto expr = to_expression(ptr); - - if (ptr_expression) - ptr_expression->need_transpose = old_need_transpose; - - // Suppress usage tracking since using same expression multiple times does not imply any extra work. - auto &e = emit_op(result_type, id, expr, forward, true); - e.need_transpose = need_transpose; - register_read(id, ptr, forward); - - // Pass through whether the result is of a packed type. - if (has_decoration(ptr, DecorationCPacked)) - set_decoration(id, DecorationCPacked); - - break; - } - - case OpInBoundsAccessChain: - case OpAccessChain: - { - auto *var = maybe_get(ops[2]); - if (var) - flush_variable_declaration(var->self); - - // If the base is immutable, the access chain pointer must also be. - // If an expression is mutable and forwardable, we speculate that it is immutable. - bool need_transpose, result_is_packed; - auto e = access_chain(ops[2], &ops[3], length - 3, get(ops[0]), &need_transpose, &result_is_packed); - auto &expr = set(ops[1], move(e), ops[0], should_forward(ops[2])); - expr.loaded_from = ops[2]; - expr.need_transpose = need_transpose; - - // Mark the result as being packed. Some platforms handled packed vectors differently than non-packed. - if (result_is_packed) - set_decoration(ops[1], DecorationCPacked); - else - unset_decoration(ops[1], DecorationCPacked); - - break; - } - - case OpStore: - { - auto *var = maybe_get(ops[0]); - - if (var && var->statically_assigned) - var->static_expression = ops[1]; - else if (var && var->loop_variable && !var->loop_variable_enable) - var->static_expression = ops[1]; - else if (var && flattened_structs.count(ops[0])) - { - store_flattened_struct(*var, ops[1]); - register_write(ops[0]); - } - else - { - auto rhs = to_expression(ops[1]); - // Statements to OpStore may be empty if it is a struct with zero members. Just forward the store to /dev/null. - if (!rhs.empty()) - { - auto lhs = to_expression(ops[0]); - - // Tries to optimize assignments like " = op expr". - // While this is purely cosmetic, this is important for legacy ESSL where loop - // variable increments must be in either i++ or i += const-expr. - // Without this, we end up with i = i + 1, which is correct GLSL, but not correct GLES 2.0. - if (!optimize_read_modify_write(lhs, rhs)) - statement(lhs, " = ", rhs, ";"); - register_write(ops[0]); - } - } - break; - } - - case OpArrayLength: - { - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - auto e = access_chain_internal(ops[2], &ops[3], length - 3, true); - set(id, e + ".length()", result_type, true); - break; - } - - // Function calls - case OpFunctionCall: - { - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - uint32_t func = ops[2]; - const auto *arg = &ops[3]; - length -= 3; - - auto &callee = get(func); - bool pure = function_is_pure(callee); - - bool callee_has_out_variables = false; - - // Invalidate out variables passed to functions since they can be OpStore'd to. - for (uint32_t i = 0; i < length; i++) - { - if (callee.arguments[i].write_count) - { - register_call_out_argument(arg[i]); - callee_has_out_variables = true; - } - - flush_variable_declaration(arg[i]); - } - - if (!pure) - register_impure_function_call(); - - string funexpr; - vector arglist; - funexpr += to_name(func) + "("; - for (uint32_t i = 0; i < length; i++) - { - // Do not pass in separate images or samplers if we're remapping - // to combined image samplers. - if (skip_argument(arg[i])) - continue; - - arglist.push_back(to_func_call_arg(arg[i])); - } - - for (auto &combined : callee.combined_parameters) - { - uint32_t image_id = combined.global_image ? combined.image_id : arg[combined.image_id]; - uint32_t sampler_id = combined.global_sampler ? combined.sampler_id : arg[combined.sampler_id]; - - auto *image = maybe_get_backing_variable(image_id); - if (image) - image_id = image->self; - - auto *samp = maybe_get_backing_variable(sampler_id); - if (samp) - sampler_id = samp->self; - - arglist.push_back(to_combined_image_sampler(image_id, sampler_id)); - } - - append_global_func_args(callee, length, arglist); - - funexpr += merge(arglist); - funexpr += ")"; - - // Check for function call constraints. - check_function_call_constraints(arg, length); - - if (get(result_type).basetype != SPIRType::Void) - { - // If the function actually writes to an out variable, - // take the conservative route and do not forward. - // The problem is that we might not read the function - // result (and emit the function) before an out variable - // is read (common case when return value is ignored! - // In order to avoid start tracking invalid variables, - // just avoid the forwarding problem altogether. - bool forward = args_will_forward(id, arg, length, pure) && !callee_has_out_variables && pure && - (forced_temporaries.find(id) == end(forced_temporaries)); - - emit_op(result_type, id, funexpr, forward); - - // Function calls are implicit loads from all variables in question. - // Set dependencies for them. - for (uint32_t i = 0; i < length; i++) - register_read(id, arg[i], forward); - - // If we're going to forward the temporary result, - // put dependencies on every variable that must not change. - if (forward) - register_global_read_dependencies(callee, id); - } - else - statement(funexpr, ";"); - - break; - } - - // Composite munging - case OpCompositeConstruct: - { - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - const auto *elems = &ops[2]; - length -= 2; - - bool forward = true; - for (uint32_t i = 0; i < length; i++) - forward = forward && should_forward(elems[i]); - - auto &out_type = get(result_type); - - if (!length) - { - if (out_type.basetype == SPIRType::Struct) - { - // It is technically allowed to make a blank struct, - // but we cannot make a meaningful expression out of it in high level languages, - // so make it a blank expression. - emit_op(result_type, id, "", forward); - break; - } - else - SPIRV_CROSS_THROW("Invalid input to OpCompositeConstruct."); - } - - auto &in_type = expression_type(elems[0]); - - // Only splat if we have vector constructors. - // Arrays and structs must be initialized properly in full. - bool composite = !out_type.array.empty() || out_type.basetype == SPIRType::Struct; - bool splat = in_type.vecsize == 1 && in_type.columns == 1 && !composite && backend.use_constructor_splatting; - bool swizzle_splat = in_type.vecsize == 1 && in_type.columns == 1 && backend.can_swizzle_scalar; - - if (ids[elems[0]].get_type() == TypeConstant && - (in_type.basetype != SPIRType::Float && in_type.basetype != SPIRType::Double)) - { - // Cannot swizzle literal integers as a special case. - swizzle_splat = false; - } - - if (splat || swizzle_splat) - { - uint32_t input = elems[0]; - for (uint32_t i = 0; i < length; i++) - { - if (input != elems[i]) - { - splat = false; - swizzle_splat = false; - } - } - } - - if (out_type.basetype == SPIRType::Struct && !backend.can_declare_struct_inline) - forward = false; - - string constructor_op; - if (backend.use_initializer_list && composite) - { - // Only use this path if we are building composites. - // This path cannot be used for arithmetic. - if (backend.use_typed_initializer_list) - constructor_op += type_to_glsl_constructor(get(result_type)); - constructor_op += "{ "; - if (splat) - constructor_op += to_expression(elems[0]); - else - constructor_op += build_composite_combiner(result_type, elems, length); - constructor_op += " }"; - } - else if (swizzle_splat && !composite) - { - constructor_op = remap_swizzle(get(result_type), 1, to_expression(elems[0])); - } - else - { - constructor_op = type_to_glsl_constructor(get(result_type)) + "("; - if (splat) - constructor_op += to_expression(elems[0]); - else - constructor_op += build_composite_combiner(result_type, elems, length); - constructor_op += ")"; - } - - emit_op(result_type, id, constructor_op, forward); - break; - } - - case OpVectorInsertDynamic: - { - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - uint32_t vec = ops[2]; - uint32_t comp = ops[3]; - uint32_t index = ops[4]; - - flush_variable_declaration(vec); - - // Make a copy, then use access chain to store the variable. - statement(declare_temporary(result_type, id), to_expression(vec), ";"); - set(id, to_name(id), result_type, true); - auto chain = access_chain_internal(id, &index, 1, false); - statement(chain, " = ", to_expression(comp), ";"); - break; - } - - case OpVectorExtractDynamic: - { - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - - auto expr = access_chain_internal(ops[2], &ops[3], 1, false); - emit_op(result_type, id, expr, should_forward(ops[2])); - break; - } - - case OpCompositeExtract: - { - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - length -= 3; - - auto &type = get(result_type); - - // We can only split the expression here if our expression is forwarded as a temporary. - bool allow_base_expression = forced_temporaries.find(id) == end(forced_temporaries); - - // Do not allow base expression for struct members. We risk doing "swizzle" optimizations in this case. - auto &composite_type = expression_type(ops[2]); - if (composite_type.basetype == SPIRType::Struct || !composite_type.array.empty()) - allow_base_expression = false; - - // Only apply this optimization if result is scalar. - if (allow_base_expression && should_forward(ops[2]) && type.vecsize == 1 && type.columns == 1 && length == 1) - { - // We want to split the access chain from the base. - // This is so we can later combine different CompositeExtract results - // with CompositeConstruct without emitting code like - // - // vec3 temp = texture(...).xyz - // vec4(temp.x, temp.y, temp.z, 1.0). - // - // when we actually wanted to emit this - // vec4(texture(...).xyz, 1.0). - // - // Including the base will prevent this and would trigger multiple reads - // from expression causing it to be forced to an actual temporary in GLSL. - auto expr = access_chain_internal(ops[2], &ops[3], length, true, true); - auto &e = emit_op(result_type, id, expr, true, !expression_is_forwarded(ops[2])); - e.base_expression = ops[2]; - } - else - { - auto expr = access_chain_internal(ops[2], &ops[3], length, true); - emit_op(result_type, id, expr, should_forward(ops[2]), !expression_is_forwarded(ops[2])); - } - break; - } - - case OpCompositeInsert: - { - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - uint32_t obj = ops[2]; - uint32_t composite = ops[3]; - const auto *elems = &ops[4]; - length -= 4; - - flush_variable_declaration(composite); - - // Make a copy, then use access chain to store the variable. - statement(declare_temporary(result_type, id), to_expression(composite), ";"); - set(id, to_name(id), result_type, true); - auto chain = access_chain_internal(id, elems, length, true); - statement(chain, " = ", to_expression(obj), ";"); - - break; - } - - case OpCopyMemory: - { - uint32_t lhs = ops[0]; - uint32_t rhs = ops[1]; - if (lhs != rhs) - { - flush_variable_declaration(lhs); - flush_variable_declaration(rhs); - statement(to_expression(lhs), " = ", to_expression(rhs), ";"); - register_write(lhs); - } - break; - } - - case OpCopyObject: - { - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - uint32_t rhs = ops[2]; - bool pointer = get(result_type).pointer; - - if (expression_is_lvalue(rhs) && !pointer) - { - // Need a copy. - // For pointer types, we copy the pointer itself. - statement(declare_temporary(result_type, id), to_expression(rhs), ";"); - set(id, to_name(id), result_type, true); - } - else - { - // RHS expression is immutable, so just forward it. - // Copying these things really make no sense, but - // seems to be allowed anyways. - auto &e = set(id, to_expression(rhs), result_type, true); - if (pointer) - { - auto *var = maybe_get_backing_variable(rhs); - e.loaded_from = var ? var->self : 0; - } - } - break; - } - - case OpVectorShuffle: - { - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - uint32_t vec0 = ops[2]; - uint32_t vec1 = ops[3]; - const auto *elems = &ops[4]; - length -= 4; - - auto &type0 = expression_type(vec0); - - bool shuffle = false; - for (uint32_t i = 0; i < length; i++) - if (elems[i] >= type0.vecsize) - shuffle = true; - - string expr; - bool should_fwd, trivial_forward; - - if (shuffle) - { - should_fwd = should_forward(vec0) && should_forward(vec1); - trivial_forward = !expression_is_forwarded(vec0) && !expression_is_forwarded(vec1); - - // Constructor style and shuffling from two different vectors. - vector args; - for (uint32_t i = 0; i < length; i++) - { - if (elems[i] >= type0.vecsize) - args.push_back(join(to_enclosed_expression(vec1), ".", index_to_swizzle(elems[i] - type0.vecsize))); - else - args.push_back(join(to_enclosed_expression(vec0), ".", index_to_swizzle(elems[i]))); - } - expr += join(type_to_glsl_constructor(get(result_type)), "(", merge(args), ")"); - } - else - { - should_fwd = should_forward(vec0); - trivial_forward = !expression_is_forwarded(vec0); - - // We only source from first vector, so can use swizzle. - // If the vector is packed, unpack it before applying a swizzle (needed for MSL) - expr += to_enclosed_expression(vec0); - if (has_decoration(vec0, DecorationCPacked)) - expr = unpack_expression_type(expr, expression_type(vec0)); - - expr += "."; - for (uint32_t i = 0; i < length; i++) - expr += index_to_swizzle(elems[i]); - - if (backend.swizzle_is_function && length > 1) - expr += "()"; - } - - // A shuffle is trivial in that it doesn't actually *do* anything. - // We inherit the forwardedness from our arguments to avoid flushing out to temporaries when it's not really needed. - - emit_op(result_type, id, expr, should_fwd, trivial_forward); - break; - } - - // ALU - case OpIsNan: - UFOP(isnan); - break; - - case OpIsInf: - UFOP(isinf); - break; - - case OpSNegate: - case OpFNegate: - UOP(-); - break; - - case OpIAdd: - { - // For simple arith ops, prefer the output type if there's a mismatch to avoid extra bitcasts. - auto type = get(ops[0]).basetype; - BOP_CAST(+, type); - break; - } - - case OpFAdd: - BOP(+); - break; - - case OpISub: - { - auto type = get(ops[0]).basetype; - BOP_CAST(-, type); - break; - } - - case OpFSub: - BOP(-); - break; - - case OpIMul: - { - auto type = get(ops[0]).basetype; - BOP_CAST(*, type); - break; - } - - case OpVectorTimesMatrix: - case OpMatrixTimesVector: - { - // If the matrix needs transpose, just flip the multiply order. - auto *e = maybe_get(ops[opcode == OpMatrixTimesVector ? 2 : 3]); - if (e && e->need_transpose) - { - e->need_transpose = false; - emit_binary_op(ops[0], ops[1], ops[3], ops[2], "*"); - e->need_transpose = true; - } - else - BOP(*); - break; - } - - case OpFMul: - case OpMatrixTimesScalar: - case OpVectorTimesScalar: - case OpMatrixTimesMatrix: - BOP(*); - break; - - case OpOuterProduct: - BFOP(outerProduct); - break; - - case OpDot: - BFOP(dot); - break; - - case OpTranspose: - UFOP(transpose); - break; - - case OpSDiv: - BOP_CAST(/, SPIRType::Int); - break; - - case OpUDiv: - BOP_CAST(/, SPIRType::UInt); - break; - - case OpFDiv: - BOP(/); - break; - - case OpShiftRightLogical: - BOP_CAST(>>, SPIRType::UInt); - break; - - case OpShiftRightArithmetic: - BOP_CAST(>>, SPIRType::Int); - break; - - case OpShiftLeftLogical: - { - auto type = get(ops[0]).basetype; - BOP_CAST(<<, type); - break; - } - - case OpBitwiseOr: - { - auto type = get(ops[0]).basetype; - BOP_CAST(|, type); - break; - } - - case OpBitwiseXor: - { - auto type = get(ops[0]).basetype; - BOP_CAST (^, type); - break; - } - - case OpBitwiseAnd: - { - auto type = get(ops[0]).basetype; - BOP_CAST(&, type); - break; - } - - case OpNot: - UOP(~); - break; - - case OpUMod: - BOP_CAST(%, SPIRType::UInt); - break; - - case OpSMod: - BOP_CAST(%, SPIRType::Int); - break; - - case OpFMod: - BFOP(mod); - break; - - // Relational - case OpAny: - UFOP(any); - break; - - case OpAll: - UFOP(all); - break; - - case OpSelect: - emit_mix_op(ops[0], ops[1], ops[4], ops[3], ops[2]); - break; - - case OpLogicalOr: - { - // No vector variant in GLSL for logical OR. - auto result_type = ops[0]; - auto id = ops[1]; - auto &type = get(result_type); - - if (type.vecsize > 1) - emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "||"); - else - BOP(||); - break; - } - - case OpLogicalAnd: - { - // No vector variant in GLSL for logical AND. - auto result_type = ops[0]; - auto id = ops[1]; - auto &type = get(result_type); - - if (type.vecsize > 1) - emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "&&"); - else - BOP(&&); - break; - } - - case OpLogicalNot: - { - auto &type = get(ops[0]); - if (type.vecsize > 1) - UFOP(not); - else - UOP(!); - break; - } - - case OpIEqual: - { - if (expression_type(ops[2]).vecsize > 1) - BFOP_CAST(equal, SPIRType::Int); - else - BOP_CAST(==, SPIRType::Int); - break; - } - - case OpLogicalEqual: - case OpFOrdEqual: - { - if (expression_type(ops[2]).vecsize > 1) - BFOP(equal); - else - BOP(==); - break; - } - - case OpINotEqual: - { - if (expression_type(ops[2]).vecsize > 1) - BFOP_CAST(notEqual, SPIRType::Int); - else - BOP_CAST(!=, SPIRType::Int); - break; - } - - case OpLogicalNotEqual: - case OpFOrdNotEqual: - { - if (expression_type(ops[2]).vecsize > 1) - BFOP(notEqual); - else - BOP(!=); - break; - } - - case OpUGreaterThan: - case OpSGreaterThan: - { - auto type = opcode == OpUGreaterThan ? SPIRType::UInt : SPIRType::Int; - if (expression_type(ops[2]).vecsize > 1) - BFOP_CAST(greaterThan, type); - else - BOP_CAST(>, type); - break; - } - - case OpFOrdGreaterThan: - { - if (expression_type(ops[2]).vecsize > 1) - BFOP(greaterThan); - else - BOP(>); - break; - } - - case OpUGreaterThanEqual: - case OpSGreaterThanEqual: - { - auto type = opcode == OpUGreaterThanEqual ? SPIRType::UInt : SPIRType::Int; - if (expression_type(ops[2]).vecsize > 1) - BFOP_CAST(greaterThanEqual, type); - else - BOP_CAST(>=, type); - break; - } - - case OpFOrdGreaterThanEqual: - { - if (expression_type(ops[2]).vecsize > 1) - BFOP(greaterThanEqual); - else - BOP(>=); - break; - } - - case OpULessThan: - case OpSLessThan: - { - auto type = opcode == OpULessThan ? SPIRType::UInt : SPIRType::Int; - if (expression_type(ops[2]).vecsize > 1) - BFOP_CAST(lessThan, type); - else - BOP_CAST(<, type); - break; - } - - case OpFOrdLessThan: - { - if (expression_type(ops[2]).vecsize > 1) - BFOP(lessThan); - else - BOP(<); - break; - } - - case OpULessThanEqual: - case OpSLessThanEqual: - { - auto type = opcode == OpULessThanEqual ? SPIRType::UInt : SPIRType::Int; - if (expression_type(ops[2]).vecsize > 1) - BFOP_CAST(lessThanEqual, type); - else - BOP_CAST(<=, type); - break; - } - - case OpFOrdLessThanEqual: - { - if (expression_type(ops[2]).vecsize > 1) - BFOP(lessThanEqual); - else - BOP(<=); - break; - } - - // Conversion - case OpConvertFToU: - case OpConvertFToS: - case OpConvertSToF: - case OpConvertUToF: - case OpUConvert: - case OpSConvert: - case OpFConvert: - { - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - - auto func = type_to_glsl_constructor(get(result_type)); - emit_unary_func_op(result_type, id, ops[2], func.c_str()); - break; - } - - case OpBitcast: - { - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - uint32_t arg = ops[2]; - - auto op = bitcast_glsl_op(get(result_type), expression_type(arg)); - emit_unary_func_op(result_type, id, arg, op.c_str()); - break; - } - - case OpQuantizeToF16: - { - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - uint32_t arg = ops[2]; - - string op; - auto &type = get(result_type); - - switch (type.vecsize) - { - case 1: - op = join("unpackHalf2x16(packHalf2x16(vec2(", to_expression(arg), "))).x"); - break; - case 2: - op = join("unpackHalf2x16(packHalf2x16(", to_expression(arg), "))"); - break; - case 3: - { - auto op0 = join("unpackHalf2x16(packHalf2x16(", to_expression(arg), ".xy))"); - auto op1 = join("unpackHalf2x16(packHalf2x16(", to_expression(arg), ".zz)).x"); - op = join("vec3(", op0, ", ", op1, ")"); - break; - } - case 4: - { - auto op0 = join("unpackHalf2x16(packHalf2x16(", to_expression(arg), ".xy))"); - auto op1 = join("unpackHalf2x16(packHalf2x16(", to_expression(arg), ".zw))"); - op = join("vec4(", op0, ", ", op1, ")"); - break; - } - default: - SPIRV_CROSS_THROW("Illegal argument to OpQuantizeToF16."); - } - - emit_op(result_type, id, op, should_forward(arg)); - break; - } - - // Derivatives - case OpDPdx: - UFOP(dFdx); - if (is_legacy_es()) - require_extension("GL_OES_standard_derivatives"); - break; - - case OpDPdy: - UFOP(dFdy); - if (is_legacy_es()) - require_extension("GL_OES_standard_derivatives"); - break; - - case OpDPdxFine: - UFOP(dFdxFine); - if (options.es) - { - SPIRV_CROSS_THROW("GL_ARB_derivative_control is unavailable in OpenGL ES."); - } - if (options.version < 450) - require_extension("GL_ARB_derivative_control"); - break; - - case OpDPdyFine: - UFOP(dFdyFine); - if (options.es) - { - SPIRV_CROSS_THROW("GL_ARB_derivative_control is unavailable in OpenGL ES."); - } - if (options.version < 450) - require_extension("GL_ARB_derivative_control"); - break; - - case OpDPdxCoarse: - if (options.es) - { - SPIRV_CROSS_THROW("GL_ARB_derivative_control is unavailable in OpenGL ES."); - } - UFOP(dFdxCoarse); - if (options.version < 450) - require_extension("GL_ARB_derivative_control"); - break; - - case OpDPdyCoarse: - UFOP(dFdyCoarse); - if (options.es) - { - SPIRV_CROSS_THROW("GL_ARB_derivative_control is unavailable in OpenGL ES."); - } - if (options.version < 450) - require_extension("GL_ARB_derivative_control"); - break; - - case OpFwidth: - UFOP(fwidth); - if (is_legacy_es()) - require_extension("GL_OES_standard_derivatives"); - break; - - // Bitfield - case OpBitFieldInsert: - // TODO: The signedness of inputs is strict in GLSL, but not in SPIR-V, bitcast if necessary. - QFOP(bitfieldInsert); - break; - - case OpBitFieldSExtract: - case OpBitFieldUExtract: - // TODO: The signedness of inputs is strict in GLSL, but not in SPIR-V, bitcast if necessary. - TFOP(bitfieldExtract); - break; - - case OpBitReverse: - UFOP(bitfieldReverse); - break; - - case OpBitCount: - UFOP(bitCount); - break; - - // Atomics - case OpAtomicExchange: - { - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - uint32_t ptr = ops[2]; - // Ignore semantics for now, probably only relevant to CL. - uint32_t val = ops[5]; - const char *op = check_atomic_image(ptr) ? "imageAtomicExchange" : "atomicExchange"; - forced_temporaries.insert(id); - emit_binary_func_op(result_type, id, ptr, val, op); - flush_all_atomic_capable_variables(); - break; - } - - case OpAtomicCompareExchange: - { - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - uint32_t ptr = ops[2]; - uint32_t val = ops[6]; - uint32_t comp = ops[7]; - const char *op = check_atomic_image(ptr) ? "imageAtomicCompSwap" : "atomicCompSwap"; - - forced_temporaries.insert(id); - emit_trinary_func_op(result_type, id, ptr, comp, val, op); - flush_all_atomic_capable_variables(); - break; - } - - case OpAtomicLoad: - flush_all_atomic_capable_variables(); - // FIXME: Image? - // OpAtomicLoad seems to only be relevant for atomic counters. - UFOP(atomicCounter); - register_read(ops[1], ops[2], should_forward(ops[2])); - break; - - case OpAtomicStore: - SPIRV_CROSS_THROW("Unsupported opcode OpAtomicStore."); - - case OpAtomicIIncrement: - forced_temporaries.insert(ops[1]); - // FIXME: Image? - UFOP(atomicCounterIncrement); - flush_all_atomic_capable_variables(); - register_read(ops[1], ops[2], should_forward(ops[2])); - break; - - case OpAtomicIDecrement: - forced_temporaries.insert(ops[1]); - // FIXME: Image? - UFOP(atomicCounterDecrement); - flush_all_atomic_capable_variables(); - register_read(ops[1], ops[2], should_forward(ops[2])); - break; - - case OpAtomicIAdd: - { - const char *op = check_atomic_image(ops[2]) ? "imageAtomicAdd" : "atomicAdd"; - forced_temporaries.insert(ops[1]); - emit_binary_func_op(ops[0], ops[1], ops[2], ops[5], op); - flush_all_atomic_capable_variables(); - register_read(ops[1], ops[2], should_forward(ops[2])); - break; - } - - case OpAtomicISub: - { - const char *op = check_atomic_image(ops[2]) ? "imageAtomicAdd" : "atomicAdd"; - forced_temporaries.insert(ops[1]); - auto expr = join(op, "(", to_expression(ops[2]), ", -", to_enclosed_expression(ops[5]), ")"); - emit_op(ops[0], ops[1], expr, should_forward(ops[2]) && should_forward(ops[5])); - flush_all_atomic_capable_variables(); - register_read(ops[1], ops[2], should_forward(ops[2])); - break; - } - - case OpAtomicSMin: - case OpAtomicUMin: - { - const char *op = check_atomic_image(ops[2]) ? "imageAtomicMin" : "atomicMin"; - forced_temporaries.insert(ops[1]); - emit_binary_func_op(ops[0], ops[1], ops[2], ops[5], op); - flush_all_atomic_capable_variables(); - register_read(ops[1], ops[2], should_forward(ops[2])); - break; - } - - case OpAtomicSMax: - case OpAtomicUMax: - { - const char *op = check_atomic_image(ops[2]) ? "imageAtomicMax" : "atomicMax"; - forced_temporaries.insert(ops[1]); - emit_binary_func_op(ops[0], ops[1], ops[2], ops[5], op); - flush_all_atomic_capable_variables(); - register_read(ops[1], ops[2], should_forward(ops[2])); - break; - } - - case OpAtomicAnd: - { - const char *op = check_atomic_image(ops[2]) ? "imageAtomicAnd" : "atomicAnd"; - forced_temporaries.insert(ops[1]); - emit_binary_func_op(ops[0], ops[1], ops[2], ops[5], op); - flush_all_atomic_capable_variables(); - register_read(ops[1], ops[2], should_forward(ops[2])); - break; - } - - case OpAtomicOr: - { - const char *op = check_atomic_image(ops[2]) ? "imageAtomicOr" : "atomicOr"; - forced_temporaries.insert(ops[1]); - emit_binary_func_op(ops[0], ops[1], ops[2], ops[5], op); - flush_all_atomic_capable_variables(); - register_read(ops[1], ops[2], should_forward(ops[2])); - break; - } - - case OpAtomicXor: - { - const char *op = check_atomic_image(ops[2]) ? "imageAtomicXor" : "atomicXor"; - forced_temporaries.insert(ops[1]); - emit_binary_func_op(ops[0], ops[1], ops[2], ops[5], op); - flush_all_atomic_capable_variables(); - register_read(ops[1], ops[2], should_forward(ops[2])); - break; - } - - // Geometry shaders - case OpEmitVertex: - statement("EmitVertex();"); - break; - - case OpEndPrimitive: - statement("EndPrimitive();"); - break; - - case OpEmitStreamVertex: - statement("EmitStreamVertex();"); - break; - - case OpEndStreamPrimitive: - statement("EndStreamPrimitive();"); - break; - - // Textures - case OpImageSampleExplicitLod: - case OpImageSampleProjExplicitLod: - case OpImageSampleDrefExplicitLod: - case OpImageSampleProjDrefExplicitLod: - case OpImageSampleImplicitLod: - case OpImageSampleProjImplicitLod: - case OpImageSampleDrefImplicitLod: - case OpImageSampleProjDrefImplicitLod: - case OpImageFetch: - case OpImageGather: - case OpImageDrefGather: - // Gets a bit hairy, so move this to a separate instruction. - emit_texture_op(instruction); - break; - - case OpImage: - { - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - auto &e = emit_op(result_type, id, to_expression(ops[2]), true); - - // When using the image, we need to know which variable it is actually loaded from. - auto *var = maybe_get_backing_variable(ops[2]); - e.loaded_from = var ? var->self : 0; - break; - } - - case OpImageQueryLod: - { - if (!options.es && options.version < 400) - { - require_extension("GL_ARB_texture_query_lod"); - // For some reason, the ARB spec is all-caps. - BFOP(textureQueryLOD); - } - else if (options.es) - SPIRV_CROSS_THROW("textureQueryLod not supported in ES profile."); - else - BFOP(textureQueryLod); - break; - } - - case OpImageQueryLevels: - { - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - - if (!options.es && options.version < 430) - require_extension("GL_ARB_texture_query_levels"); - if (options.es) - SPIRV_CROSS_THROW("textureQueryLevels not supported in ES profile."); - - auto expr = join("textureQueryLevels(", to_expression(ops[2]), ")"); - auto &restype = get(ops[0]); - expr = bitcast_expression(restype, SPIRType::Int, expr); - emit_op(result_type, id, expr, true); - break; - } - - case OpImageQuerySamples: - { - auto &type = expression_type(ops[2]); - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - - string expr; - if (type.image.sampled == 2) - expr = join("imageSamples(", to_expression(ops[2]), ")"); - else - expr = join("textureSamples(", to_expression(ops[2]), ")"); - - auto &restype = get(ops[0]); - expr = bitcast_expression(restype, SPIRType::Int, expr); - emit_op(result_type, id, expr, true); - break; - } - - case OpSampledImage: - { - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - emit_sampled_image_op(result_type, id, ops[2], ops[3]); - break; - } - - case OpImageQuerySizeLod: - { - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - - auto expr = join("textureSize(", to_expression(ops[2]), ", ", bitcast_expression(SPIRType::Int, ops[3]), ")"); - auto &restype = get(ops[0]); - expr = bitcast_expression(restype, SPIRType::Int, expr); - emit_op(result_type, id, expr, true); - break; - } - - // Image load/store - case OpImageRead: - { - // We added Nonreadable speculatively to the OpImage variable due to glslangValidator - // not adding the proper qualifiers. - // If it turns out we need to read the image after all, remove the qualifier and recompile. - auto *var = maybe_get_backing_variable(ops[2]); - if (var) - { - auto &flags = meta.at(var->self).decoration.decoration_flags; - if (flags & (1ull << DecorationNonReadable)) - { - flags &= ~(1ull << DecorationNonReadable); - force_recompile = true; - } - } - - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - - bool pure; - string imgexpr; - auto &type = expression_type(ops[2]); - - if (var && var->remapped_variable) // Remapped input, just read as-is without any op-code - { - if (type.image.ms) - SPIRV_CROSS_THROW("Trying to remap multisampled image to variable, this is not possible."); - - auto itr = - find_if(begin(pls_inputs), end(pls_inputs), [var](const PlsRemap &pls) { return pls.id == var->self; }); - - if (itr == end(pls_inputs)) - { - // For non-PLS inputs, we rely on subpass type remapping information to get it right - // since ImageRead always returns 4-component vectors and the backing type is opaque. - if (!var->remapped_components) - SPIRV_CROSS_THROW("subpassInput was remapped, but remap_components is not set correctly."); - imgexpr = remap_swizzle(get(result_type), var->remapped_components, to_expression(ops[2])); - } - else - { - // PLS input could have different number of components than what the SPIR expects, swizzle to - // the appropriate vector size. - uint32_t components = pls_format_to_components(itr->format); - imgexpr = remap_swizzle(get(result_type), components, to_expression(ops[2])); - } - pure = true; - } - else if (type.image.dim == DimSubpassData) - { - if (options.vulkan_semantics) - { - // With Vulkan semantics, use the proper Vulkan GLSL construct. - if (type.image.ms) - { - uint32_t operands = ops[4]; - if (operands != ImageOperandsSampleMask || length != 6) - SPIRV_CROSS_THROW( - "Multisampled image used in OpImageRead, but unexpected operand mask was used."); - - uint32_t samples = ops[5]; - imgexpr = join("subpassLoad(", to_expression(ops[2]), ", ", to_expression(samples), ")"); - } - else - imgexpr = join("subpassLoad(", to_expression(ops[2]), ")"); - } - else - { - if (type.image.ms) - { - uint32_t operands = ops[4]; - if (operands != ImageOperandsSampleMask || length != 6) - SPIRV_CROSS_THROW( - "Multisampled image used in OpImageRead, but unexpected operand mask was used."); - - uint32_t samples = ops[5]; - imgexpr = join("texelFetch(", to_expression(ops[2]), ", ivec2(gl_FragCoord.xy), ", - to_expression(samples), ")"); - } - else - { - // Implement subpass loads via texture barrier style sampling. - imgexpr = join("texelFetch(", to_expression(ops[2]), ", ivec2(gl_FragCoord.xy), 0)"); - } - } - imgexpr = remap_swizzle(get(result_type), 4, imgexpr); - pure = true; - } - else - { - // imageLoad only accepts int coords, not uint. - auto coord_expr = to_expression(ops[3]); - auto target_coord_type = expression_type(ops[3]); - target_coord_type.basetype = SPIRType::Int; - coord_expr = bitcast_expression(target_coord_type, expression_type(ops[3]).basetype, coord_expr); - - // Plain image load/store. - if (type.image.ms) - { - uint32_t operands = ops[4]; - if (operands != ImageOperandsSampleMask || length != 6) - SPIRV_CROSS_THROW("Multisampled image used in OpImageRead, but unexpected operand mask was used."); - - uint32_t samples = ops[5]; - imgexpr = - join("imageLoad(", to_expression(ops[2]), ", ", coord_expr, ", ", to_expression(samples), ")"); - } - else - imgexpr = join("imageLoad(", to_expression(ops[2]), ", ", coord_expr, ")"); - - imgexpr = remap_swizzle(get(result_type), 4, imgexpr); - pure = false; - } - - if (var && var->forwardable) - { - bool forward = forced_temporaries.find(id) == end(forced_temporaries); - auto &e = emit_op(result_type, id, imgexpr, forward); - - // We only need to track dependencies if we're reading from image load/store. - if (!pure) - { - e.loaded_from = var->self; - if (forward) - var->dependees.push_back(id); - } - } - else - emit_op(result_type, id, imgexpr, false); - break; - } - - case OpImageTexelPointer: - { - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - auto &e = set(id, join(to_expression(ops[2]), ", ", to_expression(ops[3])), result_type, true); - - // When using the pointer, we need to know which variable it is actually loaded from. - auto *var = maybe_get_backing_variable(ops[2]); - e.loaded_from = var ? var->self : 0; - break; - } - - case OpImageWrite: - { - // We added Nonwritable speculatively to the OpImage variable due to glslangValidator - // not adding the proper qualifiers. - // If it turns out we need to write to the image after all, remove the qualifier and recompile. - auto *var = maybe_get_backing_variable(ops[0]); - if (var) - { - auto &flags = meta.at(var->self).decoration.decoration_flags; - if (flags & (1ull << DecorationNonWritable)) - { - flags &= ~(1ull << DecorationNonWritable); - force_recompile = true; - } - } - - auto &type = expression_type(ops[0]); - auto &value_type = expression_type(ops[2]); - auto store_type = value_type; - store_type.vecsize = 4; - - // imageStore only accepts int coords, not uint. - auto coord_expr = to_expression(ops[1]); - auto target_coord_type = expression_type(ops[1]); - target_coord_type.basetype = SPIRType::Int; - coord_expr = bitcast_expression(target_coord_type, expression_type(ops[1]).basetype, coord_expr); - - if (type.image.ms) - { - uint32_t operands = ops[3]; - if (operands != ImageOperandsSampleMask || length != 5) - SPIRV_CROSS_THROW("Multisampled image used in OpImageWrite, but unexpected operand mask was used."); - uint32_t samples = ops[4]; - statement("imageStore(", to_expression(ops[0]), ", ", coord_expr, ", ", to_expression(samples), ", ", - remap_swizzle(store_type, value_type.vecsize, to_expression(ops[2])), ");"); - } - else - statement("imageStore(", to_expression(ops[0]), ", ", coord_expr, ", ", - remap_swizzle(store_type, value_type.vecsize, to_expression(ops[2])), ");"); - - if (var && variable_storage_is_aliased(*var)) - flush_all_aliased_variables(); - break; - } - - case OpImageQuerySize: - { - auto &type = expression_type(ops[2]); - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - - if (type.basetype == SPIRType::Image) - { - string expr; - if (type.image.sampled == 2) - { - // The size of an image is always constant. - expr = join("imageSize(", to_expression(ops[2]), ")"); - } - else - { - // This path is hit for samplerBuffers and multisampled images which do not have LOD. - expr = join("textureSize(", to_expression(ops[2]), ")"); - } - - auto &restype = get(ops[0]); - expr = bitcast_expression(restype, SPIRType::Int, expr); - emit_op(result_type, id, expr, true); - } - else - SPIRV_CROSS_THROW("Invalid type for OpImageQuerySize."); - break; - } - - // Compute - case OpControlBarrier: - case OpMemoryBarrier: - { - if (get_entry_point().model == ExecutionModelTessellationControl) - { - // Control shaders only have barriers, and it implies memory barriers. - if (opcode == OpControlBarrier) - statement("barrier();"); - break; - } - - uint32_t memory; - uint32_t semantics; - - if (opcode == OpMemoryBarrier) - { - memory = get(ops[0]).scalar(); - semantics = get(ops[1]).scalar(); - } - else - { - memory = get(ops[1]).scalar(); - semantics = get(ops[2]).scalar(); - } - - // We only care about these flags, acquire/release and friends are not relevant to GLSL. - semantics = mask_relevant_memory_semantics(semantics); - - if (opcode == OpMemoryBarrier) - { - // If we are a memory barrier, and the next instruction is a control barrier, check if that memory barrier - // does what we need, so we avoid redundant barriers. - const Instruction *next = get_next_instruction_in_block(instruction); - if (next && next->op == OpControlBarrier) - { - auto *next_ops = stream(*next); - uint32_t next_memory = get(next_ops[1]).scalar(); - uint32_t next_semantics = get(next_ops[2]).scalar(); - next_semantics = mask_relevant_memory_semantics(next_semantics); - - bool memory_scope_covered = false; - if (next_memory == memory) - memory_scope_covered = true; - else if (next_semantics == MemorySemanticsWorkgroupMemoryMask) - { - // If we only care about workgroup memory, either Device or Workgroup scope is fine, - // scope does not have to match. - if ((next_memory == ScopeDevice || next_memory == ScopeWorkgroup) && - (memory == ScopeDevice || memory == ScopeWorkgroup)) - { - memory_scope_covered = true; - } - } - else if (memory == ScopeWorkgroup && next_memory == ScopeDevice) - { - // The control barrier has device scope, but the memory barrier just has workgroup scope. - memory_scope_covered = true; - } - - // If we have the same memory scope, and all memory types are covered, we're good. - if (memory_scope_covered && (semantics & next_semantics) == semantics) - break; - } - } - - // We are synchronizing some memory or syncing execution, - // so we cannot forward any loads beyond the memory barrier. - if (semantics || opcode == OpControlBarrier) - flush_all_active_variables(); - - if (memory == ScopeWorkgroup) // Only need to consider memory within a group - { - if (semantics == MemorySemanticsWorkgroupMemoryMask) - statement("memoryBarrierShared();"); - else if (semantics != 0) - statement("groupMemoryBarrier();"); - } - else - { - const uint32_t all_barriers = MemorySemanticsWorkgroupMemoryMask | MemorySemanticsUniformMemoryMask | - MemorySemanticsImageMemoryMask | MemorySemanticsAtomicCounterMemoryMask; - - if (semantics & (MemorySemanticsCrossWorkgroupMemoryMask | MemorySemanticsSubgroupMemoryMask)) - { - // These are not relevant for GLSL, but assume it means memoryBarrier(). - // memoryBarrier() does everything, so no need to test anything else. - statement("memoryBarrier();"); - } - else if ((semantics & all_barriers) == all_barriers) - { - // Short-hand instead of emitting 4 barriers. - statement("memoryBarrier();"); - } - else - { - // Pick out individual barriers. - if (semantics & MemorySemanticsWorkgroupMemoryMask) - statement("memoryBarrierShared();"); - if (semantics & MemorySemanticsUniformMemoryMask) - statement("memoryBarrierBuffer();"); - if (semantics & MemorySemanticsImageMemoryMask) - statement("memoryBarrierImage();"); - if (semantics & MemorySemanticsAtomicCounterMemoryMask) - statement("memoryBarrierAtomicCounter();"); - } - } - - if (opcode == OpControlBarrier) - statement("barrier();"); - break; - } - - case OpExtInst: - { - uint32_t extension_set = ops[2]; - - if (get(extension_set).ext == SPIRExtension::GLSL) - { - emit_glsl_op(ops[0], ops[1], ops[3], &ops[4], length - 4); - } - else if (get(extension_set).ext == SPIRExtension::SPV_AMD_shader_ballot) - { - emit_spv_amd_shader_ballot_op(ops[0], ops[1], ops[3], &ops[4], length - 4); - } - else if (get(extension_set).ext == SPIRExtension::SPV_AMD_shader_explicit_vertex_parameter) - { - emit_spv_amd_shader_explicit_vertex_parameter_op(ops[0], ops[1], ops[3], &ops[4], length - 4); - } - else if (get(extension_set).ext == SPIRExtension::SPV_AMD_shader_trinary_minmax) - { - emit_spv_amd_shader_trinary_minmax_op(ops[0], ops[1], ops[3], &ops[4], length - 4); - } - else if (get(extension_set).ext == SPIRExtension::SPV_AMD_gcn_shader) - { - emit_spv_amd_gcn_shader_op(ops[0], ops[1], ops[3], &ops[4], length - 4); - } - else - { - statement("// unimplemented ext op ", instruction.op); - break; - } - - break; - } - - case OpSubgroupBallotKHR: - { - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - string expr; - expr = join("unpackUint2x32(ballotARB(" + to_expression(ops[2]) + "))"); - emit_op(result_type, id, expr, true); - - require_extension("GL_ARB_shader_ballot"); - break; - } - - case OpSubgroupFirstInvocationKHR: - { - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - emit_unary_func_op(result_type, id, ops[2], "readFirstInvocationARB"); - - require_extension("GL_ARB_shader_ballot"); - break; - } - - case OpSubgroupReadInvocationKHR: - { - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - emit_binary_func_op(result_type, id, ops[2], ops[3], "readInvocationARB"); - - require_extension("GL_ARB_shader_ballot"); - break; - } - - case OpSubgroupAllKHR: - { - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - emit_unary_func_op(result_type, id, ops[2], "allInvocationsARB"); - - require_extension("GL_ARB_shader_group_vote"); - break; - } - - case OpSubgroupAnyKHR: - { - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - emit_unary_func_op(result_type, id, ops[2], "anyInvocationARB"); - - require_extension("GL_ARB_shader_group_vote"); - break; - } - - case OpSubgroupAllEqualKHR: - { - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - emit_unary_func_op(result_type, id, ops[2], "allInvocationsEqualARB"); - - require_extension("GL_ARB_shader_group_vote"); - break; - } - - case OpGroupIAddNonUniformAMD: - case OpGroupFAddNonUniformAMD: - { - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - emit_unary_func_op(result_type, id, ops[4], "addInvocationsNonUniformAMD"); - - require_extension("GL_AMD_shader_ballot"); - break; - } - - case OpGroupFMinNonUniformAMD: - case OpGroupUMinNonUniformAMD: - case OpGroupSMinNonUniformAMD: - { - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - emit_unary_func_op(result_type, id, ops[4], "minInvocationsNonUniformAMD"); - - require_extension("GL_AMD_shader_ballot"); - break; - } - - case OpGroupFMaxNonUniformAMD: - case OpGroupUMaxNonUniformAMD: - case OpGroupSMaxNonUniformAMD: - { - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - emit_unary_func_op(result_type, id, ops[4], "maxInvocationsNonUniformAMD"); - - require_extension("GL_AMD_shader_ballot"); - break; - } - - case OpFragmentMaskFetchAMD: - { - auto &type = expression_type(ops[2]); - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - - if (type.image.dim == spv::DimSubpassData) - { - emit_unary_func_op(result_type, id, ops[2], "fragmentMaskFetchAMD"); - } - else - { - emit_binary_func_op(result_type, id, ops[2], ops[3], "fragmentMaskFetchAMD"); - } - - require_extension("GL_AMD_shader_fragment_mask"); - break; - } - - case OpFragmentFetchAMD: - { - auto &type = expression_type(ops[2]); - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - - if (type.image.dim == spv::DimSubpassData) - { - emit_binary_func_op(result_type, id, ops[2], ops[4], "fragmentFetchAMD"); - } - else - { - emit_trinary_func_op(result_type, id, ops[2], ops[3], ops[4], "fragmentFetchAMD"); - } - - require_extension("GL_AMD_shader_fragment_mask"); - break; - } - - default: - statement("// unimplemented op ", instruction.op); - break; - } -} - -// Appends function arguments, mapped from global variables, beyond the specified arg index. -// This is used when a function call uses fewer arguments than the function defines. -// This situation may occur if the function signature has been dynamically modified to -// extract global variables referenced from within the function, and convert them to -// function arguments. This is necessary for shader languages that do not support global -// access to shader input content from within a function (eg. Metal). Each additional -// function args uses the name of the global variable. Function nesting will modify the -// functions and function calls all the way up the nesting chain. -void CompilerGLSL::append_global_func_args(const SPIRFunction &func, uint32_t index, vector &arglist) -{ - auto &args = func.arguments; - uint32_t arg_cnt = uint32_t(args.size()); - for (uint32_t arg_idx = index; arg_idx < arg_cnt; arg_idx++) - { - auto &arg = args[arg_idx]; - assert(arg.alias_global_variable); - arglist.push_back(to_func_call_arg(arg.id)); - - // If the underlying variable needs to be declared - // (ie. a local variable with deferred declaration), do so now. - uint32_t var_id = get(arg.id).basevariable; - if (var_id) - flush_variable_declaration(var_id); - } -} - -string CompilerGLSL::to_member_name(const SPIRType &type, uint32_t index) -{ - auto &memb = meta[type.self].members; - if (index < memb.size() && !memb[index].alias.empty()) - return memb[index].alias; - else - return join("_m", index); -} - -void CompilerGLSL::add_member_name(SPIRType &type, uint32_t index) -{ - auto &memb = meta[type.self].members; - if (index < memb.size() && !memb[index].alias.empty()) - { - auto &name = memb[index].alias; - if (name.empty()) - return; - - // Reserved for temporaries. - if (name[0] == '_' && name.size() >= 2 && isdigit(name[1])) - { - name.clear(); - return; - } - - update_name_cache(type.member_name_cache, name); - } -} - -// Checks whether the ID is a row_major matrix that requires conversion before use -bool CompilerGLSL::is_non_native_row_major_matrix(uint32_t id) -{ - // Natively supported row-major matrices do not need to be converted. - // Legacy targets do not support row major. - if (backend.native_row_major_matrix && !is_legacy()) - return false; - - // Non-matrix or column-major matrix types do not need to be converted. - if (!(meta[id].decoration.decoration_flags & (1ull << DecorationRowMajor))) - return false; - - // Only square row-major matrices can be converted at this time. - // Converting non-square matrices will require defining custom GLSL function that - // swaps matrix elements while retaining the original dimensional form of the matrix. - const auto type = expression_type(id); - if (type.columns != type.vecsize) - SPIRV_CROSS_THROW("Row-major matrices must be square on this platform."); - - return true; -} - -// Checks whether the member is a row_major matrix that requires conversion before use -bool CompilerGLSL::member_is_non_native_row_major_matrix(const SPIRType &type, uint32_t index) -{ - // Natively supported row-major matrices do not need to be converted. - if (backend.native_row_major_matrix && !is_legacy()) - return false; - - // Non-matrix or column-major matrix types do not need to be converted. - if (!(combined_decoration_for_member(type, index) & (1ull << DecorationRowMajor))) - return false; - - // Only square row-major matrices can be converted at this time. - // Converting non-square matrices will require defining custom GLSL function that - // swaps matrix elements while retaining the original dimensional form of the matrix. - const auto mbr_type = get(type.member_types[index]); - if (mbr_type.columns != mbr_type.vecsize) - SPIRV_CROSS_THROW("Row-major matrices must be square on this platform."); - - return true; -} - -// Checks whether the member is in packed data type, that might need to be unpacked. -// GLSL does not define packed data types, but certain subclasses do. -bool CompilerGLSL::member_is_packed_type(const SPIRType &type, uint32_t index) const -{ - return has_member_decoration(type.self, index, DecorationCPacked); -} - -// Wraps the expression string in a function call that converts the -// row_major matrix result of the expression to a column_major matrix. -// Base implementation uses the standard library transpose() function. -// Subclasses may override to use a different function. -string CompilerGLSL::convert_row_major_matrix(string exp_str, const SPIRType & /*exp_type*/) -{ - strip_enclosed_expression(exp_str); - return join("transpose(", exp_str, ")"); -} - -string CompilerGLSL::variable_decl(const SPIRType &type, const string &name, uint32_t id) -{ - string type_name = type_to_glsl(type, id); - remap_variable_type_name(type, name, type_name); - return join(type_name, " ", name, type_to_array_glsl(type)); -} - -// Emit a structure member. Subclasses may override to modify output, -// or to dynamically add a padding member if needed. -void CompilerGLSL::emit_struct_member(const SPIRType &type, uint32_t member_type_id, uint32_t index, - const string &qualifier) -{ - auto &membertype = get(member_type_id); - - uint64_t memberflags = 0; - auto &memb = meta[type.self].members; - if (index < memb.size()) - memberflags = memb[index].decoration_flags; - - string qualifiers; - bool is_block = (meta[type.self].decoration.decoration_flags & - ((1ull << DecorationBlock) | (1ull << DecorationBufferBlock))) != 0; - if (is_block) - qualifiers = to_interpolation_qualifiers(memberflags); - - statement(layout_for_member(type, index), qualifiers, qualifier, - flags_to_precision_qualifiers_glsl(membertype, memberflags), - variable_decl(membertype, to_member_name(type, index)), ";"); -} - -const char *CompilerGLSL::flags_to_precision_qualifiers_glsl(const SPIRType &type, uint64_t flags) -{ - // Structs do not have precision qualifiers, neither do doubles (desktop only anyways, so no mediump/highp). - if (type.basetype != SPIRType::Float && type.basetype != SPIRType::Int && type.basetype != SPIRType::UInt && - type.basetype != SPIRType::Image && type.basetype != SPIRType::SampledImage && - type.basetype != SPIRType::Sampler) - return ""; - - if (options.es) - { - auto &execution = get_entry_point(); - - if (flags & (1ull << DecorationRelaxedPrecision)) - { - bool implied_fmediump = type.basetype == SPIRType::Float && - options.fragment.default_float_precision == Options::Mediump && - execution.model == ExecutionModelFragment; - - bool implied_imediump = (type.basetype == SPIRType::Int || type.basetype == SPIRType::UInt) && - options.fragment.default_int_precision == Options::Mediump && - execution.model == ExecutionModelFragment; - - return implied_fmediump || implied_imediump ? "" : "mediump "; - } - else - { - bool implied_fhighp = - type.basetype == SPIRType::Float && ((options.fragment.default_float_precision == Options::Highp && - execution.model == ExecutionModelFragment) || - (execution.model != ExecutionModelFragment)); - - bool implied_ihighp = (type.basetype == SPIRType::Int || type.basetype == SPIRType::UInt) && - ((options.fragment.default_int_precision == Options::Highp && - execution.model == ExecutionModelFragment) || - (execution.model != ExecutionModelFragment)); - - return implied_fhighp || implied_ihighp ? "" : "highp "; - } - } - else if (backend.allow_precision_qualifiers) - { - // Vulkan GLSL supports precision qualifiers, even in desktop profiles, which is convenient. - // The default is highp however, so only emit mediump in the rare case that a shader has these. - if (flags & (1ull << DecorationRelaxedPrecision)) - { - bool can_use_mediump = - type.basetype == SPIRType::Float || type.basetype == SPIRType::Int || type.basetype == SPIRType::UInt; - return can_use_mediump ? "mediump " : ""; - } - else - return ""; - } - else - return ""; -} - -const char *CompilerGLSL::to_precision_qualifiers_glsl(uint32_t id) -{ - return flags_to_precision_qualifiers_glsl(expression_type(id), meta[id].decoration.decoration_flags); -} - -string CompilerGLSL::to_qualifiers_glsl(uint32_t id) -{ - auto flags = meta[id].decoration.decoration_flags; - string res; - - auto *var = maybe_get(id); - - if (var && var->storage == StorageClassWorkgroup && !backend.shared_is_implied) - res += "shared "; - - res += to_interpolation_qualifiers(flags); - if (var) - res += to_storage_qualifiers_glsl(*var); - - auto &type = expression_type(id); - if (type.image.dim != DimSubpassData && type.image.sampled == 2) - { - if (flags & (1ull << DecorationCoherent)) - res += "coherent "; - if (flags & (1ull << DecorationRestrict)) - res += "restrict "; - if (flags & (1ull << DecorationNonWritable)) - res += "readonly "; - if (flags & (1ull << DecorationNonReadable)) - res += "writeonly "; - } - - res += to_precision_qualifiers_glsl(id); - - return res; -} - -string CompilerGLSL::argument_decl(const SPIRFunction::Parameter &arg) -{ - // glslangValidator seems to make all arguments pointer no matter what which is rather bizarre ... - auto &type = expression_type(arg.id); - const char *direction = ""; - - if (type.pointer) - { - if (arg.write_count && arg.read_count) - direction = "inout "; - else if (arg.write_count) - direction = "out "; - } - - return join(direction, to_qualifiers_glsl(arg.id), variable_decl(type, to_name(arg.id), arg.id)); -} - -string CompilerGLSL::variable_decl(const SPIRVariable &variable) -{ - // Ignore the pointer type since GLSL doesn't have pointers. - auto &type = get(variable.basetype); - - auto res = join(to_qualifiers_glsl(variable.self), variable_decl(type, to_name(variable.self), variable.self)); - - if (variable.loop_variable && variable.static_expression) - { - uint32_t expr = variable.static_expression; - if (ids[expr].get_type() != TypeUndef) - res += join(" = ", to_expression(variable.static_expression)); - } - else if (variable.initializer) - { - uint32_t expr = variable.initializer; - if (ids[expr].get_type() != TypeUndef) - res += join(" = ", to_expression(variable.initializer)); - } - return res; -} - -const char *CompilerGLSL::to_pls_qualifiers_glsl(const SPIRVariable &variable) -{ - auto flags = meta[variable.self].decoration.decoration_flags; - if (flags & (1ull << DecorationRelaxedPrecision)) - return "mediump "; - else - return "highp "; -} - -string CompilerGLSL::pls_decl(const PlsRemap &var) -{ - auto &variable = get(var.id); - - SPIRType type; - type.vecsize = pls_format_to_components(var.format); - type.basetype = pls_format_to_basetype(var.format); - - return join(to_pls_layout(var.format), to_pls_qualifiers_glsl(variable), type_to_glsl(type), " ", - to_name(variable.self)); -} - -uint32_t CompilerGLSL::to_array_size_literal(const SPIRType &type, uint32_t index) const -{ - assert(type.array.size() == type.array_size_literal.size()); - - if (!type.array_size_literal[index]) - SPIRV_CROSS_THROW("The array size is not a literal, but a specialization constant or spec constant op."); - - return type.array[index]; -} - -string CompilerGLSL::to_array_size(const SPIRType &type, uint32_t index) -{ - assert(type.array.size() == type.array_size_literal.size()); - - // Tessellation control shaders must have either gl_MaxPatchVertices or unsized arrays for input arrays. - // Opt for unsized as it's the more "correct" variant to use. - if (type.storage == StorageClassInput && get_entry_point().model == ExecutionModelTessellationControl) - return ""; - - auto &size = type.array[index]; - if (!type.array_size_literal[index]) - return to_expression(size); - else if (size) - return convert_to_string(size); - else if (!backend.flexible_member_array_supported) - { - // For runtime-sized arrays, we can work around - // lack of standard support for this by simply having - // a single element array. - // - // Runtime length arrays must always be the last element - // in an interface block. - return "1"; - } - else - return ""; -} - -string CompilerGLSL::type_to_array_glsl(const SPIRType &type) -{ - if (type.array.empty()) - return ""; - - if (options.flatten_multidimensional_arrays) - { - string res; - res += "["; - for (auto i = uint32_t(type.array.size()); i; i--) - { - res += enclose_expression(to_array_size(type, i - 1)); - if (i > 1) - res += " * "; - } - res += "]"; - return res; - } - else - { - if (type.array.size() > 1) - { - if (!options.es && options.version < 430) - require_extension("GL_ARB_arrays_of_arrays"); - else if (options.es && options.version < 310) - SPIRV_CROSS_THROW("Arrays of arrays not supported before ESSL version 310. " - "Try using --flatten-multidimensional-arrays or set " - "options.flatten_multidimensional_arrays to true."); - } - - string res; - for (auto i = uint32_t(type.array.size()); i; i--) - { - res += "["; - res += to_array_size(type, i - 1); - res += "]"; - } - return res; - } -} - -string CompilerGLSL::image_type_glsl(const SPIRType &type, uint32_t /* id */) -{ - auto &imagetype = get(type.image.type); - string res; - - switch (imagetype.basetype) - { - case SPIRType::Int: - res = "i"; - break; - case SPIRType::UInt: - res = "u"; - break; - default: - break; - } - - if (type.basetype == SPIRType::Image && type.image.dim == DimSubpassData && options.vulkan_semantics) - return res + "subpassInput" + (type.image.ms ? "MS" : ""); - - // If we're emulating subpassInput with samplers, force sampler2D - // so we don't have to specify format. - if (type.basetype == SPIRType::Image && type.image.dim != DimSubpassData) - { - // Sampler buffers are always declared as samplerBuffer even though they might be separate images in the SPIR-V. - if (type.image.dim == DimBuffer && type.image.sampled == 1) - res += "sampler"; - else - res += type.image.sampled == 2 ? "image" : "texture"; - } - else - res += "sampler"; - - switch (type.image.dim) - { - case Dim1D: - res += "1D"; - break; - case Dim2D: - res += "2D"; - break; - case Dim3D: - res += "3D"; - break; - case DimCube: - res += "Cube"; - break; - - case DimBuffer: - if (options.es && options.version < 320) - require_extension("GL_OES_texture_buffer"); - else if (!options.es && options.version < 300) - require_extension("GL_EXT_texture_buffer_object"); - res += "Buffer"; - break; - - case DimSubpassData: - res += "2D"; - break; - default: - SPIRV_CROSS_THROW("Only 1D, 2D, 3D, Buffer, InputTarget and Cube textures supported."); - } - - if (type.image.ms) - res += "MS"; - if (type.image.arrayed) - { - if (is_legacy_desktop()) - require_extension("GL_EXT_texture_array"); - res += "Array"; - } - if (type.image.depth) - res += "Shadow"; - - return res; -} - -string CompilerGLSL::type_to_glsl_constructor(const SPIRType &type) -{ - if (type.array.size() > 1) - { - if (options.flatten_multidimensional_arrays) - SPIRV_CROSS_THROW("Cannot flatten constructors of multidimensional array constructors, e.g. float[][]()."); - else if (!options.es && options.version < 430) - require_extension("GL_ARB_arrays_of_arrays"); - else if (options.es && options.version < 310) - SPIRV_CROSS_THROW("Arrays of arrays not supported before ESSL version 310."); - } - - auto e = type_to_glsl(type); - for (uint32_t i = 0; i < type.array.size(); i++) - e += "[]"; - return e; -} - -// The optional id parameter indicates the object whose type we are trying -// to find the description for. It is optional. Most type descriptions do not -// depend on a specific object's use of that type. -string CompilerGLSL::type_to_glsl(const SPIRType &type, uint32_t id) -{ - // Ignore the pointer type since GLSL doesn't have pointers. - - switch (type.basetype) - { - case SPIRType::Struct: - // Need OpName lookup here to get a "sensible" name for a struct. - if (backend.explicit_struct_type) - return join("struct ", to_name(type.self)); - else - return to_name(type.self); - - case SPIRType::Image: - case SPIRType::SampledImage: - return image_type_glsl(type, id); - - case SPIRType::Sampler: - // The depth field is set by calling code based on the variable ID of the sampler, effectively reintroducing - // this distinction into the type system. - return comparison_samplers.count(id) ? "samplerShadow" : "sampler"; - - case SPIRType::Void: - return "void"; - - default: - break; - } - - if (type.vecsize == 1 && type.columns == 1) // Scalar builtin - { - switch (type.basetype) - { - case SPIRType::Boolean: - return "bool"; - case SPIRType::Int: - return backend.basic_int_type; - case SPIRType::UInt: - return backend.basic_uint_type; - case SPIRType::AtomicCounter: - return "atomic_uint"; - case SPIRType::Float: - return "float"; - case SPIRType::Double: - return "double"; - case SPIRType::Int64: - return "int64_t"; - case SPIRType::UInt64: - return "uint64_t"; - default: - return "???"; - } - } - else if (type.vecsize > 1 && type.columns == 1) // Vector builtin - { - switch (type.basetype) - { - case SPIRType::Boolean: - return join("bvec", type.vecsize); - case SPIRType::Int: - return join("ivec", type.vecsize); - case SPIRType::UInt: - return join("uvec", type.vecsize); - case SPIRType::Float: - return join("vec", type.vecsize); - case SPIRType::Double: - return join("dvec", type.vecsize); - case SPIRType::Int64: - return join("i64vec", type.vecsize); - case SPIRType::UInt64: - return join("u64vec", type.vecsize); - default: - return "???"; - } - } - else if (type.vecsize == type.columns) // Simple Matrix builtin - { - switch (type.basetype) - { - case SPIRType::Boolean: - return join("bmat", type.vecsize); - case SPIRType::Int: - return join("imat", type.vecsize); - case SPIRType::UInt: - return join("umat", type.vecsize); - case SPIRType::Float: - return join("mat", type.vecsize); - case SPIRType::Double: - return join("dmat", type.vecsize); - // Matrix types not supported for int64/uint64. - default: - return "???"; - } - } - else - { - switch (type.basetype) - { - case SPIRType::Boolean: - return join("bmat", type.columns, "x", type.vecsize); - case SPIRType::Int: - return join("imat", type.columns, "x", type.vecsize); - case SPIRType::UInt: - return join("umat", type.columns, "x", type.vecsize); - case SPIRType::Float: - return join("mat", type.columns, "x", type.vecsize); - case SPIRType::Double: - return join("dmat", type.columns, "x", type.vecsize); - // Matrix types not supported for int64/uint64. - default: - return "???"; - } - } -} - -void CompilerGLSL::add_variable(unordered_set &variables, string &name) -{ - if (name.empty()) - return; - - // Reserved for temporaries. - if (name[0] == '_' && name.size() >= 2 && isdigit(name[1])) - { - name.clear(); - return; - } - - update_name_cache(variables, name); -} - -void CompilerGLSL::add_variable(unordered_set &variables, uint32_t id) -{ - auto &name = meta[id].decoration.alias; - add_variable(variables, name); -} - -void CompilerGLSL::add_local_variable_name(uint32_t id) -{ - add_variable(local_variable_names, id); -} - -void CompilerGLSL::add_resource_name(uint32_t id) -{ - add_variable(resource_names, id); -} - -void CompilerGLSL::add_header_line(const std::string &line) -{ - header_lines.push_back(line); -} - -bool CompilerGLSL::has_extension(const std::string &ext) const -{ - auto itr = find(begin(forced_extensions), end(forced_extensions), ext); - return itr != end(forced_extensions); -} - -void CompilerGLSL::require_extension(const string &ext) -{ - if (!has_extension(ext)) - { - forced_extensions.push_back(ext); - force_recompile = true; - } -} - -void CompilerGLSL::flatten_buffer_block(uint32_t id) -{ - auto &var = get(id); - auto &type = get(var.basetype); - auto name = to_name(type.self, false); - auto flags = meta.at(type.self).decoration.decoration_flags; - - if (!type.array.empty()) - SPIRV_CROSS_THROW(name + " is an array of UBOs."); - if (type.basetype != SPIRType::Struct) - SPIRV_CROSS_THROW(name + " is not a struct."); - if ((flags & (1ull << DecorationBlock)) == 0) - SPIRV_CROSS_THROW(name + " is not a block."); - if (type.member_types.empty()) - SPIRV_CROSS_THROW(name + " is an empty struct."); - - flattened_buffer_blocks.insert(id); -} - -bool CompilerGLSL::check_atomic_image(uint32_t id) -{ - auto &type = expression_type(id); - if (type.storage == StorageClassImage) - { - if (options.es && options.version < 320) - require_extension("GL_OES_shader_image_atomic"); - - auto *var = maybe_get_backing_variable(id); - if (var) - { - auto &flags = meta.at(var->self).decoration.decoration_flags; - if (flags & ((1ull << DecorationNonWritable) | (1ull << DecorationNonReadable))) - { - flags &= ~(1ull << DecorationNonWritable); - flags &= ~(1ull << DecorationNonReadable); - force_recompile = true; - } - } - return true; - } - else - return false; -} - -void CompilerGLSL::emit_function_prototype(SPIRFunction &func, uint64_t return_flags) -{ - // Avoid shadow declarations. - local_variable_names = resource_names; - - string decl; - - auto &type = get(func.return_type); - decl += flags_to_precision_qualifiers_glsl(type, return_flags); - decl += type_to_glsl(type); - decl += " "; - - if (func.self == entry_point) - { - decl += "main"; - processing_entry_point = true; - } - else - decl += to_name(func.self); - - decl += "("; - vector arglist; - for (auto &arg : func.arguments) - { - // Do not pass in separate images or samplers if we're remapping - // to combined image samplers. - if (skip_argument(arg.id)) - continue; - - // Might change the variable name if it already exists in this function. - // SPIRV OpName doesn't have any semantic effect, so it's valid for an implementation - // to use same name for variables. - // Since we want to make the GLSL debuggable and somewhat sane, use fallback names for variables which are duplicates. - add_local_variable_name(arg.id); - - arglist.push_back(argument_decl(arg)); - - // Hold a pointer to the parameter so we can invalidate the readonly field if needed. - auto *var = maybe_get(arg.id); - if (var) - var->parameter = &arg; - } - - for (auto &arg : func.shadow_arguments) - { - // Might change the variable name if it already exists in this function. - // SPIRV OpName doesn't have any semantic effect, so it's valid for an implementation - // to use same name for variables. - // Since we want to make the GLSL debuggable and somewhat sane, use fallback names for variables which are duplicates. - add_local_variable_name(arg.id); - - arglist.push_back(argument_decl(arg)); - - // Hold a pointer to the parameter so we can invalidate the readonly field if needed. - auto *var = maybe_get(arg.id); - if (var) - var->parameter = &arg; - } - - decl += merge(arglist); - decl += ")"; - statement(decl); -} - -void CompilerGLSL::emit_function(SPIRFunction &func, uint64_t return_flags) -{ - // Avoid potential cycles. - if (func.active) - return; - func.active = true; - - // If we depend on a function, emit that function before we emit our own function. - for (auto block : func.blocks) - { - auto &b = get(block); - for (auto &i : b.ops) - { - auto ops = stream(i); - auto op = static_cast(i.op); - - if (op == OpFunctionCall) - { - // Recursively emit functions which are called. - uint32_t id = ops[2]; - emit_function(get(id), meta[ops[1]].decoration.decoration_flags); - } - } - } - - emit_function_prototype(func, return_flags); - begin_scope(); - - current_function = &func; - auto &entry_block = get(func.entry_block); - - if (!func.analyzed_variable_scope) - { - analyze_variable_scope(func); - - // Check if we can actually use the loop variables we found in analyze_variable_scope. - // To use multiple initializers, we need the same type and qualifiers. - for (auto block : func.blocks) - { - auto &b = get(block); - if (b.loop_variables.size() < 2) - continue; - - uint64_t flags = get_decoration_mask(b.loop_variables.front()); - uint32_t type = get(b.loop_variables.front()).basetype; - bool invalid_initializers = false; - for (auto loop_variable : b.loop_variables) - { - if (flags != get_decoration_mask(loop_variable) || - type != get(b.loop_variables.front()).basetype) - { - invalid_initializers = true; - break; - } - } - - if (invalid_initializers) - { - for (auto loop_variable : b.loop_variables) - get(loop_variable).loop_variable = false; - b.loop_variables.clear(); - } - } - func.analyzed_variable_scope = true; - } - - for (auto &v : func.local_variables) - { - auto &var = get(v); - if (expression_is_lvalue(v)) - { - add_local_variable_name(var.self); - - if (var.initializer) - statement(variable_decl_function_local(var), ";"); - else - { - // Don't declare variable until first use to declutter the GLSL output quite a lot. - // If we don't touch the variable before first branch, - // declare it then since we need variable declaration to be in top scope. - // Never declare empty structs. They have no meaningful representation. - auto &type = get(var.basetype); - bool empty_struct = type.basetype == SPIRType::Struct && type.member_types.empty(); - var.deferred_declaration = !empty_struct; - } - } - else - { - // HACK: SPIR-V in older glslang output likes to use samplers and images as local variables, but GLSL does not allow this. - // For these types (non-lvalue), we enforce forwarding through a shadowed variable. - // This means that when we OpStore to these variables, we just write in the expression ID directly. - // This breaks any kind of branching, since the variable must be statically assigned. - // Branching on samplers and images would be pretty much impossible to fake in GLSL. - var.statically_assigned = true; - } - - var.loop_variable_enable = false; - - // Loop variables are never declared outside their for-loop, so block any implicit declaration. - if (var.loop_variable) - var.deferred_declaration = false; - } - - entry_block.loop_dominator = SPIRBlock::NoDominator; - emit_block_chain(entry_block); - - end_scope(); - processing_entry_point = false; - statement(""); -} - -void CompilerGLSL::emit_fixup() -{ - auto &execution = get_entry_point(); - if (execution.model == ExecutionModelVertex) - { - if (options.vertex.fixup_clipspace) - { - const char *suffix = backend.float_literal_suffix ? "f" : ""; - statement("gl_Position.z = 2.0", suffix, " * gl_Position.z - gl_Position.w;"); - } - - if (options.vertex.flip_vert_y) - statement("gl_Position.y = -gl_Position.y;"); - } -} - -bool CompilerGLSL::flush_phi_required(uint32_t from, uint32_t to) -{ - auto &child = get(to); - for (auto &phi : child.phi_variables) - if (phi.parent == from) - return true; - return false; -} - -void CompilerGLSL::flush_phi(uint32_t from, uint32_t to) -{ - auto &child = get(to); - - for (auto &phi : child.phi_variables) - { - if (phi.parent == from) - { - auto &var = get(phi.function_variable); - - // A Phi variable might be a loop variable, so flush to static expression. - if (var.loop_variable && !var.loop_variable_enable) - var.static_expression = phi.local_variable; - else - { - flush_variable_declaration(phi.function_variable); - - // This might be called in continue block, so make sure we - // use this to emit ESSL 1.0 compliant increments/decrements. - auto lhs = to_expression(phi.function_variable); - auto rhs = to_expression(phi.local_variable); - if (!optimize_read_modify_write(lhs, rhs)) - statement(lhs, " = ", rhs, ";"); - } - } - } -} - -void CompilerGLSL::branch(uint32_t from, uint32_t to) -{ - flush_phi(from, to); - flush_all_active_variables(); - - // This is only a continue if we branch to our loop dominator. - if (loop_blocks.find(to) != end(loop_blocks) && get(from).loop_dominator == to) - { - // This can happen if we had a complex continue block which was emitted. - // Once the continue block tries to branch to the loop header, just emit continue; - // and end the chain here. - statement("continue;"); - } - else if (is_continue(to)) - { - auto &to_block = get(to); - if (to_block.complex_continue) - { - // Just emit the whole block chain as is. - auto usage_counts = expression_usage_counts; - auto invalid = invalid_expressions; - - emit_block_chain(to_block); - - // Expression usage counts and invalid expressions - // are moot after returning from the continue block. - // Since we emit the same block multiple times, - // we don't want to invalidate ourselves. - expression_usage_counts = usage_counts; - invalid_expressions = invalid; - } - else - { - auto &from_block = get(from); - auto &dominator = get(from_block.loop_dominator); - - // For non-complex continue blocks, we implicitly branch to the continue block - // by having the continue block be part of the loop header in for (; ; continue-block). - bool outside_control_flow = block_is_outside_flow_control_from_block(dominator, from_block); - - // Some simplification for for-loops. We always end up with a useless continue; - // statement since we branch to a loop block. - // Walk the CFG, if we uncoditionally execute the block calling continue assuming we're in the loop block, - // we can avoid writing out an explicit continue statement. - // Similar optimization to return statements if we know we're outside flow control. - if (!outside_control_flow) - statement("continue;"); - } - } - else if (is_break(to)) - statement("break;"); - else if (!is_conditional(to)) - emit_block_chain(get(to)); -} - -void CompilerGLSL::branch(uint32_t from, uint32_t cond, uint32_t true_block, uint32_t false_block) -{ - // If we branch directly to a selection merge target, we don't really need a code path. - bool true_sub = !is_conditional(true_block); - bool false_sub = !is_conditional(false_block); - - if (true_sub) - { - statement("if (", to_expression(cond), ")"); - begin_scope(); - branch(from, true_block); - end_scope(); - - if (false_sub) - { - statement("else"); - begin_scope(); - branch(from, false_block); - end_scope(); - } - else if (flush_phi_required(from, false_block)) - { - statement("else"); - begin_scope(); - flush_phi(from, false_block); - end_scope(); - } - } - else if (false_sub && !true_sub) - { - // Only need false path, use negative conditional. - statement("if (!", to_expression(cond), ")"); - begin_scope(); - branch(from, false_block); - end_scope(); - - if (flush_phi_required(from, true_block)) - { - statement("else"); - begin_scope(); - flush_phi(from, true_block); - end_scope(); - } - } -} - -void CompilerGLSL::propagate_loop_dominators(const SPIRBlock &block) -{ - // Propagate down the loop dominator block, so that dominated blocks can back trace. - if (block.merge == SPIRBlock::MergeLoop || block.loop_dominator) - { - uint32_t dominator = block.merge == SPIRBlock::MergeLoop ? block.self : block.loop_dominator; - - auto set_dominator = [this](uint32_t self, uint32_t new_dominator) { - auto &dominated_block = this->get(self); - - // If we already have a loop dominator, we're trying to break out to merge targets - // which should not update the loop dominator. - if (!dominated_block.loop_dominator) - dominated_block.loop_dominator = new_dominator; - }; - - // After merging a loop, we inherit the loop dominator always. - if (block.merge_block) - set_dominator(block.merge_block, block.loop_dominator); - - if (block.true_block) - set_dominator(block.true_block, dominator); - if (block.false_block) - set_dominator(block.false_block, dominator); - if (block.next_block) - set_dominator(block.next_block, dominator); - - for (auto &c : block.cases) - set_dominator(c.block, dominator); - - // In older glslang output continue_block can be == loop header. - if (block.continue_block && block.continue_block != block.self) - set_dominator(block.continue_block, dominator); - } -} - -// FIXME: This currently cannot handle complex continue blocks -// as in do-while. -// This should be seen as a "trivial" continue block. -string CompilerGLSL::emit_continue_block(uint32_t continue_block) -{ - auto *block = &get(continue_block); - - // While emitting the continue block, declare_temporary will check this - // if we have to emit temporaries. - current_continue_block = block; - - vector statements; - - // Capture all statements into our list. - auto *old = redirect_statement; - redirect_statement = &statements; - - // Stamp out all blocks one after each other. - while (loop_blocks.find(block->self) == end(loop_blocks)) - { - propagate_loop_dominators(*block); - // Write out all instructions we have in this block. - emit_block_instructions(*block); - - // For plain branchless for/while continue blocks. - if (block->next_block) - { - flush_phi(continue_block, block->next_block); - block = &get(block->next_block); - } - // For do while blocks. The last block will be a select block. - else if (block->true_block) - { - flush_phi(continue_block, block->true_block); - block = &get(block->true_block); - } - } - - // Restore old pointer. - redirect_statement = old; - - // Somewhat ugly, strip off the last ';' since we use ',' instead. - // Ideally, we should select this behavior in statement(). - for (auto &s : statements) - { - if (!s.empty() && s.back() == ';') - s.erase(s.size() - 1, 1); - } - - current_continue_block = nullptr; - return merge(statements); -} - -string CompilerGLSL::emit_for_loop_initializers(const SPIRBlock &block) -{ - if (block.loop_variables.empty()) - return ""; - - bool same_types = for_loop_initializers_are_same_type(block); - // We can only declare for loop initializers if all variables are of same type. - // If we cannot do this, declare individual variables before the loop header. - - // We might have a loop variable candidate which was not assigned to for some reason. - uint32_t missing_initializers = 0; - for (auto &variable : block.loop_variables) - { - uint32_t expr = get(variable).static_expression; - - // Sometimes loop variables are initialized with OpUndef, but we can just declare - // a plain variable without initializer in this case. - if (expr == 0 || ids[expr].get_type() == TypeUndef) - missing_initializers++; - } - - if (block.loop_variables.size() == 1 && missing_initializers == 0) - { - return variable_decl(get(block.loop_variables.front())); - } - else if (!same_types || missing_initializers == uint32_t(block.loop_variables.size())) - { - for (auto &loop_var : block.loop_variables) - statement(variable_decl(get(loop_var)), ";"); - return ""; - } - else - { - // We have a mix of loop variables, either ones with a clear initializer, or ones without. - // Separate the two streams. - string expr; - - for (auto &loop_var : block.loop_variables) - { - uint32_t static_expr = get(loop_var).static_expression; - if (static_expr == 0 || ids[static_expr].get_type() == TypeUndef) - { - statement(variable_decl(get(loop_var)), ";"); - } - else - { - if (expr.empty()) - { - // For loop initializers are of the form (block.loop_variables.front()); - auto &type = get(var.basetype); - expr = join(to_qualifiers_glsl(var.self), type_to_glsl(type), " "); - } - else - expr += ", "; - - auto &v = get(loop_var); - expr += join(to_name(loop_var), " = ", to_expression(v.static_expression)); - } - } - return expr; - } -} - -bool CompilerGLSL::for_loop_initializers_are_same_type(const SPIRBlock &block) -{ - if (block.loop_variables.size() <= 1) - return true; - - uint32_t expected = 0; - uint64_t expected_flags = 0; - for (auto &var : block.loop_variables) - { - // Don't care about uninitialized variables as they will not be part of the initializers. - uint32_t expr = get(var).static_expression; - if (expr == 0 || ids[expr].get_type() == TypeUndef) - continue; - - if (expected == 0) - { - expected = get(var).basetype; - expected_flags = get_decoration_mask(var); - } - else if (expected != get(var).basetype) - return false; - - // Precision flags and things like that must also match. - if (expected_flags != get_decoration_mask(var)) - return false; - } - - return true; -} - -bool CompilerGLSL::attempt_emit_loop_header(SPIRBlock &block, SPIRBlock::Method method) -{ - SPIRBlock::ContinueBlockType continue_type = continue_block_type(get(block.continue_block)); - - if (method == SPIRBlock::MergeToSelectForLoop) - { - uint32_t current_count = statement_count; - // If we're trying to create a true for loop, - // we need to make sure that all opcodes before branch statement do not actually emit any code. - // We can then take the condition expression and create a for (; cond ; ) { body; } structure instead. - emit_block_instructions(block); - - bool condition_is_temporary = forced_temporaries.find(block.condition) == end(forced_temporaries); - - // This can work! We only did trivial things which could be forwarded in block body! - if (current_count == statement_count && condition_is_temporary) - { - switch (continue_type) - { - case SPIRBlock::ForLoop: - { - // This block may be a dominating block, so make sure we flush undeclared variables before building the for loop header. - flush_undeclared_variables(block); - - // Important that we do this in this order because - // emitting the continue block can invalidate the condition expression. - auto initializer = emit_for_loop_initializers(block); - auto condition = to_expression(block.condition); - auto continue_block = emit_continue_block(block.continue_block); - statement("for (", initializer, "; ", condition, "; ", continue_block, ")"); - break; - } - - case SPIRBlock::WhileLoop: - // This block may be a dominating block, so make sure we flush undeclared variables before building the while loop header. - flush_undeclared_variables(block); - statement("while (", to_expression(block.condition), ")"); - break; - - default: - SPIRV_CROSS_THROW("For/while loop detected, but need while/for loop semantics."); - } - - begin_scope(); - return true; - } - else - { - block.disable_block_optimization = true; - force_recompile = true; - begin_scope(); // We'll see an end_scope() later. - return false; - } - } - else if (method == SPIRBlock::MergeToDirectForLoop) - { - auto &child = get(block.next_block); - - // This block may be a dominating block, so make sure we flush undeclared variables before building the for loop header. - flush_undeclared_variables(child); - - uint32_t current_count = statement_count; - - // If we're trying to create a true for loop, - // we need to make sure that all opcodes before branch statement do not actually emit any code. - // We can then take the condition expression and create a for (; cond ; ) { body; } structure instead. - emit_block_instructions(child); - - bool condition_is_temporary = forced_temporaries.find(child.condition) == end(forced_temporaries); - - if (current_count == statement_count && condition_is_temporary) - { - propagate_loop_dominators(child); - - switch (continue_type) - { - case SPIRBlock::ForLoop: - { - // Important that we do this in this order because - // emitting the continue block can invalidate the condition expression. - auto initializer = emit_for_loop_initializers(block); - auto condition = to_expression(child.condition); - auto continue_block = emit_continue_block(block.continue_block); - statement("for (", initializer, "; ", condition, "; ", continue_block, ")"); - break; - } - - case SPIRBlock::WhileLoop: - statement("while (", to_expression(child.condition), ")"); - break; - - default: - SPIRV_CROSS_THROW("For/while loop detected, but need while/for loop semantics."); - } - - begin_scope(); - branch(child.self, child.true_block); - return true; - } - else - { - block.disable_block_optimization = true; - force_recompile = true; - begin_scope(); // We'll see an end_scope() later. - return false; - } - } - else - return false; -} - -void CompilerGLSL::flush_undeclared_variables(SPIRBlock &block) -{ - // Enforce declaration order for regression testing purposes. - sort(begin(block.dominated_variables), end(block.dominated_variables)); - - for (auto &v : block.dominated_variables) - { - auto &var = get(v); - if (var.deferred_declaration) - statement(variable_decl(var), ";"); - var.deferred_declaration = false; - } -} - -void CompilerGLSL::emit_block_chain(SPIRBlock &block) -{ - propagate_loop_dominators(block); - - bool select_branch_to_true_block = false; - bool skip_direct_branch = false; - bool emitted_for_loop_header = false; - - // If we need to force temporaries for certain IDs due to continue blocks, do it before starting loop header. - for (auto &tmp : block.declare_temporary) - { - auto flags = meta[tmp.second].decoration.decoration_flags; - auto &type = get(tmp.first); - statement(flags_to_precision_qualifiers_glsl(type, flags), variable_decl(type, to_name(tmp.second)), ";"); - } - - SPIRBlock::ContinueBlockType continue_type = SPIRBlock::ContinueNone; - if (block.continue_block) - continue_type = continue_block_type(get(block.continue_block)); - - // If we have loop variables, stop masking out access to the variable now. - for (auto var : block.loop_variables) - get(var).loop_variable_enable = true; - - // This is the older loop behavior in glslang which branches to loop body directly from the loop header. - if (block_is_loop_candidate(block, SPIRBlock::MergeToSelectForLoop)) - { - flush_undeclared_variables(block); - if (attempt_emit_loop_header(block, SPIRBlock::MergeToSelectForLoop)) - { - // The body of while, is actually just the true block, so always branch there unconditionally. - select_branch_to_true_block = true; - emitted_for_loop_header = true; - } - } - // This is the newer loop behavior in glslang which branches from Loop header directly to - // a new block, which in turn has a OpBranchSelection without a selection merge. - else if (block_is_loop_candidate(block, SPIRBlock::MergeToDirectForLoop)) - { - flush_undeclared_variables(block); - if (attempt_emit_loop_header(block, SPIRBlock::MergeToDirectForLoop)) - { - skip_direct_branch = true; - emitted_for_loop_header = true; - } - } - else if (continue_type == SPIRBlock::DoWhileLoop) - { - flush_undeclared_variables(block); - statement("do"); - begin_scope(); - - emit_block_instructions(block); - } - else if (block.merge == SPIRBlock::MergeLoop) - { - flush_undeclared_variables(block); - - // We have a generic loop without any distinguishable pattern like for, while or do while. - get(block.continue_block).complex_continue = true; - continue_type = SPIRBlock::ComplexLoop; - - statement("for (;;)"); - begin_scope(); - - emit_block_instructions(block); - } - else - { - emit_block_instructions(block); - } - - // If we didn't successfully emit a loop header and we had loop variable candidates, we have a problem - // as writes to said loop variables might have been masked out, we need a recompile. - if (!emitted_for_loop_header && !block.loop_variables.empty()) - { - force_recompile = true; - for (auto var : block.loop_variables) - get(var).loop_variable = false; - block.loop_variables.clear(); - } - - flush_undeclared_variables(block); - bool emit_next_block = true; - - // Handle end of block. - switch (block.terminator) - { - case SPIRBlock::Direct: - // True when emitting complex continue block. - if (block.loop_dominator == block.next_block) - { - branch(block.self, block.next_block); - emit_next_block = false; - } - // True if MergeToDirectForLoop succeeded. - else if (skip_direct_branch) - emit_next_block = false; - else if (is_continue(block.next_block) || is_break(block.next_block) || is_conditional(block.next_block)) - { - branch(block.self, block.next_block); - emit_next_block = false; - } - break; - - case SPIRBlock::Select: - // True if MergeToSelectForLoop succeeded. - if (select_branch_to_true_block) - branch(block.self, block.true_block); - else - branch(block.self, block.condition, block.true_block, block.false_block); - break; - - case SPIRBlock::MultiSelect: - { - auto &type = expression_type(block.condition); - bool uint32_t_case = type.basetype == SPIRType::UInt; - - statement("switch (", to_expression(block.condition), ")"); - begin_scope(); - - for (auto &c : block.cases) - { - auto case_value = - uint32_t_case ? convert_to_string(uint32_t(c.value)) : convert_to_string(int32_t(c.value)); - statement("case ", case_value, ":"); - begin_scope(); - branch(block.self, c.block); - end_scope(); - } - - if (block.default_block != block.next_block) - { - statement("default:"); - begin_scope(); - if (is_break(block.default_block)) - SPIRV_CROSS_THROW("Cannot break; out of a switch statement and out of a loop at the same time ..."); - branch(block.self, block.default_block); - end_scope(); - } - else if (flush_phi_required(block.self, block.next_block)) - { - statement("default:"); - begin_scope(); - flush_phi(block.self, block.next_block); - statement("break;"); - end_scope(); - } - - end_scope(); - break; - } - - case SPIRBlock::Return: - if (processing_entry_point) - emit_fixup(); - - if (block.return_value) - { - // OpReturnValue can return Undef, so don't emit anything for this case. - if (ids.at(block.return_value).get_type() != TypeUndef) - statement("return ", to_expression(block.return_value), ";"); - } - // If this block is the very final block and not called from control flow, - // we do not need an explicit return which looks out of place. Just end the function here. - // In the very weird case of for(;;) { return; } executing return is unconditional, - // but we actually need a return here ... - else if (!block_is_outside_flow_control_from_block(get(current_function->entry_block), block) || - block.loop_dominator != SPIRBlock::NoDominator) - statement("return;"); - break; - - case SPIRBlock::Kill: - statement(backend.discard_literal, ";"); - break; - - case SPIRBlock::Unreachable: - emit_next_block = false; - break; - - default: - SPIRV_CROSS_THROW("Unimplemented block terminator."); - } - - if (block.next_block && emit_next_block) - { - // If we hit this case, we're dealing with an unconditional branch, which means we will output - // that block after this. If we had selection merge, we already flushed phi variables. - if (block.merge != SPIRBlock::MergeSelection) - flush_phi(block.self, block.next_block); - emit_block_chain(get(block.next_block)); - } - - if (block.merge == SPIRBlock::MergeLoop) - { - if (continue_type == SPIRBlock::DoWhileLoop) - { - // Make sure that we run the continue block to get the expressions set, but this - // should become an empty string. - // We have no fallbacks if we cannot forward everything to temporaries ... - auto statements = emit_continue_block(block.continue_block); - if (!statements.empty()) - { - // The DoWhile block has side effects, force ComplexLoop pattern next pass. - get(block.continue_block).complex_continue = true; - force_recompile = true; - } - - end_scope_decl(join("while (", to_expression(get(block.continue_block).condition), ")")); - } - else - end_scope(); - - flush_phi(block.self, block.merge_block); - emit_block_chain(get(block.merge_block)); - } -} - -void CompilerGLSL::begin_scope() -{ - statement("{"); - indent++; -} - -void CompilerGLSL::end_scope() -{ - if (!indent) - SPIRV_CROSS_THROW("Popping empty indent stack."); - indent--; - statement("}"); -} - -void CompilerGLSL::end_scope_decl() -{ - if (!indent) - SPIRV_CROSS_THROW("Popping empty indent stack."); - indent--; - statement("};"); -} - -void CompilerGLSL::end_scope_decl(const string &decl) -{ - if (!indent) - SPIRV_CROSS_THROW("Popping empty indent stack."); - indent--; - statement("} ", decl, ";"); -} - -void CompilerGLSL::check_function_call_constraints(const uint32_t *args, uint32_t length) -{ - // If our variable is remapped, and we rely on type-remapping information as - // well, then we cannot pass the variable as a function parameter. - // Fixing this is non-trivial without stamping out variants of the same function, - // so for now warn about this and suggest workarounds instead. - for (uint32_t i = 0; i < length; i++) - { - auto *var = maybe_get(args[i]); - if (!var || !var->remapped_variable) - continue; - - auto &type = get(var->basetype); - if (type.basetype == SPIRType::Image && type.image.dim == DimSubpassData) - { - SPIRV_CROSS_THROW("Tried passing a remapped subpassInput variable to a function. " - "This will not work correctly because type-remapping information is lost. " - "To workaround, please consider not passing the subpass input as a function parameter, " - "or use in/out variables instead which do not need type remapping information."); - } - } -} - -const Instruction *CompilerGLSL::get_next_instruction_in_block(const Instruction &instr) -{ - // FIXME: This is kind of hacky. There should be a cleaner way. - auto offset = uint32_t(&instr - current_emitting_block->ops.data()); - if ((offset + 1) < current_emitting_block->ops.size()) - return ¤t_emitting_block->ops[offset + 1]; - else - return nullptr; -} - -uint32_t CompilerGLSL::mask_relevant_memory_semantics(uint32_t semantics) -{ - return semantics & (MemorySemanticsAtomicCounterMemoryMask | MemorySemanticsImageMemoryMask | - MemorySemanticsWorkgroupMemoryMask | MemorySemanticsUniformMemoryMask | - MemorySemanticsCrossWorkgroupMemoryMask | MemorySemanticsSubgroupMemoryMask); -} diff --git a/deps/SPIRV-Cross/spirv_glsl.hpp b/deps/SPIRV-Cross/spirv_glsl.hpp deleted file mode 100644 index 5421f258e9..0000000000 --- a/deps/SPIRV-Cross/spirv_glsl.hpp +++ /dev/null @@ -1,534 +0,0 @@ -/* - * Copyright 2015-2017 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef SPIRV_CROSS_GLSL_HPP -#define SPIRV_CROSS_GLSL_HPP - -#include "spirv_cross.hpp" -#include -#include -#include -#include - -namespace spirv_cross -{ -enum PlsFormat -{ - PlsNone = 0, - - PlsR11FG11FB10F, - PlsR32F, - PlsRG16F, - PlsRGB10A2, - PlsRGBA8, - PlsRG16, - - PlsRGBA8I, - PlsRG16I, - - PlsRGB10A2UI, - PlsRGBA8UI, - PlsRG16UI, - PlsR32UI -}; - -struct PlsRemap -{ - uint32_t id; - PlsFormat format; -}; - -class CompilerGLSL : public Compiler -{ -public: - struct Options - { - // The shading language version. Corresponds to #version $VALUE. - uint32_t version = 450; - - // Emit the OpenGL ES shading language instead of desktop OpenGL. - bool es = false; - - // Debug option to always emit temporary variables for all expressions. - bool force_temporary = false; - - // If true, Vulkan GLSL features are used instead of GL-compatible features. - // Mostly useful for debugging SPIR-V files. - bool vulkan_semantics = false; - - // If true, gl_PerVertex is explicitly redeclared in vertex, geometry and tessellation shaders. - // The members of gl_PerVertex is determined by which built-ins are declared by the shader. - // This option is ignored in ES versions, as redeclaration in ES is not required, and it depends on a different extension - // (EXT_shader_io_blocks) which makes things a bit more fuzzy. - bool separate_shader_objects = false; - - // Flattens multidimensional arrays, e.g. float foo[a][b][c] into single-dimensional arrays, - // e.g. float foo[a * b * c]. - // This function does not change the actual SPIRType of any object. - // Only the generated code, including declarations of interface variables are changed to be single array dimension. - bool flatten_multidimensional_arrays = false; - - // For older desktop GLSL targets than version 420, the - // GL_ARB_shading_language_420pack extensions is used to be able to support - // layout(binding) on UBOs and samplers. - // If disabled on older targets, binding decorations will be stripped. - bool enable_420pack_extension = true; - - enum Precision - { - DontCare, - Lowp, - Mediump, - Highp - }; - - struct - { - // GLSL: In vertex shaders, rewrite [0, w] depth (Vulkan/D3D style) to [-w, w] depth (GL style). - // MSL: In vertex shaders, rewrite [-w, w] depth (GL style) to [0, w] depth. - // HLSL: In vertex shaders, rewrite [-w, w] depth (GL style) to [0, w] depth. - bool fixup_clipspace = false; - - // Inverts gl_Position.y or equivalent. - bool flip_vert_y = false; - } vertex; - - struct - { - // Add precision mediump float in ES targets when emitting GLES source. - // Add precision highp int in ES targets when emitting GLES source. - Precision default_float_precision = Mediump; - Precision default_int_precision = Highp; - } fragment; - }; - - void remap_pixel_local_storage(std::vector inputs, std::vector outputs) - { - pls_inputs = std::move(inputs); - pls_outputs = std::move(outputs); - remap_pls_variables(); - } - - CompilerGLSL(std::vector spirv_) - : Compiler(move(spirv_)) - { - init(); - } - - CompilerGLSL(const uint32_t *ir, size_t word_count) - : Compiler(ir, word_count) - { - init(); - } - - const Options &get_options() const - { - return options; - } - void set_options(Options &opts) - { - options = opts; - } - - std::string compile() override; - - // Returns the current string held in the conversion buffer. Useful for - // capturing what has been converted so far when compile() throws an error. - std::string get_partial_source(); - - // Adds a line to be added right after #version in GLSL backend. - // This is useful for enabling custom extensions which are outside the scope of SPIRV-Cross. - // This can be combined with variable remapping. - // A new-line will be added. - // - // While add_header_line() is a more generic way of adding arbitrary text to the header - // of a GLSL file, require_extension() should be used when adding extensions since it will - // avoid creating collisions with SPIRV-Cross generated extensions. - // - // Code added via add_header_line() is typically backend-specific. - void add_header_line(const std::string &str); - - // Adds an extension which is required to run this shader, e.g. - // require_extension("GL_KHR_my_extension"); - void require_extension(const std::string &ext); - - // Legacy GLSL compatibility method. - // Takes a uniform or push constant variable and flattens it into a (i|u)vec4 array[N]; array instead. - // For this to work, all types in the block must be the same basic type, e.g. mixing vec2 and vec4 is fine, but - // mixing int and float is not. - // The name of the uniform array will be the same as the interface block name. - void flatten_buffer_block(uint32_t id); - -protected: - void reset(); - void emit_function(SPIRFunction &func, uint64_t return_flags); - - bool has_extension(const std::string &ext) const; - - // Virtualize methods which need to be overridden by subclass targets like C++ and such. - virtual void emit_function_prototype(SPIRFunction &func, uint64_t return_flags); - - // Kinda ugly way to let opcodes peek at their neighbor instructions for trivial peephole scenarios. - const SPIRBlock *current_emitting_block = nullptr; - - virtual void emit_instruction(const Instruction &instr); - void emit_block_instructions(const SPIRBlock &block); - virtual void emit_glsl_op(uint32_t result_type, uint32_t result_id, uint32_t op, const uint32_t *args, - uint32_t count); - virtual void emit_spv_amd_shader_ballot_op(uint32_t result_type, uint32_t result_id, uint32_t op, - const uint32_t *args, uint32_t count); - virtual void emit_spv_amd_shader_explicit_vertex_parameter_op(uint32_t result_type, uint32_t result_id, uint32_t op, - const uint32_t *args, uint32_t count); - virtual void emit_spv_amd_shader_trinary_minmax_op(uint32_t result_type, uint32_t result_id, uint32_t op, - const uint32_t *args, uint32_t count); - virtual void emit_spv_amd_gcn_shader_op(uint32_t result_type, uint32_t result_id, uint32_t op, const uint32_t *args, - uint32_t count); - virtual void emit_header(); - virtual void emit_sampled_image_op(uint32_t result_type, uint32_t result_id, uint32_t image_id, uint32_t samp_id); - virtual void emit_texture_op(const Instruction &i); - virtual std::string type_to_glsl(const SPIRType &type, uint32_t id = 0); - virtual std::string builtin_to_glsl(spv::BuiltIn builtin, spv::StorageClass storage); - virtual void emit_struct_member(const SPIRType &type, uint32_t member_type_id, uint32_t index, - const std::string &qualifier = ""); - virtual std::string image_type_glsl(const SPIRType &type, uint32_t id = 0); - virtual std::string constant_expression(const SPIRConstant &c); - std::string constant_op_expression(const SPIRConstantOp &cop); - virtual std::string constant_expression_vector(const SPIRConstant &c, uint32_t vector); - virtual void emit_fixup(); - virtual std::string variable_decl(const SPIRType &type, const std::string &name, uint32_t id = 0); - virtual std::string to_func_call_arg(uint32_t id); - virtual std::string to_function_name(uint32_t img, const SPIRType &imgtype, bool is_fetch, bool is_gather, - bool is_proj, bool has_array_offsets, bool has_offset, bool has_grad, - bool has_dref, uint32_t lod); - virtual std::string to_function_args(uint32_t img, const SPIRType &imgtype, bool is_fetch, bool is_gather, - bool is_proj, uint32_t coord, uint32_t coord_components, uint32_t dref, - uint32_t grad_x, uint32_t grad_y, uint32_t lod, uint32_t coffset, - uint32_t offset, uint32_t bias, uint32_t comp, uint32_t sample, - bool *p_forward); - virtual void emit_buffer_block(const SPIRVariable &type); - virtual void emit_push_constant_block(const SPIRVariable &var); - virtual void emit_uniform(const SPIRVariable &var); - virtual std::string unpack_expression_type(std::string expr_str, const SPIRType &type); - - std::unique_ptr buffer; - - template - inline void statement_inner(T &&t) - { - (*buffer) << std::forward(t); - statement_count++; - } - - template - inline void statement_inner(T &&t, Ts &&... ts) - { - (*buffer) << std::forward(t); - statement_count++; - statement_inner(std::forward(ts)...); - } - - template - inline void statement(Ts &&... ts) - { - if (force_recompile) - { - // Do not bother emitting code while force_recompile is active. - // We will compile again. - statement_count++; - return; - } - - if (redirect_statement) - redirect_statement->push_back(join(std::forward(ts)...)); - else - { - for (uint32_t i = 0; i < indent; i++) - (*buffer) << " "; - - statement_inner(std::forward(ts)...); - (*buffer) << '\n'; - } - } - - template - inline void statement_no_indent(Ts &&... ts) - { - auto old_indent = indent; - indent = 0; - statement(std::forward(ts)...); - indent = old_indent; - } - - // Used for implementing continue blocks where - // we want to obtain a list of statements we can merge - // on a single line separated by comma. - std::vector *redirect_statement = nullptr; - const SPIRBlock *current_continue_block = nullptr; - - void begin_scope(); - void end_scope(); - void end_scope_decl(); - void end_scope_decl(const std::string &decl); - - Options options; - - std::string type_to_array_glsl(const SPIRType &type); - std::string to_array_size(const SPIRType &type, uint32_t index); - uint32_t to_array_size_literal(const SPIRType &type, uint32_t index) const; - std::string variable_decl(const SPIRVariable &variable); - std::string variable_decl_function_local(SPIRVariable &variable); - - void add_local_variable_name(uint32_t id); - void add_resource_name(uint32_t id); - void add_member_name(SPIRType &type, uint32_t name); - - virtual bool is_non_native_row_major_matrix(uint32_t id); - virtual bool member_is_non_native_row_major_matrix(const SPIRType &type, uint32_t index); - bool member_is_packed_type(const SPIRType &type, uint32_t index) const; - virtual std::string convert_row_major_matrix(std::string exp_str, const SPIRType &exp_type); - - std::unordered_set local_variable_names; - std::unordered_set resource_names; - - bool processing_entry_point = false; - - // Can be overriden by subclass backends for trivial things which - // shouldn't need polymorphism. - struct BackendVariations - { - std::string discard_literal = "discard"; - bool float_literal_suffix = false; - bool double_literal_suffix = true; - bool uint32_t_literal_suffix = true; - bool long_long_literal_suffix = false; - const char *basic_int_type = "int"; - const char *basic_uint_type = "uint"; - bool swizzle_is_function = false; - bool shared_is_implied = false; - bool flexible_member_array_supported = true; - bool explicit_struct_type = false; - bool use_initializer_list = false; - bool use_typed_initializer_list = false; - bool can_declare_struct_inline = true; - bool native_row_major_matrix = true; - bool use_constructor_splatting = true; - bool boolean_mix_support = true; - bool allow_precision_qualifiers = false; - bool can_swizzle_scalar = false; - bool force_gl_in_out_block = false; - } backend; - - void emit_struct(SPIRType &type); - void emit_resources(); - void emit_buffer_block_native(const SPIRVariable &var); - void emit_buffer_block_legacy(const SPIRVariable &var); - void emit_buffer_block_flattened(const SPIRVariable &type); - void emit_declared_builtin_block(spv::StorageClass storage, spv::ExecutionModel model); - void emit_push_constant_block_vulkan(const SPIRVariable &var); - void emit_push_constant_block_glsl(const SPIRVariable &var); - void emit_interface_block(const SPIRVariable &type); - void emit_flattened_io_block(const SPIRVariable &var, const char *qual); - void emit_block_chain(SPIRBlock &block); - void emit_specialization_constant(const SPIRConstant &constant); - std::string emit_continue_block(uint32_t continue_block); - bool attempt_emit_loop_header(SPIRBlock &block, SPIRBlock::Method method); - void propagate_loop_dominators(const SPIRBlock &block); - - void branch(uint32_t from, uint32_t to); - void branch(uint32_t from, uint32_t cond, uint32_t true_block, uint32_t false_block); - void flush_phi(uint32_t from, uint32_t to); - bool flush_phi_required(uint32_t from, uint32_t to); - void flush_variable_declaration(uint32_t id); - void flush_undeclared_variables(SPIRBlock &block); - - bool should_forward(uint32_t id); - void emit_mix_op(uint32_t result_type, uint32_t id, uint32_t left, uint32_t right, uint32_t lerp); - bool to_trivial_mix_op(const SPIRType &type, std::string &op, uint32_t left, uint32_t right, uint32_t lerp); - void emit_quaternary_func_op(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, uint32_t op2, - uint32_t op3, const char *op); - void emit_trinary_func_op(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, uint32_t op2, - const char *op); - void emit_binary_func_op(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, const char *op); - void emit_binary_func_op_cast(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, const char *op, - SPIRType::BaseType input_type, bool skip_cast_if_equal_type); - void emit_unary_func_op(uint32_t result_type, uint32_t result_id, uint32_t op0, const char *op); - void emit_unrolled_unary_op(uint32_t result_type, uint32_t result_id, uint32_t operand, const char *op); - void emit_binary_op(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, const char *op); - void emit_unrolled_binary_op(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, const char *op); - void emit_binary_op_cast(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, const char *op, - SPIRType::BaseType input_type, bool skip_cast_if_equal_type); - - SPIRType binary_op_bitcast_helper(std::string &cast_op0, std::string &cast_op1, SPIRType::BaseType &input_type, - uint32_t op0, uint32_t op1, bool skip_cast_if_equal_type); - - void emit_unary_op(uint32_t result_type, uint32_t result_id, uint32_t op0, const char *op); - bool expression_is_forwarded(uint32_t id); - SPIRExpression &emit_op(uint32_t result_type, uint32_t result_id, const std::string &rhs, bool forward_rhs, - bool suppress_usage_tracking = false); - std::string access_chain_internal(uint32_t base, const uint32_t *indices, uint32_t count, bool index_is_literal, - bool chain_only = false, bool *need_transpose = nullptr, - bool *result_is_packed = nullptr); - std::string access_chain(uint32_t base, const uint32_t *indices, uint32_t count, const SPIRType &target_type, - bool *need_transpose = nullptr, bool *result_is_packed = nullptr); - - std::string flattened_access_chain(uint32_t base, const uint32_t *indices, uint32_t count, - const SPIRType &target_type, uint32_t offset, uint32_t matrix_stride, - bool need_transpose); - std::string flattened_access_chain_struct(uint32_t base, const uint32_t *indices, uint32_t count, - const SPIRType &target_type, uint32_t offset); - std::string flattened_access_chain_matrix(uint32_t base, const uint32_t *indices, uint32_t count, - const SPIRType &target_type, uint32_t offset, uint32_t matrix_stride, - bool need_transpose); - std::string flattened_access_chain_vector(uint32_t base, const uint32_t *indices, uint32_t count, - const SPIRType &target_type, uint32_t offset, uint32_t matrix_stride, - bool need_transpose); - std::pair flattened_access_chain_offset(const SPIRType &basetype, const uint32_t *indices, - uint32_t count, uint32_t offset, - uint32_t word_stride, bool *need_transpose = nullptr, - uint32_t *matrix_stride = nullptr); - - const char *index_to_swizzle(uint32_t index); - std::string remap_swizzle(const SPIRType &result_type, uint32_t input_components, const std::string &expr); - std::string declare_temporary(uint32_t type, uint32_t id); - void append_global_func_args(const SPIRFunction &func, uint32_t index, std::vector &arglist); - std::string to_expression(uint32_t id); - std::string to_enclosed_expression(uint32_t id); - std::string enclose_expression(const std::string &expr); - void strip_enclosed_expression(std::string &expr); - std::string to_member_name(const SPIRType &type, uint32_t index); - std::string type_to_glsl_constructor(const SPIRType &type); - std::string argument_decl(const SPIRFunction::Parameter &arg); - virtual std::string to_qualifiers_glsl(uint32_t id); - const char *to_precision_qualifiers_glsl(uint32_t id); - virtual const char *to_storage_qualifiers_glsl(const SPIRVariable &var); - const char *flags_to_precision_qualifiers_glsl(const SPIRType &type, uint64_t flags); - const char *format_to_glsl(spv::ImageFormat format); - virtual std::string layout_for_member(const SPIRType &type, uint32_t index); - virtual std::string to_interpolation_qualifiers(uint64_t flags); - uint64_t combined_decoration_for_member(const SPIRType &type, uint32_t index); - std::string layout_for_variable(const SPIRVariable &variable); - std::string to_combined_image_sampler(uint32_t image_id, uint32_t samp_id); - virtual bool skip_argument(uint32_t id) const; - - bool buffer_is_packing_standard(const SPIRType &type, BufferPackingStandard packing); - uint32_t type_to_packed_base_size(const SPIRType &type, BufferPackingStandard packing); - uint32_t type_to_packed_alignment(const SPIRType &type, uint64_t flags, BufferPackingStandard packing); - uint32_t type_to_packed_array_stride(const SPIRType &type, uint64_t flags, BufferPackingStandard packing); - uint32_t type_to_packed_size(const SPIRType &type, uint64_t flags, BufferPackingStandard packing); - - std::string bitcast_glsl(const SPIRType &result_type, uint32_t arg); - virtual std::string bitcast_glsl_op(const SPIRType &result_type, const SPIRType &argument_type); - - std::string bitcast_expression(SPIRType::BaseType target_type, uint32_t arg); - std::string bitcast_expression(const SPIRType &target_type, SPIRType::BaseType expr_type, const std::string &expr); - - std::string build_composite_combiner(uint32_t result_type, const uint32_t *elems, uint32_t length); - bool remove_duplicate_swizzle(std::string &op); - bool remove_unity_swizzle(uint32_t base, std::string &op); - - // Can modify flags to remote readonly/writeonly if image type - // and force recompile. - bool check_atomic_image(uint32_t id); - - virtual void replace_illegal_names(); - - void replace_fragment_output(SPIRVariable &var); - void replace_fragment_outputs(); - bool check_explicit_lod_allowed(uint32_t lod); - std::string legacy_tex_op(const std::string &op, const SPIRType &imgtype, uint32_t lod); - - uint32_t indent = 0; - - std::unordered_set emitted_functions; - - std::unordered_set flattened_buffer_blocks; - std::unordered_set flattened_structs; - - std::string load_flattened_struct(SPIRVariable &var); - std::string to_flattened_struct_member(const SPIRVariable &var, uint32_t index); - void store_flattened_struct(SPIRVariable &var, uint32_t value); - - // Usage tracking. If a temporary is used more than once, use the temporary instead to - // avoid AST explosion when SPIRV is generated with pure SSA and doesn't write stuff to variables. - std::unordered_map expression_usage_counts; - void track_expression_read(uint32_t id); - - std::vector forced_extensions; - std::vector header_lines; - - uint32_t statement_count; - - inline bool is_legacy() const - { - return (options.es && options.version < 300) || (!options.es && options.version < 130); - } - - inline bool is_legacy_es() const - { - return options.es && options.version < 300; - } - - inline bool is_legacy_desktop() const - { - return !options.es && options.version < 130; - } - - bool args_will_forward(uint32_t id, const uint32_t *args, uint32_t num_args, bool pure); - void register_call_out_argument(uint32_t id); - void register_impure_function_call(); - - // GL_EXT_shader_pixel_local_storage support. - std::vector pls_inputs; - std::vector pls_outputs; - std::string pls_decl(const PlsRemap &variable); - const char *to_pls_qualifiers_glsl(const SPIRVariable &variable); - void emit_pls(); - void remap_pls_variables(); - - void add_variable(std::unordered_set &variables, uint32_t id); - void add_variable(std::unordered_set &variables, std::string &name); - void check_function_call_constraints(const uint32_t *args, uint32_t length); - void handle_invalid_expression(uint32_t id); - void find_static_extensions(); - - std::string emit_for_loop_initializers(const SPIRBlock &block); - bool for_loop_initializers_are_same_type(const SPIRBlock &block); - bool optimize_read_modify_write(const std::string &lhs, const std::string &rhs); - void fixup_image_load_store_access(); - - bool type_is_empty(const SPIRType &type); - - virtual void declare_undefined_values(); - - static std::string sanitize_underscores(const std::string &str); - - bool can_use_io_location(spv::StorageClass storage); - const Instruction *get_next_instruction_in_block(const Instruction &instr); - static uint32_t mask_relevant_memory_semantics(uint32_t semantics); - -private: - void init() - { - if (source.known) - { - options.es = source.es; - options.version = source.version; - } - } -}; -} - -#endif diff --git a/deps/SPIRV-Cross/spirv_hlsl.cpp b/deps/SPIRV-Cross/spirv_hlsl.cpp deleted file mode 100644 index 09c6a502aa..0000000000 --- a/deps/SPIRV-Cross/spirv_hlsl.cpp +++ /dev/null @@ -1,3676 +0,0 @@ -/* - * Copyright 2016-2017 Robert Konrad - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "spirv_hlsl.hpp" -#include "GLSL.std.450.h" -#include -#include - -using namespace spv; -using namespace spirv_cross; -using namespace std; - -static unsigned image_format_to_components(ImageFormat fmt) -{ - switch (fmt) - { - case ImageFormatR8: - case ImageFormatR16: - case ImageFormatR8Snorm: - case ImageFormatR16Snorm: - case ImageFormatR16f: - case ImageFormatR32f: - case ImageFormatR8i: - case ImageFormatR16i: - case ImageFormatR32i: - case ImageFormatR8ui: - case ImageFormatR16ui: - case ImageFormatR32ui: - return 1; - - case ImageFormatRg8: - case ImageFormatRg16: - case ImageFormatRg8Snorm: - case ImageFormatRg16Snorm: - case ImageFormatRg16f: - case ImageFormatRg32f: - case ImageFormatRg8i: - case ImageFormatRg16i: - case ImageFormatRg32i: - case ImageFormatRg8ui: - case ImageFormatRg16ui: - case ImageFormatRg32ui: - return 2; - - case ImageFormatR11fG11fB10f: - return 3; - - case ImageFormatRgba8: - case ImageFormatRgba16: - case ImageFormatRgb10A2: - case ImageFormatRgba8Snorm: - case ImageFormatRgba16Snorm: - case ImageFormatRgba16f: - case ImageFormatRgba32f: - case ImageFormatRgba8i: - case ImageFormatRgba16i: - case ImageFormatRgba32i: - case ImageFormatRgba8ui: - case ImageFormatRgba16ui: - case ImageFormatRgba32ui: - case ImageFormatRgb10a2ui: - return 4; - - case ImageFormatUnknown: - return 4; // Assume 4. - - default: - SPIRV_CROSS_THROW("Unrecognized typed image format."); - } -} - -static string image_format_to_type(ImageFormat fmt, SPIRType::BaseType basetype) -{ - switch (fmt) - { - case ImageFormatR8: - case ImageFormatR16: - if (basetype != SPIRType::Float) - SPIRV_CROSS_THROW("Mismatch in image type and base type of image."); - return "unorm float"; - case ImageFormatRg8: - case ImageFormatRg16: - if (basetype != SPIRType::Float) - SPIRV_CROSS_THROW("Mismatch in image type and base type of image."); - return "unorm float2"; - case ImageFormatRgba8: - case ImageFormatRgba16: - if (basetype != SPIRType::Float) - SPIRV_CROSS_THROW("Mismatch in image type and base type of image."); - return "unorm float4"; - case ImageFormatRgb10A2: - if (basetype != SPIRType::Float) - SPIRV_CROSS_THROW("Mismatch in image type and base type of image."); - return "unorm float4"; - - case ImageFormatR8Snorm: - case ImageFormatR16Snorm: - if (basetype != SPIRType::Float) - SPIRV_CROSS_THROW("Mismatch in image type and base type of image."); - return "snorm float"; - case ImageFormatRg8Snorm: - case ImageFormatRg16Snorm: - if (basetype != SPIRType::Float) - SPIRV_CROSS_THROW("Mismatch in image type and base type of image."); - return "snorm float2"; - case ImageFormatRgba8Snorm: - case ImageFormatRgba16Snorm: - if (basetype != SPIRType::Float) - SPIRV_CROSS_THROW("Mismatch in image type and base type of image."); - return "snorm float4"; - - case ImageFormatR16f: - case ImageFormatR32f: - if (basetype != SPIRType::Float) - SPIRV_CROSS_THROW("Mismatch in image type and base type of image."); - return "float"; - case ImageFormatRg16f: - case ImageFormatRg32f: - if (basetype != SPIRType::Float) - SPIRV_CROSS_THROW("Mismatch in image type and base type of image."); - return "float2"; - case ImageFormatRgba16f: - case ImageFormatRgba32f: - if (basetype != SPIRType::Float) - SPIRV_CROSS_THROW("Mismatch in image type and base type of image."); - return "float4"; - - case ImageFormatR11fG11fB10f: - if (basetype != SPIRType::Float) - SPIRV_CROSS_THROW("Mismatch in image type and base type of image."); - return "float3"; - - case ImageFormatR8i: - case ImageFormatR16i: - case ImageFormatR32i: - if (basetype != SPIRType::Int) - SPIRV_CROSS_THROW("Mismatch in image type and base type of image."); - return "int"; - case ImageFormatRg8i: - case ImageFormatRg16i: - case ImageFormatRg32i: - if (basetype != SPIRType::Int) - SPIRV_CROSS_THROW("Mismatch in image type and base type of image."); - return "int2"; - case ImageFormatRgba8i: - case ImageFormatRgba16i: - case ImageFormatRgba32i: - if (basetype != SPIRType::Int) - SPIRV_CROSS_THROW("Mismatch in image type and base type of image."); - return "int4"; - - case ImageFormatR8ui: - case ImageFormatR16ui: - case ImageFormatR32ui: - if (basetype != SPIRType::UInt) - SPIRV_CROSS_THROW("Mismatch in image type and base type of image."); - return "uint"; - case ImageFormatRg8ui: - case ImageFormatRg16ui: - case ImageFormatRg32ui: - if (basetype != SPIRType::UInt) - SPIRV_CROSS_THROW("Mismatch in image type and base type of image."); - return "uint2"; - case ImageFormatRgba8ui: - case ImageFormatRgba16ui: - case ImageFormatRgba32ui: - if (basetype != SPIRType::UInt) - SPIRV_CROSS_THROW("Mismatch in image type and base type of image."); - return "uint4"; - case ImageFormatRgb10a2ui: - if (basetype != SPIRType::UInt) - SPIRV_CROSS_THROW("Mismatch in image type and base type of image."); - return "uint4"; - - case ImageFormatUnknown: - switch (basetype) - { - case SPIRType::Float: - return "float4"; - case SPIRType::Int: - return "int4"; - case SPIRType::UInt: - return "uint4"; - default: - SPIRV_CROSS_THROW("Unsupported base type for image."); - } - - default: - SPIRV_CROSS_THROW("Unrecognized typed image format."); - } -} - -// Returns true if an arithmetic operation does not change behavior depending on signedness. -static bool opcode_is_sign_invariant(Op opcode) -{ - switch (opcode) - { - case OpIEqual: - case OpINotEqual: - case OpISub: - case OpIAdd: - case OpIMul: - case OpShiftLeftLogical: - case OpBitwiseOr: - case OpBitwiseXor: - case OpBitwiseAnd: - return true; - - default: - return false; - } -} - -string CompilerHLSL::image_type_hlsl_modern(const SPIRType &type) -{ - auto &imagetype = get(type.image.type); - const char *dim = nullptr; - bool typed_load = false; - uint32_t components = 4; - - switch (type.image.dim) - { - case Dim1D: - typed_load = type.image.sampled == 2; - dim = "1D"; - break; - case Dim2D: - typed_load = type.image.sampled == 2; - dim = "2D"; - break; - case Dim3D: - typed_load = type.image.sampled == 2; - dim = "3D"; - break; - case DimCube: - if (type.image.sampled == 2) - SPIRV_CROSS_THROW("RWTextureCube does not exist in HLSL."); - dim = "Cube"; - break; - case DimRect: - SPIRV_CROSS_THROW("Rectangle texture support is not yet implemented for HLSL."); // TODO - case DimBuffer: - if (type.image.sampled == 1) - return join("Buffer<", type_to_glsl(imagetype), components, ">"); - else if (type.image.sampled == 2) - return join("RWBuffer<", image_format_to_type(type.image.format, imagetype.basetype), ">"); - else - SPIRV_CROSS_THROW("Sampler buffers must be either sampled or unsampled. Cannot deduce in runtime."); - case DimSubpassData: - // This should be implemented same way as desktop GL. Fetch on a 2D texture based on int2(SV_Position). - SPIRV_CROSS_THROW("Subpass data support is not yet implemented for HLSL"); // TODO - default: - SPIRV_CROSS_THROW("Invalid dimension."); - } - const char *arrayed = type.image.arrayed ? "Array" : ""; - const char *ms = type.image.ms ? "MS" : ""; - const char *rw = typed_load ? "RW" : ""; - return join(rw, "Texture", dim, ms, arrayed, "<", - typed_load ? image_format_to_type(type.image.format, imagetype.basetype) : - join(type_to_glsl(imagetype), components), - ">"); -} - -string CompilerHLSL::image_type_hlsl_legacy(const SPIRType &type) -{ - auto &imagetype = get(type.image.type); - string res; - - switch (imagetype.basetype) - { - case SPIRType::Int: - res = "i"; - break; - case SPIRType::UInt: - res = "u"; - break; - default: - break; - } - - if (type.basetype == SPIRType::Image && type.image.dim == DimSubpassData) - return res + "subpassInput" + (type.image.ms ? "MS" : ""); - - // If we're emulating subpassInput with samplers, force sampler2D - // so we don't have to specify format. - if (type.basetype == SPIRType::Image && type.image.dim != DimSubpassData) - { - // Sampler buffers are always declared as samplerBuffer even though they might be separate images in the SPIR-V. - if (type.image.dim == DimBuffer && type.image.sampled == 1) - res += "sampler"; - else - res += type.image.sampled == 2 ? "image" : "texture"; - } - else - res += "sampler"; - - switch (type.image.dim) - { - case Dim1D: - res += "1D"; - break; - case Dim2D: - res += "2D"; - break; - case Dim3D: - res += "3D"; - break; - case DimCube: - res += "CUBE"; - break; - - case DimBuffer: - res += "Buffer"; - break; - - case DimSubpassData: - res += "2D"; - break; - default: - SPIRV_CROSS_THROW("Only 1D, 2D, 3D, Buffer, InputTarget and Cube textures supported."); - } - - if (type.image.ms) - res += "MS"; - if (type.image.arrayed) - res += "Array"; - if (type.image.depth) - res += "Shadow"; - - return res; -} - -string CompilerHLSL::image_type_hlsl(const SPIRType &type) -{ - if (options.shader_model <= 30) - return image_type_hlsl_legacy(type); - else - return image_type_hlsl_modern(type); -} - -// The optional id parameter indicates the object whose type we are trying -// to find the description for. It is optional. Most type descriptions do not -// depend on a specific object's use of that type. -string CompilerHLSL::type_to_glsl(const SPIRType &type, uint32_t id) -{ - // Ignore the pointer type since GLSL doesn't have pointers. - - switch (type.basetype) - { - case SPIRType::Struct: - // Need OpName lookup here to get a "sensible" name for a struct. - if (backend.explicit_struct_type) - return join("struct ", to_name(type.self)); - else - return to_name(type.self); - - case SPIRType::Image: - case SPIRType::SampledImage: - return image_type_hlsl(type); - - case SPIRType::Sampler: - return comparison_samplers.count(id) ? "SamplerComparisonState" : "SamplerState"; - - case SPIRType::Void: - return "void"; - - default: - break; - } - - if (type.vecsize == 1 && type.columns == 1) // Scalar builtin - { - switch (type.basetype) - { - case SPIRType::Boolean: - return "bool"; - case SPIRType::Int: - return backend.basic_int_type; - case SPIRType::UInt: - return backend.basic_uint_type; - case SPIRType::AtomicCounter: - return "atomic_uint"; - case SPIRType::Float: - return "float"; - case SPIRType::Double: - return "double"; - case SPIRType::Int64: - return "int64_t"; - case SPIRType::UInt64: - return "uint64_t"; - default: - return "???"; - } - } - else if (type.vecsize > 1 && type.columns == 1) // Vector builtin - { - switch (type.basetype) - { - case SPIRType::Boolean: - return join("bool", type.vecsize); - case SPIRType::Int: - return join("int", type.vecsize); - case SPIRType::UInt: - return join("uint", type.vecsize); - case SPIRType::Float: - return join("float", type.vecsize); - case SPIRType::Double: - return join("double", type.vecsize); - case SPIRType::Int64: - return join("i64vec", type.vecsize); - case SPIRType::UInt64: - return join("u64vec", type.vecsize); - default: - return "???"; - } - } - else - { - switch (type.basetype) - { - case SPIRType::Boolean: - return join("bool", type.columns, "x", type.vecsize); - case SPIRType::Int: - return join("int", type.columns, "x", type.vecsize); - case SPIRType::UInt: - return join("uint", type.columns, "x", type.vecsize); - case SPIRType::Float: - return join("float", type.columns, "x", type.vecsize); - case SPIRType::Double: - return join("double", type.columns, "x", type.vecsize); - // Matrix types not supported for int64/uint64. - default: - return "???"; - } - } -} - -void CompilerHLSL::emit_header() -{ - for (auto &header : header_lines) - statement(header); - - if (header_lines.size() > 0) - { - statement(""); - } -} - -void CompilerHLSL::emit_interface_block_globally(const SPIRVariable &var) -{ - add_resource_name(var.self); - - // The global copies of I/O variables should not contain interpolation qualifiers. - // These are emitted inside the interface structs. - auto &flags = meta[var.self].decoration.decoration_flags; - auto old_flags = flags; - flags = 0; - statement("static ", variable_decl(var), ";"); - flags = old_flags; -} - -const char *CompilerHLSL::to_storage_qualifiers_glsl(const SPIRVariable &var) -{ - // Input and output variables are handled specially in HLSL backend. - // The variables are declared as global, private variables, and do not need any qualifiers. - if (var.storage == StorageClassUniformConstant || var.storage == StorageClassUniform || - var.storage == StorageClassPushConstant) - { - return "uniform "; - } - - return ""; -} - -void CompilerHLSL::emit_builtin_outputs_in_struct() -{ - bool legacy = options.shader_model <= 30; - for (uint32_t i = 0; i < 64; i++) - { - if (!(active_output_builtins & (1ull << i))) - continue; - - const char *type = nullptr; - const char *semantic = nullptr; - auto builtin = static_cast(i); - switch (builtin) - { - case BuiltInPosition: - type = "float4"; - semantic = legacy ? "POSITION" : "SV_Position"; - break; - - case BuiltInFragDepth: - type = "float"; - semantic = legacy ? "DEPTH" : "SV_Depth"; - break; - - case BuiltInPointSize: - // If point_size_compat is enabled, just ignore PointSize. - // PointSize does not exist in HLSL, but some code bases might want to be able to use these shaders, - // even if it means working around the missing feature. - if (options.point_size_compat) - break; - else - SPIRV_CROSS_THROW("Unsupported builtin in HLSL."); - - default: - SPIRV_CROSS_THROW("Unsupported builtin in HLSL."); - break; - } - - if (type && semantic) - statement(type, " ", builtin_to_glsl(builtin, StorageClassOutput), " : ", semantic, ";"); - } -} - -void CompilerHLSL::emit_builtin_inputs_in_struct() -{ - bool legacy = options.shader_model <= 30; - for (uint32_t i = 0; i < 64; i++) - { - if (!(active_input_builtins & (1ull << i))) - continue; - - const char *type = nullptr; - const char *semantic = nullptr; - auto builtin = static_cast(i); - switch (builtin) - { - case BuiltInFragCoord: - type = "float4"; - semantic = legacy ? "VPOS" : "SV_Position"; - break; - - case BuiltInVertexId: - case BuiltInVertexIndex: - if (legacy) - SPIRV_CROSS_THROW("Vertex index not supported in SM 3.0 or lower."); - type = "uint"; - semantic = "SV_VertexID"; - break; - - case BuiltInInstanceId: - case BuiltInInstanceIndex: - if (legacy) - SPIRV_CROSS_THROW("Instance index not supported in SM 3.0 or lower."); - type = "uint"; - semantic = "SV_InstanceID"; - break; - - case BuiltInSampleId: - if (legacy) - SPIRV_CROSS_THROW("Sample ID not supported in SM 3.0 or lower."); - type = "uint"; - semantic = "SV_SampleIndex"; - break; - - case BuiltInGlobalInvocationId: - type = "uint3"; - semantic = "SV_DispatchThreadID"; - break; - - case BuiltInLocalInvocationId: - type = "uint3"; - semantic = "SV_GroupThreadID"; - break; - - case BuiltInLocalInvocationIndex: - type = "uint"; - semantic = "SV_GroupIndex"; - break; - - case BuiltInWorkgroupId: - type = "uint3"; - semantic = "SV_GroupID"; - break; - - default: - SPIRV_CROSS_THROW("Unsupported builtin in HLSL."); - break; - } - - if (type && semantic) - statement(type, " ", builtin_to_glsl(builtin, StorageClassInput), " : ", semantic, ";"); - } -} - -uint32_t CompilerHLSL::type_to_consumed_locations(const SPIRType &type) const -{ - // TODO: Need to verify correctness. - uint32_t elements = 0; - - if (type.basetype == SPIRType::Struct) - { - for (uint32_t i = 0; i < uint32_t(type.member_types.size()); i++) - elements += type_to_consumed_locations(get(type.member_types[i])); - } - else - { - uint32_t array_multiplier = 1; - for (uint32_t i = 0; i < uint32_t(type.array.size()); i++) - { - if (type.array_size_literal[i]) - array_multiplier *= type.array[i]; - else - array_multiplier *= get(type.array[i]).scalar(); - } - elements += array_multiplier * type.columns; - } - return elements; -} - -string CompilerHLSL::to_interpolation_qualifiers(uint64_t flags) -{ - string res; - //if (flags & (1ull << DecorationSmooth)) - // res += "linear "; - if (flags & (1ull << DecorationFlat)) - res += "nointerpolation "; - if (flags & (1ull << DecorationNoPerspective)) - res += "noperspective "; - if (flags & (1ull << DecorationCentroid)) - res += "centroid "; - if (flags & (1ull << DecorationPatch)) - res += "patch "; // Seems to be different in actual HLSL. - if (flags & (1ull << DecorationSample)) - res += "sample "; - if (flags & (1ull << DecorationInvariant)) - res += "invariant "; // Not supported? - - return res; -} - -std::string CompilerHLSL::to_semantic(uint32_t vertex_location) -{ - for (auto &attribute : remap_vertex_attributes) - if (attribute.location == vertex_location) - return attribute.semantic; - - return join("TEXCOORD", vertex_location); -} - -void CompilerHLSL::emit_io_block(const SPIRVariable &var) -{ - auto &type = get(var.basetype); - add_resource_name(type.self); - - statement("struct ", to_name(type.self)); - begin_scope(); - type.member_name_cache.clear(); - - uint32_t base_location = get_decoration(var.self, DecorationLocation); - - for (uint32_t i = 0; i < uint32_t(type.member_types.size()); i++) - { - string semantic; - if (has_member_decoration(type.self, i, DecorationLocation)) - { - uint32_t location = get_member_decoration(type.self, i, DecorationLocation); - semantic = join(" : ", to_semantic(location)); - } - else - { - // If the block itself has a location, but not its members, use the implicit location. - // There could be a conflict if the block members partially specialize the locations. - // It is unclear how SPIR-V deals with this. Assume this does not happen for now. - uint32_t location = base_location + i; - semantic = join(" : ", to_semantic(location)); - } - - add_member_name(type, i); - - auto &membertype = get(type.member_types[i]); - statement(to_interpolation_qualifiers(get_member_decoration_mask(type.self, i)), - variable_decl(membertype, to_member_name(type, i)), semantic, ";"); - } - - end_scope_decl(); - statement(""); - - statement("static ", variable_decl(var), ";"); - statement(""); -} - -void CompilerHLSL::emit_interface_block_in_struct(const SPIRVariable &var, unordered_set &active_locations) -{ - auto &execution = get_entry_point(); - auto &type = get(var.basetype); - - string binding; - bool use_location_number = true; - bool legacy = options.shader_model <= 30; - if (execution.model == ExecutionModelFragment && var.storage == StorageClassOutput) - { - binding = join(legacy ? "COLOR" : "SV_Target", get_decoration(var.self, DecorationLocation)); - use_location_number = false; - } - - const auto get_vacant_location = [&]() -> uint32_t { - for (uint32_t i = 0; i < 64; i++) - if (!active_locations.count(i)) - return i; - SPIRV_CROSS_THROW("All locations from 0 to 63 are exhausted."); - }; - - bool need_matrix_unroll = var.storage == StorageClassInput && execution.model == ExecutionModelVertex; - - auto &m = meta[var.self].decoration; - auto name = to_name(var.self); - if (use_location_number) - { - uint32_t location_number; - - // If an explicit location exists, use it with TEXCOORD[N] semantic. - // Otherwise, pick a vacant location. - if (m.decoration_flags & (1ull << DecorationLocation)) - location_number = m.location; - else - location_number = get_vacant_location(); - - // Allow semantic remap if specified. - auto semantic = to_semantic(location_number); - - if (need_matrix_unroll && type.columns > 1) - { - if (!type.array.empty()) - SPIRV_CROSS_THROW("Arrays of matrices used as input/output. This is not supported."); - - // Unroll matrices. - for (uint32_t i = 0; i < type.columns; i++) - { - SPIRType newtype = type; - newtype.columns = 1; - statement(to_interpolation_qualifiers(get_decoration_mask(var.self)), - variable_decl(newtype, join(name, "_", i)), " : ", semantic, "_", i, ";"); - active_locations.insert(location_number++); - } - } - else - { - statement(to_interpolation_qualifiers(get_decoration_mask(var.self)), variable_decl(type, name), " : ", - semantic, ";"); - - // Structs and arrays should consume more locations. - uint32_t consumed_locations = type_to_consumed_locations(type); - for (uint32_t i = 0; i < consumed_locations; i++) - active_locations.insert(location_number + i); - } - } - else - statement(variable_decl(type, name), " : ", binding, ";"); -} - -std::string CompilerHLSL::builtin_to_glsl(spv::BuiltIn builtin, spv::StorageClass storage) -{ - switch (builtin) - { - case BuiltInVertexId: - return "gl_VertexID"; - case BuiltInInstanceId: - return "gl_InstanceID"; - default: - return CompilerGLSL::builtin_to_glsl(builtin, storage); - } -} - -void CompilerHLSL::emit_builtin_variables() -{ - // Emit global variables for the interface variables which are statically used by the shader. - for (uint32_t i = 0; i < 64; i++) - { - if (!((active_input_builtins | active_output_builtins) & (1ull << i))) - continue; - - const char *type = nullptr; - auto builtin = static_cast(i); - - switch (builtin) - { - case BuiltInFragCoord: - case BuiltInPosition: - type = "float4"; - break; - - case BuiltInFragDepth: - type = "float"; - break; - - case BuiltInVertexId: - case BuiltInVertexIndex: - case BuiltInInstanceId: - case BuiltInInstanceIndex: - case BuiltInSampleId: - type = "int"; - break; - - case BuiltInPointSize: - if (options.point_size_compat) - { - // Just emit the global variable, it will be ignored. - type = "float"; - break; - } - else - SPIRV_CROSS_THROW(join("Unsupported builtin in HLSL: ", unsigned(builtin))); - - case BuiltInGlobalInvocationId: - case BuiltInLocalInvocationId: - case BuiltInWorkgroupId: - type = "uint3"; - break; - - case BuiltInLocalInvocationIndex: - type = "uint"; - break; - - default: - SPIRV_CROSS_THROW(join("Unsupported builtin in HLSL: ", unsigned(builtin))); - break; - } - - StorageClass storage = (active_input_builtins & (1ull << i)) != 0 ? StorageClassInput : StorageClassOutput; - // FIXME: SampleMask can be both in and out with sample builtin, - // need to distinguish that when we add support for that. - - if (type) - statement("static ", type, " ", builtin_to_glsl(builtin, storage), ";"); - } -} - -void CompilerHLSL::emit_specialization_constants() -{ - bool emitted = false; - SpecializationConstant wg_x, wg_y, wg_z; - uint32_t workgroup_size_id = get_work_group_size_specialization_constants(wg_x, wg_y, wg_z); - - for (auto &id : ids) - { - if (id.get_type() == TypeConstant) - { - auto &c = id.get(); - if (!c.specialization) - continue; - if (c.self == workgroup_size_id) - continue; - - auto &type = get(c.constant_type); - auto name = to_name(c.self); - - statement("static const ", variable_decl(type, name), " = ", constant_expression(c), ";"); - emitted = true; - } - } - - if (workgroup_size_id) - { - statement("static const uint3 gl_WorkGroupSize = ", constant_expression(get(workgroup_size_id)), - ";"); - emitted = true; - } - - if (emitted) - statement(""); -} - -void CompilerHLSL::emit_resources() -{ - auto &execution = get_entry_point(); - - emit_specialization_constants(); - - // Output all basic struct types which are not Block or BufferBlock as these are declared inplace - // when such variables are instantiated. - for (auto &id : ids) - { - if (id.get_type() == TypeType) - { - auto &type = id.get(); - if (type.basetype == SPIRType::Struct && type.array.empty() && !type.pointer && - (meta[type.self].decoration.decoration_flags & - ((1ull << DecorationBlock) | (1ull << DecorationBufferBlock))) == 0) - { - emit_struct(type); - } - } - } - - bool emitted = false; - - // Output UBOs and SSBOs - for (auto &id : ids) - { - if (id.get_type() == TypeVariable) - { - auto &var = id.get(); - auto &type = get(var.basetype); - - bool is_block_storage = type.storage == StorageClassStorageBuffer || type.storage == StorageClassUniform; - bool has_block_flags = (meta[type.self].decoration.decoration_flags & - ((1ull << DecorationBlock) | (1ull << DecorationBufferBlock))) != 0; - - if (var.storage != StorageClassFunction && type.pointer && is_block_storage && !is_hidden_variable(var) && - has_block_flags) - { - emit_buffer_block(var); - emitted = true; - } - } - } - - // Output push constant blocks - for (auto &id : ids) - { - if (id.get_type() == TypeVariable) - { - auto &var = id.get(); - auto &type = get(var.basetype); - if (var.storage != StorageClassFunction && type.pointer && type.storage == StorageClassPushConstant && - !is_hidden_variable(var)) - { - emit_push_constant_block(var); - emitted = true; - } - } - } - - if (execution.model == ExecutionModelVertex && options.shader_model <= 30) - { - statement("uniform float4 gl_HalfPixel;"); - emitted = true; - } - - // Output Uniform Constants (values, samplers, images, etc). - for (auto &id : ids) - { - if (id.get_type() == TypeVariable) - { - auto &var = id.get(); - auto &type = get(var.basetype); - - if (var.storage != StorageClassFunction && !is_builtin_variable(var) && !var.remapped_variable && - type.pointer && - (type.storage == StorageClassUniformConstant || type.storage == StorageClassAtomicCounter)) - { - emit_uniform(var); - emitted = true; - } - } - } - - if (emitted) - statement(""); - emitted = false; - - // Emit builtin input and output variables here. - emit_builtin_variables(); - - for (auto &id : ids) - { - if (id.get_type() == TypeVariable) - { - auto &var = id.get(); - auto &type = get(var.basetype); - bool block = (meta[type.self].decoration.decoration_flags & (1ull << DecorationBlock)) != 0; - - // Do not emit I/O blocks here. - // I/O blocks can be arrayed, so we must deal with them separately to support geometry shaders - // and tessellation down the line. - if (!block && var.storage != StorageClassFunction && !var.remapped_variable && type.pointer && - (var.storage == StorageClassInput || var.storage == StorageClassOutput) && !is_builtin_variable(var) && - interface_variable_exists_in_entry_point(var.self)) - { - // Only emit non-builtins which are not blocks here. Builtin variables are handled separately. - emit_interface_block_globally(var); - emitted = true; - } - } - } - - if (emitted) - statement(""); - emitted = false; - - require_input = false; - require_output = false; - unordered_set active_inputs; - unordered_set active_outputs; - vector input_variables; - vector output_variables; - for (auto &id : ids) - { - if (id.get_type() == TypeVariable) - { - auto &var = id.get(); - auto &type = get(var.basetype); - bool block = (meta[type.self].decoration.decoration_flags & (1ull << DecorationBlock)) != 0; - - if (var.storage != StorageClassInput && var.storage != StorageClassOutput) - continue; - - // Do not emit I/O blocks here. - // I/O blocks can be arrayed, so we must deal with them separately to support geometry shaders - // and tessellation down the line. - if (!block && !var.remapped_variable && type.pointer && !is_builtin_variable(var) && - interface_variable_exists_in_entry_point(var.self)) - { - if (var.storage == StorageClassInput) - input_variables.push_back(&var); - else - output_variables.push_back(&var); - } - - // Reserve input and output locations for block variables as necessary. - if (block && !is_builtin_variable(var) && interface_variable_exists_in_entry_point(var.self)) - { - auto &active = var.storage == StorageClassInput ? active_inputs : active_outputs; - for (uint32_t i = 0; i < uint32_t(type.member_types.size()); i++) - { - if (has_member_decoration(type.self, i, DecorationLocation)) - { - uint32_t location = get_member_decoration(type.self, i, DecorationLocation); - active.insert(location); - } - } - - // Emit the block struct and a global variable here. - emit_io_block(var); - } - } - } - - const auto variable_compare = [&](const SPIRVariable *a, const SPIRVariable *b) -> bool { - // Sort input and output variables based on, from more robust to less robust: - // - Location - // - Variable has a location - // - Name comparison - // - Variable has a name - // - Fallback: ID - bool has_location_a = has_decoration(a->self, DecorationLocation); - bool has_location_b = has_decoration(b->self, DecorationLocation); - - if (has_location_a && has_location_b) - { - return get_decoration(a->self, DecorationLocation) < get_decoration(b->self, DecorationLocation); - } - else if (has_location_a && !has_location_b) - return true; - else if (!has_location_a && has_location_b) - return false; - - const auto &name1 = to_name(a->self); - const auto &name2 = to_name(b->self); - - if (name1.empty() && name2.empty()) - return a->self < b->self; - else if (name1.empty()) - return true; - else if (name2.empty()) - return false; - - return name1.compare(name2) < 0; - }; - - if (!input_variables.empty() || active_input_builtins) - { - require_input = true; - statement("struct SPIRV_Cross_Input"); - - begin_scope(); - sort(input_variables.begin(), input_variables.end(), variable_compare); - for (auto var : input_variables) - emit_interface_block_in_struct(*var, active_inputs); - emit_builtin_inputs_in_struct(); - end_scope_decl(); - statement(""); - } - - if (!output_variables.empty() || active_output_builtins) - { - require_output = true; - statement("struct SPIRV_Cross_Output"); - - begin_scope(); - // FIXME: Use locations properly if they exist. - sort(output_variables.begin(), output_variables.end(), variable_compare); - for (auto var : output_variables) - emit_interface_block_in_struct(*var, active_outputs); - emit_builtin_outputs_in_struct(); - end_scope_decl(); - statement(""); - } - - // Global variables. - for (auto global : global_variables) - { - auto &var = get(global); - if (var.storage != StorageClassOutput) - { - add_resource_name(var.self); - - const char *storage = nullptr; - switch (var.storage) - { - case StorageClassWorkgroup: - storage = "groupshared"; - break; - - default: - storage = "static"; - break; - } - statement(storage, " ", variable_decl(var), ";"); - emitted = true; - } - } - - if (emitted) - statement(""); - - declare_undefined_values(); - - if (requires_op_fmod) - { - static const char *types[] = { - "float", - "float2", - "float3", - "float4", - }; - - for (auto &type : types) - { - statement(type, " mod(", type, " x, ", type, " y)"); - begin_scope(); - statement("return x - y * floor(x / y);"); - end_scope(); - statement(""); - } - } - - if (requires_textureProj) - { - if (options.shader_model >= 40) - { - statement("float SPIRV_Cross_projectTextureCoordinate(float2 coord)"); - begin_scope(); - statement("return coord.x / coord.y;"); - end_scope(); - statement(""); - - statement("float2 SPIRV_Cross_projectTextureCoordinate(float3 coord)"); - begin_scope(); - statement("return float2(coord.x, coord.y) / coord.z;"); - end_scope(); - statement(""); - - statement("float3 SPIRV_Cross_projectTextureCoordinate(float4 coord)"); - begin_scope(); - statement("return float3(coord.x, coord.y, coord.z) / coord.w;"); - end_scope(); - statement(""); - } - else - { - statement("float4 SPIRV_Cross_projectTextureCoordinate(float2 coord)"); - begin_scope(); - statement("return float4(coord.x, 0.0, 0.0, coord.y);"); - end_scope(); - statement(""); - - statement("float4 SPIRV_Cross_projectTextureCoordinate(float3 coord)"); - begin_scope(); - statement("return float4(coord.x, coord.y, 0.0, coord.z);"); - end_scope(); - statement(""); - - statement("float4 SPIRV_Cross_projectTextureCoordinate(float4 coord)"); - begin_scope(); - statement("return coord;"); - end_scope(); - statement(""); - } - } - - if (required_textureSizeVariants != 0) - { - static const char *types[QueryTypeCount] = { "float4", "int4", "uint4" }; - static const char *dims[QueryDimCount] = { "Texture1D", "Texture1DArray", "Texture2D", "Texture2DArray", - "Texture3D", "Buffer", "TextureCube", "TextureCubeArray", - "Texture2DMS", "Texture2DMSArray" }; - - static const bool has_lod[QueryDimCount] = { true, true, true, true, true, false, true, true, false, false }; - - static const char *ret_types[QueryDimCount] = { - "uint", "uint2", "uint2", "uint3", "uint3", "uint", "uint2", "uint3", "uint2", "uint3", - }; - - static const uint32_t return_arguments[QueryDimCount] = { - 1, 2, 2, 3, 3, 1, 2, 3, 2, 3, - }; - - for (uint32_t index = 0; index < QueryDimCount; index++) - { - for (uint32_t type_index = 0; type_index < QueryTypeCount; type_index++) - { - uint32_t bit = 16 * type_index + index; - uint64_t mask = 1ull << bit; - - if ((required_textureSizeVariants & mask) == 0) - continue; - - statement(ret_types[index], " SPIRV_Cross_textureSize(", dims[index], "<", types[type_index], - "> Tex, uint Level, out uint Param)"); - begin_scope(); - statement(ret_types[index], " ret;"); - switch (return_arguments[index]) - { - case 1: - if (has_lod[index]) - statement("Tex.GetDimensions(Level, ret.x, Param);"); - else - { - statement("Tex.GetDimensions(ret.x);"); - statement("Param = 0u;"); - } - break; - case 2: - if (has_lod[index]) - statement("Tex.GetDimensions(Level, ret.x, ret.y, Param);"); - else - statement("Tex.GetDimensions(ret.x, ret.y, Param);"); - break; - case 3: - if (has_lod[index]) - statement("Tex.GetDimensions(Level, ret.x, ret.y, ret.z, Param);"); - else - statement("Tex.GetDimensions(ret.x, ret.y, ret.z, Param);"); - break; - } - - statement("return ret;"); - end_scope(); - statement(""); - } - } - } - - if (requires_fp16_packing) - { - // HLSL does not pack into a single word sadly :( - statement("uint SPIRV_Cross_packHalf2x16(float2 value)"); - begin_scope(); - statement("uint2 Packed = f32tof16(value);"); - statement("return Packed.x | (Packed.y << 16);"); - end_scope(); - statement(""); - - statement("float2 SPIRV_Cross_unpackHalf2x16(uint value)"); - begin_scope(); - statement("return f16tof32(uint2(value & 0xffff, value >> 16));"); - end_scope(); - statement(""); - } - - // HLSL does not seem to have builtins for these operation, so roll them by hand ... - if (requires_unorm8_packing) - { - statement("uint SPIRV_Cross_packUnorm4x8(float4 value)"); - begin_scope(); - statement("uint4 Packed = uint4(round(saturate(value) * 255.0));"); - statement("return Packed.x | (Packed.y << 8) | (Packed.z << 16) | (Packed.w << 24);"); - end_scope(); - statement(""); - - statement("float4 SPIRV_Cross_unpackUnorm4x8(uint value)"); - begin_scope(); - statement("uint4 Packed = uint4(value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, value >> 24);"); - statement("return float4(Packed) / 255.0;"); - end_scope(); - statement(""); - } - - if (requires_snorm8_packing) - { - statement("uint SPIRV_Cross_packSnorm4x8(float4 value)"); - begin_scope(); - statement("int4 Packed = int4(round(clamp(value, -1.0, 1.0) * 127.0)) & 0xff;"); - statement("return uint(Packed.x | (Packed.y << 8) | (Packed.z << 16) | (Packed.w << 24));"); - end_scope(); - statement(""); - - statement("float4 SPIRV_Cross_unpackSnorm4x8(uint value)"); - begin_scope(); - statement("int SignedValue = int(value);"); - statement("int4 Packed = int4(SignedValue << 24, SignedValue << 16, SignedValue << 8, SignedValue) >> 24;"); - statement("return clamp(float4(Packed) / 127.0, -1.0, 1.0);"); - end_scope(); - statement(""); - } - - if (requires_unorm16_packing) - { - statement("uint SPIRV_Cross_packUnorm2x16(float2 value)"); - begin_scope(); - statement("uint2 Packed = uint2(round(saturate(value) * 65535.0));"); - statement("return Packed.x | (Packed.y << 16);"); - end_scope(); - statement(""); - - statement("float2 SPIRV_Cross_unpackUnorm2x16(uint value)"); - begin_scope(); - statement("uint2 Packed = uint2(value & 0xffff, value >> 16);"); - statement("return float2(Packed) / 65535.0;"); - end_scope(); - statement(""); - } - - if (requires_snorm16_packing) - { - statement("uint SPIRV_Cross_packSnorm2x16(float2 value)"); - begin_scope(); - statement("int2 Packed = int2(round(clamp(value, -1.0, 1.0) * 32767.0)) & 0xffff;"); - statement("return uint(Packed.x | (Packed.y << 16));"); - end_scope(); - statement(""); - - statement("float2 SPIRV_Cross_unpackSnorm2x16(uint value)"); - begin_scope(); - statement("int SignedValue = int(value);"); - statement("int2 Packed = int2(SignedValue << 16, SignedValue) >> 16;"); - statement("return clamp(float2(Packed) / 32767.0, -1.0, 1.0);"); - end_scope(); - statement(""); - } - - if (requires_bitfield_insert) - { - static const char *types[] = { "uint", "uint2", "uint3", "uint4" }; - for (auto &type : types) - { - statement(type, " SPIRV_Cross_bitfieldInsert(", type, " Base, ", type, " Insert, uint Offset, uint Count)"); - begin_scope(); - statement("uint Mask = Count == 32 ? 0xffffffff : (((1u << Count) - 1) << (Offset & 31));"); - statement("return (Base & ~Mask) | ((Insert << Offset) & Mask);"); - end_scope(); - statement(""); - } - } - - if (requires_bitfield_extract) - { - static const char *unsigned_types[] = { "uint", "uint2", "uint3", "uint4" }; - for (auto &type : unsigned_types) - { - statement(type, " SPIRV_Cross_bitfieldUExtract(", type, " Base, uint Offset, uint Count)"); - begin_scope(); - statement("uint Mask = Count == 32 ? 0xffffffff : ((1 << Count) - 1);"); - statement("return (Base >> Offset) & Mask;"); - end_scope(); - statement(""); - } - - // In this overload, we will have to do sign-extension, which we will emulate by shifting up and down. - static const char *signed_types[] = { "int", "int2", "int3", "int4" }; - for (auto &type : signed_types) - { - statement(type, " SPIRV_Cross_bitfieldSExtract(", type, " Base, int Offset, int Count)"); - begin_scope(); - statement("int Mask = Count == 32 ? -1 : ((1 << Count) - 1);"); - statement(type, " Masked = (Base >> Offset) & Mask;"); - statement("int ExtendShift = (32 - Count) & 31;"); - statement("return (Masked << ExtendShift) >> ExtendShift;"); - end_scope(); - statement(""); - } - } -} - -string CompilerHLSL::layout_for_member(const SPIRType &type, uint32_t index) -{ - auto flags = combined_decoration_for_member(type, index); - - bool is_block = (meta[type.self].decoration.decoration_flags & - ((1ull << DecorationBlock) | (1ull << DecorationBufferBlock))) != 0; - - if (!is_block) - return ""; - - // Flip the convention. HLSL is a bit odd in that the memory layout is column major ... but the language API is "row-major". - // The way to deal with this is to multiply everything in inverse order, and reverse the memory layout. - if (flags & (1ull << DecorationColMajor)) - return "row_major "; - else if (flags & (1ull << DecorationRowMajor)) - return "column_major "; - - return ""; -} - -void CompilerHLSL::emit_struct_member(const SPIRType &type, uint32_t member_type_id, uint32_t index, - const string &qualifier) -{ - auto &membertype = get(member_type_id); - - uint64_t memberflags = 0; - auto &memb = meta[type.self].members; - if (index < memb.size()) - memberflags = memb[index].decoration_flags; - - string qualifiers; - bool is_block = (meta[type.self].decoration.decoration_flags & - ((1ull << DecorationBlock) | (1ull << DecorationBufferBlock))) != 0; - if (is_block) - qualifiers = to_interpolation_qualifiers(memberflags); - - string packing_offset; - if (has_decoration(type.self, DecorationCPacked) && has_member_decoration(type.self, index, DecorationOffset)) - { - uint32_t offset = memb[index].offset; - if (offset & 3) - SPIRV_CROSS_THROW("Cannot pack on tighter bounds than 4 bytes in HLSL."); - - static const char *packing_swizzle[] = { "", ".y", ".z", ".w" }; - packing_offset = join(" : packoffset(c", offset / 16, packing_swizzle[(offset & 15) >> 2], ")"); - } - - statement(layout_for_member(type, index), qualifiers, qualifier, - variable_decl(membertype, to_member_name(type, index)), packing_offset, ";"); -} - -void CompilerHLSL::emit_buffer_block(const SPIRVariable &var) -{ - auto &type = get(var.basetype); - - bool is_uav = var.storage == StorageClassStorageBuffer || has_decoration(type.self, DecorationBufferBlock); - - if (is_uav) - { - uint64_t flags = get_buffer_block_flags(var); - bool is_readonly = (flags & (1ull << DecorationNonWritable)) != 0; - add_resource_name(var.self); - statement(is_readonly ? "ByteAddressBuffer " : "RWByteAddressBuffer ", to_name(var.self), - type_to_array_glsl(type), to_resource_binding(var), ";"); - } - else - { - if (type.array.empty()) - { - if (buffer_is_packing_standard(type, BufferPackingHLSLCbufferPackOffset)) - set_decoration(type.self, DecorationCPacked); - else - SPIRV_CROSS_THROW("cbuffer cannot be expressed with either HLSL packing layout or packoffset."); - - // Flatten the top-level struct so we can use packoffset, - // this restriction is similar to GLSL where layout(offset) is not possible on sub-structs. - flattened_structs.insert(var.self); - - type.member_name_cache.clear(); - add_resource_name(var.self); - statement("cbuffer ", to_name(var.self), to_resource_binding(var)); - begin_scope(); - - uint32_t i = 0; - for (auto &member : type.member_types) - { - add_member_name(type, i); - auto backup_name = get_member_name(type.self, i); - auto member_name = to_member_name(type, i); - set_member_name(type.self, i, sanitize_underscores(join(to_name(var.self), "_", member_name))); - emit_struct_member(type, member, i, ""); - set_member_name(type.self, i, backup_name); - i++; - } - - end_scope_decl(); - } - else - { - if (options.shader_model < 51) - SPIRV_CROSS_THROW( - "Need ConstantBuffer to use arrays of UBOs, but this is only supported in SM 5.1."); - - // ConstantBuffer does not support packoffset, so it is unuseable unless everything aligns as we expect. - if (!buffer_is_packing_standard(type, BufferPackingHLSLCbuffer)) - SPIRV_CROSS_THROW("HLSL ConstantBuffer cannot be expressed with normal HLSL packing rules."); - - add_resource_name(type.self); - add_resource_name(var.self); - - emit_struct(get(type.self)); - statement("ConstantBuffer<", to_name(type.self), "> ", to_name(var.self), type_to_array_glsl(type), - to_resource_binding(var), ";"); - } - } -} - -void CompilerHLSL::emit_push_constant_block(const SPIRVariable &var) -{ - emit_buffer_block(var); -} - -string CompilerHLSL::to_sampler_expression(uint32_t id) -{ - auto expr = join("_", to_expression(id)); - auto index = expr.find_first_of('['); - if (index == string::npos) - { - return expr + "_sampler"; - } - else - { - // We have an expression like _ident[array], so we cannot tack on _sampler, insert it inside the string instead. - return expr.insert(index, "_sampler"); - } -} - -void CompilerHLSL::emit_sampled_image_op(uint32_t result_type, uint32_t result_id, uint32_t image_id, uint32_t samp_id) -{ - set(result_id, result_type, image_id, samp_id); -} - -string CompilerHLSL::to_func_call_arg(uint32_t id) -{ - string arg_str = CompilerGLSL::to_func_call_arg(id); - - if (options.shader_model <= 30) - return arg_str; - - // Manufacture automatic sampler arg if the arg is a SampledImage texture and we're in modern HLSL. - auto &type = expression_type(id); - - // We don't have to consider combined image samplers here via OpSampledImage because - // those variables cannot be passed as arguments to functions. - // Only global SampledImage variables may be used as arguments. - if (type.basetype == SPIRType::SampledImage && type.image.dim != DimBuffer) - arg_str += ", " + to_sampler_expression(id); - - return arg_str; -} - -void CompilerHLSL::emit_function_prototype(SPIRFunction &func, uint64_t return_flags) -{ - auto &execution = get_entry_point(); - // Avoid shadow declarations. - local_variable_names = resource_names; - - string decl; - - auto &type = get(func.return_type); - decl += flags_to_precision_qualifiers_glsl(type, return_flags); - decl += type_to_glsl(type); - decl += " "; - - if (func.self == entry_point) - { - if (execution.model == ExecutionModelVertex) - decl += "vert_main"; - else if (execution.model == ExecutionModelFragment) - decl += "frag_main"; - else if (execution.model == ExecutionModelGLCompute) - decl += "comp_main"; - else - SPIRV_CROSS_THROW("Unsupported execution model."); - processing_entry_point = true; - } - else - decl += to_name(func.self); - - decl += "("; - for (auto &arg : func.arguments) - { - // Might change the variable name if it already exists in this function. - // SPIRV OpName doesn't have any semantic effect, so it's valid for an implementation - // to use same name for variables. - // Since we want to make the GLSL debuggable and somewhat sane, use fallback names for variables which are duplicates. - add_local_variable_name(arg.id); - - decl += argument_decl(arg); - - // Flatten a combined sampler to two separate arguments in modern HLSL. - auto &arg_type = get(arg.type); - if (options.shader_model > 30 && arg_type.basetype == SPIRType::SampledImage && arg_type.image.dim != DimBuffer) - { - // Manufacture automatic sampler arg for SampledImage texture - decl += ", "; - decl += - join(arg_type.image.depth ? "SamplerComparisonState " : "SamplerState ", to_sampler_expression(arg.id)); - } - - if (&arg != &func.arguments.back()) - decl += ", "; - - // Hold a pointer to the parameter so we can invalidate the readonly field if needed. - auto *var = maybe_get(arg.id); - if (var) - var->parameter = &arg; - } - - decl += ")"; - statement(decl); -} - -void CompilerHLSL::emit_hlsl_entry_point() -{ - vector arguments; - - if (require_input) - arguments.push_back("SPIRV_Cross_Input stage_input"); - - // Add I/O blocks as separate arguments with appropriate storage qualifier. - for (auto &id : ids) - { - if (id.get_type() == TypeVariable) - { - auto &var = id.get(); - auto &type = get(var.basetype); - bool block = (meta[type.self].decoration.decoration_flags & (1ull << DecorationBlock)) != 0; - - if (var.storage != StorageClassInput && var.storage != StorageClassOutput) - continue; - - if (block && !is_builtin_variable(var) && interface_variable_exists_in_entry_point(var.self)) - { - if (var.storage == StorageClassInput) - { - arguments.push_back(join("in ", variable_decl(type, join("stage_input", to_name(var.self))))); - } - else if (var.storage == StorageClassOutput) - { - arguments.push_back(join("out ", variable_decl(type, join("stage_output", to_name(var.self))))); - } - } - } - } - - auto &execution = get_entry_point(); - - switch (execution.model) - { - case ExecutionModelGLCompute: - { - SpecializationConstant wg_x, wg_y, wg_z; - get_work_group_size_specialization_constants(wg_x, wg_y, wg_z); - - uint32_t x = execution.workgroup_size.x; - uint32_t y = execution.workgroup_size.y; - uint32_t z = execution.workgroup_size.z; - - if (wg_x.id) - x = get(wg_x.id).scalar(); - if (wg_y.id) - y = get(wg_y.id).scalar(); - if (wg_z.id) - z = get(wg_z.id).scalar(); - - statement("[numthreads(", x, ", ", y, ", ", z, ")]"); - break; - } - case ExecutionModelFragment: - if (execution.flags & (1ull << ExecutionModeEarlyFragmentTests)) - statement("[earlydepthstencil]"); - break; - default: - break; - } - - statement(require_output ? "SPIRV_Cross_Output " : "void ", "main(", merge(arguments), ")"); - begin_scope(); - bool legacy = options.shader_model <= 30; - - // Copy builtins from entry point arguments to globals. - for (uint32_t i = 0; i < 64; i++) - { - if (!(active_input_builtins & (1ull << i))) - continue; - - auto builtin = builtin_to_glsl(static_cast(i), StorageClassInput); - switch (static_cast(i)) - { - case BuiltInFragCoord: - // VPOS in D3D9 is sampled at integer locations, apply half-pixel offset to be consistent. - // TODO: Do we need an option here? Any reason why a D3D9 shader would be used - // on a D3D10+ system with a different rasterization config? - if (legacy) - statement(builtin, " = stage_input.", builtin, " + float4(0.5f, 0.5f, 0.0f, 0.0f);"); - else - statement(builtin, " = stage_input.", builtin, ";"); - break; - - case BuiltInVertexId: - case BuiltInVertexIndex: - case BuiltInInstanceId: - case BuiltInInstanceIndex: - // D3D semantics are uint, but shader wants int. - statement(builtin, " = int(stage_input.", builtin, ");"); - break; - - default: - statement(builtin, " = stage_input.", builtin, ";"); - break; - } - } - - // Copy from stage input struct to globals. - for (auto &id : ids) - { - if (id.get_type() == TypeVariable) - { - auto &var = id.get(); - auto &type = get(var.basetype); - bool block = (meta[type.self].decoration.decoration_flags & (1ull << DecorationBlock)) != 0; - - if (var.storage != StorageClassInput) - continue; - - bool need_matrix_unroll = var.storage == StorageClassInput && execution.model == ExecutionModelVertex; - - if (!block && !var.remapped_variable && type.pointer && !is_builtin_variable(var) && - interface_variable_exists_in_entry_point(var.self)) - { - auto name = to_name(var.self); - auto &mtype = get(var.basetype); - if (need_matrix_unroll && mtype.columns > 1) - { - // Unroll matrices. - for (uint32_t col = 0; col < mtype.columns; col++) - statement(name, "[", col, "] = stage_input.", name, "_", col, ";"); - } - else - { - statement(name, " = stage_input.", name, ";"); - } - } - - // I/O blocks don't use the common stage input/output struct, but separate outputs. - if (block && !is_builtin_variable(var) && interface_variable_exists_in_entry_point(var.self)) - { - auto name = to_name(var.self); - statement(name, " = stage_input", name, ";"); - } - } - } - - // Run the shader. - if (execution.model == ExecutionModelVertex) - statement("vert_main();"); - else if (execution.model == ExecutionModelFragment) - statement("frag_main();"); - else if (execution.model == ExecutionModelGLCompute) - statement("comp_main();"); - else - SPIRV_CROSS_THROW("Unsupported shader stage."); - - // Copy block outputs. - for (auto &id : ids) - { - if (id.get_type() == TypeVariable) - { - auto &var = id.get(); - auto &type = get(var.basetype); - bool block = (meta[type.self].decoration.decoration_flags & (1ull << DecorationBlock)) != 0; - - if (var.storage != StorageClassOutput) - continue; - - // I/O blocks don't use the common stage input/output struct, but separate outputs. - if (block && !is_builtin_variable(var) && interface_variable_exists_in_entry_point(var.self)) - { - auto name = to_name(var.self); - statement("stage_output", name, " = ", name, ";"); - } - } - } - - // Copy stage outputs. - if (require_output) - { - statement("SPIRV_Cross_Output stage_output;"); - - // Copy builtins from globals to return struct. - for (uint32_t i = 0; i < 64; i++) - { - if (!(active_output_builtins & (1ull << i))) - continue; - - // PointSize doesn't exist in HLSL. - if (i == BuiltInPointSize) - continue; - - auto builtin = builtin_to_glsl(static_cast(i), StorageClassOutput); - statement("stage_output.", builtin, " = ", builtin, ";"); - } - - for (auto &id : ids) - { - if (id.get_type() == TypeVariable) - { - auto &var = id.get(); - auto &type = get(var.basetype); - bool block = (meta[type.self].decoration.decoration_flags & (1ull << DecorationBlock)) != 0; - - if (var.storage != StorageClassOutput) - continue; - - if (!block && var.storage != StorageClassFunction && !var.remapped_variable && type.pointer && - !is_builtin_variable(var) && interface_variable_exists_in_entry_point(var.self)) - { - auto name = to_name(var.self); - statement("stage_output.", name, " = ", name, ";"); - } - } - } - - statement("return stage_output;"); - } - - end_scope(); -} - -void CompilerHLSL::emit_fixup() -{ - if (get_entry_point().model == ExecutionModelVertex) - { - // Do various mangling on the gl_Position. - if (options.shader_model <= 30) - { - statement("gl_Position.x = gl_Position.x - gl_HalfPixel.x * " - "gl_Position.w;"); - statement("gl_Position.y = gl_Position.y + gl_HalfPixel.y * " - "gl_Position.w;"); - } - - if (CompilerGLSL::options.vertex.flip_vert_y) - statement("gl_Position.y = -gl_Position.y;"); - if (CompilerGLSL::options.vertex.fixup_clipspace) - statement("gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;"); - } -} - -void CompilerHLSL::emit_texture_op(const Instruction &i) -{ - auto ops = stream(i); - auto op = static_cast(i.op); - uint32_t length = i.length; - - if (i.offset + length > spirv.size()) - SPIRV_CROSS_THROW("Compiler::parse() opcode out of range."); - - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - uint32_t img = ops[2]; - uint32_t coord = ops[3]; - uint32_t dref = 0; - uint32_t comp = 0; - bool gather = false; - bool proj = false; - const uint32_t *opt = nullptr; - auto *combined_image = maybe_get(img); - auto img_expr = to_expression(combined_image ? combined_image->image : img); - - switch (op) - { - case OpImageSampleDrefImplicitLod: - case OpImageSampleDrefExplicitLod: - dref = ops[4]; - opt = &ops[5]; - length -= 5; - break; - - case OpImageSampleProjDrefImplicitLod: - case OpImageSampleProjDrefExplicitLod: - dref = ops[4]; - proj = true; - opt = &ops[5]; - length -= 5; - break; - - case OpImageDrefGather: - dref = ops[4]; - opt = &ops[5]; - gather = true; - length -= 5; - break; - - case OpImageGather: - comp = ops[4]; - opt = &ops[5]; - gather = true; - length -= 5; - break; - - case OpImageSampleProjImplicitLod: - case OpImageSampleProjExplicitLod: - opt = &ops[4]; - length -= 4; - proj = true; - break; - - case OpImageQueryLod: - opt = &ops[4]; - length -= 4; - break; - - default: - opt = &ops[4]; - length -= 4; - break; - } - - auto &imgtype = expression_type(img); - uint32_t coord_components = 0; - switch (imgtype.image.dim) - { - case spv::Dim1D: - coord_components = 1; - break; - case spv::Dim2D: - coord_components = 2; - break; - case spv::Dim3D: - coord_components = 3; - break; - case spv::DimCube: - coord_components = 3; - break; - case spv::DimBuffer: - coord_components = 1; - break; - default: - coord_components = 2; - break; - } - - if (proj) - coord_components++; - if (imgtype.image.arrayed) - coord_components++; - - uint32_t bias = 0; - uint32_t lod = 0; - uint32_t grad_x = 0; - uint32_t grad_y = 0; - uint32_t coffset = 0; - uint32_t offset = 0; - uint32_t coffsets = 0; - uint32_t sample = 0; - uint32_t flags = 0; - - if (length) - { - flags = opt[0]; - opt++; - length--; - } - - auto test = [&](uint32_t &v, uint32_t flag) { - if (length && (flags & flag)) - { - v = *opt++; - length--; - } - }; - - test(bias, ImageOperandsBiasMask); - test(lod, ImageOperandsLodMask); - test(grad_x, ImageOperandsGradMask); - test(grad_y, ImageOperandsGradMask); - test(coffset, ImageOperandsConstOffsetMask); - test(offset, ImageOperandsOffsetMask); - test(coffsets, ImageOperandsConstOffsetsMask); - test(sample, ImageOperandsSampleMask); - - string expr; - string texop; - - if (op == OpImageFetch) - { - if (options.shader_model < 40) - { - SPIRV_CROSS_THROW("texelFetch is not supported in HLSL shader model 2/3."); - } - texop += img_expr; - texop += ".Load"; - } - else if (op == OpImageQueryLod) - { - texop += img_expr; - texop += ".CalculateLevelOfDetail"; - } - else - { - auto &imgformat = get(imgtype.image.type); - if (imgformat.basetype != SPIRType::Float) - { - SPIRV_CROSS_THROW("Sampling non-float textures is not supported in HLSL."); - } - - if (options.shader_model >= 40) - { - texop += img_expr; - - if (imgtype.image.depth) - { - if (gather) - { - SPIRV_CROSS_THROW("GatherCmp does not exist in HLSL."); - } - else if (lod || grad_x || grad_y) - { - // Assume we want a fixed level, and the only thing we can get in HLSL is SampleCmpLevelZero. - texop += ".SampleCmpLevelZero"; - } - else - texop += ".SampleCmp"; - } - else if (gather) - { - uint32_t comp_num = get(comp).scalar(); - if (options.shader_model >= 50) - { - switch (comp_num) - { - case 0: - texop += ".GatherRed"; - break; - case 1: - texop += ".GatherGreen"; - break; - case 2: - texop += ".GatherBlue"; - break; - case 3: - texop += ".GatherAlpha"; - break; - default: - SPIRV_CROSS_THROW("Invalid component."); - } - } - else - { - if (comp_num == 0) - texop += ".Gather"; - else - SPIRV_CROSS_THROW("HLSL shader model 4 can only gather from the red component."); - } - } - else if (bias) - texop += ".SampleBias"; - else if (grad_x || grad_y) - texop += ".SampleGrad"; - else if (lod) - texop += ".SampleLevel"; - else - texop += ".Sample"; - } - else - { - switch (imgtype.image.dim) - { - case Dim1D: - texop += "tex1D"; - break; - case Dim2D: - texop += "tex2D"; - break; - case Dim3D: - texop += "tex3D"; - break; - case DimCube: - texop += "texCUBE"; - break; - case DimRect: - case DimBuffer: - case DimSubpassData: - SPIRV_CROSS_THROW("Buffer texture support is not yet implemented for HLSL"); // TODO - default: - SPIRV_CROSS_THROW("Invalid dimension."); - } - - if (gather) - SPIRV_CROSS_THROW("textureGather is not supported in HLSL shader model 2/3."); - if (offset || coffset) - SPIRV_CROSS_THROW("textureOffset is not supported in HLSL shader model 2/3."); - if (proj) - texop += "proj"; - if (grad_x || grad_y) - texop += "grad"; - if (lod) - texop += "lod"; - if (bias) - texop += "bias"; - } - } - - expr += texop; - expr += "("; - if (options.shader_model < 40) - { - if (combined_image) - SPIRV_CROSS_THROW("Separate images/samplers are not supported in HLSL shader model 2/3."); - expr += to_expression(img); - } - else if (op != OpImageFetch) - { - string sampler_expr; - if (combined_image) - sampler_expr = to_expression(combined_image->sampler); - else - sampler_expr = to_sampler_expression(img); - expr += sampler_expr; - } - - auto swizzle = [](uint32_t comps, uint32_t in_comps) -> const char * { - if (comps == in_comps) - return ""; - - switch (comps) - { - case 1: - return ".x"; - case 2: - return ".xy"; - case 3: - return ".xyz"; - default: - return ""; - } - }; - - bool forward = should_forward(coord); - - // The IR can give us more components than we need, so chop them off as needed. - auto coord_expr = to_expression(coord) + swizzle(coord_components, expression_type(coord).vecsize); - - if (proj) - { - if (!requires_textureProj) - { - requires_textureProj = true; - force_recompile = true; - } - coord_expr = "SPIRV_Cross_projectTextureCoordinate(" + coord_expr + ")"; - } - - if (options.shader_model < 40 && lod) - { - auto &coordtype = expression_type(coord); - string coord_filler; - for (uint32_t size = coordtype.vecsize; size < 3; ++size) - { - coord_filler += ", 0.0"; - } - coord_expr = "float4(" + coord_expr + coord_filler + ", " + to_expression(lod) + ")"; - } - - if (options.shader_model < 40 && bias) - { - auto &coordtype = expression_type(coord); - string coord_filler; - for (uint32_t size = coordtype.vecsize; size < 3; ++size) - { - coord_filler += ", 0.0"; - } - coord_expr = "float4(" + coord_expr + coord_filler + ", " + to_expression(bias) + ")"; - } - - if (op == OpImageFetch) - { - auto &coordtype = expression_type(coord); - if (imgtype.image.dim != DimBuffer) - coord_expr = join("int", coordtype.vecsize + 1, "(", coord_expr, ", ", to_expression(lod), ")"); - } - else - expr += ", "; - expr += coord_expr; - - if (dref) - { - forward = forward && should_forward(dref); - expr += ", "; - expr += to_expression(dref); - } - - if (!dref && (grad_x || grad_y)) - { - forward = forward && should_forward(grad_x); - forward = forward && should_forward(grad_y); - expr += ", "; - expr += to_expression(grad_x); - expr += ", "; - expr += to_expression(grad_y); - } - - if (!dref && lod && options.shader_model >= 40 && op != OpImageFetch) - { - forward = forward && should_forward(lod); - expr += ", "; - expr += to_expression(lod); - } - - if (!dref && bias && options.shader_model >= 40) - { - forward = forward && should_forward(bias); - expr += ", "; - expr += to_expression(bias); - } - - if (coffset) - { - forward = forward && should_forward(coffset); - expr += ", "; - expr += to_expression(coffset); - } - else if (offset) - { - forward = forward && should_forward(offset); - expr += ", "; - expr += to_expression(offset); - } - - if (sample) - { - expr += ", "; - expr += to_expression(sample); - } - - expr += ")"; - - if (op == OpImageQueryLod) - { - // This is rather awkward. - // textureQueryLod returns two values, the "accessed level", - // as well as the actual LOD lambda. - // As far as I can tell, there is no way to get the .x component - // according to GLSL spec, and it depends on the sampler itself. - // Just assume X == Y, so we will need to splat the result to a float2. - statement("float _", id, "_tmp = ", expr, ";"); - emit_op(result_type, id, join("float2(_", id, "_tmp, _", id, "_tmp)"), true, true); - } - else - { - emit_op(result_type, id, expr, forward, false); - } -} - -string CompilerHLSL::to_resource_binding(const SPIRVariable &var) -{ - // TODO: Basic implementation, might need special consideration for RW/RO structured buffers, - // RW/RO images, and so on. - - if (!has_decoration(var.self, DecorationBinding)) - return ""; - - auto &type = get(var.basetype); - const char *space = nullptr; - - switch (type.basetype) - { - case SPIRType::SampledImage: - space = "t"; // SRV - break; - - case SPIRType::Image: - if (type.image.sampled == 2) - space = "u"; // UAV - else - space = "t"; // SRV - break; - - case SPIRType::Sampler: - space = "s"; - break; - - case SPIRType::Struct: - { - auto storage = type.storage; - if (storage == StorageClassUniform) - { - if (has_decoration(type.self, DecorationBufferBlock)) - { - uint64_t flags = get_buffer_block_flags(var); - bool is_readonly = (flags & (1ull << DecorationNonWritable)) != 0; - space = is_readonly ? "t" : "u"; // UAV - } - else if (has_decoration(type.self, DecorationBlock)) - space = "b"; // Constant buffers - } - else if (storage == StorageClassPushConstant) - space = "b"; // Constant buffers - else if (storage == StorageClassStorageBuffer) - space = "u"; // UAV - - break; - } - default: - break; - } - - if (!space) - return ""; - - // shader model 5.1 supports space - if (options.shader_model >= 51) - return join(" : register(", space, get_decoration(var.self, DecorationBinding), ", space", - get_decoration(var.self, DecorationDescriptorSet), ")"); - else - return join(" : register(", space, get_decoration(var.self, DecorationBinding), ")"); -} - -string CompilerHLSL::to_resource_binding_sampler(const SPIRVariable &var) -{ - // For combined image samplers. - if (!has_decoration(var.self, DecorationBinding)) - return ""; - - if (options.shader_model >= 51) - return join(" : register(s", get_decoration(var.self, DecorationBinding), ", space", - get_decoration(var.self, DecorationDescriptorSet), ")"); - else - return join(" : register(s", get_decoration(var.self, DecorationBinding), ")"); -} - -void CompilerHLSL::emit_modern_uniform(const SPIRVariable &var) -{ - auto &type = get(var.basetype); - switch (type.basetype) - { - case SPIRType::SampledImage: - case SPIRType::Image: - { - statement(image_type_hlsl_modern(type), " ", to_name(var.self), type_to_array_glsl(type), - to_resource_binding(var), ";"); - - if (type.basetype == SPIRType::SampledImage && type.image.dim != DimBuffer) - { - // For combined image samplers, also emit a combined image sampler. - if (type.image.depth) - statement("SamplerComparisonState ", to_sampler_expression(var.self), type_to_array_glsl(type), - to_resource_binding_sampler(var), ";"); - else - statement("SamplerState ", to_sampler_expression(var.self), type_to_array_glsl(type), - to_resource_binding_sampler(var), ";"); - } - break; - } - - case SPIRType::Sampler: - if (comparison_samplers.count(var.self)) - statement("SamplerComparisonState ", to_name(var.self), type_to_array_glsl(type), to_resource_binding(var), - ";"); - else - statement("SamplerState ", to_name(var.self), type_to_array_glsl(type), to_resource_binding(var), ";"); - break; - - default: - statement(variable_decl(var), to_resource_binding(var), ";"); - break; - } -} - -void CompilerHLSL::emit_legacy_uniform(const SPIRVariable &var) -{ - auto &type = get(var.basetype); - switch (type.basetype) - { - case SPIRType::Sampler: - case SPIRType::Image: - SPIRV_CROSS_THROW("Separate image and samplers not supported in legacy HLSL."); - - default: - statement(variable_decl(var), ";"); - break; - } -} - -void CompilerHLSL::emit_uniform(const SPIRVariable &var) -{ - add_resource_name(var.self); - if (options.shader_model >= 40) - emit_modern_uniform(var); - else - emit_legacy_uniform(var); -} - -string CompilerHLSL::bitcast_glsl_op(const SPIRType &out_type, const SPIRType &in_type) -{ - if (out_type.basetype == SPIRType::UInt && in_type.basetype == SPIRType::Int) - return type_to_glsl(out_type); - else if (out_type.basetype == SPIRType::UInt64 && in_type.basetype == SPIRType::Int64) - return type_to_glsl(out_type); - else if (out_type.basetype == SPIRType::UInt && in_type.basetype == SPIRType::Float) - return "asuint"; - else if (out_type.basetype == SPIRType::Int && in_type.basetype == SPIRType::UInt) - return type_to_glsl(out_type); - else if (out_type.basetype == SPIRType::Int64 && in_type.basetype == SPIRType::UInt64) - return type_to_glsl(out_type); - else if (out_type.basetype == SPIRType::Int && in_type.basetype == SPIRType::Float) - return "asint"; - else if (out_type.basetype == SPIRType::Float && in_type.basetype == SPIRType::UInt) - return "asfloat"; - else if (out_type.basetype == SPIRType::Float && in_type.basetype == SPIRType::Int) - return "asfloat"; - else if (out_type.basetype == SPIRType::Int64 && in_type.basetype == SPIRType::Double) - SPIRV_CROSS_THROW("Double to Int64 is not supported in HLSL."); - else if (out_type.basetype == SPIRType::UInt64 && in_type.basetype == SPIRType::Double) - SPIRV_CROSS_THROW("Double to UInt64 is not supported in HLSL."); - else if (out_type.basetype == SPIRType::Double && in_type.basetype == SPIRType::Int64) - return "asdouble"; - else if (out_type.basetype == SPIRType::Double && in_type.basetype == SPIRType::UInt64) - return "asdouble"; - else - return ""; -} - -void CompilerHLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop, const uint32_t *args, uint32_t count) -{ - GLSLstd450 op = static_cast(eop); - - switch (op) - { - case GLSLstd450InverseSqrt: - emit_unary_func_op(result_type, id, args[0], "rsqrt"); - break; - - case GLSLstd450Fract: - emit_unary_func_op(result_type, id, args[0], "frac"); - break; - - case GLSLstd450FMix: - case GLSLstd450IMix: - emit_trinary_func_op(result_type, id, args[0], args[1], args[2], "lerp"); - break; - - case GLSLstd450Atan2: - emit_binary_func_op(result_type, id, args[0], args[1], "atan2"); - break; - - case GLSLstd450Fma: - emit_trinary_func_op(result_type, id, args[0], args[1], args[2], "mad"); - break; - - case GLSLstd450InterpolateAtCentroid: - emit_unary_func_op(result_type, id, args[0], "EvaluateAttributeAtCentroid"); - break; - case GLSLstd450InterpolateAtSample: - emit_binary_func_op(result_type, id, args[0], args[1], "EvaluateAttributeAtSample"); - break; - case GLSLstd450InterpolateAtOffset: - emit_binary_func_op(result_type, id, args[0], args[1], "EvaluateAttributeSnapped"); - break; - - case GLSLstd450PackHalf2x16: - if (!requires_fp16_packing) - { - requires_fp16_packing = true; - force_recompile = true; - } - emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_packHalf2x16"); - break; - - case GLSLstd450UnpackHalf2x16: - if (!requires_fp16_packing) - { - requires_fp16_packing = true; - force_recompile = true; - } - emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_unpackHalf2x16"); - break; - - case GLSLstd450PackSnorm4x8: - if (!requires_snorm8_packing) - { - requires_snorm8_packing = true; - force_recompile = true; - } - emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_packSnorm4x8"); - break; - - case GLSLstd450UnpackSnorm4x8: - if (!requires_snorm8_packing) - { - requires_snorm8_packing = true; - force_recompile = true; - } - emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_unpackSnorm4x8"); - break; - - case GLSLstd450PackUnorm4x8: - if (!requires_unorm8_packing) - { - requires_unorm8_packing = true; - force_recompile = true; - } - emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_packUnorm4x8"); - break; - - case GLSLstd450UnpackUnorm4x8: - if (!requires_unorm8_packing) - { - requires_unorm8_packing = true; - force_recompile = true; - } - emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_unpackUnorm4x8"); - break; - - case GLSLstd450PackSnorm2x16: - if (!requires_snorm16_packing) - { - requires_snorm16_packing = true; - force_recompile = true; - } - emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_packSnorm2x16"); - break; - - case GLSLstd450UnpackSnorm2x16: - if (!requires_snorm16_packing) - { - requires_snorm16_packing = true; - force_recompile = true; - } - emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_unpackSnorm2x16"); - break; - - case GLSLstd450PackUnorm2x16: - if (!requires_unorm16_packing) - { - requires_unorm16_packing = true; - force_recompile = true; - } - emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_packUnorm2x16"); - break; - - case GLSLstd450UnpackUnorm2x16: - if (!requires_unorm16_packing) - { - requires_unorm16_packing = true; - force_recompile = true; - } - emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_unpackUnorm2x16"); - break; - - case GLSLstd450PackDouble2x32: - case GLSLstd450UnpackDouble2x32: - SPIRV_CROSS_THROW("packDouble2x32/unpackDouble2x32 not supported in HLSL."); - - case GLSLstd450FindILsb: - emit_unary_func_op(result_type, id, args[0], "firstbitlow"); - break; - case GLSLstd450FindSMsb: - case GLSLstd450FindUMsb: - emit_unary_func_op(result_type, id, args[0], "firstbithigh"); - break; - - default: - CompilerGLSL::emit_glsl_op(result_type, id, eop, args, count); - break; - } -} - -string CompilerHLSL::read_access_chain(const SPIRAccessChain &chain) -{ - auto &type = get(chain.basetype); - - SPIRType target_type; - target_type.basetype = SPIRType::UInt; - target_type.vecsize = type.vecsize; - target_type.columns = type.columns; - - if (type.basetype == SPIRType::Struct) - SPIRV_CROSS_THROW("Reading structs from ByteAddressBuffer not yet supported."); - - if (type.width != 32) - SPIRV_CROSS_THROW("Reading types other than 32-bit from ByteAddressBuffer not yet supported."); - - if (!type.array.empty()) - SPIRV_CROSS_THROW("Reading arrays from ByteAddressBuffer not yet supported."); - - string load_expr; - - // Load a vector or scalar. - if (type.columns == 1 && !chain.row_major_matrix) - { - const char *load_op = nullptr; - switch (type.vecsize) - { - case 1: - load_op = "Load"; - break; - case 2: - load_op = "Load2"; - break; - case 3: - load_op = "Load3"; - break; - case 4: - load_op = "Load4"; - break; - default: - SPIRV_CROSS_THROW("Unknown vector size."); - } - - load_expr = join(chain.base, ".", load_op, "(", chain.dynamic_index, chain.static_index, ")"); - } - else if (type.columns == 1) - { - // Strided load since we are loading a column from a row-major matrix. - if (type.vecsize > 1) - { - load_expr = type_to_glsl(target_type); - load_expr += "("; - } - - for (uint32_t r = 0; r < type.vecsize; r++) - { - load_expr += - join(chain.base, ".Load(", chain.dynamic_index, chain.static_index + r * chain.matrix_stride, ")"); - if (r + 1 < type.vecsize) - load_expr += ", "; - } - - if (type.vecsize > 1) - load_expr += ")"; - } - else if (!chain.row_major_matrix) - { - // Load a matrix, column-major, the easy case. - const char *load_op = nullptr; - switch (type.vecsize) - { - case 1: - load_op = "Load"; - break; - case 2: - load_op = "Load2"; - break; - case 3: - load_op = "Load3"; - break; - case 4: - load_op = "Load4"; - break; - default: - SPIRV_CROSS_THROW("Unknown vector size."); - } - - // Note, this loading style in HLSL is *actually* row-major, but we always treat matrices as transposed in this backend, - // so row-major is technically column-major ... - load_expr = type_to_glsl(target_type); - load_expr += "("; - for (uint32_t c = 0; c < type.columns; c++) - { - load_expr += join(chain.base, ".", load_op, "(", chain.dynamic_index, - chain.static_index + c * chain.matrix_stride, ")"); - if (c + 1 < type.columns) - load_expr += ", "; - } - load_expr += ")"; - } - else - { - // Pick out elements one by one ... Hopefully compilers are smart enough to recognize this pattern - // considering HLSL is "row-major decl", but "column-major" memory layout (basically implicit transpose model, ugh) ... - - load_expr = type_to_glsl(target_type); - load_expr += "("; - for (uint32_t c = 0; c < type.columns; c++) - { - for (uint32_t r = 0; r < type.vecsize; r++) - { - load_expr += join(chain.base, ".Load(", chain.dynamic_index, - chain.static_index + c * (type.width / 8) + r * chain.matrix_stride, ")"); - - if ((r + 1 < type.vecsize) || (c + 1 < type.columns)) - load_expr += ", "; - } - } - load_expr += ")"; - } - - auto bitcast_op = bitcast_glsl_op(type, target_type); - if (!bitcast_op.empty()) - load_expr = join(bitcast_op, "(", load_expr, ")"); - - return load_expr; -} - -void CompilerHLSL::emit_load(const Instruction &instruction) -{ - auto ops = stream(instruction); - - auto *chain = maybe_get(ops[2]); - if (chain) - { - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - uint32_t ptr = ops[2]; - - auto load_expr = read_access_chain(*chain); - - bool forward = should_forward(ptr) && forced_temporaries.find(id) == end(forced_temporaries); - - // Do not forward complex load sequences like matrices, structs and arrays. - auto &type = get(result_type); - if (type.columns > 1 || !type.array.empty() || type.basetype == SPIRType::Struct) - forward = false; - - auto &e = emit_op(result_type, id, load_expr, forward, true); - e.need_transpose = false; - register_read(id, ptr, forward); - } - else - CompilerGLSL::emit_instruction(instruction); -} - -void CompilerHLSL::write_access_chain(const SPIRAccessChain &chain, uint32_t value) -{ - auto &type = get(chain.basetype); - - SPIRType target_type; - target_type.basetype = SPIRType::UInt; - target_type.vecsize = type.vecsize; - target_type.columns = type.columns; - - if (type.basetype == SPIRType::Struct) - SPIRV_CROSS_THROW("Writing structs to RWByteAddressBuffer not yet supported."); - if (type.width != 32) - SPIRV_CROSS_THROW("Writing types other than 32-bit to RWByteAddressBuffer not yet supported."); - if (!type.array.empty()) - SPIRV_CROSS_THROW("Reading arrays from ByteAddressBuffer not yet supported."); - - if (type.columns == 1 && !chain.row_major_matrix) - { - const char *store_op = nullptr; - switch (type.vecsize) - { - case 1: - store_op = "Store"; - break; - case 2: - store_op = "Store2"; - break; - case 3: - store_op = "Store3"; - break; - case 4: - store_op = "Store4"; - break; - default: - SPIRV_CROSS_THROW("Unknown vector size."); - } - - auto store_expr = to_expression(value); - auto bitcast_op = bitcast_glsl_op(target_type, type); - if (!bitcast_op.empty()) - store_expr = join(bitcast_op, "(", store_expr, ")"); - statement(chain.base, ".", store_op, "(", chain.dynamic_index, chain.static_index, ", ", store_expr, ");"); - } - else if (type.columns == 1) - { - // Strided store. - for (uint32_t r = 0; r < type.vecsize; r++) - { - auto store_expr = to_enclosed_expression(value); - if (type.vecsize > 1) - { - store_expr += "."; - store_expr += index_to_swizzle(r); - } - remove_duplicate_swizzle(store_expr); - - auto bitcast_op = bitcast_glsl_op(target_type, type); - if (!bitcast_op.empty()) - store_expr = join(bitcast_op, "(", store_expr, ")"); - statement(chain.base, ".Store(", chain.dynamic_index, chain.static_index + chain.matrix_stride * r, ", ", - store_expr, ");"); - } - } - else if (!chain.row_major_matrix) - { - const char *store_op = nullptr; - switch (type.vecsize) - { - case 1: - store_op = "Store"; - break; - case 2: - store_op = "Store2"; - break; - case 3: - store_op = "Store3"; - break; - case 4: - store_op = "Store4"; - break; - default: - SPIRV_CROSS_THROW("Unknown vector size."); - } - - for (uint32_t c = 0; c < type.columns; c++) - { - auto store_expr = join(to_enclosed_expression(value), "[", c, "]"); - auto bitcast_op = bitcast_glsl_op(target_type, type); - if (!bitcast_op.empty()) - store_expr = join(bitcast_op, "(", store_expr, ")"); - statement(chain.base, ".", store_op, "(", chain.dynamic_index, chain.static_index + c * chain.matrix_stride, - ", ", store_expr, ");"); - } - } - else - { - for (uint32_t r = 0; r < type.vecsize; r++) - { - for (uint32_t c = 0; c < type.columns; c++) - { - auto store_expr = join(to_enclosed_expression(value), "[", c, "].", index_to_swizzle(r)); - remove_duplicate_swizzle(store_expr); - auto bitcast_op = bitcast_glsl_op(target_type, type); - if (!bitcast_op.empty()) - store_expr = join(bitcast_op, "(", store_expr, ")"); - statement(chain.base, ".Store(", chain.dynamic_index, - chain.static_index + c * (type.width / 8) + r * chain.matrix_stride, ", ", store_expr, ");"); - } - } - } - - register_write(chain.self); -} - -void CompilerHLSL::emit_store(const Instruction &instruction) -{ - auto ops = stream(instruction); - auto *chain = maybe_get(ops[0]); - if (chain) - write_access_chain(*chain, ops[1]); - else - CompilerGLSL::emit_instruction(instruction); -} - -void CompilerHLSL::emit_access_chain(const Instruction &instruction) -{ - auto ops = stream(instruction); - uint32_t length = instruction.length; - - bool need_byte_access_chain = false; - auto &type = expression_type(ops[2]); - const SPIRAccessChain *chain = nullptr; - if (type.storage == StorageClassStorageBuffer || has_decoration(type.self, DecorationBufferBlock)) - { - // If we are starting to poke into an SSBO, we are dealing with ByteAddressBuffers, and we need - // to emit SPIRAccessChain rather than a plain SPIRExpression. - uint32_t chain_arguments = length - 3; - if (chain_arguments > type.array.size()) - need_byte_access_chain = true; - } - else - { - // Keep tacking on an existing access chain. - chain = maybe_get(ops[2]); - if (chain) - need_byte_access_chain = true; - } - - if (need_byte_access_chain) - { - uint32_t to_plain_buffer_length = static_cast(type.array.size()); - - string base; - if (to_plain_buffer_length != 0) - { - bool need_transpose; - base = access_chain(ops[2], &ops[3], to_plain_buffer_length, get(ops[0]), &need_transpose); - } - else - base = to_expression(ops[2]); - - auto *basetype = &type; - - // Start traversing type hierarchy at the proper non-pointer types. - while (basetype->pointer) - { - assert(basetype->parent_type); - basetype = &get(basetype->parent_type); - } - - // Traverse the type hierarchy down to the actual buffer types. - for (uint32_t i = 0; i < to_plain_buffer_length; i++) - { - assert(basetype->parent_type); - basetype = &get(basetype->parent_type); - } - - uint32_t matrix_stride = 0; - bool row_major_matrix = false; - - // Inherit matrix information. - if (chain) - { - matrix_stride = chain->matrix_stride; - row_major_matrix = chain->row_major_matrix; - } - - auto offsets = - flattened_access_chain_offset(*basetype, &ops[3 + to_plain_buffer_length], - length - 3 - to_plain_buffer_length, 0, 1, &row_major_matrix, &matrix_stride); - - auto &e = set(ops[1], ops[0], type.storage, base, offsets.first, offsets.second); - e.row_major_matrix = row_major_matrix; - e.matrix_stride = matrix_stride; - e.immutable = should_forward(ops[2]); - - if (chain) - { - e.dynamic_index += chain->dynamic_index; - e.static_index += chain->static_index; - } - } - else - { - CompilerGLSL::emit_instruction(instruction); - } -} - -void CompilerHLSL::emit_atomic(const uint32_t *ops, uint32_t length, spv::Op op) -{ - const char *atomic_op = nullptr; - auto value_expr = to_expression(ops[op == OpAtomicCompareExchange ? 6 : 5]); - - switch (op) - { - case OpAtomicISub: - atomic_op = "InterlockedAdd"; - value_expr = join("-", enclose_expression(value_expr)); - break; - - case OpAtomicSMin: - case OpAtomicUMin: - atomic_op = "InterlockedMin"; - break; - - case OpAtomicSMax: - case OpAtomicUMax: - atomic_op = "InterlockedMax"; - break; - - case OpAtomicAnd: - atomic_op = "InterlockedAnd"; - break; - - case OpAtomicOr: - atomic_op = "InterlockedOr"; - break; - - case OpAtomicXor: - atomic_op = "InterlockedXor"; - break; - - case OpAtomicIAdd: - atomic_op = "InterlockedAdd"; - break; - - case OpAtomicExchange: - atomic_op = "InterlockedExchange"; - break; - - case OpAtomicCompareExchange: - if (length < 8) - SPIRV_CROSS_THROW("Not enough data for opcode."); - atomic_op = "InterlockedCompareExchange"; - value_expr = join(to_expression(ops[7]), ", ", value_expr); - break; - - default: - SPIRV_CROSS_THROW("Unknown atomic opcode."); - } - - if (length < 6) - SPIRV_CROSS_THROW("Not enough data for opcode."); - - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - forced_temporaries.insert(ops[1]); - - auto &type = get(result_type); - statement(variable_decl(type, to_name(id)), ";"); - - auto &data_type = expression_type(ops[2]); - auto *chain = maybe_get(ops[2]); - SPIRType::BaseType expr_type; - if (data_type.storage == StorageClassImage || !chain) - { - statement(atomic_op, "(", to_expression(ops[2]), ", ", value_expr, ", ", to_name(id), ");"); - expr_type = data_type.basetype; - } - else - { - // RWByteAddress buffer is always uint in its underlying type. - expr_type = SPIRType::UInt; - statement(chain->base, ".", atomic_op, "(", chain->dynamic_index, chain->static_index, ", ", value_expr, ", ", - to_name(id), ");"); - } - - auto expr = bitcast_expression(type, expr_type, to_name(id)); - set(id, expr, result_type, true); - flush_all_atomic_capable_variables(); - register_read(ops[1], ops[2], should_forward(ops[2])); -} - -void CompilerHLSL::emit_instruction(const Instruction &instruction) -{ - auto ops = stream(instruction); - auto opcode = static_cast(instruction.op); - -#define BOP(op) emit_binary_op(ops[0], ops[1], ops[2], ops[3], #op) -#define BOP_CAST(op, type) \ - emit_binary_op_cast(ops[0], ops[1], ops[2], ops[3], #op, type, opcode_is_sign_invariant(opcode)) -#define UOP(op) emit_unary_op(ops[0], ops[1], ops[2], #op) -#define QFOP(op) emit_quaternary_func_op(ops[0], ops[1], ops[2], ops[3], ops[4], ops[5], #op) -#define TFOP(op) emit_trinary_func_op(ops[0], ops[1], ops[2], ops[3], ops[4], #op) -#define BFOP(op) emit_binary_func_op(ops[0], ops[1], ops[2], ops[3], #op) -#define BFOP_CAST(op, type) \ - emit_binary_func_op_cast(ops[0], ops[1], ops[2], ops[3], #op, type, opcode_is_sign_invariant(opcode)) -#define BFOP(op) emit_binary_func_op(ops[0], ops[1], ops[2], ops[3], #op) -#define UFOP(op) emit_unary_func_op(ops[0], ops[1], ops[2], #op) - - switch (opcode) - { - case OpAccessChain: - case OpInBoundsAccessChain: - { - emit_access_chain(instruction); - break; - } - - case OpStore: - { - emit_store(instruction); - break; - } - - case OpLoad: - { - emit_load(instruction); - break; - } - - case OpMatrixTimesVector: - { - emit_binary_func_op(ops[0], ops[1], ops[3], ops[2], "mul"); - break; - } - - case OpVectorTimesMatrix: - { - emit_binary_func_op(ops[0], ops[1], ops[3], ops[2], "mul"); - break; - } - - case OpMatrixTimesMatrix: - { - emit_binary_func_op(ops[0], ops[1], ops[3], ops[2], "mul"); - break; - } - - case OpFMod: - { - if (!requires_op_fmod) - { - requires_op_fmod = true; - force_recompile = true; - } - CompilerGLSL::emit_instruction(instruction); - break; - } - - case OpImage: - { - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - emit_op(result_type, id, to_expression(ops[2]), true, true); - // TODO: Maybe change this when separate samplers/images are supported - break; - } - - case OpDPdx: - UFOP(ddx); - break; - - case OpDPdy: - UFOP(ddy); - break; - - case OpDPdxFine: - UFOP(ddx_fine); - break; - - case OpDPdyFine: - UFOP(ddy_fine); - break; - - case OpDPdxCoarse: - UFOP(ddx_coarse); - break; - - case OpDPdyCoarse: - UFOP(ddy_coarse); - break; - - case OpLogicalNot: - { - auto result_type = ops[0]; - auto id = ops[1]; - auto &type = get(result_type); - - if (type.vecsize > 1) - emit_unrolled_unary_op(result_type, id, ops[2], "!"); - else - UOP(!); - break; - } - - case OpIEqual: - { - auto result_type = ops[0]; - auto id = ops[1]; - - if (expression_type(ops[2]).vecsize > 1) - emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "=="); - else - BOP_CAST(==, SPIRType::Int); - break; - } - - case OpLogicalEqual: - case OpFOrdEqual: - { - auto result_type = ops[0]; - auto id = ops[1]; - - if (expression_type(ops[2]).vecsize > 1) - emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "=="); - else - BOP(==); - break; - } - - case OpINotEqual: - { - auto result_type = ops[0]; - auto id = ops[1]; - - if (expression_type(ops[2]).vecsize > 1) - emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "!="); - else - BOP_CAST(!=, SPIRType::Int); - break; - } - - case OpLogicalNotEqual: - case OpFOrdNotEqual: - { - auto result_type = ops[0]; - auto id = ops[1]; - - if (expression_type(ops[2]).vecsize > 1) - emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "!="); - else - BOP(!=); - break; - } - - case OpUGreaterThan: - case OpSGreaterThan: - { - auto result_type = ops[0]; - auto id = ops[1]; - auto type = opcode == OpUGreaterThan ? SPIRType::UInt : SPIRType::Int; - - if (expression_type(ops[2]).vecsize > 1) - emit_unrolled_binary_op(result_type, id, ops[2], ops[3], ">"); - else - BOP_CAST(>, type); - break; - } - - case OpFOrdGreaterThan: - { - auto result_type = ops[0]; - auto id = ops[1]; - - if (expression_type(ops[2]).vecsize > 1) - emit_unrolled_binary_op(result_type, id, ops[2], ops[3], ">"); - else - BOP(>); - break; - } - - case OpUGreaterThanEqual: - case OpSGreaterThanEqual: - { - auto result_type = ops[0]; - auto id = ops[1]; - - auto type = opcode == OpUGreaterThanEqual ? SPIRType::UInt : SPIRType::Int; - if (expression_type(ops[2]).vecsize > 1) - emit_unrolled_binary_op(result_type, id, ops[2], ops[3], ">="); - else - BOP_CAST(>=, type); - break; - } - - case OpFOrdGreaterThanEqual: - { - auto result_type = ops[0]; - auto id = ops[1]; - - if (expression_type(ops[2]).vecsize > 1) - emit_unrolled_binary_op(result_type, id, ops[2], ops[3], ">="); - else - BOP(>=); - break; - } - - case OpULessThan: - case OpSLessThan: - { - auto result_type = ops[0]; - auto id = ops[1]; - - auto type = opcode == OpULessThan ? SPIRType::UInt : SPIRType::Int; - if (expression_type(ops[2]).vecsize > 1) - emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "<"); - else - BOP_CAST(<, type); - break; - } - - case OpFOrdLessThan: - { - auto result_type = ops[0]; - auto id = ops[1]; - - if (expression_type(ops[2]).vecsize > 1) - emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "<"); - else - BOP(<); - break; - } - - case OpULessThanEqual: - case OpSLessThanEqual: - { - auto result_type = ops[0]; - auto id = ops[1]; - - auto type = opcode == OpULessThanEqual ? SPIRType::UInt : SPIRType::Int; - if (expression_type(ops[2]).vecsize > 1) - emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "<="); - else - BOP_CAST(<=, type); - break; - } - - case OpFOrdLessThanEqual: - { - auto result_type = ops[0]; - auto id = ops[1]; - - if (expression_type(ops[2]).vecsize > 1) - emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "<="); - else - BOP(<=); - break; - } - - case OpImageQueryLod: - emit_texture_op(instruction); - break; - - case OpImageQuerySizeLod: - { - auto result_type = ops[0]; - auto id = ops[1]; - - require_texture_query_variant(expression_type(ops[2])); - - auto dummy_samples_levels = join(get_fallback_name(id), "_dummy_parameter"); - statement("uint ", dummy_samples_levels, ";"); - - auto expr = join("SPIRV_Cross_textureSize(", to_expression(ops[2]), ", ", - bitcast_expression(SPIRType::UInt, ops[3]), ", ", dummy_samples_levels, ")"); - - auto &restype = get(ops[0]); - expr = bitcast_expression(restype, SPIRType::UInt, expr); - emit_op(result_type, id, expr, true); - break; - } - - case OpImageQuerySize: - { - auto result_type = ops[0]; - auto id = ops[1]; - - require_texture_query_variant(expression_type(ops[2])); - - auto dummy_samples_levels = join(get_fallback_name(id), "_dummy_parameter"); - statement("uint ", dummy_samples_levels, ";"); - - auto expr = join("SPIRV_Cross_textureSize(", to_expression(ops[2]), ", 0u, ", dummy_samples_levels, ")"); - auto &restype = get(ops[0]); - expr = bitcast_expression(restype, SPIRType::UInt, expr); - emit_op(result_type, id, expr, true); - break; - } - - case OpImageQuerySamples: - case OpImageQueryLevels: - { - auto result_type = ops[0]; - auto id = ops[1]; - - require_texture_query_variant(expression_type(ops[2])); - - // Keep it simple and do not emit special variants to make this look nicer ... - // This stuff is barely, if ever, used. - forced_temporaries.insert(id); - auto &type = get(result_type); - statement(variable_decl(type, to_name(id)), ";"); - statement("SPIRV_Cross_textureSize(", to_expression(ops[2]), ", 0u, ", to_name(id), ");"); - - auto &restype = get(ops[0]); - auto expr = bitcast_expression(restype, SPIRType::UInt, to_name(id)); - set(id, expr, result_type, true); - break; - } - - case OpImageRead: - { - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - auto *var = maybe_get_backing_variable(ops[2]); - auto imgexpr = join(to_expression(ops[2]), "[", to_expression(ops[3]), "]"); - - // The underlying image type in HLSL depends on the image format, unlike GLSL, where all images are "vec4", - // except that the underlying type changes how the data is interpreted. - if (var) - imgexpr = remap_swizzle(get(result_type), - image_format_to_components(get(var->basetype).image.format), imgexpr); - - if (var && var->forwardable) - { - bool forward = forced_temporaries.find(id) == end(forced_temporaries); - auto &e = emit_op(result_type, id, imgexpr, forward); - e.loaded_from = var->self; - if (forward) - var->dependees.push_back(id); - } - else - emit_op(result_type, id, imgexpr, false); - break; - } - - case OpImageWrite: - { - auto *var = maybe_get_backing_variable(ops[0]); - - // The underlying image type in HLSL depends on the image format, unlike GLSL, where all images are "vec4", - // except that the underlying type changes how the data is interpreted. - auto value_expr = to_expression(ops[2]); - if (var) - { - auto &type = get(var->basetype); - auto narrowed_type = get(type.image.type); - narrowed_type.vecsize = image_format_to_components(type.image.format); - value_expr = remap_swizzle(narrowed_type, expression_type(ops[2]).vecsize, value_expr); - } - - statement(to_expression(ops[0]), "[", to_expression(ops[1]), "] = ", value_expr, ";"); - if (var && variable_storage_is_aliased(*var)) - flush_all_aliased_variables(); - break; - } - - case OpImageTexelPointer: - { - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - auto &e = - set(id, join(to_expression(ops[2]), "[", to_expression(ops[3]), "]"), result_type, true); - - // When using the pointer, we need to know which variable it is actually loaded from. - auto *var = maybe_get_backing_variable(ops[2]); - e.loaded_from = var ? var->self : 0; - break; - } - - case OpAtomicCompareExchange: - case OpAtomicExchange: - case OpAtomicISub: - case OpAtomicSMin: - case OpAtomicUMin: - case OpAtomicSMax: - case OpAtomicUMax: - case OpAtomicAnd: - case OpAtomicOr: - case OpAtomicXor: - case OpAtomicIAdd: - { - emit_atomic(ops, instruction.length, opcode); - break; - } - - case OpControlBarrier: - case OpMemoryBarrier: - { - uint32_t memory; - uint32_t semantics; - - if (opcode == OpMemoryBarrier) - { - memory = get(ops[0]).scalar(); - semantics = get(ops[1]).scalar(); - } - else - { - memory = get(ops[1]).scalar(); - semantics = get(ops[2]).scalar(); - } - - // We only care about these flags, acquire/release and friends are not relevant to GLSL. - semantics = mask_relevant_memory_semantics(semantics); - - if (opcode == OpMemoryBarrier) - { - // If we are a memory barrier, and the next instruction is a control barrier, check if that memory barrier - // does what we need, so we avoid redundant barriers. - const Instruction *next = get_next_instruction_in_block(instruction); - if (next && next->op == OpControlBarrier) - { - auto *next_ops = stream(*next); - uint32_t next_memory = get(next_ops[1]).scalar(); - uint32_t next_semantics = get(next_ops[2]).scalar(); - next_semantics = mask_relevant_memory_semantics(next_semantics); - - // There is no "just execution barrier" in HLSL. - // If there are no memory semantics for next instruction, we will imply group shared memory is synced. - if (next_semantics == 0) - next_semantics = MemorySemanticsWorkgroupMemoryMask; - - bool memory_scope_covered = false; - if (next_memory == memory) - memory_scope_covered = true; - else if (next_semantics == MemorySemanticsWorkgroupMemoryMask) - { - // If we only care about workgroup memory, either Device or Workgroup scope is fine, - // scope does not have to match. - if ((next_memory == ScopeDevice || next_memory == ScopeWorkgroup) && - (memory == ScopeDevice || memory == ScopeWorkgroup)) - { - memory_scope_covered = true; - } - } - else if (memory == ScopeWorkgroup && next_memory == ScopeDevice) - { - // The control barrier has device scope, but the memory barrier just has workgroup scope. - memory_scope_covered = true; - } - - // If we have the same memory scope, and all memory types are covered, we're good. - if (memory_scope_covered && (semantics & next_semantics) == semantics) - break; - } - } - - // We are synchronizing some memory or syncing execution, - // so we cannot forward any loads beyond the memory barrier. - if (semantics || opcode == OpControlBarrier) - flush_all_active_variables(); - - if (opcode == OpControlBarrier) - { - // We cannot emit just execution barrier, for no memory semantics pick the cheapest option. - if (semantics == MemorySemanticsWorkgroupMemoryMask || semantics == 0) - statement("GroupMemoryBarrierWithGroupSync();"); - else if (semantics != 0 && (semantics & MemorySemanticsWorkgroupMemoryMask) == 0) - statement("DeviceMemoryBarrierWithGroupSync();"); - else - statement("AllMemoryBarrierWithGroupSync();"); - } - else - { - if (semantics == MemorySemanticsWorkgroupMemoryMask) - statement("GroupMemoryBarrier();"); - else if (semantics != 0 && (semantics & MemorySemanticsWorkgroupMemoryMask) == 0) - statement("DeviceMemoryBarrier();"); - else - statement("AllMemoryBarrier();"); - } - break; - } - - case OpBitFieldInsert: - { - if (!requires_bitfield_insert) - { - requires_bitfield_insert = true; - force_recompile = true; - } - - auto expr = join("SPIRV_Cross_bitfieldInsert(", to_expression(ops[2]), ", ", to_expression(ops[3]), ", ", - to_expression(ops[4]), ", ", to_expression(ops[5]), ")"); - - bool forward = - should_forward(ops[2]) && should_forward(ops[3]) && should_forward(ops[4]) && should_forward(ops[5]); - - auto &restype = get(ops[0]); - expr = bitcast_expression(restype, SPIRType::UInt, expr); - emit_op(ops[0], ops[1], expr, forward); - break; - } - - case OpBitFieldSExtract: - case OpBitFieldUExtract: - { - if (!requires_bitfield_extract) - { - requires_bitfield_extract = true; - force_recompile = true; - } - - if (opcode == OpBitFieldSExtract) - TFOP(SPIRV_Cross_bitfieldSExtract); - else - TFOP(SPIRV_Cross_bitfieldUExtract); - break; - } - - case OpBitCount: - UFOP(countbits); - break; - - case OpBitReverse: - UFOP(reversebits); - break; - - default: - CompilerGLSL::emit_instruction(instruction); - break; - } -} - -void CompilerHLSL::require_texture_query_variant(const SPIRType &type) -{ - uint32_t bit = 0; - switch (type.image.dim) - { - case Dim1D: - bit = type.image.arrayed ? Query1DArray : Query1D; - break; - - case Dim2D: - if (type.image.ms) - bit = type.image.arrayed ? Query2DMSArray : Query2DMS; - else - bit = type.image.arrayed ? Query2DArray : Query2D; - break; - - case Dim3D: - bit = Query3D; - break; - - case DimCube: - bit = type.image.arrayed ? QueryCubeArray : QueryCube; - break; - - case DimBuffer: - bit = QueryBuffer; - break; - - default: - SPIRV_CROSS_THROW("Unsupported query type."); - } - - switch (get(type.image.type).basetype) - { - case SPIRType::Float: - bit += QueryTypeFloat; - break; - - case SPIRType::Int: - bit += QueryTypeInt; - break; - - case SPIRType::UInt: - bit += QueryTypeUInt; - break; - - default: - SPIRV_CROSS_THROW("Unsupported query type."); - } - - uint64_t mask = 1ull << bit; - if ((required_textureSizeVariants & mask) == 0) - { - force_recompile = true; - required_textureSizeVariants |= mask; - } -} - -string CompilerHLSL::compile(std::vector vertex_attributes) -{ - remap_vertex_attributes = move(vertex_attributes); - return compile(); -} - -string CompilerHLSL::compile() -{ - // Do not deal with ES-isms like precision, older extensions and such. - CompilerGLSL::options.es = false; - CompilerGLSL::options.version = 450; - CompilerGLSL::options.vulkan_semantics = true; - backend.float_literal_suffix = true; - backend.double_literal_suffix = false; - backend.long_long_literal_suffix = true; - backend.uint32_t_literal_suffix = true; - backend.basic_int_type = "int"; - backend.basic_uint_type = "uint"; - backend.swizzle_is_function = false; - backend.shared_is_implied = true; - backend.flexible_member_array_supported = false; - backend.explicit_struct_type = false; - backend.use_initializer_list = true; - backend.use_constructor_splatting = false; - backend.boolean_mix_support = false; - backend.can_swizzle_scalar = true; - backend.can_declare_struct_inline = false; - - update_active_builtins(); - analyze_sampler_comparison_states(); - - uint32_t pass_count = 0; - do - { - if (pass_count >= 3) - SPIRV_CROSS_THROW("Over 3 compilation loops detected. Must be a bug!"); - - reset(); - - // Move constructor for this type is broken on GCC 4.9 ... - buffer = unique_ptr(new ostringstream()); - - emit_header(); - emit_resources(); - - emit_function(get(entry_point), 0); - emit_hlsl_entry_point(); - - pass_count++; - } while (force_recompile); - - // Entry point in HLSL is always main() for the time being. - get_entry_point().name = "main"; - - return buffer->str(); -} diff --git a/deps/SPIRV-Cross/spirv_hlsl.hpp b/deps/SPIRV-Cross/spirv_hlsl.hpp deleted file mode 100644 index 7144b5cdca..0000000000 --- a/deps/SPIRV-Cross/spirv_hlsl.hpp +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright 2016-2017 Robert Konrad - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef SPIRV_HLSL_HPP -#define SPIRV_HLSL_HPP - -#include "spirv_glsl.hpp" -#include -#include - -namespace spirv_cross -{ -// Interface which remaps vertex inputs to a fixed semantic name to make linking easier. -struct HLSLVertexAttributeRemap -{ - uint32_t location; - std::string semantic; -}; - -class CompilerHLSL : public CompilerGLSL -{ -public: - struct Options - { - uint32_t shader_model = 30; // TODO: map ps_4_0_level_9_0,... somehow - - // Allows the PointSize builtin, and ignores it, as PointSize is not supported in HLSL. - bool point_size_compat = false; - }; - - CompilerHLSL(std::vector spirv_) - : CompilerGLSL(move(spirv_)) - { - } - - CompilerHLSL(const uint32_t *ir, size_t size) - : CompilerGLSL(ir, size) - { - } - - const Options &get_options() const - { - return options; - } - - void set_options(Options &opts) - { - options = opts; - } - - // Compiles and remaps vertex attributes at specific locations to a fixed semantic. - // The default is TEXCOORD# where # denotes location. - // Matrices are unrolled to vectors with notation ${SEMANTIC}_#, where # denotes row. - // $SEMANTIC is either TEXCOORD# or a semantic name specified here. - std::string compile(std::vector vertex_attributes); - std::string compile() override; - -private: - std::string type_to_glsl(const SPIRType &type, uint32_t id = 0) override; - std::string image_type_hlsl(const SPIRType &type); - std::string image_type_hlsl_modern(const SPIRType &type); - std::string image_type_hlsl_legacy(const SPIRType &type); - void emit_function_prototype(SPIRFunction &func, uint64_t return_flags) override; - void emit_hlsl_entry_point(); - void emit_header() override; - void emit_resources(); - void emit_interface_block_globally(const SPIRVariable &type); - void emit_interface_block_in_struct(const SPIRVariable &type, std::unordered_set &active_locations); - void emit_builtin_inputs_in_struct(); - void emit_builtin_outputs_in_struct(); - void emit_texture_op(const Instruction &i) override; - void emit_instruction(const Instruction &instruction) override; - void emit_glsl_op(uint32_t result_type, uint32_t result_id, uint32_t op, const uint32_t *args, - uint32_t count) override; - void emit_buffer_block(const SPIRVariable &type) override; - void emit_push_constant_block(const SPIRVariable &var) override; - void emit_uniform(const SPIRVariable &var) override; - void emit_modern_uniform(const SPIRVariable &var); - void emit_legacy_uniform(const SPIRVariable &var); - void emit_specialization_constants(); - void emit_fixup() override; - std::string builtin_to_glsl(spv::BuiltIn builtin, spv::StorageClass storage) override; - std::string layout_for_member(const SPIRType &type, uint32_t index) override; - std::string to_interpolation_qualifiers(uint64_t flags) override; - std::string bitcast_glsl_op(const SPIRType &result_type, const SPIRType &argument_type) override; - std::string to_func_call_arg(uint32_t id) override; - std::string to_sampler_expression(uint32_t id); - std::string to_resource_binding(const SPIRVariable &var); - std::string to_resource_binding_sampler(const SPIRVariable &var); - void emit_sampled_image_op(uint32_t result_type, uint32_t result_id, uint32_t image_id, uint32_t samp_id) override; - void emit_access_chain(const Instruction &instruction); - void emit_load(const Instruction &instruction); - std::string read_access_chain(const SPIRAccessChain &chain); - void write_access_chain(const SPIRAccessChain &chain, uint32_t value); - void emit_store(const Instruction &instruction); - void emit_atomic(const uint32_t *ops, uint32_t length, spv::Op op); - - void emit_struct_member(const SPIRType &type, uint32_t member_type_id, uint32_t index, - const std::string &qualifier) override; - - const char *to_storage_qualifiers_glsl(const SPIRVariable &var) override; - - Options options; - bool requires_op_fmod = false; - bool requires_textureProj = false; - bool requires_fp16_packing = false; - bool requires_unorm8_packing = false; - bool requires_snorm8_packing = false; - bool requires_unorm16_packing = false; - bool requires_snorm16_packing = false; - bool requires_bitfield_insert = false; - bool requires_bitfield_extract = false; - uint64_t required_textureSizeVariants = 0; - void require_texture_query_variant(const SPIRType &type); - - enum TextureQueryVariantDim - { - Query1D = 0, - Query1DArray, - Query2D, - Query2DArray, - Query3D, - QueryBuffer, - QueryCube, - QueryCubeArray, - Query2DMS, - Query2DMSArray, - QueryDimCount - }; - - enum TextureQueryVariantType - { - QueryTypeFloat = 0, - QueryTypeInt = 16, - QueryTypeUInt = 32, - QueryTypeCount = 3 - }; - - void emit_builtin_variables(); - bool require_output = false; - bool require_input = false; - std::vector remap_vertex_attributes; - - uint32_t type_to_consumed_locations(const SPIRType &type) const; - - void emit_io_block(const SPIRVariable &var); - std::string to_semantic(uint32_t vertex_location); -}; -} - -#endif diff --git a/deps/SPIRV-Cross/spirv_msl.cpp b/deps/SPIRV-Cross/spirv_msl.cpp deleted file mode 100644 index 70e9b4108f..0000000000 --- a/deps/SPIRV-Cross/spirv_msl.cpp +++ /dev/null @@ -1,3591 +0,0 @@ -/* - * Copyright 2016-2017 The Brenwill Workshop Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "spirv_msl.hpp" -#include "GLSL.std.450.h" - -#include -#include - -using namespace spv; -using namespace spirv_cross; -using namespace std; - -static const uint32_t k_unknown_location = ~0; - -CompilerMSL::CompilerMSL(vector spirv_, vector *p_vtx_attrs, - vector *p_res_bindings) - : CompilerGLSL(move(spirv_)) -{ - if (p_vtx_attrs) - for (auto &va : *p_vtx_attrs) - vtx_attrs_by_location[va.location] = &va; - - if (p_res_bindings) - for (auto &rb : *p_res_bindings) - resource_bindings.push_back(&rb); -} - -CompilerMSL::CompilerMSL(const uint32_t *ir, size_t word_count, MSLVertexAttr *p_vtx_attrs, size_t vtx_attrs_count, - MSLResourceBinding *p_res_bindings, size_t res_bindings_count) - : CompilerGLSL(ir, word_count) -{ - if (p_vtx_attrs) - for (size_t i = 0; i < vtx_attrs_count; i++) - vtx_attrs_by_location[p_vtx_attrs[i].location] = &p_vtx_attrs[i]; - - if (p_res_bindings) - for (size_t i = 0; i < res_bindings_count; i++) - resource_bindings.push_back(&p_res_bindings[i]); -} - -string CompilerMSL::compile() -{ - // Force a classic "C" locale, reverts when function returns - ClassicLocale classic_locale; - - // Do not deal with GLES-isms like precision, older extensions and such. - CompilerGLSL::options.vulkan_semantics = true; - CompilerGLSL::options.es = false; - CompilerGLSL::options.version = 120; - backend.float_literal_suffix = false; - backend.uint32_t_literal_suffix = true; - backend.basic_int_type = "int"; - backend.basic_uint_type = "uint"; - backend.discard_literal = "discard_fragment()"; - backend.swizzle_is_function = false; - backend.shared_is_implied = false; - backend.use_initializer_list = true; - backend.use_typed_initializer_list = true; - backend.native_row_major_matrix = false; - backend.flexible_member_array_supported = false; - - replace_illegal_names(); - - non_stage_in_input_var_ids.clear(); - struct_member_padding.clear(); - - update_active_builtins(); - fixup_image_load_store_access(); - - set_enabled_interface_variables(get_active_interface_variables()); - - // Preprocess OpCodes to extract the need to output additional header content - preprocess_op_codes(); - - // Create structs to hold input, output and uniform variables - qual_pos_var_name = ""; - stage_in_var_id = add_interface_block(StorageClassInput); - stage_out_var_id = add_interface_block(StorageClassOutput); - stage_uniforms_var_id = add_interface_block(StorageClassUniformConstant); - - // Convert the use of global variables to recursively-passed function parameters - localize_global_variables(); - extract_global_variables_from_functions(); - - // Mark any non-stage-in structs to be tightly packed. - mark_packable_structs(); - - // Metal does not allow dynamic array lengths. - // Resolve any specialization constants that are used for array lengths. - if (options.resolve_specialized_array_lengths) - resolve_specialized_array_lengths(); - - uint32_t pass_count = 0; - do - { - if (pass_count >= 3) - SPIRV_CROSS_THROW("Over 3 compilation loops detected. Must be a bug!"); - - reset(); - - next_metal_resource_index = MSLResourceBinding(); // Start bindings at zero - - // Move constructor for this type is broken on GCC 4.9 ... - buffer = unique_ptr(new ostringstream()); - - emit_header(); - emit_specialization_constants(); - emit_resources(); - emit_custom_functions(); - emit_function(get(entry_point), 0); - - pass_count++; - } while (force_recompile); - - return buffer->str(); -} - -string CompilerMSL::compile(vector *p_vtx_attrs, vector *p_res_bindings) -{ - if (p_vtx_attrs) - { - vtx_attrs_by_location.clear(); - for (auto &va : *p_vtx_attrs) - vtx_attrs_by_location[va.location] = &va; - } - - if (p_res_bindings) - { - resource_bindings.clear(); - for (auto &rb : *p_res_bindings) - resource_bindings.push_back(&rb); - } - - return compile(); -} - -string CompilerMSL::compile(MSLConfiguration &msl_cfg, vector *p_vtx_attrs, - vector *p_res_bindings) -{ - options = msl_cfg; - return compile(p_vtx_attrs, p_res_bindings); -} - -// Register the need to output any custom functions. -void CompilerMSL::preprocess_op_codes() -{ - spv_function_implementations.clear(); - - OpCodePreprocessor preproc(*this); - traverse_all_reachable_opcodes(get(entry_point), preproc); - - if (preproc.suppress_missing_prototypes) - add_pragma_line("#pragma clang diagnostic ignored \"-Wmissing-prototypes\""); - - if (preproc.uses_atomics) - { - add_header_line("#include "); - add_pragma_line("#pragma clang diagnostic ignored \"-Wunused-variable\""); - } -} - -// Move the Private and Workgroup global variables to the entry function. -// Non-constant variables cannot have global scope in Metal. -void CompilerMSL::localize_global_variables() -{ - auto &entry_func = get(entry_point); - auto iter = global_variables.begin(); - while (iter != global_variables.end()) - { - uint32_t v_id = *iter; - auto &var = get(v_id); - if (var.storage == StorageClassPrivate || var.storage == StorageClassWorkgroup) - { - var.storage = StorageClassFunction; - entry_func.add_local_variable(v_id); - iter = global_variables.erase(iter); - } - else - iter++; - } -} - -// Metal does not allow dynamic array lengths. -// Turn off specialization of any constants that are used for array lengths. -void CompilerMSL::resolve_specialized_array_lengths() -{ - for (auto &id : ids) - { - if (id.get_type() == TypeConstant) - { - auto &c = id.get(); - if (c.is_used_as_array_length) - c.specialization = false; - } - } -} - -// For any global variable accessed directly by a function, -// extract that variable and add it as an argument to that function. -void CompilerMSL::extract_global_variables_from_functions() -{ - - // Uniforms - unordered_set global_var_ids; - for (auto &id : ids) - { - if (id.get_type() == TypeVariable) - { - auto &var = id.get(); - if (var.storage == StorageClassInput || var.storage == StorageClassUniform || - var.storage == StorageClassUniformConstant || var.storage == StorageClassPushConstant || - var.storage == StorageClassStorageBuffer) - { - global_var_ids.insert(var.self); - } - } - } - - // Local vars that are declared in the main function and accessed directy by a function - auto &entry_func = get(entry_point); - for (auto &var : entry_func.local_variables) - global_var_ids.insert(var); - - std::set added_arg_ids; - unordered_set processed_func_ids; - extract_global_variables_from_function(entry_point, added_arg_ids, global_var_ids, processed_func_ids); -} - -// MSL does not support the use of global variables for shader input content. -// For any global variable accessed directly by the specified function, extract that variable, -// add it as an argument to that function, and the arg to the added_arg_ids collection. -void CompilerMSL::extract_global_variables_from_function(uint32_t func_id, std::set &added_arg_ids, - unordered_set &global_var_ids, - unordered_set &processed_func_ids) -{ - // Avoid processing a function more than once - if (processed_func_ids.find(func_id) != processed_func_ids.end()) - { - // Return function global variables - added_arg_ids = function_global_vars[func_id]; - return; - } - - processed_func_ids.insert(func_id); - - auto &func = get(func_id); - - // Recursively establish global args added to functions on which we depend. - for (auto block : func.blocks) - { - auto &b = get(block); - for (auto &i : b.ops) - { - auto ops = stream(i); - auto op = static_cast(i.op); - - switch (op) - { - case OpLoad: - case OpAccessChain: - { - uint32_t base_id = ops[2]; - if (global_var_ids.find(base_id) != global_var_ids.end()) - added_arg_ids.insert(base_id); - - break; - } - case OpFunctionCall: - { - // First see if any of the function call args are globals - for (uint32_t arg_idx = 3; arg_idx < i.length; arg_idx++) - { - uint32_t arg_id = ops[arg_idx]; - if (global_var_ids.find(arg_id) != global_var_ids.end()) - added_arg_ids.insert(arg_id); - } - - // Then recurse into the function itself to extract globals used internally in the function - uint32_t inner_func_id = ops[2]; - std::set inner_func_args; - extract_global_variables_from_function(inner_func_id, inner_func_args, global_var_ids, - processed_func_ids); - added_arg_ids.insert(inner_func_args.begin(), inner_func_args.end()); - break; - } - - default: - break; - } - } - } - - function_global_vars[func_id] = added_arg_ids; - - // Add the global variables as arguments to the function - if (func_id != entry_point) - { - uint32_t next_id = increase_bound_by(uint32_t(added_arg_ids.size())); - for (uint32_t arg_id : added_arg_ids) - { - auto var = get(arg_id); - uint32_t type_id = var.basetype; - func.add_parameter(type_id, next_id, true); - set(next_id, type_id, StorageClassFunction, 0, arg_id); - - // Ensure the existing variable has a valid name and the new variable has all the same meta info - set_name(arg_id, ensure_valid_name(to_name(arg_id), "v")); - meta[next_id] = meta[arg_id]; - - next_id++; - } - } -} - -// For all variables that are some form of non-input-output interface block, mark that all the structs -// that are recursively contained within the type referenced by that variable should be packed tightly. -void CompilerMSL::mark_packable_structs() -{ - for (auto &id : ids) - { - if (id.get_type() == TypeVariable) - { - auto &var = id.get(); - if (var.storage != StorageClassFunction && !is_hidden_variable(var)) - { - auto &type = get(var.basetype); - if (type.pointer && - (type.storage == StorageClassUniform || type.storage == StorageClassUniformConstant || - type.storage == StorageClassPushConstant || type.storage == StorageClassStorageBuffer) && - (has_decoration(type.self, DecorationBlock) || has_decoration(type.self, DecorationBufferBlock))) - mark_as_packable(type); - } - } - } -} - -// If the specified type is a struct, it and any nested structs -// are marked as packable with the DecorationCPacked decoration, -void CompilerMSL::mark_as_packable(SPIRType &type) -{ - // If this is not the base type (eg. it's a pointer or array), tunnel down - if (type.parent_type) - { - mark_as_packable(get(type.parent_type)); - return; - } - - if (type.basetype == SPIRType::Struct) - { - set_decoration(type.self, DecorationCPacked); - - // Recurse - size_t mbr_cnt = type.member_types.size(); - for (uint32_t mbr_idx = 0; mbr_idx < mbr_cnt; mbr_idx++) - { - uint32_t mbr_type_id = type.member_types[mbr_idx]; - auto &mbr_type = get(mbr_type_id); - mark_as_packable(mbr_type); - if (mbr_type.type_alias) - { - auto &mbr_type_alias = get(mbr_type.type_alias); - mark_as_packable(mbr_type_alias); - } - } - } -} - -// If a vertex attribute exists at the location, it is marked as being used by this shader -void CompilerMSL::mark_location_as_used_by_shader(uint32_t location, StorageClass storage) -{ - MSLVertexAttr *p_va; - auto &execution = get_entry_point(); - if ((execution.model == ExecutionModelVertex) && (storage == StorageClassInput) && - (p_va = vtx_attrs_by_location[location])) - p_va->used_by_shader = true; -} - -// Add an interface structure for the type of storage, which is either StorageClassInput or StorageClassOutput. -// Returns the ID of the newly added variable, or zero if no variable was added. -uint32_t CompilerMSL::add_interface_block(StorageClass storage) -{ - // Accumulate the variables that should appear in the interface struct - vector vars; - bool incl_builtins = (storage == StorageClassOutput); - for (auto &id : ids) - { - if (id.get_type() == TypeVariable) - { - auto &var = id.get(); - auto &type = get(var.basetype); - if (var.storage == storage && interface_variable_exists_in_entry_point(var.self) && - !is_hidden_variable(var, incl_builtins) && type.pointer) - { - vars.push_back(&var); - } - } - } - - // If no variables qualify, leave - if (vars.empty()) - return 0; - - // Add a new typed variable for this interface structure. - // The initializer expression is allocated here, but populated when the function - // declaraion is emitted, because it is cleared after each compilation pass. - uint32_t next_id = increase_bound_by(3); - uint32_t ib_type_id = next_id++; - auto &ib_type = set(ib_type_id); - ib_type.basetype = SPIRType::Struct; - ib_type.storage = storage; - set_decoration(ib_type_id, DecorationBlock); - - uint32_t ib_var_id = next_id++; - auto &var = set(ib_var_id, ib_type_id, storage, 0); - var.initializer = next_id++; - - string ib_var_ref; - switch (storage) - { - case StorageClassInput: - ib_var_ref = stage_in_var_name; - break; - - case StorageClassOutput: - { - ib_var_ref = stage_out_var_name; - - // Add the output interface struct as a local variable to the entry function, - // and force the entry function to return the output interface struct from - // any blocks that perform a function return. - auto &entry_func = get(entry_point); - entry_func.add_local_variable(ib_var_id); - for (auto &blk_id : entry_func.blocks) - { - auto &blk = get(blk_id); - if (blk.terminator == SPIRBlock::Return) - blk.return_value = ib_var_id; - } - break; - } - - case StorageClassUniformConstant: - { - ib_var_ref = stage_uniform_var_name; - active_interface_variables.insert(ib_var_id); // Ensure will be emitted - break; - } - - default: - break; - } - - set_name(ib_type_id, get_entry_point_name() + "_" + ib_var_ref); - set_name(ib_var_id, ib_var_ref); - - for (auto p_var : vars) - { - uint32_t type_id = p_var->basetype; - auto &type = get(type_id); - if (type.basetype == SPIRType::Struct) - { - // Flatten the struct members into the interface struct - uint32_t mbr_idx = 0; - for (auto &mbr_type_id : type.member_types) - { - BuiltIn builtin; - bool is_builtin = is_member_builtin(type, mbr_idx, &builtin); - - auto &mbr_type = get(mbr_type_id); - if (should_move_to_input_buffer(mbr_type, is_builtin, storage)) - move_member_to_input_buffer(type, mbr_idx); - - else if (!is_builtin || has_active_builtin(builtin, storage)) - { - // Add a reference to the member to the interface struct. - uint32_t ib_mbr_idx = uint32_t(ib_type.member_types.size()); - ib_type.member_types.push_back(mbr_type_id); // membertype.self is different for array types - - // Give the member a name - string mbr_name = ensure_valid_name(to_qualified_member_name(type, mbr_idx), "m"); - set_member_name(ib_type_id, ib_mbr_idx, mbr_name); - - // Update the original variable reference to include the structure reference - string qual_var_name = ib_var_ref + "." + mbr_name; - set_member_qualified_name(type_id, mbr_idx, qual_var_name); - - // Copy the variable location from the original variable to the member - if (has_member_decoration(type_id, mbr_idx, DecorationLocation)) - { - uint32_t locn = get_member_decoration(type_id, mbr_idx, DecorationLocation); - set_member_decoration(ib_type_id, ib_mbr_idx, DecorationLocation, locn); - mark_location_as_used_by_shader(locn, storage); - } - else if (has_decoration(p_var->self, DecorationLocation)) - { - // The block itself might have a location and in this case, all members of the block - // receive incrementing locations. - uint32_t locn = get_decoration(p_var->self, DecorationLocation) + mbr_idx; - set_member_decoration(ib_type_id, ib_mbr_idx, DecorationLocation, locn); - mark_location_as_used_by_shader(locn, storage); - } - - // Mark the member as builtin if needed - if (is_builtin) - { - set_member_decoration(ib_type_id, ib_mbr_idx, DecorationBuiltIn, builtin); - if (builtin == BuiltInPosition) - qual_pos_var_name = qual_var_name; - } - } - mbr_idx++; - } - } - else if (type.basetype == SPIRType::Boolean || type.basetype == SPIRType::Char || - type.basetype == SPIRType::Int || type.basetype == SPIRType::UInt || - type.basetype == SPIRType::Int64 || type.basetype == SPIRType::UInt64 || - type.basetype == SPIRType::Float || type.basetype == SPIRType::Double || - type.basetype == SPIRType::Boolean) - { - bool is_builtin = is_builtin_variable(*p_var); - BuiltIn builtin = BuiltIn(get_decoration(p_var->self, DecorationBuiltIn)); - - if (should_move_to_input_buffer(type, is_builtin, storage)) - move_to_input_buffer(*p_var); - - else if (!is_builtin || has_active_builtin(builtin, storage)) - { - // Add a reference to the variable type to the interface struct. - uint32_t ib_mbr_idx = uint32_t(ib_type.member_types.size()); - ib_type.member_types.push_back(type_id); - - // Give the member a name - string mbr_name = ensure_valid_name(to_expression(p_var->self), "m"); - set_member_name(ib_type_id, ib_mbr_idx, mbr_name); - - // Update the original variable reference to include the structure reference - string qual_var_name = ib_var_ref + "." + mbr_name; - meta[p_var->self].decoration.qualified_alias = qual_var_name; - - // Copy the variable location from the original variable to the member - if (get_decoration_mask(p_var->self) & (1ull << DecorationLocation)) - { - uint32_t locn = get_decoration(p_var->self, DecorationLocation); - set_member_decoration(ib_type_id, ib_mbr_idx, DecorationLocation, locn); - mark_location_as_used_by_shader(locn, storage); - } - - // Mark the member as builtin if needed - if (is_builtin) - { - set_member_decoration(ib_type_id, ib_mbr_idx, DecorationBuiltIn, builtin); - if (builtin == BuiltInPosition) - qual_pos_var_name = qual_var_name; - } - } - } - } - - // Sort the members of the structure by their locations. - // Oddly, Metal handles inputs better if they are sorted in reverse order. - MemberSorter::SortAspect sort_aspect = - (storage == StorageClassInput) ? MemberSorter::LocationReverse : MemberSorter::Location; - MemberSorter member_sorter(ib_type, meta[ib_type_id], sort_aspect); - member_sorter.sort(); - - return ib_var_id; -} - -// Returns whether a variable of type and storage class should be moved from an interface -// block to a secondary input buffer block. -// This is the case for matrixes and arrays that appear in the stage_in interface block -// of a vertex function, and true is returned. -// Other types do not need to move, and false is returned. -// Matrices and arrays are not permitted in the output of a vertex function or the input -// or output of a fragment function, and in those cases, an exception is thrown. -bool CompilerMSL::should_move_to_input_buffer(SPIRType &type, bool is_builtin, StorageClass storage) -{ - if ((is_matrix(type) || is_array(type)) && !is_builtin) - { - auto &execution = get_entry_point(); - - if (execution.model == ExecutionModelVertex) - { - if (storage == StorageClassInput) - return true; - - if (storage == StorageClassOutput) - SPIRV_CROSS_THROW("The vertex function output structure may not include a matrix or array."); - } - else if (execution.model == ExecutionModelFragment) - { - if (storage == StorageClassInput) - SPIRV_CROSS_THROW("The fragment function stage_in structure may not include a matrix or array."); - - if (storage == StorageClassOutput) - SPIRV_CROSS_THROW("The fragment function output structure may not include a matrix or array."); - } - } - - return false; -} - -// Excludes the specified variable from an interface block structure. -// Instead, for the variable is added to a block variable corresponding to a secondary MSL buffer. -// The use case for this is when a vertex stage_in variable contains a matrix or array. -void CompilerMSL::move_to_input_buffer(SPIRVariable &var) -{ - uint32_t var_id = var.self; - - if (!has_decoration(var_id, DecorationLocation)) - return; - - uint32_t mbr_type_id = var.basetype; - string mbr_name = ensure_valid_name(to_expression(var_id), "m"); - uint32_t mbr_locn = get_decoration(var_id, DecorationLocation); - meta[var_id].decoration.qualified_alias = add_input_buffer_block_member(mbr_type_id, mbr_name, mbr_locn); -} - -// Excludes the specified type member from the stage_in block structure. -// Instead, for the variable is added to a block variable corresponding to a secondary MSL buffer. -// The use case for this is when a vertex stage_in variable contains a matrix or array. -void CompilerMSL::move_member_to_input_buffer(const SPIRType &type, uint32_t index) -{ - uint32_t type_id = type.self; - - if (!has_member_decoration(type_id, index, DecorationLocation)) - return; - - uint32_t mbr_type_id = type.member_types[index]; - string mbr_name = ensure_valid_name(to_qualified_member_name(type, index), "m"); - uint32_t mbr_locn = get_member_decoration(type_id, index, DecorationLocation); - string qual_name = add_input_buffer_block_member(mbr_type_id, mbr_name, mbr_locn); - set_member_qualified_name(type_id, index, qual_name); -} - -// Adds a member to the input buffer block that corresponds to the MTLBuffer used by an attribute location -string CompilerMSL::add_input_buffer_block_member(uint32_t mbr_type_id, string mbr_name, uint32_t mbr_locn) -{ - mark_location_as_used_by_shader(mbr_locn, StorageClassInput); - - MSLVertexAttr *p_va = vtx_attrs_by_location[mbr_locn]; - if (!p_va) - return ""; - - if (p_va->per_instance) - needs_instance_idx_arg = true; - else - needs_vertex_idx_arg = true; - - // The variable that is the block struct. - // Record the stride of this struct in its offset decoration. - uint32_t ib_var_id = get_input_buffer_block_var_id(p_va->msl_buffer); - auto &ib_var = get(ib_var_id); - uint32_t ib_type_id = ib_var.basetype; - auto &ib_type = get(ib_type_id); - set_decoration(ib_type_id, DecorationOffset, p_va->msl_stride); - - // Add a reference to the variable type to the interface struct. - uint32_t ib_mbr_idx = uint32_t(ib_type.member_types.size()); - ib_type.member_types.push_back(mbr_type_id); - - // Give the member a name - set_member_name(ib_type_id, ib_mbr_idx, mbr_name); - - // Set MSL buffer and offset decorations, and indicate no valid attribute location - set_member_decoration(ib_type_id, ib_mbr_idx, DecorationBinding, p_va->msl_buffer); - set_member_decoration(ib_type_id, ib_mbr_idx, DecorationOffset, p_va->msl_offset); - set_member_decoration(ib_type_id, ib_mbr_idx, DecorationLocation, k_unknown_location); - - // Update the original variable reference to include the structure and index reference - string idx_var_name = - builtin_to_glsl(p_va->per_instance ? BuiltInInstanceIndex : BuiltInVertexIndex, StorageClassInput); - return get_name(ib_var_id) + "[" + idx_var_name + "]." + mbr_name; -} - -// Returns the ID of the input block that will use the specified MSL buffer index, -// lazily creating an input block variable and type if needed. -// -// The use of this block applies only to input variables that have been excluded from the stage_in -// block, which typically only occurs if an attempt to pass a matrix in the stage_in block. -uint32_t CompilerMSL::get_input_buffer_block_var_id(uint32_t msl_buffer) -{ - uint32_t ib_var_id = non_stage_in_input_var_ids[msl_buffer]; - if (!ib_var_id) - { - // No interface block exists yet. Create a new typed variable for this interface block. - // The initializer expression is allocated here, but populated when the function - // declaraion is emitted, because it is cleared after each compilation pass. - uint32_t next_id = increase_bound_by(3); - uint32_t ib_type_id = next_id++; - auto &ib_type = set(ib_type_id); - ib_type.basetype = SPIRType::Struct; - ib_type.storage = StorageClassInput; - set_decoration(ib_type_id, DecorationBlock); - - ib_var_id = next_id++; - auto &var = set(ib_var_id, ib_type_id, StorageClassInput, 0); - var.initializer = next_id++; - - string ib_var_name = stage_in_var_name + convert_to_string(msl_buffer); - set_name(ib_var_id, ib_var_name); - set_name(ib_type_id, get_entry_point_name() + "_" + ib_var_name); - - // Add the variable to the map of buffer blocks, accessed by the Metal buffer index. - non_stage_in_input_var_ids[msl_buffer] = ib_var_id; - } - return ib_var_id; -} - -// Sort the members of the struct type by offset, and pack and then pad members where needed -// to align MSL members with SPIR-V offsets. The struct members are iterated twice. Packing -// occurs first, followed by padding, because packing a member reduces both its size and its -// natural alignment, possibly requiring a padding member to be added ahead of it. -void CompilerMSL::align_struct(SPIRType &ib_type) -{ - uint32_t &ib_type_id = ib_type.self; - - // Sort the members of the interface structure by their offset. - // They should already be sorted per SPIR-V spec anyway. - MemberSorter member_sorter(ib_type, meta[ib_type_id], MemberSorter::Offset); - member_sorter.sort(); - - uint32_t curr_offset; - uint32_t mbr_cnt = uint32_t(ib_type.member_types.size()); - - // Test the alignment of each member, and if a member should be closer to the previous - // member than the default spacing expects, it is likely that the previous member is in - // a packed format. If so, and the previous member is packable, pack it. - // For example...this applies to any 3-element vector that is followed by a scalar. - curr_offset = 0; - for (uint32_t mbr_idx = 0; mbr_idx < mbr_cnt; mbr_idx++) - { - // Align current offset to the current member's default alignment. - size_t align_mask = get_declared_struct_member_alignment(ib_type, mbr_idx) - 1; - curr_offset = uint32_t((curr_offset + align_mask) & ~align_mask); - - // Fetch the member offset as declared in the SPIRV. - uint32_t mbr_offset = get_member_decoration(ib_type_id, mbr_idx, DecorationOffset); - if (curr_offset > mbr_offset) - { - uint32_t prev_mbr_idx = mbr_idx - 1; - if (is_member_packable(ib_type, prev_mbr_idx)) - set_member_decoration(ib_type_id, prev_mbr_idx, DecorationCPacked); - } - - // Increment the current offset to be positioned immediately after the current member. - curr_offset = mbr_offset + uint32_t(get_declared_struct_member_size(ib_type, mbr_idx)); - } - - // Test the alignment of each member, and if a member is positioned farther than its - // alignment and the end of the previous member, add a dummy padding member that will - // be added before the current member when the delaration of this struct is emitted. - curr_offset = 0; - for (uint32_t mbr_idx = 0; mbr_idx < mbr_cnt; mbr_idx++) - { - // Align current offset to the current member's default alignment. - size_t align_mask = get_declared_struct_member_alignment(ib_type, mbr_idx) - 1; - curr_offset = uint32_t((curr_offset + align_mask) & ~align_mask); - - // Fetch the member offset as declared in the SPIRV. - uint32_t mbr_offset = get_member_decoration(ib_type_id, mbr_idx, DecorationOffset); - if (mbr_offset > curr_offset) - { - // Since MSL and SPIR-V have slightly different struct member alignment and - // size rules, we'll pad to standard C-packing rules. If the member is farther - // away than C-packing, expects, add an inert padding member before the the member. - MSLStructMemberKey key = get_struct_member_key(ib_type_id, mbr_idx); - struct_member_padding[key] = mbr_offset - curr_offset; - } - - // Increment the current offset to be positioned immediately after the current member. - curr_offset = mbr_offset + uint32_t(get_declared_struct_member_size(ib_type, mbr_idx)); - } -} - -// Returns whether the specified struct member supports a packable type -// variation that is smaller than the unpacked variation of that type. -bool CompilerMSL::is_member_packable(SPIRType &ib_type, uint32_t index) -{ - uint32_t mbr_type_id = ib_type.member_types[index]; - auto &mbr_type = get(mbr_type_id); - - // 3-element vectors (char3, uchar3, short3, ushort3, int3, uint3, half3, float3) - if (mbr_type.vecsize == 3 && mbr_type.columns == 1) - return true; - - return false; -} - -// Returns a combination of type ID and member index for use as hash key -MSLStructMemberKey CompilerMSL::get_struct_member_key(uint32_t type_id, uint32_t index) -{ - MSLStructMemberKey k = type_id; - k <<= 32; - k += index; - return k; -} - -// Converts the format of the current expression from packed to unpacked, -// by wrapping the expression in a constructor of the appropriate type. -string CompilerMSL::unpack_expression_type(string expr_str, const SPIRType &type) -{ - return join(type_to_glsl(type), "(", expr_str, ")"); -} - -// Emits the file header info -void CompilerMSL::emit_header() -{ - for (auto &pragma : pragma_lines) - statement(pragma); - - if (!pragma_lines.empty()) - statement(""); - - statement("#include "); - statement("#include "); - - for (auto &header : header_lines) - statement(header); - - statement(""); - statement("using namespace metal;"); - statement(""); -} - -void CompilerMSL::add_pragma_line(const string &line) -{ - pragma_lines.insert(line); -} - -// Emits any needed custom function bodies. -void CompilerMSL::emit_custom_functions() -{ - for (auto &spv_func : spv_function_implementations) - { - switch (spv_func) - { - case SPVFuncImplMod: - statement("// Implementation of the GLSL mod() function, which is slightly different than Metal fmod()"); - statement("template"); - statement("Tx mod(Tx x, Ty y)"); - begin_scope(); - statement("return x - y * floor(x / y);"); - end_scope(); - statement(""); - break; - - case SPVFuncImplRadians: - statement("// Implementation of the GLSL radians() function"); - statement("template"); - statement("T radians(T d)"); - begin_scope(); - statement("return d * 0.01745329251;"); - end_scope(); - statement(""); - break; - - case SPVFuncImplDegrees: - statement("// Implementation of the GLSL degrees() function"); - statement("template"); - statement("T degrees(T r)"); - begin_scope(); - statement("return r * 57.2957795131;"); - end_scope(); - statement(""); - break; - - case SPVFuncImplFindILsb: - statement("// Implementation of the GLSL findLSB() function"); - statement("template"); - statement("T findLSB(T x)"); - begin_scope(); - statement("return select(ctz(x), T(-1), x == T(0));"); - end_scope(); - statement(""); - break; - - case SPVFuncImplFindUMsb: - statement("// Implementation of the unsigned GLSL findMSB() function"); - statement("template"); - statement("T findUMSB(T x)"); - begin_scope(); - statement("return select(clz(T(0)) - (clz(x) + T(1)), T(-1), x == T(0));"); - end_scope(); - statement(""); - break; - - case SPVFuncImplFindSMsb: - statement("// Implementation of the signed GLSL findMSB() function"); - statement("template"); - statement("T findSMSB(T x)"); - begin_scope(); - statement("T v = select(x, T(-1) - x, x < T(0));"); - statement("return select(clz(T(0)) - (clz(v) + T(1)), T(-1), v == T(0));"); - end_scope(); - statement(""); - break; - - case SPVFuncImplArrayCopy: - statement("// Implementation of an array copy function to cover GLSL's ability to copy an array via " - "assignment. "); - statement("template"); - statement("void spvArrayCopy(thread T* dst, thread const T* src, uint count)"); - begin_scope(); - statement("for (uint i = 0; i < count; *dst++ = *src++, i++);"); - end_scope(); - statement(""); - break; - - case SPVFuncImplInverse4x4: - statement("// Returns the determinant of a 2x2 matrix."); - statement("inline float spvDet2x2(float a1, float a2, float b1, float b2)"); - begin_scope(); - statement("return a1 * b2 - b1 * a2;"); - end_scope(); - statement(""); - statement("// Returns the determinant of a 3x3 matrix."); - statement("inline float spvDet3x3(float a1, float a2, float a3, float b1, float b2, float b3, float c1, " - "float c2, float c3)"); - begin_scope(); - statement("return a1 * spvDet2x2(b2, b3, c2, c3) - b1 * spvDet2x2(a2, a3, c2, c3) + c1 * spvDet2x2(a2, a3, " - "b2, b3);"); - end_scope(); - statement(""); - statement("// Returns the inverse of a matrix, by using the algorithm of calculating the classical"); - statement("// adjoint and dividing by the determinant. The contents of the matrix are changed."); - statement("float4x4 spvInverse4x4(float4x4 m)"); - begin_scope(); - statement("float4x4 adj; // The adjoint matrix (inverse after dividing by determinant)"); - statement(""); - statement("// Create the transpose of the cofactors, as the classical adjoint of the matrix."); - statement("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]);"); - statement("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]);"); - statement("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]);"); - statement("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]);"); - statement(""); - statement("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]);"); - statement("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]);"); - statement("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]);"); - statement("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]);"); - statement(""); - statement("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]);"); - statement("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]);"); - statement("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]);"); - statement("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]);"); - statement(""); - statement("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]);"); - statement("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]);"); - statement("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]);"); - statement("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]);"); - statement(""); - statement("// Calculate the determinant as a combination of the cofactors of the first row."); - statement("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]);"); - statement(""); - statement("// Divide the classical adjoint matrix by the determinant."); - statement("// If determinant is zero, matrix is not invertable, so leave it unchanged."); - statement("return (det != 0.0f) ? (adj * (1.0f / det)) : m;"); - end_scope(); - statement(""); - break; - - case SPVFuncImplInverse3x3: - statement("// Returns the determinant of a 2x2 matrix."); - statement("inline float spvDet2x2(float a1, float a2, float b1, float b2)"); - begin_scope(); - statement("return a1 * b2 - b1 * a2;"); - end_scope(); - statement(""); - statement("// Returns the inverse of a matrix, by using the algorithm of calculating the classical"); - statement("// adjoint and dividing by the determinant. The contents of the matrix are changed."); - statement("float3x3 spvInverse3x3(float3x3 m)"); - begin_scope(); - statement("float3x3 adj; // The adjoint matrix (inverse after dividing by determinant)"); - statement(""); - statement("// Create the transpose of the cofactors, as the classical adjoint of the matrix."); - statement("adj[0][0] = spvDet2x2(m[1][1], m[1][2], m[2][1], m[2][2]);"); - statement("adj[0][1] = -spvDet2x2(m[0][1], m[0][2], m[2][1], m[2][2]);"); - statement("adj[0][2] = spvDet2x2(m[0][1], m[0][2], m[1][1], m[1][2]);"); - statement(""); - statement("adj[1][0] = -spvDet2x2(m[1][0], m[1][2], m[2][0], m[2][2]);"); - statement("adj[1][1] = spvDet2x2(m[0][0], m[0][2], m[2][0], m[2][2]);"); - statement("adj[1][2] = -spvDet2x2(m[0][0], m[0][2], m[1][0], m[1][2]);"); - statement(""); - statement("adj[2][0] = spvDet2x2(m[1][0], m[1][1], m[2][0], m[2][1]);"); - statement("adj[2][1] = -spvDet2x2(m[0][0], m[0][1], m[2][0], m[2][1]);"); - statement("adj[2][2] = spvDet2x2(m[0][0], m[0][1], m[1][0], m[1][1]);"); - statement(""); - statement("// Calculate the determinant as a combination of the cofactors of the first row."); - statement("float det = (adj[0][0] * m[0][0]) + (adj[0][1] * m[1][0]) + (adj[0][2] * m[2][0]);"); - statement(""); - statement("// Divide the classical adjoint matrix by the determinant."); - statement("// If determinant is zero, matrix is not invertable, so leave it unchanged."); - statement("return (det != 0.0f) ? (adj * (1.0f / det)) : m;"); - end_scope(); - statement(""); - break; - - case SPVFuncImplInverse2x2: - statement("// Returns the inverse of a matrix, by using the algorithm of calculating the classical"); - statement("// adjoint and dividing by the determinant. The contents of the matrix are changed."); - statement("float2x2 spvInverse2x2(float2x2 m)"); - begin_scope(); - statement("float2x2 adj; // The adjoint matrix (inverse after dividing by determinant)"); - statement(""); - statement("// Create the transpose of the cofactors, as the classical adjoint of the matrix."); - statement("adj[0][0] = m[1][1];"); - statement("adj[0][1] = -m[0][1];"); - statement(""); - statement("adj[1][0] = -m[1][0];"); - statement("adj[1][1] = m[0][0];"); - statement(""); - statement("// Calculate the determinant as a combination of the cofactors of the first row."); - statement("float det = (adj[0][0] * m[0][0]) + (adj[0][1] * m[1][0]);"); - statement(""); - statement("// Divide the classical adjoint matrix by the determinant."); - statement("// If determinant is zero, matrix is not invertable, so leave it unchanged."); - statement("return (det != 0.0f) ? (adj * (1.0f / det)) : m;"); - end_scope(); - statement(""); - break; - - case SPVFuncImplRowMajor2x3: - statement("// Implementation of a conversion of matrix content from RowMajor to ColumnMajor organization."); - statement("float2x3 spvConvertFromRowMajor2x3(float2x3 m)"); - begin_scope(); - statement("return float2x3(float3(m[0][0], m[0][2], m[1][1]), float3(m[0][1], m[1][0], m[1][2]));"); - end_scope(); - statement(""); - break; - - case SPVFuncImplRowMajor2x4: - statement("// Implementation of a conversion of matrix content from RowMajor to ColumnMajor organization."); - statement("float2x4 spvConvertFromRowMajor2x4(float2x4 m)"); - begin_scope(); - statement("return float2x4(float4(m[0][0], m[0][2], m[1][0], m[1][2]), float4(m[0][1], m[0][3], m[1][1], " - "m[1][3]));"); - end_scope(); - statement(""); - break; - - case SPVFuncImplRowMajor3x2: - statement("// Implementation of a conversion of matrix content from RowMajor to ColumnMajor organization."); - statement("float3x2 spvConvertFromRowMajor3x2(float3x2 m)"); - begin_scope(); - statement("return float3x2(float2(m[0][0], m[1][1]), float2(m[0][1], m[2][0]), float2(m[1][0], m[2][1]));"); - end_scope(); - statement(""); - break; - - case SPVFuncImplRowMajor3x4: - statement("// Implementation of a conversion of matrix content from RowMajor to ColumnMajor organization."); - statement("float3x4 spvConvertFromRowMajor3x4(float3x4 m)"); - begin_scope(); - statement("return float3x4(float4(m[0][0], m[0][3], m[1][2], m[2][1]), float4(m[0][1], m[1][0], m[1][3], " - "m[2][2]), float4(m[0][2], m[1][1], m[2][0], m[2][3]));"); - end_scope(); - statement(""); - break; - - case SPVFuncImplRowMajor4x2: - statement("// Implementation of a conversion of matrix content from RowMajor to ColumnMajor organization."); - statement("float4x2 spvConvertFromRowMajor4x2(float4x2 m)"); - begin_scope(); - statement("return float4x2(float2(m[0][0], m[2][0]), float2(m[0][1], m[2][1]), float2(m[1][0], m[3][0]), " - "float2(m[1][1], m[3][1]));"); - end_scope(); - statement(""); - break; - - case SPVFuncImplRowMajor4x3: - statement("// Implementation of a conversion of matrix content from RowMajor to ColumnMajor organization."); - statement("float4x3 spvConvertFromRowMajor4x3(float4x3 m)"); - begin_scope(); - statement("return float4x3(float3(m[0][0], m[1][1], m[2][2]), float3(m[0][1], m[1][2], m[3][0]), " - "float3(m[0][2], m[2][0], m[3][1]), float3(m[1][0], m[2][1], m[3][2]));"); - end_scope(); - statement(""); - break; - - default: - break; - } - } -} - -// Undefined global memory is not allowed in MSL. -// Declare constant and init to zeros. Use {}, as global constructors can break Metal. -void CompilerMSL::declare_undefined_values() -{ - bool emitted = false; - for (auto &id : ids) - { - if (id.get_type() == TypeUndef) - { - auto &undef = id.get(); - auto &type = get(undef.basetype); - statement("constant ", variable_decl(type, to_name(undef.self), undef.self), " = {};"); - emitted = true; - } - } - - if (emitted) - statement(""); -} - -void CompilerMSL::emit_resources() -{ - // Output non-interface structs. These include local function structs - // and structs nested within uniform and read-write buffers. - unordered_set declared_structs; - for (auto &id : ids) - { - if (id.get_type() == TypeType) - { - auto &type = id.get(); - uint32_t type_id = type.self; - - bool is_struct = (type.basetype == SPIRType::Struct) && type.array.empty(); - bool is_block = - has_decoration(type.self, DecorationBlock) || has_decoration(type.self, DecorationBufferBlock); - bool is_basic_struct = is_struct && !type.pointer && !is_block; - - bool is_interface = (type.storage == StorageClassInput || type.storage == StorageClassOutput || - type.storage == StorageClassUniformConstant); - bool is_non_interface_block = is_struct && type.pointer && is_block && !is_interface; - - bool is_declarable_struct = is_basic_struct || is_non_interface_block; - - // Align and emit declarable structs...but avoid declaring each more than once. - if (is_declarable_struct && declared_structs.count(type_id) == 0) - { - declared_structs.insert(type_id); - - if (has_decoration(type_id, DecorationCPacked)) - align_struct(type); - - emit_struct(type); - } - } - } - - declare_undefined_values(); - - // Output interface structs. - emit_interface_block(stage_in_var_id); - for (auto &nsi_var : non_stage_in_input_var_ids) - emit_interface_block(nsi_var.second); - - emit_interface_block(stage_out_var_id); - emit_interface_block(stage_uniforms_var_id); -} - -// Emit declarations for the specialization Metal function constants -void CompilerMSL::emit_specialization_constants() -{ - const vector spec_consts = get_specialization_constants(); - - SpecializationConstant wg_x, wg_y, wg_z; - uint32_t workgroup_size_id = get_work_group_size_specialization_constants(wg_x, wg_y, wg_z); - - for (auto &sc : spec_consts) - { - // If WorkGroupSize is a specialization constant, it will be declared explicitly below. - if (sc.id == workgroup_size_id) - continue; - - auto &type = expression_type(sc.id); - string sc_type_name = type_to_glsl(type); - string sc_name = to_name(sc.id); - string sc_tmp_name = to_name(sc.id) + "_tmp"; - - if (type.vecsize == 1 && type.columns == 1 && type.basetype != SPIRType::Struct && type.array.empty()) - { - // Only scalar, non-composite values can be function constants. - statement("constant ", sc_type_name, " ", sc_tmp_name, " [[function_constant(", - convert_to_string(sc.constant_id), ")]];"); - statement("constant ", sc_type_name, " ", sc_name, " = is_function_constant_defined(", sc_tmp_name, ") ? ", - sc_tmp_name, " : ", constant_expression(get(sc.id)), ";"); - } - else - { - // Composite specialization constants must be built from other specialization constants. - statement("constant ", sc_type_name, " ", sc_name, " = ", constant_expression(get(sc.id)), - ";"); - } - } - - // TODO: This can be expressed as a [[threads_per_threadgroup]] input semantic, but we need to know - // the work group size at compile time in SPIR-V, and [[threads_per_threadgroup]] would need to be passed around as a global. - // The work group size may be a specialization constant. - if (workgroup_size_id) - statement("constant uint3 ", builtin_to_glsl(BuiltInWorkgroupSize, StorageClassWorkgroup), " = ", - constant_expression(get(workgroup_size_id)), ";"); - - if (!spec_consts.empty() || workgroup_size_id) - statement(""); -} - -// Override for MSL-specific syntax instructions -void CompilerMSL::emit_instruction(const Instruction &instruction) -{ - -#define BOP(op) emit_binary_op(ops[0], ops[1], ops[2], ops[3], #op) -#define BOP_CAST(op, type) \ - emit_binary_op_cast(ops[0], ops[1], ops[2], ops[3], #op, type, opcode_is_sign_invariant(opcode)) -#define UOP(op) emit_unary_op(ops[0], ops[1], ops[2], #op) -#define QFOP(op) emit_quaternary_func_op(ops[0], ops[1], ops[2], ops[3], ops[4], ops[5], #op) -#define TFOP(op) emit_trinary_func_op(ops[0], ops[1], ops[2], ops[3], ops[4], #op) -#define BFOP(op) emit_binary_func_op(ops[0], ops[1], ops[2], ops[3], #op) -#define BFOP_CAST(op, type) \ - emit_binary_func_op_cast(ops[0], ops[1], ops[2], ops[3], #op, type, opcode_is_sign_invariant(opcode)) -#define UFOP(op) emit_unary_func_op(ops[0], ops[1], ops[2], #op) - - auto ops = stream(instruction); - auto opcode = static_cast(instruction.op); - - switch (opcode) - { - - // Comparisons - case OpIEqual: - case OpLogicalEqual: - case OpFOrdEqual: - BOP(==); - break; - - case OpINotEqual: - case OpLogicalNotEqual: - case OpFOrdNotEqual: - BOP(!=); - break; - - case OpUGreaterThan: - case OpSGreaterThan: - case OpFOrdGreaterThan: - BOP(>); - break; - - case OpUGreaterThanEqual: - case OpSGreaterThanEqual: - case OpFOrdGreaterThanEqual: - BOP(>=); - break; - - case OpULessThan: - case OpSLessThan: - case OpFOrdLessThan: - BOP(<); - break; - - case OpULessThanEqual: - case OpSLessThanEqual: - case OpFOrdLessThanEqual: - BOP(<=); - break; - - // Derivatives - case OpDPdx: - case OpDPdxFine: - case OpDPdxCoarse: - UFOP(dfdx); - break; - - case OpDPdy: - case OpDPdyFine: - case OpDPdyCoarse: - UFOP(dfdy); - break; - - // Bitfield - case OpBitFieldInsert: - QFOP(insert_bits); - break; - - case OpBitFieldSExtract: - case OpBitFieldUExtract: - TFOP(extract_bits); - break; - - case OpBitReverse: - UFOP(reverse_bits); - break; - - case OpBitCount: - UFOP(popcount); - break; - - // Atomics - case OpAtomicExchange: - { - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - uint32_t ptr = ops[2]; - uint32_t mem_sem = ops[4]; - uint32_t val = ops[5]; - emit_atomic_func_op(result_type, id, "atomic_exchange_explicit", mem_sem, mem_sem, false, ptr, val); - break; - } - - case OpAtomicCompareExchange: - case OpAtomicCompareExchangeWeak: - { - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - uint32_t ptr = ops[2]; - uint32_t mem_sem_pass = ops[4]; - uint32_t mem_sem_fail = ops[5]; - uint32_t val = ops[6]; - uint32_t comp = ops[7]; - emit_atomic_func_op(result_type, id, "atomic_compare_exchange_weak_explicit", mem_sem_pass, mem_sem_fail, true, - ptr, comp, true, val); - break; - } - - case OpAtomicLoad: - { - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - uint32_t ptr = ops[2]; - uint32_t mem_sem = ops[4]; - emit_atomic_func_op(result_type, id, "atomic_load_explicit", mem_sem, mem_sem, false, ptr, 0); - break; - } - - case OpAtomicStore: - { - uint32_t result_type = expression_type(ops[0]).self; - uint32_t id = ops[0]; - uint32_t ptr = ops[0]; - uint32_t mem_sem = ops[2]; - uint32_t val = ops[3]; - emit_atomic_func_op(result_type, id, "atomic_store_explicit", mem_sem, mem_sem, false, ptr, val); - break; - } - -#define AFMOImpl(op, valsrc) \ - do \ - { \ - uint32_t result_type = ops[0]; \ - uint32_t id = ops[1]; \ - uint32_t ptr = ops[2]; \ - uint32_t mem_sem = ops[4]; \ - uint32_t val = valsrc; \ - emit_atomic_func_op(result_type, id, "atomic_fetch_" #op "_explicit", mem_sem, mem_sem, false, ptr, val); \ - } while (false) - -#define AFMO(op) AFMOImpl(op, ops[5]) -#define AFMIO(op) AFMOImpl(op, 1) - - case OpAtomicIIncrement: - AFMIO(add); - break; - - case OpAtomicIDecrement: - AFMIO(sub); - break; - - case OpAtomicIAdd: - AFMO(add); - break; - - case OpAtomicISub: - AFMO(sub); - break; - - case OpAtomicSMin: - case OpAtomicUMin: - AFMO(min); - break; - - case OpAtomicSMax: - case OpAtomicUMax: - AFMO(max); - break; - - case OpAtomicAnd: - AFMO(and); - break; - - case OpAtomicOr: - AFMO(or); - break; - - case OpAtomicXor: - AFMO (xor); - break; - - // Images - - // Reads == Fetches in Metal - case OpImageRead: - { - // Mark that this shader reads from this image - uint32_t img_id = ops[2]; - auto *p_var = maybe_get_backing_variable(img_id); - if (p_var && has_decoration(p_var->self, DecorationNonReadable)) - { - unset_decoration(p_var->self, DecorationNonReadable); - force_recompile = true; - } - - emit_texture_op(instruction); - break; - } - - case OpImageWrite: - { - uint32_t img_id = ops[0]; - uint32_t coord_id = ops[1]; - uint32_t texel_id = ops[2]; - const uint32_t *opt = &ops[3]; - uint32_t length = instruction.length - 4; - - // Bypass pointers because we need the real image struct - auto &type = expression_type(img_id); - auto &img_type = get(type.self); - - // Ensure this image has been marked as being written to and force a - // recommpile so that the image type output will include write access - auto *p_var = maybe_get_backing_variable(img_id); - if (p_var && has_decoration(p_var->self, DecorationNonWritable)) - { - unset_decoration(p_var->self, DecorationNonWritable); - force_recompile = true; - } - - bool forward = false; - uint32_t bias = 0; - uint32_t lod = 0; - uint32_t flags = 0; - - if (length) - { - flags = *opt++; - length--; - } - - auto test = [&](uint32_t &v, uint32_t flag) { - if (length && (flags & flag)) - { - v = *opt++; - length--; - } - }; - - test(bias, ImageOperandsBiasMask); - test(lod, ImageOperandsLodMask); - - statement(join( - to_expression(img_id), ".write(", to_expression(texel_id), ", ", - to_function_args(img_id, img_type, true, false, false, coord_id, 0, 0, 0, 0, lod, 0, 0, 0, 0, 0, &forward), - ");")); - - if (p_var && variable_storage_is_aliased(*p_var)) - flush_all_aliased_variables(); - - break; - } - - case OpImageQuerySize: - case OpImageQuerySizeLod: - { - uint32_t rslt_type_id = ops[0]; - auto &rslt_type = get(rslt_type_id); - - uint32_t id = ops[1]; - - uint32_t img_id = ops[2]; - string img_exp = to_expression(img_id); - auto &img_type = expression_type(img_id); - Dim img_dim = img_type.image.dim; - bool img_is_array = img_type.image.arrayed; - - if (img_type.basetype != SPIRType::Image) - SPIRV_CROSS_THROW("Invalid type for OpImageQuerySize."); - - string lod; - if (opcode == OpImageQuerySizeLod) - { - // LOD index defaults to zero, so don't bother outputing level zero index - string decl_lod = to_expression(ops[3]); - if (decl_lod != "0") - lod = decl_lod; - } - - string expr = type_to_glsl(rslt_type) + "("; - expr += img_exp + ".get_width(" + lod + ")"; - - if (img_dim == Dim2D || img_dim == DimCube || img_dim == Dim3D) - expr += ", " + img_exp + ".get_height(" + lod + ")"; - - if (img_dim == Dim3D) - expr += ", " + img_exp + ".get_depth(" + lod + ")"; - - if (img_is_array) - expr += ", " + img_exp + ".get_array_size()"; - - expr += ")"; - - emit_op(rslt_type_id, id, expr, should_forward(img_id)); - - break; - } - -#define ImgQry(qrytype) \ - do \ - { \ - uint32_t rslt_type_id = ops[0]; \ - auto &rslt_type = get(rslt_type_id); \ - uint32_t id = ops[1]; \ - uint32_t img_id = ops[2]; \ - string img_exp = to_expression(img_id); \ - string expr = type_to_glsl(rslt_type) + "(" + img_exp + ".get_num_" #qrytype "())"; \ - emit_op(rslt_type_id, id, expr, should_forward(img_id)); \ - } while (false) - - case OpImageQueryLevels: - ImgQry(mip_levels); - break; - - case OpImageQuerySamples: - ImgQry(samples); - break; - - // Casting - case OpQuantizeToF16: - { - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; - uint32_t arg = ops[2]; - - string exp; - auto &type = get(result_type); - - switch (type.vecsize) - { - case 1: - exp = join("float(half(", to_expression(arg), "))"); - break; - case 2: - exp = join("float2(half2(", to_expression(arg), "))"); - break; - case 3: - exp = join("float3(half3(", to_expression(arg), "))"); - break; - case 4: - exp = join("float4(half4(", to_expression(arg), "))"); - break; - default: - SPIRV_CROSS_THROW("Illegal argument to OpQuantizeToF16."); - } - - emit_op(result_type, id, exp, should_forward(arg)); - break; - } - - case OpStore: - if (maybe_emit_input_struct_assignment(ops[0], ops[1])) - break; - - if (maybe_emit_array_assignment(ops[0], ops[1])) - break; - - CompilerGLSL::emit_instruction(instruction); - break; - - // Compute barriers - case OpMemoryBarrier: - emit_barrier(0, ops[0], ops[1]); - break; - - case OpControlBarrier: - // In GLSL a memory barrier is often followed by a control barrier. - // But in MSL, memory barriers are also control barriers, so don't - // emit a simple control barrier if a memory barrier has just been emitted. - if (previous_instruction_opcode != OpMemoryBarrier) - emit_barrier(ops[0], ops[1], ops[2]); - break; - - case OpVectorTimesMatrix: - case OpMatrixTimesVector: - { - // If the matrix needs transpose and it is square, just flip the multiply order. - uint32_t mtx_id = ops[opcode == OpMatrixTimesVector ? 2 : 3]; - auto *e = maybe_get(mtx_id); - auto &t = expression_type(mtx_id); - if (e && e->need_transpose && t.columns == t.vecsize) - { - e->need_transpose = false; - emit_binary_op(ops[0], ops[1], ops[3], ops[2], "*"); - e->need_transpose = true; - } - else - BOP(*); - break; - } - - // OpOuterProduct - - default: - CompilerGLSL::emit_instruction(instruction); - break; - } - - previous_instruction_opcode = opcode; -} - -void CompilerMSL::emit_barrier(uint32_t id_exe_scope, uint32_t id_mem_scope, uint32_t id_mem_sem) -{ - if (get_entry_point().model != ExecutionModelGLCompute) - return; - - string bar_stmt = "threadgroup_barrier(mem_flags::"; - - uint32_t mem_sem = id_mem_sem ? get(id_mem_sem).scalar() : uint32_t(MemorySemanticsMaskNone); - - if (mem_sem & MemorySemanticsCrossWorkgroupMemoryMask) - bar_stmt += "mem_device"; - else if (mem_sem & (MemorySemanticsSubgroupMemoryMask | MemorySemanticsWorkgroupMemoryMask | - MemorySemanticsAtomicCounterMemoryMask)) - bar_stmt += "mem_threadgroup"; - else if (mem_sem & MemorySemanticsImageMemoryMask) - bar_stmt += "mem_texture"; - else - bar_stmt += "mem_none"; - - if (options.is_ios() && options.supports_msl_version(2)) - { - bar_stmt += ", "; - - // Use the wider of the two scopes (smaller value) - uint32_t exe_scope = id_exe_scope ? get(id_exe_scope).scalar() : uint32_t(ScopeInvocation); - uint32_t mem_scope = id_mem_scope ? get(id_mem_scope).scalar() : uint32_t(ScopeInvocation); - uint32_t scope = min(exe_scope, mem_scope); - switch (scope) - { - case ScopeCrossDevice: - case ScopeDevice: - bar_stmt += "memory_scope_device"; - break; - - case ScopeSubgroup: - case ScopeInvocation: - bar_stmt += "memory_scope_simdgroup"; - break; - - case ScopeWorkgroup: - default: - bar_stmt += "memory_scope_threadgroup"; - break; - } - } - - bar_stmt += ");"; - - statement(bar_stmt); -} - -// Since MSL does not allow structs to be nested within the stage_in struct, the original input -// structs are flattened into a single stage_in struct by add_interface_block. As a result, -// if the LHS and RHS represent an assignment of an entire input struct, we must perform this -// member-by-member, mapping each RHS member to its name in the flattened stage_in struct. -// Returns whether the struct assignment was emitted. -bool CompilerMSL::maybe_emit_input_struct_assignment(uint32_t id_lhs, uint32_t id_rhs) -{ - // We only care about assignments of an entire struct - uint32_t type_id = expression_type_id(id_rhs); - auto &type = get(type_id); - if (type.basetype != SPIRType::Struct) - return false; - - // We only care about assignments from Input variables - auto *p_v_rhs = maybe_get_backing_variable(id_rhs); - if (!(p_v_rhs && p_v_rhs->storage == StorageClassInput)) - return false; - - // Get the ID of the type of the underlying RHS variable. - // This will be an Input OpTypePointer containing the qualified member names. - uint32_t tid_v_rhs = p_v_rhs->basetype; - - // Ensure the LHS variable has been declared - auto *p_v_lhs = maybe_get_backing_variable(id_lhs); - if (p_v_lhs) - flush_variable_declaration(p_v_lhs->self); - - size_t mbr_cnt = type.member_types.size(); - for (uint32_t mbr_idx = 0; mbr_idx < mbr_cnt; mbr_idx++) - { - string expr; - - //LHS - expr += to_name(id_lhs); - expr += "."; - expr += to_member_name(type, mbr_idx); - - expr += " = "; - - //RHS - string qual_mbr_name = get_member_qualified_name(tid_v_rhs, mbr_idx); - if (qual_mbr_name.empty()) - { - expr += to_name(id_rhs); - expr += "."; - expr += to_member_name(type, mbr_idx); - } - else - expr += qual_mbr_name; - - statement(expr, ";"); - } - - return true; -} - -// Since MSL does not allow arrays to be copied via simple variable assignment, -// if the LHS and RHS represent an assignment of an entire array, it must be -// implemented by calling an array copy function. -// Returns whether the struct assignment was emitted. -bool CompilerMSL::maybe_emit_array_assignment(uint32_t id_lhs, uint32_t id_rhs) -{ - // Assignment from an array initializer is fine. - if (ids[id_rhs].get_type() == TypeConstant) - return false; - - // We only care about assignments of an entire array - auto &type = expression_type(id_rhs); - if (type.array.size() == 0) - return false; - - // Ensure the LHS variable has been declared - auto *p_v_lhs = maybe_get_backing_variable(id_lhs); - if (p_v_lhs) - flush_variable_declaration(p_v_lhs->self); - - statement("spvArrayCopy(", to_expression(id_lhs), ", ", to_expression(id_rhs), ", ", to_array_size(type, 0), ");"); - register_write(id_lhs); - - return true; -} - -// Emits one of the atomic functions. In MSL, the atomic functions operate on pointers -void CompilerMSL::emit_atomic_func_op(uint32_t result_type, uint32_t result_id, const char *op, uint32_t mem_order_1, - uint32_t mem_order_2, bool has_mem_order_2, uint32_t obj, uint32_t op1, - bool op1_is_pointer, uint32_t op2) -{ - forced_temporaries.insert(result_id); - - bool fwd_obj = should_forward(obj); - bool fwd_op1 = op1 ? should_forward(op1) : true; - bool fwd_op2 = op2 ? should_forward(op2) : true; - - bool forward = fwd_obj && fwd_op1 && fwd_op2; - - string exp = string(op) + "("; - - auto &type = expression_type(obj); - exp += "(volatile "; - exp += "device"; - exp += " atomic_"; - exp += type_to_glsl(type); - exp += "*)"; - - exp += "&("; - exp += to_expression(obj); - exp += ")"; - - if (op1) - { - if (op1_is_pointer) - { - statement(declare_temporary(expression_type(op2).self, op1), to_expression(op1), ";"); - exp += ", &(" + to_name(op1) + ")"; - } - else - exp += ", " + to_expression(op1); - } - - if (op2) - exp += ", " + to_expression(op2); - - exp += string(", ") + get_memory_order(mem_order_1); - - if (has_mem_order_2) - exp += string(", ") + get_memory_order(mem_order_2); - - exp += ")"; - emit_op(result_type, result_id, exp, forward); - - inherit_expression_dependencies(result_id, obj); - if (op1) - inherit_expression_dependencies(result_id, op1); - if (op2) - inherit_expression_dependencies(result_id, op2); - - flush_all_atomic_capable_variables(); -} - -// Metal only supports relaxed memory order for now -const char *CompilerMSL::get_memory_order(uint32_t) -{ - return "memory_order_relaxed"; -} - -// Override for MSL-specific extension syntax instructions -void CompilerMSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop, const uint32_t *args, uint32_t count) -{ - GLSLstd450 op = static_cast(eop); - - switch (op) - { - case GLSLstd450Atan2: - emit_binary_func_op(result_type, id, args[0], args[1], "atan2"); - break; - case GLSLstd450InverseSqrt: - emit_unary_func_op(result_type, id, args[0], "rsqrt"); - break; - case GLSLstd450RoundEven: - emit_unary_func_op(result_type, id, args[0], "rint"); - break; - - case GLSLstd450FindSMsb: - emit_unary_func_op(result_type, id, args[0], "findSMSB"); - break; - case GLSLstd450FindUMsb: - emit_unary_func_op(result_type, id, args[0], "findUMSB"); - break; - - case GLSLstd450PackSnorm4x8: - emit_unary_func_op(result_type, id, args[0], "pack_float_to_snorm4x8"); - break; - case GLSLstd450PackUnorm4x8: - emit_unary_func_op(result_type, id, args[0], "pack_float_to_unorm4x8"); - break; - case GLSLstd450PackSnorm2x16: - emit_unary_func_op(result_type, id, args[0], "pack_float_to_snorm2x16"); - break; - case GLSLstd450PackUnorm2x16: - emit_unary_func_op(result_type, id, args[0], "pack_float_to_unorm2x16"); - break; - case GLSLstd450PackHalf2x16: - emit_unary_func_op(result_type, id, args[0], "unsupported_GLSLstd450PackHalf2x16"); // Currently unsupported - break; - - case GLSLstd450UnpackSnorm4x8: - emit_unary_func_op(result_type, id, args[0], "unpack_snorm4x8_to_float"); - break; - case GLSLstd450UnpackUnorm4x8: - emit_unary_func_op(result_type, id, args[0], "unpack_unorm4x8_to_float"); - break; - case GLSLstd450UnpackSnorm2x16: - emit_unary_func_op(result_type, id, args[0], "unpack_snorm2x16_to_float"); - break; - case GLSLstd450UnpackUnorm2x16: - emit_unary_func_op(result_type, id, args[0], "unpack_unorm2x16_to_float"); - break; - case GLSLstd450UnpackHalf2x16: - emit_unary_func_op(result_type, id, args[0], "unsupported_GLSLstd450UnpackHalf2x16"); // Currently unsupported - break; - - case GLSLstd450PackDouble2x32: - emit_unary_func_op(result_type, id, args[0], "unsupported_GLSLstd450PackDouble2x32"); // Currently unsupported - break; - case GLSLstd450UnpackDouble2x32: - emit_unary_func_op(result_type, id, args[0], "unsupported_GLSLstd450UnpackDouble2x32"); // Currently unsupported - break; - - case GLSLstd450MatrixInverse: - { - auto &mat_type = get(result_type); - switch (mat_type.columns) - { - case 2: - emit_unary_func_op(result_type, id, args[0], "spvInverse2x2"); - break; - case 3: - emit_unary_func_op(result_type, id, args[0], "spvInverse3x3"); - break; - case 4: - emit_unary_func_op(result_type, id, args[0], "spvInverse4x4"); - break; - default: - break; - } - break; - } - - // TODO: - // GLSLstd450InterpolateAtCentroid (centroid_no_perspective qualifier) - // GLSLstd450InterpolateAtSample (sample_no_perspective qualifier) - // GLSLstd450InterpolateAtOffset - - default: - CompilerGLSL::emit_glsl_op(result_type, id, eop, args, count); - break; - } -} - -// Emit a structure declaration for the specified interface variable. -void CompilerMSL::emit_interface_block(uint32_t ib_var_id) -{ - if (ib_var_id) - { - auto &ib_var = get(ib_var_id); - auto &ib_type = get(ib_var.basetype); - auto &m = meta.at(ib_type.self); - if (m.members.size() > 0) - emit_struct(ib_type); - } -} - -// Emits the declaration signature of the specified function. -// If this is the entry point function, Metal-specific return value and function arguments are added. -void CompilerMSL::emit_function_prototype(SPIRFunction &func, uint64_t) -{ - local_variable_names = resource_names; - string decl; - - processing_entry_point = (func.self == entry_point); - - auto &type = get(func.return_type); - decl += func_type_decl(type); - decl += " "; - decl += to_name(func.self); - - decl += "("; - - if (processing_entry_point) - { - decl += entry_point_args(!func.arguments.empty()); - - // If entry point function has a output interface struct, set its initializer. - // This is done at this late stage because the initialization expression is - // cleared after each compilation pass. - if (stage_out_var_id) - { - auto &so_var = get(stage_out_var_id); - auto &so_type = get(so_var.basetype); - set(so_var.initializer, "{}", so_type.self, true); - } - } - - for (auto &arg : func.arguments) - { - add_local_variable_name(arg.id); - - string address_space = "thread"; - - auto *var = maybe_get(arg.id); - if (var) - { - var->parameter = &arg; // Hold a pointer to the parameter so we can invalidate the readonly field if needed. - address_space = get_argument_address_space(*var); - } - - decl += address_space + " "; - decl += argument_decl(arg); - - // Manufacture automatic sampler arg for SampledImage texture - auto &arg_type = get(arg.type); - if (arg_type.basetype == SPIRType::SampledImage && arg_type.image.dim != DimBuffer) - decl += ", thread const sampler& " + to_sampler_expression(arg.id); - - if (&arg != &func.arguments.back()) - decl += ", "; - } - - decl += ")"; - statement(decl); -} - -// Returns the texture sampling function string for the specified image and sampling characteristics. -string CompilerMSL::to_function_name(uint32_t img, const SPIRType &, bool is_fetch, bool is_gather, bool, bool, bool, - bool, bool has_dref, uint32_t) -{ - // Texture reference - string fname = to_expression(img) + "."; - - // Texture function and sampler - if (is_fetch) - fname += "read"; - else if (is_gather) - fname += "gather"; - else - fname += "sample"; - - if (has_dref) - fname += "_compare"; - - return fname; -} - -// Returns the function args for a texture sampling function for the specified image and sampling characteristics. -string CompilerMSL::to_function_args(uint32_t img, const SPIRType &imgtype, bool is_fetch, bool, bool is_proj, - uint32_t coord, uint32_t, uint32_t dref, uint32_t grad_x, uint32_t grad_y, - uint32_t lod, uint32_t coffset, uint32_t offset, uint32_t bias, uint32_t comp, - uint32_t sample, bool *p_forward) -{ - string farg_str; - if (!is_fetch) - farg_str += to_sampler_expression(img); - - // Texture coordinates - bool forward = should_forward(coord); - auto coord_expr = to_enclosed_expression(coord); - auto &coord_type = expression_type(coord); - bool coord_is_fp = (coord_type.basetype == SPIRType::Float) || (coord_type.basetype == SPIRType::Double); - bool is_cube_fetch = false; - - string tex_coords = coord_expr; - const char *alt_coord = ""; - - switch (imgtype.image.dim) - { - - case Dim1D: - if (coord_type.vecsize > 1) - tex_coords += ".x"; - - if (is_fetch) - tex_coords = "uint(" + round_fp_tex_coords(tex_coords, coord_is_fp) + ")"; - - alt_coord = ".y"; - - break; - - case DimBuffer: - if (coord_type.vecsize > 1) - tex_coords += ".x"; - - if (is_fetch) - tex_coords = "uint2(" + round_fp_tex_coords(tex_coords, coord_is_fp) + ", 0)"; // Metal textures are 2D - - alt_coord = ".y"; - - break; - - case Dim2D: - if (coord_type.vecsize > 2) - tex_coords += ".xy"; - - if (is_fetch) - tex_coords = "uint2(" + round_fp_tex_coords(tex_coords, coord_is_fp) + ")"; - - alt_coord = ".z"; - - break; - - case Dim3D: - if (coord_type.vecsize > 3) - tex_coords += ".xyz"; - - if (is_fetch) - tex_coords = "uint3(" + round_fp_tex_coords(tex_coords, coord_is_fp) + ")"; - - alt_coord = ".w"; - - break; - - case DimCube: - if (is_fetch) - { - is_cube_fetch = true; - tex_coords += ".xy"; - tex_coords = "uint2(" + round_fp_tex_coords(tex_coords, coord_is_fp) + ")"; - } - else - { - if (coord_type.vecsize > 3) - tex_coords += ".xyz"; - } - - alt_coord = ".w"; - - break; - - default: - break; - } - - // If projection, use alt coord as divisor - if (is_proj) - tex_coords += " / " + coord_expr + alt_coord; - - if (!farg_str.empty()) - farg_str += ", "; - farg_str += tex_coords; - - // If fetch from cube, add face explicitly - if (is_cube_fetch) - farg_str += ", uint(" + round_fp_tex_coords(coord_expr + ".z", coord_is_fp) + ")"; - - // If array, use alt coord - if (imgtype.image.arrayed) - farg_str += ", uint(" + round_fp_tex_coords(coord_expr + alt_coord, coord_is_fp) + ")"; - - // Depth compare reference value - if (dref) - { - forward = forward && should_forward(dref); - farg_str += ", "; - farg_str += to_expression(dref); - } - - // LOD Options - if (bias) - { - forward = forward && should_forward(bias); - farg_str += ", bias(" + to_expression(bias) + ")"; - } - - if (lod) - { - forward = forward && should_forward(lod); - if (is_fetch) - { - farg_str += ", " + to_expression(lod); - } - else - { - farg_str += ", level(" + to_expression(lod) + ")"; - } - } - - if (grad_x || grad_y) - { - forward = forward && should_forward(grad_x); - forward = forward && should_forward(grad_y); - string grad_opt; - switch (imgtype.image.dim) - { - case Dim2D: - grad_opt = "2d"; - break; - case Dim3D: - grad_opt = "3d"; - break; - case DimCube: - grad_opt = "cube"; - break; - default: - grad_opt = "unsupported_gradient_dimension"; - break; - } - farg_str += ", gradient" + grad_opt + "(" + to_expression(grad_x) + ", " + to_expression(grad_y) + ")"; - } - - // Add offsets - string offset_expr; - if (coffset) - { - forward = forward && should_forward(coffset); - offset_expr = to_expression(coffset); - } - else if (offset) - { - forward = forward && should_forward(offset); - offset_expr = to_expression(offset); - } - - if (!offset_expr.empty()) - { - switch (imgtype.image.dim) - { - case Dim2D: - if (coord_type.vecsize > 2) - offset_expr += ".xy"; - - farg_str += ", " + offset_expr; - break; - - case Dim3D: - if (coord_type.vecsize > 3) - offset_expr += ".xyz"; - - farg_str += ", " + offset_expr; - break; - - default: - break; - } - } - - if (comp) - { - forward = forward && should_forward(comp); - farg_str += ", " + to_component_argument(comp); - } - - if (sample) - { - farg_str += ", "; - farg_str += to_expression(sample); - } - - *p_forward = forward; - - return farg_str; -} - -// If the texture coordinates are floating point, invokes MSL round() function to round them. -string CompilerMSL::round_fp_tex_coords(string tex_coords, bool coord_is_fp) -{ - return coord_is_fp ? ("round(" + tex_coords + ")") : tex_coords; -} - -// Returns a string to use in an image sampling function argument. -// The ID must be a scalar constant. -string CompilerMSL::to_component_argument(uint32_t id) -{ - if (ids[id].get_type() != TypeConstant) - { - SPIRV_CROSS_THROW("ID " + to_string(id) + " is not an OpConstant."); - return "component::x"; - } - - uint32_t component_index = get(id).scalar(); - switch (component_index) - { - case 0: - return "component::x"; - case 1: - return "component::y"; - case 2: - return "component::z"; - case 3: - return "component::w"; - - default: - SPIRV_CROSS_THROW("The value (" + to_string(component_index) + ") of OpConstant ID " + to_string(id) + - " is not a valid Component index, which must be one of 0, 1, 2, or 3."); - return "component::x"; - } -} - -// Establish sampled image as expression object and assign the sampler to it. -void CompilerMSL::emit_sampled_image_op(uint32_t result_type, uint32_t result_id, uint32_t image_id, uint32_t samp_id) -{ - set(result_id, to_expression(image_id), result_type, true); - meta[result_id].sampler = samp_id; -} - -// Returns a string representation of the ID, usable as a function arg. -// Manufacture automatic sampler arg for SampledImage texture. -string CompilerMSL::to_func_call_arg(uint32_t id) -{ - string arg_str = CompilerGLSL::to_func_call_arg(id); - - // Manufacture automatic sampler arg if the arg is a SampledImage texture. - Variant &id_v = ids[id]; - if (id_v.get_type() == TypeVariable) - { - auto &var = id_v.get(); - auto &type = get(var.basetype); - if (type.basetype == SPIRType::SampledImage && type.image.dim != DimBuffer) - arg_str += ", " + to_sampler_expression(id); - } - - return arg_str; -} - -// If the ID represents a sampled image that has been assigned a sampler already, -// generate an expression for the sampler, otherwise generate a fake sampler name -// by appending a suffix to the expression constructed from the ID. -string CompilerMSL::to_sampler_expression(uint32_t id) -{ - uint32_t samp_id = meta[id].sampler; - return samp_id ? to_expression(samp_id) : to_expression(id) + sampler_name_suffix; -} - -// Checks whether the ID is a row_major matrix that requires conversion before use -bool CompilerMSL::is_non_native_row_major_matrix(uint32_t id) -{ - // Natively supported row-major matrices do not need to be converted. - if (backend.native_row_major_matrix) - return false; - - // Non-matrix or column-major matrix types do not need to be converted. - if (!(meta[id].decoration.decoration_flags & (1ull << DecorationRowMajor))) - return false; - - // Generate a function that will swap matrix elements from row-major to column-major. - const auto type = expression_type(id); - add_convert_row_major_matrix_function(type.columns, type.vecsize); - return true; -} - -// Checks whether the member is a row_major matrix that requires conversion before use -bool CompilerMSL::member_is_non_native_row_major_matrix(const SPIRType &type, uint32_t index) -{ - // Natively supported row-major matrices do not need to be converted. - if (backend.native_row_major_matrix) - return false; - - // Non-matrix or column-major matrix types do not need to be converted. - if (!(combined_decoration_for_member(type, index) & (1ull << DecorationRowMajor))) - return false; - - // Generate a function that will swap matrix elements from row-major to column-major. - const auto mbr_type = get(type.member_types[index]); - add_convert_row_major_matrix_function(mbr_type.columns, mbr_type.vecsize); - return true; -} - -// Adds a function suitable for converting a non-square row-major matrix to a column-major matrix. -void CompilerMSL::add_convert_row_major_matrix_function(uint32_t cols, uint32_t rows) -{ - SPVFuncImpl spv_func; - if (cols == rows) // Square matrix...just use transpose() function - return; - else if (cols == 2 && rows == 3) - spv_func = SPVFuncImplRowMajor2x3; - else if (cols == 2 && rows == 4) - spv_func = SPVFuncImplRowMajor2x4; - else if (cols == 3 && rows == 2) - spv_func = SPVFuncImplRowMajor3x2; - else if (cols == 3 && rows == 4) - spv_func = SPVFuncImplRowMajor3x4; - else if (cols == 4 && rows == 2) - spv_func = SPVFuncImplRowMajor4x2; - else if (cols == 4 && rows == 3) - spv_func = SPVFuncImplRowMajor4x3; - else - SPIRV_CROSS_THROW("Could not convert row-major matrix."); - - auto rslt = spv_function_implementations.insert(spv_func); - if (rslt.second) - { - add_pragma_line("#pragma clang diagnostic ignored \"-Wmissing-prototypes\""); - force_recompile = true; - } -} - -// Wraps the expression string in a function call that converts the -// row_major matrix result of the expression to a column_major matrix. -string CompilerMSL::convert_row_major_matrix(string exp_str, const SPIRType &exp_type) -{ - strip_enclosed_expression(exp_str); - - string func_name; - if (exp_type.columns == exp_type.vecsize) - func_name = "transpose"; - else - func_name = string("spvConvertFromRowMajor") + to_string(exp_type.columns) + "x" + to_string(exp_type.vecsize); - - return join(func_name, "(", exp_str, ")"); -} - -// Called automatically at the end of the entry point function -void CompilerMSL::emit_fixup() -{ - auto &execution = get_entry_point(); - - if ((execution.model == ExecutionModelVertex) && stage_out_var_id && !qual_pos_var_name.empty()) - { - if (CompilerGLSL::options.vertex.fixup_clipspace) - statement(qual_pos_var_name, ".z = (", qual_pos_var_name, ".z + ", qual_pos_var_name, - ".w) * 0.5; // Adjust clip-space for Metal"); - - if (CompilerGLSL::options.vertex.flip_vert_y) - statement(qual_pos_var_name, ".y = -(", qual_pos_var_name, ".y);", " // Invert Y-axis for Metal"); - } -} - -// Emit a structure member, padding and packing to maintain the correct memeber alignments. -void CompilerMSL::emit_struct_member(const SPIRType &type, uint32_t member_type_id, uint32_t index, - const string &qualifier) -{ - auto &membertype = get(member_type_id); - - // If this member requires padding to maintain alignment, emit a dummy padding member. - MSLStructMemberKey key = get_struct_member_key(type.self, index); - uint32_t pad_len = struct_member_padding[key]; - if (pad_len > 0) - statement("char pad", to_string(index), "[", to_string(pad_len), "];"); - - // If this member is packed, mark it as so. - string pack_pfx = member_is_packed_type(type, index) ? "packed_" : ""; - - statement(pack_pfx, type_to_glsl(membertype), " ", qualifier, to_member_name(type, index), - member_attribute_qualifier(type, index), type_to_array_glsl(membertype), ";"); -} - -// Return a MSL qualifier for the specified function attribute member -string CompilerMSL::member_attribute_qualifier(const SPIRType &type, uint32_t index) -{ - auto &execution = get_entry_point(); - - uint32_t mbr_type_id = type.member_types[index]; - auto &mbr_type = get(mbr_type_id); - - BuiltIn builtin; - bool is_builtin = is_member_builtin(type, index, &builtin); - - // Vertex function inputs - if (execution.model == ExecutionModelVertex && type.storage == StorageClassInput) - { - if (is_builtin) - { - switch (builtin) - { - case BuiltInVertexId: - case BuiltInVertexIndex: - case BuiltInInstanceId: - case BuiltInInstanceIndex: - return string(" [[") + builtin_qualifier(builtin) + "]]"; - - default: - return ""; - } - } - uint32_t locn = get_ordered_member_location(type.self, index); - if (locn != k_unknown_location) - return string(" [[attribute(") + convert_to_string(locn) + ")]]"; - } - - // Vertex function outputs - if (execution.model == ExecutionModelVertex && type.storage == StorageClassOutput) - { - if (is_builtin) - { - switch (builtin) - { - case BuiltInPointSize: - // Only mark the PointSize builtin if really rendering points. - // Some shaders may include a PointSize builtin even when used to render - // non-point topologies, and Metal will reject this builtin when compiling - // the shader into a render pipeline that uses a non-point topology. - return options.enable_point_size_builtin ? (string(" [[") + builtin_qualifier(builtin) + "]]") : ""; - - case BuiltInPosition: - case BuiltInLayer: - case BuiltInClipDistance: - return string(" [[") + builtin_qualifier(builtin) + "]]" + (mbr_type.array.empty() ? "" : " "); - - default: - return ""; - } - } - uint32_t locn = get_ordered_member_location(type.self, index); - if (locn != k_unknown_location) - return string(" [[user(locn") + convert_to_string(locn) + ")]]"; - } - - // Fragment function inputs - if (execution.model == ExecutionModelFragment && type.storage == StorageClassInput) - { - if (is_builtin) - { - switch (builtin) - { - case BuiltInFrontFacing: - case BuiltInPointCoord: - case BuiltInFragCoord: - case BuiltInSampleId: - case BuiltInSampleMask: - case BuiltInLayer: - return string(" [[") + builtin_qualifier(builtin) + "]]"; - - default: - return ""; - } - } - uint32_t locn = get_ordered_member_location(type.self, index); - if (locn != k_unknown_location) - return string(" [[user(locn") + convert_to_string(locn) + ")]]"; - } - - // Fragment function outputs - if (execution.model == ExecutionModelFragment && type.storage == StorageClassOutput) - { - if (is_builtin) - { - switch (builtin) - { - case BuiltInSampleMask: - case BuiltInFragDepth: - return string(" [[") + builtin_qualifier(builtin) + "]]"; - - default: - return ""; - } - } - uint32_t locn = get_ordered_member_location(type.self, index); - if (locn != k_unknown_location) - return string(" [[color(") + convert_to_string(locn) + ")]]"; - } - - // Compute function inputs - if (execution.model == ExecutionModelGLCompute && type.storage == StorageClassInput) - { - if (is_builtin) - { - switch (builtin) - { - case BuiltInGlobalInvocationId: - case BuiltInWorkgroupId: - case BuiltInNumWorkgroups: - case BuiltInLocalInvocationId: - case BuiltInLocalInvocationIndex: - return string(" [[") + builtin_qualifier(builtin) + "]]"; - - default: - return ""; - } - } - } - - return ""; -} - -// Returns the location decoration of the member with the specified index in the specified type. -// If the location of the member has been explicitly set, that location is used. If not, this -// function assumes the members are ordered in their location order, and simply returns the -// index as the location. -uint32_t CompilerMSL::get_ordered_member_location(uint32_t type_id, uint32_t index) -{ - auto &m = meta.at(type_id); - if (index < m.members.size()) - { - auto &dec = m.members[index]; - if (dec.decoration_flags & (1ull << DecorationLocation)) - return dec.location; - } - - return index; -} - -string CompilerMSL::constant_expression(const SPIRConstant &c) -{ - if (!c.subconstants.empty()) - { - // Handles Arrays and structures. - string res = "{"; - for (auto &elem : c.subconstants) - { - res += constant_expression(get(elem)); - if (&elem != &c.subconstants.back()) - res += ", "; - } - res += "}"; - return res; - } - else if (c.columns() == 1) - { - return constant_expression_vector(c, 0); - } - else - { - string res = type_to_glsl(get(c.constant_type)) + "("; - for (uint32_t col = 0; col < c.columns(); col++) - { - res += constant_expression_vector(c, col); - if (col + 1 < c.columns()) - res += ", "; - } - res += ")"; - return res; - } -} - -// Returns the type declaration for a function, including the -// entry type if the current function is the entry point function -string CompilerMSL::func_type_decl(SPIRType &type) -{ - auto &execution = get_entry_point(); - // The regular function return type. If not processing the entry point function, that's all we need - string return_type = type_to_glsl(type); - if (!processing_entry_point) - return return_type; - - // If an outgoing interface block has been defined, override the entry point return type - if (stage_out_var_id) - { - auto &so_var = get(stage_out_var_id); - auto &so_type = get(so_var.basetype); - return_type = type_to_glsl(so_type); - } - - // Prepend a entry type, based on the execution model - string entry_type; - switch (execution.model) - { - case ExecutionModelVertex: - entry_type = "vertex"; - break; - case ExecutionModelFragment: - entry_type = (execution.flags & (1ull << ExecutionModeEarlyFragmentTests)) ? - "fragment [[ early_fragment_tests ]]" : - "fragment"; - break; - case ExecutionModelGLCompute: - case ExecutionModelKernel: - entry_type = "kernel"; - break; - default: - entry_type = "unknown"; - break; - } - - return entry_type + " " + return_type; -} - -// In MSL, address space qualifiers are required for all pointer or reference arguments -string CompilerMSL::get_argument_address_space(const SPIRVariable &argument) -{ - const auto &type = get(argument.basetype); - - switch (type.storage) - { - case StorageClassWorkgroup: - return "threadgroup"; - - case StorageClassStorageBuffer: - return "device"; - - case StorageClassUniform: - case StorageClassUniformConstant: - case StorageClassPushConstant: - if (type.basetype == SPIRType::Struct) - return ((meta[type.self].decoration.decoration_flags & (1ull << DecorationBufferBlock)) != 0 && - (meta[argument.self].decoration.decoration_flags & (1ull << DecorationNonWritable)) == 0) ? - "device" : - "constant"; - - break; - - default: - break; - } - - return "thread"; -} - -// Returns a string containing a comma-delimited list of args for the entry point function -string CompilerMSL::entry_point_args(bool append_comma) -{ - string ep_args; - - // Stage-in structure - if (stage_in_var_id) - { - auto &var = get(stage_in_var_id); - auto &type = get(var.basetype); - - if (!ep_args.empty()) - ep_args += ", "; - - ep_args += type_to_glsl(type) + " " + to_name(var.self) + " [[stage_in]]"; - } - - // Non-stage-in vertex attribute structures - for (auto &nsi_var : non_stage_in_input_var_ids) - { - auto &var = get(nsi_var.second); - auto &type = get(var.basetype); - - if (!ep_args.empty()) - ep_args += ", "; - - ep_args += "device " + type_to_glsl(type) + "* " + to_name(var.self) + " [[buffer(" + - convert_to_string(nsi_var.first) + ")]]"; - } - - // Uniforms - for (auto &id : ids) - { - if (id.get_type() == TypeVariable) - { - auto &var = id.get(); - auto &type = get(var.basetype); - - uint32_t var_id = var.self; - - if ((var.storage == StorageClassUniform || var.storage == StorageClassUniformConstant || - var.storage == StorageClassPushConstant || var.storage == StorageClassStorageBuffer) && - !is_hidden_variable(var)) - { - switch (type.basetype) - { - case SPIRType::Struct: - { - auto &m = meta.at(type.self); - if (m.members.size() == 0) - break; - if (!ep_args.empty()) - ep_args += ", "; - ep_args += get_argument_address_space(var) + " " + type_to_glsl(type) + "& " + to_name(var_id); - ep_args += " [[buffer(" + convert_to_string(get_metal_resource_index(var, type.basetype)) + ")]]"; - break; - } - case SPIRType::Sampler: - if (!ep_args.empty()) - ep_args += ", "; - ep_args += type_to_glsl(type) + " " + to_name(var_id); - ep_args += " [[sampler(" + convert_to_string(get_metal_resource_index(var, type.basetype)) + ")]]"; - break; - case SPIRType::Image: - if (!ep_args.empty()) - ep_args += ", "; - ep_args += type_to_glsl(type, var_id) + " " + to_name(var_id); - ep_args += " [[texture(" + convert_to_string(get_metal_resource_index(var, type.basetype)) + ")]]"; - break; - case SPIRType::SampledImage: - if (!ep_args.empty()) - ep_args += ", "; - ep_args += type_to_glsl(type, var_id) + " " + to_name(var_id); - ep_args += - " [[texture(" + convert_to_string(get_metal_resource_index(var, SPIRType::Image)) + ")]]"; - if (type.image.dim != DimBuffer) - { - ep_args += ", sampler " + to_sampler_expression(var_id); - ep_args += - " [[sampler(" + convert_to_string(get_metal_resource_index(var, SPIRType::Sampler)) + ")]]"; - } - break; - default: - break; - } - } - if (var.storage == StorageClassInput && is_builtin_variable(var)) - { - if (!ep_args.empty()) - ep_args += ", "; - - BuiltIn bi_type = meta[var_id].decoration.builtin_type; - ep_args += builtin_type_decl(bi_type) + " " + to_expression(var_id); - ep_args += " [[" + builtin_qualifier(bi_type) + "]]"; - } - } - } - - // Vertex and instance index built-ins - if (needs_vertex_idx_arg) - ep_args += built_in_func_arg(BuiltInVertexIndex, !ep_args.empty()); - - if (needs_instance_idx_arg) - ep_args += built_in_func_arg(BuiltInInstanceIndex, !ep_args.empty()); - - if (!ep_args.empty() && append_comma) - ep_args += ", "; - - return ep_args; -} - -// Returns the Metal index of the resource of the specified type as used by the specified variable. -uint32_t CompilerMSL::get_metal_resource_index(SPIRVariable &var, SPIRType::BaseType basetype) -{ - auto &execution = get_entry_point(); - auto &var_dec = meta[var.self].decoration; - uint32_t var_desc_set = (var.storage == StorageClassPushConstant) ? kPushConstDescSet : var_dec.set; - uint32_t var_binding = (var.storage == StorageClassPushConstant) ? kPushConstBinding : var_dec.binding; - - // If a matching binding has been specified, find and use it - for (auto p_res_bind : resource_bindings) - { - if (p_res_bind->stage == execution.model && p_res_bind->desc_set == var_desc_set && - p_res_bind->binding == var_binding) - { - - p_res_bind->used_by_shader = true; - switch (basetype) - { - case SPIRType::Struct: - return p_res_bind->msl_buffer; - case SPIRType::Image: - return p_res_bind->msl_texture; - case SPIRType::Sampler: - return p_res_bind->msl_sampler; - default: - return 0; - } - } - } - - // If a binding has not been specified, revert to incrementing resource indices - switch (basetype) - { - case SPIRType::Struct: - return next_metal_resource_index.msl_buffer++; - case SPIRType::Image: - return next_metal_resource_index.msl_texture++; - case SPIRType::Sampler: - return next_metal_resource_index.msl_sampler++; - default: - return 0; - } -} - -// Returns the name of the entry point of this shader -string CompilerMSL::get_entry_point_name() -{ - return to_name(entry_point); -} - -string CompilerMSL::argument_decl(const SPIRFunction::Parameter &arg) -{ - auto &var = get(arg.id); - auto &type = expression_type(arg.id); - bool constref = !arg.alias_global_variable && (!type.pointer || arg.write_count == 0); - - // TODO: Check if this arg is an uniform pointer - bool pointer = type.storage == StorageClassUniformConstant; - - string decl; - if (constref) - decl += "const "; - - if (is_builtin_variable(var)) - decl += builtin_type_decl((BuiltIn)get_decoration(arg.id, DecorationBuiltIn)); - else - decl += type_to_glsl(type, arg.id); - - if (is_array(type)) - decl += "*"; - else if (!pointer) - decl += "&"; - - decl += " "; - decl += to_name(var.self); - - return decl; -} - -// If we're currently in the entry point function, and the object -// has a qualified name, use it, otherwise use the standard name. -string CompilerMSL::to_name(uint32_t id, bool allow_alias) const -{ - if (current_function && (current_function->self == entry_point)) - { - string qual_name = meta.at(id).decoration.qualified_alias; - if (!qual_name.empty()) - return qual_name; - } - return Compiler::to_name(id, allow_alias); -} - -// Returns a name that combines the name of the struct with the name of the member, except for Builtins -string CompilerMSL::to_qualified_member_name(const SPIRType &type, uint32_t index) -{ - // Don't qualify Builtin names because they are unique and are treated as such when building expressions - BuiltIn builtin; - if (is_member_builtin(type, index, &builtin)) - return builtin_to_glsl(builtin, type.storage); - - // Strip any underscore prefix from member name - string mbr_name = to_member_name(type, index); - size_t startPos = mbr_name.find_first_not_of("_"); - mbr_name = (startPos != string::npos) ? mbr_name.substr(startPos) : ""; - return join(to_name(type.self), "_", mbr_name); -} - -// Ensures that the specified name is permanently usable by prepending a prefix -// if the first chars are _ and a digit, which indicate a transient name. -string CompilerMSL::ensure_valid_name(string name, string pfx) -{ - return (name.size() >= 2 && name[0] == '_' && isdigit(name[1])) ? (pfx + name) : name; -} - -// Replace all names that match MSL keywords or Metal Standard Library functions. -void CompilerMSL::replace_illegal_names() -{ - static const unordered_set keywords = { - "kernel", - "bias", - }; - - static const unordered_set illegal_func_names = { - "main", - "saturate", - }; - - for (auto &id : ids) - { - switch (id.get_type()) - { - case TypeVariable: - { - auto &dec = meta[id.get_id()].decoration; - if (keywords.find(dec.alias) != end(keywords)) - dec.alias += "0"; - - break; - } - - case TypeFunction: - { - auto &dec = meta[id.get_id()].decoration; - if (illegal_func_names.find(dec.alias) != end(illegal_func_names)) - dec.alias += "0"; - - break; - } - - case TypeType: - { - for (auto &mbr_dec : meta[id.get_id()].members) - if (keywords.find(mbr_dec.alias) != end(keywords)) - mbr_dec.alias += "0"; - - break; - } - - default: - break; - } - } - - for (auto &entry : entry_points) - { - // Change both the entry point name and the alias, to keep them synced. - string &ep_name = entry.second.name; - if (illegal_func_names.find(ep_name) != end(illegal_func_names)) - ep_name += "0"; - - // Always write this because entry point might have been renamed earlier. - meta[entry.first].decoration.alias = ep_name; - } -} - -string CompilerMSL::to_qualifiers_glsl(uint32_t id) -{ - string quals; - - auto &type = expression_type(id); - if (type.storage == StorageClassWorkgroup) - quals += "threadgroup "; - - return quals; -} - -// The optional id parameter indicates the object whose type we are trying -// to find the description for. It is optional. Most type descriptions do not -// depend on a specific object's use of that type. -string CompilerMSL::type_to_glsl(const SPIRType &type, uint32_t id) -{ - // Ignore the pointer type since GLSL doesn't have pointers. - - string type_name; - - switch (type.basetype) - { - case SPIRType::Struct: - // Need OpName lookup here to get a "sensible" name for a struct. - return to_name(type.self); - - case SPIRType::Image: - case SPIRType::SampledImage: - return image_type_glsl(type, id); - - case SPIRType::Sampler: - return "sampler"; - - case SPIRType::Void: - return "void"; - - case SPIRType::AtomicCounter: - return "atomic_uint"; - - // Scalars - case SPIRType::Boolean: - type_name = "bool"; - break; - case SPIRType::Char: - type_name = "char"; - break; - case SPIRType::Int: - type_name = (type.width == 16 ? "short" : "int"); - break; - case SPIRType::UInt: - type_name = (type.width == 16 ? "ushort" : "uint"); - break; - case SPIRType::Int64: - type_name = "long"; // Currently unsupported - break; - case SPIRType::UInt64: - type_name = "size_t"; - break; - case SPIRType::Float: - type_name = (type.width == 16 ? "half" : "float"); - break; - case SPIRType::Double: - type_name = "double"; // Currently unsupported - break; - - default: - return "unknown_type"; - } - - // Matrix? - if (type.columns > 1) - type_name += to_string(type.columns) + "x"; - - // Vector or Matrix? - if (type.vecsize > 1) - type_name += to_string(type.vecsize); - - return type_name; -} - -// Returns an MSL string describing the SPIR-V image type -string CompilerMSL::image_type_glsl(const SPIRType &type, uint32_t id) -{ - string img_type_name; - - // Bypass pointers because we need the real image struct - auto &img_type = get(type.self).image; - - if (img_type.depth) - { - switch (img_type.dim) - { - case Dim1D: - img_type_name += "depth1d_unsupported_by_metal"; - break; - case Dim2D: - img_type_name += (img_type.ms ? "depth2d_ms" : (img_type.arrayed ? "depth2d_array" : "depth2d")); - break; - case Dim3D: - img_type_name += "depth3d_unsupported_by_metal"; - break; - case DimCube: - img_type_name += (img_type.arrayed ? "depthcube_array" : "depthcube"); - break; - default: - img_type_name += "unknown_depth_texture_type"; - break; - } - } - else - { - switch (img_type.dim) - { - case Dim1D: - img_type_name += (img_type.arrayed ? "texture1d_array" : "texture1d"); - break; - case DimBuffer: - case Dim2D: - img_type_name += (img_type.ms ? "texture2d_ms" : (img_type.arrayed ? "texture2d_array" : "texture2d")); - break; - case Dim3D: - img_type_name += "texture3d"; - break; - case DimCube: - img_type_name += (img_type.arrayed ? "texturecube_array" : "texturecube"); - break; - default: - img_type_name += "unknown_texture_type"; - break; - } - } - - // Append the pixel type - img_type_name += "<"; - img_type_name += type_to_glsl(get(img_type.type)); - - // For unsampled images, append the sample/read/write access qualifier. - // For kernel images, the access qualifier my be supplied directly by SPIR-V. - // Otherwise it may be set based on whether the image is read from or written to within the shader. - if (type.basetype == SPIRType::Image && type.image.sampled == 2) - { - switch (img_type.access) - { - case AccessQualifierReadOnly: - img_type_name += ", access::read"; - break; - - case AccessQualifierWriteOnly: - img_type_name += ", access::write"; - break; - - case AccessQualifierReadWrite: - img_type_name += ", access::read_write"; - break; - - default: - { - auto *p_var = maybe_get_backing_variable(id); - if (p_var && p_var->basevariable) - p_var = maybe_get(p_var->basevariable); - if (p_var && !has_decoration(p_var->self, DecorationNonWritable)) - { - img_type_name += ", access::"; - - if (!has_decoration(p_var->self, DecorationNonReadable)) - img_type_name += "read_"; - - img_type_name += "write"; - } - break; - } - } - } - - img_type_name += ">"; - - return img_type_name; -} - -string CompilerMSL::bitcast_glsl_op(const SPIRType &out_type, const SPIRType &in_type) -{ - if ((out_type.basetype == SPIRType::UInt && in_type.basetype == SPIRType::Int) || - (out_type.basetype == SPIRType::Int && in_type.basetype == SPIRType::UInt) || - (out_type.basetype == SPIRType::UInt64 && in_type.basetype == SPIRType::Int64) || - (out_type.basetype == SPIRType::Int64 && in_type.basetype == SPIRType::UInt64)) - return type_to_glsl(out_type); - - if ((out_type.basetype == SPIRType::UInt && in_type.basetype == SPIRType::Float) || - (out_type.basetype == SPIRType::Int && in_type.basetype == SPIRType::Float) || - (out_type.basetype == SPIRType::Float && in_type.basetype == SPIRType::UInt) || - (out_type.basetype == SPIRType::Float && in_type.basetype == SPIRType::Int) || - (out_type.basetype == SPIRType::Int64 && in_type.basetype == SPIRType::Double) || - (out_type.basetype == SPIRType::UInt64 && in_type.basetype == SPIRType::Double) || - (out_type.basetype == SPIRType::Double && in_type.basetype == SPIRType::Int64) || - (out_type.basetype == SPIRType::Double && in_type.basetype == SPIRType::UInt64)) - return "as_type<" + type_to_glsl(out_type) + ">"; - - return ""; -} - -// Returns an MSL string identifying the name of a SPIR-V builtin. -// Output builtins are qualified with the name of the stage out structure. -string CompilerMSL::builtin_to_glsl(BuiltIn builtin, StorageClass storage) -{ - switch (builtin) - { - - // Override GLSL compiler strictness - case BuiltInVertexId: - return "gl_VertexID"; - case BuiltInInstanceId: - return "gl_InstanceID"; - case BuiltInVertexIndex: - return "gl_VertexIndex"; - case BuiltInInstanceIndex: - return "gl_InstanceIndex"; - - // When used in the entry function, output builtins are qualified with output struct name. - case BuiltInPosition: - case BuiltInPointSize: - case BuiltInClipDistance: - case BuiltInCullDistance: - case BuiltInLayer: - case BuiltInFragDepth: - if (current_function && (current_function->self == entry_point)) - return stage_out_var_name + "." + CompilerGLSL::builtin_to_glsl(builtin, storage); - else - return CompilerGLSL::builtin_to_glsl(builtin, storage); - - default: - return CompilerGLSL::builtin_to_glsl(builtin, storage); - } -} - -// Returns an MSL string attribute qualifer for a SPIR-V builtin -string CompilerMSL::builtin_qualifier(BuiltIn builtin) -{ - auto &execution = get_entry_point(); - - switch (builtin) - { - // Vertex function in - case BuiltInVertexId: - return "vertex_id"; - case BuiltInVertexIndex: - return "vertex_id"; - case BuiltInInstanceId: - return "instance_id"; - case BuiltInInstanceIndex: - return "instance_id"; - - // Vertex function out - case BuiltInClipDistance: - return "clip_distance"; - case BuiltInPointSize: - return "point_size"; - case BuiltInPosition: - return "position"; - case BuiltInLayer: - return "render_target_array_index"; - - // Fragment function in - case BuiltInFrontFacing: - return "front_facing"; - case BuiltInPointCoord: - return "point_coord"; - case BuiltInFragCoord: - return "position"; - case BuiltInSampleId: - return "sample_id"; - case BuiltInSampleMask: - return "sample_mask"; - - // Fragment function out - case BuiltInFragDepth: - if (execution.flags & (1ull << ExecutionModeDepthGreater)) - return "depth(greater)"; - else if (execution.flags & (1ull << ExecutionModeDepthLess)) - return "depth(less)"; - else - return "depth(any)"; - - // Compute function in - case BuiltInGlobalInvocationId: - return "thread_position_in_grid"; - - case BuiltInWorkgroupId: - return "threadgroup_position_in_grid"; - - case BuiltInNumWorkgroups: - return "threadgroups_per_grid"; - - case BuiltInLocalInvocationId: - return "thread_position_in_threadgroup"; - - case BuiltInLocalInvocationIndex: - return "thread_index_in_threadgroup"; - - default: - return "unsupported-built-in"; - } -} - -// Returns an MSL string type declaration for a SPIR-V builtin -string CompilerMSL::builtin_type_decl(BuiltIn builtin) -{ - switch (builtin) - { - // Vertex function in - case BuiltInVertexId: - return "uint"; - case BuiltInVertexIndex: - return "uint"; - case BuiltInInstanceId: - return "uint"; - case BuiltInInstanceIndex: - return "uint"; - - // Vertex function out - case BuiltInClipDistance: - return "float"; - case BuiltInPointSize: - return "float"; - case BuiltInPosition: - return "float4"; - case BuiltInLayer: - return "uint"; - - // Fragment function in - case BuiltInFrontFacing: - return "bool"; - case BuiltInPointCoord: - return "float2"; - case BuiltInFragCoord: - return "float4"; - case BuiltInSampleId: - return "uint"; - case BuiltInSampleMask: - return "uint"; - - // Compute function in - case BuiltInGlobalInvocationId: - case BuiltInLocalInvocationId: - case BuiltInNumWorkgroups: - case BuiltInWorkgroupId: - return "uint3"; - case BuiltInLocalInvocationIndex: - return "uint"; - - default: - return "unsupported-built-in-type"; - } -} - -// Returns the declaration of a built-in argument to a function -string CompilerMSL::built_in_func_arg(BuiltIn builtin, bool prefix_comma) -{ - string bi_arg; - if (prefix_comma) - bi_arg += ", "; - - bi_arg += builtin_type_decl(builtin); - bi_arg += " " + builtin_to_glsl(builtin, StorageClassInput); - bi_arg += " [[" + builtin_qualifier(builtin) + "]]"; - - return bi_arg; -} - -// Returns the byte size of a struct member. -size_t CompilerMSL::get_declared_struct_member_size(const SPIRType &struct_type, uint32_t index) const -{ - auto dec_mask = get_member_decoration_mask(struct_type.self, index); - auto &type = get(struct_type.member_types[index]); - - switch (type.basetype) - { - case SPIRType::Unknown: - case SPIRType::Void: - case SPIRType::AtomicCounter: - case SPIRType::Image: - case SPIRType::SampledImage: - case SPIRType::Sampler: - SPIRV_CROSS_THROW("Querying size of opaque object."); - - default: - { - size_t component_size = type.width / 8; - unsigned vecsize = type.vecsize; - unsigned columns = type.columns; - - // For arrays, we can use ArrayStride to get an easy check. - // Runtime arrays will have zero size so force to min of one. - if (!type.array.empty()) - return type_struct_member_array_stride(struct_type, index) * max(type.array.back(), 1U); - - if (type.basetype == SPIRType::Struct) - return get_declared_struct_size(type); - - if (columns == 1) // An unpacked 3-element vector is the same size as a 4-element vector. - { - if (!(dec_mask & (1ull << DecorationCPacked))) - { - if (vecsize == 3) - vecsize = 4; - } - } - else // For matrices, a 3-element column is the same size as a 4-element column. - { - if (dec_mask & (1ull << DecorationColMajor)) - { - if (vecsize == 3) - vecsize = 4; - } - else if (dec_mask & (1ull << DecorationRowMajor)) - { - if (columns == 3) - columns = 4; - } - } - - return vecsize * columns * component_size; - } - } -} - -// Returns the byte alignment of a struct member. -size_t CompilerMSL::get_declared_struct_member_alignment(const SPIRType &struct_type, uint32_t index) const -{ - auto &type = get(struct_type.member_types[index]); - - switch (type.basetype) - { - case SPIRType::Unknown: - case SPIRType::Void: - case SPIRType::AtomicCounter: - case SPIRType::Image: - case SPIRType::SampledImage: - case SPIRType::Sampler: - SPIRV_CROSS_THROW("Querying alignment of opaque object."); - - case SPIRType::Struct: - return 16; // Per Vulkan spec section 14.5.4 - - default: - { - // Alignment of packed type is the same as the underlying component size. - // Alignment of unpacked type is the same as the type size (or one matrix column). - if (member_is_packed_type(struct_type, index)) - return type.width / 8; - else - { - // Divide by array size and colum count. Runtime arrays will have zero size so force to min of one. - uint32_t array_size = type.array.empty() ? 1 : max(type.array.back(), 1U); - return get_declared_struct_member_size(struct_type, index) / (type.columns * array_size); - } - } - } -} - -bool CompilerMSL::skip_argument(uint32_t) const -{ - return false; -} - -bool CompilerMSL::OpCodePreprocessor::handle(Op opcode, const uint32_t *args, uint32_t length) -{ - // Since MSL exists in a single execution scope, function prototype declarations are not - // needed, and clutter the output. If secondary functions are output (either as a SPIR-V - // function implementation or as indicated by the presence of OpFunctionCall), then set - // suppress_missing_prototypes to suppress compiler warnings of missing function prototypes. - - // Mark if the input requires the implementation of an SPIR-V function that does not exist in Metal. - SPVFuncImpl spv_func = get_spv_func_impl(opcode, args); - if (spv_func != SPVFuncImplNone) - { - compiler.spv_function_implementations.insert(spv_func); - suppress_missing_prototypes = true; - } - - switch (opcode) - { - - case OpFunctionCall: - suppress_missing_prototypes = true; - break; - - case OpAtomicExchange: - case OpAtomicCompareExchange: - case OpAtomicCompareExchangeWeak: - case OpAtomicLoad: - case OpAtomicIIncrement: - case OpAtomicIDecrement: - case OpAtomicIAdd: - case OpAtomicISub: - case OpAtomicSMin: - case OpAtomicUMin: - case OpAtomicSMax: - case OpAtomicUMax: - case OpAtomicAnd: - case OpAtomicOr: - case OpAtomicXor: - uses_atomics = true; - break; - - default: - break; - } - - // If it has one, keep track of the instruction's result type, mapped by ID - uint32_t result_type, result_id; - if (compiler.instruction_to_result_type(result_type, result_id, opcode, args, length)) - result_types[result_id] = result_type; - - return true; -} - -// Returns an enumeration of a SPIR-V function that needs to be output for certain Op codes. -CompilerMSL::SPVFuncImpl CompilerMSL::OpCodePreprocessor::get_spv_func_impl(Op opcode, const uint32_t *args) -{ - switch (opcode) - { - case OpFMod: - return SPVFuncImplMod; - - case OpStore: - { - // Get the result type of the RHS. Since this is run as a pre-processing stage, - // we must extract the result type directly from the Instruction, rather than the ID. - uint32_t id_rhs = args[1]; - uint32_t type_id_rhs = result_types[id_rhs]; - if ((compiler.ids[id_rhs].get_type() != TypeConstant) && type_id_rhs && - compiler.is_array(compiler.get(type_id_rhs))) - return SPVFuncImplArrayCopy; - - break; - } - - case OpExtInst: - { - uint32_t extension_set = args[2]; - if (compiler.get(extension_set).ext == SPIRExtension::GLSL) - { - GLSLstd450 op_450 = static_cast(args[3]); - switch (op_450) - { - case GLSLstd450Radians: - return SPVFuncImplRadians; - case GLSLstd450Degrees: - return SPVFuncImplDegrees; - case GLSLstd450FindILsb: - return SPVFuncImplFindILsb; - case GLSLstd450FindSMsb: - return SPVFuncImplFindSMsb; - case GLSLstd450FindUMsb: - return SPVFuncImplFindUMsb; - case GLSLstd450MatrixInverse: - { - auto &mat_type = compiler.get(args[0]); - switch (mat_type.columns) - { - case 2: - return SPVFuncImplInverse2x2; - case 3: - return SPVFuncImplInverse3x3; - case 4: - return SPVFuncImplInverse4x4; - default: - break; - } - break; - } - default: - break; - } - } - break; - } - - default: - break; - } - return SPVFuncImplNone; -} - -// Sort both type and meta member content based on builtin status (put builtins at end), -// then by the required sorting aspect. -void CompilerMSL::MemberSorter::sort() -{ - // Create a temporary array of consecutive member indices and sort it based on how - // the members should be reordered, based on builtin and sorting aspect meta info. - size_t mbr_cnt = type.member_types.size(); - vector mbr_idxs(mbr_cnt); - iota(mbr_idxs.begin(), mbr_idxs.end(), 0); // Fill with consecutive indices - std::sort(mbr_idxs.begin(), mbr_idxs.end(), *this); // Sort member indices based on sorting aspect - - // Move type and meta member info to the order defined by the sorted member indices. - // This is done by creating temporary copies of both member types and meta, and then - // copying back to the original content at the sorted indices. - auto mbr_types_cpy = type.member_types; - auto mbr_meta_cpy = meta.members; - for (uint32_t mbr_idx = 0; mbr_idx < mbr_cnt; mbr_idx++) - { - type.member_types[mbr_idx] = mbr_types_cpy[mbr_idxs[mbr_idx]]; - meta.members[mbr_idx] = mbr_meta_cpy[mbr_idxs[mbr_idx]]; - } -} - -// Sort first by builtin status (put builtins at end), then by the sorting aspect. -bool CompilerMSL::MemberSorter::operator()(uint32_t mbr_idx1, uint32_t mbr_idx2) -{ - auto &mbr_meta1 = meta.members[mbr_idx1]; - auto &mbr_meta2 = meta.members[mbr_idx2]; - if (mbr_meta1.builtin != mbr_meta2.builtin) - return mbr_meta2.builtin; - else - switch (sort_aspect) - { - case Location: - return mbr_meta1.location < mbr_meta2.location; - case LocationReverse: - return mbr_meta1.location > mbr_meta2.location; - case Offset: - return mbr_meta1.offset < mbr_meta2.offset; - case OffsetThenLocationReverse: - return (mbr_meta1.offset < mbr_meta2.offset) || - ((mbr_meta1.offset == mbr_meta2.offset) && (mbr_meta1.location > mbr_meta2.location)); - case Alphabetical: - return mbr_meta1.alias < mbr_meta2.alias; - default: - return false; - } -} - -CompilerMSL::MemberSorter::MemberSorter(SPIRType &t, Meta &m, SortAspect sa) - : type(t) - , meta(m) - , sort_aspect(sa) -{ - // Ensure enough meta info is available - meta.members.resize(max(type.member_types.size(), meta.members.size())); -} diff --git a/deps/SPIRV-Cross/spirv_msl.hpp b/deps/SPIRV-Cross/spirv_msl.hpp deleted file mode 100644 index fbc8dadf40..0000000000 --- a/deps/SPIRV-Cross/spirv_msl.hpp +++ /dev/null @@ -1,331 +0,0 @@ -/* - * Copyright 2016-2017 The Brenwill Workshop Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef SPIRV_CROSS_MSL_HPP -#define SPIRV_CROSS_MSL_HPP - -#include "spirv_glsl.hpp" -#include -#include -#include -#include -#include -#include - -namespace spirv_cross -{ - -// Defines MSL characteristics of a vertex attribute at a particular location. -// The used_by_shader flag is set to true during compilation of SPIR-V to MSL -// if the shader makes use of this vertex attribute. -struct MSLVertexAttr -{ - uint32_t location = 0; - uint32_t msl_buffer = 0; - uint32_t msl_offset = 0; - uint32_t msl_stride = 0; - bool per_instance = false; - bool used_by_shader = false; -}; - -// Matches the binding index of a MSL resource for a binding within a descriptor set. -// Taken together, the stage, desc_set and binding combine to form a reference to a resource -// descriptor used in a particular shading stage. Generally, only one of the buffer, texture, -// or sampler elements will be populated. The used_by_shader flag is set to true during -// compilation of SPIR-V to MSL if the shader makes use of this vertex attribute. -struct MSLResourceBinding -{ - spv::ExecutionModel stage; - uint32_t desc_set = 0; - uint32_t binding = 0; - - uint32_t msl_buffer = 0; - uint32_t msl_texture = 0; - uint32_t msl_sampler = 0; - - bool used_by_shader = false; -}; - -// Tracks the type ID and member index of a struct member -using MSLStructMemberKey = uint64_t; - -// Special constant used in a MSLResourceBinding desc_set -// element to indicate the bindings for the push constants. -static const uint32_t kPushConstDescSet = std::numeric_limits::max(); - -// Special constant used in a MSLResourceBinding binding -// element to indicate the bindings for the push constants. -static const uint32_t kPushConstBinding = 0; - -// Decompiles SPIR-V to Metal Shading Language -class CompilerMSL : public CompilerGLSL -{ -public: - // Options for compiling to Metal Shading Language - struct Options - { - typedef enum { - iOS, - macOS, - } Platform; - - Platform platform = macOS; - uint32_t msl_version = make_msl_version(1, 2); - bool enable_point_size_builtin = true; - bool resolve_specialized_array_lengths = true; - - bool is_ios() - { - return platform == iOS; - } - - bool is_macos() - { - return platform == macOS; - } - - void set_msl_version(uint32_t major, uint32_t minor = 0, uint32_t patch = 0) - { - msl_version = make_msl_version(major, minor, patch); - } - - bool supports_msl_version(uint32_t major, uint32_t minor = 0, uint32_t patch = 0) - { - return msl_version >= make_msl_version(major, minor, patch); - } - - static uint32_t make_msl_version(uint32_t major, uint32_t minor = 0, uint32_t patch = 0) - { - return (major * 10000) + (minor * 100) + patch; - } - }; - - const Options &get_options() const - { - return options; - } - - void set_options(Options &opts) - { - options = opts; - } - - // An enum of SPIR-V functions that are implemented in additional - // source code that is added to the shader if necessary. - enum SPVFuncImpl - { - SPVFuncImplNone, - SPVFuncImplMod, - SPVFuncImplRadians, - SPVFuncImplDegrees, - SPVFuncImplFindILsb, - SPVFuncImplFindSMsb, - SPVFuncImplFindUMsb, - SPVFuncImplArrayCopy, - SPVFuncImplInverse2x2, - SPVFuncImplInverse3x3, - SPVFuncImplInverse4x4, - SPVFuncImplRowMajor2x3, - SPVFuncImplRowMajor2x4, - SPVFuncImplRowMajor3x2, - SPVFuncImplRowMajor3x4, - SPVFuncImplRowMajor4x2, - SPVFuncImplRowMajor4x3, - }; - - // Constructs an instance to compile the SPIR-V code into Metal Shading Language, - // using the configuration parameters, if provided: - // - p_vtx_attrs is an optional list of vertex attribute bindings used to match - // vertex content locations to MSL attributes. If vertex attributes are provided, - // the compiler will set the used_by_shader flag to true in any vertex attribute - // actually used by the MSL code. - // - p_res_bindings is a list of resource bindings to indicate the MSL buffer, - // texture or sampler index to use for a particular SPIR-V description set - // and binding. If resource bindings are provided, the compiler will set the - // used_by_shader flag to true in any resource binding actually used by the MSL code. - CompilerMSL(std::vector spirv, std::vector *p_vtx_attrs = nullptr, - std::vector *p_res_bindings = nullptr); - - // Alternate constructor avoiding use of std::vectors. - CompilerMSL(const uint32_t *ir, size_t word_count, MSLVertexAttr *p_vtx_attrs = nullptr, size_t vtx_attrs_count = 0, - MSLResourceBinding *p_res_bindings = nullptr, size_t res_bindings_count = 0); - - // Compiles the SPIR-V code into Metal Shading Language. - std::string compile() override; - - // Compiles the SPIR-V code into Metal Shading Language, overriding configuration parameters. - // Any of the parameters here may be null to indicate that the configuration provided in the - // constructor should be used. They are not declared as optional to avoid a conflict with the - // inherited and overridden zero-parameter compile() function. - std::string compile(std::vector *p_vtx_attrs, std::vector *p_res_bindings); - - // This legacy method is deprecated. - typedef Options MSLConfiguration; - SPIRV_CROSS_DEPRECATED("Please use get_options() and set_options() instead.") - std::string compile(MSLConfiguration &msl_cfg, std::vector *p_vtx_attrs = nullptr, - std::vector *p_res_bindings = nullptr); - -protected: - void emit_instruction(const Instruction &instr) override; - void emit_glsl_op(uint32_t result_type, uint32_t result_id, uint32_t op, const uint32_t *args, - uint32_t count) override; - void emit_header() override; - void emit_function_prototype(SPIRFunction &func, uint64_t return_flags) override; - void emit_sampled_image_op(uint32_t result_type, uint32_t result_id, uint32_t image_id, uint32_t samp_id) override; - void emit_fixup() override; - void emit_struct_member(const SPIRType &type, uint32_t member_type_id, uint32_t index, - const std::string &qualifier = "") override; - std::string type_to_glsl(const SPIRType &type, uint32_t id = 0) override; - std::string image_type_glsl(const SPIRType &type, uint32_t id = 0) override; - std::string builtin_to_glsl(spv::BuiltIn builtin, spv::StorageClass storage) override; - std::string constant_expression(const SPIRConstant &c) override; - size_t get_declared_struct_member_size(const SPIRType &struct_type, uint32_t index) const override; - std::string to_func_call_arg(uint32_t id) override; - std::string to_name(uint32_t id, bool allow_alias = true) const override; - std::string to_function_name(uint32_t img, const SPIRType &imgtype, bool is_fetch, bool is_gather, bool is_proj, - bool has_array_offsets, bool has_offset, bool has_grad, bool has_dref, - uint32_t lod) override; - std::string to_function_args(uint32_t img, const SPIRType &imgtype, bool is_fetch, bool is_gather, bool is_proj, - uint32_t coord, uint32_t coord_components, uint32_t dref, uint32_t grad_x, - uint32_t grad_y, uint32_t lod, uint32_t coffset, uint32_t offset, uint32_t bias, - uint32_t comp, uint32_t sample, bool *p_forward) override; - std::string unpack_expression_type(std::string expr_str, const SPIRType &type) override; - std::string bitcast_glsl_op(const SPIRType &result_type, const SPIRType &argument_type) override; - bool skip_argument(uint32_t id) const override; - std::string to_qualifiers_glsl(uint32_t id) override; - void replace_illegal_names() override; - void declare_undefined_values() override; - bool is_non_native_row_major_matrix(uint32_t id) override; - bool member_is_non_native_row_major_matrix(const SPIRType &type, uint32_t index) override; - std::string convert_row_major_matrix(std::string exp_str, const SPIRType &exp_type) override; - - void preprocess_op_codes(); - void localize_global_variables(); - void extract_global_variables_from_functions(); - void resolve_specialized_array_lengths(); - void mark_packable_structs(); - void mark_as_packable(SPIRType &type); - - std::unordered_map> function_global_vars; - void extract_global_variables_from_function(uint32_t func_id, std::set &added_arg_ids, - std::unordered_set &global_var_ids, - std::unordered_set &processed_func_ids); - uint32_t add_interface_block(spv::StorageClass storage); - void mark_location_as_used_by_shader(uint32_t location, spv::StorageClass storage); - - void emit_custom_functions(); - void emit_resources(); - void emit_specialization_constants(); - void emit_interface_block(uint32_t ib_var_id); - bool maybe_emit_input_struct_assignment(uint32_t id_lhs, uint32_t id_rhs); - bool maybe_emit_array_assignment(uint32_t id_lhs, uint32_t id_rhs); - void add_convert_row_major_matrix_function(uint32_t cols, uint32_t rows); - - std::string func_type_decl(SPIRType &type); - std::string entry_point_args(bool append_comma); - std::string get_entry_point_name(); - std::string to_qualified_member_name(const SPIRType &type, uint32_t index); - std::string ensure_valid_name(std::string name, std::string pfx); - std::string to_sampler_expression(uint32_t id); - std::string builtin_qualifier(spv::BuiltIn builtin); - std::string builtin_type_decl(spv::BuiltIn builtin); - std::string built_in_func_arg(spv::BuiltIn builtin, bool prefix_comma); - std::string member_attribute_qualifier(const SPIRType &type, uint32_t index); - std::string argument_decl(const SPIRFunction::Parameter &arg); - std::string round_fp_tex_coords(std::string tex_coords, bool coord_is_fp); - uint32_t get_metal_resource_index(SPIRVariable &var, SPIRType::BaseType basetype); - uint32_t get_ordered_member_location(uint32_t type_id, uint32_t index); - size_t get_declared_struct_member_alignment(const SPIRType &struct_type, uint32_t index) const; - std::string to_component_argument(uint32_t id); - bool should_move_to_input_buffer(SPIRType &type, bool is_builtin, spv::StorageClass storage); - void move_to_input_buffer(SPIRVariable &var); - void move_member_to_input_buffer(const SPIRType &type, uint32_t index); - std::string add_input_buffer_block_member(uint32_t mbr_type_id, std::string mbr_name, uint32_t mbr_locn); - uint32_t get_input_buffer_block_var_id(uint32_t msl_buffer); - void align_struct(SPIRType &ib_type); - bool is_member_packable(SPIRType &ib_type, uint32_t index); - MSLStructMemberKey get_struct_member_key(uint32_t type_id, uint32_t index); - std::string get_argument_address_space(const SPIRVariable &argument); - void emit_atomic_func_op(uint32_t result_type, uint32_t result_id, const char *op, uint32_t mem_order_1, - uint32_t mem_order_2, bool has_mem_order_2, uint32_t op0, uint32_t op1 = 0, - bool op1_is_pointer = false, uint32_t op2 = 0); - const char *get_memory_order(uint32_t spv_mem_sem); - void add_pragma_line(const std::string &line); - void emit_barrier(uint32_t id_exe_scope, uint32_t id_mem_scope, uint32_t id_mem_sem); - - Options options; - std::set spv_function_implementations; - std::unordered_map vtx_attrs_by_location; - std::map non_stage_in_input_var_ids; - std::unordered_map struct_member_padding; - std::set pragma_lines; - std::vector resource_bindings; - MSLResourceBinding next_metal_resource_index; - uint32_t stage_in_var_id = 0; - uint32_t stage_out_var_id = 0; - uint32_t stage_uniforms_var_id = 0; - bool needs_vertex_idx_arg = false; - bool needs_instance_idx_arg = false; - std::string qual_pos_var_name; - std::string stage_in_var_name = "in"; - std::string stage_out_var_name = "out"; - std::string stage_uniform_var_name = "uniforms"; - std::string sampler_name_suffix = "Smplr"; - spv::Op previous_instruction_opcode = spv::OpNop; - - // OpcodeHandler that handles several MSL preprocessing operations. - struct OpCodePreprocessor : OpcodeHandler - { - OpCodePreprocessor(CompilerMSL &compiler_) - : compiler(compiler_) - { - } - - bool handle(spv::Op opcode, const uint32_t *args, uint32_t length) override; - CompilerMSL::SPVFuncImpl get_spv_func_impl(spv::Op opcode, const uint32_t *args); - - CompilerMSL &compiler; - std::unordered_map result_types; - bool suppress_missing_prototypes = false; - bool uses_atomics = false; - }; - - // Sorts the members of a SPIRType and associated Meta info based on a settable sorting - // aspect, which defines which aspect of the struct members will be used to sort them. - // Regardless of the sorting aspect, built-in members always appear at the end of the struct. - struct MemberSorter - { - enum SortAspect - { - Location, - LocationReverse, - Offset, - OffsetThenLocationReverse, - Alphabetical - }; - - void sort(); - bool operator()(uint32_t mbr_idx1, uint32_t mbr_idx2); - MemberSorter(SPIRType &t, Meta &m, SortAspect sa); - - SPIRType &type; - Meta &meta; - SortAspect sort_aspect; - }; -}; -} - -#endif diff --git a/deps/SPIRV-Cross/test_shaders.py b/deps/SPIRV-Cross/test_shaders.py deleted file mode 100755 index 1ca8f9af5f..0000000000 --- a/deps/SPIRV-Cross/test_shaders.py +++ /dev/null @@ -1,451 +0,0 @@ -#!/usr/bin/env python3 - -import sys -import os -import os.path -import subprocess -import tempfile -import re -import itertools -import hashlib -import shutil -import argparse -import codecs - -force_no_external_validation = False - -def parse_stats(stats): - m = re.search('([0-9]+) work registers', stats) - registers = int(m.group(1)) if m else 0 - - m = re.search('([0-9]+) uniform registers', stats) - uniform_regs = int(m.group(1)) if m else 0 - - m_list = re.findall('(-?[0-9]+)\s+(-?[0-9]+)\s+(-?[0-9]+)', stats) - alu_short = float(m_list[1][0]) if m_list else 0 - ls_short = float(m_list[1][1]) if m_list else 0 - tex_short = float(m_list[1][2]) if m_list else 0 - alu_long = float(m_list[2][0]) if m_list else 0 - ls_long = float(m_list[2][1]) if m_list else 0 - tex_long = float(m_list[2][2]) if m_list else 0 - - return (registers, uniform_regs, alu_short, ls_short, tex_short, alu_long, ls_long, tex_long) - -def get_shader_type(shader): - _, ext = os.path.splitext(shader) - if ext == '.vert': - return '--vertex' - elif ext == '.frag': - return '--fragment' - elif ext == '.comp': - return '--compute' - elif ext == '.tesc': - return '--tessellation_control' - elif ext == '.tese': - return '--tessellation_evaluation' - elif ext == '.geom': - return '--geometry' - else: - return '' - -def get_shader_stats(shader): - f, path = tempfile.mkstemp() - - os.close(f) - p = subprocess.Popen(['malisc', get_shader_type(shader), '--core', 'Mali-T760', '-V', shader], stdout = subprocess.PIPE, stderr = subprocess.PIPE) - stdout, stderr = p.communicate() - os.remove(path) - - if p.returncode != 0: - print(stderr.decode('utf-8')) - raise OSError('malisc failed') - p.wait() - - returned = stdout.decode('utf-8') - return parse_stats(returned) - -def print_msl_compiler_version(): - try: - subprocess.check_call(['xcrun', '--sdk', 'iphoneos', 'metal', '--version']) - print('...are the Metal compiler characteristics.\n') # display after so xcrun FNF is silent - except OSError as e: - if (e.errno != os.errno.ENOENT): # Ignore xcrun not found error - raise - -def validate_shader_msl(shader, opt): - msl_path = reference_path(shader[0], shader[1], opt) - try: - msl_os = 'macosx' -# msl_os = 'iphoneos' - subprocess.check_call(['xcrun', '--sdk', msl_os, 'metal', '-x', 'metal', '-std=osx-metal1.2', '-Werror', '-Wno-unused-variable', msl_path]) - print('Compiled Metal shader: ' + msl_path) # display after so xcrun FNF is silent - except OSError as oe: - if (oe.errno != os.errno.ENOENT): # Ignore xcrun not found error - raise - except subprocess.CalledProcessError: - print('Error compiling Metal shader: ' + msl_path) - sys.exit(1) - -def cross_compile_msl(shader, spirv, opt): - spirv_f, spirv_path = tempfile.mkstemp() - msl_f, msl_path = tempfile.mkstemp(suffix = os.path.basename(shader)) - os.close(spirv_f) - os.close(msl_f) - - if spirv: - subprocess.check_call(['spirv-as', '-o', spirv_path, shader]) - else: - subprocess.check_call(['glslangValidator', '-V', '-o', spirv_path, shader]) - - if opt: - subprocess.check_call(['spirv-opt', '-O', '-o', spirv_path, spirv_path]) - - spirv_cross_path = './spirv-cross' - subprocess.check_call([spirv_cross_path, '--entry', 'main', '--output', msl_path, spirv_path, '--msl']) - subprocess.check_call(['spirv-val', spirv_path]) - return (spirv_path, msl_path) - -def shader_model_hlsl(shader): - if '.vert' in shader: - return '-Tvs_5_1' - elif '.frag' in shader: - return '-Tps_5_1' - elif '.comp' in shader: - return '-Tcs_5_1' - else: - return None - -def shader_to_win_path(shader): - # It's (very) convenient to be able to run HLSL testing in wine on Unix-likes, so support that. - try: - with subprocess.Popen(['winepath', '-w', shader], stdout = subprocess.PIPE, stderr = subprocess.PIPE) as f: - stdout_data, stderr_data = f.communicate() - return stdout_data.decode('utf-8') - except OSError as oe: - if (oe.errno != os.errno.ENOENT): # Ignore not found errors - return shader - except subprocess.CalledProcessError: - raise - - return shader - -def validate_shader_hlsl(shader): - subprocess.check_call(['glslangValidator', '-e', 'main', '-D', '-V', shader]) - is_no_fxc = '.nofxc.' in shader - if (not force_no_external_validation) and (not is_no_fxc): - try: - win_path = shader_to_win_path(shader) - subprocess.check_call(['fxc', '-nologo', shader_model_hlsl(shader), win_path]) - except OSError as oe: - if (oe.errno != os.errno.ENOENT): # Ignore not found errors - raise - except subprocess.CalledProcessError: - print('Failed compiling HLSL shader:', shader, 'with FXC.') - sys.exit(1) - -def shader_to_sm(shader): - if '.sm51.' in shader: - return '51' - elif '.sm20.' in shader: - return '20' - else: - return '50' - -def cross_compile_hlsl(shader, spirv, opt): - spirv_f, spirv_path = tempfile.mkstemp() - hlsl_f, hlsl_path = tempfile.mkstemp(suffix = os.path.basename(shader)) - os.close(spirv_f) - os.close(hlsl_f) - - if spirv: - subprocess.check_call(['spirv-as', '-o', spirv_path, shader]) - else: - subprocess.check_call(['glslangValidator', '-V', '-o', spirv_path, shader]) - - if opt: - subprocess.check_call(['spirv-opt', '-O', '-o', spirv_path, spirv_path]) - - spirv_cross_path = './spirv-cross' - - sm = shader_to_sm(shader) - subprocess.check_call([spirv_cross_path, '--entry', 'main', '--output', hlsl_path, spirv_path, '--hlsl-enable-compat', '--hlsl', '--shader-model', sm]) - subprocess.check_call(['spirv-val', spirv_path]) - - validate_shader_hlsl(hlsl_path) - - return (spirv_path, hlsl_path) - -def validate_shader(shader, vulkan): - if vulkan: - subprocess.check_call(['glslangValidator', '-V', shader]) - else: - subprocess.check_call(['glslangValidator', shader]) - -def cross_compile(shader, vulkan, spirv, invalid_spirv, eliminate, is_legacy, flatten_ubo, sso, flatten_dim, opt): - spirv_f, spirv_path = tempfile.mkstemp() - glsl_f, glsl_path = tempfile.mkstemp(suffix = os.path.basename(shader)) - os.close(spirv_f) - os.close(glsl_f) - - if vulkan or spirv: - vulkan_glsl_f, vulkan_glsl_path = tempfile.mkstemp(suffix = os.path.basename(shader)) - os.close(vulkan_glsl_f) - - if spirv: - subprocess.check_call(['spirv-as', '-o', spirv_path, shader]) - else: - subprocess.check_call(['glslangValidator', '-V', '-o', spirv_path, shader]) - - if opt and (not invalid_spirv): - subprocess.check_call(['spirv-opt', '-O', '-o', spirv_path, spirv_path]) - - if not invalid_spirv: - subprocess.check_call(['spirv-val', spirv_path]) - - extra_args = [] - if eliminate: - extra_args += ['--remove-unused-variables'] - if is_legacy: - extra_args += ['--version', '100', '--es'] - if flatten_ubo: - extra_args += ['--flatten-ubo'] - if sso: - extra_args += ['--separate-shader-objects'] - if flatten_dim: - extra_args += ['--flatten-multidimensional-arrays'] - - spirv_cross_path = './spirv-cross' - subprocess.check_call([spirv_cross_path, '--entry', 'main', '--output', glsl_path, spirv_path] + extra_args) - - # A shader might not be possible to make valid GLSL from, skip validation for this case. - if (not ('nocompat' in glsl_path)) and (not spirv): - validate_shader(glsl_path, False) - - if vulkan or spirv: - subprocess.check_call([spirv_cross_path, '--entry', 'main', '--vulkan-semantics', '--output', vulkan_glsl_path, spirv_path] + extra_args) - validate_shader(vulkan_glsl_path, True) - - return (spirv_path, glsl_path, vulkan_glsl_path if vulkan else None) - -def make_unix_newline(buf): - decoded = codecs.decode(buf, 'utf-8') - decoded = decoded.replace('\r', '') - return codecs.encode(decoded, 'utf-8') - -def md5_for_file(path): - md5 = hashlib.md5() - with open(path, 'rb') as f: - for chunk in iter(lambda: make_unix_newline(f.read(8192)), b''): - md5.update(chunk) - return md5.digest() - -def make_reference_dir(path): - base = os.path.dirname(path) - if not os.path.exists(base): - os.makedirs(base) - -def reference_path(directory, relpath, opt): - split_paths = os.path.split(directory) - reference_dir = os.path.join(split_paths[0], 'reference/' + ('opt/' if opt else '')) - reference_dir = os.path.join(reference_dir, split_paths[1]) - return os.path.join(reference_dir, relpath) - -def regression_check(shader, glsl, update, keep, opt): - reference = reference_path(shader[0], shader[1], opt) - joined_path = os.path.join(shader[0], shader[1]) - print('Reference shader path:', reference) - - if os.path.exists(reference): - if md5_for_file(glsl) != md5_for_file(reference): - if update: - print('Generated source code has changed for {}!'.format(reference)) - # If we expect changes, update the reference file. - if os.path.exists(reference): - os.remove(reference) - make_reference_dir(reference) - shutil.move(glsl, reference) - else: - print('Generated source code in {} does not match reference {}!'.format(glsl, reference)) - with open(glsl, 'r') as f: - print('') - print('Generated:') - print('======================') - print(f.read()) - print('======================') - print('') - - # Otherwise, fail the test. Keep the shader file around so we can inspect. - if not keep: - os.remove(glsl) - sys.exit(1) - else: - os.remove(glsl) - else: - print('Found new shader {}. Placing generated source code in {}'.format(joined_path, reference)) - make_reference_dir(reference) - shutil.move(glsl, reference) - -def shader_is_vulkan(shader): - return '.vk.' in shader - -def shader_is_desktop(shader): - return '.desktop.' in shader - -def shader_is_eliminate_dead_variables(shader): - return '.noeliminate.' not in shader - -def shader_is_spirv(shader): - return '.asm.' in shader - -def shader_is_invalid_spirv(shader): - return '.invalid.' in shader - -def shader_is_legacy(shader): - return '.legacy.' in shader - -def shader_is_flatten_ubo(shader): - return '.flatten.' in shader - -def shader_is_sso(shader): - return '.sso.' in shader - -def shader_is_flatten_dimensions(shader): - return '.flatten_dim.' in shader - -def shader_is_noopt(shader): - return '.noopt.' in shader - -def test_shader(stats, shader, update, keep, opt): - joined_path = os.path.join(shader[0], shader[1]) - vulkan = shader_is_vulkan(shader[1]) - desktop = shader_is_desktop(shader[1]) - eliminate = shader_is_eliminate_dead_variables(shader[1]) - is_spirv = shader_is_spirv(shader[1]) - invalid_spirv = shader_is_invalid_spirv(shader[1]) - is_legacy = shader_is_legacy(shader[1]) - flatten_ubo = shader_is_flatten_ubo(shader[1]) - sso = shader_is_sso(shader[1]) - flatten_dim = shader_is_flatten_dimensions(shader[1]) - noopt = shader_is_noopt(shader[1]) - - print('Testing shader:', joined_path) - spirv, glsl, vulkan_glsl = cross_compile(joined_path, vulkan, is_spirv, invalid_spirv, eliminate, is_legacy, flatten_ubo, sso, flatten_dim, opt and (not noopt)) - - # Only test GLSL stats if we have a shader following GL semantics. - if stats and (not vulkan) and (not is_spirv) and (not desktop): - cross_stats = get_shader_stats(glsl) - - regression_check(shader, glsl, update, keep, opt) - if vulkan_glsl: - regression_check((shader[0], shader[1] + '.vk'), vulkan_glsl, update, keep, opt) - os.remove(spirv) - - if stats and (not vulkan) and (not is_spirv) and (not desktop): - pristine_stats = get_shader_stats(joined_path) - - a = [] - a.append(shader[1]) - for i in pristine_stats: - a.append(str(i)) - for i in cross_stats: - a.append(str(i)) - print(','.join(a), file = stats) - -def test_shader_msl(stats, shader, update, keep, opt): - joined_path = os.path.join(shader[0], shader[1]) - print('\nTesting MSL shader:', joined_path) - is_spirv = shader_is_spirv(shader[1]) - noopt = shader_is_noopt(shader[1]) - spirv, msl = cross_compile_msl(joined_path, is_spirv, opt and (not noopt)) - regression_check(shader, msl, update, keep, opt) - - # Uncomment the following line to print the temp SPIR-V file path. - # This temp SPIR-V file is not deleted until after the Metal validation step below. - # If Metal validation fails, the temp SPIR-V file can be copied out and - # used as input to an invocation of spirv-cross to debug from Xcode directly. - # To do so, build spriv-cross using `make DEBUG=1`, then run the spriv-cross - # executable from Xcode using args: `--msl --entry main --output msl_path spirv_path`. -# print('SPRIV shader: ' + spirv) - - if not force_no_external_validation: - validate_shader_msl(shader, opt) - - os.remove(spirv) - -def test_shader_hlsl(stats, shader, update, keep, opt): - joined_path = os.path.join(shader[0], shader[1]) - print('Testing HLSL shader:', joined_path) - is_spirv = shader_is_spirv(shader[1]) - noopt = shader_is_noopt(shader[1]) - spirv, msl = cross_compile_hlsl(joined_path, is_spirv, opt and (not noopt)) - regression_check(shader, msl, update, keep, opt) - os.remove(spirv) - -def test_shaders_helper(stats, shader_dir, update, malisc, keep, opt, backend): - for root, dirs, files in os.walk(os.path.join(shader_dir)): - files = [ f for f in files if not f.startswith(".") ] #ignore system files (esp OSX) - for i in files: - path = os.path.join(root, i) - relpath = os.path.relpath(path, shader_dir) - if backend == 'msl': - test_shader_msl(stats, (shader_dir, relpath), update, keep, opt) - elif backend == 'hlsl': - test_shader_hlsl(stats, (shader_dir, relpath), update, keep, opt) - else: - test_shader(stats, (shader_dir, relpath), update, keep, opt) - -def test_shaders(shader_dir, update, malisc, keep, opt, backend): - if malisc: - with open('stats.csv', 'w') as stats: - print('Shader,OrigRegs,OrigUniRegs,OrigALUShort,OrigLSShort,OrigTEXShort,OrigALULong,OrigLSLong,OrigTEXLong,CrossRegs,CrossUniRegs,CrossALUShort,CrossLSShort,CrossTEXShort,CrossALULong,CrossLSLong,CrossTEXLong', file = stats) - test_shaders_helper(stats, shader_dir, update, malisc, keep, backend) - else: - test_shaders_helper(None, shader_dir, update, malisc, keep, opt, backend) - -def main(): - parser = argparse.ArgumentParser(description = 'Script for regression testing.') - parser.add_argument('folder', - help = 'Folder containing shader files to test.') - parser.add_argument('--update', - action = 'store_true', - help = 'Updates reference files if there is a mismatch. Use when legitimate changes in output is found.') - parser.add_argument('--keep', - action = 'store_true', - help = 'Leave failed GLSL shaders on disk if they fail regression. Useful for debugging.') - parser.add_argument('--malisc', - action = 'store_true', - help = 'Use malisc offline compiler to determine static cycle counts before and after spirv-cross.') - parser.add_argument('--msl', - action = 'store_true', - help = 'Test Metal backend.') - parser.add_argument('--metal', - action = 'store_true', - help = 'Deprecated Metal option. Use --msl instead.') - parser.add_argument('--hlsl', - action = 'store_true', - help = 'Test HLSL backend.') - parser.add_argument('--force-no-external-validation', - action = 'store_true', - help = 'Disable all external validation.') - parser.add_argument('--opt', - action = 'store_true', - help = 'Run SPIRV-Tools optimization passes as well.') - args = parser.parse_args() - - if not args.folder: - sys.stderr.write('Need shader folder.\n') - sys.exit(1) - - if args.msl: - print_msl_compiler_version() - - global force_no_external_validation - force_no_external_validation = args.force_no_external_validation - - test_shaders(args.folder, args.update, args.malisc, args.keep, args.opt, 'msl' if (args.msl or args.metal) else ('hlsl' if args.hlsl else 'glsl')) - if args.malisc: - print('Stats in stats.csv!') - print('Tests completed!') - -if __name__ == '__main__': - main() diff --git a/deps/SPIRV-Cross/test_shaders.sh b/deps/SPIRV-Cross/test_shaders.sh deleted file mode 100644 index a3608730b9..0000000000 --- a/deps/SPIRV-Cross/test_shaders.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -echo "Building spirv-cross" -make -j$(nproc) - -export PATH="./external/glslang-build/StandAlone:./external/spirv-tools-build/tools:.:$PATH" -echo "Using glslangValidation in: $(which glslangValidator)." -echo "Using spirv-opt in: $(which spirv-opt)." - -./test_shaders.py shaders || exit 1 -./test_shaders.py shaders --opt || exit 1 -./test_shaders.py shaders-msl --msl || exit 1 -./test_shaders.py shaders-msl --msl --opt || exit 1 -./test_shaders.py shaders-msl-no-opt --msl || exit 1 -./test_shaders.py shaders-hlsl --hlsl || exit 1 -./test_shaders.py shaders-hlsl --hlsl --opt || exit 1 - diff --git a/deps/SPIRV-Cross/update_test_shaders.sh b/deps/SPIRV-Cross/update_test_shaders.sh deleted file mode 100644 index 712c3eec5d..0000000000 --- a/deps/SPIRV-Cross/update_test_shaders.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -echo "Building spirv-cross" -make -j$(nproc) - -export PATH="./external/glslang-build/StandAlone:./external/spirv-tools-build/tools:.:$PATH" -echo "Using glslangValidation in: $(which glslangValidator)." -echo "Using spirv-opt in: $(which spirv-opt)." - -./test_shaders.py shaders --update || exit 1 -./test_shaders.py shaders --update --opt || exit 1 -./test_shaders.py shaders-msl --msl --update || exit 1 -./test_shaders.py shaders-msl --msl --update --opt || exit 1 -./test_shaders.py shaders-msl-no-opt --msl --update || exit 1 -./test_shaders.py shaders-hlsl --hlsl --update || exit 1 -./test_shaders.py shaders-hlsl --hlsl --update --opt || exit 1 - From 501fd33b6849de260c6a81fd9575c3aa8a01f7a5 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Fri, 2 Feb 2018 11:53:59 +0100 Subject: [PATCH 010/232] Squashed 'deps/SPIRV-Cross/' content from commit d4b0625cbd git-subtree-dir: deps/SPIRV-Cross git-subtree-split: d4b0625cbd7377e720b4fa1d63e6a3c09da5db63 --- .clang-format | 167 + .gitignore | 19 + .travis.yml | 33 + CMakeLists.txt | 145 + GLSL.std.450.h | 131 + LICENSE | 202 + Makefile | 41 + README.md | 350 + checkout_glslang_spirv_tools.sh | 57 + format_all.sh | 7 + include/spirv_cross/barrier.hpp | 79 + include/spirv_cross/external_interface.h | 126 + include/spirv_cross/image.hpp | 62 + include/spirv_cross/internal_interface.hpp | 603 ++ include/spirv_cross/sampler.hpp | 105 + include/spirv_cross/thread_group.hpp | 113 + jni/Android.mk | 12 + jni/Application.mk | 2 + main.cpp | 923 ++ msvc/SPIRV-Cross.sln | 28 + msvc/SPIRV-Cross.vcxproj | 148 + msvc/SPIRV-Cross.vcxproj.filters | 69 + ...lization-constant-workgroup.nofxc.asm.comp | 16 + .../comp/storage-buffer-basic.nofxc.asm.comp | 24 + .../asm/frag/cbuffer-stripped.asm.frag | 25 + .../asm/frag/unreachable.asm.frag | 42 + .../asm/vert/empty-struct-composite.asm.vert | 8 + .../asm/vert/vertex-id-instance-id.asm.vert | 28 + .../opt/shaders-hlsl/comp/access-chains.comp | 21 + .../shaders-hlsl/comp/address-buffers.comp | 15 + reference/opt/shaders-hlsl/comp/atomic.comp | 89 + reference/opt/shaders-hlsl/comp/barriers.comp | 26 + .../opt/shaders-hlsl/comp/bitfield.noopt.comp | 113 + reference/opt/shaders-hlsl/comp/builtins.comp | 9 + reference/opt/shaders-hlsl/comp/image.comp | 62 + .../shaders-hlsl/comp/rwbuffer-matrix.comp | 90 + reference/opt/shaders-hlsl/comp/shared.comp | 29 + .../opt/shaders-hlsl/comp/ssbo-array.comp | 9 + reference/opt/shaders-hlsl/frag/basic.frag | 32 + .../shaders-hlsl/frag/bit-conversions.frag | 26 + .../opt/shaders-hlsl/frag/boolean-mix.frag | 27 + reference/opt/shaders-hlsl/frag/builtins.frag | 33 + .../shaders-hlsl/frag/bvec-operations.frag | 27 + .../combined-texture-sampler-parameter.frag | 24 + .../frag/combined-texture-sampler-shadow.frag | 23 + .../frag/constant-buffer-array.sm51.frag | 43 + .../frag/constant-composites.frag | 43 + .../frag/early-fragment-test.frag | 9 + .../opt/shaders-hlsl/frag/fp16-packing.frag | 44 + .../frag/image-query-selective.frag | 29 + .../opt/shaders-hlsl/frag/image-query.frag | 8 + reference/opt/shaders-hlsl/frag/io-block.frag | 28 + .../opt/shaders-hlsl/frag/matrix-input.frag | 26 + reference/opt/shaders-hlsl/frag/mod.frag | 67 + reference/opt/shaders-hlsl/frag/mrt.frag | 31 + .../opt/shaders-hlsl/frag/no-return.frag | 8 + .../opt/shaders-hlsl/frag/no-return2.frag | 16 + .../frag/partial-write-preserve.frag | 14 + .../shaders-hlsl/frag/query-lod.desktop.frag | 30 + .../opt/shaders-hlsl/frag/resources.frag | 39 + .../frag/sample-cmp-level-zero.frag | 57 + .../opt/shaders-hlsl/frag/sampler-array.frag | 29 + .../opt/shaders-hlsl/frag/spec-constant.frag | 33 + .../opt/shaders-hlsl/frag/swizzle-scalar.frag | 41 + .../opt/shaders-hlsl/frag/tex-sampling.frag | 87 + .../frag/texture-proj-shadow.frag | 66 + .../texture-size-combined-image-sampler.frag | 30 + .../opt/shaders-hlsl/frag/unary-enclose.frag | 29 + .../frag/unorm-snorm-packing.frag | 109 + .../shaders-hlsl/frag/various-glsl-ops.frag | 26 + reference/opt/shaders-hlsl/vert/basic.vert | 38 + .../opt/shaders-hlsl/vert/instancing.vert | 28 + .../opt/shaders-hlsl/vert/locations.vert | 79 + .../shaders-hlsl/vert/matrix-attribute.vert | 35 + .../opt/shaders-hlsl/vert/matrix-output.vert | 23 + reference/opt/shaders-hlsl/vert/no-input.vert | 18 + .../shaders-hlsl/vert/point-size-compat.vert | 20 + .../opt/shaders-hlsl/vert/qualifiers.vert | 50 + .../shaders-hlsl/vert/sampler-buffers.vert | 22 + .../vert/struct-composite-decl.vert | 44 + .../opt/shaders-hlsl/vert/texture_buffer.vert | 21 + .../asm/comp/bitcast_iadd.asm.comp | 29 + .../shaders-msl/asm/comp/bitcast_sar.asm.comp | 29 + .../asm/comp/bitcast_sdiv.asm.comp | 29 + .../shaders-msl/asm/comp/bitcast_slr.asm.comp | 29 + .../asm/comp/multiple-entry.asm.comp | 29 + .../shaders-msl/asm/comp/quantize.asm.comp | 21 + ...specialization-constant-workgroup.asm.comp | 21 + .../asm/comp/storage-buffer-basic.asm.comp | 21 + .../asm/frag/default-member-names.asm.frag | 41 + .../inliner-dominator-inside-loop.asm.frag | 235 + .../asm/frag/op-constant-null.asm.frag | 23 + .../asm/frag/phi-loop-variable.asm.frag | 12 + .../asm/frag/undef-variable-store.asm.frag | 38 + .../shaders-msl/asm/frag/unreachable.asm.frag | 38 + .../asm/frag/vector-shuffle-oom.asm.frag | 321 + .../asm/vert/empty-struct-composite.asm.vert | 9 + reference/opt/shaders-msl/comp/atomic.comp | 36 + .../opt/shaders-msl/comp/bake_gradient.comp | 22 + reference/opt/shaders-msl/comp/barriers.comp | 20 + reference/opt/shaders-msl/comp/basic.comp | 33 + .../opt/shaders-msl/comp/bitfield.noopt.comp | 47 + reference/opt/shaders-msl/comp/builtins.comp | 9 + .../comp/cfg-preserve-parameter.comp | 9 + .../opt/shaders-msl/comp/coherent-block.comp | 15 + .../opt/shaders-msl/comp/coherent-image.comp | 15 + reference/opt/shaders-msl/comp/culling.comp | 35 + .../opt/shaders-msl/comp/defer-parens.comp | 21 + reference/opt/shaders-msl/comp/dowhile.comp | 39 + reference/opt/shaders-msl/comp/functions.comp | 11 + ...vocation-id-writable-ssbo-in-function.comp | 26 + .../comp/global-invocation-id.comp | 26 + reference/opt/shaders-msl/comp/image.comp | 10 + reference/opt/shaders-msl/comp/insert.comp | 26 + .../shaders-msl/comp/local-invocation-id.comp | 26 + .../comp/local-invocation-index.comp | 26 + .../opt/shaders-msl/comp/loop.noopt.comp | 107 + reference/opt/shaders-msl/comp/mat3.comp | 15 + reference/opt/shaders-msl/comp/mod.comp | 31 + reference/opt/shaders-msl/comp/modf.comp | 22 + .../opt/shaders-msl/comp/read-write-only.comp | 29 + reference/opt/shaders-msl/comp/return.comp | 33 + reference/opt/shaders-msl/comp/rmw-opt.comp | 26 + .../comp/shared-array-of-arrays.comp | 20 + reference/opt/shaders-msl/comp/shared.comp | 25 + .../opt/shaders-msl/comp/struct-layout.comp | 25 + .../opt/shaders-msl/comp/struct-packing.comp | 100 + .../opt/shaders-msl/comp/torture-loop.comp | 79 + .../opt/shaders-msl/comp/type-alias.comp | 35 + reference/opt/shaders-msl/comp/udiv.comp | 20 + .../opt/shaders-msl/comp/writable-ssbo.comp | 26 + .../desktop-only/frag/image-ms.desktop.frag | 11 + .../frag/query-levels.desktop.frag | 17 + .../frag/sampler-ms-query.desktop.frag | 17 + .../desktop-only/vert/basic.desktop.sso.vert | 30 + .../vert/clip-cull-distance.desktop.vert | 23 + .../shaders-msl/flatten/basic.flatten.vert | 30 + .../flatten/multiindex.flatten.vert | 27 + .../flatten/push-constant.flatten.vert | 32 + .../shaders-msl/flatten/rowmajor.flatten.vert | 29 + .../shaders-msl/flatten/struct.flatten.vert | 40 + .../shaders-msl/flatten/swizzle.flatten.vert | 47 + .../shaders-msl/flatten/types.flatten.frag | 35 + reference/opt/shaders-msl/frag/basic.frag | 23 + .../opt/shaders-msl/frag/bitcasting.frag | 26 + reference/opt/shaders-msl/frag/builtins.frag | 24 + .../composite-extract-forced-temporary.frag | 24 + .../opt/shaders-msl/frag/constant-array.frag | 31 + .../shaders-msl/frag/constant-composites.frag | 31 + .../opt/shaders-msl/frag/false-loop-init.frag | 38 + .../opt/shaders-msl/frag/flush_params.frag | 22 + .../opt/shaders-msl/frag/for-loop-init.frag | 57 + reference/opt/shaders-msl/frag/in_block.frag | 23 + .../frag/in_block_assign.noopt.frag | 30 + reference/opt/shaders-msl/frag/mix.frag | 29 + reference/opt/shaders-msl/frag/pls.frag | 31 + .../opt/shaders-msl/frag/sampler-ms.frag | 18 + reference/opt/shaders-msl/frag/sampler.frag | 23 + .../frag/separate-image-sampler-argument.frag | 17 + reference/opt/shaders-msl/frag/swizzle.frag | 28 + .../shaders-msl/frag/texture-proj-shadow.frag | 29 + .../opt/shaders-msl/frag/ubo_layout.frag | 32 + .../opt/shaders-msl/frag/unary-enclose.frag | 22 + .../legacy/vert/transpose.legacy.vert | 29 + reference/opt/shaders-msl/vert/basic.vert | 30 + .../opt/shaders-msl/vert/copy.flatten.vert | 43 + .../opt/shaders-msl/vert/dynamic.flatten.vert | 43 + reference/opt/shaders-msl/vert/functions.vert | 119 + reference/opt/shaders-msl/vert/out_block.vert | 32 + reference/opt/shaders-msl/vert/pointsize.vert | 33 + .../opt/shaders-msl/vert/texture_buffer.vert | 17 + .../opt/shaders-msl/vert/ubo.alignment.vert | 38 + reference/opt/shaders-msl/vert/ubo.vert | 30 + .../vulkan/frag/push-constant.vk.frag | 28 + .../vulkan/frag/spec-constant.vk.frag | 22 + .../vulkan/vert/vulkan-vertex.vk.vert | 17 + ...etch_subpassInput.vk.nocompat.invalid.frag | 11 + ...h_subpassInput.vk.nocompat.invalid.frag.vk | 11 + reference/opt/shaders/amd/fs.invalid.frag | 15 + reference/opt/shaders/amd/gcn_shader.comp | 8 + reference/opt/shaders/amd/shader_ballot.comp | 26 + ...ballot_nonuniform_invocations.invalid.comp | 11 + .../opt/shaders/amd/shader_group_vote.comp | 7 + .../shaders/amd/shader_trinary_minmax.comp | 7 + .../shaders/asm/comp/bitcast_iadd.asm.comp | 27 + .../shaders/asm/comp/bitcast_iequal.asm.comp | 31 + .../opt/shaders/asm/comp/bitcast_sar.asm.comp | 27 + .../shaders/asm/comp/bitcast_sdiv.asm.comp | 27 + .../opt/shaders/asm/comp/bitcast_slr.asm.comp | 27 + .../opt/shaders/asm/comp/logical.asm.comp | 7 + .../shaders/asm/comp/multiple-entry.asm.comp | 27 + .../asm/comp/name-alias.asm.invalid.comp | 37 + .../opt/shaders/asm/comp/quantize.asm.comp | 19 + ...specialization-constant-workgroup.asm.comp | 13 + .../asm/comp/storage-buffer-basic.asm.comp | 18 + ...osite-construct-struct-no-swizzle.asm.frag | 18 + .../asm/frag/default-member-names.asm.frag | 33 + .../hlsl-sample-cmp-level-zero-cube.asm.frag | 11 + .../frag/hlsl-sample-cmp-level-zero.asm.frag | 14 + .../inliner-dominator-inside-loop.asm.frag | 227 + .../shaders/asm/frag/invalidation.asm.frag | 11 + ...op-body-dominator-continue-access.asm.frag | 52 + .../asm/frag/loop-header-to-continue.asm.frag | 39 + .../asm/frag/multi-for-loop-init.asm.frag | 19 + .../asm/frag/op-constant-null.asm.frag | 17 + .../asm/frag/phi-loop-variable.asm.frag | 9 + .../sampler-buffer-without-sampler.asm.frag | 13 + .../struct-composite-extract-swizzle.asm.frag | 21 + .../asm/frag/temporary-phi-hoisting.asm.frag | 26 + .../asm/frag/undef-variable-store.asm.frag | 30 + .../opt/shaders/asm/frag/unreachable.asm.frag | 26 + .../asm/frag/vector-shuffle-oom.asm.frag | 316 + ...s-fixed-input-array-builtin-array.asm.tesc | 81 + .../opt/shaders/asm/vert/empty-io.asm.vert | 19 + .../asm/vert/empty-struct-composite.asm.vert | 6 + .../asm/vert/global-builtin.sso.asm.vert | 26 + reference/opt/shaders/comp/atomic.comp | 49 + reference/opt/shaders/comp/bake_gradient.comp | 23 + reference/opt/shaders/comp/barriers.comp | 28 + reference/opt/shaders/comp/basic.comp | 28 + .../opt/shaders/comp/bitfield.noopt.comp | 19 + reference/opt/shaders/comp/casts.comp | 18 + .../shaders/comp/cfg-preserve-parameter.comp | 7 + reference/opt/shaders/comp/cfg.comp | 56 + .../opt/shaders/comp/coherent-block.comp | 13 + .../opt/shaders/comp/coherent-image.comp | 15 + .../opt/shaders/comp/composite-construct.comp | 26 + reference/opt/shaders/comp/culling.comp | 28 + reference/opt/shaders/comp/defer-parens.comp | 19 + reference/opt/shaders/comp/dowhile.comp | 39 + .../opt/shaders/comp/generate_height.comp | 54 + reference/opt/shaders/comp/image.comp | 11 + .../shaders/comp/inout-struct.invalid.comp | 65 + reference/opt/shaders/comp/insert.comp | 24 + reference/opt/shaders/comp/loop.noopt.comp | 105 + reference/opt/shaders/comp/mat3.comp | 13 + reference/opt/shaders/comp/mod.comp | 20 + reference/opt/shaders/comp/modf.comp | 20 + .../opt/shaders/comp/read-write-only.comp | 27 + reference/opt/shaders/comp/return.comp | 31 + reference/opt/shaders/comp/rmw-opt.comp | 24 + reference/opt/shaders/comp/shared.comp | 23 + reference/opt/shaders/comp/ssbo-array.comp | 13 + reference/opt/shaders/comp/struct-layout.comp | 23 + .../opt/shaders/comp/struct-packing.comp | 104 + reference/opt/shaders/comp/torture-loop.comp | 77 + reference/opt/shaders/comp/type-alias.comp | 33 + reference/opt/shaders/comp/udiv.comp | 18 + .../desktop-only/comp/enhanced-layouts.comp | 40 + .../desktop-only/comp/fp64.desktop.comp | 63 + .../image-formats.desktop.noeliminate.comp | 7 + .../desktop-only/comp/int64.desktop.comp | 52 + .../frag/hlsl-uav-block-alias.asm.frag | 19 + .../desktop-only/frag/image-ms.desktop.frag | 12 + .../frag/image-query.desktop.frag | 16 + .../frag/in-block-qualifiers.frag | 21 + .../frag/query-levels.desktop.frag | 11 + .../desktop-only/frag/query-lod.desktop.frag | 12 + .../frag/sampler-ms-query.desktop.frag | 14 + .../frag/texture-proj-shadow.desktop.frag | 26 + .../desktop-only/geom/basic.desktop.sso.geom | 35 + .../geom/viewport-index.desktop.geom | 9 + .../desktop-only/tesc/basic.desktop.sso.tesc | 27 + .../tese/triangle.desktop.sso.tese | 18 + .../desktop-only/vert/basic.desktop.sso.vert | 22 + .../vert/clip-cull-distance.desktop.vert | 11 + .../vert/out-block-qualifiers.vert | 27 + .../opt/shaders/flatten/array.flatten.vert | 10 + .../opt/shaders/flatten/basic.flatten.vert | 13 + .../opt/shaders/flatten/copy.flatten.vert | 25 + .../opt/shaders/flatten/dynamic.flatten.vert | 25 + .../shaders/flatten/matrixindex.flatten.vert | 19 + ...multi-dimensional.desktop.flatten_dim.frag | 34 + .../shaders/flatten/multiindex.flatten.vert | 10 + .../flatten/push-constant.flatten.vert | 13 + .../opt/shaders/flatten/rowmajor.flatten.vert | 10 + .../opt/shaders/flatten/struct.flatten.vert | 22 + .../flatten/struct.rowmajor.flatten.vert | 20 + .../opt/shaders/flatten/swizzle.flatten.vert | 21 + .../opt/shaders/flatten/types.flatten.frag | 14 + reference/opt/shaders/frag/basic.frag | 15 + .../composite-extract-forced-temporary.frag | 16 + .../opt/shaders/frag/constant-array.frag | 21 + .../opt/shaders/frag/constant-composites.frag | 23 + .../frag/eliminate-dead-variables.frag | 14 + .../opt/shaders/frag/false-loop-init.frag | 28 + reference/opt/shaders/frag/flush_params.frag | 16 + reference/opt/shaders/frag/for-loop-init.frag | 51 + reference/opt/shaders/frag/frexp-modf.frag | 33 + reference/opt/shaders/frag/ground.frag | 35 + .../frag/image-load-store-uint-coord.asm.frag | 17 + reference/opt/shaders/frag/mix.frag | 18 + .../shaders/frag/partial-write-preserve.frag | 14 + reference/opt/shaders/frag/pls.frag | 21 + .../opt/shaders/frag/sample-parameter.frag | 13 + .../opt/shaders/frag/sampler-ms-query.frag | 14 + reference/opt/shaders/frag/sampler-ms.frag | 14 + reference/opt/shaders/frag/sampler-proj.frag | 16 + reference/opt/shaders/frag/sampler.frag | 15 + reference/opt/shaders/frag/swizzle.frag | 20 + reference/opt/shaders/frag/temporary.frag | 14 + reference/opt/shaders/frag/ubo_layout.frag | 26 + reference/opt/shaders/frag/unary-enclose.frag | 12 + reference/opt/shaders/geom/basic.geom | 26 + .../opt/shaders/geom/lines-adjacency.geom | 26 + reference/opt/shaders/geom/lines.geom | 23 + reference/opt/shaders/geom/points.geom | 26 + .../opt/shaders/geom/single-invocation.geom | 26 + .../opt/shaders/geom/triangles-adjacency.geom | 26 + reference/opt/shaders/geom/triangles.geom | 26 + .../legacy/fragment/explicit-lod.legacy.frag | 12 + .../legacy/fragment/io-blocks.legacy.frag | 12 + .../fragment/struct-varying.legacy.frag | 18 + .../legacy/vert/implicit-lod.legacy.vert | 9 + .../shaders/legacy/vert/io-block.legacy.vert | 13 + .../legacy/vert/struct-varying.legacy.vert | 30 + .../shaders/legacy/vert/transpose.legacy.vert | 18 + reference/opt/shaders/tesc/basic.tesc | 17 + reference/opt/shaders/tesc/water_tess.tesc | 79 + reference/opt/shaders/tese/ccw.tese | 9 + reference/opt/shaders/tese/cw.tese | 9 + reference/opt/shaders/tese/equal.tese | 9 + .../opt/shaders/tese/fractional_even.tese | 9 + .../opt/shaders/tese/fractional_odd.tese | 9 + reference/opt/shaders/tese/line.tese | 9 + reference/opt/shaders/tese/triangle.tese | 9 + reference/opt/shaders/tese/water_tess.tese | 37 + reference/opt/shaders/vert/basic.vert | 17 + reference/opt/shaders/vert/ground.vert | 87 + reference/opt/shaders/vert/ocean.vert | 117 + .../opt/shaders/vert/texture_buffer.vert | 11 + reference/opt/shaders/vert/ubo.vert | 17 + .../combined-texture-sampler-shadow.vk.frag | 14 + ...combined-texture-sampler-shadow.vk.frag.vk | 15 + .../frag/combined-texture-sampler.vk.frag | 17 + .../frag/combined-texture-sampler.vk.frag.vk | 17 + .../vulkan/frag/desktop-mediump.vk.frag | 12 + .../vulkan/frag/desktop-mediump.vk.frag.vk | 12 + .../vulkan/frag/input-attachment-ms.vk.frag | 12 + .../frag/input-attachment-ms.vk.frag.vk | 12 + .../vulkan/frag/input-attachment.vk.frag | 14 + .../vulkan/frag/input-attachment.vk.frag.vk | 14 + .../shaders/vulkan/frag/push-constant.vk.frag | 20 + .../vulkan/frag/push-constant.vk.frag.vk | 18 + .../frag/separate-sampler-texture.vk.frag | 20 + .../frag/separate-sampler-texture.vk.frag.vk | 21 + .../shaders/vulkan/frag/spec-constant.vk.frag | 20 + .../vulkan/frag/spec-constant.vk.frag.vk | 25 + .../vulkan/vert/multiview.nocompat.vk.vert | 15 + .../vulkan/vert/multiview.nocompat.vk.vert.vk | 15 + .../shaders/vulkan/vert/vulkan-vertex.vk.vert | 9 + .../vulkan/vert/vulkan-vertex.vk.vert.vk | 7 + ...lization-constant-workgroup.nofxc.asm.comp | 16 + .../comp/storage-buffer-basic.nofxc.asm.comp | 26 + .../asm/frag/cbuffer-stripped.asm.frag | 31 + .../asm/frag/unreachable.asm.frag | 44 + .../asm/vert/empty-struct-composite.asm.vert | 8 + .../asm/vert/vertex-id-instance-id.asm.vert | 28 + .../shaders-hlsl/comp/access-chains.comp | 21 + .../shaders-hlsl/comp/address-buffers.comp | 15 + reference/shaders-hlsl/comp/atomic.comp | 89 + reference/shaders-hlsl/comp/barriers.comp | 81 + .../shaders-hlsl/comp/bitfield.noopt.comp | 113 + reference/shaders-hlsl/comp/builtins.comp | 32 + reference/shaders-hlsl/comp/image.comp | 71 + .../shaders-hlsl/comp/rwbuffer-matrix.comp | 136 + reference/shaders-hlsl/comp/shared.comp | 31 + reference/shaders-hlsl/comp/ssbo-array.comp | 11 + reference/shaders-hlsl/frag/basic.frag | 32 + .../shaders-hlsl/frag/bit-conversions.frag | 27 + reference/shaders-hlsl/frag/boolean-mix.frag | 27 + reference/shaders-hlsl/frag/builtins.frag | 33 + .../shaders-hlsl/frag/bvec-operations.frag | 29 + .../combined-texture-sampler-parameter.frag | 44 + .../frag/combined-texture-sampler-shadow.frag | 40 + .../frag/constant-buffer-array.sm51.frag | 43 + .../frag/constant-composites.frag | 43 + .../frag/early-fragment-test.frag | 9 + reference/shaders-hlsl/frag/fp16-packing.frag | 44 + .../frag/image-query-selective.frag | 146 + reference/shaders-hlsl/frag/image-query.frag | 132 + reference/shaders-hlsl/frag/io-block.frag | 28 + reference/shaders-hlsl/frag/matrix-input.frag | 26 + reference/shaders-hlsl/frag/mod.frag | 71 + reference/shaders-hlsl/frag/mrt.frag | 31 + reference/shaders-hlsl/frag/no-return.frag | 8 + reference/shaders-hlsl/frag/no-return2.frag | 17 + .../frag/partial-write-preserve.frag | 75 + .../shaders-hlsl/frag/query-lod.desktop.frag | 30 + reference/shaders-hlsl/frag/resources.frag | 42 + .../frag/sample-cmp-level-zero.frag | 66 + .../shaders-hlsl/frag/sampler-array.frag | 43 + .../shaders-hlsl/frag/spec-constant.frag | 79 + .../shaders-hlsl/frag/swizzle-scalar.frag | 41 + reference/shaders-hlsl/frag/tex-sampling.frag | 118 + .../frag/texture-proj-shadow.frag | 66 + .../texture-size-combined-image-sampler.frag | 30 + .../shaders-hlsl/frag/unary-enclose.frag | 32 + .../frag/unorm-snorm-packing.frag | 109 + .../shaders-hlsl/frag/various-glsl-ops.frag | 28 + reference/shaders-hlsl/vert/basic.vert | 38 + reference/shaders-hlsl/vert/instancing.vert | 28 + reference/shaders-hlsl/vert/locations.vert | 75 + .../shaders-hlsl/vert/matrix-attribute.vert | 35 + .../shaders-hlsl/vert/matrix-output.vert | 23 + reference/shaders-hlsl/vert/no-input.vert | 18 + .../shaders-hlsl/vert/point-size-compat.vert | 20 + reference/shaders-hlsl/vert/qualifiers.vert | 50 + .../shaders-hlsl/vert/sampler-buffers.vert | 27 + .../vert/struct-composite-decl.vert | 50 + .../shaders-hlsl/vert/texture_buffer.vert | 21 + .../vert/functions_nested.vert | 189 + .../asm/comp/bitcast_iadd.asm.comp | 29 + .../shaders-msl/asm/comp/bitcast_sar.asm.comp | 29 + .../asm/comp/bitcast_sdiv.asm.comp | 29 + .../shaders-msl/asm/comp/bitcast_slr.asm.comp | 29 + .../asm/comp/multiple-entry.asm.comp | 29 + .../shaders-msl/asm/comp/quantize.asm.comp | 21 + ...specialization-constant-workgroup.asm.comp | 21 + .../asm/comp/storage-buffer-basic.asm.comp | 22 + .../asm/frag/default-member-names.asm.frag | 40 + .../inliner-dominator-inside-loop.asm.frag | 235 + .../asm/frag/op-constant-null.asm.frag | 28 + .../asm/frag/phi-loop-variable.asm.frag | 12 + .../asm/frag/undef-variable-store.asm.frag | 37 + .../shaders-msl/asm/frag/unreachable.asm.frag | 40 + .../asm/frag/vector-shuffle-oom.asm.frag | 321 + .../asm/vert/empty-struct-composite.asm.vert | 9 + reference/shaders-msl/comp/atomic.comp | 36 + reference/shaders-msl/comp/bake_gradient.comp | 40 + reference/shaders-msl/comp/barriers.comp | 67 + reference/shaders-msl/comp/basic.comp | 34 + .../shaders-msl/comp/bitfield.noopt.comp | 47 + reference/shaders-msl/comp/builtins.comp | 17 + .../comp/cfg-preserve-parameter.comp | 78 + .../shaders-msl/comp/coherent-block.comp | 15 + .../shaders-msl/comp/coherent-image.comp | 15 + reference/shaders-msl/comp/culling.comp | 36 + reference/shaders-msl/comp/defer-parens.comp | 23 + reference/shaders-msl/comp/dowhile.comp | 29 + reference/shaders-msl/comp/functions.comp | 18 + ...vocation-id-writable-ssbo-in-function.comp | 31 + .../comp/global-invocation-id.comp | 26 + reference/shaders-msl/comp/image.comp | 11 + reference/shaders-msl/comp/insert.comp | 21 + .../shaders-msl/comp/local-invocation-id.comp | 26 + .../comp/local-invocation-index.comp | 26 + reference/shaders-msl/comp/loop.noopt.comp | 107 + reference/shaders-msl/comp/mat3.comp | 16 + reference/shaders-msl/comp/mod.comp | 35 + reference/shaders-msl/comp/modf.comp | 24 + .../shaders-msl/comp/read-write-only.comp | 29 + reference/shaders-msl/comp/return.comp | 36 + reference/shaders-msl/comp/rmw-opt.comp | 29 + .../comp/shared-array-of-arrays.comp | 32 + reference/shaders-msl/comp/shared.comp | 27 + reference/shaders-msl/comp/struct-layout.comp | 26 + .../shaders-msl/comp/struct-packing.comp | 100 + reference/shaders-msl/comp/torture-loop.comp | 51 + reference/shaders-msl/comp/type-alias.comp | 53 + reference/shaders-msl/comp/udiv.comp | 20 + reference/shaders-msl/comp/writable-ssbo.comp | 26 + .../desktop-only/frag/image-ms.desktop.frag | 13 + .../frag/query-levels.desktop.frag | 17 + .../frag/sampler-ms-query.desktop.frag | 17 + .../desktop-only/vert/basic.desktop.sso.vert | 30 + .../vert/clip-cull-distance.desktop.vert | 23 + .../shaders-msl/flatten/basic.flatten.vert | 30 + .../flatten/multiindex.flatten.vert | 27 + .../flatten/push-constant.flatten.vert | 32 + .../shaders-msl/flatten/rowmajor.flatten.vert | 38 + .../shaders-msl/flatten/struct.flatten.vert | 40 + .../shaders-msl/flatten/swizzle.flatten.vert | 47 + .../shaders-msl/flatten/types.flatten.frag | 35 + reference/shaders-msl/frag/basic.frag | 23 + reference/shaders-msl/frag/bitcasting.frag | 30 + reference/shaders-msl/frag/builtins.frag | 24 + .../composite-extract-forced-temporary.frag | 23 + .../shaders-msl/frag/constant-array.frag | 40 + .../shaders-msl/frag/constant-composites.frag | 31 + .../shaders-msl/frag/false-loop-init.frag | 35 + reference/shaders-msl/frag/flush_params.frag | 38 + reference/shaders-msl/frag/for-loop-init.frag | 58 + reference/shaders-msl/frag/in_block.frag | 23 + .../frag/in_block_assign.noopt.frag | 30 + reference/shaders-msl/frag/mix.frag | 31 + reference/shaders-msl/frag/pls.frag | 31 + reference/shaders-msl/frag/sampler-ms.frag | 18 + reference/shaders-msl/frag/sampler.frag | 31 + .../frag/separate-image-sampler-argument.frag | 24 + reference/shaders-msl/frag/swizzle.frag | 28 + .../shaders-msl/frag/texture-proj-shadow.frag | 29 + reference/shaders-msl/frag/ubo_layout.frag | 32 + reference/shaders-msl/frag/unary-enclose.frag | 26 + .../legacy/vert/transpose.legacy.vert | 33 + reference/shaders-msl/vert/basic.vert | 30 + reference/shaders-msl/vert/copy.flatten.vert | 47 + .../shaders-msl/vert/dynamic.flatten.vert | 43 + reference/shaders-msl/vert/functions.vert | 119 + reference/shaders-msl/vert/out_block.vert | 32 + reference/shaders-msl/vert/pointsize.vert | 33 + .../shaders-msl/vert/texture_buffer.vert | 17 + reference/shaders-msl/vert/ubo.alignment.vert | 38 + reference/shaders-msl/vert/ubo.vert | 30 + .../vulkan/frag/push-constant.vk.frag | 28 + .../vulkan/frag/spec-constant.vk.frag | 74 + .../vulkan/vert/vulkan-vertex.vk.vert | 17 + ...etch_subpassInput.vk.nocompat.invalid.frag | 11 + ...h_subpassInput.vk.nocompat.invalid.frag.vk | 11 + reference/shaders/amd/fs.invalid.frag | 15 + reference/shaders/amd/gcn_shader.comp | 12 + reference/shaders/amd/shader_ballot.comp | 32 + ...ballot_nonuniform_invocations.invalid.comp | 11 + reference/shaders/amd/shader_group_vote.comp | 18 + .../shaders/amd/shader_trinary_minmax.comp | 11 + .../shaders/asm/comp/bitcast_iadd.asm.comp | 27 + .../shaders/asm/comp/bitcast_iequal.asm.comp | 31 + .../shaders/asm/comp/bitcast_sar.asm.comp | 27 + .../shaders/asm/comp/bitcast_sdiv.asm.comp | 27 + .../shaders/asm/comp/bitcast_slr.asm.comp | 27 + reference/shaders/asm/comp/logical.asm.comp | 56 + .../shaders/asm/comp/multiple-entry.asm.comp | 27 + .../asm/comp/name-alias.asm.invalid.comp | 37 + reference/shaders/asm/comp/quantize.asm.comp | 19 + ...specialization-constant-workgroup.asm.comp | 13 + .../asm/comp/storage-buffer-basic.asm.comp | 20 + ...osite-construct-struct-no-swizzle.asm.frag | 19 + .../asm/frag/default-member-names.asm.frag | 32 + .../hlsl-sample-cmp-level-zero-cube.asm.frag | 17 + .../frag/hlsl-sample-cmp-level-zero.asm.frag | 27 + .../inliner-dominator-inside-loop.asm.frag | 227 + .../shaders/asm/frag/invalidation.asm.frag | 15 + ...op-body-dominator-continue-access.asm.frag | 48 + .../asm/frag/loop-header-to-continue.asm.frag | 39 + .../asm/frag/multi-for-loop-init.asm.frag | 19 + .../asm/frag/op-constant-null.asm.frag | 22 + .../asm/frag/phi-loop-variable.asm.frag | 9 + .../sampler-buffer-without-sampler.asm.frag | 20 + .../struct-composite-extract-swizzle.asm.frag | 21 + .../asm/frag/temporary-phi-hoisting.asm.frag | 26 + .../asm/frag/undef-variable-store.asm.frag | 29 + .../shaders/asm/frag/unreachable.asm.frag | 28 + .../asm/frag/vector-shuffle-oom.asm.frag | 316 + ...s-fixed-input-array-builtin-array.asm.tesc | 79 + reference/shaders/asm/vert/empty-io.asm.vert | 29 + .../asm/vert/empty-struct-composite.asm.vert | 6 + .../asm/vert/global-builtin.sso.asm.vert | 35 + reference/shaders/comp/atomic.comp | 49 + reference/shaders/comp/bake_gradient.comp | 39 + reference/shaders/comp/barriers.comp | 83 + reference/shaders/comp/basic.comp | 29 + reference/shaders/comp/bitfield.noopt.comp | 19 + reference/shaders/comp/casts.comp | 19 + .../shaders/comp/cfg-preserve-parameter.comp | 74 + reference/shaders/comp/cfg.comp | 81 + reference/shaders/comp/coherent-block.comp | 13 + reference/shaders/comp/coherent-image.comp | 15 + .../shaders/comp/composite-construct.comp | 38 + reference/shaders/comp/culling.comp | 29 + reference/shaders/comp/defer-parens.comp | 21 + reference/shaders/comp/dowhile.comp | 29 + reference/shaders/comp/generate_height.comp | 96 + reference/shaders/comp/image.comp | 12 + .../shaders/comp/inout-struct.invalid.comp | 65 + reference/shaders/comp/insert.comp | 19 + reference/shaders/comp/loop.noopt.comp | 105 + reference/shaders/comp/mat3.comp | 14 + reference/shaders/comp/mod.comp | 24 + reference/shaders/comp/modf.comp | 22 + reference/shaders/comp/read-write-only.comp | 27 + reference/shaders/comp/return.comp | 34 + reference/shaders/comp/rmw-opt.comp | 27 + reference/shaders/comp/shared.comp | 25 + reference/shaders/comp/ssbo-array.comp | 14 + reference/shaders/comp/struct-layout.comp | 24 + reference/shaders/comp/struct-packing.comp | 104 + reference/shaders/comp/torture-loop.comp | 49 + reference/shaders/comp/type-alias.comp | 49 + reference/shaders/comp/udiv.comp | 18 + .../desktop-only/comp/enhanced-layouts.comp | 40 + .../desktop-only/comp/fp64.desktop.comp | 84 + .../image-formats.desktop.noeliminate.comp | 47 + .../desktop-only/comp/int64.desktop.comp | 52 + .../frag/hlsl-uav-block-alias.asm.frag | 24 + .../desktop-only/frag/image-ms.desktop.frag | 13 + .../frag/image-query.desktop.frag | 53 + .../frag/in-block-qualifiers.frag | 21 + .../frag/query-levels.desktop.frag | 11 + .../desktop-only/frag/query-lod.desktop.frag | 12 + .../frag/sampler-ms-query.desktop.frag | 14 + .../frag/texture-proj-shadow.desktop.frag | 26 + .../desktop-only/geom/basic.desktop.sso.geom | 35 + .../geom/viewport-index.desktop.geom | 9 + .../desktop-only/tesc/basic.desktop.sso.tesc | 27 + .../tese/triangle.desktop.sso.tese | 18 + .../desktop-only/vert/basic.desktop.sso.vert | 22 + .../vert/clip-cull-distance.desktop.vert | 11 + .../vert/out-block-qualifiers.vert | 27 + reference/shaders/flatten/array.flatten.vert | 12 + reference/shaders/flatten/basic.flatten.vert | 13 + reference/shaders/flatten/copy.flatten.vert | 29 + .../shaders/flatten/dynamic.flatten.vert | 25 + .../shaders/flatten/matrixindex.flatten.vert | 19 + ...multi-dimensional.desktop.flatten_dim.frag | 24 + .../shaders/flatten/multiindex.flatten.vert | 10 + .../flatten/push-constant.flatten.vert | 13 + .../shaders/flatten/rowmajor.flatten.vert | 11 + reference/shaders/flatten/struct.flatten.vert | 22 + .../flatten/struct.rowmajor.flatten.vert | 25 + .../shaders/flatten/swizzle.flatten.vert | 21 + reference/shaders/flatten/types.flatten.frag | 14 + reference/shaders/frag/basic.frag | 15 + .../composite-extract-forced-temporary.frag | 15 + reference/shaders/frag/constant-array.frag | 28 + .../shaders/frag/constant-composites.frag | 23 + reference/shaders/frag/false-loop-init.frag | 25 + reference/shaders/frag/flush_params.frag | 30 + reference/shaders/frag/for-loop-init.frag | 52 + reference/shaders/frag/frexp-modf.frag | 43 + reference/shaders/frag/ground.frag | 62 + .../frag/image-load-store-uint-coord.asm.frag | 26 + reference/shaders/frag/mix.frag | 20 + .../shaders/frag/partial-write-preserve.frag | 109 + reference/shaders/frag/pls.frag | 21 + reference/shaders/frag/sample-parameter.frag | 13 + reference/shaders/frag/sampler-ms.frag | 14 + reference/shaders/frag/sampler-proj.frag | 16 + reference/shaders/frag/sampler.frag | 21 + reference/shaders/frag/swizzle.frag | 20 + reference/shaders/frag/ubo_layout.frag | 26 + reference/shaders/frag/unary-enclose.frag | 16 + reference/shaders/geom/basic.geom | 26 + reference/shaders/geom/lines-adjacency.geom | 26 + reference/shaders/geom/lines.geom | 23 + reference/shaders/geom/points.geom | 26 + reference/shaders/geom/single-invocation.geom | 26 + .../shaders/geom/triangles-adjacency.geom | 26 + reference/shaders/geom/triangles.geom | 26 + .../legacy/fragment/explicit-lod.legacy.frag | 12 + .../legacy/fragment/io-blocks.legacy.frag | 12 + .../fragment/struct-varying.legacy.frag | 22 + .../legacy/vert/implicit-lod.legacy.vert | 9 + .../shaders/legacy/vert/io-block.legacy.vert | 13 + .../legacy/vert/struct-varying.legacy.vert | 32 + .../shaders/legacy/vert/transpose.legacy.vert | 22 + reference/shaders/tesc/basic.tesc | 17 + reference/shaders/tesc/water_tess.tesc | 117 + reference/shaders/tese/ccw.tese | 9 + reference/shaders/tese/cw.tese | 9 + reference/shaders/tese/equal.tese | 9 + reference/shaders/tese/fractional_even.tese | 9 + reference/shaders/tese/fractional_odd.tese | 9 + reference/shaders/tese/line.tese | 9 + reference/shaders/tese/triangle.tese | 9 + reference/shaders/tese/water_tess.tese | 61 + reference/shaders/vert/basic.vert | 17 + reference/shaders/vert/ground.vert | 110 + reference/shaders/vert/ocean.vert | 133 + reference/shaders/vert/texture_buffer.vert | 11 + reference/shaders/vert/ubo.vert | 17 + .../combined-texture-sampler-shadow.vk.frag | 31 + ...combined-texture-sampler-shadow.vk.frag.vk | 32 + .../frag/combined-texture-sampler.vk.frag | 48 + .../frag/combined-texture-sampler.vk.frag.vk | 48 + .../vulkan/frag/desktop-mediump.vk.frag | 12 + .../vulkan/frag/desktop-mediump.vk.frag.vk | 12 + .../vulkan/frag/input-attachment-ms.vk.frag | 12 + .../frag/input-attachment-ms.vk.frag.vk | 12 + .../vulkan/frag/input-attachment.vk.frag | 14 + .../vulkan/frag/input-attachment.vk.frag.vk | 14 + .../shaders/vulkan/frag/push-constant.frag.vk | 18 + .../shaders/vulkan/frag/push-constant.vk.frag | 20 + .../vulkan/frag/push-constant.vk.frag.vk | 18 + .../frag/separate-sampler-texture.vk.frag | 37 + .../frag/separate-sampler-texture.vk.frag.vk | 38 + .../shaders/vulkan/frag/spec-constant.vk.frag | 59 + .../vulkan/frag/spec-constant.vk.frag.vk | 68 + .../vulkan/vert/multiview.nocompat.vk.vert | 15 + .../vulkan/vert/multiview.nocompat.vk.vert.vk | 15 + .../shaders/vulkan/vert/vulkan-vertex.vert | 9 + .../shaders/vulkan/vert/vulkan-vertex.vert.vk | 7 + .../shaders/vulkan/vert/vulkan-vertex.vk.vert | 9 + .../vulkan/vert/vulkan-vertex.vk.vert.vk | 7 + samples/cpp/Makefile | 28 + samples/cpp/atomics.comp | 29 + samples/cpp/atomics.cpp | 90 + samples/cpp/multiply.comp | 22 + samples/cpp/multiply.cpp | 91 + samples/cpp/shared.comp | 36 + samples/cpp/shared.cpp | 89 + ...lization-constant-workgroup.nofxc.asm.comp | 47 + .../comp/storage-buffer-basic.nofxc.asm.comp | 57 + .../asm/frag/cbuffer-stripped.asm.frag | 55 + shaders-hlsl/asm/frag/unreachable.asm.frag | 61 + .../asm/vert/empty-struct-composite.asm.vert | 37 + .../asm/vert/vertex-id-instance-id.asm.vert | 53 + shaders-hlsl/comp/access-chains.comp | 24 + shaders-hlsl/comp/address-buffers.comp | 23 + shaders-hlsl/comp/atomic.comp | 66 + shaders-hlsl/comp/barriers.comp | 79 + shaders-hlsl/comp/bitfield.noopt.comp | 44 + shaders-hlsl/comp/builtins.comp | 11 + shaders-hlsl/comp/image.comp | 77 + shaders-hlsl/comp/rwbuffer-matrix.comp | 104 + shaders-hlsl/comp/shared.comp | 27 + shaders-hlsl/comp/ssbo-array.comp | 29 + shaders-hlsl/frag/basic.frag | 13 + shaders-hlsl/frag/bit-conversions.frag | 12 + shaders-hlsl/frag/boolean-mix.frag | 10 + shaders-hlsl/frag/builtins.frag | 11 + shaders-hlsl/frag/bvec-operations.frag | 13 + .../combined-texture-sampler-parameter.frag | 31 + .../frag/combined-texture-sampler-shadow.frag | 29 + .../frag/constant-buffer-array.sm51.frag | 32 + shaders-hlsl/frag/constant-composites.frag | 20 + shaders-hlsl/frag/early-fragment-test.frag | 7 + shaders-hlsl/frag/fp16-packing.frag | 12 + shaders-hlsl/frag/image-query-selective.frag | 35 + shaders-hlsl/frag/image-query.frag | 33 + shaders-hlsl/frag/io-block.frag | 16 + shaders-hlsl/frag/matrix-input.frag | 9 + shaders-hlsl/frag/mod.frag | 22 + shaders-hlsl/frag/mrt.frag | 15 + shaders-hlsl/frag/no-return.frag | 5 + shaders-hlsl/frag/no-return2.frag | 9 + shaders-hlsl/frag/partial-write-preserve.frag | 64 + shaders-hlsl/frag/query-lod.desktop.frag | 10 + shaders-hlsl/frag/resources.frag | 27 + shaders-hlsl/frag/sample-cmp-level-zero.frag | 27 + shaders-hlsl/frag/sampler-array.frag | 28 + shaders-hlsl/frag/spec-constant.frag | 80 + shaders-hlsl/frag/swizzle-scalar.frag | 16 + shaders-hlsl/frag/tex-sampling.frag | 81 + shaders-hlsl/frag/texture-proj-shadow.frag | 21 + .../texture-size-combined-image-sampler.frag | 9 + shaders-hlsl/frag/unary-enclose.frag | 15 + shaders-hlsl/frag/unorm-snorm-packing.frag | 24 + shaders-hlsl/frag/various-glsl-ops.frag | 17 + shaders-hlsl/vert/basic.vert | 15 + shaders-hlsl/vert/instancing.vert | 6 + shaders-hlsl/vert/locations.vert | 51 + shaders-hlsl/vert/matrix-attribute.vert | 9 + shaders-hlsl/vert/matrix-output.vert | 9 + shaders-hlsl/vert/no-input.vert | 6 + shaders-hlsl/vert/point-size-compat.vert | 8 + shaders-hlsl/vert/qualifiers.vert | 27 + shaders-hlsl/vert/sampler-buffers.vert | 17 + shaders-hlsl/vert/struct-composite-decl.vert | 26 + shaders-hlsl/vert/texture_buffer.vert | 9 + shaders-msl-no-opt/vert/functions_nested.vert | 132 + shaders-msl/asm/comp/bitcast_iadd.asm.comp | 79 + shaders-msl/asm/comp/bitcast_sar.asm.comp | 77 + shaders-msl/asm/comp/bitcast_sdiv.asm.comp | 77 + shaders-msl/asm/comp/bitcast_slr.asm.comp | 77 + shaders-msl/asm/comp/multiple-entry.asm.comp | 97 + shaders-msl/asm/comp/quantize.asm.comp | 67 + ...specialization-constant-workgroup.asm.comp | 47 + .../asm/comp/storage-buffer-basic.asm.comp | 58 + .../asm/frag/default-member-names.asm.frag | 57 + .../inliner-dominator-inside-loop.asm.frag | 646 ++ .../asm/frag/op-constant-null.asm.frag | 85 + .../asm/frag/phi-loop-variable.asm.frag | 71 + .../asm/frag/undef-variable-store.asm.frag | 85 + shaders-msl/asm/frag/unreachable.asm.frag | 61 + .../asm/frag/vector-shuffle-oom.asm.frag | 886 ++ .../asm/vert/empty-struct-composite.asm.vert | 37 + shaders-msl/comp/atomic.comp | 33 + shaders-msl/comp/barriers.comp | 83 + shaders-msl/comp/basic.comp | 28 + shaders-msl/comp/bitfield.noopt.comp | 23 + shaders-msl/comp/builtins.comp | 12 + shaders-msl/comp/cfg-preserve-parameter.comp | 54 + shaders-msl/comp/coherent-block.comp | 12 + shaders-msl/comp/coherent-image.comp | 14 + shaders-msl/comp/culling.comp | 26 + shaders-msl/comp/defer-parens.comp | 30 + shaders-msl/comp/dowhile.comp | 31 + shaders-msl/comp/functions.comp | 12 + ...vocation-id-writable-ssbo-in-function.comp | 12 + shaders-msl/comp/global-invocation-id.comp | 9 + shaders-msl/comp/image.comp | 12 + shaders-msl/comp/insert.comp | 18 + shaders-msl/comp/local-invocation-id.comp | 9 + shaders-msl/comp/local-invocation-index.comp | 9 + shaders-msl/comp/loop.noopt.comp | 98 + shaders-msl/comp/mat3.comp | 14 + shaders-msl/comp/mod.comp | 26 + shaders-msl/comp/modf.comp | 23 + shaders-msl/comp/read-write-only.comp | 26 + shaders-msl/comp/return.comp | 33 + shaders-msl/comp/rmw-opt.comp | 27 + shaders-msl/comp/shared-array-of-arrays.comp | 29 + shaders-msl/comp/shared.comp | 27 + shaders-msl/comp/struct-layout.comp | 24 + shaders-msl/comp/struct-packing.comp | 76 + shaders-msl/comp/torture-loop.comp | 40 + shaders-msl/comp/type-alias.comp | 45 + shaders-msl/comp/udiv.comp | 17 + shaders-msl/comp/writable-ssbo.comp | 9 + .../desktop-only/frag/image-ms.desktop.frag | 13 + .../frag/query-levels.desktop.frag | 11 + .../frag/sampler-ms-query.desktop.frag | 14 + .../desktop-only/vert/basic.desktop.sso.vert | 20 + .../vert/clip-cull-distance.desktop.vert | 10 + shaders-msl/flatten/basic.flatten.vert | 16 + shaders-msl/flatten/multiindex.flatten.vert | 13 + .../flatten/push-constant.flatten.vert | 17 + shaders-msl/flatten/rowmajor.flatten.vert | 16 + shaders-msl/flatten/struct.flatten.vert | 30 + shaders-msl/flatten/swizzle.flatten.vert | 47 + shaders-msl/flatten/types.flatten.frag | 27 + shaders-msl/frag/basic.frag | 13 + shaders-msl/frag/bitcasting.frag | 24 + shaders-msl/frag/builtins.frag | 11 + .../composite-extract-forced-temporary.frag | 11 + shaders-msl/frag/constant-array.frag | 21 + shaders-msl/frag/constant-composites.frag | 20 + shaders-msl/frag/false-loop-init.frag | 19 + shaders-msl/frag/flush_params.frag | 27 + shaders-msl/frag/for-loop-init.frag | 52 + shaders-msl/frag/in_block.frag | 14 + shaders-msl/frag/in_block_assign.noopt.frag | 16 + shaders-msl/frag/mix.frag | 20 + shaders-msl/frag/pls.frag | 20 + shaders-msl/frag/sampler-ms.frag | 16 + shaders-msl/frag/sampler.frag | 18 + .../frag/separate-image-sampler-argument.frag | 16 + shaders-msl/frag/swizzle.frag | 17 + shaders-msl/frag/texture-proj-shadow.frag | 19 + shaders-msl/frag/ubo_layout.frag | 24 + shaders-msl/frag/unary-enclose.frag | 15 + shaders-msl/legacy/vert/transpose.legacy.vert | 20 + shaders-msl/vert/basic.vert | 17 + shaders-msl/vert/copy.flatten.vert | 34 + shaders-msl/vert/dynamic.flatten.vert | 33 + shaders-msl/vert/functions.vert | 28 + shaders-msl/vert/out_block.vert | 22 + shaders-msl/vert/pointsize.vert | 15 + shaders-msl/vert/texture_buffer.vert | 10 + shaders-msl/vert/ubo.alignment.vert | 23 + shaders-msl/vert/ubo.vert | 16 + shaders-msl/vulkan/frag/push-constant.vk.frag | 16 + shaders-msl/vulkan/frag/spec-constant.vk.frag | 67 + shaders-msl/vulkan/vert/vulkan-vertex.vk.vert | 6 + ...etch_subpassInput.vk.nocompat.invalid.frag | 10 + shaders/amd/fs.invalid.frag | 14 + shaders/amd/gcn_shader.comp | 13 + shaders/amd/shader_ballot.comp | 33 + ...ballot_nonuniform_invocations.invalid.comp | 9 + shaders/amd/shader_group_vote.comp | 18 + shaders/amd/shader_trinary_minmax.comp | 11 + shaders/asm/comp/bitcast_iadd.asm.comp | 79 + shaders/asm/comp/bitcast_iequal.asm.comp | 90 + shaders/asm/comp/bitcast_sar.asm.comp | 77 + shaders/asm/comp/bitcast_sdiv.asm.comp | 77 + shaders/asm/comp/bitcast_slr.asm.comp | 77 + shaders/asm/comp/logical.asm.comp | 191 + shaders/asm/comp/multiple-entry.asm.comp | 97 + shaders/asm/comp/name-alias.asm.invalid.comp | 124 + shaders/asm/comp/quantize.asm.comp | 67 + ...specialization-constant-workgroup.asm.comp | 47 + .../asm/comp/storage-buffer-basic.asm.comp | 57 + ...osite-construct-struct-no-swizzle.asm.frag | 51 + .../asm/frag/default-member-names.asm.frag | 57 + .../hlsl-sample-cmp-level-zero-cube.asm.frag | 58 + .../frag/hlsl-sample-cmp-level-zero.asm.frag | 113 + .../inliner-dominator-inside-loop.asm.frag | 646 ++ shaders/asm/frag/invalidation.asm.frag | 46 + ...op-body-dominator-continue-access.asm.frag | 190 + .../asm/frag/loop-header-to-continue.asm.frag | 132 + shaders/asm/frag/multi-for-loop-init.asm.frag | 111 + shaders/asm/frag/op-constant-null.asm.frag | 85 + shaders/asm/frag/phi-loop-variable.asm.frag | 71 + .../sampler-buffer-without-sampler.asm.frag | 59 + .../struct-composite-extract-swizzle.asm.frag | 55 + .../asm/frag/temporary-phi-hoisting.asm.frag | 75 + .../asm/frag/undef-variable-store.asm.frag | 85 + shaders/asm/frag/unreachable.asm.frag | 61 + shaders/asm/frag/vector-shuffle-oom.asm.frag | 886 ++ ...s-fixed-input-array-builtin-array.asm.tesc | 248 + shaders/asm/vert/empty-io.asm.vert | 70 + .../asm/vert/empty-struct-composite.asm.vert | 37 + shaders/asm/vert/global-builtin.sso.asm.vert | 68 + shaders/comp/atomic.comp | 56 + shaders/comp/bake_gradient.comp | 55 + shaders/comp/barriers.comp | 79 + shaders/comp/basic.comp | 28 + shaders/comp/bitfield.noopt.comp | 21 + shaders/comp/casts.comp | 18 + shaders/comp/cfg-preserve-parameter.comp | 54 + shaders/comp/cfg.comp | 91 + shaders/comp/coherent-block.comp | 12 + shaders/comp/coherent-image.comp | 14 + shaders/comp/composite-construct.comp | 40 + shaders/comp/culling.comp | 26 + shaders/comp/defer-parens.comp | 30 + shaders/comp/dowhile.comp | 31 + shaders/comp/generate_height.comp | 97 + shaders/comp/image.comp | 12 + shaders/comp/inout-struct.invalid.comp | 55 + shaders/comp/insert.comp | 18 + shaders/comp/loop.noopt.comp | 98 + shaders/comp/mat3.comp | 14 + shaders/comp/mod.comp | 26 + shaders/comp/modf.comp | 23 + shaders/comp/read-write-only.comp | 26 + shaders/comp/return.comp | 33 + shaders/comp/rmw-opt.comp | 27 + shaders/comp/shared.comp | 27 + shaders/comp/ssbo-array.comp | 14 + shaders/comp/struct-layout.comp | 24 + shaders/comp/struct-packing.comp | 86 + shaders/comp/torture-loop.comp | 40 + shaders/comp/type-alias.comp | 45 + shaders/comp/udiv.comp | 17 + .../desktop-only/comp/enhanced-layouts.comp | 39 + shaders/desktop-only/comp/fp64.desktop.comp | 91 + .../image-formats.desktop.noeliminate.comp | 48 + shaders/desktop-only/comp/int64.desktop.comp | 55 + .../frag/hlsl-uav-block-alias.asm.frag | 56 + .../desktop-only/frag/image-ms.desktop.frag | 12 + .../frag/image-query.desktop.frag | 56 + .../frag/in-block-qualifiers.frag | 20 + .../frag/query-levels.desktop.frag | 9 + .../desktop-only/frag/query-lod.desktop.frag | 10 + .../frag/sampler-ms-query.desktop.frag | 17 + .../frag/texture-proj-shadow.desktop.frag | 21 + .../desktop-only/geom/basic.desktop.sso.geom | 37 + .../geom/viewport-index.desktop.geom | 11 + .../desktop-only/tesc/basic.desktop.sso.tesc | 28 + .../tese/triangle.desktop.sso.tese | 22 + .../desktop-only/vert/basic.desktop.sso.vert | 20 + .../vert/clip-cull-distance.desktop.vert | 10 + .../vert/out-block-qualifiers.vert | 26 + shaders/flatten/array.flatten.vert | 19 + shaders/flatten/basic.flatten.vert | 16 + shaders/flatten/copy.flatten.vert | 34 + shaders/flatten/dynamic.flatten.vert | 33 + shaders/flatten/matrixindex.flatten.vert | 25 + ...multi-dimensional.desktop.flatten_dim.frag | 18 + shaders/flatten/multiindex.flatten.vert | 13 + shaders/flatten/push-constant.flatten.vert | 17 + shaders/flatten/rowmajor.flatten.vert | 16 + shaders/flatten/struct.flatten.vert | 30 + shaders/flatten/struct.rowmajor.flatten.vert | 26 + shaders/flatten/swizzle.flatten.vert | 47 + shaders/flatten/types.flatten.frag | 27 + shaders/frag/basic.frag | 13 + .../composite-extract-forced-temporary.frag | 11 + shaders/frag/constant-array.frag | 21 + shaders/frag/constant-composites.frag | 20 + shaders/frag/false-loop-init.frag | 19 + shaders/frag/flush_params.frag | 27 + shaders/frag/for-loop-init.frag | 52 + shaders/frag/frexp-modf.frag | 24 + shaders/frag/ground.frag | 162 + .../frag/image-load-store-uint-coord.asm.frag | 103 + shaders/frag/mix.frag | 20 + shaders/frag/partial-write-preserve.frag | 95 + shaders/frag/pls.frag | 20 + shaders/frag/sample-parameter.frag | 11 + shaders/frag/sampler-ms.frag | 16 + shaders/frag/sampler-proj.frag | 12 + shaders/frag/sampler.frag | 18 + shaders/frag/swizzle.frag | 17 + shaders/frag/ubo_layout.frag | 24 + shaders/frag/unary-enclose.frag | 15 + shaders/geom/basic.geom | 28 + shaders/geom/lines-adjacency.geom | 28 + shaders/geom/lines.geom | 24 + shaders/geom/points.geom | 28 + shaders/geom/single-invocation.geom | 28 + shaders/geom/triangles-adjacency.geom | 28 + shaders/geom/triangles.geom | 28 + .../legacy/fragment/explicit-lod.legacy.frag | 12 + shaders/legacy/fragment/io-blocks.legacy.frag | 16 + .../fragment/struct-varying.legacy.frag | 25 + shaders/legacy/vert/implicit-lod.legacy.vert | 8 + shaders/legacy/vert/io-block.legacy.vert | 17 + .../legacy/vert/struct-varying.legacy.vert | 33 + shaders/legacy/vert/transpose.legacy.vert | 20 + shaders/tesc/basic.tesc | 17 + shaders/tesc/water_tess.tesc | 115 + shaders/tese/ccw.tese | 10 + shaders/tese/cw.tese | 10 + shaders/tese/equal.tese | 10 + shaders/tese/fractional_even.tese | 10 + shaders/tese/fractional_odd.tese | 10 + shaders/tese/line.tese | 10 + shaders/tese/triangle.tese | 10 + shaders/tese/water_tess.tese | 65 + shaders/vert/basic.vert | 16 + shaders/vert/ground.vert | 202 + shaders/vert/ocean.vert | 200 + shaders/vert/texture_buffer.vert | 10 + shaders/vert/ubo.vert | 16 + .../combined-texture-sampler-shadow.vk.frag | 29 + .../frag/combined-texture-sampler.vk.frag | 47 + shaders/vulkan/frag/desktop-mediump.vk.frag | 11 + .../vulkan/frag/input-attachment-ms.vk.frag | 10 + shaders/vulkan/frag/input-attachment.vk.frag | 11 + shaders/vulkan/frag/push-constant.vk.frag | 16 + .../frag/separate-sampler-texture.vk.frag | 36 + shaders/vulkan/frag/spec-constant.vk.frag | 77 + .../vulkan/vert/multiview.nocompat.vk.vert | 14 + shaders/vulkan/vert/vulkan-vertex.vk.vert | 6 + spirv.hpp | 968 ++ spirv_cfg.cpp | 229 + spirv_cfg.hpp | 119 + spirv_common.hpp | 1026 ++ spirv_cpp.cpp | 522 + spirv_cpp.hpp | 77 + spirv_cross.cpp | 3957 ++++++++ spirv_cross.hpp | 753 ++ spirv_glsl.cpp | 8574 +++++++++++++++++ spirv_glsl.hpp | 535 + spirv_hlsl.cpp | 3712 +++++++ spirv_hlsl.hpp | 165 + spirv_msl.cpp | 3641 +++++++ spirv_msl.hpp | 331 + test_shaders.py | 451 + test_shaders.sh | 17 + update_test_shaders.sh | 17 + 1023 files changed, 65745 insertions(+) create mode 100755 .clang-format create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 CMakeLists.txt create mode 100644 GLSL.std.450.h create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 README.md create mode 100755 checkout_glslang_spirv_tools.sh create mode 100755 format_all.sh create mode 100644 include/spirv_cross/barrier.hpp create mode 100644 include/spirv_cross/external_interface.h create mode 100644 include/spirv_cross/image.hpp create mode 100644 include/spirv_cross/internal_interface.hpp create mode 100644 include/spirv_cross/sampler.hpp create mode 100644 include/spirv_cross/thread_group.hpp create mode 100644 jni/Android.mk create mode 100644 jni/Application.mk create mode 100644 main.cpp create mode 100644 msvc/SPIRV-Cross.sln create mode 100644 msvc/SPIRV-Cross.vcxproj create mode 100644 msvc/SPIRV-Cross.vcxproj.filters create mode 100644 reference/opt/shaders-hlsl/asm/comp/specialization-constant-workgroup.nofxc.asm.comp create mode 100644 reference/opt/shaders-hlsl/asm/comp/storage-buffer-basic.nofxc.asm.comp create mode 100644 reference/opt/shaders-hlsl/asm/frag/cbuffer-stripped.asm.frag create mode 100644 reference/opt/shaders-hlsl/asm/frag/unreachable.asm.frag create mode 100644 reference/opt/shaders-hlsl/asm/vert/empty-struct-composite.asm.vert create mode 100644 reference/opt/shaders-hlsl/asm/vert/vertex-id-instance-id.asm.vert create mode 100644 reference/opt/shaders-hlsl/comp/access-chains.comp create mode 100644 reference/opt/shaders-hlsl/comp/address-buffers.comp create mode 100644 reference/opt/shaders-hlsl/comp/atomic.comp create mode 100644 reference/opt/shaders-hlsl/comp/barriers.comp create mode 100644 reference/opt/shaders-hlsl/comp/bitfield.noopt.comp create mode 100644 reference/opt/shaders-hlsl/comp/builtins.comp create mode 100644 reference/opt/shaders-hlsl/comp/image.comp create mode 100644 reference/opt/shaders-hlsl/comp/rwbuffer-matrix.comp create mode 100644 reference/opt/shaders-hlsl/comp/shared.comp create mode 100644 reference/opt/shaders-hlsl/comp/ssbo-array.comp create mode 100644 reference/opt/shaders-hlsl/frag/basic.frag create mode 100644 reference/opt/shaders-hlsl/frag/bit-conversions.frag create mode 100644 reference/opt/shaders-hlsl/frag/boolean-mix.frag create mode 100644 reference/opt/shaders-hlsl/frag/builtins.frag create mode 100644 reference/opt/shaders-hlsl/frag/bvec-operations.frag create mode 100644 reference/opt/shaders-hlsl/frag/combined-texture-sampler-parameter.frag create mode 100644 reference/opt/shaders-hlsl/frag/combined-texture-sampler-shadow.frag create mode 100644 reference/opt/shaders-hlsl/frag/constant-buffer-array.sm51.frag create mode 100644 reference/opt/shaders-hlsl/frag/constant-composites.frag create mode 100644 reference/opt/shaders-hlsl/frag/early-fragment-test.frag create mode 100644 reference/opt/shaders-hlsl/frag/fp16-packing.frag create mode 100644 reference/opt/shaders-hlsl/frag/image-query-selective.frag create mode 100644 reference/opt/shaders-hlsl/frag/image-query.frag create mode 100644 reference/opt/shaders-hlsl/frag/io-block.frag create mode 100644 reference/opt/shaders-hlsl/frag/matrix-input.frag create mode 100644 reference/opt/shaders-hlsl/frag/mod.frag create mode 100644 reference/opt/shaders-hlsl/frag/mrt.frag create mode 100644 reference/opt/shaders-hlsl/frag/no-return.frag create mode 100644 reference/opt/shaders-hlsl/frag/no-return2.frag create mode 100644 reference/opt/shaders-hlsl/frag/partial-write-preserve.frag create mode 100644 reference/opt/shaders-hlsl/frag/query-lod.desktop.frag create mode 100644 reference/opt/shaders-hlsl/frag/resources.frag create mode 100644 reference/opt/shaders-hlsl/frag/sample-cmp-level-zero.frag create mode 100644 reference/opt/shaders-hlsl/frag/sampler-array.frag create mode 100644 reference/opt/shaders-hlsl/frag/spec-constant.frag create mode 100644 reference/opt/shaders-hlsl/frag/swizzle-scalar.frag create mode 100644 reference/opt/shaders-hlsl/frag/tex-sampling.frag create mode 100644 reference/opt/shaders-hlsl/frag/texture-proj-shadow.frag create mode 100644 reference/opt/shaders-hlsl/frag/texture-size-combined-image-sampler.frag create mode 100644 reference/opt/shaders-hlsl/frag/unary-enclose.frag create mode 100644 reference/opt/shaders-hlsl/frag/unorm-snorm-packing.frag create mode 100644 reference/opt/shaders-hlsl/frag/various-glsl-ops.frag create mode 100644 reference/opt/shaders-hlsl/vert/basic.vert create mode 100644 reference/opt/shaders-hlsl/vert/instancing.vert create mode 100644 reference/opt/shaders-hlsl/vert/locations.vert create mode 100644 reference/opt/shaders-hlsl/vert/matrix-attribute.vert create mode 100644 reference/opt/shaders-hlsl/vert/matrix-output.vert create mode 100644 reference/opt/shaders-hlsl/vert/no-input.vert create mode 100644 reference/opt/shaders-hlsl/vert/point-size-compat.vert create mode 100644 reference/opt/shaders-hlsl/vert/qualifiers.vert create mode 100644 reference/opt/shaders-hlsl/vert/sampler-buffers.vert create mode 100644 reference/opt/shaders-hlsl/vert/struct-composite-decl.vert create mode 100644 reference/opt/shaders-hlsl/vert/texture_buffer.vert create mode 100644 reference/opt/shaders-msl/asm/comp/bitcast_iadd.asm.comp create mode 100644 reference/opt/shaders-msl/asm/comp/bitcast_sar.asm.comp create mode 100644 reference/opt/shaders-msl/asm/comp/bitcast_sdiv.asm.comp create mode 100644 reference/opt/shaders-msl/asm/comp/bitcast_slr.asm.comp create mode 100644 reference/opt/shaders-msl/asm/comp/multiple-entry.asm.comp create mode 100644 reference/opt/shaders-msl/asm/comp/quantize.asm.comp create mode 100644 reference/opt/shaders-msl/asm/comp/specialization-constant-workgroup.asm.comp create mode 100644 reference/opt/shaders-msl/asm/comp/storage-buffer-basic.asm.comp create mode 100644 reference/opt/shaders-msl/asm/frag/default-member-names.asm.frag create mode 100644 reference/opt/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag create mode 100644 reference/opt/shaders-msl/asm/frag/op-constant-null.asm.frag create mode 100644 reference/opt/shaders-msl/asm/frag/phi-loop-variable.asm.frag create mode 100644 reference/opt/shaders-msl/asm/frag/undef-variable-store.asm.frag create mode 100644 reference/opt/shaders-msl/asm/frag/unreachable.asm.frag create mode 100644 reference/opt/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag create mode 100644 reference/opt/shaders-msl/asm/vert/empty-struct-composite.asm.vert create mode 100644 reference/opt/shaders-msl/comp/atomic.comp create mode 100644 reference/opt/shaders-msl/comp/bake_gradient.comp create mode 100644 reference/opt/shaders-msl/comp/barriers.comp create mode 100644 reference/opt/shaders-msl/comp/basic.comp create mode 100644 reference/opt/shaders-msl/comp/bitfield.noopt.comp create mode 100644 reference/opt/shaders-msl/comp/builtins.comp create mode 100644 reference/opt/shaders-msl/comp/cfg-preserve-parameter.comp create mode 100644 reference/opt/shaders-msl/comp/coherent-block.comp create mode 100644 reference/opt/shaders-msl/comp/coherent-image.comp create mode 100644 reference/opt/shaders-msl/comp/culling.comp create mode 100644 reference/opt/shaders-msl/comp/defer-parens.comp create mode 100644 reference/opt/shaders-msl/comp/dowhile.comp create mode 100644 reference/opt/shaders-msl/comp/functions.comp create mode 100644 reference/opt/shaders-msl/comp/global-invocation-id-writable-ssbo-in-function.comp create mode 100644 reference/opt/shaders-msl/comp/global-invocation-id.comp create mode 100644 reference/opt/shaders-msl/comp/image.comp create mode 100644 reference/opt/shaders-msl/comp/insert.comp create mode 100644 reference/opt/shaders-msl/comp/local-invocation-id.comp create mode 100644 reference/opt/shaders-msl/comp/local-invocation-index.comp create mode 100644 reference/opt/shaders-msl/comp/loop.noopt.comp create mode 100644 reference/opt/shaders-msl/comp/mat3.comp create mode 100644 reference/opt/shaders-msl/comp/mod.comp create mode 100644 reference/opt/shaders-msl/comp/modf.comp create mode 100644 reference/opt/shaders-msl/comp/read-write-only.comp create mode 100644 reference/opt/shaders-msl/comp/return.comp create mode 100644 reference/opt/shaders-msl/comp/rmw-opt.comp create mode 100644 reference/opt/shaders-msl/comp/shared-array-of-arrays.comp create mode 100644 reference/opt/shaders-msl/comp/shared.comp create mode 100644 reference/opt/shaders-msl/comp/struct-layout.comp create mode 100644 reference/opt/shaders-msl/comp/struct-packing.comp create mode 100644 reference/opt/shaders-msl/comp/torture-loop.comp create mode 100644 reference/opt/shaders-msl/comp/type-alias.comp create mode 100644 reference/opt/shaders-msl/comp/udiv.comp create mode 100644 reference/opt/shaders-msl/comp/writable-ssbo.comp create mode 100644 reference/opt/shaders-msl/desktop-only/frag/image-ms.desktop.frag create mode 100644 reference/opt/shaders-msl/desktop-only/frag/query-levels.desktop.frag create mode 100644 reference/opt/shaders-msl/desktop-only/frag/sampler-ms-query.desktop.frag create mode 100644 reference/opt/shaders-msl/desktop-only/vert/basic.desktop.sso.vert create mode 100644 reference/opt/shaders-msl/desktop-only/vert/clip-cull-distance.desktop.vert create mode 100644 reference/opt/shaders-msl/flatten/basic.flatten.vert create mode 100644 reference/opt/shaders-msl/flatten/multiindex.flatten.vert create mode 100644 reference/opt/shaders-msl/flatten/push-constant.flatten.vert create mode 100644 reference/opt/shaders-msl/flatten/rowmajor.flatten.vert create mode 100644 reference/opt/shaders-msl/flatten/struct.flatten.vert create mode 100644 reference/opt/shaders-msl/flatten/swizzle.flatten.vert create mode 100644 reference/opt/shaders-msl/flatten/types.flatten.frag create mode 100644 reference/opt/shaders-msl/frag/basic.frag create mode 100644 reference/opt/shaders-msl/frag/bitcasting.frag create mode 100644 reference/opt/shaders-msl/frag/builtins.frag create mode 100644 reference/opt/shaders-msl/frag/composite-extract-forced-temporary.frag create mode 100644 reference/opt/shaders-msl/frag/constant-array.frag create mode 100644 reference/opt/shaders-msl/frag/constant-composites.frag create mode 100644 reference/opt/shaders-msl/frag/false-loop-init.frag create mode 100644 reference/opt/shaders-msl/frag/flush_params.frag create mode 100644 reference/opt/shaders-msl/frag/for-loop-init.frag create mode 100644 reference/opt/shaders-msl/frag/in_block.frag create mode 100644 reference/opt/shaders-msl/frag/in_block_assign.noopt.frag create mode 100644 reference/opt/shaders-msl/frag/mix.frag create mode 100644 reference/opt/shaders-msl/frag/pls.frag create mode 100644 reference/opt/shaders-msl/frag/sampler-ms.frag create mode 100644 reference/opt/shaders-msl/frag/sampler.frag create mode 100644 reference/opt/shaders-msl/frag/separate-image-sampler-argument.frag create mode 100644 reference/opt/shaders-msl/frag/swizzle.frag create mode 100644 reference/opt/shaders-msl/frag/texture-proj-shadow.frag create mode 100644 reference/opt/shaders-msl/frag/ubo_layout.frag create mode 100644 reference/opt/shaders-msl/frag/unary-enclose.frag create mode 100644 reference/opt/shaders-msl/legacy/vert/transpose.legacy.vert create mode 100644 reference/opt/shaders-msl/vert/basic.vert create mode 100644 reference/opt/shaders-msl/vert/copy.flatten.vert create mode 100644 reference/opt/shaders-msl/vert/dynamic.flatten.vert create mode 100644 reference/opt/shaders-msl/vert/functions.vert create mode 100644 reference/opt/shaders-msl/vert/out_block.vert create mode 100644 reference/opt/shaders-msl/vert/pointsize.vert create mode 100644 reference/opt/shaders-msl/vert/texture_buffer.vert create mode 100644 reference/opt/shaders-msl/vert/ubo.alignment.vert create mode 100644 reference/opt/shaders-msl/vert/ubo.vert create mode 100644 reference/opt/shaders-msl/vulkan/frag/push-constant.vk.frag create mode 100644 reference/opt/shaders-msl/vulkan/frag/spec-constant.vk.frag create mode 100644 reference/opt/shaders-msl/vulkan/vert/vulkan-vertex.vk.vert create mode 100644 reference/opt/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag create mode 100644 reference/opt/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag.vk create mode 100644 reference/opt/shaders/amd/fs.invalid.frag create mode 100644 reference/opt/shaders/amd/gcn_shader.comp create mode 100644 reference/opt/shaders/amd/shader_ballot.comp create mode 100644 reference/opt/shaders/amd/shader_ballot_nonuniform_invocations.invalid.comp create mode 100644 reference/opt/shaders/amd/shader_group_vote.comp create mode 100644 reference/opt/shaders/amd/shader_trinary_minmax.comp create mode 100644 reference/opt/shaders/asm/comp/bitcast_iadd.asm.comp create mode 100644 reference/opt/shaders/asm/comp/bitcast_iequal.asm.comp create mode 100644 reference/opt/shaders/asm/comp/bitcast_sar.asm.comp create mode 100644 reference/opt/shaders/asm/comp/bitcast_sdiv.asm.comp create mode 100644 reference/opt/shaders/asm/comp/bitcast_slr.asm.comp create mode 100644 reference/opt/shaders/asm/comp/logical.asm.comp create mode 100644 reference/opt/shaders/asm/comp/multiple-entry.asm.comp create mode 100644 reference/opt/shaders/asm/comp/name-alias.asm.invalid.comp create mode 100644 reference/opt/shaders/asm/comp/quantize.asm.comp create mode 100644 reference/opt/shaders/asm/comp/specialization-constant-workgroup.asm.comp create mode 100644 reference/opt/shaders/asm/comp/storage-buffer-basic.asm.comp create mode 100644 reference/opt/shaders/asm/frag/composite-construct-struct-no-swizzle.asm.frag create mode 100644 reference/opt/shaders/asm/frag/default-member-names.asm.frag create mode 100644 reference/opt/shaders/asm/frag/hlsl-sample-cmp-level-zero-cube.asm.frag create mode 100644 reference/opt/shaders/asm/frag/hlsl-sample-cmp-level-zero.asm.frag create mode 100644 reference/opt/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag create mode 100644 reference/opt/shaders/asm/frag/invalidation.asm.frag create mode 100644 reference/opt/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag create mode 100644 reference/opt/shaders/asm/frag/loop-header-to-continue.asm.frag create mode 100644 reference/opt/shaders/asm/frag/multi-for-loop-init.asm.frag create mode 100644 reference/opt/shaders/asm/frag/op-constant-null.asm.frag create mode 100644 reference/opt/shaders/asm/frag/phi-loop-variable.asm.frag create mode 100644 reference/opt/shaders/asm/frag/sampler-buffer-without-sampler.asm.frag create mode 100644 reference/opt/shaders/asm/frag/struct-composite-extract-swizzle.asm.frag create mode 100644 reference/opt/shaders/asm/frag/temporary-phi-hoisting.asm.frag create mode 100644 reference/opt/shaders/asm/frag/undef-variable-store.asm.frag create mode 100644 reference/opt/shaders/asm/frag/unreachable.asm.frag create mode 100644 reference/opt/shaders/asm/frag/vector-shuffle-oom.asm.frag create mode 100644 reference/opt/shaders/asm/tesc/tess-fixed-input-array-builtin-array.asm.tesc create mode 100644 reference/opt/shaders/asm/vert/empty-io.asm.vert create mode 100644 reference/opt/shaders/asm/vert/empty-struct-composite.asm.vert create mode 100644 reference/opt/shaders/asm/vert/global-builtin.sso.asm.vert create mode 100644 reference/opt/shaders/comp/atomic.comp create mode 100644 reference/opt/shaders/comp/bake_gradient.comp create mode 100644 reference/opt/shaders/comp/barriers.comp create mode 100644 reference/opt/shaders/comp/basic.comp create mode 100644 reference/opt/shaders/comp/bitfield.noopt.comp create mode 100644 reference/opt/shaders/comp/casts.comp create mode 100644 reference/opt/shaders/comp/cfg-preserve-parameter.comp create mode 100644 reference/opt/shaders/comp/cfg.comp create mode 100644 reference/opt/shaders/comp/coherent-block.comp create mode 100644 reference/opt/shaders/comp/coherent-image.comp create mode 100644 reference/opt/shaders/comp/composite-construct.comp create mode 100644 reference/opt/shaders/comp/culling.comp create mode 100644 reference/opt/shaders/comp/defer-parens.comp create mode 100644 reference/opt/shaders/comp/dowhile.comp create mode 100644 reference/opt/shaders/comp/generate_height.comp create mode 100644 reference/opt/shaders/comp/image.comp create mode 100644 reference/opt/shaders/comp/inout-struct.invalid.comp create mode 100644 reference/opt/shaders/comp/insert.comp create mode 100644 reference/opt/shaders/comp/loop.noopt.comp create mode 100644 reference/opt/shaders/comp/mat3.comp create mode 100644 reference/opt/shaders/comp/mod.comp create mode 100644 reference/opt/shaders/comp/modf.comp create mode 100644 reference/opt/shaders/comp/read-write-only.comp create mode 100644 reference/opt/shaders/comp/return.comp create mode 100644 reference/opt/shaders/comp/rmw-opt.comp create mode 100644 reference/opt/shaders/comp/shared.comp create mode 100644 reference/opt/shaders/comp/ssbo-array.comp create mode 100644 reference/opt/shaders/comp/struct-layout.comp create mode 100644 reference/opt/shaders/comp/struct-packing.comp create mode 100644 reference/opt/shaders/comp/torture-loop.comp create mode 100644 reference/opt/shaders/comp/type-alias.comp create mode 100644 reference/opt/shaders/comp/udiv.comp create mode 100644 reference/opt/shaders/desktop-only/comp/enhanced-layouts.comp create mode 100644 reference/opt/shaders/desktop-only/comp/fp64.desktop.comp create mode 100644 reference/opt/shaders/desktop-only/comp/image-formats.desktop.noeliminate.comp create mode 100644 reference/opt/shaders/desktop-only/comp/int64.desktop.comp create mode 100644 reference/opt/shaders/desktop-only/frag/hlsl-uav-block-alias.asm.frag create mode 100644 reference/opt/shaders/desktop-only/frag/image-ms.desktop.frag create mode 100644 reference/opt/shaders/desktop-only/frag/image-query.desktop.frag create mode 100644 reference/opt/shaders/desktop-only/frag/in-block-qualifiers.frag create mode 100644 reference/opt/shaders/desktop-only/frag/query-levels.desktop.frag create mode 100644 reference/opt/shaders/desktop-only/frag/query-lod.desktop.frag create mode 100644 reference/opt/shaders/desktop-only/frag/sampler-ms-query.desktop.frag create mode 100644 reference/opt/shaders/desktop-only/frag/texture-proj-shadow.desktop.frag create mode 100644 reference/opt/shaders/desktop-only/geom/basic.desktop.sso.geom create mode 100644 reference/opt/shaders/desktop-only/geom/viewport-index.desktop.geom create mode 100644 reference/opt/shaders/desktop-only/tesc/basic.desktop.sso.tesc create mode 100644 reference/opt/shaders/desktop-only/tese/triangle.desktop.sso.tese create mode 100644 reference/opt/shaders/desktop-only/vert/basic.desktop.sso.vert create mode 100644 reference/opt/shaders/desktop-only/vert/clip-cull-distance.desktop.vert create mode 100644 reference/opt/shaders/desktop-only/vert/out-block-qualifiers.vert create mode 100644 reference/opt/shaders/flatten/array.flatten.vert create mode 100644 reference/opt/shaders/flatten/basic.flatten.vert create mode 100644 reference/opt/shaders/flatten/copy.flatten.vert create mode 100644 reference/opt/shaders/flatten/dynamic.flatten.vert create mode 100644 reference/opt/shaders/flatten/matrixindex.flatten.vert create mode 100644 reference/opt/shaders/flatten/multi-dimensional.desktop.flatten_dim.frag create mode 100644 reference/opt/shaders/flatten/multiindex.flatten.vert create mode 100644 reference/opt/shaders/flatten/push-constant.flatten.vert create mode 100644 reference/opt/shaders/flatten/rowmajor.flatten.vert create mode 100644 reference/opt/shaders/flatten/struct.flatten.vert create mode 100644 reference/opt/shaders/flatten/struct.rowmajor.flatten.vert create mode 100644 reference/opt/shaders/flatten/swizzle.flatten.vert create mode 100644 reference/opt/shaders/flatten/types.flatten.frag create mode 100644 reference/opt/shaders/frag/basic.frag create mode 100644 reference/opt/shaders/frag/composite-extract-forced-temporary.frag create mode 100644 reference/opt/shaders/frag/constant-array.frag create mode 100644 reference/opt/shaders/frag/constant-composites.frag create mode 100644 reference/opt/shaders/frag/eliminate-dead-variables.frag create mode 100644 reference/opt/shaders/frag/false-loop-init.frag create mode 100644 reference/opt/shaders/frag/flush_params.frag create mode 100644 reference/opt/shaders/frag/for-loop-init.frag create mode 100644 reference/opt/shaders/frag/frexp-modf.frag create mode 100644 reference/opt/shaders/frag/ground.frag create mode 100644 reference/opt/shaders/frag/image-load-store-uint-coord.asm.frag create mode 100644 reference/opt/shaders/frag/mix.frag create mode 100644 reference/opt/shaders/frag/partial-write-preserve.frag create mode 100644 reference/opt/shaders/frag/pls.frag create mode 100644 reference/opt/shaders/frag/sample-parameter.frag create mode 100644 reference/opt/shaders/frag/sampler-ms-query.frag create mode 100644 reference/opt/shaders/frag/sampler-ms.frag create mode 100644 reference/opt/shaders/frag/sampler-proj.frag create mode 100644 reference/opt/shaders/frag/sampler.frag create mode 100644 reference/opt/shaders/frag/swizzle.frag create mode 100644 reference/opt/shaders/frag/temporary.frag create mode 100644 reference/opt/shaders/frag/ubo_layout.frag create mode 100644 reference/opt/shaders/frag/unary-enclose.frag create mode 100644 reference/opt/shaders/geom/basic.geom create mode 100644 reference/opt/shaders/geom/lines-adjacency.geom create mode 100644 reference/opt/shaders/geom/lines.geom create mode 100644 reference/opt/shaders/geom/points.geom create mode 100644 reference/opt/shaders/geom/single-invocation.geom create mode 100644 reference/opt/shaders/geom/triangles-adjacency.geom create mode 100644 reference/opt/shaders/geom/triangles.geom create mode 100644 reference/opt/shaders/legacy/fragment/explicit-lod.legacy.frag create mode 100644 reference/opt/shaders/legacy/fragment/io-blocks.legacy.frag create mode 100644 reference/opt/shaders/legacy/fragment/struct-varying.legacy.frag create mode 100644 reference/opt/shaders/legacy/vert/implicit-lod.legacy.vert create mode 100644 reference/opt/shaders/legacy/vert/io-block.legacy.vert create mode 100644 reference/opt/shaders/legacy/vert/struct-varying.legacy.vert create mode 100644 reference/opt/shaders/legacy/vert/transpose.legacy.vert create mode 100644 reference/opt/shaders/tesc/basic.tesc create mode 100644 reference/opt/shaders/tesc/water_tess.tesc create mode 100644 reference/opt/shaders/tese/ccw.tese create mode 100644 reference/opt/shaders/tese/cw.tese create mode 100644 reference/opt/shaders/tese/equal.tese create mode 100644 reference/opt/shaders/tese/fractional_even.tese create mode 100644 reference/opt/shaders/tese/fractional_odd.tese create mode 100644 reference/opt/shaders/tese/line.tese create mode 100644 reference/opt/shaders/tese/triangle.tese create mode 100644 reference/opt/shaders/tese/water_tess.tese create mode 100644 reference/opt/shaders/vert/basic.vert create mode 100644 reference/opt/shaders/vert/ground.vert create mode 100644 reference/opt/shaders/vert/ocean.vert create mode 100644 reference/opt/shaders/vert/texture_buffer.vert create mode 100644 reference/opt/shaders/vert/ubo.vert create mode 100644 reference/opt/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag create mode 100644 reference/opt/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag.vk create mode 100644 reference/opt/shaders/vulkan/frag/combined-texture-sampler.vk.frag create mode 100644 reference/opt/shaders/vulkan/frag/combined-texture-sampler.vk.frag.vk create mode 100644 reference/opt/shaders/vulkan/frag/desktop-mediump.vk.frag create mode 100644 reference/opt/shaders/vulkan/frag/desktop-mediump.vk.frag.vk create mode 100644 reference/opt/shaders/vulkan/frag/input-attachment-ms.vk.frag create mode 100644 reference/opt/shaders/vulkan/frag/input-attachment-ms.vk.frag.vk create mode 100644 reference/opt/shaders/vulkan/frag/input-attachment.vk.frag create mode 100644 reference/opt/shaders/vulkan/frag/input-attachment.vk.frag.vk create mode 100644 reference/opt/shaders/vulkan/frag/push-constant.vk.frag create mode 100644 reference/opt/shaders/vulkan/frag/push-constant.vk.frag.vk create mode 100644 reference/opt/shaders/vulkan/frag/separate-sampler-texture.vk.frag create mode 100644 reference/opt/shaders/vulkan/frag/separate-sampler-texture.vk.frag.vk create mode 100644 reference/opt/shaders/vulkan/frag/spec-constant.vk.frag create mode 100644 reference/opt/shaders/vulkan/frag/spec-constant.vk.frag.vk create mode 100644 reference/opt/shaders/vulkan/vert/multiview.nocompat.vk.vert create mode 100644 reference/opt/shaders/vulkan/vert/multiview.nocompat.vk.vert.vk create mode 100644 reference/opt/shaders/vulkan/vert/vulkan-vertex.vk.vert create mode 100644 reference/opt/shaders/vulkan/vert/vulkan-vertex.vk.vert.vk create mode 100644 reference/shaders-hlsl/asm/comp/specialization-constant-workgroup.nofxc.asm.comp create mode 100644 reference/shaders-hlsl/asm/comp/storage-buffer-basic.nofxc.asm.comp create mode 100644 reference/shaders-hlsl/asm/frag/cbuffer-stripped.asm.frag create mode 100644 reference/shaders-hlsl/asm/frag/unreachable.asm.frag create mode 100644 reference/shaders-hlsl/asm/vert/empty-struct-composite.asm.vert create mode 100644 reference/shaders-hlsl/asm/vert/vertex-id-instance-id.asm.vert create mode 100644 reference/shaders-hlsl/comp/access-chains.comp create mode 100644 reference/shaders-hlsl/comp/address-buffers.comp create mode 100644 reference/shaders-hlsl/comp/atomic.comp create mode 100644 reference/shaders-hlsl/comp/barriers.comp create mode 100644 reference/shaders-hlsl/comp/bitfield.noopt.comp create mode 100644 reference/shaders-hlsl/comp/builtins.comp create mode 100644 reference/shaders-hlsl/comp/image.comp create mode 100644 reference/shaders-hlsl/comp/rwbuffer-matrix.comp create mode 100644 reference/shaders-hlsl/comp/shared.comp create mode 100644 reference/shaders-hlsl/comp/ssbo-array.comp create mode 100644 reference/shaders-hlsl/frag/basic.frag create mode 100644 reference/shaders-hlsl/frag/bit-conversions.frag create mode 100644 reference/shaders-hlsl/frag/boolean-mix.frag create mode 100644 reference/shaders-hlsl/frag/builtins.frag create mode 100644 reference/shaders-hlsl/frag/bvec-operations.frag create mode 100644 reference/shaders-hlsl/frag/combined-texture-sampler-parameter.frag create mode 100644 reference/shaders-hlsl/frag/combined-texture-sampler-shadow.frag create mode 100644 reference/shaders-hlsl/frag/constant-buffer-array.sm51.frag create mode 100644 reference/shaders-hlsl/frag/constant-composites.frag create mode 100644 reference/shaders-hlsl/frag/early-fragment-test.frag create mode 100644 reference/shaders-hlsl/frag/fp16-packing.frag create mode 100644 reference/shaders-hlsl/frag/image-query-selective.frag create mode 100644 reference/shaders-hlsl/frag/image-query.frag create mode 100644 reference/shaders-hlsl/frag/io-block.frag create mode 100644 reference/shaders-hlsl/frag/matrix-input.frag create mode 100644 reference/shaders-hlsl/frag/mod.frag create mode 100644 reference/shaders-hlsl/frag/mrt.frag create mode 100644 reference/shaders-hlsl/frag/no-return.frag create mode 100644 reference/shaders-hlsl/frag/no-return2.frag create mode 100644 reference/shaders-hlsl/frag/partial-write-preserve.frag create mode 100644 reference/shaders-hlsl/frag/query-lod.desktop.frag create mode 100644 reference/shaders-hlsl/frag/resources.frag create mode 100644 reference/shaders-hlsl/frag/sample-cmp-level-zero.frag create mode 100644 reference/shaders-hlsl/frag/sampler-array.frag create mode 100644 reference/shaders-hlsl/frag/spec-constant.frag create mode 100644 reference/shaders-hlsl/frag/swizzle-scalar.frag create mode 100644 reference/shaders-hlsl/frag/tex-sampling.frag create mode 100644 reference/shaders-hlsl/frag/texture-proj-shadow.frag create mode 100644 reference/shaders-hlsl/frag/texture-size-combined-image-sampler.frag create mode 100644 reference/shaders-hlsl/frag/unary-enclose.frag create mode 100644 reference/shaders-hlsl/frag/unorm-snorm-packing.frag create mode 100644 reference/shaders-hlsl/frag/various-glsl-ops.frag create mode 100644 reference/shaders-hlsl/vert/basic.vert create mode 100644 reference/shaders-hlsl/vert/instancing.vert create mode 100644 reference/shaders-hlsl/vert/locations.vert create mode 100644 reference/shaders-hlsl/vert/matrix-attribute.vert create mode 100644 reference/shaders-hlsl/vert/matrix-output.vert create mode 100644 reference/shaders-hlsl/vert/no-input.vert create mode 100644 reference/shaders-hlsl/vert/point-size-compat.vert create mode 100644 reference/shaders-hlsl/vert/qualifiers.vert create mode 100644 reference/shaders-hlsl/vert/sampler-buffers.vert create mode 100644 reference/shaders-hlsl/vert/struct-composite-decl.vert create mode 100644 reference/shaders-hlsl/vert/texture_buffer.vert create mode 100644 reference/shaders-msl-no-opt/vert/functions_nested.vert create mode 100644 reference/shaders-msl/asm/comp/bitcast_iadd.asm.comp create mode 100644 reference/shaders-msl/asm/comp/bitcast_sar.asm.comp create mode 100644 reference/shaders-msl/asm/comp/bitcast_sdiv.asm.comp create mode 100644 reference/shaders-msl/asm/comp/bitcast_slr.asm.comp create mode 100644 reference/shaders-msl/asm/comp/multiple-entry.asm.comp create mode 100644 reference/shaders-msl/asm/comp/quantize.asm.comp create mode 100644 reference/shaders-msl/asm/comp/specialization-constant-workgroup.asm.comp create mode 100644 reference/shaders-msl/asm/comp/storage-buffer-basic.asm.comp create mode 100644 reference/shaders-msl/asm/frag/default-member-names.asm.frag create mode 100644 reference/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag create mode 100644 reference/shaders-msl/asm/frag/op-constant-null.asm.frag create mode 100644 reference/shaders-msl/asm/frag/phi-loop-variable.asm.frag create mode 100644 reference/shaders-msl/asm/frag/undef-variable-store.asm.frag create mode 100644 reference/shaders-msl/asm/frag/unreachable.asm.frag create mode 100644 reference/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag create mode 100644 reference/shaders-msl/asm/vert/empty-struct-composite.asm.vert create mode 100644 reference/shaders-msl/comp/atomic.comp create mode 100644 reference/shaders-msl/comp/bake_gradient.comp create mode 100644 reference/shaders-msl/comp/barriers.comp create mode 100644 reference/shaders-msl/comp/basic.comp create mode 100644 reference/shaders-msl/comp/bitfield.noopt.comp create mode 100644 reference/shaders-msl/comp/builtins.comp create mode 100644 reference/shaders-msl/comp/cfg-preserve-parameter.comp create mode 100644 reference/shaders-msl/comp/coherent-block.comp create mode 100644 reference/shaders-msl/comp/coherent-image.comp create mode 100644 reference/shaders-msl/comp/culling.comp create mode 100644 reference/shaders-msl/comp/defer-parens.comp create mode 100644 reference/shaders-msl/comp/dowhile.comp create mode 100644 reference/shaders-msl/comp/functions.comp create mode 100644 reference/shaders-msl/comp/global-invocation-id-writable-ssbo-in-function.comp create mode 100644 reference/shaders-msl/comp/global-invocation-id.comp create mode 100644 reference/shaders-msl/comp/image.comp create mode 100644 reference/shaders-msl/comp/insert.comp create mode 100644 reference/shaders-msl/comp/local-invocation-id.comp create mode 100644 reference/shaders-msl/comp/local-invocation-index.comp create mode 100644 reference/shaders-msl/comp/loop.noopt.comp create mode 100644 reference/shaders-msl/comp/mat3.comp create mode 100644 reference/shaders-msl/comp/mod.comp create mode 100644 reference/shaders-msl/comp/modf.comp create mode 100644 reference/shaders-msl/comp/read-write-only.comp create mode 100644 reference/shaders-msl/comp/return.comp create mode 100644 reference/shaders-msl/comp/rmw-opt.comp create mode 100644 reference/shaders-msl/comp/shared-array-of-arrays.comp create mode 100644 reference/shaders-msl/comp/shared.comp create mode 100644 reference/shaders-msl/comp/struct-layout.comp create mode 100644 reference/shaders-msl/comp/struct-packing.comp create mode 100644 reference/shaders-msl/comp/torture-loop.comp create mode 100644 reference/shaders-msl/comp/type-alias.comp create mode 100644 reference/shaders-msl/comp/udiv.comp create mode 100644 reference/shaders-msl/comp/writable-ssbo.comp create mode 100644 reference/shaders-msl/desktop-only/frag/image-ms.desktop.frag create mode 100644 reference/shaders-msl/desktop-only/frag/query-levels.desktop.frag create mode 100644 reference/shaders-msl/desktop-only/frag/sampler-ms-query.desktop.frag create mode 100644 reference/shaders-msl/desktop-only/vert/basic.desktop.sso.vert create mode 100644 reference/shaders-msl/desktop-only/vert/clip-cull-distance.desktop.vert create mode 100644 reference/shaders-msl/flatten/basic.flatten.vert create mode 100644 reference/shaders-msl/flatten/multiindex.flatten.vert create mode 100644 reference/shaders-msl/flatten/push-constant.flatten.vert create mode 100644 reference/shaders-msl/flatten/rowmajor.flatten.vert create mode 100644 reference/shaders-msl/flatten/struct.flatten.vert create mode 100644 reference/shaders-msl/flatten/swizzle.flatten.vert create mode 100644 reference/shaders-msl/flatten/types.flatten.frag create mode 100644 reference/shaders-msl/frag/basic.frag create mode 100644 reference/shaders-msl/frag/bitcasting.frag create mode 100644 reference/shaders-msl/frag/builtins.frag create mode 100644 reference/shaders-msl/frag/composite-extract-forced-temporary.frag create mode 100644 reference/shaders-msl/frag/constant-array.frag create mode 100644 reference/shaders-msl/frag/constant-composites.frag create mode 100644 reference/shaders-msl/frag/false-loop-init.frag create mode 100644 reference/shaders-msl/frag/flush_params.frag create mode 100644 reference/shaders-msl/frag/for-loop-init.frag create mode 100644 reference/shaders-msl/frag/in_block.frag create mode 100644 reference/shaders-msl/frag/in_block_assign.noopt.frag create mode 100644 reference/shaders-msl/frag/mix.frag create mode 100644 reference/shaders-msl/frag/pls.frag create mode 100644 reference/shaders-msl/frag/sampler-ms.frag create mode 100644 reference/shaders-msl/frag/sampler.frag create mode 100644 reference/shaders-msl/frag/separate-image-sampler-argument.frag create mode 100644 reference/shaders-msl/frag/swizzle.frag create mode 100644 reference/shaders-msl/frag/texture-proj-shadow.frag create mode 100644 reference/shaders-msl/frag/ubo_layout.frag create mode 100644 reference/shaders-msl/frag/unary-enclose.frag create mode 100644 reference/shaders-msl/legacy/vert/transpose.legacy.vert create mode 100644 reference/shaders-msl/vert/basic.vert create mode 100644 reference/shaders-msl/vert/copy.flatten.vert create mode 100644 reference/shaders-msl/vert/dynamic.flatten.vert create mode 100644 reference/shaders-msl/vert/functions.vert create mode 100644 reference/shaders-msl/vert/out_block.vert create mode 100644 reference/shaders-msl/vert/pointsize.vert create mode 100644 reference/shaders-msl/vert/texture_buffer.vert create mode 100644 reference/shaders-msl/vert/ubo.alignment.vert create mode 100644 reference/shaders-msl/vert/ubo.vert create mode 100644 reference/shaders-msl/vulkan/frag/push-constant.vk.frag create mode 100644 reference/shaders-msl/vulkan/frag/spec-constant.vk.frag create mode 100644 reference/shaders-msl/vulkan/vert/vulkan-vertex.vk.vert create mode 100644 reference/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag create mode 100644 reference/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag.vk create mode 100644 reference/shaders/amd/fs.invalid.frag create mode 100644 reference/shaders/amd/gcn_shader.comp create mode 100644 reference/shaders/amd/shader_ballot.comp create mode 100644 reference/shaders/amd/shader_ballot_nonuniform_invocations.invalid.comp create mode 100644 reference/shaders/amd/shader_group_vote.comp create mode 100644 reference/shaders/amd/shader_trinary_minmax.comp create mode 100644 reference/shaders/asm/comp/bitcast_iadd.asm.comp create mode 100644 reference/shaders/asm/comp/bitcast_iequal.asm.comp create mode 100644 reference/shaders/asm/comp/bitcast_sar.asm.comp create mode 100644 reference/shaders/asm/comp/bitcast_sdiv.asm.comp create mode 100644 reference/shaders/asm/comp/bitcast_slr.asm.comp create mode 100644 reference/shaders/asm/comp/logical.asm.comp create mode 100644 reference/shaders/asm/comp/multiple-entry.asm.comp create mode 100644 reference/shaders/asm/comp/name-alias.asm.invalid.comp create mode 100644 reference/shaders/asm/comp/quantize.asm.comp create mode 100644 reference/shaders/asm/comp/specialization-constant-workgroup.asm.comp create mode 100644 reference/shaders/asm/comp/storage-buffer-basic.asm.comp create mode 100644 reference/shaders/asm/frag/composite-construct-struct-no-swizzle.asm.frag create mode 100644 reference/shaders/asm/frag/default-member-names.asm.frag create mode 100644 reference/shaders/asm/frag/hlsl-sample-cmp-level-zero-cube.asm.frag create mode 100644 reference/shaders/asm/frag/hlsl-sample-cmp-level-zero.asm.frag create mode 100644 reference/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag create mode 100644 reference/shaders/asm/frag/invalidation.asm.frag create mode 100644 reference/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag create mode 100644 reference/shaders/asm/frag/loop-header-to-continue.asm.frag create mode 100644 reference/shaders/asm/frag/multi-for-loop-init.asm.frag create mode 100644 reference/shaders/asm/frag/op-constant-null.asm.frag create mode 100644 reference/shaders/asm/frag/phi-loop-variable.asm.frag create mode 100644 reference/shaders/asm/frag/sampler-buffer-without-sampler.asm.frag create mode 100644 reference/shaders/asm/frag/struct-composite-extract-swizzle.asm.frag create mode 100644 reference/shaders/asm/frag/temporary-phi-hoisting.asm.frag create mode 100644 reference/shaders/asm/frag/undef-variable-store.asm.frag create mode 100644 reference/shaders/asm/frag/unreachable.asm.frag create mode 100644 reference/shaders/asm/frag/vector-shuffle-oom.asm.frag create mode 100644 reference/shaders/asm/tesc/tess-fixed-input-array-builtin-array.asm.tesc create mode 100644 reference/shaders/asm/vert/empty-io.asm.vert create mode 100644 reference/shaders/asm/vert/empty-struct-composite.asm.vert create mode 100644 reference/shaders/asm/vert/global-builtin.sso.asm.vert create mode 100644 reference/shaders/comp/atomic.comp create mode 100644 reference/shaders/comp/bake_gradient.comp create mode 100644 reference/shaders/comp/barriers.comp create mode 100644 reference/shaders/comp/basic.comp create mode 100644 reference/shaders/comp/bitfield.noopt.comp create mode 100644 reference/shaders/comp/casts.comp create mode 100644 reference/shaders/comp/cfg-preserve-parameter.comp create mode 100644 reference/shaders/comp/cfg.comp create mode 100644 reference/shaders/comp/coherent-block.comp create mode 100644 reference/shaders/comp/coherent-image.comp create mode 100644 reference/shaders/comp/composite-construct.comp create mode 100644 reference/shaders/comp/culling.comp create mode 100644 reference/shaders/comp/defer-parens.comp create mode 100644 reference/shaders/comp/dowhile.comp create mode 100644 reference/shaders/comp/generate_height.comp create mode 100644 reference/shaders/comp/image.comp create mode 100644 reference/shaders/comp/inout-struct.invalid.comp create mode 100644 reference/shaders/comp/insert.comp create mode 100644 reference/shaders/comp/loop.noopt.comp create mode 100644 reference/shaders/comp/mat3.comp create mode 100644 reference/shaders/comp/mod.comp create mode 100644 reference/shaders/comp/modf.comp create mode 100644 reference/shaders/comp/read-write-only.comp create mode 100644 reference/shaders/comp/return.comp create mode 100644 reference/shaders/comp/rmw-opt.comp create mode 100644 reference/shaders/comp/shared.comp create mode 100644 reference/shaders/comp/ssbo-array.comp create mode 100644 reference/shaders/comp/struct-layout.comp create mode 100644 reference/shaders/comp/struct-packing.comp create mode 100644 reference/shaders/comp/torture-loop.comp create mode 100644 reference/shaders/comp/type-alias.comp create mode 100644 reference/shaders/comp/udiv.comp create mode 100644 reference/shaders/desktop-only/comp/enhanced-layouts.comp create mode 100644 reference/shaders/desktop-only/comp/fp64.desktop.comp create mode 100644 reference/shaders/desktop-only/comp/image-formats.desktop.noeliminate.comp create mode 100644 reference/shaders/desktop-only/comp/int64.desktop.comp create mode 100644 reference/shaders/desktop-only/frag/hlsl-uav-block-alias.asm.frag create mode 100644 reference/shaders/desktop-only/frag/image-ms.desktop.frag create mode 100644 reference/shaders/desktop-only/frag/image-query.desktop.frag create mode 100644 reference/shaders/desktop-only/frag/in-block-qualifiers.frag create mode 100644 reference/shaders/desktop-only/frag/query-levels.desktop.frag create mode 100644 reference/shaders/desktop-only/frag/query-lod.desktop.frag create mode 100644 reference/shaders/desktop-only/frag/sampler-ms-query.desktop.frag create mode 100644 reference/shaders/desktop-only/frag/texture-proj-shadow.desktop.frag create mode 100644 reference/shaders/desktop-only/geom/basic.desktop.sso.geom create mode 100644 reference/shaders/desktop-only/geom/viewport-index.desktop.geom create mode 100644 reference/shaders/desktop-only/tesc/basic.desktop.sso.tesc create mode 100644 reference/shaders/desktop-only/tese/triangle.desktop.sso.tese create mode 100644 reference/shaders/desktop-only/vert/basic.desktop.sso.vert create mode 100644 reference/shaders/desktop-only/vert/clip-cull-distance.desktop.vert create mode 100644 reference/shaders/desktop-only/vert/out-block-qualifiers.vert create mode 100644 reference/shaders/flatten/array.flatten.vert create mode 100644 reference/shaders/flatten/basic.flatten.vert create mode 100644 reference/shaders/flatten/copy.flatten.vert create mode 100644 reference/shaders/flatten/dynamic.flatten.vert create mode 100644 reference/shaders/flatten/matrixindex.flatten.vert create mode 100644 reference/shaders/flatten/multi-dimensional.desktop.flatten_dim.frag create mode 100644 reference/shaders/flatten/multiindex.flatten.vert create mode 100644 reference/shaders/flatten/push-constant.flatten.vert create mode 100644 reference/shaders/flatten/rowmajor.flatten.vert create mode 100644 reference/shaders/flatten/struct.flatten.vert create mode 100644 reference/shaders/flatten/struct.rowmajor.flatten.vert create mode 100644 reference/shaders/flatten/swizzle.flatten.vert create mode 100644 reference/shaders/flatten/types.flatten.frag create mode 100644 reference/shaders/frag/basic.frag create mode 100644 reference/shaders/frag/composite-extract-forced-temporary.frag create mode 100644 reference/shaders/frag/constant-array.frag create mode 100644 reference/shaders/frag/constant-composites.frag create mode 100644 reference/shaders/frag/false-loop-init.frag create mode 100644 reference/shaders/frag/flush_params.frag create mode 100644 reference/shaders/frag/for-loop-init.frag create mode 100644 reference/shaders/frag/frexp-modf.frag create mode 100644 reference/shaders/frag/ground.frag create mode 100644 reference/shaders/frag/image-load-store-uint-coord.asm.frag create mode 100644 reference/shaders/frag/mix.frag create mode 100644 reference/shaders/frag/partial-write-preserve.frag create mode 100644 reference/shaders/frag/pls.frag create mode 100644 reference/shaders/frag/sample-parameter.frag create mode 100644 reference/shaders/frag/sampler-ms.frag create mode 100644 reference/shaders/frag/sampler-proj.frag create mode 100644 reference/shaders/frag/sampler.frag create mode 100644 reference/shaders/frag/swizzle.frag create mode 100644 reference/shaders/frag/ubo_layout.frag create mode 100644 reference/shaders/frag/unary-enclose.frag create mode 100644 reference/shaders/geom/basic.geom create mode 100644 reference/shaders/geom/lines-adjacency.geom create mode 100644 reference/shaders/geom/lines.geom create mode 100644 reference/shaders/geom/points.geom create mode 100644 reference/shaders/geom/single-invocation.geom create mode 100644 reference/shaders/geom/triangles-adjacency.geom create mode 100644 reference/shaders/geom/triangles.geom create mode 100644 reference/shaders/legacy/fragment/explicit-lod.legacy.frag create mode 100644 reference/shaders/legacy/fragment/io-blocks.legacy.frag create mode 100644 reference/shaders/legacy/fragment/struct-varying.legacy.frag create mode 100644 reference/shaders/legacy/vert/implicit-lod.legacy.vert create mode 100644 reference/shaders/legacy/vert/io-block.legacy.vert create mode 100644 reference/shaders/legacy/vert/struct-varying.legacy.vert create mode 100644 reference/shaders/legacy/vert/transpose.legacy.vert create mode 100644 reference/shaders/tesc/basic.tesc create mode 100644 reference/shaders/tesc/water_tess.tesc create mode 100644 reference/shaders/tese/ccw.tese create mode 100644 reference/shaders/tese/cw.tese create mode 100644 reference/shaders/tese/equal.tese create mode 100644 reference/shaders/tese/fractional_even.tese create mode 100644 reference/shaders/tese/fractional_odd.tese create mode 100644 reference/shaders/tese/line.tese create mode 100644 reference/shaders/tese/triangle.tese create mode 100644 reference/shaders/tese/water_tess.tese create mode 100644 reference/shaders/vert/basic.vert create mode 100644 reference/shaders/vert/ground.vert create mode 100644 reference/shaders/vert/ocean.vert create mode 100644 reference/shaders/vert/texture_buffer.vert create mode 100644 reference/shaders/vert/ubo.vert create mode 100644 reference/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag create mode 100644 reference/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag.vk create mode 100644 reference/shaders/vulkan/frag/combined-texture-sampler.vk.frag create mode 100644 reference/shaders/vulkan/frag/combined-texture-sampler.vk.frag.vk create mode 100644 reference/shaders/vulkan/frag/desktop-mediump.vk.frag create mode 100644 reference/shaders/vulkan/frag/desktop-mediump.vk.frag.vk create mode 100644 reference/shaders/vulkan/frag/input-attachment-ms.vk.frag create mode 100644 reference/shaders/vulkan/frag/input-attachment-ms.vk.frag.vk create mode 100644 reference/shaders/vulkan/frag/input-attachment.vk.frag create mode 100644 reference/shaders/vulkan/frag/input-attachment.vk.frag.vk create mode 100644 reference/shaders/vulkan/frag/push-constant.frag.vk create mode 100644 reference/shaders/vulkan/frag/push-constant.vk.frag create mode 100644 reference/shaders/vulkan/frag/push-constant.vk.frag.vk create mode 100644 reference/shaders/vulkan/frag/separate-sampler-texture.vk.frag create mode 100644 reference/shaders/vulkan/frag/separate-sampler-texture.vk.frag.vk create mode 100644 reference/shaders/vulkan/frag/spec-constant.vk.frag create mode 100644 reference/shaders/vulkan/frag/spec-constant.vk.frag.vk create mode 100644 reference/shaders/vulkan/vert/multiview.nocompat.vk.vert create mode 100644 reference/shaders/vulkan/vert/multiview.nocompat.vk.vert.vk create mode 100644 reference/shaders/vulkan/vert/vulkan-vertex.vert create mode 100644 reference/shaders/vulkan/vert/vulkan-vertex.vert.vk create mode 100644 reference/shaders/vulkan/vert/vulkan-vertex.vk.vert create mode 100644 reference/shaders/vulkan/vert/vulkan-vertex.vk.vert.vk create mode 100644 samples/cpp/Makefile create mode 100644 samples/cpp/atomics.comp create mode 100644 samples/cpp/atomics.cpp create mode 100644 samples/cpp/multiply.comp create mode 100644 samples/cpp/multiply.cpp create mode 100644 samples/cpp/shared.comp create mode 100644 samples/cpp/shared.cpp create mode 100644 shaders-hlsl/asm/comp/specialization-constant-workgroup.nofxc.asm.comp create mode 100644 shaders-hlsl/asm/comp/storage-buffer-basic.nofxc.asm.comp create mode 100644 shaders-hlsl/asm/frag/cbuffer-stripped.asm.frag create mode 100644 shaders-hlsl/asm/frag/unreachable.asm.frag create mode 100644 shaders-hlsl/asm/vert/empty-struct-composite.asm.vert create mode 100644 shaders-hlsl/asm/vert/vertex-id-instance-id.asm.vert create mode 100644 shaders-hlsl/comp/access-chains.comp create mode 100644 shaders-hlsl/comp/address-buffers.comp create mode 100644 shaders-hlsl/comp/atomic.comp create mode 100644 shaders-hlsl/comp/barriers.comp create mode 100644 shaders-hlsl/comp/bitfield.noopt.comp create mode 100644 shaders-hlsl/comp/builtins.comp create mode 100644 shaders-hlsl/comp/image.comp create mode 100644 shaders-hlsl/comp/rwbuffer-matrix.comp create mode 100644 shaders-hlsl/comp/shared.comp create mode 100644 shaders-hlsl/comp/ssbo-array.comp create mode 100644 shaders-hlsl/frag/basic.frag create mode 100644 shaders-hlsl/frag/bit-conversions.frag create mode 100644 shaders-hlsl/frag/boolean-mix.frag create mode 100644 shaders-hlsl/frag/builtins.frag create mode 100644 shaders-hlsl/frag/bvec-operations.frag create mode 100644 shaders-hlsl/frag/combined-texture-sampler-parameter.frag create mode 100644 shaders-hlsl/frag/combined-texture-sampler-shadow.frag create mode 100644 shaders-hlsl/frag/constant-buffer-array.sm51.frag create mode 100644 shaders-hlsl/frag/constant-composites.frag create mode 100644 shaders-hlsl/frag/early-fragment-test.frag create mode 100644 shaders-hlsl/frag/fp16-packing.frag create mode 100644 shaders-hlsl/frag/image-query-selective.frag create mode 100644 shaders-hlsl/frag/image-query.frag create mode 100644 shaders-hlsl/frag/io-block.frag create mode 100644 shaders-hlsl/frag/matrix-input.frag create mode 100644 shaders-hlsl/frag/mod.frag create mode 100644 shaders-hlsl/frag/mrt.frag create mode 100644 shaders-hlsl/frag/no-return.frag create mode 100644 shaders-hlsl/frag/no-return2.frag create mode 100644 shaders-hlsl/frag/partial-write-preserve.frag create mode 100644 shaders-hlsl/frag/query-lod.desktop.frag create mode 100644 shaders-hlsl/frag/resources.frag create mode 100644 shaders-hlsl/frag/sample-cmp-level-zero.frag create mode 100644 shaders-hlsl/frag/sampler-array.frag create mode 100644 shaders-hlsl/frag/spec-constant.frag create mode 100644 shaders-hlsl/frag/swizzle-scalar.frag create mode 100644 shaders-hlsl/frag/tex-sampling.frag create mode 100644 shaders-hlsl/frag/texture-proj-shadow.frag create mode 100644 shaders-hlsl/frag/texture-size-combined-image-sampler.frag create mode 100644 shaders-hlsl/frag/unary-enclose.frag create mode 100644 shaders-hlsl/frag/unorm-snorm-packing.frag create mode 100644 shaders-hlsl/frag/various-glsl-ops.frag create mode 100644 shaders-hlsl/vert/basic.vert create mode 100644 shaders-hlsl/vert/instancing.vert create mode 100644 shaders-hlsl/vert/locations.vert create mode 100644 shaders-hlsl/vert/matrix-attribute.vert create mode 100644 shaders-hlsl/vert/matrix-output.vert create mode 100644 shaders-hlsl/vert/no-input.vert create mode 100644 shaders-hlsl/vert/point-size-compat.vert create mode 100644 shaders-hlsl/vert/qualifiers.vert create mode 100644 shaders-hlsl/vert/sampler-buffers.vert create mode 100644 shaders-hlsl/vert/struct-composite-decl.vert create mode 100644 shaders-hlsl/vert/texture_buffer.vert create mode 100644 shaders-msl-no-opt/vert/functions_nested.vert create mode 100644 shaders-msl/asm/comp/bitcast_iadd.asm.comp create mode 100644 shaders-msl/asm/comp/bitcast_sar.asm.comp create mode 100644 shaders-msl/asm/comp/bitcast_sdiv.asm.comp create mode 100644 shaders-msl/asm/comp/bitcast_slr.asm.comp create mode 100644 shaders-msl/asm/comp/multiple-entry.asm.comp create mode 100644 shaders-msl/asm/comp/quantize.asm.comp create mode 100644 shaders-msl/asm/comp/specialization-constant-workgroup.asm.comp create mode 100644 shaders-msl/asm/comp/storage-buffer-basic.asm.comp create mode 100644 shaders-msl/asm/frag/default-member-names.asm.frag create mode 100644 shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag create mode 100644 shaders-msl/asm/frag/op-constant-null.asm.frag create mode 100644 shaders-msl/asm/frag/phi-loop-variable.asm.frag create mode 100644 shaders-msl/asm/frag/undef-variable-store.asm.frag create mode 100644 shaders-msl/asm/frag/unreachable.asm.frag create mode 100644 shaders-msl/asm/frag/vector-shuffle-oom.asm.frag create mode 100644 shaders-msl/asm/vert/empty-struct-composite.asm.vert create mode 100644 shaders-msl/comp/atomic.comp create mode 100644 shaders-msl/comp/barriers.comp create mode 100644 shaders-msl/comp/basic.comp create mode 100644 shaders-msl/comp/bitfield.noopt.comp create mode 100644 shaders-msl/comp/builtins.comp create mode 100644 shaders-msl/comp/cfg-preserve-parameter.comp create mode 100644 shaders-msl/comp/coherent-block.comp create mode 100644 shaders-msl/comp/coherent-image.comp create mode 100644 shaders-msl/comp/culling.comp create mode 100644 shaders-msl/comp/defer-parens.comp create mode 100644 shaders-msl/comp/dowhile.comp create mode 100644 shaders-msl/comp/functions.comp create mode 100644 shaders-msl/comp/global-invocation-id-writable-ssbo-in-function.comp create mode 100644 shaders-msl/comp/global-invocation-id.comp create mode 100644 shaders-msl/comp/image.comp create mode 100644 shaders-msl/comp/insert.comp create mode 100644 shaders-msl/comp/local-invocation-id.comp create mode 100644 shaders-msl/comp/local-invocation-index.comp create mode 100644 shaders-msl/comp/loop.noopt.comp create mode 100644 shaders-msl/comp/mat3.comp create mode 100644 shaders-msl/comp/mod.comp create mode 100644 shaders-msl/comp/modf.comp create mode 100644 shaders-msl/comp/read-write-only.comp create mode 100644 shaders-msl/comp/return.comp create mode 100644 shaders-msl/comp/rmw-opt.comp create mode 100644 shaders-msl/comp/shared-array-of-arrays.comp create mode 100644 shaders-msl/comp/shared.comp create mode 100644 shaders-msl/comp/struct-layout.comp create mode 100644 shaders-msl/comp/struct-packing.comp create mode 100644 shaders-msl/comp/torture-loop.comp create mode 100644 shaders-msl/comp/type-alias.comp create mode 100644 shaders-msl/comp/udiv.comp create mode 100644 shaders-msl/comp/writable-ssbo.comp create mode 100644 shaders-msl/desktop-only/frag/image-ms.desktop.frag create mode 100644 shaders-msl/desktop-only/frag/query-levels.desktop.frag create mode 100644 shaders-msl/desktop-only/frag/sampler-ms-query.desktop.frag create mode 100644 shaders-msl/desktop-only/vert/basic.desktop.sso.vert create mode 100644 shaders-msl/desktop-only/vert/clip-cull-distance.desktop.vert create mode 100644 shaders-msl/flatten/basic.flatten.vert create mode 100644 shaders-msl/flatten/multiindex.flatten.vert create mode 100644 shaders-msl/flatten/push-constant.flatten.vert create mode 100644 shaders-msl/flatten/rowmajor.flatten.vert create mode 100644 shaders-msl/flatten/struct.flatten.vert create mode 100644 shaders-msl/flatten/swizzle.flatten.vert create mode 100644 shaders-msl/flatten/types.flatten.frag create mode 100644 shaders-msl/frag/basic.frag create mode 100644 shaders-msl/frag/bitcasting.frag create mode 100644 shaders-msl/frag/builtins.frag create mode 100644 shaders-msl/frag/composite-extract-forced-temporary.frag create mode 100644 shaders-msl/frag/constant-array.frag create mode 100644 shaders-msl/frag/constant-composites.frag create mode 100644 shaders-msl/frag/false-loop-init.frag create mode 100644 shaders-msl/frag/flush_params.frag create mode 100644 shaders-msl/frag/for-loop-init.frag create mode 100644 shaders-msl/frag/in_block.frag create mode 100644 shaders-msl/frag/in_block_assign.noopt.frag create mode 100644 shaders-msl/frag/mix.frag create mode 100644 shaders-msl/frag/pls.frag create mode 100644 shaders-msl/frag/sampler-ms.frag create mode 100644 shaders-msl/frag/sampler.frag create mode 100644 shaders-msl/frag/separate-image-sampler-argument.frag create mode 100644 shaders-msl/frag/swizzle.frag create mode 100644 shaders-msl/frag/texture-proj-shadow.frag create mode 100644 shaders-msl/frag/ubo_layout.frag create mode 100644 shaders-msl/frag/unary-enclose.frag create mode 100644 shaders-msl/legacy/vert/transpose.legacy.vert create mode 100644 shaders-msl/vert/basic.vert create mode 100644 shaders-msl/vert/copy.flatten.vert create mode 100644 shaders-msl/vert/dynamic.flatten.vert create mode 100644 shaders-msl/vert/functions.vert create mode 100644 shaders-msl/vert/out_block.vert create mode 100644 shaders-msl/vert/pointsize.vert create mode 100644 shaders-msl/vert/texture_buffer.vert create mode 100644 shaders-msl/vert/ubo.alignment.vert create mode 100644 shaders-msl/vert/ubo.vert create mode 100644 shaders-msl/vulkan/frag/push-constant.vk.frag create mode 100644 shaders-msl/vulkan/frag/spec-constant.vk.frag create mode 100644 shaders-msl/vulkan/vert/vulkan-vertex.vk.vert create mode 100644 shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag create mode 100644 shaders/amd/fs.invalid.frag create mode 100644 shaders/amd/gcn_shader.comp create mode 100644 shaders/amd/shader_ballot.comp create mode 100644 shaders/amd/shader_ballot_nonuniform_invocations.invalid.comp create mode 100644 shaders/amd/shader_group_vote.comp create mode 100644 shaders/amd/shader_trinary_minmax.comp create mode 100644 shaders/asm/comp/bitcast_iadd.asm.comp create mode 100644 shaders/asm/comp/bitcast_iequal.asm.comp create mode 100644 shaders/asm/comp/bitcast_sar.asm.comp create mode 100644 shaders/asm/comp/bitcast_sdiv.asm.comp create mode 100644 shaders/asm/comp/bitcast_slr.asm.comp create mode 100644 shaders/asm/comp/logical.asm.comp create mode 100644 shaders/asm/comp/multiple-entry.asm.comp create mode 100644 shaders/asm/comp/name-alias.asm.invalid.comp create mode 100644 shaders/asm/comp/quantize.asm.comp create mode 100644 shaders/asm/comp/specialization-constant-workgroup.asm.comp create mode 100644 shaders/asm/comp/storage-buffer-basic.asm.comp create mode 100644 shaders/asm/frag/composite-construct-struct-no-swizzle.asm.frag create mode 100644 shaders/asm/frag/default-member-names.asm.frag create mode 100644 shaders/asm/frag/hlsl-sample-cmp-level-zero-cube.asm.frag create mode 100644 shaders/asm/frag/hlsl-sample-cmp-level-zero.asm.frag create mode 100644 shaders/asm/frag/inliner-dominator-inside-loop.asm.frag create mode 100644 shaders/asm/frag/invalidation.asm.frag create mode 100644 shaders/asm/frag/loop-body-dominator-continue-access.asm.frag create mode 100644 shaders/asm/frag/loop-header-to-continue.asm.frag create mode 100644 shaders/asm/frag/multi-for-loop-init.asm.frag create mode 100644 shaders/asm/frag/op-constant-null.asm.frag create mode 100644 shaders/asm/frag/phi-loop-variable.asm.frag create mode 100644 shaders/asm/frag/sampler-buffer-without-sampler.asm.frag create mode 100644 shaders/asm/frag/struct-composite-extract-swizzle.asm.frag create mode 100644 shaders/asm/frag/temporary-phi-hoisting.asm.frag create mode 100644 shaders/asm/frag/undef-variable-store.asm.frag create mode 100644 shaders/asm/frag/unreachable.asm.frag create mode 100644 shaders/asm/frag/vector-shuffle-oom.asm.frag create mode 100644 shaders/asm/tesc/tess-fixed-input-array-builtin-array.asm.tesc create mode 100644 shaders/asm/vert/empty-io.asm.vert create mode 100644 shaders/asm/vert/empty-struct-composite.asm.vert create mode 100644 shaders/asm/vert/global-builtin.sso.asm.vert create mode 100644 shaders/comp/atomic.comp create mode 100644 shaders/comp/bake_gradient.comp create mode 100644 shaders/comp/barriers.comp create mode 100644 shaders/comp/basic.comp create mode 100644 shaders/comp/bitfield.noopt.comp create mode 100644 shaders/comp/casts.comp create mode 100644 shaders/comp/cfg-preserve-parameter.comp create mode 100644 shaders/comp/cfg.comp create mode 100644 shaders/comp/coherent-block.comp create mode 100644 shaders/comp/coherent-image.comp create mode 100644 shaders/comp/composite-construct.comp create mode 100644 shaders/comp/culling.comp create mode 100644 shaders/comp/defer-parens.comp create mode 100644 shaders/comp/dowhile.comp create mode 100644 shaders/comp/generate_height.comp create mode 100644 shaders/comp/image.comp create mode 100644 shaders/comp/inout-struct.invalid.comp create mode 100644 shaders/comp/insert.comp create mode 100644 shaders/comp/loop.noopt.comp create mode 100644 shaders/comp/mat3.comp create mode 100644 shaders/comp/mod.comp create mode 100644 shaders/comp/modf.comp create mode 100644 shaders/comp/read-write-only.comp create mode 100644 shaders/comp/return.comp create mode 100644 shaders/comp/rmw-opt.comp create mode 100644 shaders/comp/shared.comp create mode 100644 shaders/comp/ssbo-array.comp create mode 100644 shaders/comp/struct-layout.comp create mode 100644 shaders/comp/struct-packing.comp create mode 100644 shaders/comp/torture-loop.comp create mode 100644 shaders/comp/type-alias.comp create mode 100644 shaders/comp/udiv.comp create mode 100644 shaders/desktop-only/comp/enhanced-layouts.comp create mode 100644 shaders/desktop-only/comp/fp64.desktop.comp create mode 100644 shaders/desktop-only/comp/image-formats.desktop.noeliminate.comp create mode 100644 shaders/desktop-only/comp/int64.desktop.comp create mode 100644 shaders/desktop-only/frag/hlsl-uav-block-alias.asm.frag create mode 100644 shaders/desktop-only/frag/image-ms.desktop.frag create mode 100644 shaders/desktop-only/frag/image-query.desktop.frag create mode 100644 shaders/desktop-only/frag/in-block-qualifiers.frag create mode 100644 shaders/desktop-only/frag/query-levels.desktop.frag create mode 100644 shaders/desktop-only/frag/query-lod.desktop.frag create mode 100644 shaders/desktop-only/frag/sampler-ms-query.desktop.frag create mode 100644 shaders/desktop-only/frag/texture-proj-shadow.desktop.frag create mode 100644 shaders/desktop-only/geom/basic.desktop.sso.geom create mode 100644 shaders/desktop-only/geom/viewport-index.desktop.geom create mode 100644 shaders/desktop-only/tesc/basic.desktop.sso.tesc create mode 100644 shaders/desktop-only/tese/triangle.desktop.sso.tese create mode 100644 shaders/desktop-only/vert/basic.desktop.sso.vert create mode 100644 shaders/desktop-only/vert/clip-cull-distance.desktop.vert create mode 100644 shaders/desktop-only/vert/out-block-qualifiers.vert create mode 100644 shaders/flatten/array.flatten.vert create mode 100644 shaders/flatten/basic.flatten.vert create mode 100644 shaders/flatten/copy.flatten.vert create mode 100644 shaders/flatten/dynamic.flatten.vert create mode 100644 shaders/flatten/matrixindex.flatten.vert create mode 100644 shaders/flatten/multi-dimensional.desktop.flatten_dim.frag create mode 100644 shaders/flatten/multiindex.flatten.vert create mode 100644 shaders/flatten/push-constant.flatten.vert create mode 100644 shaders/flatten/rowmajor.flatten.vert create mode 100644 shaders/flatten/struct.flatten.vert create mode 100644 shaders/flatten/struct.rowmajor.flatten.vert create mode 100644 shaders/flatten/swizzle.flatten.vert create mode 100644 shaders/flatten/types.flatten.frag create mode 100644 shaders/frag/basic.frag create mode 100644 shaders/frag/composite-extract-forced-temporary.frag create mode 100644 shaders/frag/constant-array.frag create mode 100644 shaders/frag/constant-composites.frag create mode 100644 shaders/frag/false-loop-init.frag create mode 100644 shaders/frag/flush_params.frag create mode 100644 shaders/frag/for-loop-init.frag create mode 100644 shaders/frag/frexp-modf.frag create mode 100755 shaders/frag/ground.frag create mode 100644 shaders/frag/image-load-store-uint-coord.asm.frag create mode 100644 shaders/frag/mix.frag create mode 100644 shaders/frag/partial-write-preserve.frag create mode 100644 shaders/frag/pls.frag create mode 100644 shaders/frag/sample-parameter.frag create mode 100644 shaders/frag/sampler-ms.frag create mode 100644 shaders/frag/sampler-proj.frag create mode 100644 shaders/frag/sampler.frag create mode 100644 shaders/frag/swizzle.frag create mode 100644 shaders/frag/ubo_layout.frag create mode 100644 shaders/frag/unary-enclose.frag create mode 100644 shaders/geom/basic.geom create mode 100644 shaders/geom/lines-adjacency.geom create mode 100644 shaders/geom/lines.geom create mode 100644 shaders/geom/points.geom create mode 100644 shaders/geom/single-invocation.geom create mode 100644 shaders/geom/triangles-adjacency.geom create mode 100644 shaders/geom/triangles.geom create mode 100644 shaders/legacy/fragment/explicit-lod.legacy.frag create mode 100644 shaders/legacy/fragment/io-blocks.legacy.frag create mode 100644 shaders/legacy/fragment/struct-varying.legacy.frag create mode 100644 shaders/legacy/vert/implicit-lod.legacy.vert create mode 100644 shaders/legacy/vert/io-block.legacy.vert create mode 100644 shaders/legacy/vert/struct-varying.legacy.vert create mode 100644 shaders/legacy/vert/transpose.legacy.vert create mode 100644 shaders/tesc/basic.tesc create mode 100644 shaders/tesc/water_tess.tesc create mode 100644 shaders/tese/ccw.tese create mode 100644 shaders/tese/cw.tese create mode 100644 shaders/tese/equal.tese create mode 100644 shaders/tese/fractional_even.tese create mode 100644 shaders/tese/fractional_odd.tese create mode 100644 shaders/tese/line.tese create mode 100644 shaders/tese/triangle.tese create mode 100644 shaders/tese/water_tess.tese create mode 100644 shaders/vert/basic.vert create mode 100755 shaders/vert/ground.vert create mode 100644 shaders/vert/ocean.vert create mode 100644 shaders/vert/texture_buffer.vert create mode 100644 shaders/vert/ubo.vert create mode 100644 shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag create mode 100644 shaders/vulkan/frag/combined-texture-sampler.vk.frag create mode 100644 shaders/vulkan/frag/desktop-mediump.vk.frag create mode 100644 shaders/vulkan/frag/input-attachment-ms.vk.frag create mode 100644 shaders/vulkan/frag/input-attachment.vk.frag create mode 100644 shaders/vulkan/frag/push-constant.vk.frag create mode 100644 shaders/vulkan/frag/separate-sampler-texture.vk.frag create mode 100644 shaders/vulkan/frag/spec-constant.vk.frag create mode 100644 shaders/vulkan/vert/multiview.nocompat.vk.vert create mode 100644 shaders/vulkan/vert/vulkan-vertex.vk.vert create mode 100644 spirv.hpp create mode 100644 spirv_cfg.cpp create mode 100644 spirv_cfg.hpp create mode 100644 spirv_common.hpp create mode 100644 spirv_cpp.cpp create mode 100644 spirv_cpp.hpp create mode 100644 spirv_cross.cpp create mode 100644 spirv_cross.hpp create mode 100644 spirv_glsl.cpp create mode 100644 spirv_glsl.hpp create mode 100644 spirv_hlsl.cpp create mode 100644 spirv_hlsl.hpp create mode 100644 spirv_msl.cpp create mode 100644 spirv_msl.hpp create mode 100755 test_shaders.py create mode 100755 test_shaders.sh create mode 100755 update_test_shaders.sh diff --git a/.clang-format b/.clang-format new file mode 100755 index 0000000000..443f90b774 --- /dev/null +++ b/.clang-format @@ -0,0 +1,167 @@ +# The style used for all options not specifically set in the configuration. +BasedOnStyle: LLVM + +# The extra indent or outdent of access modifiers, e.g. public:. +AccessModifierOffset: -4 + +# If true, aligns escaped newlines as far left as possible. Otherwise puts them into the right-most column. +AlignEscapedNewlinesLeft: true + +# If true, aligns trailing comments. +AlignTrailingComments: false + +# Allow putting all parameters of a function declaration onto the next line even if BinPackParameters is false. +AllowAllParametersOfDeclarationOnNextLine: false + +# Allows contracting simple braced statements to a single line. +AllowShortBlocksOnASingleLine: false + +# If true, short case labels will be contracted to a single line. +AllowShortCaseLabelsOnASingleLine: false + +# Dependent on the value, int f() { return 0; } can be put on a single line. Possible values: None, Inline, All. +AllowShortFunctionsOnASingleLine: None + +# If true, if (a) return; can be put on a single line. +AllowShortIfStatementsOnASingleLine: false + +# If true, while (true) continue; can be put on a single line. +AllowShortLoopsOnASingleLine: false + +# If true, always break after function definition return types. +AlwaysBreakAfterDefinitionReturnType: false + +# If true, always break before multiline string literals. +AlwaysBreakBeforeMultilineStrings: false + +# If true, always break after the template<...> of a template declaration. +AlwaysBreakTemplateDeclarations: true + +# If false, a function call's arguments will either be all on the same line or will have one line each. +BinPackArguments: true + +# If false, a function declaration's or function definition's parameters will either all be on the same line +# or will have one line each. +BinPackParameters: true + +# The way to wrap binary operators. Possible values: None, NonAssignment, All. +BreakBeforeBinaryOperators: None + +# The brace breaking style to use. Possible values: Attach, Linux, Stroustrup, Allman, GNU. +BreakBeforeBraces: Allman + +# If true, ternary operators will be placed after line breaks. +BreakBeforeTernaryOperators: false + +# Always break constructor initializers before commas and align the commas with the colon. +BreakConstructorInitializersBeforeComma: true + +# The column limit. A column limit of 0 means that there is no column limit. +ColumnLimit: 120 + +# A regular expression that describes comments with special meaning, which should not be split into lines or otherwise changed. +CommentPragmas: '^ *' + +# If the constructor initializers don't fit on a line, put each initializer on its own line. +ConstructorInitializerAllOnOneLineOrOnePerLine: false + +# The number of characters to use for indentation of constructor initializer lists. +ConstructorInitializerIndentWidth: 4 + +# Indent width for line continuations. +ContinuationIndentWidth: 4 + +# If true, format braced lists as best suited for C++11 braced lists. +Cpp11BracedListStyle: false + +# Disables formatting at all. +DisableFormat: false + +# A vector of macros that should be interpreted as foreach loops instead of as function calls. +#ForEachMacros: '' + +# Indent case labels one level from the switch statement. +# When false, use the same indentation level as for the switch statement. +# Switch statement body is always indented one level more than case labels. +IndentCaseLabels: false + +# The number of columns to use for indentation. +IndentWidth: 4 + +# Indent if a function definition or declaration is wrapped after the type. +IndentWrappedFunctionNames: false + +# If true, empty lines at the start of blocks are kept. +KeepEmptyLinesAtTheStartOfBlocks: true + +# Language, this format style is targeted at. Possible values: None, Cpp, Java, JavaScript, Proto. +Language: Cpp + +# The maximum number of consecutive empty lines to keep. +MaxEmptyLinesToKeep: 1 + +# The indentation used for namespaces. Possible values: None, Inner, All. +NamespaceIndentation: None + +# The penalty for breaking a function call after "call(". +PenaltyBreakBeforeFirstCallParameter: 19 + +# The penalty for each line break introduced inside a comment. +PenaltyBreakComment: 300 + +# The penalty for breaking before the first <<. +PenaltyBreakFirstLessLess: 120 + +# The penalty for each line break introduced inside a string literal. +PenaltyBreakString: 1000 + +# The penalty for each character outside of the column limit. +PenaltyExcessCharacter: 1000000 + +# Penalty for putting the return type of a function onto its own line. +PenaltyReturnTypeOnItsOwnLine: 1000000000 + +# Pointer and reference alignment style. Possible values: Left, Right, Middle. +PointerAlignment: Right + +# If true, a space may be inserted after C style casts. +SpaceAfterCStyleCast: false + +# If false, spaces will be removed before assignment operators. +SpaceBeforeAssignmentOperators: true + +# Defines in which cases to put a space before opening parentheses. Possible values: Never, ControlStatements, Always. +SpaceBeforeParens: ControlStatements + +# If true, spaces may be inserted into '()'. +SpaceInEmptyParentheses: false + +# The number of spaces before trailing line comments (// - comments). +SpacesBeforeTrailingComments: 1 + +# If true, spaces will be inserted after '<' and before '>' in template argument lists. +SpacesInAngles: false + +# If true, spaces may be inserted into C style casts. +SpacesInCStyleCastParentheses: false + +# If true, spaces are inserted inside container literals (e.g. ObjC and Javascript array and dict literals). +SpacesInContainerLiterals: false + +# If true, spaces will be inserted after '(' and before ')'. +SpacesInParentheses: false + +# If true, spaces will be inserted after '[' and befor']'. +SpacesInSquareBrackets: false + +# Format compatible with this standard, e.g. use A > instead of A> for LS_Cpp03. Possible values: Cpp03, Cpp11, Auto. +Standard: Cpp11 + +# The number of columns used for tab stops. +TabWidth: 4 + +# The way to use tab characters in the resulting file. Possible values: Never, ForIndentation, Always. +UseTab: ForIndentation + +# Do not reflow comments +ReflowComments: false diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..b89f729741 --- /dev/null +++ b/.gitignore @@ -0,0 +1,19 @@ +*.o +*.d +*.txt +/test +/spirv-cross +*.spv +/obj +/msvc/x64 +/msvc/Debug +/msvc/Release +*.suo +*.sdf +*.opensdf +*.shader +*.a +*.bc +/external + +!CMakeLists.txt diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000..21af2a0203 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,33 @@ +language: cpp +os: + - linux + - osx +osx_image: xcode8.2 + +# Use Ubuntu 14.04 LTS (Trusty) as the Linux testing environment. +sudo: required +dist: trusty + +# We check out glslang and SPIRV-Tools at specific revisions to avoid test output mismatches +env: + - GLSLANG_REV=9c6f8cc29ba303b43ccf36deea6bb38a304f9b92 SPIRV_TOOLS_REV=e28edd458b729da7bbfd51e375feb33103709e6f + +before_script: + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; brew install 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 + +script: + - git -C glslang checkout $GLSLANG_REV + - git -C SPIRV-Tools checkout $SPIRV_TOOLS_REV + - cd glslang && cmake . && make -j2 && cd .. + - cd SPIRV-Tools && cmake . && make -j2 && cd .. + - make -j2 + - PATH=./glslang/StandAlone:./SPIRV-Tools/tools:$PATH + - ./test_shaders.py shaders + - ./test_shaders.py --msl shaders-msl + - ./test_shaders.py --hlsl shaders-hlsl + - ./test_shaders.py shaders --opt + - ./test_shaders.py --msl shaders-msl --opt + - ./test_shaders.py --hlsl shaders-hlsl --opt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000000..cd3f677475 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,145 @@ +# Copyright 2016 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +cmake_minimum_required(VERSION 2.8) +project(SPIRV-Cross) +enable_testing() + +option(SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS "Instead of throwing exceptions assert" OFF) + +if(${CMAKE_GENERATOR} MATCHES "Makefile") + if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR}) + message(FATAL_ERROR "Build out of tree to avoid overwriting Makefile") + endif() +endif() + +set(spirv-compiler-options "") +set(spirv-compiler-defines "") + +if(SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS) + set(spirv-compiler-defines ${spirv-compiler-defines} SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS) +endif() + +# To specify special debug or optimization options, use +# -DCMAKE_CXX_COMPILE_FLAGS +# However, we require the C++11 dialect. +if (NOT "${MSVC}") + set(spirv-compiler-options ${spirv-compiler-options} -std=c++11 -Wall -Wextra -Werror -Wshadow) + set(spirv-compiler-defines ${spirv-compiler-defines} __STDC_LIMIT_MACROS) + + if(SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS) + set(spirv-compiler-options ${spirv-compiler-options} -fno-exceptions) + endif() +endif() + +macro(extract_headers out_abs file_list) + set(${out_abs}) # absolute paths + foreach(_a ${file_list}) + # get_filename_component only returns the longest extension, so use a regex + string(REGEX REPLACE ".*\\.(h|hpp)" "\\1" ext ${_a}) + if(("${ext}" STREQUAL "h") OR ("${ext}" STREQUAL "hpp")) + list(APPEND ${out_abs} "${_a}") + endif() + endforeach() +endmacro() + +macro(spirv_cross_add_library name config_name) + add_library(${name} ${ARGN}) + extract_headers(hdrs "${ARGN}") + target_include_directories(${name} PUBLIC + $ + $) + set_target_properties(${name} PROPERTIES + PUBLIC_HEADERS "${hdrs}") + target_compile_options(${name} PRIVATE ${spirv-compiler-options}) + target_compile_definitions(${name} PRIVATE ${spirv-compiler-defines}) + install(TARGETS ${name} + EXPORT ${config_name}Config + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib + PUBLIC_HEADER DESTINATION include/spirv_cross) + install(FILES ${hdrs} DESTINATION include/spirv_cross) + install(EXPORT ${config_name}Config DESTINATION share/${config_name}/cmake) + export(TARGETS ${targets} FILE ${config_name}Config.cmake) +endmacro() + + +spirv_cross_add_library(spirv-cross-core spirv_cross_core STATIC + ${CMAKE_CURRENT_SOURCE_DIR}/GLSL.std.450.h + ${CMAKE_CURRENT_SOURCE_DIR}/spirv_common.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/spirv.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/spirv_cross.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/spirv_cross.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/spirv_cfg.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/spirv_cfg.cpp) + +spirv_cross_add_library(spirv-cross-glsl spirv_cross_glsl STATIC + ${CMAKE_CURRENT_SOURCE_DIR}/spirv_glsl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/spirv_glsl.hpp) + +spirv_cross_add_library(spirv-cross-cpp spirv_cross_cpp STATIC + ${CMAKE_CURRENT_SOURCE_DIR}/spirv_cpp.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/spirv_cpp.cpp) + +spirv_cross_add_library(spirv-cross-msl spirv_cross_msl STATIC + ${CMAKE_CURRENT_SOURCE_DIR}/spirv_msl.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/spirv_msl.cpp) + +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) + +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-glsl spirv-cross-core) +target_link_libraries(spirv-cross-msl spirv-cross-glsl) +target_link_libraries(spirv-cross-hlsl spirv-cross-glsl) +target_link_libraries(spirv-cross-cpp spirv-cross-glsl) + +# Set up tests, using only the simplest modes of the test_shaders +# script. You have to invoke the script manually to: +# - Update the reference files +# - Get cycle counts from malisc +# - Keep failing outputs +find_package(PythonInterp) +if (${PYTHONINTERP_FOUND}) + if (${PYTHON_VERSION_MAJOR} GREATER 2) + add_test(NAME spirv-cross-test + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_shaders.py + ${CMAKE_CURRENT_SOURCE_DIR}/shaders) + add_test(NAME spirv-cross-test-metal + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_shaders.py --metal + ${CMAKE_CURRENT_SOURCE_DIR}/shaders-msl) + add_test(NAME spirv-cross-test-hlsl + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_shaders.py --hlsl + ${CMAKE_CURRENT_SOURCE_DIR}/shaders-hlsl) + add_test(NAME spirv-cross-test-opt + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_shaders.py --opt + ${CMAKE_CURRENT_SOURCE_DIR}/shaders) + add_test(NAME spirv-cross-test-metal-opt + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_shaders.py --metal --opt + ${CMAKE_CURRENT_SOURCE_DIR}/shaders-msl) + add_test(NAME spirv-cross-test-hlsl-opt + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_shaders.py --hlsl --opt + ${CMAKE_CURRENT_SOURCE_DIR}/shaders-hlsl) + endif() +else() + message(WARNING "Testing disabled. Could not find python3. If you have python3 installed try running " + "cmake with -DPYTHON_EXECUTABLE:FILEPATH=/path/to/python3 to help it find the executable") +endif() diff --git a/GLSL.std.450.h b/GLSL.std.450.h new file mode 100644 index 0000000000..54cc00e9a8 --- /dev/null +++ b/GLSL.std.450.h @@ -0,0 +1,131 @@ +/* +** Copyright (c) 2014-2016 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a copy +** of this software and/or associated documentation files (the "Materials"), +** to deal in the Materials without restriction, including without limitation +** the rights to use, copy, modify, merge, publish, distribute, sublicense, +** and/or sell copies of the Materials, and to permit persons to whom the +** Materials are furnished to do so, subject to the following conditions: +** +** The above copyright notice and this permission notice shall be included in +** all copies or substantial portions of the Materials. +** +** MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS +** STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND +** HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +** OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +** THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +** FROM,OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS +** IN THE MATERIALS. +*/ + +#ifndef GLSLstd450_H +#define GLSLstd450_H + +static const int GLSLstd450Version = 100; +static const int GLSLstd450Revision = 3; + +enum GLSLstd450 { + GLSLstd450Bad = 0, // Don't use + + GLSLstd450Round = 1, + GLSLstd450RoundEven = 2, + GLSLstd450Trunc = 3, + GLSLstd450FAbs = 4, + GLSLstd450SAbs = 5, + GLSLstd450FSign = 6, + GLSLstd450SSign = 7, + GLSLstd450Floor = 8, + GLSLstd450Ceil = 9, + GLSLstd450Fract = 10, + + GLSLstd450Radians = 11, + GLSLstd450Degrees = 12, + GLSLstd450Sin = 13, + GLSLstd450Cos = 14, + GLSLstd450Tan = 15, + GLSLstd450Asin = 16, + GLSLstd450Acos = 17, + GLSLstd450Atan = 18, + GLSLstd450Sinh = 19, + GLSLstd450Cosh = 20, + GLSLstd450Tanh = 21, + GLSLstd450Asinh = 22, + GLSLstd450Acosh = 23, + GLSLstd450Atanh = 24, + GLSLstd450Atan2 = 25, + + GLSLstd450Pow = 26, + GLSLstd450Exp = 27, + GLSLstd450Log = 28, + GLSLstd450Exp2 = 29, + GLSLstd450Log2 = 30, + GLSLstd450Sqrt = 31, + GLSLstd450InverseSqrt = 32, + + GLSLstd450Determinant = 33, + GLSLstd450MatrixInverse = 34, + + GLSLstd450Modf = 35, // second operand needs an OpVariable to write to + GLSLstd450ModfStruct = 36, // no OpVariable operand + GLSLstd450FMin = 37, + GLSLstd450UMin = 38, + GLSLstd450SMin = 39, + GLSLstd450FMax = 40, + GLSLstd450UMax = 41, + GLSLstd450SMax = 42, + GLSLstd450FClamp = 43, + GLSLstd450UClamp = 44, + GLSLstd450SClamp = 45, + GLSLstd450FMix = 46, + GLSLstd450IMix = 47, // Reserved + GLSLstd450Step = 48, + GLSLstd450SmoothStep = 49, + + GLSLstd450Fma = 50, + GLSLstd450Frexp = 51, // second operand needs an OpVariable to write to + GLSLstd450FrexpStruct = 52, // no OpVariable operand + GLSLstd450Ldexp = 53, + + GLSLstd450PackSnorm4x8 = 54, + GLSLstd450PackUnorm4x8 = 55, + GLSLstd450PackSnorm2x16 = 56, + GLSLstd450PackUnorm2x16 = 57, + GLSLstd450PackHalf2x16 = 58, + GLSLstd450PackDouble2x32 = 59, + GLSLstd450UnpackSnorm2x16 = 60, + GLSLstd450UnpackUnorm2x16 = 61, + GLSLstd450UnpackHalf2x16 = 62, + GLSLstd450UnpackSnorm4x8 = 63, + GLSLstd450UnpackUnorm4x8 = 64, + GLSLstd450UnpackDouble2x32 = 65, + + GLSLstd450Length = 66, + GLSLstd450Distance = 67, + GLSLstd450Cross = 68, + GLSLstd450Normalize = 69, + GLSLstd450FaceForward = 70, + GLSLstd450Reflect = 71, + GLSLstd450Refract = 72, + + GLSLstd450FindILsb = 73, + GLSLstd450FindSMsb = 74, + GLSLstd450FindUMsb = 75, + + GLSLstd450InterpolateAtCentroid = 76, + GLSLstd450InterpolateAtSample = 77, + GLSLstd450InterpolateAtOffset = 78, + + GLSLstd450NMin = 79, + GLSLstd450NMax = 80, + GLSLstd450NClamp = 81, + + GLSLstd450Count +}; + +#endif // #ifndef GLSLstd450_H diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000..d645695673 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000..0564b650ad --- /dev/null +++ b/Makefile @@ -0,0 +1,41 @@ +TARGET := spirv-cross + +SOURCES := $(wildcard spirv_*.cpp) +CLI_SOURCES := main.cpp + +OBJECTS := $(SOURCES:.cpp=.o) +CLI_OBJECTS := $(CLI_SOURCES:.cpp=.o) + +STATIC_LIB := lib$(TARGET).a + +DEPS := $(OBJECTS:.o=.d) $(CLI_OBJECTS:.o=.d) + +CXXFLAGS += -std=c++11 -Wall -Wextra -Wshadow -D__STDC_LIMIT_MACROS + +ifeq ($(DEBUG), 1) + CXXFLAGS += -O0 -g +else + CXXFLAGS += -O2 -DNDEBUG +endif + +ifeq ($(SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS), 1) + CXXFLAGS += -DSPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS -fno-exceptions +endif + +all: $(TARGET) + +-include $(DEPS) + +$(TARGET): $(CLI_OBJECTS) $(STATIC_LIB) + $(CXX) -o $@ $(CLI_OBJECTS) $(STATIC_LIB) $(LDFLAGS) + +$(STATIC_LIB): $(OBJECTS) + $(AR) rcs $@ $(OBJECTS) + +%.o: %.cpp + $(CXX) -c -o $@ $< $(CXXFLAGS) -MMD + +clean: + rm -f $(TARGET) $(OBJECTS) $(CLI_OBJECTS) $(STATIC_LIB) $(DEPS) + +.PHONY: clean diff --git a/README.md b/README.md new file mode 100644 index 0000000000..e1409a4bf7 --- /dev/null +++ b/README.md @@ -0,0 +1,350 @@ +# SPIRV-Cross + +SPIRV-Cross is a tool designed for parsing and converting SPIR-V to other shader languages. + +[![Build Status](https://travis-ci.org/KhronosGroup/SPIRV-Cross.svg?branch=master)](https://travis-ci.org/KhronosGroup/SPIRV-Cross) + +## 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 debuggable C++ [EXPERIMENTAL] + - Reflection API to simplify the creation of Vulkan pipeline layouts + - Reflection API to modify and tweak OpDecorations + - Supports "all" of vertex, fragment, tessellation, geometry and compute shaders. + +SPIRV-Cross tries hard to emit readable and clean output from the SPIR-V. +The goal is to emit GLSL or MSL that looks like it was written by a human and not awkward IR/assembly-like code. + +NOTE: Individual features are expected to be mostly complete, but it is possible that certain obscure GLSL features are not yet supported. +However, most missing features are expected to be "trivial" improvements at this stage. + +## Building + +SPIRV-Cross has been tested on Linux, OSX and Windows. + +The make and CMake build flavors offer the option to treat exceptions as assertions. To disable exceptions for make just append SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS=1 to the command line. For CMake append -DSPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS=ON. By default exceptions are enabled. + +### Linux and macOS + +Just run `make` on the command line. A recent GCC (4.8+) or Clang (3.x+) compiler is required as SPIRV-Cross uses C++11 extensively. + +### Windows + +MinGW-w64 based compilation works with `make`, and an MSVC 2013 solution is also included. + +## Usage + +### Using the C++ API + +To perform reflection and convert to other shader languages you can use the SPIRV-Cross API. +For example: + +``` +#include "spirv_glsl.hpp" +#include +#include + +extern std::vector load_spirv_file(); + +int main() +{ + // Read SPIR-V from disk or similar. + std::vector spirv_binary = load_spirv_file(); + + spirv_cross::CompilerGLSL glsl(std::move(spirv_binary)); + + // The SPIR-V is now parsed, and we can perform reflection on it. + spirv_cross::ShaderResources resources = glsl.get_shader_resources(); + + // Get all sampled images in the shader. + for (auto &resource : resources.sampled_images) + { + unsigned set = glsl.get_decoration(resource.id, spv::DecorationDescriptorSet); + unsigned binding = glsl.get_decoration(resource.id, spv::DecorationBinding); + printf("Image %s at set = %u, binding = %u\n", resource.name.c_str(), set, binding); + + // Modify the decoration to prepare it for GLSL. + glsl.unset_decoration(resource.id, spv::DecorationDescriptorSet); + + // Some arbitrary remapping if we want. + glsl.set_decoration(resource.id, spv::DecorationBinding, set * 16 + binding); + } + + // Set some options. + spirv_cross::CompilerGLSL::Options options; + options.version = 310; + options.es = true; + glsl.set_options(options); + + // Compile to GLSL, ready to give to GL driver. + std::string source = glsl.compile(); +} +``` + +#### Integrating SPIRV-Cross in a custom build system + +To add SPIRV-Cross to your own codebase, just copy the source and header files from root directory +and build the relevant .cpp files you need. Make sure to build with C++11 support, e.g. `-std=c++11` in GCC and Clang. +Alternatively, the Makefile generates a libspirv-cross.a static library during build that can be linked in. + +### Creating a SPIR-V file from GLSL with glslang + +``` +glslangValidator -H -V -o test.spv test.frag +``` + +### Converting a SPIR-V file to GLSL ES + +``` +glslangValidator -H -V -o test.spv shaders/comp/basic.comp +./spirv-cross --version 310 --es test.spv +``` + +#### Converting to desktop GLSL + +``` +glslangValidator -H -V -o test.spv shaders/comp/basic.comp +./spirv-cross --version 330 test.spv --output test.comp +``` + +#### Disable prettifying optimizations + +``` +glslangValidator -H -V -o test.spv shaders/comp/basic.comp +./spirv-cross --version 310 --es test.spv --output test.comp --force-temporary +``` + +### Using shaders generated from C++ backend + +Please see `samples/cpp` where some GLSL shaders are compiled to SPIR-V, decompiled to C++ and run with test data. +Reading through the samples should explain how to use the C++ interface. +A simple Makefile is included to build all shaders in the directory. + +### Implementation notes + +When using SPIR-V and SPIRV-Cross as an intermediate step for cross-compiling between high level languages there are some considerations to take into account, +as not all features used by one high-level language are necessarily supported natively by the target shader language. +SPIRV-Cross aims to provide the tools needed to handle these scenarios in a clean and robust way, but some manual action is required to maintain compatibility. + +#### HLSL source to GLSL + +##### HLSL entry points + +When using SPIR-V shaders compiled from HLSL, there are some extra things you need to take care of. +First make sure that the entry point is used correctly. +If you forget to set the entry point correctly in glslangValidator (-e MyFancyEntryPoint), +you will likely encounter this error message: + +``` +Cannot end a function before ending the current block. +Likely cause: If this SPIR-V was created from glslang HLSL, make sure the entry point is valid. +``` + +##### Vertex/Fragment interface linking + +HLSL relies on semantics in order to effectively link together shader stages. In the SPIR-V generated by glslang, the transformation from HLSL to GLSL ends up looking like + +``` +struct VSOutput { + // SV_Position is rerouted to gl_Position + float4 position : SV_Position; + float4 coord : TEXCOORD0; +}; + +VSOutput main(...) {} +``` + +``` +struct VSOutput { + float4 coord; +} +layout(location = 0) out VSOutput _magicNameGeneratedByGlslang; +``` + +While this works, be aware of the type of the struct which is used in the vertex stage and the fragment stage. +There may be issues if the structure type name differs in vertex stage and fragment stage. + +You can make use of the reflection interface to force the name of the struct type. + +``` +// Something like this for both vertex outputs and fragment inputs. +compiler.set_name(varying_resource.base_type_id, "VertexFragmentLinkage"); +``` + +Some platform may require identical variable name for both vertex outputs and fragment inputs. (for example MacOSX) +to rename varaible base on location, please add +``` +--rename-interface-variable +``` + +#### HLSL source to legacy GLSL/ESSL + +HLSL tends to emit varying struct types to pass data between vertex and fragment. +This is not supported in legacy GL/GLES targets, so to support this, varying structs are flattened. +This is done automatically, but the API user might need to be aware that this is happening in order to support all cases. + +Modern GLES code like this: +``` +struct Output { + vec4 a; + vec2 b; +}; +out Output vout; +``` + +Is transformed into: +``` +struct Output { + vec4 a; + vec2 b; +}; +varying vec4 Output_a; +varying vec2 Output_b; +``` + +Note that now, both the struct name and the member names will participate in the linking interface between vertex and fragment, so +API users might want to ensure that both the struct names and member names match so that vertex outputs and fragment inputs can link properly. + + +#### Separate image samplers (HLSL/Vulkan) for backends which do not support it (GLSL) + +Another thing you need to remember is when using samplers and textures in HLSL these are separable, and not directly compatible with GLSL. If you need to use this with desktop GL/GLES, you need to call `Compiler::build_combined_image_samplers` first before calling `Compiler::compile`, or you will get an exception. + +``` +// From main.cpp +// Builds a mapping for all combinations of images and samplers. +compiler->build_combined_image_samplers(); + +// Give the remapped combined samplers new names. +// Here you can also set up decorations if you want (binding = #N). +for (auto &remap : compiler->get_combined_image_samplers()) +{ + compiler->set_name(remap.combined_id, join("SPIRV_Cross_Combined", compiler->get_name(remap.image_id), + compiler->get_name(remap.sampler_id))); +} +``` + +If your target is Vulkan GLSL, `--vulkan-semantics` will emit separate image samplers as you'd expect. +The command line client calls `Compiler::build_combined_image_samplers` automatically, but if you're calling the library, you'll need to do this yourself. + +#### Descriptor sets (Vulkan GLSL) for backends which do not support them (HLSL/GLSL/Metal) + +Descriptor sets are unique to Vulkan, so make sure that descriptor set + binding is remapped to a flat binding scheme (set always 0), so that other APIs can make sense of the bindings. +This can be done with `Compiler::set_decoration(id, spv::DecorationDescriptorSet)`. + +#### Linking by name for targets which do not support explicit locations (legacy GLSL/ESSL) + +Modern GLSL and HLSL sources (and SPIR-V) relies on explicit layout(location) qualifiers to guide the linking process between shader stages, +but older GLSL relies on symbol names to perform the linking. When emitting shaders with older versions, these layout statements will be removed, +so it is important that the API user ensures that the names of I/O variables are sanitized so that linking will work properly. +The reflection API can rename variables, struct types and struct members to deal with these scenarios using `Compiler::set_name` and friends. + +#### Clip-space conventions + +SPIRV-Cross can perform some common clip space conversions on gl_Position/SV_Position by enabling `CompilerGLSL::Options.vertex.fixup_clipspace`. +While this can be convenient, it is recommended to modify the projection matrices instead as that can achieve the same result. + +For GLSL targets, enabling this will convert a shader which assumes `[0, w]` depth range (Vulkan / D3D / Metal) into `[-w, w]` range. +For MSL and HLSL targets, enabling this will convert a shader in `[-w, w]` depth range (OpenGL) to `[0, w]` depth range. + +By default, the CLI will not enable `fixup_clipspace`, but in the API you might want to set an explicit value using `CompilerGLSL::set_options()`. + +Y-flipping of gl_Position and similar is also supported. +The use of this is discouraged, because relying on vertex shader Y-flipping tends to get quite messy. +To enable this, set `CompilerGLSL::Options.vertex.flip_vert_y` or `--flip-vert-y` in CLI. + +## Contributing + +Contributions to SPIRV-Cross are welcome. See Testing and Licensing sections for details. + +### Testing + +SPIRV-Cross maintains a test suite of shaders with reference output of how the output looks after going through a roundtrip through +glslangValidator then back through SPIRV-Cross again. The reference files are stored inside the repository in order to be able to track regressions. + +All pull requests should ensure that test output does not change unexpectedly. This can be tested with: + +``` +./test_shaders.py shaders +./test_shaders.py shaders --opt +./test_shaders.py shaders-hlsl --hlsl +./test_shaders.py shaders-hlsl --hlsl --opt +./test_shaders.py shaders-msl --msl +./test_shaders.py shaders-msl --msl --opt +``` + +although there are a couple of convenience script for doing this: + +``` +./checkout_glslang_spirv_tools.sh # Checks out glslang and SPIRV-Tools at a fixed revision which matches the reference output. +./test_shaders.sh # Runs over all changes and makes sure that there are no deltas compared to reference files. +``` + +However, when improving SPIRV-Cross there are of course legitimate cases where reference output should change. +In these cases, run: + +``` +./update_test_shaders.sh +``` + +to update the reference files and include these changes as part of the pull request. +Always make sure you are running the correct version of glslangValidator as well as SPIRV-Tools when updating reference files. +See `checkout_glslang_spirv_tools.sh`. + +In short, the master branch should always be able to run `./test_shaders.py shaders` and friends without failure. +SPIRV-Cross uses Travis CI to test all pull requests, so it is not strictly needed to perform testing yourself if you have problems running it locally. +A pull request which does not pass testing on Travis will not be accepted however. + +When adding support for new features to SPIRV-Cross, a new shader and reference file should be added which covers usage of the new shader features in question. + +### Licensing + +Contributors of new files should add a copyright header at the top of every new source code file with their copyright +along with the Apache 2.0 licensing stub. + +### Formatting + +SPIRV-Cross uses `clang-format` to automatically format code. +Please use `clang-format` with the style sheet found in `.clang-format` to automatically format code before submitting a pull request. + +To make things easy, the `format_all.sh` script can be used to format all +source files in the library. In this directory, run the following from the +command line: + + ./format_all.sh + +## ABI concerns + +### SPIR-V headers + +The current repository uses the latest SPIR-V and GLSL.std.450 headers. +SPIR-V files created from older headers could have ABI issues. + +## Regression testing + +In shaders/ a collection of shaders are maintained for purposes of regression testing. +The current reference output is contained in reference/. +`./test_shaders.py shaders` can be run to perform regression testing. + +See `./test_shaders.py --help` for more. + +### Metal backend + +To test the roundtrip path GLSL -> SPIR-V -> MSL, `--msl` can be added, e.g. `./test_shaders.py --msl shaders-msl`. + +### HLSL backend + +To test the roundtrip path GLSL -> SPIR-V -> HLSL, `--hlsl` can be added, e.g. `./test_shaders.py --hlsl shaders-hlsl`. + +### Updating regression tests + +When legitimate changes are found, use `--update` flag to update regression files. +Otherwise, `./test_shaders.py` will fail with error code. + +### Mali Offline Compiler cycle counts + +To obtain a CSV of static shader cycle counts before and after going through spirv-cross, add +`--malisc` flag to `./test_shaders`. This requires the Mali Offline Compiler to be installed in PATH. + diff --git a/checkout_glslang_spirv_tools.sh b/checkout_glslang_spirv_tools.sh new file mode 100755 index 0000000000..a4674c14e1 --- /dev/null +++ b/checkout_glslang_spirv_tools.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +GLSLANG_REV=9c6f8cc29ba303b43ccf36deea6bb38a304f9b92 +SPIRV_TOOLS_REV=e28edd458b729da7bbfd51e375feb33103709e6f + +if [ -d external/glslang ]; then + echo "Updating glslang to revision $GLSLANG_REV." + cd external/glslang + git fetch origin + git checkout $GLSLANG_REV +else + echo "Cloning glslang revision $GLSLANG_REV." + mkdir -p external + cd external + git clone git://github.com/KhronosGroup/glslang.git + cd glslang + git checkout $GLSLANG_REV +fi +cd ../.. + +echo "Building glslang." +mkdir -p external/glslang-build +cd external/glslang-build +cmake ../glslang -DCMAKE_BUILD_TYPE=Release -G"Unix Makefiles" +make -j$(nproc) +cd ../.. + +if [ -d external/spirv-tools ]; then + echo "Updating SPIRV-Tools to revision $SPIRV_TOOLS_REV." + cd external/spirv-tools + git fetch origin + git checkout $SPIRV_TOOLS_REV +else + echo "Cloning SPIRV-Tools revision $SPIRV_TOOLS_REV." + mkdir -p external + cd external + git clone git://github.com/KhronosGroup/SPIRV-Tools.git spirv-tools + cd spirv-tools + git checkout $SPIRV_TOOLS_REV + + if [ -d external/spirv-headers ]; then + cd external/spirv-headers + git pull origin master + cd ../.. + else + git clone git://github.com/KhronosGroup/SPIRV-Headers.git external/spirv-headers + fi +fi +cd ../.. + +echo "Building SPIRV-Tools." +mkdir -p external/spirv-tools-build +cd external/spirv-tools-build +cmake ../spirv-tools -DCMAKE_BUILD_TYPE=Release -G"Unix Makefiles" +make -j$(nproc) +cd ../.. + diff --git a/format_all.sh b/format_all.sh new file mode 100755 index 0000000000..05efeb3eae --- /dev/null +++ b/format_all.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +for file in spirv_*.{cpp,hpp} include/spirv_cross/*.{hpp,h} samples/cpp/*.cpp main.cpp +do + echo "Formatting file: $file ..." + clang-format -style=file -i $file +done diff --git a/include/spirv_cross/barrier.hpp b/include/spirv_cross/barrier.hpp new file mode 100644 index 0000000000..bfcd228431 --- /dev/null +++ b/include/spirv_cross/barrier.hpp @@ -0,0 +1,79 @@ +/* + * Copyright 2015-2017 ARM Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SPIRV_CROSS_BARRIER_HPP +#define SPIRV_CROSS_BARRIER_HPP + +#include +#include + +namespace spirv_cross +{ +class Barrier +{ +public: + Barrier() + { + count.store(0); + iteration.store(0); + } + + void set_release_divisor(unsigned divisor) + { + this->divisor = divisor; + } + + static inline void memoryBarrier() + { + std::atomic_thread_fence(std::memory_order_seq_cst); + } + + void reset_counter() + { + count.store(0); + iteration.store(0); + } + + void wait() + { + unsigned target_iteration = iteration.load(std::memory_order_relaxed) + 1; + // Overflows cleanly. + unsigned target_count = divisor * target_iteration; + + // Barriers don't enforce memory ordering. + // Be as relaxed about the barrier as we possibly can! + unsigned c = count.fetch_add(1u, std::memory_order_relaxed); + + if (c + 1 == target_count) + { + iteration.store(target_iteration, std::memory_order_relaxed); + } + else + { + // If we have more threads than the CPU, don't hog the CPU for very long periods of time. + while (iteration.load(std::memory_order_relaxed) != target_iteration) + std::this_thread::yield(); + } + } + +private: + unsigned divisor = 1; + std::atomic count; + std::atomic iteration; +}; +} + +#endif diff --git a/include/spirv_cross/external_interface.h b/include/spirv_cross/external_interface.h new file mode 100644 index 0000000000..1d26f1e1e4 --- /dev/null +++ b/include/spirv_cross/external_interface.h @@ -0,0 +1,126 @@ +/* + * Copyright 2015-2017 ARM Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SPIRV_CROSS_EXTERNAL_INTERFACE_H +#define SPIRV_CROSS_EXTERNAL_INTERFACE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +typedef struct spirv_cross_shader spirv_cross_shader_t; + +struct spirv_cross_interface +{ + spirv_cross_shader_t *(*construct)(void); + void (*destruct)(spirv_cross_shader_t *thiz); + void (*invoke)(spirv_cross_shader_t *thiz); +}; + +void spirv_cross_set_stage_input(spirv_cross_shader_t *thiz, unsigned location, void *data, size_t size); + +void spirv_cross_set_stage_output(spirv_cross_shader_t *thiz, unsigned location, void *data, size_t size); + +void spirv_cross_set_push_constant(spirv_cross_shader_t *thiz, void *data, size_t size); + +void spirv_cross_set_uniform_constant(spirv_cross_shader_t *thiz, unsigned location, void *data, size_t size); + +void spirv_cross_set_resource(spirv_cross_shader_t *thiz, unsigned set, unsigned binding, void **data, size_t size); + +const struct spirv_cross_interface *spirv_cross_get_interface(void); + +typedef enum spirv_cross_builtin { + SPIRV_CROSS_BUILTIN_POSITION = 0, + SPIRV_CROSS_BUILTIN_FRAG_COORD = 1, + SPIRV_CROSS_BUILTIN_WORK_GROUP_ID = 2, + SPIRV_CROSS_BUILTIN_NUM_WORK_GROUPS = 3, + SPIRV_CROSS_NUM_BUILTINS +} spirv_cross_builtin; + +void spirv_cross_set_builtin(spirv_cross_shader_t *thiz, spirv_cross_builtin builtin, void *data, size_t size); + +#define SPIRV_CROSS_NUM_DESCRIPTOR_SETS 4 +#define SPIRV_CROSS_NUM_DESCRIPTOR_BINDINGS 16 +#define SPIRV_CROSS_NUM_STAGE_INPUTS 16 +#define SPIRV_CROSS_NUM_STAGE_OUTPUTS 16 +#define SPIRV_CROSS_NUM_UNIFORM_CONSTANTS 32 + +enum spirv_cross_format +{ + SPIRV_CROSS_FORMAT_R8_UNORM = 0, + SPIRV_CROSS_FORMAT_R8G8_UNORM = 1, + SPIRV_CROSS_FORMAT_R8G8B8_UNORM = 2, + SPIRV_CROSS_FORMAT_R8G8B8A8_UNORM = 3, + + SPIRV_CROSS_NUM_FORMATS +}; + +enum spirv_cross_wrap +{ + SPIRV_CROSS_WRAP_CLAMP_TO_EDGE = 0, + SPIRV_CROSS_WRAP_REPEAT = 1, + + SPIRV_CROSS_NUM_WRAP +}; + +enum spirv_cross_filter +{ + SPIRV_CROSS_FILTER_NEAREST = 0, + SPIRV_CROSS_FILTER_LINEAR = 1, + + SPIRV_CROSS_NUM_FILTER +}; + +enum spirv_cross_mipfilter +{ + SPIRV_CROSS_MIPFILTER_BASE = 0, + SPIRV_CROSS_MIPFILTER_NEAREST = 1, + SPIRV_CROSS_MIPFILTER_LINEAR = 2, + + SPIRV_CROSS_NUM_MIPFILTER +}; + +struct spirv_cross_miplevel +{ + const void *data; + unsigned width, height; + size_t stride; +}; + +struct spirv_cross_sampler_info +{ + const struct spirv_cross_miplevel *mipmaps; + unsigned num_mipmaps; + + enum spirv_cross_format format; + enum spirv_cross_wrap wrap_s; + enum spirv_cross_wrap wrap_t; + enum spirv_cross_filter min_filter; + enum spirv_cross_filter mag_filter; + enum spirv_cross_mipfilter mip_filter; +}; + +typedef struct spirv_cross_sampler_2d spirv_cross_sampler_2d_t; +spirv_cross_sampler_2d_t *spirv_cross_create_sampler_2d(const struct spirv_cross_sampler_info *info); +void spirv_cross_destroy_sampler_2d(spirv_cross_sampler_2d_t *samp); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/spirv_cross/image.hpp b/include/spirv_cross/image.hpp new file mode 100644 index 0000000000..73de894f88 --- /dev/null +++ b/include/spirv_cross/image.hpp @@ -0,0 +1,62 @@ +/* + * Copyright 2015-2017 ARM Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SPIRV_CROSS_IMAGE_HPP +#define SPIRV_CROSS_IMAGE_HPP + +#ifndef GLM_SWIZZLE +#define GLM_SWIZZLE +#endif + +#ifndef GLM_FORCE_RADIANS +#define GLM_FORCE_RADIANS +#endif + +#include + +namespace spirv_cross +{ +template +struct image2DBase +{ + virtual ~image2DBase() = default; + inline virtual T load(glm::ivec2 coord) const + { + return T(0, 0, 0, 1); + } + inline virtual void store(glm::ivec2 coord, const T &v) + { + } +}; + +typedef image2DBase image2D; +typedef image2DBase iimage2D; +typedef image2DBase uimage2D; + +template +inline T imageLoad(const image2DBase &image, glm::ivec2 coord) +{ + return image.load(coord); +} + +template +void imageStore(image2DBase &image, glm::ivec2 coord, const T &value) +{ + image.store(coord, value); +} +} + +#endif diff --git a/include/spirv_cross/internal_interface.hpp b/include/spirv_cross/internal_interface.hpp new file mode 100644 index 0000000000..e56223dfdb --- /dev/null +++ b/include/spirv_cross/internal_interface.hpp @@ -0,0 +1,603 @@ +/* + * Copyright 2015-2017 ARM Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SPIRV_CROSS_INTERNAL_INTERFACE_HPP +#define SPIRV_CROSS_INTERNAL_INTERFACE_HPP + +// This file must only be included by the shader generated by spirv-cross! + +#ifndef GLM_FORCE_SWIZZLE +#define GLM_FORCE_SWIZZLE +#endif + +#ifndef GLM_FORCE_RADIANS +#define GLM_FORCE_RADIANS +#endif + +#include + +#include "barrier.hpp" +#include "external_interface.h" +#include "image.hpp" +#include "sampler.hpp" +#include "thread_group.hpp" +#include +#include + +namespace internal +{ +// Adaptor helpers to adapt GLSL access chain syntax to C++. +// Don't bother with arrays of arrays on uniforms ... +// Would likely need horribly complex variadic template munging. + +template +struct Interface +{ + enum + { + ArraySize = 1, + Size = sizeof(T) + }; + + Interface() + : ptr(0) + { + } + T &get() + { + assert(ptr); + return *ptr; + } + + T *ptr; +}; + +// For array types, return a pointer instead. +template +struct Interface +{ + enum + { + ArraySize = U, + Size = U * sizeof(T) + }; + + Interface() + : ptr(0) + { + } + T *get() + { + assert(ptr); + return ptr; + } + + T *ptr; +}; + +// For case when array size is 1, avoid double dereference. +template +struct PointerInterface +{ + enum + { + ArraySize = 1, + Size = sizeof(T *) + }; + enum + { + PreDereference = true + }; + + PointerInterface() + : ptr(0) + { + } + + T &get() + { + assert(ptr); + return *ptr; + } + + T *ptr; +}; + +// Automatically converts a pointer down to reference to match GLSL syntax. +template +struct DereferenceAdaptor +{ + DereferenceAdaptor(T **ptr) + : ptr(ptr) + { + } + T &operator[](unsigned index) const + { + return *(ptr[index]); + } + T **ptr; +}; + +// We can't have a linear array of T* since T* can be an abstract type in case of samplers. +// We also need a list of pointers since we can have run-time length SSBOs. +template +struct PointerInterface +{ + enum + { + ArraySize = U, + Size = sizeof(T *) * U + }; + enum + { + PreDereference = false + }; + PointerInterface() + : ptr(0) + { + } + + DereferenceAdaptor get() + { + assert(ptr); + return DereferenceAdaptor(ptr); + } + + T **ptr; +}; + +// Resources can be more abstract and be unsized, +// so we need to have an array of pointers for those cases. +template +struct Resource : PointerInterface +{ +}; + +// POD with no unknown sizes, so we can express these as flat arrays. +template +struct UniformConstant : Interface +{ +}; +template +struct StageInput : Interface +{ +}; +template +struct StageOutput : Interface +{ +}; +template +struct PushConstant : Interface +{ +}; +} + +struct spirv_cross_shader +{ + struct PPSize + { + PPSize() + : ptr(0) + , size(0) + { + } + void **ptr; + size_t size; + }; + + struct PPSizeResource + { + PPSizeResource() + : ptr(0) + , size(0) + , pre_dereference(false) + { + } + void **ptr; + size_t size; + bool pre_dereference; + }; + + PPSizeResource resources[SPIRV_CROSS_NUM_DESCRIPTOR_SETS][SPIRV_CROSS_NUM_DESCRIPTOR_BINDINGS]; + PPSize stage_inputs[SPIRV_CROSS_NUM_STAGE_INPUTS]; + PPSize stage_outputs[SPIRV_CROSS_NUM_STAGE_OUTPUTS]; + PPSize uniform_constants[SPIRV_CROSS_NUM_UNIFORM_CONSTANTS]; + PPSize push_constant; + PPSize builtins[SPIRV_CROSS_NUM_BUILTINS]; + + template + void register_builtin(spirv_cross_builtin builtin, const U &value) + { + assert(!builtins[builtin].ptr); + + builtins[builtin].ptr = (void **)&value.ptr; + builtins[builtin].size = sizeof(*value.ptr) * U::ArraySize; + } + + void set_builtin(spirv_cross_builtin builtin, void *data, size_t size) + { + assert(builtins[builtin].ptr); + assert(size >= builtins[builtin].size); + + *builtins[builtin].ptr = data; + } + + template + void register_resource(const internal::Resource &value, unsigned set, unsigned binding) + { + assert(set < SPIRV_CROSS_NUM_DESCRIPTOR_SETS); + assert(binding < SPIRV_CROSS_NUM_DESCRIPTOR_BINDINGS); + assert(!resources[set][binding].ptr); + + resources[set][binding].ptr = (void **)&value.ptr; + resources[set][binding].size = internal::Resource::Size; + resources[set][binding].pre_dereference = internal::Resource::PreDereference; + } + + template + void register_stage_input(const internal::StageInput &value, unsigned location) + { + assert(location < SPIRV_CROSS_NUM_STAGE_INPUTS); + assert(!stage_inputs[location].ptr); + + stage_inputs[location].ptr = (void **)&value.ptr; + stage_inputs[location].size = internal::StageInput::Size; + } + + template + void register_stage_output(const internal::StageOutput &value, unsigned location) + { + assert(location < SPIRV_CROSS_NUM_STAGE_OUTPUTS); + assert(!stage_outputs[location].ptr); + + stage_outputs[location].ptr = (void **)&value.ptr; + stage_outputs[location].size = internal::StageOutput::Size; + } + + template + void register_uniform_constant(const internal::UniformConstant &value, unsigned location) + { + assert(location < SPIRV_CROSS_NUM_UNIFORM_CONSTANTS); + assert(!uniform_constants[location].ptr); + + uniform_constants[location].ptr = (void **)&value.ptr; + uniform_constants[location].size = internal::UniformConstant::Size; + } + + template + void register_push_constant(const internal::PushConstant &value) + { + assert(!push_constant.ptr); + + push_constant.ptr = (void **)&value.ptr; + push_constant.size = internal::PushConstant::Size; + } + + void set_stage_input(unsigned location, void *data, size_t size) + { + assert(location < SPIRV_CROSS_NUM_STAGE_INPUTS); + assert(stage_inputs[location].ptr); + assert(size >= stage_inputs[location].size); + + *stage_inputs[location].ptr = data; + } + + void set_stage_output(unsigned location, void *data, size_t size) + { + assert(location < SPIRV_CROSS_NUM_STAGE_OUTPUTS); + assert(stage_outputs[location].ptr); + assert(size >= stage_outputs[location].size); + + *stage_outputs[location].ptr = data; + } + + void set_uniform_constant(unsigned location, void *data, size_t size) + { + assert(location < SPIRV_CROSS_NUM_UNIFORM_CONSTANTS); + assert(uniform_constants[location].ptr); + assert(size >= uniform_constants[location].size); + + *uniform_constants[location].ptr = data; + } + + void set_push_constant(void *data, size_t size) + { + assert(push_constant.ptr); + assert(size >= push_constant.size); + + *push_constant.ptr = data; + } + + void set_resource(unsigned set, unsigned binding, void **data, size_t size) + { + assert(set < SPIRV_CROSS_NUM_DESCRIPTOR_SETS); + assert(binding < SPIRV_CROSS_NUM_DESCRIPTOR_BINDINGS); + assert(resources[set][binding].ptr); + assert(size >= resources[set][binding].size); + + // We're using the regular PointerInterface, dereference ahead of time. + if (resources[set][binding].pre_dereference) + *resources[set][binding].ptr = *data; + else + *resources[set][binding].ptr = data; + } +}; + +namespace spirv_cross +{ +template +struct BaseShader : spirv_cross_shader +{ + void invoke() + { + static_cast(this)->main(); + } +}; + +struct FragmentResources +{ + internal::StageOutput gl_FragCoord; + void init(spirv_cross_shader &s) + { + s.register_builtin(SPIRV_CROSS_BUILTIN_FRAG_COORD, gl_FragCoord); + } +#define gl_FragCoord __res->gl_FragCoord.get() +}; + +template +struct FragmentShader : BaseShader> +{ + inline void main() + { + impl.main(); + } + + FragmentShader() + { + resources.init(*this); + impl.__res = &resources; + } + + T impl; + Res resources; +}; + +struct VertexResources +{ + internal::StageOutput gl_Position; + void init(spirv_cross_shader &s) + { + s.register_builtin(SPIRV_CROSS_BUILTIN_POSITION, gl_Position); + } +#define gl_Position __res->gl_Position.get() +}; + +template +struct VertexShader : BaseShader> +{ + inline void main() + { + impl.main(); + } + + VertexShader() + { + resources.init(*this); + impl.__res = &resources; + } + + T impl; + Res resources; +}; + +struct TessEvaluationResources +{ + inline void init(spirv_cross_shader &) + { + } +}; + +template +struct TessEvaluationShader : BaseShader> +{ + inline void main() + { + impl.main(); + } + + TessEvaluationShader() + { + resources.init(*this); + impl.__res = &resources; + } + + T impl; + Res resources; +}; + +struct TessControlResources +{ + inline void init(spirv_cross_shader &) + { + } +}; + +template +struct TessControlShader : BaseShader> +{ + inline void main() + { + impl.main(); + } + + TessControlShader() + { + resources.init(*this); + impl.__res = &resources; + } + + T impl; + Res resources; +}; + +struct GeometryResources +{ + inline void init(spirv_cross_shader &) + { + } +}; + +template +struct GeometryShader : BaseShader> +{ + inline void main() + { + impl.main(); + } + + GeometryShader() + { + resources.init(*this); + impl.__res = &resources; + } + + T impl; + Res resources; +}; + +struct ComputeResources +{ + internal::StageInput gl_WorkGroupID__; + internal::StageInput gl_NumWorkGroups__; + void init(spirv_cross_shader &s) + { + s.register_builtin(SPIRV_CROSS_BUILTIN_WORK_GROUP_ID, gl_WorkGroupID__); + s.register_builtin(SPIRV_CROSS_BUILTIN_NUM_WORK_GROUPS, gl_NumWorkGroups__); + } +#define gl_WorkGroupID __res->gl_WorkGroupID__.get() +#define gl_NumWorkGroups __res->gl_NumWorkGroups__.get() + + Barrier barrier__; +#define barrier() __res->barrier__.wait() +}; + +struct ComputePrivateResources +{ + uint32_t gl_LocalInvocationIndex__; +#define gl_LocalInvocationIndex __priv_res.gl_LocalInvocationIndex__ + glm::uvec3 gl_LocalInvocationID__; +#define gl_LocalInvocationID __priv_res.gl_LocalInvocationID__ + glm::uvec3 gl_GlobalInvocationID__; +#define gl_GlobalInvocationID __priv_res.gl_GlobalInvocationID__ +}; + +template +struct ComputeShader : BaseShader> +{ + inline void main() + { + resources.barrier__.reset_counter(); + + for (unsigned z = 0; z < WorkGroupZ; z++) + for (unsigned y = 0; y < WorkGroupY; y++) + for (unsigned x = 0; x < WorkGroupX; x++) + impl[z][y][x].__priv_res.gl_GlobalInvocationID__ = + glm::uvec3(WorkGroupX, WorkGroupY, WorkGroupZ) * resources.gl_WorkGroupID__.get() + + glm::uvec3(x, y, z); + + group.run(); + group.wait(); + } + + ComputeShader() + : group(&impl[0][0][0]) + { + resources.init(*this); + resources.barrier__.set_release_divisor(WorkGroupX * WorkGroupY * WorkGroupZ); + + unsigned i = 0; + for (unsigned z = 0; z < WorkGroupZ; z++) + { + for (unsigned y = 0; y < WorkGroupY; y++) + { + for (unsigned x = 0; x < WorkGroupX; x++) + { + impl[z][y][x].__priv_res.gl_LocalInvocationID__ = glm::uvec3(x, y, z); + impl[z][y][x].__priv_res.gl_LocalInvocationIndex__ = i++; + impl[z][y][x].__res = &resources; + } + } + } + } + + T impl[WorkGroupZ][WorkGroupY][WorkGroupX]; + ThreadGroup group; + Res resources; +}; + +inline void memoryBarrierShared() +{ + Barrier::memoryBarrier(); +} +inline void memoryBarrier() +{ + Barrier::memoryBarrier(); +} +// TODO: Rest of the barriers. + +// Atomics +template +inline T atomicAdd(T &v, T a) +{ + static_assert(sizeof(std::atomic) == sizeof(T), "Cannot cast properly to std::atomic."); + + // We need explicit memory barriers in GLSL to enfore any ordering. + // FIXME: Can we really cast this? There is no other way I think ... + return std::atomic_fetch_add_explicit(reinterpret_cast *>(&v), a, std::memory_order_relaxed); +} +} + +void spirv_cross_set_stage_input(spirv_cross_shader_t *shader, unsigned location, void *data, size_t size) +{ + shader->set_stage_input(location, data, size); +} + +void spirv_cross_set_stage_output(spirv_cross_shader_t *shader, unsigned location, void *data, size_t size) +{ + shader->set_stage_output(location, data, size); +} + +void spirv_cross_set_uniform_constant(spirv_cross_shader_t *shader, unsigned location, void *data, size_t size) +{ + shader->set_uniform_constant(location, data, size); +} + +void spirv_cross_set_resource(spirv_cross_shader_t *shader, unsigned set, unsigned binding, void **data, size_t size) +{ + shader->set_resource(set, binding, data, size); +} + +void spirv_cross_set_push_constant(spirv_cross_shader_t *shader, void *data, size_t size) +{ + shader->set_push_constant(data, size); +} + +void spirv_cross_set_builtin(spirv_cross_shader_t *shader, spirv_cross_builtin builtin, void *data, size_t size) +{ + shader->set_builtin(builtin, data, size); +} + +#endif diff --git a/include/spirv_cross/sampler.hpp b/include/spirv_cross/sampler.hpp new file mode 100644 index 0000000000..a95d489e2d --- /dev/null +++ b/include/spirv_cross/sampler.hpp @@ -0,0 +1,105 @@ +/* + * Copyright 2015-2017 ARM Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SPIRV_CROSS_SAMPLER_HPP +#define SPIRV_CROSS_SAMPLER_HPP + +#include + +namespace spirv_cross +{ +struct spirv_cross_sampler_2d +{ + inline virtual ~spirv_cross_sampler_2d() + { + } +}; + +template +struct sampler2DBase : spirv_cross_sampler_2d +{ + sampler2DBase(const spirv_cross_sampler_info *info) + { + mips.insert(mips.end(), info->mipmaps, info->mipmaps + info->num_mipmaps); + format = info->format; + wrap_s = info->wrap_s; + wrap_t = info->wrap_t; + min_filter = info->min_filter; + mag_filter = info->mag_filter; + mip_filter = info->mip_filter; + } + + inline virtual T sample(glm::vec2 uv, float bias) + { + return sampleLod(uv, bias); + } + + inline virtual T sampleLod(glm::vec2 uv, float lod) + { + if (mag_filter == SPIRV_CROSS_FILTER_NEAREST) + { + uv.x = wrap(uv.x, wrap_s, mips[0].width); + uv.y = wrap(uv.y, wrap_t, mips[0].height); + glm::vec2 uv_full = uv * glm::vec2(mips[0].width, mips[0].height); + + int x = int(uv_full.x); + int y = int(uv_full.y); + return sample(x, y, 0); + } + else + { + return T(0, 0, 0, 1); + } + } + + inline float wrap(float v, spirv_cross_wrap wrap, unsigned size) + { + switch (wrap) + { + case SPIRV_CROSS_WRAP_REPEAT: + return v - glm::floor(v); + case SPIRV_CROSS_WRAP_CLAMP_TO_EDGE: + { + float half = 0.5f / size; + return glm::clamp(v, half, 1.0f - half); + } + + default: + return 0.0f; + } + } + + std::vector mips; + spirv_cross_format format; + spirv_cross_wrap wrap_s; + spirv_cross_format wrap_t; + spirv_cross_filter min_filter; + spirv_cross_filter mag_filter; + spirv_cross_mipfilter mip_filter; +}; + +typedef sampler2DBase sampler2D; +typedef sampler2DBase isampler2D; +typedef sampler2DBase usampler2D; + +template +inline T texture(const sampler2DBase &samp, const glm::vec2 &uv, float bias = 0.0f) +{ + return samp.sample(uv, bias); +} +} + +#endif diff --git a/include/spirv_cross/thread_group.hpp b/include/spirv_cross/thread_group.hpp new file mode 100644 index 0000000000..377f098b4f --- /dev/null +++ b/include/spirv_cross/thread_group.hpp @@ -0,0 +1,113 @@ +/* + * Copyright 2015-2017 ARM Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SPIRV_CROSS_THREAD_GROUP_HPP +#define SPIRV_CROSS_THREAD_GROUP_HPP + +#include +#include +#include + +namespace spirv_cross +{ +template +class ThreadGroup +{ +public: + ThreadGroup(T *impl) + { + for (unsigned i = 0; i < Size; i++) + workers[i].start(&impl[i]); + } + + void run() + { + for (auto &worker : workers) + worker.run(); + } + + void wait() + { + for (auto &worker : workers) + worker.wait(); + } + +private: + struct Thread + { + enum State + { + Idle, + Running, + Dying + }; + State state = Idle; + + void start(T *impl) + { + worker = std::thread([impl, this] { + for (;;) + { + { + std::unique_lock l{ lock }; + cond.wait(l, [this] { return state != Idle; }); + if (state == Dying) + break; + } + + impl->main(); + + std::lock_guard l{ lock }; + state = Idle; + cond.notify_one(); + } + }); + } + + void wait() + { + std::unique_lock l{ lock }; + cond.wait(l, [this] { return state == Idle; }); + } + + void run() + { + std::lock_guard l{ lock }; + state = Running; + cond.notify_one(); + } + + ~Thread() + { + if (worker.joinable()) + { + { + std::lock_guard l{ lock }; + state = Dying; + cond.notify_one(); + } + worker.join(); + } + } + std::thread worker; + std::condition_variable cond; + std::mutex lock; + }; + Thread workers[Size]; +}; +} + +#endif diff --git a/jni/Android.mk b/jni/Android.mk new file mode 100644 index 0000000000..ca5014d63a --- /dev/null +++ b/jni/Android.mk @@ -0,0 +1,12 @@ +LOCAL_PATH := $(call my-dir) + +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_CPP_FEATURES := exceptions +LOCAL_ARM_MODE := arm +LOCAL_CFLAGS := -D__STDC_LIMIT_MACROS + +include $(BUILD_STATIC_LIBRARY) diff --git a/jni/Application.mk b/jni/Application.mk new file mode 100644 index 0000000000..9a2e77f2d1 --- /dev/null +++ b/jni/Application.mk @@ -0,0 +1,2 @@ +APP_STL := c++_static +APP_ABI := armeabi-v7a diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000000..49fc8653b3 --- /dev/null +++ b/main.cpp @@ -0,0 +1,923 @@ +/* + * Copyright 2015-2017 ARM Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "spirv_cpp.hpp" +#include "spirv_glsl.hpp" +#include "spirv_hlsl.hpp" +#include "spirv_msl.hpp" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef _MSC_VER +#pragma warning(disable : 4996) +#endif + +using namespace spv; +using namespace spirv_cross; +using namespace std; + +#ifdef SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS +static inline void THROW(const char *str) +{ + fprintf(stderr, "SPIRV-Cross will abort: %s\n", str); + fflush(stderr); + abort(); +} +#else +#define THROW(x) throw runtime_error(x) +#endif + +struct CLIParser; +struct CLICallbacks +{ + void add(const char *cli, const function &func) + { + callbacks[cli] = func; + } + unordered_map> callbacks; + function error_handler; + function default_handler; +}; + +struct CLIParser +{ + CLIParser(CLICallbacks cbs_, int argc_, char *argv_[]) + : cbs(move(cbs_)) + , argc(argc_) + , argv(argv_) + { + } + + bool parse() + { +#ifndef SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS + try +#endif + { + while (argc && !ended_state) + { + const char *next = *argv++; + argc--; + + if (*next != '-' && cbs.default_handler) + { + cbs.default_handler(next); + } + else + { + auto itr = cbs.callbacks.find(next); + if (itr == ::end(cbs.callbacks)) + { + THROW("Invalid argument"); + } + + itr->second(*this); + } + } + + return true; + } +#ifndef SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS + catch (...) + { + if (cbs.error_handler) + { + cbs.error_handler(); + } + return false; + } +#endif + } + + void end() + { + ended_state = true; + } + + uint32_t next_uint() + { + if (!argc) + { + THROW("Tried to parse uint, but nothing left in arguments"); + } + + uint32_t val = stoul(*argv); + if (val > numeric_limits::max()) + { + THROW("next_uint() out of range"); + } + + argc--; + argv++; + + return val; + } + + double next_double() + { + if (!argc) + { + THROW("Tried to parse double, but nothing left in arguments"); + } + + double val = stod(*argv); + + argc--; + argv++; + + return val; + } + + const char *next_string() + { + if (!argc) + { + THROW("Tried to parse string, but nothing left in arguments"); + } + + const char *ret = *argv; + argc--; + argv++; + return ret; + } + + CLICallbacks cbs; + int argc; + char **argv; + bool ended_state = false; +}; + +static vector read_spirv_file(const char *path) +{ + FILE *file = fopen(path, "rb"); + if (!file) + { + fprintf(stderr, "Failed to open SPIRV file: %s\n", path); + return {}; + } + + fseek(file, 0, SEEK_END); + long len = ftell(file) / sizeof(uint32_t); + rewind(file); + + vector spirv(len); + if (fread(spirv.data(), sizeof(uint32_t), len, file) != size_t(len)) + spirv.clear(); + + fclose(file); + return spirv; +} + +static bool write_string_to_file(const char *path, const char *string) +{ + FILE *file = fopen(path, "w"); + if (!file) + { + fprintf(stderr, "Failed to write file: %s\n", path); + return false; + } + + fprintf(file, "%s", string); + fclose(file); + return true; +} + +static void print_resources(const Compiler &compiler, const char *tag, const vector &resources) +{ + fprintf(stderr, "%s\n", tag); + fprintf(stderr, "=============\n\n"); + bool print_ssbo = !strcmp(tag, "ssbos"); + + for (auto &res : resources) + { + auto &type = compiler.get_type(res.type_id); + auto mask = compiler.get_decoration_mask(res.id); + + if (print_ssbo && compiler.buffer_is_hlsl_counter_buffer(res.id)) + continue; + + // If we don't have a name, use the fallback for the type instead of the variable + // for SSBOs and UBOs since those are the only meaningful names to use externally. + // Push constant blocks are still accessed by name and not block name, even though they are technically Blocks. + bool is_push_constant = compiler.get_storage_class(res.id) == StorageClassPushConstant; + bool is_block = (compiler.get_decoration_mask(type.self) & + ((1ull << DecorationBlock) | (1ull << DecorationBufferBlock))) != 0; + bool is_sized_block = is_block && (compiler.get_storage_class(res.id) == StorageClassUniform || + compiler.get_storage_class(res.id) == StorageClassUniformConstant); + uint32_t fallback_id = !is_push_constant && is_block ? res.base_type_id : res.id; + + uint32_t block_size = 0; + if (is_sized_block) + block_size = uint32_t(compiler.get_declared_struct_size(compiler.get_type(res.base_type_id))); + + string array; + for (auto arr : type.array) + array = join("[", arr ? convert_to_string(arr) : "", "]") + array; + + fprintf(stderr, " ID %03u : %s%s", res.id, + !res.name.empty() ? res.name.c_str() : compiler.get_fallback_name(fallback_id).c_str(), array.c_str()); + + if (mask & (1ull << DecorationLocation)) + fprintf(stderr, " (Location : %u)", compiler.get_decoration(res.id, DecorationLocation)); + if (mask & (1ull << DecorationDescriptorSet)) + fprintf(stderr, " (Set : %u)", compiler.get_decoration(res.id, DecorationDescriptorSet)); + if (mask & (1ull << DecorationBinding)) + fprintf(stderr, " (Binding : %u)", compiler.get_decoration(res.id, DecorationBinding)); + if (mask & (1ull << DecorationInputAttachmentIndex)) + fprintf(stderr, " (Attachment : %u)", compiler.get_decoration(res.id, DecorationInputAttachmentIndex)); + if (mask & (1ull << DecorationNonReadable)) + fprintf(stderr, " writeonly"); + if (mask & (1ull << DecorationNonWritable)) + fprintf(stderr, " readonly"); + if (is_sized_block) + fprintf(stderr, " (BlockSize : %u bytes)", block_size); + + uint32_t counter_id = 0; + if (print_ssbo && compiler.buffer_get_hlsl_counter_buffer(res.id, counter_id)) + fprintf(stderr, " (HLSL counter buffer ID: %u)", counter_id); + fprintf(stderr, "\n"); + } + fprintf(stderr, "=============\n\n"); +} + +static const char *execution_model_to_str(spv::ExecutionModel model) +{ + switch (model) + { + case spv::ExecutionModelVertex: + return "vertex"; + case spv::ExecutionModelTessellationControl: + return "tessellation control"; + case ExecutionModelTessellationEvaluation: + return "tessellation evaluation"; + case ExecutionModelGeometry: + return "geometry"; + case ExecutionModelFragment: + return "fragment"; + case ExecutionModelGLCompute: + return "compute"; + default: + return "???"; + } +} + +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(); + 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, "\n"); + + fprintf(stderr, "Execution modes:\n"); + for (unsigned i = 0; i < 64; i++) + { + if (!(modes & (1ull << i))) + continue; + + auto mode = static_cast(i); + uint32_t arg0 = compiler.get_execution_mode_argument(mode, 0); + uint32_t arg1 = compiler.get_execution_mode_argument(mode, 1); + uint32_t arg2 = compiler.get_execution_mode_argument(mode, 2); + + switch (static_cast(i)) + { + case ExecutionModeInvocations: + fprintf(stderr, " Invocations: %u\n", arg0); + break; + + case ExecutionModeLocalSize: + fprintf(stderr, " LocalSize: (%u, %u, %u)\n", arg0, arg1, arg2); + break; + + case ExecutionModeOutputVertices: + fprintf(stderr, " OutputVertices: %u\n", arg0); + break; + +#define CHECK_MODE(m) \ + case ExecutionMode##m: \ + fprintf(stderr, " %s\n", #m); \ + break + CHECK_MODE(SpacingEqual); + CHECK_MODE(SpacingFractionalEven); + CHECK_MODE(SpacingFractionalOdd); + CHECK_MODE(VertexOrderCw); + CHECK_MODE(VertexOrderCcw); + CHECK_MODE(PixelCenterInteger); + CHECK_MODE(OriginUpperLeft); + CHECK_MODE(OriginLowerLeft); + CHECK_MODE(EarlyFragmentTests); + CHECK_MODE(PointMode); + CHECK_MODE(Xfb); + CHECK_MODE(DepthReplacing); + CHECK_MODE(DepthGreater); + CHECK_MODE(DepthLess); + CHECK_MODE(DepthUnchanged); + CHECK_MODE(LocalSizeHint); + CHECK_MODE(InputPoints); + CHECK_MODE(InputLines); + CHECK_MODE(InputLinesAdjacency); + CHECK_MODE(Triangles); + CHECK_MODE(InputTrianglesAdjacency); + CHECK_MODE(Quads); + CHECK_MODE(Isolines); + CHECK_MODE(OutputPoints); + CHECK_MODE(OutputLineStrip); + CHECK_MODE(OutputTriangleStrip); + CHECK_MODE(VecTypeHint); + CHECK_MODE(ContractionOff); + + default: + break; + } + } + fprintf(stderr, "\n"); + + print_resources(compiler, "subpass inputs", res.subpass_inputs); + print_resources(compiler, "inputs", res.stage_inputs); + print_resources(compiler, "outputs", res.stage_outputs); + print_resources(compiler, "textures", res.sampled_images); + print_resources(compiler, "separate images", res.separate_images); + print_resources(compiler, "separate samplers", res.separate_samplers); + print_resources(compiler, "images", res.storage_images); + print_resources(compiler, "ssbos", res.storage_buffers); + print_resources(compiler, "ubos", res.uniform_buffers); + print_resources(compiler, "push", res.push_constant_buffers); + print_resources(compiler, "counters", res.atomic_counters); +} + +static void print_push_constant_resources(const Compiler &compiler, const vector &res) +{ + for (auto &block : res) + { + auto ranges = compiler.get_active_buffer_ranges(block.id); + fprintf(stderr, "Active members in buffer: %s\n", + !block.name.empty() ? block.name.c_str() : compiler.get_fallback_name(block.id).c_str()); + + fprintf(stderr, "==================\n\n"); + for (auto &range : ranges) + { + const auto &name = compiler.get_member_name(block.base_type_id, range.index); + + fprintf(stderr, "Member #%3u (%s): Offset: %4u, Range: %4u\n", range.index, + !name.empty() ? name.c_str() : compiler.get_fallback_member_name(range.index).c_str(), + unsigned(range.offset), unsigned(range.range)); + } + fprintf(stderr, "==================\n\n"); + } +} + +static void print_spec_constants(const Compiler &compiler) +{ + auto spec_constants = compiler.get_specialization_constants(); + fprintf(stderr, "Specialization constants\n"); + fprintf(stderr, "==================\n\n"); + for (auto &c : spec_constants) + fprintf(stderr, "ID: %u, Spec ID: %u\n", c.id, c.constant_id); + fprintf(stderr, "==================\n\n"); +} + +static void print_capabilities_and_extensions(const Compiler &compiler) +{ + fprintf(stderr, "Capabilities\n"); + fprintf(stderr, "============\n"); + for (auto &capability : compiler.get_declared_capabilities()) + fprintf(stderr, "Capability: %u\n", static_cast(capability)); + fprintf(stderr, "============\n\n"); + + fprintf(stderr, "Extensions\n"); + fprintf(stderr, "============\n"); + for (auto &ext : compiler.get_declared_extensions()) + fprintf(stderr, "Extension: %s\n", ext.c_str()); + fprintf(stderr, "============\n\n"); +} + +struct PLSArg +{ + PlsFormat format; + string name; +}; + +struct Remap +{ + string src_name; + string dst_name; + unsigned components; +}; + +struct VariableTypeRemap +{ + string variable_name; + string new_variable_type; +}; + +struct InterfaceVariableRename +{ + StorageClass storageClass; + uint32_t location; + string variable_name; +}; + +struct CLIArguments +{ + const char *input = nullptr; + const char *output = nullptr; + const char *cpp_interface_name = nullptr; + uint32_t version = 0; + uint32_t shader_model = 0; + uint32_t msl_version = 0; + bool es = false; + bool set_version = false; + bool set_shader_model = false; + bool set_msl_version = false; + bool set_es = false; + bool dump_resources = false; + bool force_temporary = false; + bool flatten_ubo = false; + bool fixup = false; + bool yflip = false; + bool sso = false; + vector pls_in; + vector pls_out; + vector remaps; + vector extensions; + vector variable_type_remaps; + vector interface_variable_renames; + vector hlsl_attr_remap; + string entry; + + vector> entry_point_rename; + + uint32_t iterations = 1; + bool cpp = false; + bool msl = false; + bool hlsl = false; + bool hlsl_compat = false; + bool vulkan_semantics = false; + bool flatten_multidimensional_arrays = false; + bool use_420pack_extension = true; + bool remove_unused = false; +}; + +static void print_help() +{ + fprintf(stderr, "Usage: spirv-cross [--output ] [SPIR-V file] [--es] [--no-es] " + "[--version ] [--dump-resources] [--help] [--force-temporary] " + "[--vulkan-semantics] [--flatten-ubo] [--fixup-clipspace] [--flip-vert-y] [--iterations iter] " + "[--cpp] [--cpp-interface-name ] " + "[--msl] [--msl-version ]" + "[--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] " + "[--flatten-multidimensional-arrays] [--no-420pack-extension] " + "[--remap-variable-type ] " + "[--rename-interface-variable ] " + "[--set-hlsl-vertex-input-semantic ] " + "[--rename-entry-point ] " + "\n"); +} + +static bool remap_generic(Compiler &compiler, const vector &resources, const Remap &remap) +{ + auto itr = + find_if(begin(resources), end(resources), [&remap](const Resource &res) { return res.name == remap.src_name; }); + + if (itr != end(resources)) + { + compiler.set_remapped_variable_state(itr->id, true); + compiler.set_name(itr->id, remap.dst_name); + compiler.set_subpass_input_remapped_components(itr->id, remap.components); + return true; + } + else + return false; +} + +static vector remap_pls(const vector &pls_variables, const vector &resources, + const vector *secondary_resources) +{ + vector ret; + + for (auto &pls : pls_variables) + { + bool found = false; + for (auto &res : resources) + { + if (res.name == pls.name) + { + ret.push_back({ res.id, pls.format }); + found = true; + break; + } + } + + if (!found && secondary_resources) + { + for (auto &res : *secondary_resources) + { + if (res.name == pls.name) + { + ret.push_back({ res.id, pls.format }); + found = true; + break; + } + } + } + + if (!found) + fprintf(stderr, "Did not find stage input/output/target with name \"%s\".\n", pls.name.c_str()); + } + + return ret; +} + +static PlsFormat pls_format(const char *str) +{ + if (!strcmp(str, "r11f_g11f_b10f")) + return PlsR11FG11FB10F; + else if (!strcmp(str, "r32f")) + return PlsR32F; + else if (!strcmp(str, "rg16f")) + return PlsRG16F; + else if (!strcmp(str, "rg16")) + return PlsRG16; + else if (!strcmp(str, "rgb10_a2")) + return PlsRGB10A2; + else if (!strcmp(str, "rgba8")) + return PlsRGBA8; + else if (!strcmp(str, "rgba8i")) + return PlsRGBA8I; + else if (!strcmp(str, "rgba8ui")) + return PlsRGBA8UI; + else if (!strcmp(str, "rg16i")) + return PlsRG16I; + else if (!strcmp(str, "rgb10_a2ui")) + return PlsRGB10A2UI; + else if (!strcmp(str, "rg16ui")) + return PlsRG16UI; + else if (!strcmp(str, "r32ui")) + return PlsR32UI; + else + return PlsNone; +} + +void rename_interface_variable(Compiler &compiler, const vector &resources, + const InterfaceVariableRename &rename) +{ + 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); + } +} + +static int main_inner(int argc, char *argv[]) +{ + CLIArguments args; + CLICallbacks cbs; + + cbs.add("--help", [](CLIParser &parser) { + print_help(); + parser.end(); + }); + cbs.add("--output", [&args](CLIParser &parser) { args.output = parser.next_string(); }); + cbs.add("--es", [&args](CLIParser &) { + args.es = true; + args.set_es = true; + }); + cbs.add("--no-es", [&args](CLIParser &) { + args.es = false; + args.set_es = true; + }); + cbs.add("--version", [&args](CLIParser &parser) { + args.version = parser.next_uint(); + args.set_version = true; + }); + cbs.add("--dump-resources", [&args](CLIParser &) { args.dump_resources = true; }); + cbs.add("--force-temporary", [&args](CLIParser &) { args.force_temporary = true; }); + cbs.add("--flatten-ubo", [&args](CLIParser &) { args.flatten_ubo = true; }); + cbs.add("--fixup-clipspace", [&args](CLIParser &) { args.fixup = true; }); + cbs.add("--flip-vert-y", [&args](CLIParser &) { args.yflip = true; }); + cbs.add("--iterations", [&args](CLIParser &parser) { args.iterations = parser.next_uint(); }); + cbs.add("--cpp", [&args](CLIParser &) { args.cpp = true; }); + cbs.add("--cpp-interface-name", [&args](CLIParser &parser) { args.cpp_interface_name = parser.next_string(); }); + cbs.add("--metal", [&args](CLIParser &) { args.msl = true; }); // Legacy compatibility + cbs.add("--msl", [&args](CLIParser &) { args.msl = true; }); + cbs.add("--hlsl", [&args](CLIParser &) { args.hlsl = true; }); + cbs.add("--hlsl-enable-compat", [&args](CLIParser &) { args.hlsl_compat = true; }); + cbs.add("--vulkan-semantics", [&args](CLIParser &) { args.vulkan_semantics = true; }); + cbs.add("--flatten-multidimensional-arrays", [&args](CLIParser &) { args.flatten_multidimensional_arrays = true; }); + cbs.add("--no-420pack-extension", [&args](CLIParser &) { args.use_420pack_extension = false; }); + cbs.add("--extension", [&args](CLIParser &parser) { args.extensions.push_back(parser.next_string()); }); + 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 }); + }); + cbs.add("--entry", [&args](CLIParser &parser) { args.entry = 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; + remap.location = parser.next_uint(); + remap.semantic = parser.next_string(); + args.hlsl_attr_remap.push_back(move(remap)); + }); + + cbs.add("--remap", [&args](CLIParser &parser) { + string src = parser.next_string(); + string dst = parser.next_string(); + uint32_t components = parser.next_uint(); + args.remaps.push_back({ move(src), move(dst), components }); + }); + + cbs.add("--remap-variable-type", [&args](CLIParser &parser) { + string var_name = parser.next_string(); + string new_type = parser.next_string(); + args.variable_type_remaps.push_back({ move(var_name), move(new_type) }); + }); + + cbs.add("--rename-interface-variable", [&args](CLIParser &parser) { + StorageClass cls = StorageClassMax; + string clsStr = parser.next_string(); + if (clsStr == "in") + cls = StorageClassInput; + else if (clsStr == "out") + cls = StorageClassOutput; + + uint32_t loc = parser.next_uint(); + string var_name = parser.next_string(); + args.interface_variable_renames.push_back({ cls, loc, move(var_name) }); + }); + + cbs.add("--pls-in", [&args](CLIParser &parser) { + auto fmt = pls_format(parser.next_string()); + auto name = parser.next_string(); + args.pls_in.push_back({ move(fmt), move(name) }); + }); + cbs.add("--pls-out", [&args](CLIParser &parser) { + auto fmt = pls_format(parser.next_string()); + auto name = parser.next_string(); + args.pls_out.push_back({ move(fmt), move(name) }); + }); + cbs.add("--shader-model", [&args](CLIParser &parser) { + args.shader_model = parser.next_uint(); + args.set_shader_model = true; + }); + cbs.add("--msl-version", [&args](CLIParser &parser) { + args.msl_version = parser.next_uint(); + args.set_msl_version = true; + }); + + cbs.add("--remove-unused-variables", [&args](CLIParser &) { args.remove_unused = true; }); + + cbs.default_handler = [&args](const char *value) { args.input = value; }; + cbs.error_handler = [] { print_help(); }; + + CLIParser parser{ move(cbs), argc - 1, argv + 1 }; + if (!parser.parse()) + { + return EXIT_FAILURE; + } + else if (parser.ended_state) + { + return EXIT_SUCCESS; + } + + if (!args.input) + { + fprintf(stderr, "Didn't specify input file.\n"); + print_help(); + return EXIT_FAILURE; + } + + unique_ptr compiler; + + bool combined_image_samplers = false; + + if (args.cpp) + { + compiler = unique_ptr(new CompilerCPP(read_spirv_file(args.input))); + if (args.cpp_interface_name) + static_cast(compiler.get())->set_interface_name(args.cpp_interface_name); + } + else if (args.msl) + { + compiler = unique_ptr(new CompilerMSL(read_spirv_file(args.input))); + + auto *msl_comp = static_cast(compiler.get()); + auto msl_opts = msl_comp->get_options(); + if (args.set_msl_version) + msl_opts.msl_version = args.msl_version; + msl_comp->set_options(msl_opts); + } + else if (args.hlsl) + compiler = unique_ptr(new CompilerHLSL(read_spirv_file(args.input))); + else + { + combined_image_samplers = !args.vulkan_semantics; + compiler = unique_ptr(new CompilerGLSL(read_spirv_file(args.input))); + } + + if (!args.variable_type_remaps.empty()) + { + auto remap_cb = [&](const SPIRType &, const string &name, string &out) -> void { + for (const VariableTypeRemap &remap : args.variable_type_remaps) + if (name == remap.variable_name) + out = remap.new_variable_type; + }; + + compiler->set_variable_type_remap_callback(move(remap_cb)); + } + + for (auto &rename : args.entry_point_rename) + compiler->rename_entry_point(rename.first, rename.second); + + if (!args.entry.empty()) + compiler->set_entry_point(args.entry); + + if (!args.set_version && !compiler->get_options().version) + { + fprintf(stderr, "Didn't specify GLSL version and SPIR-V did not specify language.\n"); + print_help(); + return EXIT_FAILURE; + } + + CompilerGLSL::Options opts = compiler->get_options(); + if (args.set_version) + opts.version = args.version; + if (args.set_es) + opts.es = args.es; + opts.force_temporary = args.force_temporary; + opts.separate_shader_objects = args.sso; + opts.flatten_multidimensional_arrays = args.flatten_multidimensional_arrays; + opts.enable_420pack_extension = args.use_420pack_extension; + opts.vulkan_semantics = args.vulkan_semantics; + opts.vertex.fixup_clipspace = args.fixup; + opts.vertex.flip_vert_y = args.yflip; + compiler->set_options(opts); + + // Set HLSL specific options. + if (args.hlsl) + { + auto *hlsl = static_cast(compiler.get()); + auto hlsl_opts = hlsl->get_options(); + if (args.set_shader_model) + { + if (args.shader_model < 30) + { + fprintf(stderr, "Shader model earlier than 30 (3.0) not supported.\n"); + return EXIT_FAILURE; + } + + hlsl_opts.shader_model = args.shader_model; + } + + if (args.hlsl_compat) + { + // Enable all compat options. + hlsl_opts.point_size_compat = true; + } + hlsl->set_options(hlsl_opts); + } + + ShaderResources res; + if (args.remove_unused) + { + auto active = compiler->get_active_interface_variables(); + res = compiler->get_shader_resources(active); + compiler->set_enabled_interface_variables(move(active)); + } + else + res = compiler->get_shader_resources(); + + if (args.flatten_ubo) + { + for (auto &ubo : res.uniform_buffers) + compiler->flatten_buffer_block(ubo.id); + for (auto &ubo : res.push_constant_buffers) + compiler->flatten_buffer_block(ubo.id); + } + + auto pls_inputs = remap_pls(args.pls_in, res.stage_inputs, &res.subpass_inputs); + auto pls_outputs = remap_pls(args.pls_out, res.stage_outputs, nullptr); + compiler->remap_pixel_local_storage(move(pls_inputs), move(pls_outputs)); + + for (auto &ext : args.extensions) + compiler->require_extension(ext); + + for (auto &remap : args.remaps) + { + if (remap_generic(*compiler, res.stage_inputs, remap)) + continue; + if (remap_generic(*compiler, res.stage_outputs, remap)) + continue; + if (remap_generic(*compiler, res.subpass_inputs, remap)) + continue; + } + + for (auto &rename : args.interface_variable_renames) + { + if (rename.storageClass == StorageClassInput) + rename_interface_variable(*compiler, res.stage_inputs, rename); + else if (rename.storageClass == StorageClassOutput) + rename_interface_variable(*compiler, res.stage_outputs, rename); + else + { + fprintf(stderr, "error at --rename-interface-variable ...\n"); + return EXIT_FAILURE; + } + } + + if (args.dump_resources) + { + print_resources(*compiler, res); + print_push_constant_resources(*compiler, res.push_constant_buffers); + print_spec_constants(*compiler); + print_capabilities_and_extensions(*compiler); + } + + if (combined_image_samplers) + { + compiler->build_combined_image_samplers(); + // Give the remapped combined samplers new names. + for (auto &remap : compiler->get_combined_image_samplers()) + { + compiler->set_name(remap.combined_id, join("SPIRV_Cross_Combined", compiler->get_name(remap.image_id), + compiler->get_name(remap.sampler_id))); + } + } + + string glsl; + for (uint32_t i = 0; i < args.iterations; i++) + { + if (args.hlsl) + glsl = static_cast(compiler.get())->compile(move(args.hlsl_attr_remap)); + else + glsl = compiler->compile(); + } + + if (args.output) + write_string_to_file(args.output, glsl.c_str()); + else + printf("%s", glsl.c_str()); + + return EXIT_SUCCESS; +} + +int main(int argc, char *argv[]) +{ +#ifdef SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS + return main_inner(argc, argv); +#else + // Make sure we catch the exception or it just disappears into the aether on Windows. + try + { + return main_inner(argc, argv); + } + catch (const std::exception &e) + { + fprintf(stderr, "SPIRV-Cross threw an exception: %s\n", e.what()); + return EXIT_FAILURE; + } +#endif +} diff --git a/msvc/SPIRV-Cross.sln b/msvc/SPIRV-Cross.sln new file mode 100644 index 0000000000..c265ec3347 --- /dev/null +++ b/msvc/SPIRV-Cross.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Express 2013 for Windows Desktop +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SPIRV-Cross", "SPIRV-Cross.vcxproj", "{977E3701-1A21-4425-B7E5-6BDF5EA062CD}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {977E3701-1A21-4425-B7E5-6BDF5EA062CD}.Debug|Win32.ActiveCfg = Debug|Win32 + {977E3701-1A21-4425-B7E5-6BDF5EA062CD}.Debug|Win32.Build.0 = Debug|Win32 + {977E3701-1A21-4425-B7E5-6BDF5EA062CD}.Debug|x64.ActiveCfg = Debug|x64 + {977E3701-1A21-4425-B7E5-6BDF5EA062CD}.Debug|x64.Build.0 = Debug|x64 + {977E3701-1A21-4425-B7E5-6BDF5EA062CD}.Release|Win32.ActiveCfg = Release|Win32 + {977E3701-1A21-4425-B7E5-6BDF5EA062CD}.Release|Win32.Build.0 = Release|Win32 + {977E3701-1A21-4425-B7E5-6BDF5EA062CD}.Release|x64.ActiveCfg = Release|x64 + {977E3701-1A21-4425-B7E5-6BDF5EA062CD}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/msvc/SPIRV-Cross.vcxproj b/msvc/SPIRV-Cross.vcxproj new file mode 100644 index 0000000000..8c57633e94 --- /dev/null +++ b/msvc/SPIRV-Cross.vcxproj @@ -0,0 +1,148 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {977E3701-1A21-4425-B7E5-6BDF5EA062CD} + SPIRV-Cross + + + + Application + true + v120 + MultiByte + + + Application + true + v120 + MultiByte + + + Application + false + v120 + true + MultiByte + + + Application + false + v120 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + Level3 + Disabled + true + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + MultiThreadedDebugDLL + + + true + + + + + Level3 + Disabled + true + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + MultiThreadedDebugDLL + + + true + + + + + Level3 + MaxSpeed + true + true + true + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + MultiThreadedDLL + + + true + true + true + + + + + Level3 + MaxSpeed + true + true + true + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + MultiThreadedDLL + + + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/msvc/SPIRV-Cross.vcxproj.filters b/msvc/SPIRV-Cross.vcxproj.filters new file mode 100644 index 0000000000..c9edf4608b --- /dev/null +++ b/msvc/SPIRV-Cross.vcxproj.filters @@ -0,0 +1,69 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + diff --git a/reference/opt/shaders-hlsl/asm/comp/specialization-constant-workgroup.nofxc.asm.comp b/reference/opt/shaders-hlsl/asm/comp/specialization-constant-workgroup.nofxc.asm.comp new file mode 100644 index 0000000000..8243347bf6 --- /dev/null +++ b/reference/opt/shaders-hlsl/asm/comp/specialization-constant-workgroup.nofxc.asm.comp @@ -0,0 +1,16 @@ +static const uint _5 = 9u; +static const uint _6 = 4u; +static const uint3 gl_WorkGroupSize = uint3(_5, 20u, _6); + +RWByteAddressBuffer _4 : register(u0); + +void comp_main() +{ + _4.Store(0, asuint(asfloat(_4.Load(0)) + 1.0f)); +} + +[numthreads(9, 20, 4)] +void main() +{ + comp_main(); +} diff --git a/reference/opt/shaders-hlsl/asm/comp/storage-buffer-basic.nofxc.asm.comp b/reference/opt/shaders-hlsl/asm/comp/storage-buffer-basic.nofxc.asm.comp new file mode 100644 index 0000000000..1bdb27d7fa --- /dev/null +++ b/reference/opt/shaders-hlsl/asm/comp/storage-buffer-basic.nofxc.asm.comp @@ -0,0 +1,24 @@ +static const uint _3 = 1u; +static const uint _4 = 3u; +static const uint3 gl_WorkGroupSize = uint3(_3, 2u, _4); + +RWByteAddressBuffer _8 : register(u0); +RWByteAddressBuffer _9 : register(u1); + +static uint3 gl_WorkGroupID; +struct SPIRV_Cross_Input +{ + uint3 gl_WorkGroupID : SV_GroupID; +}; + +void comp_main() +{ + _8.Store(gl_WorkGroupID.x * 4 + 0, asuint(asfloat(_9.Load(gl_WorkGroupID.x * 4 + 0)) + asfloat(_8.Load(gl_WorkGroupID.x * 4 + 0)))); +} + +[numthreads(1, 2, 3)] +void main(SPIRV_Cross_Input stage_input) +{ + gl_WorkGroupID = stage_input.gl_WorkGroupID; + comp_main(); +} diff --git a/reference/opt/shaders-hlsl/asm/frag/cbuffer-stripped.asm.frag b/reference/opt/shaders-hlsl/asm/frag/cbuffer-stripped.asm.frag new file mode 100644 index 0000000000..25eee2d954 --- /dev/null +++ b/reference/opt/shaders-hlsl/asm/frag/cbuffer-stripped.asm.frag @@ -0,0 +1,25 @@ +cbuffer _5 : register(b0) +{ + column_major float2x4 _5_m0 : packoffset(c0); + float4 _5_m1 : packoffset(c4); +}; + +static float2 _3; + +struct SPIRV_Cross_Output +{ + float2 _3 : SV_Target0; +}; + +void frag_main() +{ + _3 = mul(_5_m0, _5_m1); +} + +SPIRV_Cross_Output main() +{ + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output._3 = _3; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/asm/frag/unreachable.asm.frag b/reference/opt/shaders-hlsl/asm/frag/unreachable.asm.frag new file mode 100644 index 0000000000..e7cb790205 --- /dev/null +++ b/reference/opt/shaders-hlsl/asm/frag/unreachable.asm.frag @@ -0,0 +1,42 @@ +static int counter; +static float4 FragColor; + +struct SPIRV_Cross_Input +{ + nointerpolation int counter : TEXCOORD0; +}; + +struct SPIRV_Cross_Output +{ + float4 FragColor : SV_Target0; +}; + +float4 _21; + +void frag_main() +{ + float4 _33; + do + { + if (counter == 10) + { + _33 = 10.0f.xxxx; + break; + } + else + { + _33 = 30.0f.xxxx; + break; + } + } while (false); + FragColor = _33; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + counter = stage_input.counter; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/asm/vert/empty-struct-composite.asm.vert b/reference/opt/shaders-hlsl/asm/vert/empty-struct-composite.asm.vert new file mode 100644 index 0000000000..103ff46a3f --- /dev/null +++ b/reference/opt/shaders-hlsl/asm/vert/empty-struct-composite.asm.vert @@ -0,0 +1,8 @@ +void vert_main() +{ +} + +void main() +{ + vert_main(); +} diff --git a/reference/opt/shaders-hlsl/asm/vert/vertex-id-instance-id.asm.vert b/reference/opt/shaders-hlsl/asm/vert/vertex-id-instance-id.asm.vert new file mode 100644 index 0000000000..8d5e771fe4 --- /dev/null +++ b/reference/opt/shaders-hlsl/asm/vert/vertex-id-instance-id.asm.vert @@ -0,0 +1,28 @@ +static float4 gl_Position; +static int gl_VertexID; +static int gl_InstanceID; +struct SPIRV_Cross_Input +{ + uint gl_VertexID : SV_VertexID; + uint gl_InstanceID : SV_InstanceID; +}; + +struct SPIRV_Cross_Output +{ + float4 gl_Position : SV_Position; +}; + +void vert_main() +{ + gl_Position = float(gl_VertexID + gl_InstanceID).xxxx; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + gl_VertexID = int(stage_input.gl_VertexID); + gl_InstanceID = int(stage_input.gl_InstanceID); + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/comp/access-chains.comp b/reference/opt/shaders-hlsl/comp/access-chains.comp new file mode 100644 index 0000000000..924e919124 --- /dev/null +++ b/reference/opt/shaders-hlsl/comp/access-chains.comp @@ -0,0 +1,21 @@ +RWByteAddressBuffer wo : register(u1); +ByteAddressBuffer ro : register(t0); + +static uint3 gl_GlobalInvocationID; +struct SPIRV_Cross_Input +{ + uint3 gl_GlobalInvocationID : SV_DispatchThreadID; +}; + +void comp_main() +{ + wo.Store4(gl_GlobalInvocationID.x * 64 + 272, asuint(asfloat(ro.Load4(gl_GlobalInvocationID.x * 64 + 160)))); + wo.Store4(gl_GlobalInvocationID.x * 16 + 480, asuint(asfloat(ro.Load4(gl_GlobalInvocationID.x * 16 + 480)))); +} + +[numthreads(1, 1, 1)] +void main(SPIRV_Cross_Input stage_input) +{ + gl_GlobalInvocationID = stage_input.gl_GlobalInvocationID; + comp_main(); +} diff --git a/reference/opt/shaders-hlsl/comp/address-buffers.comp b/reference/opt/shaders-hlsl/comp/address-buffers.comp new file mode 100644 index 0000000000..a252fc8ae3 --- /dev/null +++ b/reference/opt/shaders-hlsl/comp/address-buffers.comp @@ -0,0 +1,15 @@ +RWByteAddressBuffer WriteOnly : register(u2); +ByteAddressBuffer ReadOnly : register(t0); +RWByteAddressBuffer ReadWrite : register(u1); + +void comp_main() +{ + WriteOnly.Store4(0, asuint(asfloat(ReadOnly.Load4(0)))); + ReadWrite.Store4(0, asuint(asfloat(ReadWrite.Load4(0)) + 10.0f.xxxx)); +} + +[numthreads(1, 1, 1)] +void main() +{ + comp_main(); +} diff --git a/reference/opt/shaders-hlsl/comp/atomic.comp b/reference/opt/shaders-hlsl/comp/atomic.comp new file mode 100644 index 0000000000..72e15bf77d --- /dev/null +++ b/reference/opt/shaders-hlsl/comp/atomic.comp @@ -0,0 +1,89 @@ +RWByteAddressBuffer ssbo : register(u2); +RWTexture2D uImage : register(u0); +RWTexture2D iImage : register(u1); + +groupshared int int_atomic; +groupshared uint uint_atomic; +groupshared int int_atomic_array[1]; +groupshared uint uint_atomic_array[1]; + +void comp_main() +{ + uint _19; + InterlockedAdd(uImage[int2(1, 5)], 1u, _19); + uint _27; + InterlockedAdd(uImage[int2(1, 5)], 1u, _27); + iImage[int2(1, 6)] = int(_27).x; + uint _32; + InterlockedOr(uImage[int2(1, 5)], 1u, _32); + uint _34; + InterlockedXor(uImage[int2(1, 5)], 1u, _34); + uint _36; + InterlockedAnd(uImage[int2(1, 5)], 1u, _36); + uint _38; + InterlockedMin(uImage[int2(1, 5)], 1u, _38); + uint _40; + InterlockedMax(uImage[int2(1, 5)], 1u, _40); + uint _44; + InterlockedCompareExchange(uImage[int2(1, 5)], 10u, 2u, _44); + int _47; + InterlockedAdd(iImage[int2(1, 6)], 1, _47); + int _49; + InterlockedOr(iImage[int2(1, 6)], 1, _49); + int _51; + InterlockedXor(iImage[int2(1, 6)], 1, _51); + int _53; + InterlockedAnd(iImage[int2(1, 6)], 1, _53); + int _55; + InterlockedMin(iImage[int2(1, 6)], 1, _55); + int _57; + InterlockedMax(iImage[int2(1, 6)], 1, _57); + int _61; + InterlockedCompareExchange(iImage[int2(1, 5)], 10, 2, _61); + uint _68; + ssbo.InterlockedAdd(0, 1u, _68); + uint _70; + ssbo.InterlockedOr(0, 1u, _70); + uint _72; + ssbo.InterlockedXor(0, 1u, _72); + uint _74; + ssbo.InterlockedAnd(0, 1u, _74); + uint _76; + ssbo.InterlockedMin(0, 1u, _76); + uint _78; + ssbo.InterlockedMax(0, 1u, _78); + uint _80; + ssbo.InterlockedExchange(0, 1u, _80); + uint _82; + ssbo.InterlockedCompareExchange(0, 10u, 2u, _82); + int _85; + ssbo.InterlockedAdd(4, 1, _85); + int _87; + ssbo.InterlockedOr(4, 1, _87); + int _89; + ssbo.InterlockedXor(4, 1, _89); + int _91; + ssbo.InterlockedAnd(4, 1, _91); + int _93; + ssbo.InterlockedMin(4, 1, _93); + int _95; + ssbo.InterlockedMax(4, 1, _95); + int _97; + ssbo.InterlockedExchange(4, 1, _97); + int _99; + ssbo.InterlockedCompareExchange(4, 10, 2, _99); + int _102; + InterlockedAdd(int_atomic, 10, _102); + uint _105; + InterlockedAdd(uint_atomic, 10u, _105); + int _110; + InterlockedAdd(int_atomic_array[0], 10, _110); + uint _115; + InterlockedAdd(uint_atomic_array[0], 10u, _115); +} + +[numthreads(1, 1, 1)] +void main() +{ + comp_main(); +} diff --git a/reference/opt/shaders-hlsl/comp/barriers.comp b/reference/opt/shaders-hlsl/comp/barriers.comp new file mode 100644 index 0000000000..7ac2a656f0 --- /dev/null +++ b/reference/opt/shaders-hlsl/comp/barriers.comp @@ -0,0 +1,26 @@ +static const uint3 gl_WorkGroupSize = uint3(4u, 1u, 1u); + +void comp_main() +{ + GroupMemoryBarrier(); + AllMemoryBarrier(); + DeviceMemoryBarrier(); + DeviceMemoryBarrier(); + AllMemoryBarrier(); + GroupMemoryBarrierWithGroupSync(); + AllMemoryBarrier(); + GroupMemoryBarrierWithGroupSync(); + DeviceMemoryBarrier(); + GroupMemoryBarrierWithGroupSync(); + DeviceMemoryBarrier(); + GroupMemoryBarrierWithGroupSync(); + AllMemoryBarrier(); + GroupMemoryBarrierWithGroupSync(); + GroupMemoryBarrierWithGroupSync(); +} + +[numthreads(4, 1, 1)] +void main() +{ + comp_main(); +} diff --git a/reference/opt/shaders-hlsl/comp/bitfield.noopt.comp b/reference/opt/shaders-hlsl/comp/bitfield.noopt.comp new file mode 100644 index 0000000000..6839d9569e --- /dev/null +++ b/reference/opt/shaders-hlsl/comp/bitfield.noopt.comp @@ -0,0 +1,113 @@ +uint SPIRV_Cross_bitfieldInsert(uint Base, uint Insert, uint Offset, uint Count) +{ + uint Mask = Count == 32 ? 0xffffffff : (((1u << Count) - 1) << (Offset & 31)); + return (Base & ~Mask) | ((Insert << Offset) & Mask); +} + +uint2 SPIRV_Cross_bitfieldInsert(uint2 Base, uint2 Insert, uint Offset, uint Count) +{ + uint Mask = Count == 32 ? 0xffffffff : (((1u << Count) - 1) << (Offset & 31)); + return (Base & ~Mask) | ((Insert << Offset) & Mask); +} + +uint3 SPIRV_Cross_bitfieldInsert(uint3 Base, uint3 Insert, uint Offset, uint Count) +{ + uint Mask = Count == 32 ? 0xffffffff : (((1u << Count) - 1) << (Offset & 31)); + return (Base & ~Mask) | ((Insert << Offset) & Mask); +} + +uint4 SPIRV_Cross_bitfieldInsert(uint4 Base, uint4 Insert, uint Offset, uint Count) +{ + uint Mask = Count == 32 ? 0xffffffff : (((1u << Count) - 1) << (Offset & 31)); + return (Base & ~Mask) | ((Insert << Offset) & Mask); +} + +uint SPIRV_Cross_bitfieldUExtract(uint Base, uint Offset, uint Count) +{ + uint Mask = Count == 32 ? 0xffffffff : ((1 << Count) - 1); + return (Base >> Offset) & Mask; +} + +uint2 SPIRV_Cross_bitfieldUExtract(uint2 Base, uint Offset, uint Count) +{ + uint Mask = Count == 32 ? 0xffffffff : ((1 << Count) - 1); + return (Base >> Offset) & Mask; +} + +uint3 SPIRV_Cross_bitfieldUExtract(uint3 Base, uint Offset, uint Count) +{ + uint Mask = Count == 32 ? 0xffffffff : ((1 << Count) - 1); + return (Base >> Offset) & Mask; +} + +uint4 SPIRV_Cross_bitfieldUExtract(uint4 Base, uint Offset, uint Count) +{ + uint Mask = Count == 32 ? 0xffffffff : ((1 << Count) - 1); + return (Base >> Offset) & Mask; +} + +int SPIRV_Cross_bitfieldSExtract(int Base, int Offset, int Count) +{ + int Mask = Count == 32 ? -1 : ((1 << Count) - 1); + int Masked = (Base >> Offset) & Mask; + int ExtendShift = (32 - Count) & 31; + return (Masked << ExtendShift) >> ExtendShift; +} + +int2 SPIRV_Cross_bitfieldSExtract(int2 Base, int Offset, int Count) +{ + int Mask = Count == 32 ? -1 : ((1 << Count) - 1); + int2 Masked = (Base >> Offset) & Mask; + int ExtendShift = (32 - Count) & 31; + return (Masked << ExtendShift) >> ExtendShift; +} + +int3 SPIRV_Cross_bitfieldSExtract(int3 Base, int Offset, int Count) +{ + int Mask = Count == 32 ? -1 : ((1 << Count) - 1); + int3 Masked = (Base >> Offset) & Mask; + int ExtendShift = (32 - Count) & 31; + return (Masked << ExtendShift) >> ExtendShift; +} + +int4 SPIRV_Cross_bitfieldSExtract(int4 Base, int Offset, int Count) +{ + int Mask = Count == 32 ? -1 : ((1 << Count) - 1); + int4 Masked = (Base >> Offset) & Mask; + int ExtendShift = (32 - Count) & 31; + return (Masked << ExtendShift) >> ExtendShift; +} + +void comp_main() +{ + int signed_value = 0; + uint unsigned_value = 0u; + int3 signed_values = int3(0, 0, 0); + uint3 unsigned_values = uint3(0u, 0u, 0u); + int s = SPIRV_Cross_bitfieldSExtract(signed_value, 5, 20); + uint u = SPIRV_Cross_bitfieldUExtract(unsigned_value, 6, 21); + s = int(SPIRV_Cross_bitfieldInsert(s, 40, 5, 4)); + u = SPIRV_Cross_bitfieldInsert(u, 60u, 5, 4); + u = reversebits(u); + s = reversebits(s); + int v0 = countbits(u); + int v1 = countbits(s); + int v2 = firstbithigh(u); + int v3 = firstbitlow(s); + int3 s_1 = SPIRV_Cross_bitfieldSExtract(signed_values, 5, 20); + uint3 u_1 = SPIRV_Cross_bitfieldUExtract(unsigned_values, 6, 21); + s_1 = int3(SPIRV_Cross_bitfieldInsert(s_1, int3(40, 40, 40), 5, 4)); + u_1 = SPIRV_Cross_bitfieldInsert(u_1, uint3(60u, 60u, 60u), 5, 4); + u_1 = reversebits(u_1); + s_1 = reversebits(s_1); + int3 v0_1 = countbits(u_1); + int3 v1_1 = countbits(s_1); + int3 v2_1 = firstbithigh(u_1); + int3 v3_1 = firstbitlow(s_1); +} + +[numthreads(1, 1, 1)] +void main() +{ + comp_main(); +} diff --git a/reference/opt/shaders-hlsl/comp/builtins.comp b/reference/opt/shaders-hlsl/comp/builtins.comp new file mode 100644 index 0000000000..990fc85337 --- /dev/null +++ b/reference/opt/shaders-hlsl/comp/builtins.comp @@ -0,0 +1,9 @@ +void comp_main() +{ +} + +[numthreads(8, 4, 2)] +void main() +{ + comp_main(); +} diff --git a/reference/opt/shaders-hlsl/comp/image.comp b/reference/opt/shaders-hlsl/comp/image.comp new file mode 100644 index 0000000000..a8fc137581 --- /dev/null +++ b/reference/opt/shaders-hlsl/comp/image.comp @@ -0,0 +1,62 @@ +RWTexture2D uImageInF : register(u0); +RWTexture2D uImageOutF : register(u1); +RWTexture2D uImageInI : register(u2); +RWTexture2D uImageOutI : register(u3); +RWTexture2D uImageInU : register(u4); +RWTexture2D uImageOutU : register(u5); +RWBuffer uImageInBuffer : register(u6); +RWBuffer uImageOutBuffer : register(u7); +RWTexture2D uImageInF2 : register(u8); +RWTexture2D uImageOutF2 : register(u9); +RWTexture2D uImageInI2 : register(u10); +RWTexture2D uImageOutI2 : register(u11); +RWTexture2D uImageInU2 : register(u12); +RWTexture2D uImageOutU2 : register(u13); +RWBuffer uImageInBuffer2 : register(u14); +RWBuffer uImageOutBuffer2 : register(u15); +RWTexture2D uImageInF4 : register(u16); +RWTexture2D uImageOutF4 : register(u17); +RWTexture2D uImageInI4 : register(u18); +RWTexture2D uImageOutI4 : register(u19); +RWTexture2D uImageInU4 : register(u20); +RWTexture2D uImageOutU4 : register(u21); +RWBuffer uImageInBuffer4 : register(u22); +RWBuffer uImageOutBuffer4 : register(u23); +RWTexture2D uImageNoFmtF : register(u24); +RWTexture2D uImageNoFmtU : register(u25); +RWTexture2D uImageNoFmtI : register(u26); + +static uint3 gl_GlobalInvocationID; +struct SPIRV_Cross_Input +{ + uint3 gl_GlobalInvocationID : SV_DispatchThreadID; +}; + +void comp_main() +{ + uImageOutF[int2(gl_GlobalInvocationID.xy)] = uImageInF[int2(gl_GlobalInvocationID.xy)].x; + uImageOutI[int2(gl_GlobalInvocationID.xy)] = uImageInI[int2(gl_GlobalInvocationID.xy)].x; + uImageOutU[int2(gl_GlobalInvocationID.xy)] = uImageInU[int2(gl_GlobalInvocationID.xy)].x; + uImageOutBuffer[int(gl_GlobalInvocationID.x)] = uImageInBuffer[int(gl_GlobalInvocationID.x)].x; + uImageOutF2[int2(gl_GlobalInvocationID.xy)] = uImageInF2[int2(gl_GlobalInvocationID.xy)].xy; + uImageOutI2[int2(gl_GlobalInvocationID.xy)] = uImageInI2[int2(gl_GlobalInvocationID.xy)].xy; + uImageOutU2[int2(gl_GlobalInvocationID.xy)] = uImageInU2[int2(gl_GlobalInvocationID.xy)].xy; + float4 _135 = uImageInBuffer2[int(gl_GlobalInvocationID.x)].xyyy; + uImageOutBuffer2[int(gl_GlobalInvocationID.x)] = _135.xy; + uImageOutF4[int2(gl_GlobalInvocationID.xy)] = uImageInF4[int2(gl_GlobalInvocationID.xy)]; + int4 _165 = uImageInI4[int2(gl_GlobalInvocationID.xy)]; + uImageOutI4[int2(gl_GlobalInvocationID.xy)] = _165; + uint4 _180 = uImageInU4[int2(gl_GlobalInvocationID.xy)]; + uImageOutU4[int2(gl_GlobalInvocationID.xy)] = _180; + uImageOutBuffer4[int(gl_GlobalInvocationID.x)] = uImageInBuffer4[int(gl_GlobalInvocationID.x)]; + uImageNoFmtF[int2(gl_GlobalInvocationID.xy)] = _135; + uImageNoFmtU[int2(gl_GlobalInvocationID.xy)] = _180; + uImageNoFmtI[int2(gl_GlobalInvocationID.xy)] = _165; +} + +[numthreads(1, 1, 1)] +void main(SPIRV_Cross_Input stage_input) +{ + gl_GlobalInvocationID = stage_input.gl_GlobalInvocationID; + comp_main(); +} diff --git a/reference/opt/shaders-hlsl/comp/rwbuffer-matrix.comp b/reference/opt/shaders-hlsl/comp/rwbuffer-matrix.comp new file mode 100644 index 0000000000..c05f8ffbf8 --- /dev/null +++ b/reference/opt/shaders-hlsl/comp/rwbuffer-matrix.comp @@ -0,0 +1,90 @@ +RWByteAddressBuffer _28 : register(u0); +cbuffer _68 : register(b1) +{ + int _68_index0 : packoffset(c0); + int _68_index1 : packoffset(c0.y); +}; + +void comp_main() +{ + float4x4 _253 = asfloat(uint4x4(_28.Load(64), _28.Load(80), _28.Load(96), _28.Load(112), _28.Load(68), _28.Load(84), _28.Load(100), _28.Load(116), _28.Load(72), _28.Load(88), _28.Load(104), _28.Load(120), _28.Load(76), _28.Load(92), _28.Load(108), _28.Load(124))); + _28.Store4(0, asuint(_253[0])); + _28.Store4(16, asuint(_253[1])); + _28.Store4(32, asuint(_253[2])); + _28.Store4(48, asuint(_253[3])); + float2x2 _256 = asfloat(uint2x2(_28.Load(144), _28.Load(152), _28.Load(148), _28.Load(156))); + _28.Store2(128, asuint(_256[0])); + _28.Store2(136, asuint(_256[1])); + float2x3 _259 = asfloat(uint2x3(_28.Load(192), _28.Load(200), _28.Load(208), _28.Load(196), _28.Load(204), _28.Load(212))); + _28.Store3(160, asuint(_259[0])); + _28.Store3(176, asuint(_259[1])); + float3x2 _262 = asfloat(uint3x2(_28.Load(240), _28.Load(256), _28.Load(244), _28.Load(260), _28.Load(248), _28.Load(264))); + _28.Store2(216, asuint(_262[0])); + _28.Store2(224, asuint(_262[1])); + _28.Store2(232, asuint(_262[2])); + float4x4 _265 = asfloat(uint4x4(_28.Load4(0), _28.Load4(16), _28.Load4(32), _28.Load4(48))); + _28.Store(64, asuint(_265[0].x)); + _28.Store(68, asuint(_265[1].x)); + _28.Store(72, asuint(_265[2].x)); + _28.Store(76, asuint(_265[3].x)); + _28.Store(80, asuint(_265[0].y)); + _28.Store(84, asuint(_265[1].y)); + _28.Store(88, asuint(_265[2].y)); + _28.Store(92, asuint(_265[3].y)); + _28.Store(96, asuint(_265[0].z)); + _28.Store(100, asuint(_265[1].z)); + _28.Store(104, asuint(_265[2].z)); + _28.Store(108, asuint(_265[3].z)); + _28.Store(112, asuint(_265[0].w)); + _28.Store(116, asuint(_265[1].w)); + _28.Store(120, asuint(_265[2].w)); + _28.Store(124, asuint(_265[3].w)); + float2x2 _268 = asfloat(uint2x2(_28.Load2(128), _28.Load2(136))); + _28.Store(144, asuint(_268[0].x)); + _28.Store(148, asuint(_268[1].x)); + _28.Store(152, asuint(_268[0].y)); + _28.Store(156, asuint(_268[1].y)); + float2x3 _271 = asfloat(uint2x3(_28.Load3(160), _28.Load3(176))); + _28.Store(192, asuint(_271[0].x)); + _28.Store(196, asuint(_271[1].x)); + _28.Store(200, asuint(_271[0].y)); + _28.Store(204, asuint(_271[1].y)); + _28.Store(208, asuint(_271[0].z)); + _28.Store(212, asuint(_271[1].z)); + float3x2 _274 = asfloat(uint3x2(_28.Load2(216), _28.Load2(224), _28.Load2(232))); + _28.Store(240, asuint(_274[0].x)); + _28.Store(244, asuint(_274[1].x)); + _28.Store(248, asuint(_274[2].x)); + _28.Store(256, asuint(_274[0].y)); + _28.Store(260, asuint(_274[1].y)); + _28.Store(264, asuint(_274[2].y)); + _28.Store(_68_index0 * 4 + _68_index1 * 16 + 64, asuint(1.0f)); + _28.Store(_68_index0 * 4 + _68_index1 * 8 + 144, asuint(2.0f)); + _28.Store(_68_index0 * 4 + _68_index1 * 8 + 192, asuint(3.0f)); + _28.Store(_68_index0 * 4 + _68_index1 * 16 + 240, asuint(4.0f)); + _28.Store(_68_index0 * 4 + 64, asuint(1.0f.x)); + _28.Store(_68_index0 * 4 + 80, asuint(1.0f.xxxx.y)); + _28.Store(_68_index0 * 4 + 96, asuint(1.0f.xxxx.z)); + _28.Store(_68_index0 * 4 + 112, asuint(1.0f.xxxx.w)); + _28.Store(_68_index0 * 4 + 144, asuint(2.0f.x)); + _28.Store(_68_index0 * 4 + 152, asuint(2.0f.xx.y)); + _28.Store(_68_index0 * 4 + 192, asuint(3.0f.x)); + _28.Store(_68_index0 * 4 + 200, asuint(3.0f.xxx.y)); + _28.Store(_68_index0 * 4 + 208, asuint(3.0f.xxx.z)); + _28.Store(_68_index0 * 4 + 240, asuint(4.0f.x)); + _28.Store(_68_index0 * 4 + 256, asuint(4.0f.xx.y)); + _28.Store(_68_index0 * 16 + _68_index1 * 4 + 0, asuint(1.0f)); + _28.Store(_68_index0 * 8 + _68_index1 * 4 + 128, asuint(2.0f)); + _28.Store(_68_index0 * 16 + _68_index1 * 4 + 160, asuint(3.0f)); + _28.Store(_68_index0 * 8 + _68_index1 * 4 + 216, asuint(4.0f)); + _28.Store4(_68_index0 * 16 + 0, asuint(1.0f.xxxx)); + _28.Store2(_68_index0 * 8 + 128, asuint(2.0f.xx)); + _28.Store3(_68_index0 * 16 + 160, asuint(3.0f.xxx)); + _28.Store2(_68_index0 * 8 + 216, asuint(4.0f.xx)); +} + +[numthreads(1, 1, 1)] +void main() +{ + comp_main(); +} diff --git a/reference/opt/shaders-hlsl/comp/shared.comp b/reference/opt/shaders-hlsl/comp/shared.comp new file mode 100644 index 0000000000..498241eaca --- /dev/null +++ b/reference/opt/shaders-hlsl/comp/shared.comp @@ -0,0 +1,29 @@ +static const uint3 gl_WorkGroupSize = uint3(4u, 1u, 1u); + +ByteAddressBuffer _22 : register(t0); +RWByteAddressBuffer _44 : register(u1); + +static uint3 gl_GlobalInvocationID; +static uint gl_LocalInvocationIndex; +struct SPIRV_Cross_Input +{ + uint3 gl_GlobalInvocationID : SV_DispatchThreadID; + uint gl_LocalInvocationIndex : SV_GroupIndex; +}; + +groupshared float sShared[4]; + +void comp_main() +{ + sShared[gl_LocalInvocationIndex] = asfloat(_22.Load(gl_GlobalInvocationID.x * 4 + 0)); + GroupMemoryBarrierWithGroupSync(); + _44.Store(gl_GlobalInvocationID.x * 4 + 0, asuint(sShared[(4u - gl_LocalInvocationIndex) - 1u])); +} + +[numthreads(4, 1, 1)] +void main(SPIRV_Cross_Input stage_input) +{ + gl_GlobalInvocationID = stage_input.gl_GlobalInvocationID; + gl_LocalInvocationIndex = stage_input.gl_LocalInvocationIndex; + comp_main(); +} diff --git a/reference/opt/shaders-hlsl/comp/ssbo-array.comp b/reference/opt/shaders-hlsl/comp/ssbo-array.comp new file mode 100644 index 0000000000..d8bce8d54b --- /dev/null +++ b/reference/opt/shaders-hlsl/comp/ssbo-array.comp @@ -0,0 +1,9 @@ +void comp_main() +{ +} + +[numthreads(1, 1, 1)] +void main() +{ + comp_main(); +} diff --git a/reference/opt/shaders-hlsl/frag/basic.frag b/reference/opt/shaders-hlsl/frag/basic.frag new file mode 100644 index 0000000000..6d067041c2 --- /dev/null +++ b/reference/opt/shaders-hlsl/frag/basic.frag @@ -0,0 +1,32 @@ +Texture2D uTex : register(t0); +SamplerState _uTex_sampler : register(s0); + +static float4 FragColor; +static float4 vColor; +static float2 vTex; + +struct SPIRV_Cross_Input +{ + float4 vColor : TEXCOORD0; + float2 vTex : TEXCOORD1; +}; + +struct SPIRV_Cross_Output +{ + float4 FragColor : SV_Target0; +}; + +void frag_main() +{ + FragColor = vColor * uTex.Sample(_uTex_sampler, vTex); +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + vColor = stage_input.vColor; + vTex = stage_input.vTex; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/frag/bit-conversions.frag b/reference/opt/shaders-hlsl/frag/bit-conversions.frag new file mode 100644 index 0000000000..b60b2ebb4a --- /dev/null +++ b/reference/opt/shaders-hlsl/frag/bit-conversions.frag @@ -0,0 +1,26 @@ +static float2 value; +static float4 FragColor; + +struct SPIRV_Cross_Input +{ + float2 value : TEXCOORD0; +}; + +struct SPIRV_Cross_Output +{ + float4 FragColor : SV_Target0; +}; + +void frag_main() +{ + FragColor = float4(1.0f, 0.0f, asfloat(asint(value.x)), 1.0f); +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + value = stage_input.value; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/frag/boolean-mix.frag b/reference/opt/shaders-hlsl/frag/boolean-mix.frag new file mode 100644 index 0000000000..f3e84898d6 --- /dev/null +++ b/reference/opt/shaders-hlsl/frag/boolean-mix.frag @@ -0,0 +1,27 @@ +static float2 FragColor; +static float2 x0; + +struct SPIRV_Cross_Input +{ + float2 x0 : TEXCOORD0; +}; + +struct SPIRV_Cross_Output +{ + float2 FragColor : SV_Target0; +}; + +void frag_main() +{ + bool2 _27 = (x0.x > x0.y).xx; + FragColor = float2(_27.x ? float2(1.0f, 0.0f).x : float2(0.0f, 1.0f).x, _27.y ? float2(1.0f, 0.0f).y : float2(0.0f, 1.0f).y); +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + x0 = stage_input.x0; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/frag/builtins.frag b/reference/opt/shaders-hlsl/frag/builtins.frag new file mode 100644 index 0000000000..922eca7c2d --- /dev/null +++ b/reference/opt/shaders-hlsl/frag/builtins.frag @@ -0,0 +1,33 @@ +static float4 gl_FragCoord; +static float gl_FragDepth; +static float4 FragColor; +static float4 vColor; + +struct SPIRV_Cross_Input +{ + float4 vColor : TEXCOORD0; + float4 gl_FragCoord : SV_Position; +}; + +struct SPIRV_Cross_Output +{ + float4 FragColor : SV_Target0; + float gl_FragDepth : SV_Depth; +}; + +void frag_main() +{ + FragColor = gl_FragCoord + vColor; + gl_FragDepth = 0.5f; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + gl_FragCoord = stage_input.gl_FragCoord; + vColor = stage_input.vColor; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_FragDepth = gl_FragDepth; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/frag/bvec-operations.frag b/reference/opt/shaders-hlsl/frag/bvec-operations.frag new file mode 100644 index 0000000000..886e71180e --- /dev/null +++ b/reference/opt/shaders-hlsl/frag/bvec-operations.frag @@ -0,0 +1,27 @@ +static float2 value; +static float4 FragColor; + +struct SPIRV_Cross_Input +{ + float2 value : TEXCOORD0; +}; + +struct SPIRV_Cross_Output +{ + float4 FragColor : SV_Target0; +}; + +void frag_main() +{ + bool2 _25 = bool2(value.x == 0.0f, value.y == 0.0f); + FragColor = float4(1.0f, 0.0f, float(bool2(!_25.x, !_25.y).x), float(bool2(value.x <= float2(1.5f, 0.5f).x, value.y <= float2(1.5f, 0.5f).y).x)); +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + value = stage_input.value; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/frag/combined-texture-sampler-parameter.frag b/reference/opt/shaders-hlsl/frag/combined-texture-sampler-parameter.frag new file mode 100644 index 0000000000..18968cb193 --- /dev/null +++ b/reference/opt/shaders-hlsl/frag/combined-texture-sampler-parameter.frag @@ -0,0 +1,24 @@ +Texture2D uSampler : register(t0); +SamplerState _uSampler_sampler : register(s0); +Texture2D uSamplerShadow : register(t1); +SamplerComparisonState _uSamplerShadow_sampler : register(s1); + +static float FragColor; + +struct SPIRV_Cross_Output +{ + float FragColor : SV_Target0; +}; + +void frag_main() +{ + FragColor = (uSampler.Sample(_uSampler_sampler, 1.0f.xx) + uSampler.Load(int3(int2(10, 10), 0))).x + uSamplerShadow.SampleCmp(_uSamplerShadow_sampler, 1.0f.xxx.xy, 1.0f); +} + +SPIRV_Cross_Output main() +{ + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/frag/combined-texture-sampler-shadow.frag b/reference/opt/shaders-hlsl/frag/combined-texture-sampler-shadow.frag new file mode 100644 index 0000000000..6e8f833b34 --- /dev/null +++ b/reference/opt/shaders-hlsl/frag/combined-texture-sampler-shadow.frag @@ -0,0 +1,23 @@ +Texture2D uDepth : register(t2); +SamplerComparisonState uSampler : register(s0); +SamplerState uSampler1 : register(s1); + +static float FragColor; + +struct SPIRV_Cross_Output +{ + float FragColor : SV_Target0; +}; + +void frag_main() +{ + FragColor = uDepth.SampleCmp(uSampler, 1.0f.xxx.xy, 1.0f) + uDepth.Sample(uSampler1, 1.0f.xx).x; +} + +SPIRV_Cross_Output main() +{ + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/frag/constant-buffer-array.sm51.frag b/reference/opt/shaders-hlsl/frag/constant-buffer-array.sm51.frag new file mode 100644 index 0000000000..7e613da1cf --- /dev/null +++ b/reference/opt/shaders-hlsl/frag/constant-buffer-array.sm51.frag @@ -0,0 +1,43 @@ +struct CBO_1 +{ + float4 a; + float4 b; + float4 c; + float4 d; +}; + +ConstantBuffer cbo[2][4] : register(b4, space0); +cbuffer push +{ + float4 push_a : packoffset(c0); + float4 push_b : packoffset(c1); + float4 push_c : packoffset(c2); + float4 push_d : packoffset(c3); +}; + +static float4 FragColor; + +struct SPIRV_Cross_Output +{ + float4 FragColor : SV_Target0; +}; + +void frag_main() +{ + FragColor = cbo[1][2].a; + FragColor += cbo[1][2].b; + FragColor += cbo[1][2].c; + FragColor += cbo[1][2].d; + FragColor += push_a; + FragColor += push_b; + FragColor += push_c; + FragColor += push_d; +} + +SPIRV_Cross_Output main() +{ + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/frag/constant-composites.frag b/reference/opt/shaders-hlsl/frag/constant-composites.frag new file mode 100644 index 0000000000..0514eef1ee --- /dev/null +++ b/reference/opt/shaders-hlsl/frag/constant-composites.frag @@ -0,0 +1,43 @@ +struct Foo +{ + float a; + float b; +}; + +static const float _16[4] = { 1.0f, 4.0f, 3.0f, 2.0f }; +static const Foo _24 = { 10.0f, 20.0f }; +static const Foo _27 = { 30.0f, 40.0f }; +static const Foo _28[2] = { { 10.0f, 20.0f }, { 30.0f, 40.0f } }; + +static float4 FragColor; +static int _line; + +struct SPIRV_Cross_Input +{ + nointerpolation int _line : TEXCOORD0; +}; + +struct SPIRV_Cross_Output +{ + float4 FragColor : SV_Target0; +}; + +static float lut[4]; +static Foo foos[2]; + +void frag_main() +{ + lut = _16; + foos = _28; + FragColor = lut[_line].xxxx; + FragColor += (foos[_line].a * (foos[1 - _line].a)).xxxx; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + _line = stage_input._line; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/frag/early-fragment-test.frag b/reference/opt/shaders-hlsl/frag/early-fragment-test.frag new file mode 100644 index 0000000000..ae2569d5cf --- /dev/null +++ b/reference/opt/shaders-hlsl/frag/early-fragment-test.frag @@ -0,0 +1,9 @@ +void frag_main() +{ +} + +[earlydepthstencil] +void main() +{ + frag_main(); +} diff --git a/reference/opt/shaders-hlsl/frag/fp16-packing.frag b/reference/opt/shaders-hlsl/frag/fp16-packing.frag new file mode 100644 index 0000000000..d87828225f --- /dev/null +++ b/reference/opt/shaders-hlsl/frag/fp16-packing.frag @@ -0,0 +1,44 @@ +static float2 FP32Out; +static uint FP16; +static uint FP16Out; +static float2 FP32; + +struct SPIRV_Cross_Input +{ + nointerpolation uint FP16 : TEXCOORD0; + nointerpolation float2 FP32 : TEXCOORD1; +}; + +struct SPIRV_Cross_Output +{ + float2 FP32Out : SV_Target0; + uint FP16Out : SV_Target1; +}; + +uint SPIRV_Cross_packHalf2x16(float2 value) +{ + uint2 Packed = f32tof16(value); + return Packed.x | (Packed.y << 16); +} + +float2 SPIRV_Cross_unpackHalf2x16(uint value) +{ + return f16tof32(uint2(value & 0xffff, value >> 16)); +} + +void frag_main() +{ + FP32Out = SPIRV_Cross_unpackHalf2x16(FP16); + FP16Out = SPIRV_Cross_packHalf2x16(FP32); +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + FP16 = stage_input.FP16; + FP32 = stage_input.FP32; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FP32Out = FP32Out; + stage_output.FP16Out = FP16Out; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/frag/image-query-selective.frag b/reference/opt/shaders-hlsl/frag/image-query-selective.frag new file mode 100644 index 0000000000..c73b742b5a --- /dev/null +++ b/reference/opt/shaders-hlsl/frag/image-query-selective.frag @@ -0,0 +1,29 @@ +Texture1D uSampler1DUint : register(t0); +SamplerState _uSampler1DUint_sampler : register(s0); +Texture1D uSampler1DInt : register(t0); +SamplerState _uSampler1DInt_sampler : register(s0); + +uint SPIRV_Cross_textureSize(Texture1D Tex, uint Level, out uint Param) +{ + uint ret; + Tex.GetDimensions(Level, ret.x, Param); + return ret; +} + +uint SPIRV_Cross_textureSize(Texture1D Tex, uint Level, out uint Param) +{ + uint ret; + Tex.GetDimensions(Level, ret.x, Param); + return ret; +} + +void frag_main() +{ + uint _17_dummy_parameter; + uint _24_dummy_parameter; +} + +void main() +{ + frag_main(); +} diff --git a/reference/opt/shaders-hlsl/frag/image-query.frag b/reference/opt/shaders-hlsl/frag/image-query.frag new file mode 100644 index 0000000000..3b50282fe0 --- /dev/null +++ b/reference/opt/shaders-hlsl/frag/image-query.frag @@ -0,0 +1,8 @@ +void frag_main() +{ +} + +void main() +{ + frag_main(); +} diff --git a/reference/opt/shaders-hlsl/frag/io-block.frag b/reference/opt/shaders-hlsl/frag/io-block.frag new file mode 100644 index 0000000000..52c1f518bf --- /dev/null +++ b/reference/opt/shaders-hlsl/frag/io-block.frag @@ -0,0 +1,28 @@ +static float4 FragColor; + +struct VertexOut +{ + float4 a : TEXCOORD1; + float4 b : TEXCOORD2; +}; + +static VertexOut _12; + +struct SPIRV_Cross_Output +{ + float4 FragColor : SV_Target0; +}; + +void frag_main() +{ + FragColor = _12.a + _12.b; +} + +SPIRV_Cross_Output main(in VertexOut stage_input_12) +{ + _12 = stage_input_12; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/frag/matrix-input.frag b/reference/opt/shaders-hlsl/frag/matrix-input.frag new file mode 100644 index 0000000000..92d87d396e --- /dev/null +++ b/reference/opt/shaders-hlsl/frag/matrix-input.frag @@ -0,0 +1,26 @@ +static float4 FragColor; +static float4x4 m; + +struct SPIRV_Cross_Input +{ + float4x4 m : TEXCOORD1; +}; + +struct SPIRV_Cross_Output +{ + float4 FragColor : SV_Target0; +}; + +void frag_main() +{ + FragColor = ((m[0] + m[1]) + m[2]) + m[3]; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + m = stage_input.m; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/frag/mod.frag b/reference/opt/shaders-hlsl/frag/mod.frag new file mode 100644 index 0000000000..41ac930496 --- /dev/null +++ b/reference/opt/shaders-hlsl/frag/mod.frag @@ -0,0 +1,67 @@ +static float4 a4; +static float4 b4; +static float3 a3; +static float3 b3; +static float2 a2; +static float2 b2; +static float a1; +static float b1; +static float4 FragColor; + +struct SPIRV_Cross_Input +{ + float4 a4 : TEXCOORD0; + float3 a3 : TEXCOORD1; + float2 a2 : TEXCOORD2; + float a1 : TEXCOORD3; + float4 b4 : TEXCOORD4; + float3 b3 : TEXCOORD5; + float2 b2 : TEXCOORD6; + float b1 : TEXCOORD7; +}; + +struct SPIRV_Cross_Output +{ + float4 FragColor : SV_Target0; +}; + +float mod(float x, float y) +{ + return x - y * floor(x / y); +} + +float2 mod(float2 x, float2 y) +{ + return x - y * floor(x / y); +} + +float3 mod(float3 x, float3 y) +{ + return x - y * floor(x / y); +} + +float4 mod(float4 x, float4 y) +{ + return x - y * floor(x / y); +} + +void frag_main() +{ + FragColor = ((mod(a4, b4) + mod(a3, b3).xyzx) + mod(a2, b2).xyxy) + mod(a1, b1).xxxx; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + a4 = stage_input.a4; + b4 = stage_input.b4; + a3 = stage_input.a3; + b3 = stage_input.b3; + a2 = stage_input.a2; + b2 = stage_input.b2; + a1 = stage_input.a1; + b1 = stage_input.b1; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/frag/mrt.frag b/reference/opt/shaders-hlsl/frag/mrt.frag new file mode 100644 index 0000000000..e69e91196a --- /dev/null +++ b/reference/opt/shaders-hlsl/frag/mrt.frag @@ -0,0 +1,31 @@ +static float4 RT0; +static float4 RT1; +static float4 RT2; +static float4 RT3; + +struct SPIRV_Cross_Output +{ + float4 RT0 : SV_Target0; + float4 RT1 : SV_Target1; + float4 RT2 : SV_Target2; + float4 RT3 : SV_Target3; +}; + +void frag_main() +{ + RT0 = 1.0f.xxxx; + RT1 = 2.0f.xxxx; + RT2 = 3.0f.xxxx; + RT3 = 4.0f.xxxx; +} + +SPIRV_Cross_Output main() +{ + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.RT0 = RT0; + stage_output.RT1 = RT1; + stage_output.RT2 = RT2; + stage_output.RT3 = RT3; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/frag/no-return.frag b/reference/opt/shaders-hlsl/frag/no-return.frag new file mode 100644 index 0000000000..3b50282fe0 --- /dev/null +++ b/reference/opt/shaders-hlsl/frag/no-return.frag @@ -0,0 +1,8 @@ +void frag_main() +{ +} + +void main() +{ + frag_main(); +} diff --git a/reference/opt/shaders-hlsl/frag/no-return2.frag b/reference/opt/shaders-hlsl/frag/no-return2.frag new file mode 100644 index 0000000000..e9d7bbc8f9 --- /dev/null +++ b/reference/opt/shaders-hlsl/frag/no-return2.frag @@ -0,0 +1,16 @@ +static float4 vColor; + +struct SPIRV_Cross_Input +{ + float4 vColor : TEXCOORD0; +}; + +void frag_main() +{ +} + +void main(SPIRV_Cross_Input stage_input) +{ + vColor = stage_input.vColor; + frag_main(); +} diff --git a/reference/opt/shaders-hlsl/frag/partial-write-preserve.frag b/reference/opt/shaders-hlsl/frag/partial-write-preserve.frag new file mode 100644 index 0000000000..20da99c336 --- /dev/null +++ b/reference/opt/shaders-hlsl/frag/partial-write-preserve.frag @@ -0,0 +1,14 @@ +struct B +{ + float a; + float b; +}; + +void frag_main() +{ +} + +void main() +{ + frag_main(); +} diff --git a/reference/opt/shaders-hlsl/frag/query-lod.desktop.frag b/reference/opt/shaders-hlsl/frag/query-lod.desktop.frag new file mode 100644 index 0000000000..fd95798bf4 --- /dev/null +++ b/reference/opt/shaders-hlsl/frag/query-lod.desktop.frag @@ -0,0 +1,30 @@ +Texture2D uSampler : register(t0); +SamplerState _uSampler_sampler : register(s0); + +static float4 FragColor; +static float2 vTexCoord; + +struct SPIRV_Cross_Input +{ + float2 vTexCoord : TEXCOORD0; +}; + +struct SPIRV_Cross_Output +{ + float4 FragColor : SV_Target0; +}; + +void frag_main() +{ + float _19_tmp = uSampler.CalculateLevelOfDetail(_uSampler_sampler, vTexCoord); + FragColor = float2(_19_tmp, _19_tmp).xyxy; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + vTexCoord = stage_input.vTexCoord; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/frag/resources.frag b/reference/opt/shaders-hlsl/frag/resources.frag new file mode 100644 index 0000000000..24b93c239c --- /dev/null +++ b/reference/opt/shaders-hlsl/frag/resources.frag @@ -0,0 +1,39 @@ +cbuffer cbuf : register(b3) +{ + float4 cbuf_a : packoffset(c0); +}; +cbuffer registers +{ + float4 registers_d : packoffset(c0); +}; +Texture2D uSampledImage : register(t4); +SamplerState _uSampledImage_sampler : register(s4); +Texture2D uTexture : register(t5); +SamplerState uSampler : register(s6); + +static float2 vTex; +static float4 FragColor; + +struct SPIRV_Cross_Input +{ + float2 vTex : TEXCOORD0; +}; + +struct SPIRV_Cross_Output +{ + float4 FragColor : SV_Target0; +}; + +void frag_main() +{ + FragColor = (uSampledImage.Sample(_uSampledImage_sampler, vTex) + uTexture.Sample(uSampler, vTex)) + (cbuf_a + registers_d); +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + vTex = stage_input.vTex; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/frag/sample-cmp-level-zero.frag b/reference/opt/shaders-hlsl/frag/sample-cmp-level-zero.frag new file mode 100644 index 0000000000..6f5ae7e38c --- /dev/null +++ b/reference/opt/shaders-hlsl/frag/sample-cmp-level-zero.frag @@ -0,0 +1,57 @@ +Texture2D uSampler2D : register(t0); +SamplerComparisonState _uSampler2D_sampler : register(s0); +Texture2DArray uSampler2DArray : register(t1); +SamplerComparisonState _uSampler2DArray_sampler : register(s1); +TextureCube uSamplerCube : register(t2); +SamplerComparisonState _uSamplerCube_sampler : register(s2); +TextureCubeArray uSamplerCubeArray : register(t3); +SamplerComparisonState _uSamplerCubeArray_sampler : register(s3); + +static float3 vUVRef; +static float4 vDirRef; +static float FragColor; + +struct SPIRV_Cross_Input +{ + float3 vUVRef : TEXCOORD0; + float4 vDirRef : TEXCOORD1; +}; + +struct SPIRV_Cross_Output +{ + float FragColor : SV_Target0; +}; + +float SPIRV_Cross_projectTextureCoordinate(float2 coord) +{ + return coord.x / coord.y; +} + +float2 SPIRV_Cross_projectTextureCoordinate(float3 coord) +{ + return float2(coord.x, coord.y) / coord.z; +} + +float3 SPIRV_Cross_projectTextureCoordinate(float4 coord) +{ + return float3(coord.x, coord.y, coord.z) / coord.w; +} + +void frag_main() +{ + float4 _80 = vDirRef; + _80.z = vDirRef.w; + float4 _87 = vDirRef; + _87.z = vDirRef.w; + FragColor = (((((((uSampler2D.SampleCmp(_uSampler2D_sampler, vUVRef.xy, vUVRef.z, int2(-1, -1)) + uSampler2DArray.SampleCmp(_uSampler2DArray_sampler, vDirRef.xyz, vDirRef.w, int2(-1, -1))) + uSamplerCube.SampleCmp(_uSamplerCube_sampler, vDirRef.xyz, vDirRef.w)) + uSamplerCubeArray.SampleCmp(_uSamplerCubeArray_sampler, vDirRef, 0.5f)) + uSampler2D.SampleCmpLevelZero(_uSampler2D_sampler, vUVRef.xy, vUVRef.z, int2(-1, -1))) + uSampler2DArray.SampleCmpLevelZero(_uSampler2DArray_sampler, vDirRef.xyz, vDirRef.w, int2(-1, -1))) + uSamplerCube.SampleCmpLevelZero(_uSamplerCube_sampler, vDirRef.xyz, vDirRef.w)) + uSampler2D.SampleCmp(_uSampler2D_sampler, SPIRV_Cross_projectTextureCoordinate(_80.xyz), vDirRef.z, int2(1, 1))) + uSampler2D.SampleCmpLevelZero(_uSampler2D_sampler, SPIRV_Cross_projectTextureCoordinate(_87.xyz), vDirRef.z, int2(1, 1)); +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + vUVRef = stage_input.vUVRef; + vDirRef = stage_input.vDirRef; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/frag/sampler-array.frag b/reference/opt/shaders-hlsl/frag/sampler-array.frag new file mode 100644 index 0000000000..5b8e492de6 --- /dev/null +++ b/reference/opt/shaders-hlsl/frag/sampler-array.frag @@ -0,0 +1,29 @@ +Texture2D uCombined[4] : register(t0); +SamplerState _uCombined_sampler[4] : register(s0); +Texture2D uTex[4] : register(t4); +SamplerState uSampler[4] : register(s8); +RWTexture2D uImage[8] : register(u12); + +static float4 gl_FragCoord; +static float2 vTex; +static int vIndex; + +struct SPIRV_Cross_Input +{ + float2 vTex : TEXCOORD0; + nointerpolation int vIndex : TEXCOORD1; + float4 gl_FragCoord : SV_Position; +}; + +void frag_main() +{ + uImage[vIndex][int2(gl_FragCoord.xy)] = ((uCombined[vIndex].Sample(_uCombined_sampler[vIndex], vTex) + uTex[vIndex].Sample(uSampler[vIndex], vTex)) + (uCombined[vIndex + 1].Sample(_uCombined_sampler[vIndex + 1], vTex))) + (uTex[vIndex + 1].Sample(uSampler[vIndex + 1], vTex)); +} + +void main(SPIRV_Cross_Input stage_input) +{ + gl_FragCoord = stage_input.gl_FragCoord; + vTex = stage_input.vTex; + vIndex = stage_input.vIndex; + frag_main(); +} diff --git a/reference/opt/shaders-hlsl/frag/spec-constant.frag b/reference/opt/shaders-hlsl/frag/spec-constant.frag new file mode 100644 index 0000000000..781e3f20b8 --- /dev/null +++ b/reference/opt/shaders-hlsl/frag/spec-constant.frag @@ -0,0 +1,33 @@ +static const float a = 1.0f; +static const float b = 2.0f; +static const int c = 3; +static const int d = 4; + +struct Foo +{ + float elems[(d + 2)]; +}; + +static float4 FragColor; + +struct SPIRV_Cross_Output +{ + float4 FragColor : SV_Target0; +}; + +void frag_main() +{ + float vec0[(c + 3)][8]; + vec0[0][0] = 10.0f; + Foo foo; + foo.elems[c] = 10.0f; + FragColor = (((a + b).xxxx + vec0[0][0].xxxx) + 20.0f.xxxx) + foo.elems[c].xxxx; +} + +SPIRV_Cross_Output main() +{ + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/frag/swizzle-scalar.frag b/reference/opt/shaders-hlsl/frag/swizzle-scalar.frag new file mode 100644 index 0000000000..ab310b82f2 --- /dev/null +++ b/reference/opt/shaders-hlsl/frag/swizzle-scalar.frag @@ -0,0 +1,41 @@ +static float4 Float; +static float vFloat; +static int4 Int; +static int vInt; +static float4 Float2; +static int4 Int2; + +struct SPIRV_Cross_Input +{ + nointerpolation float vFloat : TEXCOORD0; + nointerpolation int vInt : TEXCOORD1; +}; + +struct SPIRV_Cross_Output +{ + float4 Float : SV_Target0; + int4 Int : SV_Target1; + float4 Float2 : SV_Target2; + int4 Int2 : SV_Target3; +}; + +void frag_main() +{ + Float = vFloat.xxxx * 2.0f; + Int = vInt.xxxx * int4(2, 2, 2, 2); + Float2 = 10.0f.xxxx; + Int2 = int4(10, 10, 10, 10); +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + vFloat = stage_input.vFloat; + vInt = stage_input.vInt; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.Float = Float; + stage_output.Int = Int; + stage_output.Float2 = Float2; + stage_output.Int2 = Int2; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/frag/tex-sampling.frag b/reference/opt/shaders-hlsl/frag/tex-sampling.frag new file mode 100644 index 0000000000..6ebca5d8d1 --- /dev/null +++ b/reference/opt/shaders-hlsl/frag/tex-sampling.frag @@ -0,0 +1,87 @@ +Texture1D tex1d; +SamplerState _tex1d_sampler; +Texture2D tex2d; +SamplerState _tex2d_sampler; +Texture3D tex3d; +SamplerState _tex3d_sampler; +TextureCube texCube; +SamplerState _texCube_sampler; +Texture1D tex1dShadow; +SamplerComparisonState _tex1dShadow_sampler; +Texture2D tex2dShadow; +SamplerComparisonState _tex2dShadow_sampler; +TextureCube texCubeShadow; +SamplerComparisonState _texCubeShadow_sampler; +Texture1DArray tex1dArray; +SamplerState _tex1dArray_sampler; +Texture2DArray tex2dArray; +SamplerState _tex2dArray_sampler; +TextureCubeArray texCubeArray; +SamplerState _texCubeArray_sampler; +Texture2D separateTex2d; +SamplerState samplerNonDepth; +Texture2D separateTex2dDepth; +SamplerComparisonState samplerDepth; + +static float texCoord1d; +static float2 texCoord2d; +static float3 texCoord3d; +static float4 texCoord4d; +static float4 FragColor; + +struct SPIRV_Cross_Input +{ + float texCoord1d : TEXCOORD0; + float2 texCoord2d : TEXCOORD1; + float3 texCoord3d : TEXCOORD2; + float4 texCoord4d : TEXCOORD3; +}; + +struct SPIRV_Cross_Output +{ + float4 FragColor : SV_Target0; +}; + +float SPIRV_Cross_projectTextureCoordinate(float2 coord) +{ + return coord.x / coord.y; +} + +float2 SPIRV_Cross_projectTextureCoordinate(float3 coord) +{ + return float2(coord.x, coord.y) / coord.z; +} + +float3 SPIRV_Cross_projectTextureCoordinate(float4 coord) +{ + return float3(coord.x, coord.y, coord.z) / coord.w; +} + +void frag_main() +{ + float4 _162 = (((((((((((((((((((tex1d.Sample(_tex1d_sampler, texCoord1d) + tex1d.Sample(_tex1d_sampler, texCoord1d, 1)) + tex1d.SampleLevel(_tex1d_sampler, texCoord1d, 2.0f)) + tex1d.SampleGrad(_tex1d_sampler, texCoord1d, 1.0f, 2.0f)) + tex1d.Sample(_tex1d_sampler, SPIRV_Cross_projectTextureCoordinate(float2(texCoord1d, 2.0f)))) + tex1d.SampleBias(_tex1d_sampler, texCoord1d, 1.0f)) + tex2d.Sample(_tex2d_sampler, texCoord2d)) + tex2d.Sample(_tex2d_sampler, texCoord2d, int2(1, 2))) + tex2d.SampleLevel(_tex2d_sampler, texCoord2d, 2.0f)) + tex2d.SampleGrad(_tex2d_sampler, texCoord2d, float2(1.0f, 2.0f), float2(3.0f, 4.0f))) + tex2d.Sample(_tex2d_sampler, SPIRV_Cross_projectTextureCoordinate(float3(texCoord2d, 2.0f)))) + tex2d.SampleBias(_tex2d_sampler, texCoord2d, 1.0f)) + tex3d.Sample(_tex3d_sampler, texCoord3d)) + tex3d.Sample(_tex3d_sampler, texCoord3d, int3(1, 2, 3))) + tex3d.SampleLevel(_tex3d_sampler, texCoord3d, 2.0f)) + tex3d.SampleGrad(_tex3d_sampler, texCoord3d, float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f))) + tex3d.Sample(_tex3d_sampler, SPIRV_Cross_projectTextureCoordinate(float4(texCoord3d, 2.0f)))) + tex3d.SampleBias(_tex3d_sampler, texCoord3d, 1.0f)) + texCube.Sample(_texCube_sampler, texCoord3d)) + texCube.SampleLevel(_texCube_sampler, texCoord3d, 2.0f)) + texCube.SampleBias(_texCube_sampler, texCoord3d, 1.0f); + float _178 = _162.w + tex1dShadow.SampleCmp(_tex1dShadow_sampler, float3(texCoord1d, 0.0f, 0.0f).x, 0.0f); + float4 _327 = _162; + _327.w = _178; + float _193 = _178 + tex2dShadow.SampleCmp(_tex2dShadow_sampler, float3(texCoord2d, 0.0f).xy, 0.0f); + float4 _331 = _327; + _331.w = _193; + float4 _335 = _331; + _335.w = _193 + texCubeShadow.SampleCmp(_texCubeShadow_sampler, float4(texCoord3d, 0.0f).xyz, 0.0f); + float4 _308 = ((((((((((((((_335 + tex1dArray.Sample(_tex1dArray_sampler, texCoord2d)) + tex2dArray.Sample(_tex2dArray_sampler, texCoord3d)) + texCubeArray.Sample(_texCubeArray_sampler, texCoord4d)) + tex2d.GatherRed(_tex2d_sampler, texCoord2d)) + tex2d.GatherRed(_tex2d_sampler, texCoord2d)) + tex2d.GatherGreen(_tex2d_sampler, texCoord2d)) + tex2d.GatherBlue(_tex2d_sampler, texCoord2d)) + tex2d.GatherAlpha(_tex2d_sampler, texCoord2d)) + tex2d.GatherRed(_tex2d_sampler, texCoord2d, int2(1, 1))) + tex2d.GatherRed(_tex2d_sampler, texCoord2d, int2(1, 1))) + tex2d.GatherGreen(_tex2d_sampler, texCoord2d, int2(1, 1))) + tex2d.GatherBlue(_tex2d_sampler, texCoord2d, int2(1, 1))) + tex2d.GatherAlpha(_tex2d_sampler, texCoord2d, int2(1, 1))) + tex2d.Load(int3(int2(1, 2), 0))) + separateTex2d.Sample(samplerNonDepth, texCoord2d); + float4 _339 = _308; + _339.w = _308.w + separateTex2dDepth.SampleCmp(samplerDepth, texCoord3d.xy, texCoord3d.z); + FragColor = _339; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + texCoord1d = stage_input.texCoord1d; + texCoord2d = stage_input.texCoord2d; + texCoord3d = stage_input.texCoord3d; + texCoord4d = stage_input.texCoord4d; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/frag/texture-proj-shadow.frag b/reference/opt/shaders-hlsl/frag/texture-proj-shadow.frag new file mode 100644 index 0000000000..4beaa11761 --- /dev/null +++ b/reference/opt/shaders-hlsl/frag/texture-proj-shadow.frag @@ -0,0 +1,66 @@ +Texture1D uShadow1D : register(t0); +SamplerComparisonState _uShadow1D_sampler : register(s0); +Texture2D uShadow2D : register(t1); +SamplerComparisonState _uShadow2D_sampler : register(s1); +Texture1D uSampler1D : register(t2); +SamplerState _uSampler1D_sampler : register(s2); +Texture2D uSampler2D : register(t3); +SamplerState _uSampler2D_sampler : register(s3); +Texture3D uSampler3D : register(t4); +SamplerState _uSampler3D_sampler : register(s4); + +static float FragColor; +static float4 vClip4; +static float2 vClip2; +static float3 vClip3; + +struct SPIRV_Cross_Input +{ + float3 vClip3 : TEXCOORD0; + float4 vClip4 : TEXCOORD1; + float2 vClip2 : TEXCOORD2; +}; + +struct SPIRV_Cross_Output +{ + float FragColor : SV_Target0; +}; + +float SPIRV_Cross_projectTextureCoordinate(float2 coord) +{ + return coord.x / coord.y; +} + +float2 SPIRV_Cross_projectTextureCoordinate(float3 coord) +{ + return float2(coord.x, coord.y) / coord.z; +} + +float3 SPIRV_Cross_projectTextureCoordinate(float4 coord) +{ + return float3(coord.x, coord.y, coord.z) / coord.w; +} + +void frag_main() +{ + float4 _20 = vClip4; + _20.y = vClip4.w; + FragColor = uShadow1D.SampleCmp(_uShadow1D_sampler, SPIRV_Cross_projectTextureCoordinate(_20.xy), vClip4.z); + float4 _30 = vClip4; + _30.z = vClip4.w; + FragColor = uShadow2D.SampleCmp(_uShadow2D_sampler, SPIRV_Cross_projectTextureCoordinate(_30.xyz), vClip4.z); + FragColor = uSampler1D.Sample(_uSampler1D_sampler, SPIRV_Cross_projectTextureCoordinate(vClip2)).x; + FragColor = uSampler2D.Sample(_uSampler2D_sampler, SPIRV_Cross_projectTextureCoordinate(vClip3)).x; + FragColor = uSampler3D.Sample(_uSampler3D_sampler, SPIRV_Cross_projectTextureCoordinate(vClip4)).x; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + vClip4 = stage_input.vClip4; + vClip2 = stage_input.vClip2; + vClip3 = stage_input.vClip3; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/frag/texture-size-combined-image-sampler.frag b/reference/opt/shaders-hlsl/frag/texture-size-combined-image-sampler.frag new file mode 100644 index 0000000000..d5c373746d --- /dev/null +++ b/reference/opt/shaders-hlsl/frag/texture-size-combined-image-sampler.frag @@ -0,0 +1,30 @@ +Texture2D uTex : register(t0); +SamplerState uSampler : register(s1); + +static int2 FooOut; + +struct SPIRV_Cross_Output +{ + int2 FooOut : SV_Target0; +}; + +uint2 SPIRV_Cross_textureSize(Texture2D Tex, uint Level, out uint Param) +{ + uint2 ret; + Tex.GetDimensions(Level, ret.x, ret.y, Param); + return ret; +} + +void frag_main() +{ + uint _23_dummy_parameter; + FooOut = int2(SPIRV_Cross_textureSize(uTex, uint(0), _23_dummy_parameter)); +} + +SPIRV_Cross_Output main() +{ + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FooOut = FooOut; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/frag/unary-enclose.frag b/reference/opt/shaders-hlsl/frag/unary-enclose.frag new file mode 100644 index 0000000000..76e98a66d0 --- /dev/null +++ b/reference/opt/shaders-hlsl/frag/unary-enclose.frag @@ -0,0 +1,29 @@ +static float4 FragColor; +static float4 vIn; +static int4 vIn1; + +struct SPIRV_Cross_Input +{ + float4 vIn : TEXCOORD0; + nointerpolation int4 vIn1 : TEXCOORD1; +}; + +struct SPIRV_Cross_Output +{ + float4 FragColor : SV_Target0; +}; + +void frag_main() +{ + FragColor = -(-vIn); +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + vIn = stage_input.vIn; + vIn1 = stage_input.vIn1; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/frag/unorm-snorm-packing.frag b/reference/opt/shaders-hlsl/frag/unorm-snorm-packing.frag new file mode 100644 index 0000000000..57b5950636 --- /dev/null +++ b/reference/opt/shaders-hlsl/frag/unorm-snorm-packing.frag @@ -0,0 +1,109 @@ +static float4 FP32Out; +static uint UNORM8; +static uint SNORM8; +static uint UNORM16; +static uint SNORM16; +static uint UNORM8Out; +static float4 FP32; +static uint SNORM8Out; +static uint UNORM16Out; +static uint SNORM16Out; + +struct SPIRV_Cross_Input +{ + nointerpolation uint SNORM8 : TEXCOORD0; + nointerpolation uint UNORM8 : TEXCOORD1; + nointerpolation uint SNORM16 : TEXCOORD2; + nointerpolation uint UNORM16 : TEXCOORD3; + nointerpolation float4 FP32 : TEXCOORD4; +}; + +struct SPIRV_Cross_Output +{ + float4 FP32Out : SV_Target0; + uint UNORM8Out : SV_Target1; + uint SNORM8Out : SV_Target2; + uint UNORM16Out : SV_Target3; + uint SNORM16Out : SV_Target4; +}; + +uint SPIRV_Cross_packUnorm4x8(float4 value) +{ + uint4 Packed = uint4(round(saturate(value) * 255.0)); + return Packed.x | (Packed.y << 8) | (Packed.z << 16) | (Packed.w << 24); +} + +float4 SPIRV_Cross_unpackUnorm4x8(uint value) +{ + uint4 Packed = uint4(value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, value >> 24); + return float4(Packed) / 255.0; +} + +uint SPIRV_Cross_packSnorm4x8(float4 value) +{ + int4 Packed = int4(round(clamp(value, -1.0, 1.0) * 127.0)) & 0xff; + return uint(Packed.x | (Packed.y << 8) | (Packed.z << 16) | (Packed.w << 24)); +} + +float4 SPIRV_Cross_unpackSnorm4x8(uint value) +{ + int SignedValue = int(value); + int4 Packed = int4(SignedValue << 24, SignedValue << 16, SignedValue << 8, SignedValue) >> 24; + return clamp(float4(Packed) / 127.0, -1.0, 1.0); +} + +uint SPIRV_Cross_packUnorm2x16(float2 value) +{ + uint2 Packed = uint2(round(saturate(value) * 65535.0)); + return Packed.x | (Packed.y << 16); +} + +float2 SPIRV_Cross_unpackUnorm2x16(uint value) +{ + uint2 Packed = uint2(value & 0xffff, value >> 16); + return float2(Packed) / 65535.0; +} + +uint SPIRV_Cross_packSnorm2x16(float2 value) +{ + int2 Packed = int2(round(clamp(value, -1.0, 1.0) * 32767.0)) & 0xffff; + return uint(Packed.x | (Packed.y << 16)); +} + +float2 SPIRV_Cross_unpackSnorm2x16(uint value) +{ + int SignedValue = int(value); + int2 Packed = int2(SignedValue << 16, SignedValue) >> 16; + return clamp(float2(Packed) / 32767.0, -1.0, 1.0); +} + +void frag_main() +{ + FP32Out = SPIRV_Cross_unpackUnorm4x8(UNORM8); + FP32Out = SPIRV_Cross_unpackSnorm4x8(SNORM8); + float2 _21 = SPIRV_Cross_unpackUnorm2x16(UNORM16); + FP32Out = float4(_21.x, _21.y, FP32Out.z, FP32Out.w); + float2 _26 = SPIRV_Cross_unpackSnorm2x16(SNORM16); + FP32Out = float4(_26.x, _26.y, FP32Out.z, FP32Out.w); + UNORM8Out = SPIRV_Cross_packUnorm4x8(FP32); + SNORM8Out = SPIRV_Cross_packSnorm4x8(FP32); + UNORM16Out = SPIRV_Cross_packUnorm2x16(FP32.xy); + SNORM16Out = SPIRV_Cross_packSnorm2x16(FP32.zw); +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + UNORM8 = stage_input.UNORM8; + SNORM8 = stage_input.SNORM8; + UNORM16 = stage_input.UNORM16; + SNORM16 = stage_input.SNORM16; + FP32 = stage_input.FP32; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FP32Out = FP32Out; + stage_output.UNORM8Out = UNORM8Out; + stage_output.SNORM8Out = SNORM8Out; + stage_output.UNORM16Out = UNORM16Out; + stage_output.SNORM16Out = SNORM16Out; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/frag/various-glsl-ops.frag b/reference/opt/shaders-hlsl/frag/various-glsl-ops.frag new file mode 100644 index 0000000000..0bc2fc1a96 --- /dev/null +++ b/reference/opt/shaders-hlsl/frag/various-glsl-ops.frag @@ -0,0 +1,26 @@ +static float2 interpolant; +static float4 FragColor; + +struct SPIRV_Cross_Input +{ + float2 interpolant : TEXCOORD0; +}; + +struct SPIRV_Cross_Output +{ + float4 FragColor : SV_Target0; +}; + +void frag_main() +{ + FragColor = float4(0.0f, 0.0f, 0.0f, EvaluateAttributeSnapped(interpolant, 0.100000001490116119384765625f.xx).x) + float4(0.0f, 0.0f, 0.0f, ddx_coarse(interpolant.x)); +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + interpolant = stage_input.interpolant; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/vert/basic.vert b/reference/opt/shaders-hlsl/vert/basic.vert new file mode 100644 index 0000000000..5f0a5f3d1a --- /dev/null +++ b/reference/opt/shaders-hlsl/vert/basic.vert @@ -0,0 +1,38 @@ +cbuffer _16 +{ + row_major float4x4 _16_uMVP : packoffset(c0); +}; + +static float4 gl_Position; +static float4 aVertex; +static float3 vNormal; +static float3 aNormal; + +struct SPIRV_Cross_Input +{ + float4 aVertex : TEXCOORD0; + float3 aNormal : TEXCOORD1; +}; + +struct SPIRV_Cross_Output +{ + float3 vNormal : TEXCOORD0; + float4 gl_Position : SV_Position; +}; + +void vert_main() +{ + gl_Position = mul(aVertex, _16_uMVP); + vNormal = aNormal; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + aVertex = stage_input.aVertex; + aNormal = stage_input.aNormal; + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + stage_output.vNormal = vNormal; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/vert/instancing.vert b/reference/opt/shaders-hlsl/vert/instancing.vert new file mode 100644 index 0000000000..48b2df20d3 --- /dev/null +++ b/reference/opt/shaders-hlsl/vert/instancing.vert @@ -0,0 +1,28 @@ +static float4 gl_Position; +static int gl_VertexIndex; +static int gl_InstanceIndex; +struct SPIRV_Cross_Input +{ + uint gl_VertexIndex : SV_VertexID; + uint gl_InstanceIndex : SV_InstanceID; +}; + +struct SPIRV_Cross_Output +{ + float4 gl_Position : SV_Position; +}; + +void vert_main() +{ + gl_Position = float(gl_VertexIndex + gl_InstanceIndex).xxxx; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + gl_VertexIndex = int(stage_input.gl_VertexIndex); + gl_InstanceIndex = int(stage_input.gl_InstanceIndex); + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/vert/locations.vert b/reference/opt/shaders-hlsl/vert/locations.vert new file mode 100644 index 0000000000..ba36c4ae39 --- /dev/null +++ b/reference/opt/shaders-hlsl/vert/locations.vert @@ -0,0 +1,79 @@ +struct Foo +{ + float3 a; + float3 b; + float3 c; +}; + +static float4 gl_Position; +static float4 Input2; +static float4 Input4; +static float4 Input0; +static float vLocation0; +static float vLocation1; +static float vLocation2[2]; +static Foo vLocation4; +static float vLocation9; + +struct VertexOut +{ + float3 color : TEXCOORD7; + float3 foo : TEXCOORD8; +}; + +static VertexOut vout; + +struct SPIRV_Cross_Input +{ + float4 Input0 : TEXCOORD0; + float4 Input2 : TEXCOORD2; + float4 Input4 : TEXCOORD4; +}; + +struct SPIRV_Cross_Output +{ + float vLocation0 : TEXCOORD0; + float vLocation1 : TEXCOORD1; + float vLocation2[2] : TEXCOORD2; + Foo vLocation4 : TEXCOORD4; + float vLocation9 : TEXCOORD9; + float4 gl_Position : SV_Position; +}; + +Foo _70; + +void vert_main() +{ + gl_Position = ((1.0f.xxxx + Input2) + Input4) + Input0; + vLocation0 = 0.0f; + vLocation1 = 1.0f; + vLocation2[0] = 2.0f; + vLocation2[1] = 2.0f; + Foo _65 = _70; + _65.a = 1.0f.xxx; + Foo _67 = _65; + _67.b = 1.0f.xxx; + Foo _69 = _67; + _69.c = 1.0f.xxx; + vLocation4 = _69; + vLocation9 = 9.0f; + vout.color = 2.0f.xxx; + vout.foo = 4.0f.xxx; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input, out VertexOut stage_outputvout) +{ + Input2 = stage_input.Input2; + Input4 = stage_input.Input4; + Input0 = stage_input.Input0; + vert_main(); + stage_outputvout = vout; + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + stage_output.vLocation0 = vLocation0; + stage_output.vLocation1 = vLocation1; + stage_output.vLocation2 = vLocation2; + stage_output.vLocation4 = vLocation4; + stage_output.vLocation9 = vLocation9; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/vert/matrix-attribute.vert b/reference/opt/shaders-hlsl/vert/matrix-attribute.vert new file mode 100644 index 0000000000..a3d0eef56e --- /dev/null +++ b/reference/opt/shaders-hlsl/vert/matrix-attribute.vert @@ -0,0 +1,35 @@ +static float4 gl_Position; +static float4x4 m; +static float3 pos; + +struct SPIRV_Cross_Input +{ + float3 pos : TEXCOORD0; + float4 m_0 : TEXCOORD1_0; + float4 m_1 : TEXCOORD1_1; + float4 m_2 : TEXCOORD1_2; + float4 m_3 : TEXCOORD1_3; +}; + +struct SPIRV_Cross_Output +{ + float4 gl_Position : SV_Position; +}; + +void vert_main() +{ + gl_Position = mul(float4(pos, 1.0f), m); +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + m[0] = stage_input.m_0; + m[1] = stage_input.m_1; + m[2] = stage_input.m_2; + m[3] = stage_input.m_3; + pos = stage_input.pos; + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/vert/matrix-output.vert b/reference/opt/shaders-hlsl/vert/matrix-output.vert new file mode 100644 index 0000000000..dc776cb5ec --- /dev/null +++ b/reference/opt/shaders-hlsl/vert/matrix-output.vert @@ -0,0 +1,23 @@ +static float4 gl_Position; +static float4x4 m; + +struct SPIRV_Cross_Output +{ + float4x4 m : TEXCOORD0; + float4 gl_Position : SV_Position; +}; + +void vert_main() +{ + gl_Position = 1.0f.xxxx; + m = float4x4(float4(1.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 1.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 1.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 1.0f)); +} + +SPIRV_Cross_Output main() +{ + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + stage_output.m = m; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/vert/no-input.vert b/reference/opt/shaders-hlsl/vert/no-input.vert new file mode 100644 index 0000000000..c98544dbe8 --- /dev/null +++ b/reference/opt/shaders-hlsl/vert/no-input.vert @@ -0,0 +1,18 @@ +static float4 gl_Position; +struct SPIRV_Cross_Output +{ + float4 gl_Position : SV_Position; +}; + +void vert_main() +{ + gl_Position = 1.0f.xxxx; +} + +SPIRV_Cross_Output main() +{ + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/vert/point-size-compat.vert b/reference/opt/shaders-hlsl/vert/point-size-compat.vert new file mode 100644 index 0000000000..83333d0be2 --- /dev/null +++ b/reference/opt/shaders-hlsl/vert/point-size-compat.vert @@ -0,0 +1,20 @@ +static float4 gl_Position; +static float gl_PointSize; +struct SPIRV_Cross_Output +{ + float4 gl_Position : SV_Position; +}; + +void vert_main() +{ + gl_Position = 1.0f.xxxx; + gl_PointSize = 10.0f; +} + +SPIRV_Cross_Output main() +{ + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/vert/qualifiers.vert b/reference/opt/shaders-hlsl/vert/qualifiers.vert new file mode 100644 index 0000000000..13ee2a8c1c --- /dev/null +++ b/reference/opt/shaders-hlsl/vert/qualifiers.vert @@ -0,0 +1,50 @@ +static float4 gl_Position; +static float vFlat; +static float vCentroid; +static float vSample; +static float vNoperspective; + +struct Block +{ + nointerpolation float vFlat : TEXCOORD4; + centroid float vCentroid : TEXCOORD5; + sample float vSample : TEXCOORD6; + noperspective float vNoperspective : TEXCOORD7; +}; + +static Block vout; + +struct SPIRV_Cross_Output +{ + nointerpolation float vFlat : TEXCOORD0; + centroid float vCentroid : TEXCOORD1; + sample float vSample : TEXCOORD2; + noperspective float vNoperspective : TEXCOORD3; + float4 gl_Position : SV_Position; +}; + +void vert_main() +{ + gl_Position = 1.0f.xxxx; + vFlat = 0.0f; + vCentroid = 1.0f; + vSample = 2.0f; + vNoperspective = 3.0f; + vout.vFlat = 0.0f; + vout.vCentroid = 1.0f; + vout.vSample = 2.0f; + vout.vNoperspective = 3.0f; +} + +SPIRV_Cross_Output main(out Block stage_outputvout) +{ + vert_main(); + stage_outputvout = vout; + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + stage_output.vFlat = vFlat; + stage_output.vCentroid = vCentroid; + stage_output.vSample = vSample; + stage_output.vNoperspective = vNoperspective; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/vert/sampler-buffers.vert b/reference/opt/shaders-hlsl/vert/sampler-buffers.vert new file mode 100644 index 0000000000..3652185443 --- /dev/null +++ b/reference/opt/shaders-hlsl/vert/sampler-buffers.vert @@ -0,0 +1,22 @@ +Buffer uFloatSampler : register(t1); +Buffer uIntSampler : register(t2); +Buffer uUintSampler : register(t3); + +static float4 gl_Position; +struct SPIRV_Cross_Output +{ + float4 gl_Position : SV_Position; +}; + +void vert_main() +{ + gl_Position = (uFloatSampler.Load(20) + asfloat(uIntSampler.Load(40))) + asfloat(uUintSampler.Load(60)); +} + +SPIRV_Cross_Output main() +{ + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/vert/struct-composite-decl.vert b/reference/opt/shaders-hlsl/vert/struct-composite-decl.vert new file mode 100644 index 0000000000..76bd349775 --- /dev/null +++ b/reference/opt/shaders-hlsl/vert/struct-composite-decl.vert @@ -0,0 +1,44 @@ +struct VOut +{ + float4 a; + float4 b; + float4 c; + float4 d; +}; + +static VOut vout; +static float4 a; +static float4 b; +static float4 c; +static float4 d; + +struct SPIRV_Cross_Input +{ + float4 a : TEXCOORD0; + float4 b : TEXCOORD1; + float4 c : TEXCOORD2; + float4 d : TEXCOORD3; +}; + +struct SPIRV_Cross_Output +{ + VOut vout : TEXCOORD0; +}; + +void vert_main() +{ + VOut _26 = { a, b, c, d }; + vout = _26; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + a = stage_input.a; + b = stage_input.b; + c = stage_input.c; + d = stage_input.d; + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.vout = vout; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/vert/texture_buffer.vert b/reference/opt/shaders-hlsl/vert/texture_buffer.vert new file mode 100644 index 0000000000..1c92f6fe65 --- /dev/null +++ b/reference/opt/shaders-hlsl/vert/texture_buffer.vert @@ -0,0 +1,21 @@ +Buffer uSamp : register(t4); +RWBuffer uSampo : register(u5); + +static float4 gl_Position; +struct SPIRV_Cross_Output +{ + float4 gl_Position : SV_Position; +}; + +void vert_main() +{ + gl_Position = uSamp.Load(10) + uSampo[100]; +} + +SPIRV_Cross_Output main() +{ + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + return stage_output; +} diff --git a/reference/opt/shaders-msl/asm/comp/bitcast_iadd.asm.comp b/reference/opt/shaders-msl/asm/comp/bitcast_iadd.asm.comp new file mode 100644 index 0000000000..47ce85f8fc --- /dev/null +++ b/reference/opt/shaders-msl/asm/comp/bitcast_iadd.asm.comp @@ -0,0 +1,29 @@ +#include +#include + +using namespace metal; + +struct _3 +{ + int4 _m0; + uint4 _m1; +}; + +struct _4 +{ + uint4 _m0; + int4 _m1; +}; + +kernel void main0(device _3& _5 [[buffer(0)]], device _4& _6 [[buffer(1)]]) +{ + _6._m0 = _5._m1 + uint4(_5._m0); + _6._m0 = uint4(_5._m0) + _5._m1; + _6._m0 = _5._m1 + _5._m1; + _6._m0 = uint4(_5._m0 + _5._m0); + _6._m1 = int4(_5._m1 + _5._m1); + _6._m1 = _5._m0 + _5._m0; + _6._m1 = int4(_5._m1) + _5._m0; + _6._m1 = _5._m0 + int4(_5._m1); +} + diff --git a/reference/opt/shaders-msl/asm/comp/bitcast_sar.asm.comp b/reference/opt/shaders-msl/asm/comp/bitcast_sar.asm.comp new file mode 100644 index 0000000000..20d6fe9e9d --- /dev/null +++ b/reference/opt/shaders-msl/asm/comp/bitcast_sar.asm.comp @@ -0,0 +1,29 @@ +#include +#include + +using namespace metal; + +struct _3 +{ + int4 _m0; + uint4 _m1; +}; + +struct _4 +{ + uint4 _m0; + int4 _m1; +}; + +kernel void main0(device _3& _5 [[buffer(0)]], device _4& _6 [[buffer(1)]]) +{ + _6._m0 = uint4(int4(_5._m1) >> _5._m0); + _6._m0 = uint4(_5._m0 >> int4(_5._m1)); + _6._m0 = uint4(int4(_5._m1) >> int4(_5._m1)); + _6._m0 = uint4(_5._m0 >> _5._m0); + _6._m1 = int4(_5._m1) >> int4(_5._m1); + _6._m1 = _5._m0 >> _5._m0; + _6._m1 = int4(_5._m1) >> _5._m0; + _6._m1 = _5._m0 >> int4(_5._m1); +} + diff --git a/reference/opt/shaders-msl/asm/comp/bitcast_sdiv.asm.comp b/reference/opt/shaders-msl/asm/comp/bitcast_sdiv.asm.comp new file mode 100644 index 0000000000..f18b318bbb --- /dev/null +++ b/reference/opt/shaders-msl/asm/comp/bitcast_sdiv.asm.comp @@ -0,0 +1,29 @@ +#include +#include + +using namespace metal; + +struct _3 +{ + int4 _m0; + uint4 _m1; +}; + +struct _4 +{ + uint4 _m0; + int4 _m1; +}; + +kernel void main0(device _3& _5 [[buffer(0)]], device _4& _6 [[buffer(1)]]) +{ + _6._m0 = uint4(int4(_5._m1) / _5._m0); + _6._m0 = uint4(_5._m0 / int4(_5._m1)); + _6._m0 = uint4(int4(_5._m1) / int4(_5._m1)); + _6._m0 = uint4(_5._m0 / _5._m0); + _6._m1 = int4(_5._m1) / int4(_5._m1); + _6._m1 = _5._m0 / _5._m0; + _6._m1 = int4(_5._m1) / _5._m0; + _6._m1 = _5._m0 / int4(_5._m1); +} + diff --git a/reference/opt/shaders-msl/asm/comp/bitcast_slr.asm.comp b/reference/opt/shaders-msl/asm/comp/bitcast_slr.asm.comp new file mode 100644 index 0000000000..9fd60bef26 --- /dev/null +++ b/reference/opt/shaders-msl/asm/comp/bitcast_slr.asm.comp @@ -0,0 +1,29 @@ +#include +#include + +using namespace metal; + +struct _3 +{ + int4 _m0; + uint4 _m1; +}; + +struct _4 +{ + uint4 _m0; + int4 _m1; +}; + +kernel void main0(device _3& _5 [[buffer(0)]], device _4& _6 [[buffer(1)]]) +{ + _6._m0 = _5._m1 >> uint4(_5._m0); + _6._m0 = uint4(_5._m0) >> _5._m1; + _6._m0 = _5._m1 >> _5._m1; + _6._m0 = uint4(_5._m0) >> uint4(_5._m0); + _6._m1 = int4(_5._m1 >> _5._m1); + _6._m1 = int4(uint4(_5._m0) >> uint4(_5._m0)); + _6._m1 = int4(_5._m1 >> uint4(_5._m0)); + _6._m1 = int4(uint4(_5._m0) >> _5._m1); +} + diff --git a/reference/opt/shaders-msl/asm/comp/multiple-entry.asm.comp b/reference/opt/shaders-msl/asm/comp/multiple-entry.asm.comp new file mode 100644 index 0000000000..7652733268 --- /dev/null +++ b/reference/opt/shaders-msl/asm/comp/multiple-entry.asm.comp @@ -0,0 +1,29 @@ +#include +#include + +using namespace metal; + +struct _6 +{ + int4 _m0; + uint4 _m1; +}; + +struct _7 +{ + uint4 _m0; + int4 _m1; +}; + +kernel void main0(device _6& _8 [[buffer(0)]], device _7& _9 [[buffer(1)]]) +{ + _9._m0 = _8._m1 + uint4(_8._m0); + _9._m0 = uint4(_8._m0) + _8._m1; + _9._m0 = _8._m1 + _8._m1; + _9._m0 = uint4(_8._m0 + _8._m0); + _9._m1 = int4(_8._m1 + _8._m1); + _9._m1 = _8._m0 + _8._m0; + _9._m1 = int4(_8._m1) + _8._m0; + _9._m1 = _8._m0 + int4(_8._m1); +} + diff --git a/reference/opt/shaders-msl/asm/comp/quantize.asm.comp b/reference/opt/shaders-msl/asm/comp/quantize.asm.comp new file mode 100644 index 0000000000..1839ec7a3b --- /dev/null +++ b/reference/opt/shaders-msl/asm/comp/quantize.asm.comp @@ -0,0 +1,21 @@ +#include +#include + +using namespace metal; + +struct SSBO0 +{ + float scalar; + float2 vec2_val; + float3 vec3_val; + float4 vec4_val; +}; + +kernel void main0(device SSBO0& _4 [[buffer(0)]]) +{ + _4.scalar = float(half(_4.scalar)); + _4.vec2_val = float2(half2(_4.vec2_val)); + _4.vec3_val = float3(half3(_4.vec3_val)); + _4.vec4_val = float4(half4(_4.vec4_val)); +} + diff --git a/reference/opt/shaders-msl/asm/comp/specialization-constant-workgroup.asm.comp b/reference/opt/shaders-msl/asm/comp/specialization-constant-workgroup.asm.comp new file mode 100644 index 0000000000..5802ddac90 --- /dev/null +++ b/reference/opt/shaders-msl/asm/comp/specialization-constant-workgroup.asm.comp @@ -0,0 +1,21 @@ +#include +#include + +using namespace metal; + +constant uint _5_tmp [[function_constant(10)]]; +constant uint _5 = is_function_constant_defined(_5_tmp) ? _5_tmp : 9u; +constant uint _6_tmp [[function_constant(12)]]; +constant uint _6 = is_function_constant_defined(_6_tmp) ? _6_tmp : 4u; +constant uint3 gl_WorkGroupSize = uint3(_5, 20u, _6); + +struct SSBO +{ + float a; +}; + +kernel void main0(device SSBO& _4 [[buffer(0)]]) +{ + _4.a += 1.0; +} + diff --git a/reference/opt/shaders-msl/asm/comp/storage-buffer-basic.asm.comp b/reference/opt/shaders-msl/asm/comp/storage-buffer-basic.asm.comp new file mode 100644 index 0000000000..3df6161fc2 --- /dev/null +++ b/reference/opt/shaders-msl/asm/comp/storage-buffer-basic.asm.comp @@ -0,0 +1,21 @@ +#include +#include + +using namespace metal; + +constant uint _3_tmp [[function_constant(0)]]; +constant uint _3 = is_function_constant_defined(_3_tmp) ? _3_tmp : 1u; +constant uint _4_tmp [[function_constant(2)]]; +constant uint _4 = is_function_constant_defined(_4_tmp) ? _4_tmp : 3u; +constant uint3 gl_WorkGroupSize = uint3(_3, 2u, _4); + +struct _6 +{ + float _m0[1]; +}; + +kernel void main0(device _6& _8 [[buffer(0)]], device _6& _9 [[buffer(1)]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]]) +{ + _8._m0[gl_WorkGroupID.x] = _9._m0[gl_WorkGroupID.x] + _8._m0[gl_WorkGroupID.x]; +} + diff --git a/reference/opt/shaders-msl/asm/frag/default-member-names.asm.frag b/reference/opt/shaders-msl/asm/frag/default-member-names.asm.frag new file mode 100644 index 0000000000..1c730c7bbc --- /dev/null +++ b/reference/opt/shaders-msl/asm/frag/default-member-names.asm.frag @@ -0,0 +1,41 @@ +#include +#include + +using namespace metal; + +struct _9 +{ + float _m0; +}; + +struct _10 +{ + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + _9 _m12; +}; + +constant _10 _51 = {}; + +struct main0_out +{ + float4 m_3 [[color(0)]]; +}; + +fragment main0_out main0() +{ + main0_out out = {}; + out.m_3 = float4(_51._m0, _51._m1, _51._m2, _51._m3); + return out; +} + diff --git a/reference/opt/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag b/reference/opt/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag new file mode 100644 index 0000000000..2ac8cbe015 --- /dev/null +++ b/reference/opt/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag @@ -0,0 +1,235 @@ +#include +#include + +using namespace metal; + +struct VertexOutput +{ + float4 HPosition; + float4 Uv_EdgeDistance1; + float4 UvStuds_EdgeDistance2; + float4 Color; + float4 LightPosition_Fog; + float4 View_Depth; + float4 Normal_SpecPower; + float3 Tangent; + float4 PosLightSpace_Reflectance; + float studIndex; +}; + +struct Surface +{ + float3 albedo; + float3 normal; + float specular; + float gloss; + float reflectance; + float opacity; +}; + +struct SurfaceInput +{ + float4 Color; + float2 Uv; + float2 UvStuds; +}; + +struct Globals +{ + float4x4 ViewProjection; + float4 ViewRight; + float4 ViewUp; + float4 ViewDir; + float3 CameraPosition; + float3 AmbientColor; + float3 Lamp0Color; + float3 Lamp0Dir; + float3 Lamp1Color; + float4 FogParams; + float3 FogColor; + float4 LightBorder; + float4 LightConfig0; + float4 LightConfig1; + float4 LightConfig2; + float4 LightConfig3; + float4 RefractionBias_FadeDistance_GlowFactor; + float4 OutlineBrightness_ShadowInfo; + float4 ShadowMatrix0; + float4 ShadowMatrix1; + float4 ShadowMatrix2; +}; + +struct Params +{ + float4 LqmatFarTilingFactor; +}; + +struct CB0 +{ + Globals CB0; +}; + +struct CB2 +{ + Params CB2; +}; + +constant VertexOutput _121 = {}; +constant SurfaceInput _122 = {}; +constant float2 _123 = {}; +constant float4 _124 = {}; +constant Surface _125 = {}; +constant float4 _192 = {}; +constant float4 _219 = {}; +constant float4 _297 = {}; + +struct main0_in +{ + float IN_studIndex [[user(locn8)]]; + float4 IN_PosLightSpace_Reflectance [[user(locn7)]]; + float3 IN_Tangent [[user(locn6)]]; + float4 IN_Normal_SpecPower [[user(locn5)]]; + float4 IN_View_Depth [[user(locn4)]]; + float4 IN_LightPosition_Fog [[user(locn3)]]; + float4 IN_Color [[user(locn2)]]; + float4 IN_UvStuds_EdgeDistance2 [[user(locn1)]]; + float4 IN_Uv_EdgeDistance1 [[user(locn0)]]; +}; + +struct main0_out +{ + float4 _entryPointOutput [[color(0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], constant CB0& _19 [[buffer(0)]], texture3d LightMapTexture [[texture(0)]], texture2d ShadowMapTexture [[texture(1)]], texturecube EnvironmentMapTexture [[texture(2)]], texture2d DiffuseMapTexture [[texture(3)]], texture2d NormalMapTexture [[texture(4)]], texture2d NormalDetailMapTexture [[texture(5)]], texture2d StudsMapTexture [[texture(6)]], texture2d SpecularMapTexture [[texture(7)]], sampler LightMapSampler [[sampler(0)]], sampler ShadowMapSampler [[sampler(1)]], sampler EnvironmentMapSampler [[sampler(2)]], sampler DiffuseMapSampler [[sampler(3)]], sampler NormalMapSampler [[sampler(4)]], sampler NormalDetailMapSampler [[sampler(5)]], sampler StudsMapSampler [[sampler(6)]], sampler SpecularMapSampler [[sampler(7)]], float4 gl_FragCoord [[position]]) +{ + main0_out out = {}; + VertexOutput _128 = _121; + _128.HPosition = gl_FragCoord; + VertexOutput _130 = _128; + _130.Uv_EdgeDistance1 = in.IN_Uv_EdgeDistance1; + VertexOutput _132 = _130; + _132.UvStuds_EdgeDistance2 = in.IN_UvStuds_EdgeDistance2; + VertexOutput _134 = _132; + _134.Color = in.IN_Color; + VertexOutput _136 = _134; + _136.LightPosition_Fog = in.IN_LightPosition_Fog; + VertexOutput _138 = _136; + _138.View_Depth = in.IN_View_Depth; + VertexOutput _140 = _138; + _140.Normal_SpecPower = in.IN_Normal_SpecPower; + VertexOutput _142 = _140; + _142.Tangent = in.IN_Tangent; + VertexOutput _144 = _142; + _144.PosLightSpace_Reflectance = in.IN_PosLightSpace_Reflectance; + VertexOutput _146 = _144; + _146.studIndex = in.IN_studIndex; + SurfaceInput _147 = _122; + _147.Color = in.IN_Color; + SurfaceInput _149 = _147; + _149.Uv = in.IN_Uv_EdgeDistance1.xy; + SurfaceInput _151 = _149; + _151.UvStuds = in.IN_UvStuds_EdgeDistance2.xy; + SurfaceInput _156 = _151; + _156.UvStuds.y = (fract(_151.UvStuds.y) + in.IN_studIndex) * 0.25; + float _163 = _146.View_Depth.w * _19.CB0.RefractionBias_FadeDistance_GlowFactor.y; + float _165 = clamp(1.0 - _163, 0.0, 1.0); + float2 _166 = in.IN_Uv_EdgeDistance1.xy * 1.0; + bool _173; + float4 _193; + do + { + _173 = 0.0 == 0.0; + if (_173) + { + _193 = DiffuseMapTexture.sample(DiffuseMapSampler, _166); + break; + } + else + { + float _180 = 1.0 / (1.0 - 0.0); + _193 = mix(DiffuseMapTexture.sample(DiffuseMapSampler, (_166 * 0.25)), DiffuseMapTexture.sample(DiffuseMapSampler, _166), float4(clamp((clamp(1.0 - (_146.View_Depth.w * 0.00333332992158830165863037109375), 0.0, 1.0) * _180) - (0.0 * _180), 0.0, 1.0))); + break; + } + _193 = _192; + break; + } while (false); + float4 _220; + do + { + if (_173) + { + _220 = NormalMapTexture.sample(NormalMapSampler, _166); + break; + } + else + { + float _207 = 1.0 / (1.0 - 0.0); + _220 = mix(NormalMapTexture.sample(NormalMapSampler, (_166 * 0.25)), NormalMapTexture.sample(NormalMapSampler, _166), float4(clamp((_165 * _207) - (0.0 * _207), 0.0, 1.0))); + break; + } + _220 = _219; + break; + } while (false); + float2 _223 = float2(1.0); + float2 _224 = (_220.wy * 2.0) - _223; + float3 _232 = float3(_224, sqrt(clamp(1.0 + dot(-_224, _224), 0.0, 1.0))); + float2 _240 = (NormalDetailMapTexture.sample(NormalDetailMapSampler, (_166 * 0.0)).wy * 2.0) - _223; + float2 _252 = _232.xy + (float3(_240, sqrt(clamp(1.0 + dot(-_240, _240), 0.0, 1.0))).xy * 0.0); + float3 _253 = float3(_252.x, _252.y, _232.z); + float2 _255 = _253.xy * _165; + float3 _256 = float3(_255.x, _255.y, _253.z); + float3 _271 = ((in.IN_Color.xyz * (_193 * 1.0).xyz) * (1.0 + (_256.x * 0.300000011920928955078125))) * (StudsMapTexture.sample(StudsMapSampler, _156.UvStuds).x * 2.0); + float4 _298; + do + { + if (0.75 == 0.0) + { + _298 = SpecularMapTexture.sample(SpecularMapSampler, _166); + break; + } + else + { + float _285 = 1.0 / (1.0 - 0.75); + _298 = mix(SpecularMapTexture.sample(SpecularMapSampler, (_166 * 0.25)), SpecularMapTexture.sample(SpecularMapSampler, _166), float4(clamp((_165 * _285) - (0.75 * _285), 0.0, 1.0))); + break; + } + _298 = _297; + break; + } while (false); + float2 _303 = mix(float2(0.800000011920928955078125, 120.0), (_298.xy * float2(2.0, 256.0)) + float2(0.0, 0.00999999977648258209228515625), float2(_165)); + Surface _304 = _125; + _304.albedo = _271; + Surface _305 = _304; + _305.normal = _256; + float _306 = _303.x; + Surface _307 = _305; + _307.specular = _306; + float _308 = _303.y; + Surface _309 = _307; + _309.gloss = _308; + float _312 = (_298.xy.y * _165) * 0.0; + Surface _313 = _309; + _313.reflectance = _312; + float4 _318 = float4(_271, _146.Color.w); + float3 _329 = normalize(((in.IN_Tangent * _313.normal.x) + (cross(in.IN_Normal_SpecPower.xyz, in.IN_Tangent) * _313.normal.y)) + (in.IN_Normal_SpecPower.xyz * _313.normal.z)); + float3 _332 = -_19.CB0.Lamp0Dir; + float _333 = dot(_329, _332); + float _357 = clamp(dot(step(_19.CB0.LightConfig3.xyz, abs(in.IN_LightPosition_Fog.xyz - _19.CB0.LightConfig2.xyz)), float3(1.0)), 0.0, 1.0); + float4 _368 = mix(LightMapTexture.sample(LightMapSampler, (in.IN_LightPosition_Fog.xyz.yzx - (in.IN_LightPosition_Fog.xyz.yzx * _357))), _19.CB0.LightBorder, float4(_357)); + float2 _376 = ShadowMapTexture.sample(ShadowMapSampler, in.IN_PosLightSpace_Reflectance.xyz.xy).xy; + float _392 = (1.0 - (((step(_376.x, in.IN_PosLightSpace_Reflectance.xyz.z) * clamp(9.0 - (20.0 * abs(in.IN_PosLightSpace_Reflectance.xyz.z - 0.5)), 0.0, 1.0)) * _376.y) * _19.CB0.OutlineBrightness_ShadowInfo.w)) * _368.w; + float3 _403 = mix(_318.xyz, EnvironmentMapTexture.sample(EnvironmentMapSampler, reflect(-in.IN_View_Depth.xyz, _329)).xyz, float3(_312)); + float4 _404 = float4(_403.x, _403.y, _403.z, _318.w); + float3 _422 = (((_19.CB0.AmbientColor + (((_19.CB0.Lamp0Color * clamp(_333, 0.0, 1.0)) + (_19.CB0.Lamp1Color * max(-_333, 0.0))) * _392)) + _368.xyz) * _404.xyz) + (_19.CB0.Lamp0Color * (((step(0.0, _333) * _306) * _392) * pow(clamp(dot(_329, normalize(_332 + normalize(in.IN_View_Depth.xyz))), 0.0, 1.0), _308))); + float4 _425 = float4(_422.x, _422.y, _422.z, _124.w); + _425.w = _404.w; + float2 _435 = min(in.IN_Uv_EdgeDistance1.wz, in.IN_UvStuds_EdgeDistance2.wz); + float _439 = min(_435.x, _435.y) / _163; + float3 _445 = _425.xyz * clamp((clamp((_163 * _19.CB0.OutlineBrightness_ShadowInfo.x) + _19.CB0.OutlineBrightness_ShadowInfo.y, 0.0, 1.0) * (1.5 - _439)) + _439, 0.0, 1.0); + float4 _446 = float4(_445.x, _445.y, _445.z, _425.w); + float3 _453 = mix(_19.CB0.FogColor, _446.xyz, float3(clamp(_146.LightPosition_Fog.w, 0.0, 1.0))); + out._entryPointOutput = float4(_453.x, _453.y, _453.z, _446.w); + return out; +} + diff --git a/reference/opt/shaders-msl/asm/frag/op-constant-null.asm.frag b/reference/opt/shaders-msl/asm/frag/op-constant-null.asm.frag new file mode 100644 index 0000000000..9472add395 --- /dev/null +++ b/reference/opt/shaders-msl/asm/frag/op-constant-null.asm.frag @@ -0,0 +1,23 @@ +#include +#include + +using namespace metal; + +struct D +{ + float4 a; + float b; +}; + +struct main0_out +{ + float FragColor [[color(0)]]; +}; + +fragment main0_out main0() +{ + main0_out out = {}; + out.FragColor = 0.0; + return out; +} + diff --git a/reference/opt/shaders-msl/asm/frag/phi-loop-variable.asm.frag b/reference/opt/shaders-msl/asm/frag/phi-loop-variable.asm.frag new file mode 100644 index 0000000000..036774d661 --- /dev/null +++ b/reference/opt/shaders-msl/asm/frag/phi-loop-variable.asm.frag @@ -0,0 +1,12 @@ +#include +#include + +using namespace metal; + +fragment void main0() +{ + for (int _22 = 35; _22 >= 0; _22--) + { + } +} + diff --git a/reference/opt/shaders-msl/asm/frag/undef-variable-store.asm.frag b/reference/opt/shaders-msl/asm/frag/undef-variable-store.asm.frag new file mode 100644 index 0000000000..fb39c46fbb --- /dev/null +++ b/reference/opt/shaders-msl/asm/frag/undef-variable-store.asm.frag @@ -0,0 +1,38 @@ +#include +#include + +using namespace metal; + +constant float4 _38 = {}; +constant float4 _50 = {}; + +struct main0_out +{ + float4 _entryPointOutput [[color(0)]]; +}; + +fragment main0_out main0() +{ + main0_out out = {}; + float4 _51; + _51 = _50; + float4 _52; + for (;;) + { + if (0.0 != 0.0) + { + _52 = float4(1.0, 0.0, 0.0, 1.0); + break; + } + else + { + _52 = float4(1.0, 1.0, 0.0, 1.0); + break; + } + _52 = _38; + break; + } + out._entryPointOutput = _52; + return out; +} + diff --git a/reference/opt/shaders-msl/asm/frag/unreachable.asm.frag b/reference/opt/shaders-msl/asm/frag/unreachable.asm.frag new file mode 100644 index 0000000000..3e80051e6b --- /dev/null +++ b/reference/opt/shaders-msl/asm/frag/unreachable.asm.frag @@ -0,0 +1,38 @@ +#include +#include + +using namespace metal; + +constant float4 _21 = {}; + +struct main0_in +{ + int counter [[user(locn0)]]; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + float4 _33; + do + { + if (in.counter == 10) + { + _33 = float4(10.0); + break; + } + else + { + _33 = float4(30.0); + break; + } + } while (false); + out.FragColor = _33; + return out; +} + diff --git a/reference/opt/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag b/reference/opt/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag new file mode 100644 index 0000000000..97daea5d90 --- /dev/null +++ b/reference/opt/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag @@ -0,0 +1,321 @@ +#include +#include + +using namespace metal; + +struct _28 +{ + float4 _m0; +}; + +struct _6 +{ + float4 _m0; + float _m1; + float4 _m2; +}; + +struct _10 +{ + float3 _m0; + packed_float3 _m1; + float _m2; + packed_float3 _m3; + float _m4; + packed_float3 _m5; + float _m6; + packed_float3 _m7; + float _m8; + packed_float3 _m9; + float _m10; + packed_float3 _m11; + float _m12; + float2 _m13; + float2 _m14; + packed_float3 _m15; + float _m16; + float _m17; + float _m18; + float _m19; + float _m20; + float4 _m21; + float4 _m22; + float4x4 _m23; + float4 _m24; +}; + +struct _18 +{ + float4x4 _m0; + float4x4 _m1; + float4x4 _m2; + float4x4 _m3; + float4 _m4; + float4 _m5; + float _m6; + float _m7; + float _m8; + float _m9; + packed_float3 _m10; + float _m11; + packed_float3 _m12; + float _m13; + packed_float3 _m14; + float _m15; + packed_float3 _m16; + float _m17; + float _m18; + float _m19; + float2 _m20; + float2 _m21; + float2 _m22; + float4 _m23; + float2 _m24; + float2 _m25; + float2 _m26; + char pad27[8]; + packed_float3 _m27; + float _m28; + float _m29; + float _m30; + float _m31; + float _m32; + float2 _m33; + float _m34; + float _m35; + float3 _m36; + float4x4 _m37[2]; + float4 _m38[2]; +}; + +constant _28 _74 = {}; + +struct main0_out +{ + float4 m_5 [[color(0)]]; +}; + +fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buffer(1)]], constant _18& _19 [[buffer(2)]], texture2d _8 [[texture(0)]], texture2d _12 [[texture(1)]], texture2d _14 [[texture(2)]], sampler _9 [[sampler(0)]], sampler _13 [[sampler(1)]], sampler _15 [[sampler(2)]], float4 gl_FragCoord [[position]]) +{ + main0_out out = {}; + _28 _77 = _74; + _77._m0 = float4(0.0); + float2 _82 = gl_FragCoord.xy * _19._m23.xy; + float4 _88 = _7._m2 * _7._m0.xyxy; + float2 _97 = clamp(_82 + (float3(0.0, -2.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); + float3 _109 = _11._m5 * clamp(_8.sample(_9, _97, level(0.0)).w * _7._m1, 0.0, 1.0); + float4 _113 = _12.sample(_13, _97, level(0.0)); + float3 _129; + if (_113.y > 0.0) + { + _129 = _109 + (_14.sample(_15, _97, level(0.0)).xyz * clamp(_113.y * _113.z, 0.0, 1.0)); + } + else + { + _129 = _109; + } + float3 _133 = float4(0.0).xyz + (_129 * 0.5); + float4 _134 = float4(_133.x, _133.y, _133.z, float4(0.0).w); + _28 _135 = _77; + _135._m0 = _134; + float2 _144 = clamp(_82 + (float3(-1.0, -1.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); + float3 _156 = _11._m5 * clamp(_8.sample(_9, _144, level(0.0)).w * _7._m1, 0.0, 1.0); + float4 _160 = _12.sample(_13, _144, level(0.0)); + float3 _176; + if (_160.y > 0.0) + { + _176 = _156 + (_14.sample(_15, _144, level(0.0)).xyz * clamp(_160.y * _160.z, 0.0, 1.0)); + } + else + { + _176 = _156; + } + float3 _180 = _134.xyz + (_176 * 0.5); + float4 _181 = float4(_180.x, _180.y, _180.z, _134.w); + _28 _182 = _135; + _182._m0 = _181; + float2 _191 = clamp(_82 + (float3(0.0, -1.0, 0.75).xy * _7._m0.xy), _88.xy, _88.zw); + float3 _203 = _11._m5 * clamp(_8.sample(_9, _191, level(0.0)).w * _7._m1, 0.0, 1.0); + float4 _207 = _12.sample(_13, _191, level(0.0)); + float3 _223; + if (_207.y > 0.0) + { + _223 = _203 + (_14.sample(_15, _191, level(0.0)).xyz * clamp(_207.y * _207.z, 0.0, 1.0)); + } + else + { + _223 = _203; + } + float3 _227 = _181.xyz + (_223 * 0.75); + float4 _228 = float4(_227.x, _227.y, _227.z, _181.w); + _28 _229 = _182; + _229._m0 = _228; + float2 _238 = clamp(_82 + (float3(1.0, -1.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); + float3 _250 = _11._m5 * clamp(_8.sample(_9, _238, level(0.0)).w * _7._m1, 0.0, 1.0); + float4 _254 = _12.sample(_13, _238, level(0.0)); + float3 _270; + if (_254.y > 0.0) + { + _270 = _250 + (_14.sample(_15, _238, level(0.0)).xyz * clamp(_254.y * _254.z, 0.0, 1.0)); + } + else + { + _270 = _250; + } + float3 _274 = _228.xyz + (_270 * 0.5); + float4 _275 = float4(_274.x, _274.y, _274.z, _228.w); + _28 _276 = _229; + _276._m0 = _275; + float2 _285 = clamp(_82 + (float3(-2.0, 0.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); + float3 _297 = _11._m5 * clamp(_8.sample(_9, _285, level(0.0)).w * _7._m1, 0.0, 1.0); + float4 _301 = _12.sample(_13, _285, level(0.0)); + float3 _317; + if (_301.y > 0.0) + { + _317 = _297 + (_14.sample(_15, _285, level(0.0)).xyz * clamp(_301.y * _301.z, 0.0, 1.0)); + } + else + { + _317 = _297; + } + float3 _321 = _275.xyz + (_317 * 0.5); + float4 _322 = float4(_321.x, _321.y, _321.z, _275.w); + _28 _323 = _276; + _323._m0 = _322; + float2 _332 = clamp(_82 + (float3(-1.0, 0.0, 0.75).xy * _7._m0.xy), _88.xy, _88.zw); + float3 _344 = _11._m5 * clamp(_8.sample(_9, _332, level(0.0)).w * _7._m1, 0.0, 1.0); + float4 _348 = _12.sample(_13, _332, level(0.0)); + float3 _364; + if (_348.y > 0.0) + { + _364 = _344 + (_14.sample(_15, _332, level(0.0)).xyz * clamp(_348.y * _348.z, 0.0, 1.0)); + } + else + { + _364 = _344; + } + float3 _368 = _322.xyz + (_364 * 0.75); + float4 _369 = float4(_368.x, _368.y, _368.z, _322.w); + _28 _370 = _323; + _370._m0 = _369; + float2 _379 = clamp(_82 + (float3(0.0, 0.0, 1.0).xy * _7._m0.xy), _88.xy, _88.zw); + float3 _391 = _11._m5 * clamp(_8.sample(_9, _379, level(0.0)).w * _7._m1, 0.0, 1.0); + float4 _395 = _12.sample(_13, _379, level(0.0)); + float3 _411; + if (_395.y > 0.0) + { + _411 = _391 + (_14.sample(_15, _379, level(0.0)).xyz * clamp(_395.y * _395.z, 0.0, 1.0)); + } + else + { + _411 = _391; + } + float3 _415 = _369.xyz + (_411 * 1.0); + float4 _416 = float4(_415.x, _415.y, _415.z, _369.w); + _28 _417 = _370; + _417._m0 = _416; + float2 _426 = clamp(_82 + (float3(1.0, 0.0, 0.75).xy * _7._m0.xy), _88.xy, _88.zw); + float3 _438 = _11._m5 * clamp(_8.sample(_9, _426, level(0.0)).w * _7._m1, 0.0, 1.0); + float4 _442 = _12.sample(_13, _426, level(0.0)); + float3 _458; + if (_442.y > 0.0) + { + _458 = _438 + (_14.sample(_15, _426, level(0.0)).xyz * clamp(_442.y * _442.z, 0.0, 1.0)); + } + else + { + _458 = _438; + } + float3 _462 = _416.xyz + (_458 * 0.75); + float4 _463 = float4(_462.x, _462.y, _462.z, _416.w); + _28 _464 = _417; + _464._m0 = _463; + float2 _473 = clamp(_82 + (float3(2.0, 0.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); + float3 _485 = _11._m5 * clamp(_8.sample(_9, _473, level(0.0)).w * _7._m1, 0.0, 1.0); + float4 _489 = _12.sample(_13, _473, level(0.0)); + float3 _505; + if (_489.y > 0.0) + { + _505 = _485 + (_14.sample(_15, _473, level(0.0)).xyz * clamp(_489.y * _489.z, 0.0, 1.0)); + } + else + { + _505 = _485; + } + float3 _509 = _463.xyz + (_505 * 0.5); + float4 _510 = float4(_509.x, _509.y, _509.z, _463.w); + _28 _511 = _464; + _511._m0 = _510; + float2 _520 = clamp(_82 + (float3(-1.0, 1.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); + float3 _532 = _11._m5 * clamp(_8.sample(_9, _520, level(0.0)).w * _7._m1, 0.0, 1.0); + float4 _536 = _12.sample(_13, _520, level(0.0)); + float3 _552; + if (_536.y > 0.0) + { + _552 = _532 + (_14.sample(_15, _520, level(0.0)).xyz * clamp(_536.y * _536.z, 0.0, 1.0)); + } + else + { + _552 = _532; + } + float3 _556 = _510.xyz + (_552 * 0.5); + float4 _557 = float4(_556.x, _556.y, _556.z, _510.w); + _28 _558 = _511; + _558._m0 = _557; + float2 _567 = clamp(_82 + (float3(0.0, 1.0, 0.75).xy * _7._m0.xy), _88.xy, _88.zw); + float3 _579 = _11._m5 * clamp(_8.sample(_9, _567, level(0.0)).w * _7._m1, 0.0, 1.0); + float4 _583 = _12.sample(_13, _567, level(0.0)); + float3 _599; + if (_583.y > 0.0) + { + _599 = _579 + (_14.sample(_15, _567, level(0.0)).xyz * clamp(_583.y * _583.z, 0.0, 1.0)); + } + else + { + _599 = _579; + } + float3 _603 = _557.xyz + (_599 * 0.75); + float4 _604 = float4(_603.x, _603.y, _603.z, _557.w); + _28 _605 = _558; + _605._m0 = _604; + float2 _614 = clamp(_82 + (float3(1.0, 1.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); + float3 _626 = _11._m5 * clamp(_8.sample(_9, _614, level(0.0)).w * _7._m1, 0.0, 1.0); + float4 _630 = _12.sample(_13, _614, level(0.0)); + float3 _646; + if (_630.y > 0.0) + { + _646 = _626 + (_14.sample(_15, _614, level(0.0)).xyz * clamp(_630.y * _630.z, 0.0, 1.0)); + } + else + { + _646 = _626; + } + float3 _650 = _604.xyz + (_646 * 0.5); + float4 _651 = float4(_650.x, _650.y, _650.z, _604.w); + _28 _652 = _605; + _652._m0 = _651; + float2 _661 = clamp(_82 + (float3(0.0, 2.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); + float3 _673 = _11._m5 * clamp(_8.sample(_9, _661, level(0.0)).w * _7._m1, 0.0, 1.0); + float4 _677 = _12.sample(_13, _661, level(0.0)); + float3 _693; + if (_677.y > 0.0) + { + _693 = _673 + (_14.sample(_15, _661, level(0.0)).xyz * clamp(_677.y * _677.z, 0.0, 1.0)); + } + else + { + _693 = _673; + } + float3 _697 = _651.xyz + (_693 * 0.5); + float4 _698 = float4(_697.x, _697.y, _697.z, _651.w); + _28 _699 = _652; + _699._m0 = _698; + float3 _702 = _698.xyz / float3(((((((((((((0.0 + 0.5) + 0.5) + 0.75) + 0.5) + 0.5) + 0.75) + 1.0) + 0.75) + 0.5) + 0.5) + 0.75) + 0.5) + 0.5); + _28 _704 = _699; + _704._m0 = float4(_702.x, _702.y, _702.z, _698.w); + _28 _705 = _704; + _705._m0.w = 1.0; + out.m_5 = _705._m0; + return out; +} + diff --git a/reference/opt/shaders-msl/asm/vert/empty-struct-composite.asm.vert b/reference/opt/shaders-msl/asm/vert/empty-struct-composite.asm.vert new file mode 100644 index 0000000000..9e024c2095 --- /dev/null +++ b/reference/opt/shaders-msl/asm/vert/empty-struct-composite.asm.vert @@ -0,0 +1,9 @@ +#include +#include + +using namespace metal; + +vertex void main0() +{ +} + diff --git a/reference/opt/shaders-msl/comp/atomic.comp b/reference/opt/shaders-msl/comp/atomic.comp new file mode 100644 index 0000000000..90a39ec643 --- /dev/null +++ b/reference/opt/shaders-msl/comp/atomic.comp @@ -0,0 +1,36 @@ +#pragma clang diagnostic ignored "-Wunused-variable" + +#include +#include +#include + +using namespace metal; + +struct SSBO +{ + uint u32; + int i32; +}; + +kernel void main0(device SSBO& ssbo [[buffer(0)]]) +{ + uint _16 = atomic_fetch_add_explicit((volatile device atomic_uint*)&(ssbo.u32), 1u, memory_order_relaxed); + uint _18 = atomic_fetch_or_explicit((volatile device atomic_uint*)&(ssbo.u32), 1u, memory_order_relaxed); + uint _20 = atomic_fetch_xor_explicit((volatile device atomic_uint*)&(ssbo.u32), 1u, memory_order_relaxed); + uint _22 = atomic_fetch_and_explicit((volatile device atomic_uint*)&(ssbo.u32), 1u, memory_order_relaxed); + uint _24 = atomic_fetch_min_explicit((volatile device atomic_uint*)&(ssbo.u32), 1u, memory_order_relaxed); + uint _26 = atomic_fetch_max_explicit((volatile device atomic_uint*)&(ssbo.u32), 1u, memory_order_relaxed); + uint _28 = atomic_exchange_explicit((volatile device atomic_uint*)&(ssbo.u32), 1u, memory_order_relaxed); + uint _30 = 10u; + uint _32 = atomic_compare_exchange_weak_explicit((volatile device atomic_uint*)&(ssbo.u32), &(_30), 2u, memory_order_relaxed, memory_order_relaxed); + int _36 = atomic_fetch_add_explicit((volatile device atomic_int*)&(ssbo.i32), 1, memory_order_relaxed); + int _38 = atomic_fetch_or_explicit((volatile device atomic_int*)&(ssbo.i32), 1, memory_order_relaxed); + int _40 = atomic_fetch_xor_explicit((volatile device atomic_int*)&(ssbo.i32), 1, memory_order_relaxed); + int _42 = atomic_fetch_and_explicit((volatile device atomic_int*)&(ssbo.i32), 1, memory_order_relaxed); + int _44 = atomic_fetch_min_explicit((volatile device atomic_int*)&(ssbo.i32), 1, memory_order_relaxed); + int _46 = atomic_fetch_max_explicit((volatile device atomic_int*)&(ssbo.i32), 1, memory_order_relaxed); + int _48 = atomic_exchange_explicit((volatile device atomic_int*)&(ssbo.i32), 1, memory_order_relaxed); + int _50 = 10; + int _52 = atomic_compare_exchange_weak_explicit((volatile device atomic_int*)&(ssbo.i32), &(_50), 2, memory_order_relaxed, memory_order_relaxed); +} + diff --git a/reference/opt/shaders-msl/comp/bake_gradient.comp b/reference/opt/shaders-msl/comp/bake_gradient.comp new file mode 100644 index 0000000000..fe7ac2b7d4 --- /dev/null +++ b/reference/opt/shaders-msl/comp/bake_gradient.comp @@ -0,0 +1,22 @@ +#include +#include + +using namespace metal; + +constant uint3 gl_WorkGroupSize = uint3(8u, 8u, 1u); + +struct UBO +{ + float4 uInvSize; + float4 uScale; +}; + +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], constant UBO& _46 [[buffer(0)]], texture2d uHeight [[texture(0)]], sampler uHeightSmplr [[sampler(0)]], texture2d uDisplacement [[texture(1)]], sampler uDisplacementSmplr [[sampler(1)]], texture2d iHeightDisplacement [[texture(2)]], texture2d iGradJacobian [[texture(3)]]) +{ + float4 _59 = (float2(gl_GlobalInvocationID.xy) * _46.uInvSize.xy).xyxy + (_46.uInvSize * 0.5); + float2 _157 = ((uDisplacement.sample(uDisplacementSmplr, _59.zw, level(0.0), int2(1, 0)).xy - uDisplacement.sample(uDisplacementSmplr, _59.zw, level(0.0), int2(-1, 0)).xy) * 0.60000002384185791015625) * _46.uScale.z; + float2 _161 = ((uDisplacement.sample(uDisplacementSmplr, _59.zw, level(0.0), int2(0, 1)).xy - uDisplacement.sample(uDisplacementSmplr, _59.zw, level(0.0), int2(0, -1)).xy) * 0.60000002384185791015625) * _46.uScale.z; + iHeightDisplacement.write(float4(uHeight.sample(uHeightSmplr, _59.xy, level(0.0)).x, 0.0, 0.0, 0.0), uint2(int2(gl_GlobalInvocationID.xy))); + iGradJacobian.write(float4((_46.uScale.xy * 0.5) * float2(uHeight.sample(uHeightSmplr, _59.xy, level(0.0), int2(1, 0)).x - uHeight.sample(uHeightSmplr, _59.xy, level(0.0), int2(-1, 0)).x, uHeight.sample(uHeightSmplr, _59.xy, level(0.0), int2(0, 1)).x - uHeight.sample(uHeightSmplr, _59.xy, level(0.0), int2(0, -1)).x), ((1.0 + _157.x) * (1.0 + _161.y)) - (_157.y * _161.x), 0.0), uint2(int2(gl_GlobalInvocationID.xy))); +} + diff --git a/reference/opt/shaders-msl/comp/barriers.comp b/reference/opt/shaders-msl/comp/barriers.comp new file mode 100644 index 0000000000..23a19914c2 --- /dev/null +++ b/reference/opt/shaders-msl/comp/barriers.comp @@ -0,0 +1,20 @@ +#include +#include + +using namespace metal; + +constant uint3 gl_WorkGroupSize = uint3(4u, 1u, 1u); + +kernel void main0() +{ + threadgroup_barrier(mem_flags::mem_threadgroup); + threadgroup_barrier(mem_flags::mem_threadgroup); + threadgroup_barrier(mem_flags::mem_none); + threadgroup_barrier(mem_flags::mem_threadgroup); + threadgroup_barrier(mem_flags::mem_threadgroup); + threadgroup_barrier(mem_flags::mem_threadgroup); + threadgroup_barrier(mem_flags::mem_none); + threadgroup_barrier(mem_flags::mem_threadgroup); + threadgroup_barrier(mem_flags::mem_threadgroup); +} + diff --git a/reference/opt/shaders-msl/comp/basic.comp b/reference/opt/shaders-msl/comp/basic.comp new file mode 100644 index 0000000000..c41f7c0acf --- /dev/null +++ b/reference/opt/shaders-msl/comp/basic.comp @@ -0,0 +1,33 @@ +#pragma clang diagnostic ignored "-Wunused-variable" + +#include +#include +#include + +using namespace metal; + +struct SSBO +{ + float4 in_data[1]; +}; + +struct SSBO2 +{ + float4 out_data[1]; +}; + +struct SSBO3 +{ + uint counter; +}; + +kernel void main0(device SSBO& _23 [[buffer(0)]], device SSBO2& _45 [[buffer(1)]], device SSBO3& _48 [[buffer(2)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + float4 _29 = _23.in_data[gl_GlobalInvocationID.x]; + if (dot(_29, float4(1.0, 5.0, 6.0, 2.0)) > 8.19999980926513671875) + { + uint _52 = atomic_fetch_add_explicit((volatile device atomic_uint*)&(_48.counter), 1u, memory_order_relaxed); + _45.out_data[_52] = _29; + } +} + diff --git a/reference/opt/shaders-msl/comp/bitfield.noopt.comp b/reference/opt/shaders-msl/comp/bitfield.noopt.comp new file mode 100644 index 0000000000..62ef02c997 --- /dev/null +++ b/reference/opt/shaders-msl/comp/bitfield.noopt.comp @@ -0,0 +1,47 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +// Implementation of the GLSL findLSB() function +template +T findLSB(T x) +{ + return select(ctz(x), T(-1), x == T(0)); +} + +// Implementation of the signed GLSL findMSB() function +template +T findSMSB(T x) +{ + T v = select(x, T(-1) - x, x < T(0)); + return select(clz(T(0)) - (clz(v) + T(1)), T(-1), v == T(0)); +} + +// Implementation of the unsigned GLSL findMSB() function +template +T findUMSB(T x) +{ + return select(clz(T(0)) - (clz(x) + T(1)), T(-1), x == T(0)); +} + +kernel void main0() +{ + int signed_value = 0; + uint unsigned_value = 0u; + int s = extract_bits(signed_value, 5, 20); + uint u = extract_bits(unsigned_value, 6, 21); + s = insert_bits(s, 40, 5, 4); + u = insert_bits(u, 60u, 5, 4); + u = reverse_bits(u); + s = reverse_bits(s); + int v0 = popcount(u); + int v1 = popcount(s); + int v2 = findUMSB(u); + int v3 = findSMSB(s); + int v4 = findLSB(u); + int v5 = findLSB(s); +} + diff --git a/reference/opt/shaders-msl/comp/builtins.comp b/reference/opt/shaders-msl/comp/builtins.comp new file mode 100644 index 0000000000..8278220225 --- /dev/null +++ b/reference/opt/shaders-msl/comp/builtins.comp @@ -0,0 +1,9 @@ +#include +#include + +using namespace metal; + +kernel void main0(uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]], uint3 gl_NumWorkGroups [[threadgroups_per_grid]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]]) +{ +} + diff --git a/reference/opt/shaders-msl/comp/cfg-preserve-parameter.comp b/reference/opt/shaders-msl/comp/cfg-preserve-parameter.comp new file mode 100644 index 0000000000..59fc03a752 --- /dev/null +++ b/reference/opt/shaders-msl/comp/cfg-preserve-parameter.comp @@ -0,0 +1,9 @@ +#include +#include + +using namespace metal; + +kernel void main0() +{ +} + diff --git a/reference/opt/shaders-msl/comp/coherent-block.comp b/reference/opt/shaders-msl/comp/coherent-block.comp new file mode 100644 index 0000000000..bec9b218c7 --- /dev/null +++ b/reference/opt/shaders-msl/comp/coherent-block.comp @@ -0,0 +1,15 @@ +#include +#include + +using namespace metal; + +struct SSBO +{ + float4 value; +}; + +kernel void main0(device SSBO& _10 [[buffer(0)]]) +{ + _10.value = float4(20.0); +} + diff --git a/reference/opt/shaders-msl/comp/coherent-image.comp b/reference/opt/shaders-msl/comp/coherent-image.comp new file mode 100644 index 0000000000..0fe044fb9a --- /dev/null +++ b/reference/opt/shaders-msl/comp/coherent-image.comp @@ -0,0 +1,15 @@ +#include +#include + +using namespace metal; + +struct SSBO +{ + int4 value; +}; + +kernel void main0(device SSBO& _10 [[buffer(0)]], texture2d uImage [[texture(0)]]) +{ + _10.value = uImage.read(uint2(int2(10))); +} + diff --git a/reference/opt/shaders-msl/comp/culling.comp b/reference/opt/shaders-msl/comp/culling.comp new file mode 100644 index 0000000000..b20480bb45 --- /dev/null +++ b/reference/opt/shaders-msl/comp/culling.comp @@ -0,0 +1,35 @@ +#pragma clang diagnostic ignored "-Wunused-variable" + +#include +#include +#include + +using namespace metal; + +constant uint3 gl_WorkGroupSize = uint3(4u, 1u, 1u); + +struct SSBO +{ + float in_data[1]; +}; + +struct SSBO2 +{ + float out_data[1]; +}; + +struct SSBO3 +{ + uint count; +}; + +kernel void main0(device SSBO& _22 [[buffer(0)]], device SSBO2& _38 [[buffer(1)]], device SSBO3& _41 [[buffer(2)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + float _28 = _22.in_data[gl_GlobalInvocationID.x]; + if (_28 > 12.0) + { + uint _45 = atomic_fetch_add_explicit((volatile device atomic_uint*)&(_41.count), 1u, memory_order_relaxed); + _38.out_data[_45] = _28; + } +} + diff --git a/reference/opt/shaders-msl/comp/defer-parens.comp b/reference/opt/shaders-msl/comp/defer-parens.comp new file mode 100644 index 0000000000..b9a742a13c --- /dev/null +++ b/reference/opt/shaders-msl/comp/defer-parens.comp @@ -0,0 +1,21 @@ +#include +#include + +using namespace metal; + +struct SSBO +{ + float4 data; + int index; +}; + +kernel void main0(device SSBO& _13 [[buffer(0)]]) +{ + float4 _17 = _13.data; + _13.data = float4(_17.x, _17.yz + float2(10.0), _17.w); + _13.data = (_17 + _17) + _17; + _13.data = (_17.yz + float2(10.0)).xxyy; + _13.data = float4((_17.yz + float2(10.0)).y); + _13.data = float4((_17.zw + float2(10.0))[_13.index]); +} + diff --git a/reference/opt/shaders-msl/comp/dowhile.comp b/reference/opt/shaders-msl/comp/dowhile.comp new file mode 100644 index 0000000000..d76ca819c4 --- /dev/null +++ b/reference/opt/shaders-msl/comp/dowhile.comp @@ -0,0 +1,39 @@ +#include +#include + +using namespace metal; + +struct SSBO +{ + float4x4 mvp; + float4 in_data[1]; +}; + +struct SSBO2 +{ + float4 out_data[1]; +}; + +kernel void main0(device SSBO& _28 [[buffer(0)]], device SSBO2& _52 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + int i = 0; + float4 _56; + _56 = _28.in_data[gl_GlobalInvocationID.x]; + float4 _42; + for (;;) + { + _42 = _28.mvp * _56; + i++; + if (i < 16) + { + _56 = _42; + continue; + } + else + { + break; + } + } + _52.out_data[gl_GlobalInvocationID.x] = _42; +} + diff --git a/reference/opt/shaders-msl/comp/functions.comp b/reference/opt/shaders-msl/comp/functions.comp new file mode 100644 index 0000000000..35ee32d220 --- /dev/null +++ b/reference/opt/shaders-msl/comp/functions.comp @@ -0,0 +1,11 @@ +#include +#include + +using namespace metal; + +kernel void main0() +{ + threadgroup int foo[1337]; + foo[0] = 13; +} + diff --git a/reference/opt/shaders-msl/comp/global-invocation-id-writable-ssbo-in-function.comp b/reference/opt/shaders-msl/comp/global-invocation-id-writable-ssbo-in-function.comp new file mode 100644 index 0000000000..fe0212ec3f --- /dev/null +++ b/reference/opt/shaders-msl/comp/global-invocation-id-writable-ssbo-in-function.comp @@ -0,0 +1,26 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct myBlock +{ + int a; + float b[1]; +}; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +kernel void main0(device myBlock& myStorage [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + myStorage.a = (myStorage.a + 1) % 256; + myStorage.b[gl_GlobalInvocationID.x] = mod(myStorage.b[gl_GlobalInvocationID.x] + 0.0199999995529651641845703125, 1.0); +} + diff --git a/reference/opt/shaders-msl/comp/global-invocation-id.comp b/reference/opt/shaders-msl/comp/global-invocation-id.comp new file mode 100644 index 0000000000..fe0212ec3f --- /dev/null +++ b/reference/opt/shaders-msl/comp/global-invocation-id.comp @@ -0,0 +1,26 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct myBlock +{ + int a; + float b[1]; +}; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +kernel void main0(device myBlock& myStorage [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + myStorage.a = (myStorage.a + 1) % 256; + myStorage.b[gl_GlobalInvocationID.x] = mod(myStorage.b[gl_GlobalInvocationID.x] + 0.0199999995529651641845703125, 1.0); +} + diff --git a/reference/opt/shaders-msl/comp/image.comp b/reference/opt/shaders-msl/comp/image.comp new file mode 100644 index 0000000000..d615fb2736 --- /dev/null +++ b/reference/opt/shaders-msl/comp/image.comp @@ -0,0 +1,10 @@ +#include +#include + +using namespace metal; + +kernel void main0(texture2d uImageIn [[texture(0)]], texture2d uImageOut [[texture(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + uImageOut.write(uImageIn.read(uint2((int2(gl_GlobalInvocationID.xy) + int2(uImageIn.get_width(), uImageIn.get_height())))), uint2(int2(gl_GlobalInvocationID.xy))); +} + diff --git a/reference/opt/shaders-msl/comp/insert.comp b/reference/opt/shaders-msl/comp/insert.comp new file mode 100644 index 0000000000..1418ce35b5 --- /dev/null +++ b/reference/opt/shaders-msl/comp/insert.comp @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct SSBO +{ + float4 out_data[1]; +}; + +constant float4 _52 = {}; + +kernel void main0(device SSBO& _27 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + float4 _45 = _52; + _45.x = 10.0; + float4 _47 = _45; + _47.y = 30.0; + float4 _49 = _47; + _49.z = 70.0; + float4 _51 = _49; + _51.w = 90.0; + _27.out_data[gl_GlobalInvocationID.x] = _51; + _27.out_data[gl_GlobalInvocationID.x].y = 20.0; +} + diff --git a/reference/opt/shaders-msl/comp/local-invocation-id.comp b/reference/opt/shaders-msl/comp/local-invocation-id.comp new file mode 100644 index 0000000000..772e5e0d86 --- /dev/null +++ b/reference/opt/shaders-msl/comp/local-invocation-id.comp @@ -0,0 +1,26 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct myBlock +{ + int a; + float b[1]; +}; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +kernel void main0(device myBlock& myStorage [[buffer(0)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]]) +{ + myStorage.a = (myStorage.a + 1) % 256; + myStorage.b[gl_LocalInvocationID.x] = mod(myStorage.b[gl_LocalInvocationID.x] + 0.0199999995529651641845703125, 1.0); +} + diff --git a/reference/opt/shaders-msl/comp/local-invocation-index.comp b/reference/opt/shaders-msl/comp/local-invocation-index.comp new file mode 100644 index 0000000000..41adbdca5c --- /dev/null +++ b/reference/opt/shaders-msl/comp/local-invocation-index.comp @@ -0,0 +1,26 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct myBlock +{ + int a; + float b[1]; +}; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +kernel void main0(device myBlock& myStorage [[buffer(0)]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]]) +{ + myStorage.a = (myStorage.a + 1) % 256; + myStorage.b[gl_LocalInvocationIndex] = mod(myStorage.b[gl_LocalInvocationIndex] + 0.0199999995529651641845703125, 1.0); +} + diff --git a/reference/opt/shaders-msl/comp/loop.noopt.comp b/reference/opt/shaders-msl/comp/loop.noopt.comp new file mode 100644 index 0000000000..00ed570b31 --- /dev/null +++ b/reference/opt/shaders-msl/comp/loop.noopt.comp @@ -0,0 +1,107 @@ +#include +#include + +using namespace metal; + +struct SSBO +{ + float4x4 mvp; + float4 in_data[1]; +}; + +struct SSBO2 +{ + float4 out_data[1]; +}; + +kernel void main0(device SSBO& _24 [[buffer(0)]], device SSBO2& _177 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + uint ident = gl_GlobalInvocationID.x; + float4 idat = _24.in_data[ident]; + int k = 0; + uint i = 0u; + if (idat.y == 20.0) + { + do + { + k *= 2; + i++; + } while (i < ident); + } + switch (k) + { + case 10: + { + for (;;) + { + i++; + if (i > 10u) + { + break; + } + continue; + } + break; + } + default: + { + for (;;) + { + i += 2u; + if (i > 20u) + { + break; + } + continue; + } + break; + } + } + while (k < 10) + { + idat *= 2.0; + k++; + } + for (uint i_1 = 0u; i_1 < 16u; i_1++, k++) + { + for (uint j = 0u; j < 30u; j++) + { + idat = _24.mvp * idat; + } + } + k = 0; + for (;;) + { + k++; + if (k > 10) + { + k += 2; + } + else + { + k += 3; + continue; + } + k += 10; + continue; + } + k = 0; + do + { + k++; + } while (k > 10); + int l = 0; + for (;;) + { + if (l == 5) + { + l++; + continue; + } + idat += float4(1.0); + l++; + continue; + } + _177.out_data[ident] = idat; +} + diff --git a/reference/opt/shaders-msl/comp/mat3.comp b/reference/opt/shaders-msl/comp/mat3.comp new file mode 100644 index 0000000000..72f08dd85e --- /dev/null +++ b/reference/opt/shaders-msl/comp/mat3.comp @@ -0,0 +1,15 @@ +#include +#include + +using namespace metal; + +struct SSBO2 +{ + float3x3 out_data[1]; +}; + +kernel void main0(device SSBO2& _22 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + _22.out_data[gl_GlobalInvocationID.x] = float3x3(float3(10.0), float3(20.0), float3(40.0)); +} + diff --git a/reference/opt/shaders-msl/comp/mod.comp b/reference/opt/shaders-msl/comp/mod.comp new file mode 100644 index 0000000000..86bde9c27d --- /dev/null +++ b/reference/opt/shaders-msl/comp/mod.comp @@ -0,0 +1,31 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct SSBO +{ + float4 in_data[1]; +}; + +struct SSBO2 +{ + float4 out_data[1]; +}; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +kernel void main0(device SSBO& _23 [[buffer(0)]], device SSBO2& _33 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + _33.out_data[gl_GlobalInvocationID.x] = mod(_23.in_data[gl_GlobalInvocationID.x], _33.out_data[gl_GlobalInvocationID.x]); + _33.out_data[gl_GlobalInvocationID.x] = as_type(as_type(_23.in_data[gl_GlobalInvocationID.x]) % as_type(_33.out_data[gl_GlobalInvocationID.x])); + _33.out_data[gl_GlobalInvocationID.x] = as_type(as_type(_23.in_data[gl_GlobalInvocationID.x]) % as_type(_33.out_data[gl_GlobalInvocationID.x])); +} + diff --git a/reference/opt/shaders-msl/comp/modf.comp b/reference/opt/shaders-msl/comp/modf.comp new file mode 100644 index 0000000000..40cbb40cea --- /dev/null +++ b/reference/opt/shaders-msl/comp/modf.comp @@ -0,0 +1,22 @@ +#include +#include + +using namespace metal; + +struct SSBO +{ + float4 in_data[1]; +}; + +struct SSBO2 +{ + float4 out_data[1]; +}; + +kernel void main0(device SSBO& _23 [[buffer(0)]], device SSBO2& _35 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + float4 i; + float4 _31 = modf(_23.in_data[gl_GlobalInvocationID.x], i); + _35.out_data[gl_GlobalInvocationID.x] = _31; +} + diff --git a/reference/opt/shaders-msl/comp/read-write-only.comp b/reference/opt/shaders-msl/comp/read-write-only.comp new file mode 100644 index 0000000000..ba53b334ba --- /dev/null +++ b/reference/opt/shaders-msl/comp/read-write-only.comp @@ -0,0 +1,29 @@ +#include +#include + +using namespace metal; + +struct SSBO2 +{ + float4 data4; + float4 data5; +}; + +struct SSBO0 +{ + float4 data0; + float4 data1; +}; + +struct SSBO1 +{ + float4 data2; + float4 data3; +}; + +kernel void main0(device SSBO2& _10 [[buffer(0)]], device SSBO0& _15 [[buffer(1)]], device SSBO1& _21 [[buffer(2)]]) +{ + _10.data4 = _15.data0 + _21.data2; + _10.data5 = _15.data1 + _21.data3; +} + diff --git a/reference/opt/shaders-msl/comp/return.comp b/reference/opt/shaders-msl/comp/return.comp new file mode 100644 index 0000000000..06ce8d7662 --- /dev/null +++ b/reference/opt/shaders-msl/comp/return.comp @@ -0,0 +1,33 @@ +#include +#include + +using namespace metal; + +struct SSBO2 +{ + float4 out_data[1]; +}; + +constant int _69 = {}; + +kernel void main0(device SSBO2& _27 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + if (gl_GlobalInvocationID.x == 2u) + { + _27.out_data[gl_GlobalInvocationID.x] = float4(20.0); + } + else + { + if (gl_GlobalInvocationID.x == 4u) + { + _27.out_data[gl_GlobalInvocationID.x] = float4(10.0); + return; + } + } + for (int _68 = 0; _68 < 20; _68 = _69 + 1) + { + return; + } + _27.out_data[gl_GlobalInvocationID.x] = float4(10.0); +} + diff --git a/reference/opt/shaders-msl/comp/rmw-opt.comp b/reference/opt/shaders-msl/comp/rmw-opt.comp new file mode 100644 index 0000000000..4bbd8b3c71 --- /dev/null +++ b/reference/opt/shaders-msl/comp/rmw-opt.comp @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct SSBO +{ + int a; +}; + +kernel void main0(device SSBO& _9 [[buffer(0)]]) +{ + _9.a += 10; + _9.a -= 10; + _9.a *= 10; + _9.a /= 10; + _9.a = _9.a << 2; + _9.a = _9.a >> 3; + _9.a &= 40; + _9.a ^= 10; + _9.a %= 40; + _9.a |= 1; + bool _65 = false && true; + _9.a = int(_65 && (true || _65)); +} + diff --git a/reference/opt/shaders-msl/comp/shared-array-of-arrays.comp b/reference/opt/shaders-msl/comp/shared-array-of-arrays.comp new file mode 100644 index 0000000000..db1ffebf2b --- /dev/null +++ b/reference/opt/shaders-msl/comp/shared-array-of-arrays.comp @@ -0,0 +1,20 @@ +#include +#include + +using namespace metal; + +constant uint3 gl_WorkGroupSize = uint3(4u, 4u, 1u); + +struct SSBO +{ + float out_data[1]; +}; + +kernel void main0(device SSBO& _67 [[buffer(0)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + threadgroup float foo[4][4]; + foo[gl_LocalInvocationID.x][gl_LocalInvocationID.y] = float(gl_LocalInvocationIndex); + threadgroup_barrier(mem_flags::mem_threadgroup); + _67.out_data[gl_GlobalInvocationID.x] = (((0.0 + foo[gl_LocalInvocationID.x][0]) + foo[gl_LocalInvocationID.x][1]) + foo[gl_LocalInvocationID.x][2]) + foo[gl_LocalInvocationID.x][3]; +} + diff --git a/reference/opt/shaders-msl/comp/shared.comp b/reference/opt/shaders-msl/comp/shared.comp new file mode 100644 index 0000000000..ef82961e2b --- /dev/null +++ b/reference/opt/shaders-msl/comp/shared.comp @@ -0,0 +1,25 @@ +#include +#include + +using namespace metal; + +constant uint3 gl_WorkGroupSize = uint3(4u, 1u, 1u); + +struct SSBO +{ + float in_data[1]; +}; + +struct SSBO2 +{ + float out_data[1]; +}; + +kernel void main0(device SSBO& _22 [[buffer(0)]], device SSBO2& _44 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]]) +{ + threadgroup float sShared[4]; + sShared[gl_LocalInvocationIndex] = _22.in_data[gl_GlobalInvocationID.x]; + threadgroup_barrier(mem_flags::mem_threadgroup); + _44.out_data[gl_GlobalInvocationID.x] = sShared[(4u - gl_LocalInvocationIndex) - 1u]; +} + diff --git a/reference/opt/shaders-msl/comp/struct-layout.comp b/reference/opt/shaders-msl/comp/struct-layout.comp new file mode 100644 index 0000000000..aa11cc966a --- /dev/null +++ b/reference/opt/shaders-msl/comp/struct-layout.comp @@ -0,0 +1,25 @@ +#include +#include + +using namespace metal; + +struct Foo +{ + float4x4 m; +}; + +struct SSBO2 +{ + Foo out_data[1]; +}; + +struct SSBO +{ + Foo in_data[1]; +}; + +kernel void main0(device SSBO2& _23 [[buffer(0)]], device SSBO& _30 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + _23.out_data[gl_GlobalInvocationID.x].m = _30.in_data[gl_GlobalInvocationID.x].m * _30.in_data[gl_GlobalInvocationID.x].m; +} + diff --git a/reference/opt/shaders-msl/comp/struct-packing.comp b/reference/opt/shaders-msl/comp/struct-packing.comp new file mode 100644 index 0000000000..cf626ce63f --- /dev/null +++ b/reference/opt/shaders-msl/comp/struct-packing.comp @@ -0,0 +1,100 @@ +#include +#include + +using namespace metal; + +struct S0 +{ + float2 a[1]; + float b; +}; + +struct S1 +{ + packed_float3 a; + float b; +}; + +struct S2 +{ + float3 a[1]; + float b; +}; + +struct S3 +{ + float2 a; + float b; +}; + +struct S4 +{ + float2 c; +}; + +struct Content +{ + S0 m0s[1]; + S1 m1s[1]; + S2 m2s[1]; + S0 m0; + S1 m1; + S2 m2; + S3 m3; + char pad7[4]; + float m4; + S4 m3s[8]; +}; + +struct SSBO1 +{ + Content content; + Content content1[2]; + Content content2; + char pad3[8]; + float2x2 m0; + float2x2 m1; + float2x3 m2[4]; + float3x2 m3; + float2x2 m4; + float2x2 m5[9]; + float2x3 m6[4][2]; + float3x2 m7; + float array[1]; +}; + +struct SSBO0 +{ + Content content; + Content content1[2]; + Content content2; + float array[1]; +}; + +kernel void main0(device SSBO1& ssbo_430 [[buffer(0)]], device SSBO0& ssbo_140 [[buffer(1)]]) +{ + ssbo_430.content.m0s[0].a[0] = ssbo_140.content.m0s[0].a[0]; + ssbo_430.content.m0s[0].b = ssbo_140.content.m0s[0].b; + ssbo_430.content.m1s[0].a = ssbo_140.content.m1s[0].a; + ssbo_430.content.m1s[0].b = ssbo_140.content.m1s[0].b; + ssbo_430.content.m2s[0].a[0] = ssbo_140.content.m2s[0].a[0]; + ssbo_430.content.m2s[0].b = ssbo_140.content.m2s[0].b; + ssbo_430.content.m0.a[0] = ssbo_140.content.m0.a[0]; + ssbo_430.content.m0.b = ssbo_140.content.m0.b; + ssbo_430.content.m1.a = ssbo_140.content.m1.a; + ssbo_430.content.m1.b = ssbo_140.content.m1.b; + ssbo_430.content.m2.a[0] = ssbo_140.content.m2.a[0]; + ssbo_430.content.m2.b = ssbo_140.content.m2.b; + ssbo_430.content.m3.a = ssbo_140.content.m3.a; + ssbo_430.content.m3.b = ssbo_140.content.m3.b; + ssbo_430.content.m4 = ssbo_140.content.m4; + ssbo_430.content.m3s[0].c = ssbo_140.content.m3s[0].c; + ssbo_430.content.m3s[1].c = ssbo_140.content.m3s[1].c; + ssbo_430.content.m3s[2].c = ssbo_140.content.m3s[2].c; + ssbo_430.content.m3s[3].c = ssbo_140.content.m3s[3].c; + ssbo_430.content.m3s[4].c = ssbo_140.content.m3s[4].c; + 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; +} + diff --git a/reference/opt/shaders-msl/comp/torture-loop.comp b/reference/opt/shaders-msl/comp/torture-loop.comp new file mode 100644 index 0000000000..1b239550e1 --- /dev/null +++ b/reference/opt/shaders-msl/comp/torture-loop.comp @@ -0,0 +1,79 @@ +#include +#include + +using namespace metal; + +struct SSBO +{ + float4x4 mvp; + float4 in_data[1]; +}; + +struct SSBO2 +{ + float4 out_data[1]; +}; + +constant uint _98 = {}; + +kernel void main0(device SSBO& _24 [[buffer(0)]], device SSBO2& _89 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + float4 _93; + int _94; + _93 = _24.in_data[gl_GlobalInvocationID.x]; + _94 = 0; + int _40; + float4 _46; + int _48; + for (;;) + { + _40 = _94 + 1; + if (_40 < 10) + { + _46 = _93 * 2.0; + _48 = _40 + 1; + _93 = _46; + _94 = _48; + continue; + } + else + { + break; + } + } + float4 _95; + int _96; + _95 = _93; + _96 = _40; + float4 _100; + uint _101; + uint _99; + for (uint _97 = 0u; _97 < 16u; _95 = _100, _96++, _97++, _99 = _101) + { + _100 = _95; + _101 = 0u; + float4 _71; + for (; _101 < 30u; _100 = _71, _101++) + { + _71 = _24.mvp * _100; + } + } + int _102; + _102 = _96; + int _83; + for (;;) + { + _83 = _102 + 1; + if (_83 > 10) + { + _102 = _83; + continue; + } + else + { + break; + } + } + _89.out_data[gl_GlobalInvocationID.x] = _95; +} + diff --git a/reference/opt/shaders-msl/comp/type-alias.comp b/reference/opt/shaders-msl/comp/type-alias.comp new file mode 100644 index 0000000000..02e23e733e --- /dev/null +++ b/reference/opt/shaders-msl/comp/type-alias.comp @@ -0,0 +1,35 @@ +#include +#include + +using namespace metal; + +struct S0 +{ + float4 a; +}; + +struct S1 +{ + float4 a; +}; + +struct SSBO0 +{ + S0 s0s[1]; +}; + +struct SSBO1 +{ + S1 s1s[1]; +}; + +struct SSBO2 +{ + float4 outputs[1]; +}; + +kernel void main0(device SSBO0& _36 [[buffer(0)]], device SSBO1& _55 [[buffer(1)]], device SSBO2& _66 [[buffer(2)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + _66.outputs[gl_GlobalInvocationID.x] = _36.s0s[gl_GlobalInvocationID.x].a + _55.s1s[gl_GlobalInvocationID.x].a; +} + diff --git a/reference/opt/shaders-msl/comp/udiv.comp b/reference/opt/shaders-msl/comp/udiv.comp new file mode 100644 index 0000000000..32874ad787 --- /dev/null +++ b/reference/opt/shaders-msl/comp/udiv.comp @@ -0,0 +1,20 @@ +#include +#include + +using namespace metal; + +struct SSBO2 +{ + uint outputs[1]; +}; + +struct SSBO +{ + uint inputs[1]; +}; + +kernel void main0(device SSBO2& _10 [[buffer(0)]], device SSBO& _23 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + _10.outputs[gl_GlobalInvocationID.x] = _23.inputs[gl_GlobalInvocationID.x] / 29u; +} + diff --git a/reference/opt/shaders-msl/comp/writable-ssbo.comp b/reference/opt/shaders-msl/comp/writable-ssbo.comp new file mode 100644 index 0000000000..9dc53b6dd5 --- /dev/null +++ b/reference/opt/shaders-msl/comp/writable-ssbo.comp @@ -0,0 +1,26 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct myBlock +{ + int a; + float b; +}; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +kernel void main0(device myBlock& myStorage [[buffer(0)]]) +{ + myStorage.a = (myStorage.a + 1) % 256; + myStorage.b = mod(myStorage.b + 0.0199999995529651641845703125, 1.0); +} + diff --git a/reference/opt/shaders-msl/desktop-only/frag/image-ms.desktop.frag b/reference/opt/shaders-msl/desktop-only/frag/image-ms.desktop.frag new file mode 100644 index 0000000000..4083e4ea16 --- /dev/null +++ b/reference/opt/shaders-msl/desktop-only/frag/image-ms.desktop.frag @@ -0,0 +1,11 @@ +#include +#include + +using namespace metal; + +fragment void main0(texture2d_ms uImageMS [[texture(0)]], texture2d_array uImageArray [[texture(1)]], texture2d uImage [[texture(2)]]) +{ + uImage.write(uImageMS.read(uint2(int2(1, 2)), 2), uint2(int2(2, 3))); + uImageArray.write(uImageArray.read(uint2(int3(1, 2, 4).xy), uint(int3(1, 2, 4).z)), uint2(int3(2, 3, 7).xy), uint(int3(2, 3, 7).z)); +} + diff --git a/reference/opt/shaders-msl/desktop-only/frag/query-levels.desktop.frag b/reference/opt/shaders-msl/desktop-only/frag/query-levels.desktop.frag new file mode 100644 index 0000000000..922796b749 --- /dev/null +++ b/reference/opt/shaders-msl/desktop-only/frag/query-levels.desktop.frag @@ -0,0 +1,17 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(texture2d uSampler [[texture(0)]], sampler uSamplerSmplr [[sampler(0)]]) +{ + main0_out out = {}; + out.FragColor = float4(float(int(uSampler.get_num_mip_levels()))); + return out; +} + diff --git a/reference/opt/shaders-msl/desktop-only/frag/sampler-ms-query.desktop.frag b/reference/opt/shaders-msl/desktop-only/frag/sampler-ms-query.desktop.frag new file mode 100644 index 0000000000..937e27465e --- /dev/null +++ b/reference/opt/shaders-msl/desktop-only/frag/sampler-ms-query.desktop.frag @@ -0,0 +1,17 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(texture2d_ms uSampler [[texture(0)]], texture2d_ms uSamplerArray [[texture(1)]], texture2d_ms uImage [[texture(2)]], texture2d_ms uImageArray [[texture(3)]], sampler uSamplerSmplr [[sampler(0)]], sampler uSamplerArraySmplr [[sampler(1)]]) +{ + main0_out out = {}; + out.FragColor = float4(float(((int(uSampler.get_num_samples()) + int(uSamplerArray.get_num_samples())) + int(uImage.get_num_samples())) + int(uImageArray.get_num_samples()))); + return out; +} + diff --git a/reference/opt/shaders-msl/desktop-only/vert/basic.desktop.sso.vert b/reference/opt/shaders-msl/desktop-only/vert/basic.desktop.sso.vert new file mode 100644 index 0000000000..1592b5c5cf --- /dev/null +++ b/reference/opt/shaders-msl/desktop-only/vert/basic.desktop.sso.vert @@ -0,0 +1,30 @@ +#include +#include + +using namespace metal; + +struct UBO +{ + float4x4 uMVP; +}; + +struct main0_in +{ + float3 aNormal [[attribute(1)]]; + float4 aVertex [[attribute(0)]]; +}; + +struct main0_out +{ + float3 vNormal [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _16 [[buffer(0)]]) +{ + main0_out out = {}; + out.gl_Position = _16.uMVP * in.aVertex; + out.vNormal = in.aNormal; + return out; +} + diff --git a/reference/opt/shaders-msl/desktop-only/vert/clip-cull-distance.desktop.vert b/reference/opt/shaders-msl/desktop-only/vert/clip-cull-distance.desktop.vert new file mode 100644 index 0000000000..32f0d9aa0d --- /dev/null +++ b/reference/opt/shaders-msl/desktop-only/vert/clip-cull-distance.desktop.vert @@ -0,0 +1,23 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 gl_Position [[position]]; + float gl_ClipDistance [[clip_distance]] [2]; + float gl_CullDistance[2]; +}; + +vertex main0_out main0() +{ + main0_out out = {}; + out.gl_Position = float4(10.0); + out.gl_ClipDistance[0] = 1.0; + out.gl_ClipDistance[1] = 4.0; + out.gl_CullDistance[0] = 4.0; + out.gl_CullDistance[1] = 9.0; + return out; +} + diff --git a/reference/opt/shaders-msl/flatten/basic.flatten.vert b/reference/opt/shaders-msl/flatten/basic.flatten.vert new file mode 100644 index 0000000000..1592b5c5cf --- /dev/null +++ b/reference/opt/shaders-msl/flatten/basic.flatten.vert @@ -0,0 +1,30 @@ +#include +#include + +using namespace metal; + +struct UBO +{ + float4x4 uMVP; +}; + +struct main0_in +{ + float3 aNormal [[attribute(1)]]; + float4 aVertex [[attribute(0)]]; +}; + +struct main0_out +{ + float3 vNormal [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _16 [[buffer(0)]]) +{ + main0_out out = {}; + out.gl_Position = _16.uMVP * in.aVertex; + out.vNormal = in.aNormal; + return out; +} + diff --git a/reference/opt/shaders-msl/flatten/multiindex.flatten.vert b/reference/opt/shaders-msl/flatten/multiindex.flatten.vert new file mode 100644 index 0000000000..84c4b408b2 --- /dev/null +++ b/reference/opt/shaders-msl/flatten/multiindex.flatten.vert @@ -0,0 +1,27 @@ +#include +#include + +using namespace metal; + +struct UBO +{ + float4 Data[3][5]; +}; + +struct main0_in +{ + int2 aIndex [[attribute(0)]]; +}; + +struct main0_out +{ + float4 gl_Position [[position]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _20 [[buffer(0)]]) +{ + main0_out out = {}; + out.gl_Position = _20.Data[in.aIndex.x][in.aIndex.y]; + return out; +} + diff --git a/reference/opt/shaders-msl/flatten/push-constant.flatten.vert b/reference/opt/shaders-msl/flatten/push-constant.flatten.vert new file mode 100644 index 0000000000..83def9c0bb --- /dev/null +++ b/reference/opt/shaders-msl/flatten/push-constant.flatten.vert @@ -0,0 +1,32 @@ +#include +#include + +using namespace metal; + +struct PushMe +{ + float4x4 MVP; + float2x2 Rot; + float Arr[4]; +}; + +struct main0_in +{ + float4 Pos [[attribute(1)]]; + float2 Rot [[attribute(0)]]; +}; + +struct main0_out +{ + float2 vRot [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]], constant PushMe& registers [[buffer(0)]]) +{ + main0_out out = {}; + out.gl_Position = registers.MVP * in.Pos; + out.vRot = (registers.Rot * in.Rot) + float2(registers.Arr[2]); + return out; +} + diff --git a/reference/opt/shaders-msl/flatten/rowmajor.flatten.vert b/reference/opt/shaders-msl/flatten/rowmajor.flatten.vert new file mode 100644 index 0000000000..3e0fcdbb75 --- /dev/null +++ b/reference/opt/shaders-msl/flatten/rowmajor.flatten.vert @@ -0,0 +1,29 @@ +#include +#include + +using namespace metal; + +struct UBO +{ + float4x4 uMVPR; + float4x4 uMVPC; + float2x4 uMVP; +}; + +struct main0_in +{ + float4 aVertex [[attribute(0)]]; +}; + +struct main0_out +{ + float4 gl_Position [[position]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _18 [[buffer(0)]]) +{ + main0_out out = {}; + out.gl_Position = (_18.uMVPR * in.aVertex) + (in.aVertex * _18.uMVPC); + return out; +} + diff --git a/reference/opt/shaders-msl/flatten/struct.flatten.vert b/reference/opt/shaders-msl/flatten/struct.flatten.vert new file mode 100644 index 0000000000..594d29fe57 --- /dev/null +++ b/reference/opt/shaders-msl/flatten/struct.flatten.vert @@ -0,0 +1,40 @@ +#include +#include + +using namespace metal; + +struct Light +{ + packed_float3 Position; + float Radius; + float4 Color; +}; + +struct UBO +{ + float4x4 uMVP; + Light light; +}; + +struct main0_in +{ + float3 aNormal [[attribute(1)]]; + float4 aVertex [[attribute(0)]]; +}; + +struct main0_out +{ + float4 vColor [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _18 [[buffer(0)]]) +{ + main0_out out = {}; + out.gl_Position = _18.uMVP * in.aVertex; + out.vColor = float4(0.0); + float3 _39 = in.aVertex.xyz - _18.light.Position; + out.vColor += ((_18.light.Color * clamp(1.0 - (length(_39) / _18.light.Radius), 0.0, 1.0)) * dot(in.aNormal, normalize(_39))); + return out; +} + diff --git a/reference/opt/shaders-msl/flatten/swizzle.flatten.vert b/reference/opt/shaders-msl/flatten/swizzle.flatten.vert new file mode 100644 index 0000000000..53fc21f99e --- /dev/null +++ b/reference/opt/shaders-msl/flatten/swizzle.flatten.vert @@ -0,0 +1,47 @@ +#include +#include + +using namespace metal; + +struct UBO +{ + float4 A; + float2 B0; + float2 B1; + float C0; + float3 C1; + packed_float3 D0; + float D1; + float E0; + float E1; + float E2; + float E3; + float F0; + float2 F1; + float F2; +}; + +struct main0_out +{ + float4 oA [[user(locn0)]]; + float4 oB [[user(locn1)]]; + float4 oC [[user(locn2)]]; + float4 oD [[user(locn3)]]; + float4 oE [[user(locn4)]]; + float4 oF [[user(locn5)]]; + float4 gl_Position [[position]]; +}; + +vertex main0_out main0(constant UBO& _22 [[buffer(0)]]) +{ + main0_out out = {}; + out.gl_Position = float4(0.0); + out.oA = _22.A; + out.oB = float4(_22.B0, _22.B1); + out.oC = float4(_22.C0, _22.C1) + float4(_22.C1.xy, _22.C1.z, _22.C0); + out.oD = float4(_22.D0, _22.D1) + float4(float3(_22.D0).xy, float3(_22.D0).z, _22.D1); + out.oE = float4(_22.E0, _22.E1, _22.E2, _22.E3); + out.oF = float4(_22.F0, _22.F1, _22.F2); + return out; +} + diff --git a/reference/opt/shaders-msl/flatten/types.flatten.frag b/reference/opt/shaders-msl/flatten/types.flatten.frag new file mode 100644 index 0000000000..cee53d9e58 --- /dev/null +++ b/reference/opt/shaders-msl/flatten/types.flatten.frag @@ -0,0 +1,35 @@ +#include +#include + +using namespace metal; + +struct UBO1 +{ + int4 c; + int4 d; +}; + +struct UBO2 +{ + uint4 e; + uint4 f; +}; + +struct UBO0 +{ + float4 a; + float4 b; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(constant UBO1& _14 [[buffer(0)]], constant UBO2& _29 [[buffer(1)]], constant UBO0& _41 [[buffer(2)]]) +{ + main0_out out = {}; + out.FragColor = ((((float4(_14.c) + float4(_14.d)) + float4(_29.e)) + float4(_29.f)) + _41.a) + _41.b; + return out; +} + diff --git a/reference/opt/shaders-msl/frag/basic.frag b/reference/opt/shaders-msl/frag/basic.frag new file mode 100644 index 0000000000..4d33ee7bca --- /dev/null +++ b/reference/opt/shaders-msl/frag/basic.frag @@ -0,0 +1,23 @@ +#include +#include + +using namespace metal; + +struct main0_in +{ + float2 vTex [[user(locn1)]]; + float4 vColor [[user(locn0)]]; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], texture2d uTex [[texture(0)]], sampler uTexSmplr [[sampler(0)]]) +{ + main0_out out = {}; + out.FragColor = in.vColor * uTex.sample(uTexSmplr, in.vTex); + return out; +} + diff --git a/reference/opt/shaders-msl/frag/bitcasting.frag b/reference/opt/shaders-msl/frag/bitcasting.frag new file mode 100644 index 0000000000..659d320e9f --- /dev/null +++ b/reference/opt/shaders-msl/frag/bitcasting.frag @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_in +{ + float4 VertGeom [[user(locn0)]]; +}; + +struct main0_out +{ + float4 FragColor0 [[color(0)]]; + float4 FragColor1 [[color(1)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], texture2d TextureBase [[texture(0)]], texture2d TextureDetail [[texture(1)]], sampler TextureBaseSmplr [[sampler(0)]], sampler TextureDetailSmplr [[sampler(1)]]) +{ + main0_out out = {}; + float4 _20 = TextureBase.sample(TextureBaseSmplr, in.VertGeom.xy); + float4 _31 = TextureDetail.sample(TextureDetailSmplr, in.VertGeom.xy, int2(3, 2)); + out.FragColor0 = as_type(as_type(_20)) * as_type(as_type(_31)); + out.FragColor1 = as_type(as_type(_20)) * as_type(as_type(_31)); + return out; +} + diff --git a/reference/opt/shaders-msl/frag/builtins.frag b/reference/opt/shaders-msl/frag/builtins.frag new file mode 100644 index 0000000000..9283d1a66b --- /dev/null +++ b/reference/opt/shaders-msl/frag/builtins.frag @@ -0,0 +1,24 @@ +#include +#include + +using namespace metal; + +struct main0_in +{ + float4 vColor [[user(locn0)]]; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; + float gl_FragDepth [[depth(any)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], float4 gl_FragCoord [[position]]) +{ + main0_out out = {}; + out.FragColor = gl_FragCoord + in.vColor; + out.gl_FragDepth = 0.5; + return out; +} + diff --git a/reference/opt/shaders-msl/frag/composite-extract-forced-temporary.frag b/reference/opt/shaders-msl/frag/composite-extract-forced-temporary.frag new file mode 100644 index 0000000000..5539c2508f --- /dev/null +++ b/reference/opt/shaders-msl/frag/composite-extract-forced-temporary.frag @@ -0,0 +1,24 @@ +#include +#include + +using namespace metal; + +struct main0_in +{ + float2 vTexCoord [[user(locn0)]]; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], texture2d Texture [[texture(0)]], sampler TextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 _19 = Texture.sample(TextureSmplr, in.vTexCoord); + float _22 = _19.x; + out.FragColor = float4(_22 * _22); + return out; +} + diff --git a/reference/opt/shaders-msl/frag/constant-array.frag b/reference/opt/shaders-msl/frag/constant-array.frag new file mode 100644 index 0000000000..7a9a0dea1c --- /dev/null +++ b/reference/opt/shaders-msl/frag/constant-array.frag @@ -0,0 +1,31 @@ +#include +#include + +using namespace metal; + +struct Foobar +{ + float a; + float b; +}; + +struct main0_in +{ + int index [[user(locn0)]]; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + float4 indexable[3] = {float4(1.0), float4(2.0), float4(3.0)}; + float4 indexable_1[2][2] = {{float4(1.0), float4(2.0)}, {float4(8.0), float4(10.0)}}; + Foobar indexable_2[2] = {{10.0, 40.0}, {90.0, 70.0}}; + out.FragColor = ((indexable[in.index] + (indexable_1[in.index][in.index + 1])) + float4(10.0 + 20.0)) + float4(indexable_2[in.index].a + indexable_2[in.index].b); + return out; +} + diff --git a/reference/opt/shaders-msl/frag/constant-composites.frag b/reference/opt/shaders-msl/frag/constant-composites.frag new file mode 100644 index 0000000000..1962db1752 --- /dev/null +++ b/reference/opt/shaders-msl/frag/constant-composites.frag @@ -0,0 +1,31 @@ +#include +#include + +using namespace metal; + +struct Foo +{ + float a; + float b; +}; + +struct main0_in +{ + int line [[user(locn0)]]; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + float lut[4] = {1.0, 4.0, 3.0, 2.0}; + Foo foos[2] = {{10.0, 20.0}, {30.0, 40.0}}; + out.FragColor = float4(lut[in.line]); + out.FragColor += float4(foos[in.line].a * (foos[1 - in.line].a)); + return out; +} + diff --git a/reference/opt/shaders-msl/frag/false-loop-init.frag b/reference/opt/shaders-msl/frag/false-loop-init.frag new file mode 100644 index 0000000000..c67bb9d396 --- /dev/null +++ b/reference/opt/shaders-msl/frag/false-loop-init.frag @@ -0,0 +1,38 @@ +#include +#include + +using namespace metal; + +constant uint _49 = {}; + +struct main0_in +{ + float4 accum [[user(locn0)]]; +}; + +struct main0_out +{ + float4 result [[color(0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.result = float4(0.0); + uint _51; + uint _50; + for (int _48 = 0; _48 < 4; _48 += int(_51), _50 = _51) + { + if (in.accum.y > 10.0) + { + _51 = 40u; + } + else + { + _51 = 30u; + } + out.result += in.accum; + } + return out; +} + diff --git a/reference/opt/shaders-msl/frag/flush_params.frag b/reference/opt/shaders-msl/frag/flush_params.frag new file mode 100644 index 0000000000..059167fd4b --- /dev/null +++ b/reference/opt/shaders-msl/frag/flush_params.frag @@ -0,0 +1,22 @@ +#include +#include + +using namespace metal; + +struct Structy +{ + float4 c; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0() +{ + main0_out out = {}; + out.FragColor = float4(10.0); + return out; +} + diff --git a/reference/opt/shaders-msl/frag/for-loop-init.frag b/reference/opt/shaders-msl/frag/for-loop-init.frag new file mode 100644 index 0000000000..0e5c92c7e5 --- /dev/null +++ b/reference/opt/shaders-msl/frag/for-loop-init.frag @@ -0,0 +1,57 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + int FragColor [[color(0)]]; +}; + +fragment main0_out main0() +{ + main0_out out = {}; + out.FragColor = 16; + for (int _140 = 0; _140 < 25; _140++) + { + out.FragColor += 10; + } + for (int _141 = 1; _141 < 30; _141++) + { + out.FragColor += 11; + } + int _142; + _142 = 0; + for (; _142 < 20; _142++) + { + out.FragColor += 12; + } + int _62 = _142 + 3; + out.FragColor += _62; + if (_62 == 40) + { + for (int _143 = 0; _143 < 40; _143++) + { + out.FragColor += 13; + } + return out; + } + else + { + out.FragColor += _62; + } + int2 _144; + _144 = int2(0); + int2 _139; + for (; _144.x < 10; _139 = _144, _139.x = _144.x + 4, _144 = _139) + { + out.FragColor += _144.y; + } + for (int _145 = _62; _145 < 40; _145++) + { + out.FragColor += _145; + } + out.FragColor += _62; + return out; +} + diff --git a/reference/opt/shaders-msl/frag/in_block.frag b/reference/opt/shaders-msl/frag/in_block.frag new file mode 100644 index 0000000000..43b4a05897 --- /dev/null +++ b/reference/opt/shaders-msl/frag/in_block.frag @@ -0,0 +1,23 @@ +#include +#include + +using namespace metal; + +struct main0_in +{ + float4 VertexOut_color2 [[user(locn3)]]; + float4 VertexOut_color [[user(locn2)]]; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.FragColor = in.VertexOut_color + in.VertexOut_color2; + return out; +} + diff --git a/reference/opt/shaders-msl/frag/in_block_assign.noopt.frag b/reference/opt/shaders-msl/frag/in_block_assign.noopt.frag new file mode 100644 index 0000000000..d06863d99c --- /dev/null +++ b/reference/opt/shaders-msl/frag/in_block_assign.noopt.frag @@ -0,0 +1,30 @@ +#include +#include + +using namespace metal; + +struct VOUT +{ + float4 a; +}; + +struct main0_in +{ + float4 VOUT_a [[user(locn0)]]; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + VOUT tmp; + tmp.a = in.VOUT_a; + tmp.a += float4(1.0); + out.FragColor = tmp.a; + return out; +} + diff --git a/reference/opt/shaders-msl/frag/mix.frag b/reference/opt/shaders-msl/frag/mix.frag new file mode 100644 index 0000000000..9c9b8398cf --- /dev/null +++ b/reference/opt/shaders-msl/frag/mix.frag @@ -0,0 +1,29 @@ +#include +#include + +using namespace metal; + +struct main0_in +{ + float vIn3 [[user(locn3)]]; + float vIn2 [[user(locn2)]]; + float4 vIn1 [[user(locn1)]]; + float4 vIn0 [[user(locn0)]]; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.FragColor = float4(bool4(false, true, false, false).x ? in.vIn1.x : in.vIn0.x, bool4(false, true, false, false).y ? in.vIn1.y : in.vIn0.y, bool4(false, true, false, false).z ? in.vIn1.z : in.vIn0.z, bool4(false, true, false, false).w ? in.vIn1.w : in.vIn0.w); + out.FragColor = float4(true ? in.vIn3 : in.vIn2); + bool4 _37 = bool4(true); + out.FragColor = float4(_37.x ? in.vIn0.x : in.vIn1.x, _37.y ? in.vIn0.y : in.vIn1.y, _37.z ? in.vIn0.z : in.vIn1.z, _37.w ? in.vIn0.w : in.vIn1.w); + out.FragColor = float4(true ? in.vIn2 : in.vIn3); + return out; +} + diff --git a/reference/opt/shaders-msl/frag/pls.frag b/reference/opt/shaders-msl/frag/pls.frag new file mode 100644 index 0000000000..42b5d2bf59 --- /dev/null +++ b/reference/opt/shaders-msl/frag/pls.frag @@ -0,0 +1,31 @@ +#include +#include + +using namespace metal; + +struct main0_in +{ + float4 PLSIn3 [[user(locn3)]]; + float4 PLSIn2 [[user(locn2)]]; + float4 PLSIn1 [[user(locn1)]]; + float4 PLSIn0 [[user(locn0)]]; +}; + +struct main0_out +{ + float4 PLSOut0 [[color(0)]]; + float4 PLSOut1 [[color(1)]]; + float4 PLSOut2 [[color(2)]]; + float4 PLSOut3 [[color(3)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.PLSOut0 = in.PLSIn0 * 2.0; + out.PLSOut1 = in.PLSIn1 * 6.0; + out.PLSOut2 = in.PLSIn2 * 7.0; + out.PLSOut3 = in.PLSIn3 * 4.0; + return out; +} + diff --git a/reference/opt/shaders-msl/frag/sampler-ms.frag b/reference/opt/shaders-msl/frag/sampler-ms.frag new file mode 100644 index 0000000000..8245ed8263 --- /dev/null +++ b/reference/opt/shaders-msl/frag/sampler-ms.frag @@ -0,0 +1,18 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(texture2d_ms uSampler [[texture(0)]], sampler uSamplerSmplr [[sampler(0)]], float4 gl_FragCoord [[position]]) +{ + main0_out out = {}; + int2 _17 = int2(gl_FragCoord.xy); + out.FragColor = ((uSampler.read(uint2(_17), 0) + uSampler.read(uint2(_17), 1)) + uSampler.read(uint2(_17), 2)) + uSampler.read(uint2(_17), 3); + return out; +} + diff --git a/reference/opt/shaders-msl/frag/sampler.frag b/reference/opt/shaders-msl/frag/sampler.frag new file mode 100644 index 0000000000..4d33ee7bca --- /dev/null +++ b/reference/opt/shaders-msl/frag/sampler.frag @@ -0,0 +1,23 @@ +#include +#include + +using namespace metal; + +struct main0_in +{ + float2 vTex [[user(locn1)]]; + float4 vColor [[user(locn0)]]; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], texture2d uTex [[texture(0)]], sampler uTexSmplr [[sampler(0)]]) +{ + main0_out out = {}; + out.FragColor = in.vColor * uTex.sample(uTexSmplr, in.vTex); + return out; +} + diff --git a/reference/opt/shaders-msl/frag/separate-image-sampler-argument.frag b/reference/opt/shaders-msl/frag/separate-image-sampler-argument.frag new file mode 100644 index 0000000000..e576b49e7e --- /dev/null +++ b/reference/opt/shaders-msl/frag/separate-image-sampler-argument.frag @@ -0,0 +1,17 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(texture2d uDepth [[texture(0)]], sampler uSampler [[sampler(0)]]) +{ + main0_out out = {}; + out.FragColor = uDepth.sample(uSampler, float2(0.5)); + return out; +} + diff --git a/reference/opt/shaders-msl/frag/swizzle.frag b/reference/opt/shaders-msl/frag/swizzle.frag new file mode 100644 index 0000000000..eb46111f00 --- /dev/null +++ b/reference/opt/shaders-msl/frag/swizzle.frag @@ -0,0 +1,28 @@ +#include +#include + +using namespace metal; + +struct main0_in +{ + float2 vUV [[user(locn2)]]; + float3 vNormal [[user(locn1)]]; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], texture2d samp [[texture(0)]], sampler sampSmplr [[sampler(0)]]) +{ + main0_out out = {}; + out.FragColor = float4(samp.sample(sampSmplr, in.vUV).xyz, 1.0); + out.FragColor = float4(samp.sample(sampSmplr, in.vUV).xz, 1.0, 4.0); + out.FragColor = float4(samp.sample(sampSmplr, in.vUV).xx, samp.sample(sampSmplr, (in.vUV + float2(0.100000001490116119384765625))).yy); + out.FragColor = float4(in.vNormal, 1.0); + out.FragColor = float4(in.vNormal + float3(1.7999999523162841796875), 1.0); + out.FragColor = float4(in.vUV, in.vUV + float2(1.7999999523162841796875)); + return out; +} + diff --git a/reference/opt/shaders-msl/frag/texture-proj-shadow.frag b/reference/opt/shaders-msl/frag/texture-proj-shadow.frag new file mode 100644 index 0000000000..8b9b03a59e --- /dev/null +++ b/reference/opt/shaders-msl/frag/texture-proj-shadow.frag @@ -0,0 +1,29 @@ +#include +#include + +using namespace metal; + +struct main0_in +{ + float2 vClip2 [[user(locn2)]]; + float4 vClip4 [[user(locn1)]]; + float3 vClip3 [[user(locn0)]]; +}; + +struct main0_out +{ + float FragColor [[color(0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], depth2d uShadow2D [[texture(0)]], texture1d uSampler1D [[texture(1)]], texture2d uSampler2D [[texture(2)]], texture3d uSampler3D [[texture(3)]], sampler uShadow2DSmplr [[sampler(0)]], sampler uSampler1DSmplr [[sampler(1)]], sampler uSampler2DSmplr [[sampler(2)]], sampler uSampler3DSmplr [[sampler(3)]]) +{ + main0_out out = {}; + float4 _20 = in.vClip4; + _20.z = in.vClip4.w; + out.FragColor = uShadow2D.sample_compare(uShadow2DSmplr, _20.xy / _20.z, in.vClip4.z); + out.FragColor = uSampler1D.sample(uSampler1DSmplr, in.vClip2.x / in.vClip2.y).x; + out.FragColor = uSampler2D.sample(uSampler2DSmplr, in.vClip3.xy / in.vClip3.z).x; + out.FragColor = uSampler3D.sample(uSampler3DSmplr, in.vClip4.xyz / in.vClip4.w).x; + return out; +} + diff --git a/reference/opt/shaders-msl/frag/ubo_layout.frag b/reference/opt/shaders-msl/frag/ubo_layout.frag new file mode 100644 index 0000000000..8c03e33b39 --- /dev/null +++ b/reference/opt/shaders-msl/frag/ubo_layout.frag @@ -0,0 +1,32 @@ +#include +#include + +using namespace metal; + +struct Str +{ + float4x4 foo; +}; + +struct UBO1 +{ + Str foo; +}; + +struct UBO2 +{ + Str foo; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(constant UBO1& ubo1 [[buffer(0)]], constant UBO2& ubo0 [[buffer(1)]]) +{ + main0_out out = {}; + out.FragColor = transpose(ubo1.foo.foo)[0] + ubo0.foo.foo[0]; + return out; +} + diff --git a/reference/opt/shaders-msl/frag/unary-enclose.frag b/reference/opt/shaders-msl/frag/unary-enclose.frag new file mode 100644 index 0000000000..7437f1dfe8 --- /dev/null +++ b/reference/opt/shaders-msl/frag/unary-enclose.frag @@ -0,0 +1,22 @@ +#include +#include + +using namespace metal; + +struct main0_in +{ + float4 vIn [[user(locn0)]]; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.FragColor = -(-in.vIn); + return out; +} + diff --git a/reference/opt/shaders-msl/legacy/vert/transpose.legacy.vert b/reference/opt/shaders-msl/legacy/vert/transpose.legacy.vert new file mode 100644 index 0000000000..b28067e589 --- /dev/null +++ b/reference/opt/shaders-msl/legacy/vert/transpose.legacy.vert @@ -0,0 +1,29 @@ +#include +#include + +using namespace metal; + +struct Buffer +{ + float4x4 MVPRowMajor; + float4x4 MVPColMajor; + float4x4 M; +}; + +struct main0_in +{ + float4 Position [[attribute(0)]]; +}; + +struct main0_out +{ + float4 gl_Position [[position]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]], constant Buffer& _13 [[buffer(0)]]) +{ + main0_out out = {}; + out.gl_Position = (((_13.M * (in.Position * _13.MVPRowMajor)) + (_13.M * (_13.MVPColMajor * in.Position))) + (_13.M * (_13.MVPRowMajor * in.Position))) + (_13.M * (in.Position * _13.MVPColMajor)); + return out; +} + diff --git a/reference/opt/shaders-msl/vert/basic.vert b/reference/opt/shaders-msl/vert/basic.vert new file mode 100644 index 0000000000..1592b5c5cf --- /dev/null +++ b/reference/opt/shaders-msl/vert/basic.vert @@ -0,0 +1,30 @@ +#include +#include + +using namespace metal; + +struct UBO +{ + float4x4 uMVP; +}; + +struct main0_in +{ + float3 aNormal [[attribute(1)]]; + float4 aVertex [[attribute(0)]]; +}; + +struct main0_out +{ + float3 vNormal [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _16 [[buffer(0)]]) +{ + main0_out out = {}; + out.gl_Position = _16.uMVP * in.aVertex; + out.vNormal = in.aNormal; + return out; +} + diff --git a/reference/opt/shaders-msl/vert/copy.flatten.vert b/reference/opt/shaders-msl/vert/copy.flatten.vert new file mode 100644 index 0000000000..dc87c849dc --- /dev/null +++ b/reference/opt/shaders-msl/vert/copy.flatten.vert @@ -0,0 +1,43 @@ +#include +#include + +using namespace metal; + +struct Light +{ + packed_float3 Position; + float Radius; + float4 Color; +}; + +struct UBO +{ + float4x4 uMVP; + Light lights[4]; +}; + +struct main0_in +{ + float3 aNormal [[attribute(1)]]; + float4 aVertex [[attribute(0)]]; +}; + +struct main0_out +{ + float4 vColor [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _21 [[buffer(0)]]) +{ + main0_out out = {}; + out.gl_Position = _21.uMVP * in.aVertex; + out.vColor = float4(0.0); + for (int _103 = 0; _103 < 4; _103++) + { + float3 _68 = in.aVertex.xyz - _21.lights[_103].Position; + out.vColor += ((_21.lights[_103].Color * clamp(1.0 - (length(_68) / _21.lights[_103].Radius), 0.0, 1.0)) * dot(in.aNormal, normalize(_68))); + } + return out; +} + diff --git a/reference/opt/shaders-msl/vert/dynamic.flatten.vert b/reference/opt/shaders-msl/vert/dynamic.flatten.vert new file mode 100644 index 0000000000..eb38ab4fd1 --- /dev/null +++ b/reference/opt/shaders-msl/vert/dynamic.flatten.vert @@ -0,0 +1,43 @@ +#include +#include + +using namespace metal; + +struct Light +{ + packed_float3 Position; + float Radius; + float4 Color; +}; + +struct UBO +{ + float4x4 uMVP; + Light lights[4]; +}; + +struct main0_in +{ + float3 aNormal [[attribute(1)]]; + float4 aVertex [[attribute(0)]]; +}; + +struct main0_out +{ + float4 vColor [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _21 [[buffer(0)]]) +{ + main0_out out = {}; + out.gl_Position = _21.uMVP * in.aVertex; + out.vColor = float4(0.0); + for (int _82 = 0; _82 < 4; _82++) + { + float3 _54 = in.aVertex.xyz - _21.lights[_82].Position; + out.vColor += ((_21.lights[_82].Color * clamp(1.0 - (length(_54) / _21.lights[_82].Radius), 0.0, 1.0)) * dot(in.aNormal, normalize(_54))); + } + return out; +} + diff --git a/reference/opt/shaders-msl/vert/functions.vert b/reference/opt/shaders-msl/vert/functions.vert new file mode 100644 index 0000000000..8ec2484c3e --- /dev/null +++ b/reference/opt/shaders-msl/vert/functions.vert @@ -0,0 +1,119 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct UBO +{ + float4x4 uMVP; + float3 rotDeg; + float3 rotRad; + int2 bits; +}; + +struct main0_in +{ + float3 aNormal [[attribute(1)]]; + float4 aVertex [[attribute(0)]]; +}; + +struct main0_out +{ + float3 vNormal [[user(locn0)]]; + float3 vRotDeg [[user(locn1)]]; + float3 vRotRad [[user(locn2)]]; + int2 vLSB [[user(locn3)]]; + int2 vMSB [[user(locn4)]]; + float4 gl_Position [[position]]; +}; + +// Implementation of the GLSL radians() function +template +T radians(T d) +{ + return d * 0.01745329251; +} + +// Implementation of the GLSL degrees() function +template +T degrees(T r) +{ + return r * 57.2957795131; +} + +// Implementation of the GLSL findLSB() function +template +T findLSB(T x) +{ + return select(ctz(x), T(-1), x == T(0)); +} + +// Implementation of the signed GLSL findMSB() function +template +T findSMSB(T x) +{ + T v = select(x, T(-1) - x, x < T(0)); + return select(clz(T(0)) - (clz(v) + T(1)), T(-1), v == T(0)); +} + +// 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; +} + +vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _18 [[buffer(0)]]) +{ + main0_out out = {}; + out.gl_Position = spvInverse4x4(_18.uMVP) * in.aVertex; + out.vNormal = in.aNormal; + out.vRotDeg = degrees(_18.rotRad); + out.vRotRad = radians(_18.rotDeg); + out.vLSB = findLSB(_18.bits); + out.vMSB = findSMSB(_18.bits); + return out; +} + diff --git a/reference/opt/shaders-msl/vert/out_block.vert b/reference/opt/shaders-msl/vert/out_block.vert new file mode 100644 index 0000000000..3ae18387a6 --- /dev/null +++ b/reference/opt/shaders-msl/vert/out_block.vert @@ -0,0 +1,32 @@ +#include +#include + +using namespace metal; + +struct Transform +{ + float4x4 transform; +}; + +struct main0_in +{ + float4 color [[attribute(1)]]; + float3 position [[attribute(0)]]; +}; + +struct main0_out +{ + float4 VertexOut_color [[user(locn2)]]; + float4 VertexOut_color2 [[user(locn3)]]; + float4 gl_Position [[position]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]], constant Transform& block [[buffer(0)]]) +{ + main0_out out = {}; + out.gl_Position = block.transform * float4(in.position, 1.0); + out.VertexOut_color = in.color; + out.VertexOut_color2 = in.color + float4(1.0); + return out; +} + diff --git a/reference/opt/shaders-msl/vert/pointsize.vert b/reference/opt/shaders-msl/vert/pointsize.vert new file mode 100644 index 0000000000..faf828b4d3 --- /dev/null +++ b/reference/opt/shaders-msl/vert/pointsize.vert @@ -0,0 +1,33 @@ +#include +#include + +using namespace metal; + +struct params +{ + float4x4 mvp; + float psize; +}; + +struct main0_in +{ + float4 color0 [[attribute(1)]]; + float4 position [[attribute(0)]]; +}; + +struct main0_out +{ + float4 color [[user(locn0)]]; + float4 gl_Position [[position]]; + float gl_PointSize [[point_size]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]], constant params& _19 [[buffer(0)]]) +{ + main0_out out = {}; + out.gl_Position = _19.mvp * in.position; + out.gl_PointSize = _19.psize; + out.color = in.color0; + return out; +} + diff --git a/reference/opt/shaders-msl/vert/texture_buffer.vert b/reference/opt/shaders-msl/vert/texture_buffer.vert new file mode 100644 index 0000000000..690757b830 --- /dev/null +++ b/reference/opt/shaders-msl/vert/texture_buffer.vert @@ -0,0 +1,17 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 gl_Position [[position]]; +}; + +vertex main0_out main0(texture2d uSamp [[texture(0)]], texture2d uSampo [[texture(1)]]) +{ + main0_out out = {}; + out.gl_Position = uSamp.read(uint2(10, 0)) + uSampo.read(uint2(100, 0)); + return out; +} + diff --git a/reference/opt/shaders-msl/vert/ubo.alignment.vert b/reference/opt/shaders-msl/vert/ubo.alignment.vert new file mode 100644 index 0000000000..6e48ae0e42 --- /dev/null +++ b/reference/opt/shaders-msl/vert/ubo.alignment.vert @@ -0,0 +1,38 @@ +#include +#include + +using namespace metal; + +struct UBO +{ + float4x4 mvp; + float2 targSize; + char pad2[8]; + packed_float3 color; + float opacity; +}; + +struct main0_in +{ + float3 aNormal [[attribute(1)]]; + float4 aVertex [[attribute(0)]]; +}; + +struct main0_out +{ + float3 vNormal [[user(locn0)]]; + float3 vColor [[user(locn1)]]; + float2 vSize [[user(locn2)]]; + float4 gl_Position [[position]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _18 [[buffer(0)]]) +{ + main0_out out = {}; + out.gl_Position = _18.mvp * in.aVertex; + out.vNormal = in.aNormal; + out.vColor = _18.color * _18.opacity; + out.vSize = _18.targSize * _18.opacity; + return out; +} + diff --git a/reference/opt/shaders-msl/vert/ubo.vert b/reference/opt/shaders-msl/vert/ubo.vert new file mode 100644 index 0000000000..4a1adcd7f6 --- /dev/null +++ b/reference/opt/shaders-msl/vert/ubo.vert @@ -0,0 +1,30 @@ +#include +#include + +using namespace metal; + +struct UBO +{ + float4x4 mvp; +}; + +struct main0_in +{ + float3 aNormal [[attribute(1)]]; + float4 aVertex [[attribute(0)]]; +}; + +struct main0_out +{ + float3 vNormal [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _16 [[buffer(0)]]) +{ + main0_out out = {}; + out.gl_Position = _16.mvp * in.aVertex; + out.vNormal = in.aNormal; + return out; +} + diff --git a/reference/opt/shaders-msl/vulkan/frag/push-constant.vk.frag b/reference/opt/shaders-msl/vulkan/frag/push-constant.vk.frag new file mode 100644 index 0000000000..bc97e3cc51 --- /dev/null +++ b/reference/opt/shaders-msl/vulkan/frag/push-constant.vk.frag @@ -0,0 +1,28 @@ +#include +#include + +using namespace metal; + +struct PushConstants +{ + float4 value0; + float4 value1; +}; + +struct main0_in +{ + float4 vColor [[user(locn0)]]; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], constant PushConstants& push [[buffer(0)]]) +{ + main0_out out = {}; + out.FragColor = (in.vColor + push.value0) + push.value1; + return out; +} + diff --git a/reference/opt/shaders-msl/vulkan/frag/spec-constant.vk.frag b/reference/opt/shaders-msl/vulkan/frag/spec-constant.vk.frag new file mode 100644 index 0000000000..aee290f5a2 --- /dev/null +++ b/reference/opt/shaders-msl/vulkan/frag/spec-constant.vk.frag @@ -0,0 +1,22 @@ +#include +#include + +using namespace metal; + +constant float a_tmp [[function_constant(1)]]; +constant float a = is_function_constant_defined(a_tmp) ? a_tmp : 1.0; +constant float b_tmp [[function_constant(2)]]; +constant float b = is_function_constant_defined(b_tmp) ? b_tmp : 2.0; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0() +{ + main0_out out = {}; + out.FragColor = float4(a + b); + return out; +} + diff --git a/reference/opt/shaders-msl/vulkan/vert/vulkan-vertex.vk.vert b/reference/opt/shaders-msl/vulkan/vert/vulkan-vertex.vk.vert new file mode 100644 index 0000000000..53e26e4a8e --- /dev/null +++ b/reference/opt/shaders-msl/vulkan/vert/vulkan-vertex.vk.vert @@ -0,0 +1,17 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 gl_Position [[position]]; +}; + +vertex main0_out main0(uint gl_VertexIndex [[vertex_id]], uint gl_InstanceIndex [[instance_id]]) +{ + main0_out out = {}; + out.gl_Position = float4(1.0, 2.0, 3.0, 4.0) * float(gl_VertexIndex + gl_InstanceIndex); + return out; +} + diff --git a/reference/opt/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag b/reference/opt/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag new file mode 100644 index 0000000000..d670898481 --- /dev/null +++ b/reference/opt/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag @@ -0,0 +1,11 @@ +#version 450 +#extension GL_AMD_shader_fragment_mask : require + +layout(binding = 0) uniform sampler2DMS t; + +void main() +{ + vec4 test2 = fragmentFetchAMD(t, 4u); + uint testi2 = fragmentMaskFetchAMD(t); +} + diff --git a/reference/opt/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag.vk b/reference/opt/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag.vk new file mode 100644 index 0000000000..4aaf397a0f --- /dev/null +++ b/reference/opt/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag.vk @@ -0,0 +1,11 @@ +#version 450 +#extension GL_AMD_shader_fragment_mask : require + +layout(input_attachment_index = 0, set = 0, binding = 0) uniform subpassInputMS t; + +void main() +{ + vec4 test2 = fragmentFetchAMD(t, 4u); + uint testi2 = fragmentMaskFetchAMD(t); +} + diff --git a/reference/opt/shaders/amd/fs.invalid.frag b/reference/opt/shaders/amd/fs.invalid.frag new file mode 100644 index 0000000000..97e7bcd180 --- /dev/null +++ b/reference/opt/shaders/amd/fs.invalid.frag @@ -0,0 +1,15 @@ +#version 450 +#extension GL_AMD_shader_fragment_mask : require +#extension GL_AMD_shader_explicit_vertex_parameter : require + +uniform sampler2DMS texture1; + +layout(location = 0) in vec4 vary; + +void main() +{ + uint testi1 = fragmentMaskFetchAMD(texture1, ivec2(0)); + vec4 test1 = fragmentFetchAMD(texture1, ivec2(1), 2u); + vec4 pos = interpolateAtVertexAMD(vary, 0u); +} + diff --git a/reference/opt/shaders/amd/gcn_shader.comp b/reference/opt/shaders/amd/gcn_shader.comp new file mode 100644 index 0000000000..85851de5f9 --- /dev/null +++ b/reference/opt/shaders/amd/gcn_shader.comp @@ -0,0 +1,8 @@ +#version 450 +#extension GL_ARB_gpu_shader_int64 : require +layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; + +void main() +{ +} + diff --git a/reference/opt/shaders/amd/shader_ballot.comp b/reference/opt/shaders/amd/shader_ballot.comp new file mode 100644 index 0000000000..8bdbfc9c0d --- /dev/null +++ b/reference/opt/shaders/amd/shader_ballot.comp @@ -0,0 +1,26 @@ +#version 450 +#extension GL_ARB_gpu_shader_int64 : require +#extension GL_ARB_shader_ballot : require +#extension GL_AMD_shader_ballot : require +layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) buffer inputData +{ + float inputDataArray[]; +} _12; + +layout(binding = 1, std430) buffer outputData +{ + float outputDataArray[]; +} _74; + +void main() +{ + float _25 = _12.inputDataArray[gl_LocalInvocationID.x]; + bool _31 = _25 > 0.0; + if (_31) + { + _74.outputDataArray[mbcntAMD(packUint2x32(uvec2(unpackUint2x32(ballotARB(_31)).xy)))] = _25; + } +} + diff --git a/reference/opt/shaders/amd/shader_ballot_nonuniform_invocations.invalid.comp b/reference/opt/shaders/amd/shader_ballot_nonuniform_invocations.invalid.comp new file mode 100644 index 0000000000..a14343ae12 --- /dev/null +++ b/reference/opt/shaders/amd/shader_ballot_nonuniform_invocations.invalid.comp @@ -0,0 +1,11 @@ +#version 450 +#extension GL_AMD_shader_ballot : require +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +void main() +{ + float addInvocations = addInvocationsNonUniformAMD(0.0); + int minInvocations = minInvocationsNonUniformAMD(1); + uint maxInvocations = uint(maxInvocationsNonUniformAMD(4)); +} + diff --git a/reference/opt/shaders/amd/shader_group_vote.comp b/reference/opt/shaders/amd/shader_group_vote.comp new file mode 100644 index 0000000000..77ea03495f --- /dev/null +++ b/reference/opt/shaders/amd/shader_group_vote.comp @@ -0,0 +1,7 @@ +#version 450 +layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; + +void main() +{ +} + diff --git a/reference/opt/shaders/amd/shader_trinary_minmax.comp b/reference/opt/shaders/amd/shader_trinary_minmax.comp new file mode 100644 index 0000000000..77ea03495f --- /dev/null +++ b/reference/opt/shaders/amd/shader_trinary_minmax.comp @@ -0,0 +1,7 @@ +#version 450 +layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; + +void main() +{ +} + diff --git a/reference/opt/shaders/asm/comp/bitcast_iadd.asm.comp b/reference/opt/shaders/asm/comp/bitcast_iadd.asm.comp new file mode 100644 index 0000000000..bed2dffccb --- /dev/null +++ b/reference/opt/shaders/asm/comp/bitcast_iadd.asm.comp @@ -0,0 +1,27 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) restrict buffer _3_5 +{ + ivec4 _m0; + uvec4 _m1; +} _5; + +layout(binding = 1, std430) restrict buffer _4_6 +{ + uvec4 _m0; + ivec4 _m1; +} _6; + +void main() +{ + _6._m0 = _5._m1 + uvec4(_5._m0); + _6._m0 = uvec4(_5._m0) + _5._m1; + _6._m0 = _5._m1 + _5._m1; + _6._m0 = uvec4(_5._m0 + _5._m0); + _6._m1 = ivec4(_5._m1 + _5._m1); + _6._m1 = _5._m0 + _5._m0; + _6._m1 = ivec4(_5._m1) + _5._m0; + _6._m1 = _5._m0 + ivec4(_5._m1); +} + diff --git a/reference/opt/shaders/asm/comp/bitcast_iequal.asm.comp b/reference/opt/shaders/asm/comp/bitcast_iequal.asm.comp new file mode 100644 index 0000000000..79398b404b --- /dev/null +++ b/reference/opt/shaders/asm/comp/bitcast_iequal.asm.comp @@ -0,0 +1,31 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) buffer _3_5 +{ + ivec4 _m0; + uvec4 _m1; +} _5; + +layout(binding = 1, std430) buffer _4_6 +{ + uvec4 _m0; + ivec4 _m1; +} _6; + +void main() +{ + bvec4 _34 = equal(ivec4(_5._m1), _5._m0); + bvec4 _35 = equal(_5._m0, ivec4(_5._m1)); + bvec4 _36 = equal(_5._m1, _5._m1); + bvec4 _37 = equal(_5._m0, _5._m0); + _6._m0 = mix(uvec4(0u), uvec4(1u), _34); + _6._m0 = mix(uvec4(0u), uvec4(1u), _35); + _6._m0 = mix(uvec4(0u), uvec4(1u), _36); + _6._m0 = mix(uvec4(0u), uvec4(1u), _37); + _6._m1 = mix(ivec4(0), ivec4(1), _34); + _6._m1 = mix(ivec4(0), ivec4(1), _35); + _6._m1 = mix(ivec4(0), ivec4(1), _36); + _6._m1 = mix(ivec4(0), ivec4(1), _37); +} + diff --git a/reference/opt/shaders/asm/comp/bitcast_sar.asm.comp b/reference/opt/shaders/asm/comp/bitcast_sar.asm.comp new file mode 100644 index 0000000000..42a4ed0233 --- /dev/null +++ b/reference/opt/shaders/asm/comp/bitcast_sar.asm.comp @@ -0,0 +1,27 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) buffer _3_5 +{ + ivec4 _m0; + uvec4 _m1; +} _5; + +layout(binding = 1, std430) buffer _4_6 +{ + uvec4 _m0; + ivec4 _m1; +} _6; + +void main() +{ + _6._m0 = uvec4(ivec4(_5._m1) >> _5._m0); + _6._m0 = uvec4(_5._m0 >> ivec4(_5._m1)); + _6._m0 = uvec4(ivec4(_5._m1) >> ivec4(_5._m1)); + _6._m0 = uvec4(_5._m0 >> _5._m0); + _6._m1 = ivec4(_5._m1) >> ivec4(_5._m1); + _6._m1 = _5._m0 >> _5._m0; + _6._m1 = ivec4(_5._m1) >> _5._m0; + _6._m1 = _5._m0 >> ivec4(_5._m1); +} + diff --git a/reference/opt/shaders/asm/comp/bitcast_sdiv.asm.comp b/reference/opt/shaders/asm/comp/bitcast_sdiv.asm.comp new file mode 100644 index 0000000000..eeb97e14a2 --- /dev/null +++ b/reference/opt/shaders/asm/comp/bitcast_sdiv.asm.comp @@ -0,0 +1,27 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) buffer _3_5 +{ + ivec4 _m0; + uvec4 _m1; +} _5; + +layout(binding = 1, std430) buffer _4_6 +{ + uvec4 _m0; + ivec4 _m1; +} _6; + +void main() +{ + _6._m0 = uvec4(ivec4(_5._m1) / _5._m0); + _6._m0 = uvec4(_5._m0 / ivec4(_5._m1)); + _6._m0 = uvec4(ivec4(_5._m1) / ivec4(_5._m1)); + _6._m0 = uvec4(_5._m0 / _5._m0); + _6._m1 = ivec4(_5._m1) / ivec4(_5._m1); + _6._m1 = _5._m0 / _5._m0; + _6._m1 = ivec4(_5._m1) / _5._m0; + _6._m1 = _5._m0 / ivec4(_5._m1); +} + diff --git a/reference/opt/shaders/asm/comp/bitcast_slr.asm.comp b/reference/opt/shaders/asm/comp/bitcast_slr.asm.comp new file mode 100644 index 0000000000..25245e63eb --- /dev/null +++ b/reference/opt/shaders/asm/comp/bitcast_slr.asm.comp @@ -0,0 +1,27 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) buffer _3_5 +{ + ivec4 _m0; + uvec4 _m1; +} _5; + +layout(binding = 1, std430) buffer _4_6 +{ + uvec4 _m0; + ivec4 _m1; +} _6; + +void main() +{ + _6._m0 = _5._m1 >> uvec4(_5._m0); + _6._m0 = uvec4(_5._m0) >> _5._m1; + _6._m0 = _5._m1 >> _5._m1; + _6._m0 = uvec4(_5._m0) >> uvec4(_5._m0); + _6._m1 = ivec4(_5._m1 >> _5._m1); + _6._m1 = ivec4(uvec4(_5._m0) >> uvec4(_5._m0)); + _6._m1 = ivec4(_5._m1 >> uvec4(_5._m0)); + _6._m1 = ivec4(uvec4(_5._m0) >> _5._m1); +} + diff --git a/reference/opt/shaders/asm/comp/logical.asm.comp b/reference/opt/shaders/asm/comp/logical.asm.comp new file mode 100644 index 0000000000..124652b322 --- /dev/null +++ b/reference/opt/shaders/asm/comp/logical.asm.comp @@ -0,0 +1,7 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +void main() +{ +} + diff --git a/reference/opt/shaders/asm/comp/multiple-entry.asm.comp b/reference/opt/shaders/asm/comp/multiple-entry.asm.comp new file mode 100644 index 0000000000..6418464f19 --- /dev/null +++ b/reference/opt/shaders/asm/comp/multiple-entry.asm.comp @@ -0,0 +1,27 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) restrict buffer _6_8 +{ + ivec4 _m0; + uvec4 _m1; +} _8; + +layout(binding = 1, std430) restrict buffer _7_9 +{ + uvec4 _m0; + ivec4 _m1; +} _9; + +void main() +{ + _9._m0 = _8._m1 + uvec4(_8._m0); + _9._m0 = uvec4(_8._m0) + _8._m1; + _9._m0 = _8._m1 + _8._m1; + _9._m0 = uvec4(_8._m0 + _8._m0); + _9._m1 = ivec4(_8._m1 + _8._m1); + _9._m1 = _8._m0 + _8._m0; + _9._m1 = ivec4(_8._m1) + _8._m0; + _9._m1 = _8._m0 + ivec4(_8._m1); +} + diff --git a/reference/opt/shaders/asm/comp/name-alias.asm.invalid.comp b/reference/opt/shaders/asm/comp/name-alias.asm.invalid.comp new file mode 100644 index 0000000000..870b1df98d --- /dev/null +++ b/reference/opt/shaders/asm/comp/name-alias.asm.invalid.comp @@ -0,0 +1,37 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct alias +{ + vec3 alias[100]; +}; + +struct alias_1 +{ + vec4 alias; + vec2 alias_1[10]; + alias alias_2[2]; +}; + +struct alias_2 +{ + vec4 alias; + alias_1 alias_1; +}; + +layout(binding = 0, std430) buffer alias_3 +{ + alias_2 alias; +} alias_4; + +layout(binding = 1, std140) buffer alias_5 +{ + alias_2 alias; +} alias_6; + +void main() +{ + alias_2 alias_7 = alias_4.alias; + alias_6.alias = alias_7; +} + diff --git a/reference/opt/shaders/asm/comp/quantize.asm.comp b/reference/opt/shaders/asm/comp/quantize.asm.comp new file mode 100644 index 0000000000..c089213800 --- /dev/null +++ b/reference/opt/shaders/asm/comp/quantize.asm.comp @@ -0,0 +1,19 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) buffer SSBO0 +{ + float scalar; + vec2 vec2_val; + vec3 vec3_val; + vec4 vec4_val; +} _4; + +void main() +{ + _4.scalar = unpackHalf2x16(packHalf2x16(vec2(_4.scalar))).x; + _4.vec2_val = unpackHalf2x16(packHalf2x16(_4.vec2_val)); + _4.vec3_val = vec3(unpackHalf2x16(packHalf2x16(_4.vec3_val.xy)), unpackHalf2x16(packHalf2x16(_4.vec3_val.zz)).x); + _4.vec4_val = vec4(unpackHalf2x16(packHalf2x16(_4.vec4_val.xy)), unpackHalf2x16(packHalf2x16(_4.vec4_val.zw))); +} + diff --git a/reference/opt/shaders/asm/comp/specialization-constant-workgroup.asm.comp b/reference/opt/shaders/asm/comp/specialization-constant-workgroup.asm.comp new file mode 100644 index 0000000000..1b2285a8da --- /dev/null +++ b/reference/opt/shaders/asm/comp/specialization-constant-workgroup.asm.comp @@ -0,0 +1,13 @@ +#version 310 es +layout(local_size_x = 9, local_size_y = 20, local_size_z = 4) in; + +layout(binding = 0, std430) buffer SSBO +{ + float a; +} _4; + +void main() +{ + _4.a += 1.0; +} + diff --git a/reference/opt/shaders/asm/comp/storage-buffer-basic.asm.comp b/reference/opt/shaders/asm/comp/storage-buffer-basic.asm.comp new file mode 100644 index 0000000000..3de823fb10 --- /dev/null +++ b/reference/opt/shaders/asm/comp/storage-buffer-basic.asm.comp @@ -0,0 +1,18 @@ +#version 450 +layout(local_size_x = 1, local_size_y = 2, local_size_z = 3) in; + +layout(binding = 0, std430) buffer _6_8 +{ + float _m0[]; +} _8; + +layout(binding = 1, std430) buffer _6_9 +{ + float _m0[]; +} _9; + +void main() +{ + _8._m0[gl_WorkGroupID.x] = _9._m0[gl_WorkGroupID.x] + _8._m0[gl_WorkGroupID.x]; +} + diff --git a/reference/opt/shaders/asm/frag/composite-construct-struct-no-swizzle.asm.frag b/reference/opt/shaders/asm/frag/composite-construct-struct-no-swizzle.asm.frag new file mode 100644 index 0000000000..23af17026c --- /dev/null +++ b/reference/opt/shaders/asm/frag/composite-construct-struct-no-swizzle.asm.frag @@ -0,0 +1,18 @@ +#version 310 es +precision mediump float; +precision highp int; + +struct SwizzleTest +{ + float a; + float b; +}; + +layout(location = 0) in vec2 foo; +layout(location = 0) out float FooOut; + +void main() +{ + FooOut = foo.x + foo.y; +} + diff --git a/reference/opt/shaders/asm/frag/default-member-names.asm.frag b/reference/opt/shaders/asm/frag/default-member-names.asm.frag new file mode 100644 index 0000000000..2cf68fd201 --- /dev/null +++ b/reference/opt/shaders/asm/frag/default-member-names.asm.frag @@ -0,0 +1,33 @@ +#version 450 + +struct _9 +{ + float _m0; +}; + +struct _10 +{ + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + _9 _m12; +}; + +layout(location = 0) out vec4 _3; + +_10 _51; + +void main() +{ + _3 = vec4(_51._m0, _51._m1, _51._m2, _51._m3); +} + diff --git a/reference/opt/shaders/asm/frag/hlsl-sample-cmp-level-zero-cube.asm.frag b/reference/opt/shaders/asm/frag/hlsl-sample-cmp-level-zero-cube.asm.frag new file mode 100644 index 0000000000..924b6f656c --- /dev/null +++ b/reference/opt/shaders/asm/frag/hlsl-sample-cmp-level-zero-cube.asm.frag @@ -0,0 +1,11 @@ +#version 450 + +uniform samplerCubeShadow SPIRV_Cross_CombinedpointLightShadowMapshadowSamplerPCF; + +layout(location = 0) out float _entryPointOutput; + +void main() +{ + _entryPointOutput = textureGrad(SPIRV_Cross_CombinedpointLightShadowMapshadowSamplerPCF, vec4(vec4(0.100000001490116119384765625, 0.100000001490116119384765625, 0.100000001490116119384765625, 0.5).xyz, 0.5), vec3(0.0), vec3(0.0)); +} + diff --git a/reference/opt/shaders/asm/frag/hlsl-sample-cmp-level-zero.asm.frag b/reference/opt/shaders/asm/frag/hlsl-sample-cmp-level-zero.asm.frag new file mode 100644 index 0000000000..c4e3704e52 --- /dev/null +++ b/reference/opt/shaders/asm/frag/hlsl-sample-cmp-level-zero.asm.frag @@ -0,0 +1,14 @@ +#version 450 + +uniform sampler2DArrayShadow SPIRV_Cross_CombinedShadowMapShadowSamplerPCF; + +layout(location = 0) in vec2 texCoords; +layout(location = 1) in float cascadeIndex; +layout(location = 2) in float fragDepth; +layout(location = 0) out vec4 _entryPointOutput; + +void main() +{ + _entryPointOutput = vec4(textureGrad(SPIRV_Cross_CombinedShadowMapShadowSamplerPCF, vec4(vec4(texCoords, cascadeIndex, fragDepth).xyz, fragDepth), vec2(0.0), vec2(0.0))); +} + diff --git a/reference/opt/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag b/reference/opt/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag new file mode 100644 index 0000000000..98116cfdc7 --- /dev/null +++ b/reference/opt/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag @@ -0,0 +1,227 @@ +#version 450 + +struct VertexOutput +{ + vec4 HPosition; + vec4 Uv_EdgeDistance1; + vec4 UvStuds_EdgeDistance2; + vec4 Color; + vec4 LightPosition_Fog; + vec4 View_Depth; + vec4 Normal_SpecPower; + vec3 Tangent; + vec4 PosLightSpace_Reflectance; + float studIndex; +}; + +struct Surface +{ + vec3 albedo; + vec3 normal; + float specular; + float gloss; + float reflectance; + float opacity; +}; + +struct SurfaceInput +{ + vec4 Color; + vec2 Uv; + vec2 UvStuds; +}; + +struct Globals +{ + mat4 ViewProjection; + vec4 ViewRight; + vec4 ViewUp; + vec4 ViewDir; + vec3 CameraPosition; + vec3 AmbientColor; + vec3 Lamp0Color; + vec3 Lamp0Dir; + vec3 Lamp1Color; + vec4 FogParams; + vec3 FogColor; + vec4 LightBorder; + vec4 LightConfig0; + vec4 LightConfig1; + vec4 LightConfig2; + vec4 LightConfig3; + vec4 RefractionBias_FadeDistance_GlowFactor; + vec4 OutlineBrightness_ShadowInfo; + vec4 ShadowMatrix0; + vec4 ShadowMatrix1; + vec4 ShadowMatrix2; +}; + +struct Params +{ + vec4 LqmatFarTilingFactor; +}; + +layout(binding = 0, std140) uniform CB0 +{ + Globals CB0; +} _19; + +uniform sampler2D SPIRV_Cross_CombinedDiffuseMapTextureDiffuseMapSampler; +uniform sampler2D SPIRV_Cross_CombinedNormalMapTextureNormalMapSampler; +uniform sampler2D SPIRV_Cross_CombinedNormalDetailMapTextureNormalDetailMapSampler; +uniform sampler2D SPIRV_Cross_CombinedStudsMapTextureStudsMapSampler; +uniform sampler2D SPIRV_Cross_CombinedSpecularMapTextureSpecularMapSampler; +uniform sampler3D SPIRV_Cross_CombinedLightMapTextureLightMapSampler; +uniform sampler2D SPIRV_Cross_CombinedShadowMapTextureShadowMapSampler; +uniform samplerCube SPIRV_Cross_CombinedEnvironmentMapTextureEnvironmentMapSampler; + +layout(location = 0) in vec4 IN_Uv_EdgeDistance1; +layout(location = 1) in vec4 IN_UvStuds_EdgeDistance2; +layout(location = 2) in vec4 IN_Color; +layout(location = 3) in vec4 IN_LightPosition_Fog; +layout(location = 4) in vec4 IN_View_Depth; +layout(location = 5) in vec4 IN_Normal_SpecPower; +layout(location = 6) in vec3 IN_Tangent; +layout(location = 7) in vec4 IN_PosLightSpace_Reflectance; +layout(location = 8) in float IN_studIndex; +layout(location = 0) out vec4 _entryPointOutput; + +VertexOutput _121; +SurfaceInput _122; +vec2 _123; +vec4 _124; +Surface _125; +vec4 _192; +vec4 _219; +vec4 _297; + +void main() +{ + VertexOutput _128 = _121; + _128.HPosition = gl_FragCoord; + VertexOutput _130 = _128; + _130.Uv_EdgeDistance1 = IN_Uv_EdgeDistance1; + VertexOutput _132 = _130; + _132.UvStuds_EdgeDistance2 = IN_UvStuds_EdgeDistance2; + VertexOutput _134 = _132; + _134.Color = IN_Color; + VertexOutput _136 = _134; + _136.LightPosition_Fog = IN_LightPosition_Fog; + VertexOutput _138 = _136; + _138.View_Depth = IN_View_Depth; + VertexOutput _140 = _138; + _140.Normal_SpecPower = IN_Normal_SpecPower; + VertexOutput _142 = _140; + _142.Tangent = IN_Tangent; + VertexOutput _144 = _142; + _144.PosLightSpace_Reflectance = IN_PosLightSpace_Reflectance; + VertexOutput _146 = _144; + _146.studIndex = IN_studIndex; + SurfaceInput _147 = _122; + _147.Color = IN_Color; + SurfaceInput _149 = _147; + _149.Uv = IN_Uv_EdgeDistance1.xy; + SurfaceInput _151 = _149; + _151.UvStuds = IN_UvStuds_EdgeDistance2.xy; + SurfaceInput _156 = _151; + _156.UvStuds.y = (fract(_151.UvStuds.y) + IN_studIndex) * 0.25; + float _163 = _146.View_Depth.w * _19.CB0.RefractionBias_FadeDistance_GlowFactor.y; + float _165 = clamp(1.0 - _163, 0.0, 1.0); + vec2 _166 = IN_Uv_EdgeDistance1.xy * 1.0; + bool _173; + vec4 _193; + do + { + _173 = 0.0 == 0.0; + if (_173) + { + _193 = texture(SPIRV_Cross_CombinedDiffuseMapTextureDiffuseMapSampler, _166); + break; + } + else + { + float _180 = 1.0 / (1.0 - 0.0); + _193 = mix(texture(SPIRV_Cross_CombinedDiffuseMapTextureDiffuseMapSampler, _166 * 0.25), texture(SPIRV_Cross_CombinedDiffuseMapTextureDiffuseMapSampler, _166), vec4(clamp((clamp(1.0 - (_146.View_Depth.w * 0.00333332992158830165863037109375), 0.0, 1.0) * _180) - (0.0 * _180), 0.0, 1.0))); + break; + } + _193 = _192; + break; + } while (false); + vec4 _220; + do + { + if (_173) + { + _220 = texture(SPIRV_Cross_CombinedNormalMapTextureNormalMapSampler, _166); + break; + } + else + { + float _207 = 1.0 / (1.0 - 0.0); + _220 = mix(texture(SPIRV_Cross_CombinedNormalMapTextureNormalMapSampler, _166 * 0.25), texture(SPIRV_Cross_CombinedNormalMapTextureNormalMapSampler, _166), vec4(clamp((_165 * _207) - (0.0 * _207), 0.0, 1.0))); + break; + } + _220 = _219; + break; + } while (false); + vec2 _223 = vec2(1.0); + vec2 _224 = (_220.wy * 2.0) - _223; + vec3 _232 = vec3(_224, sqrt(clamp(1.0 + dot(-_224, _224), 0.0, 1.0))); + vec2 _240 = (texture(SPIRV_Cross_CombinedNormalDetailMapTextureNormalDetailMapSampler, _166 * 0.0).wy * 2.0) - _223; + vec2 _252 = _232.xy + (vec3(_240, sqrt(clamp(1.0 + dot(-_240, _240), 0.0, 1.0))).xy * 0.0); + vec3 _253 = vec3(_252.x, _252.y, _232.z); + vec2 _255 = _253.xy * _165; + vec3 _256 = vec3(_255.x, _255.y, _253.z); + vec3 _271 = ((IN_Color.xyz * (_193 * 1.0).xyz) * (1.0 + (_256.x * 0.300000011920928955078125))) * (texture(SPIRV_Cross_CombinedStudsMapTextureStudsMapSampler, _156.UvStuds).x * 2.0); + vec4 _298; + do + { + if (0.75 == 0.0) + { + _298 = texture(SPIRV_Cross_CombinedSpecularMapTextureSpecularMapSampler, _166); + break; + } + else + { + float _285 = 1.0 / (1.0 - 0.75); + _298 = mix(texture(SPIRV_Cross_CombinedSpecularMapTextureSpecularMapSampler, _166 * 0.25), texture(SPIRV_Cross_CombinedSpecularMapTextureSpecularMapSampler, _166), vec4(clamp((_165 * _285) - (0.75 * _285), 0.0, 1.0))); + break; + } + _298 = _297; + break; + } while (false); + vec2 _303 = mix(vec2(0.800000011920928955078125, 120.0), (_298.xy * vec2(2.0, 256.0)) + vec2(0.0, 0.00999999977648258209228515625), vec2(_165)); + Surface _304 = _125; + _304.albedo = _271; + Surface _305 = _304; + _305.normal = _256; + float _306 = _303.x; + Surface _307 = _305; + _307.specular = _306; + float _308 = _303.y; + Surface _309 = _307; + _309.gloss = _308; + float _312 = (_298.xy.y * _165) * 0.0; + Surface _313 = _309; + _313.reflectance = _312; + vec4 _318 = vec4(_271, _146.Color.w); + vec3 _329 = normalize(((IN_Tangent * _313.normal.x) + (cross(IN_Normal_SpecPower.xyz, IN_Tangent) * _313.normal.y)) + (IN_Normal_SpecPower.xyz * _313.normal.z)); + vec3 _332 = -_19.CB0.Lamp0Dir; + float _333 = dot(_329, _332); + float _357 = clamp(dot(step(_19.CB0.LightConfig3.xyz, abs(IN_LightPosition_Fog.xyz - _19.CB0.LightConfig2.xyz)), vec3(1.0)), 0.0, 1.0); + vec4 _368 = mix(texture(SPIRV_Cross_CombinedLightMapTextureLightMapSampler, IN_LightPosition_Fog.xyz.yzx - (IN_LightPosition_Fog.xyz.yzx * _357)), _19.CB0.LightBorder, vec4(_357)); + vec2 _376 = texture(SPIRV_Cross_CombinedShadowMapTextureShadowMapSampler, IN_PosLightSpace_Reflectance.xyz.xy).xy; + float _392 = (1.0 - (((step(_376.x, IN_PosLightSpace_Reflectance.xyz.z) * clamp(9.0 - (20.0 * abs(IN_PosLightSpace_Reflectance.xyz.z - 0.5)), 0.0, 1.0)) * _376.y) * _19.CB0.OutlineBrightness_ShadowInfo.w)) * _368.w; + vec3 _403 = mix(_318.xyz, texture(SPIRV_Cross_CombinedEnvironmentMapTextureEnvironmentMapSampler, reflect(-IN_View_Depth.xyz, _329)).xyz, vec3(_312)); + vec4 _404 = vec4(_403.x, _403.y, _403.z, _318.w); + vec3 _422 = (((_19.CB0.AmbientColor + (((_19.CB0.Lamp0Color * clamp(_333, 0.0, 1.0)) + (_19.CB0.Lamp1Color * max(-_333, 0.0))) * _392)) + _368.xyz) * _404.xyz) + (_19.CB0.Lamp0Color * (((step(0.0, _333) * _306) * _392) * pow(clamp(dot(_329, normalize(_332 + normalize(IN_View_Depth.xyz))), 0.0, 1.0), _308))); + vec4 _425 = vec4(_422.x, _422.y, _422.z, _124.w); + _425.w = _404.w; + vec2 _435 = min(IN_Uv_EdgeDistance1.wz, IN_UvStuds_EdgeDistance2.wz); + float _439 = min(_435.x, _435.y) / _163; + vec3 _445 = _425.xyz * clamp((clamp((_163 * _19.CB0.OutlineBrightness_ShadowInfo.x) + _19.CB0.OutlineBrightness_ShadowInfo.y, 0.0, 1.0) * (1.5 - _439)) + _439, 0.0, 1.0); + vec4 _446 = vec4(_445.x, _445.y, _445.z, _425.w); + vec3 _453 = mix(_19.CB0.FogColor, _446.xyz, vec3(clamp(_146.LightPosition_Fog.w, 0.0, 1.0))); + _entryPointOutput = vec4(_453.x, _453.y, _453.z, _446.w); +} + diff --git a/reference/opt/shaders/asm/frag/invalidation.asm.frag b/reference/opt/shaders/asm/frag/invalidation.asm.frag new file mode 100644 index 0000000000..c0dc7b682b --- /dev/null +++ b/reference/opt/shaders/asm/frag/invalidation.asm.frag @@ -0,0 +1,11 @@ +#version 450 + +layout(location = 0) in float v0; +layout(location = 1) in float v1; +layout(location = 0) out float FragColor; + +void main() +{ + FragColor = (v0 + v1) * v1; +} + diff --git a/reference/opt/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag b/reference/opt/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag new file mode 100644 index 0000000000..4fb4b75740 --- /dev/null +++ b/reference/opt/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag @@ -0,0 +1,52 @@ +#version 450 + +layout(binding = 0, std140) uniform Foo +{ + layout(row_major) mat4 lightVP[64]; + uint shadowCascadesNum; + int test; +} _11; + +layout(location = 0) in vec3 fragWorld; +layout(location = 0) out int _entryPointOutput; + +mat4 _152; +uint _155; + +int GetCascade(vec3 fragWorldPosition) +{ + mat4 _153; + _153 = _152; + uint _156; + mat4 _157; + for (uint _151 = 0u; _151 < _11.shadowCascadesNum; _151 = _156 + uint(1), _153 = _157) + { + mat4 _154; + _154 = _153; + for (;;) + { + if (_11.test == 0) + { + _156 = _151; + _157 = mat4(vec4(0.5, 0.0, 0.0, 0.0), vec4(0.0, 0.5, 0.0, 0.0), vec4(0.0, 0.0, 0.5, 0.0), vec4(0.0, 0.0, 0.0, 1.0)); + break; + } + _156 = _151; + _157 = mat4(vec4(1.0, 0.0, 0.0, 0.0), vec4(0.0, 1.0, 0.0, 0.0), vec4(0.0, 0.0, 1.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0)); + break; + } + vec4 _92 = (_157 * _11.lightVP[_156]) * vec4(fragWorldPosition, 1.0); + if ((((_92.z >= 0.0) && (_92.z <= 1.0)) && (max(_92.x, _92.y) <= 1.0)) && (min(_92.x, _92.y) >= 0.0)) + { + return int(_156); + } + } + return -1; +} + +void main() +{ + vec3 _123 = fragWorld; + _entryPointOutput = GetCascade(_123); +} + diff --git a/reference/opt/shaders/asm/frag/loop-header-to-continue.asm.frag b/reference/opt/shaders/asm/frag/loop-header-to-continue.asm.frag new file mode 100644 index 0000000000..f3a6b4eceb --- /dev/null +++ b/reference/opt/shaders/asm/frag/loop-header-to-continue.asm.frag @@ -0,0 +1,39 @@ +#version 450 + +struct Params +{ + vec4 TextureSize; + vec4 Params1; + vec4 Params2; + vec4 Params3; + vec4 Params4; + vec4 Bloom; +}; + +layout(binding = 1, std140) uniform CB1 +{ + Params CB1; +} _8; + +uniform sampler2D SPIRV_Cross_CombinedmapTexturemapSampler; + +layout(location = 0) in vec2 IN_uv; +layout(location = 0) out vec4 _entryPointOutput; + +void main() +{ + vec4 _49 = texture(SPIRV_Cross_CombinedmapTexturemapSampler, IN_uv); + float _50 = _49.y; + float _55; + float _58; + _55 = 0.0; + _58 = 0.0; + float _64; + vec4 _72; + float _78; + for (int _60 = -3; _60 <= 3; _64 = float(_60), _72 = texture(SPIRV_Cross_CombinedmapTexturemapSampler, IN_uv + (vec2(0.0, _8.CB1.TextureSize.w) * _64)), _78 = exp(((-_64) * _64) * 0.2222220003604888916015625) * float(abs(_72.y - _50) < clamp((_50 * 80.0) * 0.0007999999797903001308441162109375, 7.999999797903001308441162109375e-05, 0.008000000379979610443115234375)), _55 += (_72.x * _78), _58 += _78, _60++) + { + } + _entryPointOutput = vec4(_55 / _58, _50, 0.0, 1.0); +} + diff --git a/reference/opt/shaders/asm/frag/multi-for-loop-init.asm.frag b/reference/opt/shaders/asm/frag/multi-for-loop-init.asm.frag new file mode 100644 index 0000000000..c41c77c701 --- /dev/null +++ b/reference/opt/shaders/asm/frag/multi-for-loop-init.asm.frag @@ -0,0 +1,19 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(location = 0) out vec4 FragColor; +layout(location = 0) flat in mediump int counter; + +void main() +{ + FragColor = vec4(0.0); + int _53 = 0; + uint _54 = 1u; + for (; (_53 < 10) && (int(_54) < int(20u)); _53 += counter, _54 += uint(counter)) + { + FragColor += vec4(float(_53)); + FragColor += vec4(float(_54)); + } +} + diff --git a/reference/opt/shaders/asm/frag/op-constant-null.asm.frag b/reference/opt/shaders/asm/frag/op-constant-null.asm.frag new file mode 100644 index 0000000000..cb882cd7b1 --- /dev/null +++ b/reference/opt/shaders/asm/frag/op-constant-null.asm.frag @@ -0,0 +1,17 @@ +#version 310 es +precision mediump float; +precision highp int; + +struct D +{ + vec4 a; + float b; +}; + +layout(location = 0) out float FragColor; + +void main() +{ + FragColor = 0.0; +} + diff --git a/reference/opt/shaders/asm/frag/phi-loop-variable.asm.frag b/reference/opt/shaders/asm/frag/phi-loop-variable.asm.frag new file mode 100644 index 0000000000..786ac74de5 --- /dev/null +++ b/reference/opt/shaders/asm/frag/phi-loop-variable.asm.frag @@ -0,0 +1,9 @@ +#version 450 + +void main() +{ + for (int _22 = 35; _22 >= 0; _22--) + { + } +} + diff --git a/reference/opt/shaders/asm/frag/sampler-buffer-without-sampler.asm.frag b/reference/opt/shaders/asm/frag/sampler-buffer-without-sampler.asm.frag new file mode 100644 index 0000000000..560a4e79b9 --- /dev/null +++ b/reference/opt/shaders/asm/frag/sampler-buffer-without-sampler.asm.frag @@ -0,0 +1,13 @@ +#version 450 + +layout(rgba32f) uniform writeonly imageBuffer RWTex; +uniform samplerBuffer Tex; + +layout(location = 0) out vec4 _entryPointOutput; + +void main() +{ + imageStore(RWTex, 20, vec4(1.0, 2.0, 3.0, 4.0)); + _entryPointOutput = texelFetch(Tex, 10); +} + diff --git a/reference/opt/shaders/asm/frag/struct-composite-extract-swizzle.asm.frag b/reference/opt/shaders/asm/frag/struct-composite-extract-swizzle.asm.frag new file mode 100644 index 0000000000..b2473f4d03 --- /dev/null +++ b/reference/opt/shaders/asm/frag/struct-composite-extract-swizzle.asm.frag @@ -0,0 +1,21 @@ +#version 310 es +precision mediump float; +precision highp int; + +struct Foo +{ + float var1; + float var2; +}; + +layout(binding = 0) uniform mediump sampler2D uSampler; + +layout(location = 0) out vec4 FragColor; + +Foo _22; + +void main() +{ + FragColor = texture(uSampler, vec2(_22.var1, _22.var2)); +} + diff --git a/reference/opt/shaders/asm/frag/temporary-phi-hoisting.asm.frag b/reference/opt/shaders/asm/frag/temporary-phi-hoisting.asm.frag new file mode 100644 index 0000000000..3917594d98 --- /dev/null +++ b/reference/opt/shaders/asm/frag/temporary-phi-hoisting.asm.frag @@ -0,0 +1,26 @@ +#version 450 + +struct MyStruct +{ + vec4 color; +}; + +layout(std140) uniform MyStruct_CB +{ + MyStruct g_MyStruct[4]; +} _6; + +layout(location = 0) out vec4 _entryPointOutput; + +void main() +{ + vec3 _28; + _28 = vec3(0.0); + vec3 _29; + for (int _31 = 0; _31 < 4; _28 = _29, _31++) + { + _29 = _28 + _6.g_MyStruct[_31].color.xyz; + } + _entryPointOutput = vec4(_28, 1.0); +} + diff --git a/reference/opt/shaders/asm/frag/undef-variable-store.asm.frag b/reference/opt/shaders/asm/frag/undef-variable-store.asm.frag new file mode 100644 index 0000000000..23576ed850 --- /dev/null +++ b/reference/opt/shaders/asm/frag/undef-variable-store.asm.frag @@ -0,0 +1,30 @@ +#version 450 + +layout(location = 0) out vec4 _entryPointOutput; + +vec4 _38; +vec4 _50; + +void main() +{ + vec4 _51; + _51 = _50; + vec4 _52; + for (;;) + { + if (0.0 != 0.0) + { + _52 = vec4(1.0, 0.0, 0.0, 1.0); + break; + } + else + { + _52 = vec4(1.0, 1.0, 0.0, 1.0); + break; + } + _52 = _38; + break; + } + _entryPointOutput = _52; +} + diff --git a/reference/opt/shaders/asm/frag/unreachable.asm.frag b/reference/opt/shaders/asm/frag/unreachable.asm.frag new file mode 100644 index 0000000000..d8126d752e --- /dev/null +++ b/reference/opt/shaders/asm/frag/unreachable.asm.frag @@ -0,0 +1,26 @@ +#version 450 + +layout(location = 0) flat in int counter; +layout(location = 0) out vec4 FragColor; + +vec4 _21; + +void main() +{ + vec4 _33; + do + { + if (counter == 10) + { + _33 = vec4(10.0); + break; + } + else + { + _33 = vec4(30.0); + break; + } + } while (false); + FragColor = _33; +} + diff --git a/reference/opt/shaders/asm/frag/vector-shuffle-oom.asm.frag b/reference/opt/shaders/asm/frag/vector-shuffle-oom.asm.frag new file mode 100644 index 0000000000..1c211caa6d --- /dev/null +++ b/reference/opt/shaders/asm/frag/vector-shuffle-oom.asm.frag @@ -0,0 +1,316 @@ +#version 450 + +struct _28 +{ + vec4 _m0; +}; + +layout(binding = 0, std140) uniform _6_7 +{ + vec4 _m0; + float _m1; + vec4 _m2; +} _7; + +layout(binding = 2, std140) uniform _10_11 +{ + vec3 _m0; + vec3 _m1; + float _m2; + vec3 _m3; + float _m4; + vec3 _m5; + float _m6; + vec3 _m7; + float _m8; + vec3 _m9; + float _m10; + vec3 _m11; + float _m12; + vec2 _m13; + vec2 _m14; + vec3 _m15; + float _m16; + float _m17; + float _m18; + float _m19; + float _m20; + vec4 _m21; + vec4 _m22; + layout(row_major) mat4 _m23; + vec4 _m24; +} _11; + +layout(binding = 1, std140) uniform _18_19 +{ + layout(row_major) mat4 _m0; + layout(row_major) mat4 _m1; + layout(row_major) mat4 _m2; + layout(row_major) mat4 _m3; + vec4 _m4; + vec4 _m5; + float _m6; + float _m7; + float _m8; + float _m9; + vec3 _m10; + float _m11; + vec3 _m12; + float _m13; + vec3 _m14; + float _m15; + vec3 _m16; + float _m17; + float _m18; + float _m19; + vec2 _m20; + vec2 _m21; + vec2 _m22; + vec4 _m23; + vec2 _m24; + vec2 _m25; + vec2 _m26; + vec3 _m27; + float _m28; + float _m29; + float _m30; + float _m31; + float _m32; + vec2 _m33; + float _m34; + float _m35; + vec3 _m36; + layout(row_major) mat4 _m37[2]; + vec4 _m38[2]; +} _19; + +uniform sampler2D SPIRV_Cross_Combined; +uniform sampler2D SPIRV_Cross_Combined_1; +uniform sampler2D SPIRV_Cross_Combined_2; + +layout(location = 0) out vec4 _5; + +_28 _74; + +void main() +{ + _28 _77 = _74; + _77._m0 = vec4(0.0); + vec2 _82 = gl_FragCoord.xy * _19._m23.xy; + vec4 _88 = _7._m2 * _7._m0.xyxy; + vec2 _97 = clamp(_82 + (vec3(0.0, -2.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); + vec3 _109 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _97, 0.0).w * _7._m1, 0.0, 1.0); + vec4 _113 = textureLod(SPIRV_Cross_Combined_1, _97, 0.0); + vec3 _129; + if (_113.y > 0.0) + { + _129 = _109 + (textureLod(SPIRV_Cross_Combined_2, _97, 0.0).xyz * clamp(_113.y * _113.z, 0.0, 1.0)); + } + else + { + _129 = _109; + } + vec3 _133 = vec4(0.0).xyz + (_129 * 0.5); + vec4 _134 = vec4(_133.x, _133.y, _133.z, vec4(0.0).w); + _28 _135 = _77; + _135._m0 = _134; + vec2 _144 = clamp(_82 + (vec3(-1.0, -1.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); + vec3 _156 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _144, 0.0).w * _7._m1, 0.0, 1.0); + vec4 _160 = textureLod(SPIRV_Cross_Combined_1, _144, 0.0); + vec3 _176; + if (_160.y > 0.0) + { + _176 = _156 + (textureLod(SPIRV_Cross_Combined_2, _144, 0.0).xyz * clamp(_160.y * _160.z, 0.0, 1.0)); + } + else + { + _176 = _156; + } + vec3 _180 = _134.xyz + (_176 * 0.5); + vec4 _181 = vec4(_180.x, _180.y, _180.z, _134.w); + _28 _182 = _135; + _182._m0 = _181; + vec2 _191 = clamp(_82 + (vec3(0.0, -1.0, 0.75).xy * _7._m0.xy), _88.xy, _88.zw); + vec3 _203 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _191, 0.0).w * _7._m1, 0.0, 1.0); + vec4 _207 = textureLod(SPIRV_Cross_Combined_1, _191, 0.0); + vec3 _223; + if (_207.y > 0.0) + { + _223 = _203 + (textureLod(SPIRV_Cross_Combined_2, _191, 0.0).xyz * clamp(_207.y * _207.z, 0.0, 1.0)); + } + else + { + _223 = _203; + } + vec3 _227 = _181.xyz + (_223 * 0.75); + vec4 _228 = vec4(_227.x, _227.y, _227.z, _181.w); + _28 _229 = _182; + _229._m0 = _228; + vec2 _238 = clamp(_82 + (vec3(1.0, -1.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); + vec3 _250 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _238, 0.0).w * _7._m1, 0.0, 1.0); + vec4 _254 = textureLod(SPIRV_Cross_Combined_1, _238, 0.0); + vec3 _270; + if (_254.y > 0.0) + { + _270 = _250 + (textureLod(SPIRV_Cross_Combined_2, _238, 0.0).xyz * clamp(_254.y * _254.z, 0.0, 1.0)); + } + else + { + _270 = _250; + } + vec3 _274 = _228.xyz + (_270 * 0.5); + vec4 _275 = vec4(_274.x, _274.y, _274.z, _228.w); + _28 _276 = _229; + _276._m0 = _275; + vec2 _285 = clamp(_82 + (vec3(-2.0, 0.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); + vec3 _297 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _285, 0.0).w * _7._m1, 0.0, 1.0); + vec4 _301 = textureLod(SPIRV_Cross_Combined_1, _285, 0.0); + vec3 _317; + if (_301.y > 0.0) + { + _317 = _297 + (textureLod(SPIRV_Cross_Combined_2, _285, 0.0).xyz * clamp(_301.y * _301.z, 0.0, 1.0)); + } + else + { + _317 = _297; + } + vec3 _321 = _275.xyz + (_317 * 0.5); + vec4 _322 = vec4(_321.x, _321.y, _321.z, _275.w); + _28 _323 = _276; + _323._m0 = _322; + vec2 _332 = clamp(_82 + (vec3(-1.0, 0.0, 0.75).xy * _7._m0.xy), _88.xy, _88.zw); + vec3 _344 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _332, 0.0).w * _7._m1, 0.0, 1.0); + vec4 _348 = textureLod(SPIRV_Cross_Combined_1, _332, 0.0); + vec3 _364; + if (_348.y > 0.0) + { + _364 = _344 + (textureLod(SPIRV_Cross_Combined_2, _332, 0.0).xyz * clamp(_348.y * _348.z, 0.0, 1.0)); + } + else + { + _364 = _344; + } + vec3 _368 = _322.xyz + (_364 * 0.75); + vec4 _369 = vec4(_368.x, _368.y, _368.z, _322.w); + _28 _370 = _323; + _370._m0 = _369; + vec2 _379 = clamp(_82 + (vec3(0.0, 0.0, 1.0).xy * _7._m0.xy), _88.xy, _88.zw); + vec3 _391 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _379, 0.0).w * _7._m1, 0.0, 1.0); + vec4 _395 = textureLod(SPIRV_Cross_Combined_1, _379, 0.0); + vec3 _411; + if (_395.y > 0.0) + { + _411 = _391 + (textureLod(SPIRV_Cross_Combined_2, _379, 0.0).xyz * clamp(_395.y * _395.z, 0.0, 1.0)); + } + else + { + _411 = _391; + } + vec3 _415 = _369.xyz + (_411 * 1.0); + vec4 _416 = vec4(_415.x, _415.y, _415.z, _369.w); + _28 _417 = _370; + _417._m0 = _416; + vec2 _426 = clamp(_82 + (vec3(1.0, 0.0, 0.75).xy * _7._m0.xy), _88.xy, _88.zw); + vec3 _438 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _426, 0.0).w * _7._m1, 0.0, 1.0); + vec4 _442 = textureLod(SPIRV_Cross_Combined_1, _426, 0.0); + vec3 _458; + if (_442.y > 0.0) + { + _458 = _438 + (textureLod(SPIRV_Cross_Combined_2, _426, 0.0).xyz * clamp(_442.y * _442.z, 0.0, 1.0)); + } + else + { + _458 = _438; + } + vec3 _462 = _416.xyz + (_458 * 0.75); + vec4 _463 = vec4(_462.x, _462.y, _462.z, _416.w); + _28 _464 = _417; + _464._m0 = _463; + vec2 _473 = clamp(_82 + (vec3(2.0, 0.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); + vec3 _485 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _473, 0.0).w * _7._m1, 0.0, 1.0); + vec4 _489 = textureLod(SPIRV_Cross_Combined_1, _473, 0.0); + vec3 _505; + if (_489.y > 0.0) + { + _505 = _485 + (textureLod(SPIRV_Cross_Combined_2, _473, 0.0).xyz * clamp(_489.y * _489.z, 0.0, 1.0)); + } + else + { + _505 = _485; + } + vec3 _509 = _463.xyz + (_505 * 0.5); + vec4 _510 = vec4(_509.x, _509.y, _509.z, _463.w); + _28 _511 = _464; + _511._m0 = _510; + vec2 _520 = clamp(_82 + (vec3(-1.0, 1.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); + vec3 _532 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _520, 0.0).w * _7._m1, 0.0, 1.0); + vec4 _536 = textureLod(SPIRV_Cross_Combined_1, _520, 0.0); + vec3 _552; + if (_536.y > 0.0) + { + _552 = _532 + (textureLod(SPIRV_Cross_Combined_2, _520, 0.0).xyz * clamp(_536.y * _536.z, 0.0, 1.0)); + } + else + { + _552 = _532; + } + vec3 _556 = _510.xyz + (_552 * 0.5); + vec4 _557 = vec4(_556.x, _556.y, _556.z, _510.w); + _28 _558 = _511; + _558._m0 = _557; + vec2 _567 = clamp(_82 + (vec3(0.0, 1.0, 0.75).xy * _7._m0.xy), _88.xy, _88.zw); + vec3 _579 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _567, 0.0).w * _7._m1, 0.0, 1.0); + vec4 _583 = textureLod(SPIRV_Cross_Combined_1, _567, 0.0); + vec3 _599; + if (_583.y > 0.0) + { + _599 = _579 + (textureLod(SPIRV_Cross_Combined_2, _567, 0.0).xyz * clamp(_583.y * _583.z, 0.0, 1.0)); + } + else + { + _599 = _579; + } + vec3 _603 = _557.xyz + (_599 * 0.75); + vec4 _604 = vec4(_603.x, _603.y, _603.z, _557.w); + _28 _605 = _558; + _605._m0 = _604; + vec2 _614 = clamp(_82 + (vec3(1.0, 1.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); + vec3 _626 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _614, 0.0).w * _7._m1, 0.0, 1.0); + vec4 _630 = textureLod(SPIRV_Cross_Combined_1, _614, 0.0); + vec3 _646; + if (_630.y > 0.0) + { + _646 = _626 + (textureLod(SPIRV_Cross_Combined_2, _614, 0.0).xyz * clamp(_630.y * _630.z, 0.0, 1.0)); + } + else + { + _646 = _626; + } + vec3 _650 = _604.xyz + (_646 * 0.5); + vec4 _651 = vec4(_650.x, _650.y, _650.z, _604.w); + _28 _652 = _605; + _652._m0 = _651; + vec2 _661 = clamp(_82 + (vec3(0.0, 2.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); + vec3 _673 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _661, 0.0).w * _7._m1, 0.0, 1.0); + vec4 _677 = textureLod(SPIRV_Cross_Combined_1, _661, 0.0); + vec3 _693; + if (_677.y > 0.0) + { + _693 = _673 + (textureLod(SPIRV_Cross_Combined_2, _661, 0.0).xyz * clamp(_677.y * _677.z, 0.0, 1.0)); + } + else + { + _693 = _673; + } + vec3 _697 = _651.xyz + (_693 * 0.5); + vec4 _698 = vec4(_697.x, _697.y, _697.z, _651.w); + _28 _699 = _652; + _699._m0 = _698; + vec3 _702 = _698.xyz / vec3(((((((((((((0.0 + 0.5) + 0.5) + 0.75) + 0.5) + 0.5) + 0.75) + 1.0) + 0.75) + 0.5) + 0.5) + 0.75) + 0.5) + 0.5); + _28 _704 = _699; + _704._m0 = vec4(_702.x, _702.y, _702.z, _698.w); + _28 _705 = _704; + _705._m0.w = 1.0; + _5 = _705._m0; +} + diff --git a/reference/opt/shaders/asm/tesc/tess-fixed-input-array-builtin-array.asm.tesc b/reference/opt/shaders/asm/tesc/tess-fixed-input-array-builtin-array.asm.tesc new file mode 100644 index 0000000000..dc43d91a9b --- /dev/null +++ b/reference/opt/shaders/asm/tesc/tess-fixed-input-array-builtin-array.asm.tesc @@ -0,0 +1,81 @@ +#version 450 +layout(vertices = 3) out; + +struct VertexOutput +{ + vec4 pos; + vec2 uv; +}; + +struct HSOut +{ + vec4 pos; + vec2 uv; +}; + +struct HSConstantOut +{ + float EdgeTess[3]; + float InsideTess; +}; + +struct VertexOutput_1 +{ + vec2 uv; +}; + +struct HSOut_1 +{ + vec2 uv; +}; + +layout(location = 0) in VertexOutput_1 p[]; +layout(location = 0) out HSOut_1 _entryPointOutput[3]; + +void main() +{ + VertexOutput p_1[3]; + p_1[0].pos = gl_in[0].gl_Position; + p_1[0].uv = p[0].uv; + p_1[1].pos = gl_in[1].gl_Position; + p_1[1].uv = p[1].uv; + p_1[2].pos = gl_in[2].gl_Position; + p_1[2].uv = p[2].uv; + VertexOutput param[3] = p_1; + HSOut _158; + HSOut _197 = _158; + _197.pos = param[gl_InvocationID].pos; + HSOut _199 = _197; + _199.uv = param[gl_InvocationID].uv; + _158 = _199; + gl_out[gl_InvocationID].gl_Position = param[gl_InvocationID].pos; + _entryPointOutput[gl_InvocationID].uv = param[gl_InvocationID].uv; + barrier(); + if (int(gl_InvocationID) == 0) + { + VertexOutput param_1[3] = p_1; + vec2 _174 = vec2(1.0) + param_1[0].uv; + float _175 = _174.x; + HSConstantOut _169; + HSConstantOut _205 = _169; + _205.EdgeTess[0] = _175; + vec2 _180 = vec2(1.0) + param_1[0].uv; + float _181 = _180.x; + HSConstantOut _207 = _205; + _207.EdgeTess[1] = _181; + vec2 _186 = vec2(1.0) + param_1[0].uv; + float _187 = _186.x; + HSConstantOut _209 = _207; + _209.EdgeTess[2] = _187; + vec2 _192 = vec2(1.0) + param_1[0].uv; + float _193 = _192.x; + HSConstantOut _211 = _209; + _211.InsideTess = _193; + _169 = _211; + gl_TessLevelOuter[0] = _175; + gl_TessLevelOuter[1] = _181; + gl_TessLevelOuter[2] = _187; + gl_TessLevelInner[0] = _193; + } +} + diff --git a/reference/opt/shaders/asm/vert/empty-io.asm.vert b/reference/opt/shaders/asm/vert/empty-io.asm.vert new file mode 100644 index 0000000000..5286269337 --- /dev/null +++ b/reference/opt/shaders/asm/vert/empty-io.asm.vert @@ -0,0 +1,19 @@ +#version 450 + +struct VSInput +{ + vec4 position; +}; + +struct VSOutput +{ + vec4 position; +}; + +layout(location = 0) in vec4 position; + +void main() +{ + gl_Position = position; +} + diff --git a/reference/opt/shaders/asm/vert/empty-struct-composite.asm.vert b/reference/opt/shaders/asm/vert/empty-struct-composite.asm.vert new file mode 100644 index 0000000000..05ce10adfa --- /dev/null +++ b/reference/opt/shaders/asm/vert/empty-struct-composite.asm.vert @@ -0,0 +1,6 @@ +#version 450 + +void main() +{ +} + diff --git a/reference/opt/shaders/asm/vert/global-builtin.sso.asm.vert b/reference/opt/shaders/asm/vert/global-builtin.sso.asm.vert new file mode 100644 index 0000000000..2fc44c526e --- /dev/null +++ b/reference/opt/shaders/asm/vert/global-builtin.sso.asm.vert @@ -0,0 +1,26 @@ +#version 450 + +out gl_PerVertex +{ + vec4 gl_Position; +}; + +struct VSOut +{ + float a; + vec4 pos; +}; + +struct VSOut_1 +{ + float a; +}; + +layout(location = 0) out VSOut_1 _entryPointOutput; + +void main() +{ + _entryPointOutput.a = 40.0; + gl_Position = vec4(1.0); +} + diff --git a/reference/opt/shaders/comp/atomic.comp b/reference/opt/shaders/comp/atomic.comp new file mode 100644 index 0000000000..89b1351c0c --- /dev/null +++ b/reference/opt/shaders/comp/atomic.comp @@ -0,0 +1,49 @@ +#version 310 es +#extension GL_OES_shader_image_atomic : require +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 2, std430) buffer SSBO +{ + uint u32; + int i32; +} ssbo; + +layout(binding = 0, r32ui) uniform highp uimage2D uImage; +layout(binding = 1, r32i) uniform highp iimage2D iImage; + +void main() +{ + uint _19 = imageAtomicAdd(uImage, ivec2(1, 5), 1u); + uint _27 = imageAtomicAdd(uImage, ivec2(1, 5), 1u); + imageStore(iImage, ivec2(1, 6), ivec4(int(_27))); + uint _32 = imageAtomicOr(uImage, ivec2(1, 5), 1u); + uint _34 = imageAtomicXor(uImage, ivec2(1, 5), 1u); + uint _36 = imageAtomicAnd(uImage, ivec2(1, 5), 1u); + uint _38 = imageAtomicMin(uImage, ivec2(1, 5), 1u); + uint _40 = imageAtomicMax(uImage, ivec2(1, 5), 1u); + uint _44 = imageAtomicCompSwap(uImage, ivec2(1, 5), 10u, 2u); + int _47 = imageAtomicAdd(iImage, ivec2(1, 6), 1); + int _49 = imageAtomicOr(iImage, ivec2(1, 6), 1); + int _51 = imageAtomicXor(iImage, ivec2(1, 6), 1); + int _53 = imageAtomicAnd(iImage, ivec2(1, 6), 1); + int _55 = imageAtomicMin(iImage, ivec2(1, 6), 1); + int _57 = imageAtomicMax(iImage, ivec2(1, 6), 1); + int _61 = imageAtomicCompSwap(iImage, ivec2(1, 5), 10, 2); + uint _68 = atomicAdd(ssbo.u32, 1u); + uint _70 = atomicOr(ssbo.u32, 1u); + uint _72 = atomicXor(ssbo.u32, 1u); + uint _74 = atomicAnd(ssbo.u32, 1u); + uint _76 = atomicMin(ssbo.u32, 1u); + uint _78 = atomicMax(ssbo.u32, 1u); + uint _80 = atomicExchange(ssbo.u32, 1u); + uint _82 = atomicCompSwap(ssbo.u32, 10u, 2u); + int _85 = atomicAdd(ssbo.i32, 1); + int _87 = atomicOr(ssbo.i32, 1); + int _89 = atomicXor(ssbo.i32, 1); + int _91 = atomicAnd(ssbo.i32, 1); + int _93 = atomicMin(ssbo.i32, 1); + int _95 = atomicMax(ssbo.i32, 1); + int _97 = atomicExchange(ssbo.i32, 1); + int _99 = atomicCompSwap(ssbo.i32, 10, 2); +} + diff --git a/reference/opt/shaders/comp/bake_gradient.comp b/reference/opt/shaders/comp/bake_gradient.comp new file mode 100644 index 0000000000..0af4833926 --- /dev/null +++ b/reference/opt/shaders/comp/bake_gradient.comp @@ -0,0 +1,23 @@ +#version 310 es +layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in; + +layout(binding = 4, std140) uniform UBO +{ + vec4 uInvSize; + vec4 uScale; +} _46; + +layout(binding = 0) uniform mediump sampler2D uHeight; +layout(binding = 1) uniform mediump sampler2D uDisplacement; +layout(binding = 2, rgba16f) uniform writeonly mediump image2D iHeightDisplacement; +layout(binding = 3, rgba16f) uniform writeonly mediump image2D iGradJacobian; + +void main() +{ + vec4 _59 = (vec2(gl_GlobalInvocationID.xy) * _46.uInvSize.xy).xyxy + (_46.uInvSize * 0.5); + vec2 _157 = ((textureLodOffset(uDisplacement, _59.zw, 0.0, ivec2(1, 0)).xy - textureLodOffset(uDisplacement, _59.zw, 0.0, ivec2(-1, 0)).xy) * 0.60000002384185791015625) * _46.uScale.z; + vec2 _161 = ((textureLodOffset(uDisplacement, _59.zw, 0.0, ivec2(0, 1)).xy - textureLodOffset(uDisplacement, _59.zw, 0.0, ivec2(0, -1)).xy) * 0.60000002384185791015625) * _46.uScale.z; + imageStore(iHeightDisplacement, ivec2(gl_GlobalInvocationID.xy), vec4(textureLod(uHeight, _59.xy, 0.0).x, 0.0, 0.0, 0.0)); + imageStore(iGradJacobian, ivec2(gl_GlobalInvocationID.xy), vec4((_46.uScale.xy * 0.5) * vec2(textureLodOffset(uHeight, _59.xy, 0.0, ivec2(1, 0)).x - textureLodOffset(uHeight, _59.xy, 0.0, ivec2(-1, 0)).x, textureLodOffset(uHeight, _59.xy, 0.0, ivec2(0, 1)).x - textureLodOffset(uHeight, _59.xy, 0.0, ivec2(0, -1)).x), ((1.0 + _157.x) * (1.0 + _161.y)) - (_157.y * _161.x), 0.0)); +} + diff --git a/reference/opt/shaders/comp/barriers.comp b/reference/opt/shaders/comp/barriers.comp new file mode 100644 index 0000000000..a091497a49 --- /dev/null +++ b/reference/opt/shaders/comp/barriers.comp @@ -0,0 +1,28 @@ +#version 310 es +layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in; + +void main() +{ + memoryBarrierShared(); + memoryBarrier(); + memoryBarrierImage(); + memoryBarrierBuffer(); + groupMemoryBarrier(); + memoryBarrierShared(); + barrier(); + memoryBarrier(); + memoryBarrierShared(); + barrier(); + memoryBarrierImage(); + memoryBarrierShared(); + barrier(); + memoryBarrierBuffer(); + memoryBarrierShared(); + barrier(); + groupMemoryBarrier(); + memoryBarrierShared(); + barrier(); + memoryBarrierShared(); + barrier(); +} + diff --git a/reference/opt/shaders/comp/basic.comp b/reference/opt/shaders/comp/basic.comp new file mode 100644 index 0000000000..f025d53c6f --- /dev/null +++ b/reference/opt/shaders/comp/basic.comp @@ -0,0 +1,28 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) readonly buffer SSBO +{ + vec4 in_data[]; +} _23; + +layout(binding = 1, std430) writeonly buffer SSBO2 +{ + vec4 out_data[]; +} _45; + +layout(binding = 2, std430) buffer SSBO3 +{ + uint counter; +} _48; + +void main() +{ + vec4 _29 = _23.in_data[gl_GlobalInvocationID.x]; + if (dot(_29, vec4(1.0, 5.0, 6.0, 2.0)) > 8.19999980926513671875) + { + uint _52 = atomicAdd(_48.counter, 1u); + _45.out_data[_52] = _29; + } +} + diff --git a/reference/opt/shaders/comp/bitfield.noopt.comp b/reference/opt/shaders/comp/bitfield.noopt.comp new file mode 100644 index 0000000000..49bbddb0ab --- /dev/null +++ b/reference/opt/shaders/comp/bitfield.noopt.comp @@ -0,0 +1,19 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +void main() +{ + int signed_value = 0; + uint unsigned_value = 0u; + int s = bitfieldExtract(signed_value, 5, 20); + uint u = bitfieldExtract(unsigned_value, 6, 21); + s = bitfieldInsert(s, 40, 5, 4); + u = bitfieldInsert(u, 60u, 5, 4); + u = bitfieldReverse(u); + s = bitfieldReverse(s); + int v0 = bitCount(u); + int v1 = bitCount(s); + int v2 = findMSB(u); + int v3 = findLSB(s); +} + diff --git a/reference/opt/shaders/comp/casts.comp b/reference/opt/shaders/comp/casts.comp new file mode 100644 index 0000000000..11ef36287b --- /dev/null +++ b/reference/opt/shaders/comp/casts.comp @@ -0,0 +1,18 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 1, std430) buffer SSBO1 +{ + ivec4 outputs[]; +} _21; + +layout(binding = 0, std430) buffer SSBO0 +{ + ivec4 inputs[]; +} _27; + +void main() +{ + _21.outputs[gl_GlobalInvocationID.x] = mix(ivec4(0), ivec4(1), notEqual((_27.inputs[gl_GlobalInvocationID.x] & ivec4(3)), ivec4(uvec4(0u)))); +} + diff --git a/reference/opt/shaders/comp/cfg-preserve-parameter.comp b/reference/opt/shaders/comp/cfg-preserve-parameter.comp new file mode 100644 index 0000000000..124652b322 --- /dev/null +++ b/reference/opt/shaders/comp/cfg-preserve-parameter.comp @@ -0,0 +1,7 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +void main() +{ +} + diff --git a/reference/opt/shaders/comp/cfg.comp b/reference/opt/shaders/comp/cfg.comp new file mode 100644 index 0000000000..c2c7136bbd --- /dev/null +++ b/reference/opt/shaders/comp/cfg.comp @@ -0,0 +1,56 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) buffer SSBO +{ + float data; +} _11; + +float _180; + +void main() +{ + if (_11.data != 0.0) + { + _11.data = 10.0; + } + else + { + _11.data = 15.0; + } + switch (int(_11.data)) + { + case 0: + { + _11.data = 20.0; + break; + } + case 1: + { + _11.data = 30.0; + break; + } + } + switch (int(_11.data)) + { + case 0: + { + break; + } + case 1: + { + break; + } + } + float _181; + _181 = _180; + for (int _179 = 0; _179 < 20; _179++, _181 += 10.0) + { + } + _11.data = _181; + do + { + } while (_180 != 20.0); + _11.data = _180; +} + diff --git a/reference/opt/shaders/comp/coherent-block.comp b/reference/opt/shaders/comp/coherent-block.comp new file mode 100644 index 0000000000..bfab6bbea8 --- /dev/null +++ b/reference/opt/shaders/comp/coherent-block.comp @@ -0,0 +1,13 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 1, std430) coherent restrict writeonly buffer SSBO +{ + vec4 value; +} _10; + +void main() +{ + _10.value = vec4(20.0); +} + diff --git a/reference/opt/shaders/comp/coherent-image.comp b/reference/opt/shaders/comp/coherent-image.comp new file mode 100644 index 0000000000..b3992f242e --- /dev/null +++ b/reference/opt/shaders/comp/coherent-image.comp @@ -0,0 +1,15 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 1, std430) coherent restrict writeonly buffer SSBO +{ + ivec4 value; +} _10; + +layout(binding = 3, r32i) uniform coherent restrict readonly mediump iimage2D uImage; + +void main() +{ + _10.value = imageLoad(uImage, ivec2(10)); +} + diff --git a/reference/opt/shaders/comp/composite-construct.comp b/reference/opt/shaders/comp/composite-construct.comp new file mode 100644 index 0000000000..5371f7e528 --- /dev/null +++ b/reference/opt/shaders/comp/composite-construct.comp @@ -0,0 +1,26 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct Composite +{ + vec4 a[2]; + vec4 b[2]; +}; + +layout(binding = 0, std430) buffer SSBO0 +{ + vec4 as[]; +} _41; + +layout(binding = 1, std430) buffer SSBO1 +{ + vec4 bs[]; +} _55; + +void main() +{ + vec4 _60[2] = vec4[](_41.as[gl_GlobalInvocationID.x], _55.bs[gl_GlobalInvocationID.x]); + vec4 param[3][2] = vec4[][](_60, vec4[](vec4(10.0), vec4(30.0)), _60); + _41.as[gl_GlobalInvocationID.x] = ((param[0][0] + param[2][1]) + param[0][1]) + param[1][0]; +} + diff --git a/reference/opt/shaders/comp/culling.comp b/reference/opt/shaders/comp/culling.comp new file mode 100644 index 0000000000..f4dea4b359 --- /dev/null +++ b/reference/opt/shaders/comp/culling.comp @@ -0,0 +1,28 @@ +#version 310 es +layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) readonly buffer SSBO +{ + float in_data[]; +} _22; + +layout(binding = 1, std430) writeonly buffer SSBO2 +{ + float out_data[]; +} _38; + +layout(binding = 2, std430) buffer SSBO3 +{ + uint count; +} _41; + +void main() +{ + float _28 = _22.in_data[gl_GlobalInvocationID.x]; + if (_28 > 12.0) + { + uint _45 = atomicAdd(_41.count, 1u); + _38.out_data[_45] = _28; + } +} + diff --git a/reference/opt/shaders/comp/defer-parens.comp b/reference/opt/shaders/comp/defer-parens.comp new file mode 100644 index 0000000000..51fa7f0abf --- /dev/null +++ b/reference/opt/shaders/comp/defer-parens.comp @@ -0,0 +1,19 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) buffer SSBO +{ + vec4 data; + int index; +} _13; + +void main() +{ + vec4 _17 = _13.data; + _13.data = vec4(_17.x, _17.yz + vec2(10.0), _17.w); + _13.data = (_17 + _17) + _17; + _13.data = (_17.yz + vec2(10.0)).xxyy; + _13.data = vec4((_17.yz + vec2(10.0)).y); + _13.data = vec4((_17.zw + vec2(10.0))[_13.index]); +} + diff --git a/reference/opt/shaders/comp/dowhile.comp b/reference/opt/shaders/comp/dowhile.comp new file mode 100644 index 0000000000..61a3735d13 --- /dev/null +++ b/reference/opt/shaders/comp/dowhile.comp @@ -0,0 +1,39 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) readonly buffer SSBO +{ + mat4 mvp; + vec4 in_data[]; +} _28; + +layout(binding = 1, std430) writeonly buffer SSBO2 +{ + vec4 out_data[]; +} _52; + +int i; + +void main() +{ + i = 0; + vec4 _56; + _56 = _28.in_data[gl_GlobalInvocationID.x]; + vec4 _42; + for (;;) + { + _42 = _28.mvp * _56; + i++; + if (i < 16) + { + _56 = _42; + continue; + } + else + { + break; + } + } + _52.out_data[gl_GlobalInvocationID.x] = _42; +} + diff --git a/reference/opt/shaders/comp/generate_height.comp b/reference/opt/shaders/comp/generate_height.comp new file mode 100644 index 0000000000..1b5e0c3dc1 --- /dev/null +++ b/reference/opt/shaders/comp/generate_height.comp @@ -0,0 +1,54 @@ +#version 310 es +layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) readonly buffer Distribution +{ + vec2 distribution[]; +} _136; + +layout(binding = 2, std140) uniform UBO +{ + vec4 uModTime; +} _165; + +layout(binding = 1, std430) writeonly buffer HeightmapFFT +{ + uint heights[]; +} _224; + +void main() +{ + uvec2 _263 = uvec2(64u, 1u) * gl_NumWorkGroups.xy; + uvec2 _268 = _263 - gl_GlobalInvocationID.xy; + bvec2 _270 = equal(gl_GlobalInvocationID.xy, uvec2(0u)); + uint _470; + if (_270.x) + { + _470 = 0u; + } + else + { + _470 = _268.x; + } + uint _471; + if (_270.y) + { + _471 = 0u; + } + else + { + _471 = _268.y; + } + vec2 _296 = vec2(gl_GlobalInvocationID.xy); + vec2 _298 = vec2(_263); + float _308 = sqrt(9.81000041961669921875 * length(_165.uModTime.xy * mix(_296, _296 - _298, greaterThan(_296, _298 * 0.5)))) * _165.uModTime.z; + float _310 = cos(_308); + float _312 = sin(_308); + vec2 _315 = vec2(_310, _312); + vec2 _394 = _315.yy * (_136.distribution[(gl_GlobalInvocationID.xy.y * _263.x) + gl_GlobalInvocationID.xy.x]).yx; + vec2 _320 = vec2(_310, _312); + vec2 _420 = _320.yy * (_136.distribution[(_471 * _263.x) + _470]).yx; + vec2 _428 = ((_136.distribution[(_471 * _263.x) + _470]) * _320.xx) + vec2(-_420.x, _420.y); + _224.heights[(gl_GlobalInvocationID.xy.y * _263.x) + gl_GlobalInvocationID.xy.x] = packHalf2x16((((_136.distribution[(gl_GlobalInvocationID.xy.y * _263.x) + gl_GlobalInvocationID.xy.x]) * _315.xx) + vec2(-_394.x, _394.y)) + vec2(_428.x, -_428.y)); +} + diff --git a/reference/opt/shaders/comp/image.comp b/reference/opt/shaders/comp/image.comp new file mode 100644 index 0000000000..8bd7dd06ab --- /dev/null +++ b/reference/opt/shaders/comp/image.comp @@ -0,0 +1,11 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, rgba8) uniform readonly mediump image2D uImageIn; +layout(binding = 1, rgba8) uniform writeonly mediump image2D uImageOut; + +void main() +{ + imageStore(uImageOut, ivec2(gl_GlobalInvocationID.xy), imageLoad(uImageIn, ivec2(gl_GlobalInvocationID.xy) + imageSize(uImageIn))); +} + diff --git a/reference/opt/shaders/comp/inout-struct.invalid.comp b/reference/opt/shaders/comp/inout-struct.invalid.comp new file mode 100644 index 0000000000..640e25bb95 --- /dev/null +++ b/reference/opt/shaders/comp/inout-struct.invalid.comp @@ -0,0 +1,65 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct Foo +{ + vec4 a; + vec4 b; + vec4 c; + vec4 d; +}; + +layout(binding = 1, std430) readonly buffer SSBO2 +{ + vec4 data[]; +} indata; + +layout(binding = 0, std430) writeonly buffer SSBO +{ + vec4 data[]; +} outdata; + +layout(binding = 2, std430) readonly buffer SSBO3 +{ + Foo foos[]; +} foobar; + +void baz(inout Foo foo) +{ + uint ident = gl_GlobalInvocationID.x; + foo.a = indata.data[(4u * ident) + 0u]; + foo.b = indata.data[(4u * ident) + 1u]; + foo.c = indata.data[(4u * ident) + 2u]; + foo.d = indata.data[(4u * ident) + 3u]; +} + +void meow(inout Foo foo) +{ + foo.a += vec4(10.0); + foo.b += vec4(20.0); + foo.c += vec4(30.0); + foo.d += vec4(40.0); +} + +vec4 bar(Foo foo) +{ + return ((foo.a + foo.b) + foo.c) + foo.d; +} + +void main() +{ + Foo param; + baz(param); + Foo foo = param; + Foo param_1 = foo; + meow(param_1); + foo = param_1; + Foo param_2 = foo; + Foo param_3; + param_3.a = foobar.foos[gl_GlobalInvocationID.x].a; + param_3.b = foobar.foos[gl_GlobalInvocationID.x].b; + param_3.c = foobar.foos[gl_GlobalInvocationID.x].c; + param_3.d = foobar.foos[gl_GlobalInvocationID.x].d; + outdata.data[gl_GlobalInvocationID.x] = bar(param_2) + bar(param_3); +} + diff --git a/reference/opt/shaders/comp/insert.comp b/reference/opt/shaders/comp/insert.comp new file mode 100644 index 0000000000..5ff719449a --- /dev/null +++ b/reference/opt/shaders/comp/insert.comp @@ -0,0 +1,24 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) writeonly buffer SSBO +{ + vec4 out_data[]; +} _27; + +vec4 _52; + +void main() +{ + vec4 _45 = _52; + _45.x = 10.0; + vec4 _47 = _45; + _47.y = 30.0; + vec4 _49 = _47; + _49.z = 70.0; + vec4 _51 = _49; + _51.w = 90.0; + _27.out_data[gl_GlobalInvocationID.x] = _51; + _27.out_data[gl_GlobalInvocationID.x].y = 20.0; +} + diff --git a/reference/opt/shaders/comp/loop.noopt.comp b/reference/opt/shaders/comp/loop.noopt.comp new file mode 100644 index 0000000000..049a30669c --- /dev/null +++ b/reference/opt/shaders/comp/loop.noopt.comp @@ -0,0 +1,105 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) readonly buffer SSBO +{ + mat4 mvp; + vec4 in_data[]; +} _24; + +layout(binding = 1, std430) writeonly buffer SSBO2 +{ + vec4 out_data[]; +} _177; + +void main() +{ + uint ident = gl_GlobalInvocationID.x; + vec4 idat = _24.in_data[ident]; + int k = 0; + uint i = 0u; + if (idat.y == 20.0) + { + do + { + k *= 2; + i++; + } while (i < ident); + } + switch (k) + { + case 10: + { + for (;;) + { + i++; + if (i > 10u) + { + break; + } + continue; + } + break; + } + default: + { + for (;;) + { + i += 2u; + if (i > 20u) + { + break; + } + continue; + } + break; + } + } + while (k < 10) + { + idat *= 2.0; + k++; + } + for (uint i_1 = 0u; i_1 < 16u; i_1++, k++) + { + for (uint j = 0u; j < 30u; j++) + { + idat = _24.mvp * idat; + } + } + k = 0; + for (;;) + { + k++; + if (k > 10) + { + k += 2; + } + else + { + k += 3; + continue; + } + k += 10; + continue; + } + k = 0; + do + { + k++; + } while (k > 10); + int l = 0; + for (;;) + { + if (l == 5) + { + l++; + continue; + } + idat += vec4(1.0); + l++; + continue; + } + _177.out_data[ident] = idat; +} + diff --git a/reference/opt/shaders/comp/mat3.comp b/reference/opt/shaders/comp/mat3.comp new file mode 100644 index 0000000000..b1c585b849 --- /dev/null +++ b/reference/opt/shaders/comp/mat3.comp @@ -0,0 +1,13 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 1, std430) writeonly buffer SSBO2 +{ + mat3 out_data[]; +} _22; + +void main() +{ + _22.out_data[gl_GlobalInvocationID.x] = mat3(vec3(10.0), vec3(20.0), vec3(40.0)); +} + diff --git a/reference/opt/shaders/comp/mod.comp b/reference/opt/shaders/comp/mod.comp new file mode 100644 index 0000000000..d8ee0ff83a --- /dev/null +++ b/reference/opt/shaders/comp/mod.comp @@ -0,0 +1,20 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) readonly buffer SSBO +{ + vec4 in_data[]; +} _23; + +layout(binding = 1, std430) writeonly buffer SSBO2 +{ + vec4 out_data[]; +} _33; + +void main() +{ + _33.out_data[gl_GlobalInvocationID.x] = mod(_23.in_data[gl_GlobalInvocationID.x], _33.out_data[gl_GlobalInvocationID.x]); + _33.out_data[gl_GlobalInvocationID.x] = uintBitsToFloat(floatBitsToUint(_23.in_data[gl_GlobalInvocationID.x]) % floatBitsToUint(_33.out_data[gl_GlobalInvocationID.x])); + _33.out_data[gl_GlobalInvocationID.x] = intBitsToFloat(floatBitsToInt(_23.in_data[gl_GlobalInvocationID.x]) % floatBitsToInt(_33.out_data[gl_GlobalInvocationID.x])); +} + diff --git a/reference/opt/shaders/comp/modf.comp b/reference/opt/shaders/comp/modf.comp new file mode 100644 index 0000000000..3c8ab6ecd7 --- /dev/null +++ b/reference/opt/shaders/comp/modf.comp @@ -0,0 +1,20 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) readonly buffer SSBO +{ + vec4 in_data[]; +} _23; + +layout(binding = 1, std430) writeonly buffer SSBO2 +{ + vec4 out_data[]; +} _35; + +void main() +{ + vec4 i; + vec4 _31 = modf(_23.in_data[gl_GlobalInvocationID.x], i); + _35.out_data[gl_GlobalInvocationID.x] = _31; +} + diff --git a/reference/opt/shaders/comp/read-write-only.comp b/reference/opt/shaders/comp/read-write-only.comp new file mode 100644 index 0000000000..06227ee2c6 --- /dev/null +++ b/reference/opt/shaders/comp/read-write-only.comp @@ -0,0 +1,27 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 2, std430) restrict writeonly buffer SSBO2 +{ + vec4 data4; + vec4 data5; +} _10; + +layout(binding = 0, std430) readonly buffer SSBO0 +{ + vec4 data0; + vec4 data1; +} _15; + +layout(binding = 1, std430) restrict buffer SSBO1 +{ + vec4 data2; + vec4 data3; +} _21; + +void main() +{ + _10.data4 = _15.data0 + _21.data2; + _10.data5 = _15.data1 + _21.data3; +} + diff --git a/reference/opt/shaders/comp/return.comp b/reference/opt/shaders/comp/return.comp new file mode 100644 index 0000000000..ea41907a7b --- /dev/null +++ b/reference/opt/shaders/comp/return.comp @@ -0,0 +1,31 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 1, std430) writeonly buffer SSBO2 +{ + vec4 out_data[]; +} _27; + +int _69; + +void main() +{ + if (gl_GlobalInvocationID.x == 2u) + { + _27.out_data[gl_GlobalInvocationID.x] = vec4(20.0); + } + else + { + if (gl_GlobalInvocationID.x == 4u) + { + _27.out_data[gl_GlobalInvocationID.x] = vec4(10.0); + return; + } + } + for (int _68 = 0; _68 < 20; _68 = _69 + 1) + { + return; + } + _27.out_data[gl_GlobalInvocationID.x] = vec4(10.0); +} + diff --git a/reference/opt/shaders/comp/rmw-opt.comp b/reference/opt/shaders/comp/rmw-opt.comp new file mode 100644 index 0000000000..7d4d24b29f --- /dev/null +++ b/reference/opt/shaders/comp/rmw-opt.comp @@ -0,0 +1,24 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) buffer SSBO +{ + int a; +} _9; + +void main() +{ + _9.a += 10; + _9.a -= 10; + _9.a *= 10; + _9.a /= 10; + _9.a = _9.a << 2; + _9.a = _9.a >> 3; + _9.a &= 40; + _9.a ^= 10; + _9.a %= 40; + _9.a |= 1; + bool _65 = false && true; + _9.a = int(_65 && (true || _65)); +} + diff --git a/reference/opt/shaders/comp/shared.comp b/reference/opt/shaders/comp/shared.comp new file mode 100644 index 0000000000..66ec1c2cc7 --- /dev/null +++ b/reference/opt/shaders/comp/shared.comp @@ -0,0 +1,23 @@ +#version 310 es +layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) readonly buffer SSBO +{ + float in_data[]; +} _22; + +layout(binding = 1, std430) writeonly buffer SSBO2 +{ + float out_data[]; +} _44; + +shared float sShared[4]; + +void main() +{ + sShared[gl_LocalInvocationIndex] = _22.in_data[gl_GlobalInvocationID.x]; + memoryBarrierShared(); + barrier(); + _44.out_data[gl_GlobalInvocationID.x] = sShared[(4u - gl_LocalInvocationIndex) - 1u]; +} + diff --git a/reference/opt/shaders/comp/ssbo-array.comp b/reference/opt/shaders/comp/ssbo-array.comp new file mode 100644 index 0000000000..6caf8f49f5 --- /dev/null +++ b/reference/opt/shaders/comp/ssbo-array.comp @@ -0,0 +1,13 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) buffer SSBO +{ + vec4 data[]; +} ssbos[2]; + +void main() +{ + ssbos[1].data[gl_GlobalInvocationID.x] = ssbos[0].data[gl_GlobalInvocationID.x]; +} + diff --git a/reference/opt/shaders/comp/struct-layout.comp b/reference/opt/shaders/comp/struct-layout.comp new file mode 100644 index 0000000000..0f73fa7fa9 --- /dev/null +++ b/reference/opt/shaders/comp/struct-layout.comp @@ -0,0 +1,23 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct Foo +{ + mat4 m; +}; + +layout(binding = 1, std430) writeonly buffer SSBO2 +{ + Foo out_data[]; +} _23; + +layout(binding = 0, std430) readonly buffer SSBO +{ + Foo in_data[]; +} _30; + +void main() +{ + _23.out_data[gl_GlobalInvocationID.x].m = _30.in_data[gl_GlobalInvocationID.x].m * _30.in_data[gl_GlobalInvocationID.x].m; +} + diff --git a/reference/opt/shaders/comp/struct-packing.comp b/reference/opt/shaders/comp/struct-packing.comp new file mode 100644 index 0000000000..3c30aa6088 --- /dev/null +++ b/reference/opt/shaders/comp/struct-packing.comp @@ -0,0 +1,104 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct S0 +{ + vec2 a[1]; + float b; +}; + +struct S1 +{ + vec3 a; + float b; +}; + +struct S2 +{ + vec3 a[1]; + float b; +}; + +struct S3 +{ + vec2 a; + float b; +}; + +struct S4 +{ + vec2 c; +}; + +struct Content +{ + S0 m0s[1]; + S1 m1s[1]; + S2 m2s[1]; + S0 m0; + S1 m1; + S2 m2; + S3 m3; + float m4; + S4 m3s[8]; +}; + +layout(binding = 1, std430) buffer SSBO1 +{ + Content content; + Content content1[2]; + Content content2; + mat2 m0; + mat2 m1; + mat2x3 m2[4]; + mat3x2 m3; + layout(row_major) mat2 m4; + layout(row_major) mat2 m5[9]; + layout(row_major) mat2x3 m6[4][2]; + layout(row_major) mat3x2 m7; + float array[]; +} ssbo_430; + +layout(binding = 0, std140) buffer SSBO0 +{ + Content content; + Content content1[2]; + Content content2; + mat2 m0; + mat2 m1; + mat2x3 m2[4]; + mat3x2 m3; + layout(row_major) mat2 m4; + layout(row_major) mat2 m5[9]; + layout(row_major) mat2x3 m6[4][2]; + layout(row_major) mat3x2 m7; + float array[]; +} ssbo_140; + +void main() +{ + ssbo_430.content.m0s[0].a[0] = ssbo_140.content.m0s[0].a[0]; + ssbo_430.content.m0s[0].b = ssbo_140.content.m0s[0].b; + ssbo_430.content.m1s[0].a = ssbo_140.content.m1s[0].a; + ssbo_430.content.m1s[0].b = ssbo_140.content.m1s[0].b; + ssbo_430.content.m2s[0].a[0] = ssbo_140.content.m2s[0].a[0]; + ssbo_430.content.m2s[0].b = ssbo_140.content.m2s[0].b; + ssbo_430.content.m0.a[0] = ssbo_140.content.m0.a[0]; + ssbo_430.content.m0.b = ssbo_140.content.m0.b; + ssbo_430.content.m1.a = ssbo_140.content.m1.a; + ssbo_430.content.m1.b = ssbo_140.content.m1.b; + ssbo_430.content.m2.a[0] = ssbo_140.content.m2.a[0]; + ssbo_430.content.m2.b = ssbo_140.content.m2.b; + ssbo_430.content.m3.a = ssbo_140.content.m3.a; + ssbo_430.content.m3.b = ssbo_140.content.m3.b; + ssbo_430.content.m4 = ssbo_140.content.m4; + ssbo_430.content.m3s[0].c = ssbo_140.content.m3s[0].c; + ssbo_430.content.m3s[1].c = ssbo_140.content.m3s[1].c; + ssbo_430.content.m3s[2].c = ssbo_140.content.m3s[2].c; + ssbo_430.content.m3s[3].c = ssbo_140.content.m3s[3].c; + ssbo_430.content.m3s[4].c = ssbo_140.content.m3s[4].c; + 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; +} + diff --git a/reference/opt/shaders/comp/torture-loop.comp b/reference/opt/shaders/comp/torture-loop.comp new file mode 100644 index 0000000000..640142b30a --- /dev/null +++ b/reference/opt/shaders/comp/torture-loop.comp @@ -0,0 +1,77 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) readonly buffer SSBO +{ + mat4 mvp; + vec4 in_data[]; +} _24; + +layout(binding = 1, std430) writeonly buffer SSBO2 +{ + vec4 out_data[]; +} _89; + +uint _98; + +void main() +{ + vec4 _93; + int _94; + _93 = _24.in_data[gl_GlobalInvocationID.x]; + _94 = 0; + int _40; + vec4 _46; + int _48; + for (;;) + { + _40 = _94 + 1; + if (_40 < 10) + { + _46 = _93 * 2.0; + _48 = _40 + 1; + _93 = _46; + _94 = _48; + continue; + } + else + { + break; + } + } + vec4 _95; + int _96; + _95 = _93; + _96 = _40; + vec4 _100; + uint _101; + uint _99; + for (uint _97 = 0u; _97 < 16u; _95 = _100, _96++, _97++, _99 = _101) + { + _100 = _95; + _101 = 0u; + vec4 _71; + for (; _101 < 30u; _100 = _71, _101++) + { + _71 = _24.mvp * _100; + } + } + int _102; + _102 = _96; + int _83; + for (;;) + { + _83 = _102 + 1; + if (_83 > 10) + { + _102 = _83; + continue; + } + else + { + break; + } + } + _89.out_data[gl_GlobalInvocationID.x] = _95; +} + diff --git a/reference/opt/shaders/comp/type-alias.comp b/reference/opt/shaders/comp/type-alias.comp new file mode 100644 index 0000000000..c0f57f4bda --- /dev/null +++ b/reference/opt/shaders/comp/type-alias.comp @@ -0,0 +1,33 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct S0 +{ + vec4 a; +}; + +struct S1 +{ + vec4 a; +}; + +layout(binding = 0, std430) buffer SSBO0 +{ + S0 s0s[]; +} _36; + +layout(binding = 1, std430) buffer SSBO1 +{ + S1 s1s[]; +} _55; + +layout(binding = 2, std430) buffer SSBO2 +{ + vec4 outputs[]; +} _66; + +void main() +{ + _66.outputs[gl_GlobalInvocationID.x] = _36.s0s[gl_GlobalInvocationID.x].a + _55.s1s[gl_GlobalInvocationID.x].a; +} + diff --git a/reference/opt/shaders/comp/udiv.comp b/reference/opt/shaders/comp/udiv.comp new file mode 100644 index 0000000000..0c1f926ad0 --- /dev/null +++ b/reference/opt/shaders/comp/udiv.comp @@ -0,0 +1,18 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) buffer SSBO2 +{ + uint outputs[]; +} _10; + +layout(binding = 0, std430) buffer SSBO +{ + uint inputs[]; +} _23; + +void main() +{ + _10.outputs[gl_GlobalInvocationID.x] = _23.inputs[gl_GlobalInvocationID.x] / 29u; +} + diff --git a/reference/opt/shaders/desktop-only/comp/enhanced-layouts.comp b/reference/opt/shaders/desktop-only/comp/enhanced-layouts.comp new file mode 100644 index 0000000000..ba37ca237b --- /dev/null +++ b/reference/opt/shaders/desktop-only/comp/enhanced-layouts.comp @@ -0,0 +1,40 @@ +#version 450 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct Foo +{ + int a; + int b; + int c; +}; + +layout(binding = 1, std140) buffer SSBO1 +{ + layout(offset = 4) int a; + layout(offset = 8) int b; + layout(offset = 16) Foo foo; + layout(offset = 48) int c[8]; +} ssbo1; + +layout(binding = 2, std430) buffer SSBO2 +{ + layout(offset = 4) int a; + layout(offset = 8) int b; + layout(offset = 16) Foo foo; + layout(offset = 48) int c[8]; +} ssbo2; + +layout(binding = 0, std140) uniform UBO +{ + layout(offset = 4) int a; + layout(offset = 8) int b; + layout(offset = 16) Foo foo; + layout(offset = 48) int c[8]; +} ubo; + +void main() +{ + ssbo1.a = ssbo2.a; + ssbo1.b = ubo.b; +} + diff --git a/reference/opt/shaders/desktop-only/comp/fp64.desktop.comp b/reference/opt/shaders/desktop-only/comp/fp64.desktop.comp new file mode 100644 index 0000000000..3839a091f5 --- /dev/null +++ b/reference/opt/shaders/desktop-only/comp/fp64.desktop.comp @@ -0,0 +1,63 @@ +#version 450 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct M0 +{ + double v; + dvec2 b[2]; + dmat2x3 c; + dmat3x2 d; +}; + +layout(binding = 0, std430) buffer SSBO0 +{ + dvec4 a; + M0 m0; + dmat4 b; +} ssbo_0; + +layout(binding = 1, std430) buffer SSBO1 +{ + dmat4 a; + dvec4 b; + M0 m0; +} ssbo_1; + +layout(binding = 2, std430) buffer SSBO2 +{ + double a[4]; + dvec2 b[4]; +} ssbo_2; + +layout(binding = 3, std140) buffer SSBO3 +{ + double a[4]; + dvec2 b[4]; +} ssbo_3; + +void main() +{ + ssbo_0.a += dvec4(10.0lf, 20.0lf, 30.0lf, 40.0lf); + ssbo_0.a += dvec4(20.0lf); + dvec4 _40 = ssbo_0.a; + ssbo_0.a = abs(_40); + ssbo_0.a = sign(_40); + ssbo_0.a = floor(_40); + ssbo_0.a = trunc(_40); + ssbo_0.a = round(_40); + ssbo_0.a = roundEven(_40); + ssbo_0.a = ceil(_40); + ssbo_0.a = fract(_40); + ssbo_0.a = mod(_40, dvec4(20.0lf)); + ssbo_0.a = mod(_40, _40); + ssbo_0.a = min(_40, _40); + ssbo_0.a = max(_40, _40); + ssbo_0.a = clamp(_40, _40, _40); + ssbo_0.a = mix(_40, _40, _40); + ssbo_0.a = step(_40, _40); + ssbo_0.a = smoothstep(_40, _40, _40); + ssbo_1.b.x += 1.0lf; + ssbo_2.b[0].x += 1.0lf; + ssbo_3.b[0].x += 1.0lf; +} + diff --git a/reference/opt/shaders/desktop-only/comp/image-formats.desktop.noeliminate.comp b/reference/opt/shaders/desktop-only/comp/image-formats.desktop.noeliminate.comp new file mode 100644 index 0000000000..37b2863558 --- /dev/null +++ b/reference/opt/shaders/desktop-only/comp/image-formats.desktop.noeliminate.comp @@ -0,0 +1,7 @@ +#version 450 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +void main() +{ +} + diff --git a/reference/opt/shaders/desktop-only/comp/int64.desktop.comp b/reference/opt/shaders/desktop-only/comp/int64.desktop.comp new file mode 100644 index 0000000000..702456b303 --- /dev/null +++ b/reference/opt/shaders/desktop-only/comp/int64.desktop.comp @@ -0,0 +1,52 @@ +#version 450 +#extension GL_ARB_gpu_shader_int64 : require +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct M0 +{ + int64_t v; + i64vec2 b[2]; + uint64_t c; + uint64_t d[5]; +}; + +layout(binding = 0, std430) buffer SSBO0 +{ + i64vec4 a; + M0 m0; +} ssbo_0; + +layout(binding = 1, std430) buffer SSBO1 +{ + u64vec4 b; + M0 m0; +} ssbo_1; + +layout(binding = 2, std430) buffer SSBO2 +{ + int64_t a[4]; + i64vec2 b[4]; +} ssbo_2; + +layout(binding = 3, std140) buffer SSBO3 +{ + int64_t a[4]; + i64vec2 b[4]; +} ssbo_3; + +void main() +{ + ssbo_0.a += i64vec4(10l, 20l, 30l, 40l); + ssbo_1.b += u64vec4(999999999999999999ul, 8888888888888888ul, 77777777777777777ul, 6666666666666666ul); + ssbo_0.a += i64vec4(20l); + ssbo_0.a = abs(ssbo_0.a + i64vec4(ssbo_1.b)); + ssbo_0.a += i64vec4(1l); + ssbo_1.b += u64vec4(i64vec4(1l)); + ssbo_0.a -= i64vec4(1l); + ssbo_1.b -= u64vec4(i64vec4(1l)); + ssbo_1.b = doubleBitsToUint64(int64BitsToDouble(ssbo_0.a)); + ssbo_0.a = doubleBitsToInt64(uint64BitsToDouble(ssbo_1.b)); + ssbo_2.a[0] += 1l; + ssbo_3.a[0] += 2l; +} + diff --git a/reference/opt/shaders/desktop-only/frag/hlsl-uav-block-alias.asm.frag b/reference/opt/shaders/desktop-only/frag/hlsl-uav-block-alias.asm.frag new file mode 100644 index 0000000000..2d0809fdbf --- /dev/null +++ b/reference/opt/shaders/desktop-only/frag/hlsl-uav-block-alias.asm.frag @@ -0,0 +1,19 @@ +#version 450 + +layout(binding = 0, std430) buffer Foobar +{ + vec4 _data[]; +} Foobar_1; + +layout(binding = 1, std430) buffer Foobaz +{ + vec4 _data[]; +} Foobaz_1; + +layout(location = 0) out vec4 _entryPointOutput; + +void main() +{ + _entryPointOutput = Foobar_1._data[0] + Foobaz_1._data[0]; +} + diff --git a/reference/opt/shaders/desktop-only/frag/image-ms.desktop.frag b/reference/opt/shaders/desktop-only/frag/image-ms.desktop.frag new file mode 100644 index 0000000000..1276981768 --- /dev/null +++ b/reference/opt/shaders/desktop-only/frag/image-ms.desktop.frag @@ -0,0 +1,12 @@ +#version 450 + +layout(binding = 0, rgba8) uniform image2DMS uImage; +layout(binding = 1, rgba8) uniform image2DMSArray uImageArray; + +void main() +{ + vec4 _29 = imageLoad(uImageArray, ivec3(1, 2, 4), 3); + imageStore(uImage, ivec2(2, 3), 1, imageLoad(uImage, ivec2(1, 2), 2)); + imageStore(uImageArray, ivec3(2, 3, 7), 1, _29); +} + diff --git a/reference/opt/shaders/desktop-only/frag/image-query.desktop.frag b/reference/opt/shaders/desktop-only/frag/image-query.desktop.frag new file mode 100644 index 0000000000..fa1ac0abae --- /dev/null +++ b/reference/opt/shaders/desktop-only/frag/image-query.desktop.frag @@ -0,0 +1,16 @@ +#version 450 + +layout(binding = 0) uniform sampler1D uSampler1D; +layout(binding = 1) uniform sampler2D uSampler2D; +layout(binding = 2) uniform sampler2DArray uSampler2DArray; +layout(binding = 3) uniform sampler3D uSampler3D; +layout(binding = 4) uniform samplerCube uSamplerCube; +layout(binding = 5) uniform samplerCubeArray uSamplerCubeArray; +layout(binding = 6) uniform samplerBuffer uSamplerBuffer; +layout(binding = 7) uniform sampler2DMS uSamplerMS; +layout(binding = 8) uniform sampler2DMSArray uSamplerMSArray; + +void main() +{ +} + diff --git a/reference/opt/shaders/desktop-only/frag/in-block-qualifiers.frag b/reference/opt/shaders/desktop-only/frag/in-block-qualifiers.frag new file mode 100644 index 0000000000..d4622801df --- /dev/null +++ b/reference/opt/shaders/desktop-only/frag/in-block-qualifiers.frag @@ -0,0 +1,21 @@ +#version 450 + +layout(location = 0) out vec4 FragColor; +layout(location = 0) in VertexData +{ + flat float f; + centroid vec4 g; + flat int h; + float i; +} vin; + +layout(location = 4) flat in float f; +layout(location = 5) centroid in vec4 g; +layout(location = 6) flat in int h; +layout(location = 7) sample in float i; + +void main() +{ + FragColor = ((((((vec4(vin.f) + vin.g) + vec4(float(vin.h))) + vec4(vin.i)) + vec4(f)) + g) + vec4(float(h))) + vec4(i); +} + diff --git a/reference/opt/shaders/desktop-only/frag/query-levels.desktop.frag b/reference/opt/shaders/desktop-only/frag/query-levels.desktop.frag new file mode 100644 index 0000000000..4a80cbf81f --- /dev/null +++ b/reference/opt/shaders/desktop-only/frag/query-levels.desktop.frag @@ -0,0 +1,11 @@ +#version 450 + +layout(binding = 0) uniform sampler2D uSampler; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = vec4(float(textureQueryLevels(uSampler))); +} + diff --git a/reference/opt/shaders/desktop-only/frag/query-lod.desktop.frag b/reference/opt/shaders/desktop-only/frag/query-lod.desktop.frag new file mode 100644 index 0000000000..f43543b8c0 --- /dev/null +++ b/reference/opt/shaders/desktop-only/frag/query-lod.desktop.frag @@ -0,0 +1,12 @@ +#version 450 + +layout(binding = 0) uniform sampler2D uSampler; + +layout(location = 0) out vec4 FragColor; +layout(location = 0) in vec2 vTexCoord; + +void main() +{ + FragColor = textureQueryLod(uSampler, vTexCoord).xyxy; +} + diff --git a/reference/opt/shaders/desktop-only/frag/sampler-ms-query.desktop.frag b/reference/opt/shaders/desktop-only/frag/sampler-ms-query.desktop.frag new file mode 100644 index 0000000000..4c30ed1529 --- /dev/null +++ b/reference/opt/shaders/desktop-only/frag/sampler-ms-query.desktop.frag @@ -0,0 +1,14 @@ +#version 450 + +layout(binding = 0) uniform sampler2DMS uSampler; +layout(binding = 1) uniform sampler2DMSArray uSamplerArray; +layout(binding = 2, rgba8) uniform readonly writeonly image2DMS uImage; +layout(binding = 3, rgba8) uniform readonly writeonly image2DMSArray uImageArray; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = vec4(float(((textureSamples(uSampler) + textureSamples(uSamplerArray)) + imageSamples(uImage)) + imageSamples(uImageArray))); +} + diff --git a/reference/opt/shaders/desktop-only/frag/texture-proj-shadow.desktop.frag b/reference/opt/shaders/desktop-only/frag/texture-proj-shadow.desktop.frag new file mode 100644 index 0000000000..d5e45bda43 --- /dev/null +++ b/reference/opt/shaders/desktop-only/frag/texture-proj-shadow.desktop.frag @@ -0,0 +1,26 @@ +#version 450 + +layout(binding = 0) uniform sampler1DShadow uShadow1D; +layout(binding = 1) uniform sampler2DShadow uShadow2D; +layout(binding = 2) uniform sampler1D uSampler1D; +layout(binding = 3) uniform sampler2D uSampler2D; +layout(binding = 4) uniform sampler3D uSampler3D; + +layout(location = 0) out float FragColor; +layout(location = 1) in vec4 vClip4; +layout(location = 2) in vec2 vClip2; +layout(location = 0) in vec3 vClip3; + +void main() +{ + vec4 _20 = vClip4; + _20.y = vClip4.w; + FragColor = textureProj(uShadow1D, vec4(_20.x, 0.0, vClip4.z, _20.y)); + vec4 _30 = vClip4; + _30.z = vClip4.w; + FragColor = textureProj(uShadow2D, vec4(_30.xy, vClip4.z, _30.z)); + FragColor = textureProj(uSampler1D, vClip2).x; + FragColor = textureProj(uSampler2D, vClip3).x; + FragColor = textureProj(uSampler3D, vClip4).x; +} + diff --git a/reference/opt/shaders/desktop-only/geom/basic.desktop.sso.geom b/reference/opt/shaders/desktop-only/geom/basic.desktop.sso.geom new file mode 100644 index 0000000000..f1afee69ec --- /dev/null +++ b/reference/opt/shaders/desktop-only/geom/basic.desktop.sso.geom @@ -0,0 +1,35 @@ +#version 450 +layout(invocations = 4, triangles) in; +layout(max_vertices = 3, triangle_strip) out; + +in gl_PerVertex +{ + vec4 gl_Position; +} gl_in[]; + +out gl_PerVertex +{ + vec4 gl_Position; +}; + +layout(location = 0) out vec3 vNormal; +layout(location = 0) in VertexData +{ + vec3 normal; +} vin[3]; + + +void main() +{ + gl_Position = gl_in[0].gl_Position; + vNormal = vin[0].normal + vec3(float(gl_InvocationID)); + EmitVertex(); + gl_Position = gl_in[1].gl_Position; + vNormal = vin[1].normal + vec3(4.0 * float(gl_InvocationID)); + EmitVertex(); + gl_Position = gl_in[2].gl_Position; + vNormal = vin[2].normal + vec3(2.0 * float(gl_InvocationID)); + EmitVertex(); + EndPrimitive(); +} + diff --git a/reference/opt/shaders/desktop-only/geom/viewport-index.desktop.geom b/reference/opt/shaders/desktop-only/geom/viewport-index.desktop.geom new file mode 100644 index 0000000000..773aeb8bfd --- /dev/null +++ b/reference/opt/shaders/desktop-only/geom/viewport-index.desktop.geom @@ -0,0 +1,9 @@ +#version 450 +layout(triangles) in; +layout(max_vertices = 4, triangle_strip) out; + +void main() +{ + gl_ViewportIndex = 1; +} + diff --git a/reference/opt/shaders/desktop-only/tesc/basic.desktop.sso.tesc b/reference/opt/shaders/desktop-only/tesc/basic.desktop.sso.tesc new file mode 100644 index 0000000000..5e958256af --- /dev/null +++ b/reference/opt/shaders/desktop-only/tesc/basic.desktop.sso.tesc @@ -0,0 +1,27 @@ +#version 450 +layout(vertices = 1) out; + +in gl_PerVertex +{ + vec4 gl_Position; +} gl_in[gl_MaxPatchVertices]; + +out gl_PerVertex +{ + vec4 gl_Position; +} gl_out[1]; + +layout(location = 0) patch out vec3 vFoo; + +void main() +{ + gl_TessLevelInner[0] = 8.8999996185302734375; + gl_TessLevelInner[1] = 6.900000095367431640625; + gl_TessLevelOuter[0] = 8.8999996185302734375; + gl_TessLevelOuter[1] = 6.900000095367431640625; + gl_TessLevelOuter[2] = 3.900000095367431640625; + gl_TessLevelOuter[3] = 4.900000095367431640625; + vFoo = vec3(1.0); + gl_out[gl_InvocationID].gl_Position = gl_in[0].gl_Position + gl_in[1].gl_Position; +} + diff --git a/reference/opt/shaders/desktop-only/tese/triangle.desktop.sso.tese b/reference/opt/shaders/desktop-only/tese/triangle.desktop.sso.tese new file mode 100644 index 0000000000..31027dae80 --- /dev/null +++ b/reference/opt/shaders/desktop-only/tese/triangle.desktop.sso.tese @@ -0,0 +1,18 @@ +#version 450 +layout(triangles, cw, fractional_even_spacing) in; + +in gl_PerVertex +{ + vec4 gl_Position; +} gl_in[gl_MaxPatchVertices]; + +out gl_PerVertex +{ + vec4 gl_Position; +}; + +void main() +{ + gl_Position = ((gl_in[0].gl_Position * gl_TessCoord.x) + (gl_in[1].gl_Position * gl_TessCoord.y)) + (gl_in[2].gl_Position * gl_TessCoord.z); +} + diff --git a/reference/opt/shaders/desktop-only/vert/basic.desktop.sso.vert b/reference/opt/shaders/desktop-only/vert/basic.desktop.sso.vert new file mode 100644 index 0000000000..5f527e08c1 --- /dev/null +++ b/reference/opt/shaders/desktop-only/vert/basic.desktop.sso.vert @@ -0,0 +1,22 @@ +#version 450 + +out gl_PerVertex +{ + vec4 gl_Position; +}; + +layout(std140) uniform UBO +{ + mat4 uMVP; +} _16; + +layout(location = 0) in vec4 aVertex; +layout(location = 0) out vec3 vNormal; +layout(location = 1) in vec3 aNormal; + +void main() +{ + gl_Position = _16.uMVP * aVertex; + vNormal = aNormal; +} + diff --git a/reference/opt/shaders/desktop-only/vert/clip-cull-distance.desktop.vert b/reference/opt/shaders/desktop-only/vert/clip-cull-distance.desktop.vert new file mode 100644 index 0000000000..566809db23 --- /dev/null +++ b/reference/opt/shaders/desktop-only/vert/clip-cull-distance.desktop.vert @@ -0,0 +1,11 @@ +#version 450 + +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; +} + diff --git a/reference/opt/shaders/desktop-only/vert/out-block-qualifiers.vert b/reference/opt/shaders/desktop-only/vert/out-block-qualifiers.vert new file mode 100644 index 0000000000..7c731684bc --- /dev/null +++ b/reference/opt/shaders/desktop-only/vert/out-block-qualifiers.vert @@ -0,0 +1,27 @@ +#version 450 + +layout(location = 0) out VertexData +{ + flat float f; + centroid vec4 g; + flat int h; + float i; +} vout; + +layout(location = 4) flat out float f; +layout(location = 5) centroid out vec4 g; +layout(location = 6) flat out int h; +layout(location = 7) out float i; + +void main() +{ + vout.f = 10.0; + vout.g = vec4(20.0); + vout.h = 20; + vout.i = 30.0; + f = 10.0; + g = vec4(20.0); + h = 20; + i = 30.0; +} + diff --git a/reference/opt/shaders/flatten/array.flatten.vert b/reference/opt/shaders/flatten/array.flatten.vert new file mode 100644 index 0000000000..de4eb3b78d --- /dev/null +++ b/reference/opt/shaders/flatten/array.flatten.vert @@ -0,0 +1,10 @@ +#version 310 es + +uniform vec4 UBO[56]; +layout(location = 0) in vec4 aVertex; + +void main() +{ + gl_Position = ((mat4(UBO[40], UBO[41], UBO[42], UBO[43]) * aVertex) + UBO[55]) + ((UBO[50] + UBO[45]) + vec4(UBO[54].x)); +} + diff --git a/reference/opt/shaders/flatten/basic.flatten.vert b/reference/opt/shaders/flatten/basic.flatten.vert new file mode 100644 index 0000000000..f7eb758f2a --- /dev/null +++ b/reference/opt/shaders/flatten/basic.flatten.vert @@ -0,0 +1,13 @@ +#version 310 es + +uniform vec4 UBO[4]; +layout(location = 0) in vec4 aVertex; +layout(location = 0) out vec3 vNormal; +layout(location = 1) in vec3 aNormal; + +void main() +{ + gl_Position = mat4(UBO[0], UBO[1], UBO[2], UBO[3]) * aVertex; + vNormal = aNormal; +} + diff --git a/reference/opt/shaders/flatten/copy.flatten.vert b/reference/opt/shaders/flatten/copy.flatten.vert new file mode 100644 index 0000000000..59f0dc1b42 --- /dev/null +++ b/reference/opt/shaders/flatten/copy.flatten.vert @@ -0,0 +1,25 @@ +#version 310 es + +struct Light +{ + vec3 Position; + float Radius; + vec4 Color; +}; + +uniform vec4 UBO[12]; +layout(location = 0) in vec4 aVertex; +layout(location = 0) out vec4 vColor; +layout(location = 1) in vec3 aNormal; + +void main() +{ + gl_Position = mat4(UBO[0], UBO[1], UBO[2], UBO[3]) * aVertex; + vColor = vec4(0.0); + for (int _103 = 0; _103 < 4; _103++) + { + vec3 _68 = aVertex.xyz - Light(UBO[_103 * 2 + 4].xyz, UBO[_103 * 2 + 4].w, UBO[_103 * 2 + 5]).Position; + vColor += (((UBO[_103 * 2 + 5]) * clamp(1.0 - (length(_68) / Light(UBO[_103 * 2 + 4].xyz, UBO[_103 * 2 + 4].w, UBO[_103 * 2 + 5]).Radius), 0.0, 1.0)) * dot(aNormal, normalize(_68))); + } +} + diff --git a/reference/opt/shaders/flatten/dynamic.flatten.vert b/reference/opt/shaders/flatten/dynamic.flatten.vert new file mode 100644 index 0000000000..c08f7445be --- /dev/null +++ b/reference/opt/shaders/flatten/dynamic.flatten.vert @@ -0,0 +1,25 @@ +#version 310 es + +struct Light +{ + vec3 Position; + float Radius; + vec4 Color; +}; + +uniform vec4 UBO[12]; +layout(location = 0) in vec4 aVertex; +layout(location = 0) out vec4 vColor; +layout(location = 1) in vec3 aNormal; + +void main() +{ + gl_Position = mat4(UBO[0], UBO[1], UBO[2], UBO[3]) * aVertex; + vColor = vec4(0.0); + for (int _82 = 0; _82 < 4; _82++) + { + vec3 _54 = aVertex.xyz - (UBO[_82 * 2 + 4].xyz); + vColor += (((UBO[_82 * 2 + 5]) * clamp(1.0 - (length(_54) / (UBO[_82 * 2 + 4].w)), 0.0, 1.0)) * dot(aNormal, normalize(_54))); + } +} + diff --git a/reference/opt/shaders/flatten/matrixindex.flatten.vert b/reference/opt/shaders/flatten/matrixindex.flatten.vert new file mode 100644 index 0000000000..f6d0fa486d --- /dev/null +++ b/reference/opt/shaders/flatten/matrixindex.flatten.vert @@ -0,0 +1,19 @@ +#version 310 es + +uniform vec4 UBO[14]; +layout(location = 0) out vec4 oA; +layout(location = 1) out vec4 oB; +layout(location = 2) out vec4 oC; +layout(location = 3) out vec4 oD; +layout(location = 4) out vec4 oE; + +void main() +{ + gl_Position = vec4(0.0); + oA = UBO[1]; + oB = vec4(UBO[4].y, UBO[5].y, UBO[6].y, UBO[7].y); + oC = UBO[9]; + oD = vec4(UBO[10].x, UBO[11].x, UBO[12].x, UBO[13].x); + oE = vec4(UBO[1].z, UBO[6].y, UBO[9].z, UBO[12].y); +} + diff --git a/reference/opt/shaders/flatten/multi-dimensional.desktop.flatten_dim.frag b/reference/opt/shaders/flatten/multi-dimensional.desktop.flatten_dim.frag new file mode 100644 index 0000000000..6ccede21a9 --- /dev/null +++ b/reference/opt/shaders/flatten/multi-dimensional.desktop.flatten_dim.frag @@ -0,0 +1,34 @@ +#version 450 + +layout(binding = 0) uniform sampler2D uTextures[2 * 3 * 1]; + +layout(location = 1) in vec2 vUV; +layout(location = 0) out vec4 FragColor; +layout(location = 0) flat in int vIndex; + +int _93; + +void main() +{ + vec4 values3[2 * 3 * 1]; + int _96; + int _97; + int _94; + int _95; + for (int _92 = 0; _92 < 2; _92++, _94 = _96, _95 = _97) + { + _96 = 0; + _97 = _95; + int _98; + for (; _96 < 3; _96++, _97 = _98) + { + _98 = 0; + for (; _98 < 1; _98++) + { + values3[_92 * 3 * 1 + _96 * 1 + _98] = texture(uTextures[_92 * 3 * 1 + _96 * 1 + _98], vUV); + } + } + } + FragColor = ((values3[1 * 3 * 1 + 2 * 1 + 0]) + (values3[0 * 3 * 1 + 2 * 1 + 0])) + (values3[(vIndex + 1) * 3 * 1 + 2 * 1 + vIndex]); +} + diff --git a/reference/opt/shaders/flatten/multiindex.flatten.vert b/reference/opt/shaders/flatten/multiindex.flatten.vert new file mode 100644 index 0000000000..3850bf6c70 --- /dev/null +++ b/reference/opt/shaders/flatten/multiindex.flatten.vert @@ -0,0 +1,10 @@ +#version 310 es + +uniform vec4 UBO[15]; +layout(location = 0) in ivec2 aIndex; + +void main() +{ + gl_Position = UBO[aIndex.x * 5 + aIndex.y * 1 + 0]; +} + diff --git a/reference/opt/shaders/flatten/push-constant.flatten.vert b/reference/opt/shaders/flatten/push-constant.flatten.vert new file mode 100644 index 0000000000..216c1f9d1b --- /dev/null +++ b/reference/opt/shaders/flatten/push-constant.flatten.vert @@ -0,0 +1,13 @@ +#version 310 es + +uniform vec4 PushMe[6]; +layout(location = 1) in vec4 Pos; +layout(location = 0) out vec2 vRot; +layout(location = 0) in vec2 Rot; + +void main() +{ + gl_Position = mat4(PushMe[0], PushMe[1], PushMe[2], PushMe[3]) * Pos; + vRot = (mat2(PushMe[4].xy, PushMe[4].zw) * Rot) + vec2(PushMe[5].z); +} + diff --git a/reference/opt/shaders/flatten/rowmajor.flatten.vert b/reference/opt/shaders/flatten/rowmajor.flatten.vert new file mode 100644 index 0000000000..b74aa004b4 --- /dev/null +++ b/reference/opt/shaders/flatten/rowmajor.flatten.vert @@ -0,0 +1,10 @@ +#version 310 es + +uniform vec4 UBO[12]; +layout(location = 0) in vec4 aVertex; + +void main() +{ + gl_Position = (mat4(UBO[0], UBO[1], UBO[2], UBO[3]) * aVertex) + (aVertex * mat4(UBO[4], UBO[5], UBO[6], UBO[7])); +} + diff --git a/reference/opt/shaders/flatten/struct.flatten.vert b/reference/opt/shaders/flatten/struct.flatten.vert new file mode 100644 index 0000000000..35db010c76 --- /dev/null +++ b/reference/opt/shaders/flatten/struct.flatten.vert @@ -0,0 +1,22 @@ +#version 310 es + +struct Light +{ + vec3 Position; + float Radius; + vec4 Color; +}; + +uniform vec4 UBO[6]; +layout(location = 0) in vec4 aVertex; +layout(location = 0) out vec4 vColor; +layout(location = 1) in vec3 aNormal; + +void main() +{ + gl_Position = mat4(UBO[0], UBO[1], UBO[2], UBO[3]) * aVertex; + vColor = vec4(0.0); + vec3 _39 = aVertex.xyz - UBO[4].xyz; + vColor += ((UBO[5] * clamp(1.0 - (length(_39) / UBO[4].w), 0.0, 1.0)) * dot(aNormal, normalize(_39))); +} + diff --git a/reference/opt/shaders/flatten/struct.rowmajor.flatten.vert b/reference/opt/shaders/flatten/struct.rowmajor.flatten.vert new file mode 100644 index 0000000000..0dfa3b46ce --- /dev/null +++ b/reference/opt/shaders/flatten/struct.rowmajor.flatten.vert @@ -0,0 +1,20 @@ +#version 310 es + +struct Foo +{ + mat3x4 MVP0; + mat3x4 MVP1; +}; + +uniform vec4 UBO[8]; +layout(location = 0) in vec4 v0; +layout(location = 1) in vec4 v1; +layout(location = 0) out vec3 V0; +layout(location = 1) out vec3 V1; + +void main() +{ + V0 = v0 * Foo(transpose(mat4x3(UBO[0].xyz, UBO[1].xyz, UBO[2].xyz, UBO[3].xyz)), transpose(mat4x3(UBO[4].xyz, UBO[5].xyz, UBO[6].xyz, UBO[7].xyz))).MVP0; + V1 = v1 * Foo(transpose(mat4x3(UBO[0].xyz, UBO[1].xyz, UBO[2].xyz, UBO[3].xyz)), transpose(mat4x3(UBO[4].xyz, UBO[5].xyz, UBO[6].xyz, UBO[7].xyz))).MVP1; +} + diff --git a/reference/opt/shaders/flatten/swizzle.flatten.vert b/reference/opt/shaders/flatten/swizzle.flatten.vert new file mode 100644 index 0000000000..92afb475e6 --- /dev/null +++ b/reference/opt/shaders/flatten/swizzle.flatten.vert @@ -0,0 +1,21 @@ +#version 310 es + +uniform vec4 UBO[8]; +layout(location = 0) out vec4 oA; +layout(location = 1) out vec4 oB; +layout(location = 2) out vec4 oC; +layout(location = 3) out vec4 oD; +layout(location = 4) out vec4 oE; +layout(location = 5) out vec4 oF; + +void main() +{ + gl_Position = vec4(0.0); + oA = UBO[0]; + oB = vec4(UBO[1].xy, UBO[1].zw); + oC = vec4(UBO[2].x, UBO[3].xyz); + oD = vec4(UBO[4].xyz, UBO[4].w); + oE = vec4(UBO[5].x, UBO[5].y, UBO[5].z, UBO[5].w); + oF = vec4(UBO[6].x, UBO[6].zw, UBO[7].x); +} + diff --git a/reference/opt/shaders/flatten/types.flatten.frag b/reference/opt/shaders/flatten/types.flatten.frag new file mode 100644 index 0000000000..a74327d97b --- /dev/null +++ b/reference/opt/shaders/flatten/types.flatten.frag @@ -0,0 +1,14 @@ +#version 310 es +precision mediump float; +precision highp int; + +uniform mediump ivec4 UBO1[2]; +uniform mediump uvec4 UBO2[2]; +uniform vec4 UBO0[2]; +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = ((((vec4(UBO1[0]) + vec4(UBO1[1])) + vec4(UBO2[0])) + vec4(UBO2[1])) + UBO0[0]) + UBO0[1]; +} + diff --git a/reference/opt/shaders/frag/basic.frag b/reference/opt/shaders/frag/basic.frag new file mode 100644 index 0000000000..2a4e440421 --- /dev/null +++ b/reference/opt/shaders/frag/basic.frag @@ -0,0 +1,15 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(binding = 0) uniform mediump sampler2D uTex; + +layout(location = 0) out vec4 FragColor; +layout(location = 0) in vec4 vColor; +layout(location = 1) in vec2 vTex; + +void main() +{ + FragColor = vColor * texture(uTex, vTex); +} + diff --git a/reference/opt/shaders/frag/composite-extract-forced-temporary.frag b/reference/opt/shaders/frag/composite-extract-forced-temporary.frag new file mode 100644 index 0000000000..eb59732fdc --- /dev/null +++ b/reference/opt/shaders/frag/composite-extract-forced-temporary.frag @@ -0,0 +1,16 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(binding = 0) uniform mediump sampler2D Texture; + +layout(location = 0) in vec2 vTexCoord; +layout(location = 0) out vec4 FragColor; + +void main() +{ + vec4 _19 = texture(Texture, vTexCoord); + float _22 = _19.x; + FragColor = vec4(_22 * _22); +} + diff --git a/reference/opt/shaders/frag/constant-array.frag b/reference/opt/shaders/frag/constant-array.frag new file mode 100644 index 0000000000..a6ffda0737 --- /dev/null +++ b/reference/opt/shaders/frag/constant-array.frag @@ -0,0 +1,21 @@ +#version 310 es +precision mediump float; +precision highp int; + +struct Foobar +{ + float a; + float b; +}; + +layout(location = 0) out vec4 FragColor; +layout(location = 0) flat in mediump int index; + +void main() +{ + highp vec4 indexable[3] = vec4[](vec4(1.0), vec4(2.0), vec4(3.0)); + highp vec4 indexable_1[2][2] = vec4[][](vec4[](vec4(1.0), vec4(2.0)), vec4[](vec4(8.0), vec4(10.0))); + Foobar indexable_2[2] = Foobar[](Foobar(10.0, 40.0), Foobar(90.0, 70.0)); + FragColor = ((indexable[index] + (indexable_1[index][index + 1])) + vec4(10.0 + 20.0)) + vec4(indexable_2[index].a + indexable_2[index].b); +} + diff --git a/reference/opt/shaders/frag/constant-composites.frag b/reference/opt/shaders/frag/constant-composites.frag new file mode 100644 index 0000000000..ab0816c3d2 --- /dev/null +++ b/reference/opt/shaders/frag/constant-composites.frag @@ -0,0 +1,23 @@ +#version 310 es +precision mediump float; +precision highp int; + +struct Foo +{ + float a; + float b; +}; + +layout(location = 0) out vec4 FragColor; +layout(location = 0) flat in mediump int _line; +float lut[4]; +Foo foos[2]; + +void main() +{ + lut = float[](1.0, 4.0, 3.0, 2.0); + foos = Foo[](Foo(10.0, 20.0), Foo(30.0, 40.0)); + FragColor = vec4(lut[_line]); + FragColor += vec4(foos[_line].a * (foos[1 - _line].a)); +} + diff --git a/reference/opt/shaders/frag/eliminate-dead-variables.frag b/reference/opt/shaders/frag/eliminate-dead-variables.frag new file mode 100644 index 0000000000..c97ae20f9a --- /dev/null +++ b/reference/opt/shaders/frag/eliminate-dead-variables.frag @@ -0,0 +1,14 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(binding = 0) uniform mediump sampler2D uSampler; + +layout(location = 0) out vec4 FragColor; +layout(location = 0) in vec2 vTexCoord; + +void main() +{ + FragColor = texture(uSampler, vTexCoord); +} + diff --git a/reference/opt/shaders/frag/false-loop-init.frag b/reference/opt/shaders/frag/false-loop-init.frag new file mode 100644 index 0000000000..1db46c1bd5 --- /dev/null +++ b/reference/opt/shaders/frag/false-loop-init.frag @@ -0,0 +1,28 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(location = 0) out vec4 result; +layout(location = 0) in vec4 accum; + +uint _49; + +void main() +{ + result = vec4(0.0); + uint _51; + uint _50; + for (int _48 = 0; _48 < 4; _48 += int(_51), _50 = _51) + { + if (accum.y > 10.0) + { + _51 = 40u; + } + else + { + _51 = 30u; + } + result += accum; + } +} + diff --git a/reference/opt/shaders/frag/flush_params.frag b/reference/opt/shaders/frag/flush_params.frag new file mode 100644 index 0000000000..5f386dffbb --- /dev/null +++ b/reference/opt/shaders/frag/flush_params.frag @@ -0,0 +1,16 @@ +#version 310 es +precision mediump float; +precision highp int; + +struct Structy +{ + vec4 c; +}; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = vec4(10.0); +} + diff --git a/reference/opt/shaders/frag/for-loop-init.frag b/reference/opt/shaders/frag/for-loop-init.frag new file mode 100644 index 0000000000..626d7c8d5e --- /dev/null +++ b/reference/opt/shaders/frag/for-loop-init.frag @@ -0,0 +1,51 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(location = 0) out mediump int FragColor; + +void main() +{ + FragColor = 16; + for (int _140 = 0; _140 < 25; _140++) + { + FragColor += 10; + } + for (int _141 = 1; _141 < 30; _141++) + { + FragColor += 11; + } + int _142; + _142 = 0; + for (; _142 < 20; _142++) + { + FragColor += 12; + } + mediump int _62 = _142 + 3; + FragColor += _62; + if (_62 == 40) + { + for (int _143 = 0; _143 < 40; _143++) + { + FragColor += 13; + } + return; + } + else + { + FragColor += _62; + } + ivec2 _144; + _144 = ivec2(0); + ivec2 _139; + for (; _144.x < 10; _139 = _144, _139.x = _144.x + 4, _144 = _139) + { + FragColor += _144.y; + } + for (int _145 = _62; _145 < 40; _145++) + { + FragColor += _145; + } + FragColor += _62; +} + diff --git a/reference/opt/shaders/frag/frexp-modf.frag b/reference/opt/shaders/frag/frexp-modf.frag new file mode 100644 index 0000000000..25f3360aaa --- /dev/null +++ b/reference/opt/shaders/frag/frexp-modf.frag @@ -0,0 +1,33 @@ +#version 310 es +precision mediump float; +precision highp int; + +struct ResType +{ + highp float _m0; + int _m1; +}; + +struct ResType_1 +{ + highp vec2 _m0; + ivec2 _m1; +}; + +layout(location = 0) in float v0; +layout(location = 1) in vec2 v1; +layout(location = 0) out float FragColor; + +void main() +{ + ResType _22; + _22._m0 = frexp(v0 + 1.0, _22._m1); + ResType_1 _35; + _35._m0 = frexp(v1, _35._m1); + float r0; + float _41 = modf(v0, r0); + vec2 r1; + vec2 _45 = modf(v1, r1); + FragColor = ((((_22._m0 + _35._m0.x) + _35._m0.y) + _41) + _45.x) + _45.y; +} + diff --git a/reference/opt/shaders/frag/ground.frag b/reference/opt/shaders/frag/ground.frag new file mode 100644 index 0000000000..aaca58c1cd --- /dev/null +++ b/reference/opt/shaders/frag/ground.frag @@ -0,0 +1,35 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(binding = 4, std140) uniform GlobalPSData +{ + vec4 g_CamPos; + vec4 g_SunDir; + vec4 g_SunColor; + vec4 g_ResolutionParams; + vec4 g_TimeParams; + vec4 g_FogColor_Distance; +} _101; + +layout(binding = 2) uniform mediump sampler2D TexNormalmap; + +layout(location = 3) out vec4 LightingOut; +layout(location = 2) out vec4 NormalOut; +layout(location = 1) out vec4 SpecularOut; +layout(location = 0) out vec4 AlbedoOut; +layout(location = 0) in vec2 TexCoord; +layout(location = 1) in vec3 EyeVec; + +void main() +{ + vec3 _68 = normalize((texture(TexNormalmap, TexCoord).xyz * 2.0) - vec3(1.0)); + float _113 = smoothstep(0.0, 0.1500000059604644775390625, (_101.g_CamPos.y + EyeVec.y) / 200.0); + float _125 = smoothstep(0.699999988079071044921875, 0.75, _68.y); + vec3 _130 = mix(vec3(0.100000001490116119384765625), mix(vec3(0.100000001490116119384765625, 0.300000011920928955078125, 0.100000001490116119384765625), vec3(0.800000011920928955078125), vec3(_113)), vec3(_125)); + LightingOut = vec4(0.0); + NormalOut = vec4((_68 * 0.5) + vec3(0.5), 0.0); + SpecularOut = vec4(1.0 - (_125 * _113), 0.0, 0.0, 0.0); + AlbedoOut = vec4(_130 * _130, 1.0); +} + diff --git a/reference/opt/shaders/frag/image-load-store-uint-coord.asm.frag b/reference/opt/shaders/frag/image-load-store-uint-coord.asm.frag new file mode 100644 index 0000000000..5dfb4d0028 --- /dev/null +++ b/reference/opt/shaders/frag/image-load-store-uint-coord.asm.frag @@ -0,0 +1,17 @@ +#version 450 + +layout(binding = 1, rgba32f) uniform image2D RWIm; +layout(binding = 0, rgba32f) uniform writeonly imageBuffer RWBuf; +layout(binding = 1) uniform sampler2D ROIm; +layout(binding = 0) uniform samplerBuffer ROBuf; + +layout(location = 0) out vec4 _entryPointOutput; + +void main() +{ + imageStore(RWIm, ivec2(uvec2(10u)), vec4(10.0, 0.5, 8.0, 2.0)); + vec4 _69 = imageLoad(RWIm, ivec2(uvec2(30u))); + imageStore(RWBuf, int(80u), _69); + _entryPointOutput = (_69 + texelFetch(ROIm, ivec2(uvec2(50u, 60u)), 0)) + texelFetch(ROBuf, int(80u)); +} + diff --git a/reference/opt/shaders/frag/mix.frag b/reference/opt/shaders/frag/mix.frag new file mode 100644 index 0000000000..f1494e0775 --- /dev/null +++ b/reference/opt/shaders/frag/mix.frag @@ -0,0 +1,18 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(location = 0) out vec4 FragColor; +layout(location = 0) in vec4 vIn0; +layout(location = 1) in vec4 vIn1; +layout(location = 2) in float vIn2; +layout(location = 3) in float vIn3; + +void main() +{ + FragColor = mix(vIn0, vIn1, bvec4(false, true, false, false)); + FragColor = vec4(true ? vIn3 : vIn2); + FragColor = mix(vIn1, vIn0, bvec4(true)); + FragColor = vec4(true ? vIn2 : vIn3); +} + diff --git a/reference/opt/shaders/frag/partial-write-preserve.frag b/reference/opt/shaders/frag/partial-write-preserve.frag new file mode 100644 index 0000000000..527b661bcc --- /dev/null +++ b/reference/opt/shaders/frag/partial-write-preserve.frag @@ -0,0 +1,14 @@ +#version 310 es +precision mediump float; +precision highp int; + +struct B +{ + float a; + float b; +}; + +void main() +{ +} + diff --git a/reference/opt/shaders/frag/pls.frag b/reference/opt/shaders/frag/pls.frag new file mode 100644 index 0000000000..1cafdbd365 --- /dev/null +++ b/reference/opt/shaders/frag/pls.frag @@ -0,0 +1,21 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(location = 0) out vec4 PLSOut0; +layout(location = 0) in vec4 PLSIn0; +layout(location = 1) out vec4 PLSOut1; +layout(location = 1) in vec4 PLSIn1; +layout(location = 2) out vec4 PLSOut2; +layout(location = 2) in vec4 PLSIn2; +layout(location = 3) out vec4 PLSOut3; +layout(location = 3) in vec4 PLSIn3; + +void main() +{ + PLSOut0 = PLSIn0 * 2.0; + PLSOut1 = PLSIn1 * 6.0; + PLSOut2 = PLSIn2 * 7.0; + PLSOut3 = PLSIn3 * 4.0; +} + diff --git a/reference/opt/shaders/frag/sample-parameter.frag b/reference/opt/shaders/frag/sample-parameter.frag new file mode 100644 index 0000000000..3c130e68d4 --- /dev/null +++ b/reference/opt/shaders/frag/sample-parameter.frag @@ -0,0 +1,13 @@ +#version 310 es +#extension GL_OES_sample_variables : require +precision mediump float; +precision highp int; + +layout(location = 0) out vec2 FragColor; + +void main() +{ + FragColor = (gl_SamplePosition + vec2(float(gl_SampleMaskIn[0]))) + vec2(float(gl_SampleID)); + gl_SampleMask[0] = 1; +} + diff --git a/reference/opt/shaders/frag/sampler-ms-query.frag b/reference/opt/shaders/frag/sampler-ms-query.frag new file mode 100644 index 0000000000..4c30ed1529 --- /dev/null +++ b/reference/opt/shaders/frag/sampler-ms-query.frag @@ -0,0 +1,14 @@ +#version 450 + +layout(binding = 0) uniform sampler2DMS uSampler; +layout(binding = 1) uniform sampler2DMSArray uSamplerArray; +layout(binding = 2, rgba8) uniform readonly writeonly image2DMS uImage; +layout(binding = 3, rgba8) uniform readonly writeonly image2DMSArray uImageArray; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = vec4(float(((textureSamples(uSampler) + textureSamples(uSamplerArray)) + imageSamples(uImage)) + imageSamples(uImageArray))); +} + diff --git a/reference/opt/shaders/frag/sampler-ms.frag b/reference/opt/shaders/frag/sampler-ms.frag new file mode 100644 index 0000000000..d78b805d09 --- /dev/null +++ b/reference/opt/shaders/frag/sampler-ms.frag @@ -0,0 +1,14 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(binding = 0) uniform mediump sampler2DMS uSampler; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + ivec2 _17 = ivec2(gl_FragCoord.xy); + FragColor = ((texelFetch(uSampler, _17, 0) + texelFetch(uSampler, _17, 1)) + texelFetch(uSampler, _17, 2)) + texelFetch(uSampler, _17, 3); +} + diff --git a/reference/opt/shaders/frag/sampler-proj.frag b/reference/opt/shaders/frag/sampler-proj.frag new file mode 100644 index 0000000000..865dec6c8b --- /dev/null +++ b/reference/opt/shaders/frag/sampler-proj.frag @@ -0,0 +1,16 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(binding = 0) uniform mediump sampler2D uTex; + +layout(location = 0) out vec4 FragColor; +layout(location = 0) in vec4 vTex; + +void main() +{ + highp vec4 _19 = vTex; + _19.z = vTex.w; + FragColor = textureProj(uTex, _19.xyz); +} + diff --git a/reference/opt/shaders/frag/sampler.frag b/reference/opt/shaders/frag/sampler.frag new file mode 100644 index 0000000000..2a4e440421 --- /dev/null +++ b/reference/opt/shaders/frag/sampler.frag @@ -0,0 +1,15 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(binding = 0) uniform mediump sampler2D uTex; + +layout(location = 0) out vec4 FragColor; +layout(location = 0) in vec4 vColor; +layout(location = 1) in vec2 vTex; + +void main() +{ + FragColor = vColor * texture(uTex, vTex); +} + diff --git a/reference/opt/shaders/frag/swizzle.frag b/reference/opt/shaders/frag/swizzle.frag new file mode 100644 index 0000000000..e619be2f48 --- /dev/null +++ b/reference/opt/shaders/frag/swizzle.frag @@ -0,0 +1,20 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(location = 0) uniform mediump sampler2D samp; + +layout(location = 0) out vec4 FragColor; +layout(location = 2) in vec2 vUV; +layout(location = 1) in vec3 vNormal; + +void main() +{ + FragColor = vec4(texture(samp, vUV).xyz, 1.0); + FragColor = vec4(texture(samp, vUV).xz, 1.0, 4.0); + FragColor = vec4(texture(samp, vUV).xx, texture(samp, vUV + vec2(0.100000001490116119384765625)).yy); + FragColor = vec4(vNormal, 1.0); + FragColor = vec4(vNormal + vec3(1.7999999523162841796875), 1.0); + FragColor = vec4(vUV, vUV + vec2(1.7999999523162841796875)); +} + diff --git a/reference/opt/shaders/frag/temporary.frag b/reference/opt/shaders/frag/temporary.frag new file mode 100644 index 0000000000..ec9d3e4958 --- /dev/null +++ b/reference/opt/shaders/frag/temporary.frag @@ -0,0 +1,14 @@ +#version 310 es +precision mediump float; +precision highp int; + +uniform mediump sampler2D uTex; + +layout(location = 0) in vec2 vTex; +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = vec4(vTex.xxy, 1.0) + vec4(texture(uTex, vTex).xyz, 1.0); +} + diff --git a/reference/opt/shaders/frag/ubo_layout.frag b/reference/opt/shaders/frag/ubo_layout.frag new file mode 100644 index 0000000000..bc0b01c065 --- /dev/null +++ b/reference/opt/shaders/frag/ubo_layout.frag @@ -0,0 +1,26 @@ +#version 310 es +precision mediump float; +precision highp int; + +struct Str +{ + mat4 foo; +}; + +layout(binding = 0, std140) uniform UBO1 +{ + layout(row_major) Str foo; +} ubo1; + +layout(binding = 1, std140) uniform UBO2 +{ + Str foo; +} ubo0; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = ubo1.foo.foo[0] + ubo0.foo.foo[0]; +} + diff --git a/reference/opt/shaders/frag/unary-enclose.frag b/reference/opt/shaders/frag/unary-enclose.frag new file mode 100644 index 0000000000..118787bdf9 --- /dev/null +++ b/reference/opt/shaders/frag/unary-enclose.frag @@ -0,0 +1,12 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(location = 0) out vec4 FragColor; +layout(location = 0) in vec4 vIn; + +void main() +{ + FragColor = -(-vIn); +} + diff --git a/reference/opt/shaders/geom/basic.geom b/reference/opt/shaders/geom/basic.geom new file mode 100644 index 0000000000..296ce5792c --- /dev/null +++ b/reference/opt/shaders/geom/basic.geom @@ -0,0 +1,26 @@ +#version 310 es +#extension GL_EXT_geometry_shader : require +layout(invocations = 4, triangles) in; +layout(max_vertices = 3, triangle_strip) out; + +layout(location = 0) out vec3 vNormal; +layout(location = 0) in VertexData +{ + vec3 normal; +} vin[3]; + + +void main() +{ + gl_Position = gl_in[0].gl_Position; + vNormal = vin[0].normal + vec3(float(gl_InvocationID)); + EmitVertex(); + gl_Position = gl_in[1].gl_Position; + vNormal = vin[1].normal + vec3(4.0 * float(gl_InvocationID)); + EmitVertex(); + gl_Position = gl_in[2].gl_Position; + vNormal = vin[2].normal + vec3(2.0 * float(gl_InvocationID)); + EmitVertex(); + EndPrimitive(); +} + diff --git a/reference/opt/shaders/geom/lines-adjacency.geom b/reference/opt/shaders/geom/lines-adjacency.geom new file mode 100644 index 0000000000..46a21e9fb0 --- /dev/null +++ b/reference/opt/shaders/geom/lines-adjacency.geom @@ -0,0 +1,26 @@ +#version 310 es +#extension GL_EXT_geometry_shader : require +layout(lines_adjacency) in; +layout(max_vertices = 3, line_strip) out; + +layout(location = 0) out vec3 vNormal; +layout(location = 0) in VertexData +{ + vec3 normal; +} vin[4]; + + +void main() +{ + gl_Position = gl_in[0].gl_Position; + vNormal = vin[0].normal; + EmitVertex(); + gl_Position = gl_in[1].gl_Position; + vNormal = vin[1].normal; + EmitVertex(); + gl_Position = gl_in[2].gl_Position; + vNormal = vin[2].normal; + EmitVertex(); + EndPrimitive(); +} + diff --git a/reference/opt/shaders/geom/lines.geom b/reference/opt/shaders/geom/lines.geom new file mode 100644 index 0000000000..c5aaa53d35 --- /dev/null +++ b/reference/opt/shaders/geom/lines.geom @@ -0,0 +1,23 @@ +#version 310 es +#extension GL_EXT_geometry_shader : require +layout(lines) in; +layout(max_vertices = 2, line_strip) out; + +layout(location = 0) out vec3 vNormal; +layout(location = 0) in VertexData +{ + vec3 normal; +} vin[2]; + + +void main() +{ + gl_Position = gl_in[0].gl_Position; + vNormal = vin[0].normal; + EmitVertex(); + gl_Position = gl_in[1].gl_Position; + vNormal = vin[1].normal; + EmitVertex(); + EndPrimitive(); +} + diff --git a/reference/opt/shaders/geom/points.geom b/reference/opt/shaders/geom/points.geom new file mode 100644 index 0000000000..4d59137c3a --- /dev/null +++ b/reference/opt/shaders/geom/points.geom @@ -0,0 +1,26 @@ +#version 310 es +#extension GL_EXT_geometry_shader : require +layout(points) in; +layout(max_vertices = 3, points) out; + +layout(location = 0) out vec3 vNormal; +layout(location = 0) in VertexData +{ + vec3 normal; +} vin[1]; + + +void main() +{ + gl_Position = gl_in[0].gl_Position; + vNormal = vin[0].normal; + EmitVertex(); + gl_Position = gl_in[0].gl_Position; + vNormal = vin[0].normal; + EmitVertex(); + gl_Position = gl_in[0].gl_Position; + vNormal = vin[0].normal; + EmitVertex(); + EndPrimitive(); +} + diff --git a/reference/opt/shaders/geom/single-invocation.geom b/reference/opt/shaders/geom/single-invocation.geom new file mode 100644 index 0000000000..fdccacc04f --- /dev/null +++ b/reference/opt/shaders/geom/single-invocation.geom @@ -0,0 +1,26 @@ +#version 310 es +#extension GL_EXT_geometry_shader : require +layout(triangles) in; +layout(max_vertices = 3, triangle_strip) out; + +layout(location = 0) out vec3 vNormal; +layout(location = 0) in VertexData +{ + vec3 normal; +} vin[3]; + + +void main() +{ + gl_Position = gl_in[0].gl_Position; + vNormal = vin[0].normal; + EmitVertex(); + gl_Position = gl_in[1].gl_Position; + vNormal = vin[1].normal; + EmitVertex(); + gl_Position = gl_in[2].gl_Position; + vNormal = vin[2].normal; + EmitVertex(); + EndPrimitive(); +} + diff --git a/reference/opt/shaders/geom/triangles-adjacency.geom b/reference/opt/shaders/geom/triangles-adjacency.geom new file mode 100644 index 0000000000..e9e6857a1f --- /dev/null +++ b/reference/opt/shaders/geom/triangles-adjacency.geom @@ -0,0 +1,26 @@ +#version 310 es +#extension GL_EXT_geometry_shader : require +layout(triangles_adjacency) in; +layout(max_vertices = 3, triangle_strip) out; + +layout(location = 0) out vec3 vNormal; +layout(location = 0) in VertexData +{ + vec3 normal; +} vin[6]; + + +void main() +{ + gl_Position = gl_in[0].gl_Position; + vNormal = vin[0].normal; + EmitVertex(); + gl_Position = gl_in[1].gl_Position; + vNormal = vin[1].normal; + EmitVertex(); + gl_Position = gl_in[2].gl_Position; + vNormal = vin[2].normal; + EmitVertex(); + EndPrimitive(); +} + diff --git a/reference/opt/shaders/geom/triangles.geom b/reference/opt/shaders/geom/triangles.geom new file mode 100644 index 0000000000..fdccacc04f --- /dev/null +++ b/reference/opt/shaders/geom/triangles.geom @@ -0,0 +1,26 @@ +#version 310 es +#extension GL_EXT_geometry_shader : require +layout(triangles) in; +layout(max_vertices = 3, triangle_strip) out; + +layout(location = 0) out vec3 vNormal; +layout(location = 0) in VertexData +{ + vec3 normal; +} vin[3]; + + +void main() +{ + gl_Position = gl_in[0].gl_Position; + vNormal = vin[0].normal; + EmitVertex(); + gl_Position = gl_in[1].gl_Position; + vNormal = vin[1].normal; + EmitVertex(); + gl_Position = gl_in[2].gl_Position; + vNormal = vin[2].normal; + EmitVertex(); + EndPrimitive(); +} + diff --git a/reference/opt/shaders/legacy/fragment/explicit-lod.legacy.frag b/reference/opt/shaders/legacy/fragment/explicit-lod.legacy.frag new file mode 100644 index 0000000000..6e8dbf1a9c --- /dev/null +++ b/reference/opt/shaders/legacy/fragment/explicit-lod.legacy.frag @@ -0,0 +1,12 @@ +#version 100 +#extension GL_EXT_shader_texture_lod : require +precision mediump float; +precision highp int; + +uniform mediump sampler2D tex; + +void main() +{ + gl_FragData[0] = texture2DLodEXT(tex, vec2(0.4000000059604644775390625, 0.60000002384185791015625), 0.0); +} + diff --git a/reference/opt/shaders/legacy/fragment/io-blocks.legacy.frag b/reference/opt/shaders/legacy/fragment/io-blocks.legacy.frag new file mode 100644 index 0000000000..d5a60d53e9 --- /dev/null +++ b/reference/opt/shaders/legacy/fragment/io-blocks.legacy.frag @@ -0,0 +1,12 @@ +#version 100 +precision mediump float; +precision highp int; + +varying vec4 vin_color; +varying highp vec3 vin_normal; + +void main() +{ + gl_FragData[0] = vin_color + vin_normal.xyzz; +} + diff --git a/reference/opt/shaders/legacy/fragment/struct-varying.legacy.frag b/reference/opt/shaders/legacy/fragment/struct-varying.legacy.frag new file mode 100644 index 0000000000..e131f2e21c --- /dev/null +++ b/reference/opt/shaders/legacy/fragment/struct-varying.legacy.frag @@ -0,0 +1,18 @@ +#version 100 +precision mediump float; +precision highp int; + +struct Inputs +{ + highp vec4 a; + highp vec2 b; +}; + +varying highp vec4 vin_a; +varying highp vec2 vin_b; + +void main() +{ + gl_FragData[0] = ((((Inputs(vin_a, vin_b).a + Inputs(vin_a, vin_b).b.xxyy) + Inputs(vin_a, vin_b).a) + Inputs(vin_a, vin_b).b.yyxx) + vin_a) + vin_b.xxyy; +} + diff --git a/reference/opt/shaders/legacy/vert/implicit-lod.legacy.vert b/reference/opt/shaders/legacy/vert/implicit-lod.legacy.vert new file mode 100644 index 0000000000..6e44107448 --- /dev/null +++ b/reference/opt/shaders/legacy/vert/implicit-lod.legacy.vert @@ -0,0 +1,9 @@ +#version 100 + +uniform mediump sampler2D tex; + +void main() +{ + gl_Position = texture2D(tex, vec2(0.4000000059604644775390625, 0.60000002384185791015625)); +} + diff --git a/reference/opt/shaders/legacy/vert/io-block.legacy.vert b/reference/opt/shaders/legacy/vert/io-block.legacy.vert new file mode 100644 index 0000000000..3c518dc79e --- /dev/null +++ b/reference/opt/shaders/legacy/vert/io-block.legacy.vert @@ -0,0 +1,13 @@ +#version 100 + +attribute vec4 Position; +varying vec4 vout_color; +varying vec3 vout_normal; + +void main() +{ + gl_Position = Position; + vout_color = vec4(1.0); + vout_normal = vec3(0.5); +} + diff --git a/reference/opt/shaders/legacy/vert/struct-varying.legacy.vert b/reference/opt/shaders/legacy/vert/struct-varying.legacy.vert new file mode 100644 index 0000000000..8520e2d562 --- /dev/null +++ b/reference/opt/shaders/legacy/vert/struct-varying.legacy.vert @@ -0,0 +1,30 @@ +#version 100 + +struct Output +{ + vec4 a; + vec2 b; +}; + +varying vec4 vout_a; +varying vec2 vout_b; + +void main() +{ + { + Output vout = Output(vec4(0.5), vec2(0.25)); + vout_a = vout.a; + vout_b = vout.b; + } + { + Output vout = Output(vec4(0.5), vec2(0.25)); + vout_a = vout.a; + vout_b = vout.b; + } + Output _22 = Output(vout_a, vout_b); + vout_a = _22.a; + vout_b = _22.b; + vout_a.x = 1.0; + vout_b.y = 1.0; +} + diff --git a/reference/opt/shaders/legacy/vert/transpose.legacy.vert b/reference/opt/shaders/legacy/vert/transpose.legacy.vert new file mode 100644 index 0000000000..0d30c0e243 --- /dev/null +++ b/reference/opt/shaders/legacy/vert/transpose.legacy.vert @@ -0,0 +1,18 @@ +#version 100 + +struct Buffer +{ + mat4 MVPRowMajor; + mat4 MVPColMajor; + mat4 M; +}; + +uniform Buffer _13; + +attribute vec4 Position; + +void main() +{ + gl_Position = (((_13.M * (Position * _13.MVPRowMajor)) + (_13.M * (_13.MVPColMajor * Position))) + (_13.M * (_13.MVPRowMajor * Position))) + (_13.M * (Position * _13.MVPColMajor)); +} + diff --git a/reference/opt/shaders/tesc/basic.tesc b/reference/opt/shaders/tesc/basic.tesc new file mode 100644 index 0000000000..6019151adb --- /dev/null +++ b/reference/opt/shaders/tesc/basic.tesc @@ -0,0 +1,17 @@ +#version 310 es +#extension GL_EXT_tessellation_shader : require +layout(vertices = 1) out; + +layout(location = 0) patch out vec3 vFoo; + +void main() +{ + gl_TessLevelInner[0] = 8.8999996185302734375; + gl_TessLevelInner[1] = 6.900000095367431640625; + gl_TessLevelOuter[0] = 8.8999996185302734375; + gl_TessLevelOuter[1] = 6.900000095367431640625; + gl_TessLevelOuter[2] = 3.900000095367431640625; + gl_TessLevelOuter[3] = 4.900000095367431640625; + vFoo = vec3(1.0); +} + diff --git a/reference/opt/shaders/tesc/water_tess.tesc b/reference/opt/shaders/tesc/water_tess.tesc new file mode 100644 index 0000000000..0320fff2ca --- /dev/null +++ b/reference/opt/shaders/tesc/water_tess.tesc @@ -0,0 +1,79 @@ +#version 310 es +#extension GL_EXT_tessellation_shader : require +layout(vertices = 1) out; + +layout(std140) uniform UBO +{ + vec4 uScale; + vec3 uCamPos; + vec2 uPatchSize; + vec2 uMaxTessLevel; + float uDistanceMod; + vec4 uFrustum[6]; +} _41; + +layout(location = 1) patch out vec2 vOutPatchPosBase; +layout(location = 2) patch out vec4 vPatchLods; +layout(location = 0) in vec2 vPatchPosBase[]; + +void main() +{ + vec2 _430 = (vPatchPosBase[0] - vec2(10.0)) * _41.uScale.xy; + vec2 _440 = ((vPatchPosBase[0] + _41.uPatchSize) + vec2(10.0)) * _41.uScale.xy; + vec3 _445 = vec3(_430.x, -10.0, _430.y); + vec3 _450 = vec3(_440.x, 10.0, _440.y); + vec3 _454 = (_445 + _450) * 0.5; + float _459 = 0.5 * length(_450 - _445); + bool _515 = any(lessThanEqual(vec3(dot(_41.uFrustum[0], vec4(_454, 1.0)), dot(_41.uFrustum[1], vec4(_454, 1.0)), dot(_41.uFrustum[2], vec4(_454, 1.0))), vec3(-_459))); + bool _525; + if (!_515) + { + _525 = any(lessThanEqual(vec3(dot(_41.uFrustum[3], vec4(_454, 1.0)), dot(_41.uFrustum[4], vec4(_454, 1.0)), dot(_41.uFrustum[5], vec4(_454, 1.0))), vec3(-_459))); + } + else + { + _525 = _515; + } + if (!(!_525)) + { + gl_TessLevelOuter[0] = -1.0; + gl_TessLevelOuter[1] = -1.0; + gl_TessLevelOuter[2] = -1.0; + gl_TessLevelOuter[3] = -1.0; + gl_TessLevelInner[0] = -1.0; + gl_TessLevelInner[1] = -1.0; + } + else + { + vOutPatchPosBase = vPatchPosBase[0]; + vec2 _678 = (vPatchPosBase[0] + (vec2(-0.5) * _41.uPatchSize)) * _41.uScale.xy; + vec2 _706 = (vPatchPosBase[0] + (vec2(0.5, -0.5) * _41.uPatchSize)) * _41.uScale.xy; + float _725 = clamp(log2((length(_41.uCamPos - vec3(_706.x, 0.0, _706.y)) + 9.9999997473787516355514526367188e-05) * _41.uDistanceMod), 0.0, _41.uMaxTessLevel.x); + vec2 _734 = (vPatchPosBase[0] + (vec2(1.5, -0.5) * _41.uPatchSize)) * _41.uScale.xy; + vec2 _762 = (vPatchPosBase[0] + (vec2(-0.5, 0.5) * _41.uPatchSize)) * _41.uScale.xy; + float _781 = clamp(log2((length(_41.uCamPos - vec3(_762.x, 0.0, _762.y)) + 9.9999997473787516355514526367188e-05) * _41.uDistanceMod), 0.0, _41.uMaxTessLevel.x); + vec2 _790 = (vPatchPosBase[0] + (vec2(0.5) * _41.uPatchSize)) * _41.uScale.xy; + float _809 = clamp(log2((length(_41.uCamPos - vec3(_790.x, 0.0, _790.y)) + 9.9999997473787516355514526367188e-05) * _41.uDistanceMod), 0.0, _41.uMaxTessLevel.x); + vec2 _818 = (vPatchPosBase[0] + (vec2(1.5, 0.5) * _41.uPatchSize)) * _41.uScale.xy; + float _837 = clamp(log2((length(_41.uCamPos - vec3(_818.x, 0.0, _818.y)) + 9.9999997473787516355514526367188e-05) * _41.uDistanceMod), 0.0, _41.uMaxTessLevel.x); + vec2 _846 = (vPatchPosBase[0] + (vec2(-0.5, 1.5) * _41.uPatchSize)) * _41.uScale.xy; + vec2 _874 = (vPatchPosBase[0] + (vec2(0.5, 1.5) * _41.uPatchSize)) * _41.uScale.xy; + float _893 = clamp(log2((length(_41.uCamPos - vec3(_874.x, 0.0, _874.y)) + 9.9999997473787516355514526367188e-05) * _41.uDistanceMod), 0.0, _41.uMaxTessLevel.x); + vec2 _902 = (vPatchPosBase[0] + (vec2(1.5) * _41.uPatchSize)) * _41.uScale.xy; + float _612 = dot(vec4(_781, _809, clamp(log2((length(_41.uCamPos - vec3(_846.x, 0.0, _846.y)) + 9.9999997473787516355514526367188e-05) * _41.uDistanceMod), 0.0, _41.uMaxTessLevel.x), _893), vec4(0.25)); + float _618 = dot(vec4(clamp(log2((length(_41.uCamPos - vec3(_678.x, 0.0, _678.y)) + 9.9999997473787516355514526367188e-05) * _41.uDistanceMod), 0.0, _41.uMaxTessLevel.x), _725, _781, _809), vec4(0.25)); + float _624 = dot(vec4(_725, clamp(log2((length(_41.uCamPos - vec3(_734.x, 0.0, _734.y)) + 9.9999997473787516355514526367188e-05) * _41.uDistanceMod), 0.0, _41.uMaxTessLevel.x), _809, _837), vec4(0.25)); + float _630 = dot(vec4(_809, _837, _893, clamp(log2((length(_41.uCamPos - vec3(_902.x, 0.0, _902.y)) + 9.9999997473787516355514526367188e-05) * _41.uDistanceMod), 0.0, _41.uMaxTessLevel.x)), vec4(0.25)); + vec4 _631 = vec4(_612, _618, _624, _630); + vPatchLods = _631; + vec4 _928 = exp2(-min(_631, _631.yzwx)) * _41.uMaxTessLevel.y; + gl_TessLevelOuter[0] = _928.x; + gl_TessLevelOuter[1] = _928.y; + gl_TessLevelOuter[2] = _928.z; + gl_TessLevelOuter[3] = _928.w; + float _935 = _41.uMaxTessLevel.y * exp2(-min(min(min(_612, _618), min(_624, _630)), _809)); + gl_TessLevelInner[0] = _935; + gl_TessLevelInner[1] = _935; + } +} + diff --git a/reference/opt/shaders/tese/ccw.tese b/reference/opt/shaders/tese/ccw.tese new file mode 100644 index 0000000000..a2a4508ac0 --- /dev/null +++ b/reference/opt/shaders/tese/ccw.tese @@ -0,0 +1,9 @@ +#version 310 es +#extension GL_EXT_tessellation_shader : require +layout(triangles, ccw, fractional_even_spacing) in; + +void main() +{ + gl_Position = vec4(1.0); +} + diff --git a/reference/opt/shaders/tese/cw.tese b/reference/opt/shaders/tese/cw.tese new file mode 100644 index 0000000000..95781493d8 --- /dev/null +++ b/reference/opt/shaders/tese/cw.tese @@ -0,0 +1,9 @@ +#version 310 es +#extension GL_EXT_tessellation_shader : require +layout(triangles, cw, fractional_even_spacing) in; + +void main() +{ + gl_Position = vec4(1.0); +} + diff --git a/reference/opt/shaders/tese/equal.tese b/reference/opt/shaders/tese/equal.tese new file mode 100644 index 0000000000..6d30518a30 --- /dev/null +++ b/reference/opt/shaders/tese/equal.tese @@ -0,0 +1,9 @@ +#version 310 es +#extension GL_EXT_tessellation_shader : require +layout(triangles, cw, equal_spacing) in; + +void main() +{ + gl_Position = vec4(1.0); +} + diff --git a/reference/opt/shaders/tese/fractional_even.tese b/reference/opt/shaders/tese/fractional_even.tese new file mode 100644 index 0000000000..95781493d8 --- /dev/null +++ b/reference/opt/shaders/tese/fractional_even.tese @@ -0,0 +1,9 @@ +#version 310 es +#extension GL_EXT_tessellation_shader : require +layout(triangles, cw, fractional_even_spacing) in; + +void main() +{ + gl_Position = vec4(1.0); +} + diff --git a/reference/opt/shaders/tese/fractional_odd.tese b/reference/opt/shaders/tese/fractional_odd.tese new file mode 100644 index 0000000000..608c19aba7 --- /dev/null +++ b/reference/opt/shaders/tese/fractional_odd.tese @@ -0,0 +1,9 @@ +#version 310 es +#extension GL_EXT_tessellation_shader : require +layout(triangles, cw, fractional_odd_spacing) in; + +void main() +{ + gl_Position = vec4(1.0); +} + diff --git a/reference/opt/shaders/tese/line.tese b/reference/opt/shaders/tese/line.tese new file mode 100644 index 0000000000..8b6ad8da20 --- /dev/null +++ b/reference/opt/shaders/tese/line.tese @@ -0,0 +1,9 @@ +#version 310 es +#extension GL_EXT_tessellation_shader : require +layout(isolines, point_mode, fractional_even_spacing) in; + +void main() +{ + gl_Position = vec4(1.0); +} + diff --git a/reference/opt/shaders/tese/triangle.tese b/reference/opt/shaders/tese/triangle.tese new file mode 100644 index 0000000000..95781493d8 --- /dev/null +++ b/reference/opt/shaders/tese/triangle.tese @@ -0,0 +1,9 @@ +#version 310 es +#extension GL_EXT_tessellation_shader : require +layout(triangles, cw, fractional_even_spacing) in; + +void main() +{ + gl_Position = vec4(1.0); +} + diff --git a/reference/opt/shaders/tese/water_tess.tese b/reference/opt/shaders/tese/water_tess.tese new file mode 100644 index 0000000000..6efa9f0a69 --- /dev/null +++ b/reference/opt/shaders/tese/water_tess.tese @@ -0,0 +1,37 @@ +#version 310 es +#extension GL_EXT_tessellation_shader : require +layout(quads, cw, fractional_even_spacing) in; + +layout(binding = 1, std140) uniform UBO +{ + mat4 uMVP; + vec4 uScale; + vec2 uInvScale; + vec3 uCamPos; + vec2 uPatchSize; + vec2 uInvHeightmapSize; +} _31; + +layout(binding = 0) uniform mediump sampler2D uHeightmapDisplacement; + +layout(location = 0) patch in vec2 vOutPatchPosBase; +layout(location = 1) patch in vec4 vPatchLods; +layout(location = 1) out vec4 vGradNormalTex; +layout(location = 0) out vec3 vWorld; + +void main() +{ + vec2 _201 = vOutPatchPosBase + (gl_TessCoord.xy * _31.uPatchSize); + vec2 _214 = mix(vPatchLods.yx, vPatchLods.zw, vec2(gl_TessCoord.xy.x)); + float _221 = mix(_214.x, _214.y, gl_TessCoord.xy.y); + mediump float _223 = floor(_221); + mediump float _226 = _221 - _223; + vec2 _125 = _201 * _31.uInvHeightmapSize; + vec2 _141 = _31.uInvHeightmapSize * exp2(_223); + vGradNormalTex = vec4(_125 + (_31.uInvHeightmapSize * 0.5), _125 * _31.uScale.zw); + mediump vec3 _253 = mix(textureLod(uHeightmapDisplacement, _125 + (_141 * 0.5), _223).xyz, textureLod(uHeightmapDisplacement, _125 + (_141 * 1.0), _223 + 1.0).xyz, vec3(_226)); + vec2 _171 = (_201 * _31.uScale.xy) + _253.yz; + vWorld = vec3(_171.x, _253.x, _171.y); + gl_Position = _31.uMVP * vec4(vWorld, 1.0); +} + diff --git a/reference/opt/shaders/vert/basic.vert b/reference/opt/shaders/vert/basic.vert new file mode 100644 index 0000000000..05504eb2f2 --- /dev/null +++ b/reference/opt/shaders/vert/basic.vert @@ -0,0 +1,17 @@ +#version 310 es + +layout(std140) uniform UBO +{ + mat4 uMVP; +} _16; + +layout(location = 0) in vec4 aVertex; +layout(location = 0) out vec3 vNormal; +layout(location = 1) in vec3 aNormal; + +void main() +{ + gl_Position = _16.uMVP * aVertex; + vNormal = aNormal; +} + diff --git a/reference/opt/shaders/vert/ground.vert b/reference/opt/shaders/vert/ground.vert new file mode 100644 index 0000000000..790c4c8249 --- /dev/null +++ b/reference/opt/shaders/vert/ground.vert @@ -0,0 +1,87 @@ +#version 310 es + +struct PatchData +{ + vec4 Position; + vec4 LODs; +}; + +layout(binding = 0, std140) uniform PerPatch +{ + PatchData Patches[256]; +} _53; + +layout(binding = 2, std140) uniform GlobalGround +{ + vec4 GroundScale; + vec4 GroundPosition; + vec4 InvGroundSize_PatchScale; +} _156; + +layout(binding = 0, std140) uniform GlobalVSData +{ + vec4 g_ViewProj_Row0; + vec4 g_ViewProj_Row1; + vec4 g_ViewProj_Row2; + vec4 g_ViewProj_Row3; + vec4 g_CamPos; + vec4 g_CamRight; + vec4 g_CamUp; + vec4 g_CamFront; + vec4 g_SunDir; + vec4 g_SunColor; + vec4 g_TimeParams; + vec4 g_ResolutionParams; + vec4 g_CamAxisRight; + vec4 g_FogColor_Distance; + vec4 g_ShadowVP_Row0; + vec4 g_ShadowVP_Row1; + vec4 g_ShadowVP_Row2; + vec4 g_ShadowVP_Row3; +} _236; + +layout(binding = 1) uniform mediump sampler2D TexLOD; +layout(binding = 0) uniform mediump sampler2D TexHeightmap; + +layout(location = 1) in vec4 LODWeights; +uniform int SPIRV_Cross_BaseInstance; +layout(location = 0) in vec2 Position; +layout(location = 1) out vec3 EyeVec; +layout(location = 0) out vec2 TexCoord; + +void main() +{ + float _300 = all(equal(LODWeights, vec4(0.0))) ? _53.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].Position.w : dot(LODWeights, _53.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].LODs); + float _302 = floor(_300); + uint _307 = uint(_302); + uvec2 _309 = uvec2(Position); + uvec2 _316 = (uvec2(1u) << uvec2(_307, _307 + 1u)) - uvec2(1u); + uint _395; + if (_309.x < 32u) + { + _395 = _316.x; + } + else + { + _395 = 0u; + } + uint _396; + if (_309.y < 32u) + { + _396 = _316.y; + } + else + { + _396 = 0u; + } + vec4 _344 = vec4((_309 + uvec2(_395, _396)).xyxy & (~_316).xxyy); + vec2 _173 = ((_53.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].Position.xz * _156.InvGroundSize_PatchScale.zw) + mix(_344.xy, _344.zw, vec2(_300 - _302))) * _156.InvGroundSize_PatchScale.xy; + mediump float _360 = textureLod(TexLOD, _173, 0.0).x * 7.96875; + float _362 = floor(_360); + vec2 _185 = _156.InvGroundSize_PatchScale.xy * exp2(_362); + vec3 _230 = (vec3(_173.x, mix(textureLod(TexHeightmap, _173 + (_185 * 0.5), _362).x, textureLod(TexHeightmap, _173 + (_185 * 1.0), _362 + 1.0).x, _360 - _362), _173.y) * _156.GroundScale.xyz) + _156.GroundPosition.xyz; + EyeVec = _230 - _236.g_CamPos.xyz; + TexCoord = _173 + (_156.InvGroundSize_PatchScale.xy * 0.5); + gl_Position = (((_236.g_ViewProj_Row0 * _230.x) + (_236.g_ViewProj_Row1 * _230.y)) + (_236.g_ViewProj_Row2 * _230.z)) + _236.g_ViewProj_Row3; +} + diff --git a/reference/opt/shaders/vert/ocean.vert b/reference/opt/shaders/vert/ocean.vert new file mode 100644 index 0000000000..d37a0a8a4c --- /dev/null +++ b/reference/opt/shaders/vert/ocean.vert @@ -0,0 +1,117 @@ +#version 310 es + +struct PatchData +{ + vec4 Position; + vec4 LODs; +}; + +layout(binding = 0, std140) uniform Offsets +{ + PatchData Patches[256]; +} _53; + +layout(binding = 4, std140) uniform GlobalOcean +{ + vec4 OceanScale; + vec4 OceanPosition; + vec4 InvOceanSize_PatchScale; + vec4 NormalTexCoordScale; +} _180; + +layout(binding = 0, std140) uniform GlobalVSData +{ + vec4 g_ViewProj_Row0; + vec4 g_ViewProj_Row1; + vec4 g_ViewProj_Row2; + vec4 g_ViewProj_Row3; + vec4 g_CamPos; + vec4 g_CamRight; + vec4 g_CamUp; + vec4 g_CamFront; + vec4 g_SunDir; + vec4 g_SunColor; + vec4 g_TimeParams; + vec4 g_ResolutionParams; + vec4 g_CamAxisRight; + vec4 g_FogColor_Distance; + vec4 g_ShadowVP_Row0; + vec4 g_ShadowVP_Row1; + vec4 g_ShadowVP_Row2; + vec4 g_ShadowVP_Row3; +} _273; + +layout(binding = 1) uniform mediump sampler2D TexLOD; +layout(binding = 0) uniform mediump sampler2D TexDisplacement; + +layout(location = 1) in vec4 LODWeights; +uniform int SPIRV_Cross_BaseInstance; +layout(location = 0) in vec4 Position; +layout(location = 0) out vec3 EyeVec; +layout(location = 1) out vec4 TexCoord; + +uvec4 _483; + +void main() +{ + float _350 = all(equal(LODWeights, vec4(0.0))) ? _53.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].Position.w : dot(LODWeights, _53.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].LODs); + float _352 = floor(_350); + uint _357 = uint(_352); + uvec4 _359 = uvec4(Position); + uvec2 _366 = (uvec2(1u) << uvec2(_357, _357 + 1u)) - uvec2(1u); + uint _482; + if (_359.x < 32u) + { + _482 = _366.x; + } + else + { + _482 = 0u; + } + uvec4 _445 = _483; + _445.x = _482; + uint _484; + if (_359.y < 32u) + { + _484 = _366.x; + } + else + { + _484 = 0u; + } + uvec4 _451 = _445; + _451.y = _484; + uint _485; + if (_359.x < 32u) + { + _485 = _366.y; + } + else + { + _485 = 0u; + } + uvec4 _457 = _451; + _457.z = _485; + uint _486; + if (_359.y < 32u) + { + _486 = _366.y; + } + else + { + _486 = 0u; + } + uvec4 _463 = _457; + _463.w = _486; + vec4 _415 = vec4((_359.xyxy + _463) & (~_366).xxyy); + vec2 _197 = ((_53.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].Position.xz * _180.InvOceanSize_PatchScale.zw) + mix(_415.xy, _415.zw, vec2(_350 - _352))) * _180.InvOceanSize_PatchScale.xy; + vec2 _204 = _197 * _180.NormalTexCoordScale.zw; + mediump float _431 = textureLod(TexLOD, _197, 0.0).x * 7.96875; + float _433 = floor(_431); + vec2 _220 = (_180.InvOceanSize_PatchScale.xy * exp2(_433)) * _180.NormalTexCoordScale.zw; + vec3 _267 = ((vec3(_197.x, 0.0, _197.y) + mix(textureLod(TexDisplacement, _204 + (_220 * 0.5), _433).yxz, textureLod(TexDisplacement, _204 + (_220 * 1.0), _433 + 1.0).yxz, vec3(_431 - _433))) * _180.OceanScale.xyz) + _180.OceanPosition.xyz; + EyeVec = _267 - _273.g_CamPos.xyz; + TexCoord = vec4(_204, _204 * _180.NormalTexCoordScale.xy) + ((_180.InvOceanSize_PatchScale.xyxy * 0.5) * _180.NormalTexCoordScale.zwzw); + gl_Position = (((_273.g_ViewProj_Row0 * _267.x) + (_273.g_ViewProj_Row1 * _267.y)) + (_273.g_ViewProj_Row2 * _267.z)) + _273.g_ViewProj_Row3; +} + diff --git a/reference/opt/shaders/vert/texture_buffer.vert b/reference/opt/shaders/vert/texture_buffer.vert new file mode 100644 index 0000000000..e9442ce119 --- /dev/null +++ b/reference/opt/shaders/vert/texture_buffer.vert @@ -0,0 +1,11 @@ +#version 310 es +#extension GL_OES_texture_buffer : require + +layout(binding = 4) uniform highp samplerBuffer uSamp; +layout(binding = 5, rgba32f) uniform readonly highp imageBuffer uSampo; + +void main() +{ + gl_Position = texelFetch(uSamp, 10) + imageLoad(uSampo, 100); +} + diff --git a/reference/opt/shaders/vert/ubo.vert b/reference/opt/shaders/vert/ubo.vert new file mode 100644 index 0000000000..4e7236b290 --- /dev/null +++ b/reference/opt/shaders/vert/ubo.vert @@ -0,0 +1,17 @@ +#version 310 es + +layout(binding = 0, std140) uniform UBO +{ + mat4 mvp; +} _16; + +layout(location = 0) in vec4 aVertex; +layout(location = 0) out vec3 vNormal; +layout(location = 1) in vec3 aNormal; + +void main() +{ + gl_Position = _16.mvp * aVertex; + vNormal = aNormal; +} + diff --git a/reference/opt/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag b/reference/opt/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag new file mode 100644 index 0000000000..f0729fdcdf --- /dev/null +++ b/reference/opt/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag @@ -0,0 +1,14 @@ +#version 310 es +precision mediump float; +precision highp int; + +uniform mediump sampler2DShadow SPIRV_Cross_CombineduDepthuSampler; +uniform mediump sampler2D SPIRV_Cross_CombineduDepthuSampler1; + +layout(location = 0) out float FragColor; + +void main() +{ + FragColor = texture(SPIRV_Cross_CombineduDepthuSampler, vec3(vec3(1.0).xy, 1.0)) + texture(SPIRV_Cross_CombineduDepthuSampler1, vec2(1.0)).x; +} + diff --git a/reference/opt/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag.vk b/reference/opt/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag.vk new file mode 100644 index 0000000000..b6ad1e39c4 --- /dev/null +++ b/reference/opt/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag.vk @@ -0,0 +1,15 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(set = 0, binding = 2) uniform mediump texture2D uDepth; +layout(set = 0, binding = 0) uniform mediump samplerShadow uSampler; +layout(set = 0, binding = 1) uniform mediump sampler uSampler1; + +layout(location = 0) out float FragColor; + +void main() +{ + FragColor = texture(sampler2DShadow(uDepth, uSampler), vec3(vec3(1.0).xy, 1.0)) + texture(sampler2D(uDepth, uSampler1), vec2(1.0)).x; +} + diff --git a/reference/opt/shaders/vulkan/frag/combined-texture-sampler.vk.frag b/reference/opt/shaders/vulkan/frag/combined-texture-sampler.vk.frag new file mode 100644 index 0000000000..29c247d6d9 --- /dev/null +++ b/reference/opt/shaders/vulkan/frag/combined-texture-sampler.vk.frag @@ -0,0 +1,17 @@ +#version 310 es +precision mediump float; +precision highp int; + +uniform mediump sampler2D SPIRV_Cross_CombineduTexture0uSampler0; +uniform mediump sampler2D SPIRV_Cross_CombineduTexture1uSampler1; +uniform mediump sampler2D SPIRV_Cross_CombineduTexture1uSampler0; +uniform mediump sampler2D SPIRV_Cross_CombineduTexture0uSampler1; + +layout(location = 0) in vec2 vTex; +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = ((((texture(SPIRV_Cross_CombineduTexture0uSampler0, vTex) + texture(SPIRV_Cross_CombineduTexture1uSampler1, vTex)) + (texture(SPIRV_Cross_CombineduTexture0uSampler0, vTex) + texture(SPIRV_Cross_CombineduTexture1uSampler0, vTex))) + (texture(SPIRV_Cross_CombineduTexture0uSampler1, vTex) + texture(SPIRV_Cross_CombineduTexture1uSampler1, vTex))) + (texture(SPIRV_Cross_CombineduTexture0uSampler0, vTex) + texture(SPIRV_Cross_CombineduTexture0uSampler1, vTex))) + (texture(SPIRV_Cross_CombineduTexture1uSampler0, vTex) + texture(SPIRV_Cross_CombineduTexture1uSampler1, vTex)); +} + diff --git a/reference/opt/shaders/vulkan/frag/combined-texture-sampler.vk.frag.vk b/reference/opt/shaders/vulkan/frag/combined-texture-sampler.vk.frag.vk new file mode 100644 index 0000000000..7a543c4168 --- /dev/null +++ b/reference/opt/shaders/vulkan/frag/combined-texture-sampler.vk.frag.vk @@ -0,0 +1,17 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(set = 0, binding = 2) uniform mediump texture2D uTexture0; +layout(set = 0, binding = 3) uniform mediump texture2D uTexture1; +layout(set = 0, binding = 0) uniform mediump sampler uSampler0; +layout(set = 0, binding = 1) uniform mediump sampler uSampler1; + +layout(location = 0) in vec2 vTex; +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = ((((texture(sampler2D(uTexture0, uSampler0), vTex) + texture(sampler2D(uTexture1, uSampler1), vTex)) + (texture(sampler2D(uTexture0, uSampler0), vTex) + texture(sampler2D(uTexture1, uSampler0), vTex))) + (texture(sampler2D(uTexture0, uSampler1), vTex) + texture(sampler2D(uTexture1, uSampler1), vTex))) + (texture(sampler2D(uTexture0, uSampler0), vTex) + texture(sampler2D(uTexture0, uSampler1), vTex))) + (texture(sampler2D(uTexture1, uSampler0), vTex) + texture(sampler2D(uTexture1, uSampler1), vTex)); +} + diff --git a/reference/opt/shaders/vulkan/frag/desktop-mediump.vk.frag b/reference/opt/shaders/vulkan/frag/desktop-mediump.vk.frag new file mode 100644 index 0000000000..8f7508ee8e --- /dev/null +++ b/reference/opt/shaders/vulkan/frag/desktop-mediump.vk.frag @@ -0,0 +1,12 @@ +#version 450 + +layout(location = 0) out vec4 FragColor; +layout(location = 0) in vec4 F; +layout(location = 1) flat in ivec4 I; +layout(location = 2) flat in uvec4 U; + +void main() +{ + FragColor = (F + vec4(I)) + vec4(U); +} + diff --git a/reference/opt/shaders/vulkan/frag/desktop-mediump.vk.frag.vk b/reference/opt/shaders/vulkan/frag/desktop-mediump.vk.frag.vk new file mode 100644 index 0000000000..4c0506b110 --- /dev/null +++ b/reference/opt/shaders/vulkan/frag/desktop-mediump.vk.frag.vk @@ -0,0 +1,12 @@ +#version 450 + +layout(location = 0) out mediump vec4 FragColor; +layout(location = 0) in mediump vec4 F; +layout(location = 1) flat in mediump ivec4 I; +layout(location = 2) flat in mediump uvec4 U; + +void main() +{ + FragColor = (F + vec4(I)) + vec4(U); +} + diff --git a/reference/opt/shaders/vulkan/frag/input-attachment-ms.vk.frag b/reference/opt/shaders/vulkan/frag/input-attachment-ms.vk.frag new file mode 100644 index 0000000000..ea460c1fae --- /dev/null +++ b/reference/opt/shaders/vulkan/frag/input-attachment-ms.vk.frag @@ -0,0 +1,12 @@ +#version 450 + +layout(binding = 0) uniform sampler2DMS uSubpass0; +layout(binding = 1) uniform sampler2DMS uSubpass1; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = (texelFetch(uSubpass0, ivec2(gl_FragCoord.xy), 1) + texelFetch(uSubpass1, ivec2(gl_FragCoord.xy), 2)) + texelFetch(uSubpass0, ivec2(gl_FragCoord.xy), gl_SampleID); +} + diff --git a/reference/opt/shaders/vulkan/frag/input-attachment-ms.vk.frag.vk b/reference/opt/shaders/vulkan/frag/input-attachment-ms.vk.frag.vk new file mode 100644 index 0000000000..462df22a19 --- /dev/null +++ b/reference/opt/shaders/vulkan/frag/input-attachment-ms.vk.frag.vk @@ -0,0 +1,12 @@ +#version 450 + +layout(input_attachment_index = 0, set = 0, binding = 0) uniform subpassInputMS uSubpass0; +layout(input_attachment_index = 1, set = 0, binding = 1) uniform subpassInputMS uSubpass1; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = (subpassLoad(uSubpass0, 1) + subpassLoad(uSubpass1, 2)) + subpassLoad(uSubpass0, gl_SampleID); +} + diff --git a/reference/opt/shaders/vulkan/frag/input-attachment.vk.frag b/reference/opt/shaders/vulkan/frag/input-attachment.vk.frag new file mode 100644 index 0000000000..8d216b2c49 --- /dev/null +++ b/reference/opt/shaders/vulkan/frag/input-attachment.vk.frag @@ -0,0 +1,14 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(binding = 0) uniform mediump sampler2D uSubpass0; +layout(binding = 1) uniform mediump sampler2D uSubpass1; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = texelFetch(uSubpass0, ivec2(gl_FragCoord.xy), 0) + texelFetch(uSubpass1, ivec2(gl_FragCoord.xy), 0); +} + diff --git a/reference/opt/shaders/vulkan/frag/input-attachment.vk.frag.vk b/reference/opt/shaders/vulkan/frag/input-attachment.vk.frag.vk new file mode 100644 index 0000000000..c8b5d9a70d --- /dev/null +++ b/reference/opt/shaders/vulkan/frag/input-attachment.vk.frag.vk @@ -0,0 +1,14 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(input_attachment_index = 0, set = 0, binding = 0) uniform mediump subpassInput uSubpass0; +layout(input_attachment_index = 1, set = 0, binding = 1) uniform mediump subpassInput uSubpass1; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = subpassLoad(uSubpass0) + subpassLoad(uSubpass1); +} + diff --git a/reference/opt/shaders/vulkan/frag/push-constant.vk.frag b/reference/opt/shaders/vulkan/frag/push-constant.vk.frag new file mode 100644 index 0000000000..c04a7ca488 --- /dev/null +++ b/reference/opt/shaders/vulkan/frag/push-constant.vk.frag @@ -0,0 +1,20 @@ +#version 310 es +precision mediump float; +precision highp int; + +struct PushConstants +{ + vec4 value0; + vec4 value1; +}; + +uniform PushConstants push; + +layout(location = 0) out vec4 FragColor; +layout(location = 0) in vec4 vColor; + +void main() +{ + FragColor = (vColor + push.value0) + push.value1; +} + diff --git a/reference/opt/shaders/vulkan/frag/push-constant.vk.frag.vk b/reference/opt/shaders/vulkan/frag/push-constant.vk.frag.vk new file mode 100644 index 0000000000..6cec90f19e --- /dev/null +++ b/reference/opt/shaders/vulkan/frag/push-constant.vk.frag.vk @@ -0,0 +1,18 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(push_constant, std430) uniform PushConstants +{ + vec4 value0; + vec4 value1; +} push; + +layout(location = 0) out vec4 FragColor; +layout(location = 0) in vec4 vColor; + +void main() +{ + FragColor = (vColor + push.value0) + push.value1; +} + diff --git a/reference/opt/shaders/vulkan/frag/separate-sampler-texture.vk.frag b/reference/opt/shaders/vulkan/frag/separate-sampler-texture.vk.frag new file mode 100644 index 0000000000..a52d5bc77c --- /dev/null +++ b/reference/opt/shaders/vulkan/frag/separate-sampler-texture.vk.frag @@ -0,0 +1,20 @@ +#version 310 es +precision mediump float; +precision highp int; + +uniform mediump sampler2D SPIRV_Cross_CombineduTextureuSampler; +uniform mediump sampler2DArray SPIRV_Cross_CombineduTextureArrayuSampler; +uniform mediump samplerCube SPIRV_Cross_CombineduTextureCubeuSampler; +uniform mediump sampler3D SPIRV_Cross_CombineduTexture3DuSampler; + +layout(location = 0) in vec2 vTex; +layout(location = 1) in vec3 vTex3; +layout(location = 0) out vec4 FragColor; + +void main() +{ + vec2 _54 = vec2(1.0) / vec2(textureSize(SPIRV_Cross_CombineduTextureuSampler, 0)); + vec2 _64 = vec2(1.0) / vec2(textureSize(SPIRV_Cross_CombineduTextureuSampler, 1)); + FragColor = (((texture(SPIRV_Cross_CombineduTextureuSampler, (vTex + _54) + _64) + texture(SPIRV_Cross_CombineduTextureuSampler, (vTex + _54) + _64)) + texture(SPIRV_Cross_CombineduTextureArrayuSampler, vTex3)) + texture(SPIRV_Cross_CombineduTextureCubeuSampler, vTex3)) + texture(SPIRV_Cross_CombineduTexture3DuSampler, vTex3); +} + diff --git a/reference/opt/shaders/vulkan/frag/separate-sampler-texture.vk.frag.vk b/reference/opt/shaders/vulkan/frag/separate-sampler-texture.vk.frag.vk new file mode 100644 index 0000000000..105ca76e44 --- /dev/null +++ b/reference/opt/shaders/vulkan/frag/separate-sampler-texture.vk.frag.vk @@ -0,0 +1,21 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(set = 0, binding = 1) uniform mediump texture2D uTexture; +layout(set = 0, binding = 0) uniform mediump sampler uSampler; +layout(set = 0, binding = 4) uniform mediump texture2DArray uTextureArray; +layout(set = 0, binding = 3) uniform mediump textureCube uTextureCube; +layout(set = 0, binding = 2) uniform mediump texture3D uTexture3D; + +layout(location = 0) in vec2 vTex; +layout(location = 1) in vec3 vTex3; +layout(location = 0) out vec4 FragColor; + +void main() +{ + vec2 _54 = vec2(1.0) / vec2(textureSize(sampler2D(uTexture, uSampler), 0)); + vec2 _64 = vec2(1.0) / vec2(textureSize(sampler2D(uTexture, uSampler), 1)); + FragColor = (((texture(sampler2D(uTexture, uSampler), (vTex + _54) + _64) + texture(sampler2D(uTexture, uSampler), (vTex + _54) + _64)) + texture(sampler2DArray(uTextureArray, uSampler), vTex3)) + texture(samplerCube(uTextureCube, uSampler), vTex3)) + texture(sampler3D(uTexture3D, uSampler), vTex3); +} + diff --git a/reference/opt/shaders/vulkan/frag/spec-constant.vk.frag b/reference/opt/shaders/vulkan/frag/spec-constant.vk.frag new file mode 100644 index 0000000000..4f9b6f515f --- /dev/null +++ b/reference/opt/shaders/vulkan/frag/spec-constant.vk.frag @@ -0,0 +1,20 @@ +#version 310 es +precision mediump float; +precision highp int; + +struct Foo +{ + float elems[(4 + 2)]; +}; + +layout(location = 0) out vec4 FragColor; + +float _146[(3 + 2)]; + +void main() +{ + float vec0[(3 + 3)][8]; + Foo foo; + FragColor = ((vec4(1.0 + 2.0) + vec4(vec0[0][0])) + vec4(_146[0])) + vec4(foo.elems[3]); +} + diff --git a/reference/opt/shaders/vulkan/frag/spec-constant.vk.frag.vk b/reference/opt/shaders/vulkan/frag/spec-constant.vk.frag.vk new file mode 100644 index 0000000000..0b74896aef --- /dev/null +++ b/reference/opt/shaders/vulkan/frag/spec-constant.vk.frag.vk @@ -0,0 +1,25 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(constant_id = 1) const float a = 1.0; +layout(constant_id = 2) const float b = 2.0; +layout(constant_id = 3) const int c = 3; +layout(constant_id = 4) const int d = 4; + +struct Foo +{ + float elems[(d + 2)]; +}; + +layout(location = 0) out vec4 FragColor; + +float _146[(c + 2)]; + +void main() +{ + float vec0[(c + 3)][8]; + Foo foo; + FragColor = ((vec4(a + b) + vec4(vec0[0][0])) + vec4(_146[0])) + vec4(foo.elems[c]); +} + diff --git a/reference/opt/shaders/vulkan/vert/multiview.nocompat.vk.vert b/reference/opt/shaders/vulkan/vert/multiview.nocompat.vk.vert new file mode 100644 index 0000000000..533738efc3 --- /dev/null +++ b/reference/opt/shaders/vulkan/vert/multiview.nocompat.vk.vert @@ -0,0 +1,15 @@ +#version 310 es +#extension GL_OVR_multiview2 : require + +layout(binding = 0, std140) uniform MVPs +{ + mat4 MVP[2]; +} _19; + +layout(location = 0) in vec4 Position; + +void main() +{ + gl_Position = _19.MVP[gl_ViewID_OVR] * Position; +} + diff --git a/reference/opt/shaders/vulkan/vert/multiview.nocompat.vk.vert.vk b/reference/opt/shaders/vulkan/vert/multiview.nocompat.vk.vert.vk new file mode 100644 index 0000000000..90055473d9 --- /dev/null +++ b/reference/opt/shaders/vulkan/vert/multiview.nocompat.vk.vert.vk @@ -0,0 +1,15 @@ +#version 310 es +#extension GL_EXT_multiview : require + +layout(set = 0, binding = 0, std140) uniform MVPs +{ + mat4 MVP[2]; +} _19; + +layout(location = 0) in vec4 Position; + +void main() +{ + gl_Position = _19.MVP[gl_ViewIndex] * Position; +} + diff --git a/reference/opt/shaders/vulkan/vert/vulkan-vertex.vk.vert b/reference/opt/shaders/vulkan/vert/vulkan-vertex.vk.vert new file mode 100644 index 0000000000..60ba1882f8 --- /dev/null +++ b/reference/opt/shaders/vulkan/vert/vulkan-vertex.vk.vert @@ -0,0 +1,9 @@ +#version 310 es + +uniform int SPIRV_Cross_BaseInstance; + +void main() +{ + gl_Position = vec4(1.0, 2.0, 3.0, 4.0) * float(gl_VertexID + (gl_InstanceID + SPIRV_Cross_BaseInstance)); +} + diff --git a/reference/opt/shaders/vulkan/vert/vulkan-vertex.vk.vert.vk b/reference/opt/shaders/vulkan/vert/vulkan-vertex.vk.vert.vk new file mode 100644 index 0000000000..8c4930d7a8 --- /dev/null +++ b/reference/opt/shaders/vulkan/vert/vulkan-vertex.vk.vert.vk @@ -0,0 +1,7 @@ +#version 310 es + +void main() +{ + gl_Position = vec4(1.0, 2.0, 3.0, 4.0) * float(gl_VertexIndex + gl_InstanceIndex); +} + diff --git a/reference/shaders-hlsl/asm/comp/specialization-constant-workgroup.nofxc.asm.comp b/reference/shaders-hlsl/asm/comp/specialization-constant-workgroup.nofxc.asm.comp new file mode 100644 index 0000000000..8243347bf6 --- /dev/null +++ b/reference/shaders-hlsl/asm/comp/specialization-constant-workgroup.nofxc.asm.comp @@ -0,0 +1,16 @@ +static const uint _5 = 9u; +static const uint _6 = 4u; +static const uint3 gl_WorkGroupSize = uint3(_5, 20u, _6); + +RWByteAddressBuffer _4 : register(u0); + +void comp_main() +{ + _4.Store(0, asuint(asfloat(_4.Load(0)) + 1.0f)); +} + +[numthreads(9, 20, 4)] +void main() +{ + comp_main(); +} diff --git a/reference/shaders-hlsl/asm/comp/storage-buffer-basic.nofxc.asm.comp b/reference/shaders-hlsl/asm/comp/storage-buffer-basic.nofxc.asm.comp new file mode 100644 index 0000000000..1887eaa88f --- /dev/null +++ b/reference/shaders-hlsl/asm/comp/storage-buffer-basic.nofxc.asm.comp @@ -0,0 +1,26 @@ +static const uint _3 = 1u; +static const uint _4 = 3u; +static const uint3 gl_WorkGroupSize = uint3(_3, 2u, _4); + +RWByteAddressBuffer _8 : register(u0); +RWByteAddressBuffer _9 : register(u1); + +static uint3 gl_WorkGroupID; +struct SPIRV_Cross_Input +{ + uint3 gl_WorkGroupID : SV_GroupID; +}; + +static uint3 _22 = gl_WorkGroupSize; + +void comp_main() +{ + _8.Store(gl_WorkGroupID.x * 4 + 0, asuint(asfloat(_9.Load(gl_WorkGroupID.x * 4 + 0)) + asfloat(_8.Load(gl_WorkGroupID.x * 4 + 0)))); +} + +[numthreads(1, 2, 3)] +void main(SPIRV_Cross_Input stage_input) +{ + gl_WorkGroupID = stage_input.gl_WorkGroupID; + comp_main(); +} diff --git a/reference/shaders-hlsl/asm/frag/cbuffer-stripped.asm.frag b/reference/shaders-hlsl/asm/frag/cbuffer-stripped.asm.frag new file mode 100644 index 0000000000..851dfa1aa8 --- /dev/null +++ b/reference/shaders-hlsl/asm/frag/cbuffer-stripped.asm.frag @@ -0,0 +1,31 @@ +cbuffer _5 : register(b0) +{ + column_major float2x4 _5_m0 : packoffset(c0); + float4 _5_m1 : packoffset(c4); +}; + +static float2 _3; + +struct SPIRV_Cross_Output +{ + float2 _3 : SV_Target0; +}; + +float2 _23() +{ + float2 _25 = mul(_5_m0, _5_m1); + return _25; +} + +void frag_main() +{ + _3 = _23(); +} + +SPIRV_Cross_Output main() +{ + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output._3 = _3; + return stage_output; +} diff --git a/reference/shaders-hlsl/asm/frag/unreachable.asm.frag b/reference/shaders-hlsl/asm/frag/unreachable.asm.frag new file mode 100644 index 0000000000..c2fa519df8 --- /dev/null +++ b/reference/shaders-hlsl/asm/frag/unreachable.asm.frag @@ -0,0 +1,44 @@ +static int counter; +static float4 FragColor; + +struct SPIRV_Cross_Input +{ + nointerpolation int counter : TEXCOORD0; +}; + +struct SPIRV_Cross_Output +{ + float4 FragColor : SV_Target0; +}; + +float4 _21; + +void frag_main() +{ + float4 _24; + _24 = _21; + float4 _33; + for (;;) + { + if (counter == 10) + { + _33 = 10.0f.xxxx; + break; + } + else + { + _33 = 30.0f.xxxx; + break; + } + } + FragColor = _33; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + counter = stage_input.counter; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/shaders-hlsl/asm/vert/empty-struct-composite.asm.vert b/reference/shaders-hlsl/asm/vert/empty-struct-composite.asm.vert new file mode 100644 index 0000000000..103ff46a3f --- /dev/null +++ b/reference/shaders-hlsl/asm/vert/empty-struct-composite.asm.vert @@ -0,0 +1,8 @@ +void vert_main() +{ +} + +void main() +{ + vert_main(); +} diff --git a/reference/shaders-hlsl/asm/vert/vertex-id-instance-id.asm.vert b/reference/shaders-hlsl/asm/vert/vertex-id-instance-id.asm.vert new file mode 100644 index 0000000000..8d5e771fe4 --- /dev/null +++ b/reference/shaders-hlsl/asm/vert/vertex-id-instance-id.asm.vert @@ -0,0 +1,28 @@ +static float4 gl_Position; +static int gl_VertexID; +static int gl_InstanceID; +struct SPIRV_Cross_Input +{ + uint gl_VertexID : SV_VertexID; + uint gl_InstanceID : SV_InstanceID; +}; + +struct SPIRV_Cross_Output +{ + float4 gl_Position : SV_Position; +}; + +void vert_main() +{ + gl_Position = float(gl_VertexID + gl_InstanceID).xxxx; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + gl_VertexID = int(stage_input.gl_VertexID); + gl_InstanceID = int(stage_input.gl_InstanceID); + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + return stage_output; +} diff --git a/reference/shaders-hlsl/comp/access-chains.comp b/reference/shaders-hlsl/comp/access-chains.comp new file mode 100644 index 0000000000..924e919124 --- /dev/null +++ b/reference/shaders-hlsl/comp/access-chains.comp @@ -0,0 +1,21 @@ +RWByteAddressBuffer wo : register(u1); +ByteAddressBuffer ro : register(t0); + +static uint3 gl_GlobalInvocationID; +struct SPIRV_Cross_Input +{ + uint3 gl_GlobalInvocationID : SV_DispatchThreadID; +}; + +void comp_main() +{ + wo.Store4(gl_GlobalInvocationID.x * 64 + 272, asuint(asfloat(ro.Load4(gl_GlobalInvocationID.x * 64 + 160)))); + wo.Store4(gl_GlobalInvocationID.x * 16 + 480, asuint(asfloat(ro.Load4(gl_GlobalInvocationID.x * 16 + 480)))); +} + +[numthreads(1, 1, 1)] +void main(SPIRV_Cross_Input stage_input) +{ + gl_GlobalInvocationID = stage_input.gl_GlobalInvocationID; + comp_main(); +} diff --git a/reference/shaders-hlsl/comp/address-buffers.comp b/reference/shaders-hlsl/comp/address-buffers.comp new file mode 100644 index 0000000000..a252fc8ae3 --- /dev/null +++ b/reference/shaders-hlsl/comp/address-buffers.comp @@ -0,0 +1,15 @@ +RWByteAddressBuffer WriteOnly : register(u2); +ByteAddressBuffer ReadOnly : register(t0); +RWByteAddressBuffer ReadWrite : register(u1); + +void comp_main() +{ + WriteOnly.Store4(0, asuint(asfloat(ReadOnly.Load4(0)))); + ReadWrite.Store4(0, asuint(asfloat(ReadWrite.Load4(0)) + 10.0f.xxxx)); +} + +[numthreads(1, 1, 1)] +void main() +{ + comp_main(); +} diff --git a/reference/shaders-hlsl/comp/atomic.comp b/reference/shaders-hlsl/comp/atomic.comp new file mode 100644 index 0000000000..72e15bf77d --- /dev/null +++ b/reference/shaders-hlsl/comp/atomic.comp @@ -0,0 +1,89 @@ +RWByteAddressBuffer ssbo : register(u2); +RWTexture2D uImage : register(u0); +RWTexture2D iImage : register(u1); + +groupshared int int_atomic; +groupshared uint uint_atomic; +groupshared int int_atomic_array[1]; +groupshared uint uint_atomic_array[1]; + +void comp_main() +{ + uint _19; + InterlockedAdd(uImage[int2(1, 5)], 1u, _19); + uint _27; + InterlockedAdd(uImage[int2(1, 5)], 1u, _27); + iImage[int2(1, 6)] = int(_27).x; + uint _32; + InterlockedOr(uImage[int2(1, 5)], 1u, _32); + uint _34; + InterlockedXor(uImage[int2(1, 5)], 1u, _34); + uint _36; + InterlockedAnd(uImage[int2(1, 5)], 1u, _36); + uint _38; + InterlockedMin(uImage[int2(1, 5)], 1u, _38); + uint _40; + InterlockedMax(uImage[int2(1, 5)], 1u, _40); + uint _44; + InterlockedCompareExchange(uImage[int2(1, 5)], 10u, 2u, _44); + int _47; + InterlockedAdd(iImage[int2(1, 6)], 1, _47); + int _49; + InterlockedOr(iImage[int2(1, 6)], 1, _49); + int _51; + InterlockedXor(iImage[int2(1, 6)], 1, _51); + int _53; + InterlockedAnd(iImage[int2(1, 6)], 1, _53); + int _55; + InterlockedMin(iImage[int2(1, 6)], 1, _55); + int _57; + InterlockedMax(iImage[int2(1, 6)], 1, _57); + int _61; + InterlockedCompareExchange(iImage[int2(1, 5)], 10, 2, _61); + uint _68; + ssbo.InterlockedAdd(0, 1u, _68); + uint _70; + ssbo.InterlockedOr(0, 1u, _70); + uint _72; + ssbo.InterlockedXor(0, 1u, _72); + uint _74; + ssbo.InterlockedAnd(0, 1u, _74); + uint _76; + ssbo.InterlockedMin(0, 1u, _76); + uint _78; + ssbo.InterlockedMax(0, 1u, _78); + uint _80; + ssbo.InterlockedExchange(0, 1u, _80); + uint _82; + ssbo.InterlockedCompareExchange(0, 10u, 2u, _82); + int _85; + ssbo.InterlockedAdd(4, 1, _85); + int _87; + ssbo.InterlockedOr(4, 1, _87); + int _89; + ssbo.InterlockedXor(4, 1, _89); + int _91; + ssbo.InterlockedAnd(4, 1, _91); + int _93; + ssbo.InterlockedMin(4, 1, _93); + int _95; + ssbo.InterlockedMax(4, 1, _95); + int _97; + ssbo.InterlockedExchange(4, 1, _97); + int _99; + ssbo.InterlockedCompareExchange(4, 10, 2, _99); + int _102; + InterlockedAdd(int_atomic, 10, _102); + uint _105; + InterlockedAdd(uint_atomic, 10u, _105); + int _110; + InterlockedAdd(int_atomic_array[0], 10, _110); + uint _115; + InterlockedAdd(uint_atomic_array[0], 10u, _115); +} + +[numthreads(1, 1, 1)] +void main() +{ + comp_main(); +} diff --git a/reference/shaders-hlsl/comp/barriers.comp b/reference/shaders-hlsl/comp/barriers.comp new file mode 100644 index 0000000000..15af8ac11d --- /dev/null +++ b/reference/shaders-hlsl/comp/barriers.comp @@ -0,0 +1,81 @@ +static const uint3 gl_WorkGroupSize = uint3(4u, 1u, 1u); + +void barrier_shared() +{ + GroupMemoryBarrier(); +} + +void full_barrier() +{ + AllMemoryBarrier(); +} + +void image_barrier() +{ + DeviceMemoryBarrier(); +} + +void buffer_barrier() +{ + DeviceMemoryBarrier(); +} + +void group_barrier() +{ + AllMemoryBarrier(); +} + +void barrier_shared_exec() +{ + GroupMemoryBarrierWithGroupSync(); +} + +void full_barrier_exec() +{ + AllMemoryBarrier(); + GroupMemoryBarrierWithGroupSync(); +} + +void image_barrier_exec() +{ + DeviceMemoryBarrier(); + GroupMemoryBarrierWithGroupSync(); +} + +void buffer_barrier_exec() +{ + DeviceMemoryBarrier(); + GroupMemoryBarrierWithGroupSync(); +} + +void group_barrier_exec() +{ + AllMemoryBarrier(); + GroupMemoryBarrierWithGroupSync(); +} + +void exec_barrier() +{ + GroupMemoryBarrierWithGroupSync(); +} + +void comp_main() +{ + barrier_shared(); + full_barrier(); + image_barrier(); + buffer_barrier(); + group_barrier(); + barrier_shared_exec(); + full_barrier_exec(); + image_barrier_exec(); + buffer_barrier_exec(); + group_barrier_exec(); + exec_barrier(); +} + +[numthreads(4, 1, 1)] +void main() +{ + comp_main(); +} diff --git a/reference/shaders-hlsl/comp/bitfield.noopt.comp b/reference/shaders-hlsl/comp/bitfield.noopt.comp new file mode 100644 index 0000000000..6839d9569e --- /dev/null +++ b/reference/shaders-hlsl/comp/bitfield.noopt.comp @@ -0,0 +1,113 @@ +uint SPIRV_Cross_bitfieldInsert(uint Base, uint Insert, uint Offset, uint Count) +{ + uint Mask = Count == 32 ? 0xffffffff : (((1u << Count) - 1) << (Offset & 31)); + return (Base & ~Mask) | ((Insert << Offset) & Mask); +} + +uint2 SPIRV_Cross_bitfieldInsert(uint2 Base, uint2 Insert, uint Offset, uint Count) +{ + uint Mask = Count == 32 ? 0xffffffff : (((1u << Count) - 1) << (Offset & 31)); + return (Base & ~Mask) | ((Insert << Offset) & Mask); +} + +uint3 SPIRV_Cross_bitfieldInsert(uint3 Base, uint3 Insert, uint Offset, uint Count) +{ + uint Mask = Count == 32 ? 0xffffffff : (((1u << Count) - 1) << (Offset & 31)); + return (Base & ~Mask) | ((Insert << Offset) & Mask); +} + +uint4 SPIRV_Cross_bitfieldInsert(uint4 Base, uint4 Insert, uint Offset, uint Count) +{ + uint Mask = Count == 32 ? 0xffffffff : (((1u << Count) - 1) << (Offset & 31)); + return (Base & ~Mask) | ((Insert << Offset) & Mask); +} + +uint SPIRV_Cross_bitfieldUExtract(uint Base, uint Offset, uint Count) +{ + uint Mask = Count == 32 ? 0xffffffff : ((1 << Count) - 1); + return (Base >> Offset) & Mask; +} + +uint2 SPIRV_Cross_bitfieldUExtract(uint2 Base, uint Offset, uint Count) +{ + uint Mask = Count == 32 ? 0xffffffff : ((1 << Count) - 1); + return (Base >> Offset) & Mask; +} + +uint3 SPIRV_Cross_bitfieldUExtract(uint3 Base, uint Offset, uint Count) +{ + uint Mask = Count == 32 ? 0xffffffff : ((1 << Count) - 1); + return (Base >> Offset) & Mask; +} + +uint4 SPIRV_Cross_bitfieldUExtract(uint4 Base, uint Offset, uint Count) +{ + uint Mask = Count == 32 ? 0xffffffff : ((1 << Count) - 1); + return (Base >> Offset) & Mask; +} + +int SPIRV_Cross_bitfieldSExtract(int Base, int Offset, int Count) +{ + int Mask = Count == 32 ? -1 : ((1 << Count) - 1); + int Masked = (Base >> Offset) & Mask; + int ExtendShift = (32 - Count) & 31; + return (Masked << ExtendShift) >> ExtendShift; +} + +int2 SPIRV_Cross_bitfieldSExtract(int2 Base, int Offset, int Count) +{ + int Mask = Count == 32 ? -1 : ((1 << Count) - 1); + int2 Masked = (Base >> Offset) & Mask; + int ExtendShift = (32 - Count) & 31; + return (Masked << ExtendShift) >> ExtendShift; +} + +int3 SPIRV_Cross_bitfieldSExtract(int3 Base, int Offset, int Count) +{ + int Mask = Count == 32 ? -1 : ((1 << Count) - 1); + int3 Masked = (Base >> Offset) & Mask; + int ExtendShift = (32 - Count) & 31; + return (Masked << ExtendShift) >> ExtendShift; +} + +int4 SPIRV_Cross_bitfieldSExtract(int4 Base, int Offset, int Count) +{ + int Mask = Count == 32 ? -1 : ((1 << Count) - 1); + int4 Masked = (Base >> Offset) & Mask; + int ExtendShift = (32 - Count) & 31; + return (Masked << ExtendShift) >> ExtendShift; +} + +void comp_main() +{ + int signed_value = 0; + uint unsigned_value = 0u; + int3 signed_values = int3(0, 0, 0); + uint3 unsigned_values = uint3(0u, 0u, 0u); + int s = SPIRV_Cross_bitfieldSExtract(signed_value, 5, 20); + uint u = SPIRV_Cross_bitfieldUExtract(unsigned_value, 6, 21); + s = int(SPIRV_Cross_bitfieldInsert(s, 40, 5, 4)); + u = SPIRV_Cross_bitfieldInsert(u, 60u, 5, 4); + u = reversebits(u); + s = reversebits(s); + int v0 = countbits(u); + int v1 = countbits(s); + int v2 = firstbithigh(u); + int v3 = firstbitlow(s); + int3 s_1 = SPIRV_Cross_bitfieldSExtract(signed_values, 5, 20); + uint3 u_1 = SPIRV_Cross_bitfieldUExtract(unsigned_values, 6, 21); + s_1 = int3(SPIRV_Cross_bitfieldInsert(s_1, int3(40, 40, 40), 5, 4)); + u_1 = SPIRV_Cross_bitfieldInsert(u_1, uint3(60u, 60u, 60u), 5, 4); + u_1 = reversebits(u_1); + s_1 = reversebits(s_1); + int3 v0_1 = countbits(u_1); + int3 v1_1 = countbits(s_1); + int3 v2_1 = firstbithigh(u_1); + int3 v3_1 = firstbitlow(s_1); +} + +[numthreads(1, 1, 1)] +void main() +{ + comp_main(); +} diff --git a/reference/shaders-hlsl/comp/builtins.comp b/reference/shaders-hlsl/comp/builtins.comp new file mode 100644 index 0000000000..5d84883b2f --- /dev/null +++ b/reference/shaders-hlsl/comp/builtins.comp @@ -0,0 +1,32 @@ +static const uint3 gl_WorkGroupSize = uint3(8u, 4u, 2u); + +static uint3 gl_WorkGroupID; +static uint3 gl_LocalInvocationID; +static uint3 gl_GlobalInvocationID; +static uint gl_LocalInvocationIndex; +struct SPIRV_Cross_Input +{ + uint3 gl_WorkGroupID : SV_GroupID; + uint3 gl_LocalInvocationID : SV_GroupThreadID; + uint3 gl_GlobalInvocationID : SV_DispatchThreadID; + uint gl_LocalInvocationIndex : SV_GroupIndex; +}; + +void comp_main() +{ + uint3 local_id = gl_LocalInvocationID; + uint3 global_id = gl_GlobalInvocationID; + uint local_index = gl_LocalInvocationIndex; + uint3 work_group_size = gl_WorkGroupSize; + uint3 work_group_id = gl_WorkGroupID; +} + +[numthreads(8, 4, 2)] +void main(SPIRV_Cross_Input stage_input) +{ + gl_WorkGroupID = stage_input.gl_WorkGroupID; + gl_LocalInvocationID = stage_input.gl_LocalInvocationID; + gl_GlobalInvocationID = stage_input.gl_GlobalInvocationID; + gl_LocalInvocationIndex = stage_input.gl_LocalInvocationIndex; + comp_main(); +} diff --git a/reference/shaders-hlsl/comp/image.comp b/reference/shaders-hlsl/comp/image.comp new file mode 100644 index 0000000000..c8504e636c --- /dev/null +++ b/reference/shaders-hlsl/comp/image.comp @@ -0,0 +1,71 @@ +RWTexture2D uImageInF : register(u0); +RWTexture2D uImageOutF : register(u1); +RWTexture2D uImageInI : register(u2); +RWTexture2D uImageOutI : register(u3); +RWTexture2D uImageInU : register(u4); +RWTexture2D uImageOutU : register(u5); +RWBuffer uImageInBuffer : register(u6); +RWBuffer uImageOutBuffer : register(u7); +RWTexture2D uImageInF2 : register(u8); +RWTexture2D uImageOutF2 : register(u9); +RWTexture2D uImageInI2 : register(u10); +RWTexture2D uImageOutI2 : register(u11); +RWTexture2D uImageInU2 : register(u12); +RWTexture2D uImageOutU2 : register(u13); +RWBuffer uImageInBuffer2 : register(u14); +RWBuffer uImageOutBuffer2 : register(u15); +RWTexture2D uImageInF4 : register(u16); +RWTexture2D uImageOutF4 : register(u17); +RWTexture2D uImageInI4 : register(u18); +RWTexture2D uImageOutI4 : register(u19); +RWTexture2D uImageInU4 : register(u20); +RWTexture2D uImageOutU4 : register(u21); +RWBuffer uImageInBuffer4 : register(u22); +RWBuffer uImageOutBuffer4 : register(u23); +RWTexture2D uImageNoFmtF : register(u24); +RWTexture2D uImageNoFmtU : register(u25); +RWTexture2D uImageNoFmtI : register(u26); + +static uint3 gl_GlobalInvocationID; +struct SPIRV_Cross_Input +{ + uint3 gl_GlobalInvocationID : SV_DispatchThreadID; +}; + +void comp_main() +{ + float4 f = uImageInF[int2(gl_GlobalInvocationID.xy)].xxxx; + uImageOutF[int2(gl_GlobalInvocationID.xy)] = f.x; + int4 i = uImageInI[int2(gl_GlobalInvocationID.xy)].xxxx; + uImageOutI[int2(gl_GlobalInvocationID.xy)] = i.x; + uint4 u = uImageInU[int2(gl_GlobalInvocationID.xy)].xxxx; + uImageOutU[int2(gl_GlobalInvocationID.xy)] = u.x; + float4 b = uImageInBuffer[int(gl_GlobalInvocationID.x)].xxxx; + uImageOutBuffer[int(gl_GlobalInvocationID.x)] = b.x; + float4 f2 = uImageInF2[int2(gl_GlobalInvocationID.xy)].xyyy; + uImageOutF2[int2(gl_GlobalInvocationID.xy)] = f2.xy; + int4 i2 = uImageInI2[int2(gl_GlobalInvocationID.xy)].xyyy; + uImageOutI2[int2(gl_GlobalInvocationID.xy)] = i2.xy; + uint4 u2 = uImageInU2[int2(gl_GlobalInvocationID.xy)].xyyy; + uImageOutU2[int2(gl_GlobalInvocationID.xy)] = u2.xy; + float4 b2 = uImageInBuffer2[int(gl_GlobalInvocationID.x)].xyyy; + uImageOutBuffer2[int(gl_GlobalInvocationID.x)] = b2.xy; + float4 f4 = uImageInF4[int2(gl_GlobalInvocationID.xy)]; + uImageOutF4[int2(gl_GlobalInvocationID.xy)] = f4; + int4 i4 = uImageInI4[int2(gl_GlobalInvocationID.xy)]; + uImageOutI4[int2(gl_GlobalInvocationID.xy)] = i4; + uint4 u4 = uImageInU4[int2(gl_GlobalInvocationID.xy)]; + uImageOutU4[int2(gl_GlobalInvocationID.xy)] = u4; + float4 b4 = uImageInBuffer4[int(gl_GlobalInvocationID.x)]; + uImageOutBuffer4[int(gl_GlobalInvocationID.x)] = b4; + uImageNoFmtF[int2(gl_GlobalInvocationID.xy)] = b2; + uImageNoFmtU[int2(gl_GlobalInvocationID.xy)] = u4; + uImageNoFmtI[int2(gl_GlobalInvocationID.xy)] = i4; +} + +[numthreads(1, 1, 1)] +void main(SPIRV_Cross_Input stage_input) +{ + gl_GlobalInvocationID = stage_input.gl_GlobalInvocationID; + comp_main(); +} diff --git a/reference/shaders-hlsl/comp/rwbuffer-matrix.comp b/reference/shaders-hlsl/comp/rwbuffer-matrix.comp new file mode 100644 index 0000000000..0e352f1f83 --- /dev/null +++ b/reference/shaders-hlsl/comp/rwbuffer-matrix.comp @@ -0,0 +1,136 @@ +RWByteAddressBuffer _28 : register(u0); +cbuffer _68 : register(b1) +{ + int _68_index0 : packoffset(c0); + int _68_index1 : packoffset(c0.y); +}; + +void row_to_col() +{ + float4x4 _55 = asfloat(uint4x4(_28.Load(64), _28.Load(80), _28.Load(96), _28.Load(112), _28.Load(68), _28.Load(84), _28.Load(100), _28.Load(116), _28.Load(72), _28.Load(88), _28.Load(104), _28.Load(120), _28.Load(76), _28.Load(92), _28.Load(108), _28.Load(124))); + _28.Store4(0, asuint(_55[0])); + _28.Store4(16, asuint(_55[1])); + _28.Store4(32, asuint(_55[2])); + _28.Store4(48, asuint(_55[3])); + float2x2 _58 = asfloat(uint2x2(_28.Load(144), _28.Load(152), _28.Load(148), _28.Load(156))); + _28.Store2(128, asuint(_58[0])); + _28.Store2(136, asuint(_58[1])); + float2x3 _61 = asfloat(uint2x3(_28.Load(192), _28.Load(200), _28.Load(208), _28.Load(196), _28.Load(204), _28.Load(212))); + _28.Store3(160, asuint(_61[0])); + _28.Store3(176, asuint(_61[1])); + float3x2 _64 = asfloat(uint3x2(_28.Load(240), _28.Load(256), _28.Load(244), _28.Load(260), _28.Load(248), _28.Load(264))); + _28.Store2(216, asuint(_64[0])); + _28.Store2(224, asuint(_64[1])); + _28.Store2(232, asuint(_64[2])); +} + +void col_to_row() +{ + float4x4 _34 = asfloat(uint4x4(_28.Load4(0), _28.Load4(16), _28.Load4(32), _28.Load4(48))); + _28.Store(64, asuint(_34[0].x)); + _28.Store(68, asuint(_34[1].x)); + _28.Store(72, asuint(_34[2].x)); + _28.Store(76, asuint(_34[3].x)); + _28.Store(80, asuint(_34[0].y)); + _28.Store(84, asuint(_34[1].y)); + _28.Store(88, asuint(_34[2].y)); + _28.Store(92, asuint(_34[3].y)); + _28.Store(96, asuint(_34[0].z)); + _28.Store(100, asuint(_34[1].z)); + _28.Store(104, asuint(_34[2].z)); + _28.Store(108, asuint(_34[3].z)); + _28.Store(112, asuint(_34[0].w)); + _28.Store(116, asuint(_34[1].w)); + _28.Store(120, asuint(_34[2].w)); + _28.Store(124, asuint(_34[3].w)); + float2x2 _40 = asfloat(uint2x2(_28.Load2(128), _28.Load2(136))); + _28.Store(144, asuint(_40[0].x)); + _28.Store(148, asuint(_40[1].x)); + _28.Store(152, asuint(_40[0].y)); + _28.Store(156, asuint(_40[1].y)); + float2x3 _46 = asfloat(uint2x3(_28.Load3(160), _28.Load3(176))); + _28.Store(192, asuint(_46[0].x)); + _28.Store(196, asuint(_46[1].x)); + _28.Store(200, asuint(_46[0].y)); + _28.Store(204, asuint(_46[1].y)); + _28.Store(208, asuint(_46[0].z)); + _28.Store(212, asuint(_46[1].z)); + float3x2 _52 = asfloat(uint3x2(_28.Load2(216), _28.Load2(224), _28.Load2(232))); + _28.Store(240, asuint(_52[0].x)); + _28.Store(244, asuint(_52[1].x)); + _28.Store(248, asuint(_52[2].x)); + _28.Store(256, asuint(_52[0].y)); + _28.Store(260, asuint(_52[1].y)); + _28.Store(264, asuint(_52[2].y)); +} + +void write_dynamic_index_row() +{ + _28.Store(_68_index0 * 4 + _68_index1 * 16 + 64, asuint(1.0f)); + _28.Store(_68_index0 * 4 + _68_index1 * 8 + 144, asuint(2.0f)); + _28.Store(_68_index0 * 4 + _68_index1 * 8 + 192, asuint(3.0f)); + _28.Store(_68_index0 * 4 + _68_index1 * 16 + 240, asuint(4.0f)); + _28.Store(_68_index0 * 4 + 64, asuint(1.0f.x)); + _28.Store(_68_index0 * 4 + 80, asuint(1.0f.xxxx.y)); + _28.Store(_68_index0 * 4 + 96, asuint(1.0f.xxxx.z)); + _28.Store(_68_index0 * 4 + 112, asuint(1.0f.xxxx.w)); + _28.Store(_68_index0 * 4 + 144, asuint(2.0f.x)); + _28.Store(_68_index0 * 4 + 152, asuint(2.0f.xx.y)); + _28.Store(_68_index0 * 4 + 192, asuint(3.0f.x)); + _28.Store(_68_index0 * 4 + 200, asuint(3.0f.xxx.y)); + _28.Store(_68_index0 * 4 + 208, asuint(3.0f.xxx.z)); + _28.Store(_68_index0 * 4 + 240, asuint(4.0f.x)); + _28.Store(_68_index0 * 4 + 256, asuint(4.0f.xx.y)); +} + +void write_dynamic_index_col() +{ + _28.Store(_68_index0 * 16 + _68_index1 * 4 + 0, asuint(1.0f)); + _28.Store(_68_index0 * 8 + _68_index1 * 4 + 128, asuint(2.0f)); + _28.Store(_68_index0 * 16 + _68_index1 * 4 + 160, asuint(3.0f)); + _28.Store(_68_index0 * 8 + _68_index1 * 4 + 216, asuint(4.0f)); + _28.Store4(_68_index0 * 16 + 0, asuint(1.0f.xxxx)); + _28.Store2(_68_index0 * 8 + 128, asuint(2.0f.xx)); + _28.Store3(_68_index0 * 16 + 160, asuint(3.0f.xxx)); + _28.Store2(_68_index0 * 8 + 216, asuint(4.0f.xx)); +} + +void read_dynamic_index_row() +{ + float a0 = asfloat(_28.Load(_68_index0 * 4 + _68_index1 * 16 + 64)); + float a1 = asfloat(_28.Load(_68_index0 * 4 + _68_index1 * 8 + 144)); + float a2 = asfloat(_28.Load(_68_index0 * 4 + _68_index1 * 8 + 192)); + float a3 = asfloat(_28.Load(_68_index0 * 4 + _68_index1 * 16 + 240)); + float4 v0 = asfloat(uint4(_28.Load(_68_index0 * 4 + 64), _28.Load(_68_index0 * 4 + 80), _28.Load(_68_index0 * 4 + 96), _28.Load(_68_index0 * 4 + 112))); + float2 v1 = asfloat(uint2(_28.Load(_68_index0 * 4 + 144), _28.Load(_68_index0 * 4 + 152))); + float3 v2 = asfloat(uint3(_28.Load(_68_index0 * 4 + 192), _28.Load(_68_index0 * 4 + 200), _28.Load(_68_index0 * 4 + 208))); + float2 v3 = asfloat(uint2(_28.Load(_68_index0 * 4 + 240), _28.Load(_68_index0 * 4 + 256))); +} + +void read_dynamic_index_col() +{ + float a0 = asfloat(_28.Load(_68_index0 * 16 + _68_index1 * 4 + 0)); + float a1 = asfloat(_28.Load(_68_index0 * 8 + _68_index1 * 4 + 128)); + float a2 = asfloat(_28.Load(_68_index0 * 16 + _68_index1 * 4 + 160)); + float a3 = asfloat(_28.Load(_68_index0 * 8 + _68_index1 * 4 + 216)); + float4 v0 = asfloat(_28.Load4(_68_index0 * 16 + 0)); + float2 v1 = asfloat(_28.Load2(_68_index0 * 8 + 128)); + float3 v2 = asfloat(_28.Load3(_68_index0 * 16 + 160)); + float2 v3 = asfloat(_28.Load2(_68_index0 * 8 + 216)); +} + +void comp_main() +{ + row_to_col(); + col_to_row(); + write_dynamic_index_row(); + write_dynamic_index_col(); + read_dynamic_index_row(); + read_dynamic_index_col(); +} + +[numthreads(1, 1, 1)] +void main() +{ + comp_main(); +} diff --git a/reference/shaders-hlsl/comp/shared.comp b/reference/shaders-hlsl/comp/shared.comp new file mode 100644 index 0000000000..5d12900382 --- /dev/null +++ b/reference/shaders-hlsl/comp/shared.comp @@ -0,0 +1,31 @@ +static const uint3 gl_WorkGroupSize = uint3(4u, 1u, 1u); + +ByteAddressBuffer _22 : register(t0); +RWByteAddressBuffer _44 : register(u1); + +static uint3 gl_GlobalInvocationID; +static uint gl_LocalInvocationIndex; +struct SPIRV_Cross_Input +{ + uint3 gl_GlobalInvocationID : SV_DispatchThreadID; + uint gl_LocalInvocationIndex : SV_GroupIndex; +}; + +groupshared float sShared[4]; + +void comp_main() +{ + uint ident = gl_GlobalInvocationID.x; + float idata = asfloat(_22.Load(ident * 4 + 0)); + sShared[gl_LocalInvocationIndex] = idata; + GroupMemoryBarrierWithGroupSync(); + _44.Store(ident * 4 + 0, asuint(sShared[(4u - gl_LocalInvocationIndex) - 1u])); +} + +[numthreads(4, 1, 1)] +void main(SPIRV_Cross_Input stage_input) +{ + gl_GlobalInvocationID = stage_input.gl_GlobalInvocationID; + gl_LocalInvocationIndex = stage_input.gl_LocalInvocationIndex; + comp_main(); +} diff --git a/reference/shaders-hlsl/comp/ssbo-array.comp b/reference/shaders-hlsl/comp/ssbo-array.comp new file mode 100644 index 0000000000..90927421c6 --- /dev/null +++ b/reference/shaders-hlsl/comp/ssbo-array.comp @@ -0,0 +1,11 @@ +RWByteAddressBuffer ssbo0 : register(u0); + +void comp_main() +{ +} + +[numthreads(1, 1, 1)] +void main() +{ + comp_main(); +} diff --git a/reference/shaders-hlsl/frag/basic.frag b/reference/shaders-hlsl/frag/basic.frag new file mode 100644 index 0000000000..6d067041c2 --- /dev/null +++ b/reference/shaders-hlsl/frag/basic.frag @@ -0,0 +1,32 @@ +Texture2D uTex : register(t0); +SamplerState _uTex_sampler : register(s0); + +static float4 FragColor; +static float4 vColor; +static float2 vTex; + +struct SPIRV_Cross_Input +{ + float4 vColor : TEXCOORD0; + float2 vTex : TEXCOORD1; +}; + +struct SPIRV_Cross_Output +{ + float4 FragColor : SV_Target0; +}; + +void frag_main() +{ + FragColor = vColor * uTex.Sample(_uTex_sampler, vTex); +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + vColor = stage_input.vColor; + vTex = stage_input.vTex; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/shaders-hlsl/frag/bit-conversions.frag b/reference/shaders-hlsl/frag/bit-conversions.frag new file mode 100644 index 0000000000..2ed359bfc7 --- /dev/null +++ b/reference/shaders-hlsl/frag/bit-conversions.frag @@ -0,0 +1,27 @@ +static float2 value; +static float4 FragColor; + +struct SPIRV_Cross_Input +{ + float2 value : TEXCOORD0; +}; + +struct SPIRV_Cross_Output +{ + float4 FragColor : SV_Target0; +}; + +void frag_main() +{ + int i = asint(value.x); + FragColor = float4(1.0f, 0.0f, asfloat(i), 1.0f); +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + value = stage_input.value; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/shaders-hlsl/frag/boolean-mix.frag b/reference/shaders-hlsl/frag/boolean-mix.frag new file mode 100644 index 0000000000..f3e84898d6 --- /dev/null +++ b/reference/shaders-hlsl/frag/boolean-mix.frag @@ -0,0 +1,27 @@ +static float2 FragColor; +static float2 x0; + +struct SPIRV_Cross_Input +{ + float2 x0 : TEXCOORD0; +}; + +struct SPIRV_Cross_Output +{ + float2 FragColor : SV_Target0; +}; + +void frag_main() +{ + bool2 _27 = (x0.x > x0.y).xx; + FragColor = float2(_27.x ? float2(1.0f, 0.0f).x : float2(0.0f, 1.0f).x, _27.y ? float2(1.0f, 0.0f).y : float2(0.0f, 1.0f).y); +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + x0 = stage_input.x0; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/shaders-hlsl/frag/builtins.frag b/reference/shaders-hlsl/frag/builtins.frag new file mode 100644 index 0000000000..922eca7c2d --- /dev/null +++ b/reference/shaders-hlsl/frag/builtins.frag @@ -0,0 +1,33 @@ +static float4 gl_FragCoord; +static float gl_FragDepth; +static float4 FragColor; +static float4 vColor; + +struct SPIRV_Cross_Input +{ + float4 vColor : TEXCOORD0; + float4 gl_FragCoord : SV_Position; +}; + +struct SPIRV_Cross_Output +{ + float4 FragColor : SV_Target0; + float gl_FragDepth : SV_Depth; +}; + +void frag_main() +{ + FragColor = gl_FragCoord + vColor; + gl_FragDepth = 0.5f; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + gl_FragCoord = stage_input.gl_FragCoord; + vColor = stage_input.vColor; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_FragDepth = gl_FragDepth; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/shaders-hlsl/frag/bvec-operations.frag b/reference/shaders-hlsl/frag/bvec-operations.frag new file mode 100644 index 0000000000..2398d8c6af --- /dev/null +++ b/reference/shaders-hlsl/frag/bvec-operations.frag @@ -0,0 +1,29 @@ +static float2 value; +static float4 FragColor; + +struct SPIRV_Cross_Input +{ + float2 value : TEXCOORD0; +}; + +struct SPIRV_Cross_Output +{ + float4 FragColor : SV_Target0; +}; + +void frag_main() +{ + bool2 _25 = bool2(value.x == 0.0f, value.y == 0.0f); + bool2 bools1 = bool2(!_25.x, !_25.y); + bool2 bools2 = bool2(value.x <= float2(1.5f, 0.5f).x, value.y <= float2(1.5f, 0.5f).y); + FragColor = float4(1.0f, 0.0f, float(bools1.x), float(bools2.x)); +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + value = stage_input.value; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/shaders-hlsl/frag/combined-texture-sampler-parameter.frag b/reference/shaders-hlsl/frag/combined-texture-sampler-parameter.frag new file mode 100644 index 0000000000..7fcff423b3 --- /dev/null +++ b/reference/shaders-hlsl/frag/combined-texture-sampler-parameter.frag @@ -0,0 +1,44 @@ +Texture2D uSampler : register(t0); +SamplerState _uSampler_sampler : register(s0); +Texture2D uSamplerShadow : register(t1); +SamplerComparisonState _uSamplerShadow_sampler : register(s1); + +static float FragColor; + +struct SPIRV_Cross_Output +{ + float FragColor : SV_Target0; +}; + +float4 samp2(Texture2D s, SamplerState _s_sampler) +{ + return s.Sample(_s_sampler, 1.0f.xx) + s.Load(int3(int2(10, 10), 0)); +} + +float4 samp3(Texture2D s, SamplerState _s_sampler) +{ + return samp2(s, _s_sampler); +} + +float samp4(Texture2D s, SamplerComparisonState _s_sampler) +{ + return s.SampleCmp(_s_sampler, 1.0f.xxx.xy, 1.0f.xxx.z); +} + +float samp(Texture2D s0, SamplerState _s0_sampler, Texture2D s1, SamplerComparisonState _s1_sampler) +{ + return samp3(s0, _s0_sampler).x + samp4(s1, _s1_sampler); +} + +void frag_main() +{ + FragColor = samp(uSampler, _uSampler_sampler, uSamplerShadow, _uSamplerShadow_sampler); +} + +SPIRV_Cross_Output main() +{ + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/shaders-hlsl/frag/combined-texture-sampler-shadow.frag b/reference/shaders-hlsl/frag/combined-texture-sampler-shadow.frag new file mode 100644 index 0000000000..af5b0b5579 --- /dev/null +++ b/reference/shaders-hlsl/frag/combined-texture-sampler-shadow.frag @@ -0,0 +1,40 @@ +Texture2D uDepth : register(t2); +SamplerComparisonState uSampler : register(s0); +SamplerState uSampler1 : register(s1); + +static float FragColor; + +struct SPIRV_Cross_Output +{ + float FragColor : SV_Target0; +}; + +float samp2(Texture2D t, SamplerComparisonState s) +{ + return t.SampleCmp(s, 1.0f.xxx.xy, 1.0f.xxx.z); +} + +float samp3(Texture2D t, SamplerState s) +{ + return t.Sample(s, 1.0f.xx).x; +} + +float samp(Texture2D t, SamplerComparisonState s, SamplerState s1) +{ + float r0 = samp2(t, s); + float r1 = samp3(t, s1); + return r0 + r1; +} + +void frag_main() +{ + FragColor = samp(uDepth, uSampler, uSampler1); +} + +SPIRV_Cross_Output main() +{ + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/shaders-hlsl/frag/constant-buffer-array.sm51.frag b/reference/shaders-hlsl/frag/constant-buffer-array.sm51.frag new file mode 100644 index 0000000000..7e613da1cf --- /dev/null +++ b/reference/shaders-hlsl/frag/constant-buffer-array.sm51.frag @@ -0,0 +1,43 @@ +struct CBO_1 +{ + float4 a; + float4 b; + float4 c; + float4 d; +}; + +ConstantBuffer cbo[2][4] : register(b4, space0); +cbuffer push +{ + float4 push_a : packoffset(c0); + float4 push_b : packoffset(c1); + float4 push_c : packoffset(c2); + float4 push_d : packoffset(c3); +}; + +static float4 FragColor; + +struct SPIRV_Cross_Output +{ + float4 FragColor : SV_Target0; +}; + +void frag_main() +{ + FragColor = cbo[1][2].a; + FragColor += cbo[1][2].b; + FragColor += cbo[1][2].c; + FragColor += cbo[1][2].d; + FragColor += push_a; + FragColor += push_b; + FragColor += push_c; + FragColor += push_d; +} + +SPIRV_Cross_Output main() +{ + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/shaders-hlsl/frag/constant-composites.frag b/reference/shaders-hlsl/frag/constant-composites.frag new file mode 100644 index 0000000000..0514eef1ee --- /dev/null +++ b/reference/shaders-hlsl/frag/constant-composites.frag @@ -0,0 +1,43 @@ +struct Foo +{ + float a; + float b; +}; + +static const float _16[4] = { 1.0f, 4.0f, 3.0f, 2.0f }; +static const Foo _24 = { 10.0f, 20.0f }; +static const Foo _27 = { 30.0f, 40.0f }; +static const Foo _28[2] = { { 10.0f, 20.0f }, { 30.0f, 40.0f } }; + +static float4 FragColor; +static int _line; + +struct SPIRV_Cross_Input +{ + nointerpolation int _line : TEXCOORD0; +}; + +struct SPIRV_Cross_Output +{ + float4 FragColor : SV_Target0; +}; + +static float lut[4]; +static Foo foos[2]; + +void frag_main() +{ + lut = _16; + foos = _28; + FragColor = lut[_line].xxxx; + FragColor += (foos[_line].a * (foos[1 - _line].a)).xxxx; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + _line = stage_input._line; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/shaders-hlsl/frag/early-fragment-test.frag b/reference/shaders-hlsl/frag/early-fragment-test.frag new file mode 100644 index 0000000000..ae2569d5cf --- /dev/null +++ b/reference/shaders-hlsl/frag/early-fragment-test.frag @@ -0,0 +1,9 @@ +void frag_main() +{ +} + +[earlydepthstencil] +void main() +{ + frag_main(); +} diff --git a/reference/shaders-hlsl/frag/fp16-packing.frag b/reference/shaders-hlsl/frag/fp16-packing.frag new file mode 100644 index 0000000000..d87828225f --- /dev/null +++ b/reference/shaders-hlsl/frag/fp16-packing.frag @@ -0,0 +1,44 @@ +static float2 FP32Out; +static uint FP16; +static uint FP16Out; +static float2 FP32; + +struct SPIRV_Cross_Input +{ + nointerpolation uint FP16 : TEXCOORD0; + nointerpolation float2 FP32 : TEXCOORD1; +}; + +struct SPIRV_Cross_Output +{ + float2 FP32Out : SV_Target0; + uint FP16Out : SV_Target1; +}; + +uint SPIRV_Cross_packHalf2x16(float2 value) +{ + uint2 Packed = f32tof16(value); + return Packed.x | (Packed.y << 16); +} + +float2 SPIRV_Cross_unpackHalf2x16(uint value) +{ + return f16tof32(uint2(value & 0xffff, value >> 16)); +} + +void frag_main() +{ + FP32Out = SPIRV_Cross_unpackHalf2x16(FP16); + FP16Out = SPIRV_Cross_packHalf2x16(FP32); +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + FP16 = stage_input.FP16; + FP32 = stage_input.FP32; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FP32Out = FP32Out; + stage_output.FP16Out = FP16Out; + return stage_output; +} diff --git a/reference/shaders-hlsl/frag/image-query-selective.frag b/reference/shaders-hlsl/frag/image-query-selective.frag new file mode 100644 index 0000000000..25c12da669 --- /dev/null +++ b/reference/shaders-hlsl/frag/image-query-selective.frag @@ -0,0 +1,146 @@ +Texture1D uSampler1DUint : register(t0); +SamplerState _uSampler1DUint_sampler : register(s0); +Texture1D uSampler1DInt : register(t0); +SamplerState _uSampler1DInt_sampler : register(s0); +Texture1D uSampler1DFloat : register(t0); +SamplerState _uSampler1DFloat_sampler : register(s0); +Texture2DArray uSampler2DArray : register(t2); +SamplerState _uSampler2DArray_sampler : register(s2); +Texture3D uSampler3D : register(t3); +SamplerState _uSampler3D_sampler : register(s3); +TextureCube uSamplerCube : register(t4); +SamplerState _uSamplerCube_sampler : register(s4); +TextureCubeArray uSamplerCubeArray : register(t5); +SamplerState _uSamplerCubeArray_sampler : register(s5); +Buffer uSamplerBuffer : register(t6); +Texture2DMS uSamplerMS : register(t7); +SamplerState _uSamplerMS_sampler : register(s7); +Texture2DMSArray uSamplerMSArray : register(t8); +SamplerState _uSamplerMSArray_sampler : register(s8); +Texture2D uSampler2D : register(t1); +SamplerState _uSampler2D_sampler : register(s1); + +uint SPIRV_Cross_textureSize(Texture1D Tex, uint Level, out uint Param) +{ + uint ret; + Tex.GetDimensions(Level, ret.x, Param); + return ret; +} + +uint SPIRV_Cross_textureSize(Texture1D Tex, uint Level, out uint Param) +{ + uint ret; + Tex.GetDimensions(Level, ret.x, Param); + return ret; +} + +uint SPIRV_Cross_textureSize(Texture1D Tex, uint Level, out uint Param) +{ + uint ret; + Tex.GetDimensions(Level, ret.x, Param); + return ret; +} + +uint2 SPIRV_Cross_textureSize(Texture2D Tex, uint Level, out uint Param) +{ + uint2 ret; + Tex.GetDimensions(Level, ret.x, ret.y, Param); + return ret; +} + +uint3 SPIRV_Cross_textureSize(Texture2DArray Tex, uint Level, out uint Param) +{ + uint3 ret; + Tex.GetDimensions(Level, ret.x, ret.y, ret.z, Param); + return ret; +} + +uint3 SPIRV_Cross_textureSize(Texture3D Tex, uint Level, out uint Param) +{ + uint3 ret; + Tex.GetDimensions(Level, ret.x, ret.y, ret.z, Param); + return ret; +} + +uint SPIRV_Cross_textureSize(Buffer Tex, uint Level, out uint Param) +{ + uint ret; + Tex.GetDimensions(ret.x); + Param = 0u; + return ret; +} + +uint2 SPIRV_Cross_textureSize(TextureCube Tex, uint Level, out uint Param) +{ + uint2 ret; + Tex.GetDimensions(Level, ret.x, ret.y, Param); + return ret; +} + +uint3 SPIRV_Cross_textureSize(TextureCubeArray Tex, uint Level, out uint Param) +{ + uint3 ret; + Tex.GetDimensions(Level, ret.x, ret.y, ret.z, Param); + return ret; +} + +uint2 SPIRV_Cross_textureSize(Texture2DMS Tex, uint Level, out uint Param) +{ + uint2 ret; + Tex.GetDimensions(ret.x, ret.y, Param); + return ret; +} + +uint3 SPIRV_Cross_textureSize(Texture2DMSArray Tex, uint Level, out uint Param) +{ + uint3 ret; + Tex.GetDimensions(ret.x, ret.y, ret.z, Param); + return ret; +} + +void frag_main() +{ + uint _17_dummy_parameter; + int a = int(SPIRV_Cross_textureSize(uSampler1DUint, uint(0), _17_dummy_parameter)); + uint _24_dummy_parameter; + a = int(SPIRV_Cross_textureSize(uSampler1DInt, uint(0), _24_dummy_parameter)); + uint _32_dummy_parameter; + a = int(SPIRV_Cross_textureSize(uSampler1DFloat, uint(0), _32_dummy_parameter)); + uint _42_dummy_parameter; + int3 c = int3(SPIRV_Cross_textureSize(uSampler2DArray, uint(0), _42_dummy_parameter)); + uint _50_dummy_parameter; + int3 d = int3(SPIRV_Cross_textureSize(uSampler3D, uint(0), _50_dummy_parameter)); + uint _60_dummy_parameter; + int2 e = int2(SPIRV_Cross_textureSize(uSamplerCube, uint(0), _60_dummy_parameter)); + uint _68_dummy_parameter; + int3 f = int3(SPIRV_Cross_textureSize(uSamplerCubeArray, uint(0), _68_dummy_parameter)); + uint _76_dummy_parameter; + int g = int(SPIRV_Cross_textureSize(uSamplerBuffer, 0u, _76_dummy_parameter)); + uint _84_dummy_parameter; + int2 h = int2(SPIRV_Cross_textureSize(uSamplerMS, 0u, _84_dummy_parameter)); + uint _92_dummy_parameter; + int3 i = int3(SPIRV_Cross_textureSize(uSamplerMSArray, 0u, _92_dummy_parameter)); + int _100; + SPIRV_Cross_textureSize(uSampler2D, 0u, _100); + int l1 = int(_100); + int _104; + SPIRV_Cross_textureSize(uSampler2DArray, 0u, _104); + int l2 = int(_104); + int _108; + SPIRV_Cross_textureSize(uSampler3D, 0u, _108); + int l3 = int(_108); + int _112; + SPIRV_Cross_textureSize(uSamplerCube, 0u, _112); + int l4 = int(_112); + int _116; + SPIRV_Cross_textureSize(uSamplerMS, 0u, _116); + int s0 = int(_116); + int _120; + SPIRV_Cross_textureSize(uSamplerMSArray, 0u, _120); + int s1 = int(_120); +} + +void main() +{ + frag_main(); +} diff --git a/reference/shaders-hlsl/frag/image-query.frag b/reference/shaders-hlsl/frag/image-query.frag new file mode 100644 index 0000000000..71cefc1030 --- /dev/null +++ b/reference/shaders-hlsl/frag/image-query.frag @@ -0,0 +1,132 @@ +Texture1D uSampler1D : register(t0); +SamplerState _uSampler1D_sampler : register(s0); +Texture2D uSampler2D : register(t1); +SamplerState _uSampler2D_sampler : register(s1); +Texture2DArray uSampler2DArray : register(t2); +SamplerState _uSampler2DArray_sampler : register(s2); +Texture3D uSampler3D : register(t3); +SamplerState _uSampler3D_sampler : register(s3); +TextureCube uSamplerCube : register(t4); +SamplerState _uSamplerCube_sampler : register(s4); +TextureCubeArray uSamplerCubeArray : register(t5); +SamplerState _uSamplerCubeArray_sampler : register(s5); +Buffer uSamplerBuffer : register(t6); +Texture2DMS uSamplerMS : register(t7); +SamplerState _uSamplerMS_sampler : register(s7); +Texture2DMSArray uSamplerMSArray : register(t8); +SamplerState _uSamplerMSArray_sampler : register(s8); + +uint SPIRV_Cross_textureSize(Texture1D Tex, uint Level, out uint Param) +{ + uint ret; + Tex.GetDimensions(Level, ret.x, Param); + return ret; +} + +uint2 SPIRV_Cross_textureSize(Texture2D Tex, uint Level, out uint Param) +{ + uint2 ret; + Tex.GetDimensions(Level, ret.x, ret.y, Param); + return ret; +} + +uint3 SPIRV_Cross_textureSize(Texture2DArray Tex, uint Level, out uint Param) +{ + uint3 ret; + Tex.GetDimensions(Level, ret.x, ret.y, ret.z, Param); + return ret; +} + +uint3 SPIRV_Cross_textureSize(Texture3D Tex, uint Level, out uint Param) +{ + uint3 ret; + Tex.GetDimensions(Level, ret.x, ret.y, ret.z, Param); + return ret; +} + +uint SPIRV_Cross_textureSize(Buffer Tex, uint Level, out uint Param) +{ + uint ret; + Tex.GetDimensions(ret.x); + Param = 0u; + return ret; +} + +uint2 SPIRV_Cross_textureSize(TextureCube Tex, uint Level, out uint Param) +{ + uint2 ret; + Tex.GetDimensions(Level, ret.x, ret.y, Param); + return ret; +} + +uint3 SPIRV_Cross_textureSize(TextureCubeArray Tex, uint Level, out uint Param) +{ + uint3 ret; + Tex.GetDimensions(Level, ret.x, ret.y, ret.z, Param); + return ret; +} + +uint2 SPIRV_Cross_textureSize(Texture2DMS Tex, uint Level, out uint Param) +{ + uint2 ret; + Tex.GetDimensions(ret.x, ret.y, Param); + return ret; +} + +uint3 SPIRV_Cross_textureSize(Texture2DMSArray Tex, uint Level, out uint Param) +{ + uint3 ret; + Tex.GetDimensions(ret.x, ret.y, ret.z, Param); + return ret; +} + +void frag_main() +{ + uint _17_dummy_parameter; + int a = int(SPIRV_Cross_textureSize(uSampler1D, uint(0), _17_dummy_parameter)); + uint _27_dummy_parameter; + int2 b = int2(SPIRV_Cross_textureSize(uSampler2D, uint(0), _27_dummy_parameter)); + uint _37_dummy_parameter; + int3 c = int3(SPIRV_Cross_textureSize(uSampler2DArray, uint(0), _37_dummy_parameter)); + uint _45_dummy_parameter; + int3 d = int3(SPIRV_Cross_textureSize(uSampler3D, uint(0), _45_dummy_parameter)); + uint _53_dummy_parameter; + int2 e = int2(SPIRV_Cross_textureSize(uSamplerCube, uint(0), _53_dummy_parameter)); + uint _61_dummy_parameter; + int3 f = int3(SPIRV_Cross_textureSize(uSamplerCubeArray, uint(0), _61_dummy_parameter)); + uint _69_dummy_parameter; + int g = int(SPIRV_Cross_textureSize(uSamplerBuffer, 0u, _69_dummy_parameter)); + uint _77_dummy_parameter; + int2 h = int2(SPIRV_Cross_textureSize(uSamplerMS, 0u, _77_dummy_parameter)); + uint _85_dummy_parameter; + int3 i = int3(SPIRV_Cross_textureSize(uSamplerMSArray, 0u, _85_dummy_parameter)); + int _89; + SPIRV_Cross_textureSize(uSampler1D, 0u, _89); + int l0 = int(_89); + int _93; + SPIRV_Cross_textureSize(uSampler2D, 0u, _93); + int l1 = int(_93); + int _97; + SPIRV_Cross_textureSize(uSampler2DArray, 0u, _97); + int l2 = int(_97); + int _101; + SPIRV_Cross_textureSize(uSampler3D, 0u, _101); + int l3 = int(_101); + int _105; + SPIRV_Cross_textureSize(uSamplerCube, 0u, _105); + int l4 = int(_105); + int _109; + SPIRV_Cross_textureSize(uSamplerCubeArray, 0u, _109); + int l5 = int(_109); + int _113; + SPIRV_Cross_textureSize(uSamplerMS, 0u, _113); + int s0 = int(_113); + int _117; + SPIRV_Cross_textureSize(uSamplerMSArray, 0u, _117); + int s1 = int(_117); +} + +void main() +{ + frag_main(); +} diff --git a/reference/shaders-hlsl/frag/io-block.frag b/reference/shaders-hlsl/frag/io-block.frag new file mode 100644 index 0000000000..52c1f518bf --- /dev/null +++ b/reference/shaders-hlsl/frag/io-block.frag @@ -0,0 +1,28 @@ +static float4 FragColor; + +struct VertexOut +{ + float4 a : TEXCOORD1; + float4 b : TEXCOORD2; +}; + +static VertexOut _12; + +struct SPIRV_Cross_Output +{ + float4 FragColor : SV_Target0; +}; + +void frag_main() +{ + FragColor = _12.a + _12.b; +} + +SPIRV_Cross_Output main(in VertexOut stage_input_12) +{ + _12 = stage_input_12; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/shaders-hlsl/frag/matrix-input.frag b/reference/shaders-hlsl/frag/matrix-input.frag new file mode 100644 index 0000000000..92d87d396e --- /dev/null +++ b/reference/shaders-hlsl/frag/matrix-input.frag @@ -0,0 +1,26 @@ +static float4 FragColor; +static float4x4 m; + +struct SPIRV_Cross_Input +{ + float4x4 m : TEXCOORD1; +}; + +struct SPIRV_Cross_Output +{ + float4 FragColor : SV_Target0; +}; + +void frag_main() +{ + FragColor = ((m[0] + m[1]) + m[2]) + m[3]; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + m = stage_input.m; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/shaders-hlsl/frag/mod.frag b/reference/shaders-hlsl/frag/mod.frag new file mode 100644 index 0000000000..1da8f21e45 --- /dev/null +++ b/reference/shaders-hlsl/frag/mod.frag @@ -0,0 +1,71 @@ +static float4 a4; +static float4 b4; +static float3 a3; +static float3 b3; +static float2 a2; +static float2 b2; +static float a1; +static float b1; +static float4 FragColor; + +struct SPIRV_Cross_Input +{ + float4 a4 : TEXCOORD0; + float3 a3 : TEXCOORD1; + float2 a2 : TEXCOORD2; + float a1 : TEXCOORD3; + float4 b4 : TEXCOORD4; + float3 b3 : TEXCOORD5; + float2 b2 : TEXCOORD6; + float b1 : TEXCOORD7; +}; + +struct SPIRV_Cross_Output +{ + float4 FragColor : SV_Target0; +}; + +float mod(float x, float y) +{ + return x - y * floor(x / y); +} + +float2 mod(float2 x, float2 y) +{ + return x - y * floor(x / y); +} + +float3 mod(float3 x, float3 y) +{ + return x - y * floor(x / y); +} + +float4 mod(float4 x, float4 y) +{ + return x - y * floor(x / y); +} + +void frag_main() +{ + float4 m0 = mod(a4, b4); + float3 m1 = mod(a3, b3); + float2 m2 = mod(a2, b2); + float m3 = mod(a1, b1); + FragColor = ((m0 + m1.xyzx) + m2.xyxy) + m3.xxxx; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + a4 = stage_input.a4; + b4 = stage_input.b4; + a3 = stage_input.a3; + b3 = stage_input.b3; + a2 = stage_input.a2; + b2 = stage_input.b2; + a1 = stage_input.a1; + b1 = stage_input.b1; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/shaders-hlsl/frag/mrt.frag b/reference/shaders-hlsl/frag/mrt.frag new file mode 100644 index 0000000000..e69e91196a --- /dev/null +++ b/reference/shaders-hlsl/frag/mrt.frag @@ -0,0 +1,31 @@ +static float4 RT0; +static float4 RT1; +static float4 RT2; +static float4 RT3; + +struct SPIRV_Cross_Output +{ + float4 RT0 : SV_Target0; + float4 RT1 : SV_Target1; + float4 RT2 : SV_Target2; + float4 RT3 : SV_Target3; +}; + +void frag_main() +{ + RT0 = 1.0f.xxxx; + RT1 = 2.0f.xxxx; + RT2 = 3.0f.xxxx; + RT3 = 4.0f.xxxx; +} + +SPIRV_Cross_Output main() +{ + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.RT0 = RT0; + stage_output.RT1 = RT1; + stage_output.RT2 = RT2; + stage_output.RT3 = RT3; + return stage_output; +} diff --git a/reference/shaders-hlsl/frag/no-return.frag b/reference/shaders-hlsl/frag/no-return.frag new file mode 100644 index 0000000000..3b50282fe0 --- /dev/null +++ b/reference/shaders-hlsl/frag/no-return.frag @@ -0,0 +1,8 @@ +void frag_main() +{ +} + +void main() +{ + frag_main(); +} diff --git a/reference/shaders-hlsl/frag/no-return2.frag b/reference/shaders-hlsl/frag/no-return2.frag new file mode 100644 index 0000000000..a22ffa7725 --- /dev/null +++ b/reference/shaders-hlsl/frag/no-return2.frag @@ -0,0 +1,17 @@ +static float4 vColor; + +struct SPIRV_Cross_Input +{ + float4 vColor : TEXCOORD0; +}; + +void frag_main() +{ + float4 v = vColor; +} + +void main(SPIRV_Cross_Input stage_input) +{ + vColor = stage_input.vColor; + frag_main(); +} diff --git a/reference/shaders-hlsl/frag/partial-write-preserve.frag b/reference/shaders-hlsl/frag/partial-write-preserve.frag new file mode 100644 index 0000000000..402c8108c1 --- /dev/null +++ b/reference/shaders-hlsl/frag/partial-write-preserve.frag @@ -0,0 +1,75 @@ +struct B +{ + float a; + float b; +}; + +static const B _80 = { 10.0f, 20.0f }; + +cbuffer _42 : register(b0) +{ + int _42_some_value : packoffset(c0); +}; + +void partial_inout(inout float4 x) +{ + x.x = 10.0f; +} + +void complete_inout(out float4 x) +{ + x = 50.0f.xxxx; +} + +void branchy_inout(inout float4 v) +{ + v.y = 20.0f; + if (_42_some_value == 20) + { + v = 50.0f.xxxx; + } +} + +void branchy_inout_2(out float4 v) +{ + if (_42_some_value == 20) + { + v = 50.0f.xxxx; + } + else + { + v = 70.0f.xxxx; + } + v.y = 20.0f; +} + +void partial_inout(inout B b) +{ + b.b = 40.0f; +} + +void frag_main() +{ + float4 a = 10.0f.xxxx; + float4 param = a; + partial_inout(param); + a = param; + float4 param_1; + complete_inout(param_1); + a = param_1; + float4 param_2 = a; + branchy_inout(param_2); + a = param_2; + float4 param_3; + branchy_inout_2(param_3); + a = param_3; + B b = _80; + B param_4 = b; + partial_inout(param_4); + b = param_4; +} + +void main() +{ + frag_main(); +} diff --git a/reference/shaders-hlsl/frag/query-lod.desktop.frag b/reference/shaders-hlsl/frag/query-lod.desktop.frag new file mode 100644 index 0000000000..fd95798bf4 --- /dev/null +++ b/reference/shaders-hlsl/frag/query-lod.desktop.frag @@ -0,0 +1,30 @@ +Texture2D uSampler : register(t0); +SamplerState _uSampler_sampler : register(s0); + +static float4 FragColor; +static float2 vTexCoord; + +struct SPIRV_Cross_Input +{ + float2 vTexCoord : TEXCOORD0; +}; + +struct SPIRV_Cross_Output +{ + float4 FragColor : SV_Target0; +}; + +void frag_main() +{ + float _19_tmp = uSampler.CalculateLevelOfDetail(_uSampler_sampler, vTexCoord); + FragColor = float2(_19_tmp, _19_tmp).xyxy; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + vTexCoord = stage_input.vTexCoord; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/shaders-hlsl/frag/resources.frag b/reference/shaders-hlsl/frag/resources.frag new file mode 100644 index 0000000000..60b709e696 --- /dev/null +++ b/reference/shaders-hlsl/frag/resources.frag @@ -0,0 +1,42 @@ +cbuffer cbuf : register(b3) +{ + float4 cbuf_a : packoffset(c0); +}; +cbuffer registers +{ + float4 registers_d : packoffset(c0); +}; +Texture2D uSampledImage : register(t4); +SamplerState _uSampledImage_sampler : register(s4); +Texture2D uTexture : register(t5); +SamplerState uSampler : register(s6); + +static float2 vTex; +static float4 FragColor; + +struct SPIRV_Cross_Input +{ + float2 vTex : TEXCOORD0; +}; + +struct SPIRV_Cross_Output +{ + float4 FragColor : SV_Target0; +}; + +void frag_main() +{ + float4 c0 = uSampledImage.Sample(_uSampledImage_sampler, vTex); + float4 c1 = uTexture.Sample(uSampler, vTex); + float4 c2 = cbuf_a + registers_d; + FragColor = (c0 + c1) + c2; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + vTex = stage_input.vTex; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/shaders-hlsl/frag/sample-cmp-level-zero.frag b/reference/shaders-hlsl/frag/sample-cmp-level-zero.frag new file mode 100644 index 0000000000..b52b1df554 --- /dev/null +++ b/reference/shaders-hlsl/frag/sample-cmp-level-zero.frag @@ -0,0 +1,66 @@ +Texture2D uSampler2D : register(t0); +SamplerComparisonState _uSampler2D_sampler : register(s0); +Texture2DArray uSampler2DArray : register(t1); +SamplerComparisonState _uSampler2DArray_sampler : register(s1); +TextureCube uSamplerCube : register(t2); +SamplerComparisonState _uSamplerCube_sampler : register(s2); +TextureCubeArray uSamplerCubeArray : register(t3); +SamplerComparisonState _uSamplerCubeArray_sampler : register(s3); + +static float3 vUVRef; +static float4 vDirRef; +static float FragColor; + +struct SPIRV_Cross_Input +{ + float3 vUVRef : TEXCOORD0; + float4 vDirRef : TEXCOORD1; +}; + +struct SPIRV_Cross_Output +{ + float FragColor : SV_Target0; +}; + +float SPIRV_Cross_projectTextureCoordinate(float2 coord) +{ + return coord.x / coord.y; +} + +float2 SPIRV_Cross_projectTextureCoordinate(float3 coord) +{ + return float2(coord.x, coord.y) / coord.z; +} + +float3 SPIRV_Cross_projectTextureCoordinate(float4 coord) +{ + return float3(coord.x, coord.y, coord.z) / coord.w; +} + +void frag_main() +{ + float s0 = uSampler2D.SampleCmp(_uSampler2D_sampler, vUVRef.xy, vUVRef.z, int2(-1, -1)); + float s1 = uSampler2DArray.SampleCmp(_uSampler2DArray_sampler, vDirRef.xyz, vDirRef.w, int2(-1, -1)); + float s2 = uSamplerCube.SampleCmp(_uSamplerCube_sampler, vDirRef.xyz, vDirRef.w); + float s3 = uSamplerCubeArray.SampleCmp(_uSamplerCubeArray_sampler, vDirRef, 0.5f); + float l0 = uSampler2D.SampleCmpLevelZero(_uSampler2D_sampler, vUVRef.xy, vUVRef.z, int2(-1, -1)); + float l1 = uSampler2DArray.SampleCmpLevelZero(_uSampler2DArray_sampler, vDirRef.xyz, vDirRef.w, int2(-1, -1)); + float l2 = uSamplerCube.SampleCmpLevelZero(_uSamplerCube_sampler, vDirRef.xyz, vDirRef.w); + float4 _80 = vDirRef; + _80.z = vDirRef.w; + float p0 = uSampler2D.SampleCmp(_uSampler2D_sampler, SPIRV_Cross_projectTextureCoordinate(_80.xyz), vDirRef.z, int2(1, 1)); + float4 _87 = vDirRef; + _87.z = vDirRef.w; + float p1 = uSampler2D.SampleCmpLevelZero(_uSampler2D_sampler, SPIRV_Cross_projectTextureCoordinate(_87.xyz), vDirRef.z, int2(1, 1)); + FragColor = (((((((s0 + s1) + s2) + s3) + l0) + l1) + l2) + p0) + p1; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + vUVRef = stage_input.vUVRef; + vDirRef = stage_input.vDirRef; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/shaders-hlsl/frag/sampler-array.frag b/reference/shaders-hlsl/frag/sampler-array.frag new file mode 100644 index 0000000000..7fc5e3f37e --- /dev/null +++ b/reference/shaders-hlsl/frag/sampler-array.frag @@ -0,0 +1,43 @@ +Texture2D uCombined[4] : register(t0); +SamplerState _uCombined_sampler[4] : register(s0); +Texture2D uTex[4] : register(t4); +SamplerState uSampler[4] : register(s8); +RWTexture2D uImage[8] : register(u12); + +static float4 gl_FragCoord; +static float2 vTex; +static int vIndex; + +struct SPIRV_Cross_Input +{ + float2 vTex : TEXCOORD0; + nointerpolation int vIndex : TEXCOORD1; + float4 gl_FragCoord : SV_Position; +}; + +float4 sample_in_function(Texture2D samp, SamplerState _samp_sampler) +{ + return samp.Sample(_samp_sampler, vTex); +} + +float4 sample_in_function2(Texture2D tex, SamplerState samp) +{ + return tex.Sample(samp, vTex); +} + +void frag_main() +{ + float4 color = uCombined[vIndex].Sample(_uCombined_sampler[vIndex], vTex); + color += uTex[vIndex].Sample(uSampler[vIndex], vTex); + color += sample_in_function(uCombined[vIndex + 1], _uCombined_sampler[vIndex + 1]); + color += sample_in_function2(uTex[vIndex + 1], uSampler[vIndex + 1]); + uImage[vIndex][int2(gl_FragCoord.xy)] = color; +} + +void main(SPIRV_Cross_Input stage_input) +{ + gl_FragCoord = stage_input.gl_FragCoord; + vTex = stage_input.vTex; + vIndex = stage_input.vIndex; + frag_main(); +} diff --git a/reference/shaders-hlsl/frag/spec-constant.frag b/reference/shaders-hlsl/frag/spec-constant.frag new file mode 100644 index 0000000000..70b029dc68 --- /dev/null +++ b/reference/shaders-hlsl/frag/spec-constant.frag @@ -0,0 +1,79 @@ +static const float a = 1.0f; +static const float b = 2.0f; +static const int c = 3; +static const int d = 4; +static const uint e = 5u; +static const uint f = 6u; +static const bool g = false; +static const bool h = true; + +struct Foo +{ + float elems[(d + 2)]; +}; + +static float4 FragColor; + +struct SPIRV_Cross_Output +{ + float4 FragColor : SV_Target0; +}; + +void frag_main() +{ + float t0 = a; + float t1 = b; + uint c0 = (uint(c) + 0u); + int c1 = (-c); + int c2 = (~c); + int c3 = (c + d); + int c4 = (c - d); + int c5 = (c * d); + int c6 = (c / d); + uint c7 = (e / f); + int c8 = (c % d); + uint c9 = (e % f); + int c10 = (c >> d); + uint c11 = (e >> f); + int c12 = (c << d); + int c13 = (c | d); + int c14 = (c ^ d); + int c15 = (c & d); + bool c16 = (g || h); + bool c17 = (g && h); + bool c18 = (!g); + bool c19 = (g == h); + bool c20 = (g != h); + bool c21 = (c == d); + bool c22 = (c != d); + bool c23 = (c < d); + bool c24 = (e < f); + bool c25 = (c > d); + bool c26 = (e > f); + bool c27 = (c <= d); + bool c28 = (e <= f); + bool c29 = (c >= d); + bool c30 = (e >= f); + int c31 = c8 + c3; + int c32 = int(e + 0u); + bool c33 = (c != int(0u)); + bool c34 = (e != 0u); + int c35 = int(g); + uint c36 = uint(g); + float c37 = float(g); + float vec0[(c + 3)][8]; + vec0[0][0] = 10.0f; + float vec1[(c + 2)]; + vec1[0] = 20.0f; + Foo foo; + foo.elems[c] = 10.0f; + FragColor = (((t0 + t1).xxxx + vec0[0][0].xxxx) + vec1[0].xxxx) + foo.elems[c].xxxx; +} + +SPIRV_Cross_Output main() +{ + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/shaders-hlsl/frag/swizzle-scalar.frag b/reference/shaders-hlsl/frag/swizzle-scalar.frag new file mode 100644 index 0000000000..ab310b82f2 --- /dev/null +++ b/reference/shaders-hlsl/frag/swizzle-scalar.frag @@ -0,0 +1,41 @@ +static float4 Float; +static float vFloat; +static int4 Int; +static int vInt; +static float4 Float2; +static int4 Int2; + +struct SPIRV_Cross_Input +{ + nointerpolation float vFloat : TEXCOORD0; + nointerpolation int vInt : TEXCOORD1; +}; + +struct SPIRV_Cross_Output +{ + float4 Float : SV_Target0; + int4 Int : SV_Target1; + float4 Float2 : SV_Target2; + int4 Int2 : SV_Target3; +}; + +void frag_main() +{ + Float = vFloat.xxxx * 2.0f; + Int = vInt.xxxx * int4(2, 2, 2, 2); + Float2 = 10.0f.xxxx; + Int2 = int4(10, 10, 10, 10); +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + vFloat = stage_input.vFloat; + vInt = stage_input.vInt; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.Float = Float; + stage_output.Int = Int; + stage_output.Float2 = Float2; + stage_output.Int2 = Int2; + return stage_output; +} diff --git a/reference/shaders-hlsl/frag/tex-sampling.frag b/reference/shaders-hlsl/frag/tex-sampling.frag new file mode 100644 index 0000000000..7e10bfdd24 --- /dev/null +++ b/reference/shaders-hlsl/frag/tex-sampling.frag @@ -0,0 +1,118 @@ +Texture1D tex1d; +SamplerState _tex1d_sampler; +Texture2D tex2d; +SamplerState _tex2d_sampler; +Texture3D tex3d; +SamplerState _tex3d_sampler; +TextureCube texCube; +SamplerState _texCube_sampler; +Texture1D tex1dShadow; +SamplerComparisonState _tex1dShadow_sampler; +Texture2D tex2dShadow; +SamplerComparisonState _tex2dShadow_sampler; +TextureCube texCubeShadow; +SamplerComparisonState _texCubeShadow_sampler; +Texture1DArray tex1dArray; +SamplerState _tex1dArray_sampler; +Texture2DArray tex2dArray; +SamplerState _tex2dArray_sampler; +TextureCubeArray texCubeArray; +SamplerState _texCubeArray_sampler; +Texture2D separateTex2d; +SamplerState samplerNonDepth; +Texture2D separateTex2dDepth; +SamplerComparisonState samplerDepth; + +static float texCoord1d; +static float2 texCoord2d; +static float3 texCoord3d; +static float4 texCoord4d; +static float4 FragColor; + +struct SPIRV_Cross_Input +{ + float texCoord1d : TEXCOORD0; + float2 texCoord2d : TEXCOORD1; + float3 texCoord3d : TEXCOORD2; + float4 texCoord4d : TEXCOORD3; +}; + +struct SPIRV_Cross_Output +{ + float4 FragColor : SV_Target0; +}; + +float SPIRV_Cross_projectTextureCoordinate(float2 coord) +{ + return coord.x / coord.y; +} + +float2 SPIRV_Cross_projectTextureCoordinate(float3 coord) +{ + return float2(coord.x, coord.y) / coord.z; +} + +float3 SPIRV_Cross_projectTextureCoordinate(float4 coord) +{ + return float3(coord.x, coord.y, coord.z) / coord.w; +} + +void frag_main() +{ + float4 texcolor = tex1d.Sample(_tex1d_sampler, texCoord1d); + texcolor += tex1d.Sample(_tex1d_sampler, texCoord1d, 1); + texcolor += tex1d.SampleLevel(_tex1d_sampler, texCoord1d, 2.0f); + texcolor += tex1d.SampleGrad(_tex1d_sampler, texCoord1d, 1.0f, 2.0f); + texcolor += tex1d.Sample(_tex1d_sampler, SPIRV_Cross_projectTextureCoordinate(float2(texCoord1d, 2.0f))); + texcolor += tex1d.SampleBias(_tex1d_sampler, texCoord1d, 1.0f); + texcolor += tex2d.Sample(_tex2d_sampler, texCoord2d); + texcolor += tex2d.Sample(_tex2d_sampler, texCoord2d, int2(1, 2)); + texcolor += tex2d.SampleLevel(_tex2d_sampler, texCoord2d, 2.0f); + texcolor += tex2d.SampleGrad(_tex2d_sampler, texCoord2d, float2(1.0f, 2.0f), float2(3.0f, 4.0f)); + texcolor += tex2d.Sample(_tex2d_sampler, SPIRV_Cross_projectTextureCoordinate(float3(texCoord2d, 2.0f))); + texcolor += tex2d.SampleBias(_tex2d_sampler, texCoord2d, 1.0f); + texcolor += tex3d.Sample(_tex3d_sampler, texCoord3d); + texcolor += tex3d.Sample(_tex3d_sampler, texCoord3d, int3(1, 2, 3)); + texcolor += tex3d.SampleLevel(_tex3d_sampler, texCoord3d, 2.0f); + texcolor += tex3d.SampleGrad(_tex3d_sampler, texCoord3d, float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f)); + texcolor += tex3d.Sample(_tex3d_sampler, SPIRV_Cross_projectTextureCoordinate(float4(texCoord3d, 2.0f))); + texcolor += tex3d.SampleBias(_tex3d_sampler, texCoord3d, 1.0f); + texcolor += texCube.Sample(_texCube_sampler, texCoord3d); + texcolor += texCube.SampleLevel(_texCube_sampler, texCoord3d, 2.0f); + texcolor += texCube.SampleBias(_texCube_sampler, texCoord3d, 1.0f); + float3 _170 = float3(texCoord1d, 0.0f, 0.0f); + texcolor.w += tex1dShadow.SampleCmp(_tex1dShadow_sampler, _170.x, _170.z); + float3 _188 = float3(texCoord2d, 0.0f); + texcolor.w += tex2dShadow.SampleCmp(_tex2dShadow_sampler, _188.xy, _188.z); + float4 _204 = float4(texCoord3d, 0.0f); + texcolor.w += texCubeShadow.SampleCmp(_texCubeShadow_sampler, _204.xyz, _204.w); + texcolor += tex1dArray.Sample(_tex1dArray_sampler, texCoord2d); + texcolor += tex2dArray.Sample(_tex2dArray_sampler, texCoord3d); + texcolor += texCubeArray.Sample(_texCubeArray_sampler, texCoord4d); + texcolor += tex2d.GatherRed(_tex2d_sampler, texCoord2d); + texcolor += tex2d.GatherRed(_tex2d_sampler, texCoord2d); + texcolor += tex2d.GatherGreen(_tex2d_sampler, texCoord2d); + texcolor += tex2d.GatherBlue(_tex2d_sampler, texCoord2d); + texcolor += tex2d.GatherAlpha(_tex2d_sampler, texCoord2d); + texcolor += tex2d.GatherRed(_tex2d_sampler, texCoord2d, int2(1, 1)); + texcolor += tex2d.GatherRed(_tex2d_sampler, texCoord2d, int2(1, 1)); + texcolor += tex2d.GatherGreen(_tex2d_sampler, texCoord2d, int2(1, 1)); + texcolor += tex2d.GatherBlue(_tex2d_sampler, texCoord2d, int2(1, 1)); + texcolor += tex2d.GatherAlpha(_tex2d_sampler, texCoord2d, int2(1, 1)); + texcolor += tex2d.Load(int3(int2(1, 2), 0)); + texcolor += separateTex2d.Sample(samplerNonDepth, texCoord2d); + texcolor.w += separateTex2dDepth.SampleCmp(samplerDepth, texCoord3d.xy, texCoord3d.z); + FragColor = texcolor; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + texCoord1d = stage_input.texCoord1d; + texCoord2d = stage_input.texCoord2d; + texCoord3d = stage_input.texCoord3d; + texCoord4d = stage_input.texCoord4d; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/shaders-hlsl/frag/texture-proj-shadow.frag b/reference/shaders-hlsl/frag/texture-proj-shadow.frag new file mode 100644 index 0000000000..4beaa11761 --- /dev/null +++ b/reference/shaders-hlsl/frag/texture-proj-shadow.frag @@ -0,0 +1,66 @@ +Texture1D uShadow1D : register(t0); +SamplerComparisonState _uShadow1D_sampler : register(s0); +Texture2D uShadow2D : register(t1); +SamplerComparisonState _uShadow2D_sampler : register(s1); +Texture1D uSampler1D : register(t2); +SamplerState _uSampler1D_sampler : register(s2); +Texture2D uSampler2D : register(t3); +SamplerState _uSampler2D_sampler : register(s3); +Texture3D uSampler3D : register(t4); +SamplerState _uSampler3D_sampler : register(s4); + +static float FragColor; +static float4 vClip4; +static float2 vClip2; +static float3 vClip3; + +struct SPIRV_Cross_Input +{ + float3 vClip3 : TEXCOORD0; + float4 vClip4 : TEXCOORD1; + float2 vClip2 : TEXCOORD2; +}; + +struct SPIRV_Cross_Output +{ + float FragColor : SV_Target0; +}; + +float SPIRV_Cross_projectTextureCoordinate(float2 coord) +{ + return coord.x / coord.y; +} + +float2 SPIRV_Cross_projectTextureCoordinate(float3 coord) +{ + return float2(coord.x, coord.y) / coord.z; +} + +float3 SPIRV_Cross_projectTextureCoordinate(float4 coord) +{ + return float3(coord.x, coord.y, coord.z) / coord.w; +} + +void frag_main() +{ + float4 _20 = vClip4; + _20.y = vClip4.w; + FragColor = uShadow1D.SampleCmp(_uShadow1D_sampler, SPIRV_Cross_projectTextureCoordinate(_20.xy), vClip4.z); + float4 _30 = vClip4; + _30.z = vClip4.w; + FragColor = uShadow2D.SampleCmp(_uShadow2D_sampler, SPIRV_Cross_projectTextureCoordinate(_30.xyz), vClip4.z); + FragColor = uSampler1D.Sample(_uSampler1D_sampler, SPIRV_Cross_projectTextureCoordinate(vClip2)).x; + FragColor = uSampler2D.Sample(_uSampler2D_sampler, SPIRV_Cross_projectTextureCoordinate(vClip3)).x; + FragColor = uSampler3D.Sample(_uSampler3D_sampler, SPIRV_Cross_projectTextureCoordinate(vClip4)).x; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + vClip4 = stage_input.vClip4; + vClip2 = stage_input.vClip2; + vClip3 = stage_input.vClip3; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/shaders-hlsl/frag/texture-size-combined-image-sampler.frag b/reference/shaders-hlsl/frag/texture-size-combined-image-sampler.frag new file mode 100644 index 0000000000..d5c373746d --- /dev/null +++ b/reference/shaders-hlsl/frag/texture-size-combined-image-sampler.frag @@ -0,0 +1,30 @@ +Texture2D uTex : register(t0); +SamplerState uSampler : register(s1); + +static int2 FooOut; + +struct SPIRV_Cross_Output +{ + int2 FooOut : SV_Target0; +}; + +uint2 SPIRV_Cross_textureSize(Texture2D Tex, uint Level, out uint Param) +{ + uint2 ret; + Tex.GetDimensions(Level, ret.x, ret.y, Param); + return ret; +} + +void frag_main() +{ + uint _23_dummy_parameter; + FooOut = int2(SPIRV_Cross_textureSize(uTex, uint(0), _23_dummy_parameter)); +} + +SPIRV_Cross_Output main() +{ + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FooOut = FooOut; + return stage_output; +} diff --git a/reference/shaders-hlsl/frag/unary-enclose.frag b/reference/shaders-hlsl/frag/unary-enclose.frag new file mode 100644 index 0000000000..597c57f800 --- /dev/null +++ b/reference/shaders-hlsl/frag/unary-enclose.frag @@ -0,0 +1,32 @@ +static float4 FragColor; +static float4 vIn; +static int4 vIn1; + +struct SPIRV_Cross_Input +{ + float4 vIn : TEXCOORD0; + nointerpolation int4 vIn1 : TEXCOORD1; +}; + +struct SPIRV_Cross_Output +{ + float4 FragColor : SV_Target0; +}; + +void frag_main() +{ + FragColor = -(-vIn); + int4 a = ~(~vIn1); + bool b = false; + b = !(!b); +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + vIn = stage_input.vIn; + vIn1 = stage_input.vIn1; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/shaders-hlsl/frag/unorm-snorm-packing.frag b/reference/shaders-hlsl/frag/unorm-snorm-packing.frag new file mode 100644 index 0000000000..57b5950636 --- /dev/null +++ b/reference/shaders-hlsl/frag/unorm-snorm-packing.frag @@ -0,0 +1,109 @@ +static float4 FP32Out; +static uint UNORM8; +static uint SNORM8; +static uint UNORM16; +static uint SNORM16; +static uint UNORM8Out; +static float4 FP32; +static uint SNORM8Out; +static uint UNORM16Out; +static uint SNORM16Out; + +struct SPIRV_Cross_Input +{ + nointerpolation uint SNORM8 : TEXCOORD0; + nointerpolation uint UNORM8 : TEXCOORD1; + nointerpolation uint SNORM16 : TEXCOORD2; + nointerpolation uint UNORM16 : TEXCOORD3; + nointerpolation float4 FP32 : TEXCOORD4; +}; + +struct SPIRV_Cross_Output +{ + float4 FP32Out : SV_Target0; + uint UNORM8Out : SV_Target1; + uint SNORM8Out : SV_Target2; + uint UNORM16Out : SV_Target3; + uint SNORM16Out : SV_Target4; +}; + +uint SPIRV_Cross_packUnorm4x8(float4 value) +{ + uint4 Packed = uint4(round(saturate(value) * 255.0)); + return Packed.x | (Packed.y << 8) | (Packed.z << 16) | (Packed.w << 24); +} + +float4 SPIRV_Cross_unpackUnorm4x8(uint value) +{ + uint4 Packed = uint4(value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, value >> 24); + return float4(Packed) / 255.0; +} + +uint SPIRV_Cross_packSnorm4x8(float4 value) +{ + int4 Packed = int4(round(clamp(value, -1.0, 1.0) * 127.0)) & 0xff; + return uint(Packed.x | (Packed.y << 8) | (Packed.z << 16) | (Packed.w << 24)); +} + +float4 SPIRV_Cross_unpackSnorm4x8(uint value) +{ + int SignedValue = int(value); + int4 Packed = int4(SignedValue << 24, SignedValue << 16, SignedValue << 8, SignedValue) >> 24; + return clamp(float4(Packed) / 127.0, -1.0, 1.0); +} + +uint SPIRV_Cross_packUnorm2x16(float2 value) +{ + uint2 Packed = uint2(round(saturate(value) * 65535.0)); + return Packed.x | (Packed.y << 16); +} + +float2 SPIRV_Cross_unpackUnorm2x16(uint value) +{ + uint2 Packed = uint2(value & 0xffff, value >> 16); + return float2(Packed) / 65535.0; +} + +uint SPIRV_Cross_packSnorm2x16(float2 value) +{ + int2 Packed = int2(round(clamp(value, -1.0, 1.0) * 32767.0)) & 0xffff; + return uint(Packed.x | (Packed.y << 16)); +} + +float2 SPIRV_Cross_unpackSnorm2x16(uint value) +{ + int SignedValue = int(value); + int2 Packed = int2(SignedValue << 16, SignedValue) >> 16; + return clamp(float2(Packed) / 32767.0, -1.0, 1.0); +} + +void frag_main() +{ + FP32Out = SPIRV_Cross_unpackUnorm4x8(UNORM8); + FP32Out = SPIRV_Cross_unpackSnorm4x8(SNORM8); + float2 _21 = SPIRV_Cross_unpackUnorm2x16(UNORM16); + FP32Out = float4(_21.x, _21.y, FP32Out.z, FP32Out.w); + float2 _26 = SPIRV_Cross_unpackSnorm2x16(SNORM16); + FP32Out = float4(_26.x, _26.y, FP32Out.z, FP32Out.w); + UNORM8Out = SPIRV_Cross_packUnorm4x8(FP32); + SNORM8Out = SPIRV_Cross_packSnorm4x8(FP32); + UNORM16Out = SPIRV_Cross_packUnorm2x16(FP32.xy); + SNORM16Out = SPIRV_Cross_packSnorm2x16(FP32.zw); +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + UNORM8 = stage_input.UNORM8; + SNORM8 = stage_input.SNORM8; + UNORM16 = stage_input.UNORM16; + SNORM16 = stage_input.SNORM16; + FP32 = stage_input.FP32; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FP32Out = FP32Out; + stage_output.UNORM8Out = UNORM8Out; + stage_output.SNORM8Out = SNORM8Out; + stage_output.UNORM16Out = UNORM16Out; + stage_output.SNORM16Out = SNORM16Out; + return stage_output; +} diff --git a/reference/shaders-hlsl/frag/various-glsl-ops.frag b/reference/shaders-hlsl/frag/various-glsl-ops.frag new file mode 100644 index 0000000000..f0b345482b --- /dev/null +++ b/reference/shaders-hlsl/frag/various-glsl-ops.frag @@ -0,0 +1,28 @@ +static float2 interpolant; +static float4 FragColor; + +struct SPIRV_Cross_Input +{ + float2 interpolant : TEXCOORD0; +}; + +struct SPIRV_Cross_Output +{ + float4 FragColor : SV_Target0; +}; + +void frag_main() +{ + float4 color = float4(0.0f, 0.0f, 0.0f, EvaluateAttributeSnapped(interpolant, 0.100000001490116119384765625f.xx).x); + color += float4(0.0f, 0.0f, 0.0f, ddx_coarse(interpolant.x)); + FragColor = color; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + interpolant = stage_input.interpolant; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/shaders-hlsl/vert/basic.vert b/reference/shaders-hlsl/vert/basic.vert new file mode 100644 index 0000000000..5f0a5f3d1a --- /dev/null +++ b/reference/shaders-hlsl/vert/basic.vert @@ -0,0 +1,38 @@ +cbuffer _16 +{ + row_major float4x4 _16_uMVP : packoffset(c0); +}; + +static float4 gl_Position; +static float4 aVertex; +static float3 vNormal; +static float3 aNormal; + +struct SPIRV_Cross_Input +{ + float4 aVertex : TEXCOORD0; + float3 aNormal : TEXCOORD1; +}; + +struct SPIRV_Cross_Output +{ + float3 vNormal : TEXCOORD0; + float4 gl_Position : SV_Position; +}; + +void vert_main() +{ + gl_Position = mul(aVertex, _16_uMVP); + vNormal = aNormal; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + aVertex = stage_input.aVertex; + aNormal = stage_input.aNormal; + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + stage_output.vNormal = vNormal; + return stage_output; +} diff --git a/reference/shaders-hlsl/vert/instancing.vert b/reference/shaders-hlsl/vert/instancing.vert new file mode 100644 index 0000000000..48b2df20d3 --- /dev/null +++ b/reference/shaders-hlsl/vert/instancing.vert @@ -0,0 +1,28 @@ +static float4 gl_Position; +static int gl_VertexIndex; +static int gl_InstanceIndex; +struct SPIRV_Cross_Input +{ + uint gl_VertexIndex : SV_VertexID; + uint gl_InstanceIndex : SV_InstanceID; +}; + +struct SPIRV_Cross_Output +{ + float4 gl_Position : SV_Position; +}; + +void vert_main() +{ + gl_Position = float(gl_VertexIndex + gl_InstanceIndex).xxxx; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + gl_VertexIndex = int(stage_input.gl_VertexIndex); + gl_InstanceIndex = int(stage_input.gl_InstanceIndex); + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + return stage_output; +} diff --git a/reference/shaders-hlsl/vert/locations.vert b/reference/shaders-hlsl/vert/locations.vert new file mode 100644 index 0000000000..b06b204bdd --- /dev/null +++ b/reference/shaders-hlsl/vert/locations.vert @@ -0,0 +1,75 @@ +struct Foo +{ + float3 a; + float3 b; + float3 c; +}; + +static float4 gl_Position; +static float4 Input2; +static float4 Input4; +static float4 Input0; +static float vLocation0; +static float vLocation1; +static float vLocation2[2]; +static Foo vLocation4; +static float vLocation9; + +struct VertexOut +{ + float3 color : TEXCOORD7; + float3 foo : TEXCOORD8; +}; + +static VertexOut vout; + +struct SPIRV_Cross_Input +{ + float4 Input0 : TEXCOORD0; + float4 Input2 : TEXCOORD2; + float4 Input4 : TEXCOORD4; +}; + +struct SPIRV_Cross_Output +{ + float vLocation0 : TEXCOORD0; + float vLocation1 : TEXCOORD1; + float vLocation2[2] : TEXCOORD2; + Foo vLocation4 : TEXCOORD4; + float vLocation9 : TEXCOORD9; + float4 gl_Position : SV_Position; +}; + +void vert_main() +{ + gl_Position = ((1.0f.xxxx + Input2) + Input4) + Input0; + vLocation0 = 0.0f; + vLocation1 = 1.0f; + vLocation2[0] = 2.0f; + vLocation2[1] = 2.0f; + Foo foo; + foo.a = 1.0f.xxx; + foo.b = 1.0f.xxx; + foo.c = 1.0f.xxx; + vLocation4 = foo; + vLocation9 = 9.0f; + vout.color = 2.0f.xxx; + vout.foo = 4.0f.xxx; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input, out VertexOut stage_outputvout) +{ + Input2 = stage_input.Input2; + Input4 = stage_input.Input4; + Input0 = stage_input.Input0; + vert_main(); + stage_outputvout = vout; + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + stage_output.vLocation0 = vLocation0; + stage_output.vLocation1 = vLocation1; + stage_output.vLocation2 = vLocation2; + stage_output.vLocation4 = vLocation4; + stage_output.vLocation9 = vLocation9; + return stage_output; +} diff --git a/reference/shaders-hlsl/vert/matrix-attribute.vert b/reference/shaders-hlsl/vert/matrix-attribute.vert new file mode 100644 index 0000000000..a3d0eef56e --- /dev/null +++ b/reference/shaders-hlsl/vert/matrix-attribute.vert @@ -0,0 +1,35 @@ +static float4 gl_Position; +static float4x4 m; +static float3 pos; + +struct SPIRV_Cross_Input +{ + float3 pos : TEXCOORD0; + float4 m_0 : TEXCOORD1_0; + float4 m_1 : TEXCOORD1_1; + float4 m_2 : TEXCOORD1_2; + float4 m_3 : TEXCOORD1_3; +}; + +struct SPIRV_Cross_Output +{ + float4 gl_Position : SV_Position; +}; + +void vert_main() +{ + gl_Position = mul(float4(pos, 1.0f), m); +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + m[0] = stage_input.m_0; + m[1] = stage_input.m_1; + m[2] = stage_input.m_2; + m[3] = stage_input.m_3; + pos = stage_input.pos; + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + return stage_output; +} diff --git a/reference/shaders-hlsl/vert/matrix-output.vert b/reference/shaders-hlsl/vert/matrix-output.vert new file mode 100644 index 0000000000..dc776cb5ec --- /dev/null +++ b/reference/shaders-hlsl/vert/matrix-output.vert @@ -0,0 +1,23 @@ +static float4 gl_Position; +static float4x4 m; + +struct SPIRV_Cross_Output +{ + float4x4 m : TEXCOORD0; + float4 gl_Position : SV_Position; +}; + +void vert_main() +{ + gl_Position = 1.0f.xxxx; + m = float4x4(float4(1.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 1.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 1.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 1.0f)); +} + +SPIRV_Cross_Output main() +{ + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + stage_output.m = m; + return stage_output; +} diff --git a/reference/shaders-hlsl/vert/no-input.vert b/reference/shaders-hlsl/vert/no-input.vert new file mode 100644 index 0000000000..c98544dbe8 --- /dev/null +++ b/reference/shaders-hlsl/vert/no-input.vert @@ -0,0 +1,18 @@ +static float4 gl_Position; +struct SPIRV_Cross_Output +{ + float4 gl_Position : SV_Position; +}; + +void vert_main() +{ + gl_Position = 1.0f.xxxx; +} + +SPIRV_Cross_Output main() +{ + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + return stage_output; +} diff --git a/reference/shaders-hlsl/vert/point-size-compat.vert b/reference/shaders-hlsl/vert/point-size-compat.vert new file mode 100644 index 0000000000..83333d0be2 --- /dev/null +++ b/reference/shaders-hlsl/vert/point-size-compat.vert @@ -0,0 +1,20 @@ +static float4 gl_Position; +static float gl_PointSize; +struct SPIRV_Cross_Output +{ + float4 gl_Position : SV_Position; +}; + +void vert_main() +{ + gl_Position = 1.0f.xxxx; + gl_PointSize = 10.0f; +} + +SPIRV_Cross_Output main() +{ + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + return stage_output; +} diff --git a/reference/shaders-hlsl/vert/qualifiers.vert b/reference/shaders-hlsl/vert/qualifiers.vert new file mode 100644 index 0000000000..13ee2a8c1c --- /dev/null +++ b/reference/shaders-hlsl/vert/qualifiers.vert @@ -0,0 +1,50 @@ +static float4 gl_Position; +static float vFlat; +static float vCentroid; +static float vSample; +static float vNoperspective; + +struct Block +{ + nointerpolation float vFlat : TEXCOORD4; + centroid float vCentroid : TEXCOORD5; + sample float vSample : TEXCOORD6; + noperspective float vNoperspective : TEXCOORD7; +}; + +static Block vout; + +struct SPIRV_Cross_Output +{ + nointerpolation float vFlat : TEXCOORD0; + centroid float vCentroid : TEXCOORD1; + sample float vSample : TEXCOORD2; + noperspective float vNoperspective : TEXCOORD3; + float4 gl_Position : SV_Position; +}; + +void vert_main() +{ + gl_Position = 1.0f.xxxx; + vFlat = 0.0f; + vCentroid = 1.0f; + vSample = 2.0f; + vNoperspective = 3.0f; + vout.vFlat = 0.0f; + vout.vCentroid = 1.0f; + vout.vSample = 2.0f; + vout.vNoperspective = 3.0f; +} + +SPIRV_Cross_Output main(out Block stage_outputvout) +{ + vert_main(); + stage_outputvout = vout; + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + stage_output.vFlat = vFlat; + stage_output.vCentroid = vCentroid; + stage_output.vSample = vSample; + stage_output.vNoperspective = vNoperspective; + return stage_output; +} diff --git a/reference/shaders-hlsl/vert/sampler-buffers.vert b/reference/shaders-hlsl/vert/sampler-buffers.vert new file mode 100644 index 0000000000..a4329dbf36 --- /dev/null +++ b/reference/shaders-hlsl/vert/sampler-buffers.vert @@ -0,0 +1,27 @@ +Buffer uFloatSampler : register(t1); +Buffer uIntSampler : register(t2); +Buffer uUintSampler : register(t3); + +static float4 gl_Position; +struct SPIRV_Cross_Output +{ + float4 gl_Position : SV_Position; +}; + +float4 sample_from_function(Buffer s0, Buffer s1, Buffer s2) +{ + return (s0.Load(20) + asfloat(s1.Load(40))) + asfloat(s2.Load(60)); +} + +void vert_main() +{ + gl_Position = sample_from_function(uFloatSampler, uIntSampler, uUintSampler); +} + +SPIRV_Cross_Output main() +{ + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + return stage_output; +} diff --git a/reference/shaders-hlsl/vert/struct-composite-decl.vert b/reference/shaders-hlsl/vert/struct-composite-decl.vert new file mode 100644 index 0000000000..5b2c5824fc --- /dev/null +++ b/reference/shaders-hlsl/vert/struct-composite-decl.vert @@ -0,0 +1,50 @@ +struct VOut +{ + float4 a; + float4 b; + float4 c; + float4 d; +}; + +static VOut vout; +static float4 a; +static float4 b; +static float4 c; +static float4 d; + +struct SPIRV_Cross_Input +{ + float4 a : TEXCOORD0; + float4 b : TEXCOORD1; + float4 c : TEXCOORD2; + float4 d : TEXCOORD3; +}; + +struct SPIRV_Cross_Output +{ + VOut vout : TEXCOORD0; +}; + +void emit_result(VOut v) +{ + vout = v; +} + +void vert_main() +{ + VOut _26 = { a, b, c, d }; + VOut param = _26; + emit_result(param); +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + a = stage_input.a; + b = stage_input.b; + c = stage_input.c; + d = stage_input.d; + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.vout = vout; + return stage_output; +} diff --git a/reference/shaders-hlsl/vert/texture_buffer.vert b/reference/shaders-hlsl/vert/texture_buffer.vert new file mode 100644 index 0000000000..1c92f6fe65 --- /dev/null +++ b/reference/shaders-hlsl/vert/texture_buffer.vert @@ -0,0 +1,21 @@ +Buffer uSamp : register(t4); +RWBuffer uSampo : register(u5); + +static float4 gl_Position; +struct SPIRV_Cross_Output +{ + float4 gl_Position : SV_Position; +}; + +void vert_main() +{ + gl_Position = uSamp.Load(10) + uSampo[100]; +} + +SPIRV_Cross_Output main() +{ + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + return stage_output; +} diff --git a/reference/shaders-msl-no-opt/vert/functions_nested.vert b/reference/shaders-msl-no-opt/vert/functions_nested.vert new file mode 100644 index 0000000000..aa66304682 --- /dev/null +++ b/reference/shaders-msl-no-opt/vert/functions_nested.vert @@ -0,0 +1,189 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct attr_desc +{ + int type; + int attribute_size; + int starting_offset; + int stride; + int swap_bytes; + int is_volatile; +}; + +struct VertexBuffer +{ + float4x4 scale_offset_mat; + uint vertex_base_index; + int4 input_attributes[16]; +}; + +struct VertexConstantsBuffer +{ + float4 vc[16]; +}; + +constant float4 _295 = {}; + +struct main0_out +{ + float4 tc0 [[user(locn0)]]; + float4 back_color [[user(locn10)]]; + float4 gl_Position [[position]]; +}; + +attr_desc fetch_desc(thread const int& location, constant VertexBuffer& v_227) +{ + int attribute_flags = v_227.input_attributes[location].w; + attr_desc result; + result.type = v_227.input_attributes[location].x; + result.attribute_size = v_227.input_attributes[location].y; + result.starting_offset = v_227.input_attributes[location].z; + result.stride = attribute_flags & 255; + result.swap_bytes = (attribute_flags >> 8) & 1; + result.is_volatile = (attribute_flags >> 9) & 1; + return result; +} + +uint get_bits(thread const uint4& v, thread const int& swap) +{ + if (swap != 0) + { + return ((v.w | (v.z << uint(8))) | (v.y << uint(16))) | (v.x << uint(24)); + } + return ((v.x | (v.y << uint(8))) | (v.z << uint(16))) | (v.w << uint(24)); +} + +float4 fetch_attr(thread const attr_desc& desc, thread const int& vertex_id, thread const texture2d input_stream) +{ + float4 result = float4(0.0, 0.0, 0.0, 1.0); + bool reverse_order = false; + int first_byte = (vertex_id * desc.stride) + desc.starting_offset; + for (int n = 0; n < 4; n++) + { + if (n == desc.attribute_size) + { + break; + } + uint4 tmp; + switch (desc.type) + { + case 0: + { + int _131 = first_byte; + first_byte = _131 + 1; + tmp.x = input_stream.read(uint2(_131, 0)).x; + int _138 = first_byte; + first_byte = _138 + 1; + tmp.y = input_stream.read(uint2(_138, 0)).x; + uint4 param = tmp; + int param_1 = desc.swap_bytes; + result[n] = float(get_bits(param, param_1)); + break; + } + case 1: + { + int _156 = first_byte; + first_byte = _156 + 1; + tmp.x = input_stream.read(uint2(_156, 0)).x; + int _163 = first_byte; + first_byte = _163 + 1; + tmp.y = input_stream.read(uint2(_163, 0)).x; + int _170 = first_byte; + first_byte = _170 + 1; + tmp.z = input_stream.read(uint2(_170, 0)).x; + int _177 = first_byte; + first_byte = _177 + 1; + tmp.w = input_stream.read(uint2(_177, 0)).x; + uint4 param_2 = tmp; + int param_3 = desc.swap_bytes; + result[n] = as_type(get_bits(param_2, param_3)); + break; + } + case 2: + { + int _195 = first_byte; + first_byte = _195 + 1; + result[n] = float(input_stream.read(uint2(_195, 0)).x); + reverse_order = desc.swap_bytes != 0; + break; + } + } + } + float4 _209; + if (reverse_order) + { + _209 = result.wzyx; + } + else + { + _209 = result; + } + return _209; +} + +float4 read_location(thread const int& location, constant VertexBuffer& v_227, thread uint& gl_VertexIndex, thread texture2d buff_in_2, thread texture2d buff_in_1) +{ + int param = location; + attr_desc desc = fetch_desc(param, v_227); + int vertex_id = gl_VertexIndex - int(v_227.vertex_base_index); + if (desc.is_volatile != 0) + { + attr_desc param_1 = desc; + int param_2 = vertex_id; + return fetch_attr(param_1, param_2, buff_in_2); + } + else + { + attr_desc param_3 = desc; + int param_4 = vertex_id; + return fetch_attr(param_3, param_4, buff_in_1); + } +} + +void vs_adjust(thread float4& dst_reg0, thread float4& dst_reg1, thread float4& dst_reg7, constant VertexBuffer& v_227, thread uint& gl_VertexIndex, thread texture2d buff_in_2, thread texture2d buff_in_1, constant VertexConstantsBuffer& v_309) +{ + int param = 3; + float4 in_diff_color = read_location(param, v_227, gl_VertexIndex, buff_in_2, buff_in_1); + int param_1 = 0; + float4 in_pos = read_location(param_1, v_227, gl_VertexIndex, buff_in_2, buff_in_1); + int param_2 = 8; + float4 in_tc0 = read_location(param_2, v_227, gl_VertexIndex, buff_in_2, buff_in_1); + dst_reg1 = in_diff_color * v_309.vc[13]; + float4 tmp0; + tmp0.x = float4(dot(float4(in_pos.xyz, 1.0), v_309.vc[4])).x; + tmp0.y = float4(dot(float4(in_pos.xyz, 1.0), v_309.vc[5])).y; + tmp0.z = float4(dot(float4(in_pos.xyz, 1.0), v_309.vc[6])).z; + float4 tmp1; + tmp1 = float4(in_tc0.xy.x, in_tc0.xy.y, tmp1.z, tmp1.w); + tmp1.z = v_309.vc[15].x; + dst_reg7.y = float4(dot(float4(tmp1.xyz, 1.0), v_309.vc[8])).y; + dst_reg7.x = float4(dot(float4(tmp1.xyz, 1.0), v_309.vc[7])).x; + dst_reg0.y = float4(dot(float4(tmp0.xyz, 1.0), v_309.vc[1])).y; + dst_reg0.x = float4(dot(float4(tmp0.xyz, 1.0), v_309.vc[0])).x; +} + +vertex main0_out main0(constant VertexBuffer& v_227 [[buffer(0)]], constant VertexConstantsBuffer& v_309 [[buffer(1)]], texture2d buff_in_2 [[texture(0)]], texture2d buff_in_1 [[texture(1)]], uint gl_VertexIndex [[vertex_id]]) +{ + main0_out out = {}; + float4 dst_reg0 = float4(0.0, 0.0, 0.0, 1.0); + float4 dst_reg1 = float4(0.0); + float4 dst_reg7 = float4(0.0); + float4 param = dst_reg0; + float4 param_1 = dst_reg1; + float4 param_2 = dst_reg7; + vs_adjust(param, param_1, param_2, v_227, gl_VertexIndex, buff_in_2, buff_in_1, v_309); + dst_reg0 = param; + dst_reg1 = param_1; + dst_reg7 = param_2; + out.gl_Position = dst_reg0; + out.back_color = dst_reg1; + out.tc0 = dst_reg7; + out.gl_Position *= v_227.scale_offset_mat; + return out; +} + diff --git a/reference/shaders-msl/asm/comp/bitcast_iadd.asm.comp b/reference/shaders-msl/asm/comp/bitcast_iadd.asm.comp new file mode 100644 index 0000000000..47ce85f8fc --- /dev/null +++ b/reference/shaders-msl/asm/comp/bitcast_iadd.asm.comp @@ -0,0 +1,29 @@ +#include +#include + +using namespace metal; + +struct _3 +{ + int4 _m0; + uint4 _m1; +}; + +struct _4 +{ + uint4 _m0; + int4 _m1; +}; + +kernel void main0(device _3& _5 [[buffer(0)]], device _4& _6 [[buffer(1)]]) +{ + _6._m0 = _5._m1 + uint4(_5._m0); + _6._m0 = uint4(_5._m0) + _5._m1; + _6._m0 = _5._m1 + _5._m1; + _6._m0 = uint4(_5._m0 + _5._m0); + _6._m1 = int4(_5._m1 + _5._m1); + _6._m1 = _5._m0 + _5._m0; + _6._m1 = int4(_5._m1) + _5._m0; + _6._m1 = _5._m0 + int4(_5._m1); +} + diff --git a/reference/shaders-msl/asm/comp/bitcast_sar.asm.comp b/reference/shaders-msl/asm/comp/bitcast_sar.asm.comp new file mode 100644 index 0000000000..20d6fe9e9d --- /dev/null +++ b/reference/shaders-msl/asm/comp/bitcast_sar.asm.comp @@ -0,0 +1,29 @@ +#include +#include + +using namespace metal; + +struct _3 +{ + int4 _m0; + uint4 _m1; +}; + +struct _4 +{ + uint4 _m0; + int4 _m1; +}; + +kernel void main0(device _3& _5 [[buffer(0)]], device _4& _6 [[buffer(1)]]) +{ + _6._m0 = uint4(int4(_5._m1) >> _5._m0); + _6._m0 = uint4(_5._m0 >> int4(_5._m1)); + _6._m0 = uint4(int4(_5._m1) >> int4(_5._m1)); + _6._m0 = uint4(_5._m0 >> _5._m0); + _6._m1 = int4(_5._m1) >> int4(_5._m1); + _6._m1 = _5._m0 >> _5._m0; + _6._m1 = int4(_5._m1) >> _5._m0; + _6._m1 = _5._m0 >> int4(_5._m1); +} + diff --git a/reference/shaders-msl/asm/comp/bitcast_sdiv.asm.comp b/reference/shaders-msl/asm/comp/bitcast_sdiv.asm.comp new file mode 100644 index 0000000000..f18b318bbb --- /dev/null +++ b/reference/shaders-msl/asm/comp/bitcast_sdiv.asm.comp @@ -0,0 +1,29 @@ +#include +#include + +using namespace metal; + +struct _3 +{ + int4 _m0; + uint4 _m1; +}; + +struct _4 +{ + uint4 _m0; + int4 _m1; +}; + +kernel void main0(device _3& _5 [[buffer(0)]], device _4& _6 [[buffer(1)]]) +{ + _6._m0 = uint4(int4(_5._m1) / _5._m0); + _6._m0 = uint4(_5._m0 / int4(_5._m1)); + _6._m0 = uint4(int4(_5._m1) / int4(_5._m1)); + _6._m0 = uint4(_5._m0 / _5._m0); + _6._m1 = int4(_5._m1) / int4(_5._m1); + _6._m1 = _5._m0 / _5._m0; + _6._m1 = int4(_5._m1) / _5._m0; + _6._m1 = _5._m0 / int4(_5._m1); +} + diff --git a/reference/shaders-msl/asm/comp/bitcast_slr.asm.comp b/reference/shaders-msl/asm/comp/bitcast_slr.asm.comp new file mode 100644 index 0000000000..9fd60bef26 --- /dev/null +++ b/reference/shaders-msl/asm/comp/bitcast_slr.asm.comp @@ -0,0 +1,29 @@ +#include +#include + +using namespace metal; + +struct _3 +{ + int4 _m0; + uint4 _m1; +}; + +struct _4 +{ + uint4 _m0; + int4 _m1; +}; + +kernel void main0(device _3& _5 [[buffer(0)]], device _4& _6 [[buffer(1)]]) +{ + _6._m0 = _5._m1 >> uint4(_5._m0); + _6._m0 = uint4(_5._m0) >> _5._m1; + _6._m0 = _5._m1 >> _5._m1; + _6._m0 = uint4(_5._m0) >> uint4(_5._m0); + _6._m1 = int4(_5._m1 >> _5._m1); + _6._m1 = int4(uint4(_5._m0) >> uint4(_5._m0)); + _6._m1 = int4(_5._m1 >> uint4(_5._m0)); + _6._m1 = int4(uint4(_5._m0) >> _5._m1); +} + diff --git a/reference/shaders-msl/asm/comp/multiple-entry.asm.comp b/reference/shaders-msl/asm/comp/multiple-entry.asm.comp new file mode 100644 index 0000000000..7652733268 --- /dev/null +++ b/reference/shaders-msl/asm/comp/multiple-entry.asm.comp @@ -0,0 +1,29 @@ +#include +#include + +using namespace metal; + +struct _6 +{ + int4 _m0; + uint4 _m1; +}; + +struct _7 +{ + uint4 _m0; + int4 _m1; +}; + +kernel void main0(device _6& _8 [[buffer(0)]], device _7& _9 [[buffer(1)]]) +{ + _9._m0 = _8._m1 + uint4(_8._m0); + _9._m0 = uint4(_8._m0) + _8._m1; + _9._m0 = _8._m1 + _8._m1; + _9._m0 = uint4(_8._m0 + _8._m0); + _9._m1 = int4(_8._m1 + _8._m1); + _9._m1 = _8._m0 + _8._m0; + _9._m1 = int4(_8._m1) + _8._m0; + _9._m1 = _8._m0 + int4(_8._m1); +} + diff --git a/reference/shaders-msl/asm/comp/quantize.asm.comp b/reference/shaders-msl/asm/comp/quantize.asm.comp new file mode 100644 index 0000000000..1839ec7a3b --- /dev/null +++ b/reference/shaders-msl/asm/comp/quantize.asm.comp @@ -0,0 +1,21 @@ +#include +#include + +using namespace metal; + +struct SSBO0 +{ + float scalar; + float2 vec2_val; + float3 vec3_val; + float4 vec4_val; +}; + +kernel void main0(device SSBO0& _4 [[buffer(0)]]) +{ + _4.scalar = float(half(_4.scalar)); + _4.vec2_val = float2(half2(_4.vec2_val)); + _4.vec3_val = float3(half3(_4.vec3_val)); + _4.vec4_val = float4(half4(_4.vec4_val)); +} + diff --git a/reference/shaders-msl/asm/comp/specialization-constant-workgroup.asm.comp b/reference/shaders-msl/asm/comp/specialization-constant-workgroup.asm.comp new file mode 100644 index 0000000000..5802ddac90 --- /dev/null +++ b/reference/shaders-msl/asm/comp/specialization-constant-workgroup.asm.comp @@ -0,0 +1,21 @@ +#include +#include + +using namespace metal; + +constant uint _5_tmp [[function_constant(10)]]; +constant uint _5 = is_function_constant_defined(_5_tmp) ? _5_tmp : 9u; +constant uint _6_tmp [[function_constant(12)]]; +constant uint _6 = is_function_constant_defined(_6_tmp) ? _6_tmp : 4u; +constant uint3 gl_WorkGroupSize = uint3(_5, 20u, _6); + +struct SSBO +{ + float a; +}; + +kernel void main0(device SSBO& _4 [[buffer(0)]]) +{ + _4.a += 1.0; +} + diff --git a/reference/shaders-msl/asm/comp/storage-buffer-basic.asm.comp b/reference/shaders-msl/asm/comp/storage-buffer-basic.asm.comp new file mode 100644 index 0000000000..9e37362dbd --- /dev/null +++ b/reference/shaders-msl/asm/comp/storage-buffer-basic.asm.comp @@ -0,0 +1,22 @@ +#include +#include + +using namespace metal; + +constant uint _3_tmp [[function_constant(0)]]; +constant uint _3 = is_function_constant_defined(_3_tmp) ? _3_tmp : 1u; +constant uint _4_tmp [[function_constant(2)]]; +constant uint _4 = is_function_constant_defined(_4_tmp) ? _4_tmp : 3u; +constant uint3 gl_WorkGroupSize = uint3(_3, 2u, _4); + +struct _6 +{ + float _m0[1]; +}; + +kernel void main0(device _6& _8 [[buffer(0)]], device _6& _9 [[buffer(1)]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]]) +{ + uint3 _23 = gl_WorkGroupSize; + _8._m0[gl_WorkGroupID.x] = _9._m0[gl_WorkGroupID.x] + _8._m0[gl_WorkGroupID.x]; +} + diff --git a/reference/shaders-msl/asm/frag/default-member-names.asm.frag b/reference/shaders-msl/asm/frag/default-member-names.asm.frag new file mode 100644 index 0000000000..3628c4eaae --- /dev/null +++ b/reference/shaders-msl/asm/frag/default-member-names.asm.frag @@ -0,0 +1,40 @@ +#include +#include + +using namespace metal; + +struct _9 +{ + float _m0; +}; + +struct _10 +{ + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + _9 _m12; +}; + +struct main0_out +{ + float4 m_3 [[color(0)]]; +}; + +fragment main0_out main0() +{ + main0_out out = {}; + _10 _21; + out.m_3 = float4(_21._m0, _21._m1, _21._m2, _21._m3); + return out; +} + diff --git a/reference/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag b/reference/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag new file mode 100644 index 0000000000..2ac8cbe015 --- /dev/null +++ b/reference/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag @@ -0,0 +1,235 @@ +#include +#include + +using namespace metal; + +struct VertexOutput +{ + float4 HPosition; + float4 Uv_EdgeDistance1; + float4 UvStuds_EdgeDistance2; + float4 Color; + float4 LightPosition_Fog; + float4 View_Depth; + float4 Normal_SpecPower; + float3 Tangent; + float4 PosLightSpace_Reflectance; + float studIndex; +}; + +struct Surface +{ + float3 albedo; + float3 normal; + float specular; + float gloss; + float reflectance; + float opacity; +}; + +struct SurfaceInput +{ + float4 Color; + float2 Uv; + float2 UvStuds; +}; + +struct Globals +{ + float4x4 ViewProjection; + float4 ViewRight; + float4 ViewUp; + float4 ViewDir; + float3 CameraPosition; + float3 AmbientColor; + float3 Lamp0Color; + float3 Lamp0Dir; + float3 Lamp1Color; + float4 FogParams; + float3 FogColor; + float4 LightBorder; + float4 LightConfig0; + float4 LightConfig1; + float4 LightConfig2; + float4 LightConfig3; + float4 RefractionBias_FadeDistance_GlowFactor; + float4 OutlineBrightness_ShadowInfo; + float4 ShadowMatrix0; + float4 ShadowMatrix1; + float4 ShadowMatrix2; +}; + +struct Params +{ + float4 LqmatFarTilingFactor; +}; + +struct CB0 +{ + Globals CB0; +}; + +struct CB2 +{ + Params CB2; +}; + +constant VertexOutput _121 = {}; +constant SurfaceInput _122 = {}; +constant float2 _123 = {}; +constant float4 _124 = {}; +constant Surface _125 = {}; +constant float4 _192 = {}; +constant float4 _219 = {}; +constant float4 _297 = {}; + +struct main0_in +{ + float IN_studIndex [[user(locn8)]]; + float4 IN_PosLightSpace_Reflectance [[user(locn7)]]; + float3 IN_Tangent [[user(locn6)]]; + float4 IN_Normal_SpecPower [[user(locn5)]]; + float4 IN_View_Depth [[user(locn4)]]; + float4 IN_LightPosition_Fog [[user(locn3)]]; + float4 IN_Color [[user(locn2)]]; + float4 IN_UvStuds_EdgeDistance2 [[user(locn1)]]; + float4 IN_Uv_EdgeDistance1 [[user(locn0)]]; +}; + +struct main0_out +{ + float4 _entryPointOutput [[color(0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], constant CB0& _19 [[buffer(0)]], texture3d LightMapTexture [[texture(0)]], texture2d ShadowMapTexture [[texture(1)]], texturecube EnvironmentMapTexture [[texture(2)]], texture2d DiffuseMapTexture [[texture(3)]], texture2d NormalMapTexture [[texture(4)]], texture2d NormalDetailMapTexture [[texture(5)]], texture2d StudsMapTexture [[texture(6)]], texture2d SpecularMapTexture [[texture(7)]], sampler LightMapSampler [[sampler(0)]], sampler ShadowMapSampler [[sampler(1)]], sampler EnvironmentMapSampler [[sampler(2)]], sampler DiffuseMapSampler [[sampler(3)]], sampler NormalMapSampler [[sampler(4)]], sampler NormalDetailMapSampler [[sampler(5)]], sampler StudsMapSampler [[sampler(6)]], sampler SpecularMapSampler [[sampler(7)]], float4 gl_FragCoord [[position]]) +{ + main0_out out = {}; + VertexOutput _128 = _121; + _128.HPosition = gl_FragCoord; + VertexOutput _130 = _128; + _130.Uv_EdgeDistance1 = in.IN_Uv_EdgeDistance1; + VertexOutput _132 = _130; + _132.UvStuds_EdgeDistance2 = in.IN_UvStuds_EdgeDistance2; + VertexOutput _134 = _132; + _134.Color = in.IN_Color; + VertexOutput _136 = _134; + _136.LightPosition_Fog = in.IN_LightPosition_Fog; + VertexOutput _138 = _136; + _138.View_Depth = in.IN_View_Depth; + VertexOutput _140 = _138; + _140.Normal_SpecPower = in.IN_Normal_SpecPower; + VertexOutput _142 = _140; + _142.Tangent = in.IN_Tangent; + VertexOutput _144 = _142; + _144.PosLightSpace_Reflectance = in.IN_PosLightSpace_Reflectance; + VertexOutput _146 = _144; + _146.studIndex = in.IN_studIndex; + SurfaceInput _147 = _122; + _147.Color = in.IN_Color; + SurfaceInput _149 = _147; + _149.Uv = in.IN_Uv_EdgeDistance1.xy; + SurfaceInput _151 = _149; + _151.UvStuds = in.IN_UvStuds_EdgeDistance2.xy; + SurfaceInput _156 = _151; + _156.UvStuds.y = (fract(_151.UvStuds.y) + in.IN_studIndex) * 0.25; + float _163 = _146.View_Depth.w * _19.CB0.RefractionBias_FadeDistance_GlowFactor.y; + float _165 = clamp(1.0 - _163, 0.0, 1.0); + float2 _166 = in.IN_Uv_EdgeDistance1.xy * 1.0; + bool _173; + float4 _193; + do + { + _173 = 0.0 == 0.0; + if (_173) + { + _193 = DiffuseMapTexture.sample(DiffuseMapSampler, _166); + break; + } + else + { + float _180 = 1.0 / (1.0 - 0.0); + _193 = mix(DiffuseMapTexture.sample(DiffuseMapSampler, (_166 * 0.25)), DiffuseMapTexture.sample(DiffuseMapSampler, _166), float4(clamp((clamp(1.0 - (_146.View_Depth.w * 0.00333332992158830165863037109375), 0.0, 1.0) * _180) - (0.0 * _180), 0.0, 1.0))); + break; + } + _193 = _192; + break; + } while (false); + float4 _220; + do + { + if (_173) + { + _220 = NormalMapTexture.sample(NormalMapSampler, _166); + break; + } + else + { + float _207 = 1.0 / (1.0 - 0.0); + _220 = mix(NormalMapTexture.sample(NormalMapSampler, (_166 * 0.25)), NormalMapTexture.sample(NormalMapSampler, _166), float4(clamp((_165 * _207) - (0.0 * _207), 0.0, 1.0))); + break; + } + _220 = _219; + break; + } while (false); + float2 _223 = float2(1.0); + float2 _224 = (_220.wy * 2.0) - _223; + float3 _232 = float3(_224, sqrt(clamp(1.0 + dot(-_224, _224), 0.0, 1.0))); + float2 _240 = (NormalDetailMapTexture.sample(NormalDetailMapSampler, (_166 * 0.0)).wy * 2.0) - _223; + float2 _252 = _232.xy + (float3(_240, sqrt(clamp(1.0 + dot(-_240, _240), 0.0, 1.0))).xy * 0.0); + float3 _253 = float3(_252.x, _252.y, _232.z); + float2 _255 = _253.xy * _165; + float3 _256 = float3(_255.x, _255.y, _253.z); + float3 _271 = ((in.IN_Color.xyz * (_193 * 1.0).xyz) * (1.0 + (_256.x * 0.300000011920928955078125))) * (StudsMapTexture.sample(StudsMapSampler, _156.UvStuds).x * 2.0); + float4 _298; + do + { + if (0.75 == 0.0) + { + _298 = SpecularMapTexture.sample(SpecularMapSampler, _166); + break; + } + else + { + float _285 = 1.0 / (1.0 - 0.75); + _298 = mix(SpecularMapTexture.sample(SpecularMapSampler, (_166 * 0.25)), SpecularMapTexture.sample(SpecularMapSampler, _166), float4(clamp((_165 * _285) - (0.75 * _285), 0.0, 1.0))); + break; + } + _298 = _297; + break; + } while (false); + float2 _303 = mix(float2(0.800000011920928955078125, 120.0), (_298.xy * float2(2.0, 256.0)) + float2(0.0, 0.00999999977648258209228515625), float2(_165)); + Surface _304 = _125; + _304.albedo = _271; + Surface _305 = _304; + _305.normal = _256; + float _306 = _303.x; + Surface _307 = _305; + _307.specular = _306; + float _308 = _303.y; + Surface _309 = _307; + _309.gloss = _308; + float _312 = (_298.xy.y * _165) * 0.0; + Surface _313 = _309; + _313.reflectance = _312; + float4 _318 = float4(_271, _146.Color.w); + float3 _329 = normalize(((in.IN_Tangent * _313.normal.x) + (cross(in.IN_Normal_SpecPower.xyz, in.IN_Tangent) * _313.normal.y)) + (in.IN_Normal_SpecPower.xyz * _313.normal.z)); + float3 _332 = -_19.CB0.Lamp0Dir; + float _333 = dot(_329, _332); + float _357 = clamp(dot(step(_19.CB0.LightConfig3.xyz, abs(in.IN_LightPosition_Fog.xyz - _19.CB0.LightConfig2.xyz)), float3(1.0)), 0.0, 1.0); + float4 _368 = mix(LightMapTexture.sample(LightMapSampler, (in.IN_LightPosition_Fog.xyz.yzx - (in.IN_LightPosition_Fog.xyz.yzx * _357))), _19.CB0.LightBorder, float4(_357)); + float2 _376 = ShadowMapTexture.sample(ShadowMapSampler, in.IN_PosLightSpace_Reflectance.xyz.xy).xy; + float _392 = (1.0 - (((step(_376.x, in.IN_PosLightSpace_Reflectance.xyz.z) * clamp(9.0 - (20.0 * abs(in.IN_PosLightSpace_Reflectance.xyz.z - 0.5)), 0.0, 1.0)) * _376.y) * _19.CB0.OutlineBrightness_ShadowInfo.w)) * _368.w; + float3 _403 = mix(_318.xyz, EnvironmentMapTexture.sample(EnvironmentMapSampler, reflect(-in.IN_View_Depth.xyz, _329)).xyz, float3(_312)); + float4 _404 = float4(_403.x, _403.y, _403.z, _318.w); + float3 _422 = (((_19.CB0.AmbientColor + (((_19.CB0.Lamp0Color * clamp(_333, 0.0, 1.0)) + (_19.CB0.Lamp1Color * max(-_333, 0.0))) * _392)) + _368.xyz) * _404.xyz) + (_19.CB0.Lamp0Color * (((step(0.0, _333) * _306) * _392) * pow(clamp(dot(_329, normalize(_332 + normalize(in.IN_View_Depth.xyz))), 0.0, 1.0), _308))); + float4 _425 = float4(_422.x, _422.y, _422.z, _124.w); + _425.w = _404.w; + float2 _435 = min(in.IN_Uv_EdgeDistance1.wz, in.IN_UvStuds_EdgeDistance2.wz); + float _439 = min(_435.x, _435.y) / _163; + float3 _445 = _425.xyz * clamp((clamp((_163 * _19.CB0.OutlineBrightness_ShadowInfo.x) + _19.CB0.OutlineBrightness_ShadowInfo.y, 0.0, 1.0) * (1.5 - _439)) + _439, 0.0, 1.0); + float4 _446 = float4(_445.x, _445.y, _445.z, _425.w); + float3 _453 = mix(_19.CB0.FogColor, _446.xyz, float3(clamp(_146.LightPosition_Fog.w, 0.0, 1.0))); + out._entryPointOutput = float4(_453.x, _453.y, _453.z, _446.w); + return out; +} + diff --git a/reference/shaders-msl/asm/frag/op-constant-null.asm.frag b/reference/shaders-msl/asm/frag/op-constant-null.asm.frag new file mode 100644 index 0000000000..588e7d1572 --- /dev/null +++ b/reference/shaders-msl/asm/frag/op-constant-null.asm.frag @@ -0,0 +1,28 @@ +#include +#include + +using namespace metal; + +struct D +{ + float4 a; + float b; +}; + +struct main0_out +{ + float FragColor [[color(0)]]; +}; + +fragment main0_out main0() +{ + main0_out out = {}; + float a = 0.0; + float4 b = float4(0.0); + float2x3 c = float2x3(float3(0.0), float3(0.0)); + D d = {float4(0.0), 0.0}; + float4 e[4] = {float4(0.0), float4(0.0), float4(0.0), float4(0.0)}; + out.FragColor = a; + return out; +} + diff --git a/reference/shaders-msl/asm/frag/phi-loop-variable.asm.frag b/reference/shaders-msl/asm/frag/phi-loop-variable.asm.frag new file mode 100644 index 0000000000..036774d661 --- /dev/null +++ b/reference/shaders-msl/asm/frag/phi-loop-variable.asm.frag @@ -0,0 +1,12 @@ +#include +#include + +using namespace metal; + +fragment void main0() +{ + for (int _22 = 35; _22 >= 0; _22--) + { + } +} + diff --git a/reference/shaders-msl/asm/frag/undef-variable-store.asm.frag b/reference/shaders-msl/asm/frag/undef-variable-store.asm.frag new file mode 100644 index 0000000000..2cefeb6693 --- /dev/null +++ b/reference/shaders-msl/asm/frag/undef-variable-store.asm.frag @@ -0,0 +1,37 @@ +#include +#include + +using namespace metal; + +constant float4 _38 = {}; +constant float4 _47 = {}; + +struct main0_out +{ + float4 _entryPointOutput [[color(0)]]; +}; + +fragment main0_out main0() +{ + main0_out out = {}; + float4 _27; + do + { + float2 _26 = float2(0.0); + if (_26.x != 0.0) + { + _27 = float4(1.0, 0.0, 0.0, 1.0); + break; + } + else + { + _27 = float4(1.0, 1.0, 0.0, 1.0); + break; + } + _27 = _38; + break; + } while (false); + out._entryPointOutput = _27; + return out; +} + diff --git a/reference/shaders-msl/asm/frag/unreachable.asm.frag b/reference/shaders-msl/asm/frag/unreachable.asm.frag new file mode 100644 index 0000000000..7a98487221 --- /dev/null +++ b/reference/shaders-msl/asm/frag/unreachable.asm.frag @@ -0,0 +1,40 @@ +#include +#include + +using namespace metal; + +constant float4 _21 = {}; + +struct main0_in +{ + int counter [[user(locn0)]]; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + float4 _24; + _24 = _21; + float4 _33; + for (;;) + { + if (in.counter == 10) + { + _33 = float4(10.0); + break; + } + else + { + _33 = float4(30.0); + break; + } + } + out.FragColor = _33; + return out; +} + diff --git a/reference/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag b/reference/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag new file mode 100644 index 0000000000..97daea5d90 --- /dev/null +++ b/reference/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag @@ -0,0 +1,321 @@ +#include +#include + +using namespace metal; + +struct _28 +{ + float4 _m0; +}; + +struct _6 +{ + float4 _m0; + float _m1; + float4 _m2; +}; + +struct _10 +{ + float3 _m0; + packed_float3 _m1; + float _m2; + packed_float3 _m3; + float _m4; + packed_float3 _m5; + float _m6; + packed_float3 _m7; + float _m8; + packed_float3 _m9; + float _m10; + packed_float3 _m11; + float _m12; + float2 _m13; + float2 _m14; + packed_float3 _m15; + float _m16; + float _m17; + float _m18; + float _m19; + float _m20; + float4 _m21; + float4 _m22; + float4x4 _m23; + float4 _m24; +}; + +struct _18 +{ + float4x4 _m0; + float4x4 _m1; + float4x4 _m2; + float4x4 _m3; + float4 _m4; + float4 _m5; + float _m6; + float _m7; + float _m8; + float _m9; + packed_float3 _m10; + float _m11; + packed_float3 _m12; + float _m13; + packed_float3 _m14; + float _m15; + packed_float3 _m16; + float _m17; + float _m18; + float _m19; + float2 _m20; + float2 _m21; + float2 _m22; + float4 _m23; + float2 _m24; + float2 _m25; + float2 _m26; + char pad27[8]; + packed_float3 _m27; + float _m28; + float _m29; + float _m30; + float _m31; + float _m32; + float2 _m33; + float _m34; + float _m35; + float3 _m36; + float4x4 _m37[2]; + float4 _m38[2]; +}; + +constant _28 _74 = {}; + +struct main0_out +{ + float4 m_5 [[color(0)]]; +}; + +fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buffer(1)]], constant _18& _19 [[buffer(2)]], texture2d _8 [[texture(0)]], texture2d _12 [[texture(1)]], texture2d _14 [[texture(2)]], sampler _9 [[sampler(0)]], sampler _13 [[sampler(1)]], sampler _15 [[sampler(2)]], float4 gl_FragCoord [[position]]) +{ + main0_out out = {}; + _28 _77 = _74; + _77._m0 = float4(0.0); + float2 _82 = gl_FragCoord.xy * _19._m23.xy; + float4 _88 = _7._m2 * _7._m0.xyxy; + float2 _97 = clamp(_82 + (float3(0.0, -2.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); + float3 _109 = _11._m5 * clamp(_8.sample(_9, _97, level(0.0)).w * _7._m1, 0.0, 1.0); + float4 _113 = _12.sample(_13, _97, level(0.0)); + float3 _129; + if (_113.y > 0.0) + { + _129 = _109 + (_14.sample(_15, _97, level(0.0)).xyz * clamp(_113.y * _113.z, 0.0, 1.0)); + } + else + { + _129 = _109; + } + float3 _133 = float4(0.0).xyz + (_129 * 0.5); + float4 _134 = float4(_133.x, _133.y, _133.z, float4(0.0).w); + _28 _135 = _77; + _135._m0 = _134; + float2 _144 = clamp(_82 + (float3(-1.0, -1.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); + float3 _156 = _11._m5 * clamp(_8.sample(_9, _144, level(0.0)).w * _7._m1, 0.0, 1.0); + float4 _160 = _12.sample(_13, _144, level(0.0)); + float3 _176; + if (_160.y > 0.0) + { + _176 = _156 + (_14.sample(_15, _144, level(0.0)).xyz * clamp(_160.y * _160.z, 0.0, 1.0)); + } + else + { + _176 = _156; + } + float3 _180 = _134.xyz + (_176 * 0.5); + float4 _181 = float4(_180.x, _180.y, _180.z, _134.w); + _28 _182 = _135; + _182._m0 = _181; + float2 _191 = clamp(_82 + (float3(0.0, -1.0, 0.75).xy * _7._m0.xy), _88.xy, _88.zw); + float3 _203 = _11._m5 * clamp(_8.sample(_9, _191, level(0.0)).w * _7._m1, 0.0, 1.0); + float4 _207 = _12.sample(_13, _191, level(0.0)); + float3 _223; + if (_207.y > 0.0) + { + _223 = _203 + (_14.sample(_15, _191, level(0.0)).xyz * clamp(_207.y * _207.z, 0.0, 1.0)); + } + else + { + _223 = _203; + } + float3 _227 = _181.xyz + (_223 * 0.75); + float4 _228 = float4(_227.x, _227.y, _227.z, _181.w); + _28 _229 = _182; + _229._m0 = _228; + float2 _238 = clamp(_82 + (float3(1.0, -1.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); + float3 _250 = _11._m5 * clamp(_8.sample(_9, _238, level(0.0)).w * _7._m1, 0.0, 1.0); + float4 _254 = _12.sample(_13, _238, level(0.0)); + float3 _270; + if (_254.y > 0.0) + { + _270 = _250 + (_14.sample(_15, _238, level(0.0)).xyz * clamp(_254.y * _254.z, 0.0, 1.0)); + } + else + { + _270 = _250; + } + float3 _274 = _228.xyz + (_270 * 0.5); + float4 _275 = float4(_274.x, _274.y, _274.z, _228.w); + _28 _276 = _229; + _276._m0 = _275; + float2 _285 = clamp(_82 + (float3(-2.0, 0.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); + float3 _297 = _11._m5 * clamp(_8.sample(_9, _285, level(0.0)).w * _7._m1, 0.0, 1.0); + float4 _301 = _12.sample(_13, _285, level(0.0)); + float3 _317; + if (_301.y > 0.0) + { + _317 = _297 + (_14.sample(_15, _285, level(0.0)).xyz * clamp(_301.y * _301.z, 0.0, 1.0)); + } + else + { + _317 = _297; + } + float3 _321 = _275.xyz + (_317 * 0.5); + float4 _322 = float4(_321.x, _321.y, _321.z, _275.w); + _28 _323 = _276; + _323._m0 = _322; + float2 _332 = clamp(_82 + (float3(-1.0, 0.0, 0.75).xy * _7._m0.xy), _88.xy, _88.zw); + float3 _344 = _11._m5 * clamp(_8.sample(_9, _332, level(0.0)).w * _7._m1, 0.0, 1.0); + float4 _348 = _12.sample(_13, _332, level(0.0)); + float3 _364; + if (_348.y > 0.0) + { + _364 = _344 + (_14.sample(_15, _332, level(0.0)).xyz * clamp(_348.y * _348.z, 0.0, 1.0)); + } + else + { + _364 = _344; + } + float3 _368 = _322.xyz + (_364 * 0.75); + float4 _369 = float4(_368.x, _368.y, _368.z, _322.w); + _28 _370 = _323; + _370._m0 = _369; + float2 _379 = clamp(_82 + (float3(0.0, 0.0, 1.0).xy * _7._m0.xy), _88.xy, _88.zw); + float3 _391 = _11._m5 * clamp(_8.sample(_9, _379, level(0.0)).w * _7._m1, 0.0, 1.0); + float4 _395 = _12.sample(_13, _379, level(0.0)); + float3 _411; + if (_395.y > 0.0) + { + _411 = _391 + (_14.sample(_15, _379, level(0.0)).xyz * clamp(_395.y * _395.z, 0.0, 1.0)); + } + else + { + _411 = _391; + } + float3 _415 = _369.xyz + (_411 * 1.0); + float4 _416 = float4(_415.x, _415.y, _415.z, _369.w); + _28 _417 = _370; + _417._m0 = _416; + float2 _426 = clamp(_82 + (float3(1.0, 0.0, 0.75).xy * _7._m0.xy), _88.xy, _88.zw); + float3 _438 = _11._m5 * clamp(_8.sample(_9, _426, level(0.0)).w * _7._m1, 0.0, 1.0); + float4 _442 = _12.sample(_13, _426, level(0.0)); + float3 _458; + if (_442.y > 0.0) + { + _458 = _438 + (_14.sample(_15, _426, level(0.0)).xyz * clamp(_442.y * _442.z, 0.0, 1.0)); + } + else + { + _458 = _438; + } + float3 _462 = _416.xyz + (_458 * 0.75); + float4 _463 = float4(_462.x, _462.y, _462.z, _416.w); + _28 _464 = _417; + _464._m0 = _463; + float2 _473 = clamp(_82 + (float3(2.0, 0.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); + float3 _485 = _11._m5 * clamp(_8.sample(_9, _473, level(0.0)).w * _7._m1, 0.0, 1.0); + float4 _489 = _12.sample(_13, _473, level(0.0)); + float3 _505; + if (_489.y > 0.0) + { + _505 = _485 + (_14.sample(_15, _473, level(0.0)).xyz * clamp(_489.y * _489.z, 0.0, 1.0)); + } + else + { + _505 = _485; + } + float3 _509 = _463.xyz + (_505 * 0.5); + float4 _510 = float4(_509.x, _509.y, _509.z, _463.w); + _28 _511 = _464; + _511._m0 = _510; + float2 _520 = clamp(_82 + (float3(-1.0, 1.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); + float3 _532 = _11._m5 * clamp(_8.sample(_9, _520, level(0.0)).w * _7._m1, 0.0, 1.0); + float4 _536 = _12.sample(_13, _520, level(0.0)); + float3 _552; + if (_536.y > 0.0) + { + _552 = _532 + (_14.sample(_15, _520, level(0.0)).xyz * clamp(_536.y * _536.z, 0.0, 1.0)); + } + else + { + _552 = _532; + } + float3 _556 = _510.xyz + (_552 * 0.5); + float4 _557 = float4(_556.x, _556.y, _556.z, _510.w); + _28 _558 = _511; + _558._m0 = _557; + float2 _567 = clamp(_82 + (float3(0.0, 1.0, 0.75).xy * _7._m0.xy), _88.xy, _88.zw); + float3 _579 = _11._m5 * clamp(_8.sample(_9, _567, level(0.0)).w * _7._m1, 0.0, 1.0); + float4 _583 = _12.sample(_13, _567, level(0.0)); + float3 _599; + if (_583.y > 0.0) + { + _599 = _579 + (_14.sample(_15, _567, level(0.0)).xyz * clamp(_583.y * _583.z, 0.0, 1.0)); + } + else + { + _599 = _579; + } + float3 _603 = _557.xyz + (_599 * 0.75); + float4 _604 = float4(_603.x, _603.y, _603.z, _557.w); + _28 _605 = _558; + _605._m0 = _604; + float2 _614 = clamp(_82 + (float3(1.0, 1.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); + float3 _626 = _11._m5 * clamp(_8.sample(_9, _614, level(0.0)).w * _7._m1, 0.0, 1.0); + float4 _630 = _12.sample(_13, _614, level(0.0)); + float3 _646; + if (_630.y > 0.0) + { + _646 = _626 + (_14.sample(_15, _614, level(0.0)).xyz * clamp(_630.y * _630.z, 0.0, 1.0)); + } + else + { + _646 = _626; + } + float3 _650 = _604.xyz + (_646 * 0.5); + float4 _651 = float4(_650.x, _650.y, _650.z, _604.w); + _28 _652 = _605; + _652._m0 = _651; + float2 _661 = clamp(_82 + (float3(0.0, 2.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); + float3 _673 = _11._m5 * clamp(_8.sample(_9, _661, level(0.0)).w * _7._m1, 0.0, 1.0); + float4 _677 = _12.sample(_13, _661, level(0.0)); + float3 _693; + if (_677.y > 0.0) + { + _693 = _673 + (_14.sample(_15, _661, level(0.0)).xyz * clamp(_677.y * _677.z, 0.0, 1.0)); + } + else + { + _693 = _673; + } + float3 _697 = _651.xyz + (_693 * 0.5); + float4 _698 = float4(_697.x, _697.y, _697.z, _651.w); + _28 _699 = _652; + _699._m0 = _698; + float3 _702 = _698.xyz / float3(((((((((((((0.0 + 0.5) + 0.5) + 0.75) + 0.5) + 0.5) + 0.75) + 1.0) + 0.75) + 0.5) + 0.5) + 0.75) + 0.5) + 0.5); + _28 _704 = _699; + _704._m0 = float4(_702.x, _702.y, _702.z, _698.w); + _28 _705 = _704; + _705._m0.w = 1.0; + out.m_5 = _705._m0; + return out; +} + diff --git a/reference/shaders-msl/asm/vert/empty-struct-composite.asm.vert b/reference/shaders-msl/asm/vert/empty-struct-composite.asm.vert new file mode 100644 index 0000000000..9e024c2095 --- /dev/null +++ b/reference/shaders-msl/asm/vert/empty-struct-composite.asm.vert @@ -0,0 +1,9 @@ +#include +#include + +using namespace metal; + +vertex void main0() +{ +} + diff --git a/reference/shaders-msl/comp/atomic.comp b/reference/shaders-msl/comp/atomic.comp new file mode 100644 index 0000000000..90a39ec643 --- /dev/null +++ b/reference/shaders-msl/comp/atomic.comp @@ -0,0 +1,36 @@ +#pragma clang diagnostic ignored "-Wunused-variable" + +#include +#include +#include + +using namespace metal; + +struct SSBO +{ + uint u32; + int i32; +}; + +kernel void main0(device SSBO& ssbo [[buffer(0)]]) +{ + uint _16 = atomic_fetch_add_explicit((volatile device atomic_uint*)&(ssbo.u32), 1u, memory_order_relaxed); + uint _18 = atomic_fetch_or_explicit((volatile device atomic_uint*)&(ssbo.u32), 1u, memory_order_relaxed); + uint _20 = atomic_fetch_xor_explicit((volatile device atomic_uint*)&(ssbo.u32), 1u, memory_order_relaxed); + uint _22 = atomic_fetch_and_explicit((volatile device atomic_uint*)&(ssbo.u32), 1u, memory_order_relaxed); + uint _24 = atomic_fetch_min_explicit((volatile device atomic_uint*)&(ssbo.u32), 1u, memory_order_relaxed); + uint _26 = atomic_fetch_max_explicit((volatile device atomic_uint*)&(ssbo.u32), 1u, memory_order_relaxed); + uint _28 = atomic_exchange_explicit((volatile device atomic_uint*)&(ssbo.u32), 1u, memory_order_relaxed); + uint _30 = 10u; + uint _32 = atomic_compare_exchange_weak_explicit((volatile device atomic_uint*)&(ssbo.u32), &(_30), 2u, memory_order_relaxed, memory_order_relaxed); + int _36 = atomic_fetch_add_explicit((volatile device atomic_int*)&(ssbo.i32), 1, memory_order_relaxed); + int _38 = atomic_fetch_or_explicit((volatile device atomic_int*)&(ssbo.i32), 1, memory_order_relaxed); + int _40 = atomic_fetch_xor_explicit((volatile device atomic_int*)&(ssbo.i32), 1, memory_order_relaxed); + int _42 = atomic_fetch_and_explicit((volatile device atomic_int*)&(ssbo.i32), 1, memory_order_relaxed); + int _44 = atomic_fetch_min_explicit((volatile device atomic_int*)&(ssbo.i32), 1, memory_order_relaxed); + int _46 = atomic_fetch_max_explicit((volatile device atomic_int*)&(ssbo.i32), 1, memory_order_relaxed); + int _48 = atomic_exchange_explicit((volatile device atomic_int*)&(ssbo.i32), 1, memory_order_relaxed); + int _50 = 10; + int _52 = atomic_compare_exchange_weak_explicit((volatile device atomic_int*)&(ssbo.i32), &(_50), 2, memory_order_relaxed, memory_order_relaxed); +} + diff --git a/reference/shaders-msl/comp/bake_gradient.comp b/reference/shaders-msl/comp/bake_gradient.comp new file mode 100644 index 0000000000..1118f18f8e --- /dev/null +++ b/reference/shaders-msl/comp/bake_gradient.comp @@ -0,0 +1,40 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +constant uint3 gl_WorkGroupSize = uint3(8u, 8u, 1u); + +struct UBO +{ + float4 uInvSize; + float4 uScale; +}; + +float jacobian(thread const float2& dDdx, thread const float2& dDdy) +{ + return ((1.0 + dDdx.x) * (1.0 + dDdy.y)) - (dDdx.y * dDdy.x); +} + +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], constant UBO& _46 [[buffer(0)]], texture2d uHeight [[texture(0)]], sampler uHeightSmplr [[sampler(0)]], texture2d uDisplacement [[texture(1)]], sampler uDisplacementSmplr [[sampler(1)]], texture2d iHeightDisplacement [[texture(2)]], texture2d iGradJacobian [[texture(3)]]) +{ + float4 uv = (float2(gl_GlobalInvocationID.xy) * _46.uInvSize.xy).xyxy + (_46.uInvSize * 0.5); + float h = uHeight.sample(uHeightSmplr, uv.xy, level(0.0)).x; + float x0 = uHeight.sample(uHeightSmplr, uv.xy, level(0.0), int2(-1, 0)).x; + float x1 = uHeight.sample(uHeightSmplr, uv.xy, level(0.0), int2(1, 0)).x; + float y0 = uHeight.sample(uHeightSmplr, uv.xy, level(0.0), int2(0, -1)).x; + float y1 = uHeight.sample(uHeightSmplr, uv.xy, level(0.0), int2(0, 1)).x; + float2 grad = (_46.uScale.xy * 0.5) * float2(x1 - x0, y1 - y0); + float2 displacement = uDisplacement.sample(uDisplacementSmplr, uv.zw, level(0.0)).xy * 1.2000000476837158203125; + float2 dDdx = (uDisplacement.sample(uDisplacementSmplr, uv.zw, level(0.0), int2(1, 0)).xy - uDisplacement.sample(uDisplacementSmplr, uv.zw, level(0.0), int2(-1, 0)).xy) * 0.60000002384185791015625; + float2 dDdy = (uDisplacement.sample(uDisplacementSmplr, uv.zw, level(0.0), int2(0, 1)).xy - uDisplacement.sample(uDisplacementSmplr, uv.zw, level(0.0), int2(0, -1)).xy) * 0.60000002384185791015625; + float2 param = dDdx * _46.uScale.z; + float2 param_1 = dDdy * _46.uScale.z; + float j = jacobian(param, param_1); + displacement = float2(0.0); + iHeightDisplacement.write(float4(h, displacement, 0.0), uint2(int2(gl_GlobalInvocationID.xy))); + iGradJacobian.write(float4(grad, j, 0.0), uint2(int2(gl_GlobalInvocationID.xy))); +} + diff --git a/reference/shaders-msl/comp/barriers.comp b/reference/shaders-msl/comp/barriers.comp new file mode 100644 index 0000000000..3b8474c757 --- /dev/null +++ b/reference/shaders-msl/comp/barriers.comp @@ -0,0 +1,67 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +constant uint3 gl_WorkGroupSize = uint3(4u, 1u, 1u); + +void barrier_shared() +{ + threadgroup_barrier(mem_flags::mem_threadgroup); +} + +void full_barrier() +{ + threadgroup_barrier(mem_flags::mem_threadgroup); +} + +void buffer_barrier() +{ + threadgroup_barrier(mem_flags::mem_none); +} + +void group_barrier() +{ + threadgroup_barrier(mem_flags::mem_threadgroup); +} + +void barrier_shared_exec() +{ + threadgroup_barrier(mem_flags::mem_threadgroup); +} + +void full_barrier_exec() +{ + threadgroup_barrier(mem_flags::mem_threadgroup); +} + +void buffer_barrier_exec() +{ + threadgroup_barrier(mem_flags::mem_none); +} + +void group_barrier_exec() +{ + threadgroup_barrier(mem_flags::mem_threadgroup); +} + +void exec_barrier() +{ + threadgroup_barrier(mem_flags::mem_threadgroup); +} + +kernel void main0() +{ + barrier_shared(); + full_barrier(); + buffer_barrier(); + group_barrier(); + barrier_shared_exec(); + full_barrier_exec(); + buffer_barrier_exec(); + group_barrier_exec(); + exec_barrier(); +} + diff --git a/reference/shaders-msl/comp/basic.comp b/reference/shaders-msl/comp/basic.comp new file mode 100644 index 0000000000..732b1cb257 --- /dev/null +++ b/reference/shaders-msl/comp/basic.comp @@ -0,0 +1,34 @@ +#pragma clang diagnostic ignored "-Wunused-variable" + +#include +#include +#include + +using namespace metal; + +struct SSBO +{ + float4 in_data[1]; +}; + +struct SSBO2 +{ + float4 out_data[1]; +}; + +struct SSBO3 +{ + uint counter; +}; + +kernel void main0(device SSBO& _23 [[buffer(0)]], device SSBO2& _45 [[buffer(1)]], device SSBO3& _48 [[buffer(2)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + uint ident = gl_GlobalInvocationID.x; + float4 idata = _23.in_data[ident]; + if (dot(idata, float4(1.0, 5.0, 6.0, 2.0)) > 8.19999980926513671875) + { + uint _52 = atomic_fetch_add_explicit((volatile device atomic_uint*)&(_48.counter), 1u, memory_order_relaxed); + _45.out_data[_52] = idata; + } +} + diff --git a/reference/shaders-msl/comp/bitfield.noopt.comp b/reference/shaders-msl/comp/bitfield.noopt.comp new file mode 100644 index 0000000000..62ef02c997 --- /dev/null +++ b/reference/shaders-msl/comp/bitfield.noopt.comp @@ -0,0 +1,47 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +// Implementation of the GLSL findLSB() function +template +T findLSB(T x) +{ + return select(ctz(x), T(-1), x == T(0)); +} + +// Implementation of the signed GLSL findMSB() function +template +T findSMSB(T x) +{ + T v = select(x, T(-1) - x, x < T(0)); + return select(clz(T(0)) - (clz(v) + T(1)), T(-1), v == T(0)); +} + +// Implementation of the unsigned GLSL findMSB() function +template +T findUMSB(T x) +{ + return select(clz(T(0)) - (clz(x) + T(1)), T(-1), x == T(0)); +} + +kernel void main0() +{ + int signed_value = 0; + uint unsigned_value = 0u; + int s = extract_bits(signed_value, 5, 20); + uint u = extract_bits(unsigned_value, 6, 21); + s = insert_bits(s, 40, 5, 4); + u = insert_bits(u, 60u, 5, 4); + u = reverse_bits(u); + s = reverse_bits(s); + int v0 = popcount(u); + int v1 = popcount(s); + int v2 = findUMSB(u); + int v3 = findSMSB(s); + int v4 = findLSB(u); + int v5 = findLSB(s); +} + diff --git a/reference/shaders-msl/comp/builtins.comp b/reference/shaders-msl/comp/builtins.comp new file mode 100644 index 0000000000..4330d57831 --- /dev/null +++ b/reference/shaders-msl/comp/builtins.comp @@ -0,0 +1,17 @@ +#include +#include + +using namespace metal; + +constant uint3 gl_WorkGroupSize = uint3(8u, 4u, 2u); + +kernel void main0(uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]], uint3 gl_NumWorkGroups [[threadgroups_per_grid]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]]) +{ + uint3 local_id = gl_LocalInvocationID; + uint3 global_id = gl_GlobalInvocationID; + uint local_index = gl_LocalInvocationIndex; + uint3 work_group_size = gl_WorkGroupSize; + uint3 num_work_groups = gl_NumWorkGroups; + uint3 work_group_id = gl_WorkGroupID; +} + diff --git a/reference/shaders-msl/comp/cfg-preserve-parameter.comp b/reference/shaders-msl/comp/cfg-preserve-parameter.comp new file mode 100644 index 0000000000..d65beee5d2 --- /dev/null +++ b/reference/shaders-msl/comp/cfg-preserve-parameter.comp @@ -0,0 +1,78 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +void out_test_0(thread const int& cond, thread int& i) +{ + if (cond == 0) + { + i = 40; + } + else + { + i = 60; + } +} + +void out_test_1(thread const int& cond, thread int& i) +{ + switch (cond) + { + case 40: + { + i = 40; + break; + } + default: + { + i = 70; + break; + } + } +} + +void inout_test_0(thread const int& cond, thread int& i) +{ + if (cond == 0) + { + i = 40; + } +} + +void inout_test_1(thread const int& cond, thread int& i) +{ + switch (cond) + { + case 40: + { + i = 40; + break; + } + } +} + +kernel void main0() +{ + int cond = 40; + int i = 50; + int param = cond; + int param_1 = i; + out_test_0(param, param_1); + i = param_1; + int param_2 = cond; + int param_3 = i; + out_test_1(param_2, param_3); + i = param_3; + int param_4 = cond; + int param_5 = i; + inout_test_0(param_4, param_5); + i = param_5; + int param_6 = cond; + int param_7 = i; + inout_test_1(param_6, param_7); + i = param_7; +} + diff --git a/reference/shaders-msl/comp/coherent-block.comp b/reference/shaders-msl/comp/coherent-block.comp new file mode 100644 index 0000000000..bec9b218c7 --- /dev/null +++ b/reference/shaders-msl/comp/coherent-block.comp @@ -0,0 +1,15 @@ +#include +#include + +using namespace metal; + +struct SSBO +{ + float4 value; +}; + +kernel void main0(device SSBO& _10 [[buffer(0)]]) +{ + _10.value = float4(20.0); +} + diff --git a/reference/shaders-msl/comp/coherent-image.comp b/reference/shaders-msl/comp/coherent-image.comp new file mode 100644 index 0000000000..0fe044fb9a --- /dev/null +++ b/reference/shaders-msl/comp/coherent-image.comp @@ -0,0 +1,15 @@ +#include +#include + +using namespace metal; + +struct SSBO +{ + int4 value; +}; + +kernel void main0(device SSBO& _10 [[buffer(0)]], texture2d uImage [[texture(0)]]) +{ + _10.value = uImage.read(uint2(int2(10))); +} + diff --git a/reference/shaders-msl/comp/culling.comp b/reference/shaders-msl/comp/culling.comp new file mode 100644 index 0000000000..ef84f1d19d --- /dev/null +++ b/reference/shaders-msl/comp/culling.comp @@ -0,0 +1,36 @@ +#pragma clang diagnostic ignored "-Wunused-variable" + +#include +#include +#include + +using namespace metal; + +constant uint3 gl_WorkGroupSize = uint3(4u, 1u, 1u); + +struct SSBO +{ + float in_data[1]; +}; + +struct SSBO2 +{ + float out_data[1]; +}; + +struct SSBO3 +{ + uint count; +}; + +kernel void main0(device SSBO& _22 [[buffer(0)]], device SSBO2& _38 [[buffer(1)]], device SSBO3& _41 [[buffer(2)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + uint ident = gl_GlobalInvocationID.x; + float idata = _22.in_data[ident]; + if (idata > 12.0) + { + uint _45 = atomic_fetch_add_explicit((volatile device atomic_uint*)&(_41.count), 1u, memory_order_relaxed); + _38.out_data[_45] = idata; + } +} + diff --git a/reference/shaders-msl/comp/defer-parens.comp b/reference/shaders-msl/comp/defer-parens.comp new file mode 100644 index 0000000000..76dce77734 --- /dev/null +++ b/reference/shaders-msl/comp/defer-parens.comp @@ -0,0 +1,23 @@ +#include +#include + +using namespace metal; + +struct SSBO +{ + float4 data; + int index; +}; + +kernel void main0(device SSBO& _13 [[buffer(0)]]) +{ + float4 d = _13.data; + _13.data = float4(d.x, d.yz + float2(10.0), d.w); + _13.data = (d + d) + d; + _13.data = (d.yz + float2(10.0)).xxyy; + float t = (d.yz + float2(10.0)).y; + _13.data = float4(t); + t = (d.zw + float2(10.0))[_13.index]; + _13.data = float4(t); +} + diff --git a/reference/shaders-msl/comp/dowhile.comp b/reference/shaders-msl/comp/dowhile.comp new file mode 100644 index 0000000000..5decd415ff --- /dev/null +++ b/reference/shaders-msl/comp/dowhile.comp @@ -0,0 +1,29 @@ +#include +#include + +using namespace metal; + +struct SSBO +{ + float4x4 mvp; + float4 in_data[1]; +}; + +struct SSBO2 +{ + float4 out_data[1]; +}; + +kernel void main0(device SSBO& _28 [[buffer(0)]], device SSBO2& _52 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + uint ident = gl_GlobalInvocationID.x; + int i = 0; + float4 idat = _28.in_data[ident]; + do + { + idat = _28.mvp * idat; + i++; + } while (i < 16); + _52.out_data[ident] = idat; +} + diff --git a/reference/shaders-msl/comp/functions.comp b/reference/shaders-msl/comp/functions.comp new file mode 100644 index 0000000000..d8f6e55a46 --- /dev/null +++ b/reference/shaders-msl/comp/functions.comp @@ -0,0 +1,18 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +void myfunc(threadgroup int (&foo)[1337]) +{ + foo[0] = 13; +} + +kernel void main0() +{ + threadgroup int foo[1337]; + myfunc(foo); +} + diff --git a/reference/shaders-msl/comp/global-invocation-id-writable-ssbo-in-function.comp b/reference/shaders-msl/comp/global-invocation-id-writable-ssbo-in-function.comp new file mode 100644 index 0000000000..1b525c1f90 --- /dev/null +++ b/reference/shaders-msl/comp/global-invocation-id-writable-ssbo-in-function.comp @@ -0,0 +1,31 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct myBlock +{ + int a; + float b[1]; +}; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +float getB(device myBlock& myStorage, thread uint3& gl_GlobalInvocationID) +{ + return myStorage.b[gl_GlobalInvocationID.x]; +} + +kernel void main0(device myBlock& myStorage [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + myStorage.a = (myStorage.a + 1) % 256; + myStorage.b[gl_GlobalInvocationID.x] = mod(getB(myStorage, gl_GlobalInvocationID) + 0.0199999995529651641845703125, 1.0); +} + diff --git a/reference/shaders-msl/comp/global-invocation-id.comp b/reference/shaders-msl/comp/global-invocation-id.comp new file mode 100644 index 0000000000..fe0212ec3f --- /dev/null +++ b/reference/shaders-msl/comp/global-invocation-id.comp @@ -0,0 +1,26 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct myBlock +{ + int a; + float b[1]; +}; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +kernel void main0(device myBlock& myStorage [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + myStorage.a = (myStorage.a + 1) % 256; + myStorage.b[gl_GlobalInvocationID.x] = mod(myStorage.b[gl_GlobalInvocationID.x] + 0.0199999995529651641845703125, 1.0); +} + diff --git a/reference/shaders-msl/comp/image.comp b/reference/shaders-msl/comp/image.comp new file mode 100644 index 0000000000..f3bc1455db --- /dev/null +++ b/reference/shaders-msl/comp/image.comp @@ -0,0 +1,11 @@ +#include +#include + +using namespace metal; + +kernel void main0(texture2d uImageIn [[texture(0)]], texture2d uImageOut [[texture(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + float4 v = uImageIn.read(uint2((int2(gl_GlobalInvocationID.xy) + int2(uImageIn.get_width(), uImageIn.get_height())))); + uImageOut.write(v, uint2(int2(gl_GlobalInvocationID.xy))); +} + diff --git a/reference/shaders-msl/comp/insert.comp b/reference/shaders-msl/comp/insert.comp new file mode 100644 index 0000000000..0f56a65153 --- /dev/null +++ b/reference/shaders-msl/comp/insert.comp @@ -0,0 +1,21 @@ +#include +#include + +using namespace metal; + +struct SSBO +{ + float4 out_data[1]; +}; + +kernel void main0(device SSBO& _27 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + float4 v; + v.x = 10.0; + v.y = 30.0; + v.z = 70.0; + v.w = 90.0; + _27.out_data[gl_GlobalInvocationID.x] = v; + _27.out_data[gl_GlobalInvocationID.x].y = 20.0; +} + diff --git a/reference/shaders-msl/comp/local-invocation-id.comp b/reference/shaders-msl/comp/local-invocation-id.comp new file mode 100644 index 0000000000..772e5e0d86 --- /dev/null +++ b/reference/shaders-msl/comp/local-invocation-id.comp @@ -0,0 +1,26 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct myBlock +{ + int a; + float b[1]; +}; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +kernel void main0(device myBlock& myStorage [[buffer(0)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]]) +{ + myStorage.a = (myStorage.a + 1) % 256; + myStorage.b[gl_LocalInvocationID.x] = mod(myStorage.b[gl_LocalInvocationID.x] + 0.0199999995529651641845703125, 1.0); +} + diff --git a/reference/shaders-msl/comp/local-invocation-index.comp b/reference/shaders-msl/comp/local-invocation-index.comp new file mode 100644 index 0000000000..41adbdca5c --- /dev/null +++ b/reference/shaders-msl/comp/local-invocation-index.comp @@ -0,0 +1,26 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct myBlock +{ + int a; + float b[1]; +}; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +kernel void main0(device myBlock& myStorage [[buffer(0)]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]]) +{ + myStorage.a = (myStorage.a + 1) % 256; + myStorage.b[gl_LocalInvocationIndex] = mod(myStorage.b[gl_LocalInvocationIndex] + 0.0199999995529651641845703125, 1.0); +} + diff --git a/reference/shaders-msl/comp/loop.noopt.comp b/reference/shaders-msl/comp/loop.noopt.comp new file mode 100644 index 0000000000..00ed570b31 --- /dev/null +++ b/reference/shaders-msl/comp/loop.noopt.comp @@ -0,0 +1,107 @@ +#include +#include + +using namespace metal; + +struct SSBO +{ + float4x4 mvp; + float4 in_data[1]; +}; + +struct SSBO2 +{ + float4 out_data[1]; +}; + +kernel void main0(device SSBO& _24 [[buffer(0)]], device SSBO2& _177 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + uint ident = gl_GlobalInvocationID.x; + float4 idat = _24.in_data[ident]; + int k = 0; + uint i = 0u; + if (idat.y == 20.0) + { + do + { + k *= 2; + i++; + } while (i < ident); + } + switch (k) + { + case 10: + { + for (;;) + { + i++; + if (i > 10u) + { + break; + } + continue; + } + break; + } + default: + { + for (;;) + { + i += 2u; + if (i > 20u) + { + break; + } + continue; + } + break; + } + } + while (k < 10) + { + idat *= 2.0; + k++; + } + for (uint i_1 = 0u; i_1 < 16u; i_1++, k++) + { + for (uint j = 0u; j < 30u; j++) + { + idat = _24.mvp * idat; + } + } + k = 0; + for (;;) + { + k++; + if (k > 10) + { + k += 2; + } + else + { + k += 3; + continue; + } + k += 10; + continue; + } + k = 0; + do + { + k++; + } while (k > 10); + int l = 0; + for (;;) + { + if (l == 5) + { + l++; + continue; + } + idat += float4(1.0); + l++; + continue; + } + _177.out_data[ident] = idat; +} + diff --git a/reference/shaders-msl/comp/mat3.comp b/reference/shaders-msl/comp/mat3.comp new file mode 100644 index 0000000000..c2d9a7c838 --- /dev/null +++ b/reference/shaders-msl/comp/mat3.comp @@ -0,0 +1,16 @@ +#include +#include + +using namespace metal; + +struct SSBO2 +{ + float3x3 out_data[1]; +}; + +kernel void main0(device SSBO2& _22 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + uint ident = gl_GlobalInvocationID.x; + _22.out_data[ident] = float3x3(float3(10.0), float3(20.0), float3(40.0)); +} + diff --git a/reference/shaders-msl/comp/mod.comp b/reference/shaders-msl/comp/mod.comp new file mode 100644 index 0000000000..1a8c5c5fef --- /dev/null +++ b/reference/shaders-msl/comp/mod.comp @@ -0,0 +1,35 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct SSBO +{ + float4 in_data[1]; +}; + +struct SSBO2 +{ + float4 out_data[1]; +}; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +kernel void main0(device SSBO& _23 [[buffer(0)]], device SSBO2& _33 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + uint ident = gl_GlobalInvocationID.x; + float4 v = mod(_23.in_data[ident], _33.out_data[ident]); + _33.out_data[ident] = v; + uint4 vu = as_type(_23.in_data[ident]) % as_type(_33.out_data[ident]); + _33.out_data[ident] = as_type(vu); + int4 vi = as_type(_23.in_data[ident]) % as_type(_33.out_data[ident]); + _33.out_data[ident] = as_type(vi); +} + diff --git a/reference/shaders-msl/comp/modf.comp b/reference/shaders-msl/comp/modf.comp new file mode 100644 index 0000000000..9abd457cad --- /dev/null +++ b/reference/shaders-msl/comp/modf.comp @@ -0,0 +1,24 @@ +#include +#include + +using namespace metal; + +struct SSBO +{ + float4 in_data[1]; +}; + +struct SSBO2 +{ + float4 out_data[1]; +}; + +kernel void main0(device SSBO& _23 [[buffer(0)]], device SSBO2& _35 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + uint ident = gl_GlobalInvocationID.x; + float4 i; + float4 _31 = modf(_23.in_data[ident], i); + float4 v = _31; + _35.out_data[ident] = v; +} + diff --git a/reference/shaders-msl/comp/read-write-only.comp b/reference/shaders-msl/comp/read-write-only.comp new file mode 100644 index 0000000000..ba53b334ba --- /dev/null +++ b/reference/shaders-msl/comp/read-write-only.comp @@ -0,0 +1,29 @@ +#include +#include + +using namespace metal; + +struct SSBO2 +{ + float4 data4; + float4 data5; +}; + +struct SSBO0 +{ + float4 data0; + float4 data1; +}; + +struct SSBO1 +{ + float4 data2; + float4 data3; +}; + +kernel void main0(device SSBO2& _10 [[buffer(0)]], device SSBO0& _15 [[buffer(1)]], device SSBO1& _21 [[buffer(2)]]) +{ + _10.data4 = _15.data0 + _21.data2; + _10.data5 = _15.data1 + _21.data3; +} + diff --git a/reference/shaders-msl/comp/return.comp b/reference/shaders-msl/comp/return.comp new file mode 100644 index 0000000000..71fcfbe391 --- /dev/null +++ b/reference/shaders-msl/comp/return.comp @@ -0,0 +1,36 @@ +#include +#include + +using namespace metal; + +struct SSBO2 +{ + float4 out_data[1]; +}; + +kernel void main0(device SSBO2& _27 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + uint ident = gl_GlobalInvocationID.x; + if (ident == 2u) + { + _27.out_data[ident] = float4(20.0); + } + else + { + if (ident == 4u) + { + _27.out_data[ident] = float4(10.0); + return; + } + } + for (int i = 0; i < 20; i++) + { + if (i == 10) + { + break; + } + return; + } + _27.out_data[ident] = float4(10.0); +} + diff --git a/reference/shaders-msl/comp/rmw-opt.comp b/reference/shaders-msl/comp/rmw-opt.comp new file mode 100644 index 0000000000..060f9f9c71 --- /dev/null +++ b/reference/shaders-msl/comp/rmw-opt.comp @@ -0,0 +1,29 @@ +#include +#include + +using namespace metal; + +struct SSBO +{ + int a; +}; + +kernel void main0(device SSBO& _9 [[buffer(0)]]) +{ + _9.a += 10; + _9.a -= 10; + _9.a *= 10; + _9.a /= 10; + _9.a = _9.a << 2; + _9.a = _9.a >> 3; + _9.a &= 40; + _9.a ^= 10; + _9.a %= 40; + _9.a |= 1; + bool c = false; + bool d = true; + c = c && d; + d = d || c; + _9.a = int(c && d); +} + diff --git a/reference/shaders-msl/comp/shared-array-of-arrays.comp b/reference/shaders-msl/comp/shared-array-of-arrays.comp new file mode 100644 index 0000000000..3133e5f294 --- /dev/null +++ b/reference/shaders-msl/comp/shared-array-of-arrays.comp @@ -0,0 +1,32 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +constant uint3 gl_WorkGroupSize = uint3(4u, 4u, 1u); + +struct SSBO +{ + float out_data[1]; +}; + +void work(threadgroup float (&foo)[4][4], thread uint3& gl_LocalInvocationID, thread uint& gl_LocalInvocationIndex, device SSBO& v_67, thread uint3& gl_GlobalInvocationID) +{ + foo[gl_LocalInvocationID.x][gl_LocalInvocationID.y] = float(gl_LocalInvocationIndex); + threadgroup_barrier(mem_flags::mem_threadgroup); + float x = 0.0; + x += foo[gl_LocalInvocationID.x][0]; + x += foo[gl_LocalInvocationID.x][1]; + x += foo[gl_LocalInvocationID.x][2]; + x += foo[gl_LocalInvocationID.x][3]; + v_67.out_data[gl_GlobalInvocationID.x] = x; +} + +kernel void main0(device SSBO& v_67 [[buffer(0)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + threadgroup float foo[4][4]; + work(foo, gl_LocalInvocationID, gl_LocalInvocationIndex, v_67, gl_GlobalInvocationID); +} + diff --git a/reference/shaders-msl/comp/shared.comp b/reference/shaders-msl/comp/shared.comp new file mode 100644 index 0000000000..5aeaa4f8c1 --- /dev/null +++ b/reference/shaders-msl/comp/shared.comp @@ -0,0 +1,27 @@ +#include +#include + +using namespace metal; + +constant uint3 gl_WorkGroupSize = uint3(4u, 1u, 1u); + +struct SSBO +{ + float in_data[1]; +}; + +struct SSBO2 +{ + float out_data[1]; +}; + +kernel void main0(device SSBO& _22 [[buffer(0)]], device SSBO2& _44 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]]) +{ + uint ident = gl_GlobalInvocationID.x; + float idata = _22.in_data[ident]; + threadgroup float sShared[4]; + sShared[gl_LocalInvocationIndex] = idata; + threadgroup_barrier(mem_flags::mem_threadgroup); + _44.out_data[ident] = sShared[(4u - gl_LocalInvocationIndex) - 1u]; +} + diff --git a/reference/shaders-msl/comp/struct-layout.comp b/reference/shaders-msl/comp/struct-layout.comp new file mode 100644 index 0000000000..6c0f929480 --- /dev/null +++ b/reference/shaders-msl/comp/struct-layout.comp @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct Foo +{ + float4x4 m; +}; + +struct SSBO2 +{ + Foo out_data[1]; +}; + +struct SSBO +{ + Foo in_data[1]; +}; + +kernel void main0(device SSBO2& _23 [[buffer(0)]], device SSBO& _30 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + uint ident = gl_GlobalInvocationID.x; + _23.out_data[ident].m = _30.in_data[ident].m * _30.in_data[ident].m; +} + diff --git a/reference/shaders-msl/comp/struct-packing.comp b/reference/shaders-msl/comp/struct-packing.comp new file mode 100644 index 0000000000..cf626ce63f --- /dev/null +++ b/reference/shaders-msl/comp/struct-packing.comp @@ -0,0 +1,100 @@ +#include +#include + +using namespace metal; + +struct S0 +{ + float2 a[1]; + float b; +}; + +struct S1 +{ + packed_float3 a; + float b; +}; + +struct S2 +{ + float3 a[1]; + float b; +}; + +struct S3 +{ + float2 a; + float b; +}; + +struct S4 +{ + float2 c; +}; + +struct Content +{ + S0 m0s[1]; + S1 m1s[1]; + S2 m2s[1]; + S0 m0; + S1 m1; + S2 m2; + S3 m3; + char pad7[4]; + float m4; + S4 m3s[8]; +}; + +struct SSBO1 +{ + Content content; + Content content1[2]; + Content content2; + char pad3[8]; + float2x2 m0; + float2x2 m1; + float2x3 m2[4]; + float3x2 m3; + float2x2 m4; + float2x2 m5[9]; + float2x3 m6[4][2]; + float3x2 m7; + float array[1]; +}; + +struct SSBO0 +{ + Content content; + Content content1[2]; + Content content2; + float array[1]; +}; + +kernel void main0(device SSBO1& ssbo_430 [[buffer(0)]], device SSBO0& ssbo_140 [[buffer(1)]]) +{ + ssbo_430.content.m0s[0].a[0] = ssbo_140.content.m0s[0].a[0]; + ssbo_430.content.m0s[0].b = ssbo_140.content.m0s[0].b; + ssbo_430.content.m1s[0].a = ssbo_140.content.m1s[0].a; + ssbo_430.content.m1s[0].b = ssbo_140.content.m1s[0].b; + ssbo_430.content.m2s[0].a[0] = ssbo_140.content.m2s[0].a[0]; + ssbo_430.content.m2s[0].b = ssbo_140.content.m2s[0].b; + ssbo_430.content.m0.a[0] = ssbo_140.content.m0.a[0]; + ssbo_430.content.m0.b = ssbo_140.content.m0.b; + ssbo_430.content.m1.a = ssbo_140.content.m1.a; + ssbo_430.content.m1.b = ssbo_140.content.m1.b; + ssbo_430.content.m2.a[0] = ssbo_140.content.m2.a[0]; + ssbo_430.content.m2.b = ssbo_140.content.m2.b; + ssbo_430.content.m3.a = ssbo_140.content.m3.a; + ssbo_430.content.m3.b = ssbo_140.content.m3.b; + ssbo_430.content.m4 = ssbo_140.content.m4; + ssbo_430.content.m3s[0].c = ssbo_140.content.m3s[0].c; + ssbo_430.content.m3s[1].c = ssbo_140.content.m3s[1].c; + ssbo_430.content.m3s[2].c = ssbo_140.content.m3s[2].c; + ssbo_430.content.m3s[3].c = ssbo_140.content.m3s[3].c; + ssbo_430.content.m3s[4].c = ssbo_140.content.m3s[4].c; + 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; +} + diff --git a/reference/shaders-msl/comp/torture-loop.comp b/reference/shaders-msl/comp/torture-loop.comp new file mode 100644 index 0000000000..9257088161 --- /dev/null +++ b/reference/shaders-msl/comp/torture-loop.comp @@ -0,0 +1,51 @@ +#include +#include + +using namespace metal; + +struct SSBO +{ + float4x4 mvp; + float4 in_data[1]; +}; + +struct SSBO2 +{ + float4 out_data[1]; +}; + +kernel void main0(device SSBO& _24 [[buffer(0)]], device SSBO2& _89 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + uint ident = gl_GlobalInvocationID.x; + float4 idat = _24.in_data[ident]; + int k = 0; + for (;;) + { + int _39 = k; + int _40 = _39 + 1; + k = _40; + if (_40 < 10) + { + idat *= 2.0; + k++; + continue; + } + else + { + break; + } + } + for (uint i = 0u; i < 16u; i++, k++) + { + for (uint j = 0u; j < 30u; j++) + { + idat = _24.mvp * idat; + } + } + do + { + k++; + } while (k > 10); + _89.out_data[ident] = idat; +} + diff --git a/reference/shaders-msl/comp/type-alias.comp b/reference/shaders-msl/comp/type-alias.comp new file mode 100644 index 0000000000..d842132995 --- /dev/null +++ b/reference/shaders-msl/comp/type-alias.comp @@ -0,0 +1,53 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct S0 +{ + float4 a; +}; + +struct S1 +{ + float4 a; +}; + +struct SSBO0 +{ + S0 s0s[1]; +}; + +struct SSBO1 +{ + S1 s1s[1]; +}; + +struct SSBO2 +{ + float4 outputs[1]; +}; + +float4 overload(thread const S0& s0) +{ + return s0.a; +} + +float4 overload(thread const S1& s1) +{ + return s1.a; +} + +kernel void main0(device SSBO0& _36 [[buffer(0)]], device SSBO1& _55 [[buffer(1)]], device SSBO2& _66 [[buffer(2)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + S0 s0; + s0.a = _36.s0s[gl_GlobalInvocationID.x].a; + S1 s1; + s1.a = _55.s1s[gl_GlobalInvocationID.x].a; + S0 param = s0; + S1 param_1 = s1; + _66.outputs[gl_GlobalInvocationID.x] = overload(param) + overload(param_1); +} + diff --git a/reference/shaders-msl/comp/udiv.comp b/reference/shaders-msl/comp/udiv.comp new file mode 100644 index 0000000000..32874ad787 --- /dev/null +++ b/reference/shaders-msl/comp/udiv.comp @@ -0,0 +1,20 @@ +#include +#include + +using namespace metal; + +struct SSBO2 +{ + uint outputs[1]; +}; + +struct SSBO +{ + uint inputs[1]; +}; + +kernel void main0(device SSBO2& _10 [[buffer(0)]], device SSBO& _23 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + _10.outputs[gl_GlobalInvocationID.x] = _23.inputs[gl_GlobalInvocationID.x] / 29u; +} + diff --git a/reference/shaders-msl/comp/writable-ssbo.comp b/reference/shaders-msl/comp/writable-ssbo.comp new file mode 100644 index 0000000000..9dc53b6dd5 --- /dev/null +++ b/reference/shaders-msl/comp/writable-ssbo.comp @@ -0,0 +1,26 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct myBlock +{ + int a; + float b; +}; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +kernel void main0(device myBlock& myStorage [[buffer(0)]]) +{ + myStorage.a = (myStorage.a + 1) % 256; + myStorage.b = mod(myStorage.b + 0.0199999995529651641845703125, 1.0); +} + diff --git a/reference/shaders-msl/desktop-only/frag/image-ms.desktop.frag b/reference/shaders-msl/desktop-only/frag/image-ms.desktop.frag new file mode 100644 index 0000000000..7957b209d6 --- /dev/null +++ b/reference/shaders-msl/desktop-only/frag/image-ms.desktop.frag @@ -0,0 +1,13 @@ +#include +#include + +using namespace metal; + +fragment void main0(texture2d_ms uImageMS [[texture(0)]], texture2d_array uImageArray [[texture(1)]], texture2d uImage [[texture(2)]]) +{ + float4 a = uImageMS.read(uint2(int2(1, 2)), 2); + float4 b = uImageArray.read(uint2(int3(1, 2, 4).xy), uint(int3(1, 2, 4).z)); + uImage.write(a, uint2(int2(2, 3))); + uImageArray.write(b, uint2(int3(2, 3, 7).xy), uint(int3(2, 3, 7).z)); +} + diff --git a/reference/shaders-msl/desktop-only/frag/query-levels.desktop.frag b/reference/shaders-msl/desktop-only/frag/query-levels.desktop.frag new file mode 100644 index 0000000000..922796b749 --- /dev/null +++ b/reference/shaders-msl/desktop-only/frag/query-levels.desktop.frag @@ -0,0 +1,17 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(texture2d uSampler [[texture(0)]], sampler uSamplerSmplr [[sampler(0)]]) +{ + main0_out out = {}; + out.FragColor = float4(float(int(uSampler.get_num_mip_levels()))); + return out; +} + diff --git a/reference/shaders-msl/desktop-only/frag/sampler-ms-query.desktop.frag b/reference/shaders-msl/desktop-only/frag/sampler-ms-query.desktop.frag new file mode 100644 index 0000000000..937e27465e --- /dev/null +++ b/reference/shaders-msl/desktop-only/frag/sampler-ms-query.desktop.frag @@ -0,0 +1,17 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(texture2d_ms uSampler [[texture(0)]], texture2d_ms uSamplerArray [[texture(1)]], texture2d_ms uImage [[texture(2)]], texture2d_ms uImageArray [[texture(3)]], sampler uSamplerSmplr [[sampler(0)]], sampler uSamplerArraySmplr [[sampler(1)]]) +{ + main0_out out = {}; + out.FragColor = float4(float(((int(uSampler.get_num_samples()) + int(uSamplerArray.get_num_samples())) + int(uImage.get_num_samples())) + int(uImageArray.get_num_samples()))); + return out; +} + diff --git a/reference/shaders-msl/desktop-only/vert/basic.desktop.sso.vert b/reference/shaders-msl/desktop-only/vert/basic.desktop.sso.vert new file mode 100644 index 0000000000..1592b5c5cf --- /dev/null +++ b/reference/shaders-msl/desktop-only/vert/basic.desktop.sso.vert @@ -0,0 +1,30 @@ +#include +#include + +using namespace metal; + +struct UBO +{ + float4x4 uMVP; +}; + +struct main0_in +{ + float3 aNormal [[attribute(1)]]; + float4 aVertex [[attribute(0)]]; +}; + +struct main0_out +{ + float3 vNormal [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _16 [[buffer(0)]]) +{ + main0_out out = {}; + out.gl_Position = _16.uMVP * in.aVertex; + out.vNormal = in.aNormal; + return out; +} + diff --git a/reference/shaders-msl/desktop-only/vert/clip-cull-distance.desktop.vert b/reference/shaders-msl/desktop-only/vert/clip-cull-distance.desktop.vert new file mode 100644 index 0000000000..32f0d9aa0d --- /dev/null +++ b/reference/shaders-msl/desktop-only/vert/clip-cull-distance.desktop.vert @@ -0,0 +1,23 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 gl_Position [[position]]; + float gl_ClipDistance [[clip_distance]] [2]; + float gl_CullDistance[2]; +}; + +vertex main0_out main0() +{ + main0_out out = {}; + out.gl_Position = float4(10.0); + out.gl_ClipDistance[0] = 1.0; + out.gl_ClipDistance[1] = 4.0; + out.gl_CullDistance[0] = 4.0; + out.gl_CullDistance[1] = 9.0; + return out; +} + diff --git a/reference/shaders-msl/flatten/basic.flatten.vert b/reference/shaders-msl/flatten/basic.flatten.vert new file mode 100644 index 0000000000..1592b5c5cf --- /dev/null +++ b/reference/shaders-msl/flatten/basic.flatten.vert @@ -0,0 +1,30 @@ +#include +#include + +using namespace metal; + +struct UBO +{ + float4x4 uMVP; +}; + +struct main0_in +{ + float3 aNormal [[attribute(1)]]; + float4 aVertex [[attribute(0)]]; +}; + +struct main0_out +{ + float3 vNormal [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _16 [[buffer(0)]]) +{ + main0_out out = {}; + out.gl_Position = _16.uMVP * in.aVertex; + out.vNormal = in.aNormal; + return out; +} + diff --git a/reference/shaders-msl/flatten/multiindex.flatten.vert b/reference/shaders-msl/flatten/multiindex.flatten.vert new file mode 100644 index 0000000000..84c4b408b2 --- /dev/null +++ b/reference/shaders-msl/flatten/multiindex.flatten.vert @@ -0,0 +1,27 @@ +#include +#include + +using namespace metal; + +struct UBO +{ + float4 Data[3][5]; +}; + +struct main0_in +{ + int2 aIndex [[attribute(0)]]; +}; + +struct main0_out +{ + float4 gl_Position [[position]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _20 [[buffer(0)]]) +{ + main0_out out = {}; + out.gl_Position = _20.Data[in.aIndex.x][in.aIndex.y]; + return out; +} + diff --git a/reference/shaders-msl/flatten/push-constant.flatten.vert b/reference/shaders-msl/flatten/push-constant.flatten.vert new file mode 100644 index 0000000000..83def9c0bb --- /dev/null +++ b/reference/shaders-msl/flatten/push-constant.flatten.vert @@ -0,0 +1,32 @@ +#include +#include + +using namespace metal; + +struct PushMe +{ + float4x4 MVP; + float2x2 Rot; + float Arr[4]; +}; + +struct main0_in +{ + float4 Pos [[attribute(1)]]; + float2 Rot [[attribute(0)]]; +}; + +struct main0_out +{ + float2 vRot [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]], constant PushMe& registers [[buffer(0)]]) +{ + main0_out out = {}; + out.gl_Position = registers.MVP * in.Pos; + out.vRot = (registers.Rot * in.Rot) + float2(registers.Arr[2]); + return out; +} + diff --git a/reference/shaders-msl/flatten/rowmajor.flatten.vert b/reference/shaders-msl/flatten/rowmajor.flatten.vert new file mode 100644 index 0000000000..3ea6d78b8a --- /dev/null +++ b/reference/shaders-msl/flatten/rowmajor.flatten.vert @@ -0,0 +1,38 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct UBO +{ + float4x4 uMVPR; + float4x4 uMVPC; + float2x4 uMVP; +}; + +struct main0_in +{ + float4 aVertex [[attribute(0)]]; +}; + +struct main0_out +{ + float4 gl_Position [[position]]; +}; + +// Implementation of a conversion of matrix content from RowMajor to ColumnMajor organization. +float2x4 spvConvertFromRowMajor2x4(float2x4 m) +{ + return float2x4(float4(m[0][0], m[0][2], m[1][0], m[1][2]), float4(m[0][1], m[0][3], m[1][1], m[1][3])); +} + +vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _18 [[buffer(0)]]) +{ + main0_out out = {}; + float2 v = in.aVertex * spvConvertFromRowMajor2x4(_18.uMVP); + out.gl_Position = (_18.uMVPR * in.aVertex) + (in.aVertex * _18.uMVPC); + return out; +} + diff --git a/reference/shaders-msl/flatten/struct.flatten.vert b/reference/shaders-msl/flatten/struct.flatten.vert new file mode 100644 index 0000000000..75f58e1e29 --- /dev/null +++ b/reference/shaders-msl/flatten/struct.flatten.vert @@ -0,0 +1,40 @@ +#include +#include + +using namespace metal; + +struct Light +{ + packed_float3 Position; + float Radius; + float4 Color; +}; + +struct UBO +{ + float4x4 uMVP; + Light light; +}; + +struct main0_in +{ + float3 aNormal [[attribute(1)]]; + float4 aVertex [[attribute(0)]]; +}; + +struct main0_out +{ + float4 vColor [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _18 [[buffer(0)]]) +{ + main0_out out = {}; + out.gl_Position = _18.uMVP * in.aVertex; + out.vColor = float4(0.0); + float3 L = in.aVertex.xyz - _18.light.Position; + out.vColor += ((_18.light.Color * clamp(1.0 - (length(L) / _18.light.Radius), 0.0, 1.0)) * dot(in.aNormal, normalize(L))); + return out; +} + diff --git a/reference/shaders-msl/flatten/swizzle.flatten.vert b/reference/shaders-msl/flatten/swizzle.flatten.vert new file mode 100644 index 0000000000..53fc21f99e --- /dev/null +++ b/reference/shaders-msl/flatten/swizzle.flatten.vert @@ -0,0 +1,47 @@ +#include +#include + +using namespace metal; + +struct UBO +{ + float4 A; + float2 B0; + float2 B1; + float C0; + float3 C1; + packed_float3 D0; + float D1; + float E0; + float E1; + float E2; + float E3; + float F0; + float2 F1; + float F2; +}; + +struct main0_out +{ + float4 oA [[user(locn0)]]; + float4 oB [[user(locn1)]]; + float4 oC [[user(locn2)]]; + float4 oD [[user(locn3)]]; + float4 oE [[user(locn4)]]; + float4 oF [[user(locn5)]]; + float4 gl_Position [[position]]; +}; + +vertex main0_out main0(constant UBO& _22 [[buffer(0)]]) +{ + main0_out out = {}; + out.gl_Position = float4(0.0); + out.oA = _22.A; + out.oB = float4(_22.B0, _22.B1); + out.oC = float4(_22.C0, _22.C1) + float4(_22.C1.xy, _22.C1.z, _22.C0); + out.oD = float4(_22.D0, _22.D1) + float4(float3(_22.D0).xy, float3(_22.D0).z, _22.D1); + out.oE = float4(_22.E0, _22.E1, _22.E2, _22.E3); + out.oF = float4(_22.F0, _22.F1, _22.F2); + return out; +} + diff --git a/reference/shaders-msl/flatten/types.flatten.frag b/reference/shaders-msl/flatten/types.flatten.frag new file mode 100644 index 0000000000..cee53d9e58 --- /dev/null +++ b/reference/shaders-msl/flatten/types.flatten.frag @@ -0,0 +1,35 @@ +#include +#include + +using namespace metal; + +struct UBO1 +{ + int4 c; + int4 d; +}; + +struct UBO2 +{ + uint4 e; + uint4 f; +}; + +struct UBO0 +{ + float4 a; + float4 b; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(constant UBO1& _14 [[buffer(0)]], constant UBO2& _29 [[buffer(1)]], constant UBO0& _41 [[buffer(2)]]) +{ + main0_out out = {}; + out.FragColor = ((((float4(_14.c) + float4(_14.d)) + float4(_29.e)) + float4(_29.f)) + _41.a) + _41.b; + return out; +} + diff --git a/reference/shaders-msl/frag/basic.frag b/reference/shaders-msl/frag/basic.frag new file mode 100644 index 0000000000..4d33ee7bca --- /dev/null +++ b/reference/shaders-msl/frag/basic.frag @@ -0,0 +1,23 @@ +#include +#include + +using namespace metal; + +struct main0_in +{ + float2 vTex [[user(locn1)]]; + float4 vColor [[user(locn0)]]; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], texture2d uTex [[texture(0)]], sampler uTexSmplr [[sampler(0)]]) +{ + main0_out out = {}; + out.FragColor = in.vColor * uTex.sample(uTexSmplr, in.vTex); + return out; +} + diff --git a/reference/shaders-msl/frag/bitcasting.frag b/reference/shaders-msl/frag/bitcasting.frag new file mode 100644 index 0000000000..a2d624510f --- /dev/null +++ b/reference/shaders-msl/frag/bitcasting.frag @@ -0,0 +1,30 @@ +#include +#include + +using namespace metal; + +struct main0_in +{ + float4 VertGeom [[user(locn0)]]; +}; + +struct main0_out +{ + float4 FragColor0 [[color(0)]]; + float4 FragColor1 [[color(1)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], texture2d TextureBase [[texture(0)]], texture2d TextureDetail [[texture(1)]], sampler TextureBaseSmplr [[sampler(0)]], sampler TextureDetailSmplr [[sampler(1)]]) +{ + main0_out out = {}; + float4 texSample0 = TextureBase.sample(TextureBaseSmplr, in.VertGeom.xy); + float4 texSample1 = TextureDetail.sample(TextureDetailSmplr, in.VertGeom.xy, int2(3, 2)); + int4 iResult0 = as_type(texSample0); + int4 iResult1 = as_type(texSample1); + out.FragColor0 = as_type(iResult0) * as_type(iResult1); + uint4 uResult0 = as_type(texSample0); + uint4 uResult1 = as_type(texSample1); + out.FragColor1 = as_type(uResult0) * as_type(uResult1); + return out; +} + diff --git a/reference/shaders-msl/frag/builtins.frag b/reference/shaders-msl/frag/builtins.frag new file mode 100644 index 0000000000..9283d1a66b --- /dev/null +++ b/reference/shaders-msl/frag/builtins.frag @@ -0,0 +1,24 @@ +#include +#include + +using namespace metal; + +struct main0_in +{ + float4 vColor [[user(locn0)]]; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; + float gl_FragDepth [[depth(any)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], float4 gl_FragCoord [[position]]) +{ + main0_out out = {}; + out.FragColor = gl_FragCoord + in.vColor; + out.gl_FragDepth = 0.5; + return out; +} + diff --git a/reference/shaders-msl/frag/composite-extract-forced-temporary.frag b/reference/shaders-msl/frag/composite-extract-forced-temporary.frag new file mode 100644 index 0000000000..2d68f01299 --- /dev/null +++ b/reference/shaders-msl/frag/composite-extract-forced-temporary.frag @@ -0,0 +1,23 @@ +#include +#include + +using namespace metal; + +struct main0_in +{ + float2 vTexCoord [[user(locn0)]]; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], texture2d Texture [[texture(0)]], sampler TextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float f = Texture.sample(TextureSmplr, in.vTexCoord).x; + out.FragColor = float4(f * f); + return out; +} + diff --git a/reference/shaders-msl/frag/constant-array.frag b/reference/shaders-msl/frag/constant-array.frag new file mode 100644 index 0000000000..15aa8fdce2 --- /dev/null +++ b/reference/shaders-msl/frag/constant-array.frag @@ -0,0 +1,40 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct Foobar +{ + float a; + float b; +}; + +struct main0_in +{ + int index [[user(locn0)]]; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +float4 resolve(thread const Foobar& f) +{ + return float4(f.a + f.b); +} + +fragment main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + float4 indexable[3] = {float4(1.0), float4(2.0), float4(3.0)}; + float4 indexable_1[2][2] = {{float4(1.0), float4(2.0)}, {float4(8.0), float4(10.0)}}; + Foobar param = {10.0, 20.0}; + Foobar indexable_2[2] = {{10.0, 40.0}, {90.0, 70.0}}; + Foobar param_1 = indexable_2[in.index]; + out.FragColor = ((indexable[in.index] + (indexable_1[in.index][in.index + 1])) + resolve(param)) + resolve(param_1); + return out; +} + diff --git a/reference/shaders-msl/frag/constant-composites.frag b/reference/shaders-msl/frag/constant-composites.frag new file mode 100644 index 0000000000..1962db1752 --- /dev/null +++ b/reference/shaders-msl/frag/constant-composites.frag @@ -0,0 +1,31 @@ +#include +#include + +using namespace metal; + +struct Foo +{ + float a; + float b; +}; + +struct main0_in +{ + int line [[user(locn0)]]; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + float lut[4] = {1.0, 4.0, 3.0, 2.0}; + Foo foos[2] = {{10.0, 20.0}, {30.0, 40.0}}; + out.FragColor = float4(lut[in.line]); + out.FragColor += float4(foos[in.line].a * (foos[1 - in.line].a)); + return out; +} + diff --git a/reference/shaders-msl/frag/false-loop-init.frag b/reference/shaders-msl/frag/false-loop-init.frag new file mode 100644 index 0000000000..e0792474b5 --- /dev/null +++ b/reference/shaders-msl/frag/false-loop-init.frag @@ -0,0 +1,35 @@ +#include +#include + +using namespace metal; + +struct main0_in +{ + float4 accum [[user(locn0)]]; +}; + +struct main0_out +{ + float4 result [[color(0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.result = float4(0.0); + uint j; + for (int i = 0; i < 4; i += int(j)) + { + if (in.accum.y > 10.0) + { + j = 40u; + } + else + { + j = 30u; + } + out.result += in.accum; + } + return out; +} + diff --git a/reference/shaders-msl/frag/flush_params.frag b/reference/shaders-msl/frag/flush_params.frag new file mode 100644 index 0000000000..e2f2a48cb2 --- /dev/null +++ b/reference/shaders-msl/frag/flush_params.frag @@ -0,0 +1,38 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct Structy +{ + float4 c; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +void foo2(thread Structy& f) +{ + f.c = float4(10.0); +} + +Structy foo() +{ + Structy param; + foo2(param); + Structy f = param; + return f; +} + +fragment main0_out main0() +{ + main0_out out = {}; + Structy s = foo(); + out.FragColor = s.c; + return out; +} + diff --git a/reference/shaders-msl/frag/for-loop-init.frag b/reference/shaders-msl/frag/for-loop-init.frag new file mode 100644 index 0000000000..9f3191b971 --- /dev/null +++ b/reference/shaders-msl/frag/for-loop-init.frag @@ -0,0 +1,58 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + int FragColor [[color(0)]]; +}; + +fragment main0_out main0() +{ + main0_out out = {}; + out.FragColor = 16; + for (int i = 0; i < 25; i++) + { + out.FragColor += 10; + } + for (int i_1 = 1, j = 4; i_1 < 30; i_1++, j += 4) + { + out.FragColor += 11; + } + int k = 0; + for (; k < 20; k++) + { + out.FragColor += 12; + } + k += 3; + out.FragColor += k; + int l; + if (k == 40) + { + l = 0; + for (; l < 40; l++) + { + out.FragColor += 13; + } + return out; + } + else + { + l = k; + out.FragColor += l; + } + int2 i_2 = int2(0); + for (; i_2.x < 10; i_2.x += 4) + { + out.FragColor += i_2.y; + } + int o = k; + for (int m = k; m < 40; m++) + { + out.FragColor += m; + } + out.FragColor += o; + return out; +} + diff --git a/reference/shaders-msl/frag/in_block.frag b/reference/shaders-msl/frag/in_block.frag new file mode 100644 index 0000000000..43b4a05897 --- /dev/null +++ b/reference/shaders-msl/frag/in_block.frag @@ -0,0 +1,23 @@ +#include +#include + +using namespace metal; + +struct main0_in +{ + float4 VertexOut_color2 [[user(locn3)]]; + float4 VertexOut_color [[user(locn2)]]; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.FragColor = in.VertexOut_color + in.VertexOut_color2; + return out; +} + diff --git a/reference/shaders-msl/frag/in_block_assign.noopt.frag b/reference/shaders-msl/frag/in_block_assign.noopt.frag new file mode 100644 index 0000000000..d06863d99c --- /dev/null +++ b/reference/shaders-msl/frag/in_block_assign.noopt.frag @@ -0,0 +1,30 @@ +#include +#include + +using namespace metal; + +struct VOUT +{ + float4 a; +}; + +struct main0_in +{ + float4 VOUT_a [[user(locn0)]]; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + VOUT tmp; + tmp.a = in.VOUT_a; + tmp.a += float4(1.0); + out.FragColor = tmp.a; + return out; +} + diff --git a/reference/shaders-msl/frag/mix.frag b/reference/shaders-msl/frag/mix.frag new file mode 100644 index 0000000000..2d35766621 --- /dev/null +++ b/reference/shaders-msl/frag/mix.frag @@ -0,0 +1,31 @@ +#include +#include + +using namespace metal; + +struct main0_in +{ + float vIn3 [[user(locn3)]]; + float vIn2 [[user(locn2)]]; + float4 vIn1 [[user(locn1)]]; + float4 vIn0 [[user(locn0)]]; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + bool4 l = bool4(false, true, false, false); + out.FragColor = float4(l.x ? in.vIn1.x : in.vIn0.x, l.y ? in.vIn1.y : in.vIn0.y, l.z ? in.vIn1.z : in.vIn0.z, l.w ? in.vIn1.w : in.vIn0.w); + bool f = true; + out.FragColor = float4(f ? in.vIn3 : in.vIn2); + bool4 _37 = bool4(f); + out.FragColor = float4(_37.x ? in.vIn0.x : in.vIn1.x, _37.y ? in.vIn0.y : in.vIn1.y, _37.z ? in.vIn0.z : in.vIn1.z, _37.w ? in.vIn0.w : in.vIn1.w); + out.FragColor = float4(f ? in.vIn2 : in.vIn3); + return out; +} + diff --git a/reference/shaders-msl/frag/pls.frag b/reference/shaders-msl/frag/pls.frag new file mode 100644 index 0000000000..42b5d2bf59 --- /dev/null +++ b/reference/shaders-msl/frag/pls.frag @@ -0,0 +1,31 @@ +#include +#include + +using namespace metal; + +struct main0_in +{ + float4 PLSIn3 [[user(locn3)]]; + float4 PLSIn2 [[user(locn2)]]; + float4 PLSIn1 [[user(locn1)]]; + float4 PLSIn0 [[user(locn0)]]; +}; + +struct main0_out +{ + float4 PLSOut0 [[color(0)]]; + float4 PLSOut1 [[color(1)]]; + float4 PLSOut2 [[color(2)]]; + float4 PLSOut3 [[color(3)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.PLSOut0 = in.PLSIn0 * 2.0; + out.PLSOut1 = in.PLSIn1 * 6.0; + out.PLSOut2 = in.PLSIn2 * 7.0; + out.PLSOut3 = in.PLSIn3 * 4.0; + return out; +} + diff --git a/reference/shaders-msl/frag/sampler-ms.frag b/reference/shaders-msl/frag/sampler-ms.frag new file mode 100644 index 0000000000..1ceb3f96bd --- /dev/null +++ b/reference/shaders-msl/frag/sampler-ms.frag @@ -0,0 +1,18 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(texture2d_ms uSampler [[texture(0)]], sampler uSamplerSmplr [[sampler(0)]], float4 gl_FragCoord [[position]]) +{ + main0_out out = {}; + int2 coord = int2(gl_FragCoord.xy); + out.FragColor = ((uSampler.read(uint2(coord), 0) + uSampler.read(uint2(coord), 1)) + uSampler.read(uint2(coord), 2)) + uSampler.read(uint2(coord), 3); + return out; +} + diff --git a/reference/shaders-msl/frag/sampler.frag b/reference/shaders-msl/frag/sampler.frag new file mode 100644 index 0000000000..5d23492905 --- /dev/null +++ b/reference/shaders-msl/frag/sampler.frag @@ -0,0 +1,31 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct main0_in +{ + float2 vTex [[user(locn1)]]; + float4 vColor [[user(locn0)]]; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +float4 sample_texture(thread const texture2d tex, thread const sampler& texSmplr, thread const float2& uv) +{ + return tex.sample(texSmplr, uv); +} + +fragment main0_out main0(main0_in in [[stage_in]], texture2d uTex [[texture(0)]], sampler uTexSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float2 param = in.vTex; + out.FragColor = in.vColor * sample_texture(uTex, uTexSmplr, param); + return out; +} + diff --git a/reference/shaders-msl/frag/separate-image-sampler-argument.frag b/reference/shaders-msl/frag/separate-image-sampler-argument.frag new file mode 100644 index 0000000000..46c0524ab7 --- /dev/null +++ b/reference/shaders-msl/frag/separate-image-sampler-argument.frag @@ -0,0 +1,24 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +float4 samp(thread const texture2d t, thread const sampler s) +{ + return t.sample(s, float2(0.5)); +} + +fragment main0_out main0(texture2d uDepth [[texture(0)]], sampler uSampler [[sampler(0)]]) +{ + main0_out out = {}; + out.FragColor = samp(uDepth, uSampler); + return out; +} + diff --git a/reference/shaders-msl/frag/swizzle.frag b/reference/shaders-msl/frag/swizzle.frag new file mode 100644 index 0000000000..eb46111f00 --- /dev/null +++ b/reference/shaders-msl/frag/swizzle.frag @@ -0,0 +1,28 @@ +#include +#include + +using namespace metal; + +struct main0_in +{ + float2 vUV [[user(locn2)]]; + float3 vNormal [[user(locn1)]]; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], texture2d samp [[texture(0)]], sampler sampSmplr [[sampler(0)]]) +{ + main0_out out = {}; + out.FragColor = float4(samp.sample(sampSmplr, in.vUV).xyz, 1.0); + out.FragColor = float4(samp.sample(sampSmplr, in.vUV).xz, 1.0, 4.0); + out.FragColor = float4(samp.sample(sampSmplr, in.vUV).xx, samp.sample(sampSmplr, (in.vUV + float2(0.100000001490116119384765625))).yy); + out.FragColor = float4(in.vNormal, 1.0); + out.FragColor = float4(in.vNormal + float3(1.7999999523162841796875), 1.0); + out.FragColor = float4(in.vUV, in.vUV + float2(1.7999999523162841796875)); + return out; +} + diff --git a/reference/shaders-msl/frag/texture-proj-shadow.frag b/reference/shaders-msl/frag/texture-proj-shadow.frag new file mode 100644 index 0000000000..8b9b03a59e --- /dev/null +++ b/reference/shaders-msl/frag/texture-proj-shadow.frag @@ -0,0 +1,29 @@ +#include +#include + +using namespace metal; + +struct main0_in +{ + float2 vClip2 [[user(locn2)]]; + float4 vClip4 [[user(locn1)]]; + float3 vClip3 [[user(locn0)]]; +}; + +struct main0_out +{ + float FragColor [[color(0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], depth2d uShadow2D [[texture(0)]], texture1d uSampler1D [[texture(1)]], texture2d uSampler2D [[texture(2)]], texture3d uSampler3D [[texture(3)]], sampler uShadow2DSmplr [[sampler(0)]], sampler uSampler1DSmplr [[sampler(1)]], sampler uSampler2DSmplr [[sampler(2)]], sampler uSampler3DSmplr [[sampler(3)]]) +{ + main0_out out = {}; + float4 _20 = in.vClip4; + _20.z = in.vClip4.w; + out.FragColor = uShadow2D.sample_compare(uShadow2DSmplr, _20.xy / _20.z, in.vClip4.z); + out.FragColor = uSampler1D.sample(uSampler1DSmplr, in.vClip2.x / in.vClip2.y).x; + out.FragColor = uSampler2D.sample(uSampler2DSmplr, in.vClip3.xy / in.vClip3.z).x; + out.FragColor = uSampler3D.sample(uSampler3DSmplr, in.vClip4.xyz / in.vClip4.w).x; + return out; +} + diff --git a/reference/shaders-msl/frag/ubo_layout.frag b/reference/shaders-msl/frag/ubo_layout.frag new file mode 100644 index 0000000000..8c03e33b39 --- /dev/null +++ b/reference/shaders-msl/frag/ubo_layout.frag @@ -0,0 +1,32 @@ +#include +#include + +using namespace metal; + +struct Str +{ + float4x4 foo; +}; + +struct UBO1 +{ + Str foo; +}; + +struct UBO2 +{ + Str foo; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(constant UBO1& ubo1 [[buffer(0)]], constant UBO2& ubo0 [[buffer(1)]]) +{ + main0_out out = {}; + out.FragColor = transpose(ubo1.foo.foo)[0] + ubo0.foo.foo[0]; + return out; +} + diff --git a/reference/shaders-msl/frag/unary-enclose.frag b/reference/shaders-msl/frag/unary-enclose.frag new file mode 100644 index 0000000000..5a80f4d77c --- /dev/null +++ b/reference/shaders-msl/frag/unary-enclose.frag @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_in +{ + int4 vIn1 [[user(locn1)]]; + float4 vIn [[user(locn0)]]; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.FragColor = -(-in.vIn); + int4 a = ~(~in.vIn1); + bool b = false; + b = !(!b); + return out; +} + diff --git a/reference/shaders-msl/legacy/vert/transpose.legacy.vert b/reference/shaders-msl/legacy/vert/transpose.legacy.vert new file mode 100644 index 0000000000..ad9ed8d7fd --- /dev/null +++ b/reference/shaders-msl/legacy/vert/transpose.legacy.vert @@ -0,0 +1,33 @@ +#include +#include + +using namespace metal; + +struct Buffer +{ + float4x4 MVPRowMajor; + float4x4 MVPColMajor; + float4x4 M; +}; + +struct main0_in +{ + float4 Position [[attribute(0)]]; +}; + +struct main0_out +{ + float4 gl_Position [[position]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]], constant Buffer& _13 [[buffer(0)]]) +{ + main0_out out = {}; + float4 c0 = _13.M * (in.Position * _13.MVPRowMajor); + float4 c1 = _13.M * (_13.MVPColMajor * in.Position); + float4 c2 = _13.M * (_13.MVPRowMajor * in.Position); + float4 c3 = _13.M * (in.Position * _13.MVPColMajor); + out.gl_Position = ((c0 + c1) + c2) + c3; + return out; +} + diff --git a/reference/shaders-msl/vert/basic.vert b/reference/shaders-msl/vert/basic.vert new file mode 100644 index 0000000000..1592b5c5cf --- /dev/null +++ b/reference/shaders-msl/vert/basic.vert @@ -0,0 +1,30 @@ +#include +#include + +using namespace metal; + +struct UBO +{ + float4x4 uMVP; +}; + +struct main0_in +{ + float3 aNormal [[attribute(1)]]; + float4 aVertex [[attribute(0)]]; +}; + +struct main0_out +{ + float3 vNormal [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _16 [[buffer(0)]]) +{ + main0_out out = {}; + out.gl_Position = _16.uMVP * in.aVertex; + out.vNormal = in.aNormal; + return out; +} + diff --git a/reference/shaders-msl/vert/copy.flatten.vert b/reference/shaders-msl/vert/copy.flatten.vert new file mode 100644 index 0000000000..9ae5fcdb17 --- /dev/null +++ b/reference/shaders-msl/vert/copy.flatten.vert @@ -0,0 +1,47 @@ +#include +#include + +using namespace metal; + +struct Light +{ + packed_float3 Position; + float Radius; + float4 Color; +}; + +struct UBO +{ + float4x4 uMVP; + Light lights[4]; +}; + +struct main0_in +{ + float3 aNormal [[attribute(1)]]; + float4 aVertex [[attribute(0)]]; +}; + +struct main0_out +{ + float4 vColor [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _21 [[buffer(0)]]) +{ + main0_out out = {}; + out.gl_Position = _21.uMVP * in.aVertex; + out.vColor = float4(0.0); + for (int i = 0; i < 4; i++) + { + Light light; + light.Position = _21.lights[i].Position; + light.Radius = _21.lights[i].Radius; + light.Color = _21.lights[i].Color; + float3 L = in.aVertex.xyz - light.Position; + out.vColor += ((_21.lights[i].Color * clamp(1.0 - (length(L) / light.Radius), 0.0, 1.0)) * dot(in.aNormal, normalize(L))); + } + return out; +} + diff --git a/reference/shaders-msl/vert/dynamic.flatten.vert b/reference/shaders-msl/vert/dynamic.flatten.vert new file mode 100644 index 0000000000..696966ca0b --- /dev/null +++ b/reference/shaders-msl/vert/dynamic.flatten.vert @@ -0,0 +1,43 @@ +#include +#include + +using namespace metal; + +struct Light +{ + packed_float3 Position; + float Radius; + float4 Color; +}; + +struct UBO +{ + float4x4 uMVP; + Light lights[4]; +}; + +struct main0_in +{ + float3 aNormal [[attribute(1)]]; + float4 aVertex [[attribute(0)]]; +}; + +struct main0_out +{ + float4 vColor [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _21 [[buffer(0)]]) +{ + main0_out out = {}; + out.gl_Position = _21.uMVP * in.aVertex; + out.vColor = float4(0.0); + for (int i = 0; i < 4; i++) + { + float3 L = in.aVertex.xyz - _21.lights[i].Position; + out.vColor += ((_21.lights[i].Color * clamp(1.0 - (length(L) / _21.lights[i].Radius), 0.0, 1.0)) * dot(in.aNormal, normalize(L))); + } + return out; +} + diff --git a/reference/shaders-msl/vert/functions.vert b/reference/shaders-msl/vert/functions.vert new file mode 100644 index 0000000000..8ec2484c3e --- /dev/null +++ b/reference/shaders-msl/vert/functions.vert @@ -0,0 +1,119 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct UBO +{ + float4x4 uMVP; + float3 rotDeg; + float3 rotRad; + int2 bits; +}; + +struct main0_in +{ + float3 aNormal [[attribute(1)]]; + float4 aVertex [[attribute(0)]]; +}; + +struct main0_out +{ + float3 vNormal [[user(locn0)]]; + float3 vRotDeg [[user(locn1)]]; + float3 vRotRad [[user(locn2)]]; + int2 vLSB [[user(locn3)]]; + int2 vMSB [[user(locn4)]]; + float4 gl_Position [[position]]; +}; + +// Implementation of the GLSL radians() function +template +T radians(T d) +{ + return d * 0.01745329251; +} + +// Implementation of the GLSL degrees() function +template +T degrees(T r) +{ + return r * 57.2957795131; +} + +// Implementation of the GLSL findLSB() function +template +T findLSB(T x) +{ + return select(ctz(x), T(-1), x == T(0)); +} + +// Implementation of the signed GLSL findMSB() function +template +T findSMSB(T x) +{ + T v = select(x, T(-1) - x, x < T(0)); + return select(clz(T(0)) - (clz(v) + T(1)), T(-1), v == T(0)); +} + +// 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; +} + +vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _18 [[buffer(0)]]) +{ + main0_out out = {}; + out.gl_Position = spvInverse4x4(_18.uMVP) * in.aVertex; + out.vNormal = in.aNormal; + out.vRotDeg = degrees(_18.rotRad); + out.vRotRad = radians(_18.rotDeg); + out.vLSB = findLSB(_18.bits); + out.vMSB = findSMSB(_18.bits); + return out; +} + diff --git a/reference/shaders-msl/vert/out_block.vert b/reference/shaders-msl/vert/out_block.vert new file mode 100644 index 0000000000..3ae18387a6 --- /dev/null +++ b/reference/shaders-msl/vert/out_block.vert @@ -0,0 +1,32 @@ +#include +#include + +using namespace metal; + +struct Transform +{ + float4x4 transform; +}; + +struct main0_in +{ + float4 color [[attribute(1)]]; + float3 position [[attribute(0)]]; +}; + +struct main0_out +{ + float4 VertexOut_color [[user(locn2)]]; + float4 VertexOut_color2 [[user(locn3)]]; + float4 gl_Position [[position]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]], constant Transform& block [[buffer(0)]]) +{ + main0_out out = {}; + out.gl_Position = block.transform * float4(in.position, 1.0); + out.VertexOut_color = in.color; + out.VertexOut_color2 = in.color + float4(1.0); + return out; +} + diff --git a/reference/shaders-msl/vert/pointsize.vert b/reference/shaders-msl/vert/pointsize.vert new file mode 100644 index 0000000000..faf828b4d3 --- /dev/null +++ b/reference/shaders-msl/vert/pointsize.vert @@ -0,0 +1,33 @@ +#include +#include + +using namespace metal; + +struct params +{ + float4x4 mvp; + float psize; +}; + +struct main0_in +{ + float4 color0 [[attribute(1)]]; + float4 position [[attribute(0)]]; +}; + +struct main0_out +{ + float4 color [[user(locn0)]]; + float4 gl_Position [[position]]; + float gl_PointSize [[point_size]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]], constant params& _19 [[buffer(0)]]) +{ + main0_out out = {}; + out.gl_Position = _19.mvp * in.position; + out.gl_PointSize = _19.psize; + out.color = in.color0; + return out; +} + diff --git a/reference/shaders-msl/vert/texture_buffer.vert b/reference/shaders-msl/vert/texture_buffer.vert new file mode 100644 index 0000000000..690757b830 --- /dev/null +++ b/reference/shaders-msl/vert/texture_buffer.vert @@ -0,0 +1,17 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 gl_Position [[position]]; +}; + +vertex main0_out main0(texture2d uSamp [[texture(0)]], texture2d uSampo [[texture(1)]]) +{ + main0_out out = {}; + out.gl_Position = uSamp.read(uint2(10, 0)) + uSampo.read(uint2(100, 0)); + return out; +} + diff --git a/reference/shaders-msl/vert/ubo.alignment.vert b/reference/shaders-msl/vert/ubo.alignment.vert new file mode 100644 index 0000000000..6e48ae0e42 --- /dev/null +++ b/reference/shaders-msl/vert/ubo.alignment.vert @@ -0,0 +1,38 @@ +#include +#include + +using namespace metal; + +struct UBO +{ + float4x4 mvp; + float2 targSize; + char pad2[8]; + packed_float3 color; + float opacity; +}; + +struct main0_in +{ + float3 aNormal [[attribute(1)]]; + float4 aVertex [[attribute(0)]]; +}; + +struct main0_out +{ + float3 vNormal [[user(locn0)]]; + float3 vColor [[user(locn1)]]; + float2 vSize [[user(locn2)]]; + float4 gl_Position [[position]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _18 [[buffer(0)]]) +{ + main0_out out = {}; + out.gl_Position = _18.mvp * in.aVertex; + out.vNormal = in.aNormal; + out.vColor = _18.color * _18.opacity; + out.vSize = _18.targSize * _18.opacity; + return out; +} + diff --git a/reference/shaders-msl/vert/ubo.vert b/reference/shaders-msl/vert/ubo.vert new file mode 100644 index 0000000000..4a1adcd7f6 --- /dev/null +++ b/reference/shaders-msl/vert/ubo.vert @@ -0,0 +1,30 @@ +#include +#include + +using namespace metal; + +struct UBO +{ + float4x4 mvp; +}; + +struct main0_in +{ + float3 aNormal [[attribute(1)]]; + float4 aVertex [[attribute(0)]]; +}; + +struct main0_out +{ + float3 vNormal [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _16 [[buffer(0)]]) +{ + main0_out out = {}; + out.gl_Position = _16.mvp * in.aVertex; + out.vNormal = in.aNormal; + return out; +} + diff --git a/reference/shaders-msl/vulkan/frag/push-constant.vk.frag b/reference/shaders-msl/vulkan/frag/push-constant.vk.frag new file mode 100644 index 0000000000..bc97e3cc51 --- /dev/null +++ b/reference/shaders-msl/vulkan/frag/push-constant.vk.frag @@ -0,0 +1,28 @@ +#include +#include + +using namespace metal; + +struct PushConstants +{ + float4 value0; + float4 value1; +}; + +struct main0_in +{ + float4 vColor [[user(locn0)]]; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], constant PushConstants& push [[buffer(0)]]) +{ + main0_out out = {}; + out.FragColor = (in.vColor + push.value0) + push.value1; + return out; +} + diff --git a/reference/shaders-msl/vulkan/frag/spec-constant.vk.frag b/reference/shaders-msl/vulkan/frag/spec-constant.vk.frag new file mode 100644 index 0000000000..47dabb1771 --- /dev/null +++ b/reference/shaders-msl/vulkan/frag/spec-constant.vk.frag @@ -0,0 +1,74 @@ +#include +#include + +using namespace metal; + +constant float a_tmp [[function_constant(1)]]; +constant float a = is_function_constant_defined(a_tmp) ? a_tmp : 1.0; +constant float b_tmp [[function_constant(2)]]; +constant float b = is_function_constant_defined(b_tmp) ? b_tmp : 2.0; +constant int c_tmp [[function_constant(3)]]; +constant int c = is_function_constant_defined(c_tmp) ? c_tmp : 3; +constant int d_tmp [[function_constant(4)]]; +constant int d = is_function_constant_defined(d_tmp) ? d_tmp : 4; +constant uint e_tmp [[function_constant(5)]]; +constant uint e = is_function_constant_defined(e_tmp) ? e_tmp : 5u; +constant uint f_tmp [[function_constant(6)]]; +constant uint f = is_function_constant_defined(f_tmp) ? f_tmp : 6u; +constant bool g_tmp [[function_constant(7)]]; +constant bool g = is_function_constant_defined(g_tmp) ? g_tmp : false; +constant bool h_tmp [[function_constant(8)]]; +constant bool h = is_function_constant_defined(h_tmp) ? h_tmp : true; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0() +{ + main0_out out = {}; + float t0 = a; + float t1 = b; + uint c0 = (uint(c) + 0u); + int c1 = (-c); + int c2 = (~c); + int c3 = (c + d); + int c4 = (c - d); + int c5 = (c * d); + int c6 = (c / d); + uint c7 = (e / f); + int c8 = (c % d); + uint c9 = (e % f); + int c10 = (c >> d); + uint c11 = (e >> f); + int c12 = (c << d); + int c13 = (c | d); + int c14 = (c ^ d); + int c15 = (c & d); + bool c16 = (g || h); + bool c17 = (g && h); + bool c18 = (!g); + bool c19 = (g == h); + bool c20 = (g != h); + bool c21 = (c == d); + bool c22 = (c != d); + bool c23 = (c < d); + bool c24 = (e < f); + bool c25 = (c > d); + bool c26 = (e > f); + bool c27 = (c <= d); + bool c28 = (e <= f); + bool c29 = (c >= d); + bool c30 = (e >= f); + int c31 = c8 + c3; + int c32 = int(e + 0u); + bool c33 = (c != int(0u)); + bool c34 = (e != 0u); + int c35 = int(g); + uint c36 = uint(g); + float c37 = float(g); + out.FragColor = float4(t0 + t1); + return out; +} + diff --git a/reference/shaders-msl/vulkan/vert/vulkan-vertex.vk.vert b/reference/shaders-msl/vulkan/vert/vulkan-vertex.vk.vert new file mode 100644 index 0000000000..53e26e4a8e --- /dev/null +++ b/reference/shaders-msl/vulkan/vert/vulkan-vertex.vk.vert @@ -0,0 +1,17 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 gl_Position [[position]]; +}; + +vertex main0_out main0(uint gl_VertexIndex [[vertex_id]], uint gl_InstanceIndex [[instance_id]]) +{ + main0_out out = {}; + out.gl_Position = float4(1.0, 2.0, 3.0, 4.0) * float(gl_VertexIndex + gl_InstanceIndex); + return out; +} + diff --git a/reference/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag b/reference/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag new file mode 100644 index 0000000000..d670898481 --- /dev/null +++ b/reference/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag @@ -0,0 +1,11 @@ +#version 450 +#extension GL_AMD_shader_fragment_mask : require + +layout(binding = 0) uniform sampler2DMS t; + +void main() +{ + vec4 test2 = fragmentFetchAMD(t, 4u); + uint testi2 = fragmentMaskFetchAMD(t); +} + diff --git a/reference/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag.vk b/reference/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag.vk new file mode 100644 index 0000000000..4aaf397a0f --- /dev/null +++ b/reference/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag.vk @@ -0,0 +1,11 @@ +#version 450 +#extension GL_AMD_shader_fragment_mask : require + +layout(input_attachment_index = 0, set = 0, binding = 0) uniform subpassInputMS t; + +void main() +{ + vec4 test2 = fragmentFetchAMD(t, 4u); + uint testi2 = fragmentMaskFetchAMD(t); +} + diff --git a/reference/shaders/amd/fs.invalid.frag b/reference/shaders/amd/fs.invalid.frag new file mode 100644 index 0000000000..97e7bcd180 --- /dev/null +++ b/reference/shaders/amd/fs.invalid.frag @@ -0,0 +1,15 @@ +#version 450 +#extension GL_AMD_shader_fragment_mask : require +#extension GL_AMD_shader_explicit_vertex_parameter : require + +uniform sampler2DMS texture1; + +layout(location = 0) in vec4 vary; + +void main() +{ + uint testi1 = fragmentMaskFetchAMD(texture1, ivec2(0)); + vec4 test1 = fragmentFetchAMD(texture1, ivec2(1), 2u); + vec4 pos = interpolateAtVertexAMD(vary, 0u); +} + diff --git a/reference/shaders/amd/gcn_shader.comp b/reference/shaders/amd/gcn_shader.comp new file mode 100644 index 0000000000..1c0c5ae38b --- /dev/null +++ b/reference/shaders/amd/gcn_shader.comp @@ -0,0 +1,12 @@ +#version 450 +#extension GL_ARB_gpu_shader_int64 : require +#extension GL_AMD_gcn_shader : require +layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; + +void main() +{ + float cubeFace = cubeFaceIndexAMD(vec3(0.0)); + vec2 cubeFaceCoord = cubeFaceCoordAMD(vec3(1.0)); + uint64_t time = timeAMD(); +} + diff --git a/reference/shaders/amd/shader_ballot.comp b/reference/shaders/amd/shader_ballot.comp new file mode 100644 index 0000000000..64ac64d0d2 --- /dev/null +++ b/reference/shaders/amd/shader_ballot.comp @@ -0,0 +1,32 @@ +#version 450 +#extension GL_ARB_gpu_shader_int64 : require +#extension GL_ARB_shader_ballot : require +#extension GL_AMD_shader_ballot : require +layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) buffer inputData +{ + float inputDataArray[]; +} _12; + +layout(binding = 1, std430) buffer outputData +{ + float outputDataArray[]; +} _74; + +void main() +{ + float thisLaneData = _12.inputDataArray[gl_LocalInvocationID.x]; + bool laneActive = thisLaneData > 0.0; + uint thisLaneOutputSlot = mbcntAMD(packUint2x32(uvec2(unpackUint2x32(ballotARB(laneActive)).xy))); + int firstInvocation = readFirstInvocationARB(1); + int invocation = readInvocationARB(1, 0u); + vec3 swizzleInvocations = swizzleInvocationsAMD(vec3(0.0, 2.0, 1.0), uvec4(3u)); + vec3 swizzelInvocationsMasked = swizzleInvocationsMaskedAMD(vec3(0.0, 2.0, 1.0), uvec3(2u)); + vec3 writeInvocation = writeInvocationAMD(swizzleInvocations, swizzelInvocationsMasked, 0u); + if (laneActive) + { + _74.outputDataArray[thisLaneOutputSlot] = thisLaneData; + } +} + diff --git a/reference/shaders/amd/shader_ballot_nonuniform_invocations.invalid.comp b/reference/shaders/amd/shader_ballot_nonuniform_invocations.invalid.comp new file mode 100644 index 0000000000..a14343ae12 --- /dev/null +++ b/reference/shaders/amd/shader_ballot_nonuniform_invocations.invalid.comp @@ -0,0 +1,11 @@ +#version 450 +#extension GL_AMD_shader_ballot : require +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +void main() +{ + float addInvocations = addInvocationsNonUniformAMD(0.0); + int minInvocations = minInvocationsNonUniformAMD(1); + uint maxInvocations = uint(maxInvocationsNonUniformAMD(4)); +} + diff --git a/reference/shaders/amd/shader_group_vote.comp b/reference/shaders/amd/shader_group_vote.comp new file mode 100644 index 0000000000..007d9f9841 --- /dev/null +++ b/reference/shaders/amd/shader_group_vote.comp @@ -0,0 +1,18 @@ +#version 450 +#extension GL_ARB_shader_group_vote : require +layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) buffer inputData +{ + float inputDataArray[]; +} _12; + +void main() +{ + float thisLaneData = _12.inputDataArray[gl_LocalInvocationID.x]; + bool laneActive = thisLaneData > 0.0; + bool allInvocations = allInvocationsARB(laneActive); + bool anyInvocations = anyInvocationARB(laneActive); + bool allInvocationsEqual = allInvocationsEqualARB(laneActive); +} + diff --git a/reference/shaders/amd/shader_trinary_minmax.comp b/reference/shaders/amd/shader_trinary_minmax.comp new file mode 100644 index 0000000000..ece39b7106 --- /dev/null +++ b/reference/shaders/amd/shader_trinary_minmax.comp @@ -0,0 +1,11 @@ +#version 450 +#extension GL_AMD_shader_trinary_minmax : require +layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; + +void main() +{ + int t11 = min3(0, 3, 2); + int t12 = max3(0, 3, 2); + int t13 = mid3(0, 3, 2); +} + diff --git a/reference/shaders/asm/comp/bitcast_iadd.asm.comp b/reference/shaders/asm/comp/bitcast_iadd.asm.comp new file mode 100644 index 0000000000..bed2dffccb --- /dev/null +++ b/reference/shaders/asm/comp/bitcast_iadd.asm.comp @@ -0,0 +1,27 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) restrict buffer _3_5 +{ + ivec4 _m0; + uvec4 _m1; +} _5; + +layout(binding = 1, std430) restrict buffer _4_6 +{ + uvec4 _m0; + ivec4 _m1; +} _6; + +void main() +{ + _6._m0 = _5._m1 + uvec4(_5._m0); + _6._m0 = uvec4(_5._m0) + _5._m1; + _6._m0 = _5._m1 + _5._m1; + _6._m0 = uvec4(_5._m0 + _5._m0); + _6._m1 = ivec4(_5._m1 + _5._m1); + _6._m1 = _5._m0 + _5._m0; + _6._m1 = ivec4(_5._m1) + _5._m0; + _6._m1 = _5._m0 + ivec4(_5._m1); +} + diff --git a/reference/shaders/asm/comp/bitcast_iequal.asm.comp b/reference/shaders/asm/comp/bitcast_iequal.asm.comp new file mode 100644 index 0000000000..79398b404b --- /dev/null +++ b/reference/shaders/asm/comp/bitcast_iequal.asm.comp @@ -0,0 +1,31 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) buffer _3_5 +{ + ivec4 _m0; + uvec4 _m1; +} _5; + +layout(binding = 1, std430) buffer _4_6 +{ + uvec4 _m0; + ivec4 _m1; +} _6; + +void main() +{ + bvec4 _34 = equal(ivec4(_5._m1), _5._m0); + bvec4 _35 = equal(_5._m0, ivec4(_5._m1)); + bvec4 _36 = equal(_5._m1, _5._m1); + bvec4 _37 = equal(_5._m0, _5._m0); + _6._m0 = mix(uvec4(0u), uvec4(1u), _34); + _6._m0 = mix(uvec4(0u), uvec4(1u), _35); + _6._m0 = mix(uvec4(0u), uvec4(1u), _36); + _6._m0 = mix(uvec4(0u), uvec4(1u), _37); + _6._m1 = mix(ivec4(0), ivec4(1), _34); + _6._m1 = mix(ivec4(0), ivec4(1), _35); + _6._m1 = mix(ivec4(0), ivec4(1), _36); + _6._m1 = mix(ivec4(0), ivec4(1), _37); +} + diff --git a/reference/shaders/asm/comp/bitcast_sar.asm.comp b/reference/shaders/asm/comp/bitcast_sar.asm.comp new file mode 100644 index 0000000000..42a4ed0233 --- /dev/null +++ b/reference/shaders/asm/comp/bitcast_sar.asm.comp @@ -0,0 +1,27 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) buffer _3_5 +{ + ivec4 _m0; + uvec4 _m1; +} _5; + +layout(binding = 1, std430) buffer _4_6 +{ + uvec4 _m0; + ivec4 _m1; +} _6; + +void main() +{ + _6._m0 = uvec4(ivec4(_5._m1) >> _5._m0); + _6._m0 = uvec4(_5._m0 >> ivec4(_5._m1)); + _6._m0 = uvec4(ivec4(_5._m1) >> ivec4(_5._m1)); + _6._m0 = uvec4(_5._m0 >> _5._m0); + _6._m1 = ivec4(_5._m1) >> ivec4(_5._m1); + _6._m1 = _5._m0 >> _5._m0; + _6._m1 = ivec4(_5._m1) >> _5._m0; + _6._m1 = _5._m0 >> ivec4(_5._m1); +} + diff --git a/reference/shaders/asm/comp/bitcast_sdiv.asm.comp b/reference/shaders/asm/comp/bitcast_sdiv.asm.comp new file mode 100644 index 0000000000..eeb97e14a2 --- /dev/null +++ b/reference/shaders/asm/comp/bitcast_sdiv.asm.comp @@ -0,0 +1,27 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) buffer _3_5 +{ + ivec4 _m0; + uvec4 _m1; +} _5; + +layout(binding = 1, std430) buffer _4_6 +{ + uvec4 _m0; + ivec4 _m1; +} _6; + +void main() +{ + _6._m0 = uvec4(ivec4(_5._m1) / _5._m0); + _6._m0 = uvec4(_5._m0 / ivec4(_5._m1)); + _6._m0 = uvec4(ivec4(_5._m1) / ivec4(_5._m1)); + _6._m0 = uvec4(_5._m0 / _5._m0); + _6._m1 = ivec4(_5._m1) / ivec4(_5._m1); + _6._m1 = _5._m0 / _5._m0; + _6._m1 = ivec4(_5._m1) / _5._m0; + _6._m1 = _5._m0 / ivec4(_5._m1); +} + diff --git a/reference/shaders/asm/comp/bitcast_slr.asm.comp b/reference/shaders/asm/comp/bitcast_slr.asm.comp new file mode 100644 index 0000000000..25245e63eb --- /dev/null +++ b/reference/shaders/asm/comp/bitcast_slr.asm.comp @@ -0,0 +1,27 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) buffer _3_5 +{ + ivec4 _m0; + uvec4 _m1; +} _5; + +layout(binding = 1, std430) buffer _4_6 +{ + uvec4 _m0; + ivec4 _m1; +} _6; + +void main() +{ + _6._m0 = _5._m1 >> uvec4(_5._m0); + _6._m0 = uvec4(_5._m0) >> _5._m1; + _6._m0 = _5._m1 >> _5._m1; + _6._m0 = uvec4(_5._m0) >> uvec4(_5._m0); + _6._m1 = ivec4(_5._m1 >> _5._m1); + _6._m1 = ivec4(uvec4(_5._m0) >> uvec4(_5._m0)); + _6._m1 = ivec4(_5._m1 >> uvec4(_5._m0)); + _6._m1 = ivec4(uvec4(_5._m0) >> _5._m1); +} + diff --git a/reference/shaders/asm/comp/logical.asm.comp b/reference/shaders/asm/comp/logical.asm.comp new file mode 100644 index 0000000000..9ae25f78a9 --- /dev/null +++ b/reference/shaders/asm/comp/logical.asm.comp @@ -0,0 +1,56 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) buffer SSBO0 +{ + float a; + vec2 b; + vec3 c; + vec4 d; +} s0; + +layout(binding = 1, std430) buffer SSBO1 +{ + float a; + vec2 b; + vec3 c; + vec4 d; +} s1; + +bool and(bool a, bool b) +{ + return !((a && b) || b); +} + +bvec2 and(bvec2 a, bvec2 b) +{ + bvec2 _98 = bvec2(a.x && b.x, a.y && b.y); + return not(bvec2(_98.x || b.x, _98.y || b.y)); +} + +bvec3 and(bvec3 a, bvec3 b) +{ + return bvec3(a.x && b.x, a.y && b.y, a.z && b.z); +} + +bvec4 and(bvec4 a, bvec4 b) +{ + return bvec4(a.x && b.x, a.y && b.y, a.z && b.z, a.w && b.w); +} + +void main() +{ + bool param = isinf(s0.a); + bool param_1 = isnan(s1.a); + bool b0 = and(param, param_1); + bvec2 param_2 = isinf(s0.b); + bvec2 param_3 = isnan(s1.b); + bvec2 b1 = and(param_2, param_3); + bvec3 param_4 = isinf(s0.c); + bvec3 param_5 = isnan(s1.c); + bvec3 b2 = and(param_4, param_5); + bvec4 param_6 = isinf(s0.d); + bvec4 param_7 = isnan(s1.d); + bvec4 b3 = and(param_6, param_7); +} + diff --git a/reference/shaders/asm/comp/multiple-entry.asm.comp b/reference/shaders/asm/comp/multiple-entry.asm.comp new file mode 100644 index 0000000000..6418464f19 --- /dev/null +++ b/reference/shaders/asm/comp/multiple-entry.asm.comp @@ -0,0 +1,27 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) restrict buffer _6_8 +{ + ivec4 _m0; + uvec4 _m1; +} _8; + +layout(binding = 1, std430) restrict buffer _7_9 +{ + uvec4 _m0; + ivec4 _m1; +} _9; + +void main() +{ + _9._m0 = _8._m1 + uvec4(_8._m0); + _9._m0 = uvec4(_8._m0) + _8._m1; + _9._m0 = _8._m1 + _8._m1; + _9._m0 = uvec4(_8._m0 + _8._m0); + _9._m1 = ivec4(_8._m1 + _8._m1); + _9._m1 = _8._m0 + _8._m0; + _9._m1 = ivec4(_8._m1) + _8._m0; + _9._m1 = _8._m0 + ivec4(_8._m1); +} + diff --git a/reference/shaders/asm/comp/name-alias.asm.invalid.comp b/reference/shaders/asm/comp/name-alias.asm.invalid.comp new file mode 100644 index 0000000000..870b1df98d --- /dev/null +++ b/reference/shaders/asm/comp/name-alias.asm.invalid.comp @@ -0,0 +1,37 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct alias +{ + vec3 alias[100]; +}; + +struct alias_1 +{ + vec4 alias; + vec2 alias_1[10]; + alias alias_2[2]; +}; + +struct alias_2 +{ + vec4 alias; + alias_1 alias_1; +}; + +layout(binding = 0, std430) buffer alias_3 +{ + alias_2 alias; +} alias_4; + +layout(binding = 1, std140) buffer alias_5 +{ + alias_2 alias; +} alias_6; + +void main() +{ + alias_2 alias_7 = alias_4.alias; + alias_6.alias = alias_7; +} + diff --git a/reference/shaders/asm/comp/quantize.asm.comp b/reference/shaders/asm/comp/quantize.asm.comp new file mode 100644 index 0000000000..c089213800 --- /dev/null +++ b/reference/shaders/asm/comp/quantize.asm.comp @@ -0,0 +1,19 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) buffer SSBO0 +{ + float scalar; + vec2 vec2_val; + vec3 vec3_val; + vec4 vec4_val; +} _4; + +void main() +{ + _4.scalar = unpackHalf2x16(packHalf2x16(vec2(_4.scalar))).x; + _4.vec2_val = unpackHalf2x16(packHalf2x16(_4.vec2_val)); + _4.vec3_val = vec3(unpackHalf2x16(packHalf2x16(_4.vec3_val.xy)), unpackHalf2x16(packHalf2x16(_4.vec3_val.zz)).x); + _4.vec4_val = vec4(unpackHalf2x16(packHalf2x16(_4.vec4_val.xy)), unpackHalf2x16(packHalf2x16(_4.vec4_val.zw))); +} + diff --git a/reference/shaders/asm/comp/specialization-constant-workgroup.asm.comp b/reference/shaders/asm/comp/specialization-constant-workgroup.asm.comp new file mode 100644 index 0000000000..1b2285a8da --- /dev/null +++ b/reference/shaders/asm/comp/specialization-constant-workgroup.asm.comp @@ -0,0 +1,13 @@ +#version 310 es +layout(local_size_x = 9, local_size_y = 20, local_size_z = 4) in; + +layout(binding = 0, std430) buffer SSBO +{ + float a; +} _4; + +void main() +{ + _4.a += 1.0; +} + diff --git a/reference/shaders/asm/comp/storage-buffer-basic.asm.comp b/reference/shaders/asm/comp/storage-buffer-basic.asm.comp new file mode 100644 index 0000000000..a2210eb169 --- /dev/null +++ b/reference/shaders/asm/comp/storage-buffer-basic.asm.comp @@ -0,0 +1,20 @@ +#version 450 +layout(local_size_x = 1, local_size_y = 2, local_size_z = 3) in; + +layout(binding = 0, std430) buffer _6_8 +{ + float _m0[]; +} _8; + +layout(binding = 1, std430) buffer _6_9 +{ + float _m0[]; +} _9; + +uvec3 _22 = gl_WorkGroupSize; + +void main() +{ + _8._m0[gl_WorkGroupID.x] = _9._m0[gl_WorkGroupID.x] + _8._m0[gl_WorkGroupID.x]; +} + diff --git a/reference/shaders/asm/frag/composite-construct-struct-no-swizzle.asm.frag b/reference/shaders/asm/frag/composite-construct-struct-no-swizzle.asm.frag new file mode 100644 index 0000000000..c64818d2bf --- /dev/null +++ b/reference/shaders/asm/frag/composite-construct-struct-no-swizzle.asm.frag @@ -0,0 +1,19 @@ +#version 310 es +precision mediump float; +precision highp int; + +struct SwizzleTest +{ + float a; + float b; +}; + +layout(location = 0) in vec2 foo; +layout(location = 0) out float FooOut; + +void main() +{ + SwizzleTest _22 = SwizzleTest(foo.x, foo.y); + FooOut = _22.a + _22.b; +} + diff --git a/reference/shaders/asm/frag/default-member-names.asm.frag b/reference/shaders/asm/frag/default-member-names.asm.frag new file mode 100644 index 0000000000..57d4536c9b --- /dev/null +++ b/reference/shaders/asm/frag/default-member-names.asm.frag @@ -0,0 +1,32 @@ +#version 450 + +struct _9 +{ + float _m0; +}; + +struct _10 +{ + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + _9 _m12; +}; + +layout(location = 0) out vec4 _3; + +void main() +{ + _10 _21; + _3 = vec4(_21._m0, _21._m1, _21._m2, _21._m3); +} + diff --git a/reference/shaders/asm/frag/hlsl-sample-cmp-level-zero-cube.asm.frag b/reference/shaders/asm/frag/hlsl-sample-cmp-level-zero-cube.asm.frag new file mode 100644 index 0000000000..3585285eb6 --- /dev/null +++ b/reference/shaders/asm/frag/hlsl-sample-cmp-level-zero-cube.asm.frag @@ -0,0 +1,17 @@ +#version 450 + +uniform samplerCubeShadow SPIRV_Cross_CombinedpointLightShadowMapshadowSamplerPCF; + +layout(location = 0) out float _entryPointOutput; + +float _main() +{ + vec4 _33 = vec4(vec3(0.100000001490116119384765625), 0.5); + return textureGrad(SPIRV_Cross_CombinedpointLightShadowMapshadowSamplerPCF, vec4(_33.xyz, _33.w), vec3(0.0), vec3(0.0)); +} + +void main() +{ + _entryPointOutput = _main(); +} + diff --git a/reference/shaders/asm/frag/hlsl-sample-cmp-level-zero.asm.frag b/reference/shaders/asm/frag/hlsl-sample-cmp-level-zero.asm.frag new file mode 100644 index 0000000000..63856ddd46 --- /dev/null +++ b/reference/shaders/asm/frag/hlsl-sample-cmp-level-zero.asm.frag @@ -0,0 +1,27 @@ +#version 450 + +uniform sampler2DArrayShadow SPIRV_Cross_CombinedShadowMapShadowSamplerPCF; + +layout(location = 0) in vec2 texCoords; +layout(location = 1) in float cascadeIndex; +layout(location = 2) in float fragDepth; +layout(location = 0) out vec4 _entryPointOutput; + +vec4 _main(vec2 texCoords_1, float cascadeIndex_1, float fragDepth_1) +{ + vec4 _60 = vec4(vec3(texCoords_1, cascadeIndex_1), fragDepth_1); + float c = textureGrad(SPIRV_Cross_CombinedShadowMapShadowSamplerPCF, vec4(_60.xyz, _60.w), vec2(0.0), vec2(0.0)); + return vec4(c, c, c, c); +} + +void main() +{ + vec2 texCoords_1 = texCoords; + float cascadeIndex_1 = cascadeIndex; + float fragDepth_1 = fragDepth; + vec2 param = texCoords_1; + float param_1 = cascadeIndex_1; + float param_2 = fragDepth_1; + _entryPointOutput = _main(param, param_1, param_2); +} + diff --git a/reference/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag b/reference/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag new file mode 100644 index 0000000000..98116cfdc7 --- /dev/null +++ b/reference/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag @@ -0,0 +1,227 @@ +#version 450 + +struct VertexOutput +{ + vec4 HPosition; + vec4 Uv_EdgeDistance1; + vec4 UvStuds_EdgeDistance2; + vec4 Color; + vec4 LightPosition_Fog; + vec4 View_Depth; + vec4 Normal_SpecPower; + vec3 Tangent; + vec4 PosLightSpace_Reflectance; + float studIndex; +}; + +struct Surface +{ + vec3 albedo; + vec3 normal; + float specular; + float gloss; + float reflectance; + float opacity; +}; + +struct SurfaceInput +{ + vec4 Color; + vec2 Uv; + vec2 UvStuds; +}; + +struct Globals +{ + mat4 ViewProjection; + vec4 ViewRight; + vec4 ViewUp; + vec4 ViewDir; + vec3 CameraPosition; + vec3 AmbientColor; + vec3 Lamp0Color; + vec3 Lamp0Dir; + vec3 Lamp1Color; + vec4 FogParams; + vec3 FogColor; + vec4 LightBorder; + vec4 LightConfig0; + vec4 LightConfig1; + vec4 LightConfig2; + vec4 LightConfig3; + vec4 RefractionBias_FadeDistance_GlowFactor; + vec4 OutlineBrightness_ShadowInfo; + vec4 ShadowMatrix0; + vec4 ShadowMatrix1; + vec4 ShadowMatrix2; +}; + +struct Params +{ + vec4 LqmatFarTilingFactor; +}; + +layout(binding = 0, std140) uniform CB0 +{ + Globals CB0; +} _19; + +uniform sampler2D SPIRV_Cross_CombinedDiffuseMapTextureDiffuseMapSampler; +uniform sampler2D SPIRV_Cross_CombinedNormalMapTextureNormalMapSampler; +uniform sampler2D SPIRV_Cross_CombinedNormalDetailMapTextureNormalDetailMapSampler; +uniform sampler2D SPIRV_Cross_CombinedStudsMapTextureStudsMapSampler; +uniform sampler2D SPIRV_Cross_CombinedSpecularMapTextureSpecularMapSampler; +uniform sampler3D SPIRV_Cross_CombinedLightMapTextureLightMapSampler; +uniform sampler2D SPIRV_Cross_CombinedShadowMapTextureShadowMapSampler; +uniform samplerCube SPIRV_Cross_CombinedEnvironmentMapTextureEnvironmentMapSampler; + +layout(location = 0) in vec4 IN_Uv_EdgeDistance1; +layout(location = 1) in vec4 IN_UvStuds_EdgeDistance2; +layout(location = 2) in vec4 IN_Color; +layout(location = 3) in vec4 IN_LightPosition_Fog; +layout(location = 4) in vec4 IN_View_Depth; +layout(location = 5) in vec4 IN_Normal_SpecPower; +layout(location = 6) in vec3 IN_Tangent; +layout(location = 7) in vec4 IN_PosLightSpace_Reflectance; +layout(location = 8) in float IN_studIndex; +layout(location = 0) out vec4 _entryPointOutput; + +VertexOutput _121; +SurfaceInput _122; +vec2 _123; +vec4 _124; +Surface _125; +vec4 _192; +vec4 _219; +vec4 _297; + +void main() +{ + VertexOutput _128 = _121; + _128.HPosition = gl_FragCoord; + VertexOutput _130 = _128; + _130.Uv_EdgeDistance1 = IN_Uv_EdgeDistance1; + VertexOutput _132 = _130; + _132.UvStuds_EdgeDistance2 = IN_UvStuds_EdgeDistance2; + VertexOutput _134 = _132; + _134.Color = IN_Color; + VertexOutput _136 = _134; + _136.LightPosition_Fog = IN_LightPosition_Fog; + VertexOutput _138 = _136; + _138.View_Depth = IN_View_Depth; + VertexOutput _140 = _138; + _140.Normal_SpecPower = IN_Normal_SpecPower; + VertexOutput _142 = _140; + _142.Tangent = IN_Tangent; + VertexOutput _144 = _142; + _144.PosLightSpace_Reflectance = IN_PosLightSpace_Reflectance; + VertexOutput _146 = _144; + _146.studIndex = IN_studIndex; + SurfaceInput _147 = _122; + _147.Color = IN_Color; + SurfaceInput _149 = _147; + _149.Uv = IN_Uv_EdgeDistance1.xy; + SurfaceInput _151 = _149; + _151.UvStuds = IN_UvStuds_EdgeDistance2.xy; + SurfaceInput _156 = _151; + _156.UvStuds.y = (fract(_151.UvStuds.y) + IN_studIndex) * 0.25; + float _163 = _146.View_Depth.w * _19.CB0.RefractionBias_FadeDistance_GlowFactor.y; + float _165 = clamp(1.0 - _163, 0.0, 1.0); + vec2 _166 = IN_Uv_EdgeDistance1.xy * 1.0; + bool _173; + vec4 _193; + do + { + _173 = 0.0 == 0.0; + if (_173) + { + _193 = texture(SPIRV_Cross_CombinedDiffuseMapTextureDiffuseMapSampler, _166); + break; + } + else + { + float _180 = 1.0 / (1.0 - 0.0); + _193 = mix(texture(SPIRV_Cross_CombinedDiffuseMapTextureDiffuseMapSampler, _166 * 0.25), texture(SPIRV_Cross_CombinedDiffuseMapTextureDiffuseMapSampler, _166), vec4(clamp((clamp(1.0 - (_146.View_Depth.w * 0.00333332992158830165863037109375), 0.0, 1.0) * _180) - (0.0 * _180), 0.0, 1.0))); + break; + } + _193 = _192; + break; + } while (false); + vec4 _220; + do + { + if (_173) + { + _220 = texture(SPIRV_Cross_CombinedNormalMapTextureNormalMapSampler, _166); + break; + } + else + { + float _207 = 1.0 / (1.0 - 0.0); + _220 = mix(texture(SPIRV_Cross_CombinedNormalMapTextureNormalMapSampler, _166 * 0.25), texture(SPIRV_Cross_CombinedNormalMapTextureNormalMapSampler, _166), vec4(clamp((_165 * _207) - (0.0 * _207), 0.0, 1.0))); + break; + } + _220 = _219; + break; + } while (false); + vec2 _223 = vec2(1.0); + vec2 _224 = (_220.wy * 2.0) - _223; + vec3 _232 = vec3(_224, sqrt(clamp(1.0 + dot(-_224, _224), 0.0, 1.0))); + vec2 _240 = (texture(SPIRV_Cross_CombinedNormalDetailMapTextureNormalDetailMapSampler, _166 * 0.0).wy * 2.0) - _223; + vec2 _252 = _232.xy + (vec3(_240, sqrt(clamp(1.0 + dot(-_240, _240), 0.0, 1.0))).xy * 0.0); + vec3 _253 = vec3(_252.x, _252.y, _232.z); + vec2 _255 = _253.xy * _165; + vec3 _256 = vec3(_255.x, _255.y, _253.z); + vec3 _271 = ((IN_Color.xyz * (_193 * 1.0).xyz) * (1.0 + (_256.x * 0.300000011920928955078125))) * (texture(SPIRV_Cross_CombinedStudsMapTextureStudsMapSampler, _156.UvStuds).x * 2.0); + vec4 _298; + do + { + if (0.75 == 0.0) + { + _298 = texture(SPIRV_Cross_CombinedSpecularMapTextureSpecularMapSampler, _166); + break; + } + else + { + float _285 = 1.0 / (1.0 - 0.75); + _298 = mix(texture(SPIRV_Cross_CombinedSpecularMapTextureSpecularMapSampler, _166 * 0.25), texture(SPIRV_Cross_CombinedSpecularMapTextureSpecularMapSampler, _166), vec4(clamp((_165 * _285) - (0.75 * _285), 0.0, 1.0))); + break; + } + _298 = _297; + break; + } while (false); + vec2 _303 = mix(vec2(0.800000011920928955078125, 120.0), (_298.xy * vec2(2.0, 256.0)) + vec2(0.0, 0.00999999977648258209228515625), vec2(_165)); + Surface _304 = _125; + _304.albedo = _271; + Surface _305 = _304; + _305.normal = _256; + float _306 = _303.x; + Surface _307 = _305; + _307.specular = _306; + float _308 = _303.y; + Surface _309 = _307; + _309.gloss = _308; + float _312 = (_298.xy.y * _165) * 0.0; + Surface _313 = _309; + _313.reflectance = _312; + vec4 _318 = vec4(_271, _146.Color.w); + vec3 _329 = normalize(((IN_Tangent * _313.normal.x) + (cross(IN_Normal_SpecPower.xyz, IN_Tangent) * _313.normal.y)) + (IN_Normal_SpecPower.xyz * _313.normal.z)); + vec3 _332 = -_19.CB0.Lamp0Dir; + float _333 = dot(_329, _332); + float _357 = clamp(dot(step(_19.CB0.LightConfig3.xyz, abs(IN_LightPosition_Fog.xyz - _19.CB0.LightConfig2.xyz)), vec3(1.0)), 0.0, 1.0); + vec4 _368 = mix(texture(SPIRV_Cross_CombinedLightMapTextureLightMapSampler, IN_LightPosition_Fog.xyz.yzx - (IN_LightPosition_Fog.xyz.yzx * _357)), _19.CB0.LightBorder, vec4(_357)); + vec2 _376 = texture(SPIRV_Cross_CombinedShadowMapTextureShadowMapSampler, IN_PosLightSpace_Reflectance.xyz.xy).xy; + float _392 = (1.0 - (((step(_376.x, IN_PosLightSpace_Reflectance.xyz.z) * clamp(9.0 - (20.0 * abs(IN_PosLightSpace_Reflectance.xyz.z - 0.5)), 0.0, 1.0)) * _376.y) * _19.CB0.OutlineBrightness_ShadowInfo.w)) * _368.w; + vec3 _403 = mix(_318.xyz, texture(SPIRV_Cross_CombinedEnvironmentMapTextureEnvironmentMapSampler, reflect(-IN_View_Depth.xyz, _329)).xyz, vec3(_312)); + vec4 _404 = vec4(_403.x, _403.y, _403.z, _318.w); + vec3 _422 = (((_19.CB0.AmbientColor + (((_19.CB0.Lamp0Color * clamp(_333, 0.0, 1.0)) + (_19.CB0.Lamp1Color * max(-_333, 0.0))) * _392)) + _368.xyz) * _404.xyz) + (_19.CB0.Lamp0Color * (((step(0.0, _333) * _306) * _392) * pow(clamp(dot(_329, normalize(_332 + normalize(IN_View_Depth.xyz))), 0.0, 1.0), _308))); + vec4 _425 = vec4(_422.x, _422.y, _422.z, _124.w); + _425.w = _404.w; + vec2 _435 = min(IN_Uv_EdgeDistance1.wz, IN_UvStuds_EdgeDistance2.wz); + float _439 = min(_435.x, _435.y) / _163; + vec3 _445 = _425.xyz * clamp((clamp((_163 * _19.CB0.OutlineBrightness_ShadowInfo.x) + _19.CB0.OutlineBrightness_ShadowInfo.y, 0.0, 1.0) * (1.5 - _439)) + _439, 0.0, 1.0); + vec4 _446 = vec4(_445.x, _445.y, _445.z, _425.w); + vec3 _453 = mix(_19.CB0.FogColor, _446.xyz, vec3(clamp(_146.LightPosition_Fog.w, 0.0, 1.0))); + _entryPointOutput = vec4(_453.x, _453.y, _453.z, _446.w); +} + diff --git a/reference/shaders/asm/frag/invalidation.asm.frag b/reference/shaders/asm/frag/invalidation.asm.frag new file mode 100644 index 0000000000..db1181804c --- /dev/null +++ b/reference/shaders/asm/frag/invalidation.asm.frag @@ -0,0 +1,15 @@ +#version 450 + +layout(location = 0) in float v0; +layout(location = 1) in float v1; +layout(location = 0) out float FragColor; + +void main() +{ + float a = v0; + float b = v1; + float _17 = a; + a = v1; + FragColor = (_17 + b) * b; +} + diff --git a/reference/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag b/reference/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag new file mode 100644 index 0000000000..e1edccff69 --- /dev/null +++ b/reference/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag @@ -0,0 +1,48 @@ +#version 450 + +layout(binding = 0, std140) uniform Foo +{ + layout(row_major) mat4 lightVP[64]; + uint shadowCascadesNum; + int test; +} _11; + +layout(location = 0) in vec3 fragWorld; +layout(location = 0) out int _entryPointOutput; + +mat4 GetClip2TexMatrix() +{ + if (_11.test == 0) + { + return mat4(vec4(0.5, 0.0, 0.0, 0.0), vec4(0.0, 0.5, 0.0, 0.0), vec4(0.0, 0.0, 0.5, 0.0), vec4(0.0, 0.0, 0.0, 1.0)); + } + return mat4(vec4(1.0, 0.0, 0.0, 0.0), vec4(0.0, 1.0, 0.0, 0.0), vec4(0.0, 0.0, 1.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0)); +} + +int GetCascade(vec3 fragWorldPosition) +{ + for (uint cascadeIndex = 0u; cascadeIndex < _11.shadowCascadesNum; cascadeIndex++) + { + mat4 worldToShadowMap = GetClip2TexMatrix() * _11.lightVP[cascadeIndex]; + vec4 fragShadowMapPos = worldToShadowMap * vec4(fragWorldPosition, 1.0); + if ((((fragShadowMapPos.z >= 0.0) && (fragShadowMapPos.z <= 1.0)) && (max(fragShadowMapPos.x, fragShadowMapPos.y) <= 1.0)) && (min(fragShadowMapPos.x, fragShadowMapPos.y) >= 0.0)) + { + return int(cascadeIndex); + } + } + return -1; +} + +int _main(vec3 fragWorld_1) +{ + vec3 param = fragWorld_1; + return GetCascade(param); +} + +void main() +{ + vec3 fragWorld_1 = fragWorld; + vec3 param = fragWorld_1; + _entryPointOutput = _main(param); +} + diff --git a/reference/shaders/asm/frag/loop-header-to-continue.asm.frag b/reference/shaders/asm/frag/loop-header-to-continue.asm.frag new file mode 100644 index 0000000000..f3a6b4eceb --- /dev/null +++ b/reference/shaders/asm/frag/loop-header-to-continue.asm.frag @@ -0,0 +1,39 @@ +#version 450 + +struct Params +{ + vec4 TextureSize; + vec4 Params1; + vec4 Params2; + vec4 Params3; + vec4 Params4; + vec4 Bloom; +}; + +layout(binding = 1, std140) uniform CB1 +{ + Params CB1; +} _8; + +uniform sampler2D SPIRV_Cross_CombinedmapTexturemapSampler; + +layout(location = 0) in vec2 IN_uv; +layout(location = 0) out vec4 _entryPointOutput; + +void main() +{ + vec4 _49 = texture(SPIRV_Cross_CombinedmapTexturemapSampler, IN_uv); + float _50 = _49.y; + float _55; + float _58; + _55 = 0.0; + _58 = 0.0; + float _64; + vec4 _72; + float _78; + for (int _60 = -3; _60 <= 3; _64 = float(_60), _72 = texture(SPIRV_Cross_CombinedmapTexturemapSampler, IN_uv + (vec2(0.0, _8.CB1.TextureSize.w) * _64)), _78 = exp(((-_64) * _64) * 0.2222220003604888916015625) * float(abs(_72.y - _50) < clamp((_50 * 80.0) * 0.0007999999797903001308441162109375, 7.999999797903001308441162109375e-05, 0.008000000379979610443115234375)), _55 += (_72.x * _78), _58 += _78, _60++) + { + } + _entryPointOutput = vec4(_55 / _58, _50, 0.0, 1.0); +} + diff --git a/reference/shaders/asm/frag/multi-for-loop-init.asm.frag b/reference/shaders/asm/frag/multi-for-loop-init.asm.frag new file mode 100644 index 0000000000..b5f30a2471 --- /dev/null +++ b/reference/shaders/asm/frag/multi-for-loop-init.asm.frag @@ -0,0 +1,19 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(location = 0) out vec4 FragColor; +layout(location = 0) flat in mediump int counter; + +void main() +{ + FragColor = vec4(0.0); + mediump int i = 0; + mediump uint j = 1u; + for (; (i < 10) && (int(j) < int(20u)); i += counter, j += uint(counter)) + { + FragColor += vec4(float(i)); + FragColor += vec4(float(j)); + } +} + diff --git a/reference/shaders/asm/frag/op-constant-null.asm.frag b/reference/shaders/asm/frag/op-constant-null.asm.frag new file mode 100644 index 0000000000..c4ae981f64 --- /dev/null +++ b/reference/shaders/asm/frag/op-constant-null.asm.frag @@ -0,0 +1,22 @@ +#version 310 es +precision mediump float; +precision highp int; + +struct D +{ + vec4 a; + float b; +}; + +layout(location = 0) out float FragColor; + +void main() +{ + float a = 0.0; + vec4 b = vec4(0.0); + mat2x3 c = mat2x3(vec3(0.0), vec3(0.0)); + D d = D(vec4(0.0), 0.0); + vec4 e[4] = vec4[](vec4(0.0), vec4(0.0), vec4(0.0), vec4(0.0)); + FragColor = a; +} + diff --git a/reference/shaders/asm/frag/phi-loop-variable.asm.frag b/reference/shaders/asm/frag/phi-loop-variable.asm.frag new file mode 100644 index 0000000000..786ac74de5 --- /dev/null +++ b/reference/shaders/asm/frag/phi-loop-variable.asm.frag @@ -0,0 +1,9 @@ +#version 450 + +void main() +{ + for (int _22 = 35; _22 >= 0; _22--) + { + } +} + diff --git a/reference/shaders/asm/frag/sampler-buffer-without-sampler.asm.frag b/reference/shaders/asm/frag/sampler-buffer-without-sampler.asm.frag new file mode 100644 index 0000000000..a4cf078308 --- /dev/null +++ b/reference/shaders/asm/frag/sampler-buffer-without-sampler.asm.frag @@ -0,0 +1,20 @@ +#version 450 + +layout(rgba32f) uniform writeonly imageBuffer RWTex; +uniform samplerBuffer Tex; + +layout(location = 0) out vec4 _entryPointOutput; + +vec4 _main() +{ + vec4 storeTemp = vec4(1.0, 2.0, 3.0, 4.0); + imageStore(RWTex, 20, storeTemp); + return texelFetch(Tex, 10); +} + +void main() +{ + vec4 _28 = _main(); + _entryPointOutput = _28; +} + diff --git a/reference/shaders/asm/frag/struct-composite-extract-swizzle.asm.frag b/reference/shaders/asm/frag/struct-composite-extract-swizzle.asm.frag new file mode 100644 index 0000000000..b2473f4d03 --- /dev/null +++ b/reference/shaders/asm/frag/struct-composite-extract-swizzle.asm.frag @@ -0,0 +1,21 @@ +#version 310 es +precision mediump float; +precision highp int; + +struct Foo +{ + float var1; + float var2; +}; + +layout(binding = 0) uniform mediump sampler2D uSampler; + +layout(location = 0) out vec4 FragColor; + +Foo _22; + +void main() +{ + FragColor = texture(uSampler, vec2(_22.var1, _22.var2)); +} + diff --git a/reference/shaders/asm/frag/temporary-phi-hoisting.asm.frag b/reference/shaders/asm/frag/temporary-phi-hoisting.asm.frag new file mode 100644 index 0000000000..3917594d98 --- /dev/null +++ b/reference/shaders/asm/frag/temporary-phi-hoisting.asm.frag @@ -0,0 +1,26 @@ +#version 450 + +struct MyStruct +{ + vec4 color; +}; + +layout(std140) uniform MyStruct_CB +{ + MyStruct g_MyStruct[4]; +} _6; + +layout(location = 0) out vec4 _entryPointOutput; + +void main() +{ + vec3 _28; + _28 = vec3(0.0); + vec3 _29; + for (int _31 = 0; _31 < 4; _28 = _29, _31++) + { + _29 = _28 + _6.g_MyStruct[_31].color.xyz; + } + _entryPointOutput = vec4(_28, 1.0); +} + diff --git a/reference/shaders/asm/frag/undef-variable-store.asm.frag b/reference/shaders/asm/frag/undef-variable-store.asm.frag new file mode 100644 index 0000000000..26ad568ad0 --- /dev/null +++ b/reference/shaders/asm/frag/undef-variable-store.asm.frag @@ -0,0 +1,29 @@ +#version 450 + +layout(location = 0) out vec4 _entryPointOutput; + +vec4 _38; +vec4 _47; + +void main() +{ + vec4 _27; + do + { + vec2 _26 = vec2(0.0); + if (_26.x != 0.0) + { + _27 = vec4(1.0, 0.0, 0.0, 1.0); + break; + } + else + { + _27 = vec4(1.0, 1.0, 0.0, 1.0); + break; + } + _27 = _38; + break; + } while (false); + _entryPointOutput = _27; +} + diff --git a/reference/shaders/asm/frag/unreachable.asm.frag b/reference/shaders/asm/frag/unreachable.asm.frag new file mode 100644 index 0000000000..8bc88b9f0a --- /dev/null +++ b/reference/shaders/asm/frag/unreachable.asm.frag @@ -0,0 +1,28 @@ +#version 450 + +layout(location = 0) flat in int counter; +layout(location = 0) out vec4 FragColor; + +vec4 _21; + +void main() +{ + vec4 _24; + _24 = _21; + vec4 _33; + for (;;) + { + if (counter == 10) + { + _33 = vec4(10.0); + break; + } + else + { + _33 = vec4(30.0); + break; + } + } + FragColor = _33; +} + diff --git a/reference/shaders/asm/frag/vector-shuffle-oom.asm.frag b/reference/shaders/asm/frag/vector-shuffle-oom.asm.frag new file mode 100644 index 0000000000..1c211caa6d --- /dev/null +++ b/reference/shaders/asm/frag/vector-shuffle-oom.asm.frag @@ -0,0 +1,316 @@ +#version 450 + +struct _28 +{ + vec4 _m0; +}; + +layout(binding = 0, std140) uniform _6_7 +{ + vec4 _m0; + float _m1; + vec4 _m2; +} _7; + +layout(binding = 2, std140) uniform _10_11 +{ + vec3 _m0; + vec3 _m1; + float _m2; + vec3 _m3; + float _m4; + vec3 _m5; + float _m6; + vec3 _m7; + float _m8; + vec3 _m9; + float _m10; + vec3 _m11; + float _m12; + vec2 _m13; + vec2 _m14; + vec3 _m15; + float _m16; + float _m17; + float _m18; + float _m19; + float _m20; + vec4 _m21; + vec4 _m22; + layout(row_major) mat4 _m23; + vec4 _m24; +} _11; + +layout(binding = 1, std140) uniform _18_19 +{ + layout(row_major) mat4 _m0; + layout(row_major) mat4 _m1; + layout(row_major) mat4 _m2; + layout(row_major) mat4 _m3; + vec4 _m4; + vec4 _m5; + float _m6; + float _m7; + float _m8; + float _m9; + vec3 _m10; + float _m11; + vec3 _m12; + float _m13; + vec3 _m14; + float _m15; + vec3 _m16; + float _m17; + float _m18; + float _m19; + vec2 _m20; + vec2 _m21; + vec2 _m22; + vec4 _m23; + vec2 _m24; + vec2 _m25; + vec2 _m26; + vec3 _m27; + float _m28; + float _m29; + float _m30; + float _m31; + float _m32; + vec2 _m33; + float _m34; + float _m35; + vec3 _m36; + layout(row_major) mat4 _m37[2]; + vec4 _m38[2]; +} _19; + +uniform sampler2D SPIRV_Cross_Combined; +uniform sampler2D SPIRV_Cross_Combined_1; +uniform sampler2D SPIRV_Cross_Combined_2; + +layout(location = 0) out vec4 _5; + +_28 _74; + +void main() +{ + _28 _77 = _74; + _77._m0 = vec4(0.0); + vec2 _82 = gl_FragCoord.xy * _19._m23.xy; + vec4 _88 = _7._m2 * _7._m0.xyxy; + vec2 _97 = clamp(_82 + (vec3(0.0, -2.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); + vec3 _109 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _97, 0.0).w * _7._m1, 0.0, 1.0); + vec4 _113 = textureLod(SPIRV_Cross_Combined_1, _97, 0.0); + vec3 _129; + if (_113.y > 0.0) + { + _129 = _109 + (textureLod(SPIRV_Cross_Combined_2, _97, 0.0).xyz * clamp(_113.y * _113.z, 0.0, 1.0)); + } + else + { + _129 = _109; + } + vec3 _133 = vec4(0.0).xyz + (_129 * 0.5); + vec4 _134 = vec4(_133.x, _133.y, _133.z, vec4(0.0).w); + _28 _135 = _77; + _135._m0 = _134; + vec2 _144 = clamp(_82 + (vec3(-1.0, -1.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); + vec3 _156 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _144, 0.0).w * _7._m1, 0.0, 1.0); + vec4 _160 = textureLod(SPIRV_Cross_Combined_1, _144, 0.0); + vec3 _176; + if (_160.y > 0.0) + { + _176 = _156 + (textureLod(SPIRV_Cross_Combined_2, _144, 0.0).xyz * clamp(_160.y * _160.z, 0.0, 1.0)); + } + else + { + _176 = _156; + } + vec3 _180 = _134.xyz + (_176 * 0.5); + vec4 _181 = vec4(_180.x, _180.y, _180.z, _134.w); + _28 _182 = _135; + _182._m0 = _181; + vec2 _191 = clamp(_82 + (vec3(0.0, -1.0, 0.75).xy * _7._m0.xy), _88.xy, _88.zw); + vec3 _203 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _191, 0.0).w * _7._m1, 0.0, 1.0); + vec4 _207 = textureLod(SPIRV_Cross_Combined_1, _191, 0.0); + vec3 _223; + if (_207.y > 0.0) + { + _223 = _203 + (textureLod(SPIRV_Cross_Combined_2, _191, 0.0).xyz * clamp(_207.y * _207.z, 0.0, 1.0)); + } + else + { + _223 = _203; + } + vec3 _227 = _181.xyz + (_223 * 0.75); + vec4 _228 = vec4(_227.x, _227.y, _227.z, _181.w); + _28 _229 = _182; + _229._m0 = _228; + vec2 _238 = clamp(_82 + (vec3(1.0, -1.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); + vec3 _250 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _238, 0.0).w * _7._m1, 0.0, 1.0); + vec4 _254 = textureLod(SPIRV_Cross_Combined_1, _238, 0.0); + vec3 _270; + if (_254.y > 0.0) + { + _270 = _250 + (textureLod(SPIRV_Cross_Combined_2, _238, 0.0).xyz * clamp(_254.y * _254.z, 0.0, 1.0)); + } + else + { + _270 = _250; + } + vec3 _274 = _228.xyz + (_270 * 0.5); + vec4 _275 = vec4(_274.x, _274.y, _274.z, _228.w); + _28 _276 = _229; + _276._m0 = _275; + vec2 _285 = clamp(_82 + (vec3(-2.0, 0.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); + vec3 _297 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _285, 0.0).w * _7._m1, 0.0, 1.0); + vec4 _301 = textureLod(SPIRV_Cross_Combined_1, _285, 0.0); + vec3 _317; + if (_301.y > 0.0) + { + _317 = _297 + (textureLod(SPIRV_Cross_Combined_2, _285, 0.0).xyz * clamp(_301.y * _301.z, 0.0, 1.0)); + } + else + { + _317 = _297; + } + vec3 _321 = _275.xyz + (_317 * 0.5); + vec4 _322 = vec4(_321.x, _321.y, _321.z, _275.w); + _28 _323 = _276; + _323._m0 = _322; + vec2 _332 = clamp(_82 + (vec3(-1.0, 0.0, 0.75).xy * _7._m0.xy), _88.xy, _88.zw); + vec3 _344 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _332, 0.0).w * _7._m1, 0.0, 1.0); + vec4 _348 = textureLod(SPIRV_Cross_Combined_1, _332, 0.0); + vec3 _364; + if (_348.y > 0.0) + { + _364 = _344 + (textureLod(SPIRV_Cross_Combined_2, _332, 0.0).xyz * clamp(_348.y * _348.z, 0.0, 1.0)); + } + else + { + _364 = _344; + } + vec3 _368 = _322.xyz + (_364 * 0.75); + vec4 _369 = vec4(_368.x, _368.y, _368.z, _322.w); + _28 _370 = _323; + _370._m0 = _369; + vec2 _379 = clamp(_82 + (vec3(0.0, 0.0, 1.0).xy * _7._m0.xy), _88.xy, _88.zw); + vec3 _391 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _379, 0.0).w * _7._m1, 0.0, 1.0); + vec4 _395 = textureLod(SPIRV_Cross_Combined_1, _379, 0.0); + vec3 _411; + if (_395.y > 0.0) + { + _411 = _391 + (textureLod(SPIRV_Cross_Combined_2, _379, 0.0).xyz * clamp(_395.y * _395.z, 0.0, 1.0)); + } + else + { + _411 = _391; + } + vec3 _415 = _369.xyz + (_411 * 1.0); + vec4 _416 = vec4(_415.x, _415.y, _415.z, _369.w); + _28 _417 = _370; + _417._m0 = _416; + vec2 _426 = clamp(_82 + (vec3(1.0, 0.0, 0.75).xy * _7._m0.xy), _88.xy, _88.zw); + vec3 _438 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _426, 0.0).w * _7._m1, 0.0, 1.0); + vec4 _442 = textureLod(SPIRV_Cross_Combined_1, _426, 0.0); + vec3 _458; + if (_442.y > 0.0) + { + _458 = _438 + (textureLod(SPIRV_Cross_Combined_2, _426, 0.0).xyz * clamp(_442.y * _442.z, 0.0, 1.0)); + } + else + { + _458 = _438; + } + vec3 _462 = _416.xyz + (_458 * 0.75); + vec4 _463 = vec4(_462.x, _462.y, _462.z, _416.w); + _28 _464 = _417; + _464._m0 = _463; + vec2 _473 = clamp(_82 + (vec3(2.0, 0.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); + vec3 _485 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _473, 0.0).w * _7._m1, 0.0, 1.0); + vec4 _489 = textureLod(SPIRV_Cross_Combined_1, _473, 0.0); + vec3 _505; + if (_489.y > 0.0) + { + _505 = _485 + (textureLod(SPIRV_Cross_Combined_2, _473, 0.0).xyz * clamp(_489.y * _489.z, 0.0, 1.0)); + } + else + { + _505 = _485; + } + vec3 _509 = _463.xyz + (_505 * 0.5); + vec4 _510 = vec4(_509.x, _509.y, _509.z, _463.w); + _28 _511 = _464; + _511._m0 = _510; + vec2 _520 = clamp(_82 + (vec3(-1.0, 1.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); + vec3 _532 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _520, 0.0).w * _7._m1, 0.0, 1.0); + vec4 _536 = textureLod(SPIRV_Cross_Combined_1, _520, 0.0); + vec3 _552; + if (_536.y > 0.0) + { + _552 = _532 + (textureLod(SPIRV_Cross_Combined_2, _520, 0.0).xyz * clamp(_536.y * _536.z, 0.0, 1.0)); + } + else + { + _552 = _532; + } + vec3 _556 = _510.xyz + (_552 * 0.5); + vec4 _557 = vec4(_556.x, _556.y, _556.z, _510.w); + _28 _558 = _511; + _558._m0 = _557; + vec2 _567 = clamp(_82 + (vec3(0.0, 1.0, 0.75).xy * _7._m0.xy), _88.xy, _88.zw); + vec3 _579 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _567, 0.0).w * _7._m1, 0.0, 1.0); + vec4 _583 = textureLod(SPIRV_Cross_Combined_1, _567, 0.0); + vec3 _599; + if (_583.y > 0.0) + { + _599 = _579 + (textureLod(SPIRV_Cross_Combined_2, _567, 0.0).xyz * clamp(_583.y * _583.z, 0.0, 1.0)); + } + else + { + _599 = _579; + } + vec3 _603 = _557.xyz + (_599 * 0.75); + vec4 _604 = vec4(_603.x, _603.y, _603.z, _557.w); + _28 _605 = _558; + _605._m0 = _604; + vec2 _614 = clamp(_82 + (vec3(1.0, 1.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); + vec3 _626 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _614, 0.0).w * _7._m1, 0.0, 1.0); + vec4 _630 = textureLod(SPIRV_Cross_Combined_1, _614, 0.0); + vec3 _646; + if (_630.y > 0.0) + { + _646 = _626 + (textureLod(SPIRV_Cross_Combined_2, _614, 0.0).xyz * clamp(_630.y * _630.z, 0.0, 1.0)); + } + else + { + _646 = _626; + } + vec3 _650 = _604.xyz + (_646 * 0.5); + vec4 _651 = vec4(_650.x, _650.y, _650.z, _604.w); + _28 _652 = _605; + _652._m0 = _651; + vec2 _661 = clamp(_82 + (vec3(0.0, 2.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); + vec3 _673 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _661, 0.0).w * _7._m1, 0.0, 1.0); + vec4 _677 = textureLod(SPIRV_Cross_Combined_1, _661, 0.0); + vec3 _693; + if (_677.y > 0.0) + { + _693 = _673 + (textureLod(SPIRV_Cross_Combined_2, _661, 0.0).xyz * clamp(_677.y * _677.z, 0.0, 1.0)); + } + else + { + _693 = _673; + } + vec3 _697 = _651.xyz + (_693 * 0.5); + vec4 _698 = vec4(_697.x, _697.y, _697.z, _651.w); + _28 _699 = _652; + _699._m0 = _698; + vec3 _702 = _698.xyz / vec3(((((((((((((0.0 + 0.5) + 0.5) + 0.75) + 0.5) + 0.5) + 0.75) + 1.0) + 0.75) + 0.5) + 0.5) + 0.75) + 0.5) + 0.5); + _28 _704 = _699; + _704._m0 = vec4(_702.x, _702.y, _702.z, _698.w); + _28 _705 = _704; + _705._m0.w = 1.0; + _5 = _705._m0; +} + diff --git a/reference/shaders/asm/tesc/tess-fixed-input-array-builtin-array.asm.tesc b/reference/shaders/asm/tesc/tess-fixed-input-array-builtin-array.asm.tesc new file mode 100644 index 0000000000..8cb7a4e64c --- /dev/null +++ b/reference/shaders/asm/tesc/tess-fixed-input-array-builtin-array.asm.tesc @@ -0,0 +1,79 @@ +#version 450 +layout(vertices = 3) out; + +struct VertexOutput +{ + vec4 pos; + vec2 uv; +}; + +struct HSOut +{ + vec4 pos; + vec2 uv; +}; + +struct HSConstantOut +{ + float EdgeTess[3]; + float InsideTess; +}; + +struct VertexOutput_1 +{ + vec2 uv; +}; + +struct HSOut_1 +{ + vec2 uv; +}; + +layout(location = 0) in VertexOutput_1 p[]; +layout(location = 0) out HSOut_1 _entryPointOutput[3]; + +HSOut _hs_main(VertexOutput p_1[3], uint i) +{ + HSOut _output; + _output.pos = p_1[i].pos; + _output.uv = p_1[i].uv; + return _output; +} + +HSConstantOut PatchHS(VertexOutput _patch[3]) +{ + HSConstantOut _output; + _output.EdgeTess[0] = (vec2(1.0) + _patch[0].uv).x; + _output.EdgeTess[1] = (vec2(1.0) + _patch[0].uv).x; + _output.EdgeTess[2] = (vec2(1.0) + _patch[0].uv).x; + _output.InsideTess = (vec2(1.0) + _patch[0].uv).x; + return _output; +} + +void main() +{ + VertexOutput p_1[3]; + p_1[0].pos = gl_in[0].gl_Position; + p_1[0].uv = p[0].uv; + p_1[1].pos = gl_in[1].gl_Position; + p_1[1].uv = p[1].uv; + p_1[2].pos = gl_in[2].gl_Position; + p_1[2].uv = p[2].uv; + uint i = gl_InvocationID; + VertexOutput param[3] = p_1; + uint param_1 = i; + HSOut flattenTemp = _hs_main(param, param_1); + gl_out[gl_InvocationID].gl_Position = flattenTemp.pos; + _entryPointOutput[gl_InvocationID].uv = flattenTemp.uv; + barrier(); + if (int(gl_InvocationID) == 0) + { + VertexOutput param_2[3] = p_1; + HSConstantOut _patchConstantResult = PatchHS(param_2); + gl_TessLevelOuter[0] = _patchConstantResult.EdgeTess[0]; + gl_TessLevelOuter[1] = _patchConstantResult.EdgeTess[1]; + gl_TessLevelOuter[2] = _patchConstantResult.EdgeTess[2]; + gl_TessLevelInner[0] = _patchConstantResult.InsideTess; + } +} + diff --git a/reference/shaders/asm/vert/empty-io.asm.vert b/reference/shaders/asm/vert/empty-io.asm.vert new file mode 100644 index 0000000000..e1a56d9d4c --- /dev/null +++ b/reference/shaders/asm/vert/empty-io.asm.vert @@ -0,0 +1,29 @@ +#version 450 + +struct VSInput +{ + vec4 position; +}; + +struct VSOutput +{ + vec4 position; +}; + +layout(location = 0) in vec4 position; + +VSOutput _main(VSInput _input) +{ + VSOutput _out; + _out.position = _input.position; + return _out; +} + +void main() +{ + VSInput _input; + _input.position = position; + VSInput param = _input; + gl_Position = _main(param).position; +} + diff --git a/reference/shaders/asm/vert/empty-struct-composite.asm.vert b/reference/shaders/asm/vert/empty-struct-composite.asm.vert new file mode 100644 index 0000000000..05ce10adfa --- /dev/null +++ b/reference/shaders/asm/vert/empty-struct-composite.asm.vert @@ -0,0 +1,6 @@ +#version 450 + +void main() +{ +} + diff --git a/reference/shaders/asm/vert/global-builtin.sso.asm.vert b/reference/shaders/asm/vert/global-builtin.sso.asm.vert new file mode 100644 index 0000000000..7578827019 --- /dev/null +++ b/reference/shaders/asm/vert/global-builtin.sso.asm.vert @@ -0,0 +1,35 @@ +#version 450 + +out gl_PerVertex +{ + vec4 gl_Position; +}; + +struct VSOut +{ + float a; + vec4 pos; +}; + +struct VSOut_1 +{ + float a; +}; + +layout(location = 0) out VSOut_1 _entryPointOutput; + +VSOut _main() +{ + VSOut vout; + vout.a = 40.0; + vout.pos = vec4(1.0); + return vout; +} + +void main() +{ + VSOut flattenTemp = _main(); + _entryPointOutput.a = flattenTemp.a; + gl_Position = flattenTemp.pos; +} + diff --git a/reference/shaders/comp/atomic.comp b/reference/shaders/comp/atomic.comp new file mode 100644 index 0000000000..89b1351c0c --- /dev/null +++ b/reference/shaders/comp/atomic.comp @@ -0,0 +1,49 @@ +#version 310 es +#extension GL_OES_shader_image_atomic : require +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 2, std430) buffer SSBO +{ + uint u32; + int i32; +} ssbo; + +layout(binding = 0, r32ui) uniform highp uimage2D uImage; +layout(binding = 1, r32i) uniform highp iimage2D iImage; + +void main() +{ + uint _19 = imageAtomicAdd(uImage, ivec2(1, 5), 1u); + uint _27 = imageAtomicAdd(uImage, ivec2(1, 5), 1u); + imageStore(iImage, ivec2(1, 6), ivec4(int(_27))); + uint _32 = imageAtomicOr(uImage, ivec2(1, 5), 1u); + uint _34 = imageAtomicXor(uImage, ivec2(1, 5), 1u); + uint _36 = imageAtomicAnd(uImage, ivec2(1, 5), 1u); + uint _38 = imageAtomicMin(uImage, ivec2(1, 5), 1u); + uint _40 = imageAtomicMax(uImage, ivec2(1, 5), 1u); + uint _44 = imageAtomicCompSwap(uImage, ivec2(1, 5), 10u, 2u); + int _47 = imageAtomicAdd(iImage, ivec2(1, 6), 1); + int _49 = imageAtomicOr(iImage, ivec2(1, 6), 1); + int _51 = imageAtomicXor(iImage, ivec2(1, 6), 1); + int _53 = imageAtomicAnd(iImage, ivec2(1, 6), 1); + int _55 = imageAtomicMin(iImage, ivec2(1, 6), 1); + int _57 = imageAtomicMax(iImage, ivec2(1, 6), 1); + int _61 = imageAtomicCompSwap(iImage, ivec2(1, 5), 10, 2); + uint _68 = atomicAdd(ssbo.u32, 1u); + uint _70 = atomicOr(ssbo.u32, 1u); + uint _72 = atomicXor(ssbo.u32, 1u); + uint _74 = atomicAnd(ssbo.u32, 1u); + uint _76 = atomicMin(ssbo.u32, 1u); + uint _78 = atomicMax(ssbo.u32, 1u); + uint _80 = atomicExchange(ssbo.u32, 1u); + uint _82 = atomicCompSwap(ssbo.u32, 10u, 2u); + int _85 = atomicAdd(ssbo.i32, 1); + int _87 = atomicOr(ssbo.i32, 1); + int _89 = atomicXor(ssbo.i32, 1); + int _91 = atomicAnd(ssbo.i32, 1); + int _93 = atomicMin(ssbo.i32, 1); + int _95 = atomicMax(ssbo.i32, 1); + int _97 = atomicExchange(ssbo.i32, 1); + int _99 = atomicCompSwap(ssbo.i32, 10, 2); +} + diff --git a/reference/shaders/comp/bake_gradient.comp b/reference/shaders/comp/bake_gradient.comp new file mode 100644 index 0000000000..7b0bb34c64 --- /dev/null +++ b/reference/shaders/comp/bake_gradient.comp @@ -0,0 +1,39 @@ +#version 310 es +layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in; + +layout(binding = 4, std140) uniform UBO +{ + vec4 uInvSize; + vec4 uScale; +} _46; + +layout(binding = 0) uniform mediump sampler2D uHeight; +layout(binding = 1) uniform mediump sampler2D uDisplacement; +layout(binding = 2, rgba16f) uniform writeonly mediump image2D iHeightDisplacement; +layout(binding = 3, rgba16f) uniform writeonly mediump image2D iGradJacobian; + +mediump float jacobian(mediump vec2 dDdx, mediump vec2 dDdy) +{ + return ((1.0 + dDdx.x) * (1.0 + dDdy.y)) - (dDdx.y * dDdy.x); +} + +void main() +{ + vec4 uv = (vec2(gl_GlobalInvocationID.xy) * _46.uInvSize.xy).xyxy + (_46.uInvSize * 0.5); + float h = textureLod(uHeight, uv.xy, 0.0).x; + float x0 = textureLodOffset(uHeight, uv.xy, 0.0, ivec2(-1, 0)).x; + float x1 = textureLodOffset(uHeight, uv.xy, 0.0, ivec2(1, 0)).x; + float y0 = textureLodOffset(uHeight, uv.xy, 0.0, ivec2(0, -1)).x; + float y1 = textureLodOffset(uHeight, uv.xy, 0.0, ivec2(0, 1)).x; + vec2 grad = (_46.uScale.xy * 0.5) * vec2(x1 - x0, y1 - y0); + vec2 displacement = textureLod(uDisplacement, uv.zw, 0.0).xy * 1.2000000476837158203125; + vec2 dDdx = (textureLodOffset(uDisplacement, uv.zw, 0.0, ivec2(1, 0)).xy - textureLodOffset(uDisplacement, uv.zw, 0.0, ivec2(-1, 0)).xy) * 0.60000002384185791015625; + vec2 dDdy = (textureLodOffset(uDisplacement, uv.zw, 0.0, ivec2(0, 1)).xy - textureLodOffset(uDisplacement, uv.zw, 0.0, ivec2(0, -1)).xy) * 0.60000002384185791015625; + vec2 param = dDdx * _46.uScale.z; + vec2 param_1 = dDdy * _46.uScale.z; + float j = jacobian(param, param_1); + displacement = vec2(0.0); + imageStore(iHeightDisplacement, ivec2(gl_GlobalInvocationID.xy), vec4(h, displacement, 0.0)); + imageStore(iGradJacobian, ivec2(gl_GlobalInvocationID.xy), vec4(grad, j, 0.0)); +} + diff --git a/reference/shaders/comp/barriers.comp b/reference/shaders/comp/barriers.comp new file mode 100644 index 0000000000..a1b975de83 --- /dev/null +++ b/reference/shaders/comp/barriers.comp @@ -0,0 +1,83 @@ +#version 310 es +layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in; + +void barrier_shared() +{ + memoryBarrierShared(); +} + +void full_barrier() +{ + memoryBarrier(); +} + +void image_barrier() +{ + memoryBarrierImage(); +} + +void buffer_barrier() +{ + memoryBarrierBuffer(); +} + +void group_barrier() +{ + groupMemoryBarrier(); +} + +void barrier_shared_exec() +{ + memoryBarrierShared(); + barrier(); +} + +void full_barrier_exec() +{ + memoryBarrier(); + memoryBarrierShared(); + barrier(); +} + +void image_barrier_exec() +{ + memoryBarrierImage(); + memoryBarrierShared(); + barrier(); +} + +void buffer_barrier_exec() +{ + memoryBarrierBuffer(); + memoryBarrierShared(); + barrier(); +} + +void group_barrier_exec() +{ + groupMemoryBarrier(); + memoryBarrierShared(); + barrier(); +} + +void exec_barrier() +{ + memoryBarrierShared(); + barrier(); +} + +void main() +{ + barrier_shared(); + full_barrier(); + image_barrier(); + buffer_barrier(); + group_barrier(); + barrier_shared_exec(); + full_barrier_exec(); + image_barrier_exec(); + buffer_barrier_exec(); + group_barrier_exec(); + exec_barrier(); +} + diff --git a/reference/shaders/comp/basic.comp b/reference/shaders/comp/basic.comp new file mode 100644 index 0000000000..1485089951 --- /dev/null +++ b/reference/shaders/comp/basic.comp @@ -0,0 +1,29 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) readonly buffer SSBO +{ + vec4 in_data[]; +} _23; + +layout(binding = 1, std430) writeonly buffer SSBO2 +{ + vec4 out_data[]; +} _45; + +layout(binding = 2, std430) buffer SSBO3 +{ + uint counter; +} _48; + +void main() +{ + uint ident = gl_GlobalInvocationID.x; + vec4 idata = _23.in_data[ident]; + if (dot(idata, vec4(1.0, 5.0, 6.0, 2.0)) > 8.19999980926513671875) + { + uint _52 = atomicAdd(_48.counter, 1u); + _45.out_data[_52] = idata; + } +} + diff --git a/reference/shaders/comp/bitfield.noopt.comp b/reference/shaders/comp/bitfield.noopt.comp new file mode 100644 index 0000000000..49bbddb0ab --- /dev/null +++ b/reference/shaders/comp/bitfield.noopt.comp @@ -0,0 +1,19 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +void main() +{ + int signed_value = 0; + uint unsigned_value = 0u; + int s = bitfieldExtract(signed_value, 5, 20); + uint u = bitfieldExtract(unsigned_value, 6, 21); + s = bitfieldInsert(s, 40, 5, 4); + u = bitfieldInsert(u, 60u, 5, 4); + u = bitfieldReverse(u); + s = bitfieldReverse(s); + int v0 = bitCount(u); + int v1 = bitCount(s); + int v2 = findMSB(u); + int v3 = findLSB(s); +} + diff --git a/reference/shaders/comp/casts.comp b/reference/shaders/comp/casts.comp new file mode 100644 index 0000000000..973668676a --- /dev/null +++ b/reference/shaders/comp/casts.comp @@ -0,0 +1,19 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 1, std430) buffer SSBO1 +{ + ivec4 outputs[]; +} _21; + +layout(binding = 0, std430) buffer SSBO0 +{ + ivec4 inputs[]; +} _27; + +void main() +{ + uint ident = gl_GlobalInvocationID.x; + _21.outputs[ident] = mix(ivec4(0), ivec4(1), notEqual((_27.inputs[ident] & ivec4(3)), ivec4(uvec4(0u)))); +} + diff --git a/reference/shaders/comp/cfg-preserve-parameter.comp b/reference/shaders/comp/cfg-preserve-parameter.comp new file mode 100644 index 0000000000..72bde44a90 --- /dev/null +++ b/reference/shaders/comp/cfg-preserve-parameter.comp @@ -0,0 +1,74 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +void out_test_0(int cond, out int i) +{ + if (cond == 0) + { + i = 40; + } + else + { + i = 60; + } +} + +void out_test_1(int cond, out int i) +{ + switch (cond) + { + case 40: + { + i = 40; + break; + } + default: + { + i = 70; + break; + } + } +} + +void inout_test_0(int cond, inout int i) +{ + if (cond == 0) + { + i = 40; + } +} + +void inout_test_1(int cond, inout int i) +{ + switch (cond) + { + case 40: + { + i = 40; + break; + } + } +} + +void main() +{ + int cond = 40; + int i = 50; + int param = cond; + int param_1 = i; + out_test_0(param, param_1); + i = param_1; + int param_2 = cond; + int param_3 = i; + out_test_1(param_2, param_3); + i = param_3; + int param_4 = cond; + int param_5 = i; + inout_test_0(param_4, param_5); + i = param_5; + int param_6 = cond; + int param_7 = i; + inout_test_1(param_6, param_7); + i = param_7; +} + diff --git a/reference/shaders/comp/cfg.comp b/reference/shaders/comp/cfg.comp new file mode 100644 index 0000000000..77ad312cda --- /dev/null +++ b/reference/shaders/comp/cfg.comp @@ -0,0 +1,81 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) buffer SSBO +{ + float data; +} _11; + +void test() +{ + if (_11.data != 0.0) + { + float tmp = 10.0; + _11.data = tmp; + } + else + { + float tmp_1 = 15.0; + _11.data = tmp_1; + } + if (_11.data != 0.0) + { + float e; + if (_11.data != 5.0) + { + if (_11.data != 6.0) + { + e = 10.0; + } + } + else + { + e = 20.0; + } + } + switch (int(_11.data)) + { + case 0: + { + float tmp_2 = 20.0; + _11.data = tmp_2; + break; + } + case 1: + { + float tmp_3 = 30.0; + _11.data = tmp_3; + break; + } + } + float f; + switch (int(_11.data)) + { + case 0: + { + f = 30.0; + break; + } + case 1: + { + f = 40.0; + break; + } + } + float h; + for (int i = 0; i < 20; i++, h += 10.0) + { + } + _11.data = h; + float m; + do + { + } while (m != 20.0); + _11.data = m; +} + +void main() +{ + test(); +} + diff --git a/reference/shaders/comp/coherent-block.comp b/reference/shaders/comp/coherent-block.comp new file mode 100644 index 0000000000..bfab6bbea8 --- /dev/null +++ b/reference/shaders/comp/coherent-block.comp @@ -0,0 +1,13 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 1, std430) coherent restrict writeonly buffer SSBO +{ + vec4 value; +} _10; + +void main() +{ + _10.value = vec4(20.0); +} + diff --git a/reference/shaders/comp/coherent-image.comp b/reference/shaders/comp/coherent-image.comp new file mode 100644 index 0000000000..b3992f242e --- /dev/null +++ b/reference/shaders/comp/coherent-image.comp @@ -0,0 +1,15 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 1, std430) coherent restrict writeonly buffer SSBO +{ + ivec4 value; +} _10; + +layout(binding = 3, r32i) uniform coherent restrict readonly mediump iimage2D uImage; + +void main() +{ + _10.value = imageLoad(uImage, ivec2(10)); +} + diff --git a/reference/shaders/comp/composite-construct.comp b/reference/shaders/comp/composite-construct.comp new file mode 100644 index 0000000000..91bb5348f5 --- /dev/null +++ b/reference/shaders/comp/composite-construct.comp @@ -0,0 +1,38 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct Composite +{ + vec4 a[2]; + vec4 b[2]; +}; + +layout(binding = 0, std430) buffer SSBO0 +{ + vec4 as[]; +} _41; + +layout(binding = 1, std430) buffer SSBO1 +{ + vec4 bs[]; +} _55; + +vec4 summe(vec4 values[3][2]) +{ + return ((values[0][0] + values[2][1]) + values[0][1]) + values[1][0]; +} + +void main() +{ + vec4 values[2] = vec4[](_41.as[gl_GlobalInvocationID.x], _55.bs[gl_GlobalInvocationID.x]); + vec4 const_values[2] = vec4[](vec4(10.0), vec4(30.0)); + vec4 copy_values[2] = const_values; + vec4 copy_values2[2] = values; + vec4 param[3][2] = vec4[][](values, copy_values, copy_values2); + _41.as[gl_GlobalInvocationID.x] = summe(param); + Composite c = Composite(values, copy_values); + float arrayofarray[2][3] = float[][](float[](1.0, 1.0, 1.0), float[](2.0, 2.0, 2.0)); + float b = 10.0; + float values_scalar[4] = float[](b, b, b, b); +} + diff --git a/reference/shaders/comp/culling.comp b/reference/shaders/comp/culling.comp new file mode 100644 index 0000000000..fd83bfcb5b --- /dev/null +++ b/reference/shaders/comp/culling.comp @@ -0,0 +1,29 @@ +#version 310 es +layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) readonly buffer SSBO +{ + float in_data[]; +} _22; + +layout(binding = 1, std430) writeonly buffer SSBO2 +{ + float out_data[]; +} _38; + +layout(binding = 2, std430) buffer SSBO3 +{ + uint count; +} _41; + +void main() +{ + uint ident = gl_GlobalInvocationID.x; + float idata = _22.in_data[ident]; + if (idata > 12.0) + { + uint _45 = atomicAdd(_41.count, 1u); + _38.out_data[_45] = idata; + } +} + diff --git a/reference/shaders/comp/defer-parens.comp b/reference/shaders/comp/defer-parens.comp new file mode 100644 index 0000000000..cf98529316 --- /dev/null +++ b/reference/shaders/comp/defer-parens.comp @@ -0,0 +1,21 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) buffer SSBO +{ + vec4 data; + int index; +} _13; + +void main() +{ + vec4 d = _13.data; + _13.data = vec4(d.x, d.yz + vec2(10.0), d.w); + _13.data = (d + d) + d; + _13.data = (d.yz + vec2(10.0)).xxyy; + float t = (d.yz + vec2(10.0)).y; + _13.data = vec4(t); + t = (d.zw + vec2(10.0))[_13.index]; + _13.data = vec4(t); +} + diff --git a/reference/shaders/comp/dowhile.comp b/reference/shaders/comp/dowhile.comp new file mode 100644 index 0000000000..e717961abd --- /dev/null +++ b/reference/shaders/comp/dowhile.comp @@ -0,0 +1,29 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) readonly buffer SSBO +{ + mat4 mvp; + vec4 in_data[]; +} _28; + +layout(binding = 1, std430) writeonly buffer SSBO2 +{ + vec4 out_data[]; +} _52; + +int i; + +void main() +{ + uint ident = gl_GlobalInvocationID.x; + i = 0; + vec4 idat = _28.in_data[ident]; + do + { + idat = _28.mvp * idat; + i++; + } while (i < 16); + _52.out_data[ident] = idat; +} + diff --git a/reference/shaders/comp/generate_height.comp b/reference/shaders/comp/generate_height.comp new file mode 100644 index 0000000000..30ec624cfb --- /dev/null +++ b/reference/shaders/comp/generate_height.comp @@ -0,0 +1,96 @@ +#version 310 es +layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) readonly buffer Distribution +{ + vec2 distribution[]; +} _136; + +layout(binding = 2, std140) uniform UBO +{ + vec4 uModTime; +} _165; + +layout(binding = 1, std430) writeonly buffer HeightmapFFT +{ + uint heights[]; +} _224; + +uvec2 workaround_mix(uvec2 a, uvec2 b, bvec2 sel) +{ + uint _83; + if (sel.x) + { + _83 = b.x; + } + else + { + _83 = a.x; + } + uint _93 = _83; + uint _94; + if (sel.y) + { + _94 = b.y; + } + else + { + _94 = a.y; + } + return uvec2(_93, _94); +} + +vec2 alias(vec2 i, vec2 N) +{ + return mix(i, i - N, greaterThan(i, N * 0.5)); +} + +vec2 cmul(vec2 a, vec2 b) +{ + vec2 r3 = a.yx; + vec2 r1 = b.xx; + vec2 R0 = a * r1; + vec2 r2 = b.yy; + vec2 R1 = r2 * r3; + return R0 + vec2(-R1.x, R1.y); +} + +uint pack2(vec2 v) +{ + return packHalf2x16(v); +} + +void generate_heightmap() +{ + uvec2 N = uvec2(64u, 1u) * gl_NumWorkGroups.xy; + uvec2 i = gl_GlobalInvocationID.xy; + uvec2 param = N - i; + uvec2 param_1 = uvec2(0u); + bvec2 param_2 = equal(i, uvec2(0u)); + uvec2 wi = workaround_mix(param, param_1, param_2); + vec2 a = _136.distribution[(i.y * N.x) + i.x]; + vec2 b = _136.distribution[(wi.y * N.x) + wi.x]; + vec2 param_3 = vec2(i); + vec2 param_4 = vec2(N); + vec2 k = _165.uModTime.xy * alias(param_3, param_4); + float k_len = length(k); + float w = sqrt(9.81000041961669921875 * k_len) * _165.uModTime.z; + float cw = cos(w); + float sw = sin(w); + vec2 param_5 = a; + vec2 param_6 = vec2(cw, sw); + a = cmul(param_5, param_6); + vec2 param_7 = b; + vec2 param_8 = vec2(cw, sw); + b = cmul(param_7, param_8); + b = vec2(b.x, -b.y); + vec2 res = a + b; + vec2 param_9 = res; + _224.heights[(i.y * N.x) + i.x] = pack2(param_9); +} + +void main() +{ + generate_heightmap(); +} + diff --git a/reference/shaders/comp/image.comp b/reference/shaders/comp/image.comp new file mode 100644 index 0000000000..b2bf0d65bb --- /dev/null +++ b/reference/shaders/comp/image.comp @@ -0,0 +1,12 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, rgba8) uniform readonly mediump image2D uImageIn; +layout(binding = 1, rgba8) uniform writeonly mediump image2D uImageOut; + +void main() +{ + vec4 v = imageLoad(uImageIn, ivec2(gl_GlobalInvocationID.xy) + imageSize(uImageIn)); + imageStore(uImageOut, ivec2(gl_GlobalInvocationID.xy), v); +} + diff --git a/reference/shaders/comp/inout-struct.invalid.comp b/reference/shaders/comp/inout-struct.invalid.comp new file mode 100644 index 0000000000..640e25bb95 --- /dev/null +++ b/reference/shaders/comp/inout-struct.invalid.comp @@ -0,0 +1,65 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct Foo +{ + vec4 a; + vec4 b; + vec4 c; + vec4 d; +}; + +layout(binding = 1, std430) readonly buffer SSBO2 +{ + vec4 data[]; +} indata; + +layout(binding = 0, std430) writeonly buffer SSBO +{ + vec4 data[]; +} outdata; + +layout(binding = 2, std430) readonly buffer SSBO3 +{ + Foo foos[]; +} foobar; + +void baz(inout Foo foo) +{ + uint ident = gl_GlobalInvocationID.x; + foo.a = indata.data[(4u * ident) + 0u]; + foo.b = indata.data[(4u * ident) + 1u]; + foo.c = indata.data[(4u * ident) + 2u]; + foo.d = indata.data[(4u * ident) + 3u]; +} + +void meow(inout Foo foo) +{ + foo.a += vec4(10.0); + foo.b += vec4(20.0); + foo.c += vec4(30.0); + foo.d += vec4(40.0); +} + +vec4 bar(Foo foo) +{ + return ((foo.a + foo.b) + foo.c) + foo.d; +} + +void main() +{ + Foo param; + baz(param); + Foo foo = param; + Foo param_1 = foo; + meow(param_1); + foo = param_1; + Foo param_2 = foo; + Foo param_3; + param_3.a = foobar.foos[gl_GlobalInvocationID.x].a; + param_3.b = foobar.foos[gl_GlobalInvocationID.x].b; + param_3.c = foobar.foos[gl_GlobalInvocationID.x].c; + param_3.d = foobar.foos[gl_GlobalInvocationID.x].d; + outdata.data[gl_GlobalInvocationID.x] = bar(param_2) + bar(param_3); +} + diff --git a/reference/shaders/comp/insert.comp b/reference/shaders/comp/insert.comp new file mode 100644 index 0000000000..cbe1e27f45 --- /dev/null +++ b/reference/shaders/comp/insert.comp @@ -0,0 +1,19 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) writeonly buffer SSBO +{ + vec4 out_data[]; +} _27; + +void main() +{ + vec4 v; + v.x = 10.0; + v.y = 30.0; + v.z = 70.0; + v.w = 90.0; + _27.out_data[gl_GlobalInvocationID.x] = v; + _27.out_data[gl_GlobalInvocationID.x].y = 20.0; +} + diff --git a/reference/shaders/comp/loop.noopt.comp b/reference/shaders/comp/loop.noopt.comp new file mode 100644 index 0000000000..049a30669c --- /dev/null +++ b/reference/shaders/comp/loop.noopt.comp @@ -0,0 +1,105 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) readonly buffer SSBO +{ + mat4 mvp; + vec4 in_data[]; +} _24; + +layout(binding = 1, std430) writeonly buffer SSBO2 +{ + vec4 out_data[]; +} _177; + +void main() +{ + uint ident = gl_GlobalInvocationID.x; + vec4 idat = _24.in_data[ident]; + int k = 0; + uint i = 0u; + if (idat.y == 20.0) + { + do + { + k *= 2; + i++; + } while (i < ident); + } + switch (k) + { + case 10: + { + for (;;) + { + i++; + if (i > 10u) + { + break; + } + continue; + } + break; + } + default: + { + for (;;) + { + i += 2u; + if (i > 20u) + { + break; + } + continue; + } + break; + } + } + while (k < 10) + { + idat *= 2.0; + k++; + } + for (uint i_1 = 0u; i_1 < 16u; i_1++, k++) + { + for (uint j = 0u; j < 30u; j++) + { + idat = _24.mvp * idat; + } + } + k = 0; + for (;;) + { + k++; + if (k > 10) + { + k += 2; + } + else + { + k += 3; + continue; + } + k += 10; + continue; + } + k = 0; + do + { + k++; + } while (k > 10); + int l = 0; + for (;;) + { + if (l == 5) + { + l++; + continue; + } + idat += vec4(1.0); + l++; + continue; + } + _177.out_data[ident] = idat; +} + diff --git a/reference/shaders/comp/mat3.comp b/reference/shaders/comp/mat3.comp new file mode 100644 index 0000000000..2b050f5d01 --- /dev/null +++ b/reference/shaders/comp/mat3.comp @@ -0,0 +1,14 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 1, std430) writeonly buffer SSBO2 +{ + mat3 out_data[]; +} _22; + +void main() +{ + uint ident = gl_GlobalInvocationID.x; + _22.out_data[ident] = mat3(vec3(10.0), vec3(20.0), vec3(40.0)); +} + diff --git a/reference/shaders/comp/mod.comp b/reference/shaders/comp/mod.comp new file mode 100644 index 0000000000..4be0c5f7f4 --- /dev/null +++ b/reference/shaders/comp/mod.comp @@ -0,0 +1,24 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) readonly buffer SSBO +{ + vec4 in_data[]; +} _23; + +layout(binding = 1, std430) writeonly buffer SSBO2 +{ + vec4 out_data[]; +} _33; + +void main() +{ + uint ident = gl_GlobalInvocationID.x; + vec4 v = mod(_23.in_data[ident], _33.out_data[ident]); + _33.out_data[ident] = v; + uvec4 vu = floatBitsToUint(_23.in_data[ident]) % floatBitsToUint(_33.out_data[ident]); + _33.out_data[ident] = uintBitsToFloat(vu); + ivec4 vi = floatBitsToInt(_23.in_data[ident]) % floatBitsToInt(_33.out_data[ident]); + _33.out_data[ident] = intBitsToFloat(vi); +} + diff --git a/reference/shaders/comp/modf.comp b/reference/shaders/comp/modf.comp new file mode 100644 index 0000000000..c92149bf94 --- /dev/null +++ b/reference/shaders/comp/modf.comp @@ -0,0 +1,22 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) readonly buffer SSBO +{ + vec4 in_data[]; +} _23; + +layout(binding = 1, std430) writeonly buffer SSBO2 +{ + vec4 out_data[]; +} _35; + +void main() +{ + uint ident = gl_GlobalInvocationID.x; + vec4 i; + vec4 _31 = modf(_23.in_data[ident], i); + vec4 v = _31; + _35.out_data[ident] = v; +} + diff --git a/reference/shaders/comp/read-write-only.comp b/reference/shaders/comp/read-write-only.comp new file mode 100644 index 0000000000..06227ee2c6 --- /dev/null +++ b/reference/shaders/comp/read-write-only.comp @@ -0,0 +1,27 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 2, std430) restrict writeonly buffer SSBO2 +{ + vec4 data4; + vec4 data5; +} _10; + +layout(binding = 0, std430) readonly buffer SSBO0 +{ + vec4 data0; + vec4 data1; +} _15; + +layout(binding = 1, std430) restrict buffer SSBO1 +{ + vec4 data2; + vec4 data3; +} _21; + +void main() +{ + _10.data4 = _15.data0 + _21.data2; + _10.data5 = _15.data1 + _21.data3; +} + diff --git a/reference/shaders/comp/return.comp b/reference/shaders/comp/return.comp new file mode 100644 index 0000000000..4be20e93e4 --- /dev/null +++ b/reference/shaders/comp/return.comp @@ -0,0 +1,34 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 1, std430) writeonly buffer SSBO2 +{ + vec4 out_data[]; +} _27; + +void main() +{ + uint ident = gl_GlobalInvocationID.x; + if (ident == 2u) + { + _27.out_data[ident] = vec4(20.0); + } + else + { + if (ident == 4u) + { + _27.out_data[ident] = vec4(10.0); + return; + } + } + for (int i = 0; i < 20; i++) + { + if (i == 10) + { + break; + } + return; + } + _27.out_data[ident] = vec4(10.0); +} + diff --git a/reference/shaders/comp/rmw-opt.comp b/reference/shaders/comp/rmw-opt.comp new file mode 100644 index 0000000000..e3fba7810d --- /dev/null +++ b/reference/shaders/comp/rmw-opt.comp @@ -0,0 +1,27 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) buffer SSBO +{ + int a; +} _9; + +void main() +{ + _9.a += 10; + _9.a -= 10; + _9.a *= 10; + _9.a /= 10; + _9.a = _9.a << 2; + _9.a = _9.a >> 3; + _9.a &= 40; + _9.a ^= 10; + _9.a %= 40; + _9.a |= 1; + bool c = false; + bool d = true; + c = c && d; + d = d || c; + _9.a = int(c && d); +} + diff --git a/reference/shaders/comp/shared.comp b/reference/shaders/comp/shared.comp new file mode 100644 index 0000000000..d0987a6528 --- /dev/null +++ b/reference/shaders/comp/shared.comp @@ -0,0 +1,25 @@ +#version 310 es +layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) readonly buffer SSBO +{ + float in_data[]; +} _22; + +layout(binding = 1, std430) writeonly buffer SSBO2 +{ + float out_data[]; +} _44; + +shared float sShared[4]; + +void main() +{ + uint ident = gl_GlobalInvocationID.x; + float idata = _22.in_data[ident]; + sShared[gl_LocalInvocationIndex] = idata; + memoryBarrierShared(); + barrier(); + _44.out_data[ident] = sShared[(4u - gl_LocalInvocationIndex) - 1u]; +} + diff --git a/reference/shaders/comp/ssbo-array.comp b/reference/shaders/comp/ssbo-array.comp new file mode 100644 index 0000000000..e773bd093c --- /dev/null +++ b/reference/shaders/comp/ssbo-array.comp @@ -0,0 +1,14 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) buffer SSBO +{ + vec4 data[]; +} ssbos[2]; + +void main() +{ + uint ident = gl_GlobalInvocationID.x; + ssbos[1].data[ident] = ssbos[0].data[ident]; +} + diff --git a/reference/shaders/comp/struct-layout.comp b/reference/shaders/comp/struct-layout.comp new file mode 100644 index 0000000000..4feea8be54 --- /dev/null +++ b/reference/shaders/comp/struct-layout.comp @@ -0,0 +1,24 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct Foo +{ + mat4 m; +}; + +layout(binding = 1, std430) writeonly buffer SSBO2 +{ + Foo out_data[]; +} _23; + +layout(binding = 0, std430) readonly buffer SSBO +{ + Foo in_data[]; +} _30; + +void main() +{ + uint ident = gl_GlobalInvocationID.x; + _23.out_data[ident].m = _30.in_data[ident].m * _30.in_data[ident].m; +} + diff --git a/reference/shaders/comp/struct-packing.comp b/reference/shaders/comp/struct-packing.comp new file mode 100644 index 0000000000..3c30aa6088 --- /dev/null +++ b/reference/shaders/comp/struct-packing.comp @@ -0,0 +1,104 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct S0 +{ + vec2 a[1]; + float b; +}; + +struct S1 +{ + vec3 a; + float b; +}; + +struct S2 +{ + vec3 a[1]; + float b; +}; + +struct S3 +{ + vec2 a; + float b; +}; + +struct S4 +{ + vec2 c; +}; + +struct Content +{ + S0 m0s[1]; + S1 m1s[1]; + S2 m2s[1]; + S0 m0; + S1 m1; + S2 m2; + S3 m3; + float m4; + S4 m3s[8]; +}; + +layout(binding = 1, std430) buffer SSBO1 +{ + Content content; + Content content1[2]; + Content content2; + mat2 m0; + mat2 m1; + mat2x3 m2[4]; + mat3x2 m3; + layout(row_major) mat2 m4; + layout(row_major) mat2 m5[9]; + layout(row_major) mat2x3 m6[4][2]; + layout(row_major) mat3x2 m7; + float array[]; +} ssbo_430; + +layout(binding = 0, std140) buffer SSBO0 +{ + Content content; + Content content1[2]; + Content content2; + mat2 m0; + mat2 m1; + mat2x3 m2[4]; + mat3x2 m3; + layout(row_major) mat2 m4; + layout(row_major) mat2 m5[9]; + layout(row_major) mat2x3 m6[4][2]; + layout(row_major) mat3x2 m7; + float array[]; +} ssbo_140; + +void main() +{ + ssbo_430.content.m0s[0].a[0] = ssbo_140.content.m0s[0].a[0]; + ssbo_430.content.m0s[0].b = ssbo_140.content.m0s[0].b; + ssbo_430.content.m1s[0].a = ssbo_140.content.m1s[0].a; + ssbo_430.content.m1s[0].b = ssbo_140.content.m1s[0].b; + ssbo_430.content.m2s[0].a[0] = ssbo_140.content.m2s[0].a[0]; + ssbo_430.content.m2s[0].b = ssbo_140.content.m2s[0].b; + ssbo_430.content.m0.a[0] = ssbo_140.content.m0.a[0]; + ssbo_430.content.m0.b = ssbo_140.content.m0.b; + ssbo_430.content.m1.a = ssbo_140.content.m1.a; + ssbo_430.content.m1.b = ssbo_140.content.m1.b; + ssbo_430.content.m2.a[0] = ssbo_140.content.m2.a[0]; + ssbo_430.content.m2.b = ssbo_140.content.m2.b; + ssbo_430.content.m3.a = ssbo_140.content.m3.a; + ssbo_430.content.m3.b = ssbo_140.content.m3.b; + ssbo_430.content.m4 = ssbo_140.content.m4; + ssbo_430.content.m3s[0].c = ssbo_140.content.m3s[0].c; + ssbo_430.content.m3s[1].c = ssbo_140.content.m3s[1].c; + ssbo_430.content.m3s[2].c = ssbo_140.content.m3s[2].c; + ssbo_430.content.m3s[3].c = ssbo_140.content.m3s[3].c; + ssbo_430.content.m3s[4].c = ssbo_140.content.m3s[4].c; + 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; +} + diff --git a/reference/shaders/comp/torture-loop.comp b/reference/shaders/comp/torture-loop.comp new file mode 100644 index 0000000000..645af5c374 --- /dev/null +++ b/reference/shaders/comp/torture-loop.comp @@ -0,0 +1,49 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) readonly buffer SSBO +{ + mat4 mvp; + vec4 in_data[]; +} _24; + +layout(binding = 1, std430) writeonly buffer SSBO2 +{ + vec4 out_data[]; +} _89; + +void main() +{ + uint ident = gl_GlobalInvocationID.x; + vec4 idat = _24.in_data[ident]; + int k = 0; + for (;;) + { + int _39 = k; + int _40 = _39 + 1; + k = _40; + if (_40 < 10) + { + idat *= 2.0; + k++; + continue; + } + else + { + break; + } + } + for (uint i = 0u; i < 16u; i++, k++) + { + for (uint j = 0u; j < 30u; j++) + { + idat = _24.mvp * idat; + } + } + do + { + k++; + } while (k > 10); + _89.out_data[ident] = idat; +} + diff --git a/reference/shaders/comp/type-alias.comp b/reference/shaders/comp/type-alias.comp new file mode 100644 index 0000000000..51f3792e1a --- /dev/null +++ b/reference/shaders/comp/type-alias.comp @@ -0,0 +1,49 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct S0 +{ + vec4 a; +}; + +struct S1 +{ + vec4 a; +}; + +layout(binding = 0, std430) buffer SSBO0 +{ + S0 s0s[]; +} _36; + +layout(binding = 1, std430) buffer SSBO1 +{ + S1 s1s[]; +} _55; + +layout(binding = 2, std430) buffer SSBO2 +{ + vec4 outputs[]; +} _66; + +vec4 overload(S0 s0) +{ + return s0.a; +} + +vec4 overload(S1 s1) +{ + return s1.a; +} + +void main() +{ + S0 s0; + s0.a = _36.s0s[gl_GlobalInvocationID.x].a; + S1 s1; + s1.a = _55.s1s[gl_GlobalInvocationID.x].a; + S0 param = s0; + S1 param_1 = s1; + _66.outputs[gl_GlobalInvocationID.x] = overload(param) + overload(param_1); +} + diff --git a/reference/shaders/comp/udiv.comp b/reference/shaders/comp/udiv.comp new file mode 100644 index 0000000000..0c1f926ad0 --- /dev/null +++ b/reference/shaders/comp/udiv.comp @@ -0,0 +1,18 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) buffer SSBO2 +{ + uint outputs[]; +} _10; + +layout(binding = 0, std430) buffer SSBO +{ + uint inputs[]; +} _23; + +void main() +{ + _10.outputs[gl_GlobalInvocationID.x] = _23.inputs[gl_GlobalInvocationID.x] / 29u; +} + diff --git a/reference/shaders/desktop-only/comp/enhanced-layouts.comp b/reference/shaders/desktop-only/comp/enhanced-layouts.comp new file mode 100644 index 0000000000..ba37ca237b --- /dev/null +++ b/reference/shaders/desktop-only/comp/enhanced-layouts.comp @@ -0,0 +1,40 @@ +#version 450 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct Foo +{ + int a; + int b; + int c; +}; + +layout(binding = 1, std140) buffer SSBO1 +{ + layout(offset = 4) int a; + layout(offset = 8) int b; + layout(offset = 16) Foo foo; + layout(offset = 48) int c[8]; +} ssbo1; + +layout(binding = 2, std430) buffer SSBO2 +{ + layout(offset = 4) int a; + layout(offset = 8) int b; + layout(offset = 16) Foo foo; + layout(offset = 48) int c[8]; +} ssbo2; + +layout(binding = 0, std140) uniform UBO +{ + layout(offset = 4) int a; + layout(offset = 8) int b; + layout(offset = 16) Foo foo; + layout(offset = 48) int c[8]; +} ubo; + +void main() +{ + ssbo1.a = ssbo2.a; + ssbo1.b = ubo.b; +} + diff --git a/reference/shaders/desktop-only/comp/fp64.desktop.comp b/reference/shaders/desktop-only/comp/fp64.desktop.comp new file mode 100644 index 0000000000..18869eda52 --- /dev/null +++ b/reference/shaders/desktop-only/comp/fp64.desktop.comp @@ -0,0 +1,84 @@ +#version 450 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct M0 +{ + double v; + dvec2 b[2]; + dmat2x3 c; + dmat3x2 d; +}; + +layout(binding = 0, std430) buffer SSBO0 +{ + dvec4 a; + M0 m0; + dmat4 b; +} ssbo_0; + +layout(binding = 1, std430) buffer SSBO1 +{ + dmat4 a; + dvec4 b; + M0 m0; +} ssbo_1; + +layout(binding = 2, std430) buffer SSBO2 +{ + double a[4]; + dvec2 b[4]; +} ssbo_2; + +layout(binding = 3, std140) buffer SSBO3 +{ + double a[4]; + dvec2 b[4]; +} ssbo_3; + +void main() +{ + ssbo_0.a += dvec4(10.0lf, 20.0lf, 30.0lf, 40.0lf); + ssbo_0.a += dvec4(20.0lf); + dvec4 a = ssbo_0.a; + dmat4 amat = ssbo_0.b; + ssbo_0.a = abs(a); + ssbo_0.a = sign(a); + ssbo_0.a = floor(a); + ssbo_0.a = trunc(a); + ssbo_0.a = round(a); + ssbo_0.a = roundEven(a); + ssbo_0.a = ceil(a); + ssbo_0.a = fract(a); + ssbo_0.a = mod(a, dvec4(20.0lf)); + ssbo_0.a = mod(a, a); + ssbo_0.a = min(a, a); + ssbo_0.a = max(a, a); + ssbo_0.a = clamp(a, a, a); + ssbo_0.a = mix(a, a, a); + ssbo_0.a = step(a, a); + ssbo_0.a = smoothstep(a, a, a); + bvec4 b = isnan(a); + bvec4 c = isinf(a); + double f = packDouble2x32(uvec2(10u, 40u)); + uvec2 g = unpackDouble2x32(f); + double d = length(a); + d = distance(a, a); + d = dot(a, a); + dvec3 e = cross(a.xyz, a.yzw); + a = faceforward(a, a, a); + a = reflect(a, a); + a = refract(a, a, a.x); + dmat4 l = dmat4(amat[0] * amat[0], amat[1] * amat[1], amat[2] * amat[2], amat[3] * amat[3]); + l = outerProduct(a, a); + l = transpose(l); + double m = determinant(l); + l = inverse(l); + bvec4 k = lessThan(a, a); + k = lessThanEqual(a, a); + k = greaterThan(a, a); + k = greaterThanEqual(a, a); + ssbo_1.b.x += 1.0lf; + ssbo_2.b[0].x += 1.0lf; + ssbo_3.b[0].x += 1.0lf; +} + diff --git a/reference/shaders/desktop-only/comp/image-formats.desktop.noeliminate.comp b/reference/shaders/desktop-only/comp/image-formats.desktop.noeliminate.comp new file mode 100644 index 0000000000..7a0797578b --- /dev/null +++ b/reference/shaders/desktop-only/comp/image-formats.desktop.noeliminate.comp @@ -0,0 +1,47 @@ +#version 450 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, rgba32f) uniform readonly writeonly image2D uImg00; +layout(binding = 1, rgba16f) uniform readonly writeonly image2D uImg01; +layout(binding = 2, rg32f) uniform readonly writeonly image2D uImg02; +layout(binding = 3, rg16f) uniform readonly writeonly image2D uImg03; +layout(binding = 4, r11f_g11f_b10f) uniform readonly writeonly image2D uImg04; +layout(binding = 5, r32f) uniform readonly writeonly image2D uImg05; +layout(binding = 6, r16f) uniform readonly writeonly image2D uImg06; +layout(binding = 7, rgba16) uniform readonly writeonly image2D uImg07; +layout(binding = 8, rgb10_a2) uniform readonly writeonly image2D uImg08; +layout(binding = 9, rgba8) uniform readonly writeonly image2D uImg09; +layout(binding = 10, rg16) uniform readonly writeonly image2D uImg10; +layout(binding = 11, rg8) uniform readonly writeonly image2D uImg11; +layout(binding = 12, r16) uniform readonly writeonly image2D uImg12; +layout(binding = 13, r8) uniform readonly writeonly image2D uImg13; +layout(binding = 14, rgba16_snorm) uniform readonly writeonly image2D uImg14; +layout(binding = 15, rgba8_snorm) uniform readonly writeonly image2D uImg15; +layout(binding = 16, rg16_snorm) uniform readonly writeonly image2D uImg16; +layout(binding = 17, rg8_snorm) uniform readonly writeonly image2D uImg17; +layout(binding = 18, r16_snorm) uniform readonly writeonly image2D uImg18; +layout(binding = 19, r8_snorm) uniform readonly writeonly image2D uImg19; +layout(binding = 20, rgba32i) uniform readonly writeonly iimage2D uImage20; +layout(binding = 21, rgba16i) uniform readonly writeonly iimage2D uImage21; +layout(binding = 22, rgba8i) uniform readonly writeonly iimage2D uImage22; +layout(binding = 23, rg32i) uniform readonly writeonly iimage2D uImage23; +layout(binding = 24, rg16i) uniform readonly writeonly iimage2D uImage24; +layout(binding = 25, rg8i) uniform readonly writeonly iimage2D uImage25; +layout(binding = 26, r32i) uniform readonly writeonly iimage2D uImage26; +layout(binding = 27, r16i) uniform readonly writeonly iimage2D uImage27; +layout(binding = 28, r8i) uniform readonly writeonly iimage2D uImage28; +layout(binding = 29, rgba32ui) uniform readonly writeonly uimage2D uImage29; +layout(binding = 30, rgba16ui) uniform readonly writeonly uimage2D uImage30; +layout(binding = 31, rgb10_a2ui) uniform readonly writeonly uimage2D uImage31; +layout(binding = 32, rgba8ui) uniform readonly writeonly uimage2D uImage32; +layout(binding = 33, rg32ui) uniform readonly writeonly uimage2D uImage33; +layout(binding = 34, rg16ui) uniform readonly writeonly uimage2D uImage34; +layout(binding = 35, rg8ui) uniform readonly writeonly uimage2D uImage35; +layout(binding = 36, r32ui) uniform readonly writeonly uimage2D uImage36; +layout(binding = 37, r16ui) uniform readonly writeonly uimage2D uImage37; +layout(binding = 38, r8ui) uniform readonly writeonly uimage2D uImage38; + +void main() +{ +} + diff --git a/reference/shaders/desktop-only/comp/int64.desktop.comp b/reference/shaders/desktop-only/comp/int64.desktop.comp new file mode 100644 index 0000000000..702456b303 --- /dev/null +++ b/reference/shaders/desktop-only/comp/int64.desktop.comp @@ -0,0 +1,52 @@ +#version 450 +#extension GL_ARB_gpu_shader_int64 : require +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct M0 +{ + int64_t v; + i64vec2 b[2]; + uint64_t c; + uint64_t d[5]; +}; + +layout(binding = 0, std430) buffer SSBO0 +{ + i64vec4 a; + M0 m0; +} ssbo_0; + +layout(binding = 1, std430) buffer SSBO1 +{ + u64vec4 b; + M0 m0; +} ssbo_1; + +layout(binding = 2, std430) buffer SSBO2 +{ + int64_t a[4]; + i64vec2 b[4]; +} ssbo_2; + +layout(binding = 3, std140) buffer SSBO3 +{ + int64_t a[4]; + i64vec2 b[4]; +} ssbo_3; + +void main() +{ + ssbo_0.a += i64vec4(10l, 20l, 30l, 40l); + ssbo_1.b += u64vec4(999999999999999999ul, 8888888888888888ul, 77777777777777777ul, 6666666666666666ul); + ssbo_0.a += i64vec4(20l); + ssbo_0.a = abs(ssbo_0.a + i64vec4(ssbo_1.b)); + ssbo_0.a += i64vec4(1l); + ssbo_1.b += u64vec4(i64vec4(1l)); + ssbo_0.a -= i64vec4(1l); + ssbo_1.b -= u64vec4(i64vec4(1l)); + ssbo_1.b = doubleBitsToUint64(int64BitsToDouble(ssbo_0.a)); + ssbo_0.a = doubleBitsToInt64(uint64BitsToDouble(ssbo_1.b)); + ssbo_2.a[0] += 1l; + ssbo_3.a[0] += 2l; +} + diff --git a/reference/shaders/desktop-only/frag/hlsl-uav-block-alias.asm.frag b/reference/shaders/desktop-only/frag/hlsl-uav-block-alias.asm.frag new file mode 100644 index 0000000000..70843a8563 --- /dev/null +++ b/reference/shaders/desktop-only/frag/hlsl-uav-block-alias.asm.frag @@ -0,0 +1,24 @@ +#version 450 + +layout(binding = 0, std430) buffer Foobar +{ + vec4 _data[]; +} Foobar_1; + +layout(binding = 1, std430) buffer Foobaz +{ + vec4 _data[]; +} Foobaz_1; + +layout(location = 0) out vec4 _entryPointOutput; + +vec4 _main() +{ + return Foobar_1._data[0] + Foobaz_1._data[0]; +} + +void main() +{ + _entryPointOutput = _main(); +} + diff --git a/reference/shaders/desktop-only/frag/image-ms.desktop.frag b/reference/shaders/desktop-only/frag/image-ms.desktop.frag new file mode 100644 index 0000000000..24644be170 --- /dev/null +++ b/reference/shaders/desktop-only/frag/image-ms.desktop.frag @@ -0,0 +1,13 @@ +#version 450 + +layout(binding = 0, rgba8) uniform image2DMS uImage; +layout(binding = 1, rgba8) uniform image2DMSArray uImageArray; + +void main() +{ + vec4 a = imageLoad(uImage, ivec2(1, 2), 2); + vec4 b = imageLoad(uImageArray, ivec3(1, 2, 4), 3); + imageStore(uImage, ivec2(2, 3), 1, a); + imageStore(uImageArray, ivec3(2, 3, 7), 1, b); +} + diff --git a/reference/shaders/desktop-only/frag/image-query.desktop.frag b/reference/shaders/desktop-only/frag/image-query.desktop.frag new file mode 100644 index 0000000000..6f36d5db3b --- /dev/null +++ b/reference/shaders/desktop-only/frag/image-query.desktop.frag @@ -0,0 +1,53 @@ +#version 450 + +layout(binding = 0) uniform sampler1D uSampler1D; +layout(binding = 1) uniform sampler2D uSampler2D; +layout(binding = 2) uniform sampler2DArray uSampler2DArray; +layout(binding = 3) uniform sampler3D uSampler3D; +layout(binding = 4) uniform samplerCube uSamplerCube; +layout(binding = 5) uniform samplerCubeArray uSamplerCubeArray; +layout(binding = 6) uniform samplerBuffer uSamplerBuffer; +layout(binding = 7) uniform sampler2DMS uSamplerMS; +layout(binding = 8) uniform sampler2DMSArray uSamplerMSArray; +layout(binding = 9, r32f) uniform readonly writeonly image1D uImage1D; +layout(binding = 10, r32f) uniform readonly writeonly image2D uImage2D; +layout(binding = 11, r32f) uniform readonly writeonly image2DArray uImage2DArray; +layout(binding = 12, r32f) uniform readonly writeonly image3D uImage3D; +layout(binding = 13, r32f) uniform readonly writeonly imageCube uImageCube; +layout(binding = 14, r32f) uniform readonly writeonly imageCubeArray uImageCubeArray; +layout(binding = 15, r32f) uniform readonly writeonly imageBuffer uImageBuffer; +layout(binding = 16, r32f) uniform readonly writeonly image2DMS uImageMS; +layout(binding = 17, r32f) uniform readonly writeonly image2DMSArray uImageMSArray; + +void main() +{ + int a = textureSize(uSampler1D, 0); + ivec2 b = textureSize(uSampler2D, 0); + ivec3 c = textureSize(uSampler2DArray, 0); + ivec3 d = textureSize(uSampler3D, 0); + ivec2 e = textureSize(uSamplerCube, 0); + ivec3 f = textureSize(uSamplerCubeArray, 0); + int g = textureSize(uSamplerBuffer); + ivec2 h = textureSize(uSamplerMS); + ivec3 i = textureSize(uSamplerMSArray); + int l0 = textureQueryLevels(uSampler1D); + int l1 = textureQueryLevels(uSampler2D); + int l2 = textureQueryLevels(uSampler2DArray); + int l3 = textureQueryLevels(uSampler3D); + int l4 = textureQueryLevels(uSamplerCube); + int l5 = textureQueryLevels(uSamplerCubeArray); + a = imageSize(uImage1D); + b = imageSize(uImage2D); + c = imageSize(uImage2DArray); + d = imageSize(uImage3D); + e = imageSize(uImageCube); + f = imageSize(uImageCubeArray); + g = imageSize(uImageBuffer); + h = imageSize(uImageMS); + i = imageSize(uImageMSArray); + int s0 = textureSamples(uSamplerMS); + int s1 = textureSamples(uSamplerMSArray); + int s2 = imageSamples(uImageMS); + int s3 = imageSamples(uImageMSArray); +} + diff --git a/reference/shaders/desktop-only/frag/in-block-qualifiers.frag b/reference/shaders/desktop-only/frag/in-block-qualifiers.frag new file mode 100644 index 0000000000..d4622801df --- /dev/null +++ b/reference/shaders/desktop-only/frag/in-block-qualifiers.frag @@ -0,0 +1,21 @@ +#version 450 + +layout(location = 0) out vec4 FragColor; +layout(location = 0) in VertexData +{ + flat float f; + centroid vec4 g; + flat int h; + float i; +} vin; + +layout(location = 4) flat in float f; +layout(location = 5) centroid in vec4 g; +layout(location = 6) flat in int h; +layout(location = 7) sample in float i; + +void main() +{ + FragColor = ((((((vec4(vin.f) + vin.g) + vec4(float(vin.h))) + vec4(vin.i)) + vec4(f)) + g) + vec4(float(h))) + vec4(i); +} + diff --git a/reference/shaders/desktop-only/frag/query-levels.desktop.frag b/reference/shaders/desktop-only/frag/query-levels.desktop.frag new file mode 100644 index 0000000000..4a80cbf81f --- /dev/null +++ b/reference/shaders/desktop-only/frag/query-levels.desktop.frag @@ -0,0 +1,11 @@ +#version 450 + +layout(binding = 0) uniform sampler2D uSampler; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = vec4(float(textureQueryLevels(uSampler))); +} + diff --git a/reference/shaders/desktop-only/frag/query-lod.desktop.frag b/reference/shaders/desktop-only/frag/query-lod.desktop.frag new file mode 100644 index 0000000000..f43543b8c0 --- /dev/null +++ b/reference/shaders/desktop-only/frag/query-lod.desktop.frag @@ -0,0 +1,12 @@ +#version 450 + +layout(binding = 0) uniform sampler2D uSampler; + +layout(location = 0) out vec4 FragColor; +layout(location = 0) in vec2 vTexCoord; + +void main() +{ + FragColor = textureQueryLod(uSampler, vTexCoord).xyxy; +} + diff --git a/reference/shaders/desktop-only/frag/sampler-ms-query.desktop.frag b/reference/shaders/desktop-only/frag/sampler-ms-query.desktop.frag new file mode 100644 index 0000000000..4c30ed1529 --- /dev/null +++ b/reference/shaders/desktop-only/frag/sampler-ms-query.desktop.frag @@ -0,0 +1,14 @@ +#version 450 + +layout(binding = 0) uniform sampler2DMS uSampler; +layout(binding = 1) uniform sampler2DMSArray uSamplerArray; +layout(binding = 2, rgba8) uniform readonly writeonly image2DMS uImage; +layout(binding = 3, rgba8) uniform readonly writeonly image2DMSArray uImageArray; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = vec4(float(((textureSamples(uSampler) + textureSamples(uSamplerArray)) + imageSamples(uImage)) + imageSamples(uImageArray))); +} + diff --git a/reference/shaders/desktop-only/frag/texture-proj-shadow.desktop.frag b/reference/shaders/desktop-only/frag/texture-proj-shadow.desktop.frag new file mode 100644 index 0000000000..d5e45bda43 --- /dev/null +++ b/reference/shaders/desktop-only/frag/texture-proj-shadow.desktop.frag @@ -0,0 +1,26 @@ +#version 450 + +layout(binding = 0) uniform sampler1DShadow uShadow1D; +layout(binding = 1) uniform sampler2DShadow uShadow2D; +layout(binding = 2) uniform sampler1D uSampler1D; +layout(binding = 3) uniform sampler2D uSampler2D; +layout(binding = 4) uniform sampler3D uSampler3D; + +layout(location = 0) out float FragColor; +layout(location = 1) in vec4 vClip4; +layout(location = 2) in vec2 vClip2; +layout(location = 0) in vec3 vClip3; + +void main() +{ + vec4 _20 = vClip4; + _20.y = vClip4.w; + FragColor = textureProj(uShadow1D, vec4(_20.x, 0.0, vClip4.z, _20.y)); + vec4 _30 = vClip4; + _30.z = vClip4.w; + FragColor = textureProj(uShadow2D, vec4(_30.xy, vClip4.z, _30.z)); + FragColor = textureProj(uSampler1D, vClip2).x; + FragColor = textureProj(uSampler2D, vClip3).x; + FragColor = textureProj(uSampler3D, vClip4).x; +} + diff --git a/reference/shaders/desktop-only/geom/basic.desktop.sso.geom b/reference/shaders/desktop-only/geom/basic.desktop.sso.geom new file mode 100644 index 0000000000..f1afee69ec --- /dev/null +++ b/reference/shaders/desktop-only/geom/basic.desktop.sso.geom @@ -0,0 +1,35 @@ +#version 450 +layout(invocations = 4, triangles) in; +layout(max_vertices = 3, triangle_strip) out; + +in gl_PerVertex +{ + vec4 gl_Position; +} gl_in[]; + +out gl_PerVertex +{ + vec4 gl_Position; +}; + +layout(location = 0) out vec3 vNormal; +layout(location = 0) in VertexData +{ + vec3 normal; +} vin[3]; + + +void main() +{ + gl_Position = gl_in[0].gl_Position; + vNormal = vin[0].normal + vec3(float(gl_InvocationID)); + EmitVertex(); + gl_Position = gl_in[1].gl_Position; + vNormal = vin[1].normal + vec3(4.0 * float(gl_InvocationID)); + EmitVertex(); + gl_Position = gl_in[2].gl_Position; + vNormal = vin[2].normal + vec3(2.0 * float(gl_InvocationID)); + EmitVertex(); + EndPrimitive(); +} + diff --git a/reference/shaders/desktop-only/geom/viewport-index.desktop.geom b/reference/shaders/desktop-only/geom/viewport-index.desktop.geom new file mode 100644 index 0000000000..773aeb8bfd --- /dev/null +++ b/reference/shaders/desktop-only/geom/viewport-index.desktop.geom @@ -0,0 +1,9 @@ +#version 450 +layout(triangles) in; +layout(max_vertices = 4, triangle_strip) out; + +void main() +{ + gl_ViewportIndex = 1; +} + diff --git a/reference/shaders/desktop-only/tesc/basic.desktop.sso.tesc b/reference/shaders/desktop-only/tesc/basic.desktop.sso.tesc new file mode 100644 index 0000000000..5e958256af --- /dev/null +++ b/reference/shaders/desktop-only/tesc/basic.desktop.sso.tesc @@ -0,0 +1,27 @@ +#version 450 +layout(vertices = 1) out; + +in gl_PerVertex +{ + vec4 gl_Position; +} gl_in[gl_MaxPatchVertices]; + +out gl_PerVertex +{ + vec4 gl_Position; +} gl_out[1]; + +layout(location = 0) patch out vec3 vFoo; + +void main() +{ + gl_TessLevelInner[0] = 8.8999996185302734375; + gl_TessLevelInner[1] = 6.900000095367431640625; + gl_TessLevelOuter[0] = 8.8999996185302734375; + gl_TessLevelOuter[1] = 6.900000095367431640625; + gl_TessLevelOuter[2] = 3.900000095367431640625; + gl_TessLevelOuter[3] = 4.900000095367431640625; + vFoo = vec3(1.0); + gl_out[gl_InvocationID].gl_Position = gl_in[0].gl_Position + gl_in[1].gl_Position; +} + diff --git a/reference/shaders/desktop-only/tese/triangle.desktop.sso.tese b/reference/shaders/desktop-only/tese/triangle.desktop.sso.tese new file mode 100644 index 0000000000..31027dae80 --- /dev/null +++ b/reference/shaders/desktop-only/tese/triangle.desktop.sso.tese @@ -0,0 +1,18 @@ +#version 450 +layout(triangles, cw, fractional_even_spacing) in; + +in gl_PerVertex +{ + vec4 gl_Position; +} gl_in[gl_MaxPatchVertices]; + +out gl_PerVertex +{ + vec4 gl_Position; +}; + +void main() +{ + gl_Position = ((gl_in[0].gl_Position * gl_TessCoord.x) + (gl_in[1].gl_Position * gl_TessCoord.y)) + (gl_in[2].gl_Position * gl_TessCoord.z); +} + diff --git a/reference/shaders/desktop-only/vert/basic.desktop.sso.vert b/reference/shaders/desktop-only/vert/basic.desktop.sso.vert new file mode 100644 index 0000000000..5f527e08c1 --- /dev/null +++ b/reference/shaders/desktop-only/vert/basic.desktop.sso.vert @@ -0,0 +1,22 @@ +#version 450 + +out gl_PerVertex +{ + vec4 gl_Position; +}; + +layout(std140) uniform UBO +{ + mat4 uMVP; +} _16; + +layout(location = 0) in vec4 aVertex; +layout(location = 0) out vec3 vNormal; +layout(location = 1) in vec3 aNormal; + +void main() +{ + gl_Position = _16.uMVP * aVertex; + vNormal = aNormal; +} + diff --git a/reference/shaders/desktop-only/vert/clip-cull-distance.desktop.vert b/reference/shaders/desktop-only/vert/clip-cull-distance.desktop.vert new file mode 100644 index 0000000000..566809db23 --- /dev/null +++ b/reference/shaders/desktop-only/vert/clip-cull-distance.desktop.vert @@ -0,0 +1,11 @@ +#version 450 + +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; +} + diff --git a/reference/shaders/desktop-only/vert/out-block-qualifiers.vert b/reference/shaders/desktop-only/vert/out-block-qualifiers.vert new file mode 100644 index 0000000000..7c731684bc --- /dev/null +++ b/reference/shaders/desktop-only/vert/out-block-qualifiers.vert @@ -0,0 +1,27 @@ +#version 450 + +layout(location = 0) out VertexData +{ + flat float f; + centroid vec4 g; + flat int h; + float i; +} vout; + +layout(location = 4) flat out float f; +layout(location = 5) centroid out vec4 g; +layout(location = 6) flat out int h; +layout(location = 7) out float i; + +void main() +{ + vout.f = 10.0; + vout.g = vec4(20.0); + vout.h = 20; + vout.i = 30.0; + f = 10.0; + g = vec4(20.0); + h = 20; + i = 30.0; +} + diff --git a/reference/shaders/flatten/array.flatten.vert b/reference/shaders/flatten/array.flatten.vert new file mode 100644 index 0000000000..5afde34c55 --- /dev/null +++ b/reference/shaders/flatten/array.flatten.vert @@ -0,0 +1,12 @@ +#version 310 es + +uniform vec4 UBO[56]; +layout(location = 0) in vec4 aVertex; + +void main() +{ + vec4 a4 = UBO[23]; + vec4 offset = (UBO[50] + UBO[45]) + vec4(UBO[54].x); + gl_Position = ((mat4(UBO[40], UBO[41], UBO[42], UBO[43]) * aVertex) + UBO[55]) + offset; +} + diff --git a/reference/shaders/flatten/basic.flatten.vert b/reference/shaders/flatten/basic.flatten.vert new file mode 100644 index 0000000000..f7eb758f2a --- /dev/null +++ b/reference/shaders/flatten/basic.flatten.vert @@ -0,0 +1,13 @@ +#version 310 es + +uniform vec4 UBO[4]; +layout(location = 0) in vec4 aVertex; +layout(location = 0) out vec3 vNormal; +layout(location = 1) in vec3 aNormal; + +void main() +{ + gl_Position = mat4(UBO[0], UBO[1], UBO[2], UBO[3]) * aVertex; + vNormal = aNormal; +} + diff --git a/reference/shaders/flatten/copy.flatten.vert b/reference/shaders/flatten/copy.flatten.vert new file mode 100644 index 0000000000..2bdd723886 --- /dev/null +++ b/reference/shaders/flatten/copy.flatten.vert @@ -0,0 +1,29 @@ +#version 310 es + +struct Light +{ + vec3 Position; + float Radius; + vec4 Color; +}; + +uniform vec4 UBO[12]; +layout(location = 0) in vec4 aVertex; +layout(location = 0) out vec4 vColor; +layout(location = 1) in vec3 aNormal; + +void main() +{ + gl_Position = mat4(UBO[0], UBO[1], UBO[2], UBO[3]) * aVertex; + vColor = vec4(0.0); + for (int i = 0; i < 4; i++) + { + Light light; + light.Position = Light(UBO[i * 2 + 4].xyz, UBO[i * 2 + 4].w, UBO[i * 2 + 5]).Position; + light.Radius = Light(UBO[i * 2 + 4].xyz, UBO[i * 2 + 4].w, UBO[i * 2 + 5]).Radius; + light.Color = Light(UBO[i * 2 + 4].xyz, UBO[i * 2 + 4].w, UBO[i * 2 + 5]).Color; + vec3 L = aVertex.xyz - light.Position; + vColor += (((UBO[i * 2 + 5]) * clamp(1.0 - (length(L) / light.Radius), 0.0, 1.0)) * dot(aNormal, normalize(L))); + } +} + diff --git a/reference/shaders/flatten/dynamic.flatten.vert b/reference/shaders/flatten/dynamic.flatten.vert new file mode 100644 index 0000000000..6214ca450a --- /dev/null +++ b/reference/shaders/flatten/dynamic.flatten.vert @@ -0,0 +1,25 @@ +#version 310 es + +struct Light +{ + vec3 Position; + float Radius; + vec4 Color; +}; + +uniform vec4 UBO[12]; +layout(location = 0) in vec4 aVertex; +layout(location = 0) out vec4 vColor; +layout(location = 1) in vec3 aNormal; + +void main() +{ + gl_Position = mat4(UBO[0], UBO[1], UBO[2], UBO[3]) * aVertex; + vColor = vec4(0.0); + for (int i = 0; i < 4; i++) + { + vec3 L = aVertex.xyz - (UBO[i * 2 + 4].xyz); + vColor += (((UBO[i * 2 + 5]) * clamp(1.0 - (length(L) / (UBO[i * 2 + 4].w)), 0.0, 1.0)) * dot(aNormal, normalize(L))); + } +} + diff --git a/reference/shaders/flatten/matrixindex.flatten.vert b/reference/shaders/flatten/matrixindex.flatten.vert new file mode 100644 index 0000000000..f6d0fa486d --- /dev/null +++ b/reference/shaders/flatten/matrixindex.flatten.vert @@ -0,0 +1,19 @@ +#version 310 es + +uniform vec4 UBO[14]; +layout(location = 0) out vec4 oA; +layout(location = 1) out vec4 oB; +layout(location = 2) out vec4 oC; +layout(location = 3) out vec4 oD; +layout(location = 4) out vec4 oE; + +void main() +{ + gl_Position = vec4(0.0); + oA = UBO[1]; + oB = vec4(UBO[4].y, UBO[5].y, UBO[6].y, UBO[7].y); + oC = UBO[9]; + oD = vec4(UBO[10].x, UBO[11].x, UBO[12].x, UBO[13].x); + oE = vec4(UBO[1].z, UBO[6].y, UBO[9].z, UBO[12].y); +} + diff --git a/reference/shaders/flatten/multi-dimensional.desktop.flatten_dim.frag b/reference/shaders/flatten/multi-dimensional.desktop.flatten_dim.frag new file mode 100644 index 0000000000..21c3363ca6 --- /dev/null +++ b/reference/shaders/flatten/multi-dimensional.desktop.flatten_dim.frag @@ -0,0 +1,24 @@ +#version 450 + +layout(binding = 0) uniform sampler2D uTextures[2 * 3 * 1]; + +layout(location = 1) in vec2 vUV; +layout(location = 0) out vec4 FragColor; +layout(location = 0) flat in int vIndex; + +void main() +{ + vec4 values3[2 * 3 * 1]; + for (int z = 0; z < 2; z++) + { + for (int y = 0; y < 3; y++) + { + for (int x = 0; x < 1; x++) + { + values3[z * 3 * 1 + y * 1 + x] = texture(uTextures[z * 3 * 1 + y * 1 + x], vUV); + } + } + } + FragColor = ((values3[1 * 3 * 1 + 2 * 1 + 0]) + (values3[0 * 3 * 1 + 2 * 1 + 0])) + (values3[(vIndex + 1) * 3 * 1 + 2 * 1 + vIndex]); +} + diff --git a/reference/shaders/flatten/multiindex.flatten.vert b/reference/shaders/flatten/multiindex.flatten.vert new file mode 100644 index 0000000000..3850bf6c70 --- /dev/null +++ b/reference/shaders/flatten/multiindex.flatten.vert @@ -0,0 +1,10 @@ +#version 310 es + +uniform vec4 UBO[15]; +layout(location = 0) in ivec2 aIndex; + +void main() +{ + gl_Position = UBO[aIndex.x * 5 + aIndex.y * 1 + 0]; +} + diff --git a/reference/shaders/flatten/push-constant.flatten.vert b/reference/shaders/flatten/push-constant.flatten.vert new file mode 100644 index 0000000000..216c1f9d1b --- /dev/null +++ b/reference/shaders/flatten/push-constant.flatten.vert @@ -0,0 +1,13 @@ +#version 310 es + +uniform vec4 PushMe[6]; +layout(location = 1) in vec4 Pos; +layout(location = 0) out vec2 vRot; +layout(location = 0) in vec2 Rot; + +void main() +{ + gl_Position = mat4(PushMe[0], PushMe[1], PushMe[2], PushMe[3]) * Pos; + vRot = (mat2(PushMe[4].xy, PushMe[4].zw) * Rot) + vec2(PushMe[5].z); +} + diff --git a/reference/shaders/flatten/rowmajor.flatten.vert b/reference/shaders/flatten/rowmajor.flatten.vert new file mode 100644 index 0000000000..721c4905c0 --- /dev/null +++ b/reference/shaders/flatten/rowmajor.flatten.vert @@ -0,0 +1,11 @@ +#version 310 es + +uniform vec4 UBO[12]; +layout(location = 0) in vec4 aVertex; + +void main() +{ + vec2 v = mat4x2(UBO[8].xy, UBO[9].xy, UBO[10].xy, UBO[11].xy) * aVertex; + gl_Position = (mat4(UBO[0], UBO[1], UBO[2], UBO[3]) * aVertex) + (aVertex * mat4(UBO[4], UBO[5], UBO[6], UBO[7])); +} + diff --git a/reference/shaders/flatten/struct.flatten.vert b/reference/shaders/flatten/struct.flatten.vert new file mode 100644 index 0000000000..3468d52929 --- /dev/null +++ b/reference/shaders/flatten/struct.flatten.vert @@ -0,0 +1,22 @@ +#version 310 es + +struct Light +{ + vec3 Position; + float Radius; + vec4 Color; +}; + +uniform vec4 UBO[6]; +layout(location = 0) in vec4 aVertex; +layout(location = 0) out vec4 vColor; +layout(location = 1) in vec3 aNormal; + +void main() +{ + gl_Position = mat4(UBO[0], UBO[1], UBO[2], UBO[3]) * aVertex; + vColor = vec4(0.0); + vec3 L = aVertex.xyz - UBO[4].xyz; + vColor += ((UBO[5] * clamp(1.0 - (length(L) / UBO[4].w), 0.0, 1.0)) * dot(aNormal, normalize(L))); +} + diff --git a/reference/shaders/flatten/struct.rowmajor.flatten.vert b/reference/shaders/flatten/struct.rowmajor.flatten.vert new file mode 100644 index 0000000000..a40aea08af --- /dev/null +++ b/reference/shaders/flatten/struct.rowmajor.flatten.vert @@ -0,0 +1,25 @@ +#version 310 es + +struct Foo +{ + mat3x4 MVP0; + mat3x4 MVP1; +}; + +uniform vec4 UBO[8]; +layout(location = 0) in vec4 v0; +layout(location = 1) in vec4 v1; +layout(location = 0) out vec3 V0; +layout(location = 1) out vec3 V1; + +void main() +{ + Foo f; + f.MVP0 = Foo(transpose(mat4x3(UBO[0].xyz, UBO[1].xyz, UBO[2].xyz, UBO[3].xyz)), transpose(mat4x3(UBO[4].xyz, UBO[5].xyz, UBO[6].xyz, UBO[7].xyz))).MVP0; + f.MVP1 = Foo(transpose(mat4x3(UBO[0].xyz, UBO[1].xyz, UBO[2].xyz, UBO[3].xyz)), transpose(mat4x3(UBO[4].xyz, UBO[5].xyz, UBO[6].xyz, UBO[7].xyz))).MVP1; + vec3 a = v0 * f.MVP0; + vec3 b = v1 * f.MVP1; + V0 = a; + V1 = b; +} + diff --git a/reference/shaders/flatten/swizzle.flatten.vert b/reference/shaders/flatten/swizzle.flatten.vert new file mode 100644 index 0000000000..92afb475e6 --- /dev/null +++ b/reference/shaders/flatten/swizzle.flatten.vert @@ -0,0 +1,21 @@ +#version 310 es + +uniform vec4 UBO[8]; +layout(location = 0) out vec4 oA; +layout(location = 1) out vec4 oB; +layout(location = 2) out vec4 oC; +layout(location = 3) out vec4 oD; +layout(location = 4) out vec4 oE; +layout(location = 5) out vec4 oF; + +void main() +{ + gl_Position = vec4(0.0); + oA = UBO[0]; + oB = vec4(UBO[1].xy, UBO[1].zw); + oC = vec4(UBO[2].x, UBO[3].xyz); + oD = vec4(UBO[4].xyz, UBO[4].w); + oE = vec4(UBO[5].x, UBO[5].y, UBO[5].z, UBO[5].w); + oF = vec4(UBO[6].x, UBO[6].zw, UBO[7].x); +} + diff --git a/reference/shaders/flatten/types.flatten.frag b/reference/shaders/flatten/types.flatten.frag new file mode 100644 index 0000000000..a74327d97b --- /dev/null +++ b/reference/shaders/flatten/types.flatten.frag @@ -0,0 +1,14 @@ +#version 310 es +precision mediump float; +precision highp int; + +uniform mediump ivec4 UBO1[2]; +uniform mediump uvec4 UBO2[2]; +uniform vec4 UBO0[2]; +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = ((((vec4(UBO1[0]) + vec4(UBO1[1])) + vec4(UBO2[0])) + vec4(UBO2[1])) + UBO0[0]) + UBO0[1]; +} + diff --git a/reference/shaders/frag/basic.frag b/reference/shaders/frag/basic.frag new file mode 100644 index 0000000000..2a4e440421 --- /dev/null +++ b/reference/shaders/frag/basic.frag @@ -0,0 +1,15 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(binding = 0) uniform mediump sampler2D uTex; + +layout(location = 0) out vec4 FragColor; +layout(location = 0) in vec4 vColor; +layout(location = 1) in vec2 vTex; + +void main() +{ + FragColor = vColor * texture(uTex, vTex); +} + diff --git a/reference/shaders/frag/composite-extract-forced-temporary.frag b/reference/shaders/frag/composite-extract-forced-temporary.frag new file mode 100644 index 0000000000..e4384f559e --- /dev/null +++ b/reference/shaders/frag/composite-extract-forced-temporary.frag @@ -0,0 +1,15 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(binding = 0) uniform mediump sampler2D Texture; + +layout(location = 0) in vec2 vTexCoord; +layout(location = 0) out vec4 FragColor; + +void main() +{ + float f = texture(Texture, vTexCoord).x; + FragColor = vec4(f * f); +} + diff --git a/reference/shaders/frag/constant-array.frag b/reference/shaders/frag/constant-array.frag new file mode 100644 index 0000000000..4da9b8948b --- /dev/null +++ b/reference/shaders/frag/constant-array.frag @@ -0,0 +1,28 @@ +#version 310 es +precision mediump float; +precision highp int; + +struct Foobar +{ + float a; + float b; +}; + +layout(location = 0) out vec4 FragColor; +layout(location = 0) flat in mediump int index; + +vec4 resolve(Foobar f) +{ + return vec4(f.a + f.b); +} + +void main() +{ + highp vec4 indexable[3] = vec4[](vec4(1.0), vec4(2.0), vec4(3.0)); + highp vec4 indexable_1[2][2] = vec4[][](vec4[](vec4(1.0), vec4(2.0)), vec4[](vec4(8.0), vec4(10.0))); + Foobar param = Foobar(10.0, 20.0); + Foobar indexable_2[2] = Foobar[](Foobar(10.0, 40.0), Foobar(90.0, 70.0)); + Foobar param_1 = indexable_2[index]; + FragColor = ((indexable[index] + (indexable_1[index][index + 1])) + resolve(param)) + resolve(param_1); +} + diff --git a/reference/shaders/frag/constant-composites.frag b/reference/shaders/frag/constant-composites.frag new file mode 100644 index 0000000000..ab0816c3d2 --- /dev/null +++ b/reference/shaders/frag/constant-composites.frag @@ -0,0 +1,23 @@ +#version 310 es +precision mediump float; +precision highp int; + +struct Foo +{ + float a; + float b; +}; + +layout(location = 0) out vec4 FragColor; +layout(location = 0) flat in mediump int _line; +float lut[4]; +Foo foos[2]; + +void main() +{ + lut = float[](1.0, 4.0, 3.0, 2.0); + foos = Foo[](Foo(10.0, 20.0), Foo(30.0, 40.0)); + FragColor = vec4(lut[_line]); + FragColor += vec4(foos[_line].a * (foos[1 - _line].a)); +} + diff --git a/reference/shaders/frag/false-loop-init.frag b/reference/shaders/frag/false-loop-init.frag new file mode 100644 index 0000000000..b0ed5577d3 --- /dev/null +++ b/reference/shaders/frag/false-loop-init.frag @@ -0,0 +1,25 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(location = 0) out vec4 result; +layout(location = 0) in vec4 accum; + +void main() +{ + result = vec4(0.0); + mediump uint j; + for (mediump int i = 0; i < 4; i += int(j)) + { + if (accum.y > 10.0) + { + j = 40u; + } + else + { + j = 30u; + } + result += accum; + } +} + diff --git a/reference/shaders/frag/flush_params.frag b/reference/shaders/frag/flush_params.frag new file mode 100644 index 0000000000..b4b36ff90d --- /dev/null +++ b/reference/shaders/frag/flush_params.frag @@ -0,0 +1,30 @@ +#version 310 es +precision mediump float; +precision highp int; + +struct Structy +{ + vec4 c; +}; + +layout(location = 0) out vec4 FragColor; + +void foo2(inout Structy f) +{ + f.c = vec4(10.0); +} + +Structy foo() +{ + Structy param; + foo2(param); + Structy f = param; + return f; +} + +void main() +{ + Structy s = foo(); + FragColor = s.c; +} + diff --git a/reference/shaders/frag/for-loop-init.frag b/reference/shaders/frag/for-loop-init.frag new file mode 100644 index 0000000000..7c22e5c785 --- /dev/null +++ b/reference/shaders/frag/for-loop-init.frag @@ -0,0 +1,52 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(location = 0) out mediump int FragColor; + +void main() +{ + FragColor = 16; + for (mediump int i = 0; i < 25; i++) + { + FragColor += 10; + } + for (mediump int i_1 = 1, j = 4; i_1 < 30; i_1++, j += 4) + { + FragColor += 11; + } + mediump int k = 0; + for (; k < 20; k++) + { + FragColor += 12; + } + k += 3; + FragColor += k; + mediump int l; + if (k == 40) + { + l = 0; + for (; l < 40; l++) + { + FragColor += 13; + } + return; + } + else + { + l = k; + FragColor += l; + } + mediump ivec2 i_2 = ivec2(0); + for (; i_2.x < 10; i_2.x += 4) + { + FragColor += i_2.y; + } + mediump int o = k; + for (mediump int m = k; m < 40; m++) + { + FragColor += m; + } + FragColor += o; +} + diff --git a/reference/shaders/frag/frexp-modf.frag b/reference/shaders/frag/frexp-modf.frag new file mode 100644 index 0000000000..e495bb3169 --- /dev/null +++ b/reference/shaders/frag/frexp-modf.frag @@ -0,0 +1,43 @@ +#version 310 es +precision mediump float; +precision highp int; + +struct ResType +{ + highp float _m0; + int _m1; +}; + +struct ResType_1 +{ + highp vec2 _m0; + ivec2 _m1; +}; + +layout(location = 0) in float v0; +layout(location = 1) in vec2 v1; +layout(location = 0) out float FragColor; + +void main() +{ + ResType _16; + _16._m0 = frexp(v0, _16._m1); + mediump int e0 = _16._m1; + float f0 = _16._m0; + ResType _22; + _22._m0 = frexp(v0 + 1.0, _22._m1); + e0 = _22._m1; + f0 = _22._m0; + ResType_1 _35; + _35._m0 = frexp(v1, _35._m1); + mediump ivec2 e1 = _35._m1; + vec2 f1 = _35._m0; + float r0; + float _41 = modf(v0, r0); + float m0 = _41; + vec2 r1; + vec2 _45 = modf(v1, r1); + vec2 m1 = _45; + FragColor = ((((f0 + f1.x) + f1.y) + m0) + m1.x) + m1.y; +} + diff --git a/reference/shaders/frag/ground.frag b/reference/shaders/frag/ground.frag new file mode 100644 index 0000000000..4d998d5689 --- /dev/null +++ b/reference/shaders/frag/ground.frag @@ -0,0 +1,62 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(binding = 4, std140) uniform GlobalPSData +{ + vec4 g_CamPos; + vec4 g_SunDir; + vec4 g_SunColor; + vec4 g_ResolutionParams; + vec4 g_TimeParams; + vec4 g_FogColor_Distance; +} _101; + +layout(binding = 2) uniform mediump sampler2D TexNormalmap; + +layout(location = 3) out vec4 LightingOut; +layout(location = 2) out vec4 NormalOut; +layout(location = 1) out vec4 SpecularOut; +layout(location = 0) out vec4 AlbedoOut; +layout(location = 0) in vec2 TexCoord; +layout(location = 1) in vec3 EyeVec; + +float saturate(float x) +{ + return clamp(x, 0.0, 1.0); +} + +void Resolve(vec3 Albedo, vec3 Normal, float Roughness, float Metallic) +{ + LightingOut = vec4(0.0); + NormalOut = vec4((Normal * 0.5) + vec3(0.5), 0.0); + SpecularOut = vec4(Roughness, Metallic, 0.0, 0.0); + AlbedoOut = vec4(Albedo, 1.0); +} + +void main() +{ + vec3 Normal = (texture(TexNormalmap, TexCoord).xyz * 2.0) - vec3(1.0); + Normal = normalize(Normal); + highp float param = length(EyeVec) / 1000.0; + vec2 scatter_uv; + scatter_uv.x = saturate(param); + vec3 nEye = normalize(EyeVec); + scatter_uv.y = 0.0; + vec3 Color = vec3(0.100000001490116119384765625, 0.300000011920928955078125, 0.100000001490116119384765625); + vec3 grass = vec3(0.100000001490116119384765625, 0.300000011920928955078125, 0.100000001490116119384765625); + vec3 dirt = vec3(0.100000001490116119384765625); + vec3 snow = vec3(0.800000011920928955078125); + float grass_snow = smoothstep(0.0, 0.1500000059604644775390625, (_101.g_CamPos.y + EyeVec.y) / 200.0); + vec3 base = mix(grass, snow, vec3(grass_snow)); + float edge = smoothstep(0.699999988079071044921875, 0.75, Normal.y); + Color = mix(dirt, base, vec3(edge)); + Color *= Color; + float Roughness = 1.0 - (edge * grass_snow); + highp vec3 param_1 = Color; + highp vec3 param_2 = Normal; + highp float param_3 = Roughness; + highp float param_4 = 0.0; + Resolve(param_1, param_2, param_3, param_4); +} + diff --git a/reference/shaders/frag/image-load-store-uint-coord.asm.frag b/reference/shaders/frag/image-load-store-uint-coord.asm.frag new file mode 100644 index 0000000000..414dd956af --- /dev/null +++ b/reference/shaders/frag/image-load-store-uint-coord.asm.frag @@ -0,0 +1,26 @@ +#version 450 + +layout(binding = 1, rgba32f) uniform image2D RWIm; +layout(binding = 0, rgba32f) uniform writeonly imageBuffer RWBuf; +layout(binding = 1) uniform sampler2D ROIm; +layout(binding = 0) uniform samplerBuffer ROBuf; + +layout(location = 0) out vec4 _entryPointOutput; + +vec4 _main() +{ + vec4 storeTemp = vec4(10.0, 0.5, 8.0, 2.0); + imageStore(RWIm, ivec2(uvec2(10u)), storeTemp); + vec4 v = imageLoad(RWIm, ivec2(uvec2(30u))); + imageStore(RWBuf, int(80u), v); + v += texelFetch(ROIm, ivec2(uvec2(50u, 60u)), 0); + v += texelFetch(ROBuf, int(80u)); + return v; +} + +void main() +{ + vec4 _45 = _main(); + _entryPointOutput = _45; +} + diff --git a/reference/shaders/frag/mix.frag b/reference/shaders/frag/mix.frag new file mode 100644 index 0000000000..2b288dff02 --- /dev/null +++ b/reference/shaders/frag/mix.frag @@ -0,0 +1,20 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(location = 0) out vec4 FragColor; +layout(location = 0) in vec4 vIn0; +layout(location = 1) in vec4 vIn1; +layout(location = 2) in float vIn2; +layout(location = 3) in float vIn3; + +void main() +{ + bvec4 l = bvec4(false, true, false, false); + FragColor = mix(vIn0, vIn1, l); + bool f = true; + FragColor = vec4(f ? vIn3 : vIn2); + FragColor = mix(vIn1, vIn0, bvec4(f)); + FragColor = vec4(f ? vIn2 : vIn3); +} + diff --git a/reference/shaders/frag/partial-write-preserve.frag b/reference/shaders/frag/partial-write-preserve.frag new file mode 100644 index 0000000000..cf8a83cf0c --- /dev/null +++ b/reference/shaders/frag/partial-write-preserve.frag @@ -0,0 +1,109 @@ +#version 310 es +precision mediump float; +precision highp int; + +struct B +{ + float a; + float b; +}; + +layout(binding = 0, std140) uniform UBO +{ + mediump int some_value; +} _51; + +void partial_inout(inout vec4 x) +{ + x.x = 10.0; +} + +void complete_inout(out vec4 x) +{ + x = vec4(50.0); +} + +void branchy_inout(inout vec4 v) +{ + v.y = 20.0; + if (_51.some_value == 20) + { + v = vec4(50.0); + } +} + +void branchy_inout_2(out vec4 v) +{ + if (_51.some_value == 20) + { + v = vec4(50.0); + } + else + { + v = vec4(70.0); + } + v.y = 20.0; +} + +void partial_inout(inout B b) +{ + b.b = 40.0; +} + +void complete_inout(out B b) +{ + b = B(100.0, 200.0); +} + +void branchy_inout(inout B b) +{ + b.b = 20.0; + if (_51.some_value == 20) + { + b = B(10.0, 40.0); + } +} + +void branchy_inout_2(out B b) +{ + if (_51.some_value == 20) + { + b = B(10.0, 40.0); + } + else + { + b = B(70.0, 70.0); + } + b.b = 20.0; +} + +void main() +{ + vec4 a = vec4(10.0); + highp vec4 param = a; + partial_inout(param); + a = param; + highp vec4 param_1; + complete_inout(param_1); + a = param_1; + highp vec4 param_2 = a; + branchy_inout(param_2); + a = param_2; + highp vec4 param_3; + branchy_inout_2(param_3); + a = param_3; + B b = B(10.0, 20.0); + B param_4 = b; + partial_inout(param_4); + b = param_4; + B param_5; + complete_inout(param_5); + b = param_5; + B param_6 = b; + branchy_inout(param_6); + b = param_6; + B param_7; + branchy_inout_2(param_7); + b = param_7; +} + diff --git a/reference/shaders/frag/pls.frag b/reference/shaders/frag/pls.frag new file mode 100644 index 0000000000..1cafdbd365 --- /dev/null +++ b/reference/shaders/frag/pls.frag @@ -0,0 +1,21 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(location = 0) out vec4 PLSOut0; +layout(location = 0) in vec4 PLSIn0; +layout(location = 1) out vec4 PLSOut1; +layout(location = 1) in vec4 PLSIn1; +layout(location = 2) out vec4 PLSOut2; +layout(location = 2) in vec4 PLSIn2; +layout(location = 3) out vec4 PLSOut3; +layout(location = 3) in vec4 PLSIn3; + +void main() +{ + PLSOut0 = PLSIn0 * 2.0; + PLSOut1 = PLSIn1 * 6.0; + PLSOut2 = PLSIn2 * 7.0; + PLSOut3 = PLSIn3 * 4.0; +} + diff --git a/reference/shaders/frag/sample-parameter.frag b/reference/shaders/frag/sample-parameter.frag new file mode 100644 index 0000000000..3c130e68d4 --- /dev/null +++ b/reference/shaders/frag/sample-parameter.frag @@ -0,0 +1,13 @@ +#version 310 es +#extension GL_OES_sample_variables : require +precision mediump float; +precision highp int; + +layout(location = 0) out vec2 FragColor; + +void main() +{ + FragColor = (gl_SamplePosition + vec2(float(gl_SampleMaskIn[0]))) + vec2(float(gl_SampleID)); + gl_SampleMask[0] = 1; +} + diff --git a/reference/shaders/frag/sampler-ms.frag b/reference/shaders/frag/sampler-ms.frag new file mode 100644 index 0000000000..dbab3fb819 --- /dev/null +++ b/reference/shaders/frag/sampler-ms.frag @@ -0,0 +1,14 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(binding = 0) uniform mediump sampler2DMS uSampler; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + ivec2 coord = ivec2(gl_FragCoord.xy); + FragColor = ((texelFetch(uSampler, coord, 0) + texelFetch(uSampler, coord, 1)) + texelFetch(uSampler, coord, 2)) + texelFetch(uSampler, coord, 3); +} + diff --git a/reference/shaders/frag/sampler-proj.frag b/reference/shaders/frag/sampler-proj.frag new file mode 100644 index 0000000000..865dec6c8b --- /dev/null +++ b/reference/shaders/frag/sampler-proj.frag @@ -0,0 +1,16 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(binding = 0) uniform mediump sampler2D uTex; + +layout(location = 0) out vec4 FragColor; +layout(location = 0) in vec4 vTex; + +void main() +{ + highp vec4 _19 = vTex; + _19.z = vTex.w; + FragColor = textureProj(uTex, _19.xyz); +} + diff --git a/reference/shaders/frag/sampler.frag b/reference/shaders/frag/sampler.frag new file mode 100644 index 0000000000..0ec200c714 --- /dev/null +++ b/reference/shaders/frag/sampler.frag @@ -0,0 +1,21 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(binding = 0) uniform mediump sampler2D uTex; + +layout(location = 0) out vec4 FragColor; +layout(location = 0) in vec4 vColor; +layout(location = 1) in vec2 vTex; + +vec4 sample_texture(mediump sampler2D tex, vec2 uv) +{ + return texture(tex, uv); +} + +void main() +{ + highp vec2 param = vTex; + FragColor = vColor * sample_texture(uTex, param); +} + diff --git a/reference/shaders/frag/swizzle.frag b/reference/shaders/frag/swizzle.frag new file mode 100644 index 0000000000..e619be2f48 --- /dev/null +++ b/reference/shaders/frag/swizzle.frag @@ -0,0 +1,20 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(location = 0) uniform mediump sampler2D samp; + +layout(location = 0) out vec4 FragColor; +layout(location = 2) in vec2 vUV; +layout(location = 1) in vec3 vNormal; + +void main() +{ + FragColor = vec4(texture(samp, vUV).xyz, 1.0); + FragColor = vec4(texture(samp, vUV).xz, 1.0, 4.0); + FragColor = vec4(texture(samp, vUV).xx, texture(samp, vUV + vec2(0.100000001490116119384765625)).yy); + FragColor = vec4(vNormal, 1.0); + FragColor = vec4(vNormal + vec3(1.7999999523162841796875), 1.0); + FragColor = vec4(vUV, vUV + vec2(1.7999999523162841796875)); +} + diff --git a/reference/shaders/frag/ubo_layout.frag b/reference/shaders/frag/ubo_layout.frag new file mode 100644 index 0000000000..bc0b01c065 --- /dev/null +++ b/reference/shaders/frag/ubo_layout.frag @@ -0,0 +1,26 @@ +#version 310 es +precision mediump float; +precision highp int; + +struct Str +{ + mat4 foo; +}; + +layout(binding = 0, std140) uniform UBO1 +{ + layout(row_major) Str foo; +} ubo1; + +layout(binding = 1, std140) uniform UBO2 +{ + Str foo; +} ubo0; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = ubo1.foo.foo[0] + ubo0.foo.foo[0]; +} + diff --git a/reference/shaders/frag/unary-enclose.frag b/reference/shaders/frag/unary-enclose.frag new file mode 100644 index 0000000000..3006e86cb5 --- /dev/null +++ b/reference/shaders/frag/unary-enclose.frag @@ -0,0 +1,16 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(location = 0) out vec4 FragColor; +layout(location = 0) in vec4 vIn; +layout(location = 1) flat in mediump ivec4 vIn1; + +void main() +{ + FragColor = -(-vIn); + mediump ivec4 a = ~(~vIn1); + bool b = false; + b = !(!b); +} + diff --git a/reference/shaders/geom/basic.geom b/reference/shaders/geom/basic.geom new file mode 100644 index 0000000000..296ce5792c --- /dev/null +++ b/reference/shaders/geom/basic.geom @@ -0,0 +1,26 @@ +#version 310 es +#extension GL_EXT_geometry_shader : require +layout(invocations = 4, triangles) in; +layout(max_vertices = 3, triangle_strip) out; + +layout(location = 0) out vec3 vNormal; +layout(location = 0) in VertexData +{ + vec3 normal; +} vin[3]; + + +void main() +{ + gl_Position = gl_in[0].gl_Position; + vNormal = vin[0].normal + vec3(float(gl_InvocationID)); + EmitVertex(); + gl_Position = gl_in[1].gl_Position; + vNormal = vin[1].normal + vec3(4.0 * float(gl_InvocationID)); + EmitVertex(); + gl_Position = gl_in[2].gl_Position; + vNormal = vin[2].normal + vec3(2.0 * float(gl_InvocationID)); + EmitVertex(); + EndPrimitive(); +} + diff --git a/reference/shaders/geom/lines-adjacency.geom b/reference/shaders/geom/lines-adjacency.geom new file mode 100644 index 0000000000..46a21e9fb0 --- /dev/null +++ b/reference/shaders/geom/lines-adjacency.geom @@ -0,0 +1,26 @@ +#version 310 es +#extension GL_EXT_geometry_shader : require +layout(lines_adjacency) in; +layout(max_vertices = 3, line_strip) out; + +layout(location = 0) out vec3 vNormal; +layout(location = 0) in VertexData +{ + vec3 normal; +} vin[4]; + + +void main() +{ + gl_Position = gl_in[0].gl_Position; + vNormal = vin[0].normal; + EmitVertex(); + gl_Position = gl_in[1].gl_Position; + vNormal = vin[1].normal; + EmitVertex(); + gl_Position = gl_in[2].gl_Position; + vNormal = vin[2].normal; + EmitVertex(); + EndPrimitive(); +} + diff --git a/reference/shaders/geom/lines.geom b/reference/shaders/geom/lines.geom new file mode 100644 index 0000000000..c5aaa53d35 --- /dev/null +++ b/reference/shaders/geom/lines.geom @@ -0,0 +1,23 @@ +#version 310 es +#extension GL_EXT_geometry_shader : require +layout(lines) in; +layout(max_vertices = 2, line_strip) out; + +layout(location = 0) out vec3 vNormal; +layout(location = 0) in VertexData +{ + vec3 normal; +} vin[2]; + + +void main() +{ + gl_Position = gl_in[0].gl_Position; + vNormal = vin[0].normal; + EmitVertex(); + gl_Position = gl_in[1].gl_Position; + vNormal = vin[1].normal; + EmitVertex(); + EndPrimitive(); +} + diff --git a/reference/shaders/geom/points.geom b/reference/shaders/geom/points.geom new file mode 100644 index 0000000000..4d59137c3a --- /dev/null +++ b/reference/shaders/geom/points.geom @@ -0,0 +1,26 @@ +#version 310 es +#extension GL_EXT_geometry_shader : require +layout(points) in; +layout(max_vertices = 3, points) out; + +layout(location = 0) out vec3 vNormal; +layout(location = 0) in VertexData +{ + vec3 normal; +} vin[1]; + + +void main() +{ + gl_Position = gl_in[0].gl_Position; + vNormal = vin[0].normal; + EmitVertex(); + gl_Position = gl_in[0].gl_Position; + vNormal = vin[0].normal; + EmitVertex(); + gl_Position = gl_in[0].gl_Position; + vNormal = vin[0].normal; + EmitVertex(); + EndPrimitive(); +} + diff --git a/reference/shaders/geom/single-invocation.geom b/reference/shaders/geom/single-invocation.geom new file mode 100644 index 0000000000..fdccacc04f --- /dev/null +++ b/reference/shaders/geom/single-invocation.geom @@ -0,0 +1,26 @@ +#version 310 es +#extension GL_EXT_geometry_shader : require +layout(triangles) in; +layout(max_vertices = 3, triangle_strip) out; + +layout(location = 0) out vec3 vNormal; +layout(location = 0) in VertexData +{ + vec3 normal; +} vin[3]; + + +void main() +{ + gl_Position = gl_in[0].gl_Position; + vNormal = vin[0].normal; + EmitVertex(); + gl_Position = gl_in[1].gl_Position; + vNormal = vin[1].normal; + EmitVertex(); + gl_Position = gl_in[2].gl_Position; + vNormal = vin[2].normal; + EmitVertex(); + EndPrimitive(); +} + diff --git a/reference/shaders/geom/triangles-adjacency.geom b/reference/shaders/geom/triangles-adjacency.geom new file mode 100644 index 0000000000..e9e6857a1f --- /dev/null +++ b/reference/shaders/geom/triangles-adjacency.geom @@ -0,0 +1,26 @@ +#version 310 es +#extension GL_EXT_geometry_shader : require +layout(triangles_adjacency) in; +layout(max_vertices = 3, triangle_strip) out; + +layout(location = 0) out vec3 vNormal; +layout(location = 0) in VertexData +{ + vec3 normal; +} vin[6]; + + +void main() +{ + gl_Position = gl_in[0].gl_Position; + vNormal = vin[0].normal; + EmitVertex(); + gl_Position = gl_in[1].gl_Position; + vNormal = vin[1].normal; + EmitVertex(); + gl_Position = gl_in[2].gl_Position; + vNormal = vin[2].normal; + EmitVertex(); + EndPrimitive(); +} + diff --git a/reference/shaders/geom/triangles.geom b/reference/shaders/geom/triangles.geom new file mode 100644 index 0000000000..fdccacc04f --- /dev/null +++ b/reference/shaders/geom/triangles.geom @@ -0,0 +1,26 @@ +#version 310 es +#extension GL_EXT_geometry_shader : require +layout(triangles) in; +layout(max_vertices = 3, triangle_strip) out; + +layout(location = 0) out vec3 vNormal; +layout(location = 0) in VertexData +{ + vec3 normal; +} vin[3]; + + +void main() +{ + gl_Position = gl_in[0].gl_Position; + vNormal = vin[0].normal; + EmitVertex(); + gl_Position = gl_in[1].gl_Position; + vNormal = vin[1].normal; + EmitVertex(); + gl_Position = gl_in[2].gl_Position; + vNormal = vin[2].normal; + EmitVertex(); + EndPrimitive(); +} + diff --git a/reference/shaders/legacy/fragment/explicit-lod.legacy.frag b/reference/shaders/legacy/fragment/explicit-lod.legacy.frag new file mode 100644 index 0000000000..6e8dbf1a9c --- /dev/null +++ b/reference/shaders/legacy/fragment/explicit-lod.legacy.frag @@ -0,0 +1,12 @@ +#version 100 +#extension GL_EXT_shader_texture_lod : require +precision mediump float; +precision highp int; + +uniform mediump sampler2D tex; + +void main() +{ + gl_FragData[0] = texture2DLodEXT(tex, vec2(0.4000000059604644775390625, 0.60000002384185791015625), 0.0); +} + diff --git a/reference/shaders/legacy/fragment/io-blocks.legacy.frag b/reference/shaders/legacy/fragment/io-blocks.legacy.frag new file mode 100644 index 0000000000..d5a60d53e9 --- /dev/null +++ b/reference/shaders/legacy/fragment/io-blocks.legacy.frag @@ -0,0 +1,12 @@ +#version 100 +precision mediump float; +precision highp int; + +varying vec4 vin_color; +varying highp vec3 vin_normal; + +void main() +{ + gl_FragData[0] = vin_color + vin_normal.xyzz; +} + diff --git a/reference/shaders/legacy/fragment/struct-varying.legacy.frag b/reference/shaders/legacy/fragment/struct-varying.legacy.frag new file mode 100644 index 0000000000..81b95dd816 --- /dev/null +++ b/reference/shaders/legacy/fragment/struct-varying.legacy.frag @@ -0,0 +1,22 @@ +#version 100 +precision mediump float; +precision highp int; + +struct Inputs +{ + highp vec4 a; + highp vec2 b; +}; + +varying highp vec4 vin_a; +varying highp vec2 vin_b; + +void main() +{ + Inputs v0 = Inputs(vin_a, vin_b); + Inputs v1 = Inputs(vin_a, vin_b); + highp vec4 a = vin_a; + highp vec4 b = vin_b.xxyy; + gl_FragData[0] = ((((v0.a + v0.b.xxyy) + v1.a) + v1.b.yyxx) + a) + b; +} + diff --git a/reference/shaders/legacy/vert/implicit-lod.legacy.vert b/reference/shaders/legacy/vert/implicit-lod.legacy.vert new file mode 100644 index 0000000000..6e44107448 --- /dev/null +++ b/reference/shaders/legacy/vert/implicit-lod.legacy.vert @@ -0,0 +1,9 @@ +#version 100 + +uniform mediump sampler2D tex; + +void main() +{ + gl_Position = texture2D(tex, vec2(0.4000000059604644775390625, 0.60000002384185791015625)); +} + diff --git a/reference/shaders/legacy/vert/io-block.legacy.vert b/reference/shaders/legacy/vert/io-block.legacy.vert new file mode 100644 index 0000000000..3c518dc79e --- /dev/null +++ b/reference/shaders/legacy/vert/io-block.legacy.vert @@ -0,0 +1,13 @@ +#version 100 + +attribute vec4 Position; +varying vec4 vout_color; +varying vec3 vout_normal; + +void main() +{ + gl_Position = Position; + vout_color = vec4(1.0); + vout_normal = vec3(0.5); +} + diff --git a/reference/shaders/legacy/vert/struct-varying.legacy.vert b/reference/shaders/legacy/vert/struct-varying.legacy.vert new file mode 100644 index 0000000000..261e986034 --- /dev/null +++ b/reference/shaders/legacy/vert/struct-varying.legacy.vert @@ -0,0 +1,32 @@ +#version 100 + +struct Output +{ + vec4 a; + vec2 b; +}; + +varying vec4 vout_a; +varying vec2 vout_b; + +void main() +{ + Output s = Output(vec4(0.5), vec2(0.25)); + { + Output vout = s; + vout_a = vout.a; + vout_b = vout.b; + } + { + Output vout = s; + vout_a = vout.a; + vout_b = vout.b; + } + Output tmp = Output(vout_a, vout_b); + vout_a = tmp.a; + vout_b = tmp.b; + vout_a.x = 1.0; + vout_b.y = 1.0; + float c = vout_a.x; +} + diff --git a/reference/shaders/legacy/vert/transpose.legacy.vert b/reference/shaders/legacy/vert/transpose.legacy.vert new file mode 100644 index 0000000000..c73d1a11d9 --- /dev/null +++ b/reference/shaders/legacy/vert/transpose.legacy.vert @@ -0,0 +1,22 @@ +#version 100 + +struct Buffer +{ + mat4 MVPRowMajor; + mat4 MVPColMajor; + mat4 M; +}; + +uniform Buffer _13; + +attribute vec4 Position; + +void main() +{ + vec4 c0 = _13.M * (Position * _13.MVPRowMajor); + vec4 c1 = _13.M * (_13.MVPColMajor * Position); + vec4 c2 = _13.M * (_13.MVPRowMajor * Position); + vec4 c3 = _13.M * (Position * _13.MVPColMajor); + gl_Position = ((c0 + c1) + c2) + c3; +} + diff --git a/reference/shaders/tesc/basic.tesc b/reference/shaders/tesc/basic.tesc new file mode 100644 index 0000000000..6019151adb --- /dev/null +++ b/reference/shaders/tesc/basic.tesc @@ -0,0 +1,17 @@ +#version 310 es +#extension GL_EXT_tessellation_shader : require +layout(vertices = 1) out; + +layout(location = 0) patch out vec3 vFoo; + +void main() +{ + gl_TessLevelInner[0] = 8.8999996185302734375; + gl_TessLevelInner[1] = 6.900000095367431640625; + gl_TessLevelOuter[0] = 8.8999996185302734375; + gl_TessLevelOuter[1] = 6.900000095367431640625; + gl_TessLevelOuter[2] = 3.900000095367431640625; + gl_TessLevelOuter[3] = 4.900000095367431640625; + vFoo = vec3(1.0); +} + diff --git a/reference/shaders/tesc/water_tess.tesc b/reference/shaders/tesc/water_tess.tesc new file mode 100644 index 0000000000..26611b8b25 --- /dev/null +++ b/reference/shaders/tesc/water_tess.tesc @@ -0,0 +1,117 @@ +#version 310 es +#extension GL_EXT_tessellation_shader : require +layout(vertices = 1) out; + +layout(std140) uniform UBO +{ + vec4 uScale; + vec3 uCamPos; + vec2 uPatchSize; + vec2 uMaxTessLevel; + float uDistanceMod; + vec4 uFrustum[6]; +} _41; + +layout(location = 1) patch out vec2 vOutPatchPosBase; +layout(location = 2) patch out vec4 vPatchLods; +layout(location = 0) in vec2 vPatchPosBase[]; + +bool frustum_cull(vec2 p0) +{ + vec2 min_xz = (p0 - vec2(10.0)) * _41.uScale.xy; + vec2 max_xz = ((p0 + _41.uPatchSize) + vec2(10.0)) * _41.uScale.xy; + vec3 bb_min = vec3(min_xz.x, -10.0, min_xz.y); + vec3 bb_max = vec3(max_xz.x, 10.0, max_xz.y); + vec3 center = (bb_min + bb_max) * 0.5; + float radius = 0.5 * length(bb_max - bb_min); + vec3 f0 = vec3(dot(_41.uFrustum[0], vec4(center, 1.0)), dot(_41.uFrustum[1], vec4(center, 1.0)), dot(_41.uFrustum[2], vec4(center, 1.0))); + vec3 f1 = vec3(dot(_41.uFrustum[3], vec4(center, 1.0)), dot(_41.uFrustum[4], vec4(center, 1.0)), dot(_41.uFrustum[5], vec4(center, 1.0))); + vec3 _199 = f0; + bool _205 = any(lessThanEqual(_199, vec3(-radius))); + bool _215; + if (!_205) + { + _215 = any(lessThanEqual(f1, vec3(-radius))); + } + else + { + _215 = _205; + } + return !_215; +} + +float lod_factor(vec2 pos_) +{ + vec2 pos = pos_ * _41.uScale.xy; + vec3 dist_to_cam = _41.uCamPos - vec3(pos.x, 0.0, pos.y); + float level = log2((length(dist_to_cam) + 9.9999997473787516355514526367188e-05) * _41.uDistanceMod); + return clamp(level, 0.0, _41.uMaxTessLevel.x); +} + +vec4 tess_level(vec4 lod) +{ + return exp2(-lod) * _41.uMaxTessLevel.y; +} + +float tess_level(float lod) +{ + return _41.uMaxTessLevel.y * exp2(-lod); +} + +void compute_tess_levels(vec2 p0) +{ + vOutPatchPosBase = p0; + vec2 param = p0 + (vec2(-0.5) * _41.uPatchSize); + float l00 = lod_factor(param); + vec2 param_1 = p0 + (vec2(0.5, -0.5) * _41.uPatchSize); + float l10 = lod_factor(param_1); + vec2 param_2 = p0 + (vec2(1.5, -0.5) * _41.uPatchSize); + float l20 = lod_factor(param_2); + vec2 param_3 = p0 + (vec2(-0.5, 0.5) * _41.uPatchSize); + float l01 = lod_factor(param_3); + vec2 param_4 = p0 + (vec2(0.5) * _41.uPatchSize); + float l11 = lod_factor(param_4); + vec2 param_5 = p0 + (vec2(1.5, 0.5) * _41.uPatchSize); + float l21 = lod_factor(param_5); + vec2 param_6 = p0 + (vec2(-0.5, 1.5) * _41.uPatchSize); + float l02 = lod_factor(param_6); + vec2 param_7 = p0 + (vec2(0.5, 1.5) * _41.uPatchSize); + float l12 = lod_factor(param_7); + vec2 param_8 = p0 + (vec2(1.5) * _41.uPatchSize); + float l22 = lod_factor(param_8); + vec4 lods = vec4(dot(vec4(l01, l11, l02, l12), vec4(0.25)), dot(vec4(l00, l10, l01, l11), vec4(0.25)), dot(vec4(l10, l20, l11, l21), vec4(0.25)), dot(vec4(l11, l21, l12, l22), vec4(0.25))); + vPatchLods = lods; + vec4 outer_lods = min(lods, lods.yzwx); + vec4 param_9 = outer_lods; + vec4 levels = tess_level(param_9); + gl_TessLevelOuter[0] = levels.x; + gl_TessLevelOuter[1] = levels.y; + gl_TessLevelOuter[2] = levels.z; + gl_TessLevelOuter[3] = levels.w; + float min_lod = min(min(lods.x, lods.y), min(lods.z, lods.w)); + float param_10 = min(min_lod, l11); + float inner = tess_level(param_10); + gl_TessLevelInner[0] = inner; + gl_TessLevelInner[1] = inner; +} + +void main() +{ + vec2 p0 = vPatchPosBase[0]; + vec2 param = p0; + if (!frustum_cull(param)) + { + gl_TessLevelOuter[0] = -1.0; + gl_TessLevelOuter[1] = -1.0; + gl_TessLevelOuter[2] = -1.0; + gl_TessLevelOuter[3] = -1.0; + gl_TessLevelInner[0] = -1.0; + gl_TessLevelInner[1] = -1.0; + } + else + { + vec2 param_1 = p0; + compute_tess_levels(param_1); + } +} + diff --git a/reference/shaders/tese/ccw.tese b/reference/shaders/tese/ccw.tese new file mode 100644 index 0000000000..a2a4508ac0 --- /dev/null +++ b/reference/shaders/tese/ccw.tese @@ -0,0 +1,9 @@ +#version 310 es +#extension GL_EXT_tessellation_shader : require +layout(triangles, ccw, fractional_even_spacing) in; + +void main() +{ + gl_Position = vec4(1.0); +} + diff --git a/reference/shaders/tese/cw.tese b/reference/shaders/tese/cw.tese new file mode 100644 index 0000000000..95781493d8 --- /dev/null +++ b/reference/shaders/tese/cw.tese @@ -0,0 +1,9 @@ +#version 310 es +#extension GL_EXT_tessellation_shader : require +layout(triangles, cw, fractional_even_spacing) in; + +void main() +{ + gl_Position = vec4(1.0); +} + diff --git a/reference/shaders/tese/equal.tese b/reference/shaders/tese/equal.tese new file mode 100644 index 0000000000..6d30518a30 --- /dev/null +++ b/reference/shaders/tese/equal.tese @@ -0,0 +1,9 @@ +#version 310 es +#extension GL_EXT_tessellation_shader : require +layout(triangles, cw, equal_spacing) in; + +void main() +{ + gl_Position = vec4(1.0); +} + diff --git a/reference/shaders/tese/fractional_even.tese b/reference/shaders/tese/fractional_even.tese new file mode 100644 index 0000000000..95781493d8 --- /dev/null +++ b/reference/shaders/tese/fractional_even.tese @@ -0,0 +1,9 @@ +#version 310 es +#extension GL_EXT_tessellation_shader : require +layout(triangles, cw, fractional_even_spacing) in; + +void main() +{ + gl_Position = vec4(1.0); +} + diff --git a/reference/shaders/tese/fractional_odd.tese b/reference/shaders/tese/fractional_odd.tese new file mode 100644 index 0000000000..608c19aba7 --- /dev/null +++ b/reference/shaders/tese/fractional_odd.tese @@ -0,0 +1,9 @@ +#version 310 es +#extension GL_EXT_tessellation_shader : require +layout(triangles, cw, fractional_odd_spacing) in; + +void main() +{ + gl_Position = vec4(1.0); +} + diff --git a/reference/shaders/tese/line.tese b/reference/shaders/tese/line.tese new file mode 100644 index 0000000000..8b6ad8da20 --- /dev/null +++ b/reference/shaders/tese/line.tese @@ -0,0 +1,9 @@ +#version 310 es +#extension GL_EXT_tessellation_shader : require +layout(isolines, point_mode, fractional_even_spacing) in; + +void main() +{ + gl_Position = vec4(1.0); +} + diff --git a/reference/shaders/tese/triangle.tese b/reference/shaders/tese/triangle.tese new file mode 100644 index 0000000000..95781493d8 --- /dev/null +++ b/reference/shaders/tese/triangle.tese @@ -0,0 +1,9 @@ +#version 310 es +#extension GL_EXT_tessellation_shader : require +layout(triangles, cw, fractional_even_spacing) in; + +void main() +{ + gl_Position = vec4(1.0); +} + diff --git a/reference/shaders/tese/water_tess.tese b/reference/shaders/tese/water_tess.tese new file mode 100644 index 0000000000..e743ed3e9c --- /dev/null +++ b/reference/shaders/tese/water_tess.tese @@ -0,0 +1,61 @@ +#version 310 es +#extension GL_EXT_tessellation_shader : require +layout(quads, cw, fractional_even_spacing) in; + +layout(binding = 1, std140) uniform UBO +{ + mat4 uMVP; + vec4 uScale; + vec2 uInvScale; + vec3 uCamPos; + vec2 uPatchSize; + vec2 uInvHeightmapSize; +} _31; + +layout(binding = 0) uniform mediump sampler2D uHeightmapDisplacement; + +layout(location = 0) patch in vec2 vOutPatchPosBase; +layout(location = 1) patch in vec4 vPatchLods; +layout(location = 1) out vec4 vGradNormalTex; +layout(location = 0) out vec3 vWorld; + +vec2 lerp_vertex(vec2 tess_coord) +{ + return vOutPatchPosBase + (tess_coord * _31.uPatchSize); +} + +mediump vec2 lod_factor(vec2 tess_coord) +{ + mediump vec2 x = mix(vPatchLods.yx, vPatchLods.zw, vec2(tess_coord.x)); + mediump float level = mix(x.x, x.y, tess_coord.y); + mediump float floor_level = floor(level); + mediump float fract_level = level - floor_level; + return vec2(floor_level, fract_level); +} + +mediump vec3 sample_height_displacement(vec2 uv, vec2 off, mediump vec2 lod) +{ + return mix(textureLod(uHeightmapDisplacement, uv + (off * 0.5), lod.x).xyz, textureLod(uHeightmapDisplacement, uv + (off * 1.0), lod.x + 1.0).xyz, vec3(lod.y)); +} + +void main() +{ + vec2 tess_coord = gl_TessCoord.xy; + vec2 param = tess_coord; + vec2 pos = lerp_vertex(param); + vec2 param_1 = tess_coord; + mediump vec2 lod = lod_factor(param_1); + vec2 tex = pos * _31.uInvHeightmapSize; + pos *= _31.uScale.xy; + mediump float delta_mod = exp2(lod.x); + vec2 off = _31.uInvHeightmapSize * delta_mod; + vGradNormalTex = vec4(tex + (_31.uInvHeightmapSize * 0.5), tex * _31.uScale.zw); + vec2 param_2 = tex; + vec2 param_3 = off; + vec2 param_4 = lod; + vec3 height_displacement = sample_height_displacement(param_2, param_3, param_4); + pos += height_displacement.yz; + vWorld = vec3(pos.x, height_displacement.x, pos.y); + gl_Position = _31.uMVP * vec4(vWorld, 1.0); +} + diff --git a/reference/shaders/vert/basic.vert b/reference/shaders/vert/basic.vert new file mode 100644 index 0000000000..05504eb2f2 --- /dev/null +++ b/reference/shaders/vert/basic.vert @@ -0,0 +1,17 @@ +#version 310 es + +layout(std140) uniform UBO +{ + mat4 uMVP; +} _16; + +layout(location = 0) in vec4 aVertex; +layout(location = 0) out vec3 vNormal; +layout(location = 1) in vec3 aNormal; + +void main() +{ + gl_Position = _16.uMVP * aVertex; + vNormal = aNormal; +} + diff --git a/reference/shaders/vert/ground.vert b/reference/shaders/vert/ground.vert new file mode 100644 index 0000000000..b028cc34c6 --- /dev/null +++ b/reference/shaders/vert/ground.vert @@ -0,0 +1,110 @@ +#version 310 es + +struct PatchData +{ + vec4 Position; + vec4 LODs; +}; + +layout(binding = 0, std140) uniform PerPatch +{ + PatchData Patches[256]; +} _53; + +layout(binding = 2, std140) uniform GlobalGround +{ + vec4 GroundScale; + vec4 GroundPosition; + vec4 InvGroundSize_PatchScale; +} _156; + +layout(binding = 0, std140) uniform GlobalVSData +{ + vec4 g_ViewProj_Row0; + vec4 g_ViewProj_Row1; + vec4 g_ViewProj_Row2; + vec4 g_ViewProj_Row3; + vec4 g_CamPos; + vec4 g_CamRight; + vec4 g_CamUp; + vec4 g_CamFront; + vec4 g_SunDir; + vec4 g_SunColor; + vec4 g_TimeParams; + vec4 g_ResolutionParams; + vec4 g_CamAxisRight; + vec4 g_FogColor_Distance; + vec4 g_ShadowVP_Row0; + vec4 g_ShadowVP_Row1; + vec4 g_ShadowVP_Row2; + vec4 g_ShadowVP_Row3; +} _236; + +layout(binding = 1) uniform mediump sampler2D TexLOD; +layout(binding = 0) uniform mediump sampler2D TexHeightmap; + +layout(location = 1) in vec4 LODWeights; +uniform int SPIRV_Cross_BaseInstance; +layout(location = 0) in vec2 Position; +layout(location = 1) out vec3 EyeVec; +layout(location = 0) out vec2 TexCoord; + +vec2 warp_position() +{ + float vlod = dot(LODWeights, _53.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].LODs); + vlod = all(equal(LODWeights, vec4(0.0))) ? _53.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].Position.w : vlod; + float floor_lod = floor(vlod); + float fract_lod = vlod - floor_lod; + uint ufloor_lod = uint(floor_lod); + uvec2 uPosition = uvec2(Position); + uvec2 mask = (uvec2(1u) << uvec2(ufloor_lod, ufloor_lod + 1u)) - uvec2(1u); + uint _106; + if (uPosition.x < 32u) + { + _106 = mask.x; + } + else + { + _106 = 0u; + } + uint _116 = _106; + uint _117; + if (uPosition.y < 32u) + { + _117 = mask.y; + } + else + { + _117 = 0u; + } + uvec2 rounding = uvec2(_116, _117); + vec4 lower_upper_snapped = vec4((uPosition + rounding).xyxy & (~mask).xxyy); + return mix(lower_upper_snapped.xy, lower_upper_snapped.zw, vec2(fract_lod)); +} + +vec2 lod_factor(vec2 uv) +{ + float level = textureLod(TexLOD, uv, 0.0).x * 7.96875; + float floor_level = floor(level); + float fract_level = level - floor_level; + return vec2(floor_level, fract_level); +} + +void main() +{ + vec2 PatchPos = _53.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].Position.xz * _156.InvGroundSize_PatchScale.zw; + vec2 WarpedPos = warp_position(); + vec2 VertexPos = PatchPos + WarpedPos; + vec2 NormalizedPos = VertexPos * _156.InvGroundSize_PatchScale.xy; + vec2 param = NormalizedPos; + vec2 lod = lod_factor(param); + vec2 Offset = _156.InvGroundSize_PatchScale.xy * exp2(lod.x); + float Elevation = mix(textureLod(TexHeightmap, NormalizedPos + (Offset * 0.5), lod.x).x, textureLod(TexHeightmap, NormalizedPos + (Offset * 1.0), lod.x + 1.0).x, lod.y); + vec3 WorldPos = vec3(NormalizedPos.x, Elevation, NormalizedPos.y); + WorldPos *= _156.GroundScale.xyz; + WorldPos += _156.GroundPosition.xyz; + EyeVec = WorldPos - _236.g_CamPos.xyz; + TexCoord = NormalizedPos + (_156.InvGroundSize_PatchScale.xy * 0.5); + gl_Position = (((_236.g_ViewProj_Row0 * WorldPos.x) + (_236.g_ViewProj_Row1 * WorldPos.y)) + (_236.g_ViewProj_Row2 * WorldPos.z)) + _236.g_ViewProj_Row3; +} + diff --git a/reference/shaders/vert/ocean.vert b/reference/shaders/vert/ocean.vert new file mode 100644 index 0000000000..d77a29fcbf --- /dev/null +++ b/reference/shaders/vert/ocean.vert @@ -0,0 +1,133 @@ +#version 310 es + +struct PatchData +{ + vec4 Position; + vec4 LODs; +}; + +layout(binding = 0, std140) uniform Offsets +{ + PatchData Patches[256]; +} _53; + +layout(binding = 4, std140) uniform GlobalOcean +{ + vec4 OceanScale; + vec4 OceanPosition; + vec4 InvOceanSize_PatchScale; + vec4 NormalTexCoordScale; +} _180; + +layout(binding = 0, std140) uniform GlobalVSData +{ + vec4 g_ViewProj_Row0; + vec4 g_ViewProj_Row1; + vec4 g_ViewProj_Row2; + vec4 g_ViewProj_Row3; + vec4 g_CamPos; + vec4 g_CamRight; + vec4 g_CamUp; + vec4 g_CamFront; + vec4 g_SunDir; + vec4 g_SunColor; + vec4 g_TimeParams; + vec4 g_ResolutionParams; + vec4 g_CamAxisRight; + vec4 g_FogColor_Distance; + vec4 g_ShadowVP_Row0; + vec4 g_ShadowVP_Row1; + vec4 g_ShadowVP_Row2; + vec4 g_ShadowVP_Row3; +} _273; + +layout(binding = 1) uniform mediump sampler2D TexLOD; +layout(binding = 0) uniform mediump sampler2D TexDisplacement; + +layout(location = 1) in vec4 LODWeights; +uniform int SPIRV_Cross_BaseInstance; +layout(location = 0) in vec4 Position; +layout(location = 0) out vec3 EyeVec; +layout(location = 1) out vec4 TexCoord; + +vec2 warp_position() +{ + float vlod = dot(LODWeights, _53.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].LODs); + vlod = all(equal(LODWeights, vec4(0.0))) ? _53.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].Position.w : vlod; + float floor_lod = floor(vlod); + float fract_lod = vlod - floor_lod; + uint ufloor_lod = uint(floor_lod); + uvec4 uPosition = uvec4(Position); + uvec2 mask = (uvec2(1u) << uvec2(ufloor_lod, ufloor_lod + 1u)) - uvec2(1u); + uint _107; + if (uPosition.x < 32u) + { + _107 = mask.x; + } + else + { + _107 = 0u; + } + uvec4 rounding; + rounding.x = _107; + uint _119; + if (uPosition.y < 32u) + { + _119 = mask.x; + } + else + { + _119 = 0u; + } + rounding.y = _119; + uint _130; + if (uPosition.x < 32u) + { + _130 = mask.y; + } + else + { + _130 = 0u; + } + rounding.z = _130; + uint _142; + if (uPosition.y < 32u) + { + _142 = mask.y; + } + else + { + _142 = 0u; + } + rounding.w = _142; + vec4 lower_upper_snapped = vec4((uPosition.xyxy + rounding) & (~mask).xxyy); + return mix(lower_upper_snapped.xy, lower_upper_snapped.zw, vec2(fract_lod)); +} + +vec2 lod_factor(vec2 uv) +{ + float level = textureLod(TexLOD, uv, 0.0).x * 7.96875; + float floor_level = floor(level); + float fract_level = level - floor_level; + return vec2(floor_level, fract_level); +} + +void main() +{ + vec2 PatchPos = _53.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].Position.xz * _180.InvOceanSize_PatchScale.zw; + vec2 WarpedPos = warp_position(); + vec2 VertexPos = PatchPos + WarpedPos; + vec2 NormalizedPos = VertexPos * _180.InvOceanSize_PatchScale.xy; + vec2 NormalizedTex = NormalizedPos * _180.NormalTexCoordScale.zw; + vec2 param = NormalizedPos; + vec2 lod = lod_factor(param); + vec2 Offset = (_180.InvOceanSize_PatchScale.xy * exp2(lod.x)) * _180.NormalTexCoordScale.zw; + vec3 Displacement = mix(textureLod(TexDisplacement, NormalizedTex + (Offset * 0.5), lod.x).yxz, textureLod(TexDisplacement, NormalizedTex + (Offset * 1.0), lod.x + 1.0).yxz, vec3(lod.y)); + vec3 WorldPos = vec3(NormalizedPos.x, 0.0, NormalizedPos.y) + Displacement; + WorldPos *= _180.OceanScale.xyz; + WorldPos += _180.OceanPosition.xyz; + EyeVec = WorldPos - _273.g_CamPos.xyz; + TexCoord = vec4(NormalizedTex, NormalizedTex * _180.NormalTexCoordScale.xy) + ((_180.InvOceanSize_PatchScale.xyxy * 0.5) * _180.NormalTexCoordScale.zwzw); + gl_Position = (((_273.g_ViewProj_Row0 * WorldPos.x) + (_273.g_ViewProj_Row1 * WorldPos.y)) + (_273.g_ViewProj_Row2 * WorldPos.z)) + _273.g_ViewProj_Row3; +} + diff --git a/reference/shaders/vert/texture_buffer.vert b/reference/shaders/vert/texture_buffer.vert new file mode 100644 index 0000000000..e9442ce119 --- /dev/null +++ b/reference/shaders/vert/texture_buffer.vert @@ -0,0 +1,11 @@ +#version 310 es +#extension GL_OES_texture_buffer : require + +layout(binding = 4) uniform highp samplerBuffer uSamp; +layout(binding = 5, rgba32f) uniform readonly highp imageBuffer uSampo; + +void main() +{ + gl_Position = texelFetch(uSamp, 10) + imageLoad(uSampo, 100); +} + diff --git a/reference/shaders/vert/ubo.vert b/reference/shaders/vert/ubo.vert new file mode 100644 index 0000000000..4e7236b290 --- /dev/null +++ b/reference/shaders/vert/ubo.vert @@ -0,0 +1,17 @@ +#version 310 es + +layout(binding = 0, std140) uniform UBO +{ + mat4 mvp; +} _16; + +layout(location = 0) in vec4 aVertex; +layout(location = 0) out vec3 vNormal; +layout(location = 1) in vec3 aNormal; + +void main() +{ + gl_Position = _16.mvp * aVertex; + vNormal = aNormal; +} + diff --git a/reference/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag b/reference/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag new file mode 100644 index 0000000000..af64fb87aa --- /dev/null +++ b/reference/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag @@ -0,0 +1,31 @@ +#version 310 es +precision mediump float; +precision highp int; + +uniform mediump sampler2DShadow SPIRV_Cross_CombineduDepthuSampler; +uniform mediump sampler2D SPIRV_Cross_CombineduDepthuSampler1; + +layout(location = 0) out float FragColor; + +float samp2(mediump sampler2DShadow SPIRV_Cross_Combinedts) +{ + return texture(SPIRV_Cross_Combinedts, vec3(vec3(1.0).xy, vec3(1.0).z)); +} + +float samp3(mediump sampler2D SPIRV_Cross_Combinedts) +{ + return texture(SPIRV_Cross_Combinedts, vec2(1.0)).x; +} + +float samp(mediump sampler2DShadow SPIRV_Cross_Combinedts, mediump sampler2D SPIRV_Cross_Combinedts1) +{ + float r0 = samp2(SPIRV_Cross_Combinedts); + float r1 = samp3(SPIRV_Cross_Combinedts1); + return r0 + r1; +} + +void main() +{ + FragColor = samp(SPIRV_Cross_CombineduDepthuSampler, SPIRV_Cross_CombineduDepthuSampler1); +} + diff --git a/reference/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag.vk b/reference/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag.vk new file mode 100644 index 0000000000..f475ae53a9 --- /dev/null +++ b/reference/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag.vk @@ -0,0 +1,32 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(set = 0, binding = 2) uniform mediump texture2D uDepth; +layout(set = 0, binding = 0) uniform mediump samplerShadow uSampler; +layout(set = 0, binding = 1) uniform mediump sampler uSampler1; + +layout(location = 0) out float FragColor; + +float samp2(mediump texture2D t, mediump samplerShadow s) +{ + return texture(sampler2DShadow(t, s), vec3(vec3(1.0).xy, vec3(1.0).z)); +} + +float samp3(mediump texture2D t, mediump sampler s) +{ + return texture(sampler2D(t, s), vec2(1.0)).x; +} + +float samp(mediump texture2D t, mediump samplerShadow s, mediump sampler s1) +{ + float r0 = samp2(t, s); + float r1 = samp3(t, s1); + return r0 + r1; +} + +void main() +{ + FragColor = samp(uDepth, uSampler, uSampler1); +} + diff --git a/reference/shaders/vulkan/frag/combined-texture-sampler.vk.frag b/reference/shaders/vulkan/frag/combined-texture-sampler.vk.frag new file mode 100644 index 0000000000..5b9c0ddadf --- /dev/null +++ b/reference/shaders/vulkan/frag/combined-texture-sampler.vk.frag @@ -0,0 +1,48 @@ +#version 310 es +precision mediump float; +precision highp int; + +uniform mediump sampler2D SPIRV_Cross_CombineduTexture0uSampler0; +uniform mediump sampler2D SPIRV_Cross_CombineduTexture1uSampler1; +uniform mediump sampler2D SPIRV_Cross_CombineduTexture1uSampler0; +uniform mediump sampler2D SPIRV_Cross_CombineduTexture0uSampler1; + +layout(location = 0) in vec2 vTex; +layout(location = 0) out vec4 FragColor; + +vec4 sample_dual(mediump sampler2D SPIRV_Cross_Combinedtexsamp) +{ + return texture(SPIRV_Cross_Combinedtexsamp, vTex); +} + +vec4 sample_duals() +{ + vec4 a = sample_dual(SPIRV_Cross_CombineduTexture0uSampler0); + vec4 b = sample_dual(SPIRV_Cross_CombineduTexture1uSampler1); + return a + b; +} + +vec4 sample_global_tex(mediump sampler2D SPIRV_Cross_CombineduTexture0samp, mediump sampler2D SPIRV_Cross_CombineduTexture1samp) +{ + vec4 a = texture(SPIRV_Cross_CombineduTexture0samp, vTex); + vec4 b = sample_dual(SPIRV_Cross_CombineduTexture1samp); + return a + b; +} + +vec4 sample_global_sampler(mediump sampler2D SPIRV_Cross_CombinedtexuSampler0, mediump sampler2D SPIRV_Cross_CombinedtexuSampler1) +{ + vec4 a = texture(SPIRV_Cross_CombinedtexuSampler0, vTex); + vec4 b = sample_dual(SPIRV_Cross_CombinedtexuSampler1); + return a + b; +} + +void main() +{ + vec4 c0 = sample_duals(); + vec4 c1 = sample_global_tex(SPIRV_Cross_CombineduTexture0uSampler0, SPIRV_Cross_CombineduTexture1uSampler0); + vec4 c2 = sample_global_tex(SPIRV_Cross_CombineduTexture0uSampler1, SPIRV_Cross_CombineduTexture1uSampler1); + vec4 c3 = sample_global_sampler(SPIRV_Cross_CombineduTexture0uSampler0, SPIRV_Cross_CombineduTexture0uSampler1); + vec4 c4 = sample_global_sampler(SPIRV_Cross_CombineduTexture1uSampler0, SPIRV_Cross_CombineduTexture1uSampler1); + FragColor = (((c0 + c1) + c2) + c3) + c4; +} + diff --git a/reference/shaders/vulkan/frag/combined-texture-sampler.vk.frag.vk b/reference/shaders/vulkan/frag/combined-texture-sampler.vk.frag.vk new file mode 100644 index 0000000000..ae8df4c925 --- /dev/null +++ b/reference/shaders/vulkan/frag/combined-texture-sampler.vk.frag.vk @@ -0,0 +1,48 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(set = 0, binding = 2) uniform mediump texture2D uTexture0; +layout(set = 0, binding = 3) uniform mediump texture2D uTexture1; +layout(set = 0, binding = 0) uniform mediump sampler uSampler0; +layout(set = 0, binding = 1) uniform mediump sampler uSampler1; + +layout(location = 0) in vec2 vTex; +layout(location = 0) out vec4 FragColor; + +vec4 sample_dual(mediump sampler samp, mediump texture2D tex) +{ + return texture(sampler2D(tex, samp), vTex); +} + +vec4 sample_duals() +{ + vec4 a = sample_dual(uSampler0, uTexture0); + vec4 b = sample_dual(uSampler1, uTexture1); + return a + b; +} + +vec4 sample_global_tex(mediump sampler samp) +{ + vec4 a = texture(sampler2D(uTexture0, samp), vTex); + vec4 b = sample_dual(samp, uTexture1); + return a + b; +} + +vec4 sample_global_sampler(mediump texture2D tex) +{ + vec4 a = texture(sampler2D(tex, uSampler0), vTex); + vec4 b = sample_dual(uSampler1, tex); + return a + b; +} + +void main() +{ + vec4 c0 = sample_duals(); + vec4 c1 = sample_global_tex(uSampler0); + vec4 c2 = sample_global_tex(uSampler1); + vec4 c3 = sample_global_sampler(uTexture0); + vec4 c4 = sample_global_sampler(uTexture1); + FragColor = (((c0 + c1) + c2) + c3) + c4; +} + diff --git a/reference/shaders/vulkan/frag/desktop-mediump.vk.frag b/reference/shaders/vulkan/frag/desktop-mediump.vk.frag new file mode 100644 index 0000000000..8f7508ee8e --- /dev/null +++ b/reference/shaders/vulkan/frag/desktop-mediump.vk.frag @@ -0,0 +1,12 @@ +#version 450 + +layout(location = 0) out vec4 FragColor; +layout(location = 0) in vec4 F; +layout(location = 1) flat in ivec4 I; +layout(location = 2) flat in uvec4 U; + +void main() +{ + FragColor = (F + vec4(I)) + vec4(U); +} + diff --git a/reference/shaders/vulkan/frag/desktop-mediump.vk.frag.vk b/reference/shaders/vulkan/frag/desktop-mediump.vk.frag.vk new file mode 100644 index 0000000000..4c0506b110 --- /dev/null +++ b/reference/shaders/vulkan/frag/desktop-mediump.vk.frag.vk @@ -0,0 +1,12 @@ +#version 450 + +layout(location = 0) out mediump vec4 FragColor; +layout(location = 0) in mediump vec4 F; +layout(location = 1) flat in mediump ivec4 I; +layout(location = 2) flat in mediump uvec4 U; + +void main() +{ + FragColor = (F + vec4(I)) + vec4(U); +} + diff --git a/reference/shaders/vulkan/frag/input-attachment-ms.vk.frag b/reference/shaders/vulkan/frag/input-attachment-ms.vk.frag new file mode 100644 index 0000000000..ea460c1fae --- /dev/null +++ b/reference/shaders/vulkan/frag/input-attachment-ms.vk.frag @@ -0,0 +1,12 @@ +#version 450 + +layout(binding = 0) uniform sampler2DMS uSubpass0; +layout(binding = 1) uniform sampler2DMS uSubpass1; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = (texelFetch(uSubpass0, ivec2(gl_FragCoord.xy), 1) + texelFetch(uSubpass1, ivec2(gl_FragCoord.xy), 2)) + texelFetch(uSubpass0, ivec2(gl_FragCoord.xy), gl_SampleID); +} + diff --git a/reference/shaders/vulkan/frag/input-attachment-ms.vk.frag.vk b/reference/shaders/vulkan/frag/input-attachment-ms.vk.frag.vk new file mode 100644 index 0000000000..462df22a19 --- /dev/null +++ b/reference/shaders/vulkan/frag/input-attachment-ms.vk.frag.vk @@ -0,0 +1,12 @@ +#version 450 + +layout(input_attachment_index = 0, set = 0, binding = 0) uniform subpassInputMS uSubpass0; +layout(input_attachment_index = 1, set = 0, binding = 1) uniform subpassInputMS uSubpass1; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = (subpassLoad(uSubpass0, 1) + subpassLoad(uSubpass1, 2)) + subpassLoad(uSubpass0, gl_SampleID); +} + diff --git a/reference/shaders/vulkan/frag/input-attachment.vk.frag b/reference/shaders/vulkan/frag/input-attachment.vk.frag new file mode 100644 index 0000000000..8d216b2c49 --- /dev/null +++ b/reference/shaders/vulkan/frag/input-attachment.vk.frag @@ -0,0 +1,14 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(binding = 0) uniform mediump sampler2D uSubpass0; +layout(binding = 1) uniform mediump sampler2D uSubpass1; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = texelFetch(uSubpass0, ivec2(gl_FragCoord.xy), 0) + texelFetch(uSubpass1, ivec2(gl_FragCoord.xy), 0); +} + diff --git a/reference/shaders/vulkan/frag/input-attachment.vk.frag.vk b/reference/shaders/vulkan/frag/input-attachment.vk.frag.vk new file mode 100644 index 0000000000..c8b5d9a70d --- /dev/null +++ b/reference/shaders/vulkan/frag/input-attachment.vk.frag.vk @@ -0,0 +1,14 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(input_attachment_index = 0, set = 0, binding = 0) uniform mediump subpassInput uSubpass0; +layout(input_attachment_index = 1, set = 0, binding = 1) uniform mediump subpassInput uSubpass1; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = subpassLoad(uSubpass0) + subpassLoad(uSubpass1); +} + diff --git a/reference/shaders/vulkan/frag/push-constant.frag.vk b/reference/shaders/vulkan/frag/push-constant.frag.vk new file mode 100644 index 0000000000..748a028678 --- /dev/null +++ b/reference/shaders/vulkan/frag/push-constant.frag.vk @@ -0,0 +1,18 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(push_constant, std430) uniform PushConstants +{ + vec4 value0; + vec4 value1; +} push; + +layout(location = 0) out vec4 FragColor; +layout(location = 0) in vec4 vColor; + +void main() +{ + FragColor = ((vColor + push.value0) + push.value1); +} + diff --git a/reference/shaders/vulkan/frag/push-constant.vk.frag b/reference/shaders/vulkan/frag/push-constant.vk.frag new file mode 100644 index 0000000000..c04a7ca488 --- /dev/null +++ b/reference/shaders/vulkan/frag/push-constant.vk.frag @@ -0,0 +1,20 @@ +#version 310 es +precision mediump float; +precision highp int; + +struct PushConstants +{ + vec4 value0; + vec4 value1; +}; + +uniform PushConstants push; + +layout(location = 0) out vec4 FragColor; +layout(location = 0) in vec4 vColor; + +void main() +{ + FragColor = (vColor + push.value0) + push.value1; +} + diff --git a/reference/shaders/vulkan/frag/push-constant.vk.frag.vk b/reference/shaders/vulkan/frag/push-constant.vk.frag.vk new file mode 100644 index 0000000000..6cec90f19e --- /dev/null +++ b/reference/shaders/vulkan/frag/push-constant.vk.frag.vk @@ -0,0 +1,18 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(push_constant, std430) uniform PushConstants +{ + vec4 value0; + vec4 value1; +} push; + +layout(location = 0) out vec4 FragColor; +layout(location = 0) in vec4 vColor; + +void main() +{ + FragColor = (vColor + push.value0) + push.value1; +} + diff --git a/reference/shaders/vulkan/frag/separate-sampler-texture.vk.frag b/reference/shaders/vulkan/frag/separate-sampler-texture.vk.frag new file mode 100644 index 0000000000..78477cfbae --- /dev/null +++ b/reference/shaders/vulkan/frag/separate-sampler-texture.vk.frag @@ -0,0 +1,37 @@ +#version 310 es +precision mediump float; +precision highp int; + +uniform mediump sampler2D SPIRV_Cross_CombineduTextureuSampler; +uniform mediump sampler2DArray SPIRV_Cross_CombineduTextureArrayuSampler; +uniform mediump samplerCube SPIRV_Cross_CombineduTextureCubeuSampler; +uniform mediump sampler3D SPIRV_Cross_CombineduTexture3DuSampler; + +layout(location = 0) in vec2 vTex; +layout(location = 1) in vec3 vTex3; +layout(location = 0) out vec4 FragColor; + +vec4 sample_func(vec2 uv, mediump sampler2D SPIRV_Cross_CombineduTexturesamp) +{ + return texture(SPIRV_Cross_CombineduTexturesamp, uv); +} + +vec4 sample_func_dual(vec2 uv, mediump sampler2D SPIRV_Cross_Combinedtexsamp) +{ + return texture(SPIRV_Cross_Combinedtexsamp, uv); +} + +void main() +{ + vec2 off = vec2(1.0) / vec2(textureSize(SPIRV_Cross_CombineduTextureuSampler, 0)); + vec2 off2 = vec2(1.0) / vec2(textureSize(SPIRV_Cross_CombineduTextureuSampler, 1)); + highp vec2 param = (vTex + off) + off2; + vec4 c0 = sample_func(param, SPIRV_Cross_CombineduTextureuSampler); + highp vec2 param_1 = (vTex + off) + off2; + vec4 c1 = sample_func_dual(param_1, SPIRV_Cross_CombineduTextureuSampler); + vec4 c2 = texture(SPIRV_Cross_CombineduTextureArrayuSampler, vTex3); + vec4 c3 = texture(SPIRV_Cross_CombineduTextureCubeuSampler, vTex3); + vec4 c4 = texture(SPIRV_Cross_CombineduTexture3DuSampler, vTex3); + FragColor = (((c0 + c1) + c2) + c3) + c4; +} + diff --git a/reference/shaders/vulkan/frag/separate-sampler-texture.vk.frag.vk b/reference/shaders/vulkan/frag/separate-sampler-texture.vk.frag.vk new file mode 100644 index 0000000000..cfa2f39616 --- /dev/null +++ b/reference/shaders/vulkan/frag/separate-sampler-texture.vk.frag.vk @@ -0,0 +1,38 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(set = 0, binding = 1) uniform mediump texture2D uTexture; +layout(set = 0, binding = 0) uniform mediump sampler uSampler; +layout(set = 0, binding = 4) uniform mediump texture2DArray uTextureArray; +layout(set = 0, binding = 3) uniform mediump textureCube uTextureCube; +layout(set = 0, binding = 2) uniform mediump texture3D uTexture3D; + +layout(location = 0) in vec2 vTex; +layout(location = 1) in vec3 vTex3; +layout(location = 0) out vec4 FragColor; + +vec4 sample_func(mediump sampler samp, vec2 uv) +{ + return texture(sampler2D(uTexture, samp), uv); +} + +vec4 sample_func_dual(mediump sampler samp, mediump texture2D tex, vec2 uv) +{ + return texture(sampler2D(tex, samp), uv); +} + +void main() +{ + vec2 off = vec2(1.0) / vec2(textureSize(sampler2D(uTexture, uSampler), 0)); + vec2 off2 = vec2(1.0) / vec2(textureSize(sampler2D(uTexture, uSampler), 1)); + highp vec2 param = (vTex + off) + off2; + vec4 c0 = sample_func(uSampler, param); + highp vec2 param_1 = (vTex + off) + off2; + vec4 c1 = sample_func_dual(uSampler, uTexture, param_1); + vec4 c2 = texture(sampler2DArray(uTextureArray, uSampler), vTex3); + vec4 c3 = texture(samplerCube(uTextureCube, uSampler), vTex3); + vec4 c4 = texture(sampler3D(uTexture3D, uSampler), vTex3); + FragColor = (((c0 + c1) + c2) + c3) + c4; +} + diff --git a/reference/shaders/vulkan/frag/spec-constant.vk.frag b/reference/shaders/vulkan/frag/spec-constant.vk.frag new file mode 100644 index 0000000000..7976042a85 --- /dev/null +++ b/reference/shaders/vulkan/frag/spec-constant.vk.frag @@ -0,0 +1,59 @@ +#version 310 es +precision mediump float; +precision highp int; + +struct Foo +{ + float elems[(4 + 2)]; +}; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + float t0 = 1.0; + float t1 = 2.0; + mediump uint c0 = (uint(3) + 0u); + mediump int c1 = (-3); + mediump int c2 = (~3); + mediump int c3 = (3 + 4); + mediump int c4 = (3 - 4); + mediump int c5 = (3 * 4); + mediump int c6 = (3 / 4); + mediump uint c7 = (5u / 6u); + mediump int c8 = (3 % 4); + mediump uint c9 = (5u % 6u); + mediump int c10 = (3 >> 4); + mediump uint c11 = (5u >> 6u); + mediump int c12 = (3 << 4); + mediump int c13 = (3 | 4); + mediump int c14 = (3 ^ 4); + mediump int c15 = (3 & 4); + bool c16 = (false || true); + bool c17 = (false && true); + bool c18 = (!false); + bool c19 = (false == true); + bool c20 = (false != true); + bool c21 = (3 == 4); + bool c22 = (3 != 4); + bool c23 = (3 < 4); + bool c24 = (5u < 6u); + bool c25 = (3 > 4); + bool c26 = (5u > 6u); + bool c27 = (3 <= 4); + bool c28 = (5u <= 6u); + bool c29 = (3 >= 4); + bool c30 = (5u >= 6u); + mediump int c31 = c8 + c3; + mediump int c32 = int(5u + 0u); + bool c33 = (3 != int(0u)); + bool c34 = (5u != 0u); + mediump int c35 = int(false); + mediump uint c36 = uint(false); + float c37 = float(false); + float vec0[(3 + 3)][8]; + float vec1[(3 + 2)]; + Foo foo; + FragColor = ((vec4(t0 + t1) + vec4(vec0[0][0])) + vec4(vec1[0])) + vec4(foo.elems[3]); +} + diff --git a/reference/shaders/vulkan/frag/spec-constant.vk.frag.vk b/reference/shaders/vulkan/frag/spec-constant.vk.frag.vk new file mode 100644 index 0000000000..d0765cc8bd --- /dev/null +++ b/reference/shaders/vulkan/frag/spec-constant.vk.frag.vk @@ -0,0 +1,68 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(constant_id = 1) const float a = 1.0; +layout(constant_id = 2) const float b = 2.0; +layout(constant_id = 3) const int c = 3; +layout(constant_id = 4) const int d = 4; +layout(constant_id = 5) const uint e = 5u; +layout(constant_id = 6) const uint f = 6u; +layout(constant_id = 7) const bool g = false; +layout(constant_id = 8) const bool h = true; + +struct Foo +{ + float elems[(d + 2)]; +}; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + float t0 = a; + float t1 = b; + mediump uint c0 = (uint(c) + 0u); + mediump int c1 = (-c); + mediump int c2 = (~c); + mediump int c3 = (c + d); + mediump int c4 = (c - d); + mediump int c5 = (c * d); + mediump int c6 = (c / d); + mediump uint c7 = (e / f); + mediump int c8 = (c % d); + mediump uint c9 = (e % f); + mediump int c10 = (c >> d); + mediump uint c11 = (e >> f); + mediump int c12 = (c << d); + mediump int c13 = (c | d); + mediump int c14 = (c ^ d); + mediump int c15 = (c & d); + bool c16 = (g || h); + bool c17 = (g && h); + bool c18 = (!g); + bool c19 = (g == h); + bool c20 = (g != h); + bool c21 = (c == d); + bool c22 = (c != d); + bool c23 = (c < d); + bool c24 = (e < f); + bool c25 = (c > d); + bool c26 = (e > f); + bool c27 = (c <= d); + bool c28 = (e <= f); + bool c29 = (c >= d); + bool c30 = (e >= f); + mediump int c31 = c8 + c3; + mediump int c32 = int(e + 0u); + bool c33 = (c != int(0u)); + bool c34 = (e != 0u); + mediump int c35 = int(g); + mediump uint c36 = uint(g); + float c37 = float(g); + float vec0[(c + 3)][8]; + float vec1[(c + 2)]; + Foo foo; + FragColor = ((vec4(t0 + t1) + vec4(vec0[0][0])) + vec4(vec1[0])) + vec4(foo.elems[c]); +} + diff --git a/reference/shaders/vulkan/vert/multiview.nocompat.vk.vert b/reference/shaders/vulkan/vert/multiview.nocompat.vk.vert new file mode 100644 index 0000000000..533738efc3 --- /dev/null +++ b/reference/shaders/vulkan/vert/multiview.nocompat.vk.vert @@ -0,0 +1,15 @@ +#version 310 es +#extension GL_OVR_multiview2 : require + +layout(binding = 0, std140) uniform MVPs +{ + mat4 MVP[2]; +} _19; + +layout(location = 0) in vec4 Position; + +void main() +{ + gl_Position = _19.MVP[gl_ViewID_OVR] * Position; +} + diff --git a/reference/shaders/vulkan/vert/multiview.nocompat.vk.vert.vk b/reference/shaders/vulkan/vert/multiview.nocompat.vk.vert.vk new file mode 100644 index 0000000000..90055473d9 --- /dev/null +++ b/reference/shaders/vulkan/vert/multiview.nocompat.vk.vert.vk @@ -0,0 +1,15 @@ +#version 310 es +#extension GL_EXT_multiview : require + +layout(set = 0, binding = 0, std140) uniform MVPs +{ + mat4 MVP[2]; +} _19; + +layout(location = 0) in vec4 Position; + +void main() +{ + gl_Position = _19.MVP[gl_ViewIndex] * Position; +} + diff --git a/reference/shaders/vulkan/vert/vulkan-vertex.vert b/reference/shaders/vulkan/vert/vulkan-vertex.vert new file mode 100644 index 0000000000..8de2b111ef --- /dev/null +++ b/reference/shaders/vulkan/vert/vulkan-vertex.vert @@ -0,0 +1,9 @@ +#version 310 es + +uniform int SPIRV_Cross_BaseInstance; + +void main() +{ + gl_Position = (vec4(1.0, 2.0, 3.0, 4.0) * float((gl_VertexID + (gl_InstanceID + SPIRV_Cross_BaseInstance)))); +} + diff --git a/reference/shaders/vulkan/vert/vulkan-vertex.vert.vk b/reference/shaders/vulkan/vert/vulkan-vertex.vert.vk new file mode 100644 index 0000000000..9ee3cc0997 --- /dev/null +++ b/reference/shaders/vulkan/vert/vulkan-vertex.vert.vk @@ -0,0 +1,7 @@ +#version 310 es + +void main() +{ + gl_Position = (vec4(1.0, 2.0, 3.0, 4.0) * float((gl_VertexIndex + gl_InstanceIndex))); +} + diff --git a/reference/shaders/vulkan/vert/vulkan-vertex.vk.vert b/reference/shaders/vulkan/vert/vulkan-vertex.vk.vert new file mode 100644 index 0000000000..60ba1882f8 --- /dev/null +++ b/reference/shaders/vulkan/vert/vulkan-vertex.vk.vert @@ -0,0 +1,9 @@ +#version 310 es + +uniform int SPIRV_Cross_BaseInstance; + +void main() +{ + gl_Position = vec4(1.0, 2.0, 3.0, 4.0) * float(gl_VertexID + (gl_InstanceID + SPIRV_Cross_BaseInstance)); +} + diff --git a/reference/shaders/vulkan/vert/vulkan-vertex.vk.vert.vk b/reference/shaders/vulkan/vert/vulkan-vertex.vk.vert.vk new file mode 100644 index 0000000000..8c4930d7a8 --- /dev/null +++ b/reference/shaders/vulkan/vert/vulkan-vertex.vk.vert.vk @@ -0,0 +1,7 @@ +#version 310 es + +void main() +{ + gl_Position = vec4(1.0, 2.0, 3.0, 4.0) * float(gl_VertexIndex + gl_InstanceIndex); +} + diff --git a/samples/cpp/Makefile b/samples/cpp/Makefile new file mode 100644 index 0000000000..225bb3d57d --- /dev/null +++ b/samples/cpp/Makefile @@ -0,0 +1,28 @@ +SOURCES := $(wildcard *.comp) +SPIRV := $(SOURCES:.comp=.spv) +CPP_INTERFACE := $(SOURCES:.comp=.spv.cpp) +CPP_DRIVER := $(SOURCES:.comp=.cpp) +EXECUTABLES := $(SOURCES:.comp=.shader) +OBJECTS := $(CPP_DRIVER:.cpp=.o) $(CPP_INTERFACE:.cpp=.o) + +CXXFLAGS += -std=c++11 -I../../include -I. +LDFLAGS += -pthread -lm + +all: $(EXECUTABLES) + +%.spv: %.comp + glslangValidator -V -o $@ $< + +%.spv.cpp: %.spv + ../../spirv-cross --cpp --output $@ $< + +%.o: %.cpp + $(CXX) -c -o $@ $< $(CXXFLAGS) + +%.shader: %.o %.spv.o + $(CXX) -o $@ $^ $(LDFLAGS) + +clean: + $(RM) -f $(EXECUTABLES) $(SPIRV) $(CPP_INTERFACE) $(OBJECTS) + +.PHONY: clean diff --git a/samples/cpp/atomics.comp b/samples/cpp/atomics.comp new file mode 100644 index 0000000000..0bf6d2ad01 --- /dev/null +++ b/samples/cpp/atomics.comp @@ -0,0 +1,29 @@ +#version 310 es +layout(local_size_x = 64) in; + +layout(set = 0, binding = 0, std430) readonly buffer SSBO0 +{ + float inputs[]; +}; + +layout(set = 0, binding = 1, std430) writeonly buffer SSBO1 +{ + float outputs[]; +}; + +layout(set = 0, binding = 2, std430) buffer SSBO2 +{ + uint counter; +}; + +void main() +{ + // Builds a tightly packed list of all values less than 10.0. + // The output order is random. + float value = inputs[gl_GlobalInvocationID.x]; + if (value < 10.0) + { + uint output_index = atomicAdd(counter, 1u); + outputs[output_index] = value; + } +} diff --git a/samples/cpp/atomics.cpp b/samples/cpp/atomics.cpp new file mode 100644 index 0000000000..89351a5ae5 --- /dev/null +++ b/samples/cpp/atomics.cpp @@ -0,0 +1,90 @@ +/* + * Copyright 2015-2017 ARM Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "spirv_cross/external_interface.h" +#include + +#ifndef GLM_SWIZZLE +#define GLM_SWIZZLE +#endif + +#ifndef GLM_FORCE_RADIANS +#define GLM_FORCE_RADIANS +#endif + +#include +using namespace glm; + +int main() +{ + // First, we get the C interface to the shader. + // This can be loaded from a dynamic library, or as here, + // linked in as a static library. + auto *iface = spirv_cross_get_interface(); + + // Create an instance of the shader interface. + auto *shader = iface->construct(); + +// Build some input data for our compute shader. +#define NUM_WORKGROUPS 4 + float a[64 * NUM_WORKGROUPS]; + float b[64 * NUM_WORKGROUPS] = {}; + uint32_t counter = 0; + + for (int i = 0; i < 64 * NUM_WORKGROUPS; i++) + { + a[i] = i * 0.46f; + } + + void *aptr = a; + void *bptr = b; + void *cptr = &counter; + + // Bind resources to the shader. + // For resources like samplers and buffers, we provide a list of pointers, + // since UBOs, SSBOs and samplers can be arrays, and can point to different types, + // which is especially true for samplers. + spirv_cross_set_resource(shader, 0, 0, &aptr, sizeof(aptr)); + spirv_cross_set_resource(shader, 0, 1, &bptr, sizeof(bptr)); + spirv_cross_set_resource(shader, 0, 2, &cptr, sizeof(cptr)); + + // We also have to set builtins. + // The relevant builtins will depend on the shader, + // but for compute, there are few builtins, which are gl_NumWorkGroups and gl_WorkGroupID. + // LocalInvocationID and GlobalInvocationID are inferred when executing the invocation. + uvec3 num_workgroups(NUM_WORKGROUPS, 1, 1); + uvec3 work_group_id(0, 0, 0); + spirv_cross_set_builtin(shader, SPIRV_CROSS_BUILTIN_NUM_WORK_GROUPS, &num_workgroups, sizeof(num_workgroups)); + spirv_cross_set_builtin(shader, SPIRV_CROSS_BUILTIN_WORK_GROUP_ID, &work_group_id, sizeof(work_group_id)); + + // Execute 4 work groups. + for (unsigned i = 0; i < NUM_WORKGROUPS; i++) + { + work_group_id.x = i; + iface->invoke(shader); + } + + // Call destructor. + iface->destruct(shader); + + // Verify our output. + // TODO: Implement a test framework that asserts results computed. + fprintf(stderr, "Counter = %u\n", counter); + for (unsigned i = 0; i < counter; i++) + { + fprintf(stderr, "[%3u] = %.1f\n", i, b[i]); + } +} diff --git a/samples/cpp/multiply.comp b/samples/cpp/multiply.comp new file mode 100644 index 0000000000..1ac7869ad0 --- /dev/null +++ b/samples/cpp/multiply.comp @@ -0,0 +1,22 @@ +#version 310 es +layout(local_size_x = 64) in; + +layout(set = 0, binding = 0, std430) readonly buffer SSBO0 +{ + vec4 a[]; +}; + +layout(set = 0, binding = 1, std430) readonly buffer SSBO1 +{ + vec4 b[]; +}; + +layout(set = 0, binding = 2, std430) buffer SSBO2 +{ + vec4 c[]; +}; + +void main() +{ + c[gl_GlobalInvocationID.x] = a[gl_GlobalInvocationID.x] * b[gl_GlobalInvocationID.x]; +} diff --git a/samples/cpp/multiply.cpp b/samples/cpp/multiply.cpp new file mode 100644 index 0000000000..daa1fc6477 --- /dev/null +++ b/samples/cpp/multiply.cpp @@ -0,0 +1,91 @@ +/* + * Copyright 2015-2017 ARM Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "spirv_cross/external_interface.h" +#include + +#ifndef GLM_SWIZZLE +#define GLM_SWIZZLE +#endif + +#ifndef GLM_FORCE_RADIANS +#define GLM_FORCE_RADIANS +#endif + +#include +using namespace glm; + +int main() +{ + // First, we get the C interface to the shader. + // This can be loaded from a dynamic library, or as here, + // linked in as a static library. + auto *iface = spirv_cross_get_interface(); + + // Create an instance of the shader interface. + auto *shader = iface->construct(); + +// Build some input data for our compute shader. +#define NUM_WORKGROUPS 4 + vec4 a[64 * NUM_WORKGROUPS]; + vec4 b[64 * NUM_WORKGROUPS]; + vec4 c[64 * NUM_WORKGROUPS] = {}; + + for (int i = 0; i < 64 * NUM_WORKGROUPS; i++) + { + a[i] = vec4(100 + i, 101 + i, 102 + i, 103 + i); + b[i] = vec4(100 - i, 99 - i, 98 - i, 97 - i); + } + + void *aptr = a; + void *bptr = b; + void *cptr = c; + + // Bind resources to the shader. + // For resources like samplers and buffers, we provide a list of pointers, + // since UBOs, SSBOs and samplers can be arrays, and can point to different types, + // which is especially true for samplers. + spirv_cross_set_resource(shader, 0, 0, &aptr, sizeof(aptr)); + spirv_cross_set_resource(shader, 0, 1, &bptr, sizeof(bptr)); + spirv_cross_set_resource(shader, 0, 2, &cptr, sizeof(cptr)); + + // We also have to set builtins. + // The relevant builtins will depend on the shader, + // but for compute, there are few builtins, which are gl_NumWorkGroups and gl_WorkGroupID. + // LocalInvocationID and GlobalInvocationID are inferred when executing the invocation. + uvec3 num_workgroups(NUM_WORKGROUPS, 1, 1); + uvec3 work_group_id(0, 0, 0); + spirv_cross_set_builtin(shader, SPIRV_CROSS_BUILTIN_NUM_WORK_GROUPS, &num_workgroups, sizeof(num_workgroups)); + spirv_cross_set_builtin(shader, SPIRV_CROSS_BUILTIN_WORK_GROUP_ID, &work_group_id, sizeof(work_group_id)); + + // Execute 4 work groups. + for (unsigned i = 0; i < NUM_WORKGROUPS; i++) + { + work_group_id.x = i; + iface->invoke(shader); + } + + // Call destructor. + iface->destruct(shader); + + // Verify our output. + // TODO: Implement a test framework that asserts results computed. + for (unsigned i = 0; i < 64 * NUM_WORKGROUPS; i++) + { + fprintf(stderr, "(%.1f, %.1f, %.1f, %.1f) * (%.1f, %.1f, %.1f, %.1f) => (%.1f, %.1f, %.1f, %.1f)\n", a[i].x, + a[i].y, a[i].z, a[i].w, b[i].x, b[i].y, b[i].z, b[i].w, c[i].x, c[i].y, c[i].z, c[i].w); + } +} diff --git a/samples/cpp/shared.comp b/samples/cpp/shared.comp new file mode 100644 index 0000000000..7d59060aa9 --- /dev/null +++ b/samples/cpp/shared.comp @@ -0,0 +1,36 @@ +#version 310 es +layout(local_size_x = 64) in; + +layout(set = 0, binding = 0, std430) readonly buffer SSBO0 +{ + float inputs[]; +}; + +layout(set = 0, binding = 1, std430) writeonly buffer SSBO1 +{ + float outputs[]; +}; + +shared float tmp[gl_WorkGroupSize.x]; + +void main() +{ + uint local = gl_LocalInvocationIndex; + uint work_group = gl_WorkGroupID.x; + + // Does a trivial parallel reduction through shared memory. + tmp[local] = inputs[work_group * gl_WorkGroupSize.x * 2u + local] + inputs[work_group * gl_WorkGroupSize.x * 2u + local + gl_WorkGroupSize.x]; + memoryBarrierShared(); + barrier(); + + for (uint limit = 32u; limit > 1u; limit >>= 1u) + { + if (local < limit) + tmp[local] = tmp[local] + tmp[local + limit]; + memoryBarrierShared(); + barrier(); + } + + if (local == 0u) + outputs[work_group] = tmp[0] + tmp[1]; +} diff --git a/samples/cpp/shared.cpp b/samples/cpp/shared.cpp new file mode 100644 index 0000000000..5be62d681f --- /dev/null +++ b/samples/cpp/shared.cpp @@ -0,0 +1,89 @@ +/* + * Copyright 2015-2017 ARM Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "spirv_cross/external_interface.h" +#include + +#ifndef GLM_SWIZZLE +#define GLM_SWIZZLE +#endif + +#ifndef GLM_FORCE_RADIANS +#define GLM_FORCE_RADIANS +#endif + +#include +using namespace glm; + +int main() +{ + // First, we get the C interface to the shader. + // This can be loaded from a dynamic library, or as here, + // linked in as a static library. + auto *iface = spirv_cross_get_interface(); + + // Create an instance of the shader interface. + auto *shader = iface->construct(); + +// Build some input data for our compute shader. +#define NUM_WORKGROUPS 4 + float a[128 * NUM_WORKGROUPS]; + float b[NUM_WORKGROUPS] = {}; + + for (int i = 0; i < 128 * NUM_WORKGROUPS; i++) + { + a[i] = float(i); + } + + void *aptr = a; + void *bptr = b; + + // Bind resources to the shader. + // For resources like samplers and buffers, we provide a list of pointers, + // since UBOs, SSBOs and samplers can be arrays, and can point to different types, + // which is especially true for samplers. + spirv_cross_set_resource(shader, 0, 0, &aptr, sizeof(aptr)); + spirv_cross_set_resource(shader, 0, 1, &bptr, sizeof(bptr)); + + // We also have to set builtins. + // The relevant builtins will depend on the shader, + // but for compute, there are few builtins, which are gl_NumWorkGroups and gl_WorkGroupID. + // LocalInvocationID and GlobalInvocationID are inferred when executing the invocation. + uvec3 num_workgroups(NUM_WORKGROUPS, 1, 1); + uvec3 work_group_id(0, 0, 0); + spirv_cross_set_builtin(shader, SPIRV_CROSS_BUILTIN_NUM_WORK_GROUPS, &num_workgroups, sizeof(num_workgroups)); + spirv_cross_set_builtin(shader, SPIRV_CROSS_BUILTIN_WORK_GROUP_ID, &work_group_id, sizeof(work_group_id)); + + // Execute 4 work groups. + for (unsigned i = 0; i < NUM_WORKGROUPS; i++) + { + work_group_id.x = i; + iface->invoke(shader); + } + + // Call destructor. + iface->destruct(shader); + + // Verify our output. + // TODO: Implement a test framework that asserts results computed. + for (unsigned i = 0; i < NUM_WORKGROUPS; i++) + { + float expected_sum = 0.0f; + for (unsigned j = i * 128; j < (i + 1) * 128; j++) + expected_sum += a[j]; + fprintf(stderr, "Sum in workgroup #%u = %.1f, expected %.1f\n", i, b[i], expected_sum); + } +} diff --git a/shaders-hlsl/asm/comp/specialization-constant-workgroup.nofxc.asm.comp b/shaders-hlsl/asm/comp/specialization-constant-workgroup.nofxc.asm.comp new file mode 100644 index 0000000000..188e3fec36 --- /dev/null +++ b/shaders-hlsl/asm/comp/specialization-constant-workgroup.nofxc.asm.comp @@ -0,0 +1,47 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 1 +; Bound: 24 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 20 1 + OpSource ESSL 310 + OpName %main "main" + OpName %SSBO "SSBO" + OpMemberName %SSBO 0 "a" + OpName %_ "" + OpMemberDecorate %SSBO 0 Offset 0 + OpDecorate %SSBO BufferBlock + OpDecorate %_ DescriptorSet 0 + OpDecorate %_ Binding 0 + OpDecorate %19 SpecId 10 + OpDecorate %21 SpecId 12 + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %SSBO = OpTypeStruct %float +%_ptr_Uniform_SSBO = OpTypePointer Uniform %SSBO + %_ = OpVariable %_ptr_Uniform_SSBO Uniform + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %float_1 = OpConstant %float 1 +%_ptr_Uniform_float = OpTypePointer Uniform %float + %uint = OpTypeInt 32 0 + %19 = OpSpecConstant %uint 9 + %uint_20 = OpConstant %uint 20 + %21 = OpSpecConstant %uint 4 + %v3uint = OpTypeVector %uint 3 +%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %19 %uint_20 %21 + %main = OpFunction %void None %3 + %5 = OpLabel + %14 = OpAccessChain %_ptr_Uniform_float %_ %int_0 + %15 = OpLoad %float %14 + %16 = OpFAdd %float %15 %float_1 + %17 = OpAccessChain %_ptr_Uniform_float %_ %int_0 + OpStore %17 %16 + OpReturn + OpFunctionEnd diff --git a/shaders-hlsl/asm/comp/storage-buffer-basic.nofxc.asm.comp b/shaders-hlsl/asm/comp/storage-buffer-basic.nofxc.asm.comp new file mode 100644 index 0000000000..edb1a05e54 --- /dev/null +++ b/shaders-hlsl/asm/comp/storage-buffer-basic.nofxc.asm.comp @@ -0,0 +1,57 @@ +; SPIR-V +; Version: 1.0 +; Generator: Codeplay; 0 +; Bound: 31 +; Schema: 0 + OpCapability Shader + OpCapability VariablePointers + OpExtension "SPV_KHR_storage_buffer_storage_class" + OpExtension "SPV_KHR_variable_pointers" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %22 "main" %gl_WorkGroupID + OpSource OpenCL_C 120 + OpDecorate %15 SpecId 0 + ;OpDecorate %16 SpecId 1 + OpDecorate %17 SpecId 2 + OpDecorate %_runtimearr_float ArrayStride 4 + OpMemberDecorate %_struct_4 0 Offset 0 + OpDecorate %_struct_4 Block + OpDecorate %gl_WorkGroupID BuiltIn WorkgroupId + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + OpDecorate %20 DescriptorSet 0 + OpDecorate %20 Binding 0 + OpDecorate %21 DescriptorSet 0 + OpDecorate %21 Binding 1 + %float = OpTypeFloat 32 +%_ptr_StorageBuffer_float = OpTypePointer StorageBuffer %float +%_runtimearr_float = OpTypeRuntimeArray %float + %_struct_4 = OpTypeStruct %_runtimearr_float +%_ptr_StorageBuffer__struct_4 = OpTypePointer StorageBuffer %_struct_4 + %uint = OpTypeInt 32 0 + %void = OpTypeVoid + %8 = OpTypeFunction %void + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint +%_ptr_Input_uint = OpTypePointer Input %uint +%_ptr_Private_v3uint = OpTypePointer Private %v3uint + %uint_0 = OpConstant %uint 0 +%gl_WorkGroupID = OpVariable %_ptr_Input_v3uint Input + %15 = OpSpecConstant %uint 1 + %16 = OpConstant %uint 2 + %17 = OpSpecConstant %uint 3 +%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %15 %16 %17 + %19 = OpVariable %_ptr_Private_v3uint Private %gl_WorkGroupSize + %20 = OpVariable %_ptr_StorageBuffer__struct_4 StorageBuffer + %21 = OpVariable %_ptr_StorageBuffer__struct_4 StorageBuffer + %22 = OpFunction %void None %8 + %23 = OpLabel + %24 = OpAccessChain %_ptr_Input_uint %gl_WorkGroupID %uint_0 + %25 = OpLoad %uint %24 + %26 = OpAccessChain %_ptr_StorageBuffer_float %21 %uint_0 %25 + %27 = OpLoad %float %26 + %28 = OpAccessChain %_ptr_StorageBuffer_float %20 %uint_0 %25 + %29 = OpLoad %float %28 + %30 = OpFAdd %float %27 %29 + OpStore %28 %30 + OpReturn + OpFunctionEnd diff --git a/shaders-hlsl/asm/frag/cbuffer-stripped.asm.frag b/shaders-hlsl/asm/frag/cbuffer-stripped.asm.frag new file mode 100644 index 0000000000..d778034b5f --- /dev/null +++ b/shaders-hlsl/asm/frag/cbuffer-stripped.asm.frag @@ -0,0 +1,55 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 1 +; Bound: 34 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %_entryPointOutput + OpExecutionMode %main OriginUpperLeft + OpSource HLSL 500 + OpMemberDecorate %UBO 0 RowMajor + OpMemberDecorate %UBO 0 Offset 0 + OpMemberDecorate %UBO 0 MatrixStride 16 + OpMemberDecorate %UBO 1 Offset 64 + OpDecorate %UBO Block + OpDecorate %_ DescriptorSet 0 + OpDecorate %_ Binding 0 + OpDecorate %_entryPointOutput Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v2float = OpTypeVector %float 2 + %8 = OpTypeFunction %v2float +%_ptr_Function_v2float = OpTypePointer Function %v2float + %v4float = OpTypeVector %float 4 +%mat2v4float = OpTypeMatrix %v4float 2 + %UBO = OpTypeStruct %mat2v4float %v4float +%_ptr_Uniform_UBO = OpTypePointer Uniform %UBO + %_ = OpVariable %_ptr_Uniform_UBO Uniform + %int = OpTypeInt 32 1 + %int_1 = OpConstant %int 1 +%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float + %int_0 = OpConstant %int 0 +%_ptr_Uniform_mat2v4float = OpTypePointer Uniform %mat2v4float +%_ptr_Output_v2float = OpTypePointer Output %v2float +%_entryPointOutput = OpVariable %_ptr_Output_v2float Output + %main = OpFunction %void None %3 + %5 = OpLabel + %33 = OpFunctionCall %v2float %_main_ + OpStore %_entryPointOutput %33 + OpReturn + OpFunctionEnd + %_main_ = OpFunction %v2float None %8 + %10 = OpLabel + %a0 = OpVariable %_ptr_Function_v2float Function + %21 = OpAccessChain %_ptr_Uniform_v4float %_ %int_1 + %22 = OpLoad %v4float %21 + %25 = OpAccessChain %_ptr_Uniform_mat2v4float %_ %int_0 + %26 = OpLoad %mat2v4float %25 + %27 = OpVectorTimesMatrix %v2float %22 %26 + OpStore %a0 %27 + %28 = OpLoad %v2float %a0 + OpReturnValue %28 + OpFunctionEnd diff --git a/shaders-hlsl/asm/frag/unreachable.asm.frag b/shaders-hlsl/asm/frag/unreachable.asm.frag new file mode 100644 index 0000000000..e2ce2eb56a --- /dev/null +++ b/shaders-hlsl/asm/frag/unreachable.asm.frag @@ -0,0 +1,61 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 3 +; Bound: 47 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %counter %FragColor + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 450 + OpName %main "main" + OpName %counter "counter" + OpName %FragColor "FragColor" + OpDecorate %counter Flat + OpDecorate %counter Location 0 + OpDecorate %FragColor Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %8 = OpTypeFunction %v4float + %int = OpTypeInt 32 1 +%_ptr_Input_int = OpTypePointer Input %int + %counter = OpVariable %_ptr_Input_int Input + %int_10 = OpConstant %int 10 + %bool = OpTypeBool + %float_10 = OpConstant %float 10 + %21 = OpConstantComposite %v4float %float_10 %float_10 %float_10 %float_10 + %float_30 = OpConstant %float 30 + %25 = OpConstantComposite %v4float %float_30 %float_30 %float_30 %float_30 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %FragColor = OpVariable %_ptr_Output_v4float Output +%_ptr_Function_v4float = OpTypePointer Function %v4float + %false = OpConstantFalse %bool + %44 = OpUndef %v4float + %main = OpFunction %void None %3 + %5 = OpLabel + OpBranch %33 + %33 = OpLabel + %45 = OpPhi %v4float %44 %5 %44 %35 + OpLoopMerge %34 %35 None + OpBranch %36 + %36 = OpLabel + %37 = OpLoad %int %counter + %38 = OpIEqual %bool %37 %int_10 + OpSelectionMerge %39 None + OpBranchConditional %38 %40 %41 + %40 = OpLabel + OpBranch %34 + %41 = OpLabel + OpBranch %34 + %39 = OpLabel + OpUnreachable + %35 = OpLabel + OpBranchConditional %false %33 %34 + %34 = OpLabel + %46 = OpPhi %v4float %21 %40 %25 %41 %44 %35 + OpStore %FragColor %46 + OpReturn + OpFunctionEnd diff --git a/shaders-hlsl/asm/vert/empty-struct-composite.asm.vert b/shaders-hlsl/asm/vert/empty-struct-composite.asm.vert new file mode 100644 index 0000000000..37a2d87937 --- /dev/null +++ b/shaders-hlsl/asm/vert/empty-struct-composite.asm.vert @@ -0,0 +1,37 @@ +; SPIR-V +; Version: 1.1 +; Generator: Google rspirv; 0 +; Bound: 17 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %2 "main" + OpExecutionMode %2 OriginUpperLeft + OpName %Test "Test" + OpName %t "t" + OpName %retvar "retvar" + OpName %main "main" + OpName %retvar_0 "retvar" + %void = OpTypeVoid + %6 = OpTypeFunction %void + %Test = OpTypeStruct +%_ptr_Function_Test = OpTypePointer Function %Test +%_ptr_Function_void = OpTypePointer Function %void + %2 = OpFunction %void None %6 + %7 = OpLabel + %t = OpVariable %_ptr_Function_Test Function + %retvar = OpVariable %_ptr_Function_void Function + OpBranch %4 + %4 = OpLabel + %13 = OpCompositeConstruct %Test + OpStore %t %13 + OpReturn + OpFunctionEnd + %main = OpFunction %void None %6 + %15 = OpLabel + %retvar_0 = OpVariable %_ptr_Function_void Function + OpBranch %14 + %14 = OpLabel + OpReturn + OpFunctionEnd diff --git a/shaders-hlsl/asm/vert/vertex-id-instance-id.asm.vert b/shaders-hlsl/asm/vert/vertex-id-instance-id.asm.vert new file mode 100644 index 0000000000..85acc47ff2 --- /dev/null +++ b/shaders-hlsl/asm/vert/vertex-id-instance-id.asm.vert @@ -0,0 +1,53 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 2 +; Bound: 26 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %main "main" %_ %gl_VertexID %gl_InstanceID + OpSource GLSL 450 + OpName %main "main" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpMemberName %gl_PerVertex 1 "gl_PointSize" + OpMemberName %gl_PerVertex 2 "gl_ClipDistance" + OpMemberName %gl_PerVertex 3 "gl_CullDistance" + OpName %_ "" + OpName %gl_VertexID "gl_VertexID" + OpName %gl_InstanceID "gl_InstanceID" + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize + OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance + OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance + OpDecorate %gl_PerVertex Block + OpDecorate %gl_VertexID BuiltIn VertexId + OpDecorate %gl_InstanceID BuiltIn InstanceId + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 +%_arr_float_uint_1 = OpTypeArray %float %uint_1 +%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1 +%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex + %_ = OpVariable %_ptr_Output_gl_PerVertex Output + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 +%_ptr_Input_int = OpTypePointer Input %int +%gl_VertexID = OpVariable %_ptr_Input_int Input +%gl_InstanceID = OpVariable %_ptr_Input_int Input +%_ptr_Output_v4float = OpTypePointer Output %v4float + %main = OpFunction %void None %3 + %5 = OpLabel + %18 = OpLoad %int %gl_VertexID + %20 = OpLoad %int %gl_InstanceID + %21 = OpIAdd %int %18 %20 + %22 = OpConvertSToF %float %21 + %23 = OpCompositeConstruct %v4float %22 %22 %22 %22 + %25 = OpAccessChain %_ptr_Output_v4float %_ %int_0 + OpStore %25 %23 + OpReturn + OpFunctionEnd diff --git a/shaders-hlsl/comp/access-chains.comp b/shaders-hlsl/comp/access-chains.comp new file mode 100644 index 0000000000..639f3cac15 --- /dev/null +++ b/shaders-hlsl/comp/access-chains.comp @@ -0,0 +1,24 @@ +#version 310 es +layout(local_size_x = 1) in; + +// TODO: Read structs, matrices and arrays. + +layout(std430, binding = 0) readonly buffer SSBO +{ + vec4 a[3][2][4]; + float b[3][2][4]; + vec4 unsized[]; +} ro; + +layout(std430, binding = 1) writeonly buffer SSBO1 +{ + vec4 c[3][2][4]; + float d[3][2][4]; + vec4 unsized[]; +} wo; + +void main() +{ + wo.c[2][gl_GlobalInvocationID.x][1] = ro.a[1][gl_GlobalInvocationID.x][2]; + wo.unsized[gl_GlobalInvocationID.x] = ro.unsized[gl_GlobalInvocationID.x]; +} diff --git a/shaders-hlsl/comp/address-buffers.comp b/shaders-hlsl/comp/address-buffers.comp new file mode 100644 index 0000000000..3ba582ccd6 --- /dev/null +++ b/shaders-hlsl/comp/address-buffers.comp @@ -0,0 +1,23 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(binding = 0, std430) readonly buffer ReadOnlyBuffer +{ + vec4 ro; +} ReadOnly; + +layout(binding = 1, std430) buffer ReadWriteBuffer +{ + vec4 rw; +} ReadWrite; + +layout(binding = 2, std430) buffer WriteOnlyBuffer +{ + vec4 wo; +} WriteOnly; + +void main() +{ + WriteOnly.wo = ReadOnly.ro; + ReadWrite.rw += 10.0; +} diff --git a/shaders-hlsl/comp/atomic.comp b/shaders-hlsl/comp/atomic.comp new file mode 100644 index 0000000000..6f69ec725c --- /dev/null +++ b/shaders-hlsl/comp/atomic.comp @@ -0,0 +1,66 @@ +#version 310 es +#extension GL_OES_shader_image_atomic : require +layout(local_size_x = 1) in; + +layout(r32ui, binding = 0) uniform highp uimage2D uImage; +layout(r32i, binding = 1) uniform highp iimage2D iImage; +layout(binding = 2, std430) buffer SSBO +{ + uint u32; + int i32; +} ssbo; + +shared int int_atomic; +shared uint uint_atomic; +shared int int_atomic_array[1]; +shared uint uint_atomic_array[1]; + +void main() +{ + imageAtomicAdd(uImage, ivec2(1, 5), 1u); + + // Test that we do not invalidate OpImage variables which are loaded from UniformConstant + // address space. + imageStore(iImage, ivec2(1, 6), ivec4(imageAtomicAdd(uImage, ivec2(1, 5), 1u))); + + imageAtomicOr(uImage, ivec2(1, 5), 1u); + imageAtomicXor(uImage, ivec2(1, 5), 1u); + imageAtomicAnd(uImage, ivec2(1, 5), 1u); + imageAtomicMin(uImage, ivec2(1, 5), 1u); + imageAtomicMax(uImage, ivec2(1, 5), 1u); + //imageAtomicExchange(uImage, ivec2(1, 5), 1u); + imageAtomicCompSwap(uImage, ivec2(1, 5), 10u, 2u); + + imageAtomicAdd(iImage, ivec2(1, 6), 1); + imageAtomicOr(iImage, ivec2(1, 6), 1); + imageAtomicXor(iImage, ivec2(1, 6), 1); + imageAtomicAnd(iImage, ivec2(1, 6), 1); + imageAtomicMin(iImage, ivec2(1, 6), 1); + imageAtomicMax(iImage, ivec2(1, 6), 1); + //imageAtomicExchange(iImage, ivec2(1, 5), 1u); + imageAtomicCompSwap(iImage, ivec2(1, 5), 10, 2); + + atomicAdd(ssbo.u32, 1u); + atomicOr(ssbo.u32, 1u); + atomicXor(ssbo.u32, 1u); + atomicAnd(ssbo.u32, 1u); + atomicMin(ssbo.u32, 1u); + atomicMax(ssbo.u32, 1u); + atomicExchange(ssbo.u32, 1u); + atomicCompSwap(ssbo.u32, 10u, 2u); + + atomicAdd(ssbo.i32, 1); + atomicOr(ssbo.i32, 1); + atomicXor(ssbo.i32, 1); + atomicAnd(ssbo.i32, 1); + atomicMin(ssbo.i32, 1); + atomicMax(ssbo.i32, 1); + atomicExchange(ssbo.i32, 1); + atomicCompSwap(ssbo.i32, 10, 2); + + atomicAdd(int_atomic, 10); + atomicAdd(uint_atomic, 10u); + atomicAdd(int_atomic_array[0], 10); + atomicAdd(uint_atomic_array[0], 10u); +} + diff --git a/shaders-hlsl/comp/barriers.comp b/shaders-hlsl/comp/barriers.comp new file mode 100644 index 0000000000..7e0ea42d4e --- /dev/null +++ b/shaders-hlsl/comp/barriers.comp @@ -0,0 +1,79 @@ +#version 310 es +layout(local_size_x = 4) in; + +void barrier_shared() +{ + memoryBarrierShared(); +} + +void full_barrier() +{ + memoryBarrier(); +} + +void image_barrier() +{ + memoryBarrierImage(); +} + +void buffer_barrier() +{ + memoryBarrierBuffer(); +} + +void group_barrier() +{ + groupMemoryBarrier(); +} + +void barrier_shared_exec() +{ + memoryBarrierShared(); + barrier(); +} + +void full_barrier_exec() +{ + memoryBarrier(); + barrier(); +} + +void image_barrier_exec() +{ + memoryBarrierImage(); + barrier(); +} + +void buffer_barrier_exec() +{ + memoryBarrierBuffer(); + barrier(); +} + +void group_barrier_exec() +{ + groupMemoryBarrier(); + barrier(); +} + +void exec_barrier() +{ + barrier(); +} + +void main() +{ + barrier_shared(); + full_barrier(); + image_barrier(); + buffer_barrier(); + group_barrier(); + + barrier_shared_exec(); + full_barrier_exec(); + image_barrier_exec(); + buffer_barrier_exec(); + group_barrier_exec(); + + exec_barrier(); +} diff --git a/shaders-hlsl/comp/bitfield.noopt.comp b/shaders-hlsl/comp/bitfield.noopt.comp new file mode 100644 index 0000000000..a2ef9aa0b7 --- /dev/null +++ b/shaders-hlsl/comp/bitfield.noopt.comp @@ -0,0 +1,44 @@ +#version 310 es + +void main() +{ + int signed_value = 0; + uint unsigned_value = 0u; + + ivec3 signed_values = ivec3(0); + uvec3 unsigned_values = uvec3(0u); + + { + int s = bitfieldExtract(signed_value, 5, 20); + uint u = bitfieldExtract(unsigned_value, 6, 21); + + s = bitfieldInsert(s, 40, 5, 4); + u = bitfieldInsert(u, 60u, 5, 4); + + u = bitfieldReverse(u); + s = bitfieldReverse(s); + + int v0 = bitCount(u); + int v1 = bitCount(s); + + int v2 = findMSB(u); + int v3 = findLSB(s); + } + + { + ivec3 s = bitfieldExtract(signed_values, 5, 20); + uvec3 u = bitfieldExtract(unsigned_values, 6, 21); + + s = bitfieldInsert(s, ivec3(40), 5, 4); + u = bitfieldInsert(u, uvec3(60u), 5, 4); + + u = bitfieldReverse(u); + s = bitfieldReverse(s); + + ivec3 v0 = bitCount(u); + ivec3 v1 = bitCount(s); + + ivec3 v2 = findMSB(u); + ivec3 v3 = findLSB(s); + } +} diff --git a/shaders-hlsl/comp/builtins.comp b/shaders-hlsl/comp/builtins.comp new file mode 100644 index 0000000000..b41cb53913 --- /dev/null +++ b/shaders-hlsl/comp/builtins.comp @@ -0,0 +1,11 @@ +#version 310 es +layout(local_size_x = 8, local_size_y = 4, local_size_z = 2) in; + +void main() +{ + uvec3 local_id = gl_LocalInvocationID; + uvec3 global_id = gl_GlobalInvocationID; + uint local_index = gl_LocalInvocationIndex; + uvec3 work_group_size = gl_WorkGroupSize; + uvec3 work_group_id = gl_WorkGroupID; +} diff --git a/shaders-hlsl/comp/image.comp b/shaders-hlsl/comp/image.comp new file mode 100644 index 0000000000..1d3c8b4c65 --- /dev/null +++ b/shaders-hlsl/comp/image.comp @@ -0,0 +1,77 @@ +#version 450 +layout(local_size_x = 1) in; + +layout(r32f, binding = 0) uniform readonly image2D uImageInF; +layout(r32f, binding = 1) uniform writeonly image2D uImageOutF; +layout(r32i, binding = 2) uniform readonly iimage2D uImageInI; +layout(r32i, binding = 3) uniform writeonly iimage2D uImageOutI; +layout(r32ui, binding = 4) uniform readonly uimage2D uImageInU; +layout(r32ui, binding = 5) uniform writeonly uimage2D uImageOutU; +layout(r32f, binding = 6) uniform readonly imageBuffer uImageInBuffer; +layout(r32f, binding = 7) uniform writeonly imageBuffer uImageOutBuffer; + +layout(rg32f, binding = 8) uniform readonly image2D uImageInF2; +layout(rg32f, binding = 9) uniform writeonly image2D uImageOutF2; +layout(rg32i, binding = 10) uniform readonly iimage2D uImageInI2; +layout(rg32i, binding = 11) uniform writeonly iimage2D uImageOutI2; +layout(rg32ui, binding = 12) uniform readonly uimage2D uImageInU2; +layout(rg32ui, binding = 13) uniform writeonly uimage2D uImageOutU2; +layout(rg32f, binding = 14) uniform readonly imageBuffer uImageInBuffer2; +layout(rg32f, binding = 15) uniform writeonly imageBuffer uImageOutBuffer2; + +layout(rgba32f, binding = 16) uniform readonly image2D uImageInF4; +layout(rgba32f, binding = 17) uniform writeonly image2D uImageOutF4; +layout(rgba32i, binding = 18) uniform readonly iimage2D uImageInI4; +layout(rgba32i, binding = 19) uniform writeonly iimage2D uImageOutI4; +layout(rgba32ui, binding = 20) uniform readonly uimage2D uImageInU4; +layout(rgba32ui, binding = 21) uniform writeonly uimage2D uImageOutU4; +layout(rgba32f, binding = 22) uniform readonly imageBuffer uImageInBuffer4; +layout(rgba32f, binding = 23) uniform writeonly imageBuffer uImageOutBuffer4; + +layout(binding = 24) uniform writeonly image2D uImageNoFmtF; +layout(binding = 25) uniform writeonly uimage2D uImageNoFmtU; +layout(binding = 26) uniform writeonly iimage2D uImageNoFmtI; + +void main() +{ + vec4 f = imageLoad(uImageInF, ivec2(gl_GlobalInvocationID.xy)); + imageStore(uImageOutF, ivec2(gl_GlobalInvocationID.xy), f); + + ivec4 i = imageLoad(uImageInI, ivec2(gl_GlobalInvocationID.xy)); + imageStore(uImageOutI, ivec2(gl_GlobalInvocationID.xy), i); + + uvec4 u = imageLoad(uImageInU, ivec2(gl_GlobalInvocationID.xy)); + imageStore(uImageOutU, ivec2(gl_GlobalInvocationID.xy), u); + + vec4 b = imageLoad(uImageInBuffer, int(gl_GlobalInvocationID.x)); + imageStore(uImageOutBuffer, int(gl_GlobalInvocationID.x), b); + + vec4 f2 = imageLoad(uImageInF2, ivec2(gl_GlobalInvocationID.xy)); + imageStore(uImageOutF2, ivec2(gl_GlobalInvocationID.xy), f2); + + ivec4 i2 = imageLoad(uImageInI2, ivec2(gl_GlobalInvocationID.xy)); + imageStore(uImageOutI2, ivec2(gl_GlobalInvocationID.xy), i2); + + uvec4 u2 = imageLoad(uImageInU2, ivec2(gl_GlobalInvocationID.xy)); + imageStore(uImageOutU2, ivec2(gl_GlobalInvocationID.xy), u2); + + vec4 b2 = imageLoad(uImageInBuffer2, int(gl_GlobalInvocationID.x)); + imageStore(uImageOutBuffer2, int(gl_GlobalInvocationID.x), b2); + + vec4 f4 = imageLoad(uImageInF4, ivec2(gl_GlobalInvocationID.xy)); + imageStore(uImageOutF4, ivec2(gl_GlobalInvocationID.xy), f4); + + ivec4 i4 = imageLoad(uImageInI4, ivec2(gl_GlobalInvocationID.xy)); + imageStore(uImageOutI4, ivec2(gl_GlobalInvocationID.xy), i4); + + uvec4 u4 = imageLoad(uImageInU4, ivec2(gl_GlobalInvocationID.xy)); + imageStore(uImageOutU4, ivec2(gl_GlobalInvocationID.xy), u4); + + vec4 b4 = imageLoad(uImageInBuffer4, int(gl_GlobalInvocationID.x)); + imageStore(uImageOutBuffer4, int(gl_GlobalInvocationID.x), b4); + + imageStore(uImageNoFmtF, ivec2(gl_GlobalInvocationID.xy), b2); + imageStore(uImageNoFmtU, ivec2(gl_GlobalInvocationID.xy), u4); + imageStore(uImageNoFmtI, ivec2(gl_GlobalInvocationID.xy), i4); +} + diff --git a/shaders-hlsl/comp/rwbuffer-matrix.comp b/shaders-hlsl/comp/rwbuffer-matrix.comp new file mode 100644 index 0000000000..0e722e0a51 --- /dev/null +++ b/shaders-hlsl/comp/rwbuffer-matrix.comp @@ -0,0 +1,104 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(std140, binding = 1) uniform UBO +{ + int index0; + int index1; +}; + +layout(binding = 0, std430) buffer SSBO +{ + layout(column_major) mat4 mcol; + layout(row_major) mat4 mrow; + + layout(column_major) mat2 mcol2x2; + layout(row_major) mat2 mrow2x2; + + layout(column_major) mat2x3 mcol2x3; + layout(row_major) mat2x3 mrow2x3; + + layout(column_major) mat3x2 mcol3x2; + layout(row_major) mat3x2 mrow3x2; +}; + +void col_to_row() +{ + // Load column-major, store row-major. + mrow = mcol; + mrow2x2 = mcol2x2; + mrow2x3 = mcol2x3; + mrow3x2 = mcol3x2; +} + +void row_to_col() +{ + // Load row-major, store column-major. + mcol = mrow; + mcol2x2 = mrow2x2; + mcol2x3 = mrow2x3; + mcol3x2 = mrow3x2; +} + +void write_dynamic_index_row() +{ + mrow[index0][index1] = 1.0; + mrow2x2[index0][index1] = 2.0; + mrow2x3[index0][index1] = 3.0; + mrow3x2[index0][index1] = 4.0; + + mrow[index0] = vec4(1.0); + mrow2x2[index0] = vec2(2.0); + mrow2x3[index0] = vec3(3.0); + mrow3x2[index0] = vec2(4.0); +} + +void write_dynamic_index_col() +{ + mcol[index0][index1] = 1.0; + mcol2x2[index0][index1] = 2.0; + mcol2x3[index0][index1] = 3.0; + mcol3x2[index0][index1] = 4.0; + + mcol[index0] = vec4(1.0); + mcol2x2[index0] = vec2(2.0); + mcol2x3[index0] = vec3(3.0); + mcol3x2[index0] = vec2(4.0); +} + +void read_dynamic_index_row() +{ + float a0 = mrow[index0][index1]; + float a1 = mrow2x2[index0][index1]; + float a2 = mrow2x3[index0][index1]; + float a3 = mrow3x2[index0][index1]; + + vec4 v0 = mrow[index0]; + vec2 v1 = mrow2x2[index0]; + vec3 v2 = mrow2x3[index0]; + vec2 v3 = mrow3x2[index0]; +} + +void read_dynamic_index_col() +{ + float a0 = mcol[index0][index1]; + float a1 = mcol2x2[index0][index1]; + float a2 = mcol2x3[index0][index1]; + float a3 = mcol3x2[index0][index1]; + + vec4 v0 = mcol[index0]; + vec2 v1 = mcol2x2[index0]; + vec3 v2 = mcol2x3[index0]; + vec2 v3 = mcol3x2[index0]; +} + +void main() +{ + row_to_col(); + col_to_row(); + write_dynamic_index_row(); + write_dynamic_index_col(); + read_dynamic_index_row(); + read_dynamic_index_col(); +} + diff --git a/shaders-hlsl/comp/shared.comp b/shaders-hlsl/comp/shared.comp new file mode 100644 index 0000000000..4deff93597 --- /dev/null +++ b/shaders-hlsl/comp/shared.comp @@ -0,0 +1,27 @@ +#version 310 es +layout(local_size_x = 4) in; + +shared float sShared[gl_WorkGroupSize.x]; + +layout(std430, binding = 0) readonly buffer SSBO +{ + float in_data[]; +}; + +layout(std430, binding = 1) writeonly buffer SSBO2 +{ + float out_data[]; +}; + +void main() +{ + uint ident = gl_GlobalInvocationID.x; + float idata = in_data[ident]; + + sShared[gl_LocalInvocationIndex] = idata; + memoryBarrierShared(); + barrier(); + + out_data[ident] = sShared[gl_WorkGroupSize.x - gl_LocalInvocationIndex - 1u]; +} + diff --git a/shaders-hlsl/comp/ssbo-array.comp b/shaders-hlsl/comp/ssbo-array.comp new file mode 100644 index 0000000000..38b56e9a0a --- /dev/null +++ b/shaders-hlsl/comp/ssbo-array.comp @@ -0,0 +1,29 @@ +#version 450 +layout(local_size_x = 1) in; + +layout(binding = 0, std430) buffer SSBO0 +{ + vec4 a; +} ssbo0; + +// Does not seem to work in glslang yet in HLSL output, disable for now. +#if 0 +layout(binding = 1, std430) buffer SSBO1 +{ + vec4 b; +} ssbo1[2]; + +layout(binding = 2, std430) buffer SSBO2 +{ + vec4 c; +} ssbo2[3][3]; +#endif + +void main() +{ +#if 0 + ssbo1[1].b = ssbo0.a; + ssbo2[1][2].c = ssbo0.a; +#endif +} + diff --git a/shaders-hlsl/frag/basic.frag b/shaders-hlsl/frag/basic.frag new file mode 100644 index 0000000000..dd9a8f8507 --- /dev/null +++ b/shaders-hlsl/frag/basic.frag @@ -0,0 +1,13 @@ +#version 310 es +precision mediump float; + +layout(location = 0) in vec4 vColor; +layout(location = 1) in vec2 vTex; +layout(binding = 0) uniform sampler2D uTex; +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = vColor * texture(uTex, vTex); +} + diff --git a/shaders-hlsl/frag/bit-conversions.frag b/shaders-hlsl/frag/bit-conversions.frag new file mode 100644 index 0000000000..faacdc0f15 --- /dev/null +++ b/shaders-hlsl/frag/bit-conversions.frag @@ -0,0 +1,12 @@ +#version 310 es +precision mediump float; + +layout(location = 0) in vec2 value; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + int i = floatBitsToInt(value.x); + FragColor = vec4(1.0, 0.0, intBitsToFloat(i), 1.0); +} diff --git a/shaders-hlsl/frag/boolean-mix.frag b/shaders-hlsl/frag/boolean-mix.frag new file mode 100644 index 0000000000..9fd8ab3475 --- /dev/null +++ b/shaders-hlsl/frag/boolean-mix.frag @@ -0,0 +1,10 @@ +#version 310 es +precision mediump float; + +layout(location = 0) in vec2 x0; +layout(location = 0) out vec2 FragColor; + +void main() +{ + FragColor = x0.x > x0.y ? vec2(1.0, 0.0) : vec2(0.0, 1.0); +} diff --git a/shaders-hlsl/frag/builtins.frag b/shaders-hlsl/frag/builtins.frag new file mode 100644 index 0000000000..99e6e2df5b --- /dev/null +++ b/shaders-hlsl/frag/builtins.frag @@ -0,0 +1,11 @@ +#version 310 es +precision mediump float; + +layout(location = 0) out vec4 FragColor; +layout(location = 0) in vec4 vColor; + +void main() +{ + FragColor = gl_FragCoord + vColor; + gl_FragDepth = 0.5; +} diff --git a/shaders-hlsl/frag/bvec-operations.frag b/shaders-hlsl/frag/bvec-operations.frag new file mode 100644 index 0000000000..7221604d9a --- /dev/null +++ b/shaders-hlsl/frag/bvec-operations.frag @@ -0,0 +1,13 @@ +#version 310 es +precision mediump float; + +layout(location = 0) in vec2 value; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + bvec2 bools1 = not(bvec2(value.x == 0.0, value.y == 0.0)); + bvec2 bools2 = lessThanEqual(value, vec2(1.5, 0.5)); + FragColor = vec4(1.0, 0.0, bools1.x ? 1.0 : 0.0, bools2.x ? 1.0 : 0.0); +} diff --git a/shaders-hlsl/frag/combined-texture-sampler-parameter.frag b/shaders-hlsl/frag/combined-texture-sampler-parameter.frag new file mode 100644 index 0000000000..e5721b9026 --- /dev/null +++ b/shaders-hlsl/frag/combined-texture-sampler-parameter.frag @@ -0,0 +1,31 @@ +#version 310 es +precision mediump float; + +layout(set = 0, binding = 0) uniform mediump sampler2D uSampler; +layout(set = 0, binding = 1) uniform mediump sampler2DShadow uSamplerShadow; +layout(location = 0) out float FragColor; + +vec4 samp2(sampler2D s) +{ + return texture(s, vec2(1.0)) + texelFetch(s, ivec2(10), 0); +} + +vec4 samp3(sampler2D s) +{ + return samp2(s); +} + +float samp4(mediump sampler2DShadow s) +{ + return texture(s, vec3(1.0)); +} + +float samp(sampler2D s0, mediump sampler2DShadow s1) +{ + return samp3(s0).x + samp4(s1); +} + +void main() +{ + FragColor = samp(uSampler, uSamplerShadow); +} diff --git a/shaders-hlsl/frag/combined-texture-sampler-shadow.frag b/shaders-hlsl/frag/combined-texture-sampler-shadow.frag new file mode 100644 index 0000000000..2fabb5ea8a --- /dev/null +++ b/shaders-hlsl/frag/combined-texture-sampler-shadow.frag @@ -0,0 +1,29 @@ +#version 310 es +precision mediump float; + +layout(set = 0, binding = 0) uniform mediump samplerShadow uSampler; +layout(set = 0, binding = 1) uniform mediump sampler uSampler1; +layout(set = 0, binding = 2) uniform texture2D uDepth; +layout(location = 0) out float FragColor; + +float samp2(texture2D t, mediump samplerShadow s) +{ + return texture(sampler2DShadow(t, s), vec3(1.0)); +} + +float samp3(texture2D t, mediump sampler s) +{ + return texture(sampler2D(t, s), vec2(1.0)).x; +} + +float samp(texture2D t, mediump samplerShadow s, mediump sampler s1) +{ + float r0 = samp2(t, s); + float r1 = samp3(t, s1); + return r0 + r1; +} + +void main() +{ + FragColor = samp(uDepth, uSampler, uSampler1); +} diff --git a/shaders-hlsl/frag/constant-buffer-array.sm51.frag b/shaders-hlsl/frag/constant-buffer-array.sm51.frag new file mode 100644 index 0000000000..d60002a0f2 --- /dev/null +++ b/shaders-hlsl/frag/constant-buffer-array.sm51.frag @@ -0,0 +1,32 @@ +#version 450 + +layout(std140, binding = 4) uniform CBO +{ + vec4 a; + vec4 b; + vec4 c; + vec4 d; +} cbo[2][4]; + +layout(std430, push_constant) uniform PushMe +{ + vec4 a; + vec4 b; + vec4 c; + vec4 d; +} push; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = cbo[1][2].a; + FragColor += cbo[1][2].b; + FragColor += cbo[1][2].c; + FragColor += cbo[1][2].d; + FragColor += push.a; + FragColor += push.b; + FragColor += push.c; + FragColor += push.d; +} + diff --git a/shaders-hlsl/frag/constant-composites.frag b/shaders-hlsl/frag/constant-composites.frag new file mode 100644 index 0000000000..a12e22ff4f --- /dev/null +++ b/shaders-hlsl/frag/constant-composites.frag @@ -0,0 +1,20 @@ +#version 310 es +precision mediump float; + +float lut[4] = float[](1.0, 4.0, 3.0, 2.0); + +struct Foo +{ + float a; + float b; +}; +Foo foos[2] = Foo[](Foo(10.0, 20.0), Foo(30.0, 40.0)); + +layout(location = 0) out vec4 FragColor; +layout(location = 0) flat in int line; + +void main() +{ + FragColor = vec4(lut[line]); + FragColor += foos[line].a * foos[1 - line].a; +} diff --git a/shaders-hlsl/frag/early-fragment-test.frag b/shaders-hlsl/frag/early-fragment-test.frag new file mode 100644 index 0000000000..9f84e09880 --- /dev/null +++ b/shaders-hlsl/frag/early-fragment-test.frag @@ -0,0 +1,7 @@ +#version 420 + +layout(early_fragment_tests) in; + +void main() +{ +} diff --git a/shaders-hlsl/frag/fp16-packing.frag b/shaders-hlsl/frag/fp16-packing.frag new file mode 100644 index 0000000000..98ca24e2f8 --- /dev/null +++ b/shaders-hlsl/frag/fp16-packing.frag @@ -0,0 +1,12 @@ +#version 450 + +layout(location = 0) flat in uint FP16; +layout(location = 1) flat in vec2 FP32; +layout(location = 0) out vec2 FP32Out; +layout(location = 1) out uint FP16Out; + +void main() +{ + FP32Out = unpackHalf2x16(FP16); + FP16Out = packHalf2x16(FP32); +} diff --git a/shaders-hlsl/frag/image-query-selective.frag b/shaders-hlsl/frag/image-query-selective.frag new file mode 100644 index 0000000000..bb595bcb9b --- /dev/null +++ b/shaders-hlsl/frag/image-query-selective.frag @@ -0,0 +1,35 @@ +#version 450 + +layout(binding = 0) uniform usampler1D uSampler1DUint; +layout(binding = 0) uniform isampler1D uSampler1DInt; +layout(binding = 0) uniform sampler1D uSampler1DFloat; +layout(binding = 1) uniform sampler2D uSampler2D; +layout(binding = 2) uniform isampler2DArray uSampler2DArray; +layout(binding = 3) uniform sampler3D uSampler3D; +layout(binding = 4) uniform samplerCube uSamplerCube; +layout(binding = 5) uniform usamplerCubeArray uSamplerCubeArray; +layout(binding = 6) uniform samplerBuffer uSamplerBuffer; +layout(binding = 7) uniform isampler2DMS uSamplerMS; +layout(binding = 8) uniform sampler2DMSArray uSamplerMSArray; + +void main() +{ + int a = textureSize(uSampler1DUint, 0); + a = textureSize(uSampler1DInt, 0); + a = textureSize(uSampler1DFloat, 0); + + ivec3 c = textureSize(uSampler2DArray, 0); + ivec3 d = textureSize(uSampler3D, 0); + ivec2 e = textureSize(uSamplerCube, 0); + ivec3 f = textureSize(uSamplerCubeArray, 0); + int g = textureSize(uSamplerBuffer); + ivec2 h = textureSize(uSamplerMS); + ivec3 i = textureSize(uSamplerMSArray); + + int l1 = textureQueryLevels(uSampler2D); + int l2 = textureQueryLevels(uSampler2DArray); + int l3 = textureQueryLevels(uSampler3D); + int l4 = textureQueryLevels(uSamplerCube); + int s0 = textureSamples(uSamplerMS); + int s1 = textureSamples(uSamplerMSArray); +} diff --git a/shaders-hlsl/frag/image-query.frag b/shaders-hlsl/frag/image-query.frag new file mode 100644 index 0000000000..8e840fba11 --- /dev/null +++ b/shaders-hlsl/frag/image-query.frag @@ -0,0 +1,33 @@ +#version 450 + +layout(binding = 0) uniform sampler1D uSampler1D; +layout(binding = 1) uniform sampler2D uSampler2D; +layout(binding = 2) uniform sampler2DArray uSampler2DArray; +layout(binding = 3) uniform sampler3D uSampler3D; +layout(binding = 4) uniform samplerCube uSamplerCube; +layout(binding = 5) uniform samplerCubeArray uSamplerCubeArray; +layout(binding = 6) uniform samplerBuffer uSamplerBuffer; +layout(binding = 7) uniform sampler2DMS uSamplerMS; +layout(binding = 8) uniform sampler2DMSArray uSamplerMSArray; + +void main() +{ + int a = textureSize(uSampler1D, 0); + ivec2 b = textureSize(uSampler2D, 0); + ivec3 c = textureSize(uSampler2DArray, 0); + ivec3 d = textureSize(uSampler3D, 0); + ivec2 e = textureSize(uSamplerCube, 0); + ivec3 f = textureSize(uSamplerCubeArray, 0); + int g = textureSize(uSamplerBuffer); + ivec2 h = textureSize(uSamplerMS); + ivec3 i = textureSize(uSamplerMSArray); + + int l0 = textureQueryLevels(uSampler1D); + int l1 = textureQueryLevels(uSampler2D); + int l2 = textureQueryLevels(uSampler2DArray); + int l3 = textureQueryLevels(uSampler3D); + int l4 = textureQueryLevels(uSamplerCube); + int l5 = textureQueryLevels(uSamplerCubeArray); + int s0 = textureSamples(uSamplerMS); + int s1 = textureSamples(uSamplerMSArray); +} diff --git a/shaders-hlsl/frag/io-block.frag b/shaders-hlsl/frag/io-block.frag new file mode 100644 index 0000000000..1e3e3d77e8 --- /dev/null +++ b/shaders-hlsl/frag/io-block.frag @@ -0,0 +1,16 @@ +#version 310 es +#extension GL_EXT_shader_io_blocks : require +precision mediump float; + +layout(location = 1) in VertexOut +{ + vec4 a; + vec4 b; +}; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = a + b; +} diff --git a/shaders-hlsl/frag/matrix-input.frag b/shaders-hlsl/frag/matrix-input.frag new file mode 100644 index 0000000000..ffe242cec2 --- /dev/null +++ b/shaders-hlsl/frag/matrix-input.frag @@ -0,0 +1,9 @@ +#version 450 + +layout(location = 0) out vec4 FragColor; +layout(location = 1) in mat4 m; + +void main() +{ + FragColor = m[0] + m[1] + m[2] + m[3]; +} diff --git a/shaders-hlsl/frag/mod.frag b/shaders-hlsl/frag/mod.frag new file mode 100644 index 0000000000..32edb61841 --- /dev/null +++ b/shaders-hlsl/frag/mod.frag @@ -0,0 +1,22 @@ +#version 310 es +precision mediump float; + +layout(location = 0) in vec4 a4; +layout(location = 1) in vec3 a3; +layout(location = 2) in vec2 a2; +layout(location = 3) in float a1; +layout(location = 4) in vec4 b4; +layout(location = 5) in vec3 b3; +layout(location = 6) in vec2 b2; +layout(location = 7) in float b1; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + vec4 m0 = mod(a4, b4); + vec3 m1 = mod(a3, b3); + vec2 m2 = mod(a2, b2); + float m3 = mod(a1, b1); + FragColor = m0 + m1.xyzx + m2.xyxy + m3; +} diff --git a/shaders-hlsl/frag/mrt.frag b/shaders-hlsl/frag/mrt.frag new file mode 100644 index 0000000000..77a2bb29c7 --- /dev/null +++ b/shaders-hlsl/frag/mrt.frag @@ -0,0 +1,15 @@ +#version 310 es +precision mediump float; + +layout(location = 0) out vec4 RT0; +layout(location = 1) out vec4 RT1; +layout(location = 2) out vec4 RT2; +layout(location = 3) out vec4 RT3; + +void main() +{ + RT0 = vec4(1.0); + RT1 = vec4(2.0); + RT2 = vec4(3.0); + RT3 = vec4(4.0); +} diff --git a/shaders-hlsl/frag/no-return.frag b/shaders-hlsl/frag/no-return.frag new file mode 100644 index 0000000000..f0ef8702ce --- /dev/null +++ b/shaders-hlsl/frag/no-return.frag @@ -0,0 +1,5 @@ +#version 310 es + +void main() +{ +} diff --git a/shaders-hlsl/frag/no-return2.frag b/shaders-hlsl/frag/no-return2.frag new file mode 100644 index 0000000000..46bf9fbf20 --- /dev/null +++ b/shaders-hlsl/frag/no-return2.frag @@ -0,0 +1,9 @@ +#version 310 es +precision mediump float; + +layout(location = 0) in vec4 vColor; + +void main() +{ + vec4 v = vColor; +} diff --git a/shaders-hlsl/frag/partial-write-preserve.frag b/shaders-hlsl/frag/partial-write-preserve.frag new file mode 100644 index 0000000000..f30270b91b --- /dev/null +++ b/shaders-hlsl/frag/partial-write-preserve.frag @@ -0,0 +1,64 @@ +#version 310 es +precision mediump float; + +layout(std140, binding = 0) uniform UBO +{ + int some_value; +}; + +struct B +{ + float a; + float b; +}; + +void partial_inout(inout vec4 x) +{ + x.x = 10.0; +} + +void partial_inout(inout B b) +{ + b.b = 40.0; +} + +// Make a complete write, but only conditionally ... +void branchy_inout(inout vec4 v) +{ + v.y = 20.0; + if (some_value == 20) + { + v = vec4(50.0); + } +} + +void branchy_inout_2(out vec4 v) +{ + if (some_value == 20) + { + v = vec4(50.0); + } + else + { + v = vec4(70.0); + } + v.y = 20.0; +} + +void complete_inout(out vec4 x) +{ + x = vec4(50.0); +} + +void main() +{ + vec4 a = vec4(10.0); + partial_inout(a); + complete_inout(a); + branchy_inout(a); + branchy_inout_2(a); + + B b = B(10.0, 20.0); + partial_inout(b); +} + diff --git a/shaders-hlsl/frag/query-lod.desktop.frag b/shaders-hlsl/frag/query-lod.desktop.frag new file mode 100644 index 0000000000..0cb160402f --- /dev/null +++ b/shaders-hlsl/frag/query-lod.desktop.frag @@ -0,0 +1,10 @@ +#version 450 + +layout(location = 0) in vec2 vTexCoord; +layout(binding = 0) uniform sampler2D uSampler; +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = textureQueryLod(uSampler, vTexCoord).xyxy; +} diff --git a/shaders-hlsl/frag/resources.frag b/shaders-hlsl/frag/resources.frag new file mode 100644 index 0000000000..16178bfd77 --- /dev/null +++ b/shaders-hlsl/frag/resources.frag @@ -0,0 +1,27 @@ +#version 310 es +precision mediump float; + +layout(binding = 3, std140) uniform CBuffer +{ + vec4 a; +} cbuf; + +layout(binding = 4) uniform sampler2D uSampledImage; +layout(binding = 5) uniform mediump texture2D uTexture; +layout(binding = 6) uniform mediump sampler uSampler; + +layout(location = 0) out vec4 FragColor; +layout(location = 0) in vec2 vTex; + +layout(std430, push_constant) uniform PushMe +{ + vec4 d; +} registers; + +void main() +{ + vec4 c0 = texture(uSampledImage, vTex); + vec4 c1 = texture(sampler2D(uTexture, uSampler), vTex); + vec4 c2 = cbuf.a + registers.d; + FragColor = c0 + c1 + c2; +} diff --git a/shaders-hlsl/frag/sample-cmp-level-zero.frag b/shaders-hlsl/frag/sample-cmp-level-zero.frag new file mode 100644 index 0000000000..c40d742eeb --- /dev/null +++ b/shaders-hlsl/frag/sample-cmp-level-zero.frag @@ -0,0 +1,27 @@ +#version 450 + +layout(location = 0) out float FragColor; +layout(binding = 0) uniform sampler2DShadow uSampler2D; +layout(binding = 1) uniform sampler2DArrayShadow uSampler2DArray; +layout(binding = 2) uniform samplerCubeShadow uSamplerCube; +layout(binding = 3) uniform samplerCubeArrayShadow uSamplerCubeArray; + +layout(location = 0) in vec3 vUVRef; +layout(location = 1) in vec4 vDirRef; + +void main() +{ + float s0 = textureOffset(uSampler2D, vUVRef, ivec2(-1)); + float s1 = textureOffset(uSampler2DArray, vDirRef, ivec2(-1)); + float s2 = texture(uSamplerCube, vDirRef); + float s3 = texture(uSamplerCubeArray, vDirRef, 0.5); + + float l0 = textureLodOffset(uSampler2D, vUVRef, 0.0, ivec2(-1)); + float l1 = textureGradOffset(uSampler2DArray, vDirRef, vec2(0.0), vec2(0.0), ivec2(-1)); + float l2 = textureGrad(uSamplerCube, vDirRef, vec3(0.0), vec3(0.0)); + + float p0 = textureProjOffset(uSampler2D, vDirRef, ivec2(+1)); + float p1 = textureProjLodOffset(uSampler2D, vDirRef, 0.0, ivec2(+1)); + + FragColor = s0 + s1 + s2 + s3 + l0 + l1 + l2 + p0 + p1; +} diff --git a/shaders-hlsl/frag/sampler-array.frag b/shaders-hlsl/frag/sampler-array.frag new file mode 100644 index 0000000000..75910ed163 --- /dev/null +++ b/shaders-hlsl/frag/sampler-array.frag @@ -0,0 +1,28 @@ +#version 450 + +layout(binding = 0) uniform sampler2D uCombined[4]; +layout(binding = 4) uniform texture2D uTex[4]; +layout(binding = 8) uniform sampler uSampler[4]; +layout(binding = 12, rgba32f) uniform writeonly image2D uImage[8]; +layout(location = 0) in vec2 vTex; +layout(location = 1) flat in int vIndex; + +vec4 sample_in_function(sampler2D samp) +{ + return texture(samp, vTex); +} + +vec4 sample_in_function2(texture2D tex, sampler samp) +{ + return texture(sampler2D(tex, samp), vTex); +} + +void main() +{ + vec4 color = texture(uCombined[vIndex], vTex); + color += texture(sampler2D(uTex[vIndex], uSampler[vIndex]), vTex); + color += sample_in_function(uCombined[vIndex + 1]); + color += sample_in_function2(uTex[vIndex + 1], uSampler[vIndex + 1]); + + imageStore(uImage[vIndex], ivec2(gl_FragCoord.xy), color); +} diff --git a/shaders-hlsl/frag/spec-constant.frag b/shaders-hlsl/frag/spec-constant.frag new file mode 100644 index 0000000000..a6c8d94e78 --- /dev/null +++ b/shaders-hlsl/frag/spec-constant.frag @@ -0,0 +1,80 @@ +#version 310 es +precision mediump float; + +layout(location = 0) out vec4 FragColor; +layout(constant_id = 1) const float a = 1.0; +layout(constant_id = 2) const float b = 2.0; +layout(constant_id = 3) const int c = 3; +layout(constant_id = 4) const int d = 4; +layout(constant_id = 5) const uint e = 5u; +layout(constant_id = 6) const uint f = 6u; +layout(constant_id = 7) const bool g = false; +layout(constant_id = 8) const bool h = true; +// glslang doesn't seem to support partial spec constants or composites yet, so only test the basics. + +struct Foo +{ + float elems[d + 2]; +}; + +void main() +{ + float t0 = a; + float t1 = b; + + uint c0 = uint(c); // OpIAdd with different types. + // FConvert, float-to-double. + int c1 = -c; // SNegate + int c2 = ~c; // OpNot + int c3 = c + d; // OpIAdd + int c4 = c - d; // OpISub + int c5 = c * d; // OpIMul + int c6 = c / d; // OpSDiv + uint c7 = e / f; // OpUDiv + int c8 = c % d; // OpSMod + uint c9 = e % f; // OpUMod + // TODO: OpSRem, any way to access this in GLSL? + int c10 = c >> d; // OpShiftRightArithmetic + uint c11 = e >> f; // OpShiftRightLogical + int c12 = c << d; // OpShiftLeftLogical + int c13 = c | d; // OpBitwiseOr + int c14 = c ^ d; // OpBitwiseXor + int c15 = c & d; // OpBitwiseAnd + // VectorShuffle, CompositeExtract, CompositeInsert, not testable atm. + bool c16 = g || h; // OpLogicalOr + bool c17 = g && h; // OpLogicalAnd + bool c18 = !g; // OpLogicalNot + bool c19 = g == h; // OpLogicalEqual + bool c20 = g != h; // OpLogicalNotEqual + // OpSelect not testable atm. + bool c21 = c == d; // OpIEqual + bool c22 = c != d; // OpINotEqual + bool c23 = c < d; // OpSLessThan + bool c24 = e < f; // OpULessThan + bool c25 = c > d; // OpSGreaterThan + bool c26 = e > f; // OpUGreaterThan + bool c27 = c <= d; // OpSLessThanEqual + bool c28 = e <= f; // OpULessThanEqual + bool c29 = c >= d; // OpSGreaterThanEqual + bool c30 = e >= f; // OpUGreaterThanEqual + // OpQuantizeToF16 not testable atm. + + int c31 = c8 + c3; + + int c32 = int(e); // OpIAdd with different types. + bool c33 = bool(c); // int -> bool + bool c34 = bool(e); // uint -> bool + int c35 = int(g); // bool -> int + uint c36 = uint(g); // bool -> uint + float c37 = float(g); // bool -> float + + // Flexible sized arrays with spec constants and spec constant ops. + float vec0[c + 3][8]; + float vec1[c + 2]; + vec0[0][0] = 10.0; + vec1[0] = 20.0; + + Foo foo; + foo.elems[c] = 10.0; + FragColor = vec4(t0 + t1) + vec0[0][0] + vec1[0] + foo.elems[c]; +} diff --git a/shaders-hlsl/frag/swizzle-scalar.frag b/shaders-hlsl/frag/swizzle-scalar.frag new file mode 100644 index 0000000000..c27524f7a6 --- /dev/null +++ b/shaders-hlsl/frag/swizzle-scalar.frag @@ -0,0 +1,16 @@ +#version 450 + +layout(location = 0) flat in float vFloat; +layout(location = 1) flat in int vInt; +layout(location = 0) out vec4 Float; +layout(location = 1) out ivec4 Int; +layout(location = 2) out vec4 Float2; +layout(location = 3) out ivec4 Int2; + +void main() +{ + Float = vec4(vFloat) * 2.0; + Int = ivec4(vInt) * 2; + Float2 = vec4(10.0); + Int2 = ivec4(10); +} diff --git a/shaders-hlsl/frag/tex-sampling.frag b/shaders-hlsl/frag/tex-sampling.frag new file mode 100644 index 0000000000..4a386c0d33 --- /dev/null +++ b/shaders-hlsl/frag/tex-sampling.frag @@ -0,0 +1,81 @@ +#version 450 + +uniform sampler1D tex1d; +uniform sampler2D tex2d; +uniform sampler3D tex3d; +uniform samplerCube texCube; + +uniform sampler1DShadow tex1dShadow; +uniform sampler2DShadow tex2dShadow; +uniform samplerCubeShadow texCubeShadow; + +uniform sampler1DArray tex1dArray; +uniform sampler2DArray tex2dArray; +uniform samplerCubeArray texCubeArray; + +uniform samplerShadow samplerDepth; +uniform sampler samplerNonDepth; +uniform texture2D separateTex2d; +uniform texture2D separateTex2dDepth; + +layout(location = 0) in float texCoord1d; +layout(location = 1) in vec2 texCoord2d; +layout(location = 2) in vec3 texCoord3d; +layout(location = 3) in vec4 texCoord4d; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + vec4 texcolor = texture(tex1d, texCoord1d); + texcolor += textureOffset(tex1d, texCoord1d, 1); + texcolor += textureLod(tex1d, texCoord1d, 2); + texcolor += textureGrad(tex1d, texCoord1d, 1.0, 2.0); + texcolor += textureProj(tex1d, vec2(texCoord1d, 2.0)); + texcolor += texture(tex1d, texCoord1d, 1.0); + + texcolor += texture(tex2d, texCoord2d); + texcolor += textureOffset(tex2d, texCoord2d, ivec2(1, 2)); + texcolor += textureLod(tex2d, texCoord2d, 2); + texcolor += textureGrad(tex2d, texCoord2d, vec2(1.0, 2.0), vec2(3.0, 4.0)); + texcolor += textureProj(tex2d, vec3(texCoord2d, 2.0)); + texcolor += texture(tex2d, texCoord2d, 1.0); + + texcolor += texture(tex3d, texCoord3d); + texcolor += textureOffset(tex3d, texCoord3d, ivec3(1, 2, 3)); + texcolor += textureLod(tex3d, texCoord3d, 2); + texcolor += textureGrad(tex3d, texCoord3d, vec3(1.0, 2.0, 3.0), vec3(4.0, 5.0, 6.0)); + texcolor += textureProj(tex3d, vec4(texCoord3d, 2.0)); + texcolor += texture(tex3d, texCoord3d, 1.0); + + texcolor += texture(texCube, texCoord3d); + texcolor += textureLod(texCube, texCoord3d, 2); + texcolor += texture(texCube, texCoord3d, 1.0); + + texcolor.a += texture(tex1dShadow, vec3(texCoord1d, 0.0, 0.0)); + texcolor.a += texture(tex2dShadow, vec3(texCoord2d, 0.0)); + texcolor.a += texture(texCubeShadow, vec4(texCoord3d, 0.0)); + + texcolor += texture(tex1dArray, texCoord2d); + texcolor += texture(tex2dArray, texCoord3d); + texcolor += texture(texCubeArray, texCoord4d); + + texcolor += textureGather(tex2d, texCoord2d); + texcolor += textureGather(tex2d, texCoord2d, 0); + texcolor += textureGather(tex2d, texCoord2d, 1); + texcolor += textureGather(tex2d, texCoord2d, 2); + texcolor += textureGather(tex2d, texCoord2d, 3); + + texcolor += textureGatherOffset(tex2d, texCoord2d, ivec2(1, 1)); + texcolor += textureGatherOffset(tex2d, texCoord2d, ivec2(1, 1), 0); + texcolor += textureGatherOffset(tex2d, texCoord2d, ivec2(1, 1), 1); + texcolor += textureGatherOffset(tex2d, texCoord2d, ivec2(1, 1), 2); + texcolor += textureGatherOffset(tex2d, texCoord2d, ivec2(1, 1), 3); + + texcolor += texelFetch(tex2d, ivec2(1, 2), 0); + + texcolor += texture(sampler2D(separateTex2d, samplerNonDepth), texCoord2d); + texcolor.a += texture(sampler2DShadow(separateTex2dDepth, samplerDepth), texCoord3d); + + FragColor = texcolor; +} diff --git a/shaders-hlsl/frag/texture-proj-shadow.frag b/shaders-hlsl/frag/texture-proj-shadow.frag new file mode 100644 index 0000000000..0c4cf8f5a8 --- /dev/null +++ b/shaders-hlsl/frag/texture-proj-shadow.frag @@ -0,0 +1,21 @@ +#version 450 + +layout(binding = 0) uniform sampler1DShadow uShadow1D; +layout(binding = 1) uniform sampler2DShadow uShadow2D; +layout(binding = 2) uniform sampler1D uSampler1D; +layout(binding = 3) uniform sampler2D uSampler2D; +layout(binding = 4) uniform sampler3D uSampler3D; + +layout(location = 0) out float FragColor; +layout(location = 0) in vec3 vClip3; +layout(location = 1) in vec4 vClip4; +layout(location = 2) in vec2 vClip2; + +void main() +{ + FragColor = textureProj(uShadow1D, vClip4); + FragColor = textureProj(uShadow2D, vClip4); + FragColor = textureProj(uSampler1D, vClip2).x; + FragColor = textureProj(uSampler2D, vClip3).x; + FragColor = textureProj(uSampler3D, vClip4).x; +} diff --git a/shaders-hlsl/frag/texture-size-combined-image-sampler.frag b/shaders-hlsl/frag/texture-size-combined-image-sampler.frag new file mode 100644 index 0000000000..9488059595 --- /dev/null +++ b/shaders-hlsl/frag/texture-size-combined-image-sampler.frag @@ -0,0 +1,9 @@ +#version 450 +layout(set = 0, binding = 0) uniform texture2D uTex; +layout(set = 0, binding = 1) uniform sampler uSampler; +layout(location = 0) out ivec2 FooOut; + +void main() +{ + FooOut = textureSize(sampler2D(uTex, uSampler), 0); +} diff --git a/shaders-hlsl/frag/unary-enclose.frag b/shaders-hlsl/frag/unary-enclose.frag new file mode 100644 index 0000000000..ea502e1de8 --- /dev/null +++ b/shaders-hlsl/frag/unary-enclose.frag @@ -0,0 +1,15 @@ +#version 310 es +precision mediump float; + +layout(location = 0) out vec4 FragColor; +layout(location = 0) in vec4 vIn; +layout(location = 1) flat in ivec4 vIn1; + +void main() +{ + FragColor = +(-(-vIn)); + ivec4 a = ~(~vIn1); + + bool b = false; + b = !!b; +} diff --git a/shaders-hlsl/frag/unorm-snorm-packing.frag b/shaders-hlsl/frag/unorm-snorm-packing.frag new file mode 100644 index 0000000000..c0a01aaf8b --- /dev/null +++ b/shaders-hlsl/frag/unorm-snorm-packing.frag @@ -0,0 +1,24 @@ +#version 450 + +layout(location = 0) flat in uint SNORM8; +layout(location = 1) flat in uint UNORM8; +layout(location = 2) flat in uint SNORM16; +layout(location = 3) flat in uint UNORM16; +layout(location = 4) flat in vec4 FP32; +layout(location = 0) out vec4 FP32Out; +layout(location = 1) out uint UNORM8Out; +layout(location = 2) out uint SNORM8Out; +layout(location = 3) out uint UNORM16Out; +layout(location = 4) out uint SNORM16Out; + +void main() +{ + FP32Out = unpackUnorm4x8(UNORM8); + FP32Out = unpackSnorm4x8(SNORM8); + FP32Out.xy = unpackUnorm2x16(UNORM16); + FP32Out.xy = unpackSnorm2x16(SNORM16); + UNORM8Out = packUnorm4x8(FP32); + SNORM8Out = packSnorm4x8(FP32); + UNORM16Out = packUnorm2x16(FP32.xy); + SNORM16Out = packSnorm2x16(FP32.zw); +} diff --git a/shaders-hlsl/frag/various-glsl-ops.frag b/shaders-hlsl/frag/various-glsl-ops.frag new file mode 100644 index 0000000000..0d4af80a6e --- /dev/null +++ b/shaders-hlsl/frag/various-glsl-ops.frag @@ -0,0 +1,17 @@ +#version 450 + +layout(location = 0) in vec2 interpolant; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + vec4 color = vec4(0.0, 0.0, 0.0, interpolateAtOffset(interpolant, vec2(0.1, 0.1))); + + // glslang's HLSL parser currently fails here + //color += vec4(0.0, 0.0, 0.0, interpolateAtSample(interpolant, gl_SampleID)); + //color += vec4(0.0, 0.0, 0.0, interpolateAtCentroid(interpolant)); + + color += vec4(0.0, 0.0, 0.0, dFdxCoarse(interpolant.x)); + FragColor = color; +} diff --git a/shaders-hlsl/vert/basic.vert b/shaders-hlsl/vert/basic.vert new file mode 100644 index 0000000000..f03114feef --- /dev/null +++ b/shaders-hlsl/vert/basic.vert @@ -0,0 +1,15 @@ +#version 310 es + +layout(std140) uniform UBO +{ + uniform mat4 uMVP; +}; +layout(location = 0) in vec4 aVertex; +layout(location = 1) in vec3 aNormal; +layout(location = 0) out vec3 vNormal; + +void main() +{ + gl_Position = uMVP * aVertex; + vNormal = aNormal; +} diff --git a/shaders-hlsl/vert/instancing.vert b/shaders-hlsl/vert/instancing.vert new file mode 100644 index 0000000000..0e62ef6b0e --- /dev/null +++ b/shaders-hlsl/vert/instancing.vert @@ -0,0 +1,6 @@ +#version 310 es + +void main() +{ + gl_Position = vec4(float(gl_VertexIndex + gl_InstanceIndex)); +} diff --git a/shaders-hlsl/vert/locations.vert b/shaders-hlsl/vert/locations.vert new file mode 100644 index 0000000000..df1a44e923 --- /dev/null +++ b/shaders-hlsl/vert/locations.vert @@ -0,0 +1,51 @@ +#version 310 es +#extension GL_EXT_shader_io_blocks : require + +struct Foo +{ + vec3 a; + vec3 b; + vec3 c; +}; + +// This will lock to input location 2. +layout(location = 2) in vec4 Input2; +// This will lock to input location 4. +layout(location = 4) in vec4 Input4; +// This will pick first available, which is 0. +layout(location = 0) in vec4 Input0; + +// Locks output 0. +layout(location = 0) out float vLocation0; +// Locks output 1. +layout(location = 1) out float vLocation1; +// Picks first available two locations, so, 2 and 3. +layout(location = 2) out float vLocation2[2]; +// Picks first available location, 4. +layout(location = 4) out Foo vLocation4; +// Picks first available location 9. +layout(location = 9) out float vLocation9; + +// Locks location 7 and 8. +layout(location = 7) out VertexOut +{ + vec3 color; + vec3 foo; +} vout; + +void main() +{ + gl_Position = vec4(1.0) + Input2 + Input4 + Input0; + vLocation0 = 0.0; + vLocation1 = 1.0; + vLocation2[0] = 2.0; + vLocation2[1] = 2.0; + Foo foo; + foo.a = vec3(1.0); + foo.b = vec3(1.0); + foo.c = vec3(1.0); + vLocation4 = foo; + vLocation9 = 9.0; + vout.color = vec3(2.0); + vout.foo = vec3(4.0); +} diff --git a/shaders-hlsl/vert/matrix-attribute.vert b/shaders-hlsl/vert/matrix-attribute.vert new file mode 100644 index 0000000000..8a1393f8d6 --- /dev/null +++ b/shaders-hlsl/vert/matrix-attribute.vert @@ -0,0 +1,9 @@ +#version 310 es + +layout(location = 0) in vec3 pos; +layout(location = 1) in mat4 m; + +void main() +{ + gl_Position = m * vec4(pos, 1.0); +} diff --git a/shaders-hlsl/vert/matrix-output.vert b/shaders-hlsl/vert/matrix-output.vert new file mode 100644 index 0000000000..1151d4bd32 --- /dev/null +++ b/shaders-hlsl/vert/matrix-output.vert @@ -0,0 +1,9 @@ +#version 450 + +layout(location = 0) out mat4 m; + +void main() +{ + gl_Position = vec4(1.0); + m = mat4(1.0); +} diff --git a/shaders-hlsl/vert/no-input.vert b/shaders-hlsl/vert/no-input.vert new file mode 100644 index 0000000000..8de8e816a0 --- /dev/null +++ b/shaders-hlsl/vert/no-input.vert @@ -0,0 +1,6 @@ +#version 310 es + +void main() +{ + gl_Position = vec4(1.0); +} diff --git a/shaders-hlsl/vert/point-size-compat.vert b/shaders-hlsl/vert/point-size-compat.vert new file mode 100644 index 0000000000..64eff36315 --- /dev/null +++ b/shaders-hlsl/vert/point-size-compat.vert @@ -0,0 +1,8 @@ +#version 310 es + +void main() +{ + gl_Position = vec4(1.0); + gl_PointSize = 10.0; +} + diff --git a/shaders-hlsl/vert/qualifiers.vert b/shaders-hlsl/vert/qualifiers.vert new file mode 100644 index 0000000000..080a70915c --- /dev/null +++ b/shaders-hlsl/vert/qualifiers.vert @@ -0,0 +1,27 @@ +#version 450 + +layout(location = 0) flat out float vFlat; +layout(location = 1) centroid out float vCentroid; +layout(location = 2) sample out float vSample; +layout(location = 3) noperspective out float vNoperspective; + +layout(location = 4) out Block +{ + flat float vFlat; + centroid float vCentroid; + sample float vSample; + noperspective float vNoperspective; +} vout; + +void main() +{ + gl_Position = vec4(1.0); + vFlat = 0.0; + vCentroid = 1.0; + vSample = 2.0; + vNoperspective = 3.0; + vout.vFlat = 0.0; + vout.vCentroid = 1.0; + vout.vSample = 2.0; + vout.vNoperspective = 3.0; +} diff --git a/shaders-hlsl/vert/sampler-buffers.vert b/shaders-hlsl/vert/sampler-buffers.vert new file mode 100644 index 0000000000..dccbf77849 --- /dev/null +++ b/shaders-hlsl/vert/sampler-buffers.vert @@ -0,0 +1,17 @@ +#version 450 + +layout(binding = 1) uniform samplerBuffer uFloatSampler; +layout(binding = 2) uniform isamplerBuffer uIntSampler; +layout(binding = 3) uniform usamplerBuffer uUintSampler; + +vec4 sample_from_function(samplerBuffer s0, isamplerBuffer s1, usamplerBuffer s2) +{ + return texelFetch(s0, 20) + + intBitsToFloat(texelFetch(s1, 40)) + + uintBitsToFloat(texelFetch(s2, 60)); +} + +void main() +{ + gl_Position = sample_from_function(uFloatSampler, uIntSampler, uUintSampler); +} diff --git a/shaders-hlsl/vert/struct-composite-decl.vert b/shaders-hlsl/vert/struct-composite-decl.vert new file mode 100644 index 0000000000..c527fdf518 --- /dev/null +++ b/shaders-hlsl/vert/struct-composite-decl.vert @@ -0,0 +1,26 @@ +#version 310 es + +layout(location = 0) in vec4 a; +layout(location = 1) in vec4 b; +layout(location = 2) in vec4 c; +layout(location = 3) in vec4 d; + +struct VOut +{ + vec4 a; + vec4 b; + vec4 c; + vec4 d; +}; + +layout(location = 0) out VOut vout; + +void emit_result(VOut v) +{ + vout = v; +} + +void main() +{ + emit_result(VOut(a, b, c, d)); +} diff --git a/shaders-hlsl/vert/texture_buffer.vert b/shaders-hlsl/vert/texture_buffer.vert new file mode 100644 index 0000000000..b071e0c966 --- /dev/null +++ b/shaders-hlsl/vert/texture_buffer.vert @@ -0,0 +1,9 @@ +#version 450 + +layout(binding = 4) uniform samplerBuffer uSamp; +layout(rgba32f, binding = 5) uniform readonly imageBuffer uSampo; + +void main() +{ + gl_Position = texelFetch(uSamp, 10) + imageLoad(uSampo, 100); +} diff --git a/shaders-msl-no-opt/vert/functions_nested.vert b/shaders-msl-no-opt/vert/functions_nested.vert new file mode 100644 index 0000000000..2eec5ac551 --- /dev/null +++ b/shaders-msl-no-opt/vert/functions_nested.vert @@ -0,0 +1,132 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +layout(std140, set = 0, binding = 0) uniform VertexBuffer +{ + mat4 scale_offset_mat; + uint vertex_base_index; + ivec4 input_attributes[16]; +}; +layout(set=0, binding=3) uniform usamplerBuffer buff_in_1; +layout(set=0, binding=4) uniform usamplerBuffer buff_in_2; + +layout(location=10) out vec4 back_color; +layout(location=0) out vec4 tc0; + +layout(std140, set=0, binding = 1) uniform VertexConstantsBuffer +{ + vec4 vc[16]; +}; + +struct attr_desc +{ + int type; + int attribute_size; + int starting_offset; + int stride; + int swap_bytes; + int is_volatile; +}; + +uint get_bits(uvec4 v, int swap) +{ + if (swap != 0) return (v.w | v.z << 8 | v.y << 16 | v.x << 24); + return (v.x | v.y << 8 | v.z << 16 | v.w << 24); +} + +vec4 fetch_attr(attr_desc desc, int vertex_id, usamplerBuffer input_stream) +{ + vec4 result = vec4(0.0f, 0.0f, 0.0f, 1.0f); + uvec4 tmp; + uint bits; + bool reverse_order = false; + + int first_byte = (vertex_id * desc.stride) + desc.starting_offset; + for (int n = 0; n < 4; n++) + { + if (n == desc.attribute_size) break; + + switch (desc.type) + { + case 0: + //signed normalized 16-bit + tmp.x = texelFetch(input_stream, first_byte++).x; + tmp.y = texelFetch(input_stream, first_byte++).x; + result[n] = get_bits(tmp, desc.swap_bytes); + break; + case 1: + //float + tmp.x = texelFetch(input_stream, first_byte++).x; + tmp.y = texelFetch(input_stream, first_byte++).x; + tmp.z = texelFetch(input_stream, first_byte++).x; + tmp.w = texelFetch(input_stream, first_byte++).x; + result[n] = uintBitsToFloat(get_bits(tmp, desc.swap_bytes)); + break; + case 2: + //unsigned byte + result[n] = texelFetch(input_stream, first_byte++).x; + reverse_order = (desc.swap_bytes != 0); + break; + } + } + + return (reverse_order)? result.wzyx: result; +} + +attr_desc fetch_desc(int location) +{ + attr_desc result; + int attribute_flags = input_attributes[location].w; + result.type = input_attributes[location].x; + result.attribute_size = input_attributes[location].y; + result.starting_offset = input_attributes[location].z; + result.stride = attribute_flags & 0xFF; + result.swap_bytes = (attribute_flags >> 8) & 0x1; + result.is_volatile = (attribute_flags >> 9) & 0x1; + return result; +} + +vec4 read_location(int location) +{ + attr_desc desc = fetch_desc(location); + + int vertex_id = gl_VertexIndex - int(vertex_base_index); + if (desc.is_volatile != 0) + return fetch_attr(desc, vertex_id, buff_in_2); + else + return fetch_attr(desc, vertex_id, buff_in_1); +} + +void vs_adjust(inout vec4 dst_reg0, inout vec4 dst_reg1, inout vec4 dst_reg7) +{ + vec4 tmp0; + vec4 tmp1; + vec4 in_diff_color= read_location(3); + vec4 in_pos= read_location(0); + vec4 in_tc0= read_location(8); + dst_reg1 = (in_diff_color * vc[13]); + tmp0.x = vec4(dot(vec4(in_pos.xyzx.xyz, 1.0), vc[4])).x; + tmp0.y = vec4(dot(vec4(in_pos.xyzx.xyz, 1.0), vc[5])).y; + tmp0.z = vec4(dot(vec4(in_pos.xyzx.xyz, 1.0), vc[6])).z; + tmp1.xy = in_tc0.xyxx.xy; + tmp1.z = vc[15].xxxx.z; + dst_reg7.y = vec4(dot(vec4(tmp1.xyzx.xyz, 1.0), vc[8])).y; + dst_reg7.x = vec4(dot(vec4(tmp1.xyzx.xyz, 1.0), vc[7])).x; + dst_reg0.y = vec4(dot(vec4(tmp0.xyzx.xyz, 1.0), vc[1])).y; + dst_reg0.x = vec4(dot(vec4(tmp0.xyzx.xyz, 1.0), vc[0])).x; +} + +void main () +{ + vec4 dst_reg0= vec4(0.0f, 0.0f, 0.0f, 1.0f); + vec4 dst_reg1= vec4(0.0, 0.0, 0.0, 0.0); + vec4 dst_reg7= vec4(0.0, 0.0, 0.0, 0.0); + + vs_adjust(dst_reg0, dst_reg1, dst_reg7); + + gl_Position = dst_reg0; + back_color = dst_reg1; + tc0 = dst_reg7; + gl_Position = gl_Position * scale_offset_mat; +} + diff --git a/shaders-msl/asm/comp/bitcast_iadd.asm.comp b/shaders-msl/asm/comp/bitcast_iadd.asm.comp new file mode 100644 index 0000000000..3b31ab2851 --- /dev/null +++ b/shaders-msl/asm/comp/bitcast_iadd.asm.comp @@ -0,0 +1,79 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 1 +; Bound: 30 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %func "main" + OpExecutionMode %func LocalSize 1 1 1 + OpSource ESSL 310 + OpSourceExtension "GL_GOOGLE_cpp_style_line_directive" + OpSourceExtension "GL_GOOGLE_include_directive" + OpMemberDecorate %input_struct 0 Offset 0 + OpMemberDecorate %input_struct 1 Offset 16 + OpMemberDecorate %output_struct 0 Offset 0 + OpMemberDecorate %output_struct 1 Offset 16 + OpDecorate %input_struct BufferBlock + OpDecorate %inputs DescriptorSet 0 + OpDecorate %inputs Binding 0 + OpDecorate %inputs Restrict + OpDecorate %output_struct BufferBlock + OpDecorate %outputs DescriptorSet 0 + OpDecorate %outputs Binding 1 + OpDecorate %outputs Restrict + + %void = OpTypeVoid + %main_func = OpTypeFunction %void + + %uint = OpTypeInt 32 0 + %uvec4 = OpTypeVector %uint 4 + + %int = OpTypeInt 32 1 + %ivec4 = OpTypeVector %int 4 + + %ivec4_ptr = OpTypePointer Uniform %ivec4 + %uvec4_ptr = OpTypePointer Uniform %uvec4 + + %zero = OpConstant %int 0 + %one = OpConstant %int 1 + + %input_struct = OpTypeStruct %ivec4 %uvec4 + %input_struct_ptr = OpTypePointer Uniform %input_struct + %inputs = OpVariable %input_struct_ptr Uniform + %output_struct = OpTypeStruct %uvec4 %ivec4 + %output_struct_ptr = OpTypePointer Uniform %output_struct + %outputs = OpVariable %output_struct_ptr Uniform + + %func = OpFunction %void None %main_func + %block = OpLabel + + %input1_ptr = OpAccessChain %ivec4_ptr %inputs %zero + %input0_ptr = OpAccessChain %uvec4_ptr %inputs %one + %input1 = OpLoad %ivec4 %input1_ptr + %input0 = OpLoad %uvec4 %input0_ptr + + %output_ptr_uvec4 = OpAccessChain %uvec4_ptr %outputs %zero + %output_ptr_ivec4 = OpAccessChain %ivec4_ptr %outputs %one + +; Test all variants of IAdd + %result_iadd_0 = OpIAdd %uvec4 %input0 %input1 + %result_iadd_1 = OpIAdd %uvec4 %input1 %input0 + %result_iadd_2 = OpIAdd %uvec4 %input0 %input0 + %result_iadd_3 = OpIAdd %uvec4 %input1 %input1 + %result_iadd_4 = OpIAdd %ivec4 %input0 %input0 + %result_iadd_5 = OpIAdd %ivec4 %input1 %input1 + %result_iadd_6 = OpIAdd %ivec4 %input0 %input1 + %result_iadd_7 = OpIAdd %ivec4 %input1 %input0 + OpStore %output_ptr_uvec4 %result_iadd_0 + OpStore %output_ptr_uvec4 %result_iadd_1 + OpStore %output_ptr_uvec4 %result_iadd_2 + OpStore %output_ptr_uvec4 %result_iadd_3 + OpStore %output_ptr_ivec4 %result_iadd_4 + OpStore %output_ptr_ivec4 %result_iadd_5 + OpStore %output_ptr_ivec4 %result_iadd_6 + OpStore %output_ptr_ivec4 %result_iadd_7 + + OpReturn + OpFunctionEnd diff --git a/shaders-msl/asm/comp/bitcast_sar.asm.comp b/shaders-msl/asm/comp/bitcast_sar.asm.comp new file mode 100644 index 0000000000..64f19fc349 --- /dev/null +++ b/shaders-msl/asm/comp/bitcast_sar.asm.comp @@ -0,0 +1,77 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 1 +; Bound: 30 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %func "main" + OpExecutionMode %func LocalSize 1 1 1 + OpSource ESSL 310 + OpSourceExtension "GL_GOOGLE_cpp_style_line_directive" + OpSourceExtension "GL_GOOGLE_include_directive" + OpMemberDecorate %input_struct 0 Offset 0 + OpMemberDecorate %input_struct 1 Offset 16 + OpMemberDecorate %output_struct 0 Offset 0 + OpMemberDecorate %output_struct 1 Offset 16 + OpDecorate %input_struct BufferBlock + OpDecorate %inputs DescriptorSet 0 + OpDecorate %inputs Binding 0 + OpDecorate %output_struct BufferBlock + OpDecorate %outputs DescriptorSet 0 + OpDecorate %outputs Binding 1 + + %void = OpTypeVoid + %main_func = OpTypeFunction %void + + %uint = OpTypeInt 32 0 + %uvec4 = OpTypeVector %uint 4 + + %int = OpTypeInt 32 1 + %ivec4 = OpTypeVector %int 4 + + %ivec4_ptr = OpTypePointer Uniform %ivec4 + %uvec4_ptr = OpTypePointer Uniform %uvec4 + + %zero = OpConstant %int 0 + %one = OpConstant %int 1 + + %input_struct = OpTypeStruct %ivec4 %uvec4 + %input_struct_ptr = OpTypePointer Uniform %input_struct + %inputs = OpVariable %input_struct_ptr Uniform + %output_struct = OpTypeStruct %uvec4 %ivec4 + %output_struct_ptr = OpTypePointer Uniform %output_struct + %outputs = OpVariable %output_struct_ptr Uniform + + %func = OpFunction %void None %main_func + %block = OpLabel + + %input1_ptr = OpAccessChain %ivec4_ptr %inputs %zero + %input0_ptr = OpAccessChain %uvec4_ptr %inputs %one + %input1 = OpLoad %ivec4 %input1_ptr + %input0 = OpLoad %uvec4 %input0_ptr + + %output_ptr_uvec4 = OpAccessChain %uvec4_ptr %outputs %zero + %output_ptr_ivec4 = OpAccessChain %ivec4_ptr %outputs %one + +; Test all variants of ShiftRightArithmetic + %result_iadd_0 = OpShiftRightArithmetic %uvec4 %input0 %input1 + %result_iadd_1 = OpShiftRightArithmetic %uvec4 %input1 %input0 + %result_iadd_2 = OpShiftRightArithmetic %uvec4 %input0 %input0 + %result_iadd_3 = OpShiftRightArithmetic %uvec4 %input1 %input1 + %result_iadd_4 = OpShiftRightArithmetic %ivec4 %input0 %input0 + %result_iadd_5 = OpShiftRightArithmetic %ivec4 %input1 %input1 + %result_iadd_6 = OpShiftRightArithmetic %ivec4 %input0 %input1 + %result_iadd_7 = OpShiftRightArithmetic %ivec4 %input1 %input0 + OpStore %output_ptr_uvec4 %result_iadd_0 + OpStore %output_ptr_uvec4 %result_iadd_1 + OpStore %output_ptr_uvec4 %result_iadd_2 + OpStore %output_ptr_uvec4 %result_iadd_3 + OpStore %output_ptr_ivec4 %result_iadd_4 + OpStore %output_ptr_ivec4 %result_iadd_5 + OpStore %output_ptr_ivec4 %result_iadd_6 + OpStore %output_ptr_ivec4 %result_iadd_7 + + OpReturn + OpFunctionEnd diff --git a/shaders-msl/asm/comp/bitcast_sdiv.asm.comp b/shaders-msl/asm/comp/bitcast_sdiv.asm.comp new file mode 100644 index 0000000000..ab73ec83df --- /dev/null +++ b/shaders-msl/asm/comp/bitcast_sdiv.asm.comp @@ -0,0 +1,77 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 1 +; Bound: 30 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %func "main" + OpExecutionMode %func LocalSize 1 1 1 + OpSource ESSL 310 + OpSourceExtension "GL_GOOGLE_cpp_style_line_directive" + OpSourceExtension "GL_GOOGLE_include_directive" + OpMemberDecorate %input_struct 0 Offset 0 + OpMemberDecorate %input_struct 1 Offset 16 + OpMemberDecorate %output_struct 0 Offset 0 + OpMemberDecorate %output_struct 1 Offset 16 + OpDecorate %input_struct BufferBlock + OpDecorate %inputs DescriptorSet 0 + OpDecorate %inputs Binding 0 + OpDecorate %output_struct BufferBlock + OpDecorate %outputs DescriptorSet 0 + OpDecorate %outputs Binding 1 + + %void = OpTypeVoid + %main_func = OpTypeFunction %void + + %uint = OpTypeInt 32 0 + %uvec4 = OpTypeVector %uint 4 + + %int = OpTypeInt 32 1 + %ivec4 = OpTypeVector %int 4 + + %ivec4_ptr = OpTypePointer Uniform %ivec4 + %uvec4_ptr = OpTypePointer Uniform %uvec4 + + %zero = OpConstant %int 0 + %one = OpConstant %int 1 + + %input_struct = OpTypeStruct %ivec4 %uvec4 + %input_struct_ptr = OpTypePointer Uniform %input_struct + %inputs = OpVariable %input_struct_ptr Uniform + %output_struct = OpTypeStruct %uvec4 %ivec4 + %output_struct_ptr = OpTypePointer Uniform %output_struct + %outputs = OpVariable %output_struct_ptr Uniform + + %func = OpFunction %void None %main_func + %block = OpLabel + + %input1_ptr = OpAccessChain %ivec4_ptr %inputs %zero + %input0_ptr = OpAccessChain %uvec4_ptr %inputs %one + %input1 = OpLoad %ivec4 %input1_ptr + %input0 = OpLoad %uvec4 %input0_ptr + + %output_ptr_uvec4 = OpAccessChain %uvec4_ptr %outputs %zero + %output_ptr_ivec4 = OpAccessChain %ivec4_ptr %outputs %one + +; Test all variants of SDiv + %result_iadd_0 = OpSDiv %uvec4 %input0 %input1 + %result_iadd_1 = OpSDiv %uvec4 %input1 %input0 + %result_iadd_2 = OpSDiv %uvec4 %input0 %input0 + %result_iadd_3 = OpSDiv %uvec4 %input1 %input1 + %result_iadd_4 = OpSDiv %ivec4 %input0 %input0 + %result_iadd_5 = OpSDiv %ivec4 %input1 %input1 + %result_iadd_6 = OpSDiv %ivec4 %input0 %input1 + %result_iadd_7 = OpSDiv %ivec4 %input1 %input0 + OpStore %output_ptr_uvec4 %result_iadd_0 + OpStore %output_ptr_uvec4 %result_iadd_1 + OpStore %output_ptr_uvec4 %result_iadd_2 + OpStore %output_ptr_uvec4 %result_iadd_3 + OpStore %output_ptr_ivec4 %result_iadd_4 + OpStore %output_ptr_ivec4 %result_iadd_5 + OpStore %output_ptr_ivec4 %result_iadd_6 + OpStore %output_ptr_ivec4 %result_iadd_7 + + OpReturn + OpFunctionEnd diff --git a/shaders-msl/asm/comp/bitcast_slr.asm.comp b/shaders-msl/asm/comp/bitcast_slr.asm.comp new file mode 100644 index 0000000000..6741f5cb58 --- /dev/null +++ b/shaders-msl/asm/comp/bitcast_slr.asm.comp @@ -0,0 +1,77 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 1 +; Bound: 30 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %func "main" + OpExecutionMode %func LocalSize 1 1 1 + OpSource ESSL 310 + OpSourceExtension "GL_GOOGLE_cpp_style_line_directive" + OpSourceExtension "GL_GOOGLE_include_directive" + OpMemberDecorate %input_struct 0 Offset 0 + OpMemberDecorate %input_struct 1 Offset 16 + OpMemberDecorate %output_struct 0 Offset 0 + OpMemberDecorate %output_struct 1 Offset 16 + OpDecorate %input_struct BufferBlock + OpDecorate %inputs DescriptorSet 0 + OpDecorate %inputs Binding 0 + OpDecorate %output_struct BufferBlock + OpDecorate %outputs DescriptorSet 0 + OpDecorate %outputs Binding 1 + + %void = OpTypeVoid + %main_func = OpTypeFunction %void + + %uint = OpTypeInt 32 0 + %uvec4 = OpTypeVector %uint 4 + + %int = OpTypeInt 32 1 + %ivec4 = OpTypeVector %int 4 + + %ivec4_ptr = OpTypePointer Uniform %ivec4 + %uvec4_ptr = OpTypePointer Uniform %uvec4 + + %zero = OpConstant %int 0 + %one = OpConstant %int 1 + + %input_struct = OpTypeStruct %ivec4 %uvec4 + %input_struct_ptr = OpTypePointer Uniform %input_struct + %inputs = OpVariable %input_struct_ptr Uniform + %output_struct = OpTypeStruct %uvec4 %ivec4 + %output_struct_ptr = OpTypePointer Uniform %output_struct + %outputs = OpVariable %output_struct_ptr Uniform + + %func = OpFunction %void None %main_func + %block = OpLabel + + %input1_ptr = OpAccessChain %ivec4_ptr %inputs %zero + %input0_ptr = OpAccessChain %uvec4_ptr %inputs %one + %input1 = OpLoad %ivec4 %input1_ptr + %input0 = OpLoad %uvec4 %input0_ptr + + %output_ptr_uvec4 = OpAccessChain %uvec4_ptr %outputs %zero + %output_ptr_ivec4 = OpAccessChain %ivec4_ptr %outputs %one + +; Test all variants of ShiftRightLogical + %result_iadd_0 = OpShiftRightLogical %uvec4 %input0 %input1 + %result_iadd_1 = OpShiftRightLogical %uvec4 %input1 %input0 + %result_iadd_2 = OpShiftRightLogical %uvec4 %input0 %input0 + %result_iadd_3 = OpShiftRightLogical %uvec4 %input1 %input1 + %result_iadd_4 = OpShiftRightLogical %ivec4 %input0 %input0 + %result_iadd_5 = OpShiftRightLogical %ivec4 %input1 %input1 + %result_iadd_6 = OpShiftRightLogical %ivec4 %input0 %input1 + %result_iadd_7 = OpShiftRightLogical %ivec4 %input1 %input0 + OpStore %output_ptr_uvec4 %result_iadd_0 + OpStore %output_ptr_uvec4 %result_iadd_1 + OpStore %output_ptr_uvec4 %result_iadd_2 + OpStore %output_ptr_uvec4 %result_iadd_3 + OpStore %output_ptr_ivec4 %result_iadd_4 + OpStore %output_ptr_ivec4 %result_iadd_5 + OpStore %output_ptr_ivec4 %result_iadd_6 + OpStore %output_ptr_ivec4 %result_iadd_7 + + OpReturn + OpFunctionEnd diff --git a/shaders-msl/asm/comp/multiple-entry.asm.comp b/shaders-msl/asm/comp/multiple-entry.asm.comp new file mode 100644 index 0000000000..0cfb5543d1 --- /dev/null +++ b/shaders-msl/asm/comp/multiple-entry.asm.comp @@ -0,0 +1,97 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 1 +; Bound: 30 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %func_alt "main2" %frag_in %frag_out + OpEntryPoint GLCompute %func "main" + OpExecutionMode %func LocalSize 1 1 1 + OpSource ESSL 310 + OpSourceExtension "GL_GOOGLE_cpp_style_line_directive" + OpSourceExtension "GL_GOOGLE_include_directive" + OpMemberDecorate %input_struct 0 Offset 0 + OpMemberDecorate %input_struct 1 Offset 16 + OpMemberDecorate %output_struct 0 Offset 0 + OpMemberDecorate %output_struct 1 Offset 16 + OpDecorate %input_struct BufferBlock + OpDecorate %inputs DescriptorSet 0 + OpDecorate %inputs Binding 0 + OpDecorate %inputs Restrict + OpDecorate %output_struct BufferBlock + OpDecorate %outputs DescriptorSet 0 + OpDecorate %outputs Binding 1 + OpDecorate %outputs Restrict + OpDecorate %frag_in Location 0 + OpDecorate %frag_out Location 0 + + %void = OpTypeVoid + %main_func = OpTypeFunction %void + + %uint = OpTypeInt 32 0 + %uvec4 = OpTypeVector %uint 4 + + %int = OpTypeInt 32 1 + %ivec4 = OpTypeVector %int 4 + + %ivec4_ptr = OpTypePointer Uniform %ivec4 + %uvec4_ptr = OpTypePointer Uniform %uvec4 + + %float = OpTypeFloat 32 + %vec4 = OpTypeVector %float 4 + %vec4_input_ptr = OpTypePointer Input %vec4 + %vec4_output_ptr = OpTypePointer Output %vec4 + + %zero = OpConstant %int 0 + %one = OpConstant %int 1 + + %input_struct = OpTypeStruct %ivec4 %uvec4 + %input_struct_ptr = OpTypePointer Uniform %input_struct + %inputs = OpVariable %input_struct_ptr Uniform + %output_struct = OpTypeStruct %uvec4 %ivec4 + %output_struct_ptr = OpTypePointer Uniform %output_struct + %outputs = OpVariable %output_struct_ptr Uniform + + %frag_in = OpVariable %vec4_input_ptr Input + %frag_out = OpVariable %vec4_output_ptr Output + + %func = OpFunction %void None %main_func + %block = OpLabel + + %input1_ptr = OpAccessChain %ivec4_ptr %inputs %zero + %input0_ptr = OpAccessChain %uvec4_ptr %inputs %one + %input1 = OpLoad %ivec4 %input1_ptr + %input0 = OpLoad %uvec4 %input0_ptr + + %output_ptr_uvec4 = OpAccessChain %uvec4_ptr %outputs %zero + %output_ptr_ivec4 = OpAccessChain %ivec4_ptr %outputs %one + +; Test all variants of IAdd + %result_iadd_0 = OpIAdd %uvec4 %input0 %input1 + %result_iadd_1 = OpIAdd %uvec4 %input1 %input0 + %result_iadd_2 = OpIAdd %uvec4 %input0 %input0 + %result_iadd_3 = OpIAdd %uvec4 %input1 %input1 + %result_iadd_4 = OpIAdd %ivec4 %input0 %input0 + %result_iadd_5 = OpIAdd %ivec4 %input1 %input1 + %result_iadd_6 = OpIAdd %ivec4 %input0 %input1 + %result_iadd_7 = OpIAdd %ivec4 %input1 %input0 + OpStore %output_ptr_uvec4 %result_iadd_0 + OpStore %output_ptr_uvec4 %result_iadd_1 + OpStore %output_ptr_uvec4 %result_iadd_2 + OpStore %output_ptr_uvec4 %result_iadd_3 + OpStore %output_ptr_ivec4 %result_iadd_4 + OpStore %output_ptr_ivec4 %result_iadd_5 + OpStore %output_ptr_ivec4 %result_iadd_6 + OpStore %output_ptr_ivec4 %result_iadd_7 + + OpReturn + OpFunctionEnd + + %func_alt = OpFunction %void None %main_func + %block_alt = OpLabel + %frag_input_value = OpLoad %vec4 %frag_in + OpStore %frag_out %frag_input_value + OpReturn + OpFunctionEnd diff --git a/shaders-msl/asm/comp/quantize.asm.comp b/shaders-msl/asm/comp/quantize.asm.comp new file mode 100644 index 0000000000..f5afc6570c --- /dev/null +++ b/shaders-msl/asm/comp/quantize.asm.comp @@ -0,0 +1,67 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 1 +; Bound: 38 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpName %4 "main" + OpName %10 "SSBO0" + OpMemberName %10 0 "scalar" + OpMemberName %10 1 "vec2_val" + OpMemberName %10 2 "vec3_val" + OpMemberName %10 3 "vec4_val" + OpName %12 "" + OpMemberDecorate %10 0 Offset 0 + OpMemberDecorate %10 1 Offset 8 + OpMemberDecorate %10 2 Offset 16 + OpMemberDecorate %10 3 Offset 32 + OpDecorate %10 BufferBlock + OpDecorate %12 DescriptorSet 0 + OpDecorate %12 Binding 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeVector %6 2 + %8 = OpTypeVector %6 3 + %9 = OpTypeVector %6 4 + %10 = OpTypeStruct %6 %7 %8 %9 + %11 = OpTypePointer Uniform %10 + %12 = OpVariable %11 Uniform + %13 = OpTypeInt 32 1 + %14 = OpConstant %13 0 + %15 = OpTypePointer Uniform %6 + %20 = OpConstant %13 1 + %21 = OpTypePointer Uniform %7 + %26 = OpConstant %13 2 + %27 = OpTypePointer Uniform %8 + %32 = OpConstant %13 3 + %33 = OpTypePointer Uniform %9 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %16 = OpAccessChain %15 %12 %14 + %17 = OpLoad %6 %16 + %18 = OpQuantizeToF16 %6 %17 + %19 = OpAccessChain %15 %12 %14 + OpStore %19 %18 + %22 = OpAccessChain %21 %12 %20 + %23 = OpLoad %7 %22 + %24 = OpQuantizeToF16 %7 %23 + %25 = OpAccessChain %21 %12 %20 + OpStore %25 %24 + %28 = OpAccessChain %27 %12 %26 + %29 = OpLoad %8 %28 + %30 = OpQuantizeToF16 %8 %29 + %31 = OpAccessChain %27 %12 %26 + OpStore %31 %30 + %34 = OpAccessChain %33 %12 %32 + %35 = OpLoad %9 %34 + %36 = OpQuantizeToF16 %9 %35 + %37 = OpAccessChain %33 %12 %32 + OpStore %37 %36 + OpReturn + OpFunctionEnd diff --git a/shaders-msl/asm/comp/specialization-constant-workgroup.asm.comp b/shaders-msl/asm/comp/specialization-constant-workgroup.asm.comp new file mode 100644 index 0000000000..188e3fec36 --- /dev/null +++ b/shaders-msl/asm/comp/specialization-constant-workgroup.asm.comp @@ -0,0 +1,47 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 1 +; Bound: 24 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 20 1 + OpSource ESSL 310 + OpName %main "main" + OpName %SSBO "SSBO" + OpMemberName %SSBO 0 "a" + OpName %_ "" + OpMemberDecorate %SSBO 0 Offset 0 + OpDecorate %SSBO BufferBlock + OpDecorate %_ DescriptorSet 0 + OpDecorate %_ Binding 0 + OpDecorate %19 SpecId 10 + OpDecorate %21 SpecId 12 + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %SSBO = OpTypeStruct %float +%_ptr_Uniform_SSBO = OpTypePointer Uniform %SSBO + %_ = OpVariable %_ptr_Uniform_SSBO Uniform + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %float_1 = OpConstant %float 1 +%_ptr_Uniform_float = OpTypePointer Uniform %float + %uint = OpTypeInt 32 0 + %19 = OpSpecConstant %uint 9 + %uint_20 = OpConstant %uint 20 + %21 = OpSpecConstant %uint 4 + %v3uint = OpTypeVector %uint 3 +%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %19 %uint_20 %21 + %main = OpFunction %void None %3 + %5 = OpLabel + %14 = OpAccessChain %_ptr_Uniform_float %_ %int_0 + %15 = OpLoad %float %14 + %16 = OpFAdd %float %15 %float_1 + %17 = OpAccessChain %_ptr_Uniform_float %_ %int_0 + OpStore %17 %16 + OpReturn + OpFunctionEnd diff --git a/shaders-msl/asm/comp/storage-buffer-basic.asm.comp b/shaders-msl/asm/comp/storage-buffer-basic.asm.comp new file mode 100644 index 0000000000..bdf2027a80 --- /dev/null +++ b/shaders-msl/asm/comp/storage-buffer-basic.asm.comp @@ -0,0 +1,58 @@ +; SPIR-V +; Version: 1.0 +; Generator: Codeplay; 0 +; Bound: 31 +; Schema: 0 + OpCapability Shader + OpCapability VariablePointers + OpExtension "SPV_KHR_storage_buffer_storage_class" + OpExtension "SPV_KHR_variable_pointers" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %22 "main" %gl_WorkGroupID + OpSource OpenCL_C 120 + OpDecorate %15 SpecId 0 + ;OpDecorate %16 SpecId 1 + OpDecorate %17 SpecId 2 + OpDecorate %_runtimearr_float ArrayStride 4 + OpMemberDecorate %_struct_4 0 Offset 0 + OpDecorate %_struct_4 Block + OpDecorate %gl_WorkGroupID BuiltIn WorkgroupId + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + OpDecorate %20 DescriptorSet 0 + OpDecorate %20 Binding 0 + OpDecorate %21 DescriptorSet 0 + OpDecorate %21 Binding 1 + %float = OpTypeFloat 32 + %uint = OpTypeInt 32 0 + %size1 = OpConstant %uint 1 +%_ptr_StorageBuffer_float = OpTypePointer StorageBuffer %float +%_runtimearr_float = OpTypeArray %float %size1 ; Runtime arrays do not work yet in MSL. + %_struct_4 = OpTypeStruct %_runtimearr_float +%_ptr_StorageBuffer__struct_4 = OpTypePointer StorageBuffer %_struct_4 + %void = OpTypeVoid + %8 = OpTypeFunction %void + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint +%_ptr_Input_uint = OpTypePointer Input %uint +%_ptr_Private_v3uint = OpTypePointer Private %v3uint + %uint_0 = OpConstant %uint 0 +%gl_WorkGroupID = OpVariable %_ptr_Input_v3uint Input + %15 = OpSpecConstant %uint 1 + %16 = OpConstant %uint 2 + %17 = OpSpecConstant %uint 3 +%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %15 %16 %17 + %19 = OpVariable %_ptr_Private_v3uint Private %gl_WorkGroupSize + %20 = OpVariable %_ptr_StorageBuffer__struct_4 StorageBuffer + %21 = OpVariable %_ptr_StorageBuffer__struct_4 StorageBuffer + %22 = OpFunction %void None %8 + %23 = OpLabel + %24 = OpAccessChain %_ptr_Input_uint %gl_WorkGroupID %uint_0 + %25 = OpLoad %uint %24 + %26 = OpAccessChain %_ptr_StorageBuffer_float %21 %uint_0 %25 + %27 = OpLoad %float %26 + %28 = OpAccessChain %_ptr_StorageBuffer_float %20 %uint_0 %25 + %29 = OpLoad %float %28 + %30 = OpFAdd %float %27 %29 + OpStore %28 %30 + OpReturn + OpFunctionEnd diff --git a/shaders-msl/asm/frag/default-member-names.asm.frag b/shaders-msl/asm/frag/default-member-names.asm.frag new file mode 100644 index 0000000000..4d616fe493 --- /dev/null +++ b/shaders-msl/asm/frag/default-member-names.asm.frag @@ -0,0 +1,57 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 1 +; Bound: 43 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 + OpExecutionMode %2 OriginLowerLeft + OpDecorate %3 Location 0 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %12 = OpTypeFunction %v4float + %_struct_5 = OpTypeStruct %float + %_struct_6 = OpTypeStruct %float %float %float %float %float %float %float %float %float %float %float %float %_struct_5 +%_ptr_Function__struct_6 = OpTypePointer Function %_struct_6 + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 +%_ptr_Function_float = OpTypePointer Function %float + %int_1 = OpConstant %int 1 + %int_2 = OpConstant %int 2 + %int_3 = OpConstant %int 3 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %3 = OpVariable %_ptr_Output_v4float Output +%_ptr_Function_v4float = OpTypePointer Function %v4float + %2 = OpFunction %void None %9 + %22 = OpLabel + %23 = OpVariable %_ptr_Function__struct_6 Function + %24 = OpAccessChain %_ptr_Function_float %23 %int_0 + %25 = OpLoad %float %24 + %26 = OpAccessChain %_ptr_Function_float %23 %int_1 + %27 = OpLoad %float %26 + %28 = OpAccessChain %_ptr_Function_float %23 %int_2 + %29 = OpLoad %float %28 + %30 = OpAccessChain %_ptr_Function_float %23 %int_3 + %31 = OpLoad %float %30 + %32 = OpCompositeConstruct %v4float %25 %27 %29 %31 + OpStore %3 %32 + OpReturn + OpFunctionEnd + %4 = OpFunction %v4float None %12 + %33 = OpLabel + %7 = OpVariable %_ptr_Function__struct_6 Function + %34 = OpAccessChain %_ptr_Function_float %7 %int_0 + %35 = OpLoad %float %34 + %36 = OpAccessChain %_ptr_Function_float %7 %int_1 + %37 = OpLoad %float %36 + %38 = OpAccessChain %_ptr_Function_float %7 %int_2 + %39 = OpLoad %float %38 + %40 = OpAccessChain %_ptr_Function_float %7 %int_3 + %41 = OpLoad %float %40 + %42 = OpCompositeConstruct %v4float %35 %37 %39 %41 + OpReturnValue %42 + OpFunctionEnd diff --git a/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag b/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag new file mode 100644 index 0000000000..8b09e5b68f --- /dev/null +++ b/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag @@ -0,0 +1,646 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 3 +; Bound: 1532 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %IN_HPosition %IN_Uv_EdgeDistance1 %IN_UvStuds_EdgeDistance2 %IN_Color %IN_LightPosition_Fog %IN_View_Depth %IN_Normal_SpecPower %IN_Tangent %IN_PosLightSpace_Reflectance %IN_studIndex %_entryPointOutput + OpExecutionMode %main OriginUpperLeft + OpSource HLSL 500 + OpName %main "main" + OpName %VertexOutput "VertexOutput" + OpMemberName %VertexOutput 0 "HPosition" + OpMemberName %VertexOutput 1 "Uv_EdgeDistance1" + OpMemberName %VertexOutput 2 "UvStuds_EdgeDistance2" + OpMemberName %VertexOutput 3 "Color" + OpMemberName %VertexOutput 4 "LightPosition_Fog" + OpMemberName %VertexOutput 5 "View_Depth" + OpMemberName %VertexOutput 6 "Normal_SpecPower" + OpMemberName %VertexOutput 7 "Tangent" + OpMemberName %VertexOutput 8 "PosLightSpace_Reflectance" + OpMemberName %VertexOutput 9 "studIndex" + OpName %Surface "Surface" + OpMemberName %Surface 0 "albedo" + OpMemberName %Surface 1 "normal" + OpMemberName %Surface 2 "specular" + OpMemberName %Surface 3 "gloss" + OpMemberName %Surface 4 "reflectance" + OpMemberName %Surface 5 "opacity" + OpName %SurfaceInput "SurfaceInput" + OpMemberName %SurfaceInput 0 "Color" + OpMemberName %SurfaceInput 1 "Uv" + OpMemberName %SurfaceInput 2 "UvStuds" + OpName %Globals "Globals" + OpMemberName %Globals 0 "ViewProjection" + OpMemberName %Globals 1 "ViewRight" + OpMemberName %Globals 2 "ViewUp" + OpMemberName %Globals 3 "ViewDir" + OpMemberName %Globals 4 "CameraPosition" + OpMemberName %Globals 5 "AmbientColor" + OpMemberName %Globals 6 "Lamp0Color" + OpMemberName %Globals 7 "Lamp0Dir" + OpMemberName %Globals 8 "Lamp1Color" + OpMemberName %Globals 9 "FogParams" + OpMemberName %Globals 10 "FogColor" + OpMemberName %Globals 11 "LightBorder" + OpMemberName %Globals 12 "LightConfig0" + OpMemberName %Globals 13 "LightConfig1" + OpMemberName %Globals 14 "LightConfig2" + OpMemberName %Globals 15 "LightConfig3" + OpMemberName %Globals 16 "RefractionBias_FadeDistance_GlowFactor" + OpMemberName %Globals 17 "OutlineBrightness_ShadowInfo" + OpMemberName %Globals 18 "ShadowMatrix0" + OpMemberName %Globals 19 "ShadowMatrix1" + OpMemberName %Globals 20 "ShadowMatrix2" + OpName %CB0 "CB0" + OpMemberName %CB0 0 "CB0" + OpName %_ "" + OpName %LightMapTexture "LightMapTexture" + OpName %LightMapSampler "LightMapSampler" + OpName %ShadowMapSampler "ShadowMapSampler" + OpName %ShadowMapTexture "ShadowMapTexture" + OpName %EnvironmentMapTexture "EnvironmentMapTexture" + OpName %EnvironmentMapSampler "EnvironmentMapSampler" + OpName %IN_HPosition "IN.HPosition" + OpName %IN_Uv_EdgeDistance1 "IN.Uv_EdgeDistance1" + OpName %IN_UvStuds_EdgeDistance2 "IN.UvStuds_EdgeDistance2" + OpName %IN_Color "IN.Color" + OpName %IN_LightPosition_Fog "IN.LightPosition_Fog" + OpName %IN_View_Depth "IN.View_Depth" + OpName %IN_Normal_SpecPower "IN.Normal_SpecPower" + OpName %IN_Tangent "IN.Tangent" + OpName %IN_PosLightSpace_Reflectance "IN.PosLightSpace_Reflectance" + OpName %IN_studIndex "IN.studIndex" + OpName %_entryPointOutput "@entryPointOutput" + OpName %DiffuseMapSampler "DiffuseMapSampler" + OpName %DiffuseMapTexture "DiffuseMapTexture" + OpName %NormalMapSampler "NormalMapSampler" + OpName %NormalMapTexture "NormalMapTexture" + OpName %NormalDetailMapTexture "NormalDetailMapTexture" + OpName %NormalDetailMapSampler "NormalDetailMapSampler" + OpName %StudsMapTexture "StudsMapTexture" + OpName %StudsMapSampler "StudsMapSampler" + OpName %SpecularMapSampler "SpecularMapSampler" + OpName %SpecularMapTexture "SpecularMapTexture" + OpName %Params "Params" + OpMemberName %Params 0 "LqmatFarTilingFactor" + OpName %CB2 "CB2" + OpMemberName %CB2 0 "CB2" + OpMemberDecorate %Globals 0 ColMajor + OpMemberDecorate %Globals 0 Offset 0 + OpMemberDecorate %Globals 0 MatrixStride 16 + OpMemberDecorate %Globals 1 Offset 64 + OpMemberDecorate %Globals 2 Offset 80 + OpMemberDecorate %Globals 3 Offset 96 + OpMemberDecorate %Globals 4 Offset 112 + OpMemberDecorate %Globals 5 Offset 128 + OpMemberDecorate %Globals 6 Offset 144 + OpMemberDecorate %Globals 7 Offset 160 + OpMemberDecorate %Globals 8 Offset 176 + OpMemberDecorate %Globals 9 Offset 192 + OpMemberDecorate %Globals 10 Offset 208 + OpMemberDecorate %Globals 11 Offset 224 + OpMemberDecorate %Globals 12 Offset 240 + OpMemberDecorate %Globals 13 Offset 256 + OpMemberDecorate %Globals 14 Offset 272 + OpMemberDecorate %Globals 15 Offset 288 + OpMemberDecorate %Globals 16 Offset 304 + OpMemberDecorate %Globals 17 Offset 320 + OpMemberDecorate %Globals 18 Offset 336 + OpMemberDecorate %Globals 19 Offset 352 + OpMemberDecorate %Globals 20 Offset 368 + OpMemberDecorate %CB0 0 Offset 0 + OpDecorate %CB0 Block + OpDecorate %_ DescriptorSet 0 + OpDecorate %_ Binding 0 + OpDecorate %LightMapTexture DescriptorSet 1 + OpDecorate %LightMapTexture Binding 6 + OpDecorate %LightMapSampler DescriptorSet 1 + OpDecorate %LightMapSampler Binding 6 + OpDecorate %ShadowMapSampler DescriptorSet 1 + OpDecorate %ShadowMapSampler Binding 1 + OpDecorate %ShadowMapTexture DescriptorSet 1 + OpDecorate %ShadowMapTexture Binding 1 + OpDecorate %EnvironmentMapTexture DescriptorSet 1 + OpDecorate %EnvironmentMapTexture Binding 2 + OpDecorate %EnvironmentMapSampler DescriptorSet 1 + OpDecorate %EnvironmentMapSampler Binding 2 + OpDecorate %IN_HPosition BuiltIn FragCoord + OpDecorate %IN_Uv_EdgeDistance1 Location 0 + OpDecorate %IN_UvStuds_EdgeDistance2 Location 1 + OpDecorate %IN_Color Location 2 + OpDecorate %IN_LightPosition_Fog Location 3 + OpDecorate %IN_View_Depth Location 4 + OpDecorate %IN_Normal_SpecPower Location 5 + OpDecorate %IN_Tangent Location 6 + OpDecorate %IN_PosLightSpace_Reflectance Location 7 + OpDecorate %IN_studIndex Location 8 + OpDecorate %_entryPointOutput Location 0 + OpDecorate %DiffuseMapSampler DescriptorSet 1 + OpDecorate %DiffuseMapSampler Binding 3 + OpDecorate %DiffuseMapTexture DescriptorSet 1 + OpDecorate %DiffuseMapTexture Binding 3 + OpDecorate %NormalMapSampler DescriptorSet 1 + OpDecorate %NormalMapSampler Binding 4 + OpDecorate %NormalMapTexture DescriptorSet 1 + OpDecorate %NormalMapTexture Binding 4 + OpDecorate %NormalDetailMapTexture DescriptorSet 1 + OpDecorate %NormalDetailMapTexture Binding 8 + OpDecorate %NormalDetailMapSampler DescriptorSet 1 + OpDecorate %NormalDetailMapSampler Binding 8 + OpDecorate %StudsMapTexture DescriptorSet 1 + OpDecorate %StudsMapTexture Binding 0 + OpDecorate %StudsMapSampler DescriptorSet 1 + OpDecorate %StudsMapSampler Binding 0 + OpDecorate %SpecularMapSampler DescriptorSet 1 + OpDecorate %SpecularMapSampler Binding 5 + OpDecorate %SpecularMapTexture DescriptorSet 1 + OpDecorate %SpecularMapTexture Binding 5 + OpMemberDecorate %Params 0 Offset 0 + OpMemberDecorate %CB2 0 Offset 0 + OpDecorate %CB2 Block + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 +%_ptr_Function_float = OpTypePointer Function %float + %8 = OpTypeFunction %float %_ptr_Function_float + %v4float = OpTypeVector %float 4 +%_ptr_Function_v4float = OpTypePointer Function %v4float + %v3float = OpTypeVector %float 3 + %18 = OpTypeFunction %v3float %_ptr_Function_v4float +%_ptr_Function_v3float = OpTypePointer Function %v3float + %23 = OpTypeFunction %v4float %_ptr_Function_v3float + %27 = OpTypeFunction %float %_ptr_Function_v3float + %31 = OpTypeFunction %float %_ptr_Function_float %_ptr_Function_float + %36 = OpTypeSampler +%_ptr_Function_36 = OpTypePointer Function %36 + %38 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_Function_38 = OpTypePointer Function %38 + %40 = OpTypeFunction %float %_ptr_Function_36 %_ptr_Function_38 %_ptr_Function_v3float %_ptr_Function_float +%VertexOutput = OpTypeStruct %v4float %v4float %v4float %v4float %v4float %v4float %v4float %v3float %v4float %float +%_ptr_Function_VertexOutput = OpTypePointer Function %VertexOutput + %Surface = OpTypeStruct %v3float %v3float %float %float %float %float + %50 = OpTypeFunction %Surface %_ptr_Function_VertexOutput + %54 = OpTypeFunction %v4float %_ptr_Function_VertexOutput + %v2float = OpTypeVector %float 2 +%_ptr_Function_v2float = OpTypePointer Function %v2float + %60 = OpTypeFunction %v4float %_ptr_Function_36 %_ptr_Function_38 %_ptr_Function_v2float %_ptr_Function_float %_ptr_Function_float +%SurfaceInput = OpTypeStruct %v4float %v2float %v2float +%_ptr_Function_SurfaceInput = OpTypePointer Function %SurfaceInput + %70 = OpTypeFunction %Surface %_ptr_Function_SurfaceInput %_ptr_Function_v2float + %float_0 = OpConstant %float 0 + %float_1 = OpConstant %float 1 + %float_2 = OpConstant %float 2 +%mat4v4float = OpTypeMatrix %v4float 4 + %Globals = OpTypeStruct %mat4v4float %v4float %v4float %v4float %v3float %v3float %v3float %v3float %v3float %v4float %v3float %v4float %v4float %v4float %v4float %v4float %v4float %v4float %v4float %v4float %v4float + %CB0 = OpTypeStruct %Globals +%_ptr_Uniform_CB0 = OpTypePointer Uniform %CB0 + %_ = OpVariable %_ptr_Uniform_CB0 Uniform + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %int_15 = OpConstant %int 15 +%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float + %int_14 = OpConstant %int 14 + %128 = OpConstantComposite %v3float %float_1 %float_1 %float_1 + %133 = OpTypeImage %float 3D 0 0 0 1 Unknown +%_ptr_UniformConstant_133 = OpTypePointer UniformConstant %133 +%LightMapTexture = OpVariable %_ptr_UniformConstant_133 UniformConstant +%_ptr_UniformConstant_36 = OpTypePointer UniformConstant %36 +%LightMapSampler = OpVariable %_ptr_UniformConstant_36 UniformConstant + %140 = OpTypeSampledImage %133 + %int_11 = OpConstant %int 11 + %uint = OpTypeInt 32 0 + %float_9 = OpConstant %float 9 + %float_20 = OpConstant %float 20 + %float_0_5 = OpConstant %float 0.5 + %183 = OpTypeSampledImage %38 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %int_17 = OpConstant %int 17 + %uint_3 = OpConstant %uint 3 +%_ptr_Uniform_float = OpTypePointer Uniform %float + %float_0_25 = OpConstant %float 0.25 + %int_5 = OpConstant %int 5 +%float_0_00333333 = OpConstant %float 0.00333333 + %int_16 = OpConstant %int 16 +%_ptr_Function_Surface = OpTypePointer Function %Surface + %int_6 = OpConstant %int 6 + %int_7 = OpConstant %int 7 +%_ptr_Uniform_v3float = OpTypePointer Uniform %v3float + %int_8 = OpConstant %int 8 +%ShadowMapSampler = OpVariable %_ptr_UniformConstant_36 UniformConstant +%_ptr_UniformConstant_38 = OpTypePointer UniformConstant %38 +%ShadowMapTexture = OpVariable %_ptr_UniformConstant_38 UniformConstant + %367 = OpTypeImage %float Cube 0 0 0 1 Unknown +%_ptr_UniformConstant_367 = OpTypePointer UniformConstant %367 +%EnvironmentMapTexture = OpVariable %_ptr_UniformConstant_367 UniformConstant +%EnvironmentMapSampler = OpVariable %_ptr_UniformConstant_36 UniformConstant + %373 = OpTypeSampledImage %367 + %float_1_5 = OpConstant %float 1.5 + %int_10 = OpConstant %int 10 +%_ptr_Input_v4float = OpTypePointer Input %v4float +%IN_HPosition = OpVariable %_ptr_Input_v4float Input +%IN_Uv_EdgeDistance1 = OpVariable %_ptr_Input_v4float Input +%IN_UvStuds_EdgeDistance2 = OpVariable %_ptr_Input_v4float Input + %IN_Color = OpVariable %_ptr_Input_v4float Input +%IN_LightPosition_Fog = OpVariable %_ptr_Input_v4float Input +%IN_View_Depth = OpVariable %_ptr_Input_v4float Input +%IN_Normal_SpecPower = OpVariable %_ptr_Input_v4float Input +%_ptr_Input_v3float = OpTypePointer Input %v3float + %IN_Tangent = OpVariable %_ptr_Input_v3float Input +%IN_PosLightSpace_Reflectance = OpVariable %_ptr_Input_v4float Input +%_ptr_Input_float = OpTypePointer Input %float +%IN_studIndex = OpVariable %_ptr_Input_float Input +%_ptr_Output_v4float = OpTypePointer Output %v4float +%_entryPointOutput = OpVariable %_ptr_Output_v4float Output + %bool = OpTypeBool +%DiffuseMapSampler = OpVariable %_ptr_UniformConstant_36 UniformConstant +%DiffuseMapTexture = OpVariable %_ptr_UniformConstant_38 UniformConstant +%NormalMapSampler = OpVariable %_ptr_UniformConstant_36 UniformConstant +%NormalMapTexture = OpVariable %_ptr_UniformConstant_38 UniformConstant +%NormalDetailMapTexture = OpVariable %_ptr_UniformConstant_38 UniformConstant +%NormalDetailMapSampler = OpVariable %_ptr_UniformConstant_36 UniformConstant + %float_0_3 = OpConstant %float 0.3 +%StudsMapTexture = OpVariable %_ptr_UniformConstant_38 UniformConstant +%StudsMapSampler = OpVariable %_ptr_UniformConstant_36 UniformConstant +%SpecularMapSampler = OpVariable %_ptr_UniformConstant_36 UniformConstant +%SpecularMapTexture = OpVariable %_ptr_UniformConstant_38 UniformConstant + %float_0_75 = OpConstant %float 0.75 + %float_256 = OpConstant %float 256 + %689 = OpConstantComposite %v2float %float_2 %float_256 + %float_0_01 = OpConstant %float 0.01 + %692 = OpConstantComposite %v2float %float_0 %float_0_01 + %float_0_8 = OpConstant %float 0.8 + %float_120 = OpConstant %float 120 + %697 = OpConstantComposite %v2float %float_0_8 %float_120 + %Params = OpTypeStruct %v4float + %CB2 = OpTypeStruct %Params +%_ptr_Uniform_CB2 = OpTypePointer Uniform %CB2 + %false = OpConstantFalse %bool + %1509 = OpUndef %VertexOutput + %1510 = OpUndef %SurfaceInput + %1511 = OpUndef %v2float + %1512 = OpUndef %v4float + %1531 = OpUndef %Surface + %main = OpFunction %void None %3 + %5 = OpLabel + %501 = OpLoad %v4float %IN_HPosition + %1378 = OpCompositeInsert %VertexOutput %501 %1509 0 + %504 = OpLoad %v4float %IN_Uv_EdgeDistance1 + %1380 = OpCompositeInsert %VertexOutput %504 %1378 1 + %507 = OpLoad %v4float %IN_UvStuds_EdgeDistance2 + %1382 = OpCompositeInsert %VertexOutput %507 %1380 2 + %510 = OpLoad %v4float %IN_Color + %1384 = OpCompositeInsert %VertexOutput %510 %1382 3 + %513 = OpLoad %v4float %IN_LightPosition_Fog + %1386 = OpCompositeInsert %VertexOutput %513 %1384 4 + %516 = OpLoad %v4float %IN_View_Depth + %1388 = OpCompositeInsert %VertexOutput %516 %1386 5 + %519 = OpLoad %v4float %IN_Normal_SpecPower + %1390 = OpCompositeInsert %VertexOutput %519 %1388 6 + %523 = OpLoad %v3float %IN_Tangent + %1392 = OpCompositeInsert %VertexOutput %523 %1390 7 + %526 = OpLoad %v4float %IN_PosLightSpace_Reflectance + %1394 = OpCompositeInsert %VertexOutput %526 %1392 8 + %530 = OpLoad %float %IN_studIndex + %1396 = OpCompositeInsert %VertexOutput %530 %1394 9 + %1400 = OpCompositeInsert %SurfaceInput %510 %1510 0 + %954 = OpVectorShuffle %v2float %504 %504 0 1 + %1404 = OpCompositeInsert %SurfaceInput %954 %1400 1 + %958 = OpVectorShuffle %v2float %507 %507 0 1 + %1408 = OpCompositeInsert %SurfaceInput %958 %1404 2 + %1410 = OpCompositeExtract %float %1408 2 1 + %962 = OpExtInst %float %1 Fract %1410 + %965 = OpFAdd %float %962 %530 + %966 = OpFMul %float %965 %float_0_25 + %1414 = OpCompositeInsert %SurfaceInput %966 %1408 2 1 + %1416 = OpCompositeExtract %float %1396 5 3 + %970 = OpFMul %float %1416 %float_0_00333333 + %971 = OpFSub %float %float_1 %970 + %987 = OpExtInst %float %1 FClamp %971 %float_0 %float_1 + %976 = OpAccessChain %_ptr_Uniform_float %_ %int_0 %int_16 %uint_1 + %977 = OpLoad %float %976 + %978 = OpFMul %float %1416 %977 + %979 = OpFSub %float %float_1 %978 + %990 = OpExtInst %float %1 FClamp %979 %float_0 %float_1 + %1024 = OpVectorTimesScalar %v2float %954 %float_1 + %1029 = OpLoad %36 %DiffuseMapSampler + %1030 = OpLoad %38 %DiffuseMapTexture + OpBranch %1119 + %1119 = OpLabel + OpLoopMerge %1120 %1121 None + OpBranch %1122 + %1122 = OpLabel + %1124 = OpFOrdEqual %bool %float_0 %float_0 + OpSelectionMerge %1125 None + OpBranchConditional %1124 %1126 %1127 + %1126 = OpLabel + %1130 = OpSampledImage %183 %1030 %1029 + %1132 = OpImageSampleImplicitLod %v4float %1130 %1024 + OpBranch %1120 + %1127 = OpLabel + %1134 = OpFSub %float %float_1 %float_0 + %1135 = OpFDiv %float %float_1 %1134 + %1138 = OpSampledImage %183 %1030 %1029 + %1140 = OpVectorTimesScalar %v2float %1024 %float_0_25 + %1141 = OpImageSampleImplicitLod %v4float %1138 %1140 + %1144 = OpSampledImage %183 %1030 %1029 + %1146 = OpImageSampleImplicitLod %v4float %1144 %1024 + %1149 = OpFMul %float %987 %1135 + %1152 = OpFMul %float %float_0 %1135 + %1153 = OpFSub %float %1149 %1152 + %1161 = OpExtInst %float %1 FClamp %1153 %float_0 %float_1 + %1155 = OpCompositeConstruct %v4float %1161 %1161 %1161 %1161 + %1156 = OpExtInst %v4float %1 FMix %1141 %1146 %1155 + OpBranch %1120 + %1125 = OpLabel + %1157 = OpUndef %v4float + OpBranch %1120 + %1121 = OpLabel + OpBranchConditional %false %1119 %1120 + %1120 = OpLabel + %1517 = OpPhi %v4float %1132 %1126 %1156 %1127 %1157 %1125 %1512 %1121 + %1035 = OpVectorTimesScalar %v4float %1517 %float_1 + %1036 = OpLoad %36 %NormalMapSampler + %1037 = OpLoad %38 %NormalMapTexture + OpBranch %1165 + %1165 = OpLabel + OpLoopMerge %1166 %1167 None + OpBranch %1168 + %1168 = OpLabel + OpSelectionMerge %1171 None + OpBranchConditional %1124 %1172 %1173 + %1172 = OpLabel + %1176 = OpSampledImage %183 %1037 %1036 + %1178 = OpImageSampleImplicitLod %v4float %1176 %1024 + OpBranch %1166 + %1173 = OpLabel + %1180 = OpFSub %float %float_1 %float_0 + %1181 = OpFDiv %float %float_1 %1180 + %1184 = OpSampledImage %183 %1037 %1036 + %1186 = OpVectorTimesScalar %v2float %1024 %float_0_25 + %1187 = OpImageSampleImplicitLod %v4float %1184 %1186 + %1190 = OpSampledImage %183 %1037 %1036 + %1192 = OpImageSampleImplicitLod %v4float %1190 %1024 + %1195 = OpFMul %float %990 %1181 + %1198 = OpFMul %float %float_0 %1181 + %1199 = OpFSub %float %1195 %1198 + %1206 = OpExtInst %float %1 FClamp %1199 %float_0 %float_1 + %1201 = OpCompositeConstruct %v4float %1206 %1206 %1206 %1206 + %1202 = OpExtInst %v4float %1 FMix %1187 %1192 %1201 + OpBranch %1166 + %1171 = OpLabel + %1203 = OpUndef %v4float + OpBranch %1166 + %1167 = OpLabel + OpBranchConditional %false %1165 %1166 + %1166 = OpLabel + %1523 = OpPhi %v4float %1178 %1172 %1202 %1173 %1203 %1171 %1512 %1167 + %1210 = OpVectorShuffle %v2float %1523 %1523 3 1 + %1211 = OpVectorTimesScalar %v2float %1210 %float_2 + %1212 = OpCompositeConstruct %v2float %float_1 %float_1 + %1213 = OpFSub %v2float %1211 %1212 + %1216 = OpFNegate %v2float %1213 + %1218 = OpDot %float %1216 %1213 + %1219 = OpFAdd %float %float_1 %1218 + %1220 = OpExtInst %float %1 FClamp %1219 %float_0 %float_1 + %1221 = OpExtInst %float %1 Sqrt %1220 + %1222 = OpCompositeExtract %float %1213 0 + %1223 = OpCompositeExtract %float %1213 1 + %1224 = OpCompositeConstruct %v3float %1222 %1223 %1221 + %1042 = OpLoad %38 %NormalDetailMapTexture + %1043 = OpLoad %36 %NormalDetailMapSampler + %1044 = OpSampledImage %183 %1042 %1043 + %1046 = OpVectorTimesScalar %v2float %1024 %float_0 + %1047 = OpImageSampleImplicitLod %v4float %1044 %1046 + %1228 = OpVectorShuffle %v2float %1047 %1047 3 1 + %1229 = OpVectorTimesScalar %v2float %1228 %float_2 + %1231 = OpFSub %v2float %1229 %1212 + %1234 = OpFNegate %v2float %1231 + %1236 = OpDot %float %1234 %1231 + %1237 = OpFAdd %float %float_1 %1236 + %1238 = OpExtInst %float %1 FClamp %1237 %float_0 %float_1 + %1239 = OpExtInst %float %1 Sqrt %1238 + %1240 = OpCompositeExtract %float %1231 0 + %1241 = OpCompositeExtract %float %1231 1 + %1242 = OpCompositeConstruct %v3float %1240 %1241 %1239 + %1050 = OpVectorShuffle %v2float %1242 %1242 0 1 + %1051 = OpVectorTimesScalar %v2float %1050 %float_0 + %1053 = OpVectorShuffle %v2float %1224 %1224 0 1 + %1054 = OpFAdd %v2float %1053 %1051 + %1056 = OpVectorShuffle %v3float %1224 %1054 3 4 2 + %1059 = OpVectorShuffle %v2float %1056 %1056 0 1 + %1060 = OpVectorTimesScalar %v2float %1059 %990 + %1062 = OpVectorShuffle %v3float %1056 %1060 3 4 2 + %1430 = OpCompositeExtract %float %1062 0 + %1065 = OpFMul %float %1430 %float_0_3 + %1066 = OpFAdd %float %float_1 %1065 + %1069 = OpVectorShuffle %v3float %510 %510 0 1 2 + %1071 = OpVectorShuffle %v3float %1035 %1035 0 1 2 + %1072 = OpFMul %v3float %1069 %1071 + %1074 = OpVectorTimesScalar %v3float %1072 %1066 + %1075 = OpLoad %38 %StudsMapTexture + %1076 = OpLoad %36 %StudsMapSampler + %1077 = OpSampledImage %183 %1075 %1076 + %1434 = OpCompositeExtract %v2float %1414 2 + %1080 = OpImageSampleImplicitLod %v4float %1077 %1434 + %1436 = OpCompositeExtract %float %1080 0 + %1083 = OpFMul %float %1436 %float_2 + %1085 = OpVectorTimesScalar %v3float %1074 %1083 + %1086 = OpLoad %36 %SpecularMapSampler + %1087 = OpLoad %38 %SpecularMapTexture + OpBranch %1246 + %1246 = OpLabel + OpLoopMerge %1247 %1248 None + OpBranch %1249 + %1249 = OpLabel + %1251 = OpFOrdEqual %bool %float_0_75 %float_0 + OpSelectionMerge %1252 None + OpBranchConditional %1251 %1253 %1254 + %1253 = OpLabel + %1257 = OpSampledImage %183 %1087 %1086 + %1259 = OpImageSampleImplicitLod %v4float %1257 %1024 + OpBranch %1247 + %1254 = OpLabel + %1261 = OpFSub %float %float_1 %float_0_75 + %1262 = OpFDiv %float %float_1 %1261 + %1265 = OpSampledImage %183 %1087 %1086 + %1267 = OpVectorTimesScalar %v2float %1024 %float_0_25 + %1268 = OpImageSampleImplicitLod %v4float %1265 %1267 + %1271 = OpSampledImage %183 %1087 %1086 + %1273 = OpImageSampleImplicitLod %v4float %1271 %1024 + %1276 = OpFMul %float %990 %1262 + %1279 = OpFMul %float %float_0_75 %1262 + %1280 = OpFSub %float %1276 %1279 + %1287 = OpExtInst %float %1 FClamp %1280 %float_0 %float_1 + %1282 = OpCompositeConstruct %v4float %1287 %1287 %1287 %1287 + %1283 = OpExtInst %v4float %1 FMix %1268 %1273 %1282 + OpBranch %1247 + %1252 = OpLabel + %1284 = OpUndef %v4float + OpBranch %1247 + %1248 = OpLabel + OpBranchConditional %false %1246 %1247 + %1247 = OpLabel + %1530 = OpPhi %v4float %1259 %1253 %1283 %1254 %1284 %1252 %1512 %1248 + %1091 = OpVectorShuffle %v2float %1530 %1530 0 1 + %1093 = OpFMul %v2float %1091 %689 + %1094 = OpFAdd %v2float %1093 %692 + %1097 = OpCompositeConstruct %v2float %990 %990 + %1098 = OpExtInst %v2float %1 FMix %697 %1094 %1097 + %1438 = OpCompositeInsert %Surface %1085 %1531 0 + %1440 = OpCompositeInsert %Surface %1062 %1438 1 + %1442 = OpCompositeExtract %float %1098 0 + %1444 = OpCompositeInsert %Surface %1442 %1440 2 + %1446 = OpCompositeExtract %float %1098 1 + %1448 = OpCompositeInsert %Surface %1446 %1444 3 + %1450 = OpCompositeExtract %float %1091 1 + %1112 = OpFMul %float %1450 %990 + %1113 = OpFMul %float %1112 %float_0 + %1452 = OpCompositeInsert %Surface %1113 %1448 4 + %1456 = OpCompositeExtract %float %1396 3 3 + %764 = OpCompositeExtract %float %1085 0 + %765 = OpCompositeExtract %float %1085 1 + %766 = OpCompositeExtract %float %1085 2 + %767 = OpCompositeConstruct %v4float %764 %765 %766 %1456 + %770 = OpVectorShuffle %v3float %519 %519 0 1 2 + %773 = OpExtInst %v3float %1 Cross %770 %523 + %1462 = OpCompositeExtract %float %1452 1 0 + %778 = OpVectorTimesScalar %v3float %523 %1462 + %1466 = OpCompositeExtract %float %1452 1 1 + %782 = OpVectorTimesScalar %v3float %773 %1466 + %783 = OpFAdd %v3float %778 %782 + %1468 = OpCompositeExtract %float %1452 1 2 + %789 = OpVectorTimesScalar %v3float %770 %1468 + %790 = OpFAdd %v3float %783 %789 + %791 = OpExtInst %v3float %1 Normalize %790 + %793 = OpAccessChain %_ptr_Uniform_v3float %_ %int_0 %int_7 + %794 = OpLoad %v3float %793 + %795 = OpFNegate %v3float %794 + %796 = OpDot %float %791 %795 + %1290 = OpExtInst %float %1 FClamp %796 %float_0 %float_1 + %799 = OpAccessChain %_ptr_Uniform_v3float %_ %int_0 %int_6 + %800 = OpLoad %v3float %799 + %801 = OpVectorTimesScalar %v3float %800 %1290 + %803 = OpFNegate %float %796 + %804 = OpExtInst %float %1 FMax %803 %float_0 + %805 = OpAccessChain %_ptr_Uniform_v3float %_ %int_0 %int_8 + %806 = OpLoad %v3float %805 + %807 = OpVectorTimesScalar %v3float %806 %804 + %808 = OpFAdd %v3float %801 %807 + %810 = OpExtInst %float %1 Step %float_0 %796 + %813 = OpFMul %float %810 %1442 + %820 = OpVectorShuffle %v3float %513 %513 0 1 2 + %1296 = OpAccessChain %_ptr_Uniform_v4float %_ %int_0 %int_15 + %1297 = OpLoad %v4float %1296 + %1298 = OpVectorShuffle %v3float %1297 %1297 0 1 2 + %1300 = OpAccessChain %_ptr_Uniform_v4float %_ %int_0 %int_14 + %1301 = OpLoad %v4float %1300 + %1302 = OpVectorShuffle %v3float %1301 %1301 0 1 2 + %1303 = OpFSub %v3float %820 %1302 + %1304 = OpExtInst %v3float %1 FAbs %1303 + %1305 = OpExtInst %v3float %1 Step %1298 %1304 + %1307 = OpDot %float %1305 %128 + %1328 = OpExtInst %float %1 FClamp %1307 %float_0 %float_1 + %1309 = OpLoad %133 %LightMapTexture + %1310 = OpLoad %36 %LightMapSampler + %1311 = OpSampledImage %140 %1309 %1310 + %1313 = OpVectorShuffle %v3float %820 %820 1 2 0 + %1317 = OpVectorTimesScalar %v3float %1313 %1328 + %1318 = OpFSub %v3float %1313 %1317 + %1319 = OpImageSampleImplicitLod %v4float %1311 %1318 + %1321 = OpAccessChain %_ptr_Uniform_v4float %_ %int_0 %int_11 + %1322 = OpLoad %v4float %1321 + %1324 = OpCompositeConstruct %v4float %1328 %1328 %1328 %1328 + %1325 = OpExtInst %v4float %1 FMix %1319 %1322 %1324 + %822 = OpLoad %36 %ShadowMapSampler + %823 = OpLoad %38 %ShadowMapTexture + %826 = OpVectorShuffle %v3float %526 %526 0 1 2 + %1482 = OpCompositeExtract %float %1325 3 + %1337 = OpSampledImage %183 %823 %822 + %1339 = OpVectorShuffle %v2float %826 %826 0 1 + %1340 = OpImageSampleImplicitLod %v4float %1337 %1339 + %1341 = OpVectorShuffle %v2float %1340 %1340 0 1 + %1484 = OpCompositeExtract %float %826 2 + %1486 = OpCompositeExtract %float %1341 0 + %1363 = OpExtInst %float %1 Step %1486 %1484 + %1365 = OpFSub %float %1484 %float_0_5 + %1366 = OpExtInst %float %1 FAbs %1365 + %1367 = OpFMul %float %float_20 %1366 + %1368 = OpFSub %float %float_9 %1367 + %1369 = OpExtInst %float %1 FClamp %1368 %float_0 %float_1 + %1370 = OpFMul %float %1363 %1369 + %1488 = OpCompositeExtract %float %1341 1 + %1350 = OpFMul %float %1370 %1488 + %1351 = OpAccessChain %_ptr_Uniform_float %_ %int_0 %int_17 %uint_3 + %1352 = OpLoad %float %1351 + %1353 = OpFMul %float %1350 %1352 + %1354 = OpFSub %float %float_1 %1353 + %1356 = OpFMul %float %1354 %1482 + %830 = OpLoad %367 %EnvironmentMapTexture + %831 = OpLoad %36 %EnvironmentMapSampler + %832 = OpSampledImage %373 %830 %831 + %835 = OpVectorShuffle %v3float %516 %516 0 1 2 + %836 = OpFNegate %v3float %835 + %838 = OpExtInst %v3float %1 Reflect %836 %791 + %839 = OpImageSampleImplicitLod %v4float %832 %838 + %840 = OpVectorShuffle %v3float %839 %839 0 1 2 + %842 = OpVectorShuffle %v3float %767 %767 0 1 2 + %845 = OpCompositeConstruct %v3float %1113 %1113 %1113 + %846 = OpExtInst %v3float %1 FMix %842 %840 %845 + %848 = OpVectorShuffle %v4float %767 %846 4 5 6 3 + %849 = OpAccessChain %_ptr_Uniform_v3float %_ %int_0 %int_5 + %850 = OpLoad %v3float %849 + %853 = OpVectorTimesScalar %v3float %808 %1356 + %854 = OpFAdd %v3float %850 %853 + %856 = OpVectorShuffle %v3float %1325 %1325 0 1 2 + %857 = OpFAdd %v3float %854 %856 + %859 = OpVectorShuffle %v3float %848 %848 0 1 2 + %860 = OpFMul %v3float %857 %859 + %865 = OpFMul %float %813 %1356 + %873 = OpExtInst %v3float %1 Normalize %835 + %874 = OpFAdd %v3float %795 %873 + %875 = OpExtInst %v3float %1 Normalize %874 + %876 = OpDot %float %791 %875 + %877 = OpExtInst %float %1 FClamp %876 %float_0 %float_1 + %879 = OpExtInst %float %1 Pow %877 %1446 + %880 = OpFMul %float %865 %879 + %881 = OpVectorTimesScalar %v3float %800 %880 + %884 = OpFAdd %v3float %860 %881 + %886 = OpVectorShuffle %v4float %1512 %884 4 5 6 3 + %1494 = OpCompositeExtract %float %848 3 + %1496 = OpCompositeInsert %v4float %1494 %886 3 + %896 = OpAccessChain %_ptr_Uniform_float %_ %int_0 %int_17 %uint_0 + %897 = OpLoad %float %896 + %898 = OpFMul %float %978 %897 + %899 = OpAccessChain %_ptr_Uniform_float %_ %int_0 %int_17 %uint_1 + %900 = OpLoad %float %899 + %901 = OpFAdd %float %898 %900 + %1373 = OpExtInst %float %1 FClamp %901 %float_0 %float_1 + %905 = OpVectorShuffle %v2float %504 %504 3 2 + %908 = OpVectorShuffle %v2float %507 %507 3 2 + %909 = OpExtInst %v2float %1 FMin %905 %908 + %1504 = OpCompositeExtract %float %909 0 + %1506 = OpCompositeExtract %float %909 1 + %914 = OpExtInst %float %1 FMin %1504 %1506 + %916 = OpFDiv %float %914 %978 + %919 = OpFSub %float %float_1_5 %916 + %920 = OpFMul %float %1373 %919 + %922 = OpFAdd %float %920 %916 + %1376 = OpExtInst %float %1 FClamp %922 %float_0 %float_1 + %925 = OpVectorShuffle %v3float %1496 %1496 0 1 2 + %926 = OpVectorTimesScalar %v3float %925 %1376 + %928 = OpVectorShuffle %v4float %1496 %926 4 5 6 3 + %1508 = OpCompositeExtract %float %1396 4 3 + %931 = OpExtInst %float %1 FClamp %1508 %float_0 %float_1 + %932 = OpAccessChain %_ptr_Uniform_v3float %_ %int_0 %int_10 + %933 = OpLoad %v3float %932 + %935 = OpVectorShuffle %v3float %928 %928 0 1 2 + %937 = OpCompositeConstruct %v3float %931 %931 %931 + %938 = OpExtInst %v3float %1 FMix %933 %935 %937 + %940 = OpVectorShuffle %v4float %928 %938 4 5 6 3 + OpStore %_entryPointOutput %940 + OpReturn + OpFunctionEnd diff --git a/shaders-msl/asm/frag/op-constant-null.asm.frag b/shaders-msl/asm/frag/op-constant-null.asm.frag new file mode 100644 index 0000000000..61d2e579c8 --- /dev/null +++ b/shaders-msl/asm/frag/op-constant-null.asm.frag @@ -0,0 +1,85 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 1 +; Bound: 45 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %FragColor + OpExecutionMode %main OriginUpperLeft + OpSource ESSL 310 + OpName %main "main" + OpName %a "a" + OpName %b "b" + OpName %c "c" + OpName %D "D" + OpMemberName %D 0 "a" + OpMemberName %D 1 "b" + OpName %d "d" + OpName %e "e" + OpName %FragColor "FragColor" + OpDecorate %a RelaxedPrecision + OpDecorate %b RelaxedPrecision + OpDecorate %c RelaxedPrecision + OpMemberDecorate %D 0 RelaxedPrecision + OpMemberDecorate %D 1 RelaxedPrecision + OpDecorate %e RelaxedPrecision + OpDecorate %FragColor RelaxedPrecision + OpDecorate %FragColor Location 0 + OpDecorate %44 RelaxedPrecision + OpDecorate %float_1 RelaxedPrecision + OpDecorate %14 RelaxedPrecision + OpDecorate %23 RelaxedPrecision + OpDecorate %41 RelaxedPrecision + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 +%_ptr_Function_float = OpTypePointer Function %float + %float_1 = OpConstantNull %float + %v4float = OpTypeVector %float 4 +%_ptr_Function_v4float = OpTypePointer Function %v4float + %float_2 = OpConstantNull %float + %14 = OpConstantNull %v4float + %v3float = OpTypeVector %float 3 +%mat2v3float = OpTypeMatrix %v3float 2 +%_ptr_Function_mat2v3float = OpTypePointer Function %mat2v3float + %float_4 = OpConstantNull %float + %20 = OpConstantNull %v3float + %float_5 = OpConstantNull %float + %22 = OpConstantNull %v3float + %23 = OpConstantNull %mat2v3float + %D = OpTypeStruct %v4float %float +%_ptr_Function_D = OpTypePointer Function %D + %27 = OpConstantNull %D + %uint = OpTypeInt 32 0 + %uint_4 = OpConstant %uint 4 +%_arr_v4float_uint_4 = OpTypeArray %v4float %uint_4 +%_ptr_Function__arr_v4float_uint_4 = OpTypePointer Function %_arr_v4float_uint_4 + %float_10 = OpConstantNull %float + %34 = OpConstantNull %v4float + %float_11 = OpConstantNull %float + %36 = OpConstantNull %v4float + %float_12 = OpConstantNull %float + %38 = OpConstantNull %v4float + %float_13 = OpConstantNull %float + %40 = OpConstantNull %v4float + %41 = OpConstantNull %_arr_v4float_uint_4 +%_ptr_Output_float = OpTypePointer Output %float + %FragColor = OpVariable %_ptr_Output_float Output + %main = OpFunction %void None %3 + %5 = OpLabel + %a = OpVariable %_ptr_Function_float Function + %b = OpVariable %_ptr_Function_v4float Function + %c = OpVariable %_ptr_Function_mat2v3float Function + %d = OpVariable %_ptr_Function_D Function + %e = OpVariable %_ptr_Function__arr_v4float_uint_4 Function + OpStore %a %float_1 + OpStore %b %14 + OpStore %c %23 + OpStore %d %27 + OpStore %e %41 + %44 = OpLoad %float %a + OpStore %FragColor %44 + OpReturn + OpFunctionEnd diff --git a/shaders-msl/asm/frag/phi-loop-variable.asm.frag b/shaders-msl/asm/frag/phi-loop-variable.asm.frag new file mode 100644 index 0000000000..74c46b4af8 --- /dev/null +++ b/shaders-msl/asm/frag/phi-loop-variable.asm.frag @@ -0,0 +1,71 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 1 +; Bound: 59 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" + OpExecutionMode %4 OriginUpperLeft + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v2float = OpTypeVector %float 2 +%mat2v2float = OpTypeMatrix %v2float 2 +%_ptr_Function_mat2v2float = OpTypePointer Function %mat2v2float + %v3float = OpTypeVector %float 3 + %11 = OpTypeFunction %v3float %_ptr_Function_mat2v2float +%_ptr_Function_v3float = OpTypePointer Function %v3float + %float_1 = OpConstant %float 1 + %18 = OpConstantComposite %v3float %float_1 %float_1 %float_1 + %int = OpTypeInt 32 1 +%_ptr_Function_int = OpTypePointer Function %int + %int_35 = OpConstant %int 35 + %int_0 = OpConstant %int 0 + %bool = OpTypeBool + %int_1 = OpConstant %int 1 + %4 = OpFunction %void None %3 + %5 = OpLabel + OpBranch %48 + %48 = OpLabel + %58 = OpPhi %int %int_35 %5 %56 %50 + OpLoopMerge %49 %50 None + OpBranch %51 + %51 = OpLabel + %53 = OpSGreaterThanEqual %bool %58 %int_0 + OpBranchConditional %53 %54 %49 + %54 = OpLabel + OpBranch %50 + %50 = OpLabel + %56 = OpISub %int %58 %int_1 + OpBranch %48 + %49 = OpLabel + OpReturn + OpFunctionEnd + %13 = OpFunction %v3float None %11 + %12 = OpFunctionParameter %_ptr_Function_mat2v2float + %14 = OpLabel + %16 = OpVariable %_ptr_Function_v3float Function + %21 = OpVariable %_ptr_Function_int Function + OpStore %16 %18 + OpStore %21 %int_35 + OpBranch %23 + %23 = OpLabel + OpLoopMerge %25 %26 None + OpBranch %27 + %27 = OpLabel + %28 = OpLoad %int %21 + %31 = OpSGreaterThanEqual %bool %28 %int_0 + OpBranchConditional %31 %24 %25 + %24 = OpLabel + OpBranch %26 + %26 = OpLabel + %32 = OpLoad %int %21 + %34 = OpISub %int %32 %int_1 + OpStore %21 %34 + OpBranch %23 + %25 = OpLabel + %35 = OpLoad %v3float %16 + OpReturnValue %35 + OpFunctionEnd diff --git a/shaders-msl/asm/frag/undef-variable-store.asm.frag b/shaders-msl/asm/frag/undef-variable-store.asm.frag new file mode 100644 index 0000000000..966c2d9d5a --- /dev/null +++ b/shaders-msl/asm/frag/undef-variable-store.asm.frag @@ -0,0 +1,85 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 1 +; Bound: 50 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %fragmentProgram "main" %_entryPointOutput + OpExecutionMode %fragmentProgram OriginUpperLeft + OpSource HLSL 500 + OpName %fragmentProgram "fragmentProgram" + OpName %_fragmentProgram_ "@fragmentProgram(" + OpName %uv "uv" + OpName %_entryPointOutput "@entryPointOutput" + OpDecorate %_entryPointOutput Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %8 = OpTypeFunction %v4float + %v2float = OpTypeVector %float 2 +%_ptr_Function_v2float = OpTypePointer Function %v2float + %float_0 = OpConstant %float 0 + %15 = OpConstantComposite %v2float %float_0 %float_0 + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 +%_ptr_Function_float = OpTypePointer Function %float + %bool = OpTypeBool + %float_1 = OpConstant %float 1 + %26 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1 + %29 = OpConstantComposite %v4float %float_1 %float_1 %float_0 %float_1 +%_ptr_Output_v4float = OpTypePointer Output %v4float +%_entryPointOutput = OpVariable %_ptr_Output_v4float Output +%_ptr_Function_v4float = OpTypePointer Function %v4float + %false = OpConstantFalse %bool +%fragmentProgram = OpFunction %void None %3 + %5 = OpLabel + %35 = OpVariable %_ptr_Function_v2float Function + %37 = OpVariable %_ptr_Function_v4float Function + OpBranch %38 + %38 = OpLabel + OpLoopMerge %39 %40 None + OpBranch %41 + %41 = OpLabel + OpStore %35 %15 + %42 = OpAccessChain %_ptr_Function_float %35 %uint_0 + %43 = OpLoad %float %42 + %44 = OpFOrdNotEqual %bool %43 %float_0 + OpSelectionMerge %45 None + OpBranchConditional %44 %46 %47 + %46 = OpLabel + OpStore %37 %26 + OpBranch %39 + %47 = OpLabel + OpStore %37 %29 + OpBranch %39 + %45 = OpLabel + %48 = OpUndef %v4float + OpStore %37 %48 + OpBranch %39 + %40 = OpLabel + OpBranchConditional %false %38 %39 + %39 = OpLabel + %34 = OpLoad %v4float %37 + OpStore %_entryPointOutput %34 + OpReturn + OpFunctionEnd +%_fragmentProgram_ = OpFunction %v4float None %8 + %10 = OpLabel + %uv = OpVariable %_ptr_Function_v2float Function + OpStore %uv %15 + %19 = OpAccessChain %_ptr_Function_float %uv %uint_0 + %20 = OpLoad %float %19 + %22 = OpFOrdNotEqual %bool %20 %float_0 + OpSelectionMerge %24 None + OpBranchConditional %22 %23 %28 + %23 = OpLabel + OpReturnValue %26 + %28 = OpLabel + OpReturnValue %29 + %24 = OpLabel + %31 = OpUndef %v4float + OpReturnValue %31 + OpFunctionEnd diff --git a/shaders-msl/asm/frag/unreachable.asm.frag b/shaders-msl/asm/frag/unreachable.asm.frag new file mode 100644 index 0000000000..e2ce2eb56a --- /dev/null +++ b/shaders-msl/asm/frag/unreachable.asm.frag @@ -0,0 +1,61 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 3 +; Bound: 47 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %counter %FragColor + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 450 + OpName %main "main" + OpName %counter "counter" + OpName %FragColor "FragColor" + OpDecorate %counter Flat + OpDecorate %counter Location 0 + OpDecorate %FragColor Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %8 = OpTypeFunction %v4float + %int = OpTypeInt 32 1 +%_ptr_Input_int = OpTypePointer Input %int + %counter = OpVariable %_ptr_Input_int Input + %int_10 = OpConstant %int 10 + %bool = OpTypeBool + %float_10 = OpConstant %float 10 + %21 = OpConstantComposite %v4float %float_10 %float_10 %float_10 %float_10 + %float_30 = OpConstant %float 30 + %25 = OpConstantComposite %v4float %float_30 %float_30 %float_30 %float_30 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %FragColor = OpVariable %_ptr_Output_v4float Output +%_ptr_Function_v4float = OpTypePointer Function %v4float + %false = OpConstantFalse %bool + %44 = OpUndef %v4float + %main = OpFunction %void None %3 + %5 = OpLabel + OpBranch %33 + %33 = OpLabel + %45 = OpPhi %v4float %44 %5 %44 %35 + OpLoopMerge %34 %35 None + OpBranch %36 + %36 = OpLabel + %37 = OpLoad %int %counter + %38 = OpIEqual %bool %37 %int_10 + OpSelectionMerge %39 None + OpBranchConditional %38 %40 %41 + %40 = OpLabel + OpBranch %34 + %41 = OpLabel + OpBranch %34 + %39 = OpLabel + OpUnreachable + %35 = OpLabel + OpBranchConditional %false %33 %34 + %34 = OpLabel + %46 = OpPhi %v4float %21 %40 %25 %41 %44 %35 + OpStore %FragColor %46 + OpReturn + OpFunctionEnd diff --git a/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag b/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag new file mode 100644 index 0000000000..d60c6f52d4 --- /dev/null +++ b/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag @@ -0,0 +1,886 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 2 +; Bound: 25007 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %5663 "main" %5800 %gl_FragCoord %4317 + OpExecutionMode %5663 OriginUpperLeft + OpMemberDecorate %_struct_1116 0 Offset 0 + OpMemberDecorate %_struct_1116 1 Offset 16 + OpMemberDecorate %_struct_1116 2 Offset 32 + OpDecorate %_struct_1116 Block + OpDecorate %22044 DescriptorSet 0 + OpDecorate %22044 Binding 0 + OpDecorate %5785 DescriptorSet 0 + OpDecorate %5785 Binding 140 + OpDecorate %5688 DescriptorSet 0 + OpDecorate %5688 Binding 60 + OpMemberDecorate %_struct_994 0 Offset 0 + OpMemberDecorate %_struct_994 1 Offset 16 + OpMemberDecorate %_struct_994 2 Offset 28 + OpMemberDecorate %_struct_994 3 Offset 32 + OpMemberDecorate %_struct_994 4 Offset 44 + OpMemberDecorate %_struct_994 5 Offset 48 + OpMemberDecorate %_struct_994 6 Offset 60 + OpMemberDecorate %_struct_994 7 Offset 64 + OpMemberDecorate %_struct_994 8 Offset 76 + OpMemberDecorate %_struct_994 9 Offset 80 + OpMemberDecorate %_struct_994 10 Offset 92 + OpMemberDecorate %_struct_994 11 Offset 96 + OpMemberDecorate %_struct_994 12 Offset 108 + OpMemberDecorate %_struct_994 13 Offset 112 + OpMemberDecorate %_struct_994 14 Offset 120 + OpMemberDecorate %_struct_994 15 Offset 128 + OpMemberDecorate %_struct_994 16 Offset 140 + OpMemberDecorate %_struct_994 17 Offset 144 + OpMemberDecorate %_struct_994 18 Offset 148 + OpMemberDecorate %_struct_994 19 Offset 152 + OpMemberDecorate %_struct_994 20 Offset 156 + OpMemberDecorate %_struct_994 21 Offset 160 + OpMemberDecorate %_struct_994 22 Offset 176 + OpMemberDecorate %_struct_994 23 RowMajor + OpMemberDecorate %_struct_994 23 Offset 192 + OpMemberDecorate %_struct_994 23 MatrixStride 16 + OpMemberDecorate %_struct_994 24 Offset 256 + OpDecorate %_struct_994 Block + OpDecorate %12348 DescriptorSet 0 + OpDecorate %12348 Binding 2 + OpDecorate %3312 DescriptorSet 0 + OpDecorate %3312 Binding 142 + OpDecorate %4646 DescriptorSet 0 + OpDecorate %4646 Binding 62 + OpDecorate %4862 DescriptorSet 0 + OpDecorate %4862 Binding 141 + OpDecorate %3594 DescriptorSet 0 + OpDecorate %3594 Binding 61 + OpDecorate %_arr_mat4v4float_uint_2 ArrayStride 64 + OpDecorate %_arr_v4float_uint_2 ArrayStride 16 + OpMemberDecorate %_struct_408 0 RowMajor + OpMemberDecorate %_struct_408 0 Offset 0 + OpMemberDecorate %_struct_408 0 MatrixStride 16 + OpMemberDecorate %_struct_408 1 RowMajor + OpMemberDecorate %_struct_408 1 Offset 64 + OpMemberDecorate %_struct_408 1 MatrixStride 16 + OpMemberDecorate %_struct_408 2 RowMajor + OpMemberDecorate %_struct_408 2 Offset 128 + OpMemberDecorate %_struct_408 2 MatrixStride 16 + OpMemberDecorate %_struct_408 3 RowMajor + OpMemberDecorate %_struct_408 3 Offset 192 + OpMemberDecorate %_struct_408 3 MatrixStride 16 + OpMemberDecorate %_struct_408 4 Offset 256 + OpMemberDecorate %_struct_408 5 Offset 272 + OpMemberDecorate %_struct_408 6 Offset 288 + OpMemberDecorate %_struct_408 7 Offset 292 + OpMemberDecorate %_struct_408 8 Offset 296 + OpMemberDecorate %_struct_408 9 Offset 300 + OpMemberDecorate %_struct_408 10 Offset 304 + OpMemberDecorate %_struct_408 11 Offset 316 + OpMemberDecorate %_struct_408 12 Offset 320 + OpMemberDecorate %_struct_408 13 Offset 332 + OpMemberDecorate %_struct_408 14 Offset 336 + OpMemberDecorate %_struct_408 15 Offset 348 + OpMemberDecorate %_struct_408 16 Offset 352 + OpMemberDecorate %_struct_408 17 Offset 364 + OpMemberDecorate %_struct_408 18 Offset 368 + OpMemberDecorate %_struct_408 19 Offset 372 + OpMemberDecorate %_struct_408 20 Offset 376 + OpMemberDecorate %_struct_408 21 Offset 384 + OpMemberDecorate %_struct_408 22 Offset 392 + OpMemberDecorate %_struct_408 23 Offset 400 + OpMemberDecorate %_struct_408 24 Offset 416 + OpMemberDecorate %_struct_408 25 Offset 424 + OpMemberDecorate %_struct_408 26 Offset 432 + OpMemberDecorate %_struct_408 27 Offset 448 + OpMemberDecorate %_struct_408 28 Offset 460 + OpMemberDecorate %_struct_408 29 Offset 464 + OpMemberDecorate %_struct_408 30 Offset 468 + OpMemberDecorate %_struct_408 31 Offset 472 + OpMemberDecorate %_struct_408 32 Offset 476 + OpMemberDecorate %_struct_408 33 Offset 480 + OpMemberDecorate %_struct_408 34 Offset 488 + OpMemberDecorate %_struct_408 35 Offset 492 + OpMemberDecorate %_struct_408 36 Offset 496 + OpMemberDecorate %_struct_408 37 RowMajor + OpMemberDecorate %_struct_408 37 Offset 512 + OpMemberDecorate %_struct_408 37 MatrixStride 16 + OpMemberDecorate %_struct_408 38 Offset 640 + OpDecorate %_struct_408 Block + OpDecorate %15259 DescriptorSet 0 + OpDecorate %15259 Binding 1 + OpDecorate %5800 Location 0 + OpDecorate %gl_FragCoord BuiltIn FragCoord + OpDecorate %4317 Location 0 + OpMemberDecorate %_struct_1395 0 Offset 0 + OpMemberDecorate %_struct_1395 1 Offset 16 + OpMemberDecorate %_struct_1395 2 Offset 32 + OpMemberDecorate %_struct_1395 3 Offset 40 + OpMemberDecorate %_struct_1395 4 Offset 48 + OpMemberDecorate %_struct_1395 5 Offset 60 + OpMemberDecorate %_struct_1395 6 Offset 64 + OpMemberDecorate %_struct_1395 7 Offset 76 + OpMemberDecorate %_struct_1395 8 Offset 80 + OpMemberDecorate %_struct_1395 9 Offset 96 + OpMemberDecorate %_struct_1395 10 Offset 112 + OpMemberDecorate %_struct_1395 11 Offset 128 + OpMemberDecorate %_struct_1395 12 Offset 140 + OpMemberDecorate %_struct_1395 13 Offset 144 + OpMemberDecorate %_struct_1395 14 Offset 156 + OpMemberDecorate %_struct_1395 15 Offset 160 + OpMemberDecorate %_struct_1395 16 Offset 176 + OpMemberDecorate %_struct_1395 17 Offset 192 + OpMemberDecorate %_struct_1395 18 Offset 204 + OpMemberDecorate %_struct_1395 19 Offset 208 + OpMemberDecorate %_struct_1395 20 Offset 224 + OpDecorate %_struct_1395 Block + OpMemberDecorate %_struct_1018 0 Offset 0 + OpDecorate %_struct_1018 Block + %void = OpTypeVoid + %1282 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v2float = OpTypeVector %float 2 + %v4float = OpTypeVector %float 4 + %v3float = OpTypeVector %float 3 +%_struct_1017 = OpTypeStruct %v4float +%_struct_1116 = OpTypeStruct %v4float %float %v4float +%_ptr_Uniform__struct_1116 = OpTypePointer Uniform %_struct_1116 + %22044 = OpVariable %_ptr_Uniform__struct_1116 Uniform + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 +%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float + %150 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_150 = OpTypePointer UniformConstant %150 + %5785 = OpVariable %_ptr_UniformConstant_150 UniformConstant + %508 = OpTypeSampler +%_ptr_UniformConstant_508 = OpTypePointer UniformConstant %508 + %5688 = OpVariable %_ptr_UniformConstant_508 UniformConstant + %510 = OpTypeSampledImage %150 + %float_0 = OpConstant %float 0 + %uint = OpTypeInt 32 0 + %int_1 = OpConstant %int 1 +%_ptr_Uniform_float = OpTypePointer Uniform %float + %float_1 = OpConstant %float 1 +%mat4v4float = OpTypeMatrix %v4float 4 +%_struct_994 = OpTypeStruct %v3float %v3float %float %v3float %float %v3float %float %v3float %float %v3float %float %v3float %float %v2float %v2float %v3float %float %float %float %float %float %v4float %v4float %mat4v4float %v4float +%_ptr_Uniform__struct_994 = OpTypePointer Uniform %_struct_994 + %12348 = OpVariable %_ptr_Uniform__struct_994 Uniform + %int_5 = OpConstant %int 5 +%_ptr_Uniform_v3float = OpTypePointer Uniform %v3float + %3312 = OpVariable %_ptr_UniformConstant_150 UniformConstant + %4646 = OpVariable %_ptr_UniformConstant_508 UniformConstant + %bool = OpTypeBool + %4862 = OpVariable %_ptr_UniformConstant_150 UniformConstant + %3594 = OpVariable %_ptr_UniformConstant_508 UniformConstant + %uint_2 = OpConstant %uint 2 + %2938 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0 +%_arr_mat4v4float_uint_2 = OpTypeArray %mat4v4float %uint_2 +%_arr_v4float_uint_2 = OpTypeArray %v4float %uint_2 +%_struct_408 = OpTypeStruct %mat4v4float %mat4v4float %mat4v4float %mat4v4float %v4float %v4float %float %float %float %float %v3float %float %v3float %float %v3float %float %v3float %float %float %float %v2float %v2float %v2float %v4float %v2float %v2float %v2float %v3float %float %float %float %float %float %v2float %float %float %v3float %_arr_mat4v4float_uint_2 %_arr_v4float_uint_2 +%_ptr_Uniform__struct_408 = OpTypePointer Uniform %_struct_408 + %15259 = OpVariable %_ptr_Uniform__struct_408 Uniform + %int_23 = OpConstant %int 23 + %int_2 = OpConstant %int 2 + %float_n2 = OpConstant %float -2 + %float_0_5 = OpConstant %float 0.5 + %1196 = OpConstantComposite %v3float %float_0 %float_n2 %float_0_5 + %float_n1 = OpConstant %float -1 + %836 = OpConstantComposite %v3float %float_n1 %float_n1 %float_0_5 + %float_0_75 = OpConstant %float 0.75 + %1367 = OpConstantComposite %v3float %float_0 %float_n1 %float_0_75 + %141 = OpConstantComposite %v3float %float_1 %float_n1 %float_0_5 + %38 = OpConstantComposite %v3float %float_n2 %float_0 %float_0_5 + %95 = OpConstantComposite %v3float %float_n1 %float_0 %float_0_75 + %626 = OpConstantComposite %v3float %float_0 %float_0 %float_1 + %2411 = OpConstantComposite %v3float %float_1 %float_0 %float_0_75 + %float_2 = OpConstant %float 2 + %2354 = OpConstantComposite %v3float %float_2 %float_0 %float_0_5 + %837 = OpConstantComposite %v3float %float_n1 %float_1 %float_0_5 + %1368 = OpConstantComposite %v3float %float_0 %float_1 %float_0_75 + %142 = OpConstantComposite %v3float %float_1 %float_1 %float_0_5 + %1197 = OpConstantComposite %v3float %float_0 %float_2 %float_0_5 +%_ptr_Input_v2float = OpTypePointer Input %v2float + %5800 = OpVariable %_ptr_Input_v2float Input +%_ptr_Input_v4float = OpTypePointer Input %v4float +%gl_FragCoord = OpVariable %_ptr_Input_v4float Input +%_ptr_Output_v4float = OpTypePointer Output %v4float + %4317 = OpVariable %_ptr_Output_v4float Output +%_struct_1395 = OpTypeStruct %v4float %v4float %v2float %v2float %v3float %float %v3float %float %v4float %v4float %v4float %v3float %float %v3float %float %v3float %v4float %v3float %float %v3float %v2float +%_struct_1018 = OpTypeStruct %v4float + %10264 = OpUndef %_struct_1017 + %5663 = OpFunction %void None %1282 + %25006 = OpLabel + %17463 = OpLoad %v4float %gl_FragCoord + %13863 = OpCompositeInsert %_struct_1017 %2938 %10264 0 + %22969 = OpVectorShuffle %v2float %17463 %17463 0 1 + %13206 = OpAccessChain %_ptr_Uniform_v4float %15259 %int_23 + %10343 = OpLoad %v4float %13206 + %7422 = OpVectorShuffle %v2float %10343 %10343 0 1 + %19927 = OpFMul %v2float %22969 %7422 + %18174 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_2 + %16206 = OpLoad %v4float %18174 + %20420 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 + %21354 = OpLoad %v4float %20420 + %7688 = OpVectorShuffle %v4float %21354 %21354 0 1 0 1 + %17581 = OpFMul %v4float %16206 %7688 + %10673 = OpVectorShuffle %v2float %1196 %1196 0 1 + %18824 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 + %10344 = OpLoad %v4float %18824 + %8638 = OpVectorShuffle %v2float %10344 %10344 0 1 + %9197 = OpFMul %v2float %10673 %8638 + %18505 = OpFAdd %v2float %19927 %9197 + %7011 = OpVectorShuffle %v2float %17581 %17581 0 1 + %21058 = OpVectorShuffle %v2float %17581 %17581 2 3 + %13149 = OpExtInst %v2float %1 FClamp %18505 %7011 %21058 + %23584 = OpLoad %150 %5785 + %10339 = OpLoad %508 %5688 + %12147 = OpSampledImage %510 %23584 %10339 + %15371 = OpImageSampleExplicitLod %v4float %12147 %13149 Lod %float_0 + %15266 = OpCompositeExtract %float %15371 3 + %12116 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 + %12972 = OpLoad %float %12116 + %15710 = OpFMul %float %15266 %12972 + %15279 = OpExtInst %float %1 FClamp %15710 %float_0 %float_1 + %22213 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 + %11756 = OpLoad %v3float %22213 + %12103 = OpVectorTimesScalar %v3float %11756 %15279 + %15516 = OpLoad %150 %3312 + %24569 = OpLoad %508 %4646 + %12148 = OpSampledImage %510 %15516 %24569 + %17670 = OpImageSampleExplicitLod %v4float %12148 %13149 Lod %float_0 + %16938 = OpCompositeExtract %float %17670 1 + %14185 = OpFOrdGreaterThan %bool %16938 %float_0 + OpSelectionMerge %22307 DontFlatten + OpBranchConditional %14185 %12821 %22307 + %12821 = OpLabel + %13239 = OpLoad %150 %4862 + %19960 = OpLoad %508 %3594 + %12149 = OpSampledImage %510 %13239 %19960 + %15675 = OpImageSampleExplicitLod %v4float %12149 %13149 Lod %float_0 + %13866 = OpCompositeExtract %float %17670 1 + %12427 = OpCompositeExtract %float %17670 2 + %23300 = OpFMul %float %13866 %12427 + %17612 = OpExtInst %float %1 FClamp %23300 %float_0 %float_1 + %20291 = OpVectorShuffle %v3float %15675 %15675 0 1 2 + %11186 = OpVectorTimesScalar %v3float %20291 %17612 + %15293 = OpFAdd %v3float %12103 %11186 + OpBranch %22307 + %22307 = OpLabel + %7719 = OpPhi %v3float %12103 %25006 %15293 %12821 + %23399 = OpVectorTimesScalar %v3float %7719 %float_0_5 + %9339 = OpFAdd %float %float_0 %float_0_5 + %16235 = OpVectorShuffle %v3float %2938 %2938 0 1 2 + %22177 = OpFAdd %v3float %16235 %23399 + %15527 = OpVectorShuffle %v4float %2938 %22177 4 5 6 3 + %6434 = OpCompositeInsert %_struct_1017 %15527 %13863 0 + %24572 = OpVectorShuffle %v2float %836 %836 0 1 + %13207 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 + %10345 = OpLoad %v4float %13207 + %8639 = OpVectorShuffle %v2float %10345 %10345 0 1 + %9198 = OpFMul %v2float %24572 %8639 + %18506 = OpFAdd %v2float %19927 %9198 + %7012 = OpVectorShuffle %v2float %17581 %17581 0 1 + %21059 = OpVectorShuffle %v2float %17581 %17581 2 3 + %13150 = OpExtInst %v2float %1 FClamp %18506 %7012 %21059 + %23585 = OpLoad %150 %5785 + %10340 = OpLoad %508 %5688 + %12150 = OpSampledImage %510 %23585 %10340 + %15372 = OpImageSampleExplicitLod %v4float %12150 %13150 Lod %float_0 + %15267 = OpCompositeExtract %float %15372 3 + %12117 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 + %12973 = OpLoad %float %12117 + %15711 = OpFMul %float %15267 %12973 + %15280 = OpExtInst %float %1 FClamp %15711 %float_0 %float_1 + %22214 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 + %11757 = OpLoad %v3float %22214 + %12104 = OpVectorTimesScalar %v3float %11757 %15280 + %15517 = OpLoad %150 %3312 + %24570 = OpLoad %508 %4646 + %12151 = OpSampledImage %510 %15517 %24570 + %17671 = OpImageSampleExplicitLod %v4float %12151 %13150 Lod %float_0 + %16939 = OpCompositeExtract %float %17671 1 + %14186 = OpFOrdGreaterThan %bool %16939 %float_0 + OpSelectionMerge %22308 DontFlatten + OpBranchConditional %14186 %12822 %22308 + %12822 = OpLabel + %13240 = OpLoad %150 %4862 + %19961 = OpLoad %508 %3594 + %12152 = OpSampledImage %510 %13240 %19961 + %15676 = OpImageSampleExplicitLod %v4float %12152 %13150 Lod %float_0 + %13867 = OpCompositeExtract %float %17671 1 + %12428 = OpCompositeExtract %float %17671 2 + %23301 = OpFMul %float %13867 %12428 + %17613 = OpExtInst %float %1 FClamp %23301 %float_0 %float_1 + %20292 = OpVectorShuffle %v3float %15676 %15676 0 1 2 + %11187 = OpVectorTimesScalar %v3float %20292 %17613 + %15294 = OpFAdd %v3float %12104 %11187 + OpBranch %22308 + %22308 = OpLabel + %7720 = OpPhi %v3float %12104 %22307 %15294 %12822 + %23400 = OpVectorTimesScalar %v3float %7720 %float_0_5 + %9340 = OpFAdd %float %9339 %float_0_5 + %16236 = OpVectorShuffle %v3float %15527 %15527 0 1 2 + %22178 = OpFAdd %v3float %16236 %23400 + %15528 = OpVectorShuffle %v4float %15527 %22178 4 5 6 3 + %6435 = OpCompositeInsert %_struct_1017 %15528 %6434 0 + %24573 = OpVectorShuffle %v2float %1367 %1367 0 1 + %13208 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 + %10346 = OpLoad %v4float %13208 + %8640 = OpVectorShuffle %v2float %10346 %10346 0 1 + %9199 = OpFMul %v2float %24573 %8640 + %18507 = OpFAdd %v2float %19927 %9199 + %7013 = OpVectorShuffle %v2float %17581 %17581 0 1 + %21060 = OpVectorShuffle %v2float %17581 %17581 2 3 + %13151 = OpExtInst %v2float %1 FClamp %18507 %7013 %21060 + %23586 = OpLoad %150 %5785 + %10341 = OpLoad %508 %5688 + %12153 = OpSampledImage %510 %23586 %10341 + %15373 = OpImageSampleExplicitLod %v4float %12153 %13151 Lod %float_0 + %15268 = OpCompositeExtract %float %15373 3 + %12118 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 + %12974 = OpLoad %float %12118 + %15712 = OpFMul %float %15268 %12974 + %15281 = OpExtInst %float %1 FClamp %15712 %float_0 %float_1 + %22215 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 + %11758 = OpLoad %v3float %22215 + %12105 = OpVectorTimesScalar %v3float %11758 %15281 + %15518 = OpLoad %150 %3312 + %24571 = OpLoad %508 %4646 + %12154 = OpSampledImage %510 %15518 %24571 + %17672 = OpImageSampleExplicitLod %v4float %12154 %13151 Lod %float_0 + %16940 = OpCompositeExtract %float %17672 1 + %14187 = OpFOrdGreaterThan %bool %16940 %float_0 + OpSelectionMerge %22309 DontFlatten + OpBranchConditional %14187 %12823 %22309 + %12823 = OpLabel + %13241 = OpLoad %150 %4862 + %19962 = OpLoad %508 %3594 + %12155 = OpSampledImage %510 %13241 %19962 + %15677 = OpImageSampleExplicitLod %v4float %12155 %13151 Lod %float_0 + %13868 = OpCompositeExtract %float %17672 1 + %12429 = OpCompositeExtract %float %17672 2 + %23302 = OpFMul %float %13868 %12429 + %17614 = OpExtInst %float %1 FClamp %23302 %float_0 %float_1 + %20293 = OpVectorShuffle %v3float %15677 %15677 0 1 2 + %11188 = OpVectorTimesScalar %v3float %20293 %17614 + %15295 = OpFAdd %v3float %12105 %11188 + OpBranch %22309 + %22309 = OpLabel + %7721 = OpPhi %v3float %12105 %22308 %15295 %12823 + %23401 = OpVectorTimesScalar %v3float %7721 %float_0_75 + %9341 = OpFAdd %float %9340 %float_0_75 + %16237 = OpVectorShuffle %v3float %15528 %15528 0 1 2 + %22179 = OpFAdd %v3float %16237 %23401 + %15529 = OpVectorShuffle %v4float %15528 %22179 4 5 6 3 + %6436 = OpCompositeInsert %_struct_1017 %15529 %6435 0 + %24574 = OpVectorShuffle %v2float %141 %141 0 1 + %13209 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 + %10347 = OpLoad %v4float %13209 + %8641 = OpVectorShuffle %v2float %10347 %10347 0 1 + %9200 = OpFMul %v2float %24574 %8641 + %18508 = OpFAdd %v2float %19927 %9200 + %7014 = OpVectorShuffle %v2float %17581 %17581 0 1 + %21061 = OpVectorShuffle %v2float %17581 %17581 2 3 + %13152 = OpExtInst %v2float %1 FClamp %18508 %7014 %21061 + %23587 = OpLoad %150 %5785 + %10342 = OpLoad %508 %5688 + %12156 = OpSampledImage %510 %23587 %10342 + %15374 = OpImageSampleExplicitLod %v4float %12156 %13152 Lod %float_0 + %15269 = OpCompositeExtract %float %15374 3 + %12119 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 + %12975 = OpLoad %float %12119 + %15713 = OpFMul %float %15269 %12975 + %15282 = OpExtInst %float %1 FClamp %15713 %float_0 %float_1 + %22216 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 + %11759 = OpLoad %v3float %22216 + %12106 = OpVectorTimesScalar %v3float %11759 %15282 + %15519 = OpLoad %150 %3312 + %24575 = OpLoad %508 %4646 + %12157 = OpSampledImage %510 %15519 %24575 + %17673 = OpImageSampleExplicitLod %v4float %12157 %13152 Lod %float_0 + %16941 = OpCompositeExtract %float %17673 1 + %14188 = OpFOrdGreaterThan %bool %16941 %float_0 + OpSelectionMerge %22310 DontFlatten + OpBranchConditional %14188 %12824 %22310 + %12824 = OpLabel + %13242 = OpLoad %150 %4862 + %19963 = OpLoad %508 %3594 + %12158 = OpSampledImage %510 %13242 %19963 + %15678 = OpImageSampleExplicitLod %v4float %12158 %13152 Lod %float_0 + %13869 = OpCompositeExtract %float %17673 1 + %12430 = OpCompositeExtract %float %17673 2 + %23303 = OpFMul %float %13869 %12430 + %17615 = OpExtInst %float %1 FClamp %23303 %float_0 %float_1 + %20294 = OpVectorShuffle %v3float %15678 %15678 0 1 2 + %11189 = OpVectorTimesScalar %v3float %20294 %17615 + %15296 = OpFAdd %v3float %12106 %11189 + OpBranch %22310 + %22310 = OpLabel + %7722 = OpPhi %v3float %12106 %22309 %15296 %12824 + %23402 = OpVectorTimesScalar %v3float %7722 %float_0_5 + %9342 = OpFAdd %float %9341 %float_0_5 + %16238 = OpVectorShuffle %v3float %15529 %15529 0 1 2 + %22180 = OpFAdd %v3float %16238 %23402 + %15530 = OpVectorShuffle %v4float %15529 %22180 4 5 6 3 + %6437 = OpCompositeInsert %_struct_1017 %15530 %6436 0 + %24576 = OpVectorShuffle %v2float %38 %38 0 1 + %13210 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 + %10348 = OpLoad %v4float %13210 + %8642 = OpVectorShuffle %v2float %10348 %10348 0 1 + %9201 = OpFMul %v2float %24576 %8642 + %18509 = OpFAdd %v2float %19927 %9201 + %7015 = OpVectorShuffle %v2float %17581 %17581 0 1 + %21062 = OpVectorShuffle %v2float %17581 %17581 2 3 + %13153 = OpExtInst %v2float %1 FClamp %18509 %7015 %21062 + %23588 = OpLoad %150 %5785 + %10349 = OpLoad %508 %5688 + %12159 = OpSampledImage %510 %23588 %10349 + %15375 = OpImageSampleExplicitLod %v4float %12159 %13153 Lod %float_0 + %15270 = OpCompositeExtract %float %15375 3 + %12120 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 + %12976 = OpLoad %float %12120 + %15714 = OpFMul %float %15270 %12976 + %15283 = OpExtInst %float %1 FClamp %15714 %float_0 %float_1 + %22217 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 + %11760 = OpLoad %v3float %22217 + %12107 = OpVectorTimesScalar %v3float %11760 %15283 + %15520 = OpLoad %150 %3312 + %24577 = OpLoad %508 %4646 + %12160 = OpSampledImage %510 %15520 %24577 + %17674 = OpImageSampleExplicitLod %v4float %12160 %13153 Lod %float_0 + %16942 = OpCompositeExtract %float %17674 1 + %14189 = OpFOrdGreaterThan %bool %16942 %float_0 + OpSelectionMerge %22311 DontFlatten + OpBranchConditional %14189 %12825 %22311 + %12825 = OpLabel + %13243 = OpLoad %150 %4862 + %19964 = OpLoad %508 %3594 + %12161 = OpSampledImage %510 %13243 %19964 + %15679 = OpImageSampleExplicitLod %v4float %12161 %13153 Lod %float_0 + %13870 = OpCompositeExtract %float %17674 1 + %12431 = OpCompositeExtract %float %17674 2 + %23304 = OpFMul %float %13870 %12431 + %17616 = OpExtInst %float %1 FClamp %23304 %float_0 %float_1 + %20295 = OpVectorShuffle %v3float %15679 %15679 0 1 2 + %11190 = OpVectorTimesScalar %v3float %20295 %17616 + %15297 = OpFAdd %v3float %12107 %11190 + OpBranch %22311 + %22311 = OpLabel + %7723 = OpPhi %v3float %12107 %22310 %15297 %12825 + %23403 = OpVectorTimesScalar %v3float %7723 %float_0_5 + %9343 = OpFAdd %float %9342 %float_0_5 + %16239 = OpVectorShuffle %v3float %15530 %15530 0 1 2 + %22181 = OpFAdd %v3float %16239 %23403 + %15531 = OpVectorShuffle %v4float %15530 %22181 4 5 6 3 + %6438 = OpCompositeInsert %_struct_1017 %15531 %6437 0 + %24578 = OpVectorShuffle %v2float %95 %95 0 1 + %13211 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 + %10350 = OpLoad %v4float %13211 + %8643 = OpVectorShuffle %v2float %10350 %10350 0 1 + %9202 = OpFMul %v2float %24578 %8643 + %18510 = OpFAdd %v2float %19927 %9202 + %7016 = OpVectorShuffle %v2float %17581 %17581 0 1 + %21063 = OpVectorShuffle %v2float %17581 %17581 2 3 + %13154 = OpExtInst %v2float %1 FClamp %18510 %7016 %21063 + %23589 = OpLoad %150 %5785 + %10351 = OpLoad %508 %5688 + %12162 = OpSampledImage %510 %23589 %10351 + %15376 = OpImageSampleExplicitLod %v4float %12162 %13154 Lod %float_0 + %15271 = OpCompositeExtract %float %15376 3 + %12121 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 + %12977 = OpLoad %float %12121 + %15715 = OpFMul %float %15271 %12977 + %15284 = OpExtInst %float %1 FClamp %15715 %float_0 %float_1 + %22218 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 + %11761 = OpLoad %v3float %22218 + %12108 = OpVectorTimesScalar %v3float %11761 %15284 + %15521 = OpLoad %150 %3312 + %24579 = OpLoad %508 %4646 + %12163 = OpSampledImage %510 %15521 %24579 + %17675 = OpImageSampleExplicitLod %v4float %12163 %13154 Lod %float_0 + %16943 = OpCompositeExtract %float %17675 1 + %14190 = OpFOrdGreaterThan %bool %16943 %float_0 + OpSelectionMerge %22312 DontFlatten + OpBranchConditional %14190 %12826 %22312 + %12826 = OpLabel + %13244 = OpLoad %150 %4862 + %19965 = OpLoad %508 %3594 + %12164 = OpSampledImage %510 %13244 %19965 + %15680 = OpImageSampleExplicitLod %v4float %12164 %13154 Lod %float_0 + %13871 = OpCompositeExtract %float %17675 1 + %12432 = OpCompositeExtract %float %17675 2 + %23305 = OpFMul %float %13871 %12432 + %17617 = OpExtInst %float %1 FClamp %23305 %float_0 %float_1 + %20296 = OpVectorShuffle %v3float %15680 %15680 0 1 2 + %11191 = OpVectorTimesScalar %v3float %20296 %17617 + %15298 = OpFAdd %v3float %12108 %11191 + OpBranch %22312 + %22312 = OpLabel + %7724 = OpPhi %v3float %12108 %22311 %15298 %12826 + %23404 = OpVectorTimesScalar %v3float %7724 %float_0_75 + %9344 = OpFAdd %float %9343 %float_0_75 + %16240 = OpVectorShuffle %v3float %15531 %15531 0 1 2 + %22182 = OpFAdd %v3float %16240 %23404 + %15532 = OpVectorShuffle %v4float %15531 %22182 4 5 6 3 + %6439 = OpCompositeInsert %_struct_1017 %15532 %6438 0 + %24580 = OpVectorShuffle %v2float %626 %626 0 1 + %13212 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 + %10352 = OpLoad %v4float %13212 + %8644 = OpVectorShuffle %v2float %10352 %10352 0 1 + %9203 = OpFMul %v2float %24580 %8644 + %18511 = OpFAdd %v2float %19927 %9203 + %7017 = OpVectorShuffle %v2float %17581 %17581 0 1 + %21064 = OpVectorShuffle %v2float %17581 %17581 2 3 + %13155 = OpExtInst %v2float %1 FClamp %18511 %7017 %21064 + %23590 = OpLoad %150 %5785 + %10353 = OpLoad %508 %5688 + %12165 = OpSampledImage %510 %23590 %10353 + %15377 = OpImageSampleExplicitLod %v4float %12165 %13155 Lod %float_0 + %15272 = OpCompositeExtract %float %15377 3 + %12122 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 + %12978 = OpLoad %float %12122 + %15716 = OpFMul %float %15272 %12978 + %15285 = OpExtInst %float %1 FClamp %15716 %float_0 %float_1 + %22219 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 + %11762 = OpLoad %v3float %22219 + %12109 = OpVectorTimesScalar %v3float %11762 %15285 + %15522 = OpLoad %150 %3312 + %24581 = OpLoad %508 %4646 + %12166 = OpSampledImage %510 %15522 %24581 + %17676 = OpImageSampleExplicitLod %v4float %12166 %13155 Lod %float_0 + %16944 = OpCompositeExtract %float %17676 1 + %14191 = OpFOrdGreaterThan %bool %16944 %float_0 + OpSelectionMerge %22313 DontFlatten + OpBranchConditional %14191 %12827 %22313 + %12827 = OpLabel + %13245 = OpLoad %150 %4862 + %19966 = OpLoad %508 %3594 + %12167 = OpSampledImage %510 %13245 %19966 + %15681 = OpImageSampleExplicitLod %v4float %12167 %13155 Lod %float_0 + %13872 = OpCompositeExtract %float %17676 1 + %12433 = OpCompositeExtract %float %17676 2 + %23306 = OpFMul %float %13872 %12433 + %17618 = OpExtInst %float %1 FClamp %23306 %float_0 %float_1 + %20297 = OpVectorShuffle %v3float %15681 %15681 0 1 2 + %11192 = OpVectorTimesScalar %v3float %20297 %17618 + %15299 = OpFAdd %v3float %12109 %11192 + OpBranch %22313 + %22313 = OpLabel + %7725 = OpPhi %v3float %12109 %22312 %15299 %12827 + %23405 = OpVectorTimesScalar %v3float %7725 %float_1 + %9345 = OpFAdd %float %9344 %float_1 + %16241 = OpVectorShuffle %v3float %15532 %15532 0 1 2 + %22183 = OpFAdd %v3float %16241 %23405 + %15533 = OpVectorShuffle %v4float %15532 %22183 4 5 6 3 + %6440 = OpCompositeInsert %_struct_1017 %15533 %6439 0 + %24582 = OpVectorShuffle %v2float %2411 %2411 0 1 + %13213 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 + %10354 = OpLoad %v4float %13213 + %8645 = OpVectorShuffle %v2float %10354 %10354 0 1 + %9204 = OpFMul %v2float %24582 %8645 + %18512 = OpFAdd %v2float %19927 %9204 + %7018 = OpVectorShuffle %v2float %17581 %17581 0 1 + %21065 = OpVectorShuffle %v2float %17581 %17581 2 3 + %13156 = OpExtInst %v2float %1 FClamp %18512 %7018 %21065 + %23591 = OpLoad %150 %5785 + %10355 = OpLoad %508 %5688 + %12168 = OpSampledImage %510 %23591 %10355 + %15378 = OpImageSampleExplicitLod %v4float %12168 %13156 Lod %float_0 + %15273 = OpCompositeExtract %float %15378 3 + %12123 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 + %12979 = OpLoad %float %12123 + %15717 = OpFMul %float %15273 %12979 + %15286 = OpExtInst %float %1 FClamp %15717 %float_0 %float_1 + %22220 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 + %11763 = OpLoad %v3float %22220 + %12110 = OpVectorTimesScalar %v3float %11763 %15286 + %15523 = OpLoad %150 %3312 + %24583 = OpLoad %508 %4646 + %12169 = OpSampledImage %510 %15523 %24583 + %17677 = OpImageSampleExplicitLod %v4float %12169 %13156 Lod %float_0 + %16945 = OpCompositeExtract %float %17677 1 + %14192 = OpFOrdGreaterThan %bool %16945 %float_0 + OpSelectionMerge %22314 DontFlatten + OpBranchConditional %14192 %12828 %22314 + %12828 = OpLabel + %13246 = OpLoad %150 %4862 + %19967 = OpLoad %508 %3594 + %12170 = OpSampledImage %510 %13246 %19967 + %15682 = OpImageSampleExplicitLod %v4float %12170 %13156 Lod %float_0 + %13873 = OpCompositeExtract %float %17677 1 + %12434 = OpCompositeExtract %float %17677 2 + %23307 = OpFMul %float %13873 %12434 + %17619 = OpExtInst %float %1 FClamp %23307 %float_0 %float_1 + %20298 = OpVectorShuffle %v3float %15682 %15682 0 1 2 + %11193 = OpVectorTimesScalar %v3float %20298 %17619 + %15300 = OpFAdd %v3float %12110 %11193 + OpBranch %22314 + %22314 = OpLabel + %7726 = OpPhi %v3float %12110 %22313 %15300 %12828 + %23406 = OpVectorTimesScalar %v3float %7726 %float_0_75 + %9346 = OpFAdd %float %9345 %float_0_75 + %16242 = OpVectorShuffle %v3float %15533 %15533 0 1 2 + %22184 = OpFAdd %v3float %16242 %23406 + %15534 = OpVectorShuffle %v4float %15533 %22184 4 5 6 3 + %6441 = OpCompositeInsert %_struct_1017 %15534 %6440 0 + %24584 = OpVectorShuffle %v2float %2354 %2354 0 1 + %13214 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 + %10356 = OpLoad %v4float %13214 + %8646 = OpVectorShuffle %v2float %10356 %10356 0 1 + %9205 = OpFMul %v2float %24584 %8646 + %18513 = OpFAdd %v2float %19927 %9205 + %7019 = OpVectorShuffle %v2float %17581 %17581 0 1 + %21066 = OpVectorShuffle %v2float %17581 %17581 2 3 + %13157 = OpExtInst %v2float %1 FClamp %18513 %7019 %21066 + %23592 = OpLoad %150 %5785 + %10357 = OpLoad %508 %5688 + %12171 = OpSampledImage %510 %23592 %10357 + %15379 = OpImageSampleExplicitLod %v4float %12171 %13157 Lod %float_0 + %15274 = OpCompositeExtract %float %15379 3 + %12124 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 + %12980 = OpLoad %float %12124 + %15718 = OpFMul %float %15274 %12980 + %15287 = OpExtInst %float %1 FClamp %15718 %float_0 %float_1 + %22221 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 + %11764 = OpLoad %v3float %22221 + %12111 = OpVectorTimesScalar %v3float %11764 %15287 + %15524 = OpLoad %150 %3312 + %24585 = OpLoad %508 %4646 + %12172 = OpSampledImage %510 %15524 %24585 + %17678 = OpImageSampleExplicitLod %v4float %12172 %13157 Lod %float_0 + %16946 = OpCompositeExtract %float %17678 1 + %14193 = OpFOrdGreaterThan %bool %16946 %float_0 + OpSelectionMerge %22315 DontFlatten + OpBranchConditional %14193 %12829 %22315 + %12829 = OpLabel + %13247 = OpLoad %150 %4862 + %19968 = OpLoad %508 %3594 + %12173 = OpSampledImage %510 %13247 %19968 + %15683 = OpImageSampleExplicitLod %v4float %12173 %13157 Lod %float_0 + %13874 = OpCompositeExtract %float %17678 1 + %12435 = OpCompositeExtract %float %17678 2 + %23308 = OpFMul %float %13874 %12435 + %17620 = OpExtInst %float %1 FClamp %23308 %float_0 %float_1 + %20299 = OpVectorShuffle %v3float %15683 %15683 0 1 2 + %11194 = OpVectorTimesScalar %v3float %20299 %17620 + %15301 = OpFAdd %v3float %12111 %11194 + OpBranch %22315 + %22315 = OpLabel + %7727 = OpPhi %v3float %12111 %22314 %15301 %12829 + %23407 = OpVectorTimesScalar %v3float %7727 %float_0_5 + %9347 = OpFAdd %float %9346 %float_0_5 + %16243 = OpVectorShuffle %v3float %15534 %15534 0 1 2 + %22185 = OpFAdd %v3float %16243 %23407 + %15535 = OpVectorShuffle %v4float %15534 %22185 4 5 6 3 + %6442 = OpCompositeInsert %_struct_1017 %15535 %6441 0 + %24586 = OpVectorShuffle %v2float %837 %837 0 1 + %13215 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 + %10358 = OpLoad %v4float %13215 + %8647 = OpVectorShuffle %v2float %10358 %10358 0 1 + %9206 = OpFMul %v2float %24586 %8647 + %18514 = OpFAdd %v2float %19927 %9206 + %7020 = OpVectorShuffle %v2float %17581 %17581 0 1 + %21067 = OpVectorShuffle %v2float %17581 %17581 2 3 + %13158 = OpExtInst %v2float %1 FClamp %18514 %7020 %21067 + %23593 = OpLoad %150 %5785 + %10359 = OpLoad %508 %5688 + %12174 = OpSampledImage %510 %23593 %10359 + %15380 = OpImageSampleExplicitLod %v4float %12174 %13158 Lod %float_0 + %15275 = OpCompositeExtract %float %15380 3 + %12125 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 + %12981 = OpLoad %float %12125 + %15719 = OpFMul %float %15275 %12981 + %15288 = OpExtInst %float %1 FClamp %15719 %float_0 %float_1 + %22222 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 + %11765 = OpLoad %v3float %22222 + %12112 = OpVectorTimesScalar %v3float %11765 %15288 + %15525 = OpLoad %150 %3312 + %24587 = OpLoad %508 %4646 + %12175 = OpSampledImage %510 %15525 %24587 + %17679 = OpImageSampleExplicitLod %v4float %12175 %13158 Lod %float_0 + %16947 = OpCompositeExtract %float %17679 1 + %14194 = OpFOrdGreaterThan %bool %16947 %float_0 + OpSelectionMerge %22316 DontFlatten + OpBranchConditional %14194 %12830 %22316 + %12830 = OpLabel + %13248 = OpLoad %150 %4862 + %19969 = OpLoad %508 %3594 + %12176 = OpSampledImage %510 %13248 %19969 + %15684 = OpImageSampleExplicitLod %v4float %12176 %13158 Lod %float_0 + %13875 = OpCompositeExtract %float %17679 1 + %12436 = OpCompositeExtract %float %17679 2 + %23309 = OpFMul %float %13875 %12436 + %17621 = OpExtInst %float %1 FClamp %23309 %float_0 %float_1 + %20300 = OpVectorShuffle %v3float %15684 %15684 0 1 2 + %11195 = OpVectorTimesScalar %v3float %20300 %17621 + %15302 = OpFAdd %v3float %12112 %11195 + OpBranch %22316 + %22316 = OpLabel + %7728 = OpPhi %v3float %12112 %22315 %15302 %12830 + %23408 = OpVectorTimesScalar %v3float %7728 %float_0_5 + %9348 = OpFAdd %float %9347 %float_0_5 + %16244 = OpVectorShuffle %v3float %15535 %15535 0 1 2 + %22186 = OpFAdd %v3float %16244 %23408 + %15536 = OpVectorShuffle %v4float %15535 %22186 4 5 6 3 + %6443 = OpCompositeInsert %_struct_1017 %15536 %6442 0 + %24588 = OpVectorShuffle %v2float %1368 %1368 0 1 + %13216 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 + %10360 = OpLoad %v4float %13216 + %8648 = OpVectorShuffle %v2float %10360 %10360 0 1 + %9207 = OpFMul %v2float %24588 %8648 + %18515 = OpFAdd %v2float %19927 %9207 + %7021 = OpVectorShuffle %v2float %17581 %17581 0 1 + %21068 = OpVectorShuffle %v2float %17581 %17581 2 3 + %13159 = OpExtInst %v2float %1 FClamp %18515 %7021 %21068 + %23594 = OpLoad %150 %5785 + %10361 = OpLoad %508 %5688 + %12177 = OpSampledImage %510 %23594 %10361 + %15381 = OpImageSampleExplicitLod %v4float %12177 %13159 Lod %float_0 + %15276 = OpCompositeExtract %float %15381 3 + %12126 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 + %12982 = OpLoad %float %12126 + %15720 = OpFMul %float %15276 %12982 + %15289 = OpExtInst %float %1 FClamp %15720 %float_0 %float_1 + %22223 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 + %11766 = OpLoad %v3float %22223 + %12113 = OpVectorTimesScalar %v3float %11766 %15289 + %15526 = OpLoad %150 %3312 + %24589 = OpLoad %508 %4646 + %12178 = OpSampledImage %510 %15526 %24589 + %17680 = OpImageSampleExplicitLod %v4float %12178 %13159 Lod %float_0 + %16948 = OpCompositeExtract %float %17680 1 + %14195 = OpFOrdGreaterThan %bool %16948 %float_0 + OpSelectionMerge %22317 DontFlatten + OpBranchConditional %14195 %12831 %22317 + %12831 = OpLabel + %13249 = OpLoad %150 %4862 + %19970 = OpLoad %508 %3594 + %12179 = OpSampledImage %510 %13249 %19970 + %15685 = OpImageSampleExplicitLod %v4float %12179 %13159 Lod %float_0 + %13876 = OpCompositeExtract %float %17680 1 + %12437 = OpCompositeExtract %float %17680 2 + %23310 = OpFMul %float %13876 %12437 + %17622 = OpExtInst %float %1 FClamp %23310 %float_0 %float_1 + %20301 = OpVectorShuffle %v3float %15685 %15685 0 1 2 + %11196 = OpVectorTimesScalar %v3float %20301 %17622 + %15303 = OpFAdd %v3float %12113 %11196 + OpBranch %22317 + %22317 = OpLabel + %7729 = OpPhi %v3float %12113 %22316 %15303 %12831 + %23409 = OpVectorTimesScalar %v3float %7729 %float_0_75 + %9349 = OpFAdd %float %9348 %float_0_75 + %16245 = OpVectorShuffle %v3float %15536 %15536 0 1 2 + %22187 = OpFAdd %v3float %16245 %23409 + %15537 = OpVectorShuffle %v4float %15536 %22187 4 5 6 3 + %6444 = OpCompositeInsert %_struct_1017 %15537 %6443 0 + %24590 = OpVectorShuffle %v2float %142 %142 0 1 + %13217 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 + %10362 = OpLoad %v4float %13217 + %8649 = OpVectorShuffle %v2float %10362 %10362 0 1 + %9208 = OpFMul %v2float %24590 %8649 + %18516 = OpFAdd %v2float %19927 %9208 + %7022 = OpVectorShuffle %v2float %17581 %17581 0 1 + %21069 = OpVectorShuffle %v2float %17581 %17581 2 3 + %13160 = OpExtInst %v2float %1 FClamp %18516 %7022 %21069 + %23595 = OpLoad %150 %5785 + %10363 = OpLoad %508 %5688 + %12180 = OpSampledImage %510 %23595 %10363 + %15382 = OpImageSampleExplicitLod %v4float %12180 %13160 Lod %float_0 + %15277 = OpCompositeExtract %float %15382 3 + %12127 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 + %12983 = OpLoad %float %12127 + %15721 = OpFMul %float %15277 %12983 + %15290 = OpExtInst %float %1 FClamp %15721 %float_0 %float_1 + %22224 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 + %11767 = OpLoad %v3float %22224 + %12114 = OpVectorTimesScalar %v3float %11767 %15290 + %15538 = OpLoad %150 %3312 + %24591 = OpLoad %508 %4646 + %12181 = OpSampledImage %510 %15538 %24591 + %17681 = OpImageSampleExplicitLod %v4float %12181 %13160 Lod %float_0 + %16949 = OpCompositeExtract %float %17681 1 + %14196 = OpFOrdGreaterThan %bool %16949 %float_0 + OpSelectionMerge %22318 DontFlatten + OpBranchConditional %14196 %12832 %22318 + %12832 = OpLabel + %13250 = OpLoad %150 %4862 + %19971 = OpLoad %508 %3594 + %12182 = OpSampledImage %510 %13250 %19971 + %15686 = OpImageSampleExplicitLod %v4float %12182 %13160 Lod %float_0 + %13877 = OpCompositeExtract %float %17681 1 + %12438 = OpCompositeExtract %float %17681 2 + %23311 = OpFMul %float %13877 %12438 + %17623 = OpExtInst %float %1 FClamp %23311 %float_0 %float_1 + %20302 = OpVectorShuffle %v3float %15686 %15686 0 1 2 + %11197 = OpVectorTimesScalar %v3float %20302 %17623 + %15304 = OpFAdd %v3float %12114 %11197 + OpBranch %22318 + %22318 = OpLabel + %7730 = OpPhi %v3float %12114 %22317 %15304 %12832 + %23410 = OpVectorTimesScalar %v3float %7730 %float_0_5 + %9350 = OpFAdd %float %9349 %float_0_5 + %16246 = OpVectorShuffle %v3float %15537 %15537 0 1 2 + %22188 = OpFAdd %v3float %16246 %23410 + %15539 = OpVectorShuffle %v4float %15537 %22188 4 5 6 3 + %6445 = OpCompositeInsert %_struct_1017 %15539 %6444 0 + %24592 = OpVectorShuffle %v2float %1197 %1197 0 1 + %13218 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 + %10364 = OpLoad %v4float %13218 + %8650 = OpVectorShuffle %v2float %10364 %10364 0 1 + %9209 = OpFMul %v2float %24592 %8650 + %18517 = OpFAdd %v2float %19927 %9209 + %7023 = OpVectorShuffle %v2float %17581 %17581 0 1 + %21070 = OpVectorShuffle %v2float %17581 %17581 2 3 + %13161 = OpExtInst %v2float %1 FClamp %18517 %7023 %21070 + %23596 = OpLoad %150 %5785 + %10365 = OpLoad %508 %5688 + %12183 = OpSampledImage %510 %23596 %10365 + %15383 = OpImageSampleExplicitLod %v4float %12183 %13161 Lod %float_0 + %15278 = OpCompositeExtract %float %15383 3 + %12128 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 + %12984 = OpLoad %float %12128 + %15722 = OpFMul %float %15278 %12984 + %15291 = OpExtInst %float %1 FClamp %15722 %float_0 %float_1 + %22225 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 + %11768 = OpLoad %v3float %22225 + %12115 = OpVectorTimesScalar %v3float %11768 %15291 + %15540 = OpLoad %150 %3312 + %24593 = OpLoad %508 %4646 + %12184 = OpSampledImage %510 %15540 %24593 + %17682 = OpImageSampleExplicitLod %v4float %12184 %13161 Lod %float_0 + %16950 = OpCompositeExtract %float %17682 1 + %14197 = OpFOrdGreaterThan %bool %16950 %float_0 + OpSelectionMerge %22319 DontFlatten + OpBranchConditional %14197 %12833 %22319 + %12833 = OpLabel + %13251 = OpLoad %150 %4862 + %19972 = OpLoad %508 %3594 + %12185 = OpSampledImage %510 %13251 %19972 + %15687 = OpImageSampleExplicitLod %v4float %12185 %13161 Lod %float_0 + %13878 = OpCompositeExtract %float %17682 1 + %12439 = OpCompositeExtract %float %17682 2 + %23312 = OpFMul %float %13878 %12439 + %17624 = OpExtInst %float %1 FClamp %23312 %float_0 %float_1 + %20303 = OpVectorShuffle %v3float %15687 %15687 0 1 2 + %11198 = OpVectorTimesScalar %v3float %20303 %17624 + %15305 = OpFAdd %v3float %12115 %11198 + OpBranch %22319 + %22319 = OpLabel + %7731 = OpPhi %v3float %12115 %22318 %15305 %12833 + %23411 = OpVectorTimesScalar %v3float %7731 %float_0_5 + %9351 = OpFAdd %float %9350 %float_0_5 + %16247 = OpVectorShuffle %v3float %15539 %15539 0 1 2 + %22189 = OpFAdd %v3float %16247 %23411 + %15541 = OpVectorShuffle %v4float %15539 %22189 4 5 6 3 + %6719 = OpCompositeInsert %_struct_1017 %15541 %6445 0 + %23412 = OpVectorShuffle %v3float %15541 %15541 0 1 2 + %10833 = OpCompositeConstruct %v3float %9351 %9351 %9351 + %13750 = OpFDiv %v3float %23412 %10833 + %24033 = OpVectorShuffle %v4float %15541 %13750 4 5 6 3 + %8636 = OpCompositeInsert %_struct_1017 %24033 %6719 0 + %16315 = OpCompositeInsert %_struct_1017 %float_1 %8636 0 3 + %11544 = OpCompositeExtract %v4float %16315 0 + OpStore %4317 %11544 + OpReturn + OpFunctionEnd diff --git a/shaders-msl/asm/vert/empty-struct-composite.asm.vert b/shaders-msl/asm/vert/empty-struct-composite.asm.vert new file mode 100644 index 0000000000..37a2d87937 --- /dev/null +++ b/shaders-msl/asm/vert/empty-struct-composite.asm.vert @@ -0,0 +1,37 @@ +; SPIR-V +; Version: 1.1 +; Generator: Google rspirv; 0 +; Bound: 17 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %2 "main" + OpExecutionMode %2 OriginUpperLeft + OpName %Test "Test" + OpName %t "t" + OpName %retvar "retvar" + OpName %main "main" + OpName %retvar_0 "retvar" + %void = OpTypeVoid + %6 = OpTypeFunction %void + %Test = OpTypeStruct +%_ptr_Function_Test = OpTypePointer Function %Test +%_ptr_Function_void = OpTypePointer Function %void + %2 = OpFunction %void None %6 + %7 = OpLabel + %t = OpVariable %_ptr_Function_Test Function + %retvar = OpVariable %_ptr_Function_void Function + OpBranch %4 + %4 = OpLabel + %13 = OpCompositeConstruct %Test + OpStore %t %13 + OpReturn + OpFunctionEnd + %main = OpFunction %void None %6 + %15 = OpLabel + %retvar_0 = OpVariable %_ptr_Function_void Function + OpBranch %14 + %14 = OpLabel + OpReturn + OpFunctionEnd diff --git a/shaders-msl/comp/atomic.comp b/shaders-msl/comp/atomic.comp new file mode 100644 index 0000000000..417284d5de --- /dev/null +++ b/shaders-msl/comp/atomic.comp @@ -0,0 +1,33 @@ +#version 310 es +#extension GL_OES_shader_image_atomic : require +layout(local_size_x = 1) in; + +layout(r32ui, binding = 0) uniform highp uimage2D uImage; +layout(r32i, binding = 1) uniform highp iimage2D iImage; +layout(binding = 2, std430) buffer SSBO +{ + uint u32; + int i32; +} ssbo; + +void main() +{ + atomicAdd(ssbo.u32, 1u); + atomicOr(ssbo.u32, 1u); + atomicXor(ssbo.u32, 1u); + atomicAnd(ssbo.u32, 1u); + atomicMin(ssbo.u32, 1u); + atomicMax(ssbo.u32, 1u); + atomicExchange(ssbo.u32, 1u); + atomicCompSwap(ssbo.u32, 10u, 2u); + + atomicAdd(ssbo.i32, 1); + atomicOr(ssbo.i32, 1); + atomicXor(ssbo.i32, 1); + atomicAnd(ssbo.i32, 1); + atomicMin(ssbo.i32, 1); + atomicMax(ssbo.i32, 1); + atomicExchange(ssbo.i32, 1); + atomicCompSwap(ssbo.i32, 10, 2); +} + diff --git a/shaders-msl/comp/barriers.comp b/shaders-msl/comp/barriers.comp new file mode 100644 index 0000000000..c49b626363 --- /dev/null +++ b/shaders-msl/comp/barriers.comp @@ -0,0 +1,83 @@ +#version 310 es +layout(local_size_x = 4) in; + +void barrier_shared() +{ + memoryBarrierShared(); +} + +void full_barrier() +{ + memoryBarrier(); +} + +#if 0 +void image_barrier() +{ + memoryBarrierImage(); +} +#endif + +void buffer_barrier() +{ + memoryBarrierBuffer(); +} + +void group_barrier() +{ + groupMemoryBarrier(); +} + +void barrier_shared_exec() +{ + memoryBarrierShared(); + barrier(); +} + +void full_barrier_exec() +{ + memoryBarrier(); + barrier(); +} + +#if 0 +void image_barrier_exec() +{ + memoryBarrierImage(); + barrier(); +} +#endif + +void buffer_barrier_exec() +{ + memoryBarrierBuffer(); + barrier(); +} + +void group_barrier_exec() +{ + groupMemoryBarrier(); + barrier(); +} + +void exec_barrier() +{ + barrier(); +} + +void main() +{ + barrier_shared(); + full_barrier(); + //image_barrier(); + buffer_barrier(); + group_barrier(); + + barrier_shared_exec(); + full_barrier_exec(); + //image_barrier_exec(); + buffer_barrier_exec(); + group_barrier_exec(); + + exec_barrier(); +} diff --git a/shaders-msl/comp/basic.comp b/shaders-msl/comp/basic.comp new file mode 100644 index 0000000000..f9bf55670f --- /dev/null +++ b/shaders-msl/comp/basic.comp @@ -0,0 +1,28 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(std430, binding = 0) readonly buffer SSBO +{ + vec4 in_data[]; +}; + +layout(std430, binding = 1) writeonly buffer SSBO2 +{ + vec4 out_data[]; +}; + +layout(std430, binding = 2) buffer SSBO3 +{ + uint counter; +}; + +void main() +{ + uint ident = gl_GlobalInvocationID.x; + vec4 idata = in_data[ident]; + if (dot(idata, vec4(1.0, 5.0, 6.0, 2.0)) > 8.2) + { + out_data[atomicAdd(counter, 1u)] = idata; + } +} + diff --git a/shaders-msl/comp/bitfield.noopt.comp b/shaders-msl/comp/bitfield.noopt.comp new file mode 100644 index 0000000000..0cac0b257c --- /dev/null +++ b/shaders-msl/comp/bitfield.noopt.comp @@ -0,0 +1,23 @@ +#version 310 es + +void main() +{ + int signed_value = 0; + uint unsigned_value = 0u; + + int s = bitfieldExtract(signed_value, 5, 20); + uint u = bitfieldExtract(unsigned_value, 6, 21); + s = bitfieldInsert(s, 40, 5, 4); + u = bitfieldInsert(u, 60u, 5, 4); + + u = bitfieldReverse(u); + s = bitfieldReverse(s); + + int v0 = bitCount(u); + int v1 = bitCount(s); + + int v2 = findMSB(u); + int v3 = findMSB(s); + int v4 = findLSB(u); + int v5 = findLSB(s); +} diff --git a/shaders-msl/comp/builtins.comp b/shaders-msl/comp/builtins.comp new file mode 100644 index 0000000000..88bb5951e4 --- /dev/null +++ b/shaders-msl/comp/builtins.comp @@ -0,0 +1,12 @@ +#version 310 es +layout(local_size_x = 8, local_size_y = 4, local_size_z = 2) in; + +void main() +{ + uvec3 local_id = gl_LocalInvocationID; + uvec3 global_id = gl_GlobalInvocationID; + uint local_index = gl_LocalInvocationIndex; + uvec3 work_group_size = gl_WorkGroupSize; + uvec3 num_work_groups = gl_NumWorkGroups; + uvec3 work_group_id = gl_WorkGroupID; +} diff --git a/shaders-msl/comp/cfg-preserve-parameter.comp b/shaders-msl/comp/cfg-preserve-parameter.comp new file mode 100644 index 0000000000..9ef9092005 --- /dev/null +++ b/shaders-msl/comp/cfg-preserve-parameter.comp @@ -0,0 +1,54 @@ +#version 310 es + +// We write in all paths (and no reads), so should just be out. +void out_test_0(int cond, inout int i) +{ + if (cond == 0) + i = 40; + else + i = 60; +} + +// We write in all paths (and no reads), so should just be out. +void out_test_1(int cond, inout int i) +{ + switch (cond) + { + case 40: + i = 40; + break; + + default: + i = 70; + break; + } +} + +// We don't write in all paths, so should be inout. +void inout_test_0(int cond, inout int i) +{ + if (cond == 0) + i = 40; +} + +void inout_test_1(int cond, inout int i) +{ + switch (cond) + { + case 40: + i = 40; + break; + } +} + + +void main() +{ + int cond = 40; + int i = 50; + + out_test_0(cond, i); + out_test_1(cond, i); + inout_test_0(cond, i); + inout_test_1(cond, i); +} diff --git a/shaders-msl/comp/coherent-block.comp b/shaders-msl/comp/coherent-block.comp new file mode 100644 index 0000000000..0a174e8ef0 --- /dev/null +++ b/shaders-msl/comp/coherent-block.comp @@ -0,0 +1,12 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(binding = 1) coherent restrict writeonly buffer SSBO +{ + vec4 value; +}; + +void main() +{ + value = vec4(20.0); +} diff --git a/shaders-msl/comp/coherent-image.comp b/shaders-msl/comp/coherent-image.comp new file mode 100644 index 0000000000..fd6e280182 --- /dev/null +++ b/shaders-msl/comp/coherent-image.comp @@ -0,0 +1,14 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(binding = 1) coherent restrict writeonly buffer SSBO +{ + ivec4 value; +}; + +layout(r32i, binding = 3) coherent readonly restrict uniform mediump iimage2D uImage; + +void main() +{ + value = imageLoad(uImage, ivec2(10)); +} diff --git a/shaders-msl/comp/culling.comp b/shaders-msl/comp/culling.comp new file mode 100644 index 0000000000..9f8331b10b --- /dev/null +++ b/shaders-msl/comp/culling.comp @@ -0,0 +1,26 @@ +#version 310 es +layout(local_size_x = 4) in; + +layout(std430, binding = 0) readonly buffer SSBO +{ + float in_data[]; +}; + +layout(std430, binding = 1) writeonly buffer SSBO2 +{ + float out_data[]; +}; + +layout(std430, binding = 2) buffer SSBO3 +{ + uint count; +}; + +void main() +{ + uint ident = gl_GlobalInvocationID.x; + float idata = in_data[ident]; + if (idata > 12.0) + out_data[atomicAdd(count, 1u)] = idata; +} + diff --git a/shaders-msl/comp/defer-parens.comp b/shaders-msl/comp/defer-parens.comp new file mode 100644 index 0000000000..4e8ea6b399 --- /dev/null +++ b/shaders-msl/comp/defer-parens.comp @@ -0,0 +1,30 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(binding = 0, std430) buffer SSBO +{ + vec4 data; + int index; +}; + +void main() +{ + // Tests defer-parens behavior where a binary expression is OpCompositeExtracted chained together + // with an OpCompositeConstruct optimization. + vec4 d = data; + data = vec4(d.x, d.yz + 10.0, d.w); + + // Verify binary ops. + data = d + d + d; + + // Verify swizzles. + data = (d.yz + 10.0).xxyy; + + // OpCompositeExtract + float t = (d.yz + 10.0).y; + data = vec4(t); + + // OpVectorExtractDynamic + t = (d.zw + 10.0)[index]; + data = vec4(t); +} diff --git a/shaders-msl/comp/dowhile.comp b/shaders-msl/comp/dowhile.comp new file mode 100644 index 0000000000..709db75a17 --- /dev/null +++ b/shaders-msl/comp/dowhile.comp @@ -0,0 +1,31 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(std430, binding = 0) readonly buffer SSBO +{ + mat4 mvp; + vec4 in_data[]; +}; + +layout(std430, binding = 1) writeonly buffer SSBO2 +{ + vec4 out_data[]; +}; + +int i; + +void main() +{ + uint ident = gl_GlobalInvocationID.x; + + i = 0; + vec4 idat = in_data[ident]; + do + { + idat = mvp * idat; + i++; + } while(i < 16); + + out_data[ident] = idat; +} + diff --git a/shaders-msl/comp/functions.comp b/shaders-msl/comp/functions.comp new file mode 100644 index 0000000000..478c8ebe83 --- /dev/null +++ b/shaders-msl/comp/functions.comp @@ -0,0 +1,12 @@ +#version 450 +shared int foo[1337]; + +void myfunc() +{ + foo[0]=13; +} + +void main() +{ + myfunc(); +} diff --git a/shaders-msl/comp/global-invocation-id-writable-ssbo-in-function.comp b/shaders-msl/comp/global-invocation-id-writable-ssbo-in-function.comp new file mode 100644 index 0000000000..2fe074df7c --- /dev/null +++ b/shaders-msl/comp/global-invocation-id-writable-ssbo-in-function.comp @@ -0,0 +1,12 @@ +#version 450 +layout(set = 0, binding = 0) buffer myBlock { + int a; + float b[1]; +} myStorage; +float getB() { + return myStorage.b[gl_GlobalInvocationID.x]; +} +void main() { + myStorage.a = (myStorage.a + 1) % 256; + myStorage.b[gl_GlobalInvocationID.x] = mod((getB() + 0.02), 1.0); +} diff --git a/shaders-msl/comp/global-invocation-id.comp b/shaders-msl/comp/global-invocation-id.comp new file mode 100644 index 0000000000..f484637e1f --- /dev/null +++ b/shaders-msl/comp/global-invocation-id.comp @@ -0,0 +1,9 @@ +#version 450 +layout(set = 0, binding = 0) buffer myBlock { + int a; + float b[1]; +} myStorage; +void main() { + myStorage.a = (myStorage.a + 1) % 256; + myStorage.b[gl_GlobalInvocationID.x] = mod((myStorage.b[gl_GlobalInvocationID.x] + 0.02), 1.0); +} diff --git a/shaders-msl/comp/image.comp b/shaders-msl/comp/image.comp new file mode 100644 index 0000000000..e375534a51 --- /dev/null +++ b/shaders-msl/comp/image.comp @@ -0,0 +1,12 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(rgba8, binding = 0) uniform readonly mediump image2D uImageIn; +layout(rgba8, binding = 1) uniform writeonly mediump image2D uImageOut; + +void main() +{ + vec4 v = imageLoad(uImageIn, ivec2(gl_GlobalInvocationID.xy) + imageSize(uImageIn)); + imageStore(uImageOut, ivec2(gl_GlobalInvocationID.xy), v); +} + diff --git a/shaders-msl/comp/insert.comp b/shaders-msl/comp/insert.comp new file mode 100644 index 0000000000..07c1f8d7aa --- /dev/null +++ b/shaders-msl/comp/insert.comp @@ -0,0 +1,18 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(std430, binding = 0) writeonly buffer SSBO +{ + vec4 out_data[]; +}; + +void main() +{ + vec4 v; + v.x = 10.0; + v.y = 30.0; + v.z = 70.0; + v.w = 90.0; + out_data[gl_GlobalInvocationID.x] = v; + out_data[gl_GlobalInvocationID.x].y = 20.0; +} diff --git a/shaders-msl/comp/local-invocation-id.comp b/shaders-msl/comp/local-invocation-id.comp new file mode 100644 index 0000000000..281700f197 --- /dev/null +++ b/shaders-msl/comp/local-invocation-id.comp @@ -0,0 +1,9 @@ +#version 450 +layout(set = 0, binding = 0) buffer myBlock { + int a; + float b[1]; +} myStorage; +void main() { + myStorage.a = (myStorage.a + 1) % 256; + myStorage.b[gl_LocalInvocationID.x] = mod((myStorage.b[gl_LocalInvocationID.x] + 0.02), 1.0); +} diff --git a/shaders-msl/comp/local-invocation-index.comp b/shaders-msl/comp/local-invocation-index.comp new file mode 100644 index 0000000000..68942da8e1 --- /dev/null +++ b/shaders-msl/comp/local-invocation-index.comp @@ -0,0 +1,9 @@ +#version 450 +layout(set = 0, binding = 0) buffer myBlock { + int a; + float b[1]; +} myStorage; +void main() { + myStorage.a = (myStorage.a + 1) % 256; + myStorage.b[gl_LocalInvocationIndex.x] = mod((myStorage.b[gl_LocalInvocationIndex.x] + 0.02), 1.0); +} diff --git a/shaders-msl/comp/loop.noopt.comp b/shaders-msl/comp/loop.noopt.comp new file mode 100644 index 0000000000..6d6c324243 --- /dev/null +++ b/shaders-msl/comp/loop.noopt.comp @@ -0,0 +1,98 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(std430, binding = 0) readonly buffer SSBO +{ + mat4 mvp; + vec4 in_data[]; +}; + +layout(std430, binding = 1) writeonly buffer SSBO2 +{ + vec4 out_data[]; +}; + +void main() +{ + uint ident = gl_GlobalInvocationID.x; + vec4 idat = in_data[ident]; + + int k = 0; + uint i = 0u; + + if (idat.y == 20.0) + { + do + { + k = k * 2; + i++; + } while (i < ident); + } + + switch (k) + { + case 10: + for (;;) + { + i++; + if (i > 10u) + break; + } + break; + + default: + for (;;) + { + i += 2u; + if (i > 20u) + break; + } + break; + } + + while (k < 10) + { + idat *= 2.0; + k++; + } + + for (uint i = 0u; i < 16u; i++, k++) + for (uint j = 0u; j < 30u; j++) + idat = mvp * idat; + + k = 0; + for (;;) + { + k++; + if (k > 10) + { + k += 2; + } + else + { + k += 3; + continue; + } + + k += 10; + } + + k = 0; + do + { + k++; + } while (k > 10); + + int l = 0; + for (;; l++) + { + if (l == 5) + { + continue; + } + + idat += 1.0; + } + out_data[ident] = idat; +} + diff --git a/shaders-msl/comp/mat3.comp b/shaders-msl/comp/mat3.comp new file mode 100644 index 0000000000..7c5bb1e4f5 --- /dev/null +++ b/shaders-msl/comp/mat3.comp @@ -0,0 +1,14 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(std430, binding = 1) writeonly buffer SSBO2 +{ + mat3 out_data[]; +}; + +void main() +{ + uint ident = gl_GlobalInvocationID.x; + out_data[ident] = mat3(vec3(10.0), vec3(20.0), vec3(40.0)); +} + diff --git a/shaders-msl/comp/mod.comp b/shaders-msl/comp/mod.comp new file mode 100644 index 0000000000..1631456e30 --- /dev/null +++ b/shaders-msl/comp/mod.comp @@ -0,0 +1,26 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(std430, binding = 0) readonly buffer SSBO +{ + vec4 in_data[]; +}; + +layout(std430, binding = 1) writeonly buffer SSBO2 +{ + vec4 out_data[]; +}; + +void main() +{ + uint ident = gl_GlobalInvocationID.x; + vec4 v = mod(in_data[ident], out_data[ident]); + out_data[ident] = v; + + uvec4 vu = floatBitsToUint(in_data[ident]) % floatBitsToUint(out_data[ident]); + out_data[ident] = uintBitsToFloat(vu); + + ivec4 vi = floatBitsToInt(in_data[ident]) % floatBitsToInt(out_data[ident]); + out_data[ident] = intBitsToFloat(vi); +} + diff --git a/shaders-msl/comp/modf.comp b/shaders-msl/comp/modf.comp new file mode 100644 index 0000000000..edadefcf05 --- /dev/null +++ b/shaders-msl/comp/modf.comp @@ -0,0 +1,23 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(std430, binding = 0) readonly buffer SSBO +{ + vec4 in_data[]; +}; + +layout(std430, binding = 1) writeonly buffer SSBO2 +{ + vec4 out_data[]; +}; + +void main() +{ + uint ident = gl_GlobalInvocationID.x; + vec4 i; + //vec4 v = frexp(in_data[ident], i); + //out_data[ident] = ldexp(v, i); + vec4 v = modf(in_data[ident], i); + out_data[ident] = v; +} + diff --git a/shaders-msl/comp/read-write-only.comp b/shaders-msl/comp/read-write-only.comp new file mode 100644 index 0000000000..b224b6f121 --- /dev/null +++ b/shaders-msl/comp/read-write-only.comp @@ -0,0 +1,26 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(binding = 0, std430) readonly buffer SSBO0 +{ + vec4 data0; + vec4 data1; +}; + +layout(binding = 1, std430) restrict buffer SSBO1 +{ + vec4 data2; + vec4 data3; +}; + +layout(binding = 2, std430) restrict writeonly buffer SSBO2 +{ + vec4 data4; + vec4 data5; +}; + +void main() +{ + data4 = data0 + data2; + data5 = data1 + data3; +} diff --git a/shaders-msl/comp/return.comp b/shaders-msl/comp/return.comp new file mode 100644 index 0000000000..617f437182 --- /dev/null +++ b/shaders-msl/comp/return.comp @@ -0,0 +1,33 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(std430, binding = 1) writeonly buffer SSBO2 +{ + vec4 out_data[]; +}; + +void main() +{ + uint ident = gl_GlobalInvocationID.x; + + if (ident == 2u) + { + out_data[ident] = vec4(20.0); + } + else if (ident == 4u) + { + out_data[ident] = vec4(10.0); + return; + } + + for (int i = 0; i < 20; i++) + { + if (i == 10) + break; + + return; + } + + out_data[ident] = vec4(10.0); +} + diff --git a/shaders-msl/comp/rmw-opt.comp b/shaders-msl/comp/rmw-opt.comp new file mode 100644 index 0000000000..a6e1e7fe75 --- /dev/null +++ b/shaders-msl/comp/rmw-opt.comp @@ -0,0 +1,27 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(std430, binding = 0) buffer SSBO +{ + int a; +}; + +void main() +{ + a += 10; + a -= 10; + a *= 10; + a /= 10; + a <<= 2; + a >>= 3; + a &= 40; + a ^= 10; + a %= 40; + a |= 1; + + bool c = false; + bool d = true; + c = c && d; + d = d || c; + a = c && d ? 1 : 0; +} diff --git a/shaders-msl/comp/shared-array-of-arrays.comp b/shaders-msl/comp/shared-array-of-arrays.comp new file mode 100644 index 0000000000..009b4e41d4 --- /dev/null +++ b/shaders-msl/comp/shared-array-of-arrays.comp @@ -0,0 +1,29 @@ +#version 310 es +layout(local_size_x = 4, local_size_y = 4) in; + +shared float foo[4][4]; + +layout(binding = 0, std430) buffer SSBO +{ + float out_data[]; +}; + +void work() +{ + foo[gl_LocalInvocationID.x][gl_LocalInvocationID.y] = float(gl_LocalInvocationIndex); + memoryBarrierShared(); + barrier(); + + float x = 0.0; + x += foo[gl_LocalInvocationID.x][0]; + x += foo[gl_LocalInvocationID.x][1]; + x += foo[gl_LocalInvocationID.x][2]; + x += foo[gl_LocalInvocationID.x][3]; + out_data[gl_GlobalInvocationID.x] = x; +} + +void main() +{ + work(); +} + diff --git a/shaders-msl/comp/shared.comp b/shaders-msl/comp/shared.comp new file mode 100644 index 0000000000..4deff93597 --- /dev/null +++ b/shaders-msl/comp/shared.comp @@ -0,0 +1,27 @@ +#version 310 es +layout(local_size_x = 4) in; + +shared float sShared[gl_WorkGroupSize.x]; + +layout(std430, binding = 0) readonly buffer SSBO +{ + float in_data[]; +}; + +layout(std430, binding = 1) writeonly buffer SSBO2 +{ + float out_data[]; +}; + +void main() +{ + uint ident = gl_GlobalInvocationID.x; + float idata = in_data[ident]; + + sShared[gl_LocalInvocationIndex] = idata; + memoryBarrierShared(); + barrier(); + + out_data[ident] = sShared[gl_WorkGroupSize.x - gl_LocalInvocationIndex - 1u]; +} + diff --git a/shaders-msl/comp/struct-layout.comp b/shaders-msl/comp/struct-layout.comp new file mode 100644 index 0000000000..5a2b7802df --- /dev/null +++ b/shaders-msl/comp/struct-layout.comp @@ -0,0 +1,24 @@ +#version 310 es +layout(local_size_x = 1) in; + +struct Foo +{ + mat4 m; +}; + +layout(std430, binding = 0) readonly buffer SSBO +{ + Foo in_data[]; +}; + +layout(std430, binding = 1) writeonly buffer SSBO2 +{ + Foo out_data[]; +}; + +void main() +{ + uint ident = gl_GlobalInvocationID.x; + out_data[ident].m = in_data[ident].m * in_data[ident].m; +} + diff --git a/shaders-msl/comp/struct-packing.comp b/shaders-msl/comp/struct-packing.comp new file mode 100644 index 0000000000..04b933dd18 --- /dev/null +++ b/shaders-msl/comp/struct-packing.comp @@ -0,0 +1,76 @@ +#version 310 es +layout(local_size_x = 1) in; + +struct S0 +{ + vec2 a[1]; + float b; +}; + +struct S1 +{ + vec3 a; + float b; +}; + +struct S2 +{ + vec3 a[1]; + float b; +}; + +struct S3 +{ + vec2 a; + float b; +}; + +struct S4 +{ + vec2 c; +}; + +struct Content +{ + S0 m0s[1]; + S1 m1s[1]; + S2 m2s[1]; + S0 m0; + S1 m1; + S2 m2; + S3 m3; + float m4; + + S4 m3s[8]; +}; + +layout(binding = 1, std430) buffer SSBO1 +{ + Content content; + Content content1[2]; + Content content2; + + layout(column_major) mat2 m0; + layout(column_major) mat2 m1; + layout(column_major) mat2x3 m2[4]; + layout(column_major) mat3x2 m3; + layout(row_major) mat2 m4; + layout(row_major) mat2 m5[9]; + layout(row_major) mat2x3 m6[4][2]; + layout(row_major) mat3x2 m7; + float array[]; +} ssbo_430; + +layout(binding = 0, std140) buffer SSBO0 +{ + Content content; + Content content1[2]; + Content content2; + float array[]; +} ssbo_140; + +void main() +{ + ssbo_430.content = ssbo_140.content; +} + diff --git a/shaders-msl/comp/torture-loop.comp b/shaders-msl/comp/torture-loop.comp new file mode 100644 index 0000000000..54a1221a15 --- /dev/null +++ b/shaders-msl/comp/torture-loop.comp @@ -0,0 +1,40 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(std430, binding = 0) readonly buffer SSBO +{ + mat4 mvp; + vec4 in_data[]; +}; + +layout(std430, binding = 1) writeonly buffer SSBO2 +{ + vec4 out_data[]; +}; + +void main() +{ + uint ident = gl_GlobalInvocationID.x; + vec4 idat = in_data[ident]; + + int k = 0; + + // Continue with side effects. + while (++k < 10) + { + idat *= 2.0; + k++; + } + + // Again used here ... + for (uint i = 0u; i < 16u; i++, k++) + for (uint j = 0u; j < 30u; j++) + idat = mvp * idat; + + do + { + k++; + } while (k > 10); + out_data[ident] = idat; +} + diff --git a/shaders-msl/comp/type-alias.comp b/shaders-msl/comp/type-alias.comp new file mode 100644 index 0000000000..343d350a2f --- /dev/null +++ b/shaders-msl/comp/type-alias.comp @@ -0,0 +1,45 @@ +#version 310 es +layout(local_size_x = 1) in; + +struct S0 +{ + vec4 a; +}; + +struct S1 +{ + vec4 a; +}; + +vec4 overload(S0 s0) +{ + return s0.a; +} + +vec4 overload(S1 s1) +{ + return s1.a; +} + +layout(std430, binding = 0) buffer SSBO0 +{ + S0 s0s[]; +}; + +layout(std430, binding = 1) buffer SSBO1 +{ + S1 s1s[]; +}; + +layout(std430, binding = 2) buffer SSBO2 +{ + vec4 outputs[]; +}; + + +void main() +{ + S0 s0 = s0s[gl_GlobalInvocationID.x]; + S1 s1 = s1s[gl_GlobalInvocationID.x]; + outputs[gl_GlobalInvocationID.x] = overload(s0) + overload(s1); +} diff --git a/shaders-msl/comp/udiv.comp b/shaders-msl/comp/udiv.comp new file mode 100644 index 0000000000..33fe564f07 --- /dev/null +++ b/shaders-msl/comp/udiv.comp @@ -0,0 +1,17 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(std430, binding = 0) buffer SSBO +{ + uint inputs[]; +}; + +layout(std430, binding = 0) buffer SSBO2 +{ + uint outputs[]; +}; + +void main() +{ + outputs[gl_GlobalInvocationID.x] = inputs[gl_GlobalInvocationID.x] / 29u; +} diff --git a/shaders-msl/comp/writable-ssbo.comp b/shaders-msl/comp/writable-ssbo.comp new file mode 100644 index 0000000000..1d5128ce8a --- /dev/null +++ b/shaders-msl/comp/writable-ssbo.comp @@ -0,0 +1,9 @@ +#version 450 +layout(set = 0, binding = 0) buffer myBlock { + int a; + float b; +} myStorage; +void main() { + myStorage.a = (myStorage.a + 1) % 256; + myStorage.b = mod((myStorage.b + 0.02), 1.0); +} diff --git a/shaders-msl/desktop-only/frag/image-ms.desktop.frag b/shaders-msl/desktop-only/frag/image-ms.desktop.frag new file mode 100644 index 0000000000..e145cb8f00 --- /dev/null +++ b/shaders-msl/desktop-only/frag/image-ms.desktop.frag @@ -0,0 +1,13 @@ +#version 450 + +layout(rgba8, binding = 0) uniform image2D uImage; +layout(rgba8, binding = 1) uniform image2DArray uImageArray; +layout(rgba8, binding = 2) uniform image2DMS uImageMS; + +void main() +{ + vec4 a = imageLoad(uImageMS, ivec2(1, 2), 2); + vec4 b = imageLoad(uImageArray, ivec3(1, 2, 4)); + imageStore(uImage, ivec2(2, 3), a); + imageStore(uImageArray, ivec3(2, 3, 7), b); +} diff --git a/shaders-msl/desktop-only/frag/query-levels.desktop.frag b/shaders-msl/desktop-only/frag/query-levels.desktop.frag new file mode 100644 index 0000000000..4a80cbf81f --- /dev/null +++ b/shaders-msl/desktop-only/frag/query-levels.desktop.frag @@ -0,0 +1,11 @@ +#version 450 + +layout(binding = 0) uniform sampler2D uSampler; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = vec4(float(textureQueryLevels(uSampler))); +} + diff --git a/shaders-msl/desktop-only/frag/sampler-ms-query.desktop.frag b/shaders-msl/desktop-only/frag/sampler-ms-query.desktop.frag new file mode 100644 index 0000000000..4c30ed1529 --- /dev/null +++ b/shaders-msl/desktop-only/frag/sampler-ms-query.desktop.frag @@ -0,0 +1,14 @@ +#version 450 + +layout(binding = 0) uniform sampler2DMS uSampler; +layout(binding = 1) uniform sampler2DMSArray uSamplerArray; +layout(binding = 2, rgba8) uniform readonly writeonly image2DMS uImage; +layout(binding = 3, rgba8) uniform readonly writeonly image2DMSArray uImageArray; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = vec4(float(((textureSamples(uSampler) + textureSamples(uSamplerArray)) + imageSamples(uImage)) + imageSamples(uImageArray))); +} + diff --git a/shaders-msl/desktop-only/vert/basic.desktop.sso.vert b/shaders-msl/desktop-only/vert/basic.desktop.sso.vert new file mode 100644 index 0000000000..9ddab08cda --- /dev/null +++ b/shaders-msl/desktop-only/vert/basic.desktop.sso.vert @@ -0,0 +1,20 @@ +#version 450 + +out gl_PerVertex +{ + vec4 gl_Position; +}; + +layout(std140) uniform UBO +{ + mat4 uMVP; +}; +layout(location = 0) in vec4 aVertex; +layout(location = 1) in vec3 aNormal; +layout(location = 0) out vec3 vNormal; + +void main() +{ + gl_Position = uMVP * aVertex; + vNormal = aNormal; +} diff --git a/shaders-msl/desktop-only/vert/clip-cull-distance.desktop.vert b/shaders-msl/desktop-only/vert/clip-cull-distance.desktop.vert new file mode 100644 index 0000000000..9e4a0b7ac9 --- /dev/null +++ b/shaders-msl/desktop-only/vert/clip-cull-distance.desktop.vert @@ -0,0 +1,10 @@ +#version 450 + +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; +} diff --git a/shaders-msl/flatten/basic.flatten.vert b/shaders-msl/flatten/basic.flatten.vert new file mode 100644 index 0000000000..e60a9067b1 --- /dev/null +++ b/shaders-msl/flatten/basic.flatten.vert @@ -0,0 +1,16 @@ +#version 310 es + +layout(std140) uniform UBO +{ + mat4 uMVP; +}; + +layout(location = 0) in vec4 aVertex; +layout(location = 1) in vec3 aNormal; +layout(location = 0) out vec3 vNormal; + +void main() +{ + gl_Position = uMVP * aVertex; + vNormal = aNormal; +} diff --git a/shaders-msl/flatten/multiindex.flatten.vert b/shaders-msl/flatten/multiindex.flatten.vert new file mode 100644 index 0000000000..0b471d86e0 --- /dev/null +++ b/shaders-msl/flatten/multiindex.flatten.vert @@ -0,0 +1,13 @@ +#version 310 es + +layout(std140) uniform UBO +{ + vec4 Data[3][5]; +}; + +layout(location = 0) in ivec2 aIndex; + +void main() +{ + gl_Position = Data[aIndex.x][aIndex.y]; +} diff --git a/shaders-msl/flatten/push-constant.flatten.vert b/shaders-msl/flatten/push-constant.flatten.vert new file mode 100644 index 0000000000..c7b1b42e1b --- /dev/null +++ b/shaders-msl/flatten/push-constant.flatten.vert @@ -0,0 +1,17 @@ +#version 310 es + +layout(push_constant, std430) uniform PushMe +{ + mat4 MVP; + mat2 Rot; // The MatrixStride will be 8 here. + float Arr[4]; +} registers; + +layout(location = 0) in vec2 Rot; +layout(location = 1) in vec4 Pos; +layout(location = 0) out vec2 vRot; +void main() +{ + gl_Position = registers.MVP * Pos; + vRot = registers.Rot * Rot + registers.Arr[2]; // Constant access should work even if array stride is just 4 here. +} diff --git a/shaders-msl/flatten/rowmajor.flatten.vert b/shaders-msl/flatten/rowmajor.flatten.vert new file mode 100644 index 0000000000..88c468c8f2 --- /dev/null +++ b/shaders-msl/flatten/rowmajor.flatten.vert @@ -0,0 +1,16 @@ +#version 310 es + +layout(std140) uniform UBO +{ + layout(column_major) mat4 uMVPR; + layout(row_major) mat4 uMVPC; + layout(row_major) mat2x4 uMVP; +}; + +layout(location = 0) in vec4 aVertex; + +void main() +{ + vec2 v = aVertex * uMVP; + gl_Position = uMVPR * aVertex + uMVPC * aVertex; +} diff --git a/shaders-msl/flatten/struct.flatten.vert b/shaders-msl/flatten/struct.flatten.vert new file mode 100644 index 0000000000..936bb41b85 --- /dev/null +++ b/shaders-msl/flatten/struct.flatten.vert @@ -0,0 +1,30 @@ +#version 310 es + +struct Light +{ + vec3 Position; + float Radius; + + vec4 Color; +}; + +layout(std140) uniform UBO +{ + mat4 uMVP; + + Light light; +}; + +layout(location = 0) in vec4 aVertex; +layout(location = 1) in vec3 aNormal; +layout(location = 0) out vec4 vColor; + +void main() +{ + gl_Position = uMVP * aVertex; + + vColor = vec4(0.0); + + vec3 L = aVertex.xyz - light.Position; + vColor += dot(aNormal, normalize(L)) * (clamp(1.0 - length(L) / light.Radius, 0.0, 1.0) * light.Color); +} diff --git a/shaders-msl/flatten/swizzle.flatten.vert b/shaders-msl/flatten/swizzle.flatten.vert new file mode 100644 index 0000000000..e310cdf336 --- /dev/null +++ b/shaders-msl/flatten/swizzle.flatten.vert @@ -0,0 +1,47 @@ +#version 310 es + +// comments note the 16b alignment boundaries (see GL spec 7.6.2.2 Standard Uniform Block Layout) +layout(std140) uniform UBO +{ + // 16b boundary + vec4 A; + // 16b boundary + vec2 B0; + vec2 B1; + // 16b boundary + float C0; + // 16b boundary (vec3 is aligned to 16b) + vec3 C1; + // 16b boundary + vec3 D0; + float D1; + // 16b boundary + float E0; + float E1; + float E2; + float E3; + // 16b boundary + float F0; + vec2 F1; + // 16b boundary (vec2 before us is aligned to 8b) + float F2; +}; + +layout(location = 0) out vec4 oA; +layout(location = 1) out vec4 oB; +layout(location = 2) out vec4 oC; +layout(location = 3) out vec4 oD; +layout(location = 4) out vec4 oE; +layout(location = 5) out vec4 oF; + +void main() +{ + gl_Position = vec4(0.0); + + oA = A; + oB = vec4(B0, B1); + oC = vec4(C0, C1) + vec4(C1.xy, C1.z, C0); // not packed + oD = vec4(D0, D1) + vec4(D0.xy, D0.z, D1); // packed - must convert for swizzle + oE = vec4(E0, E1, E2, E3); + oF = vec4(F0, F1, F2); +} diff --git a/shaders-msl/flatten/types.flatten.frag b/shaders-msl/flatten/types.flatten.frag new file mode 100644 index 0000000000..faab5b7e05 --- /dev/null +++ b/shaders-msl/flatten/types.flatten.frag @@ -0,0 +1,27 @@ +#version 310 es +precision mediump float; + +layout(std140, binding = 0) uniform UBO0 +{ + vec4 a; + vec4 b; +}; + +layout(std140, binding = 0) uniform UBO1 +{ + ivec4 c; + ivec4 d; +}; + +layout(std140, binding = 0) uniform UBO2 +{ + uvec4 e; + uvec4 f; +}; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = vec4(c) + vec4(d) + vec4(e) + vec4(f) + a + b; +} diff --git a/shaders-msl/frag/basic.frag b/shaders-msl/frag/basic.frag new file mode 100644 index 0000000000..dd9a8f8507 --- /dev/null +++ b/shaders-msl/frag/basic.frag @@ -0,0 +1,13 @@ +#version 310 es +precision mediump float; + +layout(location = 0) in vec4 vColor; +layout(location = 1) in vec2 vTex; +layout(binding = 0) uniform sampler2D uTex; +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = vColor * texture(uTex, vTex); +} + diff --git a/shaders-msl/frag/bitcasting.frag b/shaders-msl/frag/bitcasting.frag new file mode 100644 index 0000000000..5dac78ef33 --- /dev/null +++ b/shaders-msl/frag/bitcasting.frag @@ -0,0 +1,24 @@ +#version 310 es +precision mediump float; + +layout(binding = 0) uniform sampler2D TextureBase; +layout(binding = 1) uniform sampler2D TextureDetail; + +layout(location = 0) in vec4 VertGeom; + +layout(location = 0) out vec4 FragColor0; +layout(location = 1) out vec4 FragColor1; + +void main() +{ + vec4 texSample0 = texture(TextureBase, VertGeom.xy); + vec4 texSample1 = textureOffset(TextureDetail, VertGeom.xy, ivec2(3, 2)); + + ivec4 iResult0 = floatBitsToInt(texSample0); + ivec4 iResult1 = floatBitsToInt(texSample1); + FragColor0 = (intBitsToFloat(iResult0) * intBitsToFloat(iResult1)); + + uvec4 uResult0 = floatBitsToUint(texSample0); + uvec4 uResult1 = floatBitsToUint(texSample1); + FragColor1 = (uintBitsToFloat(uResult0) * uintBitsToFloat(uResult1)); +} \ No newline at end of file diff --git a/shaders-msl/frag/builtins.frag b/shaders-msl/frag/builtins.frag new file mode 100644 index 0000000000..99e6e2df5b --- /dev/null +++ b/shaders-msl/frag/builtins.frag @@ -0,0 +1,11 @@ +#version 310 es +precision mediump float; + +layout(location = 0) out vec4 FragColor; +layout(location = 0) in vec4 vColor; + +void main() +{ + FragColor = gl_FragCoord + vColor; + gl_FragDepth = 0.5; +} diff --git a/shaders-msl/frag/composite-extract-forced-temporary.frag b/shaders-msl/frag/composite-extract-forced-temporary.frag new file mode 100644 index 0000000000..35fdbe8624 --- /dev/null +++ b/shaders-msl/frag/composite-extract-forced-temporary.frag @@ -0,0 +1,11 @@ +#version 310 es +precision mediump float; +layout(binding = 0) uniform sampler2D Texture; +layout(location = 0) out vec4 FragColor; +layout(location = 0) in vec2 vTexCoord; + +void main() +{ + float f = texture(Texture, vTexCoord).x; + FragColor = vec4(f * f); +} diff --git a/shaders-msl/frag/constant-array.frag b/shaders-msl/frag/constant-array.frag new file mode 100644 index 0000000000..b862cb1dbf --- /dev/null +++ b/shaders-msl/frag/constant-array.frag @@ -0,0 +1,21 @@ +#version 310 es +precision mediump float; +layout(location = 0) out vec4 FragColor; + +layout(location = 0) flat in int index; + +struct Foobar { float a; float b; }; + +vec4 resolve(Foobar f) +{ + return vec4(f.a + f.b); +} + +void main() +{ + const vec4 foo[3] = vec4[](vec4(1.0), vec4(2.0), vec4(3.0)); + const vec4 foobars[2][2] = vec4[][](vec4[](vec4(1.0), vec4(2.0)), vec4[](vec4(8.0), vec4(10.0))); + const Foobar foos[2] = Foobar[](Foobar(10.0, 40.0), Foobar(90.0, 70.0)); + + FragColor = foo[index] + foobars[index][index + 1] + resolve(Foobar(10.0, 20.0)) + resolve(foos[index]); +} diff --git a/shaders-msl/frag/constant-composites.frag b/shaders-msl/frag/constant-composites.frag new file mode 100644 index 0000000000..a12e22ff4f --- /dev/null +++ b/shaders-msl/frag/constant-composites.frag @@ -0,0 +1,20 @@ +#version 310 es +precision mediump float; + +float lut[4] = float[](1.0, 4.0, 3.0, 2.0); + +struct Foo +{ + float a; + float b; +}; +Foo foos[2] = Foo[](Foo(10.0, 20.0), Foo(30.0, 40.0)); + +layout(location = 0) out vec4 FragColor; +layout(location = 0) flat in int line; + +void main() +{ + FragColor = vec4(lut[line]); + FragColor += foos[line].a * foos[1 - line].a; +} diff --git a/shaders-msl/frag/false-loop-init.frag b/shaders-msl/frag/false-loop-init.frag new file mode 100644 index 0000000000..7ce5b52bd7 --- /dev/null +++ b/shaders-msl/frag/false-loop-init.frag @@ -0,0 +1,19 @@ +#version 310 es +precision mediump float; + +layout(location = 0) in vec4 accum; +layout(location = 0) out vec4 result; + +void main() +{ + result = vec4(0.0); + uint j; + for (int i = 0; i < 4; i += int(j)) + { + if (accum.y > 10.0) + j = 40u; + else + j = 30u; + result += accum; + } +} diff --git a/shaders-msl/frag/flush_params.frag b/shaders-msl/frag/flush_params.frag new file mode 100644 index 0000000000..8a26ad3a28 --- /dev/null +++ b/shaders-msl/frag/flush_params.frag @@ -0,0 +1,27 @@ +#version 310 es +precision mediump float; + +layout(location = 0) out vec4 FragColor; + +struct Structy +{ + vec4 c; +}; + +void foo2(out Structy f) +{ + f.c = vec4(10.0); +} + +Structy foo() +{ + Structy f; + foo2(f); + return f; +} + +void main() +{ + Structy s = foo(); + FragColor = s.c; +} diff --git a/shaders-msl/frag/for-loop-init.frag b/shaders-msl/frag/for-loop-init.frag new file mode 100644 index 0000000000..0cde26765e --- /dev/null +++ b/shaders-msl/frag/for-loop-init.frag @@ -0,0 +1,52 @@ +#version 310 es +precision mediump float; +layout(location = 0) out int FragColor; + +void main() +{ + FragColor = 16; + + // Basic loop variable. + for (int i = 0; i < 25; i++) + FragColor += 10; + + // Multiple loop variables. + for (int i = 1, j = 4; i < 30; i++, j += 4) + FragColor += 11; + + // A potential loop variables, but we access it outside the loop, + // so cannot be one. + int k = 0; + for (; k < 20; k++) + FragColor += 12; + k += 3; + FragColor += k; + + // Potential loop variables, but the dominator is not trivial. + int l; + if (k == 40) + { + for (l = 0; l < 40; l++) + FragColor += 13; + return; + } + else + { + l = k; + FragColor += l; + } + + // Vectors cannot be loop variables + for (ivec2 i = ivec2(0); i.x < 10; i.x += 4) + { + FragColor += i.y; + } + + // Check that static expressions can be used before the loop header. + int m = 0; + m = k; + int o = m; + for (; m < 40; m++) + FragColor += m; + FragColor += o; +} diff --git a/shaders-msl/frag/in_block.frag b/shaders-msl/frag/in_block.frag new file mode 100644 index 0000000000..59b97074ec --- /dev/null +++ b/shaders-msl/frag/in_block.frag @@ -0,0 +1,14 @@ +#version 450 + +layout(location = 2) in VertexOut +{ + vec4 color; + vec4 color2; +} inputs; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = inputs.color + inputs.color2; +} diff --git a/shaders-msl/frag/in_block_assign.noopt.frag b/shaders-msl/frag/in_block_assign.noopt.frag new file mode 100644 index 0000000000..760a3ba2d3 --- /dev/null +++ b/shaders-msl/frag/in_block_assign.noopt.frag @@ -0,0 +1,16 @@ +#version 450 + +struct VOUT +{ + vec4 a; +}; + +layout(location = 0) in VOUT Clip; +layout(location = 0) out vec4 FragColor; + +void main() +{ + VOUT tmp = Clip; + tmp.a += 1.0; + FragColor = tmp.a; +} diff --git a/shaders-msl/frag/mix.frag b/shaders-msl/frag/mix.frag new file mode 100644 index 0000000000..a5d589dd08 --- /dev/null +++ b/shaders-msl/frag/mix.frag @@ -0,0 +1,20 @@ +#version 310 es +precision mediump float; + +layout(location = 0) in vec4 vIn0; +layout(location = 1) in vec4 vIn1; +layout(location = 2) in float vIn2; +layout(location = 3) in float vIn3; +layout(location = 0) out vec4 FragColor; + +void main() +{ + bvec4 l = bvec4(false, true, false, false); + FragColor = mix(vIn0, vIn1, l); + + bool f = true; + FragColor = vec4(mix(vIn2, vIn3, f)); + + FragColor = f ? vIn0 : vIn1; + FragColor = vec4(f ? vIn2 : vIn3); +} diff --git a/shaders-msl/frag/pls.frag b/shaders-msl/frag/pls.frag new file mode 100644 index 0000000000..e3863e4e0e --- /dev/null +++ b/shaders-msl/frag/pls.frag @@ -0,0 +1,20 @@ +#version 310 es +precision mediump float; + +layout(location = 0) in vec4 PLSIn0; +layout(location = 1) in vec4 PLSIn1; +layout(location = 2) in vec4 PLSIn2; +layout(location = 3) in vec4 PLSIn3; + +layout(location = 0) out vec4 PLSOut0; +layout(location = 1) out vec4 PLSOut1; +layout(location = 2) out vec4 PLSOut2; +layout(location = 3) out vec4 PLSOut3; + +void main() +{ + PLSOut0 = 2.0 * PLSIn0; + PLSOut1 = 6.0 * PLSIn1; + PLSOut2 = 7.0 * PLSIn2; + PLSOut3 = 4.0 * PLSIn3; +} diff --git a/shaders-msl/frag/sampler-ms.frag b/shaders-msl/frag/sampler-ms.frag new file mode 100644 index 0000000000..6593928271 --- /dev/null +++ b/shaders-msl/frag/sampler-ms.frag @@ -0,0 +1,16 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(binding = 0) uniform mediump sampler2DMS uSampler; +layout(location = 0) out vec4 FragColor; + +void main() +{ + ivec2 coord = ivec2(gl_FragCoord.xy); + FragColor = + texelFetch(uSampler, coord, 0) + + texelFetch(uSampler, coord, 1) + + texelFetch(uSampler, coord, 2) + + texelFetch(uSampler, coord, 3); +} diff --git a/shaders-msl/frag/sampler.frag b/shaders-msl/frag/sampler.frag new file mode 100644 index 0000000000..e38f76886a --- /dev/null +++ b/shaders-msl/frag/sampler.frag @@ -0,0 +1,18 @@ +#version 310 es +precision mediump float; + +layout(location = 0) in vec4 vColor; +layout(location = 1) in vec2 vTex; +layout(binding = 0) uniform sampler2D uTex; +layout(location = 0) out vec4 FragColor; + +vec4 sample_texture(sampler2D tex, vec2 uv) +{ + return texture(tex, uv); +} + +void main() +{ + FragColor = vColor * sample_texture(uTex, vTex); +} + diff --git a/shaders-msl/frag/separate-image-sampler-argument.frag b/shaders-msl/frag/separate-image-sampler-argument.frag new file mode 100644 index 0000000000..0475b019d2 --- /dev/null +++ b/shaders-msl/frag/separate-image-sampler-argument.frag @@ -0,0 +1,16 @@ +#version 310 es +precision mediump float; + +layout(set = 0, binding = 0) uniform mediump sampler uSampler; +layout(set = 0, binding = 1) uniform mediump texture2D uDepth; +layout(location = 0) out vec4 FragColor; + +vec4 samp(texture2D t, mediump sampler s) +{ + return texture(sampler2D(t, s), vec2(0.5)); +} + +void main() +{ + FragColor = samp(uDepth, uSampler); +} diff --git a/shaders-msl/frag/swizzle.frag b/shaders-msl/frag/swizzle.frag new file mode 100644 index 0000000000..271ba6cb64 --- /dev/null +++ b/shaders-msl/frag/swizzle.frag @@ -0,0 +1,17 @@ +#version 310 es +precision mediump float; + +layout(location = 0) uniform sampler2D samp; +layout(location = 0) out vec4 FragColor; +layout(location = 1) in vec3 vNormal; +layout(location = 2) in vec2 vUV; + +void main() +{ + FragColor = vec4(texture(samp, vUV).xyz, 1.0); + FragColor = vec4(texture(samp, vUV).xz, 1.0, 4.0); + FragColor = vec4(texture(samp, vUV).xx, texture(samp, vUV + vec2(0.1)).yy); + FragColor = vec4(vNormal, 1.0); + FragColor = vec4(vNormal + 1.8, 1.0); + FragColor = vec4(vUV, vUV + 1.8); +} diff --git a/shaders-msl/frag/texture-proj-shadow.frag b/shaders-msl/frag/texture-proj-shadow.frag new file mode 100644 index 0000000000..547532e648 --- /dev/null +++ b/shaders-msl/frag/texture-proj-shadow.frag @@ -0,0 +1,19 @@ +#version 450 + +layout(binding = 1) uniform sampler2DShadow uShadow2D; +layout(binding = 2) uniform sampler1D uSampler1D; +layout(binding = 3) uniform sampler2D uSampler2D; +layout(binding = 4) uniform sampler3D uSampler3D; + +layout(location = 0) out float FragColor; +layout(location = 0) in vec3 vClip3; +layout(location = 1) in vec4 vClip4; +layout(location = 2) in vec2 vClip2; + +void main() +{ + FragColor = textureProj(uShadow2D, vClip4); + FragColor = textureProj(uSampler1D, vClip2).x; + FragColor = textureProj(uSampler2D, vClip3).x; + FragColor = textureProj(uSampler3D, vClip4).x; +} diff --git a/shaders-msl/frag/ubo_layout.frag b/shaders-msl/frag/ubo_layout.frag new file mode 100644 index 0000000000..80f9f16d3d --- /dev/null +++ b/shaders-msl/frag/ubo_layout.frag @@ -0,0 +1,24 @@ +#version 310 es +precision mediump float; + +layout(location = 0) out vec4 FragColor; + +struct Str +{ + mat4 foo; +}; + +layout(binding = 0, std140) uniform UBO1 +{ + layout(row_major) Str foo; +} ubo1; + +layout(binding = 1, std140) uniform UBO2 +{ + layout(column_major) Str foo; +} ubo0; + +void main() +{ + FragColor = ubo1.foo.foo[0] + ubo0.foo.foo[0]; +} diff --git a/shaders-msl/frag/unary-enclose.frag b/shaders-msl/frag/unary-enclose.frag new file mode 100644 index 0000000000..ea502e1de8 --- /dev/null +++ b/shaders-msl/frag/unary-enclose.frag @@ -0,0 +1,15 @@ +#version 310 es +precision mediump float; + +layout(location = 0) out vec4 FragColor; +layout(location = 0) in vec4 vIn; +layout(location = 1) flat in ivec4 vIn1; + +void main() +{ + FragColor = +(-(-vIn)); + ivec4 a = ~(~vIn1); + + bool b = false; + b = !!b; +} diff --git a/shaders-msl/legacy/vert/transpose.legacy.vert b/shaders-msl/legacy/vert/transpose.legacy.vert new file mode 100644 index 0000000000..84f618262a --- /dev/null +++ b/shaders-msl/legacy/vert/transpose.legacy.vert @@ -0,0 +1,20 @@ +#version 310 es + +uniform Buffer +{ + layout(row_major) mat4 MVPRowMajor; + layout(column_major) mat4 MVPColMajor; + mat4 M; +}; + +layout(location = 0) in vec4 Position; + +void main() +{ + vec4 c0 = M * (MVPRowMajor * Position); + vec4 c1 = M * (MVPColMajor * Position); + vec4 c2 = M * (Position * MVPRowMajor); + vec4 c3 = M * (Position * MVPColMajor); + gl_Position = c0 + c1 + c2 + c3; +} + diff --git a/shaders-msl/vert/basic.vert b/shaders-msl/vert/basic.vert new file mode 100644 index 0000000000..8191dc2d0f --- /dev/null +++ b/shaders-msl/vert/basic.vert @@ -0,0 +1,17 @@ +#version 310 es + +layout(std140) uniform UBO +{ + uniform mat4 uMVP; +}; + +layout(location = 0) in vec4 aVertex; +layout(location = 1) in vec3 aNormal; + +layout(location = 0) out vec3 vNormal; + +void main() +{ + gl_Position = uMVP * aVertex; + vNormal = aNormal; +} diff --git a/shaders-msl/vert/copy.flatten.vert b/shaders-msl/vert/copy.flatten.vert new file mode 100644 index 0000000000..4f1b8805e7 --- /dev/null +++ b/shaders-msl/vert/copy.flatten.vert @@ -0,0 +1,34 @@ +#version 310 es + +struct Light +{ + vec3 Position; + float Radius; + + vec4 Color; +}; + +layout(std140) uniform UBO +{ + mat4 uMVP; + + Light lights[4]; +}; + +layout(location = 0) in vec4 aVertex; +layout(location = 1) in vec3 aNormal; +layout(location = 0) out vec4 vColor; + +void main() +{ + gl_Position = uMVP * aVertex; + + vColor = vec4(0.0); + + for (int i = 0; i < 4; ++i) + { + Light light = lights[i]; + vec3 L = aVertex.xyz - light.Position; + vColor += dot(aNormal, normalize(L)) * (clamp(1.0 - length(L) / light.Radius, 0.0, 1.0) * lights[i].Color); + } +} diff --git a/shaders-msl/vert/dynamic.flatten.vert b/shaders-msl/vert/dynamic.flatten.vert new file mode 100644 index 0000000000..a341d45288 --- /dev/null +++ b/shaders-msl/vert/dynamic.flatten.vert @@ -0,0 +1,33 @@ +#version 310 es + +struct Light +{ + vec3 Position; + float Radius; + + vec4 Color; +}; + +layout(std140) uniform UBO +{ + mat4 uMVP; + + Light lights[4]; +}; + +layout(location = 0) in vec4 aVertex; +layout(location = 1) in vec3 aNormal; +layout(location = 0) out vec4 vColor; + +void main() +{ + gl_Position = uMVP * aVertex; + + vColor = vec4(0.0); + + for (int i = 0; i < 4; ++i) + { + vec3 L = aVertex.xyz - lights[i].Position; + vColor += dot(aNormal, normalize(L)) * (clamp(1.0 - length(L) / lights[i].Radius, 0.0, 1.0) * lights[i].Color); + } +} diff --git a/shaders-msl/vert/functions.vert b/shaders-msl/vert/functions.vert new file mode 100644 index 0000000000..b92074f465 --- /dev/null +++ b/shaders-msl/vert/functions.vert @@ -0,0 +1,28 @@ +#version 310 es + +layout(std140) uniform UBO +{ + uniform mat4 uMVP; + uniform vec3 rotDeg; + uniform vec3 rotRad; + uniform ivec2 bits; +}; + +layout(location = 0) in vec4 aVertex; +layout(location = 1) in vec3 aNormal; + +layout(location = 0) out vec3 vNormal; +layout(location = 1) out vec3 vRotDeg; +layout(location = 2) out vec3 vRotRad; +layout(location = 3) out ivec2 vLSB; +layout(location = 4) out ivec2 vMSB; + +void main() +{ + gl_Position = inverse(uMVP) * aVertex; + vNormal = aNormal; + vRotDeg = degrees(rotRad); + vRotRad = radians(rotDeg); + vLSB = findLSB(bits); + vMSB = findMSB(bits); +} diff --git a/shaders-msl/vert/out_block.vert b/shaders-msl/vert/out_block.vert new file mode 100644 index 0000000000..d7a50c783d --- /dev/null +++ b/shaders-msl/vert/out_block.vert @@ -0,0 +1,22 @@ +#version 450 + +uniform Transform +{ + mat4 transform; +} block; + +layout(location = 0) in vec3 position; +layout(location = 1) in vec4 color; + +layout(location = 2) out VertexOut +{ + vec4 color; + vec4 color2; +} outputs; + +void main() +{ + gl_Position = block.transform * vec4(position, 1.0); + outputs.color = color; + outputs.color2 = color + vec4(1.0); +} diff --git a/shaders-msl/vert/pointsize.vert b/shaders-msl/vert/pointsize.vert new file mode 100644 index 0000000000..0fc7136387 --- /dev/null +++ b/shaders-msl/vert/pointsize.vert @@ -0,0 +1,15 @@ +#version 450 +uniform params { + mat4 mvp; + float psize; +}; + +layout(location = 0) in vec4 position; +layout(location = 1) in vec4 color0; +layout(location = 0) out vec4 color; + +void main() { + gl_Position = mvp * position; + gl_PointSize = psize; + color = color0; +} diff --git a/shaders-msl/vert/texture_buffer.vert b/shaders-msl/vert/texture_buffer.vert new file mode 100644 index 0000000000..6bc7ddfae2 --- /dev/null +++ b/shaders-msl/vert/texture_buffer.vert @@ -0,0 +1,10 @@ +#version 310 es +#extension GL_OES_texture_buffer : require + +layout(binding = 4) uniform highp samplerBuffer uSamp; +layout(rgba32f, binding = 5) uniform readonly highp imageBuffer uSampo; + +void main() +{ + gl_Position = texelFetch(uSamp, 10) + imageLoad(uSampo, 100); +} diff --git a/shaders-msl/vert/ubo.alignment.vert b/shaders-msl/vert/ubo.alignment.vert new file mode 100644 index 0000000000..2e9d16df43 --- /dev/null +++ b/shaders-msl/vert/ubo.alignment.vert @@ -0,0 +1,23 @@ +#version 310 es + +layout(binding = 0, std140) uniform UBO +{ + mat4 mvp; + vec2 targSize; + vec3 color; // vec3 following vec2 should cause MSL to add pad if float3 is packed + float opacity; // Single float following vec3 should cause MSL float3 to pack +}; + +layout(location = 0) in vec4 aVertex; +layout(location = 1) in vec3 aNormal; +layout(location = 0) out vec3 vNormal; +layout(location = 1) out vec3 vColor; +layout(location = 2) out vec2 vSize; + +void main() +{ + gl_Position = mvp * aVertex; + vNormal = aNormal; + vColor = color * opacity; + vSize = targSize * opacity; +} diff --git a/shaders-msl/vert/ubo.vert b/shaders-msl/vert/ubo.vert new file mode 100644 index 0000000000..82e4626e12 --- /dev/null +++ b/shaders-msl/vert/ubo.vert @@ -0,0 +1,16 @@ +#version 310 es + +layout(binding = 0, std140) uniform UBO +{ + mat4 mvp; +}; + +layout(location = 0) in vec4 aVertex; +layout(location = 1) in vec3 aNormal; +layout(location = 0) out vec3 vNormal; + +void main() +{ + gl_Position = mvp * aVertex; + vNormal = aNormal; +} diff --git a/shaders-msl/vulkan/frag/push-constant.vk.frag b/shaders-msl/vulkan/frag/push-constant.vk.frag new file mode 100644 index 0000000000..6180faba31 --- /dev/null +++ b/shaders-msl/vulkan/frag/push-constant.vk.frag @@ -0,0 +1,16 @@ +#version 310 es +precision mediump float; + +layout(push_constant, std430) uniform PushConstants +{ + vec4 value0; + vec4 value1; +} push; + +layout(location = 0) in vec4 vColor; +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = vColor + push.value0 + push.value1; +} diff --git a/shaders-msl/vulkan/frag/spec-constant.vk.frag b/shaders-msl/vulkan/frag/spec-constant.vk.frag new file mode 100644 index 0000000000..3cb75da5c0 --- /dev/null +++ b/shaders-msl/vulkan/frag/spec-constant.vk.frag @@ -0,0 +1,67 @@ +#version 310 es +precision mediump float; + +layout(location = 0) out vec4 FragColor; +layout(constant_id = 1) const float a = 1.0; +layout(constant_id = 2) const float b = 2.0; +layout(constant_id = 3) const int c = 3; +layout(constant_id = 4) const int d = 4; +layout(constant_id = 5) const uint e = 5u; +layout(constant_id = 6) const uint f = 6u; +layout(constant_id = 7) const bool g = false; +layout(constant_id = 8) const bool h = true; +// glslang doesn't seem to support partial spec constants or composites yet, so only test the basics. + +void main() +{ + float t0 = a; + float t1 = b; + + uint c0 = uint(c); // OpIAdd with different types. + // FConvert, float-to-double. + int c1 = -c; // SNegate + int c2 = ~c; // OpNot + int c3 = c + d; // OpIAdd + int c4 = c - d; // OpISub + int c5 = c * d; // OpIMul + int c6 = c / d; // OpSDiv + uint c7 = e / f; // OpUDiv + int c8 = c % d; // OpSMod + uint c9 = e % f; // OpUMod + // TODO: OpSRem, any way to access this in GLSL? + int c10 = c >> d; // OpShiftRightArithmetic + uint c11 = e >> f; // OpShiftRightLogical + int c12 = c << d; // OpShiftLeftLogical + int c13 = c | d; // OpBitwiseOr + int c14 = c ^ d; // OpBitwiseXor + int c15 = c & d; // OpBitwiseAnd + // VectorShuffle, CompositeExtract, CompositeInsert, not testable atm. + bool c16 = g || h; // OpLogicalOr + bool c17 = g && h; // OpLogicalAnd + bool c18 = !g; // OpLogicalNot + bool c19 = g == h; // OpLogicalEqual + bool c20 = g != h; // OpLogicalNotEqual + // OpSelect not testable atm. + bool c21 = c == d; // OpIEqual + bool c22 = c != d; // OpINotEqual + bool c23 = c < d; // OpSLessThan + bool c24 = e < f; // OpULessThan + bool c25 = c > d; // OpSGreaterThan + bool c26 = e > f; // OpUGreaterThan + bool c27 = c <= d; // OpSLessThanEqual + bool c28 = e <= f; // OpULessThanEqual + bool c29 = c >= d; // OpSGreaterThanEqual + bool c30 = e >= f; // OpUGreaterThanEqual + // OpQuantizeToF16 not testable atm. + + int c31 = c8 + c3; + + int c32 = int(e); // OpIAdd with different types. + bool c33 = bool(c); // int -> bool + bool c34 = bool(e); // uint -> bool + int c35 = int(g); // bool -> int + uint c36 = uint(g); // bool -> uint + float c37 = float(g); // bool -> float + + FragColor = vec4(t0 + t1); +} diff --git a/shaders-msl/vulkan/vert/vulkan-vertex.vk.vert b/shaders-msl/vulkan/vert/vulkan-vertex.vk.vert new file mode 100644 index 0000000000..4d0438ace6 --- /dev/null +++ b/shaders-msl/vulkan/vert/vulkan-vertex.vk.vert @@ -0,0 +1,6 @@ +#version 310 es + +void main() +{ + gl_Position = float(gl_VertexIndex + gl_InstanceIndex) * vec4(1.0, 2.0, 3.0, 4.0); +} diff --git a/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag b/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag new file mode 100644 index 0000000000..a3f03664ca --- /dev/null +++ b/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag @@ -0,0 +1,10 @@ +#version 450 +#extension GL_AMD_shader_fragment_mask : require + +layout(input_attachment_index = 0, binding = 0) uniform subpassInputMS t; + +void main () +{ + vec4 test2 = fragmentFetchAMD(t, 4); + uint testi2 = fragmentMaskFetchAMD(t); +} diff --git a/shaders/amd/fs.invalid.frag b/shaders/amd/fs.invalid.frag new file mode 100644 index 0000000000..8cbd73e336 --- /dev/null +++ b/shaders/amd/fs.invalid.frag @@ -0,0 +1,14 @@ +#version 450 +#extension GL_AMD_shader_fragment_mask : require +#extension GL_AMD_shader_explicit_vertex_parameter : require + +uniform sampler2DMS texture1; +layout(location = 0) in vec4 vary; + +void main() +{ + uint testi1 = fragmentMaskFetchAMD(texture1, ivec2(0)); + vec4 test1 = fragmentFetchAMD(texture1, ivec2(1), 2); + + vec4 pos = interpolateAtVertexAMD(vary, 0u); +} diff --git a/shaders/amd/gcn_shader.comp b/shaders/amd/gcn_shader.comp new file mode 100644 index 0000000000..037cdde6b6 --- /dev/null +++ b/shaders/amd/gcn_shader.comp @@ -0,0 +1,13 @@ +#version 450 +#extension GL_AMD_gcn_shader : require +#extension GL_ARB_gpu_shader_int64 : require + +layout (local_size_x = 64) in; + +void main () +{ + float cubeFace = cubeFaceIndexAMD(vec3(0.0)); + vec2 cubeFaceCoord = cubeFaceCoordAMD(vec3(1.0)); + + uint64_t time = timeAMD(); +} diff --git a/shaders/amd/shader_ballot.comp b/shaders/amd/shader_ballot.comp new file mode 100644 index 0000000000..d2a7271128 --- /dev/null +++ b/shaders/amd/shader_ballot.comp @@ -0,0 +1,33 @@ +#version 450 +#extension GL_AMD_shader_ballot : require +#extension GL_ARB_shader_ballot : require + +layout (local_size_x = 64) in; +layout (std430, binding = 0) buffer inputData +{ + float inputDataArray[]; +}; + +layout (std430, binding = 1) buffer outputData +{ + float outputDataArray[]; +}; + +void main () +{ + float thisLaneData = inputDataArray [gl_LocalInvocationID.x]; + bool laneActive = (thisLaneData > 0); + + uint thisLaneOutputSlot = mbcntAMD (ballotARB (laneActive)); + + int firstInvocation = readFirstInvocationARB(1); + int invocation = readInvocationARB(1, 0); + + vec3 swizzleInvocations = swizzleInvocationsAMD(vec3(0.0, 2.0, 1.0), uvec4(3)); + vec3 swizzelInvocationsMasked = swizzleInvocationsMaskedAMD(vec3(0.0, 2.0, 1.0), uvec3(2)); + vec3 writeInvocation = writeInvocationAMD(swizzleInvocations, swizzelInvocationsMasked, 0); + + if (laneActive) { + outputDataArray[thisLaneOutputSlot] = thisLaneData; + } +} diff --git a/shaders/amd/shader_ballot_nonuniform_invocations.invalid.comp b/shaders/amd/shader_ballot_nonuniform_invocations.invalid.comp new file mode 100644 index 0000000000..afcc31d99e --- /dev/null +++ b/shaders/amd/shader_ballot_nonuniform_invocations.invalid.comp @@ -0,0 +1,9 @@ +#version 450 +#extension GL_AMD_shader_ballot : require + +void main () +{ + float addInvocations = addInvocationsNonUniformAMD(0.0); + int minInvocations = minInvocationsNonUniformAMD(1); + uint maxInvocations = maxInvocationsNonUniformAMD(4); +} diff --git a/shaders/amd/shader_group_vote.comp b/shaders/amd/shader_group_vote.comp new file mode 100644 index 0000000000..d24aa92f84 --- /dev/null +++ b/shaders/amd/shader_group_vote.comp @@ -0,0 +1,18 @@ +#version 450 +#extension GL_ARB_shader_group_vote : require + +layout (local_size_x = 64) in; +layout (std430, binding = 0) buffer inputData +{ + float inputDataArray[]; +}; + +void main () +{ + float thisLaneData = inputDataArray [gl_LocalInvocationID.x]; + bool laneActive = (thisLaneData > 0); + + bool allInvocations = allInvocationsARB(laneActive); + bool anyInvocations = anyInvocationARB(laneActive); + bool allInvocationsEqual = allInvocationsEqualARB(laneActive); +} diff --git a/shaders/amd/shader_trinary_minmax.comp b/shaders/amd/shader_trinary_minmax.comp new file mode 100644 index 0000000000..f836146a17 --- /dev/null +++ b/shaders/amd/shader_trinary_minmax.comp @@ -0,0 +1,11 @@ +#version 450 +#extension GL_AMD_shader_trinary_minmax : require + +layout (local_size_x = 64) in; + +void main () +{ + int t11 = min3(0, 3, 2); + int t12 = max3(0, 3, 2); + int t13 = mid3(0, 3, 2); +} diff --git a/shaders/asm/comp/bitcast_iadd.asm.comp b/shaders/asm/comp/bitcast_iadd.asm.comp new file mode 100644 index 0000000000..3b31ab2851 --- /dev/null +++ b/shaders/asm/comp/bitcast_iadd.asm.comp @@ -0,0 +1,79 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 1 +; Bound: 30 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %func "main" + OpExecutionMode %func LocalSize 1 1 1 + OpSource ESSL 310 + OpSourceExtension "GL_GOOGLE_cpp_style_line_directive" + OpSourceExtension "GL_GOOGLE_include_directive" + OpMemberDecorate %input_struct 0 Offset 0 + OpMemberDecorate %input_struct 1 Offset 16 + OpMemberDecorate %output_struct 0 Offset 0 + OpMemberDecorate %output_struct 1 Offset 16 + OpDecorate %input_struct BufferBlock + OpDecorate %inputs DescriptorSet 0 + OpDecorate %inputs Binding 0 + OpDecorate %inputs Restrict + OpDecorate %output_struct BufferBlock + OpDecorate %outputs DescriptorSet 0 + OpDecorate %outputs Binding 1 + OpDecorate %outputs Restrict + + %void = OpTypeVoid + %main_func = OpTypeFunction %void + + %uint = OpTypeInt 32 0 + %uvec4 = OpTypeVector %uint 4 + + %int = OpTypeInt 32 1 + %ivec4 = OpTypeVector %int 4 + + %ivec4_ptr = OpTypePointer Uniform %ivec4 + %uvec4_ptr = OpTypePointer Uniform %uvec4 + + %zero = OpConstant %int 0 + %one = OpConstant %int 1 + + %input_struct = OpTypeStruct %ivec4 %uvec4 + %input_struct_ptr = OpTypePointer Uniform %input_struct + %inputs = OpVariable %input_struct_ptr Uniform + %output_struct = OpTypeStruct %uvec4 %ivec4 + %output_struct_ptr = OpTypePointer Uniform %output_struct + %outputs = OpVariable %output_struct_ptr Uniform + + %func = OpFunction %void None %main_func + %block = OpLabel + + %input1_ptr = OpAccessChain %ivec4_ptr %inputs %zero + %input0_ptr = OpAccessChain %uvec4_ptr %inputs %one + %input1 = OpLoad %ivec4 %input1_ptr + %input0 = OpLoad %uvec4 %input0_ptr + + %output_ptr_uvec4 = OpAccessChain %uvec4_ptr %outputs %zero + %output_ptr_ivec4 = OpAccessChain %ivec4_ptr %outputs %one + +; Test all variants of IAdd + %result_iadd_0 = OpIAdd %uvec4 %input0 %input1 + %result_iadd_1 = OpIAdd %uvec4 %input1 %input0 + %result_iadd_2 = OpIAdd %uvec4 %input0 %input0 + %result_iadd_3 = OpIAdd %uvec4 %input1 %input1 + %result_iadd_4 = OpIAdd %ivec4 %input0 %input0 + %result_iadd_5 = OpIAdd %ivec4 %input1 %input1 + %result_iadd_6 = OpIAdd %ivec4 %input0 %input1 + %result_iadd_7 = OpIAdd %ivec4 %input1 %input0 + OpStore %output_ptr_uvec4 %result_iadd_0 + OpStore %output_ptr_uvec4 %result_iadd_1 + OpStore %output_ptr_uvec4 %result_iadd_2 + OpStore %output_ptr_uvec4 %result_iadd_3 + OpStore %output_ptr_ivec4 %result_iadd_4 + OpStore %output_ptr_ivec4 %result_iadd_5 + OpStore %output_ptr_ivec4 %result_iadd_6 + OpStore %output_ptr_ivec4 %result_iadd_7 + + OpReturn + OpFunctionEnd diff --git a/shaders/asm/comp/bitcast_iequal.asm.comp b/shaders/asm/comp/bitcast_iequal.asm.comp new file mode 100644 index 0000000000..c98f52c5ad --- /dev/null +++ b/shaders/asm/comp/bitcast_iequal.asm.comp @@ -0,0 +1,90 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 1 +; Bound: 30 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %func "main" + OpExecutionMode %func LocalSize 1 1 1 + OpSource ESSL 310 + OpSourceExtension "GL_GOOGLE_cpp_style_line_directive" + OpSourceExtension "GL_GOOGLE_include_directive" + OpMemberDecorate %input_struct 0 Offset 0 + OpMemberDecorate %input_struct 1 Offset 16 + OpMemberDecorate %output_struct 0 Offset 0 + OpMemberDecorate %output_struct 1 Offset 16 + OpDecorate %input_struct BufferBlock + OpDecorate %inputs DescriptorSet 0 + OpDecorate %inputs Binding 0 + OpDecorate %output_struct BufferBlock + OpDecorate %outputs DescriptorSet 0 + OpDecorate %outputs Binding 1 + + %void = OpTypeVoid + %main_func = OpTypeFunction %void + + %uint = OpTypeInt 32 0 + %uvec4 = OpTypeVector %uint 4 + + %int = OpTypeInt 32 1 + %ivec4 = OpTypeVector %int 4 + %bool = OpTypeBool + %bvec4 = OpTypeVector %bool 4 + + %ivec4_ptr = OpTypePointer Uniform %ivec4 + %uvec4_ptr = OpTypePointer Uniform %uvec4 + + %zero = OpConstant %int 0 + %one = OpConstant %int 1 + %uone = OpConstant %uint 1 + %uzero = OpConstant %uint 0 + %uvec41 = OpConstantComposite %uvec4 %uone %uone %uone %uone + %ivec41 = OpConstantComposite %ivec4 %one %one %one %one + %uvec40 = OpConstantComposite %uvec4 %uzero %uzero %uzero %uzero + %ivec40 = OpConstantComposite %ivec4 %zero %zero %zero %zero + + %input_struct = OpTypeStruct %ivec4 %uvec4 + %input_struct_ptr = OpTypePointer Uniform %input_struct + %inputs = OpVariable %input_struct_ptr Uniform + %output_struct = OpTypeStruct %uvec4 %ivec4 + %output_struct_ptr = OpTypePointer Uniform %output_struct + %outputs = OpVariable %output_struct_ptr Uniform + + %func = OpFunction %void None %main_func + %block = OpLabel + + %input1_ptr = OpAccessChain %ivec4_ptr %inputs %zero + %input0_ptr = OpAccessChain %uvec4_ptr %inputs %one + %input1 = OpLoad %ivec4 %input1_ptr + %input0 = OpLoad %uvec4 %input0_ptr + + %output_ptr_uvec4 = OpAccessChain %uvec4_ptr %outputs %zero + %output_ptr_ivec4 = OpAccessChain %ivec4_ptr %outputs %one + +; Test all variants of IEqual + %result_iequal0 = OpIEqual %bvec4 %input0 %input1 + %result_iequal1 = OpIEqual %bvec4 %input1 %input0 + %result_iequal2 = OpIEqual %bvec4 %input0 %input0 + %result_iequal3 = OpIEqual %bvec4 %input1 %input1 + %result_0 = OpSelect %uvec4 %result_iequal0 %uvec41 %uvec40 + %result_1 = OpSelect %uvec4 %result_iequal1 %uvec41 %uvec40 + %result_2 = OpSelect %uvec4 %result_iequal2 %uvec41 %uvec40 + %result_3 = OpSelect %uvec4 %result_iequal3 %uvec41 %uvec40 + %result_4 = OpSelect %ivec4 %result_iequal0 %ivec41 %ivec40 + %result_5 = OpSelect %ivec4 %result_iequal1 %ivec41 %ivec40 + %result_6 = OpSelect %ivec4 %result_iequal2 %ivec41 %ivec40 + %result_7 = OpSelect %ivec4 %result_iequal3 %ivec41 %ivec40 + + OpStore %output_ptr_uvec4 %result_0 + OpStore %output_ptr_uvec4 %result_1 + OpStore %output_ptr_uvec4 %result_2 + OpStore %output_ptr_uvec4 %result_3 + OpStore %output_ptr_ivec4 %result_4 + OpStore %output_ptr_ivec4 %result_5 + OpStore %output_ptr_ivec4 %result_6 + OpStore %output_ptr_ivec4 %result_7 + + OpReturn + OpFunctionEnd diff --git a/shaders/asm/comp/bitcast_sar.asm.comp b/shaders/asm/comp/bitcast_sar.asm.comp new file mode 100644 index 0000000000..64f19fc349 --- /dev/null +++ b/shaders/asm/comp/bitcast_sar.asm.comp @@ -0,0 +1,77 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 1 +; Bound: 30 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %func "main" + OpExecutionMode %func LocalSize 1 1 1 + OpSource ESSL 310 + OpSourceExtension "GL_GOOGLE_cpp_style_line_directive" + OpSourceExtension "GL_GOOGLE_include_directive" + OpMemberDecorate %input_struct 0 Offset 0 + OpMemberDecorate %input_struct 1 Offset 16 + OpMemberDecorate %output_struct 0 Offset 0 + OpMemberDecorate %output_struct 1 Offset 16 + OpDecorate %input_struct BufferBlock + OpDecorate %inputs DescriptorSet 0 + OpDecorate %inputs Binding 0 + OpDecorate %output_struct BufferBlock + OpDecorate %outputs DescriptorSet 0 + OpDecorate %outputs Binding 1 + + %void = OpTypeVoid + %main_func = OpTypeFunction %void + + %uint = OpTypeInt 32 0 + %uvec4 = OpTypeVector %uint 4 + + %int = OpTypeInt 32 1 + %ivec4 = OpTypeVector %int 4 + + %ivec4_ptr = OpTypePointer Uniform %ivec4 + %uvec4_ptr = OpTypePointer Uniform %uvec4 + + %zero = OpConstant %int 0 + %one = OpConstant %int 1 + + %input_struct = OpTypeStruct %ivec4 %uvec4 + %input_struct_ptr = OpTypePointer Uniform %input_struct + %inputs = OpVariable %input_struct_ptr Uniform + %output_struct = OpTypeStruct %uvec4 %ivec4 + %output_struct_ptr = OpTypePointer Uniform %output_struct + %outputs = OpVariable %output_struct_ptr Uniform + + %func = OpFunction %void None %main_func + %block = OpLabel + + %input1_ptr = OpAccessChain %ivec4_ptr %inputs %zero + %input0_ptr = OpAccessChain %uvec4_ptr %inputs %one + %input1 = OpLoad %ivec4 %input1_ptr + %input0 = OpLoad %uvec4 %input0_ptr + + %output_ptr_uvec4 = OpAccessChain %uvec4_ptr %outputs %zero + %output_ptr_ivec4 = OpAccessChain %ivec4_ptr %outputs %one + +; Test all variants of ShiftRightArithmetic + %result_iadd_0 = OpShiftRightArithmetic %uvec4 %input0 %input1 + %result_iadd_1 = OpShiftRightArithmetic %uvec4 %input1 %input0 + %result_iadd_2 = OpShiftRightArithmetic %uvec4 %input0 %input0 + %result_iadd_3 = OpShiftRightArithmetic %uvec4 %input1 %input1 + %result_iadd_4 = OpShiftRightArithmetic %ivec4 %input0 %input0 + %result_iadd_5 = OpShiftRightArithmetic %ivec4 %input1 %input1 + %result_iadd_6 = OpShiftRightArithmetic %ivec4 %input0 %input1 + %result_iadd_7 = OpShiftRightArithmetic %ivec4 %input1 %input0 + OpStore %output_ptr_uvec4 %result_iadd_0 + OpStore %output_ptr_uvec4 %result_iadd_1 + OpStore %output_ptr_uvec4 %result_iadd_2 + OpStore %output_ptr_uvec4 %result_iadd_3 + OpStore %output_ptr_ivec4 %result_iadd_4 + OpStore %output_ptr_ivec4 %result_iadd_5 + OpStore %output_ptr_ivec4 %result_iadd_6 + OpStore %output_ptr_ivec4 %result_iadd_7 + + OpReturn + OpFunctionEnd diff --git a/shaders/asm/comp/bitcast_sdiv.asm.comp b/shaders/asm/comp/bitcast_sdiv.asm.comp new file mode 100644 index 0000000000..ab73ec83df --- /dev/null +++ b/shaders/asm/comp/bitcast_sdiv.asm.comp @@ -0,0 +1,77 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 1 +; Bound: 30 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %func "main" + OpExecutionMode %func LocalSize 1 1 1 + OpSource ESSL 310 + OpSourceExtension "GL_GOOGLE_cpp_style_line_directive" + OpSourceExtension "GL_GOOGLE_include_directive" + OpMemberDecorate %input_struct 0 Offset 0 + OpMemberDecorate %input_struct 1 Offset 16 + OpMemberDecorate %output_struct 0 Offset 0 + OpMemberDecorate %output_struct 1 Offset 16 + OpDecorate %input_struct BufferBlock + OpDecorate %inputs DescriptorSet 0 + OpDecorate %inputs Binding 0 + OpDecorate %output_struct BufferBlock + OpDecorate %outputs DescriptorSet 0 + OpDecorate %outputs Binding 1 + + %void = OpTypeVoid + %main_func = OpTypeFunction %void + + %uint = OpTypeInt 32 0 + %uvec4 = OpTypeVector %uint 4 + + %int = OpTypeInt 32 1 + %ivec4 = OpTypeVector %int 4 + + %ivec4_ptr = OpTypePointer Uniform %ivec4 + %uvec4_ptr = OpTypePointer Uniform %uvec4 + + %zero = OpConstant %int 0 + %one = OpConstant %int 1 + + %input_struct = OpTypeStruct %ivec4 %uvec4 + %input_struct_ptr = OpTypePointer Uniform %input_struct + %inputs = OpVariable %input_struct_ptr Uniform + %output_struct = OpTypeStruct %uvec4 %ivec4 + %output_struct_ptr = OpTypePointer Uniform %output_struct + %outputs = OpVariable %output_struct_ptr Uniform + + %func = OpFunction %void None %main_func + %block = OpLabel + + %input1_ptr = OpAccessChain %ivec4_ptr %inputs %zero + %input0_ptr = OpAccessChain %uvec4_ptr %inputs %one + %input1 = OpLoad %ivec4 %input1_ptr + %input0 = OpLoad %uvec4 %input0_ptr + + %output_ptr_uvec4 = OpAccessChain %uvec4_ptr %outputs %zero + %output_ptr_ivec4 = OpAccessChain %ivec4_ptr %outputs %one + +; Test all variants of SDiv + %result_iadd_0 = OpSDiv %uvec4 %input0 %input1 + %result_iadd_1 = OpSDiv %uvec4 %input1 %input0 + %result_iadd_2 = OpSDiv %uvec4 %input0 %input0 + %result_iadd_3 = OpSDiv %uvec4 %input1 %input1 + %result_iadd_4 = OpSDiv %ivec4 %input0 %input0 + %result_iadd_5 = OpSDiv %ivec4 %input1 %input1 + %result_iadd_6 = OpSDiv %ivec4 %input0 %input1 + %result_iadd_7 = OpSDiv %ivec4 %input1 %input0 + OpStore %output_ptr_uvec4 %result_iadd_0 + OpStore %output_ptr_uvec4 %result_iadd_1 + OpStore %output_ptr_uvec4 %result_iadd_2 + OpStore %output_ptr_uvec4 %result_iadd_3 + OpStore %output_ptr_ivec4 %result_iadd_4 + OpStore %output_ptr_ivec4 %result_iadd_5 + OpStore %output_ptr_ivec4 %result_iadd_6 + OpStore %output_ptr_ivec4 %result_iadd_7 + + OpReturn + OpFunctionEnd diff --git a/shaders/asm/comp/bitcast_slr.asm.comp b/shaders/asm/comp/bitcast_slr.asm.comp new file mode 100644 index 0000000000..6741f5cb58 --- /dev/null +++ b/shaders/asm/comp/bitcast_slr.asm.comp @@ -0,0 +1,77 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 1 +; Bound: 30 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %func "main" + OpExecutionMode %func LocalSize 1 1 1 + OpSource ESSL 310 + OpSourceExtension "GL_GOOGLE_cpp_style_line_directive" + OpSourceExtension "GL_GOOGLE_include_directive" + OpMemberDecorate %input_struct 0 Offset 0 + OpMemberDecorate %input_struct 1 Offset 16 + OpMemberDecorate %output_struct 0 Offset 0 + OpMemberDecorate %output_struct 1 Offset 16 + OpDecorate %input_struct BufferBlock + OpDecorate %inputs DescriptorSet 0 + OpDecorate %inputs Binding 0 + OpDecorate %output_struct BufferBlock + OpDecorate %outputs DescriptorSet 0 + OpDecorate %outputs Binding 1 + + %void = OpTypeVoid + %main_func = OpTypeFunction %void + + %uint = OpTypeInt 32 0 + %uvec4 = OpTypeVector %uint 4 + + %int = OpTypeInt 32 1 + %ivec4 = OpTypeVector %int 4 + + %ivec4_ptr = OpTypePointer Uniform %ivec4 + %uvec4_ptr = OpTypePointer Uniform %uvec4 + + %zero = OpConstant %int 0 + %one = OpConstant %int 1 + + %input_struct = OpTypeStruct %ivec4 %uvec4 + %input_struct_ptr = OpTypePointer Uniform %input_struct + %inputs = OpVariable %input_struct_ptr Uniform + %output_struct = OpTypeStruct %uvec4 %ivec4 + %output_struct_ptr = OpTypePointer Uniform %output_struct + %outputs = OpVariable %output_struct_ptr Uniform + + %func = OpFunction %void None %main_func + %block = OpLabel + + %input1_ptr = OpAccessChain %ivec4_ptr %inputs %zero + %input0_ptr = OpAccessChain %uvec4_ptr %inputs %one + %input1 = OpLoad %ivec4 %input1_ptr + %input0 = OpLoad %uvec4 %input0_ptr + + %output_ptr_uvec4 = OpAccessChain %uvec4_ptr %outputs %zero + %output_ptr_ivec4 = OpAccessChain %ivec4_ptr %outputs %one + +; Test all variants of ShiftRightLogical + %result_iadd_0 = OpShiftRightLogical %uvec4 %input0 %input1 + %result_iadd_1 = OpShiftRightLogical %uvec4 %input1 %input0 + %result_iadd_2 = OpShiftRightLogical %uvec4 %input0 %input0 + %result_iadd_3 = OpShiftRightLogical %uvec4 %input1 %input1 + %result_iadd_4 = OpShiftRightLogical %ivec4 %input0 %input0 + %result_iadd_5 = OpShiftRightLogical %ivec4 %input1 %input1 + %result_iadd_6 = OpShiftRightLogical %ivec4 %input0 %input1 + %result_iadd_7 = OpShiftRightLogical %ivec4 %input1 %input0 + OpStore %output_ptr_uvec4 %result_iadd_0 + OpStore %output_ptr_uvec4 %result_iadd_1 + OpStore %output_ptr_uvec4 %result_iadd_2 + OpStore %output_ptr_uvec4 %result_iadd_3 + OpStore %output_ptr_ivec4 %result_iadd_4 + OpStore %output_ptr_ivec4 %result_iadd_5 + OpStore %output_ptr_ivec4 %result_iadd_6 + OpStore %output_ptr_ivec4 %result_iadd_7 + + OpReturn + OpFunctionEnd diff --git a/shaders/asm/comp/logical.asm.comp b/shaders/asm/comp/logical.asm.comp new file mode 100644 index 0000000000..4174e77f3d --- /dev/null +++ b/shaders/asm/comp/logical.asm.comp @@ -0,0 +1,191 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 1 +; Bound: 152 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + OpSource ESSL 310 + OpName %main "main" + OpName %and_b1_b1_ "and(b1;b1;" + OpName %a "a" + OpName %b "b" + OpName %and_vb2_vb2_ "and(vb2;vb2;" + OpName %a_0 "a" + OpName %b_0 "b" + OpName %and_vb3_vb3_ "and(vb3;vb3;" + OpName %a_1 "a" + OpName %b_1 "b" + OpName %and_vb4_vb4_ "and(vb4;vb4;" + OpName %a_2 "a" + OpName %b_2 "b" + OpName %b0 "b0" + OpName %SSBO0 "SSBO0" + OpMemberName %SSBO0 0 "a" + OpMemberName %SSBO0 1 "b" + OpMemberName %SSBO0 2 "c" + OpMemberName %SSBO0 3 "d" + OpName %s0 "s0" + OpName %SSBO1 "SSBO1" + OpMemberName %SSBO1 0 "a" + OpMemberName %SSBO1 1 "b" + OpMemberName %SSBO1 2 "c" + OpMemberName %SSBO1 3 "d" + OpName %s1 "s1" + OpName %param "param" + OpName %param_0 "param" + OpName %b1 "b1" + OpName %param_1 "param" + OpName %param_2 "param" + OpName %b2 "b2" + OpName %param_3 "param" + OpName %param_4 "param" + OpName %b3 "b3" + OpName %param_5 "param" + OpName %param_6 "param" + OpMemberDecorate %SSBO0 0 Offset 0 + OpMemberDecorate %SSBO0 1 Offset 8 + OpMemberDecorate %SSBO0 2 Offset 16 + OpMemberDecorate %SSBO0 3 Offset 32 + OpDecorate %SSBO0 BufferBlock + OpDecorate %s0 DescriptorSet 0 + OpDecorate %s0 Binding 0 + OpMemberDecorate %SSBO1 0 Offset 0 + OpMemberDecorate %SSBO1 1 Offset 8 + OpMemberDecorate %SSBO1 2 Offset 16 + OpMemberDecorate %SSBO1 3 Offset 32 + OpDecorate %SSBO1 BufferBlock + OpDecorate %s1 DescriptorSet 0 + OpDecorate %s1 Binding 1 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %bool = OpTypeBool +%_ptr_Function_bool = OpTypePointer Function %bool + %8 = OpTypeFunction %bool %_ptr_Function_bool %_ptr_Function_bool + %v2bool = OpTypeVector %bool 2 +%_ptr_Function_v2bool = OpTypePointer Function %v2bool + %15 = OpTypeFunction %v2bool %_ptr_Function_v2bool %_ptr_Function_v2bool + %v3bool = OpTypeVector %bool 3 +%_ptr_Function_v3bool = OpTypePointer Function %v3bool + %22 = OpTypeFunction %v3bool %_ptr_Function_v3bool %_ptr_Function_v3bool + %v4bool = OpTypeVector %bool 4 +%_ptr_Function_v4bool = OpTypePointer Function %v4bool + %29 = OpTypeFunction %v4bool %_ptr_Function_v4bool %_ptr_Function_v4bool + %float = OpTypeFloat 32 + %v2float = OpTypeVector %float 2 + %v3float = OpTypeVector %float 3 + %v4float = OpTypeVector %float 4 + %SSBO0 = OpTypeStruct %float %v2float %v3float %v4float +%_ptr_Uniform_SSBO0 = OpTypePointer Uniform %SSBO0 + %s0 = OpVariable %_ptr_Uniform_SSBO0 Uniform + %int = OpTypeInt 32 1 + %102 = OpConstant %int 0 +%_ptr_Uniform_float = OpTypePointer Uniform %float + %SSBO1 = OpTypeStruct %float %v2float %v3float %v4float +%_ptr_Uniform_SSBO1 = OpTypePointer Uniform %SSBO1 + %s1 = OpVariable %_ptr_Uniform_SSBO1 Uniform + %117 = OpConstant %int 1 +%_ptr_Uniform_v2float = OpTypePointer Uniform %v2float + %129 = OpConstant %int 2 +%_ptr_Uniform_v3float = OpTypePointer Uniform %v3float + %141 = OpConstant %int 3 +%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float + %main = OpFunction %void None %3 + %5 = OpLabel + %b0 = OpVariable %_ptr_Function_bool Function + %param = OpVariable %_ptr_Function_bool Function + %param_0 = OpVariable %_ptr_Function_bool Function + %b1 = OpVariable %_ptr_Function_v2bool Function + %param_1 = OpVariable %_ptr_Function_v2bool Function + %param_2 = OpVariable %_ptr_Function_v2bool Function + %b2 = OpVariable %_ptr_Function_v3bool Function + %param_3 = OpVariable %_ptr_Function_v3bool Function + %param_4 = OpVariable %_ptr_Function_v3bool Function + %b3 = OpVariable %_ptr_Function_v4bool Function + %param_5 = OpVariable %_ptr_Function_v4bool Function + %param_6 = OpVariable %_ptr_Function_v4bool Function + %104 = OpAccessChain %_ptr_Uniform_float %s0 %102 + %105 = OpLoad %float %104 + %106 = OpIsInf %bool %105 + %110 = OpAccessChain %_ptr_Uniform_float %s1 %102 + %111 = OpLoad %float %110 + %112 = OpIsNan %bool %111 + OpStore %param %106 + OpStore %param_0 %112 + %115 = OpFunctionCall %bool %and_b1_b1_ %param %param_0 + OpStore %b0 %115 + %119 = OpAccessChain %_ptr_Uniform_v2float %s0 %117 + %120 = OpLoad %v2float %119 + %121 = OpIsInf %v2bool %120 + %122 = OpAccessChain %_ptr_Uniform_v2float %s1 %117 + %123 = OpLoad %v2float %122 + %124 = OpIsNan %v2bool %123 + OpStore %param_1 %121 + OpStore %param_2 %124 + %127 = OpFunctionCall %v2bool %and_vb2_vb2_ %param_1 %param_2 + OpStore %b1 %127 + %131 = OpAccessChain %_ptr_Uniform_v3float %s0 %129 + %132 = OpLoad %v3float %131 + %133 = OpIsInf %v3bool %132 + %134 = OpAccessChain %_ptr_Uniform_v3float %s1 %129 + %135 = OpLoad %v3float %134 + %136 = OpIsNan %v3bool %135 + OpStore %param_3 %133 + OpStore %param_4 %136 + %139 = OpFunctionCall %v3bool %and_vb3_vb3_ %param_3 %param_4 + OpStore %b2 %139 + %143 = OpAccessChain %_ptr_Uniform_v4float %s0 %141 + %144 = OpLoad %v4float %143 + %145 = OpIsInf %v4bool %144 + %146 = OpAccessChain %_ptr_Uniform_v4float %s1 %141 + %147 = OpLoad %v4float %146 + %148 = OpIsNan %v4bool %147 + OpStore %param_5 %145 + OpStore %param_6 %148 + %151 = OpFunctionCall %v4bool %and_vb4_vb4_ %param_5 %param_6 + OpStore %b3 %151 + OpReturn + OpFunctionEnd + %and_b1_b1_ = OpFunction %bool None %8 + %a = OpFunctionParameter %_ptr_Function_bool + %b = OpFunctionParameter %_ptr_Function_bool + %12 = OpLabel + %34 = OpLoad %bool %a + %35 = OpLoad %bool %b + %36 = OpLogicalAnd %bool %34 %35 + %37 = OpLogicalOr %bool %36 %35 + %38 = OpLogicalNot %bool %37 + OpReturnValue %38 + OpFunctionEnd +%and_vb2_vb2_ = OpFunction %v2bool None %15 + %a_0 = OpFunctionParameter %_ptr_Function_v2bool + %b_0 = OpFunctionParameter %_ptr_Function_v2bool + %19 = OpLabel + %39 = OpLoad %v2bool %a_0 + %41 = OpLoad %v2bool %b_0 + %48 = OpLogicalAnd %v2bool %39 %41 + %49 = OpLogicalOr %v2bool %48 %41 + %50 = OpLogicalNot %v2bool %49 + OpReturnValue %50 + OpFunctionEnd +%and_vb3_vb3_ = OpFunction %v3bool None %22 + %a_1 = OpFunctionParameter %_ptr_Function_v3bool + %b_1 = OpFunctionParameter %_ptr_Function_v3bool + %26 = OpLabel + %52 = OpLoad %v3bool %a_1 + %54 = OpLoad %v3bool %b_1 + %66 = OpLogicalAnd %v3bool %52 %54 + OpReturnValue %66 + OpFunctionEnd +%and_vb4_vb4_ = OpFunction %v4bool None %29 + %a_2 = OpFunctionParameter %_ptr_Function_v4bool + %b_2 = OpFunctionParameter %_ptr_Function_v4bool + %33 = OpLabel + %70 = OpLoad %v4bool %a_2 + %72 = OpLoad %v4bool %b_2 + %74 = OpLogicalAnd %v4bool %70 %72 + OpReturnValue %74 + OpFunctionEnd diff --git a/shaders/asm/comp/multiple-entry.asm.comp b/shaders/asm/comp/multiple-entry.asm.comp new file mode 100644 index 0000000000..0cfb5543d1 --- /dev/null +++ b/shaders/asm/comp/multiple-entry.asm.comp @@ -0,0 +1,97 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 1 +; Bound: 30 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %func_alt "main2" %frag_in %frag_out + OpEntryPoint GLCompute %func "main" + OpExecutionMode %func LocalSize 1 1 1 + OpSource ESSL 310 + OpSourceExtension "GL_GOOGLE_cpp_style_line_directive" + OpSourceExtension "GL_GOOGLE_include_directive" + OpMemberDecorate %input_struct 0 Offset 0 + OpMemberDecorate %input_struct 1 Offset 16 + OpMemberDecorate %output_struct 0 Offset 0 + OpMemberDecorate %output_struct 1 Offset 16 + OpDecorate %input_struct BufferBlock + OpDecorate %inputs DescriptorSet 0 + OpDecorate %inputs Binding 0 + OpDecorate %inputs Restrict + OpDecorate %output_struct BufferBlock + OpDecorate %outputs DescriptorSet 0 + OpDecorate %outputs Binding 1 + OpDecorate %outputs Restrict + OpDecorate %frag_in Location 0 + OpDecorate %frag_out Location 0 + + %void = OpTypeVoid + %main_func = OpTypeFunction %void + + %uint = OpTypeInt 32 0 + %uvec4 = OpTypeVector %uint 4 + + %int = OpTypeInt 32 1 + %ivec4 = OpTypeVector %int 4 + + %ivec4_ptr = OpTypePointer Uniform %ivec4 + %uvec4_ptr = OpTypePointer Uniform %uvec4 + + %float = OpTypeFloat 32 + %vec4 = OpTypeVector %float 4 + %vec4_input_ptr = OpTypePointer Input %vec4 + %vec4_output_ptr = OpTypePointer Output %vec4 + + %zero = OpConstant %int 0 + %one = OpConstant %int 1 + + %input_struct = OpTypeStruct %ivec4 %uvec4 + %input_struct_ptr = OpTypePointer Uniform %input_struct + %inputs = OpVariable %input_struct_ptr Uniform + %output_struct = OpTypeStruct %uvec4 %ivec4 + %output_struct_ptr = OpTypePointer Uniform %output_struct + %outputs = OpVariable %output_struct_ptr Uniform + + %frag_in = OpVariable %vec4_input_ptr Input + %frag_out = OpVariable %vec4_output_ptr Output + + %func = OpFunction %void None %main_func + %block = OpLabel + + %input1_ptr = OpAccessChain %ivec4_ptr %inputs %zero + %input0_ptr = OpAccessChain %uvec4_ptr %inputs %one + %input1 = OpLoad %ivec4 %input1_ptr + %input0 = OpLoad %uvec4 %input0_ptr + + %output_ptr_uvec4 = OpAccessChain %uvec4_ptr %outputs %zero + %output_ptr_ivec4 = OpAccessChain %ivec4_ptr %outputs %one + +; Test all variants of IAdd + %result_iadd_0 = OpIAdd %uvec4 %input0 %input1 + %result_iadd_1 = OpIAdd %uvec4 %input1 %input0 + %result_iadd_2 = OpIAdd %uvec4 %input0 %input0 + %result_iadd_3 = OpIAdd %uvec4 %input1 %input1 + %result_iadd_4 = OpIAdd %ivec4 %input0 %input0 + %result_iadd_5 = OpIAdd %ivec4 %input1 %input1 + %result_iadd_6 = OpIAdd %ivec4 %input0 %input1 + %result_iadd_7 = OpIAdd %ivec4 %input1 %input0 + OpStore %output_ptr_uvec4 %result_iadd_0 + OpStore %output_ptr_uvec4 %result_iadd_1 + OpStore %output_ptr_uvec4 %result_iadd_2 + OpStore %output_ptr_uvec4 %result_iadd_3 + OpStore %output_ptr_ivec4 %result_iadd_4 + OpStore %output_ptr_ivec4 %result_iadd_5 + OpStore %output_ptr_ivec4 %result_iadd_6 + OpStore %output_ptr_ivec4 %result_iadd_7 + + OpReturn + OpFunctionEnd + + %func_alt = OpFunction %void None %main_func + %block_alt = OpLabel + %frag_input_value = OpLoad %vec4 %frag_in + OpStore %frag_out %frag_input_value + OpReturn + OpFunctionEnd diff --git a/shaders/asm/comp/name-alias.asm.invalid.comp b/shaders/asm/comp/name-alias.asm.invalid.comp new file mode 100644 index 0000000000..f9bc6dbb67 --- /dev/null +++ b/shaders/asm/comp/name-alias.asm.invalid.comp @@ -0,0 +1,124 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 1 +; Bound: 48 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpName %4 "alias" + OpName %15 "alias" + OpMemberName %15 0 "alias" + OpName %18 "alias" + OpMemberName %18 0 "alias" + OpMemberName %18 1 "alias" + OpMemberName %18 2 "alias" + OpName %19 "alias" + OpMemberName %19 0 "alias" + OpMemberName %19 1 "alias" + OpName %21 "alias" + OpName %24 "alias" + OpMemberName %24 0 "alias" + OpName %26 "alias" + OpMemberName %26 0 "alias" + OpMemberName %26 1 "alias" + OpMemberName %26 2 "alias" + OpName %27 "alias" + OpMemberName %27 0 "alias" + OpMemberName %27 1 "alias" + OpName %28 "alias" + OpMemberName %28 0 "alias" + OpName %30 "alias" + OpName %38 "alias" + OpMemberName %38 0 "alias" + OpName %40 "alias" + OpMemberName %40 0 "alias" + OpMemberName %40 1 "alias" + OpMemberName %40 2 "alias" + OpName %41 "alias" + OpMemberName %41 0 "alias" + OpMemberName %41 1 "alias" + OpName %42 "alias" + OpMemberName %42 0 "alias" + OpName %44 "alias" + OpDecorate %22 ArrayStride 8 + OpDecorate %23 ArrayStride 16 + OpMemberDecorate %24 0 Offset 0 + OpDecorate %25 ArrayStride 1600 + OpMemberDecorate %26 0 Offset 0 + OpMemberDecorate %26 1 Offset 16 + OpMemberDecorate %26 2 Offset 96 + OpMemberDecorate %27 0 Offset 0 + OpMemberDecorate %27 1 Offset 16 + OpMemberDecorate %28 0 Offset 0 + OpDecorate %28 BufferBlock + OpDecorate %30 DescriptorSet 0 + OpDecorate %30 Binding 0 + OpDecorate %36 ArrayStride 16 + OpDecorate %37 ArrayStride 16 + OpMemberDecorate %38 0 Offset 0 + OpDecorate %39 ArrayStride 1600 + OpMemberDecorate %40 0 Offset 0 + OpMemberDecorate %40 1 Offset 16 + OpMemberDecorate %40 2 Offset 176 + OpMemberDecorate %41 0 Offset 0 + OpMemberDecorate %41 1 Offset 16 + OpMemberDecorate %42 0 Offset 0 + OpDecorate %42 BufferBlock + OpDecorate %44 DescriptorSet 0 + OpDecorate %44 Binding 1 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeVector %6 4 + %8 = OpTypeVector %6 2 + %9 = OpTypeInt 32 0 + %10 = OpConstant %9 10 + %11 = OpTypeArray %8 %10 + %12 = OpTypeVector %6 3 + %13 = OpConstant %9 100 + %14 = OpTypeArray %12 %13 + %15 = OpTypeStruct %14 + %16 = OpConstant %9 2 + %17 = OpTypeArray %15 %16 + %18 = OpTypeStruct %7 %11 %17 + %19 = OpTypeStruct %7 %18 + %20 = OpTypePointer Function %19 + %22 = OpTypeArray %8 %10 + %23 = OpTypeArray %12 %13 + %24 = OpTypeStruct %23 + %25 = OpTypeArray %24 %16 + %26 = OpTypeStruct %7 %22 %25 + %27 = OpTypeStruct %7 %26 + %28 = OpTypeStruct %27 + %29 = OpTypePointer Uniform %28 + %30 = OpVariable %29 Uniform + %31 = OpTypeInt 32 1 + %32 = OpConstant %31 0 + %33 = OpTypePointer Uniform %27 + %36 = OpTypeArray %8 %10 + %37 = OpTypeArray %12 %13 + %38 = OpTypeStruct %37 + %39 = OpTypeArray %38 %16 + %40 = OpTypeStruct %7 %36 %39 + %41 = OpTypeStruct %7 %40 + %42 = OpTypeStruct %41 + %43 = OpTypePointer Uniform %42 + %44 = OpVariable %43 Uniform + %46 = OpTypePointer Uniform %41 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %21 = OpVariable %20 Function + %34 = OpAccessChain %33 %30 %32 + %35 = OpLoad %27 %34 +; This shader has an illegal aliased store for testing purposes. spirv-val is not run for this shader. + OpStore %21 %35 + %45 = OpLoad %19 %21 + %47 = OpAccessChain %46 %44 %32 +; This shader has an illegal aliased store for testing purposes. spirv-val is not run for this shader. + OpStore %47 %45 + OpReturn + OpFunctionEnd diff --git a/shaders/asm/comp/quantize.asm.comp b/shaders/asm/comp/quantize.asm.comp new file mode 100644 index 0000000000..f5afc6570c --- /dev/null +++ b/shaders/asm/comp/quantize.asm.comp @@ -0,0 +1,67 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 1 +; Bound: 38 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %4 "main" + OpExecutionMode %4 LocalSize 1 1 1 + OpSource ESSL 310 + OpName %4 "main" + OpName %10 "SSBO0" + OpMemberName %10 0 "scalar" + OpMemberName %10 1 "vec2_val" + OpMemberName %10 2 "vec3_val" + OpMemberName %10 3 "vec4_val" + OpName %12 "" + OpMemberDecorate %10 0 Offset 0 + OpMemberDecorate %10 1 Offset 8 + OpMemberDecorate %10 2 Offset 16 + OpMemberDecorate %10 3 Offset 32 + OpDecorate %10 BufferBlock + OpDecorate %12 DescriptorSet 0 + OpDecorate %12 Binding 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeVector %6 2 + %8 = OpTypeVector %6 3 + %9 = OpTypeVector %6 4 + %10 = OpTypeStruct %6 %7 %8 %9 + %11 = OpTypePointer Uniform %10 + %12 = OpVariable %11 Uniform + %13 = OpTypeInt 32 1 + %14 = OpConstant %13 0 + %15 = OpTypePointer Uniform %6 + %20 = OpConstant %13 1 + %21 = OpTypePointer Uniform %7 + %26 = OpConstant %13 2 + %27 = OpTypePointer Uniform %8 + %32 = OpConstant %13 3 + %33 = OpTypePointer Uniform %9 + %4 = OpFunction %2 None %3 + %5 = OpLabel + %16 = OpAccessChain %15 %12 %14 + %17 = OpLoad %6 %16 + %18 = OpQuantizeToF16 %6 %17 + %19 = OpAccessChain %15 %12 %14 + OpStore %19 %18 + %22 = OpAccessChain %21 %12 %20 + %23 = OpLoad %7 %22 + %24 = OpQuantizeToF16 %7 %23 + %25 = OpAccessChain %21 %12 %20 + OpStore %25 %24 + %28 = OpAccessChain %27 %12 %26 + %29 = OpLoad %8 %28 + %30 = OpQuantizeToF16 %8 %29 + %31 = OpAccessChain %27 %12 %26 + OpStore %31 %30 + %34 = OpAccessChain %33 %12 %32 + %35 = OpLoad %9 %34 + %36 = OpQuantizeToF16 %9 %35 + %37 = OpAccessChain %33 %12 %32 + OpStore %37 %36 + OpReturn + OpFunctionEnd diff --git a/shaders/asm/comp/specialization-constant-workgroup.asm.comp b/shaders/asm/comp/specialization-constant-workgroup.asm.comp new file mode 100644 index 0000000000..188e3fec36 --- /dev/null +++ b/shaders/asm/comp/specialization-constant-workgroup.asm.comp @@ -0,0 +1,47 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 1 +; Bound: 24 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 20 1 + OpSource ESSL 310 + OpName %main "main" + OpName %SSBO "SSBO" + OpMemberName %SSBO 0 "a" + OpName %_ "" + OpMemberDecorate %SSBO 0 Offset 0 + OpDecorate %SSBO BufferBlock + OpDecorate %_ DescriptorSet 0 + OpDecorate %_ Binding 0 + OpDecorate %19 SpecId 10 + OpDecorate %21 SpecId 12 + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %SSBO = OpTypeStruct %float +%_ptr_Uniform_SSBO = OpTypePointer Uniform %SSBO + %_ = OpVariable %_ptr_Uniform_SSBO Uniform + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %float_1 = OpConstant %float 1 +%_ptr_Uniform_float = OpTypePointer Uniform %float + %uint = OpTypeInt 32 0 + %19 = OpSpecConstant %uint 9 + %uint_20 = OpConstant %uint 20 + %21 = OpSpecConstant %uint 4 + %v3uint = OpTypeVector %uint 3 +%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %19 %uint_20 %21 + %main = OpFunction %void None %3 + %5 = OpLabel + %14 = OpAccessChain %_ptr_Uniform_float %_ %int_0 + %15 = OpLoad %float %14 + %16 = OpFAdd %float %15 %float_1 + %17 = OpAccessChain %_ptr_Uniform_float %_ %int_0 + OpStore %17 %16 + OpReturn + OpFunctionEnd diff --git a/shaders/asm/comp/storage-buffer-basic.asm.comp b/shaders/asm/comp/storage-buffer-basic.asm.comp new file mode 100644 index 0000000000..edb1a05e54 --- /dev/null +++ b/shaders/asm/comp/storage-buffer-basic.asm.comp @@ -0,0 +1,57 @@ +; SPIR-V +; Version: 1.0 +; Generator: Codeplay; 0 +; Bound: 31 +; Schema: 0 + OpCapability Shader + OpCapability VariablePointers + OpExtension "SPV_KHR_storage_buffer_storage_class" + OpExtension "SPV_KHR_variable_pointers" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %22 "main" %gl_WorkGroupID + OpSource OpenCL_C 120 + OpDecorate %15 SpecId 0 + ;OpDecorate %16 SpecId 1 + OpDecorate %17 SpecId 2 + OpDecorate %_runtimearr_float ArrayStride 4 + OpMemberDecorate %_struct_4 0 Offset 0 + OpDecorate %_struct_4 Block + OpDecorate %gl_WorkGroupID BuiltIn WorkgroupId + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + OpDecorate %20 DescriptorSet 0 + OpDecorate %20 Binding 0 + OpDecorate %21 DescriptorSet 0 + OpDecorate %21 Binding 1 + %float = OpTypeFloat 32 +%_ptr_StorageBuffer_float = OpTypePointer StorageBuffer %float +%_runtimearr_float = OpTypeRuntimeArray %float + %_struct_4 = OpTypeStruct %_runtimearr_float +%_ptr_StorageBuffer__struct_4 = OpTypePointer StorageBuffer %_struct_4 + %uint = OpTypeInt 32 0 + %void = OpTypeVoid + %8 = OpTypeFunction %void + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint +%_ptr_Input_uint = OpTypePointer Input %uint +%_ptr_Private_v3uint = OpTypePointer Private %v3uint + %uint_0 = OpConstant %uint 0 +%gl_WorkGroupID = OpVariable %_ptr_Input_v3uint Input + %15 = OpSpecConstant %uint 1 + %16 = OpConstant %uint 2 + %17 = OpSpecConstant %uint 3 +%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %15 %16 %17 + %19 = OpVariable %_ptr_Private_v3uint Private %gl_WorkGroupSize + %20 = OpVariable %_ptr_StorageBuffer__struct_4 StorageBuffer + %21 = OpVariable %_ptr_StorageBuffer__struct_4 StorageBuffer + %22 = OpFunction %void None %8 + %23 = OpLabel + %24 = OpAccessChain %_ptr_Input_uint %gl_WorkGroupID %uint_0 + %25 = OpLoad %uint %24 + %26 = OpAccessChain %_ptr_StorageBuffer_float %21 %uint_0 %25 + %27 = OpLoad %float %26 + %28 = OpAccessChain %_ptr_StorageBuffer_float %20 %uint_0 %25 + %29 = OpLoad %float %28 + %30 = OpFAdd %float %27 %29 + OpStore %28 %30 + OpReturn + OpFunctionEnd diff --git a/shaders/asm/frag/composite-construct-struct-no-swizzle.asm.frag b/shaders/asm/frag/composite-construct-struct-no-swizzle.asm.frag new file mode 100644 index 0000000000..f33c48617a --- /dev/null +++ b/shaders/asm/frag/composite-construct-struct-no-swizzle.asm.frag @@ -0,0 +1,51 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 3 +; Bound: 39 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %foo %FooOut + OpExecutionMode %main OriginUpperLeft + OpSource ESSL 310 + OpName %main "main" + OpName %foo "foo" + OpName %SwizzleTest "SwizzleTest" + OpMemberName %SwizzleTest 0 "a" + OpMemberName %SwizzleTest 1 "b" + OpName %FooOut "FooOut" + OpDecorate %foo RelaxedPrecision + OpDecorate %foo Location 0 + OpDecorate %12 RelaxedPrecision + OpMemberDecorate %SwizzleTest 0 RelaxedPrecision + OpMemberDecorate %SwizzleTest 1 RelaxedPrecision + OpDecorate %FooOut RelaxedPrecision + OpDecorate %FooOut Location 0 + OpDecorate %34 RelaxedPrecision + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v2float = OpTypeVector %float 2 +%_ptr_Function_v2float = OpTypePointer Function %v2float +%_ptr_Input_v2float = OpTypePointer Input %v2float + %foo = OpVariable %_ptr_Input_v2float Input +%SwizzleTest = OpTypeStruct %float %float +%_ptr_Function_SwizzleTest = OpTypePointer Function %SwizzleTest + %uint = OpTypeInt 32 0 +%_ptr_Function_float = OpTypePointer Function %float +%_ptr_Output_float = OpTypePointer Output %float + %FooOut = OpVariable %_ptr_Output_float Output + %int = OpTypeInt 32 1 + %main = OpFunction %void None %3 + %5 = OpLabel + %12 = OpLoad %v2float %foo + %36 = OpCompositeExtract %float %12 0 + %38 = OpCompositeExtract %float %12 1 + %test0 = OpCompositeConstruct %SwizzleTest %36 %38 + %new0 = OpCompositeExtract %float %test0 0 + %new1 = OpCompositeExtract %float %test0 1 + %34 = OpFAdd %float %new0 %new1 + OpStore %FooOut %34 + OpReturn + OpFunctionEnd diff --git a/shaders/asm/frag/default-member-names.asm.frag b/shaders/asm/frag/default-member-names.asm.frag new file mode 100644 index 0000000000..4d616fe493 --- /dev/null +++ b/shaders/asm/frag/default-member-names.asm.frag @@ -0,0 +1,57 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 1 +; Bound: 43 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 + OpExecutionMode %2 OriginLowerLeft + OpDecorate %3 Location 0 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %12 = OpTypeFunction %v4float + %_struct_5 = OpTypeStruct %float + %_struct_6 = OpTypeStruct %float %float %float %float %float %float %float %float %float %float %float %float %_struct_5 +%_ptr_Function__struct_6 = OpTypePointer Function %_struct_6 + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 +%_ptr_Function_float = OpTypePointer Function %float + %int_1 = OpConstant %int 1 + %int_2 = OpConstant %int 2 + %int_3 = OpConstant %int 3 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %3 = OpVariable %_ptr_Output_v4float Output +%_ptr_Function_v4float = OpTypePointer Function %v4float + %2 = OpFunction %void None %9 + %22 = OpLabel + %23 = OpVariable %_ptr_Function__struct_6 Function + %24 = OpAccessChain %_ptr_Function_float %23 %int_0 + %25 = OpLoad %float %24 + %26 = OpAccessChain %_ptr_Function_float %23 %int_1 + %27 = OpLoad %float %26 + %28 = OpAccessChain %_ptr_Function_float %23 %int_2 + %29 = OpLoad %float %28 + %30 = OpAccessChain %_ptr_Function_float %23 %int_3 + %31 = OpLoad %float %30 + %32 = OpCompositeConstruct %v4float %25 %27 %29 %31 + OpStore %3 %32 + OpReturn + OpFunctionEnd + %4 = OpFunction %v4float None %12 + %33 = OpLabel + %7 = OpVariable %_ptr_Function__struct_6 Function + %34 = OpAccessChain %_ptr_Function_float %7 %int_0 + %35 = OpLoad %float %34 + %36 = OpAccessChain %_ptr_Function_float %7 %int_1 + %37 = OpLoad %float %36 + %38 = OpAccessChain %_ptr_Function_float %7 %int_2 + %39 = OpLoad %float %38 + %40 = OpAccessChain %_ptr_Function_float %7 %int_3 + %41 = OpLoad %float %40 + %42 = OpCompositeConstruct %v4float %35 %37 %39 %41 + OpReturnValue %42 + OpFunctionEnd diff --git a/shaders/asm/frag/hlsl-sample-cmp-level-zero-cube.asm.frag b/shaders/asm/frag/hlsl-sample-cmp-level-zero-cube.asm.frag new file mode 100644 index 0000000000..2be18cfeeb --- /dev/null +++ b/shaders/asm/frag/hlsl-sample-cmp-level-zero-cube.asm.frag @@ -0,0 +1,58 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 1 +; Bound: 38 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %_entryPointOutput + OpExecutionMode %main OriginUpperLeft + OpSource HLSL 500 + OpName %main "main" + OpName %_main_ "@main(" + OpName %pointLightShadowMap "pointLightShadowMap" + OpName %shadowSamplerPCF "shadowSamplerPCF" + OpName %_entryPointOutput "@entryPointOutput" + OpDecorate %pointLightShadowMap DescriptorSet 0 + OpDecorate %shadowSamplerPCF DescriptorSet 0 + OpDecorate %_entryPointOutput Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %7 = OpTypeFunction %float + %10 = OpTypeImage %float Cube 0 0 0 1 Unknown +%_ptr_UniformConstant_10 = OpTypePointer UniformConstant %10 +%pointLightShadowMap = OpVariable %_ptr_UniformConstant_10 UniformConstant + %14 = OpTypeSampler +%_ptr_UniformConstant_14 = OpTypePointer UniformConstant %14 +%shadowSamplerPCF = OpVariable %_ptr_UniformConstant_14 UniformConstant + %18 = OpTypeImage %float Cube 1 0 0 1 Unknown + %19 = OpTypeSampledImage %18 + %v3float = OpTypeVector %float 3 + %float_0_1 = OpConstant %float 0.1 + %23 = OpConstantComposite %v3float %float_0_1 %float_0_1 %float_0_1 + %float_0_5 = OpConstant %float 0.5 + %v4float = OpTypeVector %float 4 + %float_0 = OpConstant %float 0 +%_ptr_Output_float = OpTypePointer Output %float +%_entryPointOutput = OpVariable %_ptr_Output_float Output + %main = OpFunction %void None %3 + %5 = OpLabel + %37 = OpFunctionCall %float %_main_ + OpStore %_entryPointOutput %37 + OpReturn + OpFunctionEnd + %_main_ = OpFunction %float None %7 + %9 = OpLabel + %13 = OpLoad %10 %pointLightShadowMap + %17 = OpLoad %14 %shadowSamplerPCF + %20 = OpSampledImage %19 %13 %17 + %26 = OpCompositeExtract %float %23 0 + %27 = OpCompositeExtract %float %23 1 + %28 = OpCompositeExtract %float %23 2 + %29 = OpCompositeConstruct %v4float %26 %27 %28 %float_0_5 + %31 = OpCompositeExtract %float %29 3 + %32 = OpImageSampleDrefExplicitLod %float %20 %29 %31 Lod %float_0 + OpReturnValue %32 + OpFunctionEnd diff --git a/shaders/asm/frag/hlsl-sample-cmp-level-zero.asm.frag b/shaders/asm/frag/hlsl-sample-cmp-level-zero.asm.frag new file mode 100644 index 0000000000..34fb6e834b --- /dev/null +++ b/shaders/asm/frag/hlsl-sample-cmp-level-zero.asm.frag @@ -0,0 +1,113 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 1 +; Bound: 70 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %texCoords_1 %cascadeIndex_1 %fragDepth_1 %_entryPointOutput + OpExecutionMode %main OriginUpperLeft + OpSource HLSL 500 + OpName %main "main" + OpName %_main_vf2_f1_f1_ "@main(vf2;f1;f1;" + OpName %texCoords "texCoords" + OpName %cascadeIndex "cascadeIndex" + OpName %fragDepth "fragDepth" + OpName %c "c" + OpName %ShadowMap "ShadowMap" + OpName %ShadowSamplerPCF "ShadowSamplerPCF" + OpName %texCoords_0 "texCoords" + OpName %texCoords_1 "texCoords" + OpName %cascadeIndex_0 "cascadeIndex" + OpName %cascadeIndex_1 "cascadeIndex" + OpName %fragDepth_0 "fragDepth" + OpName %fragDepth_1 "fragDepth" + OpName %_entryPointOutput "@entryPointOutput" + OpName %param "param" + OpName %param_0 "param" + OpName %param_1 "param" + OpDecorate %ShadowMap DescriptorSet 0 + OpDecorate %ShadowSamplerPCF DescriptorSet 0 + OpDecorate %texCoords_1 Location 0 + OpDecorate %cascadeIndex_1 Location 1 + OpDecorate %fragDepth_1 Location 2 + OpDecorate %_entryPointOutput Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v2float = OpTypeVector %float 2 +%_ptr_Function_v2float = OpTypePointer Function %v2float +%_ptr_Function_float = OpTypePointer Function %float + %v4float = OpTypeVector %float 4 + %11 = OpTypeFunction %v4float %_ptr_Function_v2float %_ptr_Function_float %_ptr_Function_float + %18 = OpTypeImage %float 2D 0 1 0 1 Unknown +%_ptr_UniformConstant_18 = OpTypePointer UniformConstant %18 + %ShadowMap = OpVariable %_ptr_UniformConstant_18 UniformConstant + %22 = OpTypeSampler +%_ptr_UniformConstant_22 = OpTypePointer UniformConstant %22 +%ShadowSamplerPCF = OpVariable %_ptr_UniformConstant_22 UniformConstant + %26 = OpTypeImage %float 2D 1 1 0 1 Unknown + %27 = OpTypeSampledImage %26 + %v3float = OpTypeVector %float 3 + %float_0 = OpConstant %float 0 +%_ptr_Input_v2float = OpTypePointer Input %v2float +%texCoords_1 = OpVariable %_ptr_Input_v2float Input +%_ptr_Input_float = OpTypePointer Input %float +%cascadeIndex_1 = OpVariable %_ptr_Input_float Input +%fragDepth_1 = OpVariable %_ptr_Input_float Input +%_ptr_Output_v4float = OpTypePointer Output %v4float +%_entryPointOutput = OpVariable %_ptr_Output_v4float Output + %main = OpFunction %void None %3 + %5 = OpLabel +%texCoords_0 = OpVariable %_ptr_Function_v2float Function +%cascadeIndex_0 = OpVariable %_ptr_Function_float Function +%fragDepth_0 = OpVariable %_ptr_Function_float Function + %param = OpVariable %_ptr_Function_v2float Function + %param_0 = OpVariable %_ptr_Function_float Function + %param_1 = OpVariable %_ptr_Function_float Function + %53 = OpLoad %v2float %texCoords_1 + OpStore %texCoords_0 %53 + %57 = OpLoad %float %cascadeIndex_1 + OpStore %cascadeIndex_0 %57 + %60 = OpLoad %float %fragDepth_1 + OpStore %fragDepth_0 %60 + %64 = OpLoad %v2float %texCoords_0 + OpStore %param %64 + %66 = OpLoad %float %cascadeIndex_0 + OpStore %param_0 %66 + %68 = OpLoad %float %fragDepth_0 + OpStore %param_1 %68 + %69 = OpFunctionCall %v4float %_main_vf2_f1_f1_ %param %param_0 %param_1 + OpStore %_entryPointOutput %69 + OpReturn + OpFunctionEnd +%_main_vf2_f1_f1_ = OpFunction %v4float None %11 + %texCoords = OpFunctionParameter %_ptr_Function_v2float +%cascadeIndex = OpFunctionParameter %_ptr_Function_float + %fragDepth = OpFunctionParameter %_ptr_Function_float + %16 = OpLabel + %c = OpVariable %_ptr_Function_float Function + %21 = OpLoad %18 %ShadowMap + %25 = OpLoad %22 %ShadowSamplerPCF + %28 = OpSampledImage %27 %21 %25 + %29 = OpLoad %v2float %texCoords + %30 = OpLoad %float %cascadeIndex + %32 = OpCompositeExtract %float %29 0 + %33 = OpCompositeExtract %float %29 1 + %34 = OpCompositeConstruct %v3float %32 %33 %30 + %35 = OpLoad %float %fragDepth + %36 = OpCompositeExtract %float %34 0 + %37 = OpCompositeExtract %float %34 1 + %38 = OpCompositeExtract %float %34 2 + %39 = OpCompositeConstruct %v4float %36 %37 %38 %35 + %41 = OpCompositeExtract %float %39 3 + %42 = OpImageSampleDrefExplicitLod %float %28 %39 %41 Lod %float_0 + OpStore %c %42 + %43 = OpLoad %float %c + %44 = OpLoad %float %c + %45 = OpLoad %float %c + %46 = OpLoad %float %c + %47 = OpCompositeConstruct %v4float %43 %44 %45 %46 + OpReturnValue %47 + OpFunctionEnd diff --git a/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag b/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag new file mode 100644 index 0000000000..8b09e5b68f --- /dev/null +++ b/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag @@ -0,0 +1,646 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 3 +; Bound: 1532 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %IN_HPosition %IN_Uv_EdgeDistance1 %IN_UvStuds_EdgeDistance2 %IN_Color %IN_LightPosition_Fog %IN_View_Depth %IN_Normal_SpecPower %IN_Tangent %IN_PosLightSpace_Reflectance %IN_studIndex %_entryPointOutput + OpExecutionMode %main OriginUpperLeft + OpSource HLSL 500 + OpName %main "main" + OpName %VertexOutput "VertexOutput" + OpMemberName %VertexOutput 0 "HPosition" + OpMemberName %VertexOutput 1 "Uv_EdgeDistance1" + OpMemberName %VertexOutput 2 "UvStuds_EdgeDistance2" + OpMemberName %VertexOutput 3 "Color" + OpMemberName %VertexOutput 4 "LightPosition_Fog" + OpMemberName %VertexOutput 5 "View_Depth" + OpMemberName %VertexOutput 6 "Normal_SpecPower" + OpMemberName %VertexOutput 7 "Tangent" + OpMemberName %VertexOutput 8 "PosLightSpace_Reflectance" + OpMemberName %VertexOutput 9 "studIndex" + OpName %Surface "Surface" + OpMemberName %Surface 0 "albedo" + OpMemberName %Surface 1 "normal" + OpMemberName %Surface 2 "specular" + OpMemberName %Surface 3 "gloss" + OpMemberName %Surface 4 "reflectance" + OpMemberName %Surface 5 "opacity" + OpName %SurfaceInput "SurfaceInput" + OpMemberName %SurfaceInput 0 "Color" + OpMemberName %SurfaceInput 1 "Uv" + OpMemberName %SurfaceInput 2 "UvStuds" + OpName %Globals "Globals" + OpMemberName %Globals 0 "ViewProjection" + OpMemberName %Globals 1 "ViewRight" + OpMemberName %Globals 2 "ViewUp" + OpMemberName %Globals 3 "ViewDir" + OpMemberName %Globals 4 "CameraPosition" + OpMemberName %Globals 5 "AmbientColor" + OpMemberName %Globals 6 "Lamp0Color" + OpMemberName %Globals 7 "Lamp0Dir" + OpMemberName %Globals 8 "Lamp1Color" + OpMemberName %Globals 9 "FogParams" + OpMemberName %Globals 10 "FogColor" + OpMemberName %Globals 11 "LightBorder" + OpMemberName %Globals 12 "LightConfig0" + OpMemberName %Globals 13 "LightConfig1" + OpMemberName %Globals 14 "LightConfig2" + OpMemberName %Globals 15 "LightConfig3" + OpMemberName %Globals 16 "RefractionBias_FadeDistance_GlowFactor" + OpMemberName %Globals 17 "OutlineBrightness_ShadowInfo" + OpMemberName %Globals 18 "ShadowMatrix0" + OpMemberName %Globals 19 "ShadowMatrix1" + OpMemberName %Globals 20 "ShadowMatrix2" + OpName %CB0 "CB0" + OpMemberName %CB0 0 "CB0" + OpName %_ "" + OpName %LightMapTexture "LightMapTexture" + OpName %LightMapSampler "LightMapSampler" + OpName %ShadowMapSampler "ShadowMapSampler" + OpName %ShadowMapTexture "ShadowMapTexture" + OpName %EnvironmentMapTexture "EnvironmentMapTexture" + OpName %EnvironmentMapSampler "EnvironmentMapSampler" + OpName %IN_HPosition "IN.HPosition" + OpName %IN_Uv_EdgeDistance1 "IN.Uv_EdgeDistance1" + OpName %IN_UvStuds_EdgeDistance2 "IN.UvStuds_EdgeDistance2" + OpName %IN_Color "IN.Color" + OpName %IN_LightPosition_Fog "IN.LightPosition_Fog" + OpName %IN_View_Depth "IN.View_Depth" + OpName %IN_Normal_SpecPower "IN.Normal_SpecPower" + OpName %IN_Tangent "IN.Tangent" + OpName %IN_PosLightSpace_Reflectance "IN.PosLightSpace_Reflectance" + OpName %IN_studIndex "IN.studIndex" + OpName %_entryPointOutput "@entryPointOutput" + OpName %DiffuseMapSampler "DiffuseMapSampler" + OpName %DiffuseMapTexture "DiffuseMapTexture" + OpName %NormalMapSampler "NormalMapSampler" + OpName %NormalMapTexture "NormalMapTexture" + OpName %NormalDetailMapTexture "NormalDetailMapTexture" + OpName %NormalDetailMapSampler "NormalDetailMapSampler" + OpName %StudsMapTexture "StudsMapTexture" + OpName %StudsMapSampler "StudsMapSampler" + OpName %SpecularMapSampler "SpecularMapSampler" + OpName %SpecularMapTexture "SpecularMapTexture" + OpName %Params "Params" + OpMemberName %Params 0 "LqmatFarTilingFactor" + OpName %CB2 "CB2" + OpMemberName %CB2 0 "CB2" + OpMemberDecorate %Globals 0 ColMajor + OpMemberDecorate %Globals 0 Offset 0 + OpMemberDecorate %Globals 0 MatrixStride 16 + OpMemberDecorate %Globals 1 Offset 64 + OpMemberDecorate %Globals 2 Offset 80 + OpMemberDecorate %Globals 3 Offset 96 + OpMemberDecorate %Globals 4 Offset 112 + OpMemberDecorate %Globals 5 Offset 128 + OpMemberDecorate %Globals 6 Offset 144 + OpMemberDecorate %Globals 7 Offset 160 + OpMemberDecorate %Globals 8 Offset 176 + OpMemberDecorate %Globals 9 Offset 192 + OpMemberDecorate %Globals 10 Offset 208 + OpMemberDecorate %Globals 11 Offset 224 + OpMemberDecorate %Globals 12 Offset 240 + OpMemberDecorate %Globals 13 Offset 256 + OpMemberDecorate %Globals 14 Offset 272 + OpMemberDecorate %Globals 15 Offset 288 + OpMemberDecorate %Globals 16 Offset 304 + OpMemberDecorate %Globals 17 Offset 320 + OpMemberDecorate %Globals 18 Offset 336 + OpMemberDecorate %Globals 19 Offset 352 + OpMemberDecorate %Globals 20 Offset 368 + OpMemberDecorate %CB0 0 Offset 0 + OpDecorate %CB0 Block + OpDecorate %_ DescriptorSet 0 + OpDecorate %_ Binding 0 + OpDecorate %LightMapTexture DescriptorSet 1 + OpDecorate %LightMapTexture Binding 6 + OpDecorate %LightMapSampler DescriptorSet 1 + OpDecorate %LightMapSampler Binding 6 + OpDecorate %ShadowMapSampler DescriptorSet 1 + OpDecorate %ShadowMapSampler Binding 1 + OpDecorate %ShadowMapTexture DescriptorSet 1 + OpDecorate %ShadowMapTexture Binding 1 + OpDecorate %EnvironmentMapTexture DescriptorSet 1 + OpDecorate %EnvironmentMapTexture Binding 2 + OpDecorate %EnvironmentMapSampler DescriptorSet 1 + OpDecorate %EnvironmentMapSampler Binding 2 + OpDecorate %IN_HPosition BuiltIn FragCoord + OpDecorate %IN_Uv_EdgeDistance1 Location 0 + OpDecorate %IN_UvStuds_EdgeDistance2 Location 1 + OpDecorate %IN_Color Location 2 + OpDecorate %IN_LightPosition_Fog Location 3 + OpDecorate %IN_View_Depth Location 4 + OpDecorate %IN_Normal_SpecPower Location 5 + OpDecorate %IN_Tangent Location 6 + OpDecorate %IN_PosLightSpace_Reflectance Location 7 + OpDecorate %IN_studIndex Location 8 + OpDecorate %_entryPointOutput Location 0 + OpDecorate %DiffuseMapSampler DescriptorSet 1 + OpDecorate %DiffuseMapSampler Binding 3 + OpDecorate %DiffuseMapTexture DescriptorSet 1 + OpDecorate %DiffuseMapTexture Binding 3 + OpDecorate %NormalMapSampler DescriptorSet 1 + OpDecorate %NormalMapSampler Binding 4 + OpDecorate %NormalMapTexture DescriptorSet 1 + OpDecorate %NormalMapTexture Binding 4 + OpDecorate %NormalDetailMapTexture DescriptorSet 1 + OpDecorate %NormalDetailMapTexture Binding 8 + OpDecorate %NormalDetailMapSampler DescriptorSet 1 + OpDecorate %NormalDetailMapSampler Binding 8 + OpDecorate %StudsMapTexture DescriptorSet 1 + OpDecorate %StudsMapTexture Binding 0 + OpDecorate %StudsMapSampler DescriptorSet 1 + OpDecorate %StudsMapSampler Binding 0 + OpDecorate %SpecularMapSampler DescriptorSet 1 + OpDecorate %SpecularMapSampler Binding 5 + OpDecorate %SpecularMapTexture DescriptorSet 1 + OpDecorate %SpecularMapTexture Binding 5 + OpMemberDecorate %Params 0 Offset 0 + OpMemberDecorate %CB2 0 Offset 0 + OpDecorate %CB2 Block + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 +%_ptr_Function_float = OpTypePointer Function %float + %8 = OpTypeFunction %float %_ptr_Function_float + %v4float = OpTypeVector %float 4 +%_ptr_Function_v4float = OpTypePointer Function %v4float + %v3float = OpTypeVector %float 3 + %18 = OpTypeFunction %v3float %_ptr_Function_v4float +%_ptr_Function_v3float = OpTypePointer Function %v3float + %23 = OpTypeFunction %v4float %_ptr_Function_v3float + %27 = OpTypeFunction %float %_ptr_Function_v3float + %31 = OpTypeFunction %float %_ptr_Function_float %_ptr_Function_float + %36 = OpTypeSampler +%_ptr_Function_36 = OpTypePointer Function %36 + %38 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_Function_38 = OpTypePointer Function %38 + %40 = OpTypeFunction %float %_ptr_Function_36 %_ptr_Function_38 %_ptr_Function_v3float %_ptr_Function_float +%VertexOutput = OpTypeStruct %v4float %v4float %v4float %v4float %v4float %v4float %v4float %v3float %v4float %float +%_ptr_Function_VertexOutput = OpTypePointer Function %VertexOutput + %Surface = OpTypeStruct %v3float %v3float %float %float %float %float + %50 = OpTypeFunction %Surface %_ptr_Function_VertexOutput + %54 = OpTypeFunction %v4float %_ptr_Function_VertexOutput + %v2float = OpTypeVector %float 2 +%_ptr_Function_v2float = OpTypePointer Function %v2float + %60 = OpTypeFunction %v4float %_ptr_Function_36 %_ptr_Function_38 %_ptr_Function_v2float %_ptr_Function_float %_ptr_Function_float +%SurfaceInput = OpTypeStruct %v4float %v2float %v2float +%_ptr_Function_SurfaceInput = OpTypePointer Function %SurfaceInput + %70 = OpTypeFunction %Surface %_ptr_Function_SurfaceInput %_ptr_Function_v2float + %float_0 = OpConstant %float 0 + %float_1 = OpConstant %float 1 + %float_2 = OpConstant %float 2 +%mat4v4float = OpTypeMatrix %v4float 4 + %Globals = OpTypeStruct %mat4v4float %v4float %v4float %v4float %v3float %v3float %v3float %v3float %v3float %v4float %v3float %v4float %v4float %v4float %v4float %v4float %v4float %v4float %v4float %v4float %v4float + %CB0 = OpTypeStruct %Globals +%_ptr_Uniform_CB0 = OpTypePointer Uniform %CB0 + %_ = OpVariable %_ptr_Uniform_CB0 Uniform + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %int_15 = OpConstant %int 15 +%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float + %int_14 = OpConstant %int 14 + %128 = OpConstantComposite %v3float %float_1 %float_1 %float_1 + %133 = OpTypeImage %float 3D 0 0 0 1 Unknown +%_ptr_UniformConstant_133 = OpTypePointer UniformConstant %133 +%LightMapTexture = OpVariable %_ptr_UniformConstant_133 UniformConstant +%_ptr_UniformConstant_36 = OpTypePointer UniformConstant %36 +%LightMapSampler = OpVariable %_ptr_UniformConstant_36 UniformConstant + %140 = OpTypeSampledImage %133 + %int_11 = OpConstant %int 11 + %uint = OpTypeInt 32 0 + %float_9 = OpConstant %float 9 + %float_20 = OpConstant %float 20 + %float_0_5 = OpConstant %float 0.5 + %183 = OpTypeSampledImage %38 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %int_17 = OpConstant %int 17 + %uint_3 = OpConstant %uint 3 +%_ptr_Uniform_float = OpTypePointer Uniform %float + %float_0_25 = OpConstant %float 0.25 + %int_5 = OpConstant %int 5 +%float_0_00333333 = OpConstant %float 0.00333333 + %int_16 = OpConstant %int 16 +%_ptr_Function_Surface = OpTypePointer Function %Surface + %int_6 = OpConstant %int 6 + %int_7 = OpConstant %int 7 +%_ptr_Uniform_v3float = OpTypePointer Uniform %v3float + %int_8 = OpConstant %int 8 +%ShadowMapSampler = OpVariable %_ptr_UniformConstant_36 UniformConstant +%_ptr_UniformConstant_38 = OpTypePointer UniformConstant %38 +%ShadowMapTexture = OpVariable %_ptr_UniformConstant_38 UniformConstant + %367 = OpTypeImage %float Cube 0 0 0 1 Unknown +%_ptr_UniformConstant_367 = OpTypePointer UniformConstant %367 +%EnvironmentMapTexture = OpVariable %_ptr_UniformConstant_367 UniformConstant +%EnvironmentMapSampler = OpVariable %_ptr_UniformConstant_36 UniformConstant + %373 = OpTypeSampledImage %367 + %float_1_5 = OpConstant %float 1.5 + %int_10 = OpConstant %int 10 +%_ptr_Input_v4float = OpTypePointer Input %v4float +%IN_HPosition = OpVariable %_ptr_Input_v4float Input +%IN_Uv_EdgeDistance1 = OpVariable %_ptr_Input_v4float Input +%IN_UvStuds_EdgeDistance2 = OpVariable %_ptr_Input_v4float Input + %IN_Color = OpVariable %_ptr_Input_v4float Input +%IN_LightPosition_Fog = OpVariable %_ptr_Input_v4float Input +%IN_View_Depth = OpVariable %_ptr_Input_v4float Input +%IN_Normal_SpecPower = OpVariable %_ptr_Input_v4float Input +%_ptr_Input_v3float = OpTypePointer Input %v3float + %IN_Tangent = OpVariable %_ptr_Input_v3float Input +%IN_PosLightSpace_Reflectance = OpVariable %_ptr_Input_v4float Input +%_ptr_Input_float = OpTypePointer Input %float +%IN_studIndex = OpVariable %_ptr_Input_float Input +%_ptr_Output_v4float = OpTypePointer Output %v4float +%_entryPointOutput = OpVariable %_ptr_Output_v4float Output + %bool = OpTypeBool +%DiffuseMapSampler = OpVariable %_ptr_UniformConstant_36 UniformConstant +%DiffuseMapTexture = OpVariable %_ptr_UniformConstant_38 UniformConstant +%NormalMapSampler = OpVariable %_ptr_UniformConstant_36 UniformConstant +%NormalMapTexture = OpVariable %_ptr_UniformConstant_38 UniformConstant +%NormalDetailMapTexture = OpVariable %_ptr_UniformConstant_38 UniformConstant +%NormalDetailMapSampler = OpVariable %_ptr_UniformConstant_36 UniformConstant + %float_0_3 = OpConstant %float 0.3 +%StudsMapTexture = OpVariable %_ptr_UniformConstant_38 UniformConstant +%StudsMapSampler = OpVariable %_ptr_UniformConstant_36 UniformConstant +%SpecularMapSampler = OpVariable %_ptr_UniformConstant_36 UniformConstant +%SpecularMapTexture = OpVariable %_ptr_UniformConstant_38 UniformConstant + %float_0_75 = OpConstant %float 0.75 + %float_256 = OpConstant %float 256 + %689 = OpConstantComposite %v2float %float_2 %float_256 + %float_0_01 = OpConstant %float 0.01 + %692 = OpConstantComposite %v2float %float_0 %float_0_01 + %float_0_8 = OpConstant %float 0.8 + %float_120 = OpConstant %float 120 + %697 = OpConstantComposite %v2float %float_0_8 %float_120 + %Params = OpTypeStruct %v4float + %CB2 = OpTypeStruct %Params +%_ptr_Uniform_CB2 = OpTypePointer Uniform %CB2 + %false = OpConstantFalse %bool + %1509 = OpUndef %VertexOutput + %1510 = OpUndef %SurfaceInput + %1511 = OpUndef %v2float + %1512 = OpUndef %v4float + %1531 = OpUndef %Surface + %main = OpFunction %void None %3 + %5 = OpLabel + %501 = OpLoad %v4float %IN_HPosition + %1378 = OpCompositeInsert %VertexOutput %501 %1509 0 + %504 = OpLoad %v4float %IN_Uv_EdgeDistance1 + %1380 = OpCompositeInsert %VertexOutput %504 %1378 1 + %507 = OpLoad %v4float %IN_UvStuds_EdgeDistance2 + %1382 = OpCompositeInsert %VertexOutput %507 %1380 2 + %510 = OpLoad %v4float %IN_Color + %1384 = OpCompositeInsert %VertexOutput %510 %1382 3 + %513 = OpLoad %v4float %IN_LightPosition_Fog + %1386 = OpCompositeInsert %VertexOutput %513 %1384 4 + %516 = OpLoad %v4float %IN_View_Depth + %1388 = OpCompositeInsert %VertexOutput %516 %1386 5 + %519 = OpLoad %v4float %IN_Normal_SpecPower + %1390 = OpCompositeInsert %VertexOutput %519 %1388 6 + %523 = OpLoad %v3float %IN_Tangent + %1392 = OpCompositeInsert %VertexOutput %523 %1390 7 + %526 = OpLoad %v4float %IN_PosLightSpace_Reflectance + %1394 = OpCompositeInsert %VertexOutput %526 %1392 8 + %530 = OpLoad %float %IN_studIndex + %1396 = OpCompositeInsert %VertexOutput %530 %1394 9 + %1400 = OpCompositeInsert %SurfaceInput %510 %1510 0 + %954 = OpVectorShuffle %v2float %504 %504 0 1 + %1404 = OpCompositeInsert %SurfaceInput %954 %1400 1 + %958 = OpVectorShuffle %v2float %507 %507 0 1 + %1408 = OpCompositeInsert %SurfaceInput %958 %1404 2 + %1410 = OpCompositeExtract %float %1408 2 1 + %962 = OpExtInst %float %1 Fract %1410 + %965 = OpFAdd %float %962 %530 + %966 = OpFMul %float %965 %float_0_25 + %1414 = OpCompositeInsert %SurfaceInput %966 %1408 2 1 + %1416 = OpCompositeExtract %float %1396 5 3 + %970 = OpFMul %float %1416 %float_0_00333333 + %971 = OpFSub %float %float_1 %970 + %987 = OpExtInst %float %1 FClamp %971 %float_0 %float_1 + %976 = OpAccessChain %_ptr_Uniform_float %_ %int_0 %int_16 %uint_1 + %977 = OpLoad %float %976 + %978 = OpFMul %float %1416 %977 + %979 = OpFSub %float %float_1 %978 + %990 = OpExtInst %float %1 FClamp %979 %float_0 %float_1 + %1024 = OpVectorTimesScalar %v2float %954 %float_1 + %1029 = OpLoad %36 %DiffuseMapSampler + %1030 = OpLoad %38 %DiffuseMapTexture + OpBranch %1119 + %1119 = OpLabel + OpLoopMerge %1120 %1121 None + OpBranch %1122 + %1122 = OpLabel + %1124 = OpFOrdEqual %bool %float_0 %float_0 + OpSelectionMerge %1125 None + OpBranchConditional %1124 %1126 %1127 + %1126 = OpLabel + %1130 = OpSampledImage %183 %1030 %1029 + %1132 = OpImageSampleImplicitLod %v4float %1130 %1024 + OpBranch %1120 + %1127 = OpLabel + %1134 = OpFSub %float %float_1 %float_0 + %1135 = OpFDiv %float %float_1 %1134 + %1138 = OpSampledImage %183 %1030 %1029 + %1140 = OpVectorTimesScalar %v2float %1024 %float_0_25 + %1141 = OpImageSampleImplicitLod %v4float %1138 %1140 + %1144 = OpSampledImage %183 %1030 %1029 + %1146 = OpImageSampleImplicitLod %v4float %1144 %1024 + %1149 = OpFMul %float %987 %1135 + %1152 = OpFMul %float %float_0 %1135 + %1153 = OpFSub %float %1149 %1152 + %1161 = OpExtInst %float %1 FClamp %1153 %float_0 %float_1 + %1155 = OpCompositeConstruct %v4float %1161 %1161 %1161 %1161 + %1156 = OpExtInst %v4float %1 FMix %1141 %1146 %1155 + OpBranch %1120 + %1125 = OpLabel + %1157 = OpUndef %v4float + OpBranch %1120 + %1121 = OpLabel + OpBranchConditional %false %1119 %1120 + %1120 = OpLabel + %1517 = OpPhi %v4float %1132 %1126 %1156 %1127 %1157 %1125 %1512 %1121 + %1035 = OpVectorTimesScalar %v4float %1517 %float_1 + %1036 = OpLoad %36 %NormalMapSampler + %1037 = OpLoad %38 %NormalMapTexture + OpBranch %1165 + %1165 = OpLabel + OpLoopMerge %1166 %1167 None + OpBranch %1168 + %1168 = OpLabel + OpSelectionMerge %1171 None + OpBranchConditional %1124 %1172 %1173 + %1172 = OpLabel + %1176 = OpSampledImage %183 %1037 %1036 + %1178 = OpImageSampleImplicitLod %v4float %1176 %1024 + OpBranch %1166 + %1173 = OpLabel + %1180 = OpFSub %float %float_1 %float_0 + %1181 = OpFDiv %float %float_1 %1180 + %1184 = OpSampledImage %183 %1037 %1036 + %1186 = OpVectorTimesScalar %v2float %1024 %float_0_25 + %1187 = OpImageSampleImplicitLod %v4float %1184 %1186 + %1190 = OpSampledImage %183 %1037 %1036 + %1192 = OpImageSampleImplicitLod %v4float %1190 %1024 + %1195 = OpFMul %float %990 %1181 + %1198 = OpFMul %float %float_0 %1181 + %1199 = OpFSub %float %1195 %1198 + %1206 = OpExtInst %float %1 FClamp %1199 %float_0 %float_1 + %1201 = OpCompositeConstruct %v4float %1206 %1206 %1206 %1206 + %1202 = OpExtInst %v4float %1 FMix %1187 %1192 %1201 + OpBranch %1166 + %1171 = OpLabel + %1203 = OpUndef %v4float + OpBranch %1166 + %1167 = OpLabel + OpBranchConditional %false %1165 %1166 + %1166 = OpLabel + %1523 = OpPhi %v4float %1178 %1172 %1202 %1173 %1203 %1171 %1512 %1167 + %1210 = OpVectorShuffle %v2float %1523 %1523 3 1 + %1211 = OpVectorTimesScalar %v2float %1210 %float_2 + %1212 = OpCompositeConstruct %v2float %float_1 %float_1 + %1213 = OpFSub %v2float %1211 %1212 + %1216 = OpFNegate %v2float %1213 + %1218 = OpDot %float %1216 %1213 + %1219 = OpFAdd %float %float_1 %1218 + %1220 = OpExtInst %float %1 FClamp %1219 %float_0 %float_1 + %1221 = OpExtInst %float %1 Sqrt %1220 + %1222 = OpCompositeExtract %float %1213 0 + %1223 = OpCompositeExtract %float %1213 1 + %1224 = OpCompositeConstruct %v3float %1222 %1223 %1221 + %1042 = OpLoad %38 %NormalDetailMapTexture + %1043 = OpLoad %36 %NormalDetailMapSampler + %1044 = OpSampledImage %183 %1042 %1043 + %1046 = OpVectorTimesScalar %v2float %1024 %float_0 + %1047 = OpImageSampleImplicitLod %v4float %1044 %1046 + %1228 = OpVectorShuffle %v2float %1047 %1047 3 1 + %1229 = OpVectorTimesScalar %v2float %1228 %float_2 + %1231 = OpFSub %v2float %1229 %1212 + %1234 = OpFNegate %v2float %1231 + %1236 = OpDot %float %1234 %1231 + %1237 = OpFAdd %float %float_1 %1236 + %1238 = OpExtInst %float %1 FClamp %1237 %float_0 %float_1 + %1239 = OpExtInst %float %1 Sqrt %1238 + %1240 = OpCompositeExtract %float %1231 0 + %1241 = OpCompositeExtract %float %1231 1 + %1242 = OpCompositeConstruct %v3float %1240 %1241 %1239 + %1050 = OpVectorShuffle %v2float %1242 %1242 0 1 + %1051 = OpVectorTimesScalar %v2float %1050 %float_0 + %1053 = OpVectorShuffle %v2float %1224 %1224 0 1 + %1054 = OpFAdd %v2float %1053 %1051 + %1056 = OpVectorShuffle %v3float %1224 %1054 3 4 2 + %1059 = OpVectorShuffle %v2float %1056 %1056 0 1 + %1060 = OpVectorTimesScalar %v2float %1059 %990 + %1062 = OpVectorShuffle %v3float %1056 %1060 3 4 2 + %1430 = OpCompositeExtract %float %1062 0 + %1065 = OpFMul %float %1430 %float_0_3 + %1066 = OpFAdd %float %float_1 %1065 + %1069 = OpVectorShuffle %v3float %510 %510 0 1 2 + %1071 = OpVectorShuffle %v3float %1035 %1035 0 1 2 + %1072 = OpFMul %v3float %1069 %1071 + %1074 = OpVectorTimesScalar %v3float %1072 %1066 + %1075 = OpLoad %38 %StudsMapTexture + %1076 = OpLoad %36 %StudsMapSampler + %1077 = OpSampledImage %183 %1075 %1076 + %1434 = OpCompositeExtract %v2float %1414 2 + %1080 = OpImageSampleImplicitLod %v4float %1077 %1434 + %1436 = OpCompositeExtract %float %1080 0 + %1083 = OpFMul %float %1436 %float_2 + %1085 = OpVectorTimesScalar %v3float %1074 %1083 + %1086 = OpLoad %36 %SpecularMapSampler + %1087 = OpLoad %38 %SpecularMapTexture + OpBranch %1246 + %1246 = OpLabel + OpLoopMerge %1247 %1248 None + OpBranch %1249 + %1249 = OpLabel + %1251 = OpFOrdEqual %bool %float_0_75 %float_0 + OpSelectionMerge %1252 None + OpBranchConditional %1251 %1253 %1254 + %1253 = OpLabel + %1257 = OpSampledImage %183 %1087 %1086 + %1259 = OpImageSampleImplicitLod %v4float %1257 %1024 + OpBranch %1247 + %1254 = OpLabel + %1261 = OpFSub %float %float_1 %float_0_75 + %1262 = OpFDiv %float %float_1 %1261 + %1265 = OpSampledImage %183 %1087 %1086 + %1267 = OpVectorTimesScalar %v2float %1024 %float_0_25 + %1268 = OpImageSampleImplicitLod %v4float %1265 %1267 + %1271 = OpSampledImage %183 %1087 %1086 + %1273 = OpImageSampleImplicitLod %v4float %1271 %1024 + %1276 = OpFMul %float %990 %1262 + %1279 = OpFMul %float %float_0_75 %1262 + %1280 = OpFSub %float %1276 %1279 + %1287 = OpExtInst %float %1 FClamp %1280 %float_0 %float_1 + %1282 = OpCompositeConstruct %v4float %1287 %1287 %1287 %1287 + %1283 = OpExtInst %v4float %1 FMix %1268 %1273 %1282 + OpBranch %1247 + %1252 = OpLabel + %1284 = OpUndef %v4float + OpBranch %1247 + %1248 = OpLabel + OpBranchConditional %false %1246 %1247 + %1247 = OpLabel + %1530 = OpPhi %v4float %1259 %1253 %1283 %1254 %1284 %1252 %1512 %1248 + %1091 = OpVectorShuffle %v2float %1530 %1530 0 1 + %1093 = OpFMul %v2float %1091 %689 + %1094 = OpFAdd %v2float %1093 %692 + %1097 = OpCompositeConstruct %v2float %990 %990 + %1098 = OpExtInst %v2float %1 FMix %697 %1094 %1097 + %1438 = OpCompositeInsert %Surface %1085 %1531 0 + %1440 = OpCompositeInsert %Surface %1062 %1438 1 + %1442 = OpCompositeExtract %float %1098 0 + %1444 = OpCompositeInsert %Surface %1442 %1440 2 + %1446 = OpCompositeExtract %float %1098 1 + %1448 = OpCompositeInsert %Surface %1446 %1444 3 + %1450 = OpCompositeExtract %float %1091 1 + %1112 = OpFMul %float %1450 %990 + %1113 = OpFMul %float %1112 %float_0 + %1452 = OpCompositeInsert %Surface %1113 %1448 4 + %1456 = OpCompositeExtract %float %1396 3 3 + %764 = OpCompositeExtract %float %1085 0 + %765 = OpCompositeExtract %float %1085 1 + %766 = OpCompositeExtract %float %1085 2 + %767 = OpCompositeConstruct %v4float %764 %765 %766 %1456 + %770 = OpVectorShuffle %v3float %519 %519 0 1 2 + %773 = OpExtInst %v3float %1 Cross %770 %523 + %1462 = OpCompositeExtract %float %1452 1 0 + %778 = OpVectorTimesScalar %v3float %523 %1462 + %1466 = OpCompositeExtract %float %1452 1 1 + %782 = OpVectorTimesScalar %v3float %773 %1466 + %783 = OpFAdd %v3float %778 %782 + %1468 = OpCompositeExtract %float %1452 1 2 + %789 = OpVectorTimesScalar %v3float %770 %1468 + %790 = OpFAdd %v3float %783 %789 + %791 = OpExtInst %v3float %1 Normalize %790 + %793 = OpAccessChain %_ptr_Uniform_v3float %_ %int_0 %int_7 + %794 = OpLoad %v3float %793 + %795 = OpFNegate %v3float %794 + %796 = OpDot %float %791 %795 + %1290 = OpExtInst %float %1 FClamp %796 %float_0 %float_1 + %799 = OpAccessChain %_ptr_Uniform_v3float %_ %int_0 %int_6 + %800 = OpLoad %v3float %799 + %801 = OpVectorTimesScalar %v3float %800 %1290 + %803 = OpFNegate %float %796 + %804 = OpExtInst %float %1 FMax %803 %float_0 + %805 = OpAccessChain %_ptr_Uniform_v3float %_ %int_0 %int_8 + %806 = OpLoad %v3float %805 + %807 = OpVectorTimesScalar %v3float %806 %804 + %808 = OpFAdd %v3float %801 %807 + %810 = OpExtInst %float %1 Step %float_0 %796 + %813 = OpFMul %float %810 %1442 + %820 = OpVectorShuffle %v3float %513 %513 0 1 2 + %1296 = OpAccessChain %_ptr_Uniform_v4float %_ %int_0 %int_15 + %1297 = OpLoad %v4float %1296 + %1298 = OpVectorShuffle %v3float %1297 %1297 0 1 2 + %1300 = OpAccessChain %_ptr_Uniform_v4float %_ %int_0 %int_14 + %1301 = OpLoad %v4float %1300 + %1302 = OpVectorShuffle %v3float %1301 %1301 0 1 2 + %1303 = OpFSub %v3float %820 %1302 + %1304 = OpExtInst %v3float %1 FAbs %1303 + %1305 = OpExtInst %v3float %1 Step %1298 %1304 + %1307 = OpDot %float %1305 %128 + %1328 = OpExtInst %float %1 FClamp %1307 %float_0 %float_1 + %1309 = OpLoad %133 %LightMapTexture + %1310 = OpLoad %36 %LightMapSampler + %1311 = OpSampledImage %140 %1309 %1310 + %1313 = OpVectorShuffle %v3float %820 %820 1 2 0 + %1317 = OpVectorTimesScalar %v3float %1313 %1328 + %1318 = OpFSub %v3float %1313 %1317 + %1319 = OpImageSampleImplicitLod %v4float %1311 %1318 + %1321 = OpAccessChain %_ptr_Uniform_v4float %_ %int_0 %int_11 + %1322 = OpLoad %v4float %1321 + %1324 = OpCompositeConstruct %v4float %1328 %1328 %1328 %1328 + %1325 = OpExtInst %v4float %1 FMix %1319 %1322 %1324 + %822 = OpLoad %36 %ShadowMapSampler + %823 = OpLoad %38 %ShadowMapTexture + %826 = OpVectorShuffle %v3float %526 %526 0 1 2 + %1482 = OpCompositeExtract %float %1325 3 + %1337 = OpSampledImage %183 %823 %822 + %1339 = OpVectorShuffle %v2float %826 %826 0 1 + %1340 = OpImageSampleImplicitLod %v4float %1337 %1339 + %1341 = OpVectorShuffle %v2float %1340 %1340 0 1 + %1484 = OpCompositeExtract %float %826 2 + %1486 = OpCompositeExtract %float %1341 0 + %1363 = OpExtInst %float %1 Step %1486 %1484 + %1365 = OpFSub %float %1484 %float_0_5 + %1366 = OpExtInst %float %1 FAbs %1365 + %1367 = OpFMul %float %float_20 %1366 + %1368 = OpFSub %float %float_9 %1367 + %1369 = OpExtInst %float %1 FClamp %1368 %float_0 %float_1 + %1370 = OpFMul %float %1363 %1369 + %1488 = OpCompositeExtract %float %1341 1 + %1350 = OpFMul %float %1370 %1488 + %1351 = OpAccessChain %_ptr_Uniform_float %_ %int_0 %int_17 %uint_3 + %1352 = OpLoad %float %1351 + %1353 = OpFMul %float %1350 %1352 + %1354 = OpFSub %float %float_1 %1353 + %1356 = OpFMul %float %1354 %1482 + %830 = OpLoad %367 %EnvironmentMapTexture + %831 = OpLoad %36 %EnvironmentMapSampler + %832 = OpSampledImage %373 %830 %831 + %835 = OpVectorShuffle %v3float %516 %516 0 1 2 + %836 = OpFNegate %v3float %835 + %838 = OpExtInst %v3float %1 Reflect %836 %791 + %839 = OpImageSampleImplicitLod %v4float %832 %838 + %840 = OpVectorShuffle %v3float %839 %839 0 1 2 + %842 = OpVectorShuffle %v3float %767 %767 0 1 2 + %845 = OpCompositeConstruct %v3float %1113 %1113 %1113 + %846 = OpExtInst %v3float %1 FMix %842 %840 %845 + %848 = OpVectorShuffle %v4float %767 %846 4 5 6 3 + %849 = OpAccessChain %_ptr_Uniform_v3float %_ %int_0 %int_5 + %850 = OpLoad %v3float %849 + %853 = OpVectorTimesScalar %v3float %808 %1356 + %854 = OpFAdd %v3float %850 %853 + %856 = OpVectorShuffle %v3float %1325 %1325 0 1 2 + %857 = OpFAdd %v3float %854 %856 + %859 = OpVectorShuffle %v3float %848 %848 0 1 2 + %860 = OpFMul %v3float %857 %859 + %865 = OpFMul %float %813 %1356 + %873 = OpExtInst %v3float %1 Normalize %835 + %874 = OpFAdd %v3float %795 %873 + %875 = OpExtInst %v3float %1 Normalize %874 + %876 = OpDot %float %791 %875 + %877 = OpExtInst %float %1 FClamp %876 %float_0 %float_1 + %879 = OpExtInst %float %1 Pow %877 %1446 + %880 = OpFMul %float %865 %879 + %881 = OpVectorTimesScalar %v3float %800 %880 + %884 = OpFAdd %v3float %860 %881 + %886 = OpVectorShuffle %v4float %1512 %884 4 5 6 3 + %1494 = OpCompositeExtract %float %848 3 + %1496 = OpCompositeInsert %v4float %1494 %886 3 + %896 = OpAccessChain %_ptr_Uniform_float %_ %int_0 %int_17 %uint_0 + %897 = OpLoad %float %896 + %898 = OpFMul %float %978 %897 + %899 = OpAccessChain %_ptr_Uniform_float %_ %int_0 %int_17 %uint_1 + %900 = OpLoad %float %899 + %901 = OpFAdd %float %898 %900 + %1373 = OpExtInst %float %1 FClamp %901 %float_0 %float_1 + %905 = OpVectorShuffle %v2float %504 %504 3 2 + %908 = OpVectorShuffle %v2float %507 %507 3 2 + %909 = OpExtInst %v2float %1 FMin %905 %908 + %1504 = OpCompositeExtract %float %909 0 + %1506 = OpCompositeExtract %float %909 1 + %914 = OpExtInst %float %1 FMin %1504 %1506 + %916 = OpFDiv %float %914 %978 + %919 = OpFSub %float %float_1_5 %916 + %920 = OpFMul %float %1373 %919 + %922 = OpFAdd %float %920 %916 + %1376 = OpExtInst %float %1 FClamp %922 %float_0 %float_1 + %925 = OpVectorShuffle %v3float %1496 %1496 0 1 2 + %926 = OpVectorTimesScalar %v3float %925 %1376 + %928 = OpVectorShuffle %v4float %1496 %926 4 5 6 3 + %1508 = OpCompositeExtract %float %1396 4 3 + %931 = OpExtInst %float %1 FClamp %1508 %float_0 %float_1 + %932 = OpAccessChain %_ptr_Uniform_v3float %_ %int_0 %int_10 + %933 = OpLoad %v3float %932 + %935 = OpVectorShuffle %v3float %928 %928 0 1 2 + %937 = OpCompositeConstruct %v3float %931 %931 %931 + %938 = OpExtInst %v3float %1 FMix %933 %935 %937 + %940 = OpVectorShuffle %v4float %928 %938 4 5 6 3 + OpStore %_entryPointOutput %940 + OpReturn + OpFunctionEnd diff --git a/shaders/asm/frag/invalidation.asm.frag b/shaders/asm/frag/invalidation.asm.frag new file mode 100644 index 0000000000..8e753d50fe --- /dev/null +++ b/shaders/asm/frag/invalidation.asm.frag @@ -0,0 +1,46 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 1 +; Bound: 28 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %v0 %v1 %FragColor + OpExecutionMode %4 OriginUpperLeft + OpSource GLSL 450 + OpName %4 "main" + OpName %a "a" + OpName %v0 "v0" + OpName %b "b" + OpName %v1 "v1" + OpName %FragColor "FragColor" + OpDecorate %v0 Location 0 + OpDecorate %v1 Location 1 + OpDecorate %FragColor Location 0 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %float = OpTypeFloat 32 + %pfloat = OpTypePointer Function %float + %9 = OpTypePointer Input %float + %v0 = OpVariable %9 Input + %v1 = OpVariable %9 Input + %25 = OpTypePointer Output %float + %FragColor = OpVariable %25 Output + %4 = OpFunction %2 None %3 + %5 = OpLabel + %a = OpVariable %pfloat Function + %b = OpVariable %pfloat Function + %v0_tmp = OpLoad %float %v0 + %v1_tmp = OpLoad %float %v1 + OpStore %a %v0_tmp + OpStore %b %v1_tmp + + %a_tmp = OpLoad %float %a + %b_tmp = OpLoad %float %b + %res = OpFAdd %float %a_tmp %b_tmp + %res1 = OpFMul %float %res %b_tmp + OpStore %a %v1_tmp + OpStore %FragColor %res1 + OpReturn + OpFunctionEnd diff --git a/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag b/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag new file mode 100644 index 0000000000..fa53940b14 --- /dev/null +++ b/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag @@ -0,0 +1,190 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 2 +; Bound: 131 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %fragWorld_1 %_entryPointOutput + OpExecutionMode %main OriginUpperLeft + OpSource HLSL 500 + OpName %main "main" + OpName %GetClip2TexMatrix_ "GetClip2TexMatrix(" + OpName %GetCascade_vf3_ "GetCascade(vf3;" + OpName %fragWorldPosition "fragWorldPosition" + OpName %_main_vf3_ "@main(vf3;" + OpName %fragWorld "fragWorld" + OpName %Foo "Foo" + OpMemberName %Foo 0 "lightVP" + OpMemberName %Foo 1 "shadowCascadesNum" + OpMemberName %Foo 2 "test" + OpName %_ "" + OpName %cascadeIndex "cascadeIndex" + OpName %worldToShadowMap "worldToShadowMap" + OpName %fragShadowMapPos "fragShadowMapPos" + OpName %param "param" + OpName %fragWorld_0 "fragWorld" + OpName %fragWorld_1 "fragWorld" + OpName %_entryPointOutput "@entryPointOutput" + OpName %param_0 "param" + OpDecorate %_arr_mat4v4float_uint_64 ArrayStride 64 + OpMemberDecorate %Foo 0 RowMajor + OpMemberDecorate %Foo 0 Offset 0 + OpMemberDecorate %Foo 0 MatrixStride 16 + OpMemberDecorate %Foo 1 Offset 4096 + OpMemberDecorate %Foo 2 Offset 4100 + OpDecorate %Foo Block + OpDecorate %_ DescriptorSet 0 + OpDecorate %_ Binding 0 + OpDecorate %fragWorld_1 Location 0 + OpDecorate %_entryPointOutput Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%mat4v4float = OpTypeMatrix %v4float 4 + %9 = OpTypeFunction %mat4v4float + %v3float = OpTypeVector %float 3 +%_ptr_Function_v3float = OpTypePointer Function %v3float + %int = OpTypeInt 32 1 + %15 = OpTypeFunction %int %_ptr_Function_v3float + %uint = OpTypeInt 32 0 + %uint_64 = OpConstant %uint 64 +%_arr_mat4v4float_uint_64 = OpTypeArray %mat4v4float %uint_64 + %Foo = OpTypeStruct %_arr_mat4v4float_uint_64 %uint %int +%_ptr_Uniform_Foo = OpTypePointer Uniform %Foo + %_ = OpVariable %_ptr_Uniform_Foo Uniform + %int_2 = OpConstant %int 2 +%_ptr_Uniform_int = OpTypePointer Uniform %int + %int_0 = OpConstant %int 0 + %bool = OpTypeBool + %float_0_5 = OpConstant %float 0.5 + %float_0 = OpConstant %float 0 + %39 = OpConstantComposite %v4float %float_0_5 %float_0 %float_0 %float_0 + %40 = OpConstantComposite %v4float %float_0 %float_0_5 %float_0 %float_0 + %41 = OpConstantComposite %v4float %float_0 %float_0 %float_0_5 %float_0 + %float_1 = OpConstant %float 1 + %43 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_1 + %44 = OpConstantComposite %mat4v4float %39 %40 %41 %43 + %46 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_0 + %47 = OpConstantComposite %v4float %float_0 %float_1 %float_0 %float_0 + %48 = OpConstantComposite %v4float %float_0 %float_0 %float_1 %float_0 + %49 = OpConstantComposite %mat4v4float %46 %47 %48 %43 +%_ptr_Function_uint = OpTypePointer Function %uint + %uint_0 = OpConstant %uint 0 + %int_1 = OpConstant %int 1 +%_ptr_Uniform_uint = OpTypePointer Uniform %uint +%_ptr_Function_mat4v4float = OpTypePointer Function %mat4v4float +%_ptr_Uniform_mat4v4float = OpTypePointer Uniform %mat4v4float +%_ptr_Function_v4float = OpTypePointer Function %v4float + %uint_2 = OpConstant %uint 2 +%_ptr_Function_float = OpTypePointer Function %float + %uint_1 = OpConstant %uint 1 + %int_n1 = OpConstant %int -1 +%_ptr_Input_v3float = OpTypePointer Input %v3float +%fragWorld_1 = OpVariable %_ptr_Input_v3float Input +%_ptr_Output_int = OpTypePointer Output %int +%_entryPointOutput = OpVariable %_ptr_Output_int Output + %main = OpFunction %void None %3 + %5 = OpLabel +%fragWorld_0 = OpVariable %_ptr_Function_v3float Function + %param_0 = OpVariable %_ptr_Function_v3float Function + %125 = OpLoad %v3float %fragWorld_1 + OpStore %fragWorld_0 %125 + %129 = OpLoad %v3float %fragWorld_0 + OpStore %param_0 %129 + %130 = OpFunctionCall %int %_main_vf3_ %param_0 + OpStore %_entryPointOutput %130 + OpReturn + OpFunctionEnd +%GetClip2TexMatrix_ = OpFunction %mat4v4float None %9 + %11 = OpLabel + %30 = OpAccessChain %_ptr_Uniform_int %_ %int_2 + %31 = OpLoad %int %30 + %34 = OpIEqual %bool %31 %int_0 + OpSelectionMerge %36 None + OpBranchConditional %34 %35 %36 + %35 = OpLabel + OpReturnValue %44 + %36 = OpLabel + OpReturnValue %49 + OpFunctionEnd +%GetCascade_vf3_ = OpFunction %int None %15 +%fragWorldPosition = OpFunctionParameter %_ptr_Function_v3float + %18 = OpLabel +%cascadeIndex = OpVariable %_ptr_Function_uint Function +%worldToShadowMap = OpVariable %_ptr_Function_mat4v4float Function +%fragShadowMapPos = OpVariable %_ptr_Function_v4float Function + OpStore %cascadeIndex %uint_0 + OpBranch %55 + %55 = OpLabel + OpLoopMerge %57 %58 Unroll + OpBranch %59 + %59 = OpLabel + %60 = OpLoad %uint %cascadeIndex + %63 = OpAccessChain %_ptr_Uniform_uint %_ %int_1 + %64 = OpLoad %uint %63 + %65 = OpULessThan %bool %60 %64 + OpBranchConditional %65 %56 %57 + %56 = OpLabel + %68 = OpFunctionCall %mat4v4float %GetClip2TexMatrix_ + %69 = OpLoad %uint %cascadeIndex + %71 = OpAccessChain %_ptr_Uniform_mat4v4float %_ %int_0 %69 + %72 = OpLoad %mat4v4float %71 + %73 = OpMatrixTimesMatrix %mat4v4float %68 %72 + OpStore %worldToShadowMap %73 + %76 = OpLoad %mat4v4float %worldToShadowMap + %77 = OpLoad %v3float %fragWorldPosition + %78 = OpCompositeExtract %float %77 0 + %79 = OpCompositeExtract %float %77 1 + %80 = OpCompositeExtract %float %77 2 + %81 = OpCompositeConstruct %v4float %78 %79 %80 %float_1 + %82 = OpMatrixTimesVector %v4float %76 %81 + OpStore %fragShadowMapPos %82 + %85 = OpAccessChain %_ptr_Function_float %fragShadowMapPos %uint_2 + %86 = OpLoad %float %85 + %87 = OpFOrdGreaterThanEqual %bool %86 %float_0 + %88 = OpAccessChain %_ptr_Function_float %fragShadowMapPos %uint_2 + %89 = OpLoad %float %88 + %90 = OpFOrdLessThanEqual %bool %89 %float_1 + %91 = OpLogicalAnd %bool %87 %90 + %92 = OpAccessChain %_ptr_Function_float %fragShadowMapPos %uint_0 + %93 = OpLoad %float %92 + %95 = OpAccessChain %_ptr_Function_float %fragShadowMapPos %uint_1 + %96 = OpLoad %float %95 + %97 = OpExtInst %float %1 FMax %93 %96 + %98 = OpFOrdLessThanEqual %bool %97 %float_1 + %99 = OpLogicalAnd %bool %91 %98 + %100 = OpAccessChain %_ptr_Function_float %fragShadowMapPos %uint_0 + %101 = OpLoad %float %100 + %102 = OpAccessChain %_ptr_Function_float %fragShadowMapPos %uint_1 + %103 = OpLoad %float %102 + %104 = OpExtInst %float %1 FMin %101 %103 + %105 = OpFOrdGreaterThanEqual %bool %104 %float_0 + %106 = OpLogicalAnd %bool %99 %105 + OpSelectionMerge %108 None + OpBranchConditional %106 %107 %108 + %107 = OpLabel + %109 = OpLoad %uint %cascadeIndex + %110 = OpBitcast %int %109 + OpReturnValue %110 + %108 = OpLabel + OpBranch %58 + %58 = OpLabel + %112 = OpLoad %uint %cascadeIndex + %113 = OpIAdd %uint %112 %int_1 + OpStore %cascadeIndex %113 + OpBranch %55 + %57 = OpLabel + OpReturnValue %int_n1 + OpFunctionEnd + %_main_vf3_ = OpFunction %int None %15 + %fragWorld = OpFunctionParameter %_ptr_Function_v3float + %21 = OpLabel + %param = OpVariable %_ptr_Function_v3float Function + %118 = OpLoad %v3float %fragWorld + OpStore %param %118 + %119 = OpFunctionCall %int %GetCascade_vf3_ %param + OpReturnValue %119 + OpFunctionEnd diff --git a/shaders/asm/frag/loop-header-to-continue.asm.frag b/shaders/asm/frag/loop-header-to-continue.asm.frag new file mode 100644 index 0000000000..54807d911c --- /dev/null +++ b/shaders/asm/frag/loop-header-to-continue.asm.frag @@ -0,0 +1,132 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 3 +; Bound: 279 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %IN_p %IN_uv %_entryPointOutput + OpExecutionMode %main OriginUpperLeft + OpSource HLSL 500 + OpName %main "main" + OpName %Params "Params" + OpMemberName %Params 0 "TextureSize" + OpMemberName %Params 1 "Params1" + OpMemberName %Params 2 "Params2" + OpMemberName %Params 3 "Params3" + OpMemberName %Params 4 "Params4" + OpMemberName %Params 5 "Bloom" + OpName %CB1 "CB1" + OpMemberName %CB1 0 "CB1" + OpName %_ "" + OpName %mapSampler "mapSampler" + OpName %mapTexture "mapTexture" + OpName %IN_p "IN.p" + OpName %IN_uv "IN.uv" + OpName %_entryPointOutput "@entryPointOutput" + OpMemberDecorate %Params 0 Offset 0 + OpMemberDecorate %Params 1 Offset 16 + OpMemberDecorate %Params 2 Offset 32 + OpMemberDecorate %Params 3 Offset 48 + OpMemberDecorate %Params 4 Offset 64 + OpMemberDecorate %Params 5 Offset 80 + OpMemberDecorate %CB1 0 Offset 0 + OpDecorate %CB1 Block + OpDecorate %_ DescriptorSet 0 + OpDecorate %_ Binding 1 + OpDecorate %mapSampler DescriptorSet 1 + OpDecorate %mapSampler Binding 2 + OpDecorate %mapTexture DescriptorSet 1 + OpDecorate %mapTexture Binding 2 + OpDecorate %IN_p BuiltIn FragCoord + OpDecorate %IN_uv Location 0 + OpDecorate %_entryPointOutput Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v2float = OpTypeVector %float 2 + %9 = OpTypeSampler + %11 = OpTypeImage %float 2D 0 0 0 1 Unknown + %v4float = OpTypeVector %float 4 +%float_0_222222 = OpConstant %float 0.222222 + %33 = OpTypeSampledImage %11 + %uint = OpTypeInt 32 0 + %float_80 = OpConstant %float 80 +%float_0_0008 = OpConstant %float 0.0008 +%float_8en05 = OpConstant %float 8e-05 +%float_0_008 = OpConstant %float 0.008 + %float_0 = OpConstant %float 0 + %int = OpTypeInt 32 1 + %int_n3 = OpConstant %int -3 + %int_3 = OpConstant %int 3 + %bool = OpTypeBool + %float_1 = OpConstant %float 1 + %int_1 = OpConstant %int 1 + %Params = OpTypeStruct %v4float %v4float %v4float %v4float %v4float %v4float + %CB1 = OpTypeStruct %Params +%_ptr_Uniform_CB1 = OpTypePointer Uniform %CB1 + %_ = OpVariable %_ptr_Uniform_CB1 Uniform + %int_0 = OpConstant %int 0 + %uint_3 = OpConstant %uint 3 +%_ptr_Uniform_float = OpTypePointer Uniform %float +%_ptr_UniformConstant_9 = OpTypePointer UniformConstant %9 + %mapSampler = OpVariable %_ptr_UniformConstant_9 UniformConstant +%_ptr_UniformConstant_11 = OpTypePointer UniformConstant %11 + %mapTexture = OpVariable %_ptr_UniformConstant_11 UniformConstant +%_ptr_Input_v4float = OpTypePointer Input %v4float + %IN_p = OpVariable %_ptr_Input_v4float Input +%_ptr_Input_v2float = OpTypePointer Input %v2float + %IN_uv = OpVariable %_ptr_Input_v2float Input +%_ptr_Output_v4float = OpTypePointer Output %v4float +%_entryPointOutput = OpVariable %_ptr_Output_v4float Output + %main = OpFunction %void None %3 + %5 = OpLabel + %158 = OpLoad %v2float %IN_uv + %178 = OpAccessChain %_ptr_Uniform_float %_ %int_0 %int_0 %uint_3 + %179 = OpLoad %float %178 + %180 = OpCompositeConstruct %v2float %float_0 %179 + %184 = OpLoad %9 %mapSampler + %185 = OpLoad %11 %mapTexture + %204 = OpSampledImage %33 %185 %184 + %206 = OpImageSampleImplicitLod %v4float %204 %158 + %207 = OpCompositeExtract %float %206 1 + %209 = OpFMul %float %207 %float_80 + %210 = OpFMul %float %209 %float_0_0008 + %211 = OpExtInst %float %1 FClamp %210 %float_8en05 %float_0_008 + OpBranch %212 + %212 = OpLabel + %276 = OpPhi %float %float_0 %5 %252 %218 + %277 = OpPhi %float %float_0 %5 %255 %218 + %278 = OpPhi %int %int_n3 %5 %257 %218 + %217 = OpSLessThanEqual %bool %278 %int_3 + OpLoopMerge %213 %218 None + OpBranchConditional %217 %218 %213 + %218 = OpLabel + %220 = OpConvertSToF %float %278 + %222 = OpFNegate %float %220 + %224 = OpFMul %float %222 %220 + %226 = OpFMul %float %224 %float_0_222222 + %227 = OpExtInst %float %1 Exp %226 + %230 = OpSampledImage %33 %185 %184 + %234 = OpVectorTimesScalar %v2float %180 %220 + %235 = OpFAdd %v2float %158 %234 + %236 = OpImageSampleImplicitLod %v4float %230 %235 + %273 = OpCompositeExtract %float %236 1 + %241 = OpFSub %float %273 %207 + %242 = OpExtInst %float %1 FAbs %241 + %244 = OpFOrdLessThan %bool %242 %211 + %245 = OpSelect %float %244 %float_1 %float_0 + %246 = OpFMul %float %227 %245 + %275 = OpCompositeExtract %float %236 0 + %250 = OpFMul %float %275 %246 + %252 = OpFAdd %float %276 %250 + %255 = OpFAdd %float %277 %246 + %257 = OpIAdd %int %278 %int_1 + OpBranch %212 + %213 = OpLabel + %260 = OpFDiv %float %276 %277 + %190 = OpCompositeConstruct %v4float %260 %207 %float_0 %float_1 + OpStore %_entryPointOutput %190 + OpReturn + OpFunctionEnd diff --git a/shaders/asm/frag/multi-for-loop-init.asm.frag b/shaders/asm/frag/multi-for-loop-init.asm.frag new file mode 100644 index 0000000000..d74f7ce568 --- /dev/null +++ b/shaders/asm/frag/multi-for-loop-init.asm.frag @@ -0,0 +1,111 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 3 +; Bound: 52 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %FragColor %counter %ucounter + OpExecutionMode %main OriginUpperLeft + OpSource ESSL 310 + OpName %main "main" + OpName %FragColor "FragColor" + OpName %i "i" + OpName %j "j" + OpName %counter "counter" + OpName %ucounter "ucounter" + OpDecorate %FragColor RelaxedPrecision + OpDecorate %FragColor Location 0 + OpDecorate %i RelaxedPrecision + OpDecorate %j RelaxedPrecision + OpDecorate %23 RelaxedPrecision + OpDecorate %27 RelaxedPrecision + OpDecorate %31 RelaxedPrecision + OpDecorate %32 RelaxedPrecision + OpDecorate %33 RelaxedPrecision + OpDecorate %34 RelaxedPrecision + OpDecorate %35 RelaxedPrecision + OpDecorate %36 RelaxedPrecision + OpDecorate %37 RelaxedPrecision + OpDecorate %38 RelaxedPrecision + OpDecorate %39 RelaxedPrecision + OpDecorate %40 RelaxedPrecision + OpDecorate %counter RelaxedPrecision + OpDecorate %counter Flat + OpDecorate %counter Location 0 + OpDecorate %43 RelaxedPrecision + OpDecorate %44 RelaxedPrecision + OpDecorate %45 RelaxedPrecision + OpDecorate %46 RelaxedPrecision + OpDecorate %47 RelaxedPrecision + OpDecorate %48 RelaxedPrecision + OpDecorate %ucounter RelaxedPrecision + OpDecorate %ucounter Flat + OpDecorate %ucounter Location 1 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %FragColor = OpVariable %_ptr_Output_v4float Output + %float_0 = OpConstant %float 0 + %11 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0 + %int = OpTypeInt 32 1 +%_ptr_Function_int = OpTypePointer Function %int + %uint = OpTypeInt 32 0 +%_ptr_Function_uint = OpTypePointer Function %uint + %int_0 = OpConstant %int 0 + %int_1 = OpConstant %uint 1 + %int_10 = OpConstant %int 10 + %bool = OpTypeBool + %int_20 = OpConstant %uint 20 +%_ptr_Input_int = OpTypePointer Input %int + %counter = OpVariable %_ptr_Input_int Input +%_ptr_Input_uint = OpTypePointer Input %uint + %ucounter = OpVariable %_ptr_Input_uint Input + %main = OpFunction %void None %3 + %5 = OpLabel + %i = OpVariable %_ptr_Function_int Function + %j = OpVariable %_ptr_Function_uint Function + OpStore %FragColor %11 + OpStore %i %int_0 + OpStore %j %int_1 + OpBranch %18 + %18 = OpLabel + OpLoopMerge %20 %21 None + OpBranch %22 + %22 = OpLabel + %23 = OpLoad %int %i + %26 = OpSLessThan %bool %23 %int_10 + %27 = OpLoad %uint %j + %29 = OpSLessThan %bool %27 %int_20 + %30 = OpLogicalAnd %bool %26 %29 + OpBranchConditional %30 %19 %20 + %19 = OpLabel + %31 = OpLoad %int %i + %32 = OpConvertSToF %float %31 + %33 = OpCompositeConstruct %v4float %32 %32 %32 %32 + %34 = OpLoad %v4float %FragColor + %35 = OpFAdd %v4float %34 %33 + OpStore %FragColor %35 + %36 = OpLoad %uint %j + %37 = OpConvertUToF %float %36 + %38 = OpCompositeConstruct %v4float %37 %37 %37 %37 + %39 = OpLoad %v4float %FragColor + %40 = OpFAdd %v4float %39 %38 + OpStore %FragColor %40 + OpBranch %21 + %21 = OpLabel + %43 = OpLoad %int %counter + %44 = OpLoad %int %i + %45 = OpIAdd %int %44 %43 + OpStore %i %45 + %46 = OpLoad %int %counter + %47 = OpLoad %uint %j + %48 = OpIAdd %uint %47 %46 + OpStore %j %48 + OpBranch %18 + %20 = OpLabel + OpReturn + OpFunctionEnd diff --git a/shaders/asm/frag/op-constant-null.asm.frag b/shaders/asm/frag/op-constant-null.asm.frag new file mode 100644 index 0000000000..61d2e579c8 --- /dev/null +++ b/shaders/asm/frag/op-constant-null.asm.frag @@ -0,0 +1,85 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 1 +; Bound: 45 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %FragColor + OpExecutionMode %main OriginUpperLeft + OpSource ESSL 310 + OpName %main "main" + OpName %a "a" + OpName %b "b" + OpName %c "c" + OpName %D "D" + OpMemberName %D 0 "a" + OpMemberName %D 1 "b" + OpName %d "d" + OpName %e "e" + OpName %FragColor "FragColor" + OpDecorate %a RelaxedPrecision + OpDecorate %b RelaxedPrecision + OpDecorate %c RelaxedPrecision + OpMemberDecorate %D 0 RelaxedPrecision + OpMemberDecorate %D 1 RelaxedPrecision + OpDecorate %e RelaxedPrecision + OpDecorate %FragColor RelaxedPrecision + OpDecorate %FragColor Location 0 + OpDecorate %44 RelaxedPrecision + OpDecorate %float_1 RelaxedPrecision + OpDecorate %14 RelaxedPrecision + OpDecorate %23 RelaxedPrecision + OpDecorate %41 RelaxedPrecision + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 +%_ptr_Function_float = OpTypePointer Function %float + %float_1 = OpConstantNull %float + %v4float = OpTypeVector %float 4 +%_ptr_Function_v4float = OpTypePointer Function %v4float + %float_2 = OpConstantNull %float + %14 = OpConstantNull %v4float + %v3float = OpTypeVector %float 3 +%mat2v3float = OpTypeMatrix %v3float 2 +%_ptr_Function_mat2v3float = OpTypePointer Function %mat2v3float + %float_4 = OpConstantNull %float + %20 = OpConstantNull %v3float + %float_5 = OpConstantNull %float + %22 = OpConstantNull %v3float + %23 = OpConstantNull %mat2v3float + %D = OpTypeStruct %v4float %float +%_ptr_Function_D = OpTypePointer Function %D + %27 = OpConstantNull %D + %uint = OpTypeInt 32 0 + %uint_4 = OpConstant %uint 4 +%_arr_v4float_uint_4 = OpTypeArray %v4float %uint_4 +%_ptr_Function__arr_v4float_uint_4 = OpTypePointer Function %_arr_v4float_uint_4 + %float_10 = OpConstantNull %float + %34 = OpConstantNull %v4float + %float_11 = OpConstantNull %float + %36 = OpConstantNull %v4float + %float_12 = OpConstantNull %float + %38 = OpConstantNull %v4float + %float_13 = OpConstantNull %float + %40 = OpConstantNull %v4float + %41 = OpConstantNull %_arr_v4float_uint_4 +%_ptr_Output_float = OpTypePointer Output %float + %FragColor = OpVariable %_ptr_Output_float Output + %main = OpFunction %void None %3 + %5 = OpLabel + %a = OpVariable %_ptr_Function_float Function + %b = OpVariable %_ptr_Function_v4float Function + %c = OpVariable %_ptr_Function_mat2v3float Function + %d = OpVariable %_ptr_Function_D Function + %e = OpVariable %_ptr_Function__arr_v4float_uint_4 Function + OpStore %a %float_1 + OpStore %b %14 + OpStore %c %23 + OpStore %d %27 + OpStore %e %41 + %44 = OpLoad %float %a + OpStore %FragColor %44 + OpReturn + OpFunctionEnd diff --git a/shaders/asm/frag/phi-loop-variable.asm.frag b/shaders/asm/frag/phi-loop-variable.asm.frag new file mode 100644 index 0000000000..74c46b4af8 --- /dev/null +++ b/shaders/asm/frag/phi-loop-variable.asm.frag @@ -0,0 +1,71 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 1 +; Bound: 59 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" + OpExecutionMode %4 OriginUpperLeft + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v2float = OpTypeVector %float 2 +%mat2v2float = OpTypeMatrix %v2float 2 +%_ptr_Function_mat2v2float = OpTypePointer Function %mat2v2float + %v3float = OpTypeVector %float 3 + %11 = OpTypeFunction %v3float %_ptr_Function_mat2v2float +%_ptr_Function_v3float = OpTypePointer Function %v3float + %float_1 = OpConstant %float 1 + %18 = OpConstantComposite %v3float %float_1 %float_1 %float_1 + %int = OpTypeInt 32 1 +%_ptr_Function_int = OpTypePointer Function %int + %int_35 = OpConstant %int 35 + %int_0 = OpConstant %int 0 + %bool = OpTypeBool + %int_1 = OpConstant %int 1 + %4 = OpFunction %void None %3 + %5 = OpLabel + OpBranch %48 + %48 = OpLabel + %58 = OpPhi %int %int_35 %5 %56 %50 + OpLoopMerge %49 %50 None + OpBranch %51 + %51 = OpLabel + %53 = OpSGreaterThanEqual %bool %58 %int_0 + OpBranchConditional %53 %54 %49 + %54 = OpLabel + OpBranch %50 + %50 = OpLabel + %56 = OpISub %int %58 %int_1 + OpBranch %48 + %49 = OpLabel + OpReturn + OpFunctionEnd + %13 = OpFunction %v3float None %11 + %12 = OpFunctionParameter %_ptr_Function_mat2v2float + %14 = OpLabel + %16 = OpVariable %_ptr_Function_v3float Function + %21 = OpVariable %_ptr_Function_int Function + OpStore %16 %18 + OpStore %21 %int_35 + OpBranch %23 + %23 = OpLabel + OpLoopMerge %25 %26 None + OpBranch %27 + %27 = OpLabel + %28 = OpLoad %int %21 + %31 = OpSGreaterThanEqual %bool %28 %int_0 + OpBranchConditional %31 %24 %25 + %24 = OpLabel + OpBranch %26 + %26 = OpLabel + %32 = OpLoad %int %21 + %34 = OpISub %int %32 %int_1 + OpStore %21 %34 + OpBranch %23 + %25 = OpLabel + %35 = OpLoad %v3float %16 + OpReturnValue %35 + OpFunctionEnd diff --git a/shaders/asm/frag/sampler-buffer-without-sampler.asm.frag b/shaders/asm/frag/sampler-buffer-without-sampler.asm.frag new file mode 100644 index 0000000000..9c08fc2830 --- /dev/null +++ b/shaders/asm/frag/sampler-buffer-without-sampler.asm.frag @@ -0,0 +1,59 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 1 +; Bound: 36 +; Schema: 0 + OpCapability Shader + OpCapability SampledBuffer + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %_entryPointOutput + OpExecutionMode %main OriginUpperLeft + OpName %main "main" + OpName %_main_ "@main(" + OpName %storeTemp "storeTemp" + OpName %RWTex "RWTex" + OpName %Tex "Tex" + OpName %_entryPointOutput "@entryPointOutput" + OpDecorate %RWTex DescriptorSet 0 + OpDecorate %Tex DescriptorSet 0 + OpDecorate %_entryPointOutput Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %8 = OpTypeFunction %v4float +%_ptr_Function_v4float = OpTypePointer Function %v4float + %13 = OpConstant %float 1 + %14 = OpConstant %float 2 + %15 = OpConstant %float 3 + %16 = OpConstant %float 4 + %17 = OpConstantComposite %v4float %13 %14 %15 %16 + %18 = OpTypeImage %float Buffer 0 0 0 2 Rgba32f +%_ptr_UniformConstant_18 = OpTypePointer UniformConstant %18 + %RWTex = OpVariable %_ptr_UniformConstant_18 UniformConstant + %int = OpTypeInt 32 1 + %23 = OpConstant %int 20 + %25 = OpTypeImage %float Buffer 0 0 0 1 Rgba32f +%_ptr_UniformConstant_25 = OpTypePointer UniformConstant %25 + %Tex = OpVariable %_ptr_UniformConstant_25 UniformConstant + %29 = OpConstant %int 10 +%_ptr_Output_v4float = OpTypePointer Output %v4float +%_entryPointOutput = OpVariable %_ptr_Output_v4float Output + %main = OpFunction %void None %3 + %5 = OpLabel + %35 = OpFunctionCall %v4float %_main_ + OpStore %_entryPointOutput %35 + OpReturn + OpFunctionEnd + %_main_ = OpFunction %v4float None %8 + %10 = OpLabel + %storeTemp = OpVariable %_ptr_Function_v4float Function + OpStore %storeTemp %17 + %21 = OpLoad %18 %RWTex + %24 = OpLoad %v4float %storeTemp + OpImageWrite %21 %23 %24 + %28 = OpLoad %25 %Tex + %30 = OpImageFetch %v4float %28 %29 + OpReturnValue %30 + OpFunctionEnd diff --git a/shaders/asm/frag/struct-composite-extract-swizzle.asm.frag b/shaders/asm/frag/struct-composite-extract-swizzle.asm.frag new file mode 100644 index 0000000000..33bd1c9163 --- /dev/null +++ b/shaders/asm/frag/struct-composite-extract-swizzle.asm.frag @@ -0,0 +1,55 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 1 +; Bound: 34 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %FragColor + OpExecutionMode %main OriginUpperLeft + OpSource ESSL 310 + OpName %main "main" + OpName %FragColor "FragColor" + OpName %uSampler "uSampler" + OpName %Foo "Foo" + OpMemberName %Foo 0 "var1" + OpMemberName %Foo 1 "var2" + OpName %foo "foo" + OpDecorate %FragColor RelaxedPrecision + OpDecorate %FragColor Location 0 + OpDecorate %uSampler RelaxedPrecision + OpDecorate %uSampler DescriptorSet 0 + OpDecorate %uSampler Binding 0 + OpDecorate %14 RelaxedPrecision + OpMemberDecorate %Foo 0 RelaxedPrecision + OpMemberDecorate %Foo 1 RelaxedPrecision + OpDecorate %27 RelaxedPrecision + OpDecorate %28 RelaxedPrecision + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %FragColor = OpVariable %_ptr_Output_v4float Output + %10 = OpTypeImage %float 2D 0 0 0 1 Unknown + %11 = OpTypeSampledImage %10 +%_ptr_UniformConstant_11 = OpTypePointer UniformConstant %11 + %uSampler = OpVariable %_ptr_UniformConstant_11 UniformConstant + %Foo = OpTypeStruct %float %float +%_ptr_Function_Foo = OpTypePointer Function %Foo + %int = OpTypeInt 32 1 +%_ptr_Function_float = OpTypePointer Function %float + %v2float = OpTypeVector %float 2 + %33 = OpUndef %Foo + %main = OpFunction %void None %3 + %5 = OpLabel + %foo = OpVariable %_ptr_Function_Foo Function + %14 = OpLoad %11 %uSampler + %30 = OpCompositeExtract %float %33 0 + %32 = OpCompositeExtract %float %33 1 + %27 = OpCompositeConstruct %v2float %30 %32 + %28 = OpImageSampleImplicitLod %v4float %14 %27 + OpStore %FragColor %28 + OpReturn + OpFunctionEnd diff --git a/shaders/asm/frag/temporary-phi-hoisting.asm.frag b/shaders/asm/frag/temporary-phi-hoisting.asm.frag new file mode 100644 index 0000000000..7cedcd5819 --- /dev/null +++ b/shaders/asm/frag/temporary-phi-hoisting.asm.frag @@ -0,0 +1,75 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 1 +; Bound: 87 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %_entryPointOutput + OpExecutionMode %main OriginUpperLeft + OpSource HLSL 500 + OpName %main "main" + OpName %MyStruct "MyStruct" + OpMemberName %MyStruct 0 "color" + OpName %MyStruct_CB "MyStruct_CB" + OpMemberName %MyStruct_CB 0 "g_MyStruct" + OpName %_ "" + OpName %_entryPointOutput "@entryPointOutput" + OpMemberDecorate %MyStruct 0 Offset 0 + OpDecorate %_arr_MyStruct_uint_4 ArrayStride 16 + OpMemberDecorate %MyStruct_CB 0 Offset 0 + OpDecorate %MyStruct_CB Block + OpDecorate %_ DescriptorSet 0 + OpDecorate %_entryPointOutput Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %v3float = OpTypeVector %float 3 + %float_0 = OpConstant %float 0 + %15 = OpConstantComposite %v3float %float_0 %float_0 %float_0 + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %int_4 = OpConstant %int 4 + %bool = OpTypeBool + %MyStruct = OpTypeStruct %v4float + %uint = OpTypeInt 32 0 + %uint_4 = OpConstant %uint 4 +%_arr_MyStruct_uint_4 = OpTypeArray %MyStruct %uint_4 +%MyStruct_CB = OpTypeStruct %_arr_MyStruct_uint_4 +%_ptr_Uniform_MyStruct_CB = OpTypePointer Uniform %MyStruct_CB + %_ = OpVariable %_ptr_Uniform_MyStruct_CB Uniform +%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float + %int_1 = OpConstant %int 1 + %float_1 = OpConstant %float 1 +%_ptr_Output_v4float = OpTypePointer Output %v4float +%_entryPointOutput = OpVariable %_ptr_Output_v4float Output + %main = OpFunction %void None %3 + %5 = OpLabel + OpBranch %64 + %64 = OpLabel + %85 = OpPhi %v3float %15 %5 %77 %66 + %86 = OpPhi %int %int_0 %5 %79 %66 + OpLoopMerge %65 %66 None + OpBranch %67 + %67 = OpLabel + %69 = OpSLessThan %bool %86 %int_4 + OpBranchConditional %69 %70 %65 + %70 = OpLabel + %72 = OpAccessChain %_ptr_Uniform_v4float %_ %int_0 %86 %int_0 + %73 = OpLoad %v4float %72 + %74 = OpVectorShuffle %v3float %73 %73 0 1 2 + %77 = OpFAdd %v3float %85 %74 + OpBranch %66 + %66 = OpLabel + %79 = OpIAdd %int %86 %int_1 + OpBranch %64 + %65 = OpLabel + %81 = OpCompositeExtract %float %85 0 + %82 = OpCompositeExtract %float %85 1 + %83 = OpCompositeExtract %float %85 2 + %84 = OpCompositeConstruct %v4float %81 %82 %83 %float_1 + OpStore %_entryPointOutput %84 + OpReturn + OpFunctionEnd diff --git a/shaders/asm/frag/undef-variable-store.asm.frag b/shaders/asm/frag/undef-variable-store.asm.frag new file mode 100644 index 0000000000..966c2d9d5a --- /dev/null +++ b/shaders/asm/frag/undef-variable-store.asm.frag @@ -0,0 +1,85 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 1 +; Bound: 50 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %fragmentProgram "main" %_entryPointOutput + OpExecutionMode %fragmentProgram OriginUpperLeft + OpSource HLSL 500 + OpName %fragmentProgram "fragmentProgram" + OpName %_fragmentProgram_ "@fragmentProgram(" + OpName %uv "uv" + OpName %_entryPointOutput "@entryPointOutput" + OpDecorate %_entryPointOutput Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %8 = OpTypeFunction %v4float + %v2float = OpTypeVector %float 2 +%_ptr_Function_v2float = OpTypePointer Function %v2float + %float_0 = OpConstant %float 0 + %15 = OpConstantComposite %v2float %float_0 %float_0 + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 +%_ptr_Function_float = OpTypePointer Function %float + %bool = OpTypeBool + %float_1 = OpConstant %float 1 + %26 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1 + %29 = OpConstantComposite %v4float %float_1 %float_1 %float_0 %float_1 +%_ptr_Output_v4float = OpTypePointer Output %v4float +%_entryPointOutput = OpVariable %_ptr_Output_v4float Output +%_ptr_Function_v4float = OpTypePointer Function %v4float + %false = OpConstantFalse %bool +%fragmentProgram = OpFunction %void None %3 + %5 = OpLabel + %35 = OpVariable %_ptr_Function_v2float Function + %37 = OpVariable %_ptr_Function_v4float Function + OpBranch %38 + %38 = OpLabel + OpLoopMerge %39 %40 None + OpBranch %41 + %41 = OpLabel + OpStore %35 %15 + %42 = OpAccessChain %_ptr_Function_float %35 %uint_0 + %43 = OpLoad %float %42 + %44 = OpFOrdNotEqual %bool %43 %float_0 + OpSelectionMerge %45 None + OpBranchConditional %44 %46 %47 + %46 = OpLabel + OpStore %37 %26 + OpBranch %39 + %47 = OpLabel + OpStore %37 %29 + OpBranch %39 + %45 = OpLabel + %48 = OpUndef %v4float + OpStore %37 %48 + OpBranch %39 + %40 = OpLabel + OpBranchConditional %false %38 %39 + %39 = OpLabel + %34 = OpLoad %v4float %37 + OpStore %_entryPointOutput %34 + OpReturn + OpFunctionEnd +%_fragmentProgram_ = OpFunction %v4float None %8 + %10 = OpLabel + %uv = OpVariable %_ptr_Function_v2float Function + OpStore %uv %15 + %19 = OpAccessChain %_ptr_Function_float %uv %uint_0 + %20 = OpLoad %float %19 + %22 = OpFOrdNotEqual %bool %20 %float_0 + OpSelectionMerge %24 None + OpBranchConditional %22 %23 %28 + %23 = OpLabel + OpReturnValue %26 + %28 = OpLabel + OpReturnValue %29 + %24 = OpLabel + %31 = OpUndef %v4float + OpReturnValue %31 + OpFunctionEnd diff --git a/shaders/asm/frag/unreachable.asm.frag b/shaders/asm/frag/unreachable.asm.frag new file mode 100644 index 0000000000..e2ce2eb56a --- /dev/null +++ b/shaders/asm/frag/unreachable.asm.frag @@ -0,0 +1,61 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 3 +; Bound: 47 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %counter %FragColor + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 450 + OpName %main "main" + OpName %counter "counter" + OpName %FragColor "FragColor" + OpDecorate %counter Flat + OpDecorate %counter Location 0 + OpDecorate %FragColor Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %8 = OpTypeFunction %v4float + %int = OpTypeInt 32 1 +%_ptr_Input_int = OpTypePointer Input %int + %counter = OpVariable %_ptr_Input_int Input + %int_10 = OpConstant %int 10 + %bool = OpTypeBool + %float_10 = OpConstant %float 10 + %21 = OpConstantComposite %v4float %float_10 %float_10 %float_10 %float_10 + %float_30 = OpConstant %float 30 + %25 = OpConstantComposite %v4float %float_30 %float_30 %float_30 %float_30 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %FragColor = OpVariable %_ptr_Output_v4float Output +%_ptr_Function_v4float = OpTypePointer Function %v4float + %false = OpConstantFalse %bool + %44 = OpUndef %v4float + %main = OpFunction %void None %3 + %5 = OpLabel + OpBranch %33 + %33 = OpLabel + %45 = OpPhi %v4float %44 %5 %44 %35 + OpLoopMerge %34 %35 None + OpBranch %36 + %36 = OpLabel + %37 = OpLoad %int %counter + %38 = OpIEqual %bool %37 %int_10 + OpSelectionMerge %39 None + OpBranchConditional %38 %40 %41 + %40 = OpLabel + OpBranch %34 + %41 = OpLabel + OpBranch %34 + %39 = OpLabel + OpUnreachable + %35 = OpLabel + OpBranchConditional %false %33 %34 + %34 = OpLabel + %46 = OpPhi %v4float %21 %40 %25 %41 %44 %35 + OpStore %FragColor %46 + OpReturn + OpFunctionEnd diff --git a/shaders/asm/frag/vector-shuffle-oom.asm.frag b/shaders/asm/frag/vector-shuffle-oom.asm.frag new file mode 100644 index 0000000000..d60c6f52d4 --- /dev/null +++ b/shaders/asm/frag/vector-shuffle-oom.asm.frag @@ -0,0 +1,886 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 2 +; Bound: 25007 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %5663 "main" %5800 %gl_FragCoord %4317 + OpExecutionMode %5663 OriginUpperLeft + OpMemberDecorate %_struct_1116 0 Offset 0 + OpMemberDecorate %_struct_1116 1 Offset 16 + OpMemberDecorate %_struct_1116 2 Offset 32 + OpDecorate %_struct_1116 Block + OpDecorate %22044 DescriptorSet 0 + OpDecorate %22044 Binding 0 + OpDecorate %5785 DescriptorSet 0 + OpDecorate %5785 Binding 140 + OpDecorate %5688 DescriptorSet 0 + OpDecorate %5688 Binding 60 + OpMemberDecorate %_struct_994 0 Offset 0 + OpMemberDecorate %_struct_994 1 Offset 16 + OpMemberDecorate %_struct_994 2 Offset 28 + OpMemberDecorate %_struct_994 3 Offset 32 + OpMemberDecorate %_struct_994 4 Offset 44 + OpMemberDecorate %_struct_994 5 Offset 48 + OpMemberDecorate %_struct_994 6 Offset 60 + OpMemberDecorate %_struct_994 7 Offset 64 + OpMemberDecorate %_struct_994 8 Offset 76 + OpMemberDecorate %_struct_994 9 Offset 80 + OpMemberDecorate %_struct_994 10 Offset 92 + OpMemberDecorate %_struct_994 11 Offset 96 + OpMemberDecorate %_struct_994 12 Offset 108 + OpMemberDecorate %_struct_994 13 Offset 112 + OpMemberDecorate %_struct_994 14 Offset 120 + OpMemberDecorate %_struct_994 15 Offset 128 + OpMemberDecorate %_struct_994 16 Offset 140 + OpMemberDecorate %_struct_994 17 Offset 144 + OpMemberDecorate %_struct_994 18 Offset 148 + OpMemberDecorate %_struct_994 19 Offset 152 + OpMemberDecorate %_struct_994 20 Offset 156 + OpMemberDecorate %_struct_994 21 Offset 160 + OpMemberDecorate %_struct_994 22 Offset 176 + OpMemberDecorate %_struct_994 23 RowMajor + OpMemberDecorate %_struct_994 23 Offset 192 + OpMemberDecorate %_struct_994 23 MatrixStride 16 + OpMemberDecorate %_struct_994 24 Offset 256 + OpDecorate %_struct_994 Block + OpDecorate %12348 DescriptorSet 0 + OpDecorate %12348 Binding 2 + OpDecorate %3312 DescriptorSet 0 + OpDecorate %3312 Binding 142 + OpDecorate %4646 DescriptorSet 0 + OpDecorate %4646 Binding 62 + OpDecorate %4862 DescriptorSet 0 + OpDecorate %4862 Binding 141 + OpDecorate %3594 DescriptorSet 0 + OpDecorate %3594 Binding 61 + OpDecorate %_arr_mat4v4float_uint_2 ArrayStride 64 + OpDecorate %_arr_v4float_uint_2 ArrayStride 16 + OpMemberDecorate %_struct_408 0 RowMajor + OpMemberDecorate %_struct_408 0 Offset 0 + OpMemberDecorate %_struct_408 0 MatrixStride 16 + OpMemberDecorate %_struct_408 1 RowMajor + OpMemberDecorate %_struct_408 1 Offset 64 + OpMemberDecorate %_struct_408 1 MatrixStride 16 + OpMemberDecorate %_struct_408 2 RowMajor + OpMemberDecorate %_struct_408 2 Offset 128 + OpMemberDecorate %_struct_408 2 MatrixStride 16 + OpMemberDecorate %_struct_408 3 RowMajor + OpMemberDecorate %_struct_408 3 Offset 192 + OpMemberDecorate %_struct_408 3 MatrixStride 16 + OpMemberDecorate %_struct_408 4 Offset 256 + OpMemberDecorate %_struct_408 5 Offset 272 + OpMemberDecorate %_struct_408 6 Offset 288 + OpMemberDecorate %_struct_408 7 Offset 292 + OpMemberDecorate %_struct_408 8 Offset 296 + OpMemberDecorate %_struct_408 9 Offset 300 + OpMemberDecorate %_struct_408 10 Offset 304 + OpMemberDecorate %_struct_408 11 Offset 316 + OpMemberDecorate %_struct_408 12 Offset 320 + OpMemberDecorate %_struct_408 13 Offset 332 + OpMemberDecorate %_struct_408 14 Offset 336 + OpMemberDecorate %_struct_408 15 Offset 348 + OpMemberDecorate %_struct_408 16 Offset 352 + OpMemberDecorate %_struct_408 17 Offset 364 + OpMemberDecorate %_struct_408 18 Offset 368 + OpMemberDecorate %_struct_408 19 Offset 372 + OpMemberDecorate %_struct_408 20 Offset 376 + OpMemberDecorate %_struct_408 21 Offset 384 + OpMemberDecorate %_struct_408 22 Offset 392 + OpMemberDecorate %_struct_408 23 Offset 400 + OpMemberDecorate %_struct_408 24 Offset 416 + OpMemberDecorate %_struct_408 25 Offset 424 + OpMemberDecorate %_struct_408 26 Offset 432 + OpMemberDecorate %_struct_408 27 Offset 448 + OpMemberDecorate %_struct_408 28 Offset 460 + OpMemberDecorate %_struct_408 29 Offset 464 + OpMemberDecorate %_struct_408 30 Offset 468 + OpMemberDecorate %_struct_408 31 Offset 472 + OpMemberDecorate %_struct_408 32 Offset 476 + OpMemberDecorate %_struct_408 33 Offset 480 + OpMemberDecorate %_struct_408 34 Offset 488 + OpMemberDecorate %_struct_408 35 Offset 492 + OpMemberDecorate %_struct_408 36 Offset 496 + OpMemberDecorate %_struct_408 37 RowMajor + OpMemberDecorate %_struct_408 37 Offset 512 + OpMemberDecorate %_struct_408 37 MatrixStride 16 + OpMemberDecorate %_struct_408 38 Offset 640 + OpDecorate %_struct_408 Block + OpDecorate %15259 DescriptorSet 0 + OpDecorate %15259 Binding 1 + OpDecorate %5800 Location 0 + OpDecorate %gl_FragCoord BuiltIn FragCoord + OpDecorate %4317 Location 0 + OpMemberDecorate %_struct_1395 0 Offset 0 + OpMemberDecorate %_struct_1395 1 Offset 16 + OpMemberDecorate %_struct_1395 2 Offset 32 + OpMemberDecorate %_struct_1395 3 Offset 40 + OpMemberDecorate %_struct_1395 4 Offset 48 + OpMemberDecorate %_struct_1395 5 Offset 60 + OpMemberDecorate %_struct_1395 6 Offset 64 + OpMemberDecorate %_struct_1395 7 Offset 76 + OpMemberDecorate %_struct_1395 8 Offset 80 + OpMemberDecorate %_struct_1395 9 Offset 96 + OpMemberDecorate %_struct_1395 10 Offset 112 + OpMemberDecorate %_struct_1395 11 Offset 128 + OpMemberDecorate %_struct_1395 12 Offset 140 + OpMemberDecorate %_struct_1395 13 Offset 144 + OpMemberDecorate %_struct_1395 14 Offset 156 + OpMemberDecorate %_struct_1395 15 Offset 160 + OpMemberDecorate %_struct_1395 16 Offset 176 + OpMemberDecorate %_struct_1395 17 Offset 192 + OpMemberDecorate %_struct_1395 18 Offset 204 + OpMemberDecorate %_struct_1395 19 Offset 208 + OpMemberDecorate %_struct_1395 20 Offset 224 + OpDecorate %_struct_1395 Block + OpMemberDecorate %_struct_1018 0 Offset 0 + OpDecorate %_struct_1018 Block + %void = OpTypeVoid + %1282 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v2float = OpTypeVector %float 2 + %v4float = OpTypeVector %float 4 + %v3float = OpTypeVector %float 3 +%_struct_1017 = OpTypeStruct %v4float +%_struct_1116 = OpTypeStruct %v4float %float %v4float +%_ptr_Uniform__struct_1116 = OpTypePointer Uniform %_struct_1116 + %22044 = OpVariable %_ptr_Uniform__struct_1116 Uniform + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 +%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float + %150 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_150 = OpTypePointer UniformConstant %150 + %5785 = OpVariable %_ptr_UniformConstant_150 UniformConstant + %508 = OpTypeSampler +%_ptr_UniformConstant_508 = OpTypePointer UniformConstant %508 + %5688 = OpVariable %_ptr_UniformConstant_508 UniformConstant + %510 = OpTypeSampledImage %150 + %float_0 = OpConstant %float 0 + %uint = OpTypeInt 32 0 + %int_1 = OpConstant %int 1 +%_ptr_Uniform_float = OpTypePointer Uniform %float + %float_1 = OpConstant %float 1 +%mat4v4float = OpTypeMatrix %v4float 4 +%_struct_994 = OpTypeStruct %v3float %v3float %float %v3float %float %v3float %float %v3float %float %v3float %float %v3float %float %v2float %v2float %v3float %float %float %float %float %float %v4float %v4float %mat4v4float %v4float +%_ptr_Uniform__struct_994 = OpTypePointer Uniform %_struct_994 + %12348 = OpVariable %_ptr_Uniform__struct_994 Uniform + %int_5 = OpConstant %int 5 +%_ptr_Uniform_v3float = OpTypePointer Uniform %v3float + %3312 = OpVariable %_ptr_UniformConstant_150 UniformConstant + %4646 = OpVariable %_ptr_UniformConstant_508 UniformConstant + %bool = OpTypeBool + %4862 = OpVariable %_ptr_UniformConstant_150 UniformConstant + %3594 = OpVariable %_ptr_UniformConstant_508 UniformConstant + %uint_2 = OpConstant %uint 2 + %2938 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0 +%_arr_mat4v4float_uint_2 = OpTypeArray %mat4v4float %uint_2 +%_arr_v4float_uint_2 = OpTypeArray %v4float %uint_2 +%_struct_408 = OpTypeStruct %mat4v4float %mat4v4float %mat4v4float %mat4v4float %v4float %v4float %float %float %float %float %v3float %float %v3float %float %v3float %float %v3float %float %float %float %v2float %v2float %v2float %v4float %v2float %v2float %v2float %v3float %float %float %float %float %float %v2float %float %float %v3float %_arr_mat4v4float_uint_2 %_arr_v4float_uint_2 +%_ptr_Uniform__struct_408 = OpTypePointer Uniform %_struct_408 + %15259 = OpVariable %_ptr_Uniform__struct_408 Uniform + %int_23 = OpConstant %int 23 + %int_2 = OpConstant %int 2 + %float_n2 = OpConstant %float -2 + %float_0_5 = OpConstant %float 0.5 + %1196 = OpConstantComposite %v3float %float_0 %float_n2 %float_0_5 + %float_n1 = OpConstant %float -1 + %836 = OpConstantComposite %v3float %float_n1 %float_n1 %float_0_5 + %float_0_75 = OpConstant %float 0.75 + %1367 = OpConstantComposite %v3float %float_0 %float_n1 %float_0_75 + %141 = OpConstantComposite %v3float %float_1 %float_n1 %float_0_5 + %38 = OpConstantComposite %v3float %float_n2 %float_0 %float_0_5 + %95 = OpConstantComposite %v3float %float_n1 %float_0 %float_0_75 + %626 = OpConstantComposite %v3float %float_0 %float_0 %float_1 + %2411 = OpConstantComposite %v3float %float_1 %float_0 %float_0_75 + %float_2 = OpConstant %float 2 + %2354 = OpConstantComposite %v3float %float_2 %float_0 %float_0_5 + %837 = OpConstantComposite %v3float %float_n1 %float_1 %float_0_5 + %1368 = OpConstantComposite %v3float %float_0 %float_1 %float_0_75 + %142 = OpConstantComposite %v3float %float_1 %float_1 %float_0_5 + %1197 = OpConstantComposite %v3float %float_0 %float_2 %float_0_5 +%_ptr_Input_v2float = OpTypePointer Input %v2float + %5800 = OpVariable %_ptr_Input_v2float Input +%_ptr_Input_v4float = OpTypePointer Input %v4float +%gl_FragCoord = OpVariable %_ptr_Input_v4float Input +%_ptr_Output_v4float = OpTypePointer Output %v4float + %4317 = OpVariable %_ptr_Output_v4float Output +%_struct_1395 = OpTypeStruct %v4float %v4float %v2float %v2float %v3float %float %v3float %float %v4float %v4float %v4float %v3float %float %v3float %float %v3float %v4float %v3float %float %v3float %v2float +%_struct_1018 = OpTypeStruct %v4float + %10264 = OpUndef %_struct_1017 + %5663 = OpFunction %void None %1282 + %25006 = OpLabel + %17463 = OpLoad %v4float %gl_FragCoord + %13863 = OpCompositeInsert %_struct_1017 %2938 %10264 0 + %22969 = OpVectorShuffle %v2float %17463 %17463 0 1 + %13206 = OpAccessChain %_ptr_Uniform_v4float %15259 %int_23 + %10343 = OpLoad %v4float %13206 + %7422 = OpVectorShuffle %v2float %10343 %10343 0 1 + %19927 = OpFMul %v2float %22969 %7422 + %18174 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_2 + %16206 = OpLoad %v4float %18174 + %20420 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 + %21354 = OpLoad %v4float %20420 + %7688 = OpVectorShuffle %v4float %21354 %21354 0 1 0 1 + %17581 = OpFMul %v4float %16206 %7688 + %10673 = OpVectorShuffle %v2float %1196 %1196 0 1 + %18824 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 + %10344 = OpLoad %v4float %18824 + %8638 = OpVectorShuffle %v2float %10344 %10344 0 1 + %9197 = OpFMul %v2float %10673 %8638 + %18505 = OpFAdd %v2float %19927 %9197 + %7011 = OpVectorShuffle %v2float %17581 %17581 0 1 + %21058 = OpVectorShuffle %v2float %17581 %17581 2 3 + %13149 = OpExtInst %v2float %1 FClamp %18505 %7011 %21058 + %23584 = OpLoad %150 %5785 + %10339 = OpLoad %508 %5688 + %12147 = OpSampledImage %510 %23584 %10339 + %15371 = OpImageSampleExplicitLod %v4float %12147 %13149 Lod %float_0 + %15266 = OpCompositeExtract %float %15371 3 + %12116 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 + %12972 = OpLoad %float %12116 + %15710 = OpFMul %float %15266 %12972 + %15279 = OpExtInst %float %1 FClamp %15710 %float_0 %float_1 + %22213 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 + %11756 = OpLoad %v3float %22213 + %12103 = OpVectorTimesScalar %v3float %11756 %15279 + %15516 = OpLoad %150 %3312 + %24569 = OpLoad %508 %4646 + %12148 = OpSampledImage %510 %15516 %24569 + %17670 = OpImageSampleExplicitLod %v4float %12148 %13149 Lod %float_0 + %16938 = OpCompositeExtract %float %17670 1 + %14185 = OpFOrdGreaterThan %bool %16938 %float_0 + OpSelectionMerge %22307 DontFlatten + OpBranchConditional %14185 %12821 %22307 + %12821 = OpLabel + %13239 = OpLoad %150 %4862 + %19960 = OpLoad %508 %3594 + %12149 = OpSampledImage %510 %13239 %19960 + %15675 = OpImageSampleExplicitLod %v4float %12149 %13149 Lod %float_0 + %13866 = OpCompositeExtract %float %17670 1 + %12427 = OpCompositeExtract %float %17670 2 + %23300 = OpFMul %float %13866 %12427 + %17612 = OpExtInst %float %1 FClamp %23300 %float_0 %float_1 + %20291 = OpVectorShuffle %v3float %15675 %15675 0 1 2 + %11186 = OpVectorTimesScalar %v3float %20291 %17612 + %15293 = OpFAdd %v3float %12103 %11186 + OpBranch %22307 + %22307 = OpLabel + %7719 = OpPhi %v3float %12103 %25006 %15293 %12821 + %23399 = OpVectorTimesScalar %v3float %7719 %float_0_5 + %9339 = OpFAdd %float %float_0 %float_0_5 + %16235 = OpVectorShuffle %v3float %2938 %2938 0 1 2 + %22177 = OpFAdd %v3float %16235 %23399 + %15527 = OpVectorShuffle %v4float %2938 %22177 4 5 6 3 + %6434 = OpCompositeInsert %_struct_1017 %15527 %13863 0 + %24572 = OpVectorShuffle %v2float %836 %836 0 1 + %13207 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 + %10345 = OpLoad %v4float %13207 + %8639 = OpVectorShuffle %v2float %10345 %10345 0 1 + %9198 = OpFMul %v2float %24572 %8639 + %18506 = OpFAdd %v2float %19927 %9198 + %7012 = OpVectorShuffle %v2float %17581 %17581 0 1 + %21059 = OpVectorShuffle %v2float %17581 %17581 2 3 + %13150 = OpExtInst %v2float %1 FClamp %18506 %7012 %21059 + %23585 = OpLoad %150 %5785 + %10340 = OpLoad %508 %5688 + %12150 = OpSampledImage %510 %23585 %10340 + %15372 = OpImageSampleExplicitLod %v4float %12150 %13150 Lod %float_0 + %15267 = OpCompositeExtract %float %15372 3 + %12117 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 + %12973 = OpLoad %float %12117 + %15711 = OpFMul %float %15267 %12973 + %15280 = OpExtInst %float %1 FClamp %15711 %float_0 %float_1 + %22214 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 + %11757 = OpLoad %v3float %22214 + %12104 = OpVectorTimesScalar %v3float %11757 %15280 + %15517 = OpLoad %150 %3312 + %24570 = OpLoad %508 %4646 + %12151 = OpSampledImage %510 %15517 %24570 + %17671 = OpImageSampleExplicitLod %v4float %12151 %13150 Lod %float_0 + %16939 = OpCompositeExtract %float %17671 1 + %14186 = OpFOrdGreaterThan %bool %16939 %float_0 + OpSelectionMerge %22308 DontFlatten + OpBranchConditional %14186 %12822 %22308 + %12822 = OpLabel + %13240 = OpLoad %150 %4862 + %19961 = OpLoad %508 %3594 + %12152 = OpSampledImage %510 %13240 %19961 + %15676 = OpImageSampleExplicitLod %v4float %12152 %13150 Lod %float_0 + %13867 = OpCompositeExtract %float %17671 1 + %12428 = OpCompositeExtract %float %17671 2 + %23301 = OpFMul %float %13867 %12428 + %17613 = OpExtInst %float %1 FClamp %23301 %float_0 %float_1 + %20292 = OpVectorShuffle %v3float %15676 %15676 0 1 2 + %11187 = OpVectorTimesScalar %v3float %20292 %17613 + %15294 = OpFAdd %v3float %12104 %11187 + OpBranch %22308 + %22308 = OpLabel + %7720 = OpPhi %v3float %12104 %22307 %15294 %12822 + %23400 = OpVectorTimesScalar %v3float %7720 %float_0_5 + %9340 = OpFAdd %float %9339 %float_0_5 + %16236 = OpVectorShuffle %v3float %15527 %15527 0 1 2 + %22178 = OpFAdd %v3float %16236 %23400 + %15528 = OpVectorShuffle %v4float %15527 %22178 4 5 6 3 + %6435 = OpCompositeInsert %_struct_1017 %15528 %6434 0 + %24573 = OpVectorShuffle %v2float %1367 %1367 0 1 + %13208 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 + %10346 = OpLoad %v4float %13208 + %8640 = OpVectorShuffle %v2float %10346 %10346 0 1 + %9199 = OpFMul %v2float %24573 %8640 + %18507 = OpFAdd %v2float %19927 %9199 + %7013 = OpVectorShuffle %v2float %17581 %17581 0 1 + %21060 = OpVectorShuffle %v2float %17581 %17581 2 3 + %13151 = OpExtInst %v2float %1 FClamp %18507 %7013 %21060 + %23586 = OpLoad %150 %5785 + %10341 = OpLoad %508 %5688 + %12153 = OpSampledImage %510 %23586 %10341 + %15373 = OpImageSampleExplicitLod %v4float %12153 %13151 Lod %float_0 + %15268 = OpCompositeExtract %float %15373 3 + %12118 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 + %12974 = OpLoad %float %12118 + %15712 = OpFMul %float %15268 %12974 + %15281 = OpExtInst %float %1 FClamp %15712 %float_0 %float_1 + %22215 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 + %11758 = OpLoad %v3float %22215 + %12105 = OpVectorTimesScalar %v3float %11758 %15281 + %15518 = OpLoad %150 %3312 + %24571 = OpLoad %508 %4646 + %12154 = OpSampledImage %510 %15518 %24571 + %17672 = OpImageSampleExplicitLod %v4float %12154 %13151 Lod %float_0 + %16940 = OpCompositeExtract %float %17672 1 + %14187 = OpFOrdGreaterThan %bool %16940 %float_0 + OpSelectionMerge %22309 DontFlatten + OpBranchConditional %14187 %12823 %22309 + %12823 = OpLabel + %13241 = OpLoad %150 %4862 + %19962 = OpLoad %508 %3594 + %12155 = OpSampledImage %510 %13241 %19962 + %15677 = OpImageSampleExplicitLod %v4float %12155 %13151 Lod %float_0 + %13868 = OpCompositeExtract %float %17672 1 + %12429 = OpCompositeExtract %float %17672 2 + %23302 = OpFMul %float %13868 %12429 + %17614 = OpExtInst %float %1 FClamp %23302 %float_0 %float_1 + %20293 = OpVectorShuffle %v3float %15677 %15677 0 1 2 + %11188 = OpVectorTimesScalar %v3float %20293 %17614 + %15295 = OpFAdd %v3float %12105 %11188 + OpBranch %22309 + %22309 = OpLabel + %7721 = OpPhi %v3float %12105 %22308 %15295 %12823 + %23401 = OpVectorTimesScalar %v3float %7721 %float_0_75 + %9341 = OpFAdd %float %9340 %float_0_75 + %16237 = OpVectorShuffle %v3float %15528 %15528 0 1 2 + %22179 = OpFAdd %v3float %16237 %23401 + %15529 = OpVectorShuffle %v4float %15528 %22179 4 5 6 3 + %6436 = OpCompositeInsert %_struct_1017 %15529 %6435 0 + %24574 = OpVectorShuffle %v2float %141 %141 0 1 + %13209 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 + %10347 = OpLoad %v4float %13209 + %8641 = OpVectorShuffle %v2float %10347 %10347 0 1 + %9200 = OpFMul %v2float %24574 %8641 + %18508 = OpFAdd %v2float %19927 %9200 + %7014 = OpVectorShuffle %v2float %17581 %17581 0 1 + %21061 = OpVectorShuffle %v2float %17581 %17581 2 3 + %13152 = OpExtInst %v2float %1 FClamp %18508 %7014 %21061 + %23587 = OpLoad %150 %5785 + %10342 = OpLoad %508 %5688 + %12156 = OpSampledImage %510 %23587 %10342 + %15374 = OpImageSampleExplicitLod %v4float %12156 %13152 Lod %float_0 + %15269 = OpCompositeExtract %float %15374 3 + %12119 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 + %12975 = OpLoad %float %12119 + %15713 = OpFMul %float %15269 %12975 + %15282 = OpExtInst %float %1 FClamp %15713 %float_0 %float_1 + %22216 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 + %11759 = OpLoad %v3float %22216 + %12106 = OpVectorTimesScalar %v3float %11759 %15282 + %15519 = OpLoad %150 %3312 + %24575 = OpLoad %508 %4646 + %12157 = OpSampledImage %510 %15519 %24575 + %17673 = OpImageSampleExplicitLod %v4float %12157 %13152 Lod %float_0 + %16941 = OpCompositeExtract %float %17673 1 + %14188 = OpFOrdGreaterThan %bool %16941 %float_0 + OpSelectionMerge %22310 DontFlatten + OpBranchConditional %14188 %12824 %22310 + %12824 = OpLabel + %13242 = OpLoad %150 %4862 + %19963 = OpLoad %508 %3594 + %12158 = OpSampledImage %510 %13242 %19963 + %15678 = OpImageSampleExplicitLod %v4float %12158 %13152 Lod %float_0 + %13869 = OpCompositeExtract %float %17673 1 + %12430 = OpCompositeExtract %float %17673 2 + %23303 = OpFMul %float %13869 %12430 + %17615 = OpExtInst %float %1 FClamp %23303 %float_0 %float_1 + %20294 = OpVectorShuffle %v3float %15678 %15678 0 1 2 + %11189 = OpVectorTimesScalar %v3float %20294 %17615 + %15296 = OpFAdd %v3float %12106 %11189 + OpBranch %22310 + %22310 = OpLabel + %7722 = OpPhi %v3float %12106 %22309 %15296 %12824 + %23402 = OpVectorTimesScalar %v3float %7722 %float_0_5 + %9342 = OpFAdd %float %9341 %float_0_5 + %16238 = OpVectorShuffle %v3float %15529 %15529 0 1 2 + %22180 = OpFAdd %v3float %16238 %23402 + %15530 = OpVectorShuffle %v4float %15529 %22180 4 5 6 3 + %6437 = OpCompositeInsert %_struct_1017 %15530 %6436 0 + %24576 = OpVectorShuffle %v2float %38 %38 0 1 + %13210 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 + %10348 = OpLoad %v4float %13210 + %8642 = OpVectorShuffle %v2float %10348 %10348 0 1 + %9201 = OpFMul %v2float %24576 %8642 + %18509 = OpFAdd %v2float %19927 %9201 + %7015 = OpVectorShuffle %v2float %17581 %17581 0 1 + %21062 = OpVectorShuffle %v2float %17581 %17581 2 3 + %13153 = OpExtInst %v2float %1 FClamp %18509 %7015 %21062 + %23588 = OpLoad %150 %5785 + %10349 = OpLoad %508 %5688 + %12159 = OpSampledImage %510 %23588 %10349 + %15375 = OpImageSampleExplicitLod %v4float %12159 %13153 Lod %float_0 + %15270 = OpCompositeExtract %float %15375 3 + %12120 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 + %12976 = OpLoad %float %12120 + %15714 = OpFMul %float %15270 %12976 + %15283 = OpExtInst %float %1 FClamp %15714 %float_0 %float_1 + %22217 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 + %11760 = OpLoad %v3float %22217 + %12107 = OpVectorTimesScalar %v3float %11760 %15283 + %15520 = OpLoad %150 %3312 + %24577 = OpLoad %508 %4646 + %12160 = OpSampledImage %510 %15520 %24577 + %17674 = OpImageSampleExplicitLod %v4float %12160 %13153 Lod %float_0 + %16942 = OpCompositeExtract %float %17674 1 + %14189 = OpFOrdGreaterThan %bool %16942 %float_0 + OpSelectionMerge %22311 DontFlatten + OpBranchConditional %14189 %12825 %22311 + %12825 = OpLabel + %13243 = OpLoad %150 %4862 + %19964 = OpLoad %508 %3594 + %12161 = OpSampledImage %510 %13243 %19964 + %15679 = OpImageSampleExplicitLod %v4float %12161 %13153 Lod %float_0 + %13870 = OpCompositeExtract %float %17674 1 + %12431 = OpCompositeExtract %float %17674 2 + %23304 = OpFMul %float %13870 %12431 + %17616 = OpExtInst %float %1 FClamp %23304 %float_0 %float_1 + %20295 = OpVectorShuffle %v3float %15679 %15679 0 1 2 + %11190 = OpVectorTimesScalar %v3float %20295 %17616 + %15297 = OpFAdd %v3float %12107 %11190 + OpBranch %22311 + %22311 = OpLabel + %7723 = OpPhi %v3float %12107 %22310 %15297 %12825 + %23403 = OpVectorTimesScalar %v3float %7723 %float_0_5 + %9343 = OpFAdd %float %9342 %float_0_5 + %16239 = OpVectorShuffle %v3float %15530 %15530 0 1 2 + %22181 = OpFAdd %v3float %16239 %23403 + %15531 = OpVectorShuffle %v4float %15530 %22181 4 5 6 3 + %6438 = OpCompositeInsert %_struct_1017 %15531 %6437 0 + %24578 = OpVectorShuffle %v2float %95 %95 0 1 + %13211 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 + %10350 = OpLoad %v4float %13211 + %8643 = OpVectorShuffle %v2float %10350 %10350 0 1 + %9202 = OpFMul %v2float %24578 %8643 + %18510 = OpFAdd %v2float %19927 %9202 + %7016 = OpVectorShuffle %v2float %17581 %17581 0 1 + %21063 = OpVectorShuffle %v2float %17581 %17581 2 3 + %13154 = OpExtInst %v2float %1 FClamp %18510 %7016 %21063 + %23589 = OpLoad %150 %5785 + %10351 = OpLoad %508 %5688 + %12162 = OpSampledImage %510 %23589 %10351 + %15376 = OpImageSampleExplicitLod %v4float %12162 %13154 Lod %float_0 + %15271 = OpCompositeExtract %float %15376 3 + %12121 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 + %12977 = OpLoad %float %12121 + %15715 = OpFMul %float %15271 %12977 + %15284 = OpExtInst %float %1 FClamp %15715 %float_0 %float_1 + %22218 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 + %11761 = OpLoad %v3float %22218 + %12108 = OpVectorTimesScalar %v3float %11761 %15284 + %15521 = OpLoad %150 %3312 + %24579 = OpLoad %508 %4646 + %12163 = OpSampledImage %510 %15521 %24579 + %17675 = OpImageSampleExplicitLod %v4float %12163 %13154 Lod %float_0 + %16943 = OpCompositeExtract %float %17675 1 + %14190 = OpFOrdGreaterThan %bool %16943 %float_0 + OpSelectionMerge %22312 DontFlatten + OpBranchConditional %14190 %12826 %22312 + %12826 = OpLabel + %13244 = OpLoad %150 %4862 + %19965 = OpLoad %508 %3594 + %12164 = OpSampledImage %510 %13244 %19965 + %15680 = OpImageSampleExplicitLod %v4float %12164 %13154 Lod %float_0 + %13871 = OpCompositeExtract %float %17675 1 + %12432 = OpCompositeExtract %float %17675 2 + %23305 = OpFMul %float %13871 %12432 + %17617 = OpExtInst %float %1 FClamp %23305 %float_0 %float_1 + %20296 = OpVectorShuffle %v3float %15680 %15680 0 1 2 + %11191 = OpVectorTimesScalar %v3float %20296 %17617 + %15298 = OpFAdd %v3float %12108 %11191 + OpBranch %22312 + %22312 = OpLabel + %7724 = OpPhi %v3float %12108 %22311 %15298 %12826 + %23404 = OpVectorTimesScalar %v3float %7724 %float_0_75 + %9344 = OpFAdd %float %9343 %float_0_75 + %16240 = OpVectorShuffle %v3float %15531 %15531 0 1 2 + %22182 = OpFAdd %v3float %16240 %23404 + %15532 = OpVectorShuffle %v4float %15531 %22182 4 5 6 3 + %6439 = OpCompositeInsert %_struct_1017 %15532 %6438 0 + %24580 = OpVectorShuffle %v2float %626 %626 0 1 + %13212 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 + %10352 = OpLoad %v4float %13212 + %8644 = OpVectorShuffle %v2float %10352 %10352 0 1 + %9203 = OpFMul %v2float %24580 %8644 + %18511 = OpFAdd %v2float %19927 %9203 + %7017 = OpVectorShuffle %v2float %17581 %17581 0 1 + %21064 = OpVectorShuffle %v2float %17581 %17581 2 3 + %13155 = OpExtInst %v2float %1 FClamp %18511 %7017 %21064 + %23590 = OpLoad %150 %5785 + %10353 = OpLoad %508 %5688 + %12165 = OpSampledImage %510 %23590 %10353 + %15377 = OpImageSampleExplicitLod %v4float %12165 %13155 Lod %float_0 + %15272 = OpCompositeExtract %float %15377 3 + %12122 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 + %12978 = OpLoad %float %12122 + %15716 = OpFMul %float %15272 %12978 + %15285 = OpExtInst %float %1 FClamp %15716 %float_0 %float_1 + %22219 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 + %11762 = OpLoad %v3float %22219 + %12109 = OpVectorTimesScalar %v3float %11762 %15285 + %15522 = OpLoad %150 %3312 + %24581 = OpLoad %508 %4646 + %12166 = OpSampledImage %510 %15522 %24581 + %17676 = OpImageSampleExplicitLod %v4float %12166 %13155 Lod %float_0 + %16944 = OpCompositeExtract %float %17676 1 + %14191 = OpFOrdGreaterThan %bool %16944 %float_0 + OpSelectionMerge %22313 DontFlatten + OpBranchConditional %14191 %12827 %22313 + %12827 = OpLabel + %13245 = OpLoad %150 %4862 + %19966 = OpLoad %508 %3594 + %12167 = OpSampledImage %510 %13245 %19966 + %15681 = OpImageSampleExplicitLod %v4float %12167 %13155 Lod %float_0 + %13872 = OpCompositeExtract %float %17676 1 + %12433 = OpCompositeExtract %float %17676 2 + %23306 = OpFMul %float %13872 %12433 + %17618 = OpExtInst %float %1 FClamp %23306 %float_0 %float_1 + %20297 = OpVectorShuffle %v3float %15681 %15681 0 1 2 + %11192 = OpVectorTimesScalar %v3float %20297 %17618 + %15299 = OpFAdd %v3float %12109 %11192 + OpBranch %22313 + %22313 = OpLabel + %7725 = OpPhi %v3float %12109 %22312 %15299 %12827 + %23405 = OpVectorTimesScalar %v3float %7725 %float_1 + %9345 = OpFAdd %float %9344 %float_1 + %16241 = OpVectorShuffle %v3float %15532 %15532 0 1 2 + %22183 = OpFAdd %v3float %16241 %23405 + %15533 = OpVectorShuffle %v4float %15532 %22183 4 5 6 3 + %6440 = OpCompositeInsert %_struct_1017 %15533 %6439 0 + %24582 = OpVectorShuffle %v2float %2411 %2411 0 1 + %13213 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 + %10354 = OpLoad %v4float %13213 + %8645 = OpVectorShuffle %v2float %10354 %10354 0 1 + %9204 = OpFMul %v2float %24582 %8645 + %18512 = OpFAdd %v2float %19927 %9204 + %7018 = OpVectorShuffle %v2float %17581 %17581 0 1 + %21065 = OpVectorShuffle %v2float %17581 %17581 2 3 + %13156 = OpExtInst %v2float %1 FClamp %18512 %7018 %21065 + %23591 = OpLoad %150 %5785 + %10355 = OpLoad %508 %5688 + %12168 = OpSampledImage %510 %23591 %10355 + %15378 = OpImageSampleExplicitLod %v4float %12168 %13156 Lod %float_0 + %15273 = OpCompositeExtract %float %15378 3 + %12123 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 + %12979 = OpLoad %float %12123 + %15717 = OpFMul %float %15273 %12979 + %15286 = OpExtInst %float %1 FClamp %15717 %float_0 %float_1 + %22220 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 + %11763 = OpLoad %v3float %22220 + %12110 = OpVectorTimesScalar %v3float %11763 %15286 + %15523 = OpLoad %150 %3312 + %24583 = OpLoad %508 %4646 + %12169 = OpSampledImage %510 %15523 %24583 + %17677 = OpImageSampleExplicitLod %v4float %12169 %13156 Lod %float_0 + %16945 = OpCompositeExtract %float %17677 1 + %14192 = OpFOrdGreaterThan %bool %16945 %float_0 + OpSelectionMerge %22314 DontFlatten + OpBranchConditional %14192 %12828 %22314 + %12828 = OpLabel + %13246 = OpLoad %150 %4862 + %19967 = OpLoad %508 %3594 + %12170 = OpSampledImage %510 %13246 %19967 + %15682 = OpImageSampleExplicitLod %v4float %12170 %13156 Lod %float_0 + %13873 = OpCompositeExtract %float %17677 1 + %12434 = OpCompositeExtract %float %17677 2 + %23307 = OpFMul %float %13873 %12434 + %17619 = OpExtInst %float %1 FClamp %23307 %float_0 %float_1 + %20298 = OpVectorShuffle %v3float %15682 %15682 0 1 2 + %11193 = OpVectorTimesScalar %v3float %20298 %17619 + %15300 = OpFAdd %v3float %12110 %11193 + OpBranch %22314 + %22314 = OpLabel + %7726 = OpPhi %v3float %12110 %22313 %15300 %12828 + %23406 = OpVectorTimesScalar %v3float %7726 %float_0_75 + %9346 = OpFAdd %float %9345 %float_0_75 + %16242 = OpVectorShuffle %v3float %15533 %15533 0 1 2 + %22184 = OpFAdd %v3float %16242 %23406 + %15534 = OpVectorShuffle %v4float %15533 %22184 4 5 6 3 + %6441 = OpCompositeInsert %_struct_1017 %15534 %6440 0 + %24584 = OpVectorShuffle %v2float %2354 %2354 0 1 + %13214 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 + %10356 = OpLoad %v4float %13214 + %8646 = OpVectorShuffle %v2float %10356 %10356 0 1 + %9205 = OpFMul %v2float %24584 %8646 + %18513 = OpFAdd %v2float %19927 %9205 + %7019 = OpVectorShuffle %v2float %17581 %17581 0 1 + %21066 = OpVectorShuffle %v2float %17581 %17581 2 3 + %13157 = OpExtInst %v2float %1 FClamp %18513 %7019 %21066 + %23592 = OpLoad %150 %5785 + %10357 = OpLoad %508 %5688 + %12171 = OpSampledImage %510 %23592 %10357 + %15379 = OpImageSampleExplicitLod %v4float %12171 %13157 Lod %float_0 + %15274 = OpCompositeExtract %float %15379 3 + %12124 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 + %12980 = OpLoad %float %12124 + %15718 = OpFMul %float %15274 %12980 + %15287 = OpExtInst %float %1 FClamp %15718 %float_0 %float_1 + %22221 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 + %11764 = OpLoad %v3float %22221 + %12111 = OpVectorTimesScalar %v3float %11764 %15287 + %15524 = OpLoad %150 %3312 + %24585 = OpLoad %508 %4646 + %12172 = OpSampledImage %510 %15524 %24585 + %17678 = OpImageSampleExplicitLod %v4float %12172 %13157 Lod %float_0 + %16946 = OpCompositeExtract %float %17678 1 + %14193 = OpFOrdGreaterThan %bool %16946 %float_0 + OpSelectionMerge %22315 DontFlatten + OpBranchConditional %14193 %12829 %22315 + %12829 = OpLabel + %13247 = OpLoad %150 %4862 + %19968 = OpLoad %508 %3594 + %12173 = OpSampledImage %510 %13247 %19968 + %15683 = OpImageSampleExplicitLod %v4float %12173 %13157 Lod %float_0 + %13874 = OpCompositeExtract %float %17678 1 + %12435 = OpCompositeExtract %float %17678 2 + %23308 = OpFMul %float %13874 %12435 + %17620 = OpExtInst %float %1 FClamp %23308 %float_0 %float_1 + %20299 = OpVectorShuffle %v3float %15683 %15683 0 1 2 + %11194 = OpVectorTimesScalar %v3float %20299 %17620 + %15301 = OpFAdd %v3float %12111 %11194 + OpBranch %22315 + %22315 = OpLabel + %7727 = OpPhi %v3float %12111 %22314 %15301 %12829 + %23407 = OpVectorTimesScalar %v3float %7727 %float_0_5 + %9347 = OpFAdd %float %9346 %float_0_5 + %16243 = OpVectorShuffle %v3float %15534 %15534 0 1 2 + %22185 = OpFAdd %v3float %16243 %23407 + %15535 = OpVectorShuffle %v4float %15534 %22185 4 5 6 3 + %6442 = OpCompositeInsert %_struct_1017 %15535 %6441 0 + %24586 = OpVectorShuffle %v2float %837 %837 0 1 + %13215 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 + %10358 = OpLoad %v4float %13215 + %8647 = OpVectorShuffle %v2float %10358 %10358 0 1 + %9206 = OpFMul %v2float %24586 %8647 + %18514 = OpFAdd %v2float %19927 %9206 + %7020 = OpVectorShuffle %v2float %17581 %17581 0 1 + %21067 = OpVectorShuffle %v2float %17581 %17581 2 3 + %13158 = OpExtInst %v2float %1 FClamp %18514 %7020 %21067 + %23593 = OpLoad %150 %5785 + %10359 = OpLoad %508 %5688 + %12174 = OpSampledImage %510 %23593 %10359 + %15380 = OpImageSampleExplicitLod %v4float %12174 %13158 Lod %float_0 + %15275 = OpCompositeExtract %float %15380 3 + %12125 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 + %12981 = OpLoad %float %12125 + %15719 = OpFMul %float %15275 %12981 + %15288 = OpExtInst %float %1 FClamp %15719 %float_0 %float_1 + %22222 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 + %11765 = OpLoad %v3float %22222 + %12112 = OpVectorTimesScalar %v3float %11765 %15288 + %15525 = OpLoad %150 %3312 + %24587 = OpLoad %508 %4646 + %12175 = OpSampledImage %510 %15525 %24587 + %17679 = OpImageSampleExplicitLod %v4float %12175 %13158 Lod %float_0 + %16947 = OpCompositeExtract %float %17679 1 + %14194 = OpFOrdGreaterThan %bool %16947 %float_0 + OpSelectionMerge %22316 DontFlatten + OpBranchConditional %14194 %12830 %22316 + %12830 = OpLabel + %13248 = OpLoad %150 %4862 + %19969 = OpLoad %508 %3594 + %12176 = OpSampledImage %510 %13248 %19969 + %15684 = OpImageSampleExplicitLod %v4float %12176 %13158 Lod %float_0 + %13875 = OpCompositeExtract %float %17679 1 + %12436 = OpCompositeExtract %float %17679 2 + %23309 = OpFMul %float %13875 %12436 + %17621 = OpExtInst %float %1 FClamp %23309 %float_0 %float_1 + %20300 = OpVectorShuffle %v3float %15684 %15684 0 1 2 + %11195 = OpVectorTimesScalar %v3float %20300 %17621 + %15302 = OpFAdd %v3float %12112 %11195 + OpBranch %22316 + %22316 = OpLabel + %7728 = OpPhi %v3float %12112 %22315 %15302 %12830 + %23408 = OpVectorTimesScalar %v3float %7728 %float_0_5 + %9348 = OpFAdd %float %9347 %float_0_5 + %16244 = OpVectorShuffle %v3float %15535 %15535 0 1 2 + %22186 = OpFAdd %v3float %16244 %23408 + %15536 = OpVectorShuffle %v4float %15535 %22186 4 5 6 3 + %6443 = OpCompositeInsert %_struct_1017 %15536 %6442 0 + %24588 = OpVectorShuffle %v2float %1368 %1368 0 1 + %13216 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 + %10360 = OpLoad %v4float %13216 + %8648 = OpVectorShuffle %v2float %10360 %10360 0 1 + %9207 = OpFMul %v2float %24588 %8648 + %18515 = OpFAdd %v2float %19927 %9207 + %7021 = OpVectorShuffle %v2float %17581 %17581 0 1 + %21068 = OpVectorShuffle %v2float %17581 %17581 2 3 + %13159 = OpExtInst %v2float %1 FClamp %18515 %7021 %21068 + %23594 = OpLoad %150 %5785 + %10361 = OpLoad %508 %5688 + %12177 = OpSampledImage %510 %23594 %10361 + %15381 = OpImageSampleExplicitLod %v4float %12177 %13159 Lod %float_0 + %15276 = OpCompositeExtract %float %15381 3 + %12126 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 + %12982 = OpLoad %float %12126 + %15720 = OpFMul %float %15276 %12982 + %15289 = OpExtInst %float %1 FClamp %15720 %float_0 %float_1 + %22223 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 + %11766 = OpLoad %v3float %22223 + %12113 = OpVectorTimesScalar %v3float %11766 %15289 + %15526 = OpLoad %150 %3312 + %24589 = OpLoad %508 %4646 + %12178 = OpSampledImage %510 %15526 %24589 + %17680 = OpImageSampleExplicitLod %v4float %12178 %13159 Lod %float_0 + %16948 = OpCompositeExtract %float %17680 1 + %14195 = OpFOrdGreaterThan %bool %16948 %float_0 + OpSelectionMerge %22317 DontFlatten + OpBranchConditional %14195 %12831 %22317 + %12831 = OpLabel + %13249 = OpLoad %150 %4862 + %19970 = OpLoad %508 %3594 + %12179 = OpSampledImage %510 %13249 %19970 + %15685 = OpImageSampleExplicitLod %v4float %12179 %13159 Lod %float_0 + %13876 = OpCompositeExtract %float %17680 1 + %12437 = OpCompositeExtract %float %17680 2 + %23310 = OpFMul %float %13876 %12437 + %17622 = OpExtInst %float %1 FClamp %23310 %float_0 %float_1 + %20301 = OpVectorShuffle %v3float %15685 %15685 0 1 2 + %11196 = OpVectorTimesScalar %v3float %20301 %17622 + %15303 = OpFAdd %v3float %12113 %11196 + OpBranch %22317 + %22317 = OpLabel + %7729 = OpPhi %v3float %12113 %22316 %15303 %12831 + %23409 = OpVectorTimesScalar %v3float %7729 %float_0_75 + %9349 = OpFAdd %float %9348 %float_0_75 + %16245 = OpVectorShuffle %v3float %15536 %15536 0 1 2 + %22187 = OpFAdd %v3float %16245 %23409 + %15537 = OpVectorShuffle %v4float %15536 %22187 4 5 6 3 + %6444 = OpCompositeInsert %_struct_1017 %15537 %6443 0 + %24590 = OpVectorShuffle %v2float %142 %142 0 1 + %13217 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 + %10362 = OpLoad %v4float %13217 + %8649 = OpVectorShuffle %v2float %10362 %10362 0 1 + %9208 = OpFMul %v2float %24590 %8649 + %18516 = OpFAdd %v2float %19927 %9208 + %7022 = OpVectorShuffle %v2float %17581 %17581 0 1 + %21069 = OpVectorShuffle %v2float %17581 %17581 2 3 + %13160 = OpExtInst %v2float %1 FClamp %18516 %7022 %21069 + %23595 = OpLoad %150 %5785 + %10363 = OpLoad %508 %5688 + %12180 = OpSampledImage %510 %23595 %10363 + %15382 = OpImageSampleExplicitLod %v4float %12180 %13160 Lod %float_0 + %15277 = OpCompositeExtract %float %15382 3 + %12127 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 + %12983 = OpLoad %float %12127 + %15721 = OpFMul %float %15277 %12983 + %15290 = OpExtInst %float %1 FClamp %15721 %float_0 %float_1 + %22224 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 + %11767 = OpLoad %v3float %22224 + %12114 = OpVectorTimesScalar %v3float %11767 %15290 + %15538 = OpLoad %150 %3312 + %24591 = OpLoad %508 %4646 + %12181 = OpSampledImage %510 %15538 %24591 + %17681 = OpImageSampleExplicitLod %v4float %12181 %13160 Lod %float_0 + %16949 = OpCompositeExtract %float %17681 1 + %14196 = OpFOrdGreaterThan %bool %16949 %float_0 + OpSelectionMerge %22318 DontFlatten + OpBranchConditional %14196 %12832 %22318 + %12832 = OpLabel + %13250 = OpLoad %150 %4862 + %19971 = OpLoad %508 %3594 + %12182 = OpSampledImage %510 %13250 %19971 + %15686 = OpImageSampleExplicitLod %v4float %12182 %13160 Lod %float_0 + %13877 = OpCompositeExtract %float %17681 1 + %12438 = OpCompositeExtract %float %17681 2 + %23311 = OpFMul %float %13877 %12438 + %17623 = OpExtInst %float %1 FClamp %23311 %float_0 %float_1 + %20302 = OpVectorShuffle %v3float %15686 %15686 0 1 2 + %11197 = OpVectorTimesScalar %v3float %20302 %17623 + %15304 = OpFAdd %v3float %12114 %11197 + OpBranch %22318 + %22318 = OpLabel + %7730 = OpPhi %v3float %12114 %22317 %15304 %12832 + %23410 = OpVectorTimesScalar %v3float %7730 %float_0_5 + %9350 = OpFAdd %float %9349 %float_0_5 + %16246 = OpVectorShuffle %v3float %15537 %15537 0 1 2 + %22188 = OpFAdd %v3float %16246 %23410 + %15539 = OpVectorShuffle %v4float %15537 %22188 4 5 6 3 + %6445 = OpCompositeInsert %_struct_1017 %15539 %6444 0 + %24592 = OpVectorShuffle %v2float %1197 %1197 0 1 + %13218 = OpAccessChain %_ptr_Uniform_v4float %22044 %int_0 + %10364 = OpLoad %v4float %13218 + %8650 = OpVectorShuffle %v2float %10364 %10364 0 1 + %9209 = OpFMul %v2float %24592 %8650 + %18517 = OpFAdd %v2float %19927 %9209 + %7023 = OpVectorShuffle %v2float %17581 %17581 0 1 + %21070 = OpVectorShuffle %v2float %17581 %17581 2 3 + %13161 = OpExtInst %v2float %1 FClamp %18517 %7023 %21070 + %23596 = OpLoad %150 %5785 + %10365 = OpLoad %508 %5688 + %12183 = OpSampledImage %510 %23596 %10365 + %15383 = OpImageSampleExplicitLod %v4float %12183 %13161 Lod %float_0 + %15278 = OpCompositeExtract %float %15383 3 + %12128 = OpAccessChain %_ptr_Uniform_float %22044 %int_1 + %12984 = OpLoad %float %12128 + %15722 = OpFMul %float %15278 %12984 + %15291 = OpExtInst %float %1 FClamp %15722 %float_0 %float_1 + %22225 = OpAccessChain %_ptr_Uniform_v3float %12348 %int_5 + %11768 = OpLoad %v3float %22225 + %12115 = OpVectorTimesScalar %v3float %11768 %15291 + %15540 = OpLoad %150 %3312 + %24593 = OpLoad %508 %4646 + %12184 = OpSampledImage %510 %15540 %24593 + %17682 = OpImageSampleExplicitLod %v4float %12184 %13161 Lod %float_0 + %16950 = OpCompositeExtract %float %17682 1 + %14197 = OpFOrdGreaterThan %bool %16950 %float_0 + OpSelectionMerge %22319 DontFlatten + OpBranchConditional %14197 %12833 %22319 + %12833 = OpLabel + %13251 = OpLoad %150 %4862 + %19972 = OpLoad %508 %3594 + %12185 = OpSampledImage %510 %13251 %19972 + %15687 = OpImageSampleExplicitLod %v4float %12185 %13161 Lod %float_0 + %13878 = OpCompositeExtract %float %17682 1 + %12439 = OpCompositeExtract %float %17682 2 + %23312 = OpFMul %float %13878 %12439 + %17624 = OpExtInst %float %1 FClamp %23312 %float_0 %float_1 + %20303 = OpVectorShuffle %v3float %15687 %15687 0 1 2 + %11198 = OpVectorTimesScalar %v3float %20303 %17624 + %15305 = OpFAdd %v3float %12115 %11198 + OpBranch %22319 + %22319 = OpLabel + %7731 = OpPhi %v3float %12115 %22318 %15305 %12833 + %23411 = OpVectorTimesScalar %v3float %7731 %float_0_5 + %9351 = OpFAdd %float %9350 %float_0_5 + %16247 = OpVectorShuffle %v3float %15539 %15539 0 1 2 + %22189 = OpFAdd %v3float %16247 %23411 + %15541 = OpVectorShuffle %v4float %15539 %22189 4 5 6 3 + %6719 = OpCompositeInsert %_struct_1017 %15541 %6445 0 + %23412 = OpVectorShuffle %v3float %15541 %15541 0 1 2 + %10833 = OpCompositeConstruct %v3float %9351 %9351 %9351 + %13750 = OpFDiv %v3float %23412 %10833 + %24033 = OpVectorShuffle %v4float %15541 %13750 4 5 6 3 + %8636 = OpCompositeInsert %_struct_1017 %24033 %6719 0 + %16315 = OpCompositeInsert %_struct_1017 %float_1 %8636 0 3 + %11544 = OpCompositeExtract %v4float %16315 0 + OpStore %4317 %11544 + OpReturn + OpFunctionEnd diff --git a/shaders/asm/tesc/tess-fixed-input-array-builtin-array.asm.tesc b/shaders/asm/tesc/tess-fixed-input-array-builtin-array.asm.tesc new file mode 100644 index 0000000000..0fd4dce256 --- /dev/null +++ b/shaders/asm/tesc/tess-fixed-input-array-builtin-array.asm.tesc @@ -0,0 +1,248 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 2 +; Bound: 162 +; Schema: 0 + OpCapability Tessellation + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationControl %hs_main "main" %p_pos %p_1 %i_1 %_entryPointOutput_pos %_entryPointOutput %_patchConstantOutput_EdgeTess %_patchConstantOutput_InsideTess + OpExecutionMode %hs_main OutputVertices 3 + OpExecutionMode %hs_main Triangles + OpExecutionMode %hs_main SpacingFractionalOdd + OpExecutionMode %hs_main VertexOrderCw + OpSource HLSL 500 + OpName %hs_main "hs_main" + OpName %VertexOutput "VertexOutput" + OpMemberName %VertexOutput 0 "pos" + OpMemberName %VertexOutput 1 "uv" + OpName %HSOut "HSOut" + OpMemberName %HSOut 0 "pos" + OpMemberName %HSOut 1 "uv" + OpName %_hs_main_struct_VertexOutput_vf4_vf21_3__u1_ "@hs_main(struct-VertexOutput-vf4-vf21[3];u1;" + OpName %p "p" + OpName %i "i" + OpName %HSConstantOut "HSConstantOut" + OpMemberName %HSConstantOut 0 "EdgeTess" + OpMemberName %HSConstantOut 1 "InsideTess" + OpName %PatchHS_struct_VertexOutput_vf4_vf21_3__ "PatchHS(struct-VertexOutput-vf4-vf21[3];" + OpName %patch "patch" + OpName %output "output" + OpName %p_0 "p" + OpName %p_pos "p.pos" + OpName %VertexOutput_0 "VertexOutput" + OpMemberName %VertexOutput_0 0 "uv" + OpName %p_1 "p" + OpName %i_0 "i" + OpName %i_1 "i" + OpName %flattenTemp "flattenTemp" + OpName %param "param" + OpName %param_0 "param" + OpName %_entryPointOutput_pos "@entryPointOutput.pos" + OpName %HSOut_0 "HSOut" + OpMemberName %HSOut_0 0 "uv" + OpName %_entryPointOutput "@entryPointOutput" + OpName %_patchConstantResult "@patchConstantResult" + OpName %param_1 "param" + OpName %_patchConstantOutput_EdgeTess "@patchConstantOutput.EdgeTess" + OpName %_patchConstantOutput_InsideTess "@patchConstantOutput.InsideTess" + OpName %output_0 "output" + OpDecorate %p_pos BuiltIn Position + OpDecorate %p_1 Location 0 + OpDecorate %i_1 BuiltIn InvocationId + OpDecorate %_entryPointOutput_pos BuiltIn Position + OpDecorate %_entryPointOutput Location 0 + OpDecorate %_patchConstantOutput_EdgeTess Patch + OpDecorate %_patchConstantOutput_EdgeTess BuiltIn TessLevelOuter + OpDecorate %_patchConstantOutput_InsideTess Patch + OpDecorate %_patchConstantOutput_InsideTess BuiltIn TessLevelInner + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %v2float = OpTypeVector %float 2 +%VertexOutput = OpTypeStruct %v4float %v2float + %uint = OpTypeInt 32 0 + %uint_3 = OpConstant %uint 3 +%_arr_VertexOutput_uint_3 = OpTypeArray %VertexOutput %uint_3 +%_ptr_Function__arr_VertexOutput_uint_3 = OpTypePointer Function %_arr_VertexOutput_uint_3 +%_ptr_Function_uint = OpTypePointer Function %uint + %HSOut = OpTypeStruct %v4float %v2float + %16 = OpTypeFunction %HSOut %_ptr_Function__arr_VertexOutput_uint_3 %_ptr_Function_uint +%_arr_float_uint_3 = OpTypeArray %float %uint_3 +%HSConstantOut = OpTypeStruct %_arr_float_uint_3 %float + %23 = OpTypeFunction %HSConstantOut %_ptr_Function__arr_VertexOutput_uint_3 +%_ptr_Function_HSOut = OpTypePointer Function %HSOut + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 +%_ptr_Function_v4float = OpTypePointer Function %v4float + %int_1 = OpConstant %int 1 +%_ptr_Function_v2float = OpTypePointer Function %v2float +%_arr_v4float_uint_3 = OpTypeArray %v4float %uint_3 +%_ptr_Input__arr_v4float_uint_3 = OpTypePointer Input %_arr_v4float_uint_3 + %p_pos = OpVariable %_ptr_Input__arr_v4float_uint_3 Input +%_ptr_Input_v4float = OpTypePointer Input %v4float +%VertexOutput_0 = OpTypeStruct %v2float +%_arr_VertexOutput_0_uint_3 = OpTypeArray %VertexOutput_0 %uint_3 +%_ptr_Input__arr_VertexOutput_0_uint_3 = OpTypePointer Input %_arr_VertexOutput_0_uint_3 + %p_1 = OpVariable %_ptr_Input__arr_VertexOutput_0_uint_3 Input +%_ptr_Input_v2float = OpTypePointer Input %v2float + %int_2 = OpConstant %int 2 +%_ptr_Input_uint = OpTypePointer Input %uint + %i_1 = OpVariable %_ptr_Input_uint Input +%_ptr_Output__arr_v4float_uint_3 = OpTypePointer Output %_arr_v4float_uint_3 +%_entryPointOutput_pos = OpVariable %_ptr_Output__arr_v4float_uint_3 Output +%_ptr_Output_v4float = OpTypePointer Output %v4float + %HSOut_0 = OpTypeStruct %v2float +%_arr_HSOut_0_uint_3 = OpTypeArray %HSOut_0 %uint_3 +%_ptr_Output__arr_HSOut_0_uint_3 = OpTypePointer Output %_arr_HSOut_0_uint_3 +%_entryPointOutput = OpVariable %_ptr_Output__arr_HSOut_0_uint_3 Output +%_ptr_Output_v2float = OpTypePointer Output %v2float + %uint_2 = OpConstant %uint 2 + %uint_1 = OpConstant %uint 1 + %uint_0 = OpConstant %uint 0 + %bool = OpTypeBool +%_ptr_Function_HSConstantOut = OpTypePointer Function %HSConstantOut + %uint_4 = OpConstant %uint 4 +%_arr_float_uint_4 = OpTypeArray %float %uint_4 +%_ptr_Output__arr_float_uint_4 = OpTypePointer Output %_arr_float_uint_4 +%_patchConstantOutput_EdgeTess = OpVariable %_ptr_Output__arr_float_uint_4 Output +%_ptr_Function_float = OpTypePointer Function %float +%_ptr_Output_float = OpTypePointer Output %float +%_arr_float_uint_2 = OpTypeArray %float %uint_2 +%_ptr_Output__arr_float_uint_2 = OpTypePointer Output %_arr_float_uint_2 +%_patchConstantOutput_InsideTess = OpVariable %_ptr_Output__arr_float_uint_2 Output + %float_1 = OpConstant %float 1 + %hs_main = OpFunction %void None %3 + %5 = OpLabel + %p_0 = OpVariable %_ptr_Function__arr_VertexOutput_uint_3 Function + %i_0 = OpVariable %_ptr_Function_uint Function +%flattenTemp = OpVariable %_ptr_Function_HSOut Function + %param = OpVariable %_ptr_Function__arr_VertexOutput_uint_3 Function + %param_0 = OpVariable %_ptr_Function_uint Function +%_patchConstantResult = OpVariable %_ptr_Function_HSConstantOut Function + %param_1 = OpVariable %_ptr_Function__arr_VertexOutput_uint_3 Function + %50 = OpAccessChain %_ptr_Input_v4float %p_pos %int_0 + %51 = OpLoad %v4float %50 + %52 = OpAccessChain %_ptr_Function_v4float %p_0 %int_0 %int_0 + OpStore %52 %51 + %58 = OpAccessChain %_ptr_Input_v2float %p_1 %int_0 %int_0 + %59 = OpLoad %v2float %58 + %60 = OpAccessChain %_ptr_Function_v2float %p_0 %int_0 %int_1 + OpStore %60 %59 + %61 = OpAccessChain %_ptr_Input_v4float %p_pos %int_1 + %62 = OpLoad %v4float %61 + %63 = OpAccessChain %_ptr_Function_v4float %p_0 %int_1 %int_0 + OpStore %63 %62 + %64 = OpAccessChain %_ptr_Input_v2float %p_1 %int_1 %int_0 + %65 = OpLoad %v2float %64 + %66 = OpAccessChain %_ptr_Function_v2float %p_0 %int_1 %int_1 + OpStore %66 %65 + %68 = OpAccessChain %_ptr_Input_v4float %p_pos %int_2 + %69 = OpLoad %v4float %68 + %70 = OpAccessChain %_ptr_Function_v4float %p_0 %int_2 %int_0 + OpStore %70 %69 + %71 = OpAccessChain %_ptr_Input_v2float %p_1 %int_2 %int_0 + %72 = OpLoad %v2float %71 + %73 = OpAccessChain %_ptr_Function_v2float %p_0 %int_2 %int_1 + OpStore %73 %72 + %77 = OpLoad %uint %i_1 + OpStore %i_0 %77 + %80 = OpLoad %_arr_VertexOutput_uint_3 %p_0 + OpStore %param %80 + %82 = OpLoad %uint %i_0 + OpStore %param_0 %82 + %83 = OpFunctionCall %HSOut %_hs_main_struct_VertexOutput_vf4_vf21_3__u1_ %param %param_0 + OpStore %flattenTemp %83 + %86 = OpAccessChain %_ptr_Function_v4float %flattenTemp %int_0 + %87 = OpLoad %v4float %86 + %94 = OpLoad %uint %i_1 + %89 = OpAccessChain %_ptr_Output_v4float %_entryPointOutput_pos %94 + OpStore %89 %87 + %95 = OpAccessChain %_ptr_Function_v2float %flattenTemp %int_1 + %96 = OpLoad %v2float %95 + %98 = OpAccessChain %_ptr_Output_v2float %_entryPointOutput %94 %int_0 + OpStore %98 %96 + OpControlBarrier %uint_2 %uint_1 %uint_0 + %102 = OpLoad %uint %i_1 + %104 = OpIEqual %bool %102 %int_0 + OpSelectionMerge %106 None + OpBranchConditional %104 %105 %106 + %105 = OpLabel + %110 = OpLoad %_arr_VertexOutput_uint_3 %p_0 + OpStore %param_1 %110 + %111 = OpFunctionCall %HSConstantOut %PatchHS_struct_VertexOutput_vf4_vf21_3__ %param_1 + OpStore %_patchConstantResult %111 + %117 = OpAccessChain %_ptr_Function_float %_patchConstantResult %int_0 %int_0 + %118 = OpLoad %float %117 + %120 = OpAccessChain %_ptr_Output_float %_patchConstantOutput_EdgeTess %int_0 + OpStore %120 %118 + %121 = OpAccessChain %_ptr_Function_float %_patchConstantResult %int_0 %int_1 + %122 = OpLoad %float %121 + %123 = OpAccessChain %_ptr_Output_float %_patchConstantOutput_EdgeTess %int_1 + OpStore %123 %122 + %124 = OpAccessChain %_ptr_Function_float %_patchConstantResult %int_0 %int_2 + %125 = OpLoad %float %124 + %126 = OpAccessChain %_ptr_Output_float %_patchConstantOutput_EdgeTess %int_2 + OpStore %126 %125 + %130 = OpAccessChain %_ptr_Function_float %_patchConstantResult %int_1 + %131 = OpLoad %float %130 + %132 = OpAccessChain %_ptr_Output_float %_patchConstantOutput_InsideTess %int_0 + OpStore %132 %131 + OpBranch %106 + %106 = OpLabel + OpReturn + OpFunctionEnd +%_hs_main_struct_VertexOutput_vf4_vf21_3__u1_ = OpFunction %HSOut None %16 + %p = OpFunctionParameter %_ptr_Function__arr_VertexOutput_uint_3 + %i = OpFunctionParameter %_ptr_Function_uint + %20 = OpLabel + %output = OpVariable %_ptr_Function_HSOut Function + %31 = OpLoad %uint %i + %33 = OpAccessChain %_ptr_Function_v4float %p %31 %int_0 + %34 = OpLoad %v4float %33 + %35 = OpAccessChain %_ptr_Function_v4float %output %int_0 + OpStore %35 %34 + %37 = OpLoad %uint %i + %39 = OpAccessChain %_ptr_Function_v2float %p %37 %int_1 + %40 = OpLoad %v2float %39 + %41 = OpAccessChain %_ptr_Function_v2float %output %int_1 + OpStore %41 %40 + %42 = OpLoad %HSOut %output + OpReturnValue %42 + OpFunctionEnd +%PatchHS_struct_VertexOutput_vf4_vf21_3__ = OpFunction %HSConstantOut None %23 + %patch = OpFunctionParameter %_ptr_Function__arr_VertexOutput_uint_3 + %26 = OpLabel + %output_0 = OpVariable %_ptr_Function_HSConstantOut Function + %135 = OpAccessChain %_ptr_Function_v2float %patch %int_0 %int_1 + %136 = OpLoad %v2float %135 + %137 = OpCompositeConstruct %v2float %float_1 %float_1 + %138 = OpFAdd %v2float %137 %136 + %139 = OpCompositeExtract %float %138 0 + %140 = OpAccessChain %_ptr_Function_float %output_0 %int_0 %int_0 + OpStore %140 %139 + %141 = OpAccessChain %_ptr_Function_v2float %patch %int_0 %int_1 + %142 = OpLoad %v2float %141 + %143 = OpCompositeConstruct %v2float %float_1 %float_1 + %144 = OpFAdd %v2float %143 %142 + %145 = OpCompositeExtract %float %144 0 + %146 = OpAccessChain %_ptr_Function_float %output_0 %int_0 %int_1 + OpStore %146 %145 + %147 = OpAccessChain %_ptr_Function_v2float %patch %int_0 %int_1 + %148 = OpLoad %v2float %147 + %149 = OpCompositeConstruct %v2float %float_1 %float_1 + %150 = OpFAdd %v2float %149 %148 + %151 = OpCompositeExtract %float %150 0 + %152 = OpAccessChain %_ptr_Function_float %output_0 %int_0 %int_2 + OpStore %152 %151 + %153 = OpAccessChain %_ptr_Function_v2float %patch %int_0 %int_1 + %154 = OpLoad %v2float %153 + %155 = OpCompositeConstruct %v2float %float_1 %float_1 + %156 = OpFAdd %v2float %155 %154 + %157 = OpCompositeExtract %float %156 0 + %158 = OpAccessChain %_ptr_Function_float %output_0 %int_1 + OpStore %158 %157 + %159 = OpLoad %HSConstantOut %output_0 + OpReturnValue %159 + OpFunctionEnd diff --git a/shaders/asm/vert/empty-io.asm.vert b/shaders/asm/vert/empty-io.asm.vert new file mode 100644 index 0000000000..0ba6cb7963 --- /dev/null +++ b/shaders/asm/vert/empty-io.asm.vert @@ -0,0 +1,70 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 1 +; Bound: 40 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %main "main" %position %_entryPointOutput_position %_entryPointOutput + OpName %main "main" + OpName %VSInput "VSInput" + OpMemberName %VSInput 0 "position" + OpName %VSOutput "VSOutput" + OpMemberName %VSOutput 0 "position" + OpName %_main_struct_VSInput_vf41_ "@main(struct-VSInput-vf41;" + OpName %_input "_input" + OpName %_out "_out" + OpName %_input_0 "_input" + OpName %position "position" + OpName %_entryPointOutput_position "@entryPointOutput_position" + OpName %param "param" + OpName %VSOutput_0 "VSOutput" + OpName %_entryPointOutput "@entryPointOutput" + OpDecorate %position Location 0 + OpDecorate %_entryPointOutput_position BuiltIn Position + OpDecorate %_entryPointOutput Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %VSInput = OpTypeStruct %v4float +%_ptr_Function_VSInput = OpTypePointer Function %VSInput + %VSOutput = OpTypeStruct %v4float + %11 = OpTypeFunction %VSOutput %_ptr_Function_VSInput +%_ptr_Function_VSOutput = OpTypePointer Function %VSOutput + %int = OpTypeInt 32 1 + %18 = OpConstant %int 0 +%_ptr_Function_v4float = OpTypePointer Function %v4float +%_ptr_Input_v4float = OpTypePointer Input %v4float + %position = OpVariable %_ptr_Input_v4float Input +%_ptr_Output_v4float = OpTypePointer Output %v4float +%_entryPointOutput_position = OpVariable %_ptr_Output_v4float Output + %VSOutput_0 = OpTypeStruct +%_ptr_Output_VSOutput_0 = OpTypePointer Output %VSOutput_0 +%_entryPointOutput = OpVariable %_ptr_Output_VSOutput_0 Output + %main = OpFunction %void None %3 + %5 = OpLabel + %_input_0 = OpVariable %_ptr_Function_VSInput Function + %param = OpVariable %_ptr_Function_VSInput Function + %29 = OpLoad %v4float %position + %30 = OpAccessChain %_ptr_Function_v4float %_input_0 %18 + OpStore %30 %29 + %34 = OpLoad %VSInput %_input_0 + OpStore %param %34 + %35 = OpFunctionCall %VSOutput %_main_struct_VSInput_vf41_ %param + %36 = OpCompositeExtract %v4float %35 0 + OpStore %_entryPointOutput_position %36 + OpReturn + OpFunctionEnd +%_main_struct_VSInput_vf41_ = OpFunction %VSOutput None %11 + %_input = OpFunctionParameter %_ptr_Function_VSInput + %14 = OpLabel + %_out = OpVariable %_ptr_Function_VSOutput Function + %20 = OpAccessChain %_ptr_Function_v4float %_input %18 + %21 = OpLoad %v4float %20 + %22 = OpAccessChain %_ptr_Function_v4float %_out %18 + OpStore %22 %21 + %23 = OpLoad %VSOutput %_out + OpReturnValue %23 + OpFunctionEnd diff --git a/shaders/asm/vert/empty-struct-composite.asm.vert b/shaders/asm/vert/empty-struct-composite.asm.vert new file mode 100644 index 0000000000..37a2d87937 --- /dev/null +++ b/shaders/asm/vert/empty-struct-composite.asm.vert @@ -0,0 +1,37 @@ +; SPIR-V +; Version: 1.1 +; Generator: Google rspirv; 0 +; Bound: 17 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %2 "main" + OpExecutionMode %2 OriginUpperLeft + OpName %Test "Test" + OpName %t "t" + OpName %retvar "retvar" + OpName %main "main" + OpName %retvar_0 "retvar" + %void = OpTypeVoid + %6 = OpTypeFunction %void + %Test = OpTypeStruct +%_ptr_Function_Test = OpTypePointer Function %Test +%_ptr_Function_void = OpTypePointer Function %void + %2 = OpFunction %void None %6 + %7 = OpLabel + %t = OpVariable %_ptr_Function_Test Function + %retvar = OpVariable %_ptr_Function_void Function + OpBranch %4 + %4 = OpLabel + %13 = OpCompositeConstruct %Test + OpStore %t %13 + OpReturn + OpFunctionEnd + %main = OpFunction %void None %6 + %15 = OpLabel + %retvar_0 = OpVariable %_ptr_Function_void Function + OpBranch %14 + %14 = OpLabel + OpReturn + OpFunctionEnd diff --git a/shaders/asm/vert/global-builtin.sso.asm.vert b/shaders/asm/vert/global-builtin.sso.asm.vert new file mode 100644 index 0000000000..d7306deb24 --- /dev/null +++ b/shaders/asm/vert/global-builtin.sso.asm.vert @@ -0,0 +1,68 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 1 +; Bound: 40 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %main "main" %_entryPointOutput %_entryPointOutput_pos + OpSource HLSL 500 + OpName %main "main" + OpName %VSOut "VSOut" + OpMemberName %VSOut 0 "a" + OpMemberName %VSOut 1 "pos" + OpName %_main_ "@main(" + OpName %vout "vout" + OpName %flattenTemp "flattenTemp" + OpName %VSOut_0 "VSOut" + OpMemberName %VSOut_0 0 "a" + OpName %_entryPointOutput "@entryPointOutput" + OpName %_entryPointOutput_pos "@entryPointOutput_pos" + OpDecorate %_entryPointOutput Location 0 + OpDecorate %_entryPointOutput_pos BuiltIn Position + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %VSOut = OpTypeStruct %float %v4float + %9 = OpTypeFunction %VSOut +%_ptr_Function_VSOut = OpTypePointer Function %VSOut + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %float_40 = OpConstant %float 40 +%_ptr_Function_float = OpTypePointer Function %float + %int_1 = OpConstant %int 1 + %float_1 = OpConstant %float 1 + %21 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%_ptr_Function_v4float = OpTypePointer Function %v4float + %VSOut_0 = OpTypeStruct %float +%_ptr_Output_VSOut_0 = OpTypePointer Output %VSOut_0 +%_entryPointOutput = OpVariable %_ptr_Output_VSOut_0 Output +%_ptr_Output_float = OpTypePointer Output %float +%_ptr_Output_v4float = OpTypePointer Output %v4float +%_entryPointOutput_pos = OpVariable %_ptr_Output_v4float Output + %main = OpFunction %void None %3 + %5 = OpLabel +%flattenTemp = OpVariable %_ptr_Function_VSOut Function + %28 = OpFunctionCall %VSOut %_main_ + OpStore %flattenTemp %28 + %32 = OpAccessChain %_ptr_Function_float %flattenTemp %int_0 + %33 = OpLoad %float %32 + %35 = OpAccessChain %_ptr_Output_float %_entryPointOutput %int_0 + OpStore %35 %33 + %38 = OpAccessChain %_ptr_Function_v4float %flattenTemp %int_1 + %39 = OpLoad %v4float %38 + OpStore %_entryPointOutput_pos %39 + OpReturn + OpFunctionEnd + %_main_ = OpFunction %VSOut None %9 + %11 = OpLabel + %vout = OpVariable %_ptr_Function_VSOut Function + %18 = OpAccessChain %_ptr_Function_float %vout %int_0 + OpStore %18 %float_40 + %23 = OpAccessChain %_ptr_Function_v4float %vout %int_1 + OpStore %23 %21 + %24 = OpLoad %VSOut %vout + OpReturnValue %24 + OpFunctionEnd diff --git a/shaders/comp/atomic.comp b/shaders/comp/atomic.comp new file mode 100644 index 0000000000..703256d879 --- /dev/null +++ b/shaders/comp/atomic.comp @@ -0,0 +1,56 @@ +#version 310 es +#extension GL_OES_shader_image_atomic : require +layout(local_size_x = 1) in; + +layout(r32ui, binding = 0) uniform highp uimage2D uImage; +layout(r32i, binding = 1) uniform highp iimage2D iImage; +layout(binding = 2, std430) buffer SSBO +{ + uint u32; + int i32; +} ssbo; + +void main() +{ + imageAtomicAdd(uImage, ivec2(1, 5), 1u); + + // Test that we do not invalidate OpImage variables which are loaded from UniformConstant + // address space. + imageStore(iImage, ivec2(1, 6), ivec4(imageAtomicAdd(uImage, ivec2(1, 5), 1u))); + + imageAtomicOr(uImage, ivec2(1, 5), 1u); + imageAtomicXor(uImage, ivec2(1, 5), 1u); + imageAtomicAnd(uImage, ivec2(1, 5), 1u); + imageAtomicMin(uImage, ivec2(1, 5), 1u); + imageAtomicMax(uImage, ivec2(1, 5), 1u); + //imageAtomicExchange(uImage, ivec2(1, 5), 1u); + imageAtomicCompSwap(uImage, ivec2(1, 5), 10u, 2u); + + imageAtomicAdd(iImage, ivec2(1, 6), 1); + imageAtomicOr(iImage, ivec2(1, 6), 1); + imageAtomicXor(iImage, ivec2(1, 6), 1); + imageAtomicAnd(iImage, ivec2(1, 6), 1); + imageAtomicMin(iImage, ivec2(1, 6), 1); + imageAtomicMax(iImage, ivec2(1, 6), 1); + //imageAtomicExchange(iImage, ivec2(1, 5), 1u); + imageAtomicCompSwap(iImage, ivec2(1, 5), 10, 2); + + atomicAdd(ssbo.u32, 1u); + atomicOr(ssbo.u32, 1u); + atomicXor(ssbo.u32, 1u); + atomicAnd(ssbo.u32, 1u); + atomicMin(ssbo.u32, 1u); + atomicMax(ssbo.u32, 1u); + atomicExchange(ssbo.u32, 1u); + atomicCompSwap(ssbo.u32, 10u, 2u); + + atomicAdd(ssbo.i32, 1); + atomicOr(ssbo.i32, 1); + atomicXor(ssbo.i32, 1); + atomicAnd(ssbo.i32, 1); + atomicMin(ssbo.i32, 1); + atomicMax(ssbo.i32, 1); + atomicExchange(ssbo.i32, 1); + atomicCompSwap(ssbo.i32, 10, 2); +} + diff --git a/shaders/comp/bake_gradient.comp b/shaders/comp/bake_gradient.comp new file mode 100644 index 0000000000..4885ff00bc --- /dev/null +++ b/shaders/comp/bake_gradient.comp @@ -0,0 +1,55 @@ +#version 310 es + +layout(local_size_x = 8, local_size_y = 8) in; + +layout(binding = 0) uniform sampler2D uHeight; +layout(binding = 1) uniform sampler2D uDisplacement; +layout(rgba16f, binding = 2) uniform writeonly mediump image2D iHeightDisplacement; +layout(rgba16f, binding = 3) uniform writeonly mediump image2D iGradJacobian; + +layout(binding = 4) uniform UBO +{ + vec4 uInvSize; + vec4 uScale; +}; + +mediump float jacobian(mediump vec2 dDdx, mediump vec2 dDdy) +{ + return (1.0 + dDdx.x) * (1.0 + dDdy.y) - dDdx.y * dDdy.x; +} +#define LAMBDA 1.2 + +void main() +{ + vec4 uv = (vec2(gl_GlobalInvocationID.xy) * uInvSize.xy).xyxy + 0.5 * uInvSize; + + float h = textureLod(uHeight, uv.xy, 0.0).x; + + // Compute the heightmap gradient by simple differentiation. + float x0 = textureLodOffset(uHeight, uv.xy, 0.0, ivec2(-1, 0)).x; + float x1 = textureLodOffset(uHeight, uv.xy, 0.0, ivec2(+1, 0)).x; + float y0 = textureLodOffset(uHeight, uv.xy, 0.0, ivec2(0, -1)).x; + float y1 = textureLodOffset(uHeight, uv.xy, 0.0, ivec2(0, +1)).x; + vec2 grad = uScale.xy * 0.5 * vec2(x1 - x0, y1 - y0); + + // Displacement map must be sampled with a different offset since it's a smaller texture. + vec2 displacement = LAMBDA * textureLod(uDisplacement, uv.zw, 0.0).xy; + + // Compute jacobian. + vec2 dDdx = 0.5 * LAMBDA * ( + textureLodOffset(uDisplacement, uv.zw, 0.0, ivec2(+1, 0)).xy - + textureLodOffset(uDisplacement, uv.zw, 0.0, ivec2(-1, 0)).xy); + vec2 dDdy = 0.5 * LAMBDA * ( + textureLodOffset(uDisplacement, uv.zw, 0.0, ivec2(0, +1)).xy - + textureLodOffset(uDisplacement, uv.zw, 0.0, ivec2(0, -1)).xy); + float j = jacobian(dDdx * uScale.z, dDdy * uScale.z); + + displacement = vec2(0.0); + + // Read by vertex shader/tess shader. + imageStore(iHeightDisplacement, ivec2(gl_GlobalInvocationID.xy), vec4(h, displacement, 0.0)); + + // Read by fragment shader. + imageStore(iGradJacobian, ivec2(gl_GlobalInvocationID.xy), vec4(grad, j, 0.0)); +} + diff --git a/shaders/comp/barriers.comp b/shaders/comp/barriers.comp new file mode 100644 index 0000000000..7e0ea42d4e --- /dev/null +++ b/shaders/comp/barriers.comp @@ -0,0 +1,79 @@ +#version 310 es +layout(local_size_x = 4) in; + +void barrier_shared() +{ + memoryBarrierShared(); +} + +void full_barrier() +{ + memoryBarrier(); +} + +void image_barrier() +{ + memoryBarrierImage(); +} + +void buffer_barrier() +{ + memoryBarrierBuffer(); +} + +void group_barrier() +{ + groupMemoryBarrier(); +} + +void barrier_shared_exec() +{ + memoryBarrierShared(); + barrier(); +} + +void full_barrier_exec() +{ + memoryBarrier(); + barrier(); +} + +void image_barrier_exec() +{ + memoryBarrierImage(); + barrier(); +} + +void buffer_barrier_exec() +{ + memoryBarrierBuffer(); + barrier(); +} + +void group_barrier_exec() +{ + groupMemoryBarrier(); + barrier(); +} + +void exec_barrier() +{ + barrier(); +} + +void main() +{ + barrier_shared(); + full_barrier(); + image_barrier(); + buffer_barrier(); + group_barrier(); + + barrier_shared_exec(); + full_barrier_exec(); + image_barrier_exec(); + buffer_barrier_exec(); + group_barrier_exec(); + + exec_barrier(); +} diff --git a/shaders/comp/basic.comp b/shaders/comp/basic.comp new file mode 100644 index 0000000000..f9bf55670f --- /dev/null +++ b/shaders/comp/basic.comp @@ -0,0 +1,28 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(std430, binding = 0) readonly buffer SSBO +{ + vec4 in_data[]; +}; + +layout(std430, binding = 1) writeonly buffer SSBO2 +{ + vec4 out_data[]; +}; + +layout(std430, binding = 2) buffer SSBO3 +{ + uint counter; +}; + +void main() +{ + uint ident = gl_GlobalInvocationID.x; + vec4 idata = in_data[ident]; + if (dot(idata, vec4(1.0, 5.0, 6.0, 2.0)) > 8.2) + { + out_data[atomicAdd(counter, 1u)] = idata; + } +} + diff --git a/shaders/comp/bitfield.noopt.comp b/shaders/comp/bitfield.noopt.comp new file mode 100644 index 0000000000..d75b556b62 --- /dev/null +++ b/shaders/comp/bitfield.noopt.comp @@ -0,0 +1,21 @@ +#version 310 es + +void main() +{ + int signed_value = 0; + uint unsigned_value = 0u; + + int s = bitfieldExtract(signed_value, 5, 20); + uint u = bitfieldExtract(unsigned_value, 6, 21); + s = bitfieldInsert(s, 40, 5, 4); + u = bitfieldInsert(u, 60u, 5, 4); + + u = bitfieldReverse(u); + s = bitfieldReverse(s); + + int v0 = bitCount(u); + int v1 = bitCount(s); + + int v2 = findMSB(u); + int v3 = findLSB(s); +} diff --git a/shaders/comp/casts.comp b/shaders/comp/casts.comp new file mode 100644 index 0000000000..6be539d7be --- /dev/null +++ b/shaders/comp/casts.comp @@ -0,0 +1,18 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(binding = 0, std430) buffer SSBO0 +{ + ivec4 inputs[]; +}; + +layout(binding = 1, std430) buffer SSBO1 +{ + ivec4 outputs[]; +}; + +void main() +{ + uint ident = gl_GlobalInvocationID.x; + outputs[ident] = ivec4(bvec4(inputs[ident] & 0x3)); +} diff --git a/shaders/comp/cfg-preserve-parameter.comp b/shaders/comp/cfg-preserve-parameter.comp new file mode 100644 index 0000000000..9ef9092005 --- /dev/null +++ b/shaders/comp/cfg-preserve-parameter.comp @@ -0,0 +1,54 @@ +#version 310 es + +// We write in all paths (and no reads), so should just be out. +void out_test_0(int cond, inout int i) +{ + if (cond == 0) + i = 40; + else + i = 60; +} + +// We write in all paths (and no reads), so should just be out. +void out_test_1(int cond, inout int i) +{ + switch (cond) + { + case 40: + i = 40; + break; + + default: + i = 70; + break; + } +} + +// We don't write in all paths, so should be inout. +void inout_test_0(int cond, inout int i) +{ + if (cond == 0) + i = 40; +} + +void inout_test_1(int cond, inout int i) +{ + switch (cond) + { + case 40: + i = 40; + break; + } +} + + +void main() +{ + int cond = 40; + int i = 50; + + out_test_0(cond, i); + out_test_1(cond, i); + inout_test_0(cond, i); + inout_test_1(cond, i); +} diff --git a/shaders/comp/cfg.comp b/shaders/comp/cfg.comp new file mode 100644 index 0000000000..4f4e6c0ea8 --- /dev/null +++ b/shaders/comp/cfg.comp @@ -0,0 +1,91 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(std430, binding = 0) buffer SSBO +{ + float data; +}; + +void test() +{ + // Test that variables local to a scope stay local. + if (data != 0.0) + { + float tmp = 10.0; + data = tmp; + } + else + { + float tmp = 15.0; + data = tmp; + } + + // Test that variable access propagates up to dominator + if (data != 0.0) + { + float e; + if (data != 5.0) + { + if (data != 6.0) + e = 10.0; + } + else + e = 20.0; + } + + // Test that variables local to a switch block stay local. + switch (int(data)) + { + case 0: + { + float tmp = 20.0; + data = tmp; + break; + } + + case 1: + { + float tmp = 30.0; + data = tmp; + break; + } + } + + // Check that multibranches propagate up to dominator. + float f; + switch (int(data)) + { + case 0: + { + f = 30.0; + break; + } + + case 1: + { + f = 40.0; + break; + } + } + + // Check that loops work. + // Interesting case here is propagating variable access from the continue block. + float h; + for (int i = 0; i < 20; i++, h += 10.0) + ; + data = h; + + // Do the same with do-while, gotta test all the hard cases. + float m; + do + { + } while (m != 20.0); + data = m; +} + +void main() +{ + // Test that we do the CFG analysis for all functions. + test(); +} + diff --git a/shaders/comp/coherent-block.comp b/shaders/comp/coherent-block.comp new file mode 100644 index 0000000000..0a174e8ef0 --- /dev/null +++ b/shaders/comp/coherent-block.comp @@ -0,0 +1,12 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(binding = 1) coherent restrict writeonly buffer SSBO +{ + vec4 value; +}; + +void main() +{ + value = vec4(20.0); +} diff --git a/shaders/comp/coherent-image.comp b/shaders/comp/coherent-image.comp new file mode 100644 index 0000000000..fd6e280182 --- /dev/null +++ b/shaders/comp/coherent-image.comp @@ -0,0 +1,14 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(binding = 1) coherent restrict writeonly buffer SSBO +{ + ivec4 value; +}; + +layout(r32i, binding = 3) coherent readonly restrict uniform mediump iimage2D uImage; + +void main() +{ + value = imageLoad(uImage, ivec2(10)); +} diff --git a/shaders/comp/composite-construct.comp b/shaders/comp/composite-construct.comp new file mode 100644 index 0000000000..859c56f51f --- /dev/null +++ b/shaders/comp/composite-construct.comp @@ -0,0 +1,40 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(std430, binding = 0) buffer SSBO0 +{ + vec4 as[]; +}; + +layout(std430, binding = 1) buffer SSBO1 +{ + vec4 bs[]; +}; + +vec4 summe(vec4 values[3][2]) +{ + return values[0][0] + values[2][1] + values[0][1] + values[1][0]; +} + +struct Composite +{ + vec4 a[2]; + vec4 b[2]; +}; + +void main() +{ + vec4 values[2] = vec4[](as[gl_GlobalInvocationID.x], bs[gl_GlobalInvocationID.x]); + vec4 const_values[2] = vec4[](vec4(10.0), vec4(30.0)); + vec4 copy_values[2]; + copy_values = const_values; + vec4 copy_values2[2] = values; + as[gl_GlobalInvocationID.x] = summe(vec4[][](values, copy_values, copy_values2)); + + Composite c = Composite(values, copy_values); + + float arrayofarray[2][3] = float[][](float[](1.0, 1.0, 1.0), float[](2.0, 2.0, 2.0)); + + float b = 10.0; + float values_scalar[4] = float[](b, b, b, b); +} diff --git a/shaders/comp/culling.comp b/shaders/comp/culling.comp new file mode 100644 index 0000000000..9f8331b10b --- /dev/null +++ b/shaders/comp/culling.comp @@ -0,0 +1,26 @@ +#version 310 es +layout(local_size_x = 4) in; + +layout(std430, binding = 0) readonly buffer SSBO +{ + float in_data[]; +}; + +layout(std430, binding = 1) writeonly buffer SSBO2 +{ + float out_data[]; +}; + +layout(std430, binding = 2) buffer SSBO3 +{ + uint count; +}; + +void main() +{ + uint ident = gl_GlobalInvocationID.x; + float idata = in_data[ident]; + if (idata > 12.0) + out_data[atomicAdd(count, 1u)] = idata; +} + diff --git a/shaders/comp/defer-parens.comp b/shaders/comp/defer-parens.comp new file mode 100644 index 0000000000..4e8ea6b399 --- /dev/null +++ b/shaders/comp/defer-parens.comp @@ -0,0 +1,30 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(binding = 0, std430) buffer SSBO +{ + vec4 data; + int index; +}; + +void main() +{ + // Tests defer-parens behavior where a binary expression is OpCompositeExtracted chained together + // with an OpCompositeConstruct optimization. + vec4 d = data; + data = vec4(d.x, d.yz + 10.0, d.w); + + // Verify binary ops. + data = d + d + d; + + // Verify swizzles. + data = (d.yz + 10.0).xxyy; + + // OpCompositeExtract + float t = (d.yz + 10.0).y; + data = vec4(t); + + // OpVectorExtractDynamic + t = (d.zw + 10.0)[index]; + data = vec4(t); +} diff --git a/shaders/comp/dowhile.comp b/shaders/comp/dowhile.comp new file mode 100644 index 0000000000..709db75a17 --- /dev/null +++ b/shaders/comp/dowhile.comp @@ -0,0 +1,31 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(std430, binding = 0) readonly buffer SSBO +{ + mat4 mvp; + vec4 in_data[]; +}; + +layout(std430, binding = 1) writeonly buffer SSBO2 +{ + vec4 out_data[]; +}; + +int i; + +void main() +{ + uint ident = gl_GlobalInvocationID.x; + + i = 0; + vec4 idat = in_data[ident]; + do + { + idat = mvp * idat; + i++; + } while(i < 16); + + out_data[ident] = idat; +} + diff --git a/shaders/comp/generate_height.comp b/shaders/comp/generate_height.comp new file mode 100644 index 0000000000..16cef4de78 --- /dev/null +++ b/shaders/comp/generate_height.comp @@ -0,0 +1,97 @@ +#version 310 es + +layout(local_size_x = 64) in; + +layout(std430, binding = 0) readonly buffer Distribution +{ + vec2 distribution[]; +}; + +layout(std430, binding = 1) writeonly buffer HeightmapFFT +{ + uint heights[]; +}; + +layout(binding = 2, std140) uniform UBO +{ + vec4 uModTime; +}; + +vec2 alias(vec2 i, vec2 N) +{ + return mix(i, i - N, greaterThan(i, 0.5 * N)); +} + +vec4 cmul(vec4 a, vec4 b) +{ + vec4 r3 = a.yxwz; + vec4 r1 = b.xxzz; + vec4 R0 = a * r1; + vec4 r2 = b.yyww; + vec4 R1 = r2 * r3; + return R0 + vec4(-R1.x, R1.y, -R1.z, R1.w); +} + +vec2 cmul(vec2 a, vec2 b) +{ + vec2 r3 = a.yx; + vec2 r1 = b.xx; + vec2 R0 = a * r1; + vec2 r2 = b.yy; + vec2 R1 = r2 * r3; + return R0 + vec2(-R1.x, R1.y); +} + +uint pack2(vec2 v) +{ + return packHalf2x16(v); +} + +uvec2 pack4(vec4 v) +{ + return uvec2(packHalf2x16(v.xy), packHalf2x16(v.zw)); +} + +uvec2 workaround_mix(uvec2 a, uvec2 b, bvec2 sel) +{ + return uvec2(sel.x ? b.x : a.x, sel.y ? b.y : a.y); +} + +void generate_heightmap() +{ + uvec2 N = gl_WorkGroupSize.xy * gl_NumWorkGroups.xy; + uvec2 i = gl_GlobalInvocationID.xy; + // Pick out the negative frequency variant. + uvec2 wi = workaround_mix(N - i, uvec2(0u), equal(i, uvec2(0u))); + + // Pick out positive and negative travelling waves. + vec2 a = distribution[i.y * N.x + i.x]; + vec2 b = distribution[wi.y * N.x + wi.x]; + + vec2 k = uModTime.xy * alias(vec2(i), vec2(N)); + float k_len = length(k); + + const float G = 9.81; + + // If this sample runs for hours on end, the cosines of very large numbers will eventually become unstable. + // It is fairly easy to fix this by wrapping uTime, + // and quantizing w such that wrapping uTime does not change the result. + // See Tessendorf's paper for how to do it. + // The sqrt(G * k_len) factor represents how fast ocean waves at different frequencies propagate. + float w = sqrt(G * k_len) * uModTime.z; + float cw = cos(w); + float sw = sin(w); + + // Complex multiply to rotate our frequency samples. + a = cmul(a, vec2(cw, sw)); + b = cmul(b, vec2(cw, sw)); + b = vec2(b.x, -b.y); // Complex conjugate since we picked a frequency with the opposite direction. + vec2 res = a + b; // Sum up forward and backwards travelling waves. + heights[i.y * N.x + i.x] = pack2(res); +} + +void main() +{ + generate_heightmap(); +} + diff --git a/shaders/comp/image.comp b/shaders/comp/image.comp new file mode 100644 index 0000000000..e375534a51 --- /dev/null +++ b/shaders/comp/image.comp @@ -0,0 +1,12 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(rgba8, binding = 0) uniform readonly mediump image2D uImageIn; +layout(rgba8, binding = 1) uniform writeonly mediump image2D uImageOut; + +void main() +{ + vec4 v = imageLoad(uImageIn, ivec2(gl_GlobalInvocationID.xy) + imageSize(uImageIn)); + imageStore(uImageOut, ivec2(gl_GlobalInvocationID.xy), v); +} + diff --git a/shaders/comp/inout-struct.invalid.comp b/shaders/comp/inout-struct.invalid.comp new file mode 100644 index 0000000000..c1de959743 --- /dev/null +++ b/shaders/comp/inout-struct.invalid.comp @@ -0,0 +1,55 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(std430, binding = 0) writeonly buffer SSBO +{ + vec4 data[]; +} outdata; + +layout(std430, binding = 1) readonly buffer SSBO2 +{ + vec4 data[]; +} indata; + +struct Foo +{ + vec4 a; + vec4 b; + vec4 c; + vec4 d; +}; + +layout(std430, binding = 2) readonly buffer SSBO3 +{ + Foo foos[]; +} foobar; + +vec4 bar(Foo foo) +{ + return foo.a + foo.b + foo.c + foo.d; +} + +void baz(out Foo foo) +{ + uint ident = gl_GlobalInvocationID.x; + foo.a = indata.data[4u * ident + 0u]; + foo.b = indata.data[4u * ident + 1u]; + foo.c = indata.data[4u * ident + 2u]; + foo.d = indata.data[4u * ident + 3u]; +} + +void meow(inout Foo foo) +{ + foo.a += 10.0; + foo.b += 20.0; + foo.c += 30.0; + foo.d += 40.0; +} + +void main() +{ + Foo foo; + baz(foo); + meow(foo); + outdata.data[gl_GlobalInvocationID.x] = bar(foo) + bar(foobar.foos[gl_GlobalInvocationID.x]); +} diff --git a/shaders/comp/insert.comp b/shaders/comp/insert.comp new file mode 100644 index 0000000000..07c1f8d7aa --- /dev/null +++ b/shaders/comp/insert.comp @@ -0,0 +1,18 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(std430, binding = 0) writeonly buffer SSBO +{ + vec4 out_data[]; +}; + +void main() +{ + vec4 v; + v.x = 10.0; + v.y = 30.0; + v.z = 70.0; + v.w = 90.0; + out_data[gl_GlobalInvocationID.x] = v; + out_data[gl_GlobalInvocationID.x].y = 20.0; +} diff --git a/shaders/comp/loop.noopt.comp b/shaders/comp/loop.noopt.comp new file mode 100644 index 0000000000..6d6c324243 --- /dev/null +++ b/shaders/comp/loop.noopt.comp @@ -0,0 +1,98 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(std430, binding = 0) readonly buffer SSBO +{ + mat4 mvp; + vec4 in_data[]; +}; + +layout(std430, binding = 1) writeonly buffer SSBO2 +{ + vec4 out_data[]; +}; + +void main() +{ + uint ident = gl_GlobalInvocationID.x; + vec4 idat = in_data[ident]; + + int k = 0; + uint i = 0u; + + if (idat.y == 20.0) + { + do + { + k = k * 2; + i++; + } while (i < ident); + } + + switch (k) + { + case 10: + for (;;) + { + i++; + if (i > 10u) + break; + } + break; + + default: + for (;;) + { + i += 2u; + if (i > 20u) + break; + } + break; + } + + while (k < 10) + { + idat *= 2.0; + k++; + } + + for (uint i = 0u; i < 16u; i++, k++) + for (uint j = 0u; j < 30u; j++) + idat = mvp * idat; + + k = 0; + for (;;) + { + k++; + if (k > 10) + { + k += 2; + } + else + { + k += 3; + continue; + } + + k += 10; + } + + k = 0; + do + { + k++; + } while (k > 10); + + int l = 0; + for (;; l++) + { + if (l == 5) + { + continue; + } + + idat += 1.0; + } + out_data[ident] = idat; +} + diff --git a/shaders/comp/mat3.comp b/shaders/comp/mat3.comp new file mode 100644 index 0000000000..7c5bb1e4f5 --- /dev/null +++ b/shaders/comp/mat3.comp @@ -0,0 +1,14 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(std430, binding = 1) writeonly buffer SSBO2 +{ + mat3 out_data[]; +}; + +void main() +{ + uint ident = gl_GlobalInvocationID.x; + out_data[ident] = mat3(vec3(10.0), vec3(20.0), vec3(40.0)); +} + diff --git a/shaders/comp/mod.comp b/shaders/comp/mod.comp new file mode 100644 index 0000000000..1631456e30 --- /dev/null +++ b/shaders/comp/mod.comp @@ -0,0 +1,26 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(std430, binding = 0) readonly buffer SSBO +{ + vec4 in_data[]; +}; + +layout(std430, binding = 1) writeonly buffer SSBO2 +{ + vec4 out_data[]; +}; + +void main() +{ + uint ident = gl_GlobalInvocationID.x; + vec4 v = mod(in_data[ident], out_data[ident]); + out_data[ident] = v; + + uvec4 vu = floatBitsToUint(in_data[ident]) % floatBitsToUint(out_data[ident]); + out_data[ident] = uintBitsToFloat(vu); + + ivec4 vi = floatBitsToInt(in_data[ident]) % floatBitsToInt(out_data[ident]); + out_data[ident] = intBitsToFloat(vi); +} + diff --git a/shaders/comp/modf.comp b/shaders/comp/modf.comp new file mode 100644 index 0000000000..edadefcf05 --- /dev/null +++ b/shaders/comp/modf.comp @@ -0,0 +1,23 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(std430, binding = 0) readonly buffer SSBO +{ + vec4 in_data[]; +}; + +layout(std430, binding = 1) writeonly buffer SSBO2 +{ + vec4 out_data[]; +}; + +void main() +{ + uint ident = gl_GlobalInvocationID.x; + vec4 i; + //vec4 v = frexp(in_data[ident], i); + //out_data[ident] = ldexp(v, i); + vec4 v = modf(in_data[ident], i); + out_data[ident] = v; +} + diff --git a/shaders/comp/read-write-only.comp b/shaders/comp/read-write-only.comp new file mode 100644 index 0000000000..b224b6f121 --- /dev/null +++ b/shaders/comp/read-write-only.comp @@ -0,0 +1,26 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(binding = 0, std430) readonly buffer SSBO0 +{ + vec4 data0; + vec4 data1; +}; + +layout(binding = 1, std430) restrict buffer SSBO1 +{ + vec4 data2; + vec4 data3; +}; + +layout(binding = 2, std430) restrict writeonly buffer SSBO2 +{ + vec4 data4; + vec4 data5; +}; + +void main() +{ + data4 = data0 + data2; + data5 = data1 + data3; +} diff --git a/shaders/comp/return.comp b/shaders/comp/return.comp new file mode 100644 index 0000000000..617f437182 --- /dev/null +++ b/shaders/comp/return.comp @@ -0,0 +1,33 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(std430, binding = 1) writeonly buffer SSBO2 +{ + vec4 out_data[]; +}; + +void main() +{ + uint ident = gl_GlobalInvocationID.x; + + if (ident == 2u) + { + out_data[ident] = vec4(20.0); + } + else if (ident == 4u) + { + out_data[ident] = vec4(10.0); + return; + } + + for (int i = 0; i < 20; i++) + { + if (i == 10) + break; + + return; + } + + out_data[ident] = vec4(10.0); +} + diff --git a/shaders/comp/rmw-opt.comp b/shaders/comp/rmw-opt.comp new file mode 100644 index 0000000000..a6e1e7fe75 --- /dev/null +++ b/shaders/comp/rmw-opt.comp @@ -0,0 +1,27 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(std430, binding = 0) buffer SSBO +{ + int a; +}; + +void main() +{ + a += 10; + a -= 10; + a *= 10; + a /= 10; + a <<= 2; + a >>= 3; + a &= 40; + a ^= 10; + a %= 40; + a |= 1; + + bool c = false; + bool d = true; + c = c && d; + d = d || c; + a = c && d ? 1 : 0; +} diff --git a/shaders/comp/shared.comp b/shaders/comp/shared.comp new file mode 100644 index 0000000000..4deff93597 --- /dev/null +++ b/shaders/comp/shared.comp @@ -0,0 +1,27 @@ +#version 310 es +layout(local_size_x = 4) in; + +shared float sShared[gl_WorkGroupSize.x]; + +layout(std430, binding = 0) readonly buffer SSBO +{ + float in_data[]; +}; + +layout(std430, binding = 1) writeonly buffer SSBO2 +{ + float out_data[]; +}; + +void main() +{ + uint ident = gl_GlobalInvocationID.x; + float idata = in_data[ident]; + + sShared[gl_LocalInvocationIndex] = idata; + memoryBarrierShared(); + barrier(); + + out_data[ident] = sShared[gl_WorkGroupSize.x - gl_LocalInvocationIndex - 1u]; +} + diff --git a/shaders/comp/ssbo-array.comp b/shaders/comp/ssbo-array.comp new file mode 100644 index 0000000000..da0eae0889 --- /dev/null +++ b/shaders/comp/ssbo-array.comp @@ -0,0 +1,14 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(std430, binding = 0) buffer SSBO +{ + vec4 data[]; +} ssbos[2]; + +void main() +{ + uint ident = gl_GlobalInvocationID.x; + ssbos[1].data[ident] = ssbos[0].data[ident]; +} + diff --git a/shaders/comp/struct-layout.comp b/shaders/comp/struct-layout.comp new file mode 100644 index 0000000000..5a2b7802df --- /dev/null +++ b/shaders/comp/struct-layout.comp @@ -0,0 +1,24 @@ +#version 310 es +layout(local_size_x = 1) in; + +struct Foo +{ + mat4 m; +}; + +layout(std430, binding = 0) readonly buffer SSBO +{ + Foo in_data[]; +}; + +layout(std430, binding = 1) writeonly buffer SSBO2 +{ + Foo out_data[]; +}; + +void main() +{ + uint ident = gl_GlobalInvocationID.x; + out_data[ident].m = in_data[ident].m * in_data[ident].m; +} + diff --git a/shaders/comp/struct-packing.comp b/shaders/comp/struct-packing.comp new file mode 100644 index 0000000000..53a54e4927 --- /dev/null +++ b/shaders/comp/struct-packing.comp @@ -0,0 +1,86 @@ +#version 310 es +layout(local_size_x = 1) in; + +struct S0 +{ + vec2 a[1]; + float b; +}; + +struct S1 +{ + vec3 a; + float b; +}; + +struct S2 +{ + vec3 a[1]; + float b; +}; + +struct S3 +{ + vec2 a; + float b; +}; + +struct S4 +{ + vec2 c; +}; + +struct Content +{ + S0 m0s[1]; + S1 m1s[1]; + S2 m2s[1]; + S0 m0; + S1 m1; + S2 m2; + S3 m3; + float m4; + + S4 m3s[8]; +}; + +layout(binding = 1, std430) buffer SSBO1 +{ + Content content; + Content content1[2]; + Content content2; + + layout(column_major) mat2 m0; + layout(column_major) mat2 m1; + layout(column_major) mat2x3 m2[4]; + layout(column_major) mat3x2 m3; + layout(row_major) mat2 m4; + layout(row_major) mat2 m5[9]; + layout(row_major) mat2x3 m6[4][2]; + layout(row_major) mat3x2 m7; + float array[]; +} ssbo_430; + +layout(binding = 0, std140) buffer SSBO0 +{ + Content content; + Content content1[2]; + Content content2; + + layout(column_major) mat2 m0; + layout(column_major) mat2 m1; + layout(column_major) mat2x3 m2[4]; + layout(column_major) mat3x2 m3; + layout(row_major) mat2 m4; + layout(row_major) mat2 m5[9]; + layout(row_major) mat2x3 m6[4][2]; + layout(row_major) mat3x2 m7; + + float array[]; +} ssbo_140; + +void main() +{ + ssbo_430.content = ssbo_140.content; +} + diff --git a/shaders/comp/torture-loop.comp b/shaders/comp/torture-loop.comp new file mode 100644 index 0000000000..54a1221a15 --- /dev/null +++ b/shaders/comp/torture-loop.comp @@ -0,0 +1,40 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(std430, binding = 0) readonly buffer SSBO +{ + mat4 mvp; + vec4 in_data[]; +}; + +layout(std430, binding = 1) writeonly buffer SSBO2 +{ + vec4 out_data[]; +}; + +void main() +{ + uint ident = gl_GlobalInvocationID.x; + vec4 idat = in_data[ident]; + + int k = 0; + + // Continue with side effects. + while (++k < 10) + { + idat *= 2.0; + k++; + } + + // Again used here ... + for (uint i = 0u; i < 16u; i++, k++) + for (uint j = 0u; j < 30u; j++) + idat = mvp * idat; + + do + { + k++; + } while (k > 10); + out_data[ident] = idat; +} + diff --git a/shaders/comp/type-alias.comp b/shaders/comp/type-alias.comp new file mode 100644 index 0000000000..343d350a2f --- /dev/null +++ b/shaders/comp/type-alias.comp @@ -0,0 +1,45 @@ +#version 310 es +layout(local_size_x = 1) in; + +struct S0 +{ + vec4 a; +}; + +struct S1 +{ + vec4 a; +}; + +vec4 overload(S0 s0) +{ + return s0.a; +} + +vec4 overload(S1 s1) +{ + return s1.a; +} + +layout(std430, binding = 0) buffer SSBO0 +{ + S0 s0s[]; +}; + +layout(std430, binding = 1) buffer SSBO1 +{ + S1 s1s[]; +}; + +layout(std430, binding = 2) buffer SSBO2 +{ + vec4 outputs[]; +}; + + +void main() +{ + S0 s0 = s0s[gl_GlobalInvocationID.x]; + S1 s1 = s1s[gl_GlobalInvocationID.x]; + outputs[gl_GlobalInvocationID.x] = overload(s0) + overload(s1); +} diff --git a/shaders/comp/udiv.comp b/shaders/comp/udiv.comp new file mode 100644 index 0000000000..33fe564f07 --- /dev/null +++ b/shaders/comp/udiv.comp @@ -0,0 +1,17 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(std430, binding = 0) buffer SSBO +{ + uint inputs[]; +}; + +layout(std430, binding = 0) buffer SSBO2 +{ + uint outputs[]; +}; + +void main() +{ + outputs[gl_GlobalInvocationID.x] = inputs[gl_GlobalInvocationID.x] / 29u; +} diff --git a/shaders/desktop-only/comp/enhanced-layouts.comp b/shaders/desktop-only/comp/enhanced-layouts.comp new file mode 100644 index 0000000000..470b73e9bd --- /dev/null +++ b/shaders/desktop-only/comp/enhanced-layouts.comp @@ -0,0 +1,39 @@ +#version 450 + +struct Foo +{ + int a; + int b; + int c; +}; + +layout(std140, binding = 0) uniform UBO +{ + layout(offset = 4) int a; + layout(offset = 8) int b; + layout(offset = 16) Foo foo; + layout(offset = 48) int c[8]; +} ubo; + +layout(std140, binding = 1) buffer SSBO1 +{ + layout(offset = 4) int a; + layout(offset = 8) int b; + layout(offset = 16) Foo foo; + layout(offset = 48) int c[8]; +} ssbo1; + +layout(std430, binding = 2) buffer SSBO2 +{ + layout(offset = 4) int a; + layout(offset = 8) int b; + layout(offset = 16) Foo foo; + layout(offset = 48) int c[8]; +} ssbo2; + +void main() +{ + ssbo1.a = ssbo2.a; + ssbo1.b = ubo.b; +} + diff --git a/shaders/desktop-only/comp/fp64.desktop.comp b/shaders/desktop-only/comp/fp64.desktop.comp new file mode 100644 index 0000000000..dd488a3077 --- /dev/null +++ b/shaders/desktop-only/comp/fp64.desktop.comp @@ -0,0 +1,91 @@ +#version 450 +layout(local_size_x = 1) in; + +struct M0 +{ + double v; + dvec2 b[2]; + dmat2x3 c; + dmat3x2 d; +}; + +// Test buffer layout handling. +layout(std430, binding = 0) buffer SSBO0 +{ + dvec4 a; + M0 m0; + dmat4 b; +} ssbo_0; + +layout(std430, binding = 1) buffer SSBO1 +{ + dmat4 a; + dvec4 b; + M0 m0; +} ssbo_1; + +layout(std430, binding = 2) buffer SSBO2 +{ + double a[4]; + dvec2 b[4]; +} ssbo_2; + +layout(std140, binding = 3) buffer SSBO3 +{ + double a[4]; + dvec2 b[4]; +} ssbo_3; + +void main() +{ + ssbo_0.a += dvec4(10, 20, 30, 40); + ssbo_0.a += 20; + + dvec4 a = ssbo_0.a; + dmat4 amat = ssbo_0.b; + + ssbo_0.a = abs(a); + ssbo_0.a = sign(a); + ssbo_0.a = floor(a); + ssbo_0.a = trunc(a); + ssbo_0.a = round(a); + ssbo_0.a = roundEven(a); + ssbo_0.a = ceil(a); + ssbo_0.a = fract(a); + ssbo_0.a = mod(a, 20.0); + ssbo_0.a = mod(a, a); + ssbo_0.a = min(a, a); + ssbo_0.a = max(a, a); + ssbo_0.a = clamp(a, a, a); + ssbo_0.a = mix(a, a, a); + ssbo_0.a = step(a, a); + ssbo_0.a = smoothstep(a, a, a); + bvec4 b = isnan(a); + bvec4 c = isinf(a); + + double f = packDouble2x32(uvec2(10, 40)); + uvec2 g = unpackDouble2x32(f); + + double d = length(a); + d = distance(a, a); + d = dot(a, a); + dvec3 e = cross(a.xyz, a.yzw); + a = faceforward(a, a, a); + a = reflect(a, a); + a = refract(a, a, a.x); + + dmat4 l = matrixCompMult(amat, amat); + l = outerProduct(a, a); + l = transpose(l); + double m = determinant(l); + l = inverse(l); + + bvec4 k = lessThan(a, a); + k = lessThanEqual(a, a); + k = greaterThan(a, a); + k = greaterThanEqual(a, a); + + ssbo_1.b.x += 1.0lf; + ssbo_2.b[0].x += 1.0lf; + ssbo_3.b[0].x += 1.0lf; +} diff --git a/shaders/desktop-only/comp/image-formats.desktop.noeliminate.comp b/shaders/desktop-only/comp/image-formats.desktop.noeliminate.comp new file mode 100644 index 0000000000..5a70623c85 --- /dev/null +++ b/shaders/desktop-only/comp/image-formats.desktop.noeliminate.comp @@ -0,0 +1,48 @@ +#version 450 +layout(local_size_x = 1) in; + +layout(rgba32f, binding = 0) uniform image2D uImg00; +layout(rgba16f, binding = 1) uniform image2D uImg01; +layout(rg32f, binding = 2) uniform image2D uImg02; +layout(rg16f, binding = 3) uniform image2D uImg03; +layout(r11f_g11f_b10f, binding = 4) uniform image2D uImg04; +layout(r32f, binding = 5) uniform image2D uImg05; +layout(r16f, binding = 6) uniform image2D uImg06; +layout(rgba16, binding = 7) uniform image2D uImg07; +layout(rgb10_a2, binding = 8) uniform image2D uImg08; +layout(rgba8, binding = 9) uniform image2D uImg09; +layout(rg16, binding = 10) uniform image2D uImg10; +layout(rg8, binding = 11) uniform image2D uImg11; +layout(r16, binding = 12) uniform image2D uImg12; +layout(r8, binding = 13) uniform image2D uImg13; +layout(rgba16_snorm, binding = 14) uniform image2D uImg14; +layout(rgba8_snorm, binding = 15) uniform image2D uImg15; +layout(rg16_snorm, binding = 16) uniform image2D uImg16; +layout(rg8_snorm, binding = 17) uniform image2D uImg17; +layout(r16_snorm, binding = 18) uniform image2D uImg18; +layout(r8_snorm, binding = 19) uniform image2D uImg19; + +layout(rgba32i, binding = 20) uniform iimage2D uImage20; +layout(rgba16i, binding = 21) uniform iimage2D uImage21; +layout(rgba8i, binding = 22) uniform iimage2D uImage22; +layout(rg32i, binding = 23) uniform iimage2D uImage23; +layout(rg16i, binding = 24) uniform iimage2D uImage24; +layout(rg8i, binding = 25) uniform iimage2D uImage25; +layout(r32i, binding = 26) uniform iimage2D uImage26; +layout(r16i, binding = 27) uniform iimage2D uImage27; +layout(r8i, binding = 28) uniform iimage2D uImage28; + +layout(rgba32ui, binding = 29) uniform uimage2D uImage29; +layout(rgba16ui, binding = 30) uniform uimage2D uImage30; +layout(rgb10_a2ui, binding = 31) uniform uimage2D uImage31; +layout(rgba8ui, binding = 32) uniform uimage2D uImage32; +layout(rg32ui, binding = 33) uniform uimage2D uImage33; +layout(rg16ui, binding = 34) uniform uimage2D uImage34; +layout(rg8ui, binding = 35) uniform uimage2D uImage35; +layout(r32ui, binding = 36) uniform uimage2D uImage36; +layout(r16ui, binding = 37) uniform uimage2D uImage37; +layout(r8ui, binding = 38) uniform uimage2D uImage38; + +void main() +{ +} diff --git a/shaders/desktop-only/comp/int64.desktop.comp b/shaders/desktop-only/comp/int64.desktop.comp new file mode 100644 index 0000000000..81004d4ad6 --- /dev/null +++ b/shaders/desktop-only/comp/int64.desktop.comp @@ -0,0 +1,55 @@ +#version 450 +#extension GL_ARB_gpu_shader_int64 : require +layout(local_size_x = 1) in; + +struct M0 +{ + int64_t v; + i64vec2 b[2]; + uint64_t c; + uint64_t d[5]; +}; + +// Test buffer layout handling. +layout(std430, binding = 0) buffer SSBO0 +{ + i64vec4 a; + M0 m0; +} ssbo_0; + +layout(std430, binding = 1) buffer SSBO1 +{ + u64vec4 b; + M0 m0; +} ssbo_1; + +layout(std430, binding = 2) buffer SSBO2 +{ + int64_t a[4]; + i64vec2 b[4]; +} ssbo_2; + +layout(std140, binding = 3) buffer SSBO3 +{ + int64_t a[4]; + i64vec2 b[4]; +} ssbo_3; + +void main() +{ + ssbo_0.a += i64vec4(10, 20, 30, 40); + ssbo_1.b += u64vec4(999999999999999999ul, 8888888888888888ul, 77777777777777777ul, 6666666666666666ul); + ssbo_0.a += 20; + ssbo_0.a = abs(ssbo_0.a + i64vec4(ssbo_1.b)); + + ssbo_0.a++; + ssbo_1.b++; + ssbo_0.a--; + ssbo_1.b--; + + ssbo_1.b = doubleBitsToUint64(int64BitsToDouble(ssbo_0.a)); + ssbo_0.a = doubleBitsToInt64(uint64BitsToDouble(ssbo_1.b)); + + ssbo_2.a[0] += 1l; + ssbo_3.a[0] += 2l; +} diff --git a/shaders/desktop-only/frag/hlsl-uav-block-alias.asm.frag b/shaders/desktop-only/frag/hlsl-uav-block-alias.asm.frag new file mode 100644 index 0000000000..1c6dd7b8b7 --- /dev/null +++ b/shaders/desktop-only/frag/hlsl-uav-block-alias.asm.frag @@ -0,0 +1,56 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 2 +; Bound: 29 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %_entryPointOutput + OpExecutionMode %main OriginUpperLeft + OpSource HLSL 500 + OpName %main "main" + OpName %_main_ "@main(" + OpName %Foobar "Foobar" + OpMemberName %Foobar 0 "@data" + OpName %Foobar_0 "Foobar" + OpName %Foobaz "Foobaz" + OpName %_entryPointOutput "@entryPointOutput" + OpDecorate %_runtimearr_v4float ArrayStride 16 + OpMemberDecorate %Foobar 0 Offset 0 + OpDecorate %Foobar BufferBlock + OpDecorate %Foobar_0 DescriptorSet 0 + OpDecorate %Foobar_0 Binding 0 + OpDecorate %Foobaz DescriptorSet 0 + OpDecorate %Foobaz Binding 1 + OpDecorate %_entryPointOutput Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %8 = OpTypeFunction %v4float +%_runtimearr_v4float = OpTypeRuntimeArray %v4float + %Foobar = OpTypeStruct %_runtimearr_v4float +%_ptr_Uniform_Foobar = OpTypePointer Uniform %Foobar + %Foobar_0 = OpVariable %_ptr_Uniform_Foobar Uniform + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 +%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float + %Foobaz = OpVariable %_ptr_Uniform_Foobar Uniform +%_ptr_Output_v4float = OpTypePointer Output %v4float +%_entryPointOutput = OpVariable %_ptr_Output_v4float Output + %main = OpFunction %void None %3 + %5 = OpLabel + %28 = OpFunctionCall %v4float %_main_ + OpStore %_entryPointOutput %28 + OpReturn + OpFunctionEnd + %_main_ = OpFunction %v4float None %8 + %10 = OpLabel + %18 = OpAccessChain %_ptr_Uniform_v4float %Foobar_0 %int_0 %int_0 + %19 = OpLoad %v4float %18 + %21 = OpAccessChain %_ptr_Uniform_v4float %Foobaz %int_0 %int_0 + %22 = OpLoad %v4float %21 + %23 = OpFAdd %v4float %19 %22 + OpReturnValue %23 + OpFunctionEnd diff --git a/shaders/desktop-only/frag/image-ms.desktop.frag b/shaders/desktop-only/frag/image-ms.desktop.frag new file mode 100644 index 0000000000..d3acc3081a --- /dev/null +++ b/shaders/desktop-only/frag/image-ms.desktop.frag @@ -0,0 +1,12 @@ +#version 450 + +layout(rgba8, binding = 0) uniform image2DMS uImage; +layout(rgba8, binding = 1) uniform image2DMSArray uImageArray; + +void main() +{ + vec4 a = imageLoad(uImage, ivec2(1, 2), 2); + vec4 b = imageLoad(uImageArray, ivec3(1, 2, 4), 3); + imageStore(uImage, ivec2(2, 3), 1, a); + imageStore(uImageArray, ivec3(2, 3, 7), 1, b); +} diff --git a/shaders/desktop-only/frag/image-query.desktop.frag b/shaders/desktop-only/frag/image-query.desktop.frag new file mode 100644 index 0000000000..a5cbe011e2 --- /dev/null +++ b/shaders/desktop-only/frag/image-query.desktop.frag @@ -0,0 +1,56 @@ +#version 450 + +layout(binding = 0) uniform sampler1D uSampler1D; +layout(binding = 1) uniform sampler2D uSampler2D; +layout(binding = 2) uniform sampler2DArray uSampler2DArray; +layout(binding = 3) uniform sampler3D uSampler3D; +layout(binding = 4) uniform samplerCube uSamplerCube; +layout(binding = 5) uniform samplerCubeArray uSamplerCubeArray; +layout(binding = 6) uniform samplerBuffer uSamplerBuffer; +layout(binding = 7) uniform sampler2DMS uSamplerMS; +layout(binding = 8) uniform sampler2DMSArray uSamplerMSArray; + +layout(r32f, binding = 9) uniform image1D uImage1D; +layout(r32f, binding = 10) uniform image2D uImage2D; +layout(r32f, binding = 11) uniform image2DArray uImage2DArray; +layout(r32f, binding = 12) uniform image3D uImage3D; +layout(r32f, binding = 13) uniform imageCube uImageCube; +layout(r32f, binding = 14) uniform imageCubeArray uImageCubeArray; +layout(r32f, binding = 15) uniform imageBuffer uImageBuffer; +layout(r32f, binding = 16) uniform image2DMS uImageMS; +layout(r32f, binding = 17) uniform image2DMSArray uImageMSArray; + +void main() +{ + int a = textureSize(uSampler1D, 0); + ivec2 b = textureSize(uSampler2D, 0); + ivec3 c = textureSize(uSampler2DArray, 0); + ivec3 d = textureSize(uSampler3D, 0); + ivec2 e = textureSize(uSamplerCube, 0); + ivec3 f = textureSize(uSamplerCubeArray, 0); + int g = textureSize(uSamplerBuffer); + ivec2 h = textureSize(uSamplerMS); + ivec3 i = textureSize(uSamplerMSArray); + + int l0 = textureQueryLevels(uSampler1D); + int l1 = textureQueryLevels(uSampler2D); + int l2 = textureQueryLevels(uSampler2DArray); + int l3 = textureQueryLevels(uSampler3D); + int l4 = textureQueryLevels(uSamplerCube); + int l5 = textureQueryLevels(uSamplerCubeArray); + + a = imageSize(uImage1D); + b = imageSize(uImage2D); + c = imageSize(uImage2DArray); + d = imageSize(uImage3D); + e = imageSize(uImageCube); + f = imageSize(uImageCubeArray); + g = imageSize(uImageBuffer); + h = imageSize(uImageMS); + i = imageSize(uImageMSArray); + + int s0 = textureSamples(uSamplerMS); + int s1 = textureSamples(uSamplerMSArray); + int s2 = imageSamples(uImageMS); + int s3 = imageSamples(uImageMSArray); +} diff --git a/shaders/desktop-only/frag/in-block-qualifiers.frag b/shaders/desktop-only/frag/in-block-qualifiers.frag new file mode 100644 index 0000000000..f22096e6d1 --- /dev/null +++ b/shaders/desktop-only/frag/in-block-qualifiers.frag @@ -0,0 +1,20 @@ +#version 450 + +layout(location = 0) in VertexData { + flat float f; + centroid vec4 g; + flat int h; + float i; +} vin; + +layout(location = 4) in flat float f; +layout(location = 5) in centroid vec4 g; +layout(location = 6) in flat int h; +layout(location = 7) in sample float i; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = vin.f + vin.g + float(vin.h) + vin.i + f + g + float(h) + i; +} diff --git a/shaders/desktop-only/frag/query-levels.desktop.frag b/shaders/desktop-only/frag/query-levels.desktop.frag new file mode 100644 index 0000000000..3a6977611b --- /dev/null +++ b/shaders/desktop-only/frag/query-levels.desktop.frag @@ -0,0 +1,9 @@ +#version 450 + +layout(binding = 0) uniform sampler2D uSampler; +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = vec4(textureQueryLevels(uSampler)); +} diff --git a/shaders/desktop-only/frag/query-lod.desktop.frag b/shaders/desktop-only/frag/query-lod.desktop.frag new file mode 100644 index 0000000000..0cb160402f --- /dev/null +++ b/shaders/desktop-only/frag/query-lod.desktop.frag @@ -0,0 +1,10 @@ +#version 450 + +layout(location = 0) in vec2 vTexCoord; +layout(binding = 0) uniform sampler2D uSampler; +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = textureQueryLod(uSampler, vTexCoord).xyxy; +} diff --git a/shaders/desktop-only/frag/sampler-ms-query.desktop.frag b/shaders/desktop-only/frag/sampler-ms-query.desktop.frag new file mode 100644 index 0000000000..f707ed5c41 --- /dev/null +++ b/shaders/desktop-only/frag/sampler-ms-query.desktop.frag @@ -0,0 +1,17 @@ +#version 450 + +layout(location = 0) out vec4 FragColor; +layout(binding = 0) uniform sampler2DMS uSampler; +layout(binding = 1) uniform sampler2DMSArray uSamplerArray; +layout(rgba8, binding = 2) uniform image2DMS uImage; +layout(rgba8, binding = 3) uniform image2DMSArray uImageArray; + +void main() +{ + FragColor = + vec4( + textureSamples(uSampler) + + textureSamples(uSamplerArray) + + imageSamples(uImage) + + imageSamples(uImageArray)); +} diff --git a/shaders/desktop-only/frag/texture-proj-shadow.desktop.frag b/shaders/desktop-only/frag/texture-proj-shadow.desktop.frag new file mode 100644 index 0000000000..0c4cf8f5a8 --- /dev/null +++ b/shaders/desktop-only/frag/texture-proj-shadow.desktop.frag @@ -0,0 +1,21 @@ +#version 450 + +layout(binding = 0) uniform sampler1DShadow uShadow1D; +layout(binding = 1) uniform sampler2DShadow uShadow2D; +layout(binding = 2) uniform sampler1D uSampler1D; +layout(binding = 3) uniform sampler2D uSampler2D; +layout(binding = 4) uniform sampler3D uSampler3D; + +layout(location = 0) out float FragColor; +layout(location = 0) in vec3 vClip3; +layout(location = 1) in vec4 vClip4; +layout(location = 2) in vec2 vClip2; + +void main() +{ + FragColor = textureProj(uShadow1D, vClip4); + FragColor = textureProj(uShadow2D, vClip4); + FragColor = textureProj(uSampler1D, vClip2).x; + FragColor = textureProj(uSampler2D, vClip3).x; + FragColor = textureProj(uSampler3D, vClip4).x; +} diff --git a/shaders/desktop-only/geom/basic.desktop.sso.geom b/shaders/desktop-only/geom/basic.desktop.sso.geom new file mode 100644 index 0000000000..f3d331dd15 --- /dev/null +++ b/shaders/desktop-only/geom/basic.desktop.sso.geom @@ -0,0 +1,37 @@ +#version 450 + +layout(triangles, invocations = 4) in; +layout(triangle_strip, max_vertices = 3) out; + +in gl_PerVertex +{ + vec4 gl_Position; +} gl_in[]; + +out gl_PerVertex +{ + vec4 gl_Position; +}; + +layout(location = 0) in VertexData { + vec3 normal; +} vin[]; + +layout(location = 0) out vec3 vNormal; + +void main() +{ + gl_Position = gl_in[0].gl_Position; + vNormal = vin[0].normal + float(gl_InvocationID); + EmitVertex(); + + gl_Position = gl_in[1].gl_Position; + vNormal = vin[1].normal + 4.0 * float(gl_InvocationID); + EmitVertex(); + + gl_Position = gl_in[2].gl_Position; + vNormal = vin[2].normal + 2.0 * float(gl_InvocationID); + EmitVertex(); + + EndPrimitive(); +} diff --git a/shaders/desktop-only/geom/viewport-index.desktop.geom b/shaders/desktop-only/geom/viewport-index.desktop.geom new file mode 100644 index 0000000000..e02e81daf6 --- /dev/null +++ b/shaders/desktop-only/geom/viewport-index.desktop.geom @@ -0,0 +1,11 @@ +#version 450 + +layout(triangles) in; +layout(triangle_strip) out; +layout(max_vertices = 4) out; + +void main() +{ + gl_ViewportIndex = 1; +} + diff --git a/shaders/desktop-only/tesc/basic.desktop.sso.tesc b/shaders/desktop-only/tesc/basic.desktop.sso.tesc new file mode 100644 index 0000000000..8ff739b0af --- /dev/null +++ b/shaders/desktop-only/tesc/basic.desktop.sso.tesc @@ -0,0 +1,28 @@ +#version 450 +layout(vertices = 1) out; + +in gl_PerVertex +{ + vec4 gl_Position; +} gl_in[gl_MaxPatchVertices]; + +out gl_PerVertex +{ + vec4 gl_Position; +} gl_out[1]; + +layout(location = 0) patch out vec3 vFoo; + + +void main() +{ + gl_TessLevelInner[0] = 8.9; + gl_TessLevelInner[1] = 6.9; + gl_TessLevelOuter[0] = 8.9; + gl_TessLevelOuter[1] = 6.9; + gl_TessLevelOuter[2] = 3.9; + gl_TessLevelOuter[3] = 4.9; + vFoo = vec3(1.0); + + gl_out[gl_InvocationID].gl_Position = gl_in[0].gl_Position + gl_in[1].gl_Position; +} diff --git a/shaders/desktop-only/tese/triangle.desktop.sso.tese b/shaders/desktop-only/tese/triangle.desktop.sso.tese new file mode 100644 index 0000000000..c964fbe263 --- /dev/null +++ b/shaders/desktop-only/tese/triangle.desktop.sso.tese @@ -0,0 +1,22 @@ +#version 450 + +layout(cw, triangles, fractional_even_spacing) in; + +in gl_PerVertex +{ + vec4 gl_Position; +} gl_in[gl_MaxPatchVertices]; + +out gl_PerVertex +{ + vec4 gl_Position; +}; + +void main() +{ + gl_Position = + gl_in[0].gl_Position * gl_TessCoord.x + + gl_in[1].gl_Position * gl_TessCoord.y + + gl_in[2].gl_Position * gl_TessCoord.z; +} + diff --git a/shaders/desktop-only/vert/basic.desktop.sso.vert b/shaders/desktop-only/vert/basic.desktop.sso.vert new file mode 100644 index 0000000000..9ddab08cda --- /dev/null +++ b/shaders/desktop-only/vert/basic.desktop.sso.vert @@ -0,0 +1,20 @@ +#version 450 + +out gl_PerVertex +{ + vec4 gl_Position; +}; + +layout(std140) uniform UBO +{ + mat4 uMVP; +}; +layout(location = 0) in vec4 aVertex; +layout(location = 1) in vec3 aNormal; +layout(location = 0) out vec3 vNormal; + +void main() +{ + gl_Position = uMVP * aVertex; + vNormal = aNormal; +} diff --git a/shaders/desktop-only/vert/clip-cull-distance.desktop.vert b/shaders/desktop-only/vert/clip-cull-distance.desktop.vert new file mode 100644 index 0000000000..9e4a0b7ac9 --- /dev/null +++ b/shaders/desktop-only/vert/clip-cull-distance.desktop.vert @@ -0,0 +1,10 @@ +#version 450 + +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; +} diff --git a/shaders/desktop-only/vert/out-block-qualifiers.vert b/shaders/desktop-only/vert/out-block-qualifiers.vert new file mode 100644 index 0000000000..c1e409fb4c --- /dev/null +++ b/shaders/desktop-only/vert/out-block-qualifiers.vert @@ -0,0 +1,26 @@ +#version 450 + +layout(location = 0) out VertexData { + flat float f; + centroid vec4 g; + flat int h; + float i; +} vout; + +layout(location = 4) out flat float f; +layout(location = 5) out centroid vec4 g; +layout(location = 6) out flat int h; +layout(location = 7) out float i; + +void main() +{ + vout.f = 10.0; + vout.g = vec4(20.0); + vout.h = 20; + vout.i = 30.0; + + f = 10.0; + g = vec4(20.0); + h = 20; + i = 30.0; +} diff --git a/shaders/flatten/array.flatten.vert b/shaders/flatten/array.flatten.vert new file mode 100644 index 0000000000..fa6da076c9 --- /dev/null +++ b/shaders/flatten/array.flatten.vert @@ -0,0 +1,19 @@ +#version 310 es + +layout(std140) uniform UBO +{ + vec4 A4[5][4][2]; + mat4 uMVP; + vec4 A1[2]; + vec4 A2[2][3]; + float A3[3]; + vec4 Offset; +}; +layout(location = 0) in vec4 aVertex; + +void main() +{ + vec4 a4 = A4[2][3][1]; // 2 * (4 * 2) + 3 * 2 + 1 = 16 + 6 + 1 = 23. + vec4 offset = A2[1][1] + A1[1] + A3[2]; + gl_Position = uMVP * aVertex + Offset + offset; +} diff --git a/shaders/flatten/basic.flatten.vert b/shaders/flatten/basic.flatten.vert new file mode 100644 index 0000000000..e60a9067b1 --- /dev/null +++ b/shaders/flatten/basic.flatten.vert @@ -0,0 +1,16 @@ +#version 310 es + +layout(std140) uniform UBO +{ + mat4 uMVP; +}; + +layout(location = 0) in vec4 aVertex; +layout(location = 1) in vec3 aNormal; +layout(location = 0) out vec3 vNormal; + +void main() +{ + gl_Position = uMVP * aVertex; + vNormal = aNormal; +} diff --git a/shaders/flatten/copy.flatten.vert b/shaders/flatten/copy.flatten.vert new file mode 100644 index 0000000000..4f1b8805e7 --- /dev/null +++ b/shaders/flatten/copy.flatten.vert @@ -0,0 +1,34 @@ +#version 310 es + +struct Light +{ + vec3 Position; + float Radius; + + vec4 Color; +}; + +layout(std140) uniform UBO +{ + mat4 uMVP; + + Light lights[4]; +}; + +layout(location = 0) in vec4 aVertex; +layout(location = 1) in vec3 aNormal; +layout(location = 0) out vec4 vColor; + +void main() +{ + gl_Position = uMVP * aVertex; + + vColor = vec4(0.0); + + for (int i = 0; i < 4; ++i) + { + Light light = lights[i]; + vec3 L = aVertex.xyz - light.Position; + vColor += dot(aNormal, normalize(L)) * (clamp(1.0 - length(L) / light.Radius, 0.0, 1.0) * lights[i].Color); + } +} diff --git a/shaders/flatten/dynamic.flatten.vert b/shaders/flatten/dynamic.flatten.vert new file mode 100644 index 0000000000..a341d45288 --- /dev/null +++ b/shaders/flatten/dynamic.flatten.vert @@ -0,0 +1,33 @@ +#version 310 es + +struct Light +{ + vec3 Position; + float Radius; + + vec4 Color; +}; + +layout(std140) uniform UBO +{ + mat4 uMVP; + + Light lights[4]; +}; + +layout(location = 0) in vec4 aVertex; +layout(location = 1) in vec3 aNormal; +layout(location = 0) out vec4 vColor; + +void main() +{ + gl_Position = uMVP * aVertex; + + vColor = vec4(0.0); + + for (int i = 0; i < 4; ++i) + { + vec3 L = aVertex.xyz - lights[i].Position; + vColor += dot(aNormal, normalize(L)) * (clamp(1.0 - length(L) / lights[i].Radius, 0.0, 1.0) * lights[i].Color); + } +} diff --git a/shaders/flatten/matrixindex.flatten.vert b/shaders/flatten/matrixindex.flatten.vert new file mode 100644 index 0000000000..0ee7838432 --- /dev/null +++ b/shaders/flatten/matrixindex.flatten.vert @@ -0,0 +1,25 @@ +#version 310 es + +layout(std140) uniform UBO +{ + layout(column_major) mat4 M1C; + layout(row_major) mat4 M1R; + layout(column_major) mat2x4 M2C; + layout(row_major) mat2x4 M2R; +}; + +layout(location = 0) out vec4 oA; +layout(location = 1) out vec4 oB; +layout(location = 2) out vec4 oC; +layout(location = 3) out vec4 oD; +layout(location = 4) out vec4 oE; + +void main() +{ + gl_Position = vec4(0.0); + oA = M1C[1]; + oB = M1R[1]; + oC = M2C[1]; + oD = M2R[0]; + oE = vec4(M1C[1][2], M1R[1][2], M2C[1][2], M2R[1][2]); +} diff --git a/shaders/flatten/multi-dimensional.desktop.flatten_dim.frag b/shaders/flatten/multi-dimensional.desktop.flatten_dim.frag new file mode 100644 index 0000000000..24b2ff1d2a --- /dev/null +++ b/shaders/flatten/multi-dimensional.desktop.flatten_dim.frag @@ -0,0 +1,18 @@ +#version 450 + +layout(location = 0) out vec4 FragColor; +layout(binding = 0) uniform sampler2D uTextures[2][3][1]; +layout(location = 0) flat in int vIndex; +layout(location = 1) in vec2 vUV; + +void main() +{ + vec4 values3[2][3][1]; + + for (int z = 0; z < 2; z++) + for (int y = 0; y < 3; y++) + for (int x = 0; x < 1; x++) + values3[z][y][x] = texture(uTextures[z][y][x], vUV); + + FragColor = values3[1][2][0] + values3[0][2][0] + values3[vIndex + 1][2][vIndex]; +} diff --git a/shaders/flatten/multiindex.flatten.vert b/shaders/flatten/multiindex.flatten.vert new file mode 100644 index 0000000000..0b471d86e0 --- /dev/null +++ b/shaders/flatten/multiindex.flatten.vert @@ -0,0 +1,13 @@ +#version 310 es + +layout(std140) uniform UBO +{ + vec4 Data[3][5]; +}; + +layout(location = 0) in ivec2 aIndex; + +void main() +{ + gl_Position = Data[aIndex.x][aIndex.y]; +} diff --git a/shaders/flatten/push-constant.flatten.vert b/shaders/flatten/push-constant.flatten.vert new file mode 100644 index 0000000000..c7b1b42e1b --- /dev/null +++ b/shaders/flatten/push-constant.flatten.vert @@ -0,0 +1,17 @@ +#version 310 es + +layout(push_constant, std430) uniform PushMe +{ + mat4 MVP; + mat2 Rot; // The MatrixStride will be 8 here. + float Arr[4]; +} registers; + +layout(location = 0) in vec2 Rot; +layout(location = 1) in vec4 Pos; +layout(location = 0) out vec2 vRot; +void main() +{ + gl_Position = registers.MVP * Pos; + vRot = registers.Rot * Rot + registers.Arr[2]; // Constant access should work even if array stride is just 4 here. +} diff --git a/shaders/flatten/rowmajor.flatten.vert b/shaders/flatten/rowmajor.flatten.vert new file mode 100644 index 0000000000..88c468c8f2 --- /dev/null +++ b/shaders/flatten/rowmajor.flatten.vert @@ -0,0 +1,16 @@ +#version 310 es + +layout(std140) uniform UBO +{ + layout(column_major) mat4 uMVPR; + layout(row_major) mat4 uMVPC; + layout(row_major) mat2x4 uMVP; +}; + +layout(location = 0) in vec4 aVertex; + +void main() +{ + vec2 v = aVertex * uMVP; + gl_Position = uMVPR * aVertex + uMVPC * aVertex; +} diff --git a/shaders/flatten/struct.flatten.vert b/shaders/flatten/struct.flatten.vert new file mode 100644 index 0000000000..936bb41b85 --- /dev/null +++ b/shaders/flatten/struct.flatten.vert @@ -0,0 +1,30 @@ +#version 310 es + +struct Light +{ + vec3 Position; + float Radius; + + vec4 Color; +}; + +layout(std140) uniform UBO +{ + mat4 uMVP; + + Light light; +}; + +layout(location = 0) in vec4 aVertex; +layout(location = 1) in vec3 aNormal; +layout(location = 0) out vec4 vColor; + +void main() +{ + gl_Position = uMVP * aVertex; + + vColor = vec4(0.0); + + vec3 L = aVertex.xyz - light.Position; + vColor += dot(aNormal, normalize(L)) * (clamp(1.0 - length(L) / light.Radius, 0.0, 1.0) * light.Color); +} diff --git a/shaders/flatten/struct.rowmajor.flatten.vert b/shaders/flatten/struct.rowmajor.flatten.vert new file mode 100644 index 0000000000..231389b8f4 --- /dev/null +++ b/shaders/flatten/struct.rowmajor.flatten.vert @@ -0,0 +1,26 @@ +#version 310 es + +struct Foo +{ + mat3x4 MVP0; + mat3x4 MVP1; +}; + +layout(std140, binding = 0) uniform UBO +{ + layout(row_major) Foo foo; +}; + +layout(location = 0) in vec4 v0; +layout(location = 1) in vec4 v1; +layout(location = 0) out vec3 V0; +layout(location = 1) out vec3 V1; + +void main() +{ + Foo f = foo; + vec3 a = v0 * f.MVP0; + vec3 b = v1 * f.MVP1; + V0 = a; + V1 = b; +} diff --git a/shaders/flatten/swizzle.flatten.vert b/shaders/flatten/swizzle.flatten.vert new file mode 100644 index 0000000000..fafff7734e --- /dev/null +++ b/shaders/flatten/swizzle.flatten.vert @@ -0,0 +1,47 @@ +#version 310 es + +// comments note the 16b alignment boundaries (see GL spec 7.6.2.2 Standard Uniform Block Layout) +layout(std140, binding = 0) uniform UBO +{ + // 16b boundary + vec4 A; + // 16b boundary + vec2 B0; + vec2 B1; + // 16b boundary + float C0; + // 16b boundary (vec3 is aligned to 16b) + vec3 C1; + // 16b boundary + vec3 D0; + float D1; + // 16b boundary + float E0; + float E1; + float E2; + float E3; + // 16b boundary + float F0; + vec2 F1; + // 16b boundary (vec2 before us is aligned to 8b) + float F2; +}; + +layout(location = 0) out vec4 oA; +layout(location = 1) out vec4 oB; +layout(location = 2) out vec4 oC; +layout(location = 3) out vec4 oD; +layout(location = 4) out vec4 oE; +layout(location = 5) out vec4 oF; + +void main() +{ + gl_Position = vec4(0.0); + + oA = A; + oB = vec4(B0, B1); + oC = vec4(C0, C1); + oD = vec4(D0, D1); + oE = vec4(E0, E1, E2, E3); + oF = vec4(F0, F1, F2); +} diff --git a/shaders/flatten/types.flatten.frag b/shaders/flatten/types.flatten.frag new file mode 100644 index 0000000000..faab5b7e05 --- /dev/null +++ b/shaders/flatten/types.flatten.frag @@ -0,0 +1,27 @@ +#version 310 es +precision mediump float; + +layout(std140, binding = 0) uniform UBO0 +{ + vec4 a; + vec4 b; +}; + +layout(std140, binding = 0) uniform UBO1 +{ + ivec4 c; + ivec4 d; +}; + +layout(std140, binding = 0) uniform UBO2 +{ + uvec4 e; + uvec4 f; +}; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = vec4(c) + vec4(d) + vec4(e) + vec4(f) + a + b; +} diff --git a/shaders/frag/basic.frag b/shaders/frag/basic.frag new file mode 100644 index 0000000000..dd9a8f8507 --- /dev/null +++ b/shaders/frag/basic.frag @@ -0,0 +1,13 @@ +#version 310 es +precision mediump float; + +layout(location = 0) in vec4 vColor; +layout(location = 1) in vec2 vTex; +layout(binding = 0) uniform sampler2D uTex; +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = vColor * texture(uTex, vTex); +} + diff --git a/shaders/frag/composite-extract-forced-temporary.frag b/shaders/frag/composite-extract-forced-temporary.frag new file mode 100644 index 0000000000..35fdbe8624 --- /dev/null +++ b/shaders/frag/composite-extract-forced-temporary.frag @@ -0,0 +1,11 @@ +#version 310 es +precision mediump float; +layout(binding = 0) uniform sampler2D Texture; +layout(location = 0) out vec4 FragColor; +layout(location = 0) in vec2 vTexCoord; + +void main() +{ + float f = texture(Texture, vTexCoord).x; + FragColor = vec4(f * f); +} diff --git a/shaders/frag/constant-array.frag b/shaders/frag/constant-array.frag new file mode 100644 index 0000000000..b862cb1dbf --- /dev/null +++ b/shaders/frag/constant-array.frag @@ -0,0 +1,21 @@ +#version 310 es +precision mediump float; +layout(location = 0) out vec4 FragColor; + +layout(location = 0) flat in int index; + +struct Foobar { float a; float b; }; + +vec4 resolve(Foobar f) +{ + return vec4(f.a + f.b); +} + +void main() +{ + const vec4 foo[3] = vec4[](vec4(1.0), vec4(2.0), vec4(3.0)); + const vec4 foobars[2][2] = vec4[][](vec4[](vec4(1.0), vec4(2.0)), vec4[](vec4(8.0), vec4(10.0))); + const Foobar foos[2] = Foobar[](Foobar(10.0, 40.0), Foobar(90.0, 70.0)); + + FragColor = foo[index] + foobars[index][index + 1] + resolve(Foobar(10.0, 20.0)) + resolve(foos[index]); +} diff --git a/shaders/frag/constant-composites.frag b/shaders/frag/constant-composites.frag new file mode 100644 index 0000000000..a12e22ff4f --- /dev/null +++ b/shaders/frag/constant-composites.frag @@ -0,0 +1,20 @@ +#version 310 es +precision mediump float; + +float lut[4] = float[](1.0, 4.0, 3.0, 2.0); + +struct Foo +{ + float a; + float b; +}; +Foo foos[2] = Foo[](Foo(10.0, 20.0), Foo(30.0, 40.0)); + +layout(location = 0) out vec4 FragColor; +layout(location = 0) flat in int line; + +void main() +{ + FragColor = vec4(lut[line]); + FragColor += foos[line].a * foos[1 - line].a; +} diff --git a/shaders/frag/false-loop-init.frag b/shaders/frag/false-loop-init.frag new file mode 100644 index 0000000000..7ce5b52bd7 --- /dev/null +++ b/shaders/frag/false-loop-init.frag @@ -0,0 +1,19 @@ +#version 310 es +precision mediump float; + +layout(location = 0) in vec4 accum; +layout(location = 0) out vec4 result; + +void main() +{ + result = vec4(0.0); + uint j; + for (int i = 0; i < 4; i += int(j)) + { + if (accum.y > 10.0) + j = 40u; + else + j = 30u; + result += accum; + } +} diff --git a/shaders/frag/flush_params.frag b/shaders/frag/flush_params.frag new file mode 100644 index 0000000000..8a26ad3a28 --- /dev/null +++ b/shaders/frag/flush_params.frag @@ -0,0 +1,27 @@ +#version 310 es +precision mediump float; + +layout(location = 0) out vec4 FragColor; + +struct Structy +{ + vec4 c; +}; + +void foo2(out Structy f) +{ + f.c = vec4(10.0); +} + +Structy foo() +{ + Structy f; + foo2(f); + return f; +} + +void main() +{ + Structy s = foo(); + FragColor = s.c; +} diff --git a/shaders/frag/for-loop-init.frag b/shaders/frag/for-loop-init.frag new file mode 100644 index 0000000000..0cde26765e --- /dev/null +++ b/shaders/frag/for-loop-init.frag @@ -0,0 +1,52 @@ +#version 310 es +precision mediump float; +layout(location = 0) out int FragColor; + +void main() +{ + FragColor = 16; + + // Basic loop variable. + for (int i = 0; i < 25; i++) + FragColor += 10; + + // Multiple loop variables. + for (int i = 1, j = 4; i < 30; i++, j += 4) + FragColor += 11; + + // A potential loop variables, but we access it outside the loop, + // so cannot be one. + int k = 0; + for (; k < 20; k++) + FragColor += 12; + k += 3; + FragColor += k; + + // Potential loop variables, but the dominator is not trivial. + int l; + if (k == 40) + { + for (l = 0; l < 40; l++) + FragColor += 13; + return; + } + else + { + l = k; + FragColor += l; + } + + // Vectors cannot be loop variables + for (ivec2 i = ivec2(0); i.x < 10; i.x += 4) + { + FragColor += i.y; + } + + // Check that static expressions can be used before the loop header. + int m = 0; + m = k; + int o = m; + for (; m < 40; m++) + FragColor += m; + FragColor += o; +} diff --git a/shaders/frag/frexp-modf.frag b/shaders/frag/frexp-modf.frag new file mode 100644 index 0000000000..6a26a4175f --- /dev/null +++ b/shaders/frag/frexp-modf.frag @@ -0,0 +1,24 @@ +#version 310 es +precision mediump float; + +layout(location = 0) out float FragColor; +layout(location = 0) in float v0; +layout(location = 1) in vec2 v1; + +void main() +{ + int e0; + float f0 = frexp(v0, e0); + f0 = frexp(v0 + 1.0, e0); + + ivec2 e1; + vec2 f1 = frexp(v1, e1); + + float r0; + float m0 = modf(v0, r0); + vec2 r1; + vec2 m1 = modf(v1, r1); + + FragColor = f0 + f1.x + f1.y + m0 + m1.x + m1.y; +} + diff --git a/shaders/frag/ground.frag b/shaders/frag/ground.frag new file mode 100755 index 0000000000..d1fcfd4907 --- /dev/null +++ b/shaders/frag/ground.frag @@ -0,0 +1,162 @@ +#version 310 es +precision mediump float; + +#define DEBUG_NONE 0 +#define DEBUG_DIFFUSE 1 +#define DEBUG_SPECULAR 2 +#define DEBUG_LIGHTING 3 +#define DEBUG_FOG 4 +#define DEBUG DEBUG_NONE + +#define FORWARD 0 +#define DEFERRED 1 +#define DEFERRED_VTEX 2 + +float saturate(float x) { return clamp(x, 0.0, 1.0); } + +layout(std140, binding = 4) uniform GlobalPSData +{ + vec4 g_CamPos; + vec4 g_SunDir; + vec4 g_SunColor; + vec4 g_ResolutionParams; + vec4 g_TimeParams; + vec4 g_FogColor_Distance; +}; + +vec4 ComputeFogFactor(vec3 WorldPos) +{ + vec4 FogData; + vec3 vEye = WorldPos - g_CamPos.xyz; + vec3 nEye = normalize(vEye); + FogData.w = exp(-dot(vEye, vEye) * g_FogColor_Distance.w * 0.75); + + float fog_sun_factor = pow(saturate(dot(nEye, g_SunDir.xyz)), 8.0); + FogData.xyz = mix(vec3(1.0, 1.0, 1.0), vec3(0.6, 0.6, 0.9), nEye.y * 0.5 + 0.5); + FogData.xyz = mix(FogData.xyz, vec3(0.95, 0.87, 0.78), fog_sun_factor); + return FogData; +} + +void ApplyFog(inout vec3 Color, vec4 FogData) +{ + Color = mix(FogData.xyz, Color, FogData.w); +} + +void ApplyLighting(inout mediump vec3 Color, mediump float DiffuseFactor) +{ + mediump vec3 DiffuseLight = g_SunColor.xyz * DiffuseFactor; + mediump vec3 AmbientLight = vec3(0.2, 0.35, 0.55) * 0.5; + mediump vec3 Lighting = DiffuseLight + AmbientLight; +#if DEBUG == DEBUG_LIGHTING + Color = Lighting; +#else + Color *= Lighting; +#endif +} + +#define SPECULAR 0 +#define GLOSSMAP 0 + +void ApplySpecular(inout mediump vec3 Color, mediump vec3 EyeVec, mediump vec3 Normal, mediump vec3 SpecularColor, mediump float Shininess, mediump float FresnelAmount) +{ + mediump vec3 HalfAngle = normalize(-EyeVec + g_SunDir.xyz); + + mediump float v_dot_h = saturate(dot(HalfAngle, -EyeVec)); + mediump float n_dot_l = saturate(dot(Normal, g_SunDir.xyz)); + mediump float n_dot_h = saturate(dot(Normal, HalfAngle)); + mediump float n_dot_v = saturate(dot(-EyeVec, Normal)); + mediump float h_dot_l = saturate(dot(g_SunDir.xyz, HalfAngle)); + + const mediump float roughness_value = 0.25; + + mediump float r_sq = roughness_value * roughness_value; + mediump float n_dot_h_sq = n_dot_h * n_dot_h; + mediump float roughness_a = 1.0 / (4.0 * r_sq * n_dot_h_sq * n_dot_h_sq); + mediump float roughness_b = n_dot_h_sq - 1.0; + mediump float roughness_c = r_sq * n_dot_h_sq; + mediump float roughness = saturate(roughness_a * exp(roughness_b / roughness_c)); + + FresnelAmount = 0.5; + mediump float fresnel_term = pow(1.0 - n_dot_v, 5.0) * (1.0 - FresnelAmount) + FresnelAmount; + + mediump float geo_numerator = 2.0 * n_dot_h; + mediump float geo_denominator = 1.0 / v_dot_h; + mediump float geo_term = min(1.0, min(n_dot_v, n_dot_l) * geo_numerator * geo_denominator); + +#if SPECULAR || GLOSSMAP + Color += SpecularColor * g_SunColor.xyz * fresnel_term * roughness * n_dot_l * geo_term / (n_dot_v * n_dot_l + 0.0001); +#endif + + //Color = vec3(0.025 * 1.0 / (n_dot_v * n_dot_l)); +} +layout(location = 0) in vec2 TexCoord; +layout(location = 1) in vec3 EyeVec; + +layout(binding = 2) uniform sampler2D TexNormalmap; +//layout(binding = 3) uniform sampler2D TexScatteringLUT; + +#define DIFFUSE_ONLY 0 +#define GLOBAL_RENDERER DEFERRED +#define OUTPUT_FEEDBACK_TEXTURE 0 + +#if DIFFUSE_ONLY +layout(location = 0) out vec4 ColorOut; +layout(location = 1) out vec4 NormalOut; +#else +layout(location = 0) out vec4 AlbedoOut; +layout(location = 1) out vec4 SpecularOut; +layout(location = 2) out vec4 NormalOut; +layout(location = 3) out vec4 LightingOut; +#endif + +void Resolve(vec3 Albedo, vec3 Normal, float Roughness, float Metallic) +{ +#if (GLOBAL_RENDERER == FORWARD) || OUTPUT_FEEDBACK_TEXTURE + float Lighting = saturate(dot(Normal, normalize(vec3(1.0, 0.5, 1.0)))); + ColorOut.xyz = Albedo * Lighting; + ColorOut.w = 1.0; +#elif DIFFUSE_ONLY + ColorOut = vec4(Albedo, 0.0); + NormalOut.xyz = Normal * 0.5 + 0.5; + NormalOut.w = 1.0; + + // linearize and map to 0..255 range + ColorOut.w = -0.003921569 / (gl_FragCoord.z - 1.003921569); + ColorOut.w = log2(1.0 + saturate(length(EyeVec.xyz) / 200.0)); + ColorOut.w -= 1.0 / 255.0; +#else + LightingOut = vec4(0.0); + NormalOut = vec4(Normal * 0.5 + 0.5, 0.0); + SpecularOut = vec4(Roughness, Metallic, 0.0, 0.0); + AlbedoOut = vec4(Albedo, 1.0); +#endif +} + +void main() +{ + vec3 Normal = texture(TexNormalmap, TexCoord).xyz * 2.0 - 1.0; + Normal = normalize(Normal); + + vec2 scatter_uv; + scatter_uv.x = saturate(length(EyeVec) / 1000.0); + + vec3 nEye = normalize(EyeVec); + scatter_uv.y = 0.0; //nEye.x * 0.5 + 0.5; + + vec3 Color = vec3(0.1, 0.3, 0.1); + vec3 grass = vec3(0.1, 0.3, 0.1); + vec3 dirt = vec3(0.1, 0.1, 0.1); + vec3 snow = vec3(0.8, 0.8, 0.8); + + float grass_snow = smoothstep(0.0, 0.15, (g_CamPos.y + EyeVec.y) / 200.0); + vec3 base = mix(grass, snow, grass_snow); + + float edge = smoothstep(0.7, 0.75, Normal.y); + Color = mix(dirt, base, edge); + Color *= Color; + + float Roughness = 1.0 - edge * grass_snow; + + Resolve(Color, Normal, Roughness, 0.0); +} + diff --git a/shaders/frag/image-load-store-uint-coord.asm.frag b/shaders/frag/image-load-store-uint-coord.asm.frag new file mode 100644 index 0000000000..a9bf1a7497 --- /dev/null +++ b/shaders/frag/image-load-store-uint-coord.asm.frag @@ -0,0 +1,103 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 2 +; Bound: 63 +; Schema: 0 + OpCapability Shader + OpCapability SampledBuffer + OpCapability ImageBuffer + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %_entryPointOutput + OpExecutionMode %main OriginUpperLeft + OpSource HLSL 500 + OpName %main "main" + OpName %_main_ "@main(" + OpName %storeTemp "storeTemp" + OpName %RWIm "RWIm" + OpName %v "v" + OpName %RWBuf "RWBuf" + OpName %ROIm "ROIm" + OpName %ROBuf "ROBuf" + OpName %_entryPointOutput "@entryPointOutput" + OpDecorate %RWIm DescriptorSet 0 + OpDecorate %RWIm Binding 1 + OpDecorate %RWBuf DescriptorSet 0 + OpDecorate %RWBuf Binding 0 + OpDecorate %ROIm DescriptorSet 0 + OpDecorate %ROIm Binding 1 + OpDecorate %ROBuf DescriptorSet 0 + OpDecorate %ROBuf Binding 0 + OpDecorate %_entryPointOutput Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %8 = OpTypeFunction %v4float +%_ptr_Function_v4float = OpTypePointer Function %v4float + %float_10 = OpConstant %float 10 + %float_0_5 = OpConstant %float 0.5 + %float_8 = OpConstant %float 8 + %float_2 = OpConstant %float 2 + %17 = OpConstantComposite %v4float %float_10 %float_0_5 %float_8 %float_2 + %18 = OpTypeImage %float 2D 0 0 0 2 Rgba32f +%_ptr_UniformConstant_18 = OpTypePointer UniformConstant %18 + %RWIm = OpVariable %_ptr_UniformConstant_18 UniformConstant + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 + %uint_10 = OpConstant %uint 10 + %25 = OpConstantComposite %v2uint %uint_10 %uint_10 + %uint_30 = OpConstant %uint 30 + %30 = OpConstantComposite %v2uint %uint_30 %uint_30 + %32 = OpTypeImage %float Buffer 0 0 0 2 Rgba32f +%_ptr_UniformConstant_32 = OpTypePointer UniformConstant %32 + %RWBuf = OpVariable %_ptr_UniformConstant_32 UniformConstant + %uint_80 = OpConstant %uint 80 + %38 = OpTypeImage %float 2D 0 0 0 1 Unknown + %SampledImage = OpTypeSampledImage %38 +%_ptr_UniformConstant_38 = OpTypePointer UniformConstant %SampledImage + %ROIm = OpVariable %_ptr_UniformConstant_38 UniformConstant + %uint_50 = OpConstant %uint 50 + %uint_60 = OpConstant %uint 60 + %44 = OpConstantComposite %v2uint %uint_50 %uint_60 + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %50 = OpTypeImage %float Buffer 0 0 0 1 Rgba32f +%_ptr_UniformConstant_50 = OpTypePointer UniformConstant %50 + %ROBuf = OpVariable %_ptr_UniformConstant_50 UniformConstant +%_ptr_Output_v4float = OpTypePointer Output %v4float +%_entryPointOutput = OpVariable %_ptr_Output_v4float Output + %main = OpFunction %void None %3 + %5 = OpLabel + %62 = OpFunctionCall %v4float %_main_ + OpStore %_entryPointOutput %62 + OpReturn + OpFunctionEnd + %_main_ = OpFunction %v4float None %8 + %10 = OpLabel + %storeTemp = OpVariable %_ptr_Function_v4float Function + %v = OpVariable %_ptr_Function_v4float Function + OpStore %storeTemp %17 + %21 = OpLoad %18 %RWIm + %26 = OpLoad %v4float %storeTemp + OpImageWrite %21 %25 %26 + %28 = OpLoad %18 %RWIm + %31 = OpImageRead %v4float %28 %30 + OpStore %v %31 + %35 = OpLoad %32 %RWBuf + %37 = OpLoad %v4float %v + OpImageWrite %35 %uint_80 %37 + %41 = OpLoad %SampledImage %ROIm + %ROImage = OpImage %38 %41 + %47 = OpImageFetch %v4float %ROImage %44 Lod %int_0 + %48 = OpLoad %v4float %v + %49 = OpFAdd %v4float %48 %47 + OpStore %v %49 + %53 = OpLoad %50 %ROBuf + %54 = OpImageFetch %v4float %53 %uint_80 + %55 = OpLoad %v4float %v + %56 = OpFAdd %v4float %55 %54 + OpStore %v %56 + %57 = OpLoad %v4float %v + OpReturnValue %57 + OpFunctionEnd diff --git a/shaders/frag/mix.frag b/shaders/frag/mix.frag new file mode 100644 index 0000000000..a5d589dd08 --- /dev/null +++ b/shaders/frag/mix.frag @@ -0,0 +1,20 @@ +#version 310 es +precision mediump float; + +layout(location = 0) in vec4 vIn0; +layout(location = 1) in vec4 vIn1; +layout(location = 2) in float vIn2; +layout(location = 3) in float vIn3; +layout(location = 0) out vec4 FragColor; + +void main() +{ + bvec4 l = bvec4(false, true, false, false); + FragColor = mix(vIn0, vIn1, l); + + bool f = true; + FragColor = vec4(mix(vIn2, vIn3, f)); + + FragColor = f ? vIn0 : vIn1; + FragColor = vec4(f ? vIn2 : vIn3); +} diff --git a/shaders/frag/partial-write-preserve.frag b/shaders/frag/partial-write-preserve.frag new file mode 100644 index 0000000000..227df95086 --- /dev/null +++ b/shaders/frag/partial-write-preserve.frag @@ -0,0 +1,95 @@ +#version 310 es +precision mediump float; + +layout(std140, binding = 0) uniform UBO +{ + int some_value; +}; + +struct B +{ + float a; + float b; +}; + +void partial_inout(inout vec4 x) +{ + x.x = 10.0; +} + +void partial_inout(inout B b) +{ + b.b = 40.0; +} + +// Make a complete write, but only conditionally ... +void branchy_inout(inout vec4 v) +{ + v.y = 20.0; + if (some_value == 20) + { + v = vec4(50.0); + } +} + +void branchy_inout(inout B b) +{ + b.b = 20.0; + if (some_value == 20) + { + b = B(10.0, 40.0); + } +} + +void branchy_inout_2(out vec4 v) +{ + if (some_value == 20) + { + v = vec4(50.0); + } + else + { + v = vec4(70.0); + } + v.y = 20.0; +} + +void branchy_inout_2(out B b) +{ + if (some_value == 20) + { + b = B(10.0, 40.0); + } + else + { + b = B(70.0, 70.0); + } + b.b = 20.0; +} + + +void complete_inout(out vec4 x) +{ + x = vec4(50.0); +} + +void complete_inout(out B b) +{ + b = B(100.0, 200.0); +} + +void main() +{ + vec4 a = vec4(10.0); + partial_inout(a); + complete_inout(a); + branchy_inout(a); + branchy_inout_2(a); + + B b = B(10.0, 20.0); + partial_inout(b); + complete_inout(b); + branchy_inout(b); + branchy_inout_2(b); +} + diff --git a/shaders/frag/pls.frag b/shaders/frag/pls.frag new file mode 100644 index 0000000000..e3863e4e0e --- /dev/null +++ b/shaders/frag/pls.frag @@ -0,0 +1,20 @@ +#version 310 es +precision mediump float; + +layout(location = 0) in vec4 PLSIn0; +layout(location = 1) in vec4 PLSIn1; +layout(location = 2) in vec4 PLSIn2; +layout(location = 3) in vec4 PLSIn3; + +layout(location = 0) out vec4 PLSOut0; +layout(location = 1) out vec4 PLSOut1; +layout(location = 2) out vec4 PLSOut2; +layout(location = 3) out vec4 PLSOut3; + +void main() +{ + PLSOut0 = 2.0 * PLSIn0; + PLSOut1 = 6.0 * PLSIn1; + PLSOut2 = 7.0 * PLSIn2; + PLSOut3 = 4.0 * PLSIn3; +} diff --git a/shaders/frag/sample-parameter.frag b/shaders/frag/sample-parameter.frag new file mode 100644 index 0000000000..8470bfd672 --- /dev/null +++ b/shaders/frag/sample-parameter.frag @@ -0,0 +1,11 @@ +#version 310 es +#extension GL_OES_sample_variables : require +precision mediump float; + +layout(location = 0) out vec2 FragColor; + +void main() +{ + FragColor = gl_SamplePosition + vec2(gl_SampleMaskIn[0]) + float(gl_SampleID); + gl_SampleMask[0] = 1; +} diff --git a/shaders/frag/sampler-ms.frag b/shaders/frag/sampler-ms.frag new file mode 100644 index 0000000000..6593928271 --- /dev/null +++ b/shaders/frag/sampler-ms.frag @@ -0,0 +1,16 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(binding = 0) uniform mediump sampler2DMS uSampler; +layout(location = 0) out vec4 FragColor; + +void main() +{ + ivec2 coord = ivec2(gl_FragCoord.xy); + FragColor = + texelFetch(uSampler, coord, 0) + + texelFetch(uSampler, coord, 1) + + texelFetch(uSampler, coord, 2) + + texelFetch(uSampler, coord, 3); +} diff --git a/shaders/frag/sampler-proj.frag b/shaders/frag/sampler-proj.frag new file mode 100644 index 0000000000..21fa5c0260 --- /dev/null +++ b/shaders/frag/sampler-proj.frag @@ -0,0 +1,12 @@ +#version 310 es +precision mediump float; + +layout(location = 0) in vec4 vTex; +layout(binding = 0) uniform sampler2D uTex; +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = textureProj(uTex, vTex); +} + diff --git a/shaders/frag/sampler.frag b/shaders/frag/sampler.frag new file mode 100644 index 0000000000..e38f76886a --- /dev/null +++ b/shaders/frag/sampler.frag @@ -0,0 +1,18 @@ +#version 310 es +precision mediump float; + +layout(location = 0) in vec4 vColor; +layout(location = 1) in vec2 vTex; +layout(binding = 0) uniform sampler2D uTex; +layout(location = 0) out vec4 FragColor; + +vec4 sample_texture(sampler2D tex, vec2 uv) +{ + return texture(tex, uv); +} + +void main() +{ + FragColor = vColor * sample_texture(uTex, vTex); +} + diff --git a/shaders/frag/swizzle.frag b/shaders/frag/swizzle.frag new file mode 100644 index 0000000000..271ba6cb64 --- /dev/null +++ b/shaders/frag/swizzle.frag @@ -0,0 +1,17 @@ +#version 310 es +precision mediump float; + +layout(location = 0) uniform sampler2D samp; +layout(location = 0) out vec4 FragColor; +layout(location = 1) in vec3 vNormal; +layout(location = 2) in vec2 vUV; + +void main() +{ + FragColor = vec4(texture(samp, vUV).xyz, 1.0); + FragColor = vec4(texture(samp, vUV).xz, 1.0, 4.0); + FragColor = vec4(texture(samp, vUV).xx, texture(samp, vUV + vec2(0.1)).yy); + FragColor = vec4(vNormal, 1.0); + FragColor = vec4(vNormal + 1.8, 1.0); + FragColor = vec4(vUV, vUV + 1.8); +} diff --git a/shaders/frag/ubo_layout.frag b/shaders/frag/ubo_layout.frag new file mode 100644 index 0000000000..80f9f16d3d --- /dev/null +++ b/shaders/frag/ubo_layout.frag @@ -0,0 +1,24 @@ +#version 310 es +precision mediump float; + +layout(location = 0) out vec4 FragColor; + +struct Str +{ + mat4 foo; +}; + +layout(binding = 0, std140) uniform UBO1 +{ + layout(row_major) Str foo; +} ubo1; + +layout(binding = 1, std140) uniform UBO2 +{ + layout(column_major) Str foo; +} ubo0; + +void main() +{ + FragColor = ubo1.foo.foo[0] + ubo0.foo.foo[0]; +} diff --git a/shaders/frag/unary-enclose.frag b/shaders/frag/unary-enclose.frag new file mode 100644 index 0000000000..ea502e1de8 --- /dev/null +++ b/shaders/frag/unary-enclose.frag @@ -0,0 +1,15 @@ +#version 310 es +precision mediump float; + +layout(location = 0) out vec4 FragColor; +layout(location = 0) in vec4 vIn; +layout(location = 1) flat in ivec4 vIn1; + +void main() +{ + FragColor = +(-(-vIn)); + ivec4 a = ~(~vIn1); + + bool b = false; + b = !!b; +} diff --git a/shaders/geom/basic.geom b/shaders/geom/basic.geom new file mode 100644 index 0000000000..80b977d114 --- /dev/null +++ b/shaders/geom/basic.geom @@ -0,0 +1,28 @@ +#version 310 es +#extension GL_EXT_geometry_shader : require + +layout(triangles, invocations = 4) in; +layout(triangle_strip, max_vertices = 3) out; + +layout(location = 0) in VertexData { + vec3 normal; +} vin[]; + +layout(location = 0) out vec3 vNormal; + +void main() +{ + gl_Position = gl_in[0].gl_Position; + vNormal = vin[0].normal + float(gl_InvocationID); + EmitVertex(); + + gl_Position = gl_in[1].gl_Position; + vNormal = vin[1].normal + 4.0 * float(gl_InvocationID); + EmitVertex(); + + gl_Position = gl_in[2].gl_Position; + vNormal = vin[2].normal + 2.0 * float(gl_InvocationID); + EmitVertex(); + + EndPrimitive(); +} diff --git a/shaders/geom/lines-adjacency.geom b/shaders/geom/lines-adjacency.geom new file mode 100644 index 0000000000..4c34440737 --- /dev/null +++ b/shaders/geom/lines-adjacency.geom @@ -0,0 +1,28 @@ +#version 310 es +#extension GL_EXT_geometry_shader : require + +layout(lines_adjacency) in; +layout(line_strip, max_vertices = 3) out; + +layout(location = 0) in VertexData { + vec3 normal; +} vin[]; + +layout(location = 0) out vec3 vNormal; + +void main() +{ + gl_Position = gl_in[0].gl_Position; + vNormal = vin[0].normal; + EmitVertex(); + + gl_Position = gl_in[1].gl_Position; + vNormal = vin[1].normal; + EmitVertex(); + + gl_Position = gl_in[2].gl_Position; + vNormal = vin[2].normal; + EmitVertex(); + + EndPrimitive(); +} diff --git a/shaders/geom/lines.geom b/shaders/geom/lines.geom new file mode 100644 index 0000000000..c751d5cda4 --- /dev/null +++ b/shaders/geom/lines.geom @@ -0,0 +1,24 @@ +#version 310 es +#extension GL_EXT_geometry_shader : require + +layout(lines) in; +layout(line_strip, max_vertices = 2) out; + +layout(location = 0) in VertexData { + vec3 normal; +} vin[]; + +layout(location = 0) out vec3 vNormal; + +void main() +{ + gl_Position = gl_in[0].gl_Position; + vNormal = vin[0].normal; + EmitVertex(); + + gl_Position = gl_in[1].gl_Position; + vNormal = vin[1].normal; + EmitVertex(); + + EndPrimitive(); +} diff --git a/shaders/geom/points.geom b/shaders/geom/points.geom new file mode 100644 index 0000000000..f7dce10d7f --- /dev/null +++ b/shaders/geom/points.geom @@ -0,0 +1,28 @@ +#version 310 es +#extension GL_EXT_geometry_shader : require + +layout(points) in; +layout(points, max_vertices = 3) out; + +layout(location = 0) in VertexData { + vec3 normal; +} vin[]; + +layout(location = 0) out vec3 vNormal; + +void main() +{ + gl_Position = gl_in[0].gl_Position; + vNormal = vin[0].normal; + EmitVertex(); + + gl_Position = gl_in[0].gl_Position; + vNormal = vin[0].normal; + EmitVertex(); + + gl_Position = gl_in[0].gl_Position; + vNormal = vin[0].normal; + EmitVertex(); + + EndPrimitive(); +} diff --git a/shaders/geom/single-invocation.geom b/shaders/geom/single-invocation.geom new file mode 100644 index 0000000000..c3c8d1526f --- /dev/null +++ b/shaders/geom/single-invocation.geom @@ -0,0 +1,28 @@ +#version 310 es +#extension GL_EXT_geometry_shader : require + +layout(triangles) in; +layout(triangle_strip, max_vertices = 3) out; + +layout(location = 0) in VertexData { + vec3 normal; +} vin[]; + +layout(location = 0) out vec3 vNormal; + +void main() +{ + gl_Position = gl_in[0].gl_Position; + vNormal = vin[0].normal; + EmitVertex(); + + gl_Position = gl_in[1].gl_Position; + vNormal = vin[1].normal; + EmitVertex(); + + gl_Position = gl_in[2].gl_Position; + vNormal = vin[2].normal; + EmitVertex(); + + EndPrimitive(); +} diff --git a/shaders/geom/triangles-adjacency.geom b/shaders/geom/triangles-adjacency.geom new file mode 100644 index 0000000000..017cef7b52 --- /dev/null +++ b/shaders/geom/triangles-adjacency.geom @@ -0,0 +1,28 @@ +#version 310 es +#extension GL_EXT_geometry_shader : require + +layout(triangles_adjacency) in; +layout(triangle_strip, max_vertices = 3) out; + +layout(location = 0) in VertexData { + vec3 normal; +} vin[]; + +layout(location = 0) out vec3 vNormal; + +void main() +{ + gl_Position = gl_in[0].gl_Position; + vNormal = vin[0].normal; + EmitVertex(); + + gl_Position = gl_in[1].gl_Position; + vNormal = vin[1].normal; + EmitVertex(); + + gl_Position = gl_in[2].gl_Position; + vNormal = vin[2].normal; + EmitVertex(); + + EndPrimitive(); +} diff --git a/shaders/geom/triangles.geom b/shaders/geom/triangles.geom new file mode 100644 index 0000000000..c3c8d1526f --- /dev/null +++ b/shaders/geom/triangles.geom @@ -0,0 +1,28 @@ +#version 310 es +#extension GL_EXT_geometry_shader : require + +layout(triangles) in; +layout(triangle_strip, max_vertices = 3) out; + +layout(location = 0) in VertexData { + vec3 normal; +} vin[]; + +layout(location = 0) out vec3 vNormal; + +void main() +{ + gl_Position = gl_in[0].gl_Position; + vNormal = vin[0].normal; + EmitVertex(); + + gl_Position = gl_in[1].gl_Position; + vNormal = vin[1].normal; + EmitVertex(); + + gl_Position = gl_in[2].gl_Position; + vNormal = vin[2].normal; + EmitVertex(); + + EndPrimitive(); +} diff --git a/shaders/legacy/fragment/explicit-lod.legacy.frag b/shaders/legacy/fragment/explicit-lod.legacy.frag new file mode 100644 index 0000000000..5a2eeb9913 --- /dev/null +++ b/shaders/legacy/fragment/explicit-lod.legacy.frag @@ -0,0 +1,12 @@ +#version 310 es + +precision mediump float; + +uniform sampler2D tex; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = textureLod(tex, vec2(0.4, 0.6), 0.0); +} diff --git a/shaders/legacy/fragment/io-blocks.legacy.frag b/shaders/legacy/fragment/io-blocks.legacy.frag new file mode 100644 index 0000000000..0a151dc2d6 --- /dev/null +++ b/shaders/legacy/fragment/io-blocks.legacy.frag @@ -0,0 +1,16 @@ +#version 310 es +#extension GL_EXT_shader_io_blocks : require +precision mediump float; + +layout(location = 1) in VertexOut +{ + vec4 color; + highp vec3 normal; +} vin; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = vin.color + vin.normal.xyzz; +} diff --git a/shaders/legacy/fragment/struct-varying.legacy.frag b/shaders/legacy/fragment/struct-varying.legacy.frag new file mode 100644 index 0000000000..5df5c87704 --- /dev/null +++ b/shaders/legacy/fragment/struct-varying.legacy.frag @@ -0,0 +1,25 @@ +#version 310 es +precision highp float; + +struct Inputs +{ + vec4 a; + vec2 b; +}; + +layout(location = 0) in Inputs vin; +layout(location = 0) out vec4 FragColor; + +void main() +{ + // Read struct once. + Inputs v0 = vin; + // Read struct again. + Inputs v1 = vin; + + // Read members individually. + vec4 a = vin.a; + vec4 b = vin.b.xxyy; + + FragColor = v0.a + v0.b.xxyy + v1.a + v1.b.yyxx + a + b; +} diff --git a/shaders/legacy/vert/implicit-lod.legacy.vert b/shaders/legacy/vert/implicit-lod.legacy.vert new file mode 100644 index 0000000000..1f32faebdc --- /dev/null +++ b/shaders/legacy/vert/implicit-lod.legacy.vert @@ -0,0 +1,8 @@ +#version 310 es + +uniform sampler2D tex; + +void main() +{ + gl_Position = texture(tex, vec2(0.4, 0.6)); +} diff --git a/shaders/legacy/vert/io-block.legacy.vert b/shaders/legacy/vert/io-block.legacy.vert new file mode 100644 index 0000000000..4fbc9347cf --- /dev/null +++ b/shaders/legacy/vert/io-block.legacy.vert @@ -0,0 +1,17 @@ +#version 310 es +#extension GL_EXT_shader_io_blocks : require + +layout(location = 0) out VertexOut +{ + vec4 color; + vec3 normal; +} vout; + +layout(location = 0) in vec4 Position; + +void main() +{ + gl_Position = Position; + vout.color = vec4(1.0); + vout.normal = vec3(0.5); +} diff --git a/shaders/legacy/vert/struct-varying.legacy.vert b/shaders/legacy/vert/struct-varying.legacy.vert new file mode 100644 index 0000000000..3f491be831 --- /dev/null +++ b/shaders/legacy/vert/struct-varying.legacy.vert @@ -0,0 +1,33 @@ +#version 310 es + +struct Output +{ + vec4 a; + vec2 b; +}; + +layout(location = 0) out Output vout; + +void main() +{ + Output s = Output(vec4(0.5), vec2(0.25)); + + // Write whole struct. + vout = s; + // Write whole struct again, checks for scoping. + vout = s; + + // Read it back. + Output tmp = vout; + + // Write elements individually. + vout.a = tmp.a; + vout.b = tmp.b; + + // Write individual elements. + vout.a.x = 1.0; + vout.b.y = 1.0; + + // Read individual elements. + float c = vout.a.x; +} diff --git a/shaders/legacy/vert/transpose.legacy.vert b/shaders/legacy/vert/transpose.legacy.vert new file mode 100644 index 0000000000..84f618262a --- /dev/null +++ b/shaders/legacy/vert/transpose.legacy.vert @@ -0,0 +1,20 @@ +#version 310 es + +uniform Buffer +{ + layout(row_major) mat4 MVPRowMajor; + layout(column_major) mat4 MVPColMajor; + mat4 M; +}; + +layout(location = 0) in vec4 Position; + +void main() +{ + vec4 c0 = M * (MVPRowMajor * Position); + vec4 c1 = M * (MVPColMajor * Position); + vec4 c2 = M * (Position * MVPRowMajor); + vec4 c3 = M * (Position * MVPColMajor); + gl_Position = c0 + c1 + c2 + c3; +} + diff --git a/shaders/tesc/basic.tesc b/shaders/tesc/basic.tesc new file mode 100644 index 0000000000..0a41f98c83 --- /dev/null +++ b/shaders/tesc/basic.tesc @@ -0,0 +1,17 @@ +#version 310 es +#extension GL_EXT_tessellation_shader : require + +layout(location = 0) patch out vec3 vFoo; + +layout(vertices = 1) out; + +void main() +{ + gl_TessLevelInner[0] = 8.9; + gl_TessLevelInner[1] = 6.9; + gl_TessLevelOuter[0] = 8.9; + gl_TessLevelOuter[1] = 6.9; + gl_TessLevelOuter[2] = 3.9; + gl_TessLevelOuter[3] = 4.9; + vFoo = vec3(1.0); +} diff --git a/shaders/tesc/water_tess.tesc b/shaders/tesc/water_tess.tesc new file mode 100644 index 0000000000..3ecdc3d1a9 --- /dev/null +++ b/shaders/tesc/water_tess.tesc @@ -0,0 +1,115 @@ +#version 310 es +#extension GL_EXT_tessellation_shader : require + +layout(vertices = 1) out; +layout(location = 0) in vec2 vPatchPosBase[]; + +layout(std140) uniform UBO +{ + vec4 uScale; + highp vec3 uCamPos; + vec2 uPatchSize; + vec2 uMaxTessLevel; + float uDistanceMod; + vec4 uFrustum[6]; +}; + +layout(location = 1) patch out vec2 vOutPatchPosBase; +layout(location = 2) patch out vec4 vPatchLods; + +float lod_factor(vec2 pos_) +{ + vec2 pos = pos_ * uScale.xy; + vec3 dist_to_cam = uCamPos - vec3(pos.x, 0.0, pos.y); + float level = log2((length(dist_to_cam) + 0.0001) * uDistanceMod); + return clamp(level, 0.0, uMaxTessLevel.x); +} + +float tess_level(float lod) +{ + return uMaxTessLevel.y * exp2(-lod); +} + +vec4 tess_level(vec4 lod) +{ + return uMaxTessLevel.y * exp2(-lod); +} + +// Guard band for vertex displacement. +#define GUARD_BAND 10.0 +bool frustum_cull(vec2 p0) +{ + vec2 min_xz = (p0 - GUARD_BAND) * uScale.xy; + vec2 max_xz = (p0 + uPatchSize + GUARD_BAND) * uScale.xy; + + vec3 bb_min = vec3(min_xz.x, -GUARD_BAND, min_xz.y); + vec3 bb_max = vec3(max_xz.x, +GUARD_BAND, max_xz.y); + vec3 center = 0.5 * (bb_min + bb_max); + float radius = 0.5 * length(bb_max - bb_min); + + vec3 f0 = vec3( + dot(uFrustum[0], vec4(center, 1.0)), + dot(uFrustum[1], vec4(center, 1.0)), + dot(uFrustum[2], vec4(center, 1.0))); + + vec3 f1 = vec3( + dot(uFrustum[3], vec4(center, 1.0)), + dot(uFrustum[4], vec4(center, 1.0)), + dot(uFrustum[5], vec4(center, 1.0))); + + return !(any(lessThanEqual(f0, vec3(-radius))) || any(lessThanEqual(f1, vec3(-radius)))); +} + +void compute_tess_levels(vec2 p0) +{ + vOutPatchPosBase = p0; + + float l00 = lod_factor(p0 + vec2(-0.5, -0.5) * uPatchSize); + float l10 = lod_factor(p0 + vec2(+0.5, -0.5) * uPatchSize); + float l20 = lod_factor(p0 + vec2(+1.5, -0.5) * uPatchSize); + float l01 = lod_factor(p0 + vec2(-0.5, +0.5) * uPatchSize); + float l11 = lod_factor(p0 + vec2(+0.5, +0.5) * uPatchSize); + float l21 = lod_factor(p0 + vec2(+1.5, +0.5) * uPatchSize); + float l02 = lod_factor(p0 + vec2(-0.5, +1.5) * uPatchSize); + float l12 = lod_factor(p0 + vec2(+0.5, +1.5) * uPatchSize); + float l22 = lod_factor(p0 + vec2(+1.5, +1.5) * uPatchSize); + + vec4 lods = vec4( + dot(vec4(l01, l11, l02, l12), vec4(0.25)), + dot(vec4(l00, l10, l01, l11), vec4(0.25)), + dot(vec4(l10, l20, l11, l21), vec4(0.25)), + dot(vec4(l11, l21, l12, l22), vec4(0.25))); + + vPatchLods = lods; + + vec4 outer_lods = min(lods.xyzw, lods.yzwx); + vec4 levels = tess_level(outer_lods); + gl_TessLevelOuter[0] = levels.x; + gl_TessLevelOuter[1] = levels.y; + gl_TessLevelOuter[2] = levels.z; + gl_TessLevelOuter[3] = levels.w; + + float min_lod = min(min(lods.x, lods.y), min(lods.z, lods.w)); + float inner = tess_level(min(min_lod, l11)); + gl_TessLevelInner[0] = inner; + gl_TessLevelInner[1] = inner; +} + +void main() +{ + vec2 p0 = vPatchPosBase[0]; + if (!frustum_cull(p0)) + { + gl_TessLevelOuter[0] = -1.0; + gl_TessLevelOuter[1] = -1.0; + gl_TessLevelOuter[2] = -1.0; + gl_TessLevelOuter[3] = -1.0; + gl_TessLevelInner[0] = -1.0; + gl_TessLevelInner[1] = -1.0; + } + else + { + compute_tess_levels(p0); + } +} + diff --git a/shaders/tese/ccw.tese b/shaders/tese/ccw.tese new file mode 100644 index 0000000000..26e9cc698d --- /dev/null +++ b/shaders/tese/ccw.tese @@ -0,0 +1,10 @@ +#version 310 es +#extension GL_EXT_tessellation_shader : require + +layout(ccw, triangles, fractional_even_spacing) in; + +void main() +{ + gl_Position = vec4(1.0); +} + diff --git a/shaders/tese/cw.tese b/shaders/tese/cw.tese new file mode 100644 index 0000000000..6ce7c2d6d9 --- /dev/null +++ b/shaders/tese/cw.tese @@ -0,0 +1,10 @@ +#version 310 es +#extension GL_EXT_tessellation_shader : require + +layout(cw, triangles, fractional_even_spacing) in; + +void main() +{ + gl_Position = vec4(1.0); +} + diff --git a/shaders/tese/equal.tese b/shaders/tese/equal.tese new file mode 100644 index 0000000000..08ab36ec23 --- /dev/null +++ b/shaders/tese/equal.tese @@ -0,0 +1,10 @@ +#version 310 es +#extension GL_EXT_tessellation_shader : require + +layout(cw, triangles, equal_spacing) in; + +void main() +{ + gl_Position = vec4(1.0); +} + diff --git a/shaders/tese/fractional_even.tese b/shaders/tese/fractional_even.tese new file mode 100644 index 0000000000..6ce7c2d6d9 --- /dev/null +++ b/shaders/tese/fractional_even.tese @@ -0,0 +1,10 @@ +#version 310 es +#extension GL_EXT_tessellation_shader : require + +layout(cw, triangles, fractional_even_spacing) in; + +void main() +{ + gl_Position = vec4(1.0); +} + diff --git a/shaders/tese/fractional_odd.tese b/shaders/tese/fractional_odd.tese new file mode 100644 index 0000000000..a15a32926b --- /dev/null +++ b/shaders/tese/fractional_odd.tese @@ -0,0 +1,10 @@ +#version 310 es +#extension GL_EXT_tessellation_shader : require + +layout(cw, triangles, fractional_odd_spacing) in; + +void main() +{ + gl_Position = vec4(1.0); +} + diff --git a/shaders/tese/line.tese b/shaders/tese/line.tese new file mode 100644 index 0000000000..b4237ef559 --- /dev/null +++ b/shaders/tese/line.tese @@ -0,0 +1,10 @@ +#version 310 es +#extension GL_EXT_tessellation_shader : require + +layout(isolines, point_mode, fractional_even_spacing) in; + +void main() +{ + gl_Position = vec4(1.0); +} + diff --git a/shaders/tese/triangle.tese b/shaders/tese/triangle.tese new file mode 100644 index 0000000000..6ce7c2d6d9 --- /dev/null +++ b/shaders/tese/triangle.tese @@ -0,0 +1,10 @@ +#version 310 es +#extension GL_EXT_tessellation_shader : require + +layout(cw, triangles, fractional_even_spacing) in; + +void main() +{ + gl_Position = vec4(1.0); +} + diff --git a/shaders/tese/water_tess.tese b/shaders/tese/water_tess.tese new file mode 100644 index 0000000000..32d6bc9391 --- /dev/null +++ b/shaders/tese/water_tess.tese @@ -0,0 +1,65 @@ +#version 310 es +#extension GL_EXT_tessellation_shader : require +precision highp int; + +layout(cw, quads, fractional_even_spacing) in; + +layout(location = 0) patch in vec2 vOutPatchPosBase; +layout(location = 1) patch in vec4 vPatchLods; + +layout(binding = 1, std140) uniform UBO +{ + mat4 uMVP; + vec4 uScale; + vec2 uInvScale; + vec3 uCamPos; + vec2 uPatchSize; + vec2 uInvHeightmapSize; +}; +layout(binding = 0) uniform mediump sampler2D uHeightmapDisplacement; + +layout(location = 0) highp out vec3 vWorld; +layout(location = 1) highp out vec4 vGradNormalTex; + +vec2 lerp_vertex(vec2 tess_coord) +{ + return vOutPatchPosBase + tess_coord * uPatchSize; +} + +mediump vec2 lod_factor(vec2 tess_coord) +{ + mediump vec2 x = mix(vPatchLods.yx, vPatchLods.zw, tess_coord.x); + mediump float level = mix(x.x, x.y, tess_coord.y); + mediump float floor_level = floor(level); + mediump float fract_level = level - floor_level; + return vec2(floor_level, fract_level); +} + +mediump vec3 sample_height_displacement(vec2 uv, vec2 off, mediump vec2 lod) +{ + return mix( + textureLod(uHeightmapDisplacement, uv + 0.5 * off, lod.x).xyz, + textureLod(uHeightmapDisplacement, uv + 1.0 * off, lod.x + 1.0).xyz, + lod.y); +} + +void main() +{ + vec2 tess_coord = gl_TessCoord.xy; + vec2 pos = lerp_vertex(tess_coord); + mediump vec2 lod = lod_factor(tess_coord); + + vec2 tex = pos * uInvHeightmapSize.xy; + pos *= uScale.xy; + + mediump float delta_mod = exp2(lod.x); + vec2 off = uInvHeightmapSize.xy * delta_mod; + + vGradNormalTex = vec4(tex + 0.5 * uInvHeightmapSize.xy, tex * uScale.zw); + vec3 height_displacement = sample_height_displacement(tex, off, lod); + + pos += height_displacement.yz; + vWorld = vec3(pos.x, height_displacement.x, pos.y); + gl_Position = uMVP * vec4(vWorld, 1.0); +} + diff --git a/shaders/vert/basic.vert b/shaders/vert/basic.vert new file mode 100644 index 0000000000..2c75d44a43 --- /dev/null +++ b/shaders/vert/basic.vert @@ -0,0 +1,16 @@ +#version 310 es + +layout(std140) uniform UBO +{ + uniform mat4 uMVP; +}; + +layout(location = 0) in vec4 aVertex; +layout(location = 1) in vec3 aNormal; +layout(location = 0) out vec3 vNormal; + +void main() +{ + gl_Position = uMVP * aVertex; + vNormal = aNormal; +} diff --git a/shaders/vert/ground.vert b/shaders/vert/ground.vert new file mode 100755 index 0000000000..2deeb5a94b --- /dev/null +++ b/shaders/vert/ground.vert @@ -0,0 +1,202 @@ +#version 310 es + +#define YFLIP 0 +#define SPECULAR 0 +#define GLOSSMAP 0 + +#define DEBUG_NONE 0 +#define DEBUG_DIFFUSE 1 +#define DEBUG_SPECULAR 2 +#define DEBUG_LIGHTING 3 +#define DEBUG_FOG 4 +#define DEBUG DEBUG_NONE + +#define FORWARD 0 +#define DEFERRED 1 +#define DEFERRED_VTEX 2 + +float saturate(float x) { return clamp(x, 0.0, 1.0); } + +layout(std140, binding = 0) uniform GlobalVSData +{ + vec4 g_ViewProj_Row0; + vec4 g_ViewProj_Row1; + vec4 g_ViewProj_Row2; + vec4 g_ViewProj_Row3; + vec4 g_CamPos; + vec4 g_CamRight; + vec4 g_CamUp; + vec4 g_CamFront; + vec4 g_SunDir; + vec4 g_SunColor; + vec4 g_TimeParams; + vec4 g_ResolutionParams; + vec4 g_CamAxisRight; + vec4 g_FogColor_Distance; + vec4 g_ShadowVP_Row0; + vec4 g_ShadowVP_Row1; + vec4 g_ShadowVP_Row2; + vec4 g_ShadowVP_Row3; +}; + +vec4 ComputeFogFactor(vec3 WorldPos) +{ + vec4 FogData; + vec3 vEye = WorldPos - g_CamPos.xyz; + vec3 nEye = normalize(vEye); + FogData.w = exp(-dot(vEye, vEye) * g_FogColor_Distance.w * 0.75); + + float fog_sun_factor = pow(saturate(dot(nEye, g_SunDir.xyz)), 8.0); + FogData.xyz = mix(vec3(1.0, 1.0, 1.0), vec3(0.6, 0.6, 0.9), nEye.y * 0.5 + 0.5); + FogData.xyz = mix(FogData.xyz, vec3(0.95, 0.87, 0.78), fog_sun_factor); + return FogData; +} + +void ApplyFog(inout vec3 Color, vec4 FogData) +{ + Color = mix(FogData.xyz, Color, FogData.w); +} + +void ApplyLighting(inout mediump vec3 Color, mediump float DiffuseFactor) +{ + mediump vec3 DiffuseLight = g_SunColor.xyz * DiffuseFactor; + mediump vec3 AmbientLight = vec3(0.2, 0.35, 0.55) * 0.5; + mediump vec3 Lighting = DiffuseLight + AmbientLight; +#if DEBUG == DEBUG_LIGHTING + Color = Lighting; +#else + Color *= Lighting; +#endif +} + +#pragma VARIANT SPECULAR +#pragma VARIANT GLOSSMAP + +void ApplySpecular(inout mediump vec3 Color, mediump vec3 EyeVec, mediump vec3 Normal, mediump vec3 SpecularColor, mediump float Shininess, mediump float FresnelAmount) +{ + mediump vec3 HalfAngle = normalize(-EyeVec + g_SunDir.xyz); + + mediump float v_dot_h = saturate(dot(HalfAngle, -EyeVec)); + mediump float n_dot_l = saturate(dot(Normal, g_SunDir.xyz)); + mediump float n_dot_h = saturate(dot(Normal, HalfAngle)); + mediump float n_dot_v = saturate(dot(-EyeVec, Normal)); + mediump float h_dot_l = saturate(dot(g_SunDir.xyz, HalfAngle)); + + const mediump float roughness_value = 0.25; + + mediump float r_sq = roughness_value * roughness_value; + mediump float n_dot_h_sq = n_dot_h * n_dot_h; + mediump float roughness_a = 1.0 / (4.0 * r_sq * n_dot_h_sq * n_dot_h_sq); + mediump float roughness_b = n_dot_h_sq - 1.0; + mediump float roughness_c = r_sq * n_dot_h_sq; + mediump float roughness = saturate(roughness_a * exp(roughness_b / roughness_c)); + + FresnelAmount = 0.5; + mediump float fresnel_term = pow(1.0 - n_dot_v, 5.0) * (1.0 - FresnelAmount) + FresnelAmount; + + mediump float geo_numerator = 2.0 * n_dot_h; + mediump float geo_denominator = 1.0 / v_dot_h; + mediump float geo_term = min(1.0, min(n_dot_v, n_dot_l) * geo_numerator * geo_denominator); + +#if SPECULAR || GLOSSMAP + Color += SpecularColor * g_SunColor.xyz * fresnel_term * roughness * n_dot_l * geo_term / (n_dot_v * n_dot_l + 0.0001); +#endif + + //Color = vec3(0.025 * 1.0 / (n_dot_v * n_dot_l)); +} + +layout(location = 0) in vec2 Position; +layout(location = 1) in vec4 LODWeights; + +layout(location = 0) out vec2 TexCoord; +layout(location = 1) out vec3 EyeVec; + +layout(std140, binding = 2) uniform GlobalGround +{ + vec4 GroundScale; + vec4 GroundPosition; + vec4 InvGroundSize_PatchScale; +}; + +struct PatchData +{ + vec4 Position; + vec4 LODs; +}; + +layout(std140, binding = 0) uniform PerPatch +{ + PatchData Patches[256]; +}; + +layout(binding = 0) uniform sampler2D TexHeightmap; +layout(binding = 1) uniform sampler2D TexLOD; + +vec2 lod_factor(vec2 uv) +{ + float level = textureLod(TexLOD, uv, 0.0).x * (255.0 / 32.0); + float floor_level = floor(level); + float fract_level = level - floor_level; + return vec2(floor_level, fract_level); +} + +#ifdef VULKAN +#define INSTANCE_ID gl_InstanceIndex +#else +#define INSTANCE_ID gl_InstanceID +#endif + +vec2 warp_position() +{ + float vlod = dot(LODWeights, Patches[INSTANCE_ID].LODs); + vlod = mix(vlod, Patches[INSTANCE_ID].Position.w, all(equal(LODWeights, vec4(0.0)))); + +#ifdef DEBUG_LOD_HEIGHT + LODFactor = vec4(vlod); +#endif + + float floor_lod = floor(vlod); + float fract_lod = vlod - floor_lod; + uint ufloor_lod = uint(floor_lod); + +#ifdef DEBUG_LOD_HEIGHT + LODFactor = vec4(fract_lod); +#endif + + uvec2 uPosition = uvec2(Position); + uvec2 mask = (uvec2(1u) << uvec2(ufloor_lod, ufloor_lod + 1u)) - 1u; + //uvec2 rounding = mix(uvec2(0u), mask, lessThan(uPosition, uvec2(32u))); + + uvec2 rounding = uvec2( + uPosition.x < 32u ? mask.x : 0u, + uPosition.y < 32u ? mask.y : 0u); + + vec4 lower_upper_snapped = vec4((uPosition + rounding).xyxy & (~mask).xxyy); + return mix(lower_upper_snapped.xy, lower_upper_snapped.zw, fract_lod); +} + +void main() +{ + vec2 PatchPos = Patches[INSTANCE_ID].Position.xz * InvGroundSize_PatchScale.zw; + vec2 WarpedPos = warp_position(); + vec2 VertexPos = PatchPos + WarpedPos; + vec2 NormalizedPos = VertexPos * InvGroundSize_PatchScale.xy; + vec2 lod = lod_factor(NormalizedPos); + + vec2 Offset = exp2(lod.x) * InvGroundSize_PatchScale.xy; + + float Elevation = + mix(textureLod(TexHeightmap, NormalizedPos + 0.5 * Offset, lod.x).x, + textureLod(TexHeightmap, NormalizedPos + 1.0 * Offset, lod.x + 1.0).x, + lod.y); + + vec3 WorldPos = vec3(NormalizedPos.x, Elevation, NormalizedPos.y); + WorldPos *= GroundScale.xyz; + WorldPos += GroundPosition.xyz; + + EyeVec = WorldPos - g_CamPos.xyz; + TexCoord = NormalizedPos + 0.5 * InvGroundSize_PatchScale.xy; + + gl_Position = WorldPos.x * g_ViewProj_Row0 + WorldPos.y * g_ViewProj_Row1 + WorldPos.z * g_ViewProj_Row2 + g_ViewProj_Row3; +} + diff --git a/shaders/vert/ocean.vert b/shaders/vert/ocean.vert new file mode 100644 index 0000000000..8a5677fa12 --- /dev/null +++ b/shaders/vert/ocean.vert @@ -0,0 +1,200 @@ +#version 310 es + +#define YFLIP 0 +#define SPECULAR 0 +#define GLOSSMAP 0 + +#define DEBUG_NONE 0 +#define DEBUG_DIFFUSE 1 +#define DEBUG_SPECULAR 2 +#define DEBUG_LIGHTING 3 +#define DEBUG_FOG 4 +#define DEBUG DEBUG_NONE + +#define FORWARD 0 +#define DEFERRED 1 +#define DEFERRED_VTEX 2 + +float saturate(float x) { return clamp(x, 0.0, 1.0); } + +layout(std140, binding = 0) uniform GlobalVSData +{ + vec4 g_ViewProj_Row0; + vec4 g_ViewProj_Row1; + vec4 g_ViewProj_Row2; + vec4 g_ViewProj_Row3; + vec4 g_CamPos; + vec4 g_CamRight; + vec4 g_CamUp; + vec4 g_CamFront; + vec4 g_SunDir; + vec4 g_SunColor; + vec4 g_TimeParams; + vec4 g_ResolutionParams; + vec4 g_CamAxisRight; + vec4 g_FogColor_Distance; + vec4 g_ShadowVP_Row0; + vec4 g_ShadowVP_Row1; + vec4 g_ShadowVP_Row2; + vec4 g_ShadowVP_Row3; +}; + +vec4 ComputeFogFactor(vec3 WorldPos) +{ + vec4 FogData; + vec3 vEye = WorldPos - g_CamPos.xyz; + vec3 nEye = normalize(vEye); + FogData.w = exp(-dot(vEye, vEye) * g_FogColor_Distance.w * 0.75); + + float fog_sun_factor = pow(saturate(dot(nEye, g_SunDir.xyz)), 8.0); + FogData.xyz = mix(vec3(1.0, 1.0, 1.0), vec3(0.6, 0.6, 0.9), nEye.y * 0.5 + 0.5); + FogData.xyz = mix(FogData.xyz, vec3(0.95, 0.87, 0.78), fog_sun_factor); + return FogData; +} + +void ApplyFog(inout vec3 Color, vec4 FogData) +{ + Color = mix(FogData.xyz, Color, FogData.w); +} + +void ApplyLighting(inout mediump vec3 Color, mediump float DiffuseFactor) +{ + mediump vec3 DiffuseLight = g_SunColor.xyz * DiffuseFactor; + mediump vec3 AmbientLight = vec3(0.2, 0.35, 0.55) * 0.5; + mediump vec3 Lighting = DiffuseLight + AmbientLight; +#if DEBUG == DEBUG_LIGHTING + Color = Lighting; +#else + Color *= Lighting; +#endif +} + +void ApplySpecular(inout mediump vec3 Color, mediump vec3 EyeVec, mediump vec3 Normal, mediump vec3 SpecularColor, mediump float Shininess, mediump float FresnelAmount) +{ + mediump vec3 HalfAngle = normalize(-EyeVec + g_SunDir.xyz); + + mediump float v_dot_h = saturate(dot(HalfAngle, -EyeVec)); + mediump float n_dot_l = saturate(dot(Normal, g_SunDir.xyz)); + mediump float n_dot_h = saturate(dot(Normal, HalfAngle)); + mediump float n_dot_v = saturate(dot(-EyeVec, Normal)); + mediump float h_dot_l = saturate(dot(g_SunDir.xyz, HalfAngle)); + + const mediump float roughness_value = 0.25; + + mediump float r_sq = roughness_value * roughness_value; + mediump float n_dot_h_sq = n_dot_h * n_dot_h; + mediump float roughness_a = 1.0 / (4.0 * r_sq * n_dot_h_sq * n_dot_h_sq); + mediump float roughness_b = n_dot_h_sq - 1.0; + mediump float roughness_c = r_sq * n_dot_h_sq; + mediump float roughness = saturate(roughness_a * exp(roughness_b / roughness_c)); + + FresnelAmount = 0.5; + mediump float fresnel_term = pow(1.0 - n_dot_v, 5.0) * (1.0 - FresnelAmount) + FresnelAmount; + + mediump float geo_numerator = 2.0 * n_dot_h; + mediump float geo_denominator = 1.0 / v_dot_h; + mediump float geo_term = min(1.0, min(n_dot_v, n_dot_l) * geo_numerator * geo_denominator); + +#if SPECULAR || GLOSSMAP + Color += SpecularColor * g_SunColor.xyz * fresnel_term * roughness * n_dot_l * geo_term / (n_dot_v * n_dot_l + 0.0001); +#endif + + //Color = vec3(0.025 * 1.0 / (n_dot_v * n_dot_l)); +} + + +precision highp int; + +layout(binding = 0) uniform mediump sampler2D TexDisplacement; +layout(binding = 1) uniform mediump sampler2D TexLOD; + +layout(location = 0) in vec4 Position; +layout(location = 1) in vec4 LODWeights; + +layout(location = 0) out highp vec3 EyeVec; +layout(location = 1) out highp vec4 TexCoord; + +layout(std140, binding = 4) uniform GlobalOcean +{ + vec4 OceanScale; + vec4 OceanPosition; + vec4 InvOceanSize_PatchScale; + vec4 NormalTexCoordScale; +}; + +struct PatchData +{ + vec4 Position; + vec4 LODs; +}; + +layout(std140, binding = 0) uniform Offsets +{ + PatchData Patches[256]; +}; + +vec2 lod_factor(vec2 uv) +{ + float level = textureLod(TexLOD, uv, 0.0).x * (255.0 / 32.0); + float floor_level = floor(level); + float fract_level = level - floor_level; + return vec2(floor_level, fract_level); +} + +#ifdef VULKAN +#define INSTANCE_ID gl_InstanceIndex +#else +#define INSTANCE_ID gl_InstanceID +#endif + +vec2 warp_position() +{ + float vlod = dot(LODWeights, Patches[INSTANCE_ID].LODs); + vlod = mix(vlod, Patches[INSTANCE_ID].Position.w, all(equal(LODWeights, vec4(0.0)))); + + float floor_lod = floor(vlod); + float fract_lod = vlod - floor_lod; + uint ufloor_lod = uint(floor_lod); + + uvec4 uPosition = uvec4(Position); + uvec2 mask = (uvec2(1u) << uvec2(ufloor_lod, ufloor_lod + 1u)) - 1u; + + uvec4 rounding; + rounding.x = uPosition.x < 32u ? mask.x : 0u; + rounding.y = uPosition.y < 32u ? mask.x : 0u; + rounding.z = uPosition.x < 32u ? mask.y : 0u; + rounding.w = uPosition.y < 32u ? mask.y : 0u; + + //rounding = uPosition.xyxy * mask.xxyy; + vec4 lower_upper_snapped = vec4((uPosition.xyxy + rounding) & (~mask).xxyy); + return mix(lower_upper_snapped.xy, lower_upper_snapped.zw, fract_lod); +} + +void main() +{ + vec2 PatchPos = Patches[INSTANCE_ID].Position.xz * InvOceanSize_PatchScale.zw; + vec2 WarpedPos = warp_position(); + vec2 VertexPos = PatchPos + WarpedPos; + vec2 NormalizedPos = VertexPos * InvOceanSize_PatchScale.xy; + vec2 NormalizedTex = NormalizedPos * NormalTexCoordScale.zw; + vec2 lod = lod_factor(NormalizedPos); + vec2 Offset = exp2(lod.x) * InvOceanSize_PatchScale.xy * NormalTexCoordScale.zw; + + vec3 Displacement = + mix(textureLod(TexDisplacement, NormalizedTex + 0.5 * Offset, lod.x).yxz, + textureLod(TexDisplacement, NormalizedTex + 1.0 * Offset, lod.x + 1.0).yxz, + lod.y); + + vec3 WorldPos = vec3(NormalizedPos.x, 0.0, NormalizedPos.y) + Displacement; + WorldPos *= OceanScale.xyz; + WorldPos += OceanPosition.xyz; + + EyeVec = WorldPos - g_CamPos.xyz; + TexCoord = vec4(NormalizedTex, NormalizedTex * NormalTexCoordScale.xy) + 0.5 * InvOceanSize_PatchScale.xyxy * NormalTexCoordScale.zwzw; + + gl_Position = WorldPos.x * g_ViewProj_Row0 + WorldPos.y * g_ViewProj_Row1 + WorldPos.z * g_ViewProj_Row2 + g_ViewProj_Row3; +#if YFLIP + gl_Position *= vec4(1.0, -1.0, 1.0, 1.0); +#endif +} + diff --git a/shaders/vert/texture_buffer.vert b/shaders/vert/texture_buffer.vert new file mode 100644 index 0000000000..6bc7ddfae2 --- /dev/null +++ b/shaders/vert/texture_buffer.vert @@ -0,0 +1,10 @@ +#version 310 es +#extension GL_OES_texture_buffer : require + +layout(binding = 4) uniform highp samplerBuffer uSamp; +layout(rgba32f, binding = 5) uniform readonly highp imageBuffer uSampo; + +void main() +{ + gl_Position = texelFetch(uSamp, 10) + imageLoad(uSampo, 100); +} diff --git a/shaders/vert/ubo.vert b/shaders/vert/ubo.vert new file mode 100644 index 0000000000..82e4626e12 --- /dev/null +++ b/shaders/vert/ubo.vert @@ -0,0 +1,16 @@ +#version 310 es + +layout(binding = 0, std140) uniform UBO +{ + mat4 mvp; +}; + +layout(location = 0) in vec4 aVertex; +layout(location = 1) in vec3 aNormal; +layout(location = 0) out vec3 vNormal; + +void main() +{ + gl_Position = mvp * aVertex; + vNormal = aNormal; +} diff --git a/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag b/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag new file mode 100644 index 0000000000..2fabb5ea8a --- /dev/null +++ b/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag @@ -0,0 +1,29 @@ +#version 310 es +precision mediump float; + +layout(set = 0, binding = 0) uniform mediump samplerShadow uSampler; +layout(set = 0, binding = 1) uniform mediump sampler uSampler1; +layout(set = 0, binding = 2) uniform texture2D uDepth; +layout(location = 0) out float FragColor; + +float samp2(texture2D t, mediump samplerShadow s) +{ + return texture(sampler2DShadow(t, s), vec3(1.0)); +} + +float samp3(texture2D t, mediump sampler s) +{ + return texture(sampler2D(t, s), vec2(1.0)).x; +} + +float samp(texture2D t, mediump samplerShadow s, mediump sampler s1) +{ + float r0 = samp2(t, s); + float r1 = samp3(t, s1); + return r0 + r1; +} + +void main() +{ + FragColor = samp(uDepth, uSampler, uSampler1); +} diff --git a/shaders/vulkan/frag/combined-texture-sampler.vk.frag b/shaders/vulkan/frag/combined-texture-sampler.vk.frag new file mode 100644 index 0000000000..b7de8d47e9 --- /dev/null +++ b/shaders/vulkan/frag/combined-texture-sampler.vk.frag @@ -0,0 +1,47 @@ +#version 310 es +precision mediump float; + +layout(set = 0, binding = 0) uniform mediump sampler uSampler0; +layout(set = 0, binding = 1) uniform mediump sampler uSampler1; +layout(set = 0, binding = 2) uniform mediump texture2D uTexture0; +layout(set = 0, binding = 3) uniform mediump texture2D uTexture1; + +layout(location = 0) out vec4 FragColor; +layout(location = 0) in vec2 vTex; + +vec4 sample_dual(mediump sampler samp, mediump texture2D tex) +{ + return texture(sampler2D(tex, samp), vTex); +} + +vec4 sample_global_tex(mediump sampler samp) +{ + vec4 a = texture(sampler2D(uTexture0, samp), vTex); + vec4 b = sample_dual(samp, uTexture1); + return a + b; +} + +vec4 sample_global_sampler(mediump texture2D tex) +{ + vec4 a = texture(sampler2D(tex, uSampler0), vTex); + vec4 b = sample_dual(uSampler1, tex); + return a + b; +} + +vec4 sample_duals() +{ + vec4 a = sample_dual(uSampler0, uTexture0); + vec4 b = sample_dual(uSampler1, uTexture1); + return a + b; +} + +void main() +{ + vec4 c0 = sample_duals(); + vec4 c1 = sample_global_tex(uSampler0); + vec4 c2 = sample_global_tex(uSampler1); + vec4 c3 = sample_global_sampler(uTexture0); + vec4 c4 = sample_global_sampler(uTexture1); + + FragColor = c0 + c1 + c2 + c3 + c4; +} diff --git a/shaders/vulkan/frag/desktop-mediump.vk.frag b/shaders/vulkan/frag/desktop-mediump.vk.frag new file mode 100644 index 0000000000..23fe3d3da0 --- /dev/null +++ b/shaders/vulkan/frag/desktop-mediump.vk.frag @@ -0,0 +1,11 @@ +#version 450 + +layout(location = 0) in mediump vec4 F; +layout(location = 1) flat in mediump ivec4 I; +layout(location = 2) flat in mediump uvec4 U; +layout(location = 0) out mediump vec4 FragColor; + +void main() +{ + FragColor = F + vec4(I) + vec4(U); +} diff --git a/shaders/vulkan/frag/input-attachment-ms.vk.frag b/shaders/vulkan/frag/input-attachment-ms.vk.frag new file mode 100644 index 0000000000..e060738846 --- /dev/null +++ b/shaders/vulkan/frag/input-attachment-ms.vk.frag @@ -0,0 +1,10 @@ +#version 450 + +layout(input_attachment_index = 0, set = 0, binding = 0) uniform subpassInputMS uSubpass0; +layout(input_attachment_index = 1, set = 0, binding = 1) uniform subpassInputMS uSubpass1; +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = subpassLoad(uSubpass0, 1) + subpassLoad(uSubpass1, 2) + subpassLoad(uSubpass0, gl_SampleID); +} diff --git a/shaders/vulkan/frag/input-attachment.vk.frag b/shaders/vulkan/frag/input-attachment.vk.frag new file mode 100644 index 0000000000..f082d15b2a --- /dev/null +++ b/shaders/vulkan/frag/input-attachment.vk.frag @@ -0,0 +1,11 @@ +#version 310 es +precision mediump float; + +layout(input_attachment_index = 0, set = 0, binding = 0) uniform mediump subpassInput uSubpass0; +layout(input_attachment_index = 1, set = 0, binding = 1) uniform mediump subpassInput uSubpass1; +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = subpassLoad(uSubpass0) + subpassLoad(uSubpass1); +} diff --git a/shaders/vulkan/frag/push-constant.vk.frag b/shaders/vulkan/frag/push-constant.vk.frag new file mode 100644 index 0000000000..6180faba31 --- /dev/null +++ b/shaders/vulkan/frag/push-constant.vk.frag @@ -0,0 +1,16 @@ +#version 310 es +precision mediump float; + +layout(push_constant, std430) uniform PushConstants +{ + vec4 value0; + vec4 value1; +} push; + +layout(location = 0) in vec4 vColor; +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = vColor + push.value0 + push.value1; +} diff --git a/shaders/vulkan/frag/separate-sampler-texture.vk.frag b/shaders/vulkan/frag/separate-sampler-texture.vk.frag new file mode 100644 index 0000000000..cedf114ef8 --- /dev/null +++ b/shaders/vulkan/frag/separate-sampler-texture.vk.frag @@ -0,0 +1,36 @@ +#version 310 es +precision mediump float; + +layout(set = 0, binding = 0) uniform mediump sampler uSampler; +layout(set = 0, binding = 1) uniform mediump texture2D uTexture; +layout(set = 0, binding = 2) uniform mediump texture3D uTexture3D; +layout(set = 0, binding = 3) uniform mediump textureCube uTextureCube; +layout(set = 0, binding = 4) uniform mediump texture2DArray uTextureArray; + +layout(location = 0) out vec4 FragColor; +layout(location = 0) in vec2 vTex; +layout(location = 1) in vec3 vTex3; + +vec4 sample_func(mediump sampler samp, vec2 uv) +{ + return texture(sampler2D(uTexture, samp), uv); +} + +vec4 sample_func_dual(mediump sampler samp, mediump texture2D tex, vec2 uv) +{ + return texture(sampler2D(tex, samp), uv); +} + +void main() +{ + vec2 off = 1.0 / vec2(textureSize(sampler2D(uTexture, uSampler), 0)); + vec2 off2 = 1.0 / vec2(textureSize(sampler2D(uTexture, uSampler), 1)); + + vec4 c0 = sample_func(uSampler, vTex + off + off2); + vec4 c1 = sample_func_dual(uSampler, uTexture, vTex + off + off2); + vec4 c2 = texture(sampler2DArray(uTextureArray, uSampler), vTex3); + vec4 c3 = texture(samplerCube(uTextureCube, uSampler), vTex3); + vec4 c4 = texture(sampler3D(uTexture3D, uSampler), vTex3); + + FragColor = c0 + c1 + c2 + c3 + c4; +} diff --git a/shaders/vulkan/frag/spec-constant.vk.frag b/shaders/vulkan/frag/spec-constant.vk.frag new file mode 100644 index 0000000000..2002c1272e --- /dev/null +++ b/shaders/vulkan/frag/spec-constant.vk.frag @@ -0,0 +1,77 @@ +#version 310 es +precision mediump float; + +layout(location = 0) out vec4 FragColor; +layout(constant_id = 1) const float a = 1.0; +layout(constant_id = 2) const float b = 2.0; +layout(constant_id = 3) const int c = 3; +layout(constant_id = 4) const int d = 4; +layout(constant_id = 5) const uint e = 5u; +layout(constant_id = 6) const uint f = 6u; +layout(constant_id = 7) const bool g = false; +layout(constant_id = 8) const bool h = true; +// glslang doesn't seem to support partial spec constants or composites yet, so only test the basics. + +struct Foo +{ + float elems[d + 2]; +}; + +void main() +{ + float t0 = a; + float t1 = b; + + uint c0 = uint(c); // OpIAdd with different types. + // FConvert, float-to-double. + int c1 = -c; // SNegate + int c2 = ~c; // OpNot + int c3 = c + d; // OpIAdd + int c4 = c - d; // OpISub + int c5 = c * d; // OpIMul + int c6 = c / d; // OpSDiv + uint c7 = e / f; // OpUDiv + int c8 = c % d; // OpSMod + uint c9 = e % f; // OpUMod + // TODO: OpSRem, any way to access this in GLSL? + int c10 = c >> d; // OpShiftRightArithmetic + uint c11 = e >> f; // OpShiftRightLogical + int c12 = c << d; // OpShiftLeftLogical + int c13 = c | d; // OpBitwiseOr + int c14 = c ^ d; // OpBitwiseXor + int c15 = c & d; // OpBitwiseAnd + // VectorShuffle, CompositeExtract, CompositeInsert, not testable atm. + bool c16 = g || h; // OpLogicalOr + bool c17 = g && h; // OpLogicalAnd + bool c18 = !g; // OpLogicalNot + bool c19 = g == h; // OpLogicalEqual + bool c20 = g != h; // OpLogicalNotEqual + // OpSelect not testable atm. + bool c21 = c == d; // OpIEqual + bool c22 = c != d; // OpINotEqual + bool c23 = c < d; // OpSLessThan + bool c24 = e < f; // OpULessThan + bool c25 = c > d; // OpSGreaterThan + bool c26 = e > f; // OpUGreaterThan + bool c27 = c <= d; // OpSLessThanEqual + bool c28 = e <= f; // OpULessThanEqual + bool c29 = c >= d; // OpSGreaterThanEqual + bool c30 = e >= f; // OpUGreaterThanEqual + // OpQuantizeToF16 not testable atm. + + int c31 = c8 + c3; + + int c32 = int(e); // OpIAdd with different types. + bool c33 = bool(c); // int -> bool + bool c34 = bool(e); // uint -> bool + int c35 = int(g); // bool -> int + uint c36 = uint(g); // bool -> uint + float c37 = float(g); // bool -> float + + // Flexible sized arrays with spec constants and spec constant ops. + float vec0[c + 3][8]; + float vec1[c + 2]; + + Foo foo; + FragColor = vec4(t0 + t1) + vec0[0][0] + vec1[0] + foo.elems[c]; +} diff --git a/shaders/vulkan/vert/multiview.nocompat.vk.vert b/shaders/vulkan/vert/multiview.nocompat.vk.vert new file mode 100644 index 0000000000..eb1bc766f2 --- /dev/null +++ b/shaders/vulkan/vert/multiview.nocompat.vk.vert @@ -0,0 +1,14 @@ +#version 310 es +#extension GL_EXT_multiview : require + +layout(std140, binding = 0) uniform MVPs +{ + mat4 MVP[2]; +}; + +layout(location = 0) in vec4 Position; + +void main() +{ + gl_Position = MVP[gl_ViewIndex] * Position; +} diff --git a/shaders/vulkan/vert/vulkan-vertex.vk.vert b/shaders/vulkan/vert/vulkan-vertex.vk.vert new file mode 100644 index 0000000000..4d0438ace6 --- /dev/null +++ b/shaders/vulkan/vert/vulkan-vertex.vk.vert @@ -0,0 +1,6 @@ +#version 310 es + +void main() +{ + gl_Position = float(gl_VertexIndex + gl_InstanceIndex) * vec4(1.0, 2.0, 3.0, 4.0); +} diff --git a/spirv.hpp b/spirv.hpp new file mode 100644 index 0000000000..efa1dbdf0e --- /dev/null +++ b/spirv.hpp @@ -0,0 +1,968 @@ +// Copyright (c) 2014-2017 The Khronos Group Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and/or associated documentation files (the "Materials"), +// to deal in the Materials without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Materials, and to permit persons to whom the +// Materials are furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Materials. +// +// MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS +// STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND +// HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ +// +// THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM,OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS +// IN THE MATERIALS. + +// This header is automatically generated by the same tool that creates +// the Binary Section of the SPIR-V specification. + +// Enumeration tokens for SPIR-V, in various styles: +// C, C++, C++11, JSON, Lua, Python +// +// - C will have tokens with a "Spv" prefix, e.g.: SpvSourceLanguageGLSL +// - C++ will have tokens in the "spv" name space, e.g.: spv::SourceLanguageGLSL +// - C++11 will use enum classes in the spv namespace, e.g.: spv::SourceLanguage::GLSL +// - Lua will use tables, e.g.: spv.SourceLanguage.GLSL +// - Python will use dictionaries, e.g.: spv['SourceLanguage']['GLSL'] +// +// Some tokens act like mask values, which can be OR'd together, +// while others are mutually exclusive. The mask-like ones have +// "Mask" in their name, and a parallel enum that has the shift +// amount (1 << x) for each corresponding enumerant. + +#ifndef spirv_HPP +#define spirv_HPP + +namespace spv { + +typedef unsigned int Id; + +#define SPV_VERSION 0x10000 +#define SPV_REVISION 10 + +static const unsigned int MagicNumber = 0x07230203; +static const unsigned int Version = 0x00010000; +static const unsigned int Revision = 10; +static const unsigned int OpCodeMask = 0xffff; +static const unsigned int WordCountShift = 16; + +enum SourceLanguage { + SourceLanguageUnknown = 0, + SourceLanguageESSL = 1, + SourceLanguageGLSL = 2, + SourceLanguageOpenCL_C = 3, + SourceLanguageOpenCL_CPP = 4, + SourceLanguageHLSL = 5, + SourceLanguageMax = 0x7fffffff, +}; + +enum ExecutionModel { + ExecutionModelVertex = 0, + ExecutionModelTessellationControl = 1, + ExecutionModelTessellationEvaluation = 2, + ExecutionModelGeometry = 3, + ExecutionModelFragment = 4, + ExecutionModelGLCompute = 5, + ExecutionModelKernel = 6, + ExecutionModelMax = 0x7fffffff, +}; + +enum AddressingModel { + AddressingModelLogical = 0, + AddressingModelPhysical32 = 1, + AddressingModelPhysical64 = 2, + AddressingModelMax = 0x7fffffff, +}; + +enum MemoryModel { + MemoryModelSimple = 0, + MemoryModelGLSL450 = 1, + MemoryModelOpenCL = 2, + MemoryModelMax = 0x7fffffff, +}; + +enum ExecutionMode { + ExecutionModeInvocations = 0, + ExecutionModeSpacingEqual = 1, + ExecutionModeSpacingFractionalEven = 2, + ExecutionModeSpacingFractionalOdd = 3, + ExecutionModeVertexOrderCw = 4, + ExecutionModeVertexOrderCcw = 5, + ExecutionModePixelCenterInteger = 6, + ExecutionModeOriginUpperLeft = 7, + ExecutionModeOriginLowerLeft = 8, + ExecutionModeEarlyFragmentTests = 9, + ExecutionModePointMode = 10, + ExecutionModeXfb = 11, + ExecutionModeDepthReplacing = 12, + ExecutionModeDepthGreater = 14, + ExecutionModeDepthLess = 15, + ExecutionModeDepthUnchanged = 16, + ExecutionModeLocalSize = 17, + ExecutionModeLocalSizeHint = 18, + ExecutionModeInputPoints = 19, + ExecutionModeInputLines = 20, + ExecutionModeInputLinesAdjacency = 21, + ExecutionModeTriangles = 22, + ExecutionModeInputTrianglesAdjacency = 23, + ExecutionModeQuads = 24, + ExecutionModeIsolines = 25, + ExecutionModeOutputVertices = 26, + ExecutionModeOutputPoints = 27, + ExecutionModeOutputLineStrip = 28, + ExecutionModeOutputTriangleStrip = 29, + ExecutionModeVecTypeHint = 30, + ExecutionModeContractionOff = 31, + ExecutionModeMax = 0x7fffffff, +}; + +enum StorageClass { + StorageClassUniformConstant = 0, + StorageClassInput = 1, + StorageClassUniform = 2, + StorageClassOutput = 3, + StorageClassWorkgroup = 4, + StorageClassCrossWorkgroup = 5, + StorageClassPrivate = 6, + StorageClassFunction = 7, + StorageClassGeneric = 8, + StorageClassPushConstant = 9, + StorageClassAtomicCounter = 10, + StorageClassImage = 11, + StorageClassStorageBuffer = 12, + StorageClassMax = 0x7fffffff, +}; + +enum Dim { + Dim1D = 0, + Dim2D = 1, + Dim3D = 2, + DimCube = 3, + DimRect = 4, + DimBuffer = 5, + DimSubpassData = 6, + DimMax = 0x7fffffff, +}; + +enum SamplerAddressingMode { + SamplerAddressingModeNone = 0, + SamplerAddressingModeClampToEdge = 1, + SamplerAddressingModeClamp = 2, + SamplerAddressingModeRepeat = 3, + SamplerAddressingModeRepeatMirrored = 4, + SamplerAddressingModeMax = 0x7fffffff, +}; + +enum SamplerFilterMode { + SamplerFilterModeNearest = 0, + SamplerFilterModeLinear = 1, + SamplerFilterModeMax = 0x7fffffff, +}; + +enum ImageFormat { + ImageFormatUnknown = 0, + ImageFormatRgba32f = 1, + ImageFormatRgba16f = 2, + ImageFormatR32f = 3, + ImageFormatRgba8 = 4, + ImageFormatRgba8Snorm = 5, + ImageFormatRg32f = 6, + ImageFormatRg16f = 7, + ImageFormatR11fG11fB10f = 8, + ImageFormatR16f = 9, + ImageFormatRgba16 = 10, + ImageFormatRgb10A2 = 11, + ImageFormatRg16 = 12, + ImageFormatRg8 = 13, + ImageFormatR16 = 14, + ImageFormatR8 = 15, + ImageFormatRgba16Snorm = 16, + ImageFormatRg16Snorm = 17, + ImageFormatRg8Snorm = 18, + ImageFormatR16Snorm = 19, + ImageFormatR8Snorm = 20, + ImageFormatRgba32i = 21, + ImageFormatRgba16i = 22, + ImageFormatRgba8i = 23, + ImageFormatR32i = 24, + ImageFormatRg32i = 25, + ImageFormatRg16i = 26, + ImageFormatRg8i = 27, + ImageFormatR16i = 28, + ImageFormatR8i = 29, + ImageFormatRgba32ui = 30, + ImageFormatRgba16ui = 31, + ImageFormatRgba8ui = 32, + ImageFormatR32ui = 33, + ImageFormatRgb10a2ui = 34, + ImageFormatRg32ui = 35, + ImageFormatRg16ui = 36, + ImageFormatRg8ui = 37, + ImageFormatR16ui = 38, + ImageFormatR8ui = 39, + ImageFormatMax = 0x7fffffff, +}; + +enum ImageChannelOrder { + ImageChannelOrderR = 0, + ImageChannelOrderA = 1, + ImageChannelOrderRG = 2, + ImageChannelOrderRA = 3, + ImageChannelOrderRGB = 4, + ImageChannelOrderRGBA = 5, + ImageChannelOrderBGRA = 6, + ImageChannelOrderARGB = 7, + ImageChannelOrderIntensity = 8, + ImageChannelOrderLuminance = 9, + ImageChannelOrderRx = 10, + ImageChannelOrderRGx = 11, + ImageChannelOrderRGBx = 12, + ImageChannelOrderDepth = 13, + ImageChannelOrderDepthStencil = 14, + ImageChannelOrdersRGB = 15, + ImageChannelOrdersRGBx = 16, + ImageChannelOrdersRGBA = 17, + ImageChannelOrdersBGRA = 18, + ImageChannelOrderABGR = 19, + ImageChannelOrderMax = 0x7fffffff, +}; + +enum ImageChannelDataType { + ImageChannelDataTypeSnormInt8 = 0, + ImageChannelDataTypeSnormInt16 = 1, + ImageChannelDataTypeUnormInt8 = 2, + ImageChannelDataTypeUnormInt16 = 3, + ImageChannelDataTypeUnormShort565 = 4, + ImageChannelDataTypeUnormShort555 = 5, + ImageChannelDataTypeUnormInt101010 = 6, + ImageChannelDataTypeSignedInt8 = 7, + ImageChannelDataTypeSignedInt16 = 8, + ImageChannelDataTypeSignedInt32 = 9, + ImageChannelDataTypeUnsignedInt8 = 10, + ImageChannelDataTypeUnsignedInt16 = 11, + ImageChannelDataTypeUnsignedInt32 = 12, + ImageChannelDataTypeHalfFloat = 13, + ImageChannelDataTypeFloat = 14, + ImageChannelDataTypeUnormInt24 = 15, + ImageChannelDataTypeUnormInt101010_2 = 16, + ImageChannelDataTypeMax = 0x7fffffff, +}; + +enum ImageOperandsShift { + ImageOperandsBiasShift = 0, + ImageOperandsLodShift = 1, + ImageOperandsGradShift = 2, + ImageOperandsConstOffsetShift = 3, + ImageOperandsOffsetShift = 4, + ImageOperandsConstOffsetsShift = 5, + ImageOperandsSampleShift = 6, + ImageOperandsMinLodShift = 7, + ImageOperandsMax = 0x7fffffff, +}; + +enum ImageOperandsMask { + ImageOperandsMaskNone = 0, + ImageOperandsBiasMask = 0x00000001, + ImageOperandsLodMask = 0x00000002, + ImageOperandsGradMask = 0x00000004, + ImageOperandsConstOffsetMask = 0x00000008, + ImageOperandsOffsetMask = 0x00000010, + ImageOperandsConstOffsetsMask = 0x00000020, + ImageOperandsSampleMask = 0x00000040, + ImageOperandsMinLodMask = 0x00000080, +}; + +enum FPFastMathModeShift { + FPFastMathModeNotNaNShift = 0, + FPFastMathModeNotInfShift = 1, + FPFastMathModeNSZShift = 2, + FPFastMathModeAllowRecipShift = 3, + FPFastMathModeFastShift = 4, + FPFastMathModeMax = 0x7fffffff, +}; + +enum FPFastMathModeMask { + FPFastMathModeMaskNone = 0, + FPFastMathModeNotNaNMask = 0x00000001, + FPFastMathModeNotInfMask = 0x00000002, + FPFastMathModeNSZMask = 0x00000004, + FPFastMathModeAllowRecipMask = 0x00000008, + FPFastMathModeFastMask = 0x00000010, +}; + +enum FPRoundingMode { + FPRoundingModeRTE = 0, + FPRoundingModeRTZ = 1, + FPRoundingModeRTP = 2, + FPRoundingModeRTN = 3, + FPRoundingModeMax = 0x7fffffff, +}; + +enum LinkageType { + LinkageTypeExport = 0, + LinkageTypeImport = 1, + LinkageTypeMax = 0x7fffffff, +}; + +enum AccessQualifier { + AccessQualifierReadOnly = 0, + AccessQualifierWriteOnly = 1, + AccessQualifierReadWrite = 2, + AccessQualifierMax = 0x7fffffff, +}; + +enum FunctionParameterAttribute { + FunctionParameterAttributeZext = 0, + FunctionParameterAttributeSext = 1, + FunctionParameterAttributeByVal = 2, + FunctionParameterAttributeSret = 3, + FunctionParameterAttributeNoAlias = 4, + FunctionParameterAttributeNoCapture = 5, + FunctionParameterAttributeNoWrite = 6, + FunctionParameterAttributeNoReadWrite = 7, + FunctionParameterAttributeMax = 0x7fffffff, +}; + +enum Decoration { + DecorationRelaxedPrecision = 0, + DecorationSpecId = 1, + DecorationBlock = 2, + DecorationBufferBlock = 3, + DecorationRowMajor = 4, + DecorationColMajor = 5, + DecorationArrayStride = 6, + DecorationMatrixStride = 7, + DecorationGLSLShared = 8, + DecorationGLSLPacked = 9, + DecorationCPacked = 10, + DecorationBuiltIn = 11, + DecorationNoPerspective = 13, + DecorationFlat = 14, + DecorationPatch = 15, + DecorationCentroid = 16, + DecorationSample = 17, + DecorationInvariant = 18, + DecorationRestrict = 19, + DecorationAliased = 20, + DecorationVolatile = 21, + DecorationConstant = 22, + DecorationCoherent = 23, + DecorationNonWritable = 24, + DecorationNonReadable = 25, + DecorationUniform = 26, + DecorationSaturatedConversion = 28, + DecorationStream = 29, + DecorationLocation = 30, + DecorationComponent = 31, + DecorationIndex = 32, + DecorationBinding = 33, + DecorationDescriptorSet = 34, + DecorationOffset = 35, + DecorationXfbBuffer = 36, + DecorationXfbStride = 37, + DecorationFuncParamAttr = 38, + DecorationFPRoundingMode = 39, + DecorationFPFastMathMode = 40, + DecorationLinkageAttributes = 41, + DecorationNoContraction = 42, + DecorationInputAttachmentIndex = 43, + DecorationAlignment = 44, + DecorationOverrideCoverageNV = 5248, + DecorationPassthroughNV = 5250, + DecorationViewportRelativeNV = 5252, + DecorationSecondaryViewportRelativeNV = 5256, + DecorationMax = 0x7fffffff, +}; + +enum BuiltIn { + BuiltInPosition = 0, + BuiltInPointSize = 1, + BuiltInClipDistance = 3, + BuiltInCullDistance = 4, + BuiltInVertexId = 5, + BuiltInInstanceId = 6, + BuiltInPrimitiveId = 7, + BuiltInInvocationId = 8, + BuiltInLayer = 9, + BuiltInViewportIndex = 10, + BuiltInTessLevelOuter = 11, + BuiltInTessLevelInner = 12, + BuiltInTessCoord = 13, + BuiltInPatchVertices = 14, + BuiltInFragCoord = 15, + BuiltInPointCoord = 16, + BuiltInFrontFacing = 17, + BuiltInSampleId = 18, + BuiltInSamplePosition = 19, + BuiltInSampleMask = 20, + BuiltInFragDepth = 22, + BuiltInHelperInvocation = 23, + BuiltInNumWorkgroups = 24, + BuiltInWorkgroupSize = 25, + BuiltInWorkgroupId = 26, + BuiltInLocalInvocationId = 27, + BuiltInGlobalInvocationId = 28, + BuiltInLocalInvocationIndex = 29, + BuiltInWorkDim = 30, + BuiltInGlobalSize = 31, + BuiltInEnqueuedWorkgroupSize = 32, + BuiltInGlobalOffset = 33, + BuiltInGlobalLinearId = 34, + BuiltInSubgroupSize = 36, + BuiltInSubgroupMaxSize = 37, + BuiltInNumSubgroups = 38, + BuiltInNumEnqueuedSubgroups = 39, + BuiltInSubgroupId = 40, + BuiltInSubgroupLocalInvocationId = 41, + BuiltInVertexIndex = 42, + BuiltInInstanceIndex = 43, + BuiltInSubgroupEqMaskKHR = 4416, + BuiltInSubgroupGeMaskKHR = 4417, + BuiltInSubgroupGtMaskKHR = 4418, + BuiltInSubgroupLeMaskKHR = 4419, + BuiltInSubgroupLtMaskKHR = 4420, + BuiltInBaseVertex = 4424, + BuiltInBaseInstance = 4425, + BuiltInDrawIndex = 4426, + BuiltInDeviceIndex = 4438, + BuiltInViewIndex = 4440, + BuiltInViewportMaskNV = 5253, + BuiltInSecondaryPositionNV = 5257, + BuiltInSecondaryViewportMaskNV = 5258, + BuiltInPositionPerViewNV = 5261, + BuiltInViewportMaskPerViewNV = 5262, + BuiltInMax = 0x7fffffff, +}; + +enum SelectionControlShift { + SelectionControlFlattenShift = 0, + SelectionControlDontFlattenShift = 1, + SelectionControlMax = 0x7fffffff, +}; + +enum SelectionControlMask { + SelectionControlMaskNone = 0, + SelectionControlFlattenMask = 0x00000001, + SelectionControlDontFlattenMask = 0x00000002, +}; + +enum LoopControlShift { + LoopControlUnrollShift = 0, + LoopControlDontUnrollShift = 1, + LoopControlMax = 0x7fffffff, +}; + +enum LoopControlMask { + LoopControlMaskNone = 0, + LoopControlUnrollMask = 0x00000001, + LoopControlDontUnrollMask = 0x00000002, +}; + +enum FunctionControlShift { + FunctionControlInlineShift = 0, + FunctionControlDontInlineShift = 1, + FunctionControlPureShift = 2, + FunctionControlConstShift = 3, + FunctionControlMax = 0x7fffffff, +}; + +enum FunctionControlMask { + FunctionControlMaskNone = 0, + FunctionControlInlineMask = 0x00000001, + FunctionControlDontInlineMask = 0x00000002, + FunctionControlPureMask = 0x00000004, + FunctionControlConstMask = 0x00000008, +}; + +enum MemorySemanticsShift { + MemorySemanticsAcquireShift = 1, + MemorySemanticsReleaseShift = 2, + MemorySemanticsAcquireReleaseShift = 3, + MemorySemanticsSequentiallyConsistentShift = 4, + MemorySemanticsUniformMemoryShift = 6, + MemorySemanticsSubgroupMemoryShift = 7, + MemorySemanticsWorkgroupMemoryShift = 8, + MemorySemanticsCrossWorkgroupMemoryShift = 9, + MemorySemanticsAtomicCounterMemoryShift = 10, + MemorySemanticsImageMemoryShift = 11, + MemorySemanticsMax = 0x7fffffff, +}; + +enum MemorySemanticsMask { + MemorySemanticsMaskNone = 0, + MemorySemanticsAcquireMask = 0x00000002, + MemorySemanticsReleaseMask = 0x00000004, + MemorySemanticsAcquireReleaseMask = 0x00000008, + MemorySemanticsSequentiallyConsistentMask = 0x00000010, + MemorySemanticsUniformMemoryMask = 0x00000040, + MemorySemanticsSubgroupMemoryMask = 0x00000080, + MemorySemanticsWorkgroupMemoryMask = 0x00000100, + MemorySemanticsCrossWorkgroupMemoryMask = 0x00000200, + MemorySemanticsAtomicCounterMemoryMask = 0x00000400, + MemorySemanticsImageMemoryMask = 0x00000800, +}; + +enum MemoryAccessShift { + MemoryAccessVolatileShift = 0, + MemoryAccessAlignedShift = 1, + MemoryAccessNontemporalShift = 2, + MemoryAccessMax = 0x7fffffff, +}; + +enum MemoryAccessMask { + MemoryAccessMaskNone = 0, + MemoryAccessVolatileMask = 0x00000001, + MemoryAccessAlignedMask = 0x00000002, + MemoryAccessNontemporalMask = 0x00000004, +}; + +enum Scope { + ScopeCrossDevice = 0, + ScopeDevice = 1, + ScopeWorkgroup = 2, + ScopeSubgroup = 3, + ScopeInvocation = 4, + ScopeMax = 0x7fffffff, +}; + +enum GroupOperation { + GroupOperationReduce = 0, + GroupOperationInclusiveScan = 1, + GroupOperationExclusiveScan = 2, + GroupOperationMax = 0x7fffffff, +}; + +enum KernelEnqueueFlags { + KernelEnqueueFlagsNoWait = 0, + KernelEnqueueFlagsWaitKernel = 1, + KernelEnqueueFlagsWaitWorkGroup = 2, + KernelEnqueueFlagsMax = 0x7fffffff, +}; + +enum KernelProfilingInfoShift { + KernelProfilingInfoCmdExecTimeShift = 0, + KernelProfilingInfoMax = 0x7fffffff, +}; + +enum KernelProfilingInfoMask { + KernelProfilingInfoMaskNone = 0, + KernelProfilingInfoCmdExecTimeMask = 0x00000001, +}; + +enum Capability { + CapabilityMatrix = 0, + CapabilityShader = 1, + CapabilityGeometry = 2, + CapabilityTessellation = 3, + CapabilityAddresses = 4, + CapabilityLinkage = 5, + CapabilityKernel = 6, + CapabilityVector16 = 7, + CapabilityFloat16Buffer = 8, + CapabilityFloat16 = 9, + CapabilityFloat64 = 10, + CapabilityInt64 = 11, + CapabilityInt64Atomics = 12, + CapabilityImageBasic = 13, + CapabilityImageReadWrite = 14, + CapabilityImageMipmap = 15, + CapabilityPipes = 17, + CapabilityGroups = 18, + CapabilityDeviceEnqueue = 19, + CapabilityLiteralSampler = 20, + CapabilityAtomicStorage = 21, + CapabilityInt16 = 22, + CapabilityTessellationPointSize = 23, + CapabilityGeometryPointSize = 24, + CapabilityImageGatherExtended = 25, + CapabilityStorageImageMultisample = 27, + CapabilityUniformBufferArrayDynamicIndexing = 28, + CapabilitySampledImageArrayDynamicIndexing = 29, + CapabilityStorageBufferArrayDynamicIndexing = 30, + CapabilityStorageImageArrayDynamicIndexing = 31, + CapabilityClipDistance = 32, + CapabilityCullDistance = 33, + CapabilityImageCubeArray = 34, + CapabilitySampleRateShading = 35, + CapabilityImageRect = 36, + CapabilitySampledRect = 37, + CapabilityGenericPointer = 38, + CapabilityInt8 = 39, + CapabilityInputAttachment = 40, + CapabilitySparseResidency = 41, + CapabilityMinLod = 42, + CapabilitySampled1D = 43, + CapabilityImage1D = 44, + CapabilitySampledCubeArray = 45, + CapabilitySampledBuffer = 46, + CapabilityImageBuffer = 47, + CapabilityImageMSArray = 48, + CapabilityStorageImageExtendedFormats = 49, + CapabilityImageQuery = 50, + CapabilityDerivativeControl = 51, + CapabilityInterpolationFunction = 52, + CapabilityTransformFeedback = 53, + CapabilityGeometryStreams = 54, + CapabilityStorageImageReadWithoutFormat = 55, + CapabilityStorageImageWriteWithoutFormat = 56, + CapabilityMultiViewport = 57, + CapabilitySubgroupBallotKHR = 4423, + CapabilityDrawParameters = 4427, + CapabilitySubgroupVoteKHR = 4431, + CapabilityStorageBuffer16BitAccess = 4433, + CapabilityStorageUniformBufferBlock16 = 4433, + CapabilityStorageUniform16 = 4434, + CapabilityUniformAndStorageBuffer16BitAccess = 4434, + CapabilityStoragePushConstant16 = 4435, + CapabilityStorageInputOutput16 = 4436, + CapabilityDeviceGroup = 4437, + CapabilityMultiView = 4439, + CapabilityVariablePointersStorageBuffer = 4441, + CapabilityVariablePointers = 4442, + CapabilitySampleMaskOverrideCoverageNV = 5249, + CapabilityGeometryShaderPassthroughNV = 5251, + CapabilityShaderViewportIndexLayerNV = 5254, + CapabilityShaderViewportMaskNV = 5255, + CapabilityShaderStereoViewNV = 5259, + CapabilityPerViewAttributesNV = 5260, + CapabilityMax = 0x7fffffff, +}; + +enum Op { + OpNop = 0, + OpUndef = 1, + OpSourceContinued = 2, + OpSource = 3, + OpSourceExtension = 4, + OpName = 5, + OpMemberName = 6, + OpString = 7, + OpLine = 8, + OpExtension = 10, + OpExtInstImport = 11, + OpExtInst = 12, + OpMemoryModel = 14, + OpEntryPoint = 15, + OpExecutionMode = 16, + OpCapability = 17, + OpTypeVoid = 19, + OpTypeBool = 20, + OpTypeInt = 21, + OpTypeFloat = 22, + OpTypeVector = 23, + OpTypeMatrix = 24, + OpTypeImage = 25, + OpTypeSampler = 26, + OpTypeSampledImage = 27, + OpTypeArray = 28, + OpTypeRuntimeArray = 29, + OpTypeStruct = 30, + OpTypeOpaque = 31, + OpTypePointer = 32, + OpTypeFunction = 33, + OpTypeEvent = 34, + OpTypeDeviceEvent = 35, + OpTypeReserveId = 36, + OpTypeQueue = 37, + OpTypePipe = 38, + OpTypeForwardPointer = 39, + OpConstantTrue = 41, + OpConstantFalse = 42, + OpConstant = 43, + OpConstantComposite = 44, + OpConstantSampler = 45, + OpConstantNull = 46, + OpSpecConstantTrue = 48, + OpSpecConstantFalse = 49, + OpSpecConstant = 50, + OpSpecConstantComposite = 51, + OpSpecConstantOp = 52, + OpFunction = 54, + OpFunctionParameter = 55, + OpFunctionEnd = 56, + OpFunctionCall = 57, + OpVariable = 59, + OpImageTexelPointer = 60, + OpLoad = 61, + OpStore = 62, + OpCopyMemory = 63, + OpCopyMemorySized = 64, + OpAccessChain = 65, + OpInBoundsAccessChain = 66, + OpPtrAccessChain = 67, + OpArrayLength = 68, + OpGenericPtrMemSemantics = 69, + OpInBoundsPtrAccessChain = 70, + OpDecorate = 71, + OpMemberDecorate = 72, + OpDecorationGroup = 73, + OpGroupDecorate = 74, + OpGroupMemberDecorate = 75, + OpVectorExtractDynamic = 77, + OpVectorInsertDynamic = 78, + OpVectorShuffle = 79, + OpCompositeConstruct = 80, + OpCompositeExtract = 81, + OpCompositeInsert = 82, + OpCopyObject = 83, + OpTranspose = 84, + OpSampledImage = 86, + OpImageSampleImplicitLod = 87, + OpImageSampleExplicitLod = 88, + OpImageSampleDrefImplicitLod = 89, + OpImageSampleDrefExplicitLod = 90, + OpImageSampleProjImplicitLod = 91, + OpImageSampleProjExplicitLod = 92, + OpImageSampleProjDrefImplicitLod = 93, + OpImageSampleProjDrefExplicitLod = 94, + OpImageFetch = 95, + OpImageGather = 96, + OpImageDrefGather = 97, + OpImageRead = 98, + OpImageWrite = 99, + OpImage = 100, + OpImageQueryFormat = 101, + OpImageQueryOrder = 102, + OpImageQuerySizeLod = 103, + OpImageQuerySize = 104, + OpImageQueryLod = 105, + OpImageQueryLevels = 106, + OpImageQuerySamples = 107, + OpConvertFToU = 109, + OpConvertFToS = 110, + OpConvertSToF = 111, + OpConvertUToF = 112, + OpUConvert = 113, + OpSConvert = 114, + OpFConvert = 115, + OpQuantizeToF16 = 116, + OpConvertPtrToU = 117, + OpSatConvertSToU = 118, + OpSatConvertUToS = 119, + OpConvertUToPtr = 120, + OpPtrCastToGeneric = 121, + OpGenericCastToPtr = 122, + OpGenericCastToPtrExplicit = 123, + OpBitcast = 124, + OpSNegate = 126, + OpFNegate = 127, + OpIAdd = 128, + OpFAdd = 129, + OpISub = 130, + OpFSub = 131, + OpIMul = 132, + OpFMul = 133, + OpUDiv = 134, + OpSDiv = 135, + OpFDiv = 136, + OpUMod = 137, + OpSRem = 138, + OpSMod = 139, + OpFRem = 140, + OpFMod = 141, + OpVectorTimesScalar = 142, + OpMatrixTimesScalar = 143, + OpVectorTimesMatrix = 144, + OpMatrixTimesVector = 145, + OpMatrixTimesMatrix = 146, + OpOuterProduct = 147, + OpDot = 148, + OpIAddCarry = 149, + OpISubBorrow = 150, + OpUMulExtended = 151, + OpSMulExtended = 152, + OpAny = 154, + OpAll = 155, + OpIsNan = 156, + OpIsInf = 157, + OpIsFinite = 158, + OpIsNormal = 159, + OpSignBitSet = 160, + OpLessOrGreater = 161, + OpOrdered = 162, + OpUnordered = 163, + OpLogicalEqual = 164, + OpLogicalNotEqual = 165, + OpLogicalOr = 166, + OpLogicalAnd = 167, + OpLogicalNot = 168, + OpSelect = 169, + OpIEqual = 170, + OpINotEqual = 171, + OpUGreaterThan = 172, + OpSGreaterThan = 173, + OpUGreaterThanEqual = 174, + OpSGreaterThanEqual = 175, + OpULessThan = 176, + OpSLessThan = 177, + OpULessThanEqual = 178, + OpSLessThanEqual = 179, + OpFOrdEqual = 180, + OpFUnordEqual = 181, + OpFOrdNotEqual = 182, + OpFUnordNotEqual = 183, + OpFOrdLessThan = 184, + OpFUnordLessThan = 185, + OpFOrdGreaterThan = 186, + OpFUnordGreaterThan = 187, + OpFOrdLessThanEqual = 188, + OpFUnordLessThanEqual = 189, + OpFOrdGreaterThanEqual = 190, + OpFUnordGreaterThanEqual = 191, + OpShiftRightLogical = 194, + OpShiftRightArithmetic = 195, + OpShiftLeftLogical = 196, + OpBitwiseOr = 197, + OpBitwiseXor = 198, + OpBitwiseAnd = 199, + OpNot = 200, + OpBitFieldInsert = 201, + OpBitFieldSExtract = 202, + OpBitFieldUExtract = 203, + OpBitReverse = 204, + OpBitCount = 205, + OpDPdx = 207, + OpDPdy = 208, + OpFwidth = 209, + OpDPdxFine = 210, + OpDPdyFine = 211, + OpFwidthFine = 212, + OpDPdxCoarse = 213, + OpDPdyCoarse = 214, + OpFwidthCoarse = 215, + OpEmitVertex = 218, + OpEndPrimitive = 219, + OpEmitStreamVertex = 220, + OpEndStreamPrimitive = 221, + OpControlBarrier = 224, + OpMemoryBarrier = 225, + OpAtomicLoad = 227, + OpAtomicStore = 228, + OpAtomicExchange = 229, + OpAtomicCompareExchange = 230, + OpAtomicCompareExchangeWeak = 231, + OpAtomicIIncrement = 232, + OpAtomicIDecrement = 233, + OpAtomicIAdd = 234, + OpAtomicISub = 235, + OpAtomicSMin = 236, + OpAtomicUMin = 237, + OpAtomicSMax = 238, + OpAtomicUMax = 239, + OpAtomicAnd = 240, + OpAtomicOr = 241, + OpAtomicXor = 242, + OpPhi = 245, + OpLoopMerge = 246, + OpSelectionMerge = 247, + OpLabel = 248, + OpBranch = 249, + OpBranchConditional = 250, + OpSwitch = 251, + OpKill = 252, + OpReturn = 253, + OpReturnValue = 254, + OpUnreachable = 255, + OpLifetimeStart = 256, + OpLifetimeStop = 257, + OpGroupAsyncCopy = 259, + OpGroupWaitEvents = 260, + OpGroupAll = 261, + OpGroupAny = 262, + OpGroupBroadcast = 263, + OpGroupIAdd = 264, + OpGroupFAdd = 265, + OpGroupFMin = 266, + OpGroupUMin = 267, + OpGroupSMin = 268, + OpGroupFMax = 269, + OpGroupUMax = 270, + OpGroupSMax = 271, + OpReadPipe = 274, + OpWritePipe = 275, + OpReservedReadPipe = 276, + OpReservedWritePipe = 277, + OpReserveReadPipePackets = 278, + OpReserveWritePipePackets = 279, + OpCommitReadPipe = 280, + OpCommitWritePipe = 281, + OpIsValidReserveId = 282, + OpGetNumPipePackets = 283, + OpGetMaxPipePackets = 284, + OpGroupReserveReadPipePackets = 285, + OpGroupReserveWritePipePackets = 286, + OpGroupCommitReadPipe = 287, + OpGroupCommitWritePipe = 288, + OpEnqueueMarker = 291, + OpEnqueueKernel = 292, + OpGetKernelNDrangeSubGroupCount = 293, + OpGetKernelNDrangeMaxSubGroupSize = 294, + OpGetKernelWorkGroupSize = 295, + OpGetKernelPreferredWorkGroupSizeMultiple = 296, + OpRetainEvent = 297, + OpReleaseEvent = 298, + OpCreateUserEvent = 299, + OpIsValidEvent = 300, + OpSetUserEventStatus = 301, + OpCaptureEventProfilingInfo = 302, + OpGetDefaultQueue = 303, + OpBuildNDRange = 304, + OpImageSparseSampleImplicitLod = 305, + OpImageSparseSampleExplicitLod = 306, + OpImageSparseSampleDrefImplicitLod = 307, + OpImageSparseSampleDrefExplicitLod = 308, + OpImageSparseSampleProjImplicitLod = 309, + OpImageSparseSampleProjExplicitLod = 310, + OpImageSparseSampleProjDrefImplicitLod = 311, + OpImageSparseSampleProjDrefExplicitLod = 312, + OpImageSparseFetch = 313, + OpImageSparseGather = 314, + OpImageSparseDrefGather = 315, + OpImageSparseTexelsResident = 316, + OpNoLine = 317, + OpAtomicFlagTestAndSet = 318, + OpAtomicFlagClear = 319, + OpImageSparseRead = 320, + OpSubgroupBallotKHR = 4421, + OpSubgroupFirstInvocationKHR = 4422, + OpSubgroupAllKHR = 4428, + OpSubgroupAnyKHR = 4429, + OpSubgroupAllEqualKHR = 4430, + OpSubgroupReadInvocationKHR = 4432, + OpGroupIAddNonUniformAMD = 5000, + OpGroupFAddNonUniformAMD = 5001, + OpGroupFMinNonUniformAMD = 5002, + OpGroupUMinNonUniformAMD = 5003, + OpGroupSMinNonUniformAMD = 5004, + OpGroupFMaxNonUniformAMD = 5005, + OpGroupUMaxNonUniformAMD = 5006, + OpGroupSMaxNonUniformAMD = 5007, + OpFragmentMaskFetchAMD = 5011, + OpFragmentFetchAMD = 5012, + OpMax = 0x7fffffff, +}; + +// Overload operator| for mask bit combining + +inline ImageOperandsMask operator|(ImageOperandsMask a, ImageOperandsMask b) { return ImageOperandsMask(unsigned(a) | unsigned(b)); } +inline FPFastMathModeMask operator|(FPFastMathModeMask a, FPFastMathModeMask b) { return FPFastMathModeMask(unsigned(a) | unsigned(b)); } +inline SelectionControlMask operator|(SelectionControlMask a, SelectionControlMask b) { return SelectionControlMask(unsigned(a) | unsigned(b)); } +inline LoopControlMask operator|(LoopControlMask a, LoopControlMask b) { return LoopControlMask(unsigned(a) | unsigned(b)); } +inline FunctionControlMask operator|(FunctionControlMask a, FunctionControlMask b) { return FunctionControlMask(unsigned(a) | unsigned(b)); } +inline MemorySemanticsMask operator|(MemorySemanticsMask a, MemorySemanticsMask b) { return MemorySemanticsMask(unsigned(a) | unsigned(b)); } +inline MemoryAccessMask operator|(MemoryAccessMask a, MemoryAccessMask b) { return MemoryAccessMask(unsigned(a) | unsigned(b)); } +inline KernelProfilingInfoMask operator|(KernelProfilingInfoMask a, KernelProfilingInfoMask b) { return KernelProfilingInfoMask(unsigned(a) | unsigned(b)); } + +} // end namespace spv + +#endif // #ifndef spirv_HPP + diff --git a/spirv_cfg.cpp b/spirv_cfg.cpp new file mode 100644 index 0000000000..c76698a740 --- /dev/null +++ b/spirv_cfg.cpp @@ -0,0 +1,229 @@ +/* + * Copyright 2016-2018 ARM Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "spirv_cfg.hpp" +#include "spirv_cross.hpp" +#include +#include + +using namespace std; + +namespace spirv_cross +{ +CFG::CFG(Compiler &compiler_, const SPIRFunction &func_) + : compiler(compiler_) + , func(func_) +{ + preceding_edges.resize(compiler.get_current_id_bound()); + succeeding_edges.resize(compiler.get_current_id_bound()); + visit_order.resize(compiler.get_current_id_bound()); + immediate_dominators.resize(compiler.get_current_id_bound()); + + build_post_order_visit_order(); + build_immediate_dominators(); +} + +uint32_t CFG::find_common_dominator(uint32_t a, uint32_t b) const +{ + while (a != b) + { + if (visit_order[a] < visit_order[b]) + a = immediate_dominators[a]; + else + b = immediate_dominators[b]; + } + return a; +} + +void CFG::build_immediate_dominators() +{ + // Traverse the post-order in reverse and build up the immediate dominator tree. + fill(begin(immediate_dominators), end(immediate_dominators), 0); + immediate_dominators[func.entry_block] = func.entry_block; + + for (auto i = post_order.size(); i; i--) + { + uint32_t block = post_order[i - 1]; + auto &pred = preceding_edges[block]; + if (pred.empty()) // This is for the entry block, but we've already set up the dominators. + continue; + + for (auto &edge : pred) + { + if (immediate_dominators[block]) + { + assert(immediate_dominators[edge]); + immediate_dominators[block] = find_common_dominator(block, edge); + } + else + immediate_dominators[block] = edge; + } + } +} + +bool CFG::is_back_edge(uint32_t to) const +{ + // We have a back edge if the visit order is set with the temporary magic value 0. + // Crossing edges will have already been recorded with a visit order. + return visit_order[to] == 0; +} + +bool CFG::post_order_visit(uint32_t block_id) +{ + // If we have already branched to this block (back edge), stop recursion. + // If our branches are back-edges, we do not record them. + // We have to record crossing edges however. + if (visit_order[block_id] >= 0) + return !is_back_edge(block_id); + + // Block back-edges from recursively revisiting ourselves. + visit_order[block_id] = 0; + + // First visit our branch targets. + auto &block = compiler.get(block_id); + switch (block.terminator) + { + case SPIRBlock::Direct: + if (post_order_visit(block.next_block)) + add_branch(block_id, block.next_block); + break; + + case SPIRBlock::Select: + if (post_order_visit(block.true_block)) + add_branch(block_id, block.true_block); + if (post_order_visit(block.false_block)) + add_branch(block_id, block.false_block); + break; + + case SPIRBlock::MultiSelect: + for (auto &target : block.cases) + { + if (post_order_visit(target.block)) + add_branch(block_id, target.block); + } + if (block.default_block && post_order_visit(block.default_block)) + add_branch(block_id, block.default_block); + break; + + default: + break; + } + + // If this is a loop header, add an implied branch to the merge target. + // This is needed to avoid annoying cases with do { ... } while(false) loops often generated by inliners. + // To the CFG, this is linear control flow, but we risk picking the do/while scope as our dominating block. + // This makes sure that if we are accessing a variable outside the do/while, we choose the loop header as dominator. + if (block.merge == SPIRBlock::MergeLoop) + add_branch(block_id, block.merge_block); + + // Then visit ourselves. Start counting at one, to let 0 be a magic value for testing back vs. crossing edges. + visit_order[block_id] = ++visit_count; + post_order.push_back(block_id); + return true; +} + +void CFG::build_post_order_visit_order() +{ + uint32_t block = func.entry_block; + visit_count = 0; + fill(begin(visit_order), end(visit_order), -1); + post_order.clear(); + post_order_visit(block); +} + +void CFG::add_branch(uint32_t from, uint32_t to) +{ + const auto add_unique = [](vector &l, uint32_t value) { + auto itr = find(begin(l), end(l), value); + if (itr == end(l)) + l.push_back(value); + }; + add_unique(preceding_edges[to], from); + add_unique(succeeding_edges[from], to); +} + +DominatorBuilder::DominatorBuilder(const CFG &cfg_) + : cfg(cfg_) +{ +} + +void DominatorBuilder::add_block(uint32_t block) +{ + if (!cfg.get_immediate_dominator(block)) + { + // Unreachable block via the CFG, we will never emit this code anyways. + return; + } + + if (!dominator) + { + dominator = block; + return; + } + + if (block != dominator) + dominator = cfg.find_common_dominator(block, dominator); +} + +void DominatorBuilder::lift_continue_block_dominator() +{ + // It is possible for a continue block to be the dominator of a variable is only accessed inside the while block of a do-while loop. + // We cannot safely declare variables inside a continue block, so move any variable declared + // in a continue block to the entry block to simplify. + // It makes very little sense for a continue block to ever be a dominator, so fall back to the simplest + // solution. + + if (!dominator) + return; + + auto &block = cfg.get_compiler().get(dominator); + auto post_order = cfg.get_visit_order(dominator); + + // If we are branching to a block with a higher post-order traversal index (continue blocks), we have a problem + // since we cannot create sensible GLSL code for this, fallback to entry block. + bool back_edge_dominator = false; + switch (block.terminator) + { + case SPIRBlock::Direct: + if (cfg.get_visit_order(block.next_block) > post_order) + back_edge_dominator = true; + break; + + case SPIRBlock::Select: + if (cfg.get_visit_order(block.true_block) > post_order) + back_edge_dominator = true; + if (cfg.get_visit_order(block.false_block) > post_order) + back_edge_dominator = true; + break; + + case SPIRBlock::MultiSelect: + for (auto &target : block.cases) + { + if (cfg.get_visit_order(target.block) > post_order) + back_edge_dominator = true; + } + if (block.default_block && cfg.get_visit_order(block.default_block) > post_order) + back_edge_dominator = true; + break; + + default: + break; + } + + if (back_edge_dominator) + dominator = cfg.get_function().entry_block; +} +} diff --git a/spirv_cfg.hpp b/spirv_cfg.hpp new file mode 100644 index 0000000000..104e494c22 --- /dev/null +++ b/spirv_cfg.hpp @@ -0,0 +1,119 @@ +/* + * Copyright 2016-2018 ARM Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SPIRV_CROSS_CFG_HPP +#define SPIRV_CROSS_CFG_HPP + +#include "spirv_common.hpp" +#include + +namespace spirv_cross +{ +class Compiler; +class CFG +{ +public: + CFG(Compiler &compiler, const SPIRFunction &function); + + Compiler &get_compiler() + { + return compiler; + } + + const Compiler &get_compiler() const + { + return compiler; + } + + const SPIRFunction &get_function() const + { + return func; + } + + uint32_t get_immediate_dominator(uint32_t block) const + { + return immediate_dominators[block]; + } + + uint32_t get_visit_order(uint32_t block) const + { + int v = visit_order[block]; + assert(v > 0); + return uint32_t(v); + } + + uint32_t find_common_dominator(uint32_t a, uint32_t b) const; + + const std::vector &get_preceding_edges(uint32_t block) const + { + return preceding_edges[block]; + } + + const std::vector &get_succeeding_edges(uint32_t block) const + { + return succeeding_edges[block]; + } + + template + void walk_from(std::unordered_set &seen_blocks, uint32_t block, const Op &op) const + { + if (seen_blocks.count(block)) + return; + seen_blocks.insert(block); + + op(block); + for (auto b : succeeding_edges[block]) + walk_from(seen_blocks, b, op); + } + +private: + Compiler &compiler; + const SPIRFunction &func; + std::vector> preceding_edges; + std::vector> succeeding_edges; + std::vector immediate_dominators; + std::vector visit_order; + std::vector post_order; + + void add_branch(uint32_t from, uint32_t to); + void build_post_order_visit_order(); + void build_immediate_dominators(); + bool post_order_visit(uint32_t block); + uint32_t visit_count = 0; + + bool is_back_edge(uint32_t to) const; +}; + +class DominatorBuilder +{ +public: + DominatorBuilder(const CFG &cfg); + + void add_block(uint32_t block); + uint32_t get_dominator() const + { + return dominator; + } + + void lift_continue_block_dominator(); + +private: + const CFG &cfg; + uint32_t dominator = 0; +}; +} + +#endif diff --git a/spirv_common.hpp b/spirv_common.hpp new file mode 100644 index 0000000000..c4829f4643 --- /dev/null +++ b/spirv_common.hpp @@ -0,0 +1,1026 @@ +/* + * Copyright 2015-2018 ARM Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SPIRV_CROSS_COMMON_HPP +#define SPIRV_CROSS_COMMON_HPP + +#include "spirv.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace spirv_cross +{ + +#ifdef SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS +#ifndef _MSC_VER +[[noreturn]] +#endif + inline void + report_and_abort(const std::string &msg) +{ +#ifdef NDEBUG + (void)msg; +#else + fprintf(stderr, "There was a compiler error: %s\n", msg.c_str()); +#endif + fflush(stderr); + abort(); +} + +#define SPIRV_CROSS_THROW(x) report_and_abort(x) +#else +class CompilerError : public std::runtime_error +{ +public: + CompilerError(const std::string &str) + : std::runtime_error(str) + { + } +}; + +#define SPIRV_CROSS_THROW(x) throw CompilerError(x) +#endif + +#if __cplusplus >= 201402l +#define SPIRV_CROSS_DEPRECATED(reason) [[deprecated(reason)]] +#elif defined(__GNUC__) +#define SPIRV_CROSS_DEPRECATED(reason) __attribute__((deprecated)) +#elif defined(_MSC_VER) +#define SPIRV_CROSS_DEPRECATED(reason) __declspec(deprecated(reason)) +#else +#define SPIRV_CROSS_DEPRECATED(reason) +#endif + +namespace inner +{ +template +void join_helper(std::ostringstream &stream, T &&t) +{ + stream << std::forward(t); +} + +template +void join_helper(std::ostringstream &stream, T &&t, Ts &&... ts) +{ + stream << std::forward(t); + join_helper(stream, std::forward(ts)...); +} +} + +// Helper template to avoid lots of nasty string temporary munging. +template +std::string join(Ts &&... ts) +{ + std::ostringstream stream; + inner::join_helper(stream, std::forward(ts)...); + return stream.str(); +} + +inline std::string merge(const std::vector &list) +{ + std::string s; + for (auto &elem : list) + { + s += elem; + if (&elem != &list.back()) + s += ", "; + } + return s; +} + +template +inline std::string convert_to_string(T &&t) +{ + return std::to_string(std::forward(t)); +} + +// Allow implementations to set a convenient standard precision +#ifndef SPIRV_CROSS_FLT_FMT +#define SPIRV_CROSS_FLT_FMT "%.32g" +#endif + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4996) +#endif + +inline std::string convert_to_string(float t) +{ + // std::to_string for floating point values is broken. + // Fallback to something more sane. + char buf[64]; + sprintf(buf, SPIRV_CROSS_FLT_FMT, t); + // Ensure that the literal is float. + if (!strchr(buf, '.') && !strchr(buf, 'e')) + strcat(buf, ".0"); + return buf; +} + +inline std::string convert_to_string(double t) +{ + // std::to_string for floating point values is broken. + // Fallback to something more sane. + char buf[64]; + sprintf(buf, SPIRV_CROSS_FLT_FMT, t); + // Ensure that the literal is float. + if (!strchr(buf, '.') && !strchr(buf, 'e')) + strcat(buf, ".0"); + return buf; +} + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +struct Instruction +{ + Instruction(const std::vector &spirv, uint32_t &index); + + uint16_t op; + uint16_t count; + uint32_t offset; + uint32_t length; +}; + +// Helper for Variant interface. +struct IVariant +{ + virtual ~IVariant() = default; + uint32_t self = 0; +}; + +enum Types +{ + TypeNone, + TypeType, + TypeVariable, + TypeConstant, + TypeFunction, + TypeFunctionPrototype, + TypePointer, + TypeBlock, + TypeExtension, + TypeExpression, + TypeConstantOp, + TypeCombinedImageSampler, + TypeAccessChain, + TypeUndef +}; + +struct SPIRUndef : IVariant +{ + enum + { + type = TypeUndef + }; + SPIRUndef(uint32_t basetype_) + : basetype(basetype_) + { + } + uint32_t basetype; +}; + +// This type is only used by backends which need to access the combined image and sampler IDs separately after +// the OpSampledImage opcode. +struct SPIRCombinedImageSampler : IVariant +{ + enum + { + type = TypeCombinedImageSampler + }; + SPIRCombinedImageSampler(uint32_t type_, uint32_t image_, uint32_t sampler_) + : combined_type(type_) + , image(image_) + , sampler(sampler_) + { + } + uint32_t combined_type; + uint32_t image; + uint32_t sampler; +}; + +struct SPIRConstantOp : IVariant +{ + enum + { + type = TypeConstantOp + }; + + SPIRConstantOp(uint32_t result_type, spv::Op op, const uint32_t *args, uint32_t length) + : opcode(op) + , arguments(args, args + length) + , basetype(result_type) + { + } + + spv::Op opcode; + std::vector arguments; + uint32_t basetype; +}; + +struct SPIRType : IVariant +{ + enum + { + type = TypeType + }; + + enum BaseType + { + Unknown, + Void, + Boolean, + Char, + Int, + UInt, + Int64, + UInt64, + AtomicCounter, + Float, + Double, + Struct, + Image, + SampledImage, + Sampler + }; + + // Scalar/vector/matrix support. + BaseType basetype = Unknown; + uint32_t width = 0; + uint32_t vecsize = 1; + uint32_t columns = 1; + + // Arrays, support array of arrays by having a vector of array sizes. + std::vector array; + + // Array elements can be either specialization constants or specialization ops. + // This array determines how to interpret the array size. + // If an element is true, the element is a literal, + // otherwise, it's an expression, which must be resolved on demand. + // The actual size is not really known until runtime. + std::vector array_size_literal; + + // Pointers + bool pointer = false; + spv::StorageClass storage = spv::StorageClassGeneric; + + std::vector member_types; + + struct ImageType + { + uint32_t type; + spv::Dim dim; + bool depth; + bool arrayed; + bool ms; + uint32_t sampled; + spv::ImageFormat format; + spv::AccessQualifier access; + } image; + + // Structs can be declared multiple times if they are used as part of interface blocks. + // We want to detect this so that we only emit the struct definition once. + // Since we cannot rely on OpName to be equal, we need to figure out aliases. + uint32_t type_alias = 0; + + // Denotes the type which this type is based on. + // Allows the backend to traverse how a complex type is built up during access chains. + uint32_t parent_type = 0; + + // Used in backends to avoid emitting members with conflicting names. + std::unordered_set member_name_cache; +}; + +struct SPIRExtension : IVariant +{ + enum + { + type = TypeExtension + }; + + enum Extension + { + Unsupported, + GLSL, + SPV_AMD_shader_ballot, + SPV_AMD_shader_explicit_vertex_parameter, + SPV_AMD_shader_trinary_minmax, + SPV_AMD_gcn_shader + }; + + SPIRExtension(Extension ext_) + : ext(ext_) + { + } + + Extension ext; +}; + +// SPIREntryPoint is not a variant since its IDs are used to decorate OpFunction, +// so in order to avoid conflicts, we can't stick them in the ids array. +struct SPIREntryPoint +{ + SPIREntryPoint(uint32_t self_, spv::ExecutionModel execution_model, const std::string &entry_name) + : self(self_) + , name(entry_name) + , orig_name(entry_name) + , model(execution_model) + { + } + SPIREntryPoint() = default; + + uint32_t self = 0; + std::string name; + std::string orig_name; + std::vector interface_variables; + + uint64_t flags = 0; + struct + { + uint32_t x = 0, y = 0, z = 0; + uint32_t constant = 0; // Workgroup size can be expressed as a constant/spec-constant instead. + } workgroup_size; + uint32_t invocations = 0; + uint32_t output_vertices = 0; + spv::ExecutionModel model; +}; + +struct SPIRExpression : IVariant +{ + enum + { + type = TypeExpression + }; + + // Only created by the backend target to avoid creating tons of temporaries. + SPIRExpression(std::string expr, uint32_t expression_type_, bool immutable_) + : expression(move(expr)) + , expression_type(expression_type_) + , immutable(immutable_) + { + } + + // If non-zero, prepend expression with to_expression(base_expression). + // Used in amortizing multiple calls to to_expression() + // where in certain cases that would quickly force a temporary when not needed. + uint32_t base_expression = 0; + + std::string expression; + uint32_t expression_type = 0; + + // If this expression is a forwarded load, + // allow us to reference the original variable. + uint32_t loaded_from = 0; + + // If this expression will never change, we can avoid lots of temporaries + // in high level source. + // An expression being immutable can be speculative, + // it is assumed that this is true almost always. + bool immutable = false; + + // Before use, this expression must be transposed. + // This is needed for targets which don't support row_major layouts. + bool need_transpose = false; + + // A list of expressions which this expression depends on. + std::vector expression_dependencies; +}; + +struct SPIRFunctionPrototype : IVariant +{ + enum + { + type = TypeFunctionPrototype + }; + + SPIRFunctionPrototype(uint32_t return_type_) + : return_type(return_type_) + { + } + + uint32_t return_type; + std::vector parameter_types; +}; + +struct SPIRBlock : IVariant +{ + enum + { + type = TypeBlock + }; + + enum Terminator + { + Unknown, + Direct, // Emit next block directly without a particular condition. + + Select, // Block ends with an if/else block. + MultiSelect, // Block ends with switch statement. + + Return, // Block ends with return. + Unreachable, // Noop + Kill // Discard + }; + + enum Merge + { + MergeNone, + MergeLoop, + MergeSelection + }; + + enum Method + { + MergeToSelectForLoop, + MergeToDirectForLoop + }; + + enum ContinueBlockType + { + ContinueNone, + + // Continue block is branchless and has at least one instruction. + ForLoop, + + // Noop continue block. + WhileLoop, + + // Continue block is conditional. + DoWhileLoop, + + // Highly unlikely that anything will use this, + // since it is really awkward/impossible to express in GLSL. + ComplexLoop + }; + + enum + { + NoDominator = 0xffffffffu + }; + + Terminator terminator = Unknown; + Merge merge = MergeNone; + uint32_t next_block = 0; + uint32_t merge_block = 0; + uint32_t continue_block = 0; + + uint32_t return_value = 0; // If 0, return nothing (void). + uint32_t condition = 0; + uint32_t true_block = 0; + uint32_t false_block = 0; + uint32_t default_block = 0; + + std::vector ops; + + struct Phi + { + uint32_t local_variable; // flush local variable ... + uint32_t parent; // If we're in from_block and want to branch into this block ... + uint32_t function_variable; // to this function-global "phi" variable first. + }; + + // Before entering this block flush out local variables to magical "phi" variables. + std::vector phi_variables; + + // Declare these temporaries before beginning the block. + // Used for handling complex continue blocks which have side effects. + std::vector> declare_temporary; + + struct Case + { + uint32_t value; + uint32_t block; + }; + std::vector cases; + + // If we have tried to optimize code for this block but failed, + // keep track of this. + bool disable_block_optimization = false; + + // If the continue block is complex, fallback to "dumb" for loops. + bool complex_continue = false; + + // The dominating block which this block might be within. + // Used in continue; blocks to determine if we really need to write continue. + uint32_t loop_dominator = 0; + + // All access to these variables are dominated by this block, + // so before branching anywhere we need to make sure that we declare these variables. + std::vector dominated_variables; + + // These are variables which should be declared in a for loop header, if we + // fail to use a classic for-loop, + // we remove these variables, and fall back to regular variables outside the loop. + std::vector loop_variables; +}; + +struct SPIRFunction : IVariant +{ + enum + { + type = TypeFunction + }; + + SPIRFunction(uint32_t return_type_, uint32_t function_type_) + : return_type(return_type_) + , function_type(function_type_) + { + } + + struct Parameter + { + uint32_t type; + uint32_t id; + uint32_t read_count; + uint32_t write_count; + + // Set to true if this parameter aliases a global variable, + // used mostly in Metal where global variables + // have to be passed down to functions as regular arguments. + // However, for this kind of variable, we should not care about + // read and write counts as access to the function arguments + // is not local to the function in question. + bool alias_global_variable; + }; + + // When calling a function, and we're remapping separate image samplers, + // resolve these arguments into combined image samplers and pass them + // as additional arguments in this order. + // It gets more complicated as functions can pull in their own globals + // and combine them with parameters, + // so we need to distinguish if something is local parameter index + // or a global ID. + struct CombinedImageSamplerParameter + { + uint32_t id; + uint32_t image_id; + uint32_t sampler_id; + bool global_image; + bool global_sampler; + bool depth; + }; + + uint32_t return_type; + uint32_t function_type; + std::vector arguments; + + // Can be used by backends to add magic arguments. + // Currently used by combined image/sampler implementation. + + std::vector shadow_arguments; + std::vector local_variables; + uint32_t entry_block = 0; + std::vector blocks; + std::vector combined_parameters; + + void add_local_variable(uint32_t id) + { + local_variables.push_back(id); + } + + void add_parameter(uint32_t parameter_type, uint32_t id, bool alias_global_variable = false) + { + // Arguments are read-only until proven otherwise. + arguments.push_back({ parameter_type, id, 0u, 0u, alias_global_variable }); + } + + bool active = false; + bool flush_undeclared = true; + bool do_combined_parameters = true; + bool analyzed_variable_scope = false; +}; + +struct SPIRAccessChain : IVariant +{ + enum + { + type = TypeAccessChain + }; + + SPIRAccessChain(uint32_t basetype_, spv::StorageClass storage_, std::string base_, std::string dynamic_index_, + int32_t static_index_) + : basetype(basetype_) + , storage(storage_) + , base(base_) + , dynamic_index(std::move(dynamic_index_)) + , static_index(static_index_) + { + } + + // The access chain represents an offset into a buffer. + // Some backends need more complicated handling of access chains to be able to use buffers, like HLSL + // which has no usable buffer type ala GLSL SSBOs. + // StructuredBuffer is too limited, so our only option is to deal with ByteAddressBuffer which works with raw addresses. + + uint32_t basetype; + spv::StorageClass storage; + std::string base; + std::string dynamic_index; + int32_t static_index; + + uint32_t loaded_from = 0; + uint32_t matrix_stride = 0; + bool row_major_matrix = false; + bool immutable = false; +}; + +struct SPIRVariable : IVariant +{ + enum + { + type = TypeVariable + }; + + SPIRVariable() = default; + SPIRVariable(uint32_t basetype_, spv::StorageClass storage_, uint32_t initializer_ = 0, uint32_t basevariable_ = 0) + : basetype(basetype_) + , storage(storage_) + , initializer(initializer_) + , basevariable(basevariable_) + { + } + + uint32_t basetype = 0; + spv::StorageClass storage = spv::StorageClassGeneric; + uint32_t decoration = 0; + uint32_t initializer = 0; + uint32_t basevariable = 0; + + std::vector dereference_chain; + bool compat_builtin = false; + + // If a variable is shadowed, we only statically assign to it + // and never actually emit a statement for it. + // When we read the variable as an expression, just forward + // shadowed_id as the expression. + bool statically_assigned = false; + uint32_t static_expression = 0; + + // Temporaries which can remain forwarded as long as this variable is not modified. + std::vector dependees; + bool forwardable = true; + + bool deferred_declaration = false; + bool phi_variable = false; + bool remapped_variable = false; + uint32_t remapped_components = 0; + + // The block which dominates all access to this variable. + uint32_t dominator = 0; + // If true, this variable is a loop variable, when accessing the variable + // outside a loop, + // we should statically forward it. + bool loop_variable = false; + // Set to true while we're inside the for loop. + bool loop_variable_enable = false; + + SPIRFunction::Parameter *parameter = nullptr; +}; + +struct SPIRConstant : IVariant +{ + enum + { + type = TypeConstant + }; + + union Constant { + uint32_t u32; + int32_t i32; + float f32; + + uint64_t u64; + int64_t i64; + double f64; + }; + + struct ConstantVector + { + Constant r[4]; + // If != 0, this element is a specialization constant, and we should keep track of it as such. + uint32_t id[4] = {}; + uint32_t vecsize = 1; + }; + + struct ConstantMatrix + { + ConstantVector c[4]; + // If != 0, this column is a specialization constant, and we should keep track of it as such. + uint32_t id[4] = {}; + uint32_t columns = 1; + }; + + inline uint32_t specialization_constant_id(uint32_t col, uint32_t row) const + { + return m.c[col].id[row]; + } + + inline uint32_t specialization_constant_id(uint32_t col) const + { + return m.id[col]; + } + + inline uint32_t scalar(uint32_t col = 0, uint32_t row = 0) const + { + return m.c[col].r[row].u32; + } + + inline float scalar_f32(uint32_t col = 0, uint32_t row = 0) const + { + return m.c[col].r[row].f32; + } + + inline int32_t scalar_i32(uint32_t col = 0, uint32_t row = 0) const + { + return m.c[col].r[row].i32; + } + + inline double scalar_f64(uint32_t col = 0, uint32_t row = 0) const + { + return m.c[col].r[row].f64; + } + + inline int64_t scalar_i64(uint32_t col = 0, uint32_t row = 0) const + { + return m.c[col].r[row].i64; + } + + inline uint64_t scalar_u64(uint32_t col = 0, uint32_t row = 0) const + { + return m.c[col].r[row].u64; + } + + inline const ConstantVector &vector() const + { + return m.c[0]; + } + + inline uint32_t vector_size() const + { + return m.c[0].vecsize; + } + + inline uint32_t columns() const + { + return m.columns; + } + + inline void make_null(const SPIRType &constant_type_) + { + std::memset(&m, 0, sizeof(m)); + m.columns = constant_type_.columns; + for (auto &c : m.c) + c.vecsize = constant_type_.vecsize; + } + + explicit SPIRConstant(uint32_t constant_type_) + : constant_type(constant_type_) + { + } + + SPIRConstant(uint32_t constant_type_, const uint32_t *elements, uint32_t num_elements, bool specialized) + : constant_type(constant_type_) + , specialization(specialized) + { + subconstants.insert(end(subconstants), elements, elements + num_elements); + specialization = specialized; + } + + // Construct scalar (32-bit). + SPIRConstant(uint32_t constant_type_, uint32_t v0, bool specialized) + : constant_type(constant_type_) + , specialization(specialized) + { + m.c[0].r[0].u32 = v0; + m.c[0].vecsize = 1; + m.columns = 1; + } + + // Construct scalar (64-bit). + SPIRConstant(uint32_t constant_type_, uint64_t v0, bool specialized) + : constant_type(constant_type_) + , specialization(specialized) + { + m.c[0].r[0].u64 = v0; + m.c[0].vecsize = 1; + m.columns = 1; + } + + // Construct vectors and matrices. + SPIRConstant(uint32_t constant_type_, const SPIRConstant *const *vector_elements, uint32_t num_elements, + bool specialized) + : constant_type(constant_type_) + , specialization(specialized) + { + bool matrix = vector_elements[0]->m.c[0].vecsize > 1; + + if (matrix) + { + m.columns = num_elements; + + for (uint32_t i = 0; i < num_elements; i++) + { + m.c[i] = vector_elements[i]->m.c[0]; + if (vector_elements[i]->specialization) + m.id[i] = vector_elements[i]->self; + } + } + else + { + m.c[0].vecsize = num_elements; + m.columns = 1; + + for (uint32_t i = 0; i < num_elements; i++) + { + m.c[0].r[i] = vector_elements[i]->m.c[0].r[0]; + if (vector_elements[i]->specialization) + m.c[0].id[i] = vector_elements[i]->self; + } + } + } + + uint32_t constant_type; + ConstantMatrix m; + bool specialization = false; // If this constant is a specialization constant (i.e. created with OpSpecConstant*). + bool is_used_as_array_length = + false; // If this constant is used as an array length which creates specialization restrictions on some backends. + + // For composites which are constant arrays, etc. + std::vector subconstants; +}; + +class Variant +{ +public: + // MSVC 2013 workaround, we shouldn't need these constructors. + Variant() = default; + Variant(Variant &&other) + { + *this = std::move(other); + } + Variant &operator=(Variant &&other) + { + if (this != &other) + { + holder = move(other.holder); + type = other.type; + other.type = TypeNone; + } + return *this; + } + + void set(std::unique_ptr val, uint32_t new_type) + { + holder = std::move(val); + if (type != TypeNone && type != new_type) + SPIRV_CROSS_THROW("Overwriting a variant with new type."); + type = new_type; + } + + template + T &get() + { + if (!holder) + SPIRV_CROSS_THROW("nullptr"); + if (T::type != type) + SPIRV_CROSS_THROW("Bad cast"); + return *static_cast(holder.get()); + } + + template + const T &get() const + { + if (!holder) + SPIRV_CROSS_THROW("nullptr"); + if (T::type != type) + SPIRV_CROSS_THROW("Bad cast"); + return *static_cast(holder.get()); + } + + uint32_t get_type() const + { + return type; + } + uint32_t get_id() const + { + return holder ? holder->self : 0; + } + bool empty() const + { + return !holder; + } + void reset() + { + holder.reset(); + type = TypeNone; + } + +private: + std::unique_ptr holder; + uint32_t type = TypeNone; +}; + +template +T &variant_get(Variant &var) +{ + return var.get(); +} + +template +const T &variant_get(const Variant &var) +{ + return var.get(); +} + +template +T &variant_set(Variant &var, P &&... args) +{ + auto uptr = std::unique_ptr(new T(std::forward

(args)...)); + auto ptr = uptr.get(); + var.set(std::move(uptr), T::type); + return *ptr; +} + +struct Meta +{ + struct Decoration + { + std::string alias; + std::string qualified_alias; + uint64_t decoration_flags = 0; + spv::BuiltIn builtin_type; + uint32_t location = 0; + uint32_t set = 0; + uint32_t binding = 0; + uint32_t offset = 0; + uint32_t array_stride = 0; + uint32_t matrix_stride = 0; + uint32_t input_attachment = 0; + uint32_t spec_id = 0; + bool builtin = false; + }; + + Decoration decoration; + std::vector members; + uint32_t sampler = 0; + + std::unordered_map decoration_word_offset; + + // Used when the parser has detected a candidate identifier which matches + // known "magic" counter buffers as emitted by HLSL frontends. + // We will need to match the identifiers by name later when reflecting resources. + // We could use the regular alias later, but the alias will be mangled when parsing SPIR-V because the identifier + // is not a valid identifier in any high-level language. + std::string hlsl_magic_counter_buffer_name; + bool hlsl_magic_counter_buffer_candidate = false; +}; + +// A user callback that remaps the type of any variable. +// var_name is the declared name of the variable. +// name_of_type is the textual name of the type which will be used in the code unless written to by the callback. +using VariableTypeRemapCallback = + std::function; + +class ClassicLocale +{ +public: + ClassicLocale() + { + old = std::locale::global(std::locale::classic()); + } + ~ClassicLocale() + { + std::locale::global(old); + } + +private: + std::locale old; +}; +} + +#endif diff --git a/spirv_cpp.cpp b/spirv_cpp.cpp new file mode 100644 index 0000000000..69ef138e43 --- /dev/null +++ b/spirv_cpp.cpp @@ -0,0 +1,522 @@ +/* + * Copyright 2015-2018 ARM Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "spirv_cpp.hpp" + +using namespace spv; +using namespace spirv_cross; +using namespace std; + +void CompilerCPP::emit_buffer_block(const SPIRVariable &var) +{ + add_resource_name(var.self); + + auto &type = get(var.basetype); + auto instance_name = to_name(var.self); + + uint32_t descriptor_set = meta[var.self].decoration.set; + uint32_t binding = meta[var.self].decoration.binding; + + emit_block_struct(type); + auto buffer_name = to_name(type.self); + + statement("internal::Resource<", buffer_name, type_to_array_glsl(type), "> ", instance_name, "__;"); + statement_no_indent("#define ", instance_name, " __res->", instance_name, "__.get()"); + resource_registrations.push_back( + join("s.register_resource(", instance_name, "__", ", ", descriptor_set, ", ", binding, ");")); + statement(""); +} + +void CompilerCPP::emit_interface_block(const SPIRVariable &var) +{ + add_resource_name(var.self); + + auto &type = get(var.basetype); + + const char *qual = var.storage == StorageClassInput ? "StageInput" : "StageOutput"; + const char *lowerqual = var.storage == StorageClassInput ? "stage_input" : "stage_output"; + auto instance_name = to_name(var.self); + uint32_t location = meta[var.self].decoration.location; + + string buffer_name; + auto flags = meta[type.self].decoration.decoration_flags; + if (flags & (1ull << DecorationBlock)) + { + emit_block_struct(type); + buffer_name = to_name(type.self); + } + else + buffer_name = type_to_glsl(type); + + statement("internal::", qual, "<", buffer_name, type_to_array_glsl(type), "> ", instance_name, "__;"); + statement_no_indent("#define ", instance_name, " __res->", instance_name, "__.get()"); + resource_registrations.push_back(join("s.register_", lowerqual, "(", instance_name, "__", ", ", location, ");")); + statement(""); +} + +void CompilerCPP::emit_shared(const SPIRVariable &var) +{ + add_resource_name(var.self); + + auto instance_name = to_name(var.self); + statement(CompilerGLSL::variable_decl(var), ";"); + statement_no_indent("#define ", instance_name, " __res->", instance_name); +} + +void CompilerCPP::emit_uniform(const SPIRVariable &var) +{ + add_resource_name(var.self); + + auto &type = get(var.basetype); + auto instance_name = to_name(var.self); + + uint32_t descriptor_set = meta[var.self].decoration.set; + uint32_t binding = meta[var.self].decoration.binding; + uint32_t location = meta[var.self].decoration.location; + + string type_name = type_to_glsl(type); + remap_variable_type_name(type, instance_name, type_name); + + if (type.basetype == SPIRType::Image || type.basetype == SPIRType::SampledImage || + type.basetype == SPIRType::AtomicCounter) + { + statement("internal::Resource<", type_name, type_to_array_glsl(type), "> ", instance_name, "__;"); + statement_no_indent("#define ", instance_name, " __res->", instance_name, "__.get()"); + resource_registrations.push_back( + join("s.register_resource(", instance_name, "__", ", ", descriptor_set, ", ", binding, ");")); + } + else + { + statement("internal::UniformConstant<", type_name, type_to_array_glsl(type), "> ", instance_name, "__;"); + statement_no_indent("#define ", instance_name, " __res->", instance_name, "__.get()"); + resource_registrations.push_back( + join("s.register_uniform_constant(", instance_name, "__", ", ", location, ");")); + } + + statement(""); +} + +void CompilerCPP::emit_push_constant_block(const SPIRVariable &var) +{ + add_resource_name(var.self); + + auto &type = get(var.basetype); + auto &flags = meta[var.self].decoration.decoration_flags; + if ((flags & (1ull << DecorationBinding)) || (flags & (1ull << DecorationDescriptorSet))) + SPIRV_CROSS_THROW("Push constant blocks cannot be compiled to GLSL with Binding or Set syntax. " + "Remap to location with reflection API first or disable these decorations."); + + emit_block_struct(type); + auto buffer_name = to_name(type.self); + auto instance_name = to_name(var.self); + + statement("internal::PushConstant<", buffer_name, type_to_array_glsl(type), "> ", instance_name, ";"); + statement_no_indent("#define ", instance_name, " __res->", instance_name, ".get()"); + resource_registrations.push_back(join("s.register_push_constant(", instance_name, "__", ");")); + statement(""); +} + +void CompilerCPP::emit_block_struct(SPIRType &type) +{ + // C++ can't do interface blocks, so we fake it by emitting a separate struct. + // However, these structs are not allowed to alias anything, so remove it before + // emitting the struct. + // + // The type we have here needs to be resolved to the non-pointer type so we can remove aliases. + auto &self = get(type.self); + self.type_alias = 0; + emit_struct(self); +} + +void CompilerCPP::emit_resources() +{ + // Output all basic struct types which are not Block or BufferBlock as these are declared inplace + // when such variables are instantiated. + for (auto &id : ids) + { + if (id.get_type() == TypeType) + { + auto &type = id.get(); + if (type.basetype == SPIRType::Struct && type.array.empty() && !type.pointer && + (meta[type.self].decoration.decoration_flags & + ((1ull << DecorationBlock) | (1ull << DecorationBufferBlock))) == 0) + { + emit_struct(type); + } + } + } + + statement("struct Resources : ", resource_type); + begin_scope(); + + // Output UBOs and SSBOs + for (auto &id : ids) + { + if (id.get_type() == TypeVariable) + { + auto &var = id.get(); + auto &type = get(var.basetype); + + if (var.storage != StorageClassFunction && type.pointer && type.storage == StorageClassUniform && + !is_hidden_variable(var) && + (meta[type.self].decoration.decoration_flags & + ((1ull << DecorationBlock) | (1ull << DecorationBufferBlock)))) + { + emit_buffer_block(var); + } + } + } + + // Output push constant blocks + for (auto &id : ids) + { + if (id.get_type() == TypeVariable) + { + auto &var = id.get(); + auto &type = get(var.basetype); + if (!is_hidden_variable(var) && var.storage != StorageClassFunction && type.pointer && + type.storage == StorageClassPushConstant) + { + emit_push_constant_block(var); + } + } + } + + // Output in/out interfaces. + for (auto &id : ids) + { + if (id.get_type() == TypeVariable) + { + auto &var = id.get(); + auto &type = get(var.basetype); + + if (var.storage != StorageClassFunction && !is_hidden_variable(var) && type.pointer && + (var.storage == StorageClassInput || var.storage == StorageClassOutput) && + interface_variable_exists_in_entry_point(var.self)) + { + emit_interface_block(var); + } + } + } + + // Output Uniform Constants (values, samplers, images, etc). + for (auto &id : ids) + { + if (id.get_type() == TypeVariable) + { + auto &var = id.get(); + auto &type = get(var.basetype); + + if (var.storage != StorageClassFunction && !is_hidden_variable(var) && type.pointer && + (type.storage == StorageClassUniformConstant || type.storage == StorageClassAtomicCounter)) + { + emit_uniform(var); + } + } + } + + // Global variables. + bool emitted = false; + for (auto global : global_variables) + { + auto &var = get(global); + if (var.storage == StorageClassWorkgroup) + { + emit_shared(var); + emitted = true; + } + } + + if (emitted) + statement(""); + + declare_undefined_values(); + + statement("inline void init(spirv_cross_shader& s)"); + begin_scope(); + statement(resource_type, "::init(s);"); + for (auto ® : resource_registrations) + statement(reg); + end_scope(); + resource_registrations.clear(); + + end_scope_decl(); + + statement(""); + statement("Resources* __res;"); + if (get_entry_point().model == ExecutionModelGLCompute) + statement("ComputePrivateResources __priv_res;"); + statement(""); + + // Emit regular globals which are allocated per invocation. + emitted = false; + for (auto global : global_variables) + { + auto &var = get(global); + if (var.storage == StorageClassPrivate) + { + if (var.storage == StorageClassWorkgroup) + emit_shared(var); + else + statement(CompilerGLSL::variable_decl(var), ";"); + emitted = true; + } + } + + if (emitted) + statement(""); +} + +string CompilerCPP::compile() +{ + // Force a classic "C" locale, reverts when function returns + ClassicLocale classic_locale; + + // Do not deal with ES-isms like precision, older extensions and such. + options.es = false; + options.version = 450; + backend.float_literal_suffix = true; + backend.double_literal_suffix = false; + backend.long_long_literal_suffix = true; + backend.uint32_t_literal_suffix = true; + backend.basic_int_type = "int32_t"; + backend.basic_uint_type = "uint32_t"; + backend.swizzle_is_function = true; + backend.shared_is_implied = true; + backend.flexible_member_array_supported = false; + backend.explicit_struct_type = true; + backend.use_initializer_list = true; + + update_active_builtins(); + + uint32_t pass_count = 0; + do + { + if (pass_count >= 3) + SPIRV_CROSS_THROW("Over 3 compilation loops detected. Must be a bug!"); + + resource_registrations.clear(); + reset(); + + // Move constructor for this type is broken on GCC 4.9 ... + buffer = unique_ptr(new ostringstream()); + + emit_header(); + emit_resources(); + + emit_function(get(entry_point), 0); + + pass_count++; + } while (force_recompile); + + // Match opening scope of emit_header(). + end_scope_decl(); + // namespace + end_scope(); + + // Emit C entry points + emit_c_linkage(); + + // Entry point in CPP is always main() for the time being. + get_entry_point().name = "main"; + + return buffer->str(); +} + +void CompilerCPP::emit_c_linkage() +{ + statement(""); + + statement("spirv_cross_shader_t *spirv_cross_construct(void)"); + begin_scope(); + statement("return new ", impl_type, "();"); + end_scope(); + + statement(""); + statement("void spirv_cross_destruct(spirv_cross_shader_t *shader)"); + begin_scope(); + statement("delete static_cast<", impl_type, "*>(shader);"); + end_scope(); + + statement(""); + statement("void spirv_cross_invoke(spirv_cross_shader_t *shader)"); + begin_scope(); + statement("static_cast<", impl_type, "*>(shader)->invoke();"); + end_scope(); + + statement(""); + statement("static const struct spirv_cross_interface vtable ="); + begin_scope(); + statement("spirv_cross_construct,"); + statement("spirv_cross_destruct,"); + statement("spirv_cross_invoke,"); + end_scope_decl(); + + statement(""); + statement("const struct spirv_cross_interface *", + interface_name.empty() ? string("spirv_cross_get_interface") : interface_name, "(void)"); + begin_scope(); + statement("return &vtable;"); + end_scope(); +} + +void CompilerCPP::emit_function_prototype(SPIRFunction &func, uint64_t) +{ + local_variable_names = resource_names; + string decl; + + auto &type = get(func.return_type); + decl += "inline "; + decl += type_to_glsl(type); + decl += " "; + + if (func.self == entry_point) + { + decl += "main"; + processing_entry_point = true; + } + else + decl += to_name(func.self); + + decl += "("; + for (auto &arg : func.arguments) + { + add_local_variable_name(arg.id); + + decl += argument_decl(arg); + if (&arg != &func.arguments.back()) + decl += ", "; + + // Hold a pointer to the parameter so we can invalidate the readonly field if needed. + auto *var = maybe_get(arg.id); + if (var) + var->parameter = &arg; + } + + decl += ")"; + statement(decl); +} + +string CompilerCPP::argument_decl(const SPIRFunction::Parameter &arg) +{ + auto &type = expression_type(arg.id); + bool constref = !type.pointer || arg.write_count == 0; + + auto &var = get(arg.id); + + string base = type_to_glsl(type); + string variable_name = to_name(var.self); + remap_variable_type_name(type, variable_name, base); + + for (uint32_t i = 0; i < type.array.size(); i++) + base = join("std::array<", base, ", ", to_array_size(type, i), ">"); + + return join(constref ? "const " : "", base, " &", variable_name); +} + +string CompilerCPP::variable_decl(const SPIRType &type, const string &name, uint32_t /* id */) +{ + string base = type_to_glsl(type); + remap_variable_type_name(type, name, base); + bool runtime = false; + + for (uint32_t i = 0; i < type.array.size(); i++) + { + auto &array = type.array[i]; + if (!array && type.array_size_literal[i]) + { + // Avoid using runtime arrays with std::array since this is undefined. + // Runtime arrays cannot be passed around as values, so this is fine. + runtime = true; + } + else + base = join("std::array<", base, ", ", to_array_size(type, i), ">"); + } + base += ' '; + return base + name + (runtime ? "[1]" : ""); +} + +void CompilerCPP::emit_header() +{ + auto &execution = get_entry_point(); + + statement("// This C++ shader is autogenerated by spirv-cross."); + statement("#include \"spirv_cross/internal_interface.hpp\""); + statement("#include \"spirv_cross/external_interface.h\""); + // Needed to properly implement GLSL-style arrays. + statement("#include "); + statement("#include "); + statement(""); + statement("using namespace spirv_cross;"); + statement("using namespace glm;"); + statement(""); + + statement("namespace Impl"); + begin_scope(); + + switch (execution.model) + { + case ExecutionModelGeometry: + case ExecutionModelTessellationControl: + case ExecutionModelTessellationEvaluation: + case ExecutionModelGLCompute: + case ExecutionModelFragment: + case ExecutionModelVertex: + statement("struct Shader"); + begin_scope(); + break; + + default: + SPIRV_CROSS_THROW("Unsupported execution model."); + } + + switch (execution.model) + { + case ExecutionModelGeometry: + impl_type = "GeometryShader"; + resource_type = "GeometryResources"; + break; + + case ExecutionModelVertex: + impl_type = "VertexShader"; + resource_type = "VertexResources"; + break; + + case ExecutionModelFragment: + impl_type = "FragmentShader"; + resource_type = "FragmentResources"; + break; + + case ExecutionModelGLCompute: + impl_type = join("ComputeShader"); + resource_type = "ComputeResources"; + break; + + case ExecutionModelTessellationControl: + impl_type = "TessControlShader"; + resource_type = "TessControlResources"; + break; + + case ExecutionModelTessellationEvaluation: + impl_type = "TessEvaluationShader"; + resource_type = "TessEvaluationResources"; + break; + + default: + SPIRV_CROSS_THROW("Unsupported execution model."); + } +} diff --git a/spirv_cpp.hpp b/spirv_cpp.hpp new file mode 100644 index 0000000000..57f815f3c0 --- /dev/null +++ b/spirv_cpp.hpp @@ -0,0 +1,77 @@ +/* + * Copyright 2015-2018 ARM Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SPIRV_CROSS_CPP_HPP +#define SPIRV_CROSS_CPP_HPP + +#include "spirv_glsl.hpp" +#include +#include + +namespace spirv_cross +{ +class CompilerCPP : public CompilerGLSL +{ +public: + CompilerCPP(std::vector spirv_) + : CompilerGLSL(move(spirv_)) + { + } + + CompilerCPP(const uint32_t *ir, size_t word_count) + : CompilerGLSL(ir, word_count) + { + } + + std::string compile() override; + + // Sets a custom symbol name that can override + // spirv_cross_get_interface. + // + // Useful when several shader interfaces are linked + // statically into the same binary. + void set_interface_name(std::string name) + { + interface_name = std::move(name); + } + +private: + void emit_header() override; + void emit_c_linkage(); + void emit_function_prototype(SPIRFunction &func, uint64_t return_flags) override; + + void emit_resources(); + void emit_buffer_block(const SPIRVariable &type) override; + void emit_push_constant_block(const SPIRVariable &var) override; + void emit_interface_block(const SPIRVariable &type); + void emit_block_chain(SPIRBlock &block); + void emit_uniform(const SPIRVariable &var) override; + void emit_shared(const SPIRVariable &var); + void emit_block_struct(SPIRType &type); + std::string variable_decl(const SPIRType &type, const std::string &name, uint32_t id) override; + + std::string argument_decl(const SPIRFunction::Parameter &arg); + + std::vector resource_registrations; + std::string impl_type; + std::string resource_type; + uint32_t shared_counter = 0; + + std::string interface_name; +}; +} + +#endif diff --git a/spirv_cross.cpp b/spirv_cross.cpp new file mode 100644 index 0000000000..996c0205c3 --- /dev/null +++ b/spirv_cross.cpp @@ -0,0 +1,3957 @@ +/* + * Copyright 2015-2018 ARM Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "spirv_cross.hpp" +#include "GLSL.std.450.h" +#include "spirv_cfg.hpp" +#include +#include +#include + +using namespace std; +using namespace spv; +using namespace spirv_cross; + +#define log(...) fprintf(stderr, __VA_ARGS__) + +static string ensure_valid_identifier(const string &name, bool member) +{ + // Functions in glslangValidator are mangled with name( stuff. + // Normally, we would never see '(' in any legal identifiers, so just strip them out. + auto str = name.substr(0, name.find('(')); + + for (uint32_t i = 0; i < str.size(); i++) + { + auto &c = str[i]; + + if (member) + { + // _m variables are reserved by the internal implementation, + // otherwise, make sure the name is a valid identifier. + if (i == 0) + c = isalpha(c) ? c : '_'; + else if (i == 2 && str[0] == '_' && str[1] == 'm') + c = isalpha(c) ? c : '_'; + else + c = isalnum(c) ? c : '_'; + } + else + { + // _ variables are reserved by the internal implementation, + // otherwise, make sure the name is a valid identifier. + if (i == 0 || (str[0] == '_' && i == 1)) + c = isalpha(c) ? c : '_'; + else + c = isalnum(c) ? c : '_'; + } + } + return str; +} + +Instruction::Instruction(const vector &spirv, uint32_t &index) +{ + op = spirv[index] & 0xffff; + count = (spirv[index] >> 16) & 0xffff; + + if (count == 0) + SPIRV_CROSS_THROW("SPIR-V instructions cannot consume 0 words. Invalid SPIR-V file."); + + offset = index + 1; + length = count - 1; + + index += count; + + if (index > spirv.size()) + SPIRV_CROSS_THROW("SPIR-V instruction goes out of bounds."); +} + +Compiler::Compiler(vector ir) + : spirv(move(ir)) +{ + parse(); +} + +Compiler::Compiler(const uint32_t *ir, size_t word_count) + : spirv(ir, ir + word_count) +{ + parse(); +} + +string Compiler::compile() +{ + // Force a classic "C" locale, reverts when function returns + ClassicLocale classic_locale; + return ""; +} + +bool Compiler::variable_storage_is_aliased(const SPIRVariable &v) +{ + auto &type = get(v.basetype); + bool ssbo = v.storage == StorageClassStorageBuffer || + ((meta[type.self].decoration.decoration_flags & (1ull << DecorationBufferBlock)) != 0); + bool image = type.basetype == SPIRType::Image; + bool counter = type.basetype == SPIRType::AtomicCounter; + bool is_restrict = (meta[v.self].decoration.decoration_flags & (1ull << DecorationRestrict)) != 0; + return !is_restrict && (ssbo || image || counter); +} + +bool Compiler::block_is_pure(const SPIRBlock &block) +{ + for (auto &i : block.ops) + { + auto ops = stream(i); + auto op = static_cast(i.op); + + switch (op) + { + case OpFunctionCall: + { + uint32_t func = ops[2]; + if (!function_is_pure(get(func))) + return false; + break; + } + + case OpCopyMemory: + case OpStore: + { + auto &type = expression_type(ops[0]); + if (type.storage != StorageClassFunction) + return false; + break; + } + + case OpImageWrite: + return false; + + // Atomics are impure. + case OpAtomicLoad: + case OpAtomicStore: + case OpAtomicExchange: + case OpAtomicCompareExchange: + case OpAtomicCompareExchangeWeak: + case OpAtomicIIncrement: + case OpAtomicIDecrement: + case OpAtomicIAdd: + case OpAtomicISub: + case OpAtomicSMin: + case OpAtomicUMin: + case OpAtomicSMax: + case OpAtomicUMax: + case OpAtomicAnd: + case OpAtomicOr: + case OpAtomicXor: + return false; + + // Geometry shader builtins modify global state. + case OpEndPrimitive: + case OpEmitStreamVertex: + case OpEndStreamPrimitive: + case OpEmitVertex: + return false; + + // Barriers disallow any reordering, so we should treat blocks with barrier as writing. + case OpControlBarrier: + case OpMemoryBarrier: + return false; + + // OpExtInst is potentially impure depending on extension, but GLSL builtins are at least pure. + + default: + break; + } + } + + return true; +} + +string Compiler::to_name(uint32_t id, bool allow_alias) const +{ + if (allow_alias && ids.at(id).get_type() == TypeType) + { + // If this type is a simple alias, emit the + // name of the original type instead. + // We don't want to override the meta alias + // as that can be overridden by the reflection APIs after parse. + auto &type = get(id); + if (type.type_alias) + return to_name(type.type_alias); + } + + if (meta[id].decoration.alias.empty()) + return join("_", id); + else + return meta.at(id).decoration.alias; +} + +bool Compiler::function_is_pure(const SPIRFunction &func) +{ + for (auto block : func.blocks) + { + if (!block_is_pure(get(block))) + { + //fprintf(stderr, "Function %s is impure!\n", to_name(func.self).c_str()); + return false; + } + } + + //fprintf(stderr, "Function %s is pure!\n", to_name(func.self).c_str()); + return true; +} + +void Compiler::register_global_read_dependencies(const SPIRBlock &block, uint32_t id) +{ + for (auto &i : block.ops) + { + auto ops = stream(i); + auto op = static_cast(i.op); + + switch (op) + { + case OpFunctionCall: + { + uint32_t func = ops[2]; + register_global_read_dependencies(get(func), id); + break; + } + + case OpLoad: + case OpImageRead: + { + // If we're in a storage class which does not get invalidated, adding dependencies here is no big deal. + auto *var = maybe_get_backing_variable(ops[2]); + if (var && var->storage != StorageClassFunction) + { + auto &type = get(var->basetype); + + // InputTargets are immutable. + if (type.basetype != SPIRType::Image && type.image.dim != DimSubpassData) + var->dependees.push_back(id); + } + break; + } + + default: + break; + } + } +} + +void Compiler::register_global_read_dependencies(const SPIRFunction &func, uint32_t id) +{ + for (auto block : func.blocks) + register_global_read_dependencies(get(block), id); +} + +SPIRVariable *Compiler::maybe_get_backing_variable(uint32_t chain) +{ + auto *var = maybe_get(chain); + if (!var) + { + auto *cexpr = maybe_get(chain); + if (cexpr) + var = maybe_get(cexpr->loaded_from); + + auto *access_chain = maybe_get(chain); + if (access_chain) + var = maybe_get(access_chain->loaded_from); + } + + return var; +} + +void Compiler::register_read(uint32_t expr, uint32_t chain, bool forwarded) +{ + auto &e = get(expr); + auto *var = maybe_get_backing_variable(chain); + + if (var) + { + e.loaded_from = var->self; + + // If the backing variable is immutable, we do not need to depend on the variable. + if (forwarded && !is_immutable(var->self)) + var->dependees.push_back(e.self); + + // If we load from a parameter, make sure we create "inout" if we also write to the parameter. + // The default is "in" however, so we never invalidate our compilation by reading. + if (var && var->parameter) + var->parameter->read_count++; + } +} + +void Compiler::register_write(uint32_t chain) +{ + auto *var = maybe_get(chain); + if (!var) + { + // If we're storing through an access chain, invalidate the backing variable instead. + auto *expr = maybe_get(chain); + if (expr && expr->loaded_from) + var = maybe_get(expr->loaded_from); + + auto *access_chain = maybe_get(chain); + if (access_chain && access_chain->loaded_from) + var = maybe_get(access_chain->loaded_from); + } + + if (var) + { + // If our variable is in a storage class which can alias with other buffers, + // invalidate all variables which depend on aliased variables. + if (variable_storage_is_aliased(*var)) + flush_all_aliased_variables(); + else if (var) + flush_dependees(*var); + + // We tried to write to a parameter which is not marked with out qualifier, force a recompile. + if (var->parameter && var->parameter->write_count == 0) + { + var->parameter->write_count++; + force_recompile = true; + } + } +} + +void Compiler::flush_dependees(SPIRVariable &var) +{ + for (auto expr : var.dependees) + invalid_expressions.insert(expr); + var.dependees.clear(); +} + +void Compiler::flush_all_aliased_variables() +{ + for (auto aliased : aliased_variables) + flush_dependees(get(aliased)); +} + +void Compiler::flush_all_atomic_capable_variables() +{ + for (auto global : global_variables) + flush_dependees(get(global)); + flush_all_aliased_variables(); +} + +void Compiler::flush_all_active_variables() +{ + // Invalidate all temporaries we read from variables in this block since they were forwarded. + // Invalidate all temporaries we read from globals. + for (auto &v : current_function->local_variables) + flush_dependees(get(v)); + for (auto &arg : current_function->arguments) + flush_dependees(get(arg.id)); + for (auto global : global_variables) + flush_dependees(get(global)); + + flush_all_aliased_variables(); +} + +uint32_t Compiler::expression_type_id(uint32_t id) const +{ + switch (ids[id].get_type()) + { + case TypeVariable: + return get(id).basetype; + + case TypeExpression: + return get(id).expression_type; + + case TypeConstant: + return get(id).constant_type; + + case TypeConstantOp: + return get(id).basetype; + + case TypeUndef: + return get(id).basetype; + + case TypeCombinedImageSampler: + return get(id).combined_type; + + case TypeAccessChain: + return get(id).basetype; + + default: + SPIRV_CROSS_THROW("Cannot resolve expression type."); + } +} + +const SPIRType &Compiler::expression_type(uint32_t id) const +{ + return get(expression_type_id(id)); +} + +bool Compiler::expression_is_lvalue(uint32_t id) const +{ + auto &type = expression_type(id); + switch (type.basetype) + { + case SPIRType::SampledImage: + case SPIRType::Image: + case SPIRType::Sampler: + return false; + + default: + return true; + } +} + +bool Compiler::is_immutable(uint32_t id) const +{ + if (ids[id].get_type() == TypeVariable) + { + auto &var = get(id); + + // Anything we load from the UniformConstant address space is guaranteed to be immutable. + bool pointer_to_const = var.storage == StorageClassUniformConstant; + return pointer_to_const || var.phi_variable || !expression_is_lvalue(id); + } + else if (ids[id].get_type() == TypeAccessChain) + return get(id).immutable; + else if (ids[id].get_type() == TypeExpression) + return get(id).immutable; + else if (ids[id].get_type() == TypeConstant || ids[id].get_type() == TypeConstantOp || + ids[id].get_type() == TypeUndef) + return true; + else + return false; +} + +static inline bool storage_class_is_interface(spv::StorageClass storage) +{ + switch (storage) + { + case StorageClassInput: + case StorageClassOutput: + case StorageClassUniform: + case StorageClassUniformConstant: + case StorageClassAtomicCounter: + case StorageClassPushConstant: + case StorageClassStorageBuffer: + return true; + + default: + return false; + } +} + +bool Compiler::is_hidden_variable(const SPIRVariable &var, bool include_builtins) const +{ + if ((is_builtin_variable(var) && !include_builtins) || var.remapped_variable) + return true; + + // Combined image samplers are always considered active as they are "magic" variables. + if (find_if(begin(combined_image_samplers), end(combined_image_samplers), [&var](const CombinedImageSampler &samp) { + return samp.combined_id == var.self; + }) != end(combined_image_samplers)) + { + return false; + } + + bool hidden = false; + if (check_active_interface_variables && storage_class_is_interface(var.storage)) + hidden = active_interface_variables.find(var.self) == end(active_interface_variables); + return hidden; +} + +bool Compiler::is_builtin_variable(const SPIRVariable &var) const +{ + if (var.compat_builtin || meta[var.self].decoration.builtin) + return true; + + // We can have builtin structs as well. If one member of a struct is builtin, the struct must also be builtin. + for (auto &m : meta[get(var.basetype).self].members) + if (m.builtin) + return true; + + return false; +} + +bool Compiler::is_member_builtin(const SPIRType &type, uint32_t index, BuiltIn *builtin) const +{ + auto &memb = meta[type.self].members; + if (index < memb.size() && memb[index].builtin) + { + if (builtin) + *builtin = memb[index].builtin_type; + return true; + } + + return false; +} + +bool Compiler::is_scalar(const SPIRType &type) const +{ + return type.vecsize == 1 && type.columns == 1; +} + +bool Compiler::is_vector(const SPIRType &type) const +{ + return type.vecsize > 1 && type.columns == 1; +} + +bool Compiler::is_matrix(const SPIRType &type) const +{ + return type.vecsize > 1 && type.columns > 1; +} + +bool Compiler::is_array(const SPIRType &type) const +{ + return !type.array.empty(); +} + +ShaderResources Compiler::get_shader_resources() const +{ + return get_shader_resources(nullptr); +} + +ShaderResources Compiler::get_shader_resources(const unordered_set &active_variables) const +{ + return get_shader_resources(&active_variables); +} + +bool Compiler::InterfaceVariableAccessHandler::handle(Op opcode, const uint32_t *args, uint32_t length) +{ + uint32_t variable = 0; + switch (opcode) + { + // Need this first, otherwise, GCC complains about unhandled switch statements. + default: + break; + + case OpFunctionCall: + { + // Invalid SPIR-V. + if (length < 3) + return false; + + uint32_t count = length - 3; + args += 3; + for (uint32_t i = 0; i < count; i++) + { + auto *var = compiler.maybe_get(args[i]); + if (var && storage_class_is_interface(var->storage)) + variables.insert(args[i]); + } + break; + } + + case OpAtomicStore: + case OpStore: + // Invalid SPIR-V. + if (length < 1) + return false; + variable = args[0]; + break; + + case OpCopyMemory: + { + if (length < 2) + return false; + + auto *var = compiler.maybe_get(args[0]); + if (var && storage_class_is_interface(var->storage)) + variables.insert(variable); + + var = compiler.maybe_get(args[1]); + if (var && storage_class_is_interface(var->storage)) + variables.insert(variable); + break; + } + + case OpExtInst: + { + if (length < 5) + return false; + uint32_t extension_set = args[2]; + if (compiler.get(extension_set).ext == SPIRExtension::SPV_AMD_shader_explicit_vertex_parameter) + { + enum AMDShaderExplicitVertexParameter + { + InterpolateAtVertexAMD = 1 + }; + + auto op = static_cast(args[3]); + + switch (op) + { + case InterpolateAtVertexAMD: + { + auto *var = compiler.maybe_get(args[4]); + if (var && storage_class_is_interface(var->storage)) + variables.insert(args[4]); + break; + } + + default: + break; + } + } + break; + } + + case OpAccessChain: + case OpInBoundsAccessChain: + case OpLoad: + case OpCopyObject: + case OpImageTexelPointer: + case OpAtomicLoad: + case OpAtomicExchange: + case OpAtomicCompareExchange: + case OpAtomicCompareExchangeWeak: + case OpAtomicIIncrement: + case OpAtomicIDecrement: + case OpAtomicIAdd: + case OpAtomicISub: + case OpAtomicSMin: + case OpAtomicUMin: + case OpAtomicSMax: + case OpAtomicUMax: + case OpAtomicAnd: + case OpAtomicOr: + case OpAtomicXor: + // Invalid SPIR-V. + if (length < 3) + return false; + variable = args[2]; + break; + } + + if (variable) + { + auto *var = compiler.maybe_get(variable); + if (var && storage_class_is_interface(var->storage)) + variables.insert(variable); + } + return true; +} + +unordered_set Compiler::get_active_interface_variables() const +{ + // Traverse the call graph and find all interface variables which are in use. + unordered_set variables; + InterfaceVariableAccessHandler handler(*this, variables); + traverse_all_reachable_opcodes(get(entry_point), handler); + return variables; +} + +void Compiler::set_enabled_interface_variables(std::unordered_set active_variables) +{ + active_interface_variables = move(active_variables); + check_active_interface_variables = true; +} + +ShaderResources Compiler::get_shader_resources(const unordered_set *active_variables) const +{ + ShaderResources res; + + for (auto &id : ids) + { + if (id.get_type() != TypeVariable) + continue; + + auto &var = id.get(); + auto &type = get(var.basetype); + + // It is possible for uniform storage classes to be passed as function parameters, so detect + // that. To detect function parameters, check of StorageClass of variable is function scope. + if (var.storage == StorageClassFunction || !type.pointer || is_builtin_variable(var)) + continue; + + if (active_variables && active_variables->find(var.self) == end(*active_variables)) + continue; + + // Input + if (var.storage == StorageClassInput && interface_variable_exists_in_entry_point(var.self)) + { + if (meta[type.self].decoration.decoration_flags & (1ull << DecorationBlock)) + res.stage_inputs.push_back( + { var.self, var.basetype, type.self, get_remapped_declared_block_name(var.self) }); + else + res.stage_inputs.push_back({ var.self, var.basetype, type.self, meta[var.self].decoration.alias }); + } + // Subpass inputs + else if (var.storage == StorageClassUniformConstant && type.image.dim == DimSubpassData) + { + res.subpass_inputs.push_back({ var.self, var.basetype, type.self, meta[var.self].decoration.alias }); + } + // Outputs + else if (var.storage == StorageClassOutput && interface_variable_exists_in_entry_point(var.self)) + { + if (meta[type.self].decoration.decoration_flags & (1ull << DecorationBlock)) + res.stage_outputs.push_back( + { var.self, var.basetype, type.self, get_remapped_declared_block_name(var.self) }); + else + res.stage_outputs.push_back({ var.self, var.basetype, type.self, meta[var.self].decoration.alias }); + } + // UBOs + else if (type.storage == StorageClassUniform && + (meta[type.self].decoration.decoration_flags & (1ull << DecorationBlock))) + { + res.uniform_buffers.push_back( + { var.self, var.basetype, type.self, get_remapped_declared_block_name(var.self) }); + } + // Old way to declare SSBOs. + else if (type.storage == StorageClassUniform && + (meta[type.self].decoration.decoration_flags & (1ull << DecorationBufferBlock))) + { + res.storage_buffers.push_back( + { var.self, var.basetype, type.self, get_remapped_declared_block_name(var.self) }); + } + // Modern way to declare SSBOs. + else if (type.storage == StorageClassStorageBuffer) + { + res.storage_buffers.push_back( + { var.self, var.basetype, type.self, get_remapped_declared_block_name(var.self) }); + } + // Push constant blocks + else if (type.storage == StorageClassPushConstant) + { + // There can only be one push constant block, but keep the vector in case this restriction is lifted + // in the future. + res.push_constant_buffers.push_back({ var.self, var.basetype, type.self, meta[var.self].decoration.alias }); + } + // Images + else if (type.storage == StorageClassUniformConstant && type.basetype == SPIRType::Image && + type.image.sampled == 2) + { + res.storage_images.push_back({ var.self, var.basetype, type.self, meta[var.self].decoration.alias }); + } + // Separate images + else if (type.storage == StorageClassUniformConstant && type.basetype == SPIRType::Image && + type.image.sampled == 1) + { + res.separate_images.push_back({ var.self, var.basetype, type.self, meta[var.self].decoration.alias }); + } + // Separate samplers + else if (type.storage == StorageClassUniformConstant && type.basetype == SPIRType::Sampler) + { + res.separate_samplers.push_back({ var.self, var.basetype, type.self, meta[var.self].decoration.alias }); + } + // Textures + else if (type.storage == StorageClassUniformConstant && type.basetype == SPIRType::SampledImage) + { + res.sampled_images.push_back({ var.self, var.basetype, type.self, meta[var.self].decoration.alias }); + } + // Atomic counters + else if (type.storage == StorageClassAtomicCounter) + { + res.atomic_counters.push_back({ var.self, var.basetype, type.self, meta[var.self].decoration.alias }); + } + } + + return res; +} + +static inline uint32_t swap_endian(uint32_t v) +{ + return ((v >> 24) & 0x000000ffu) | ((v >> 8) & 0x0000ff00u) | ((v << 8) & 0x00ff0000u) | ((v << 24) & 0xff000000u); +} + +static string extract_string(const vector &spirv, uint32_t offset) +{ + string ret; + for (uint32_t i = offset; i < spirv.size(); i++) + { + uint32_t w = spirv[i]; + + for (uint32_t j = 0; j < 4; j++, w >>= 8) + { + char c = w & 0xff; + if (c == '\0') + return ret; + ret += c; + } + } + + SPIRV_CROSS_THROW("String was not terminated before EOF"); +} + +static bool is_valid_spirv_version(uint32_t version) +{ + switch (version) + { + // Allow v99 since it tends to just work. + case 99: + case 0x10000: // SPIR-V 1.0 + case 0x10100: // SPIR-V 1.1 + case 0x10200: // SPIR-V 1.2 + return true; + + default: + return false; + } +} + +void Compiler::parse() +{ + auto len = spirv.size(); + if (len < 5) + SPIRV_CROSS_THROW("SPIRV file too small."); + + auto s = spirv.data(); + + // Endian-swap if we need to. + if (s[0] == swap_endian(MagicNumber)) + transform(begin(spirv), end(spirv), begin(spirv), [](uint32_t c) { return swap_endian(c); }); + + if (s[0] != MagicNumber || !is_valid_spirv_version(s[1])) + SPIRV_CROSS_THROW("Invalid SPIRV format."); + + uint32_t bound = s[3]; + ids.resize(bound); + meta.resize(bound); + + uint32_t offset = 5; + while (offset < len) + inst.emplace_back(spirv, offset); + + for (auto &i : inst) + parse(i); + + if (current_function) + SPIRV_CROSS_THROW("Function was not terminated."); + if (current_block) + SPIRV_CROSS_THROW("Block was not terminated."); + + // Figure out specialization constants for work group sizes. + for (auto &id : ids) + { + if (id.get_type() == TypeConstant) + { + auto &c = id.get(); + if (meta[c.self].decoration.builtin && meta[c.self].decoration.builtin_type == BuiltInWorkgroupSize) + { + // In current SPIR-V, there can be just one constant like this. + // All entry points will receive the constant value. + for (auto &entry : entry_points) + { + entry.second.workgroup_size.constant = c.self; + entry.second.workgroup_size.x = c.scalar(0, 0); + entry.second.workgroup_size.y = c.scalar(0, 1); + entry.second.workgroup_size.z = c.scalar(0, 2); + } + } + } + } +} + +void Compiler::flatten_interface_block(uint32_t id) +{ + auto &var = get(id); + auto &type = get(var.basetype); + auto flags = meta.at(type.self).decoration.decoration_flags; + + if (!type.array.empty()) + SPIRV_CROSS_THROW("Type is array of UBOs."); + if (type.basetype != SPIRType::Struct) + SPIRV_CROSS_THROW("Type is not a struct."); + if ((flags & (1ull << DecorationBlock)) == 0) + SPIRV_CROSS_THROW("Type is not a block."); + if (type.member_types.empty()) + SPIRV_CROSS_THROW("Member list of struct is empty."); + + uint32_t t = type.member_types[0]; + for (auto &m : type.member_types) + if (t != m) + SPIRV_CROSS_THROW("Types in block differ."); + + auto &mtype = get(t); + if (!mtype.array.empty()) + SPIRV_CROSS_THROW("Member type cannot be arrays."); + if (mtype.basetype == SPIRType::Struct) + SPIRV_CROSS_THROW("Member type cannot be struct."); + + // Inherit variable name from interface block name. + meta.at(var.self).decoration.alias = meta.at(type.self).decoration.alias; + + auto storage = var.storage; + if (storage == StorageClassUniform) + storage = StorageClassUniformConstant; + + // Change type definition in-place into an array instead. + // Access chains will still work as-is. + uint32_t array_size = uint32_t(type.member_types.size()); + type = mtype; + type.array.push_back(array_size); + type.pointer = true; + type.storage = storage; + var.storage = storage; +} + +void Compiler::update_name_cache(unordered_set &cache, string &name) +{ + if (name.empty()) + return; + + if (cache.find(name) == end(cache)) + { + cache.insert(name); + return; + } + + uint32_t counter = 0; + auto tmpname = name; + + // If there is a collision (very rare), + // keep tacking on extra identifier until it's unique. + do + { + counter++; + name = tmpname + "_" + convert_to_string(counter); + } while (cache.find(name) != end(cache)); + cache.insert(name); +} + +void Compiler::set_name(uint32_t id, const std::string &name) +{ + auto &str = meta.at(id).decoration.alias; + str.clear(); + + if (name.empty()) + return; + + // glslang uses identifiers to pass along meaningful information + // about HLSL reflection. + auto &m = meta.at(id); + if (source.hlsl && name.size() >= 6 && name.find("@count") == name.size() - 6) + { + m.hlsl_magic_counter_buffer_candidate = true; + m.hlsl_magic_counter_buffer_name = name.substr(0, name.find("@count")); + } + else + { + m.hlsl_magic_counter_buffer_candidate = false; + m.hlsl_magic_counter_buffer_name.clear(); + } + + // Reserved for temporaries. + if (name[0] == '_' && name.size() >= 2 && isdigit(name[1])) + return; + + str = ensure_valid_identifier(name, false); +} + +const SPIRType &Compiler::get_type(uint32_t id) const +{ + return get(id); +} + +const SPIRType &Compiler::get_type_from_variable(uint32_t id) const +{ + return get(get(id).basetype); +} + +void Compiler::set_member_decoration(uint32_t id, uint32_t index, Decoration decoration, uint32_t argument) +{ + meta.at(id).members.resize(max(meta[id].members.size(), size_t(index) + 1)); + auto &dec = meta.at(id).members[index]; + dec.decoration_flags |= 1ull << decoration; + + switch (decoration) + { + case DecorationBuiltIn: + dec.builtin = true; + dec.builtin_type = static_cast(argument); + break; + + case DecorationLocation: + dec.location = argument; + break; + + case DecorationBinding: + dec.binding = argument; + break; + + case DecorationOffset: + dec.offset = argument; + break; + + case DecorationSpecId: + dec.spec_id = argument; + break; + + case DecorationMatrixStride: + dec.matrix_stride = argument; + break; + + default: + break; + } +} + +void Compiler::set_member_name(uint32_t id, uint32_t index, const std::string &name) +{ + meta.at(id).members.resize(max(meta[id].members.size(), size_t(index) + 1)); + + auto &str = meta.at(id).members[index].alias; + str.clear(); + if (name.empty()) + return; + + // Reserved for unnamed members. + if (name[0] == '_' && name.size() >= 3 && name[1] == 'm' && isdigit(name[2])) + return; + + str = ensure_valid_identifier(name, true); +} + +const std::string &Compiler::get_member_name(uint32_t id, uint32_t index) const +{ + auto &m = meta.at(id); + if (index >= m.members.size()) + { + static string empty; + return empty; + } + + return m.members[index].alias; +} + +void Compiler::set_member_qualified_name(uint32_t type_id, uint32_t index, const std::string &name) +{ + meta.at(type_id).members.resize(max(meta[type_id].members.size(), size_t(index) + 1)); + meta.at(type_id).members[index].qualified_alias = name; +} + +const std::string &Compiler::get_member_qualified_name(uint32_t type_id, uint32_t index) const +{ + const static string empty; + + auto &m = meta.at(type_id); + if (index < m.members.size()) + return m.members[index].qualified_alias; + else + return empty; +} + +uint32_t Compiler::get_member_decoration(uint32_t id, uint32_t index, Decoration decoration) const +{ + auto &m = meta.at(id); + if (index >= m.members.size()) + return 0; + + auto &dec = m.members[index]; + if (!(dec.decoration_flags & (1ull << decoration))) + return 0; + + switch (decoration) + { + case DecorationBuiltIn: + return dec.builtin_type; + case DecorationLocation: + return dec.location; + case DecorationBinding: + return dec.binding; + case DecorationOffset: + return dec.offset; + case DecorationSpecId: + return dec.spec_id; + default: + return 1; + } +} + +uint64_t Compiler::get_member_decoration_mask(uint32_t id, uint32_t index) const +{ + auto &m = meta.at(id); + if (index >= m.members.size()) + return 0; + + return m.members[index].decoration_flags; +} + +bool Compiler::has_member_decoration(uint32_t id, uint32_t index, Decoration decoration) const +{ + return get_member_decoration_mask(id, index) & (1ull << decoration); +} + +void Compiler::unset_member_decoration(uint32_t id, uint32_t index, Decoration decoration) +{ + auto &m = meta.at(id); + if (index >= m.members.size()) + return; + + auto &dec = m.members[index]; + + dec.decoration_flags &= ~(1ull << decoration); + switch (decoration) + { + case DecorationBuiltIn: + dec.builtin = false; + break; + + case DecorationLocation: + dec.location = 0; + break; + + case DecorationOffset: + dec.offset = 0; + break; + + case DecorationSpecId: + dec.spec_id = 0; + break; + + default: + break; + } +} + +void Compiler::set_decoration(uint32_t id, Decoration decoration, uint32_t argument) +{ + auto &dec = meta.at(id).decoration; + dec.decoration_flags |= 1ull << decoration; + + switch (decoration) + { + case DecorationBuiltIn: + dec.builtin = true; + dec.builtin_type = static_cast(argument); + break; + + case DecorationLocation: + dec.location = argument; + break; + + case DecorationOffset: + dec.offset = argument; + break; + + case DecorationArrayStride: + dec.array_stride = argument; + break; + + case DecorationMatrixStride: + dec.matrix_stride = argument; + break; + + case DecorationBinding: + dec.binding = argument; + break; + + case DecorationDescriptorSet: + dec.set = argument; + break; + + case DecorationInputAttachmentIndex: + dec.input_attachment = argument; + break; + + case DecorationSpecId: + dec.spec_id = argument; + break; + + default: + break; + } +} + +StorageClass Compiler::get_storage_class(uint32_t id) const +{ + return get(id).storage; +} + +const std::string &Compiler::get_name(uint32_t id) const +{ + return meta.at(id).decoration.alias; +} + +const std::string Compiler::get_fallback_name(uint32_t id) const +{ + return join("_", id); +} + +const std::string Compiler::get_block_fallback_name(uint32_t id) const +{ + auto &var = get(id); + if (get_name(id).empty()) + return join("_", get(var.basetype).self, "_", id); + else + return get_name(id); +} + +uint64_t Compiler::get_decoration_mask(uint32_t id) const +{ + auto &dec = meta.at(id).decoration; + return dec.decoration_flags; +} + +bool Compiler::has_decoration(uint32_t id, Decoration decoration) const +{ + return get_decoration_mask(id) & (1ull << decoration); +} + +uint32_t Compiler::get_decoration(uint32_t id, Decoration decoration) const +{ + auto &dec = meta.at(id).decoration; + if (!(dec.decoration_flags & (1ull << decoration))) + return 0; + + switch (decoration) + { + case DecorationBuiltIn: + return dec.builtin_type; + case DecorationLocation: + return dec.location; + case DecorationOffset: + return dec.offset; + case DecorationBinding: + return dec.binding; + case DecorationDescriptorSet: + return dec.set; + case DecorationInputAttachmentIndex: + return dec.input_attachment; + case DecorationSpecId: + return dec.spec_id; + case DecorationArrayStride: + return dec.array_stride; + case DecorationMatrixStride: + return dec.matrix_stride; + default: + return 1; + } +} + +void Compiler::unset_decoration(uint32_t id, Decoration decoration) +{ + auto &dec = meta.at(id).decoration; + dec.decoration_flags &= ~(1ull << decoration); + switch (decoration) + { + case DecorationBuiltIn: + dec.builtin = false; + break; + + case DecorationLocation: + dec.location = 0; + break; + + case DecorationOffset: + dec.offset = 0; + break; + + case DecorationBinding: + dec.binding = 0; + break; + + case DecorationDescriptorSet: + dec.set = 0; + break; + + case DecorationInputAttachmentIndex: + dec.input_attachment = 0; + break; + + case DecorationSpecId: + dec.spec_id = 0; + break; + + default: + break; + } +} + +bool Compiler::get_binary_offset_for_decoration(uint32_t id, spv::Decoration decoration, uint32_t &word_offset) const +{ + auto &word_offsets = meta.at(id).decoration_word_offset; + auto itr = word_offsets.find(decoration); + if (itr == end(word_offsets)) + return false; + + word_offset = itr->second; + return true; +} + +void Compiler::parse(const Instruction &instruction) +{ + auto ops = stream(instruction); + auto op = static_cast(instruction.op); + uint32_t length = instruction.length; + + switch (op) + { + case OpMemoryModel: + case OpSourceExtension: + case OpNop: + case OpLine: + case OpNoLine: + case OpString: + break; + + case OpSource: + { + auto lang = static_cast(ops[0]); + switch (lang) + { + case SourceLanguageESSL: + source.es = true; + source.version = ops[1]; + source.known = true; + source.hlsl = false; + break; + + case SourceLanguageGLSL: + source.es = false; + source.version = ops[1]; + source.known = true; + source.hlsl = false; + break; + + case SourceLanguageHLSL: + // For purposes of cross-compiling, this is GLSL 450. + source.es = false; + source.version = 450; + source.known = true; + source.hlsl = true; + break; + + default: + source.known = false; + break; + } + break; + } + + case OpUndef: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + set(id, result_type); + break; + } + + case OpCapability: + { + uint32_t cap = ops[0]; + if (cap == CapabilityKernel) + SPIRV_CROSS_THROW("Kernel capability not supported."); + + declared_capabilities.push_back(static_cast(ops[0])); + break; + } + + case OpExtension: + { + auto ext = extract_string(spirv, instruction.offset); + declared_extensions.push_back(move(ext)); + break; + } + + case OpExtInstImport: + { + uint32_t id = ops[0]; + auto ext = extract_string(spirv, instruction.offset + 1); + if (ext == "GLSL.std.450") + set(id, SPIRExtension::GLSL); + else if (ext == "SPV_AMD_shader_ballot") + set(id, SPIRExtension::SPV_AMD_shader_ballot); + else if (ext == "SPV_AMD_shader_explicit_vertex_parameter") + set(id, SPIRExtension::SPV_AMD_shader_explicit_vertex_parameter); + else if (ext == "SPV_AMD_shader_trinary_minmax") + set(id, SPIRExtension::SPV_AMD_shader_trinary_minmax); + else if (ext == "SPV_AMD_gcn_shader") + set(id, SPIRExtension::SPV_AMD_gcn_shader); + else + set(id, SPIRExtension::Unsupported); + + // Other SPIR-V extensions currently not supported. + + break; + } + + case OpEntryPoint: + { + auto itr = + entry_points.insert(make_pair(ops[1], SPIREntryPoint(ops[1], static_cast(ops[0]), + extract_string(spirv, instruction.offset + 2)))); + auto &e = itr.first->second; + + // Strings need nul-terminator and consume the whole word. + uint32_t strlen_words = uint32_t((e.name.size() + 1 + 3) >> 2); + e.interface_variables.insert(end(e.interface_variables), ops + strlen_words + 2, ops + instruction.length); + + // Set the name of the entry point in case OpName is not provided later + set_name(ops[1], e.name); + + // If we don't have an entry, make the first one our "default". + if (!entry_point) + entry_point = ops[1]; + break; + } + + case OpExecutionMode: + { + auto &execution = entry_points[ops[0]]; + auto mode = static_cast(ops[1]); + execution.flags |= 1ull << mode; + + switch (mode) + { + case ExecutionModeInvocations: + execution.invocations = ops[2]; + break; + + case ExecutionModeLocalSize: + execution.workgroup_size.x = ops[2]; + execution.workgroup_size.y = ops[3]; + execution.workgroup_size.z = ops[4]; + break; + + case ExecutionModeOutputVertices: + execution.output_vertices = ops[2]; + break; + + default: + break; + } + break; + } + + case OpName: + { + uint32_t id = ops[0]; + set_name(id, extract_string(spirv, instruction.offset + 1)); + break; + } + + case OpMemberName: + { + uint32_t id = ops[0]; + uint32_t member = ops[1]; + set_member_name(id, member, extract_string(spirv, instruction.offset + 2)); + break; + } + + case OpDecorate: + { + uint32_t id = ops[0]; + + auto decoration = static_cast(ops[1]); + if (length >= 3) + { + meta[id].decoration_word_offset[decoration] = uint32_t(&ops[2] - spirv.data()); + set_decoration(id, decoration, ops[2]); + } + else + set_decoration(id, decoration); + + break; + } + + case OpMemberDecorate: + { + uint32_t id = ops[0]; + uint32_t member = ops[1]; + auto decoration = static_cast(ops[2]); + if (length >= 4) + set_member_decoration(id, member, decoration, ops[3]); + else + set_member_decoration(id, member, decoration); + break; + } + + // Build up basic types. + case OpTypeVoid: + { + uint32_t id = ops[0]; + auto &type = set(id); + type.basetype = SPIRType::Void; + break; + } + + case OpTypeBool: + { + uint32_t id = ops[0]; + auto &type = set(id); + type.basetype = SPIRType::Boolean; + type.width = 1; + break; + } + + case OpTypeFloat: + { + uint32_t id = ops[0]; + uint32_t width = ops[1]; + auto &type = set(id); + type.basetype = width > 32 ? SPIRType::Double : SPIRType::Float; + type.width = width; + break; + } + + case OpTypeInt: + { + uint32_t id = ops[0]; + uint32_t width = ops[1]; + auto &type = set(id); + type.basetype = + ops[2] ? (width > 32 ? SPIRType::Int64 : SPIRType::Int) : (width > 32 ? SPIRType::UInt64 : SPIRType::UInt); + type.width = width; + break; + } + + // Build composite types by "inheriting". + // NOTE: The self member is also copied! For pointers and array modifiers this is a good thing + // since we can refer to decorations on pointee classes which is needed for UBO/SSBO, I/O blocks in geometry/tess etc. + case OpTypeVector: + { + uint32_t id = ops[0]; + uint32_t vecsize = ops[2]; + + auto &base = get(ops[1]); + auto &vecbase = set(id); + + vecbase = base; + vecbase.vecsize = vecsize; + vecbase.self = id; + vecbase.parent_type = ops[1]; + break; + } + + case OpTypeMatrix: + { + uint32_t id = ops[0]; + uint32_t colcount = ops[2]; + + auto &base = get(ops[1]); + auto &matrixbase = set(id); + + matrixbase = base; + matrixbase.columns = colcount; + matrixbase.self = id; + matrixbase.parent_type = ops[1]; + break; + } + + case OpTypeArray: + { + uint32_t id = ops[0]; + auto &arraybase = set(id); + + uint32_t tid = ops[1]; + auto &base = get(tid); + + arraybase = base; + arraybase.parent_type = tid; + + uint32_t cid = ops[2]; + mark_used_as_array_length(cid); + auto *c = maybe_get(cid); + bool literal = c && !c->specialization; + + arraybase.array_size_literal.push_back(literal); + arraybase.array.push_back(literal ? c->scalar() : cid); + // Do NOT set arraybase.self! + break; + } + + case OpTypeRuntimeArray: + { + uint32_t id = ops[0]; + + auto &base = get(ops[1]); + auto &arraybase = set(id); + + arraybase = base; + arraybase.array.push_back(0); + arraybase.array_size_literal.push_back(true); + arraybase.parent_type = ops[1]; + // Do NOT set arraybase.self! + break; + } + + case OpTypeImage: + { + uint32_t id = ops[0]; + auto &type = set(id); + type.basetype = SPIRType::Image; + type.image.type = ops[1]; + type.image.dim = static_cast(ops[2]); + type.image.depth = ops[3] != 0; + type.image.arrayed = ops[4] != 0; + type.image.ms = ops[5] != 0; + type.image.sampled = ops[6]; + type.image.format = static_cast(ops[7]); + type.image.access = (length >= 9) ? static_cast(ops[8]) : AccessQualifierMax; + + if (type.image.sampled == 0) + SPIRV_CROSS_THROW("OpTypeImage Sampled parameter must not be zero."); + + break; + } + + case OpTypeSampledImage: + { + uint32_t id = ops[0]; + uint32_t imagetype = ops[1]; + auto &type = set(id); + type = get(imagetype); + type.basetype = SPIRType::SampledImage; + type.self = id; + break; + } + + case OpTypeSampler: + { + uint32_t id = ops[0]; + auto &type = set(id); + type.basetype = SPIRType::Sampler; + break; + } + + case OpTypePointer: + { + uint32_t id = ops[0]; + + auto &base = get(ops[2]); + auto &ptrbase = set(id); + + ptrbase = base; + if (ptrbase.pointer) + SPIRV_CROSS_THROW("Cannot make pointer-to-pointer type."); + ptrbase.pointer = true; + ptrbase.storage = static_cast(ops[1]); + + if (ptrbase.storage == StorageClassAtomicCounter) + ptrbase.basetype = SPIRType::AtomicCounter; + + ptrbase.parent_type = ops[2]; + + // Do NOT set ptrbase.self! + break; + } + + case OpTypeStruct: + { + uint32_t id = ops[0]; + auto &type = set(id); + type.basetype = SPIRType::Struct; + for (uint32_t i = 1; i < length; i++) + type.member_types.push_back(ops[i]); + + // Check if we have seen this struct type before, with just different + // decorations. + // + // Add workaround for issue #17 as well by looking at OpName for the struct + // types, which we shouldn't normally do. + // We should not normally have to consider type aliases like this to begin with + // however ... glslang issues #304, #307 cover this. + + // For stripped names, never consider struct type aliasing. + // We risk declaring the same struct multiple times, but type-punning is not allowed + // so this is safe. + bool consider_aliasing = !get_name(type.self).empty(); + if (consider_aliasing) + { + for (auto &other : global_struct_cache) + { + if (get_name(type.self) == get_name(other) && + types_are_logically_equivalent(type, get(other))) + { + type.type_alias = other; + break; + } + } + + if (type.type_alias == 0) + global_struct_cache.push_back(id); + } + break; + } + + case OpTypeFunction: + { + uint32_t id = ops[0]; + uint32_t ret = ops[1]; + + auto &func = set(id, ret); + for (uint32_t i = 2; i < length; i++) + func.parameter_types.push_back(ops[i]); + break; + } + + // Variable declaration + // All variables are essentially pointers with a storage qualifier. + case OpVariable: + { + uint32_t type = ops[0]; + uint32_t id = ops[1]; + auto storage = static_cast(ops[2]); + uint32_t initializer = length == 4 ? ops[3] : 0; + + if (storage == StorageClassFunction) + { + if (!current_function) + SPIRV_CROSS_THROW("No function currently in scope"); + current_function->add_local_variable(id); + } + else if (storage == StorageClassPrivate || storage == StorageClassWorkgroup || storage == StorageClassOutput) + { + global_variables.push_back(id); + } + + auto &var = set(id, type, storage, initializer); + + // hlsl based shaders don't have those decorations. force them and then reset when reading/writing images + auto &ttype = get(type); + if (ttype.basetype == SPIRType::BaseType::Image) + { + set_decoration(id, DecorationNonWritable); + set_decoration(id, DecorationNonReadable); + } + + if (variable_storage_is_aliased(var)) + aliased_variables.push_back(var.self); + + break; + } + + // OpPhi + // OpPhi is a fairly magical opcode. + // It selects temporary variables based on which parent block we *came from*. + // In high-level languages we can "de-SSA" by creating a function local, and flush out temporaries to this function-local + // variable to emulate SSA Phi. + case OpPhi: + { + if (!current_function) + SPIRV_CROSS_THROW("No function currently in scope"); + if (!current_block) + SPIRV_CROSS_THROW("No block currently in scope"); + + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + + // Instead of a temporary, create a new function-wide temporary with this ID instead. + auto &var = set(id, result_type, spv::StorageClassFunction); + var.phi_variable = true; + + current_function->add_local_variable(id); + + for (uint32_t i = 2; i + 2 <= length; i += 2) + current_block->phi_variables.push_back({ ops[i], ops[i + 1], id }); + break; + } + + // Constants + case OpSpecConstant: + case OpConstant: + { + uint32_t id = ops[1]; + auto &type = get(ops[0]); + + if (type.width > 32) + set(id, ops[0], ops[2] | (uint64_t(ops[3]) << 32), op == OpSpecConstant); + else + set(id, ops[0], ops[2], op == OpSpecConstant); + break; + } + + case OpSpecConstantFalse: + case OpConstantFalse: + { + uint32_t id = ops[1]; + set(id, ops[0], uint32_t(0), op == OpSpecConstantFalse); + break; + } + + case OpSpecConstantTrue: + case OpConstantTrue: + { + uint32_t id = ops[1]; + set(id, ops[0], uint32_t(1), op == OpSpecConstantTrue); + break; + } + + case OpConstantNull: + { + uint32_t id = ops[1]; + uint32_t type = ops[0]; + make_constant_null(id, type); + break; + } + + case OpSpecConstantComposite: + case OpConstantComposite: + { + uint32_t id = ops[1]; + uint32_t type = ops[0]; + + auto &ctype = get(type); + + // We can have constants which are structs and arrays. + // In this case, our SPIRConstant will be a list of other SPIRConstant ids which we + // can refer to. + if (ctype.basetype == SPIRType::Struct || !ctype.array.empty()) + { + set(id, type, ops + 2, length - 2, op == OpSpecConstantComposite); + } + else + { + uint32_t elements = length - 2; + if (elements > 4) + SPIRV_CROSS_THROW("OpConstantComposite only supports 1, 2, 3 and 4 elements."); + + const SPIRConstant *c[4]; + for (uint32_t i = 0; i < elements; i++) + c[i] = &get(ops[2 + i]); + set(id, type, c, elements, op == OpSpecConstantComposite); + } + break; + } + + // Functions + case OpFunction: + { + uint32_t res = ops[0]; + uint32_t id = ops[1]; + // Control + uint32_t type = ops[3]; + + if (current_function) + SPIRV_CROSS_THROW("Must end a function before starting a new one!"); + + current_function = &set(id, res, type); + break; + } + + case OpFunctionParameter: + { + uint32_t type = ops[0]; + uint32_t id = ops[1]; + + if (!current_function) + SPIRV_CROSS_THROW("Must be in a function!"); + + current_function->add_parameter(type, id); + set(id, type, StorageClassFunction); + break; + } + + case OpFunctionEnd: + { + if (current_block) + { + // Very specific error message, but seems to come up quite often. + SPIRV_CROSS_THROW( + "Cannot end a function before ending the current block.\n" + "Likely cause: If this SPIR-V was created from glslang HLSL, make sure the entry point is valid."); + } + current_function = nullptr; + break; + } + + // Blocks + case OpLabel: + { + // OpLabel always starts a block. + if (!current_function) + SPIRV_CROSS_THROW("Blocks cannot exist outside functions!"); + + uint32_t id = ops[0]; + + current_function->blocks.push_back(id); + if (!current_function->entry_block) + current_function->entry_block = id; + + if (current_block) + SPIRV_CROSS_THROW("Cannot start a block before ending the current block."); + + current_block = &set(id); + break; + } + + // Branch instructions end blocks. + case OpBranch: + { + if (!current_block) + SPIRV_CROSS_THROW("Trying to end a non-existing block."); + + uint32_t target = ops[0]; + current_block->terminator = SPIRBlock::Direct; + current_block->next_block = target; + current_block = nullptr; + break; + } + + case OpBranchConditional: + { + if (!current_block) + SPIRV_CROSS_THROW("Trying to end a non-existing block."); + + current_block->condition = ops[0]; + current_block->true_block = ops[1]; + current_block->false_block = ops[2]; + + current_block->terminator = SPIRBlock::Select; + current_block = nullptr; + break; + } + + case OpSwitch: + { + if (!current_block) + SPIRV_CROSS_THROW("Trying to end a non-existing block."); + + if (current_block->merge == SPIRBlock::MergeNone) + SPIRV_CROSS_THROW("Switch statement is not structured"); + + current_block->terminator = SPIRBlock::MultiSelect; + + current_block->condition = ops[0]; + current_block->default_block = ops[1]; + + for (uint32_t i = 2; i + 2 <= length; i += 2) + current_block->cases.push_back({ ops[i], ops[i + 1] }); + + // If we jump to next block, make it break instead since we're inside a switch case block at that point. + multiselect_merge_targets.insert(current_block->next_block); + + current_block = nullptr; + break; + } + + case OpKill: + { + if (!current_block) + SPIRV_CROSS_THROW("Trying to end a non-existing block."); + current_block->terminator = SPIRBlock::Kill; + current_block = nullptr; + break; + } + + case OpReturn: + { + if (!current_block) + SPIRV_CROSS_THROW("Trying to end a non-existing block."); + current_block->terminator = SPIRBlock::Return; + current_block = nullptr; + break; + } + + case OpReturnValue: + { + if (!current_block) + SPIRV_CROSS_THROW("Trying to end a non-existing block."); + current_block->terminator = SPIRBlock::Return; + current_block->return_value = ops[0]; + current_block = nullptr; + break; + } + + case OpUnreachable: + { + if (!current_block) + SPIRV_CROSS_THROW("Trying to end a non-existing block."); + current_block->terminator = SPIRBlock::Unreachable; + current_block = nullptr; + break; + } + + case OpSelectionMerge: + { + if (!current_block) + SPIRV_CROSS_THROW("Trying to modify a non-existing block."); + + current_block->next_block = ops[0]; + current_block->merge = SPIRBlock::MergeSelection; + selection_merge_targets.insert(current_block->next_block); + break; + } + + case OpLoopMerge: + { + if (!current_block) + SPIRV_CROSS_THROW("Trying to modify a non-existing block."); + + current_block->merge_block = ops[0]; + current_block->continue_block = ops[1]; + current_block->merge = SPIRBlock::MergeLoop; + + loop_blocks.insert(current_block->self); + loop_merge_targets.insert(current_block->merge_block); + + continue_block_to_loop_header[current_block->continue_block] = current_block->self; + + // Don't add loop headers to continue blocks, + // which would make it impossible branch into the loop header since + // they are treated as continues. + if (current_block->continue_block != current_block->self) + continue_blocks.insert(current_block->continue_block); + break; + } + + case OpSpecConstantOp: + { + if (length < 3) + SPIRV_CROSS_THROW("OpSpecConstantOp not enough arguments."); + + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + auto spec_op = static_cast(ops[2]); + + set(id, result_type, spec_op, ops + 3, length - 3); + break; + } + + // Actual opcodes. + default: + { + if (!current_block) + SPIRV_CROSS_THROW("Currently no block to insert opcode."); + + current_block->ops.push_back(instruction); + break; + } + } +} + +bool Compiler::block_is_loop_candidate(const SPIRBlock &block, SPIRBlock::Method method) const +{ + // Tried and failed. + if (block.disable_block_optimization || block.complex_continue) + return false; + + if (method == SPIRBlock::MergeToSelectForLoop) + { + // Try to detect common for loop pattern + // which the code backend can use to create cleaner code. + // for(;;) { if (cond) { some_body; } else { break; } } + // is the pattern we're looking for. + bool ret = block.terminator == SPIRBlock::Select && block.merge == SPIRBlock::MergeLoop && + block.true_block != block.merge_block && block.true_block != block.self && + block.false_block == block.merge_block; + + // If we have OpPhi which depends on branches which came from our own block, + // we need to flush phi variables in else block instead of a trivial break, + // so we cannot assume this is a for loop candidate. + if (ret) + { + for (auto &phi : block.phi_variables) + if (phi.parent == block.self) + return false; + + auto *merge = maybe_get(block.merge_block); + if (merge) + for (auto &phi : merge->phi_variables) + if (phi.parent == block.self) + return false; + } + return ret; + } + else if (method == SPIRBlock::MergeToDirectForLoop) + { + // Empty loop header that just sets up merge target + // and branches to loop body. + bool ret = block.terminator == SPIRBlock::Direct && block.merge == SPIRBlock::MergeLoop && block.ops.empty(); + + if (!ret) + return false; + + auto &child = get(block.next_block); + ret = child.terminator == SPIRBlock::Select && child.merge == SPIRBlock::MergeNone && + child.false_block == block.merge_block && child.true_block != block.merge_block && + child.true_block != block.self; + + // If we have OpPhi which depends on branches which came from our own block, + // we need to flush phi variables in else block instead of a trivial break, + // so we cannot assume this is a for loop candidate. + if (ret) + { + for (auto &phi : block.phi_variables) + if (phi.parent == block.self || phi.parent == child.self) + return false; + + for (auto &phi : child.phi_variables) + if (phi.parent == block.self) + return false; + + auto *merge = maybe_get(block.merge_block); + if (merge) + for (auto &phi : merge->phi_variables) + if (phi.parent == block.self || phi.parent == child.false_block) + return false; + } + + return ret; + } + else + return false; +} + +bool Compiler::block_is_outside_flow_control_from_block(const SPIRBlock &from, const SPIRBlock &to) +{ + auto *start = &from; + + if (start->self == to.self) + return true; + + // Break cycles. + if (is_continue(start->self)) + return false; + + // If our select block doesn't merge, we must break or continue in these blocks, + // so if continues occur branchless within these blocks, consider them branchless as well. + // This is typically used for loop control. + if (start->terminator == SPIRBlock::Select && start->merge == SPIRBlock::MergeNone && + (block_is_outside_flow_control_from_block(get(start->true_block), to) || + block_is_outside_flow_control_from_block(get(start->false_block), to))) + { + return true; + } + else if (start->merge_block && block_is_outside_flow_control_from_block(get(start->merge_block), to)) + { + return true; + } + else if (start->next_block && block_is_outside_flow_control_from_block(get(start->next_block), to)) + { + return true; + } + else + return false; +} + +bool Compiler::execution_is_noop(const SPIRBlock &from, const SPIRBlock &to) const +{ + if (!execution_is_branchless(from, to)) + return false; + + auto *start = &from; + for (;;) + { + if (start->self == to.self) + return true; + + if (!start->ops.empty()) + return false; + + start = &get(start->next_block); + } +} + +bool Compiler::execution_is_branchless(const SPIRBlock &from, const SPIRBlock &to) const +{ + auto *start = &from; + for (;;) + { + if (start->self == to.self) + return true; + + if (start->terminator == SPIRBlock::Direct && start->merge == SPIRBlock::MergeNone) + start = &get(start->next_block); + else + return false; + } +} + +SPIRBlock::ContinueBlockType Compiler::continue_block_type(const SPIRBlock &block) const +{ + // The block was deemed too complex during code emit, pick conservative fallback paths. + if (block.complex_continue) + return SPIRBlock::ComplexLoop; + + // In older glslang output continue block can be equal to the loop header. + // In this case, execution is clearly branchless, so just assume a while loop header here. + if (block.merge == SPIRBlock::MergeLoop) + return SPIRBlock::WhileLoop; + + auto &dominator = get(block.loop_dominator); + + if (execution_is_noop(block, dominator)) + return SPIRBlock::WhileLoop; + else if (execution_is_branchless(block, dominator)) + return SPIRBlock::ForLoop; + else + { + if (block.merge == SPIRBlock::MergeNone && block.terminator == SPIRBlock::Select && + block.true_block == dominator.self && block.false_block == dominator.merge_block) + { + return SPIRBlock::DoWhileLoop; + } + else + return SPIRBlock::ComplexLoop; + } +} + +bool Compiler::traverse_all_reachable_opcodes(const SPIRBlock &block, OpcodeHandler &handler) const +{ + handler.set_current_block(block); + + // Ideally, perhaps traverse the CFG instead of all blocks in order to eliminate dead blocks, + // but this shouldn't be a problem in practice unless the SPIR-V is doing insane things like recursing + // inside dead blocks ... + for (auto &i : block.ops) + { + auto ops = stream(i); + auto op = static_cast(i.op); + + if (!handler.handle(op, ops, i.length)) + return false; + + if (op == OpFunctionCall) + { + auto &func = get(ops[2]); + if (handler.follow_function_call(func)) + { + if (!handler.begin_function_scope(ops, i.length)) + return false; + if (!traverse_all_reachable_opcodes(get(ops[2]), handler)) + return false; + if (!handler.end_function_scope(ops, i.length)) + return false; + } + } + } + + return true; +} + +bool Compiler::traverse_all_reachable_opcodes(const SPIRFunction &func, OpcodeHandler &handler) const +{ + for (auto block : func.blocks) + if (!traverse_all_reachable_opcodes(get(block), handler)) + return false; + + return true; +} + +uint32_t Compiler::type_struct_member_offset(const SPIRType &type, uint32_t index) const +{ + // Decoration must be set in valid SPIR-V, otherwise throw. + auto &dec = meta[type.self].members.at(index); + if (dec.decoration_flags & (1ull << DecorationOffset)) + return dec.offset; + else + SPIRV_CROSS_THROW("Struct member does not have Offset set."); +} + +uint32_t Compiler::type_struct_member_array_stride(const SPIRType &type, uint32_t index) const +{ + // Decoration must be set in valid SPIR-V, otherwise throw. + // ArrayStride is part of the array type not OpMemberDecorate. + auto &dec = meta[type.member_types[index]].decoration; + if (dec.decoration_flags & (1ull << DecorationArrayStride)) + return dec.array_stride; + else + SPIRV_CROSS_THROW("Struct member does not have ArrayStride set."); +} + +uint32_t Compiler::type_struct_member_matrix_stride(const SPIRType &type, uint32_t index) const +{ + // Decoration must be set in valid SPIR-V, otherwise throw. + // MatrixStride is part of OpMemberDecorate. + auto &dec = meta[type.self].members[index]; + if (dec.decoration_flags & (1ull << DecorationMatrixStride)) + return dec.matrix_stride; + else + SPIRV_CROSS_THROW("Struct member does not have MatrixStride set."); +} + +size_t Compiler::get_declared_struct_size(const SPIRType &type) const +{ + uint32_t last = uint32_t(type.member_types.size() - 1); + size_t offset = type_struct_member_offset(type, last); + size_t size = get_declared_struct_member_size(type, last); + return offset + size; +} + +size_t Compiler::get_declared_struct_member_size(const SPIRType &struct_type, uint32_t index) const +{ + auto flags = get_member_decoration_mask(struct_type.self, index); + auto &type = get(struct_type.member_types[index]); + + switch (type.basetype) + { + case SPIRType::Unknown: + case SPIRType::Void: + case SPIRType::Boolean: // Bools are purely logical, and cannot be used for externally visible types. + case SPIRType::AtomicCounter: + case SPIRType::Image: + case SPIRType::SampledImage: + case SPIRType::Sampler: + SPIRV_CROSS_THROW("Querying size for object with opaque size."); + + default: + break; + } + + if (!type.array.empty()) + { + // For arrays, we can use ArrayStride to get an easy check. + return type_struct_member_array_stride(struct_type, index) * type.array.back(); + } + else if (type.basetype == SPIRType::Struct) + { + return get_declared_struct_size(type); + } + else + { + unsigned vecsize = type.vecsize; + unsigned columns = type.columns; + + // Vectors. + if (columns == 1) + { + size_t component_size = type.width / 8; + return vecsize * component_size; + } + else + { + uint32_t matrix_stride = type_struct_member_matrix_stride(struct_type, index); + + // Per SPIR-V spec, matrices must be tightly packed and aligned up for vec3 accesses. + if (flags & (1ull << DecorationRowMajor)) + return matrix_stride * vecsize; + else if (flags & (1ull << DecorationColMajor)) + return matrix_stride * columns; + else + SPIRV_CROSS_THROW("Either row-major or column-major must be declared for matrices."); + } + } +} + +bool Compiler::BufferAccessHandler::handle(Op opcode, const uint32_t *args, uint32_t length) +{ + if (opcode != OpAccessChain && opcode != OpInBoundsAccessChain) + return true; + + // Invalid SPIR-V. + if (length < 4) + return false; + + if (args[2] != id) + return true; + + // Don't bother traversing the entire access chain tree yet. + // If we access a struct member, assume we access the entire member. + uint32_t index = compiler.get(args[3]).scalar(); + + // Seen this index already. + if (seen.find(index) != end(seen)) + return true; + seen.insert(index); + + auto &type = compiler.expression_type(id); + uint32_t offset = compiler.type_struct_member_offset(type, index); + + size_t range; + // If we have another member in the struct, deduce the range by looking at the next member. + // This is okay since structs in SPIR-V can have padding, but Offset decoration must be + // monotonically increasing. + // Of course, this doesn't take into account if the SPIR-V for some reason decided to add + // very large amounts of padding, but that's not really a big deal. + if (index + 1 < type.member_types.size()) + { + range = compiler.type_struct_member_offset(type, index + 1) - offset; + } + else + { + // No padding, so just deduce it from the size of the member directly. + range = compiler.get_declared_struct_member_size(type, index); + } + + ranges.push_back({ index, offset, range }); + return true; +} + +std::vector Compiler::get_active_buffer_ranges(uint32_t id) const +{ + std::vector ranges; + BufferAccessHandler handler(*this, ranges, id); + traverse_all_reachable_opcodes(get(entry_point), handler); + return ranges; +} + +// Increase the number of IDs by the specified incremental amount. +// Returns the value of the first ID available for use in the expanded bound. +uint32_t Compiler::increase_bound_by(uint32_t incr_amount) +{ + auto curr_bound = ids.size(); + auto new_bound = curr_bound + incr_amount; + ids.resize(new_bound); + meta.resize(new_bound); + return uint32_t(curr_bound); +} + +bool Compiler::types_are_logically_equivalent(const SPIRType &a, const SPIRType &b) const +{ + if (a.basetype != b.basetype) + return false; + if (a.width != b.width) + return false; + if (a.vecsize != b.vecsize) + return false; + if (a.columns != b.columns) + return false; + if (a.array.size() != b.array.size()) + return false; + + size_t array_count = a.array.size(); + if (array_count && memcmp(a.array.data(), b.array.data(), array_count * sizeof(uint32_t)) != 0) + return false; + + if (a.basetype == SPIRType::Image || a.basetype == SPIRType::SampledImage) + { + if (memcmp(&a.image, &b.image, sizeof(SPIRType::Image)) != 0) + return false; + } + + if (a.member_types.size() != b.member_types.size()) + return false; + + size_t member_types = a.member_types.size(); + for (size_t i = 0; i < member_types; i++) + { + if (!types_are_logically_equivalent(get(a.member_types[i]), get(b.member_types[i]))) + return false; + } + + return true; +} + +uint64_t Compiler::get_execution_mode_mask() const +{ + return get_entry_point().flags; +} + +void Compiler::set_execution_mode(ExecutionMode mode, uint32_t arg0, uint32_t arg1, uint32_t arg2) +{ + auto &execution = get_entry_point(); + + execution.flags |= 1ull << mode; + switch (mode) + { + case ExecutionModeLocalSize: + execution.workgroup_size.x = arg0; + execution.workgroup_size.y = arg1; + execution.workgroup_size.z = arg2; + break; + + case ExecutionModeInvocations: + execution.invocations = arg0; + break; + + case ExecutionModeOutputVertices: + execution.output_vertices = arg0; + break; + + default: + break; + } +} + +void Compiler::unset_execution_mode(ExecutionMode mode) +{ + auto &execution = get_entry_point(); + execution.flags &= ~(1ull << mode); +} + +uint32_t Compiler::get_work_group_size_specialization_constants(SpecializationConstant &x, SpecializationConstant &y, + SpecializationConstant &z) const +{ + auto &execution = get_entry_point(); + x = { 0, 0 }; + y = { 0, 0 }; + z = { 0, 0 }; + + if (execution.workgroup_size.constant != 0) + { + auto &c = get(execution.workgroup_size.constant); + + if (c.m.c[0].id[0] != 0) + { + x.id = c.m.c[0].id[0]; + x.constant_id = get_decoration(c.m.c[0].id[0], DecorationSpecId); + } + + if (c.m.c[0].id[1] != 0) + { + y.id = c.m.c[0].id[1]; + y.constant_id = get_decoration(c.m.c[0].id[1], DecorationSpecId); + } + + if (c.m.c[0].id[2] != 0) + { + z.id = c.m.c[0].id[2]; + z.constant_id = get_decoration(c.m.c[0].id[2], DecorationSpecId); + } + } + + return execution.workgroup_size.constant; +} + +uint32_t Compiler::get_execution_mode_argument(spv::ExecutionMode mode, uint32_t index) const +{ + auto &execution = get_entry_point(); + switch (mode) + { + case ExecutionModeLocalSize: + switch (index) + { + case 0: + return execution.workgroup_size.x; + case 1: + return execution.workgroup_size.y; + case 2: + return execution.workgroup_size.z; + default: + return 0; + } + + case ExecutionModeInvocations: + return execution.invocations; + + case ExecutionModeOutputVertices: + return execution.output_vertices; + + default: + return 0; + } +} + +ExecutionModel Compiler::get_execution_model() const +{ + auto &execution = get_entry_point(); + return execution.model; +} + +void Compiler::set_remapped_variable_state(uint32_t id, bool remap_enable) +{ + get(id).remapped_variable = remap_enable; +} + +bool Compiler::get_remapped_variable_state(uint32_t id) const +{ + return get(id).remapped_variable; +} + +void Compiler::set_subpass_input_remapped_components(uint32_t id, uint32_t components) +{ + get(id).remapped_components = components; +} + +uint32_t Compiler::get_subpass_input_remapped_components(uint32_t id) const +{ + return get(id).remapped_components; +} + +void Compiler::inherit_expression_dependencies(uint32_t dst, uint32_t source_expression) +{ + // Don't inherit any expression dependencies if the expression in dst + // is not a forwarded temporary. + if (forwarded_temporaries.find(dst) == end(forwarded_temporaries) || + forced_temporaries.find(dst) != end(forced_temporaries)) + { + return; + } + + auto &e = get(dst); + auto *s = maybe_get(source_expression); + if (!s) + return; + + auto &e_deps = e.expression_dependencies; + auto &s_deps = s->expression_dependencies; + + // If we depend on a expression, we also depend on all sub-dependencies from source. + e_deps.push_back(source_expression); + e_deps.insert(end(e_deps), begin(s_deps), end(s_deps)); + + // Eliminate duplicated dependencies. + e_deps.erase(unique(begin(e_deps), end(e_deps)), end(e_deps)); +} + +vector Compiler::get_entry_points() const +{ + vector entries; + for (auto &entry : entry_points) + entries.push_back(entry.second.orig_name); + return entries; +} + +void Compiler::rename_entry_point(const std::string &old_name, const std::string &new_name) +{ + auto &entry = get_entry_point(old_name); + entry.orig_name = new_name; + entry.name = new_name; +} + +void Compiler::set_entry_point(const std::string &name) +{ + auto &entry = get_entry_point(name); + entry_point = entry.self; +} + +SPIREntryPoint &Compiler::get_entry_point(const std::string &name) +{ + auto itr = + find_if(begin(entry_points), end(entry_points), [&](const std::pair &entry) -> bool { + return entry.second.orig_name == name; + }); + + if (itr == end(entry_points)) + SPIRV_CROSS_THROW("Entry point does not exist."); + + return itr->second; +} + +const SPIREntryPoint &Compiler::get_entry_point(const std::string &name) const +{ + auto itr = + find_if(begin(entry_points), end(entry_points), [&](const std::pair &entry) -> bool { + return entry.second.orig_name == name; + }); + + if (itr == end(entry_points)) + SPIRV_CROSS_THROW("Entry point does not exist."); + + return itr->second; +} + +const string &Compiler::get_cleansed_entry_point_name(const std::string &name) const +{ + return get_entry_point(name).name; +} + +const SPIREntryPoint &Compiler::get_entry_point() const +{ + return entry_points.find(entry_point)->second; +} + +SPIREntryPoint &Compiler::get_entry_point() +{ + return entry_points.find(entry_point)->second; +} + +bool Compiler::interface_variable_exists_in_entry_point(uint32_t id) const +{ + auto &var = get(id); + if (var.storage != StorageClassInput && var.storage != StorageClassOutput && + var.storage != StorageClassUniformConstant) + SPIRV_CROSS_THROW("Only Input, Output variables and Uniform constants are part of a shader linking interface."); + + // This is to avoid potential problems with very old glslang versions which did + // not emit input/output interfaces properly. + // We can assume they only had a single entry point, and single entry point + // shaders could easily be assumed to use every interface variable anyways. + if (entry_points.size() <= 1) + return true; + + auto &execution = get_entry_point(); + return find(begin(execution.interface_variables), end(execution.interface_variables), id) != + end(execution.interface_variables); +} + +void Compiler::CombinedImageSamplerHandler::push_remap_parameters(const SPIRFunction &func, const uint32_t *args, + uint32_t length) +{ + // If possible, pipe through a remapping table so that parameters know + // which variables they actually bind to in this scope. + unordered_map remapping; + for (uint32_t i = 0; i < length; i++) + remapping[func.arguments[i].id] = remap_parameter(args[i]); + parameter_remapping.push(move(remapping)); +} + +void Compiler::CombinedImageSamplerHandler::pop_remap_parameters() +{ + parameter_remapping.pop(); +} + +uint32_t Compiler::CombinedImageSamplerHandler::remap_parameter(uint32_t id) +{ + auto *var = compiler.maybe_get_backing_variable(id); + if (var) + id = var->self; + + if (parameter_remapping.empty()) + return id; + + auto &remapping = parameter_remapping.top(); + auto itr = remapping.find(id); + if (itr != end(remapping)) + return itr->second; + else + return id; +} + +bool Compiler::CombinedImageSamplerHandler::begin_function_scope(const uint32_t *args, uint32_t length) +{ + if (length < 3) + return false; + + auto &callee = compiler.get(args[2]); + args += 3; + length -= 3; + push_remap_parameters(callee, args, length); + functions.push(&callee); + return true; +} + +bool Compiler::CombinedImageSamplerHandler::end_function_scope(const uint32_t *args, uint32_t length) +{ + if (length < 3) + return false; + + auto &callee = compiler.get(args[2]); + args += 3; + + // There are two types of cases we have to handle, + // a callee might call sampler2D(texture2D, sampler) directly where + // one or more parameters originate from parameters. + // Alternatively, we need to provide combined image samplers to our callees, + // and in this case we need to add those as well. + + pop_remap_parameters(); + + // Our callee has now been processed at least once. + // No point in doing it again. + callee.do_combined_parameters = false; + + auto ¶ms = functions.top()->combined_parameters; + functions.pop(); + if (functions.empty()) + return true; + + auto &caller = *functions.top(); + if (caller.do_combined_parameters) + { + for (auto ¶m : params) + { + uint32_t image_id = param.global_image ? param.image_id : args[param.image_id]; + uint32_t sampler_id = param.global_sampler ? param.sampler_id : args[param.sampler_id]; + + auto *i = compiler.maybe_get_backing_variable(image_id); + auto *s = compiler.maybe_get_backing_variable(sampler_id); + if (i) + image_id = i->self; + if (s) + sampler_id = s->self; + + register_combined_image_sampler(caller, image_id, sampler_id, param.depth); + } + } + + return true; +} + +void Compiler::CombinedImageSamplerHandler::register_combined_image_sampler(SPIRFunction &caller, uint32_t image_id, + uint32_t sampler_id, bool depth) +{ + // We now have a texture ID and a sampler ID which will either be found as a global + // or a parameter in our own function. If both are global, they will not need a parameter, + // otherwise, add it to our list. + SPIRFunction::CombinedImageSamplerParameter param = { + 0u, image_id, sampler_id, true, true, depth, + }; + + auto texture_itr = find_if(begin(caller.arguments), end(caller.arguments), + [image_id](const SPIRFunction::Parameter &p) { return p.id == image_id; }); + auto sampler_itr = find_if(begin(caller.arguments), end(caller.arguments), + [sampler_id](const SPIRFunction::Parameter &p) { return p.id == sampler_id; }); + + if (texture_itr != end(caller.arguments)) + { + param.global_image = false; + param.image_id = uint32_t(texture_itr - begin(caller.arguments)); + } + + if (sampler_itr != end(caller.arguments)) + { + param.global_sampler = false; + param.sampler_id = uint32_t(sampler_itr - begin(caller.arguments)); + } + + if (param.global_image && param.global_sampler) + return; + + auto itr = find_if(begin(caller.combined_parameters), end(caller.combined_parameters), + [¶m](const SPIRFunction::CombinedImageSamplerParameter &p) { + return param.image_id == p.image_id && param.sampler_id == p.sampler_id && + param.global_image == p.global_image && param.global_sampler == p.global_sampler; + }); + + if (itr == end(caller.combined_parameters)) + { + uint32_t id = compiler.increase_bound_by(3); + auto type_id = id + 0; + auto ptr_type_id = id + 1; + auto combined_id = id + 2; + auto &base = compiler.expression_type(image_id); + auto &type = compiler.set(type_id); + auto &ptr_type = compiler.set(ptr_type_id); + + type = base; + type.self = type_id; + type.basetype = SPIRType::SampledImage; + type.pointer = false; + type.storage = StorageClassGeneric; + type.image.depth = depth; + + ptr_type = type; + ptr_type.pointer = true; + ptr_type.storage = StorageClassUniformConstant; + + // Build new variable. + compiler.set(combined_id, ptr_type_id, StorageClassFunction, 0); + + // Inherit RelaxedPrecision (and potentially other useful flags if deemed relevant). + auto &new_flags = compiler.meta[combined_id].decoration.decoration_flags; + auto old_flags = compiler.meta[sampler_id].decoration.decoration_flags; + new_flags = old_flags & (1ull << DecorationRelaxedPrecision); + + param.id = combined_id; + + compiler.set_name(combined_id, + join("SPIRV_Cross_Combined", compiler.to_name(image_id), compiler.to_name(sampler_id))); + + caller.combined_parameters.push_back(param); + caller.shadow_arguments.push_back({ ptr_type_id, combined_id, 0u, 0u, true }); + } +} + +bool Compiler::CombinedImageSamplerHandler::handle(Op opcode, const uint32_t *args, uint32_t length) +{ + // We need to figure out where samplers and images are loaded from, so do only the bare bones compilation we need. + switch (opcode) + { + case OpLoad: + { + if (length < 3) + return false; + + uint32_t result_type = args[0]; + + auto &type = compiler.get(result_type); + bool separate_image = type.basetype == SPIRType::Image && type.image.sampled == 1; + bool separate_sampler = type.basetype == SPIRType::Sampler; + + // If not separate image or sampler, don't bother. + if (!separate_image && !separate_sampler) + return true; + + uint32_t id = args[1]; + uint32_t ptr = args[2]; + compiler.set(id, "", result_type, true); + compiler.register_read(id, ptr, true); + return true; + } + + case OpInBoundsAccessChain: + case OpAccessChain: + { + if (length < 3) + return false; + + // Technically, it is possible to have arrays of textures and arrays of samplers and combine them, but this becomes essentially + // impossible to implement, since we don't know which concrete sampler we are accessing. + // One potential way is to create a combinatorial explosion where N textures and M samplers are combined into N * M sampler2Ds, + // but this seems ridiculously complicated for a problem which is easy to work around. + // Checking access chains like this assumes we don't have samplers or textures inside uniform structs, but this makes no sense. + + auto &type = compiler.get(args[0]); + bool separate_image = type.basetype == SPIRType::Image && type.image.sampled == 1; + bool separate_sampler = type.basetype == SPIRType::Sampler; + if (separate_image) + SPIRV_CROSS_THROW("Attempting to use arrays or structs of separate images. This is not possible to " + "statically remap to plain GLSL."); + if (separate_sampler) + SPIRV_CROSS_THROW( + "Attempting to use arrays or structs of separate samplers. This is not possible to statically " + "remap to plain GLSL."); + return true; + } + + case OpSampledImage: + // Do it outside. + break; + + default: + return true; + } + + if (length < 4) + return false; + + // Registers sampler2D calls used in case they are parameters so + // that their callees know which combined image samplers to propagate down the call stack. + if (!functions.empty()) + { + auto &callee = *functions.top(); + if (callee.do_combined_parameters) + { + uint32_t image_id = args[2]; + + auto *image = compiler.maybe_get_backing_variable(image_id); + if (image) + image_id = image->self; + + uint32_t sampler_id = args[3]; + auto *sampler = compiler.maybe_get_backing_variable(sampler_id); + if (sampler) + sampler_id = sampler->self; + + auto &combined_type = compiler.get(args[0]); + register_combined_image_sampler(callee, image_id, sampler_id, combined_type.image.depth); + } + } + + // For function calls, we need to remap IDs which are function parameters into global variables. + // This information is statically known from the current place in the call stack. + // Function parameters are not necessarily pointers, so if we don't have a backing variable, remapping will know + // which backing variable the image/sample came from. + uint32_t image_id = remap_parameter(args[2]); + uint32_t sampler_id = remap_parameter(args[3]); + + auto itr = find_if(begin(compiler.combined_image_samplers), end(compiler.combined_image_samplers), + [image_id, sampler_id](const CombinedImageSampler &combined) { + return combined.image_id == image_id && combined.sampler_id == sampler_id; + }); + + if (itr == end(compiler.combined_image_samplers)) + { + auto id = compiler.increase_bound_by(2); + auto type_id = id + 0; + auto combined_id = id + 1; + auto sampled_type = args[0]; + + // Make a new type, pointer to OpTypeSampledImage, so we can make a variable of this type. + // We will probably have this type lying around, but it doesn't hurt to make duplicates for internal purposes. + auto &type = compiler.set(type_id); + auto &base = compiler.get(sampled_type); + type = base; + type.pointer = true; + type.storage = StorageClassUniformConstant; + + // Build new variable. + compiler.set(combined_id, type_id, StorageClassUniformConstant, 0); + + // Inherit RelaxedPrecision (and potentially other useful flags if deemed relevant). + auto &new_flags = compiler.meta[combined_id].decoration.decoration_flags; + auto old_flags = compiler.meta[sampler_id].decoration.decoration_flags; + new_flags = old_flags & (1ull << DecorationRelaxedPrecision); + + compiler.combined_image_samplers.push_back({ combined_id, image_id, sampler_id }); + } + + return true; +} + +void Compiler::build_combined_image_samplers() +{ + for (auto &id : ids) + { + if (id.get_type() == TypeFunction) + { + auto &func = id.get(); + func.combined_parameters.clear(); + func.shadow_arguments.clear(); + func.do_combined_parameters = true; + } + } + + combined_image_samplers.clear(); + CombinedImageSamplerHandler handler(*this); + traverse_all_reachable_opcodes(get(entry_point), handler); +} + +vector Compiler::get_specialization_constants() const +{ + vector spec_consts; + for (auto &id : ids) + { + if (id.get_type() == TypeConstant) + { + auto &c = id.get(); + if (c.specialization) + { + spec_consts.push_back({ c.self, get_decoration(c.self, DecorationSpecId) }); + } + } + } + return spec_consts; +} + +SPIRConstant &Compiler::get_constant(uint32_t id) +{ + return get(id); +} + +const SPIRConstant &Compiler::get_constant(uint32_t id) const +{ + return get(id); +} + +// Recursively marks any constants referenced by the specified constant instruction as being used +// as an array length. The id must be a constant instruction (SPIRConstant or SPIRConstantOp). +void Compiler::mark_used_as_array_length(uint32_t id) +{ + switch (ids[id].get_type()) + { + case TypeConstant: + get(id).is_used_as_array_length = true; + break; + + case TypeConstantOp: + { + auto &cop = get(id); + for (uint32_t arg_id : cop.arguments) + mark_used_as_array_length(arg_id); + } + + case TypeUndef: + return; + + default: + SPIRV_CROSS_THROW("Array lengths must be a constant instruction (OpConstant.. or OpSpecConstant...)."); + } +} + +static bool exists_unaccessed_path_to_return(const CFG &cfg, uint32_t block, const unordered_set &blocks) +{ + // This block accesses the variable. + if (blocks.find(block) != end(blocks)) + return false; + + // We are at the end of the CFG. + if (cfg.get_succeeding_edges(block).empty()) + return true; + + // If any of our successors have a path to the end, there exists a path from block. + for (auto &succ : cfg.get_succeeding_edges(block)) + if (exists_unaccessed_path_to_return(cfg, succ, blocks)) + return true; + + return false; +} + +void Compiler::analyze_parameter_preservation( + SPIRFunction &entry, const CFG &cfg, const unordered_map> &variable_to_blocks, + const unordered_map> &complete_write_blocks) +{ + for (auto &arg : entry.arguments) + { + // Non-pointers are always inputs. + auto &type = get(arg.type); + if (!type.pointer) + continue; + + // Opaque argument types are always in + bool potential_preserve; + switch (type.basetype) + { + case SPIRType::Sampler: + case SPIRType::Image: + case SPIRType::SampledImage: + case SPIRType::AtomicCounter: + potential_preserve = false; + break; + + default: + potential_preserve = true; + break; + } + + if (!potential_preserve) + continue; + + auto itr = variable_to_blocks.find(arg.id); + if (itr == end(variable_to_blocks)) + { + // Variable is never accessed. + continue; + } + + // We have accessed a variable, but there was no complete writes to that variable. + // We deduce that we must preserve the argument. + itr = complete_write_blocks.find(arg.id); + if (itr == end(complete_write_blocks)) + { + arg.read_count++; + continue; + } + + // If there is a path through the CFG where no block completely writes to the variable, the variable will be in an undefined state + // when the function returns. We therefore need to implicitly preserve the variable in case there are writers in the function. + // Major case here is if a function is + // void foo(int &var) { if (cond) var = 10; } + // Using read/write counts, we will think it's just an out variable, but it really needs to be inout, + // because if we don't write anything whatever we put into the function must return back to the caller. + if (exists_unaccessed_path_to_return(cfg, entry.entry_block, itr->second)) + arg.read_count++; + } +} + +void Compiler::analyze_variable_scope(SPIRFunction &entry) +{ + struct AccessHandler : OpcodeHandler + { + public: + AccessHandler(Compiler &compiler_, SPIRFunction &entry_) + : compiler(compiler_) + , entry(entry_) + { + } + + bool follow_function_call(const SPIRFunction &) + { + // Only analyze within this function. + return false; + } + + void set_current_block(const SPIRBlock &block) + { + current_block = █ + + // If we're branching to a block which uses OpPhi, in GLSL + // this will be a variable write when we branch, + // so we need to track access to these variables as well to + // have a complete picture. + const auto test_phi = [this, &block](uint32_t to) { + auto &next = compiler.get(to); + for (auto &phi : next.phi_variables) + { + if (phi.parent == block.self) + { + accessed_variables_to_block[phi.function_variable].insert(block.self); + // Phi variables are also accessed in our target branch block. + accessed_variables_to_block[phi.function_variable].insert(next.self); + + notify_variable_access(phi.local_variable, block.self); + } + } + }; + + switch (block.terminator) + { + case SPIRBlock::Direct: + notify_variable_access(block.condition, block.self); + test_phi(block.next_block); + break; + + case SPIRBlock::Select: + notify_variable_access(block.condition, block.self); + test_phi(block.true_block); + test_phi(block.false_block); + break; + + case SPIRBlock::MultiSelect: + notify_variable_access(block.condition, block.self); + for (auto &target : block.cases) + test_phi(target.block); + if (block.default_block) + test_phi(block.default_block); + break; + + default: + break; + } + } + + void notify_variable_access(uint32_t id, uint32_t block) + { + if (id_is_phi_variable(id)) + accessed_variables_to_block[id].insert(block); + else if (id_is_potential_temporary(id)) + accessed_temporaries_to_block[id].insert(block); + } + + bool id_is_phi_variable(uint32_t id) + { + if (id >= compiler.get_current_id_bound()) + return false; + auto *var = compiler.maybe_get(id); + return var && var->phi_variable; + } + + bool id_is_potential_temporary(uint32_t id) + { + if (id >= compiler.get_current_id_bound()) + return false; + + // Temporaries are not created before we start emitting code. + return compiler.ids[id].empty() || (compiler.ids[id].get_type() == TypeExpression); + } + + bool handle(spv::Op op, const uint32_t *args, uint32_t length) + { + // Keep track of the types of temporaries, so we can hoist them out as necessary. + uint32_t result_type, result_id; + if (compiler.instruction_to_result_type(result_type, result_id, op, args, length)) + result_id_to_type[result_id] = result_type; + + switch (op) + { + case OpStore: + { + if (length < 2) + return false; + + uint32_t ptr = args[0]; + auto *var = compiler.maybe_get_backing_variable(ptr); + if (var && var->storage == StorageClassFunction) + accessed_variables_to_block[var->self].insert(current_block->self); + + // If we store through an access chain, we have a partial write. + if (var && var->self == ptr && var->storage == StorageClassFunction) + complete_write_variables_to_block[var->self].insert(current_block->self); + + // Might try to store a Phi variable here. + notify_variable_access(args[1], current_block->self); + break; + } + + case OpAccessChain: + case OpInBoundsAccessChain: + { + if (length < 3) + return false; + + uint32_t ptr = args[2]; + auto *var = compiler.maybe_get(ptr); + if (var && var->storage == StorageClassFunction) + accessed_variables_to_block[var->self].insert(current_block->self); + + for (uint32_t i = 3; i < length; i++) + notify_variable_access(args[i], current_block->self); + + // The result of an access chain is a fixed expression and is not really considered a temporary. + break; + } + + case OpCopyMemory: + { + if (length < 2) + return false; + + uint32_t lhs = args[0]; + uint32_t rhs = args[1]; + auto *var = compiler.maybe_get_backing_variable(lhs); + if (var && var->storage == StorageClassFunction) + accessed_variables_to_block[var->self].insert(current_block->self); + + // If we store through an access chain, we have a partial write. + if (var->self == lhs) + complete_write_variables_to_block[var->self].insert(current_block->self); + + var = compiler.maybe_get_backing_variable(rhs); + if (var && var->storage == StorageClassFunction) + accessed_variables_to_block[var->self].insert(current_block->self); + break; + } + + case OpCopyObject: + { + if (length < 3) + return false; + + auto *var = compiler.maybe_get_backing_variable(args[2]); + if (var && var->storage == StorageClassFunction) + accessed_variables_to_block[var->self].insert(current_block->self); + + // Might try to copy a Phi variable here. + notify_variable_access(args[2], current_block->self); + break; + } + + case OpLoad: + { + if (length < 3) + return false; + uint32_t ptr = args[2]; + auto *var = compiler.maybe_get_backing_variable(ptr); + if (var && var->storage == StorageClassFunction) + accessed_variables_to_block[var->self].insert(current_block->self); + + // Loaded value is a temporary. + notify_variable_access(args[1], current_block->self); + break; + } + + case OpFunctionCall: + { + if (length < 3) + return false; + + length -= 3; + args += 3; + for (uint32_t i = 0; i < length; i++) + { + auto *var = compiler.maybe_get_backing_variable(args[i]); + if (var && var->storage == StorageClassFunction) + accessed_variables_to_block[var->self].insert(current_block->self); + + // Cannot easily prove if argument we pass to a function is completely written. + // Usually, functions write to a dummy variable, + // which is then copied to in full to the real argument. + + // Might try to copy a Phi variable here. + notify_variable_access(args[i], current_block->self); + } + + // Return value may be a temporary. + notify_variable_access(args[1], current_block->self); + break; + } + + case OpExtInst: + { + for (uint32_t i = 4; i < length; i++) + notify_variable_access(args[i], current_block->self); + notify_variable_access(args[1], current_block->self); + break; + } + + case OpArrayLength: + // Uses literals, but cannot be a phi variable, so ignore. + break; + + // Atomics shouldn't be able to access function-local variables. + // Some GLSL builtins access a pointer. + + case OpCompositeInsert: + case OpVectorShuffle: + // Specialize for opcode which contains literals. + for (uint32_t i = 1; i < 4; i++) + notify_variable_access(args[i], current_block->self); + break; + + case OpCompositeExtract: + // Specialize for opcode which contains literals. + for (uint32_t i = 1; i < 3; i++) + notify_variable_access(args[i], current_block->self); + break; + + default: + { + // Rather dirty way of figuring out where Phi variables are used. + // As long as only IDs are used, we can scan through instructions and try to find any evidence that + // the ID of a variable has been used. + // There are potential false positives here where a literal is used in-place of an ID, + // but worst case, it does not affect the correctness of the compile. + // Exhaustive analysis would be better here, but it's not worth it for now. + for (uint32_t i = 0; i < length; i++) + notify_variable_access(args[i], current_block->self); + break; + } + } + return true; + } + + Compiler &compiler; + SPIRFunction &entry; + std::unordered_map> accessed_variables_to_block; + std::unordered_map> accessed_temporaries_to_block; + std::unordered_map result_id_to_type; + std::unordered_map> complete_write_variables_to_block; + const SPIRBlock *current_block = nullptr; + } handler(*this, entry); + + // First, we map out all variable access within a function. + // Essentially a map of block -> { variables accessed in the basic block } + this->traverse_all_reachable_opcodes(entry, handler); + + // Compute the control flow graph for this function. + CFG cfg(*this, entry); + + // Analyze if there are parameters which need to be implicitly preserved with an "in" qualifier. + analyze_parameter_preservation(entry, cfg, handler.accessed_variables_to_block, + handler.complete_write_variables_to_block); + + unordered_map potential_loop_variables; + + // For each variable which is statically accessed. + for (auto &var : handler.accessed_variables_to_block) + { + DominatorBuilder builder(cfg); + auto &blocks = var.second; + auto &type = this->expression_type(var.first); + + // Figure out which block is dominating all accesses of those variables. + for (auto &block : blocks) + { + // If we're accessing a variable inside a continue block, this variable might be a loop variable. + // We can only use loop variables with scalars, as we cannot track static expressions for vectors. + if (this->is_continue(block)) + { + // Potentially awkward case to check for. + // We might have a variable inside a loop, which is touched by the continue block, + // but is not actually a loop variable. + // The continue block is dominated by the inner part of the loop, which does not make sense in high-level + // language output because it will be declared before the body, + // so we will have to lift the dominator up to the relevant loop header instead. + builder.add_block(continue_block_to_loop_header[block]); + + if (type.vecsize == 1 && type.columns == 1) + { + // The variable is used in multiple continue blocks, this is not a loop + // candidate, signal that by setting block to -1u. + auto &potential = potential_loop_variables[var.first]; + + if (potential == 0) + potential = block; + else + potential = ~(0u); + } + } + builder.add_block(block); + } + + builder.lift_continue_block_dominator(); + + // Add it to a per-block list of variables. + uint32_t dominating_block = builder.get_dominator(); + + // If all blocks here are dead code, this will be 0, so the variable in question + // will be completely eliminated. + if (dominating_block) + { + auto &block = this->get(dominating_block); + block.dominated_variables.push_back(var.first); + this->get(var.first).dominator = dominating_block; + } + } + + for (auto &var : handler.accessed_temporaries_to_block) + { + auto itr = handler.result_id_to_type.find(var.first); + + if (itr == end(handler.result_id_to_type)) + { + // We found a false positive ID being used, ignore. + // This should probably be an assert. + continue; + } + + DominatorBuilder builder(cfg); + + // Figure out which block is dominating all accesses of those temporaries. + auto &blocks = var.second; + for (auto &block : blocks) + { + builder.add_block(block); + + // If a temporary is used in more than one block, we might have to lift continue block + // access up to loop header like we did for variables. + if (blocks.size() != 1 && this->is_continue(block)) + builder.add_block(continue_block_to_loop_header[block]); + } + + uint32_t dominating_block = builder.get_dominator(); + if (dominating_block) + { + // If we touch a variable in the dominating block, this is the expected setup. + // SPIR-V normally mandates this, but we have extra cases for temporary use inside loops. + bool first_use_is_dominator = blocks.count(dominating_block) != 0; + + if (!first_use_is_dominator) + { + // This should be very rare, but if we try to declare a temporary inside a loop, + // and that temporary is used outside the loop as well (spirv-opt inliner likes this) + // we should actually emit the temporary outside the loop. + hoisted_temporaries.insert(var.first); + forced_temporaries.insert(var.first); + + auto &block_temporaries = get(dominating_block).declare_temporary; + block_temporaries.emplace_back(handler.result_id_to_type[var.first], var.first); + } + } + } + + unordered_set seen_blocks; + + // Now, try to analyze whether or not these variables are actually loop variables. + for (auto &loop_variable : potential_loop_variables) + { + auto &var = this->get(loop_variable.first); + auto dominator = var.dominator; + auto block = loop_variable.second; + + // The variable was accessed in multiple continue blocks, ignore. + if (block == ~(0u) || block == 0) + continue; + + // Dead code. + if (dominator == 0) + continue; + + uint32_t header = 0; + + // Find the loop header for this block. + for (auto b : this->loop_blocks) + { + auto &potential_header = this->get(b); + if (potential_header.continue_block == block) + { + header = b; + break; + } + } + + assert(header); + auto &header_block = this->get(header); + auto &blocks = handler.accessed_variables_to_block[loop_variable.first]; + + // If a loop variable is not used before the loop, it's probably not a loop variable. + bool has_accessed_variable = blocks.count(header) != 0; + + // Now, there are two conditions we need to meet for the variable to be a loop variable. + // 1. The dominating block must have a branch-free path to the loop header, + // this way we statically know which expression should be part of the loop variable initializer. + + // Walk from the dominator, if there is one straight edge connecting + // dominator and loop header, we statically know the loop initializer. + bool static_loop_init = true; + while (dominator != header) + { + if (blocks.count(dominator) != 0) + has_accessed_variable = true; + + auto &succ = cfg.get_succeeding_edges(dominator); + if (succ.size() != 1) + { + static_loop_init = false; + break; + } + + auto &pred = cfg.get_preceding_edges(succ.front()); + if (pred.size() != 1 || pred.front() != dominator) + { + static_loop_init = false; + break; + } + + dominator = succ.front(); + } + + if (!static_loop_init || !has_accessed_variable) + continue; + + // The second condition we need to meet is that no access after the loop + // merge can occur. Walk the CFG to see if we find anything. + + seen_blocks.clear(); + cfg.walk_from(seen_blocks, header_block.merge_block, [&](uint32_t walk_block) { + // We found a block which accesses the variable outside the loop. + if (blocks.find(walk_block) != end(blocks)) + static_loop_init = false; + }); + + if (!static_loop_init) + continue; + + // We have a loop variable. + header_block.loop_variables.push_back(loop_variable.first); + // Need to sort here as variables come from an unordered container, and pushing stuff in wrong order + // will break reproducability in regression runs. + sort(begin(header_block.loop_variables), end(header_block.loop_variables)); + this->get(loop_variable.first).loop_variable = true; + } +} + +uint64_t Compiler::get_buffer_block_flags(const SPIRVariable &var) +{ + auto &type = get(var.basetype); + assert(type.basetype == SPIRType::Struct); + + // Some flags like non-writable, non-readable are actually found + // as member decorations. If all members have a decoration set, propagate + // the decoration up as a regular variable decoration. + uint64_t base_flags = meta[var.self].decoration.decoration_flags; + + if (type.member_types.empty()) + return base_flags; + + uint64_t all_members_flag_mask = ~(0ull); + for (uint32_t i = 0; i < uint32_t(type.member_types.size()); i++) + all_members_flag_mask &= get_member_decoration_mask(type.self, i); + + return base_flags | all_members_flag_mask; +} + +bool Compiler::get_common_basic_type(const SPIRType &type, SPIRType::BaseType &base_type) +{ + if (type.basetype == SPIRType::Struct) + { + base_type = SPIRType::Unknown; + for (auto &member_type : type.member_types) + { + SPIRType::BaseType member_base; + if (!get_common_basic_type(get(member_type), member_base)) + return false; + + if (base_type == SPIRType::Unknown) + base_type = member_base; + else if (base_type != member_base) + return false; + } + return true; + } + else + { + base_type = type.basetype; + return true; + } +} + +bool Compiler::ActiveBuiltinHandler::handle(spv::Op opcode, const uint32_t *args, uint32_t length) +{ + const auto add_if_builtin = [&](uint32_t id) { + // Only handles variables here. + // Builtins which are part of a block are handled in AccessChain. + auto *var = compiler.maybe_get(id); + if (var && compiler.meta[id].decoration.builtin) + { + auto &type = compiler.get(var->basetype); + auto &flags = + type.storage == StorageClassInput ? compiler.active_input_builtins : compiler.active_output_builtins; + flags |= 1ull << compiler.meta[id].decoration.builtin_type; + } + }; + + switch (opcode) + { + case OpStore: + if (length < 1) + return false; + + add_if_builtin(args[0]); + break; + + case OpCopyMemory: + if (length < 2) + return false; + + add_if_builtin(args[0]); + add_if_builtin(args[1]); + break; + + case OpCopyObject: + case OpLoad: + if (length < 3) + return false; + + add_if_builtin(args[2]); + break; + + case OpFunctionCall: + { + if (length < 3) + return false; + + uint32_t count = length - 3; + args += 3; + for (uint32_t i = 0; i < count; i++) + add_if_builtin(args[i]); + break; + } + + case OpAccessChain: + case OpInBoundsAccessChain: + { + if (length < 4) + return false; + + // Only consider global variables, cannot consider variables in functions yet, or other + // access chains as they have not been created yet. + auto *var = compiler.maybe_get(args[2]); + if (!var) + break; + + // Required if we access chain into builtins like gl_GlobalInvocationID. + add_if_builtin(args[2]); + + auto *type = &compiler.get(var->basetype); + + // Start traversing type hierarchy at the proper non-pointer types. + while (type->pointer) + { + assert(type->parent_type); + type = &compiler.get(type->parent_type); + } + + auto &flags = + type->storage == StorageClassInput ? compiler.active_input_builtins : compiler.active_output_builtins; + + uint32_t count = length - 3; + args += 3; + for (uint32_t i = 0; i < count; i++) + { + // Arrays + if (!type->array.empty()) + { + type = &compiler.get(type->parent_type); + } + // Structs + else if (type->basetype == SPIRType::Struct) + { + uint32_t index = compiler.get(args[i]).scalar(); + + if (index < uint32_t(compiler.meta[type->self].members.size())) + { + auto &decorations = compiler.meta[type->self].members[index]; + if (decorations.builtin) + flags |= 1ull << decorations.builtin_type; + } + + type = &compiler.get(type->member_types[index]); + } + else + { + // No point in traversing further. We won't find any extra builtins. + break; + } + } + break; + } + + default: + break; + } + + return true; +} + +void Compiler::update_active_builtins() +{ + active_input_builtins = 0; + active_output_builtins = 0; + ActiveBuiltinHandler handler(*this); + traverse_all_reachable_opcodes(get(entry_point), handler); +} + +// Returns whether this shader uses a builtin of the storage class +bool Compiler::has_active_builtin(BuiltIn builtin, StorageClass storage) +{ + uint64_t flags; + switch (storage) + { + case StorageClassInput: + flags = active_input_builtins; + break; + case StorageClassOutput: + flags = active_output_builtins; + break; + + default: + return false; + } + return flags & (1ull << builtin); +} + +void Compiler::analyze_sampler_comparison_states() +{ + CombinedImageSamplerUsageHandler handler(*this); + traverse_all_reachable_opcodes(get(entry_point), handler); + comparison_samplers = move(handler.comparison_samplers); +} + +bool Compiler::CombinedImageSamplerUsageHandler::begin_function_scope(const uint32_t *args, uint32_t length) +{ + if (length < 3) + return false; + + auto &func = compiler.get(args[2]); + const auto *arg = &args[3]; + length -= 3; + + for (uint32_t i = 0; i < length; i++) + { + auto &argument = func.arguments[i]; + dependency_hierarchy[argument.id].insert(arg[i]); + } + + return true; +} + +void Compiler::CombinedImageSamplerUsageHandler::add_hierarchy_to_comparison_samplers(uint32_t sampler) +{ + // Traverse the variable dependency hierarchy and tag everything in its path with comparison samplers. + comparison_samplers.insert(sampler); + for (auto &samp : dependency_hierarchy[sampler]) + add_hierarchy_to_comparison_samplers(samp); +} + +bool Compiler::CombinedImageSamplerUsageHandler::handle(Op opcode, const uint32_t *args, uint32_t length) +{ + switch (opcode) + { + case OpAccessChain: + case OpInBoundsAccessChain: + case OpLoad: + { + if (length < 3) + return false; + dependency_hierarchy[args[1]].insert(args[2]); + break; + } + + case OpSampledImage: + { + if (length < 4) + return false; + + uint32_t result_type = args[0]; + auto &type = compiler.get(result_type); + if (type.image.depth) + { + // This sampler must be a SamplerComparisionState, and not a regular SamplerState. + uint32_t sampler = args[3]; + add_hierarchy_to_comparison_samplers(sampler); + } + return true; + } + + default: + break; + } + + return true; +} + +bool Compiler::buffer_is_hlsl_counter_buffer(uint32_t id) const +{ + if (meta.at(id).hlsl_magic_counter_buffer_candidate) + { + auto *var = maybe_get(id); + // Ensure that this is actually a buffer object. + return var && (var->storage == StorageClassStorageBuffer || + has_decoration(get(var->basetype).self, DecorationBufferBlock)); + } + else + return false; +} + +bool Compiler::buffer_get_hlsl_counter_buffer(uint32_t id, uint32_t &counter_id) const +{ + auto &name = get_name(id); + uint32_t id_bound = get_current_id_bound(); + for (uint32_t i = 0; i < id_bound; i++) + { + if (meta[i].hlsl_magic_counter_buffer_candidate && meta[i].hlsl_magic_counter_buffer_name == name) + { + auto *var = maybe_get(i); + // Ensure that this is actually a buffer object. + if (var && (var->storage == StorageClassStorageBuffer || + has_decoration(get(var->basetype).self, DecorationBufferBlock))) + { + counter_id = i; + return true; + } + } + } + return false; +} + +void Compiler::make_constant_null(uint32_t id, uint32_t type) +{ + auto &constant_type = get(type); + + if (!constant_type.array.empty()) + { + assert(constant_type.parent_type); + uint32_t parent_id = increase_bound_by(1); + make_constant_null(parent_id, constant_type.parent_type); + + if (!constant_type.array_size_literal.back()) + SPIRV_CROSS_THROW("Array size of OpConstantNull must be a literal."); + + vector elements(constant_type.array.back()); + for (uint32_t i = 0; i < constant_type.array.back(); i++) + elements[i] = parent_id; + set(id, type, elements.data(), uint32_t(elements.size()), false); + } + else if (!constant_type.member_types.empty()) + { + uint32_t member_ids = increase_bound_by(uint32_t(constant_type.member_types.size())); + vector elements(constant_type.member_types.size()); + for (uint32_t i = 0; i < constant_type.member_types.size(); i++) + { + make_constant_null(member_ids + i, constant_type.member_types[i]); + elements[i] = member_ids + i; + } + set(id, type, elements.data(), uint32_t(elements.size()), false); + } + else + { + auto &constant = set(id, type); + constant.make_null(constant_type); + } +} + +const std::vector &Compiler::get_declared_capabilities() const +{ + return declared_capabilities; +} + +const std::vector &Compiler::get_declared_extensions() const +{ + return declared_extensions; +} + +std::string Compiler::get_remapped_declared_block_name(uint32_t id) const +{ + auto itr = declared_block_names.find(id); + if (itr != end(declared_block_names)) + return itr->second; + else + { + auto &var = get(id); + auto &type = get(var.basetype); + auto &block_name = meta[type.self].decoration.alias; + return block_name.empty() ? get_block_fallback_name(id) : block_name; + } +} + +bool Compiler::instruction_to_result_type(uint32_t &result_type, uint32_t &result_id, spv::Op op, const uint32_t *args, + uint32_t length) +{ + // Most instructions follow the pattern of . + // There are some exceptions. + switch (op) + { + case OpStore: + case OpCopyMemory: + case OpCopyMemorySized: + case OpImageWrite: + case OpAtomicStore: + case OpAtomicFlagClear: + case OpEmitStreamVertex: + case OpEndStreamPrimitive: + case OpControlBarrier: + case OpMemoryBarrier: + case OpGroupWaitEvents: + case OpRetainEvent: + case OpReleaseEvent: + case OpSetUserEventStatus: + case OpCaptureEventProfilingInfo: + case OpCommitReadPipe: + case OpCommitWritePipe: + case OpGroupCommitReadPipe: + case OpGroupCommitWritePipe: + return false; + + default: + if (length > 1) + { + result_type = args[0]; + result_id = args[1]; + return true; + } + else + return false; + } +} diff --git a/spirv_cross.hpp b/spirv_cross.hpp new file mode 100644 index 0000000000..c477ea952f --- /dev/null +++ b/spirv_cross.hpp @@ -0,0 +1,753 @@ +/* + * Copyright 2015-2018 ARM Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SPIRV_CROSS_HPP +#define SPIRV_CROSS_HPP + +#include "spirv.hpp" +#include "spirv_common.hpp" + +namespace spirv_cross +{ +class CFG; +struct Resource +{ + // Resources are identified with their SPIR-V ID. + // This is the ID of the OpVariable. + uint32_t id; + + // The type ID of the variable which includes arrays and all type modifications. + // This type ID is not suitable for parsing OpMemberDecoration of a struct and other decorations in general + // since these modifications typically happen on the base_type_id. + uint32_t type_id; + + // The base type of the declared resource. + // This type is the base type which ignores pointers and arrays of the type_id. + // This is mostly useful to parse decorations of the underlying type. + // base_type_id can also be obtained with get_type(get_type(type_id).self). + uint32_t base_type_id; + + // The declared name (OpName) of the resource. + // For Buffer blocks, the name actually reflects the externally + // visible Block name. + // + // This name can be retrieved again by using either + // get_name(id) or get_name(base_type_id) depending if it's a buffer block or not. + // + // This name can be an empty string in which case get_fallback_name(id) can be + // used which obtains a suitable fallback identifier for an ID. + std::string name; +}; + +struct ShaderResources +{ + std::vector uniform_buffers; + std::vector storage_buffers; + std::vector stage_inputs; + std::vector stage_outputs; + std::vector subpass_inputs; + std::vector storage_images; + std::vector sampled_images; + std::vector atomic_counters; + + // There can only be one push constant block, + // but keep the vector in case this restriction is lifted in the future. + std::vector push_constant_buffers; + + // For Vulkan GLSL and HLSL source, + // these correspond to separate texture2D and samplers respectively. + std::vector separate_images; + std::vector separate_samplers; +}; + +struct CombinedImageSampler +{ + // The ID of the sampler2D variable. + uint32_t combined_id; + // The ID of the texture2D variable. + uint32_t image_id; + // The ID of the sampler variable. + uint32_t sampler_id; +}; + +struct SpecializationConstant +{ + // The ID of the specialization constant. + uint32_t id; + // The constant ID of the constant, used in Vulkan during pipeline creation. + uint32_t constant_id; +}; + +struct BufferRange +{ + unsigned index; + size_t offset; + size_t range; +}; + +enum BufferPackingStandard +{ + BufferPackingStd140, + BufferPackingStd430, + BufferPackingStd140EnhancedLayout, + BufferPackingStd430EnhancedLayout, + BufferPackingHLSLCbuffer, + BufferPackingHLSLCbufferPackOffset +}; + +class Compiler +{ +public: + friend class CFG; + friend class DominatorBuilder; + + // The constructor takes a buffer of SPIR-V words and parses it. + Compiler(std::vector ir); + Compiler(const uint32_t *ir, size_t word_count); + + virtual ~Compiler() = default; + + // After parsing, API users can modify the SPIR-V via reflection and call this + // to disassemble the SPIR-V into the desired langauage. + // Sub-classes actually implement this. + virtual std::string compile(); + + // Gets the identifier (OpName) of an ID. If not defined, an empty string will be returned. + const std::string &get_name(uint32_t id) const; + + // Applies a decoration to an ID. Effectively injects OpDecorate. + void set_decoration(uint32_t id, spv::Decoration decoration, uint32_t argument = 0); + + // Overrides the identifier OpName of an ID. + // Identifiers beginning with underscores or identifiers which contain double underscores + // are reserved by the implementation. + void set_name(uint32_t id, const std::string &name); + + // Gets a bitmask for the decorations which are applied to ID. + // I.e. (1ull << spv::DecorationFoo) | (1ull << spv::DecorationBar) + uint64_t get_decoration_mask(uint32_t id) const; + + // Returns whether the decoration has been applied to the ID. + bool has_decoration(uint32_t id, spv::Decoration decoration) const; + + // Gets the value for decorations which take arguments. + // If the decoration is a boolean (i.e. spv::DecorationNonWritable), + // 1 will be returned. + // If decoration doesn't exist or decoration is not recognized, + // 0 will be returned. + uint32_t get_decoration(uint32_t id, spv::Decoration decoration) const; + + // Removes the decoration for a an ID. + void unset_decoration(uint32_t id, spv::Decoration decoration); + + // Gets the SPIR-V type associated with ID. + // Mostly used with Resource::type_id and Resource::base_type_id to parse the underlying type of a resource. + const SPIRType &get_type(uint32_t id) const; + + // Gets the SPIR-V type of a variable. + const SPIRType &get_type_from_variable(uint32_t id) const; + + // Gets the underlying storage class for an OpVariable. + spv::StorageClass get_storage_class(uint32_t id) const; + + // If get_name() is an empty string, get the fallback name which will be used + // instead in the disassembled source. + virtual const std::string get_fallback_name(uint32_t id) const; + + // If get_name() of a Block struct is an empty string, get the fallback name. + // This needs to be per-variable as multiple variables can use the same block type. + virtual const std::string get_block_fallback_name(uint32_t id) const; + + // Given an OpTypeStruct in ID, obtain the identifier for member number "index". + // This may be an empty string. + const std::string &get_member_name(uint32_t id, uint32_t index) const; + + // Given an OpTypeStruct in ID, obtain the OpMemberDecoration for member number "index". + uint32_t get_member_decoration(uint32_t id, uint32_t index, spv::Decoration decoration) const; + + // Sets the member identifier for OpTypeStruct ID, member number "index". + void set_member_name(uint32_t id, uint32_t index, const std::string &name); + + // Returns the qualified member identifier for OpTypeStruct ID, member number "index", + // or an empty string if no qualified alias exists + const std::string &get_member_qualified_name(uint32_t type_id, uint32_t index) const; + + // Sets the qualified member identifier for OpTypeStruct ID, member number "index". + void set_member_qualified_name(uint32_t type_id, uint32_t index, const std::string &name); + + // Gets the decoration mask for a member of a struct, similar to get_decoration_mask. + uint64_t get_member_decoration_mask(uint32_t id, uint32_t index) const; + + // Returns whether the decoration has been applied to a member of a struct. + bool has_member_decoration(uint32_t id, uint32_t index, spv::Decoration decoration) const; + + // Similar to set_decoration, but for struct members. + void set_member_decoration(uint32_t id, uint32_t index, spv::Decoration decoration, uint32_t argument = 0); + + // Unsets a member decoration, similar to unset_decoration. + void unset_member_decoration(uint32_t id, uint32_t index, spv::Decoration decoration); + + // Gets the fallback name for a member, similar to get_fallback_name. + virtual const std::string get_fallback_member_name(uint32_t index) const + { + return join("_", index); + } + + // Returns a vector of which members of a struct are potentially in use by a + // SPIR-V shader. The granularity of this analysis is per-member of a struct. + // This can be used for Buffer (UBO), BufferBlock/StorageBuffer (SSBO) and PushConstant blocks. + // ID is the Resource::id obtained from get_shader_resources(). + std::vector get_active_buffer_ranges(uint32_t id) const; + + // Returns the effective size of a buffer block. + size_t get_declared_struct_size(const SPIRType &struct_type) const; + + // Returns the effective size of a buffer block struct member. + virtual size_t get_declared_struct_member_size(const SPIRType &struct_type, uint32_t index) const; + + // Legacy GLSL compatibility method. Deprecated in favor of CompilerGLSL::flatten_buffer_block + SPIRV_CROSS_DEPRECATED("Please use flatten_buffer_block instead.") void flatten_interface_block(uint32_t id); + + // Returns a set of all global variables which are statically accessed + // by the control flow graph from the current entry point. + // Only variables which change the interface for a shader are returned, that is, + // variables with storage class of Input, Output, Uniform, UniformConstant, PushConstant and AtomicCounter + // storage classes are returned. + // + // To use the returned set as the filter for which variables are used during compilation, + // this set can be moved to set_enabled_interface_variables(). + std::unordered_set get_active_interface_variables() const; + + // Sets the interface variables which are used during compilation. + // By default, all variables are used. + // Once set, compile() will only consider the set in active_variables. + void set_enabled_interface_variables(std::unordered_set active_variables); + + // Query shader resources, use ids with reflection interface to modify or query binding points, etc. + ShaderResources get_shader_resources() const; + + // Query shader resources, but only return the variables which are part of active_variables. + // E.g.: get_shader_resources(get_active_variables()) to only return the variables which are statically + // accessed. + ShaderResources get_shader_resources(const std::unordered_set &active_variables) const; + + // Remapped variables are considered built-in variables and a backend will + // not emit a declaration for this variable. + // This is mostly useful for making use of builtins which are dependent on extensions. + void set_remapped_variable_state(uint32_t id, bool remap_enable); + bool get_remapped_variable_state(uint32_t id) const; + + // For subpassInput variables which are remapped to plain variables, + // the number of components in the remapped + // variable must be specified as the backing type of subpass inputs are opaque. + void set_subpass_input_remapped_components(uint32_t id, uint32_t components); + uint32_t get_subpass_input_remapped_components(uint32_t id) const; + + // All operations work on the current entry point. + // Entry points can be swapped out with set_entry_point(). + // Entry points should be set right after the constructor completes as some reflection functions traverse the graph from the entry point. + // Resource reflection also depends on the entry point. + // By default, the current entry point is set to the first OpEntryPoint which appears in the SPIR-V module. + std::vector get_entry_points() const; + void set_entry_point(const std::string &name); + + // Renames an entry point from old_name to new_name. + // If old_name is currently selected as the current entry point, it will continue to be the current entry point, + // albeit with a new name. + // get_entry_points() is essentially invalidated at this point. + void rename_entry_point(const std::string &old_name, const std::string &new_name); + + // Returns the internal data structure for entry points to allow poking around. + const SPIREntryPoint &get_entry_point(const std::string &name) const; + SPIREntryPoint &get_entry_point(const std::string &name); + + // Some shader languages restrict the names that can be given to entry points, and the + // corresponding backend will automatically rename an entry point name, during the call + // to compile() if it is illegal. For example, the common entry point name main() is + // illegal in MSL, and is renamed to an alternate name by the MSL backend. + // Given the original entry point name contained in the SPIR-V, this function returns + // the name, as updated by the backend during the call to compile(). If the name is not + // illegal, and has not been renamed, or if this function is called before compile(), + // this function will simply return the same name. + const std::string &get_cleansed_entry_point_name(const std::string &name) const; + + // Query and modify OpExecutionMode. + uint64_t get_execution_mode_mask() const; + void unset_execution_mode(spv::ExecutionMode mode); + void set_execution_mode(spv::ExecutionMode mode, uint32_t arg0 = 0, uint32_t arg1 = 0, uint32_t arg2 = 0); + + // Gets argument for an execution mode (LocalSize, Invocations, OutputVertices). + // For LocalSize, the index argument is used to select the dimension (X = 0, Y = 1, Z = 2). + // For execution modes which do not have arguments, 0 is returned. + uint32_t get_execution_mode_argument(spv::ExecutionMode mode, uint32_t index = 0) const; + spv::ExecutionModel get_execution_model() const; + + // In SPIR-V, the compute work group size can be represented by a constant vector, in which case + // the LocalSize execution mode is ignored. + // + // This constant vector can be a constant vector, specialization constant vector, or partly specialized constant vector. + // To modify and query work group dimensions which are specialization constants, SPIRConstant values must be modified + // directly via get_constant() rather than using LocalSize directly. This function will return which constants should be modified. + // + // To modify dimensions which are *not* specialization constants, set_execution_mode should be used directly. + // Arguments to set_execution_mode which are specialization constants are effectively ignored during compilation. + // NOTE: This is somewhat different from how SPIR-V works. In SPIR-V, the constant vector will completely replace LocalSize, + // while in this interface, LocalSize is only ignored for specialization constants. + // + // The specialization constant will be written to x, y and z arguments. + // If the component is not a specialization constant, a zeroed out struct will be written. + // The return value is the constant ID of the builtin WorkGroupSize, but this is not expected to be useful + // for most use cases. + uint32_t get_work_group_size_specialization_constants(SpecializationConstant &x, SpecializationConstant &y, + SpecializationConstant &z) const; + + // Analyzes all separate image and samplers used from the currently selected entry point, + // and re-routes them all to a combined image sampler instead. + // This is required to "support" separate image samplers in targets which do not natively support + // this feature, like GLSL/ESSL. + // + // This must be called before compile() if such remapping is desired. + // This call will add new sampled images to the SPIR-V, + // so it will appear in reflection if get_shader_resources() is called after build_combined_image_samplers. + // + // If any image/sampler remapping was found, no separate image/samplers will appear in the decompiled output, + // but will still appear in reflection. + // + // The resulting samplers will be void of any decorations like name, descriptor sets and binding points, + // so this can be added before compile() if desired. + // + // Combined image samplers originating from this set are always considered active variables. + void build_combined_image_samplers(); + + // Gets a remapping for the combined image samplers. + const std::vector &get_combined_image_samplers() const + { + return combined_image_samplers; + } + + // Set a new variable type remap callback. + // The type remapping is designed to allow global interface variable to assume more special types. + // A typical example here is to remap sampler2D into samplerExternalOES, which currently isn't supported + // directly by SPIR-V. + // + // In compile() while emitting code, + // for every variable that is declared, including function parameters, the callback will be called + // and the API user has a chance to change the textual representation of the type used to declare the variable. + // The API user can detect special patterns in names to guide the remapping. + void set_variable_type_remap_callback(VariableTypeRemapCallback cb) + { + variable_remap_callback = std::move(cb); + } + + // API for querying which specialization constants exist. + // To modify a specialization constant before compile(), use get_constant(constant.id), + // then update constants directly in the SPIRConstant data structure. + // For composite types, the subconstants can be iterated over and modified. + // constant_type is the SPIRType for the specialization constant, + // which can be queried to determine which fields in the unions should be poked at. + std::vector get_specialization_constants() const; + SPIRConstant &get_constant(uint32_t id); + const SPIRConstant &get_constant(uint32_t id) const; + + uint32_t get_current_id_bound() const + { + return uint32_t(ids.size()); + } + + // API for querying buffer objects. + // The type passed in here should be the base type of a resource, i.e. + // get_type(resource.base_type_id) + // as decorations are set in the basic Block type. + // The type passed in here must have these decorations set, or an exception is raised. + // Only UBOs and SSBOs or sub-structs which are part of these buffer types will have these decorations set. + uint32_t type_struct_member_offset(const SPIRType &type, uint32_t index) const; + uint32_t type_struct_member_array_stride(const SPIRType &type, uint32_t index) const; + uint32_t type_struct_member_matrix_stride(const SPIRType &type, uint32_t index) const; + + // Gets the offset in SPIR-V words (uint32_t) for a decoration which was originally declared in the SPIR-V binary. + // The offset will point to one or more uint32_t literals which can be modified in-place before using the SPIR-V binary. + // Note that adding or removing decorations using the reflection API will not change the behavior of this function. + // If the decoration was declared, sets the word_offset to an offset into the provided SPIR-V binary buffer and returns true, + // otherwise, returns false. + // If the decoration does not have any value attached to it (e.g. DecorationRelaxedPrecision), this function will also return false. + bool get_binary_offset_for_decoration(uint32_t id, spv::Decoration decoration, uint32_t &word_offset) const; + + // HLSL counter buffer reflection interface. + // Append/Consume/Increment/Decrement in HLSL is implemented as two "neighbor" buffer objects where + // one buffer implements the storage, and a single buffer containing just a lone "int" implements the counter. + // To SPIR-V these will be exposed as two separate buffers, but glslang HLSL frontend emits a special indentifier + // which lets us link the two buffers together. + + // Queries if a variable ID is a counter buffer which "belongs" to a regular buffer object. + // NOTE: This query is purely based on OpName identifiers as found in the SPIR-V module, and will + // only return true if OpSource was reported HLSL. + // To rely on this functionality, ensure that the SPIR-V module is not stripped. + bool buffer_is_hlsl_counter_buffer(uint32_t id) const; + + // Queries if a buffer object has a neighbor "counter" buffer. + // If so, the ID of that counter buffer will be returned in counter_id. + // NOTE: This query is purely based on OpName identifiers as found in the SPIR-V module, and will + // only return true if OpSource was reported HLSL. + // To rely on this functionality, ensure that the SPIR-V module is not stripped. + bool buffer_get_hlsl_counter_buffer(uint32_t id, uint32_t &counter_id) const; + + // Gets the list of all SPIR-V Capabilities which were declared in the SPIR-V module. + const std::vector &get_declared_capabilities() const; + + // Gets the list of all SPIR-V extensions which were declared in the SPIR-V module. + const std::vector &get_declared_extensions() const; + + // When declaring buffer blocks in GLSL, the name declared in the GLSL source + // might not be the same as the name declared in the SPIR-V module due to naming conflicts. + // In this case, SPIRV-Cross needs to find a fallback-name, and it might only + // be possible to know this name after compiling to GLSL. + // This is particularly important for HLSL input and UAVs which tends to reuse the same block type + // for multiple distinct blocks. For these cases it is not possible to modify the name of the type itself + // because it might be unique. Instead, you can use this interface to check after compilation which + // name was actually used if your input SPIR-V tends to have this problem. + // For other names like remapped names for variables, etc, it's generally enough to query the name of the variables + // after compiling, block names are an exception to this rule. + // ID is the name of a variable as returned by Resource::id, and must be a variable with a Block-like type. + std::string get_remapped_declared_block_name(uint32_t id) const; + +protected: + const uint32_t *stream(const Instruction &instr) const + { + // If we're not going to use any arguments, just return nullptr. + // We want to avoid case where we return an out of range pointer + // that trips debug assertions on some platforms. + if (!instr.length) + return nullptr; + + if (instr.offset + instr.length > spirv.size()) + SPIRV_CROSS_THROW("Compiler::stream() out of range."); + return &spirv[instr.offset]; + } + std::vector spirv; + + std::vector inst; + std::vector ids; + std::vector meta; + + SPIRFunction *current_function = nullptr; + SPIRBlock *current_block = nullptr; + std::vector global_variables; + std::vector aliased_variables; + std::unordered_set active_interface_variables; + bool check_active_interface_variables = false; + + // If our IDs are out of range here as part of opcodes, throw instead of + // undefined behavior. + template + T &set(uint32_t id, P &&... args) + { + auto &var = variant_set(ids.at(id), std::forward

(args)...); + var.self = id; + return var; + } + + template + T &get(uint32_t id) + { + return variant_get(ids.at(id)); + } + + template + T *maybe_get(uint32_t id) + { + if (ids.at(id).get_type() == T::type) + return &get(id); + else + return nullptr; + } + + template + const T &get(uint32_t id) const + { + return variant_get(ids.at(id)); + } + + template + const T *maybe_get(uint32_t id) const + { + if (ids.at(id).get_type() == T::type) + return &get(id); + else + return nullptr; + } + + uint32_t entry_point = 0; + // Normally, we'd stick SPIREntryPoint in ids array, but it conflicts with SPIRFunction. + // Entry points can therefore be seen as some sort of meta structure. + std::unordered_map entry_points; + const SPIREntryPoint &get_entry_point() const; + SPIREntryPoint &get_entry_point(); + + struct Source + { + uint32_t version = 0; + bool es = false; + bool known = false; + bool hlsl = false; + + Source() = default; + } source; + + std::unordered_set loop_blocks; + std::unordered_set continue_blocks; + std::unordered_set loop_merge_targets; + std::unordered_set selection_merge_targets; + std::unordered_set multiselect_merge_targets; + std::unordered_map continue_block_to_loop_header; + + virtual std::string to_name(uint32_t id, bool allow_alias = true) const; + bool is_builtin_variable(const SPIRVariable &var) const; + bool is_hidden_variable(const SPIRVariable &var, bool include_builtins = false) const; + bool is_immutable(uint32_t id) const; + bool is_member_builtin(const SPIRType &type, uint32_t index, spv::BuiltIn *builtin) const; + bool is_scalar(const SPIRType &type) const; + bool is_vector(const SPIRType &type) const; + bool is_matrix(const SPIRType &type) const; + bool is_array(const SPIRType &type) const; + uint32_t expression_type_id(uint32_t id) const; + const SPIRType &expression_type(uint32_t id) const; + bool expression_is_lvalue(uint32_t id) const; + bool variable_storage_is_aliased(const SPIRVariable &var); + SPIRVariable *maybe_get_backing_variable(uint32_t chain); + void mark_used_as_array_length(uint32_t id); + + void register_read(uint32_t expr, uint32_t chain, bool forwarded); + void register_write(uint32_t chain); + + inline bool is_continue(uint32_t next) const + { + return continue_blocks.find(next) != end(continue_blocks); + } + + inline bool is_break(uint32_t next) const + { + return loop_merge_targets.find(next) != end(loop_merge_targets) || + multiselect_merge_targets.find(next) != end(multiselect_merge_targets); + } + + inline bool is_conditional(uint32_t next) const + { + return selection_merge_targets.find(next) != end(selection_merge_targets) && + multiselect_merge_targets.find(next) == end(multiselect_merge_targets); + } + + // Dependency tracking for temporaries read from variables. + void flush_dependees(SPIRVariable &var); + void flush_all_active_variables(); + void flush_all_atomic_capable_variables(); + void flush_all_aliased_variables(); + void register_global_read_dependencies(const SPIRBlock &func, uint32_t id); + void register_global_read_dependencies(const SPIRFunction &func, uint32_t id); + std::unordered_set invalid_expressions; + + void update_name_cache(std::unordered_set &cache, std::string &name); + + bool function_is_pure(const SPIRFunction &func); + bool block_is_pure(const SPIRBlock &block); + bool block_is_outside_flow_control_from_block(const SPIRBlock &from, const SPIRBlock &to); + + bool execution_is_branchless(const SPIRBlock &from, const SPIRBlock &to) const; + bool execution_is_noop(const SPIRBlock &from, const SPIRBlock &to) const; + SPIRBlock::ContinueBlockType continue_block_type(const SPIRBlock &continue_block) const; + + bool force_recompile = false; + + bool block_is_loop_candidate(const SPIRBlock &block, SPIRBlock::Method method) const; + + uint32_t increase_bound_by(uint32_t incr_amount); + + bool types_are_logically_equivalent(const SPIRType &a, const SPIRType &b) const; + void inherit_expression_dependencies(uint32_t dst, uint32_t source); + + // For proper multiple entry point support, allow querying if an Input or Output + // variable is part of that entry points interface. + bool interface_variable_exists_in_entry_point(uint32_t id) const; + + std::vector combined_image_samplers; + + void remap_variable_type_name(const SPIRType &type, const std::string &var_name, std::string &type_name) const + { + if (variable_remap_callback) + variable_remap_callback(type, var_name, type_name); + } + + void analyze_variable_scope(SPIRFunction &function); + + void parse(); + void parse(const Instruction &i); + + // Used internally to implement various traversals for queries. + struct OpcodeHandler + { + virtual ~OpcodeHandler() = default; + + // Return true if traversal should continue. + // If false, traversal will end immediately. + virtual bool handle(spv::Op opcode, const uint32_t *args, uint32_t length) = 0; + + virtual bool follow_function_call(const SPIRFunction &) + { + return true; + } + + virtual void set_current_block(const SPIRBlock &) + { + } + + virtual bool begin_function_scope(const uint32_t *, uint32_t) + { + return true; + } + + virtual bool end_function_scope(const uint32_t *, uint32_t) + { + return true; + } + }; + + struct BufferAccessHandler : OpcodeHandler + { + BufferAccessHandler(const Compiler &compiler_, std::vector &ranges_, uint32_t id_) + : compiler(compiler_) + , ranges(ranges_) + , id(id_) + { + } + + bool handle(spv::Op opcode, const uint32_t *args, uint32_t length) override; + + const Compiler &compiler; + std::vector &ranges; + uint32_t id; + + std::unordered_set seen; + }; + + struct InterfaceVariableAccessHandler : OpcodeHandler + { + InterfaceVariableAccessHandler(const Compiler &compiler_, std::unordered_set &variables_) + : compiler(compiler_) + , variables(variables_) + { + } + + bool handle(spv::Op opcode, const uint32_t *args, uint32_t length) override; + + const Compiler &compiler; + std::unordered_set &variables; + }; + + struct CombinedImageSamplerHandler : OpcodeHandler + { + CombinedImageSamplerHandler(Compiler &compiler_) + : compiler(compiler_) + { + } + bool handle(spv::Op opcode, const uint32_t *args, uint32_t length) override; + bool begin_function_scope(const uint32_t *args, uint32_t length) override; + bool end_function_scope(const uint32_t *args, uint32_t length) override; + + Compiler &compiler; + + // Each function in the call stack needs its own remapping for parameters so we can deduce which global variable each texture/sampler the parameter is statically bound to. + std::stack> parameter_remapping; + std::stack functions; + + uint32_t remap_parameter(uint32_t id); + void push_remap_parameters(const SPIRFunction &func, const uint32_t *args, uint32_t length); + void pop_remap_parameters(); + void register_combined_image_sampler(SPIRFunction &caller, uint32_t texture_id, uint32_t sampler_id, + bool depth); + }; + + struct ActiveBuiltinHandler : OpcodeHandler + { + ActiveBuiltinHandler(Compiler &compiler_) + : compiler(compiler_) + { + } + + bool handle(spv::Op opcode, const uint32_t *args, uint32_t length) override; + Compiler &compiler; + }; + + bool traverse_all_reachable_opcodes(const SPIRBlock &block, OpcodeHandler &handler) const; + bool traverse_all_reachable_opcodes(const SPIRFunction &block, OpcodeHandler &handler) const; + // This must be an ordered data structure so we always pick the same type aliases. + std::vector global_struct_cache; + + ShaderResources get_shader_resources(const std::unordered_set *active_variables) const; + + VariableTypeRemapCallback variable_remap_callback; + + uint64_t get_buffer_block_flags(const SPIRVariable &var); + bool get_common_basic_type(const SPIRType &type, SPIRType::BaseType &base_type); + + std::unordered_set forced_temporaries; + std::unordered_set forwarded_temporaries; + std::unordered_set hoisted_temporaries; + + uint64_t active_input_builtins = 0; + uint64_t active_output_builtins = 0; + // Traverses all reachable opcodes and sets active_builtins to a bitmask of all builtin variables which are accessed in the shader. + void update_active_builtins(); + bool has_active_builtin(spv::BuiltIn builtin, spv::StorageClass storage); + + void analyze_parameter_preservation( + SPIRFunction &entry, const CFG &cfg, + const std::unordered_map> &variable_to_blocks, + const std::unordered_map> &complete_write_blocks); + + // If a variable ID or parameter ID is found in this set, a sampler is actually a shadow/comparison sampler. + // SPIR-V does not support this distinction, so we must keep track of this information outside the type system. + // There might be unrelated IDs found in this set which do not correspond to actual variables. + // This set should only be queried for the existence of samplers which are already known to be variables or parameter IDs. + std::unordered_set comparison_samplers; + void analyze_sampler_comparison_states(); + struct CombinedImageSamplerUsageHandler : OpcodeHandler + { + CombinedImageSamplerUsageHandler(Compiler &compiler_) + : compiler(compiler_) + { + } + + bool begin_function_scope(const uint32_t *args, uint32_t length) override; + bool handle(spv::Op opcode, const uint32_t *args, uint32_t length) override; + Compiler &compiler; + + std::unordered_map> dependency_hierarchy; + std::unordered_set comparison_samplers; + + void add_hierarchy_to_comparison_samplers(uint32_t sampler); + }; + + void make_constant_null(uint32_t id, uint32_t type); + + std::vector declared_capabilities; + std::vector declared_extensions; + std::unordered_map declared_block_names; + + bool instruction_to_result_type(uint32_t &result_type, uint32_t &result_id, spv::Op op, const uint32_t *args, + uint32_t length); +}; +} + +#endif diff --git a/spirv_glsl.cpp b/spirv_glsl.cpp new file mode 100644 index 0000000000..926e8f2842 --- /dev/null +++ b/spirv_glsl.cpp @@ -0,0 +1,8574 @@ +/* + * Copyright 2015-2018 ARM Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "spirv_glsl.hpp" +#include "GLSL.std.450.h" +#include "spirv_common.hpp" +#include +#include +#include + +using namespace spv; +using namespace spirv_cross; +using namespace std; + +static bool packing_is_vec4_padded(BufferPackingStandard packing) +{ + switch (packing) + { + case BufferPackingHLSLCbuffer: + case BufferPackingHLSLCbufferPackOffset: + case BufferPackingStd140: + case BufferPackingStd140EnhancedLayout: + return true; + + default: + return false; + } +} + +static bool packing_is_hlsl(BufferPackingStandard packing) +{ + switch (packing) + { + case BufferPackingHLSLCbuffer: + case BufferPackingHLSLCbufferPackOffset: + return true; + + default: + return false; + } +} + +static bool packing_has_flexible_offset(BufferPackingStandard packing) +{ + switch (packing) + { + case BufferPackingStd140: + case BufferPackingStd430: + case BufferPackingHLSLCbuffer: + return false; + + default: + return true; + } +} + +static BufferPackingStandard packing_to_substruct_packing(BufferPackingStandard packing) +{ + switch (packing) + { + case BufferPackingStd140EnhancedLayout: + return BufferPackingStd140; + case BufferPackingStd430EnhancedLayout: + return BufferPackingStd430; + case BufferPackingHLSLCbufferPackOffset: + return BufferPackingHLSLCbuffer; + default: + return packing; + } +} + +// Sanitizes underscores for GLSL where multiple underscores in a row are not allowed. +string CompilerGLSL::sanitize_underscores(const string &str) +{ + string res; + res.reserve(str.size()); + + bool last_underscore = false; + for (auto c : str) + { + if (c == '_') + { + if (last_underscore) + continue; + + res += c; + last_underscore = true; + } + else + { + res += c; + last_underscore = false; + } + } + return res; +} + +// Returns true if an arithmetic operation does not change behavior depending on signedness. +static bool opcode_is_sign_invariant(Op opcode) +{ + switch (opcode) + { + case OpIEqual: + case OpINotEqual: + case OpISub: + case OpIAdd: + case OpIMul: + case OpShiftLeftLogical: + case OpBitwiseOr: + case OpBitwiseXor: + case OpBitwiseAnd: + return true; + + default: + return false; + } +} + +static const char *to_pls_layout(PlsFormat format) +{ + switch (format) + { + case PlsR11FG11FB10F: + return "layout(r11f_g11f_b10f) "; + case PlsR32F: + return "layout(r32f) "; + case PlsRG16F: + return "layout(rg16f) "; + case PlsRGB10A2: + return "layout(rgb10_a2) "; + case PlsRGBA8: + return "layout(rgba8) "; + case PlsRG16: + return "layout(rg16) "; + case PlsRGBA8I: + return "layout(rgba8i)"; + case PlsRG16I: + return "layout(rg16i) "; + case PlsRGB10A2UI: + return "layout(rgb10_a2ui) "; + case PlsRGBA8UI: + return "layout(rgba8ui) "; + case PlsRG16UI: + return "layout(rg16ui) "; + case PlsR32UI: + return "layout(r32ui) "; + default: + return ""; + } +} + +static SPIRType::BaseType pls_format_to_basetype(PlsFormat format) +{ + switch (format) + { + default: + case PlsR11FG11FB10F: + case PlsR32F: + case PlsRG16F: + case PlsRGB10A2: + case PlsRGBA8: + case PlsRG16: + return SPIRType::Float; + + case PlsRGBA8I: + case PlsRG16I: + return SPIRType::Int; + + case PlsRGB10A2UI: + case PlsRGBA8UI: + case PlsRG16UI: + case PlsR32UI: + return SPIRType::UInt; + } +} + +static uint32_t pls_format_to_components(PlsFormat format) +{ + switch (format) + { + default: + case PlsR32F: + case PlsR32UI: + return 1; + + case PlsRG16F: + case PlsRG16: + case PlsRG16UI: + case PlsRG16I: + return 2; + + case PlsR11FG11FB10F: + return 3; + + case PlsRGB10A2: + case PlsRGBA8: + case PlsRGBA8I: + case PlsRGB10A2UI: + case PlsRGBA8UI: + return 4; + } +} + +static const char *vector_swizzle(int vecsize, int index) +{ + static const char *swizzle[4][4] = { + { ".x", ".y", ".z", ".w" }, { ".xy", ".yz", ".zw" }, { ".xyz", ".yzw" }, { "" } + }; + + assert(vecsize >= 1 && vecsize <= 4); + assert(index >= 0 && index < 4); + assert(swizzle[vecsize - 1][index]); + + return swizzle[vecsize - 1][index]; +} + +void CompilerGLSL::reset() +{ + // We do some speculative optimizations which should pretty much always work out, + // but just in case the SPIR-V is rather weird, recompile until it's happy. + // This typically only means one extra pass. + force_recompile = false; + + // Clear invalid expression tracking. + invalid_expressions.clear(); + current_function = nullptr; + + // Clear temporary usage tracking. + expression_usage_counts.clear(); + forwarded_temporaries.clear(); + + resource_names.clear(); + + for (auto &id : ids) + { + if (id.get_type() == TypeVariable) + { + // Clear unflushed dependees. + id.get().dependees.clear(); + } + else if (id.get_type() == TypeExpression) + { + // And remove all expressions. + id.reset(); + } + else if (id.get_type() == TypeFunction) + { + // Reset active state for all functions. + id.get().active = false; + id.get().flush_undeclared = true; + } + } + + statement_count = 0; + indent = 0; +} + +void CompilerGLSL::remap_pls_variables() +{ + for (auto &input : pls_inputs) + { + auto &var = get(input.id); + + bool input_is_target = false; + if (var.storage == StorageClassUniformConstant) + { + auto &type = get(var.basetype); + input_is_target = type.image.dim == DimSubpassData; + } + + if (var.storage != StorageClassInput && !input_is_target) + SPIRV_CROSS_THROW("Can only use in and target variables for PLS inputs."); + var.remapped_variable = true; + } + + for (auto &output : pls_outputs) + { + auto &var = get(output.id); + if (var.storage != StorageClassOutput) + SPIRV_CROSS_THROW("Can only use out variables for PLS outputs."); + var.remapped_variable = true; + } +} + +void CompilerGLSL::find_static_extensions() +{ + for (auto &id : ids) + { + if (id.get_type() == TypeType) + { + auto &type = id.get(); + if (type.basetype == SPIRType::Double) + { + if (options.es) + SPIRV_CROSS_THROW("FP64 not supported in ES profile."); + if (!options.es && options.version < 400) + require_extension("GL_ARB_gpu_shader_fp64"); + } + + if (type.basetype == SPIRType::Int64 || type.basetype == SPIRType::UInt64) + { + if (options.es) + SPIRV_CROSS_THROW("64-bit integers not supported in ES profile."); + if (!options.es) + require_extension("GL_ARB_gpu_shader_int64"); + } + } + } + + auto &execution = get_entry_point(); + switch (execution.model) + { + case ExecutionModelGLCompute: + if (!options.es && options.version < 430) + require_extension("GL_ARB_compute_shader"); + if (options.es && options.version < 310) + SPIRV_CROSS_THROW("At least ESSL 3.10 required for compute shaders."); + break; + + case ExecutionModelGeometry: + if (options.es && options.version < 320) + require_extension("GL_EXT_geometry_shader"); + if (!options.es && options.version < 150) + require_extension("GL_ARB_geometry_shader4"); + + if ((execution.flags & (1ull << ExecutionModeInvocations)) && execution.invocations != 1) + { + // Instanced GS is part of 400 core or this extension. + if (!options.es && options.version < 400) + require_extension("GL_ARB_gpu_shader5"); + } + break; + + case ExecutionModelTessellationEvaluation: + case ExecutionModelTessellationControl: + if (options.es && options.version < 320) + require_extension("GL_EXT_tessellation_shader"); + if (!options.es && options.version < 400) + require_extension("GL_ARB_tessellation_shader"); + break; + + default: + break; + } + + if (!pls_inputs.empty() || !pls_outputs.empty()) + require_extension("GL_EXT_shader_pixel_local_storage"); + + if (options.separate_shader_objects && !options.es && options.version < 410) + require_extension("GL_ARB_separate_shader_objects"); +} + +string CompilerGLSL::compile() +{ + // Force a classic "C" locale, reverts when function returns + ClassicLocale classic_locale; + + if (options.vulkan_semantics) + backend.allow_precision_qualifiers = true; + backend.force_gl_in_out_block = true; + + // Scan the SPIR-V to find trivial uses of extensions. + find_static_extensions(); + fixup_image_load_store_access(); + update_active_builtins(); + analyze_sampler_comparison_states(); + + uint32_t pass_count = 0; + do + { + if (pass_count >= 3) + SPIRV_CROSS_THROW("Over 3 compilation loops detected. Must be a bug!"); + + reset(); + + // Move constructor for this type is broken on GCC 4.9 ... + buffer = unique_ptr(new ostringstream()); + + emit_header(); + emit_resources(); + + emit_function(get(entry_point), 0); + + pass_count++; + } while (force_recompile); + + // Entry point in GLSL is always main(). + get_entry_point().name = "main"; + + return buffer->str(); +} + +std::string CompilerGLSL::get_partial_source() +{ + return buffer ? buffer->str() : "No compiled source available yet."; +} + +void CompilerGLSL::emit_header() +{ + auto &execution = get_entry_point(); + statement("#version ", options.version, options.es && options.version > 100 ? " es" : ""); + + if (!options.es && options.version < 420) + { + // Needed for binding = # on UBOs, etc. + if (options.enable_420pack_extension) + { + statement("#ifdef GL_ARB_shading_language_420pack"); + statement("#extension GL_ARB_shading_language_420pack : require"); + statement("#endif"); + } + // Needed for: layout(early_fragment_tests) in; + if (execution.flags & (1ull << ExecutionModeEarlyFragmentTests)) + require_extension("GL_ARB_shader_image_load_store"); + } + + for (auto &ext : forced_extensions) + statement("#extension ", ext, " : require"); + + for (auto &header : header_lines) + statement(header); + + vector inputs; + vector outputs; + + switch (execution.model) + { + case ExecutionModelGeometry: + outputs.push_back(join("max_vertices = ", execution.output_vertices)); + if ((execution.flags & (1ull << ExecutionModeInvocations)) && execution.invocations != 1) + inputs.push_back(join("invocations = ", execution.invocations)); + if (execution.flags & (1ull << ExecutionModeInputPoints)) + inputs.push_back("points"); + if (execution.flags & (1ull << ExecutionModeInputLines)) + inputs.push_back("lines"); + if (execution.flags & (1ull << ExecutionModeInputLinesAdjacency)) + inputs.push_back("lines_adjacency"); + if (execution.flags & (1ull << ExecutionModeTriangles)) + inputs.push_back("triangles"); + if (execution.flags & (1ull << ExecutionModeInputTrianglesAdjacency)) + inputs.push_back("triangles_adjacency"); + if (execution.flags & (1ull << ExecutionModeOutputTriangleStrip)) + outputs.push_back("triangle_strip"); + if (execution.flags & (1ull << ExecutionModeOutputPoints)) + outputs.push_back("points"); + if (execution.flags & (1ull << ExecutionModeOutputLineStrip)) + outputs.push_back("line_strip"); + break; + + case ExecutionModelTessellationControl: + if (execution.flags & (1ull << ExecutionModeOutputVertices)) + outputs.push_back(join("vertices = ", execution.output_vertices)); + break; + + case ExecutionModelTessellationEvaluation: + if (execution.flags & (1ull << ExecutionModeQuads)) + inputs.push_back("quads"); + if (execution.flags & (1ull << ExecutionModeTriangles)) + inputs.push_back("triangles"); + if (execution.flags & (1ull << ExecutionModeIsolines)) + inputs.push_back("isolines"); + if (execution.flags & (1ull << ExecutionModePointMode)) + inputs.push_back("point_mode"); + + if ((execution.flags & (1ull << ExecutionModeIsolines)) == 0) + { + if (execution.flags & (1ull << ExecutionModeVertexOrderCw)) + inputs.push_back("cw"); + if (execution.flags & (1ull << ExecutionModeVertexOrderCcw)) + inputs.push_back("ccw"); + } + + if (execution.flags & (1ull << ExecutionModeSpacingFractionalEven)) + inputs.push_back("fractional_even_spacing"); + if (execution.flags & (1ull << ExecutionModeSpacingFractionalOdd)) + inputs.push_back("fractional_odd_spacing"); + if (execution.flags & (1ull << ExecutionModeSpacingEqual)) + inputs.push_back("equal_spacing"); + break; + + case ExecutionModelGLCompute: + { + if (execution.workgroup_size.constant != 0) + { + SpecializationConstant wg_x, wg_y, wg_z; + get_work_group_size_specialization_constants(wg_x, wg_y, wg_z); + + if (wg_x.id) + { + if (options.vulkan_semantics) + inputs.push_back(join("local_size_x_id = ", wg_x.constant_id)); + else + inputs.push_back(join("local_size_x = ", get(wg_x.id).scalar())); + } + else + inputs.push_back(join("local_size_x = ", execution.workgroup_size.x)); + + if (wg_y.id) + { + if (options.vulkan_semantics) + inputs.push_back(join("local_size_y_id = ", wg_y.constant_id)); + else + inputs.push_back(join("local_size_y = ", get(wg_y.id).scalar())); + } + else + inputs.push_back(join("local_size_y = ", execution.workgroup_size.y)); + + if (wg_z.id) + { + if (options.vulkan_semantics) + inputs.push_back(join("local_size_z_id = ", wg_z.constant_id)); + else + inputs.push_back(join("local_size_z = ", get(wg_z.id).scalar())); + } + else + inputs.push_back(join("local_size_z = ", execution.workgroup_size.z)); + } + else + { + inputs.push_back(join("local_size_x = ", execution.workgroup_size.x)); + inputs.push_back(join("local_size_y = ", execution.workgroup_size.y)); + inputs.push_back(join("local_size_z = ", execution.workgroup_size.z)); + } + break; + } + + case ExecutionModelFragment: + if (options.es) + { + switch (options.fragment.default_float_precision) + { + case Options::Lowp: + statement("precision lowp float;"); + break; + + case Options::Mediump: + statement("precision mediump float;"); + break; + + case Options::Highp: + statement("precision highp float;"); + break; + + default: + break; + } + + switch (options.fragment.default_int_precision) + { + case Options::Lowp: + statement("precision lowp int;"); + break; + + case Options::Mediump: + statement("precision mediump int;"); + break; + + case Options::Highp: + statement("precision highp int;"); + break; + + default: + break; + } + } + + if (execution.flags & (1ull << ExecutionModeEarlyFragmentTests)) + inputs.push_back("early_fragment_tests"); + if (execution.flags & (1ull << ExecutionModeDepthGreater)) + inputs.push_back("depth_greater"); + if (execution.flags & (1ull << ExecutionModeDepthLess)) + inputs.push_back("depth_less"); + + break; + + default: + break; + } + + if (!inputs.empty()) + statement("layout(", merge(inputs), ") in;"); + if (!outputs.empty()) + statement("layout(", merge(outputs), ") out;"); + + statement(""); +} + +bool CompilerGLSL::type_is_empty(const SPIRType &type) +{ + return type.basetype == SPIRType::Struct && type.member_types.empty(); +} + +void CompilerGLSL::emit_struct(SPIRType &type) +{ + // Struct types can be stamped out multiple times + // with just different offsets, matrix layouts, etc ... + // Type-punning with these types is legal, which complicates things + // when we are storing struct and array types in an SSBO for example. + if (type.type_alias != 0) + return; + + // Don't declare empty structs in GLSL, this is not allowed. + // Empty structs is a corner case of HLSL output, and only sensible thing to do is avoiding to declare + // these types. + if (type_is_empty(type)) + return; + + add_resource_name(type.self); + auto name = type_to_glsl(type); + + statement(!backend.explicit_struct_type ? "struct " : "", name); + begin_scope(); + + type.member_name_cache.clear(); + + uint32_t i = 0; + bool emitted = false; + for (auto &member : type.member_types) + { + add_member_name(type, i); + emit_struct_member(type, member, i); + i++; + emitted = true; + } + end_scope_decl(); + + if (emitted) + statement(""); +} + +uint64_t CompilerGLSL::combined_decoration_for_member(const SPIRType &type, uint32_t index) +{ + uint64_t flags = 0; + auto &memb = meta[type.self].members; + if (index >= memb.size()) + return 0; + auto &dec = memb[index]; + + // If our type is a struct, traverse all the members as well recursively. + flags |= dec.decoration_flags; + for (uint32_t i = 0; i < type.member_types.size(); i++) + flags |= combined_decoration_for_member(get(type.member_types[i]), i); + + return flags; +} + +string CompilerGLSL::to_interpolation_qualifiers(uint64_t flags) +{ + string res; + //if (flags & (1ull << DecorationSmooth)) + // res += "smooth "; + if (flags & (1ull << DecorationFlat)) + res += "flat "; + if (flags & (1ull << DecorationNoPerspective)) + res += "noperspective "; + if (flags & (1ull << DecorationCentroid)) + res += "centroid "; + if (flags & (1ull << DecorationPatch)) + res += "patch "; + if (flags & (1ull << DecorationSample)) + res += "sample "; + if (flags & (1ull << DecorationInvariant)) + res += "invariant "; + + return res; +} + +string CompilerGLSL::layout_for_member(const SPIRType &type, uint32_t index) +{ + if (is_legacy()) + return ""; + + bool is_block = (meta[type.self].decoration.decoration_flags & + ((1ull << DecorationBlock) | (1ull << DecorationBufferBlock))) != 0; + if (!is_block) + return ""; + + auto &memb = meta[type.self].members; + if (index >= memb.size()) + return ""; + auto &dec = memb[index]; + + vector attr; + + // We can only apply layouts on members in block interfaces. + // This is a bit problematic because in SPIR-V decorations are applied on the struct types directly. + // This is not supported on GLSL, so we have to make the assumption that if a struct within our buffer block struct + // has a decoration, it was originally caused by a top-level layout() qualifier in GLSL. + // + // We would like to go from (SPIR-V style): + // + // struct Foo { layout(row_major) mat4 matrix; }; + // buffer UBO { Foo foo; }; + // + // to + // + // struct Foo { mat4 matrix; }; // GLSL doesn't support any layout shenanigans in raw struct declarations. + // buffer UBO { layout(row_major) Foo foo; }; // Apply the layout on top-level. + auto flags = combined_decoration_for_member(type, index); + + if (flags & (1ull << DecorationRowMajor)) + attr.push_back("row_major"); + // We don't emit any global layouts, so column_major is default. + //if (flags & (1ull << DecorationColMajor)) + // attr.push_back("column_major"); + + if ((dec.decoration_flags & (1ull << DecorationLocation)) != 0 && can_use_io_location(type.storage)) + attr.push_back(join("location = ", dec.location)); + + // DecorationCPacked is set by layout_for_variable earlier to mark that we need to emit offset qualifiers. + // This is only done selectively in GLSL as needed. + if (has_decoration(type.self, DecorationCPacked) && (dec.decoration_flags & (1ull << DecorationOffset)) != 0) + attr.push_back(join("offset = ", dec.offset)); + + if (attr.empty()) + return ""; + + string res = "layout("; + res += merge(attr); + res += ") "; + return res; +} + +const char *CompilerGLSL::format_to_glsl(spv::ImageFormat format) +{ + auto check_desktop = [this] { + if (options.es) + SPIRV_CROSS_THROW("Attempting to use image format not supported in ES profile."); + }; + + switch (format) + { + case ImageFormatRgba32f: + return "rgba32f"; + case ImageFormatRgba16f: + return "rgba16f"; + case ImageFormatR32f: + return "r32f"; + case ImageFormatRgba8: + return "rgba8"; + case ImageFormatRgba8Snorm: + return "rgba8_snorm"; + case ImageFormatRg32f: + return "rg32f"; + case ImageFormatRg16f: + return "rg16f"; + + case ImageFormatRgba32i: + return "rgba32i"; + case ImageFormatRgba16i: + return "rgba16i"; + case ImageFormatR32i: + return "r32i"; + case ImageFormatRgba8i: + return "rgba8i"; + case ImageFormatRg32i: + return "rg32i"; + case ImageFormatRg16i: + return "rg16i"; + + case ImageFormatRgba32ui: + return "rgba32ui"; + case ImageFormatRgba16ui: + return "rgba16ui"; + case ImageFormatR32ui: + return "r32ui"; + case ImageFormatRgba8ui: + return "rgba8ui"; + case ImageFormatRg32ui: + return "rg32ui"; + case ImageFormatRg16ui: + return "rg16ui"; + + // Desktop-only formats + case ImageFormatR11fG11fB10f: + check_desktop(); + return "r11f_g11f_b10f"; + case ImageFormatR16f: + check_desktop(); + return "r16f"; + case ImageFormatRgb10A2: + check_desktop(); + return "rgb10_a2"; + case ImageFormatR8: + check_desktop(); + return "r8"; + case ImageFormatRg8: + check_desktop(); + return "rg8"; + case ImageFormatR16: + check_desktop(); + return "r16"; + case ImageFormatRg16: + check_desktop(); + return "rg16"; + case ImageFormatRgba16: + check_desktop(); + return "rgba16"; + case ImageFormatR16Snorm: + check_desktop(); + return "r16_snorm"; + case ImageFormatRg16Snorm: + check_desktop(); + return "rg16_snorm"; + case ImageFormatRgba16Snorm: + check_desktop(); + return "rgba16_snorm"; + case ImageFormatR8Snorm: + check_desktop(); + return "r8_snorm"; + case ImageFormatRg8Snorm: + check_desktop(); + return "rg8_snorm"; + + case ImageFormatR8ui: + check_desktop(); + return "r8ui"; + case ImageFormatRg8ui: + check_desktop(); + return "rg8ui"; + case ImageFormatR16ui: + check_desktop(); + return "r16ui"; + case ImageFormatRgb10a2ui: + check_desktop(); + return "rgb10_a2ui"; + + case ImageFormatR8i: + check_desktop(); + return "r8i"; + case ImageFormatRg8i: + check_desktop(); + return "rg8i"; + case ImageFormatR16i: + check_desktop(); + return "r16i"; + + default: + case ImageFormatUnknown: + return nullptr; + } +} + +uint32_t CompilerGLSL::type_to_packed_base_size(const SPIRType &type, BufferPackingStandard) +{ + switch (type.basetype) + { + case SPIRType::Double: + case SPIRType::Int64: + case SPIRType::UInt64: + return 8; + default: + return 4; + } +} + +uint32_t CompilerGLSL::type_to_packed_alignment(const SPIRType &type, uint64_t flags, BufferPackingStandard packing) +{ + const uint32_t base_alignment = type_to_packed_base_size(type, packing); + + if (!type.array.empty()) + { + uint32_t minimum_alignment = 1; + if (packing_is_vec4_padded(packing)) + minimum_alignment = 16; + + auto *tmp = &get(type.parent_type); + while (!tmp->array.empty()) + tmp = &get(tmp->parent_type); + + // Get the alignment of the base type, then maybe round up. + return max(minimum_alignment, type_to_packed_alignment(*tmp, flags, packing)); + } + + if (type.basetype == SPIRType::Struct) + { + // Rule 9. Structs alignments are maximum alignment of its members. + uint32_t alignment = 0; + for (uint32_t i = 0; i < type.member_types.size(); i++) + { + auto member_flags = meta[type.self].members.at(i).decoration_flags; + alignment = + max(alignment, type_to_packed_alignment(get(type.member_types[i]), member_flags, packing)); + } + + // In std140, struct alignment is rounded up to 16. + if (packing_is_vec4_padded(packing)) + alignment = max(alignment, 16u); + + return alignment; + } + else + { + // Vectors are *not* aligned in HLSL, but there's an extra rule where vectors cannot straddle + // a vec4, this is handled outside since that part knows our current offset. + if (type.columns == 1 && packing_is_hlsl(packing)) + return base_alignment; + + // From 7.6.2.2 in GL 4.5 core spec. + // Rule 1 + if (type.vecsize == 1 && type.columns == 1) + return base_alignment; + + // Rule 2 + if ((type.vecsize == 2 || type.vecsize == 4) && type.columns == 1) + return type.vecsize * base_alignment; + + // Rule 3 + if (type.vecsize == 3 && type.columns == 1) + return 4 * base_alignment; + + // Rule 4 implied. Alignment does not change in std430. + + // Rule 5. Column-major matrices are stored as arrays of + // vectors. + if ((flags & (1ull << DecorationColMajor)) && type.columns > 1) + { + if (packing_is_vec4_padded(packing)) + return 4 * base_alignment; + else if (type.vecsize == 3) + return 4 * base_alignment; + else + return type.vecsize * base_alignment; + } + + // Rule 6 implied. + + // Rule 7. + if ((flags & (1ull << DecorationRowMajor)) && type.vecsize > 1) + { + if (packing_is_vec4_padded(packing)) + return 4 * base_alignment; + else if (type.columns == 3) + return 4 * base_alignment; + else + return type.columns * base_alignment; + } + + // Rule 8 implied. + } + + SPIRV_CROSS_THROW("Did not find suitable rule for type. Bogus decorations?"); +} + +uint32_t CompilerGLSL::type_to_packed_array_stride(const SPIRType &type, uint64_t flags, BufferPackingStandard packing) +{ + // Array stride is equal to aligned size of the underlying type. + uint32_t parent = type.parent_type; + assert(parent); + + auto &tmp = get(parent); + + uint32_t size = type_to_packed_size(tmp, flags, packing); + if (tmp.array.empty()) + { + uint32_t alignment = type_to_packed_alignment(type, flags, packing); + return (size + alignment - 1) & ~(alignment - 1); + } + else + { + // For multidimensional arrays, array stride always matches size of subtype. + // The alignment cannot change because multidimensional arrays are basically N * M array elements. + return size; + } +} + +uint32_t CompilerGLSL::type_to_packed_size(const SPIRType &type, uint64_t flags, BufferPackingStandard packing) +{ + if (!type.array.empty()) + { + return to_array_size_literal(type, uint32_t(type.array.size()) - 1) * + type_to_packed_array_stride(type, flags, packing); + } + + const uint32_t base_alignment = type_to_packed_base_size(type, packing); + uint32_t size = 0; + + if (type.basetype == SPIRType::Struct) + { + uint32_t pad_alignment = 1; + + for (uint32_t i = 0; i < type.member_types.size(); i++) + { + auto member_flags = meta[type.self].members.at(i).decoration_flags; + auto &member_type = get(type.member_types[i]); + + uint32_t packed_alignment = type_to_packed_alignment(member_type, member_flags, packing); + uint32_t alignment = max(packed_alignment, pad_alignment); + + // The next member following a struct member is aligned to the base alignment of the struct that came before. + // GL 4.5 spec, 7.6.2.2. + if (member_type.basetype == SPIRType::Struct) + pad_alignment = packed_alignment; + else + pad_alignment = 1; + + size = (size + alignment - 1) & ~(alignment - 1); + size += type_to_packed_size(member_type, member_flags, packing); + } + } + else + { + if (type.columns == 1) + size = type.vecsize * base_alignment; + + if ((flags & (1ull << DecorationColMajor)) && type.columns > 1) + { + if (packing_is_vec4_padded(packing)) + size = type.columns * 4 * base_alignment; + else if (type.vecsize == 3) + size = type.columns * 4 * base_alignment; + else + size = type.columns * type.vecsize * base_alignment; + } + + if ((flags & (1ull << DecorationRowMajor)) && type.vecsize > 1) + { + if (packing_is_vec4_padded(packing)) + size = type.vecsize * 4 * base_alignment; + else if (type.columns == 3) + size = type.vecsize * 4 * base_alignment; + else + size = type.vecsize * type.columns * base_alignment; + } + } + + return size; +} + +bool CompilerGLSL::buffer_is_packing_standard(const SPIRType &type, BufferPackingStandard packing) +{ + // This is very tricky and error prone, but try to be exhaustive and correct here. + // SPIR-V doesn't directly say if we're using std430 or std140. + // SPIR-V communicates this using Offset and ArrayStride decorations (which is what really matters), + // so we have to try to infer whether or not the original GLSL source was std140 or std430 based on this information. + // We do not have to consider shared or packed since these layouts are not allowed in Vulkan SPIR-V (they are useless anyways, and custom offsets would do the same thing). + // + // It is almost certain that we're using std430, but it gets tricky with arrays in particular. + // We will assume std430, but infer std140 if we can prove the struct is not compliant with std430. + // + // The only two differences between std140 and std430 are related to padding alignment/array stride + // in arrays and structs. In std140 they take minimum vec4 alignment. + // std430 only removes the vec4 requirement. + + uint32_t offset = 0; + uint32_t pad_alignment = 1; + + for (uint32_t i = 0; i < type.member_types.size(); i++) + { + auto &memb_type = get(type.member_types[i]); + auto member_flags = meta[type.self].members.at(i).decoration_flags; + + // Verify alignment rules. + uint32_t packed_alignment = type_to_packed_alignment(memb_type, member_flags, packing); + uint32_t packed_size = type_to_packed_size(memb_type, member_flags, packing); + + if (packing_is_hlsl(packing)) + { + // If a member straddles across a vec4 boundary, alignment is actually vec4. + uint32_t begin_word = offset / 16; + uint32_t end_word = (offset + packed_size - 1) / 16; + if (begin_word != end_word) + packed_alignment = max(packed_alignment, 16u); + } + + uint32_t alignment = max(packed_alignment, pad_alignment); + offset = (offset + alignment - 1) & ~(alignment - 1); + + // The next member following a struct member is aligned to the base alignment of the struct that came before. + // GL 4.5 spec, 7.6.2.2. + if (memb_type.basetype == SPIRType::Struct) + pad_alignment = packed_alignment; + else + pad_alignment = 1; + + // We only care about offsets in std140, std430, etc ... + // For EnhancedLayout variants, we have the flexibility to choose our own offsets. + if (!packing_has_flexible_offset(packing)) + { + uint32_t actual_offset = type_struct_member_offset(type, i); + if (actual_offset != offset) // This cannot be the packing we're looking for. + return false; + } + + // Verify array stride rules. + if (!memb_type.array.empty() && + type_to_packed_array_stride(memb_type, member_flags, packing) != type_struct_member_array_stride(type, i)) + return false; + + // Verify that sub-structs also follow packing rules. + // We cannot use enhanced layouts on substructs, so they better be up to spec. + auto substruct_packing = packing_to_substruct_packing(packing); + + if (!memb_type.member_types.empty() && !buffer_is_packing_standard(memb_type, substruct_packing)) + return false; + + // Bump size. + offset += packed_size; + } + + return true; +} + +bool CompilerGLSL::can_use_io_location(StorageClass storage) +{ + // Location specifiers are must have in SPIR-V, but they aren't really supported in earlier versions of GLSL. + // Be very explicit here about how to solve the issue. + if ((get_execution_model() != ExecutionModelVertex && storage == StorageClassInput) || + (get_execution_model() != ExecutionModelFragment && storage == StorageClassOutput)) + { + if (!options.es && options.version < 410 && !options.separate_shader_objects) + return false; + else if (options.es && options.version < 310) + return false; + } + + if ((get_execution_model() == ExecutionModelVertex && storage == StorageClassInput) || + (get_execution_model() == ExecutionModelFragment && storage == StorageClassOutput)) + { + if (options.es && options.version < 300) + return false; + else if (!options.es && options.version < 330) + return false; + } + + return true; +} + +string CompilerGLSL::layout_for_variable(const SPIRVariable &var) +{ + // FIXME: Come up with a better solution for when to disable layouts. + // Having layouts depend on extensions as well as which types + // of layouts are used. For now, the simple solution is to just disable + // layouts for legacy versions. + if (is_legacy()) + return ""; + + vector attr; + + auto &dec = meta[var.self].decoration; + auto &type = get(var.basetype); + auto flags = dec.decoration_flags; + auto typeflags = meta[type.self].decoration.decoration_flags; + + if (options.vulkan_semantics && var.storage == StorageClassPushConstant) + attr.push_back("push_constant"); + + if (flags & (1ull << DecorationRowMajor)) + attr.push_back("row_major"); + if (flags & (1ull << DecorationColMajor)) + attr.push_back("column_major"); + + if (options.vulkan_semantics) + { + if (flags & (1ull << DecorationInputAttachmentIndex)) + attr.push_back(join("input_attachment_index = ", dec.input_attachment)); + } + + if ((flags & (1ull << DecorationLocation)) != 0 && can_use_io_location(var.storage)) + { + uint64_t combined_decoration = 0; + for (uint32_t i = 0; i < meta[type.self].members.size(); i++) + combined_decoration |= combined_decoration_for_member(type, i); + + // If our members have location decorations, we don't need to + // emit location decorations at the top as well (looks weird). + if ((combined_decoration & (1ull << DecorationLocation)) == 0) + attr.push_back(join("location = ", dec.location)); + } + + // set = 0 is the default. Do not emit set = decoration in regular GLSL output, but + // we should preserve it in Vulkan GLSL mode. + if (var.storage != StorageClassPushConstant) + { + if ((flags & (1ull << DecorationDescriptorSet)) && (dec.set != 0 || options.vulkan_semantics)) + attr.push_back(join("set = ", dec.set)); + } + + bool can_use_binding; + if (options.es) + can_use_binding = options.version >= 310; + else + can_use_binding = options.enable_420pack_extension || (options.version >= 420); + + if (can_use_binding && (flags & (1ull << DecorationBinding))) + attr.push_back(join("binding = ", dec.binding)); + + if (flags & (1ull << DecorationOffset)) + attr.push_back(join("offset = ", dec.offset)); + + bool push_constant_block = options.vulkan_semantics && var.storage == StorageClassPushConstant; + bool ssbo_block = var.storage == StorageClassStorageBuffer || + (var.storage == StorageClassUniform && (typeflags & (1ull << DecorationBufferBlock))); + + // Instead of adding explicit offsets for every element here, just assume we're using std140 or std430. + // If SPIR-V does not comply with either layout, we cannot really work around it. + if (var.storage == StorageClassUniform && (typeflags & (1ull << DecorationBlock))) + { + if (buffer_is_packing_standard(type, BufferPackingStd140)) + attr.push_back("std140"); + else if (buffer_is_packing_standard(type, BufferPackingStd140EnhancedLayout)) + { + attr.push_back("std140"); + // Fallback time. We might be able to use the ARB_enhanced_layouts to deal with this difference, + // however, we can only use layout(offset) on the block itself, not any substructs, so the substructs better be the appropriate layout. + // Enhanced layouts seem to always work in Vulkan GLSL, so no need for extensions there. + if (options.es && !options.vulkan_semantics) + SPIRV_CROSS_THROW("Push constant block cannot be expressed as neither std430 nor std140. ES-targets do " + "not support GL_ARB_enhanced_layouts."); + if (!options.es && !options.vulkan_semantics && options.version < 440) + require_extension("GL_ARB_enhanced_layouts"); + + // This is a very last minute to check for this, but use this unused decoration to mark that we should emit + // explicit offsets for this block type. + // layout_for_variable() will be called before the actual buffer emit. + // The alternative is a full pass before codegen where we deduce this decoration, + // but then we are just doing the exact same work twice, and more complexity. + set_decoration(type.self, DecorationCPacked); + } + else + { + SPIRV_CROSS_THROW("Uniform buffer cannot be expressed as std140, even with enhanced layouts. You can try " + "flattening this block to " + "support a more flexible layout."); + } + } + else if (push_constant_block || ssbo_block) + { + if (buffer_is_packing_standard(type, BufferPackingStd430)) + attr.push_back("std430"); + else if (buffer_is_packing_standard(type, BufferPackingStd140)) + attr.push_back("std140"); + else if (buffer_is_packing_standard(type, BufferPackingStd140EnhancedLayout)) + { + attr.push_back("std140"); + + // Fallback time. We might be able to use the ARB_enhanced_layouts to deal with this difference, + // however, we can only use layout(offset) on the block itself, not any substructs, so the substructs better be the appropriate layout. + // Enhanced layouts seem to always work in Vulkan GLSL, so no need for extensions there. + if (options.es && !options.vulkan_semantics) + SPIRV_CROSS_THROW("Push constant block cannot be expressed as neither std430 nor std140. ES-targets do " + "not support GL_ARB_enhanced_layouts."); + if (!options.es && !options.vulkan_semantics && options.version < 440) + require_extension("GL_ARB_enhanced_layouts"); + + set_decoration(type.self, DecorationCPacked); + } + else if (buffer_is_packing_standard(type, BufferPackingStd430EnhancedLayout)) + { + attr.push_back("std430"); + if (options.es && !options.vulkan_semantics) + SPIRV_CROSS_THROW("Push constant block cannot be expressed as neither std430 nor std140. ES-targets do " + "not support GL_ARB_enhanced_layouts."); + if (!options.es && !options.vulkan_semantics && options.version < 440) + require_extension("GL_ARB_enhanced_layouts"); + + set_decoration(type.self, DecorationCPacked); + } + else + { + SPIRV_CROSS_THROW("Buffer block cannot be expressed as neither std430 nor std140, even with enhanced " + "layouts. You can try flattening this block to support a more flexible layout."); + } + } + + // For images, the type itself adds a layout qualifer. + // Only emit the format for storage images. + if (type.basetype == SPIRType::Image && type.image.sampled == 2) + { + const char *fmt = format_to_glsl(type.image.format); + if (fmt) + attr.push_back(fmt); + } + + if (attr.empty()) + return ""; + + string res = "layout("; + res += merge(attr); + res += ") "; + return res; +} + +void CompilerGLSL::emit_push_constant_block(const SPIRVariable &var) +{ + if (flattened_buffer_blocks.count(var.self)) + emit_buffer_block_flattened(var); + else if (options.vulkan_semantics) + emit_push_constant_block_vulkan(var); + else + emit_push_constant_block_glsl(var); +} + +void CompilerGLSL::emit_push_constant_block_vulkan(const SPIRVariable &var) +{ + emit_buffer_block(var); +} + +void CompilerGLSL::emit_push_constant_block_glsl(const SPIRVariable &var) +{ + // OpenGL has no concept of push constant blocks, implement it as a uniform struct. + auto &type = get(var.basetype); + + auto &flags = meta[var.self].decoration.decoration_flags; + flags &= ~((1ull << DecorationBinding) | (1ull << DecorationDescriptorSet)); + +#if 0 + if (flags & ((1ull << DecorationBinding) | (1ull << DecorationDescriptorSet))) + SPIRV_CROSS_THROW("Push constant blocks cannot be compiled to GLSL with Binding or Set syntax. " + "Remap to location with reflection API first or disable these decorations."); +#endif + + // We're emitting the push constant block as a regular struct, so disable the block qualifier temporarily. + // Otherwise, we will end up emitting layout() qualifiers on naked structs which is not allowed. + auto &block_flags = meta[type.self].decoration.decoration_flags; + uint64_t block_flag = block_flags & (1ull << DecorationBlock); + block_flags &= ~block_flag; + + emit_struct(type); + + block_flags |= block_flag; + + emit_uniform(var); + statement(""); +} + +void CompilerGLSL::emit_buffer_block(const SPIRVariable &var) +{ + if (flattened_buffer_blocks.count(var.self)) + emit_buffer_block_flattened(var); + else if (is_legacy()) + emit_buffer_block_legacy(var); + else + emit_buffer_block_native(var); +} + +void CompilerGLSL::emit_buffer_block_legacy(const SPIRVariable &var) +{ + auto &type = get(var.basetype); + bool ssbo = var.storage == StorageClassStorageBuffer || + ((meta[type.self].decoration.decoration_flags & (1ull << DecorationBufferBlock)) != 0); + if (ssbo) + SPIRV_CROSS_THROW("SSBOs not supported in legacy targets."); + + // We're emitting the push constant block as a regular struct, so disable the block qualifier temporarily. + // Otherwise, we will end up emitting layout() qualifiers on naked structs which is not allowed. + auto &block_flags = meta[type.self].decoration.decoration_flags; + uint64_t block_flag = block_flags & (1ull << DecorationBlock); + block_flags &= ~block_flag; + emit_struct(type); + block_flags |= block_flag; + emit_uniform(var); + statement(""); +} + +void CompilerGLSL::emit_buffer_block_native(const SPIRVariable &var) +{ + auto &type = get(var.basetype); + + uint64_t flags = get_buffer_block_flags(var); + bool ssbo = var.storage == StorageClassStorageBuffer || + ((meta[type.self].decoration.decoration_flags & (1ull << DecorationBufferBlock)) != 0); + bool is_restrict = ssbo && (flags & (1ull << DecorationRestrict)) != 0; + bool is_writeonly = ssbo && (flags & (1ull << DecorationNonReadable)) != 0; + bool is_readonly = ssbo && (flags & (1ull << DecorationNonWritable)) != 0; + bool is_coherent = ssbo && (flags & (1ull << DecorationCoherent)) != 0; + + // Block names should never alias, but from HLSL input they kind of can because block types are reused for UAVs ... + auto buffer_name = to_name(type.self, false); + + // Shaders never use the block by interface name, so we don't + // have to track this other than updating name caches. + if (meta[type.self].decoration.alias.empty() || resource_names.find(buffer_name) != end(resource_names)) + buffer_name = get_block_fallback_name(var.self); + + // Make sure we get something unique. + add_variable(resource_names, buffer_name); + + // If for some reason buffer_name is an illegal name, make a final fallback to a workaround name. + // This cannot conflict with anything else, so we're safe now. + if (buffer_name.empty()) + buffer_name = join("_", get(var.basetype).self, "_", var.self); + + // Save for post-reflection later. + declared_block_names[var.self] = buffer_name; + + statement(layout_for_variable(var), is_coherent ? "coherent " : "", is_restrict ? "restrict " : "", + is_writeonly ? "writeonly " : "", is_readonly ? "readonly " : "", ssbo ? "buffer " : "uniform ", + buffer_name); + + begin_scope(); + + type.member_name_cache.clear(); + + uint32_t i = 0; + for (auto &member : type.member_types) + { + add_member_name(type, i); + emit_struct_member(type, member, i); + i++; + } + + add_resource_name(var.self); + end_scope_decl(to_name(var.self) + type_to_array_glsl(type)); + statement(""); +} + +void CompilerGLSL::emit_buffer_block_flattened(const SPIRVariable &var) +{ + auto &type = get(var.basetype); + + // Block names should never alias. + auto buffer_name = to_name(type.self, false); + size_t buffer_size = (get_declared_struct_size(type) + 15) / 16; + + SPIRType::BaseType basic_type; + if (get_common_basic_type(type, basic_type)) + { + SPIRType tmp; + tmp.basetype = basic_type; + tmp.vecsize = 4; + if (basic_type != SPIRType::Float && basic_type != SPIRType::Int && basic_type != SPIRType::UInt) + SPIRV_CROSS_THROW("Basic types in a flattened UBO must be float, int or uint."); + + auto flags = get_buffer_block_flags(var); + statement("uniform ", flags_to_precision_qualifiers_glsl(tmp, flags), type_to_glsl(tmp), " ", buffer_name, "[", + buffer_size, "];"); + } + else + SPIRV_CROSS_THROW("All basic types in a flattened block must be the same."); +} + +const char *CompilerGLSL::to_storage_qualifiers_glsl(const SPIRVariable &var) +{ + auto &execution = get_entry_point(); + + if (var.storage == StorageClassInput || var.storage == StorageClassOutput) + { + if (is_legacy() && execution.model == ExecutionModelVertex) + return var.storage == StorageClassInput ? "attribute " : "varying "; + else if (is_legacy() && execution.model == ExecutionModelFragment) + return "varying "; // Fragment outputs are renamed so they never hit this case. + else + return var.storage == StorageClassInput ? "in " : "out "; + } + else if (var.storage == StorageClassUniformConstant || var.storage == StorageClassUniform || + var.storage == StorageClassPushConstant) + { + return "uniform "; + } + + return ""; +} + +void CompilerGLSL::emit_flattened_io_block(const SPIRVariable &var, const char *qual) +{ + auto &type = get(var.basetype); + if (!type.array.empty()) + SPIRV_CROSS_THROW("Array of varying structs cannot be flattened to legacy-compatible varyings."); + + auto old_flags = meta[type.self].decoration.decoration_flags; + // Emit the members as if they are part of a block to get all qualifiers. + meta[type.self].decoration.decoration_flags |= 1ull << DecorationBlock; + + type.member_name_cache.clear(); + + uint32_t i = 0; + for (auto &member : type.member_types) + { + add_member_name(type, i); + auto &membertype = get(member); + + if (membertype.basetype == SPIRType::Struct) + SPIRV_CROSS_THROW("Cannot flatten struct inside structs in I/O variables."); + + // Pass in the varying qualifier here so it will appear in the correct declaration order. + // Replace member name while emitting it so it encodes both struct name and member name. + // Sanitize underscores because joining the two identifiers might create more than 1 underscore in a row, + // which is not allowed. + auto backup_name = get_member_name(type.self, i); + auto member_name = to_member_name(type, i); + set_member_name(type.self, i, sanitize_underscores(join(to_name(var.self), "_", member_name))); + emit_struct_member(type, member, i, qual); + // Restore member name. + set_member_name(type.self, i, member_name); + i++; + } + + meta[type.self].decoration.decoration_flags = old_flags; + + // Treat this variable as flattened from now on. + flattened_structs.insert(var.self); +} + +void CompilerGLSL::emit_interface_block(const SPIRVariable &var) +{ + auto &type = get(var.basetype); + + // Either make it plain in/out or in/out blocks depending on what shader is doing ... + bool block = (meta[type.self].decoration.decoration_flags & (1ull << DecorationBlock)) != 0; + const char *qual = to_storage_qualifiers_glsl(var); + + if (block) + { + // ESSL earlier than 310 and GLSL earlier than 150 did not support + // I/O variables which are struct types. + // To support this, flatten the struct into separate varyings instead. + if ((options.es && options.version < 310) || (!options.es && options.version < 150)) + { + // I/O blocks on ES require version 310 with Android Extension Pack extensions, or core version 320. + // On desktop, I/O blocks were introduced with geometry shaders in GL 3.2 (GLSL 150). + emit_flattened_io_block(var, qual); + } + else + { + if (options.es && options.version < 320) + { + // Geometry and tessellation extensions imply this extension. + if (!has_extension("GL_EXT_geometry_shader") && !has_extension("GL_EXT_tessellation_shader")) + require_extension("GL_EXT_shader_io_blocks"); + } + + // Block names should never alias. + auto block_name = to_name(type.self, false); + + // Shaders never use the block by interface name, so we don't + // have to track this other than updating name caches. + if (resource_names.find(block_name) != end(resource_names)) + block_name = get_fallback_name(type.self); + else + resource_names.insert(block_name); + + statement(layout_for_variable(var), qual, block_name); + begin_scope(); + + type.member_name_cache.clear(); + + uint32_t i = 0; + for (auto &member : type.member_types) + { + add_member_name(type, i); + emit_struct_member(type, member, i); + i++; + } + + add_resource_name(var.self); + end_scope_decl(join(to_name(var.self), type_to_array_glsl(type))); + statement(""); + } + } + else + { + // ESSL earlier than 310 and GLSL earlier than 150 did not support + // I/O variables which are struct types. + // To support this, flatten the struct into separate varyings instead. + if (type.basetype == SPIRType::Struct && + ((options.es && options.version < 310) || (!options.es && options.version < 150))) + { + emit_flattened_io_block(var, qual); + } + else + { + add_resource_name(var.self); + statement(layout_for_variable(var), variable_decl(var), ";"); + } + } +} + +void CompilerGLSL::emit_uniform(const SPIRVariable &var) +{ + auto &type = get(var.basetype); + if (type.basetype == SPIRType::Image && type.image.sampled == 2) + { + if (!options.es && options.version < 420) + require_extension("GL_ARB_shader_image_load_store"); + else if (options.es && options.version < 310) + SPIRV_CROSS_THROW("At least ESSL 3.10 required for shader image load store."); + } + + add_resource_name(var.self); + statement(layout_for_variable(var), variable_decl(var), ";"); +} + +void CompilerGLSL::emit_specialization_constant(const SPIRConstant &constant) +{ + auto &type = get(constant.constant_type); + auto name = to_name(constant.self); + + SpecializationConstant wg_x, wg_y, wg_z; + uint32_t workgroup_size_id = get_work_group_size_specialization_constants(wg_x, wg_y, wg_z); + + if (constant.self == workgroup_size_id || constant.self == wg_x.id || constant.self == wg_y.id || + constant.self == wg_z.id) + { + // These specialization constants are implicitly declared by emitting layout() in; + return; + } + + // Only scalars have constant IDs. + if (has_decoration(constant.self, DecorationSpecId)) + { + statement("layout(constant_id = ", get_decoration(constant.self, DecorationSpecId), ") const ", + variable_decl(type, name), " = ", constant_expression(constant), ";"); + } + else + { + statement("const ", variable_decl(type, name), " = ", constant_expression(constant), ";"); + } +} + +void CompilerGLSL::replace_illegal_names() +{ + // clang-format off + static const unordered_set keywords = { + "active", "asm", "atomic_uint", "attribute", "bool", "break", + "bvec2", "bvec3", "bvec4", "case", "cast", "centroid", "class", "coherent", "common", "const", "continue", "default", "discard", + "dmat2", "dmat2x2", "dmat2x3", "dmat2x4", "dmat3", "dmat3x2", "dmat3x3", "dmat3x4", "dmat4", "dmat4x2", "dmat4x3", "dmat4x4", + "do", "double", "dvec2", "dvec3", "dvec4", "else", "enum", "extern", "external", "false", "filter", "fixed", "flat", "float", + "for", "fvec2", "fvec3", "fvec4", "goto", "half", "highp", "hvec2", "hvec3", "hvec4", "if", "iimage1D", "iimage1DArray", + "iimage2D", "iimage2DArray", "iimage2DMS", "iimage2DMSArray", "iimage2DRect", "iimage3D", "iimageBuffer", "iimageCube", + "iimageCubeArray", "image1D", "image1DArray", "image2D", "image2DArray", "image2DMS", "image2DMSArray", "image2DRect", + "image3D", "imageBuffer", "imageCube", "imageCubeArray", "in", "inline", "inout", "input", "int", "interface", "invariant", + "isampler1D", "isampler1DArray", "isampler2D", "isampler2DArray", "isampler2DMS", "isampler2DMSArray", "isampler2DRect", + "isampler3D", "isamplerBuffer", "isamplerCube", "isamplerCubeArray", "ivec2", "ivec3", "ivec4", "layout", "line", "linear", "long", "lowp", + "mat2", "mat2x2", "mat2x3", "mat2x4", "mat3", "mat3x2", "mat3x3", "mat3x4", "mat4", "mat4x2", "mat4x3", "mat4x4", "mediump", + "namespace", "noinline", "noperspective", "out", "output", "packed", "partition", "patch", "point", "precision", "public", "readonly", + "resource", "restrict", "return", "row_major", "sample", "sampler", "sampler1D", "sampler1DArray", "sampler1DArrayShadow", + "sampler1DShadow", "sampler2D", "sampler2DArray", "sampler2DArrayShadow", "sampler2DMS", "sampler2DMSArray", + "sampler2DRect", "sampler2DRectShadow", "sampler2DShadow", "sampler3D", "sampler3DRect", "samplerBuffer", + "samplerCube", "samplerCubeArray", "samplerCubeArrayShadow", "samplerCubeShadow", "short", "sizeof", "smooth", "static", + "struct", "subroutine", "superp", "switch", "template", "this", "true", "typedef", "uimage1D", "uimage1DArray", "uimage2D", + "uimage2DArray", "uimage2DMS", "uimage2DMSArray", "uimage2DRect", "uimage3D", "uimageBuffer", "uimageCube", + "uimageCubeArray", "uint", "uniform", "union", "unsigned", "usampler1D", "usampler1DArray", "usampler2D", "usampler2DArray", + "usampler2DMS", "usampler2DMSArray", "usampler2DRect", "usampler3D", "usamplerBuffer", "usamplerCube", + "usamplerCubeArray", "using", "uvec2", "uvec3", "uvec4", "varying", "vec2", "vec3", "vec4", "void", "volatile", "volatile", + "while", "writeonly", "texture" + }; + // clang-format on + + for (auto &id : ids) + { + if (id.get_type() == TypeVariable) + { + auto &var = id.get(); + if (!is_hidden_variable(var)) + { + auto &m = meta[var.self].decoration; + if (m.alias.compare(0, 3, "gl_") == 0 || keywords.find(m.alias) != end(keywords)) + m.alias = join("_", m.alias); + } + } + } +} + +void CompilerGLSL::replace_fragment_output(SPIRVariable &var) +{ + auto &m = meta[var.self].decoration; + uint32_t location = 0; + if (m.decoration_flags & (1ull << DecorationLocation)) + location = m.location; + + // If our variable is arrayed, we must not emit the array part of this as the SPIR-V will + // do the access chain part of this for us. + auto &type = get(var.basetype); + + if (type.array.empty()) + { + // Redirect the write to a specific render target in legacy GLSL. + m.alias = join("gl_FragData[", location, "]"); + + if (is_legacy_es() && location != 0) + require_extension("GL_EXT_draw_buffers"); + } + else if (type.array.size() == 1) + { + // If location is non-zero, we probably have to add an offset. + // This gets really tricky since we'd have to inject an offset in the access chain. + // FIXME: This seems like an extremely odd-ball case, so it's probably fine to leave it like this for now. + m.alias = "gl_FragData"; + if (location != 0) + SPIRV_CROSS_THROW("Arrayed output variable used, but location is not 0. " + "This is unimplemented in SPIRV-Cross."); + + if (is_legacy_es()) + require_extension("GL_EXT_draw_buffers"); + } + else + SPIRV_CROSS_THROW("Array-of-array output variable used. This cannot be implemented in legacy GLSL."); + + var.compat_builtin = true; // We don't want to declare this variable, but use the name as-is. +} + +void CompilerGLSL::replace_fragment_outputs() +{ + for (auto &id : ids) + { + if (id.get_type() == TypeVariable) + { + auto &var = id.get(); + auto &type = get(var.basetype); + + if (!is_builtin_variable(var) && !var.remapped_variable && type.pointer && + var.storage == StorageClassOutput) + replace_fragment_output(var); + } + } +} + +string CompilerGLSL::remap_swizzle(const SPIRType &out_type, uint32_t input_components, const string &expr) +{ + if (out_type.vecsize == input_components) + return expr; + else if (input_components == 1 && !backend.can_swizzle_scalar) + return join(type_to_glsl(out_type), "(", expr, ")"); + else + { + auto e = enclose_expression(expr) + "."; + // Just clamp the swizzle index if we have more outputs than inputs. + for (uint32_t c = 0; c < out_type.vecsize; c++) + e += index_to_swizzle(min(c, input_components - 1)); + if (backend.swizzle_is_function && out_type.vecsize > 1) + e += "()"; + + remove_duplicate_swizzle(e); + return e; + } +} + +void CompilerGLSL::emit_pls() +{ + auto &execution = get_entry_point(); + if (execution.model != ExecutionModelFragment) + SPIRV_CROSS_THROW("Pixel local storage only supported in fragment shaders."); + + if (!options.es) + SPIRV_CROSS_THROW("Pixel local storage only supported in OpenGL ES."); + + if (options.version < 300) + SPIRV_CROSS_THROW("Pixel local storage only supported in ESSL 3.0 and above."); + + if (!pls_inputs.empty()) + { + statement("__pixel_local_inEXT _PLSIn"); + begin_scope(); + for (auto &input : pls_inputs) + statement(pls_decl(input), ";"); + end_scope_decl(); + statement(""); + } + + if (!pls_outputs.empty()) + { + statement("__pixel_local_outEXT _PLSOut"); + begin_scope(); + for (auto &output : pls_outputs) + statement(pls_decl(output), ";"); + end_scope_decl(); + statement(""); + } +} + +void CompilerGLSL::fixup_image_load_store_access() +{ + for (auto &id : ids) + { + if (id.get_type() != TypeVariable) + continue; + + uint32_t var = id.get().self; + auto &vartype = expression_type(var); + if (vartype.basetype == SPIRType::Image) + { + // Older glslangValidator does not emit required qualifiers here. + // Solve this by making the image access as restricted as possible and loosen up if we need to. + // If any no-read/no-write flags are actually set, assume that the compiler knows what it's doing. + + auto &flags = meta.at(var).decoration.decoration_flags; + static const uint64_t NoWrite = 1ull << DecorationNonWritable; + static const uint64_t NoRead = 1ull << DecorationNonReadable; + if ((flags & (NoWrite | NoRead)) == 0) + flags |= NoRead | NoWrite; + } + } +} + +void CompilerGLSL::emit_declared_builtin_block(StorageClass storage, ExecutionModel model) +{ + uint64_t emitted_builtins = 0; + uint64_t global_builtins = 0; + const SPIRVariable *block_var = nullptr; + bool emitted_block = false; + bool builtin_array = false; + + for (auto &id : ids) + { + if (id.get_type() != TypeVariable) + continue; + + auto &var = id.get(); + auto &type = get(var.basetype); + bool block = has_decoration(type.self, DecorationBlock); + uint64_t builtins = 0; + + if (var.storage == storage && block && is_builtin_variable(var)) + { + for (auto &m : meta[type.self].members) + if (m.builtin) + builtins |= 1ull << m.builtin_type; + } + else if (var.storage == storage && !block && is_builtin_variable(var)) + { + // While we're at it, collect all declared global builtins (HLSL mostly ...). + auto &m = meta[var.self].decoration; + if (m.builtin) + global_builtins |= 1ull << m.builtin_type; + } + + if (!builtins) + continue; + + if (emitted_block) + SPIRV_CROSS_THROW("Cannot use more than one builtin I/O block."); + + emitted_builtins = builtins; + emitted_block = true; + builtin_array = !type.array.empty(); + block_var = &var; + } + + global_builtins &= (1ull << BuiltInPosition) | (1ull << BuiltInPointSize) | (1ull << BuiltInClipDistance) | + (1ull << BuiltInCullDistance); + + // Try to collect all other declared builtins. + if (!emitted_block) + emitted_builtins = global_builtins; + + // Can't declare an empty interface block. + if (!emitted_builtins) + return; + + if (storage == StorageClassOutput) + statement("out gl_PerVertex"); + else + statement("in gl_PerVertex"); + + begin_scope(); + if (emitted_builtins & (1ull << BuiltInPosition)) + statement("vec4 gl_Position;"); + if (emitted_builtins & (1ull << BuiltInPointSize)) + statement("float gl_PointSize;"); + if (emitted_builtins & (1ull << BuiltInClipDistance)) + statement("float gl_ClipDistance[];"); // TODO: Do we need a fixed array size here? + if (emitted_builtins & (1ull << BuiltInCullDistance)) + statement("float gl_CullDistance[];"); // TODO: Do we need a fixed array size here? + + bool tessellation = model == ExecutionModelTessellationEvaluation || model == ExecutionModelTessellationControl; + if (builtin_array) + { + // Make sure the array has a supported name in the code. + if (storage == StorageClassOutput) + set_name(block_var->self, "gl_out"); + else if (storage == StorageClassInput) + set_name(block_var->self, "gl_in"); + + if (model == ExecutionModelTessellationControl && storage == StorageClassOutput) + end_scope_decl(join(to_name(block_var->self), "[", get_entry_point().output_vertices, "]")); + else + end_scope_decl(join(to_name(block_var->self), tessellation ? "[gl_MaxPatchVertices]" : "[]")); + } + else + end_scope_decl(); + statement(""); +} + +void CompilerGLSL::declare_undefined_values() +{ + bool emitted = false; + for (auto &id : ids) + { + if (id.get_type() != TypeUndef) + continue; + + auto &undef = id.get(); + statement(variable_decl(get(undef.basetype), to_name(undef.self), undef.self), ";"); + emitted = true; + } + + if (emitted) + statement(""); +} + +void CompilerGLSL::emit_resources() +{ + auto &execution = get_entry_point(); + + replace_illegal_names(); + + // Legacy GL uses gl_FragData[], redeclare all fragment outputs + // with builtins. + if (execution.model == ExecutionModelFragment && is_legacy()) + replace_fragment_outputs(); + + // Emit PLS blocks if we have such variables. + if (!pls_inputs.empty() || !pls_outputs.empty()) + emit_pls(); + + // Emit custom gl_PerVertex for SSO compatibility. + if (options.separate_shader_objects && !options.es) + { + switch (execution.model) + { + case ExecutionModelGeometry: + case ExecutionModelTessellationControl: + case ExecutionModelTessellationEvaluation: + emit_declared_builtin_block(StorageClassInput, execution.model); + emit_declared_builtin_block(StorageClassOutput, execution.model); + break; + + case ExecutionModelVertex: + emit_declared_builtin_block(StorageClassOutput, execution.model); + break; + + default: + break; + } + } + + bool emitted = false; + + // If emitted Vulkan GLSL, + // emit specialization constants as actual floats, + // spec op expressions will redirect to the constant name. + // + // TODO: If we have the fringe case that we create a spec constant which depends on a struct type, + // we'll have to deal with that, but there's currently no known way to express that. + if (options.vulkan_semantics) + { + for (auto &id : ids) + { + if (id.get_type() == TypeConstant) + { + auto &c = id.get(); + if (!c.specialization) + continue; + + emit_specialization_constant(c); + emitted = true; + } + } + } + + if (emitted) + statement(""); + emitted = false; + + // Output all basic struct types which are not Block or BufferBlock as these are declared inplace + // when such variables are instantiated. + for (auto &id : ids) + { + if (id.get_type() == TypeType) + { + auto &type = id.get(); + if (type.basetype == SPIRType::Struct && type.array.empty() && !type.pointer && + (meta[type.self].decoration.decoration_flags & + ((1ull << DecorationBlock) | (1ull << DecorationBufferBlock))) == 0) + { + emit_struct(type); + } + } + } + + // Output UBOs and SSBOs + for (auto &id : ids) + { + if (id.get_type() == TypeVariable) + { + auto &var = id.get(); + auto &type = get(var.basetype); + + bool is_block_storage = type.storage == StorageClassStorageBuffer || type.storage == StorageClassUniform; + bool has_block_flags = (meta[type.self].decoration.decoration_flags & + ((1ull << DecorationBlock) | (1ull << DecorationBufferBlock))) != 0; + + if (var.storage != StorageClassFunction && type.pointer && is_block_storage && !is_hidden_variable(var) && + has_block_flags) + { + emit_buffer_block(var); + } + } + } + + // Output push constant blocks + for (auto &id : ids) + { + if (id.get_type() == TypeVariable) + { + auto &var = id.get(); + auto &type = get(var.basetype); + if (var.storage != StorageClassFunction && type.pointer && type.storage == StorageClassPushConstant && + !is_hidden_variable(var)) + { + emit_push_constant_block(var); + } + } + } + + bool skip_separate_image_sampler = !combined_image_samplers.empty() || !options.vulkan_semantics; + + // Output Uniform Constants (values, samplers, images, etc). + for (auto &id : ids) + { + if (id.get_type() == TypeVariable) + { + auto &var = id.get(); + auto &type = get(var.basetype); + + // If we're remapping separate samplers and images, only emit the combined samplers. + if (skip_separate_image_sampler) + { + // Sampler buffers are always used without a sampler, and they will also work in regular GL. + bool sampler_buffer = type.basetype == SPIRType::Image && type.image.dim == DimBuffer; + bool separate_image = type.basetype == SPIRType::Image && type.image.sampled == 1; + bool separate_sampler = type.basetype == SPIRType::Sampler; + if (!sampler_buffer && (separate_image || separate_sampler)) + continue; + } + + if (var.storage != StorageClassFunction && type.pointer && + (type.storage == StorageClassUniformConstant || type.storage == StorageClassAtomicCounter) && + !is_hidden_variable(var)) + { + emit_uniform(var); + emitted = true; + } + } + } + + if (emitted) + statement(""); + emitted = false; + + // Output in/out interfaces. + for (auto &id : ids) + { + if (id.get_type() == TypeVariable) + { + auto &var = id.get(); + auto &type = get(var.basetype); + + // HLSL output from glslang may emit interface variables which are "empty". + // Just avoid declaring them. + if (type_is_empty(type)) + continue; + + if (var.storage != StorageClassFunction && type.pointer && + (var.storage == StorageClassInput || var.storage == StorageClassOutput) && + interface_variable_exists_in_entry_point(var.self) && !is_hidden_variable(var)) + { + emit_interface_block(var); + emitted = true; + } + else if (is_builtin_variable(var)) + { + // For gl_InstanceIndex emulation on GLES, the API user needs to + // supply this uniform. + if (meta[var.self].decoration.builtin_type == BuiltInInstanceIndex && !options.vulkan_semantics) + { + statement("uniform int SPIRV_Cross_BaseInstance;"); + emitted = true; + } + } + } + } + + // Global variables. + for (auto global : global_variables) + { + auto &var = get(global); + if (var.storage != StorageClassOutput) + { + add_resource_name(var.self); + statement(variable_decl(var), ";"); + emitted = true; + } + } + + if (emitted) + statement(""); + + declare_undefined_values(); +} + +// Returns a string representation of the ID, usable as a function arg. +// Default is to simply return the expression representation fo the arg ID. +// Subclasses may override to modify the return value. +string CompilerGLSL::to_func_call_arg(uint32_t id) +{ + return to_expression(id); +} + +void CompilerGLSL::handle_invalid_expression(uint32_t id) +{ + // We tried to read an invalidated expression. + // This means we need another pass at compilation, but next time, force temporary variables so that they cannot be invalidated. + forced_temporaries.insert(id); + force_recompile = true; +} + +// Converts the format of the current expression from packed to unpacked, +// by wrapping the expression in a constructor of the appropriate type. +// GLSL does not support packed formats, so simply return the expression. +// Subclasses that do will override +string CompilerGLSL::unpack_expression_type(string expr_str, const SPIRType &) +{ + return expr_str; +} + +// Sometimes we proactively enclosed an expression where it turns out we might have not needed it after all. +void CompilerGLSL::strip_enclosed_expression(string &expr) +{ + if (expr.size() < 2 || expr.front() != '(' || expr.back() != ')') + return; + + // Have to make sure that our first and last parens actually enclose everything inside it. + uint32_t paren_count = 0; + for (auto &c : expr) + { + if (c == '(') + paren_count++; + else if (c == ')') + { + paren_count--; + + // If we hit 0 and this is not the final char, our first and final parens actually don't + // enclose the expression, and we cannot strip, e.g.: (a + b) * (c + d). + if (paren_count == 0 && &c != &expr.back()) + return; + } + } + expr.erase(expr.size() - 1, 1); + expr.erase(begin(expr)); +} + +string CompilerGLSL::enclose_expression(const string &expr) +{ + bool need_parens = false; + + // If the expression starts with a unary we need to enclose to deal with cases where we have back-to-back + // unary expressions. + if (!expr.empty()) + { + auto c = expr.front(); + if (c == '-' || c == '+' || c == '!' || c == '~') + need_parens = true; + } + + if (!need_parens) + { + uint32_t paren_count = 0; + for (auto c : expr) + { + if (c == '(') + paren_count++; + else if (c == ')') + { + assert(paren_count); + paren_count--; + } + else if (c == ' ' && paren_count == 0) + { + need_parens = true; + break; + } + } + assert(paren_count == 0); + } + + // If this expression contains any spaces which are not enclosed by parentheses, + // we need to enclose it so we can treat the whole string as an expression. + // This happens when two expressions have been part of a binary op earlier. + if (need_parens) + return join('(', expr, ')'); + else + return expr; +} + +// Just like to_expression except that we enclose the expression inside parentheses if needed. +string CompilerGLSL::to_enclosed_expression(uint32_t id) +{ + return enclose_expression(to_expression(id)); +} + +string CompilerGLSL::to_expression(uint32_t id) +{ + auto itr = invalid_expressions.find(id); + if (itr != end(invalid_expressions)) + handle_invalid_expression(id); + + if (ids[id].get_type() == TypeExpression) + { + // We might have a more complex chain of dependencies. + // A possible scenario is that we + // + // %1 = OpLoad + // %2 = OpDoSomething %1 %1. here %2 will have a dependency on %1. + // %3 = OpDoSomethingAgain %2 %2. Here %3 will lose the link to %1 since we don't propagate the dependencies like that. + // OpStore %1 %foo // Here we can invalidate %1, and hence all expressions which depend on %1. Only %2 will know since it's part of invalid_expressions. + // %4 = OpDoSomethingAnotherTime %3 %3 // If we forward all expressions we will see %1 expression after store, not before. + // + // However, we can propagate up a list of depended expressions when we used %2, so we can check if %2 is invalid when reading %3 after the store, + // and see that we should not forward reads of the original variable. + auto &expr = get(id); + for (uint32_t dep : expr.expression_dependencies) + if (invalid_expressions.find(dep) != end(invalid_expressions)) + handle_invalid_expression(dep); + } + + track_expression_read(id); + + switch (ids[id].get_type()) + { + case TypeExpression: + { + auto &e = get(id); + if (e.base_expression) + return to_enclosed_expression(e.base_expression) + e.expression; + else if (e.need_transpose) + return convert_row_major_matrix(e.expression, get(e.expression_type)); + else + { + if (force_recompile) + { + // During first compilation phase, certain expression patterns can trigger exponential growth of memory. + // Avoid this by returning dummy expressions during this phase. + // Do not use empty expressions here, because those are sentinels for other cases. + return "_"; + } + else + return e.expression; + } + } + + case TypeConstant: + { + auto &c = get(id); + auto &type = get(c.constant_type); + + // WorkGroupSize may be a constant. + auto &dec = meta[c.self].decoration; + if (dec.builtin) + return builtin_to_glsl(dec.builtin_type, StorageClassGeneric); + else if (c.specialization && options.vulkan_semantics) + return to_name(id); + else if (type.basetype == SPIRType::Struct && !backend.can_declare_struct_inline) + return to_name(id); + else if (!type.array.empty() && !backend.can_declare_arrays_inline) + return to_name(id); + else + return constant_expression(c); + } + + case TypeConstantOp: + return constant_op_expression(get(id)); + + case TypeVariable: + { + auto &var = get(id); + // If we try to use a loop variable before the loop header, we have to redirect it to the static expression, + // the variable has not been declared yet. + if (var.statically_assigned || (var.loop_variable && !var.loop_variable_enable)) + return to_expression(var.static_expression); + else if (var.deferred_declaration) + { + var.deferred_declaration = false; + return variable_decl(var); + } + else if (flattened_structs.count(id)) + { + return load_flattened_struct(var); + } + else + { + auto &dec = meta[var.self].decoration; + if (dec.builtin) + return builtin_to_glsl(dec.builtin_type, var.storage); + else + return to_name(id); + } + } + + case TypeCombinedImageSampler: + // This type should never be taken the expression of directly. + // The intention is that texture sampling functions will extract the image and samplers + // separately and take their expressions as needed. + // GLSL does not use this type because OpSampledImage immediately creates a combined image sampler + // expression ala sampler2D(texture, sampler). + SPIRV_CROSS_THROW("Combined image samplers have no default expression representation."); + + case TypeAccessChain: + // We cannot express this type. They only have meaning in other OpAccessChains, OpStore or OpLoad. + SPIRV_CROSS_THROW("Access chains have no default expression representation."); + + default: + return to_name(id); + } +} + +string CompilerGLSL::constant_op_expression(const SPIRConstantOp &cop) +{ + auto &type = get(cop.basetype); + bool binary = false; + bool unary = false; + string op; + + // TODO: Find a clean way to reuse emit_instruction. + switch (cop.opcode) + { + case OpSConvert: + case OpUConvert: + case OpFConvert: + op = type_to_glsl_constructor(type); + break; + +#define BOP(opname, x) \ + case Op##opname: \ + binary = true; \ + op = x; \ + break + +#define UOP(opname, x) \ + case Op##opname: \ + unary = true; \ + op = x; \ + break + + UOP(SNegate, "-"); + UOP(Not, "~"); + BOP(IAdd, "+"); + BOP(ISub, "-"); + BOP(IMul, "*"); + BOP(SDiv, "/"); + BOP(UDiv, "/"); + BOP(UMod, "%"); + BOP(SMod, "%"); + BOP(ShiftRightLogical, ">>"); + BOP(ShiftRightArithmetic, ">>"); + BOP(ShiftLeftLogical, "<<"); + BOP(BitwiseOr, "|"); + BOP(BitwiseXor, "^"); + BOP(BitwiseAnd, "&"); + BOP(LogicalOr, "||"); + BOP(LogicalAnd, "&&"); + UOP(LogicalNot, "!"); + BOP(LogicalEqual, "=="); + BOP(LogicalNotEqual, "!="); + BOP(IEqual, "=="); + BOP(INotEqual, "!="); + BOP(ULessThan, "<"); + BOP(SLessThan, "<"); + BOP(ULessThanEqual, "<="); + BOP(SLessThanEqual, "<="); + BOP(UGreaterThan, ">"); + BOP(SGreaterThan, ">"); + BOP(UGreaterThanEqual, ">="); + BOP(SGreaterThanEqual, ">="); + + case OpSelect: + { + if (cop.arguments.size() < 3) + SPIRV_CROSS_THROW("Not enough arguments to OpSpecConstantOp."); + + // This one is pretty annoying. It's triggered from + // uint(bool), int(bool) from spec constants. + // In order to preserve its compile-time constness in Vulkan GLSL, + // we need to reduce the OpSelect expression back to this simplified model. + // If we cannot, fail. + if (!to_trivial_mix_op(type, op, cop.arguments[2], cop.arguments[1], cop.arguments[0])) + { + SPIRV_CROSS_THROW( + "Cannot implement specialization constant op OpSelect. " + "Need trivial select implementation which can be resolved to a simple cast from boolean."); + } + break; + } + + default: + // Some opcodes are unimplemented here, these are currently not possible to test from glslang. + SPIRV_CROSS_THROW("Unimplemented spec constant op."); + } + + SPIRType::BaseType input_type; + bool skip_cast_if_equal_type = opcode_is_sign_invariant(cop.opcode); + + switch (cop.opcode) + { + case OpIEqual: + case OpINotEqual: + input_type = SPIRType::Int; + break; + + default: + input_type = type.basetype; + break; + } + +#undef BOP +#undef UOP + if (binary) + { + if (cop.arguments.size() < 2) + SPIRV_CROSS_THROW("Not enough arguments to OpSpecConstantOp."); + + string cast_op0; + string cast_op1; + auto expected_type = binary_op_bitcast_helper(cast_op0, cast_op1, input_type, cop.arguments[0], + cop.arguments[1], skip_cast_if_equal_type); + + if (type.basetype != input_type && type.basetype != SPIRType::Boolean) + { + expected_type.basetype = input_type; + auto expr = bitcast_glsl_op(type, expected_type); + expr += '('; + expr += join(cast_op0, " ", op, " ", cast_op1); + expr += ')'; + return expr; + } + else + return join("(", cast_op0, " ", op, " ", cast_op1, ")"); + } + else if (unary) + { + if (cop.arguments.size() < 1) + SPIRV_CROSS_THROW("Not enough arguments to OpSpecConstantOp."); + + // Auto-bitcast to result type as needed. + // Works around various casting scenarios in glslang as there is no OpBitcast for specialization constants. + return join("(", op, bitcast_glsl(type, cop.arguments[0]), ")"); + } + else + { + if (cop.arguments.size() < 1) + SPIRV_CROSS_THROW("Not enough arguments to OpSpecConstantOp."); + return join(op, "(", to_expression(cop.arguments[0]), ")"); + } +} + +string CompilerGLSL::constant_expression(const SPIRConstant &c) +{ + if (!c.subconstants.empty()) + { + // Handles Arrays and structures. + string res; + if (backend.use_initializer_list) + res = "{ "; + else + res = type_to_glsl_constructor(get(c.constant_type)) + "("; + + for (auto &elem : c.subconstants) + { + auto &subc = get(elem); + if (subc.specialization && options.vulkan_semantics) + res += to_name(elem); + else + res += constant_expression(subc); + + if (&elem != &c.subconstants.back()) + res += ", "; + } + + res += backend.use_initializer_list ? " }" : ")"; + return res; + } + else if (c.columns() == 1) + { + return constant_expression_vector(c, 0); + } + else + { + string res = type_to_glsl(get(c.constant_type)) + "("; + for (uint32_t col = 0; col < c.columns(); col++) + { + if (options.vulkan_semantics && c.specialization_constant_id(col) != 0) + res += to_name(c.specialization_constant_id(col)); + else + res += constant_expression_vector(c, col); + + if (col + 1 < c.columns()) + res += ", "; + } + res += ")"; + return res; + } +} + +string CompilerGLSL::constant_expression_vector(const SPIRConstant &c, uint32_t vector) +{ + auto type = get(c.constant_type); + type.columns = 1; + + string res; + bool splat = backend.use_constructor_splatting && c.vector_size() > 1; + bool swizzle_splat = backend.can_swizzle_scalar && c.vector_size() > 1; + + if (type.basetype != SPIRType::Float && type.basetype != SPIRType::Double) + { + // Cannot swizzle literal integers as a special case. + swizzle_splat = false; + } + + if (splat || swizzle_splat) + { + // Cannot use constant splatting if we have specialization constants somewhere in the vector. + for (uint32_t i = 0; i < c.vector_size(); i++) + { + if (options.vulkan_semantics && c.specialization_constant_id(vector, i) != 0) + { + splat = false; + swizzle_splat = false; + break; + } + } + } + + if (splat || swizzle_splat) + { + if (type.width == 64) + { + uint64_t ident = c.scalar_u64(vector, 0); + for (uint32_t i = 1; i < c.vector_size(); i++) + { + if (ident != c.scalar_u64(vector, i)) + { + splat = false; + swizzle_splat = false; + break; + } + } + } + else + { + uint32_t ident = c.scalar(vector, 0); + for (uint32_t i = 1; i < c.vector_size(); i++) + { + if (ident != c.scalar(vector, i)) + { + splat = false; + swizzle_splat = false; + } + } + } + } + + if (c.vector_size() > 1 && !swizzle_splat) + res += type_to_glsl(type) + "("; + + switch (type.basetype) + { + case SPIRType::Float: + if (splat || swizzle_splat) + { + res += convert_to_string(c.scalar_f32(vector, 0)); + if (backend.float_literal_suffix) + res += "f"; + + if (swizzle_splat) + res = remap_swizzle(get(c.constant_type), 1, res); + } + else + { + for (uint32_t i = 0; i < c.vector_size(); i++) + { + if (options.vulkan_semantics && c.vector_size() > 1 && c.specialization_constant_id(vector, i) != 0) + res += to_name(c.specialization_constant_id(vector, i)); + else + res += convert_to_string(c.scalar_f32(vector, i)); + + if (backend.float_literal_suffix) + res += "f"; + if (i + 1 < c.vector_size()) + res += ", "; + } + } + break; + + case SPIRType::Double: + if (splat || swizzle_splat) + { + res += convert_to_string(c.scalar_f64(vector, 0)); + if (backend.double_literal_suffix) + res += "lf"; + + if (swizzle_splat) + res = remap_swizzle(get(c.constant_type), 1, res); + } + else + { + for (uint32_t i = 0; i < c.vector_size(); i++) + { + if (options.vulkan_semantics && c.vector_size() > 1 && c.specialization_constant_id(vector, i) != 0) + res += to_name(c.specialization_constant_id(vector, i)); + else + { + res += convert_to_string(c.scalar_f64(vector, i)); + if (backend.double_literal_suffix) + res += "lf"; + } + + if (i + 1 < c.vector_size()) + res += ", "; + } + } + break; + + case SPIRType::Int64: + if (splat) + { + res += convert_to_string(c.scalar_i64(vector, 0)); + if (backend.long_long_literal_suffix) + res += "ll"; + else + res += "l"; + } + else + { + for (uint32_t i = 0; i < c.vector_size(); i++) + { + if (options.vulkan_semantics && c.vector_size() > 1 && c.specialization_constant_id(vector, i) != 0) + res += to_name(c.specialization_constant_id(vector, i)); + else + { + res += convert_to_string(c.scalar_i64(vector, i)); + if (backend.long_long_literal_suffix) + res += "ll"; + else + res += "l"; + } + + if (i + 1 < c.vector_size()) + res += ", "; + } + } + break; + + case SPIRType::UInt64: + if (splat) + { + res += convert_to_string(c.scalar_u64(vector, 0)); + if (backend.long_long_literal_suffix) + res += "ull"; + else + res += "ul"; + } + else + { + for (uint32_t i = 0; i < c.vector_size(); i++) + { + if (options.vulkan_semantics && c.vector_size() > 1 && c.specialization_constant_id(vector, i) != 0) + res += to_name(c.specialization_constant_id(vector, i)); + else + { + res += convert_to_string(c.scalar_u64(vector, i)); + if (backend.long_long_literal_suffix) + res += "ull"; + else + res += "ul"; + } + + if (i + 1 < c.vector_size()) + res += ", "; + } + } + break; + + case SPIRType::UInt: + if (splat) + { + res += convert_to_string(c.scalar(vector, 0)); + if (backend.uint32_t_literal_suffix) + res += "u"; + } + else + { + for (uint32_t i = 0; i < c.vector_size(); i++) + { + if (options.vulkan_semantics && c.vector_size() > 1 && c.specialization_constant_id(vector, i) != 0) + res += to_name(c.specialization_constant_id(vector, i)); + else + { + res += convert_to_string(c.scalar(vector, i)); + if (backend.uint32_t_literal_suffix) + res += "u"; + } + + if (i + 1 < c.vector_size()) + res += ", "; + } + } + break; + + case SPIRType::Int: + if (splat) + res += convert_to_string(c.scalar_i32(vector, 0)); + else + { + for (uint32_t i = 0; i < c.vector_size(); i++) + { + if (options.vulkan_semantics && c.vector_size() > 1 && c.specialization_constant_id(vector, i) != 0) + res += to_name(c.specialization_constant_id(vector, i)); + else + res += convert_to_string(c.scalar_i32(vector, i)); + if (i + 1 < c.vector_size()) + res += ", "; + } + } + break; + + case SPIRType::Boolean: + if (splat) + res += c.scalar(vector, 0) ? "true" : "false"; + else + { + for (uint32_t i = 0; i < c.vector_size(); i++) + { + if (options.vulkan_semantics && c.vector_size() > 1 && c.specialization_constant_id(vector, i) != 0) + res += to_name(c.specialization_constant_id(vector, i)); + else + res += c.scalar(vector, i) ? "true" : "false"; + + if (i + 1 < c.vector_size()) + res += ", "; + } + } + break; + + default: + SPIRV_CROSS_THROW("Invalid constant expression basetype."); + } + + if (c.vector_size() > 1 && !swizzle_splat) + res += ")"; + + return res; +} + +string CompilerGLSL::declare_temporary(uint32_t result_type, uint32_t result_id) +{ + auto &type = get(result_type); + auto flags = meta[result_id].decoration.decoration_flags; + + // If we're declaring temporaries inside continue blocks, + // we must declare the temporary in the loop header so that the continue block can avoid declaring new variables. + if (current_continue_block && !hoisted_temporaries.count(result_id)) + { + auto &header = get(current_continue_block->loop_dominator); + if (find_if(begin(header.declare_temporary), end(header.declare_temporary), + [result_type, result_id](const pair &tmp) { + return tmp.first == result_type && tmp.second == result_id; + }) == end(header.declare_temporary)) + { + header.declare_temporary.emplace_back(result_type, result_id); + hoisted_temporaries.insert(result_id); + force_recompile = true; + } + + return join(to_name(result_id), " = "); + } + else if (hoisted_temporaries.count(result_id)) + { + // The temporary has already been declared earlier, so just "declare" the temporary by writing to it. + return join(to_name(result_id), " = "); + } + else + { + // The result_id has not been made into an expression yet, so use flags interface. + return join(flags_to_precision_qualifiers_glsl(type, flags), variable_decl(type, to_name(result_id)), " = "); + } +} + +bool CompilerGLSL::expression_is_forwarded(uint32_t id) +{ + return forwarded_temporaries.find(id) != end(forwarded_temporaries); +} + +SPIRExpression &CompilerGLSL::emit_op(uint32_t result_type, uint32_t result_id, const string &rhs, bool forwarding, + bool suppress_usage_tracking) +{ + if (forwarding && (forced_temporaries.find(result_id) == end(forced_temporaries))) + { + // Just forward it without temporary. + // If the forward is trivial, we do not force flushing to temporary for this expression. + if (!suppress_usage_tracking) + forwarded_temporaries.insert(result_id); + + return set(result_id, rhs, result_type, true); + } + else + { + // If expression isn't immutable, bind it to a temporary and make the new temporary immutable (they always are). + statement(declare_temporary(result_type, result_id), rhs, ";"); + return set(result_id, to_name(result_id), result_type, true); + } +} + +void CompilerGLSL::emit_unary_op(uint32_t result_type, uint32_t result_id, uint32_t op0, const char *op) +{ + bool forward = should_forward(op0); + emit_op(result_type, result_id, join(op, to_enclosed_expression(op0)), forward); + inherit_expression_dependencies(result_id, op0); +} + +void CompilerGLSL::emit_binary_op(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, const char *op) +{ + bool forward = should_forward(op0) && should_forward(op1); + emit_op(result_type, result_id, join(to_enclosed_expression(op0), " ", op, " ", to_enclosed_expression(op1)), + forward); + + inherit_expression_dependencies(result_id, op0); + inherit_expression_dependencies(result_id, op1); +} + +void CompilerGLSL::emit_unrolled_unary_op(uint32_t result_type, uint32_t result_id, uint32_t operand, const char *op) +{ + auto &type = get(result_type); + auto expr = type_to_glsl_constructor(type); + expr += '('; + for (uint32_t i = 0; i < type.vecsize; i++) + { + // Make sure to call to_expression multiple times to ensure + // that these expressions are properly flushed to temporaries if needed. + expr += op; + expr += to_enclosed_expression(operand); + expr += '.'; + expr += index_to_swizzle(i); + + if (i + 1 < type.vecsize) + expr += ", "; + } + expr += ')'; + emit_op(result_type, result_id, expr, should_forward(operand)); + + inherit_expression_dependencies(result_id, operand); +} + +void CompilerGLSL::emit_unrolled_binary_op(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, + const char *op) +{ + auto &type = get(result_type); + auto expr = type_to_glsl_constructor(type); + expr += '('; + for (uint32_t i = 0; i < type.vecsize; i++) + { + // Make sure to call to_expression multiple times to ensure + // that these expressions are properly flushed to temporaries if needed. + expr += to_enclosed_expression(op0); + expr += '.'; + expr += index_to_swizzle(i); + expr += ' '; + expr += op; + expr += ' '; + expr += to_enclosed_expression(op1); + expr += '.'; + expr += index_to_swizzle(i); + + if (i + 1 < type.vecsize) + expr += ", "; + } + expr += ')'; + emit_op(result_type, result_id, expr, should_forward(op0) && should_forward(op1)); + + inherit_expression_dependencies(result_id, op0); + inherit_expression_dependencies(result_id, op1); +} + +SPIRType CompilerGLSL::binary_op_bitcast_helper(string &cast_op0, string &cast_op1, SPIRType::BaseType &input_type, + uint32_t op0, uint32_t op1, bool skip_cast_if_equal_type) +{ + auto &type0 = expression_type(op0); + auto &type1 = expression_type(op1); + + // We have to bitcast if our inputs are of different type, or if our types are not equal to expected inputs. + // For some functions like OpIEqual and INotEqual, we don't care if inputs are of different types than expected + // since equality test is exactly the same. + bool cast = (type0.basetype != type1.basetype) || (!skip_cast_if_equal_type && type0.basetype != input_type); + + // Create a fake type so we can bitcast to it. + // We only deal with regular arithmetic types here like int, uints and so on. + SPIRType expected_type; + expected_type.basetype = input_type; + expected_type.vecsize = type0.vecsize; + expected_type.columns = type0.columns; + expected_type.width = type0.width; + + if (cast) + { + cast_op0 = bitcast_glsl(expected_type, op0); + cast_op1 = bitcast_glsl(expected_type, op1); + } + else + { + // If we don't cast, our actual input type is that of the first (or second) argument. + cast_op0 = to_enclosed_expression(op0); + cast_op1 = to_enclosed_expression(op1); + input_type = type0.basetype; + } + + return expected_type; +} + +void CompilerGLSL::emit_binary_op_cast(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, + const char *op, SPIRType::BaseType input_type, bool skip_cast_if_equal_type) +{ + string cast_op0, cast_op1; + auto expected_type = binary_op_bitcast_helper(cast_op0, cast_op1, input_type, op0, op1, skip_cast_if_equal_type); + auto &out_type = get(result_type); + + // We might have casted away from the result type, so bitcast again. + // For example, arithmetic right shift with uint inputs. + // Special case boolean outputs since relational opcodes output booleans instead of int/uint. + string expr; + if (out_type.basetype != input_type && out_type.basetype != SPIRType::Boolean) + { + expected_type.basetype = input_type; + expr = bitcast_glsl_op(out_type, expected_type); + expr += '('; + expr += join(cast_op0, " ", op, " ", cast_op1); + expr += ')'; + } + else + expr += join(cast_op0, " ", op, " ", cast_op1); + + emit_op(result_type, result_id, expr, should_forward(op0) && should_forward(op1)); +} + +void CompilerGLSL::emit_unary_func_op(uint32_t result_type, uint32_t result_id, uint32_t op0, const char *op) +{ + bool forward = should_forward(op0); + emit_op(result_type, result_id, join(op, "(", to_expression(op0), ")"), forward); + inherit_expression_dependencies(result_id, op0); +} + +void CompilerGLSL::emit_binary_func_op(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, + const char *op) +{ + bool forward = should_forward(op0) && should_forward(op1); + emit_op(result_type, result_id, join(op, "(", to_expression(op0), ", ", to_expression(op1), ")"), forward); + inherit_expression_dependencies(result_id, op0); + inherit_expression_dependencies(result_id, op1); +} + +void CompilerGLSL::emit_binary_func_op_cast(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, + const char *op, SPIRType::BaseType input_type, bool skip_cast_if_equal_type) +{ + string cast_op0, cast_op1; + auto expected_type = binary_op_bitcast_helper(cast_op0, cast_op1, input_type, op0, op1, skip_cast_if_equal_type); + auto &out_type = get(result_type); + + // Special case boolean outputs since relational opcodes output booleans instead of int/uint. + string expr; + if (out_type.basetype != input_type && out_type.basetype != SPIRType::Boolean) + { + expected_type.basetype = input_type; + expr = bitcast_glsl_op(out_type, expected_type); + expr += '('; + expr += join(op, "(", cast_op0, ", ", cast_op1, ")"); + expr += ')'; + } + else + { + expr += join(op, "(", cast_op0, ", ", cast_op1, ")"); + } + + emit_op(result_type, result_id, expr, should_forward(op0) && should_forward(op1)); +} + +void CompilerGLSL::emit_trinary_func_op(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, + uint32_t op2, const char *op) +{ + bool forward = should_forward(op0) && should_forward(op1) && should_forward(op2); + emit_op(result_type, result_id, + join(op, "(", to_expression(op0), ", ", to_expression(op1), ", ", to_expression(op2), ")"), forward); + + inherit_expression_dependencies(result_id, op0); + inherit_expression_dependencies(result_id, op1); + inherit_expression_dependencies(result_id, op2); +} + +void CompilerGLSL::emit_quaternary_func_op(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, + uint32_t op2, uint32_t op3, const char *op) +{ + bool forward = should_forward(op0) && should_forward(op1) && should_forward(op2) && should_forward(op3); + emit_op(result_type, result_id, + join(op, "(", to_expression(op0), ", ", to_expression(op1), ", ", to_expression(op2), ", ", + to_expression(op3), ")"), + forward); + + inherit_expression_dependencies(result_id, op0); + inherit_expression_dependencies(result_id, op1); + inherit_expression_dependencies(result_id, op2); + inherit_expression_dependencies(result_id, op3); +} + +// EXT_shader_texture_lod only concerns fragment shaders so lod tex functions +// are not allowed in ES 2 vertex shaders. But SPIR-V only supports lod tex +// functions in vertex shaders so we revert those back to plain calls when +// the lod is a constant value of zero. +bool CompilerGLSL::check_explicit_lod_allowed(uint32_t lod) +{ + auto &execution = get_entry_point(); + bool allowed = !is_legacy_es() || execution.model == ExecutionModelFragment; + if (!allowed && lod != 0) + { + auto *lod_constant = maybe_get(lod); + if (!lod_constant || lod_constant->scalar_f32() != 0.0f) + { + SPIRV_CROSS_THROW("Explicit lod not allowed in legacy ES non-fragment shaders."); + } + } + return allowed; +} + +string CompilerGLSL::legacy_tex_op(const std::string &op, const SPIRType &imgtype, uint32_t lod) +{ + const char *type; + switch (imgtype.image.dim) + { + case spv::Dim1D: + type = (imgtype.image.arrayed && !options.es) ? "1DArray" : "1D"; + break; + case spv::Dim2D: + type = (imgtype.image.arrayed && !options.es) ? "2DArray" : "2D"; + break; + case spv::Dim3D: + type = "3D"; + break; + case spv::DimCube: + type = "Cube"; + break; + case spv::DimBuffer: + type = "Buffer"; + break; + case spv::DimSubpassData: + type = "2D"; + break; + default: + type = ""; + break; + } + + bool use_explicit_lod = check_explicit_lod_allowed(lod); + + if (op == "textureLod" || op == "textureProjLod") + { + if (is_legacy_es()) + { + if (use_explicit_lod) + require_extension("GL_EXT_shader_texture_lod"); + } + else if (is_legacy()) + require_extension("GL_ARB_shader_texture_lod"); + } + + if (op == "texture") + return join("texture", type); + else if (op == "textureLod") + { + if (use_explicit_lod) + return join("texture", type, is_legacy_es() ? "LodEXT" : "Lod"); + else + return join("texture", type); + } + else if (op == "textureProj") + return join("texture", type, "Proj"); + else if (op == "textureProjLod") + { + if (use_explicit_lod) + return join("texture", type, is_legacy_es() ? "ProjLodEXT" : "ProjLod"); + else + return join("texture", type); + } + else + { + SPIRV_CROSS_THROW(join("Unsupported legacy texture op: ", op)); + } +} + +bool CompilerGLSL::to_trivial_mix_op(const SPIRType &type, string &op, uint32_t left, uint32_t right, uint32_t lerp) +{ + auto *cleft = maybe_get(left); + auto *cright = maybe_get(right); + auto &lerptype = expression_type(lerp); + + // If our targets aren't constants, we cannot use construction. + if (!cleft || !cright) + return false; + + // If our targets are spec constants, we cannot use construction. + if (cleft->specialization || cright->specialization) + return false; + + // We can only use trivial construction if we have a scalar + // (should be possible to do it for vectors as well, but that is overkill for now). + if (lerptype.basetype != SPIRType::Boolean || lerptype.vecsize > 1) + return false; + + // If our bool selects between 0 and 1, we can cast from bool instead, making our trivial constructor. + bool ret = false; + switch (type.basetype) + { + case SPIRType::Int: + case SPIRType::UInt: + ret = cleft->scalar() == 0 && cright->scalar() == 1; + break; + + case SPIRType::Float: + ret = cleft->scalar_f32() == 0.0f && cright->scalar_f32() == 1.0f; + break; + + case SPIRType::Double: + ret = cleft->scalar_f64() == 0.0 && cright->scalar_f64() == 1.0; + break; + + case SPIRType::Int64: + case SPIRType::UInt64: + ret = cleft->scalar_u64() == 0 && cright->scalar_u64() == 1; + break; + + default: + break; + } + + if (ret) + op = type_to_glsl_constructor(type); + return ret; +} + +void CompilerGLSL::emit_mix_op(uint32_t result_type, uint32_t id, uint32_t left, uint32_t right, uint32_t lerp) +{ + auto &lerptype = expression_type(lerp); + auto &restype = get(result_type); + + string mix_op; + bool has_boolean_mix = backend.boolean_mix_support && + ((options.es && options.version >= 310) || (!options.es && options.version >= 450)); + bool trivial_mix = to_trivial_mix_op(restype, mix_op, left, right, lerp); + + // Cannot use boolean mix when the lerp argument is just one boolean, + // fall back to regular trinary statements. + if (lerptype.vecsize == 1) + has_boolean_mix = false; + + // If we can reduce the mix to a simple cast, do so. + // This helps for cases like int(bool), uint(bool) which is implemented with + // OpSelect bool 1 0. + if (trivial_mix) + { + emit_unary_func_op(result_type, id, lerp, mix_op.c_str()); + } + else if (!has_boolean_mix && lerptype.basetype == SPIRType::Boolean) + { + // Boolean mix not supported on desktop without extension. + // Was added in OpenGL 4.5 with ES 3.1 compat. + // + // Could use GL_EXT_shader_integer_mix on desktop at least, + // but Apple doesn't support it. :( + // Just implement it as ternary expressions. + string expr; + if (lerptype.vecsize == 1) + expr = join(to_enclosed_expression(lerp), " ? ", to_enclosed_expression(right), " : ", + to_enclosed_expression(left)); + else + { + auto swiz = [this](uint32_t expression, uint32_t i) { + return join(to_enclosed_expression(expression), ".", index_to_swizzle(i)); + }; + + expr = type_to_glsl_constructor(restype); + expr += "("; + for (uint32_t i = 0; i < restype.vecsize; i++) + { + expr += swiz(lerp, i); + expr += " ? "; + expr += swiz(right, i); + expr += " : "; + expr += swiz(left, i); + if (i + 1 < restype.vecsize) + expr += ", "; + } + expr += ")"; + } + + emit_op(result_type, id, expr, should_forward(left) && should_forward(right) && should_forward(lerp)); + } + else + emit_trinary_func_op(result_type, id, left, right, lerp, "mix"); +} + +string CompilerGLSL::to_combined_image_sampler(uint32_t image_id, uint32_t samp_id) +{ + auto &args = current_function->arguments; + + // For GLSL and ESSL targets, we must enumerate all possible combinations for sampler2D(texture2D, sampler) and redirect + // all possible combinations into new sampler2D uniforms. + auto *image = maybe_get_backing_variable(image_id); + auto *samp = maybe_get_backing_variable(samp_id); + if (image) + image_id = image->self; + if (samp) + samp_id = samp->self; + + auto image_itr = find_if(begin(args), end(args), + [image_id](const SPIRFunction::Parameter ¶m) { return param.id == image_id; }); + + auto sampler_itr = find_if(begin(args), end(args), + [samp_id](const SPIRFunction::Parameter ¶m) { return param.id == samp_id; }); + + if (image_itr != end(args) || sampler_itr != end(args)) + { + // If any parameter originates from a parameter, we will find it in our argument list. + bool global_image = image_itr == end(args); + bool global_sampler = sampler_itr == end(args); + uint32_t iid = global_image ? image_id : uint32_t(image_itr - begin(args)); + uint32_t sid = global_sampler ? samp_id : uint32_t(sampler_itr - begin(args)); + + auto &combined = current_function->combined_parameters; + auto itr = find_if(begin(combined), end(combined), [=](const SPIRFunction::CombinedImageSamplerParameter &p) { + return p.global_image == global_image && p.global_sampler == global_sampler && p.image_id == iid && + p.sampler_id == sid; + }); + + if (itr != end(combined)) + return to_expression(itr->id); + else + { + SPIRV_CROSS_THROW( + "Cannot find mapping for combined sampler parameter, was build_combined_image_samplers() used " + "before compile() was called?"); + } + } + else + { + // For global sampler2D, look directly at the global remapping table. + auto &mapping = combined_image_samplers; + auto itr = find_if(begin(mapping), end(mapping), [image_id, samp_id](const CombinedImageSampler &combined) { + return combined.image_id == image_id && combined.sampler_id == samp_id; + }); + + if (itr != end(combined_image_samplers)) + return to_expression(itr->combined_id); + else + { + SPIRV_CROSS_THROW("Cannot find mapping for combined sampler, was build_combined_image_samplers() used " + "before compile() was called?"); + } + } +} + +void CompilerGLSL::emit_sampled_image_op(uint32_t result_type, uint32_t result_id, uint32_t image_id, uint32_t samp_id) +{ + if (options.vulkan_semantics && combined_image_samplers.empty()) + { + emit_binary_func_op(result_type, result_id, image_id, samp_id, + type_to_glsl(get(result_type)).c_str()); + } + else + emit_op(result_type, result_id, to_combined_image_sampler(image_id, samp_id), true); +} + +void CompilerGLSL::emit_texture_op(const Instruction &i) +{ + auto ops = stream(i); + auto op = static_cast(i.op); + uint32_t length = i.length; + + if (i.offset + length > spirv.size()) + SPIRV_CROSS_THROW("Compiler::parse() opcode out of range."); + + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + uint32_t img = ops[2]; + uint32_t coord = ops[3]; + uint32_t dref = 0; + uint32_t comp = 0; + bool gather = false; + bool proj = false; + bool fetch = false; + const uint32_t *opt = nullptr; + + switch (op) + { + case OpImageSampleDrefImplicitLod: + case OpImageSampleDrefExplicitLod: + dref = ops[4]; + opt = &ops[5]; + length -= 5; + break; + + case OpImageSampleProjDrefImplicitLod: + case OpImageSampleProjDrefExplicitLod: + dref = ops[4]; + opt = &ops[5]; + length -= 5; + proj = true; + break; + + case OpImageDrefGather: + dref = ops[4]; + opt = &ops[5]; + length -= 5; + gather = true; + break; + + case OpImageGather: + comp = ops[4]; + opt = &ops[5]; + length -= 5; + gather = true; + break; + + case OpImageFetch: + case OpImageRead: // Reads == fetches in Metal (other langs will not get here) + opt = &ops[4]; + length -= 4; + fetch = true; + break; + + case OpImageSampleProjImplicitLod: + case OpImageSampleProjExplicitLod: + opt = &ops[4]; + length -= 4; + proj = true; + break; + + default: + opt = &ops[4]; + length -= 4; + break; + } + + // Bypass pointers because we need the real image struct + auto &type = expression_type(img); + auto &imgtype = get(type.self); + + uint32_t coord_components = 0; + switch (imgtype.image.dim) + { + case spv::Dim1D: + coord_components = 1; + break; + case spv::Dim2D: + coord_components = 2; + break; + case spv::Dim3D: + coord_components = 3; + break; + case spv::DimCube: + coord_components = 3; + break; + case spv::DimBuffer: + coord_components = 1; + break; + default: + coord_components = 2; + break; + } + + if (proj) + coord_components++; + if (imgtype.image.arrayed) + coord_components++; + + uint32_t bias = 0; + uint32_t lod = 0; + uint32_t grad_x = 0; + uint32_t grad_y = 0; + uint32_t coffset = 0; + uint32_t offset = 0; + uint32_t coffsets = 0; + uint32_t sample = 0; + uint32_t flags = 0; + + if (length) + { + flags = *opt++; + length--; + } + + auto test = [&](uint32_t &v, uint32_t flag) { + if (length && (flags & flag)) + { + v = *opt++; + length--; + } + }; + + test(bias, ImageOperandsBiasMask); + test(lod, ImageOperandsLodMask); + test(grad_x, ImageOperandsGradMask); + test(grad_y, ImageOperandsGradMask); + test(coffset, ImageOperandsConstOffsetMask); + test(offset, ImageOperandsOffsetMask); + test(coffsets, ImageOperandsConstOffsetsMask); + test(sample, ImageOperandsSampleMask); + + string expr; + bool forward = false; + expr += to_function_name(img, imgtype, !!fetch, !!gather, !!proj, !!coffsets, (!!coffset || !!offset), + (!!grad_x || !!grad_y), !!dref, lod); + expr += "("; + expr += to_function_args(img, imgtype, fetch, gather, proj, coord, coord_components, dref, grad_x, grad_y, lod, + coffset, offset, bias, comp, sample, &forward); + expr += ")"; + + emit_op(result_type, id, expr, forward); +} + +// Returns the function name for a texture sampling function for the specified image and sampling characteristics. +// For some subclasses, the function is a method on the specified image. +string CompilerGLSL::to_function_name(uint32_t, const SPIRType &imgtype, bool is_fetch, bool is_gather, bool is_proj, + bool has_array_offsets, bool has_offset, bool has_grad, bool, uint32_t lod) +{ + string fname; + + // textureLod on sampler2DArrayShadow and samplerCubeShadow does not exist in GLSL for some reason. + // To emulate this, we will have to use textureGrad with a constant gradient of 0. + // The workaround will assert that the LOD is in fact constant 0, or we cannot emit correct code. + // This happens for HLSL SampleCmpLevelZero on Texture2DArray and TextureCube. + bool workaround_lod_array_shadow_as_grad = false; + if (((imgtype.image.arrayed && imgtype.image.dim == Dim2D) || imgtype.image.dim == DimCube) && + imgtype.image.depth && lod) + { + auto *constant_lod = maybe_get(lod); + if (!constant_lod || constant_lod->scalar_f32() != 0.0f) + SPIRV_CROSS_THROW( + "textureLod on sampler2DArrayShadow is not constant 0.0. This cannot be expressed in GLSL."); + workaround_lod_array_shadow_as_grad = true; + } + + if (is_fetch) + fname += "texelFetch"; + else + { + fname += "texture"; + + if (is_gather) + fname += "Gather"; + if (has_array_offsets) + fname += "Offsets"; + if (is_proj) + fname += "Proj"; + if (has_grad || workaround_lod_array_shadow_as_grad) + fname += "Grad"; + if (!!lod && !workaround_lod_array_shadow_as_grad) + fname += "Lod"; + } + + if (has_offset) + fname += "Offset"; + + return is_legacy() ? legacy_tex_op(fname, imgtype, lod) : fname; +} + +// Returns the function args for a texture sampling function for the specified image and sampling characteristics. +string CompilerGLSL::to_function_args(uint32_t img, const SPIRType &imgtype, bool, bool, bool is_proj, uint32_t coord, + uint32_t coord_components, uint32_t dref, uint32_t grad_x, uint32_t grad_y, + uint32_t lod, uint32_t coffset, uint32_t offset, uint32_t bias, uint32_t comp, + uint32_t sample, bool *p_forward) +{ + string farg_str = to_expression(img); + + bool swizz_func = backend.swizzle_is_function; + auto swizzle = [swizz_func](uint32_t comps, uint32_t in_comps) -> const char * { + if (comps == in_comps) + return ""; + + switch (comps) + { + case 1: + return ".x"; + case 2: + return swizz_func ? ".xy()" : ".xy"; + case 3: + return swizz_func ? ".xyz()" : ".xyz"; + default: + return ""; + } + }; + + bool forward = should_forward(coord); + + // The IR can give us more components than we need, so chop them off as needed. + auto swizzle_expr = swizzle(coord_components, expression_type(coord).vecsize); + // Only enclose the UV expression if needed. + auto coord_expr = (*swizzle_expr == '\0') ? to_expression(coord) : (to_enclosed_expression(coord) + swizzle_expr); + + // texelFetch only takes int, not uint. + auto &coord_type = expression_type(coord); + if (coord_type.basetype == SPIRType::UInt) + { + auto expected_type = coord_type; + expected_type.basetype = SPIRType::Int; + coord_expr = bitcast_expression(expected_type, coord_type.basetype, coord_expr); + } + + // textureLod on sampler2DArrayShadow and samplerCubeShadow does not exist in GLSL for some reason. + // To emulate this, we will have to use textureGrad with a constant gradient of 0. + // The workaround will assert that the LOD is in fact constant 0, or we cannot emit correct code. + // This happens for HLSL SampleCmpLevelZero on Texture2DArray and TextureCube. + bool workaround_lod_array_shadow_as_grad = + ((imgtype.image.arrayed && imgtype.image.dim == Dim2D) || imgtype.image.dim == DimCube) && + imgtype.image.depth && lod; + + if (dref) + { + forward = forward && should_forward(dref); + + // SPIR-V splits dref and coordinate. + if (coord_components == 4) // GLSL also splits the arguments in two. + { + farg_str += ", "; + farg_str += to_expression(coord); + farg_str += ", "; + farg_str += to_expression(dref); + } + else if (is_proj) + { + // Have to reshuffle so we get vec4(coord, dref, proj), special case. + // Other shading languages splits up the arguments for coord and compare value like SPIR-V. + // The coordinate type for textureProj shadow is always vec4 even for sampler1DShadow. + farg_str += ", vec4("; + + if (imgtype.image.dim == Dim1D) + { + // Could reuse coord_expr, but we will mess up the temporary usage checking. + farg_str += to_enclosed_expression(coord) + ".x"; + farg_str += ", "; + farg_str += "0.0, "; + farg_str += to_expression(dref); + farg_str += ", "; + farg_str += to_enclosed_expression(coord) + ".y)"; + } + else if (imgtype.image.dim == Dim2D) + { + // Could reuse coord_expr, but we will mess up the temporary usage checking. + farg_str += to_enclosed_expression(coord) + (swizz_func ? ".xy()" : ".xy"); + farg_str += ", "; + farg_str += to_expression(dref); + farg_str += ", "; + farg_str += to_enclosed_expression(coord) + ".z)"; + } + else + SPIRV_CROSS_THROW("Invalid type for textureProj with shadow."); + } + else + { + // Create a composite which merges coord/dref into a single vector. + auto type = expression_type(coord); + type.vecsize = coord_components + 1; + farg_str += ", "; + farg_str += type_to_glsl_constructor(type); + farg_str += "("; + farg_str += coord_expr; + farg_str += ", "; + farg_str += to_expression(dref); + farg_str += ")"; + } + } + else + { + farg_str += ", "; + farg_str += coord_expr; + } + + if (grad_x || grad_y) + { + forward = forward && should_forward(grad_x); + forward = forward && should_forward(grad_y); + farg_str += ", "; + farg_str += to_expression(grad_x); + farg_str += ", "; + farg_str += to_expression(grad_y); + } + + if (lod) + { + if (workaround_lod_array_shadow_as_grad) + { + // Implement textureGrad() instead. LOD == 0.0 is implemented as gradient of 0.0. + // Implementing this as plain texture() is not safe on some implementations. + if (imgtype.image.dim == Dim2D) + farg_str += ", vec2(0.0), vec2(0.0)"; + else if (imgtype.image.dim == DimCube) + farg_str += ", vec3(0.0), vec3(0.0)"; + } + else + { + if (check_explicit_lod_allowed(lod)) + { + forward = forward && should_forward(lod); + farg_str += ", "; + farg_str += to_expression(lod); + } + } + } + + if (coffset) + { + forward = forward && should_forward(coffset); + farg_str += ", "; + farg_str += to_expression(coffset); + } + else if (offset) + { + forward = forward && should_forward(offset); + farg_str += ", "; + farg_str += to_expression(offset); + } + + if (bias) + { + forward = forward && should_forward(bias); + farg_str += ", "; + farg_str += to_expression(bias); + } + + if (comp) + { + forward = forward && should_forward(comp); + farg_str += ", "; + farg_str += to_expression(comp); + } + + if (sample) + { + farg_str += ", "; + farg_str += to_expression(sample); + } + + *p_forward = forward; + + return farg_str; +} + +void CompilerGLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop, const uint32_t *args, uint32_t) +{ + GLSLstd450 op = static_cast(eop); + + switch (op) + { + // FP fiddling + case GLSLstd450Round: + emit_unary_func_op(result_type, id, args[0], "round"); + break; + + case GLSLstd450RoundEven: + if ((options.es && options.version >= 300) || (!options.es && options.version >= 130)) + emit_unary_func_op(result_type, id, args[0], "roundEven"); + else + SPIRV_CROSS_THROW("roundEven supported only in ESSL 300 and GLSL 130 and up."); + break; + + case GLSLstd450Trunc: + emit_unary_func_op(result_type, id, args[0], "trunc"); + break; + case GLSLstd450SAbs: + case GLSLstd450FAbs: + emit_unary_func_op(result_type, id, args[0], "abs"); + break; + case GLSLstd450SSign: + case GLSLstd450FSign: + emit_unary_func_op(result_type, id, args[0], "sign"); + break; + case GLSLstd450Floor: + emit_unary_func_op(result_type, id, args[0], "floor"); + break; + case GLSLstd450Ceil: + emit_unary_func_op(result_type, id, args[0], "ceil"); + break; + case GLSLstd450Fract: + emit_unary_func_op(result_type, id, args[0], "fract"); + break; + case GLSLstd450Radians: + emit_unary_func_op(result_type, id, args[0], "radians"); + break; + case GLSLstd450Degrees: + emit_unary_func_op(result_type, id, args[0], "degrees"); + break; + case GLSLstd450Fma: + emit_trinary_func_op(result_type, id, args[0], args[1], args[2], "fma"); + break; + case GLSLstd450Modf: + register_call_out_argument(args[1]); + forced_temporaries.insert(id); + emit_binary_func_op(result_type, id, args[0], args[1], "modf"); + break; + + case GLSLstd450ModfStruct: + { + forced_temporaries.insert(id); + auto &type = get(result_type); + auto flags = meta[id].decoration.decoration_flags; + statement(flags_to_precision_qualifiers_glsl(type, flags), variable_decl(type, to_name(id)), ";"); + set(id, to_name(id), result_type, true); + + statement(to_expression(id), ".", to_member_name(type, 0), " = ", "modf(", to_expression(args[0]), ", ", + to_expression(id), ".", to_member_name(type, 1), ");"); + break; + } + + // Minmax + case GLSLstd450FMin: + case GLSLstd450UMin: + case GLSLstd450SMin: + emit_binary_func_op(result_type, id, args[0], args[1], "min"); + break; + case GLSLstd450FMax: + case GLSLstd450UMax: + case GLSLstd450SMax: + emit_binary_func_op(result_type, id, args[0], args[1], "max"); + break; + case GLSLstd450FClamp: + case GLSLstd450UClamp: + case GLSLstd450SClamp: + emit_trinary_func_op(result_type, id, args[0], args[1], args[2], "clamp"); + break; + + // Trig + case GLSLstd450Sin: + emit_unary_func_op(result_type, id, args[0], "sin"); + break; + case GLSLstd450Cos: + emit_unary_func_op(result_type, id, args[0], "cos"); + break; + case GLSLstd450Tan: + emit_unary_func_op(result_type, id, args[0], "tan"); + break; + case GLSLstd450Asin: + emit_unary_func_op(result_type, id, args[0], "asin"); + break; + case GLSLstd450Acos: + emit_unary_func_op(result_type, id, args[0], "acos"); + break; + case GLSLstd450Atan: + emit_unary_func_op(result_type, id, args[0], "atan"); + break; + case GLSLstd450Sinh: + emit_unary_func_op(result_type, id, args[0], "sinh"); + break; + case GLSLstd450Cosh: + emit_unary_func_op(result_type, id, args[0], "cosh"); + break; + case GLSLstd450Tanh: + emit_unary_func_op(result_type, id, args[0], "tanh"); + break; + case GLSLstd450Asinh: + emit_unary_func_op(result_type, id, args[0], "asinh"); + break; + case GLSLstd450Acosh: + emit_unary_func_op(result_type, id, args[0], "acosh"); + break; + case GLSLstd450Atanh: + emit_unary_func_op(result_type, id, args[0], "atanh"); + break; + case GLSLstd450Atan2: + emit_binary_func_op(result_type, id, args[0], args[1], "atan"); + break; + + // Exponentials + case GLSLstd450Pow: + emit_binary_func_op(result_type, id, args[0], args[1], "pow"); + break; + case GLSLstd450Exp: + emit_unary_func_op(result_type, id, args[0], "exp"); + break; + case GLSLstd450Log: + emit_unary_func_op(result_type, id, args[0], "log"); + break; + case GLSLstd450Exp2: + emit_unary_func_op(result_type, id, args[0], "exp2"); + break; + case GLSLstd450Log2: + emit_unary_func_op(result_type, id, args[0], "log2"); + break; + case GLSLstd450Sqrt: + emit_unary_func_op(result_type, id, args[0], "sqrt"); + break; + case GLSLstd450InverseSqrt: + emit_unary_func_op(result_type, id, args[0], "inversesqrt"); + break; + + // Matrix math + case GLSLstd450Determinant: + emit_unary_func_op(result_type, id, args[0], "determinant"); + break; + case GLSLstd450MatrixInverse: + emit_unary_func_op(result_type, id, args[0], "inverse"); + break; + + // Lerping + case GLSLstd450FMix: + case GLSLstd450IMix: + { + emit_mix_op(result_type, id, args[0], args[1], args[2]); + break; + } + case GLSLstd450Step: + emit_binary_func_op(result_type, id, args[0], args[1], "step"); + break; + case GLSLstd450SmoothStep: + emit_trinary_func_op(result_type, id, args[0], args[1], args[2], "smoothstep"); + break; + + // Packing + case GLSLstd450Frexp: + register_call_out_argument(args[1]); + forced_temporaries.insert(id); + emit_binary_func_op(result_type, id, args[0], args[1], "frexp"); + break; + + case GLSLstd450FrexpStruct: + { + forced_temporaries.insert(id); + auto &type = get(result_type); + auto flags = meta[id].decoration.decoration_flags; + statement(flags_to_precision_qualifiers_glsl(type, flags), variable_decl(type, to_name(id)), ";"); + set(id, to_name(id), result_type, true); + + statement(to_expression(id), ".", to_member_name(type, 0), " = ", "frexp(", to_expression(args[0]), ", ", + to_expression(id), ".", to_member_name(type, 1), ");"); + break; + } + + case GLSLstd450Ldexp: + emit_binary_func_op(result_type, id, args[0], args[1], "ldexp"); + break; + case GLSLstd450PackSnorm4x8: + emit_unary_func_op(result_type, id, args[0], "packSnorm4x8"); + break; + case GLSLstd450PackUnorm4x8: + emit_unary_func_op(result_type, id, args[0], "packUnorm4x8"); + break; + case GLSLstd450PackSnorm2x16: + emit_unary_func_op(result_type, id, args[0], "packSnorm2x16"); + break; + case GLSLstd450PackUnorm2x16: + emit_unary_func_op(result_type, id, args[0], "packUnorm2x16"); + break; + case GLSLstd450PackHalf2x16: + emit_unary_func_op(result_type, id, args[0], "packHalf2x16"); + break; + case GLSLstd450UnpackSnorm4x8: + emit_unary_func_op(result_type, id, args[0], "unpackSnorm4x8"); + break; + case GLSLstd450UnpackUnorm4x8: + emit_unary_func_op(result_type, id, args[0], "unpackUnorm4x8"); + break; + case GLSLstd450UnpackSnorm2x16: + emit_unary_func_op(result_type, id, args[0], "unpackSnorm2x16"); + break; + case GLSLstd450UnpackUnorm2x16: + emit_unary_func_op(result_type, id, args[0], "unpackUnorm2x16"); + break; + case GLSLstd450UnpackHalf2x16: + emit_unary_func_op(result_type, id, args[0], "unpackHalf2x16"); + break; + + case GLSLstd450PackDouble2x32: + emit_unary_func_op(result_type, id, args[0], "packDouble2x32"); + break; + case GLSLstd450UnpackDouble2x32: + emit_unary_func_op(result_type, id, args[0], "unpackDouble2x32"); + break; + + // Vector math + case GLSLstd450Length: + emit_unary_func_op(result_type, id, args[0], "length"); + break; + case GLSLstd450Distance: + emit_binary_func_op(result_type, id, args[0], args[1], "distance"); + break; + case GLSLstd450Cross: + emit_binary_func_op(result_type, id, args[0], args[1], "cross"); + break; + case GLSLstd450Normalize: + emit_unary_func_op(result_type, id, args[0], "normalize"); + break; + case GLSLstd450FaceForward: + emit_trinary_func_op(result_type, id, args[0], args[1], args[2], "faceforward"); + break; + case GLSLstd450Reflect: + emit_binary_func_op(result_type, id, args[0], args[1], "reflect"); + break; + case GLSLstd450Refract: + emit_trinary_func_op(result_type, id, args[0], args[1], args[2], "refract"); + break; + + // Bit-fiddling + case GLSLstd450FindILsb: + emit_unary_func_op(result_type, id, args[0], "findLSB"); + break; + case GLSLstd450FindSMsb: + case GLSLstd450FindUMsb: + emit_unary_func_op(result_type, id, args[0], "findMSB"); + break; + + // Multisampled varying + case GLSLstd450InterpolateAtCentroid: + emit_unary_func_op(result_type, id, args[0], "interpolateAtCentroid"); + break; + case GLSLstd450InterpolateAtSample: + emit_binary_func_op(result_type, id, args[0], args[1], "interpolateAtSample"); + break; + case GLSLstd450InterpolateAtOffset: + emit_binary_func_op(result_type, id, args[0], args[1], "interpolateAtOffset"); + break; + + default: + statement("// unimplemented GLSL op ", eop); + break; + } +} + +void CompilerGLSL::emit_spv_amd_shader_ballot_op(uint32_t result_type, uint32_t id, uint32_t eop, const uint32_t *args, + uint32_t) +{ + require_extension("GL_AMD_shader_ballot"); + + enum AMDShaderBallot + { + SwizzleInvocationsAMD = 1, + SwizzleInvocationsMaskedAMD = 2, + WriteInvocationAMD = 3, + MbcntAMD = 4 + }; + + auto op = static_cast(eop); + + switch (op) + { + case SwizzleInvocationsAMD: + emit_binary_func_op(result_type, id, args[0], args[1], "swizzleInvocationsAMD"); + break; + + case SwizzleInvocationsMaskedAMD: + emit_binary_func_op(result_type, id, args[0], args[1], "swizzleInvocationsMaskedAMD"); + break; + + case WriteInvocationAMD: + emit_trinary_func_op(result_type, id, args[0], args[1], args[2], "writeInvocationAMD"); + break; + + case MbcntAMD: + emit_unary_func_op(result_type, id, args[0], "mbcntAMD"); + break; + + default: + statement("// unimplemented SPV AMD shader ballot op ", eop); + break; + } +} + +void CompilerGLSL::emit_spv_amd_shader_explicit_vertex_parameter_op(uint32_t result_type, uint32_t id, uint32_t eop, + const uint32_t *args, uint32_t) +{ + require_extension("GL_AMD_shader_explicit_vertex_parameter"); + + enum AMDShaderExplicitVertexParameter + { + InterpolateAtVertexAMD = 1 + }; + + auto op = static_cast(eop); + + switch (op) + { + case InterpolateAtVertexAMD: + emit_binary_func_op(result_type, id, args[0], args[1], "interpolateAtVertexAMD"); + break; + + default: + statement("// unimplemented SPV AMD shader explicit vertex parameter op ", eop); + break; + } +} + +void CompilerGLSL::emit_spv_amd_shader_trinary_minmax_op(uint32_t result_type, uint32_t id, uint32_t eop, + const uint32_t *args, uint32_t) +{ + require_extension("GL_AMD_shader_trinary_minmax"); + + enum AMDShaderTrinaryMinMax + { + FMin3AMD = 1, + UMin3AMD = 2, + SMin3AMD = 3, + FMax3AMD = 4, + UMax3AMD = 5, + SMax3AMD = 6, + FMid3AMD = 7, + UMid3AMD = 8, + SMid3AMD = 9 + }; + + auto op = static_cast(eop); + + switch (op) + { + case FMin3AMD: + case UMin3AMD: + case SMin3AMD: + emit_trinary_func_op(result_type, id, args[0], args[1], args[2], "min3"); + break; + + case FMax3AMD: + case UMax3AMD: + case SMax3AMD: + emit_trinary_func_op(result_type, id, args[0], args[1], args[2], "max3"); + break; + + case FMid3AMD: + case UMid3AMD: + case SMid3AMD: + emit_trinary_func_op(result_type, id, args[0], args[1], args[2], "mid3"); + break; + + default: + statement("// unimplemented SPV AMD shader trinary minmax op ", eop); + break; + } +} + +void CompilerGLSL::emit_spv_amd_gcn_shader_op(uint32_t result_type, uint32_t id, uint32_t eop, const uint32_t *args, + uint32_t) +{ + require_extension("GL_AMD_gcn_shader"); + + enum AMDGCNShader + { + CubeFaceIndexAMD = 1, + CubeFaceCoordAMD = 2, + TimeAMD = 3 + }; + + auto op = static_cast(eop); + + switch (op) + { + case CubeFaceIndexAMD: + emit_unary_func_op(result_type, id, args[0], "cubeFaceIndexAMD"); + break; + case CubeFaceCoordAMD: + emit_unary_func_op(result_type, id, args[0], "cubeFaceCoordAMD"); + break; + case TimeAMD: + { + string expr = "timeAMD()"; + emit_op(result_type, id, expr, true); + break; + } + + default: + statement("// unimplemented SPV AMD gcn shader op ", eop); + break; + } +} + +string CompilerGLSL::bitcast_glsl_op(const SPIRType &out_type, const SPIRType &in_type) +{ + if (out_type.basetype == SPIRType::UInt && in_type.basetype == SPIRType::Int) + return type_to_glsl(out_type); + else if (out_type.basetype == SPIRType::UInt64 && in_type.basetype == SPIRType::Int64) + return type_to_glsl(out_type); + else if (out_type.basetype == SPIRType::UInt && in_type.basetype == SPIRType::Float) + return "floatBitsToUint"; + else if (out_type.basetype == SPIRType::Int && in_type.basetype == SPIRType::UInt) + return type_to_glsl(out_type); + else if (out_type.basetype == SPIRType::Int64 && in_type.basetype == SPIRType::UInt64) + return type_to_glsl(out_type); + else if (out_type.basetype == SPIRType::Int && in_type.basetype == SPIRType::Float) + return "floatBitsToInt"; + else if (out_type.basetype == SPIRType::Float && in_type.basetype == SPIRType::UInt) + return "uintBitsToFloat"; + else if (out_type.basetype == SPIRType::Float && in_type.basetype == SPIRType::Int) + return "intBitsToFloat"; + else if (out_type.basetype == SPIRType::Int64 && in_type.basetype == SPIRType::Double) + return "doubleBitsToInt64"; + else if (out_type.basetype == SPIRType::UInt64 && in_type.basetype == SPIRType::Double) + return "doubleBitsToUint64"; + else if (out_type.basetype == SPIRType::Double && in_type.basetype == SPIRType::Int64) + return "int64BitsToDouble"; + else if (out_type.basetype == SPIRType::Double && in_type.basetype == SPIRType::UInt64) + return "uint64BitsToDouble"; + else if (out_type.basetype == SPIRType::UInt64 && in_type.basetype == SPIRType::UInt && in_type.vecsize == 2) + return "packUint2x32"; + else + return ""; +} + +string CompilerGLSL::bitcast_glsl(const SPIRType &result_type, uint32_t argument) +{ + auto op = bitcast_glsl_op(result_type, expression_type(argument)); + if (op.empty()) + return to_enclosed_expression(argument); + else + return join(op, "(", to_expression(argument), ")"); +} + +std::string CompilerGLSL::bitcast_expression(SPIRType::BaseType target_type, uint32_t arg) +{ + auto expr = to_expression(arg); + auto &src_type = expression_type(arg); + if (src_type.basetype != target_type) + { + auto target = src_type; + target.basetype = target_type; + expr = join(bitcast_glsl_op(target, src_type), "(", expr, ")"); + } + + return expr; +} + +std::string CompilerGLSL::bitcast_expression(const SPIRType &target_type, SPIRType::BaseType expr_type, + const std::string &expr) +{ + if (target_type.basetype == expr_type) + return expr; + + auto src_type = target_type; + src_type.basetype = expr_type; + return join(bitcast_glsl_op(target_type, src_type), "(", expr, ")"); +} + +string CompilerGLSL::builtin_to_glsl(BuiltIn builtin, StorageClass storage) +{ + switch (builtin) + { + case BuiltInPosition: + return "gl_Position"; + case BuiltInPointSize: + return "gl_PointSize"; + case BuiltInClipDistance: + return "gl_ClipDistance"; + case BuiltInCullDistance: + return "gl_CullDistance"; + case BuiltInVertexId: + if (options.vulkan_semantics) + SPIRV_CROSS_THROW( + "Cannot implement gl_VertexID in Vulkan GLSL. This shader was created with GL semantics."); + return "gl_VertexID"; + case BuiltInInstanceId: + if (options.vulkan_semantics) + SPIRV_CROSS_THROW( + "Cannot implement gl_InstanceID in Vulkan GLSL. This shader was created with GL semantics."); + return "gl_InstanceID"; + case BuiltInVertexIndex: + if (options.vulkan_semantics) + return "gl_VertexIndex"; + else + return "gl_VertexID"; // gl_VertexID already has the base offset applied. + case BuiltInInstanceIndex: + if (options.vulkan_semantics) + return "gl_InstanceIndex"; + else + return "(gl_InstanceID + SPIRV_Cross_BaseInstance)"; // ... but not gl_InstanceID. + case BuiltInPrimitiveId: + return "gl_PrimitiveID"; + case BuiltInInvocationId: + return "gl_InvocationID"; + case BuiltInLayer: + return "gl_Layer"; + case BuiltInViewportIndex: + return "gl_ViewportIndex"; + case BuiltInTessLevelOuter: + return "gl_TessLevelOuter"; + case BuiltInTessLevelInner: + return "gl_TessLevelInner"; + case BuiltInTessCoord: + return "gl_TessCoord"; + case BuiltInFragCoord: + return "gl_FragCoord"; + case BuiltInPointCoord: + return "gl_PointCoord"; + case BuiltInFrontFacing: + return "gl_FrontFacing"; + case BuiltInFragDepth: + return "gl_FragDepth"; + case BuiltInNumWorkgroups: + return "gl_NumWorkGroups"; + case BuiltInWorkgroupSize: + return "gl_WorkGroupSize"; + case BuiltInWorkgroupId: + return "gl_WorkGroupID"; + case BuiltInLocalInvocationId: + return "gl_LocalInvocationID"; + case BuiltInGlobalInvocationId: + return "gl_GlobalInvocationID"; + case BuiltInLocalInvocationIndex: + return "gl_LocalInvocationIndex"; + + case BuiltInSampleId: + if (options.es && options.version < 320) + require_extension("GL_OES_sample_variables"); + if (!options.es && options.version < 400) + SPIRV_CROSS_THROW("gl_SampleID not supported before GLSL 400."); + return "gl_SampleID"; + + case BuiltInSampleMask: + if (options.es && options.version < 320) + require_extension("GL_OES_sample_variables"); + if (!options.es && options.version < 400) + SPIRV_CROSS_THROW("gl_SampleMask/gl_SampleMaskIn not supported before GLSL 400."); + + if (storage == StorageClassInput) + return "gl_SampleMaskIn"; + else + return "gl_SampleMask"; + + case BuiltInSamplePosition: + if (options.es && options.version < 320) + require_extension("GL_OES_sample_variables"); + if (!options.es && options.version < 400) + SPIRV_CROSS_THROW("gl_SamplePosition not supported before GLSL 400."); + return "gl_SamplePosition"; + + case BuiltInViewIndex: + if (options.vulkan_semantics) + { + require_extension("GL_EXT_multiview"); + return "gl_ViewIndex"; + } + else + { + require_extension("GL_OVR_multiview2"); + return "gl_ViewID_OVR"; + } + + default: + return join("gl_BuiltIn_", convert_to_string(builtin)); + } +} + +const char *CompilerGLSL::index_to_swizzle(uint32_t index) +{ + switch (index) + { + case 0: + return "x"; + case 1: + return "y"; + case 2: + return "z"; + case 3: + return "w"; + default: + SPIRV_CROSS_THROW("Swizzle index out of range"); + } +} + +string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indices, uint32_t count, + bool index_is_literal, bool chain_only, bool *need_transpose, + bool *result_is_packed) +{ + string expr; + if (!chain_only) + expr = to_enclosed_expression(base); + + uint32_t type_id = expression_type_id(base); + const auto *type = &get(type_id); + + // Start traversing type hierarchy at the proper non-pointer types, + // but keep type_id referencing the original pointer for use below. + while (type->pointer) + { + assert(type->parent_type); + type = &get(type->parent_type); + } + + bool access_chain_is_arrayed = false; + bool row_major_matrix_needs_conversion = is_non_native_row_major_matrix(base); + bool vector_is_packed = false; + bool pending_array_enclose = false; + bool dimension_flatten = false; + + for (uint32_t i = 0; i < count; i++) + { + uint32_t index = indices[i]; + + // Arrays + if (!type->array.empty()) + { + // If we are flattening multidimensional arrays, only create opening bracket on first + // array index. + if (options.flatten_multidimensional_arrays && !pending_array_enclose) + { + dimension_flatten = type->array.size() > 1; + pending_array_enclose = dimension_flatten; + if (pending_array_enclose) + expr += "["; + } + + assert(type->parent_type); + + const auto append_index = [&]() { + expr += "["; + if (index_is_literal) + expr += convert_to_string(index); + else + expr += to_expression(index); + expr += "]"; + }; + + auto *var = maybe_get(base); + if (backend.force_gl_in_out_block && i == 0 && var && is_builtin_variable(*var) && + !has_decoration(type->self, DecorationBlock)) + { + // This deals with scenarios for tesc/geom where arrays of gl_Position[] are declared. + // Normally, these variables live in blocks when compiled from GLSL, + // but HLSL seems to just emit straight arrays here. + // We must pretend this access goes through gl_in/gl_out arrays + // to be able to access certain builtins as arrays. + auto builtin = meta[base].decoration.builtin_type; + switch (builtin) + { + // case BuiltInCullDistance: // These are already arrays, need to figure out rules for these in tess/geom. + // case BuiltInClipDistance: + case BuiltInPosition: + case BuiltInPointSize: + if (var->storage == StorageClassInput) + expr = join("gl_in[", to_expression(index), "].", expr); + else if (var->storage == StorageClassOutput) + expr = join("gl_out[", to_expression(index), "].", expr); + else + append_index(); + break; + + default: + append_index(); + break; + } + } + else if (options.flatten_multidimensional_arrays && dimension_flatten) + { + // If we are flattening multidimensional arrays, do manual stride computation. + auto &parent_type = get(type->parent_type); + + if (index_is_literal) + expr += convert_to_string(index); + else + expr += to_enclosed_expression(index); + + for (auto j = uint32_t(parent_type.array.size()); j; j--) + { + expr += " * "; + expr += enclose_expression(to_array_size(parent_type, j - 1)); + } + + if (parent_type.array.empty()) + pending_array_enclose = false; + else + expr += " + "; + + if (!pending_array_enclose) + expr += "]"; + } + else + { + append_index(); + } + + type_id = type->parent_type; + type = &get(type_id); + + access_chain_is_arrayed = true; + } + // For structs, the index refers to a constant, which indexes into the members. + // We also check if this member is a builtin, since we then replace the entire expression with the builtin one. + else if (type->basetype == SPIRType::Struct) + { + if (!index_is_literal) + index = get(index).scalar(); + + if (index >= type->member_types.size()) + SPIRV_CROSS_THROW("Member index is out of bounds!"); + + BuiltIn builtin; + if (is_member_builtin(*type, index, &builtin)) + { + // FIXME: We rely here on OpName on gl_in/gl_out to make this work properly. + // To make this properly work by omitting all OpName opcodes, + // we need to infer gl_in or gl_out based on the builtin, and stage. + if (access_chain_is_arrayed) + { + expr += "."; + expr += builtin_to_glsl(builtin, type->storage); + } + else + expr = builtin_to_glsl(builtin, type->storage); + } + else + { + // If the member has a qualified name, use it as the entire chain + string qual_mbr_name = get_member_qualified_name(type_id, index); + if (!qual_mbr_name.empty()) + expr = qual_mbr_name; + else + { + expr += "."; + expr += to_member_name(*type, index); + } + } + + vector_is_packed = member_is_packed_type(*type, index); + row_major_matrix_needs_conversion = member_is_non_native_row_major_matrix(*type, index); + type = &get(type->member_types[index]); + } + // Matrix -> Vector + else if (type->columns > 1) + { + if (row_major_matrix_needs_conversion) + { + expr = convert_row_major_matrix(expr, *type); + row_major_matrix_needs_conversion = false; + } + + expr += "["; + if (index_is_literal) + expr += convert_to_string(index); + else + expr += to_expression(index); + expr += "]"; + + type_id = type->parent_type; + type = &get(type_id); + } + // Vector -> Scalar + else if (type->vecsize > 1) + { + if (vector_is_packed) + { + expr = unpack_expression_type(expr, *type); + vector_is_packed = false; + } + + if (index_is_literal) + { + expr += "."; + expr += index_to_swizzle(index); + } + else if (ids[index].get_type() == TypeConstant) + { + auto &c = get(index); + expr += "."; + expr += index_to_swizzle(c.scalar()); + } + else + { + expr += "["; + expr += to_expression(index); + expr += "]"; + } + + type_id = type->parent_type; + type = &get(type_id); + } + else + SPIRV_CROSS_THROW("Cannot subdivide a scalar value!"); + } + + if (pending_array_enclose) + { + SPIRV_CROSS_THROW("Flattening of multidimensional arrays were enabled, " + "but the access chain was terminated in the middle of a multidimensional array. " + "This is not supported."); + } + + if (need_transpose) + *need_transpose = row_major_matrix_needs_conversion; + + if (result_is_packed) + *result_is_packed = vector_is_packed; + + return expr; +} + +string CompilerGLSL::to_flattened_struct_member(const SPIRVariable &var, uint32_t index) +{ + auto &type = get(var.basetype); + return sanitize_underscores(join(to_name(var.self), "_", to_member_name(type, index))); +} + +string CompilerGLSL::access_chain(uint32_t base, const uint32_t *indices, uint32_t count, const SPIRType &target_type, + bool *out_need_transpose, bool *result_is_packed) +{ + if (flattened_buffer_blocks.count(base)) + { + uint32_t matrix_stride = 0; + bool need_transpose = false; + flattened_access_chain_offset(expression_type(base), indices, count, 0, 16, &need_transpose, &matrix_stride); + + if (out_need_transpose) + *out_need_transpose = target_type.columns > 1 && need_transpose; + if (result_is_packed) + *result_is_packed = false; + + return flattened_access_chain(base, indices, count, target_type, 0, matrix_stride, need_transpose); + } + else if (flattened_structs.count(base) && count > 0) + { + auto chain = access_chain_internal(base, indices, count, false, true).substr(1); + if (out_need_transpose) + *out_need_transpose = false; + if (result_is_packed) + *result_is_packed = false; + return sanitize_underscores(join(to_name(base), "_", chain)); + } + else + { + return access_chain_internal(base, indices, count, false, false, out_need_transpose, result_is_packed); + } +} + +string CompilerGLSL::load_flattened_struct(SPIRVariable &var) +{ + auto expr = type_to_glsl_constructor(get(var.basetype)); + expr += '('; + + auto &type = get(var.basetype); + for (uint32_t i = 0; i < uint32_t(type.member_types.size()); i++) + { + if (i) + expr += ", "; + + // Flatten the varyings. + // Apply name transformation for flattened I/O blocks. + expr += to_flattened_struct_member(var, i); + } + expr += ')'; + return expr; +} + +void CompilerGLSL::store_flattened_struct(SPIRVariable &var, uint32_t value) +{ + // We're trying to store a structure which has been flattened. + // Need to copy members one by one. + auto rhs = to_expression(value); + + // Store result locally. + // Since we're declaring a variable potentially multiple times here, + // store the variable in an isolated scope. + begin_scope(); + statement(variable_decl_function_local(var), " = ", rhs, ";"); + + auto &type = get(var.basetype); + for (uint32_t i = 0; i < uint32_t(type.member_types.size()); i++) + { + // Flatten the varyings. + // Apply name transformation for flattened I/O blocks. + + auto lhs = sanitize_underscores(join(to_name(var.self), "_", to_member_name(type, i))); + rhs = join(to_name(var.self), ".", to_member_name(type, i)); + statement(lhs, " = ", rhs, ";"); + } + end_scope(); +} + +std::string CompilerGLSL::flattened_access_chain(uint32_t base, const uint32_t *indices, uint32_t count, + const SPIRType &target_type, uint32_t offset, uint32_t matrix_stride, + bool need_transpose) +{ + if (!target_type.array.empty()) + SPIRV_CROSS_THROW("Access chains that result in an array can not be flattened"); + else if (target_type.basetype == SPIRType::Struct) + return flattened_access_chain_struct(base, indices, count, target_type, offset); + else if (target_type.columns > 1) + return flattened_access_chain_matrix(base, indices, count, target_type, offset, matrix_stride, need_transpose); + else + return flattened_access_chain_vector(base, indices, count, target_type, offset, matrix_stride, need_transpose); +} + +std::string CompilerGLSL::flattened_access_chain_struct(uint32_t base, const uint32_t *indices, uint32_t count, + const SPIRType &target_type, uint32_t offset) +{ + std::string expr; + + expr += type_to_glsl_constructor(target_type); + expr += "("; + + for (uint32_t i = 0; i < uint32_t(target_type.member_types.size()); ++i) + { + if (i != 0) + expr += ", "; + + const SPIRType &member_type = get(target_type.member_types[i]); + uint32_t member_offset = type_struct_member_offset(target_type, i); + + // The access chain terminates at the struct, so we need to find matrix strides and row-major information + // ahead of time. + bool need_transpose = false; + uint32_t matrix_stride = 0; + if (member_type.columns > 1) + { + need_transpose = (combined_decoration_for_member(target_type, i) & (1ull << DecorationRowMajor)) != 0; + matrix_stride = type_struct_member_matrix_stride(target_type, i); + } + + auto tmp = flattened_access_chain(base, indices, count, member_type, offset + member_offset, matrix_stride, + need_transpose); + + // Cannot forward transpositions, so resolve them here. + if (need_transpose) + expr += convert_row_major_matrix(tmp, member_type); + else + expr += tmp; + } + + expr += ")"; + + return expr; +} + +std::string CompilerGLSL::flattened_access_chain_matrix(uint32_t base, const uint32_t *indices, uint32_t count, + const SPIRType &target_type, uint32_t offset, + uint32_t matrix_stride, bool need_transpose) +{ + assert(matrix_stride); + SPIRType tmp_type = target_type; + if (need_transpose) + swap(tmp_type.vecsize, tmp_type.columns); + + std::string expr; + + expr += type_to_glsl_constructor(tmp_type); + expr += "("; + + for (uint32_t i = 0; i < tmp_type.columns; i++) + { + if (i != 0) + expr += ", "; + + expr += flattened_access_chain_vector(base, indices, count, tmp_type, offset + i * matrix_stride, matrix_stride, + /* need_transpose= */ false); + } + + expr += ")"; + + return expr; +} + +std::string CompilerGLSL::flattened_access_chain_vector(uint32_t base, const uint32_t *indices, uint32_t count, + const SPIRType &target_type, uint32_t offset, + uint32_t matrix_stride, bool need_transpose) +{ + auto result = flattened_access_chain_offset(expression_type(base), indices, count, offset, 16); + + auto buffer_name = to_name(expression_type(base).self); + + if (need_transpose) + { + std::string expr; + + if (target_type.vecsize > 1) + { + expr += type_to_glsl_constructor(target_type); + expr += "("; + } + + for (uint32_t i = 0; i < target_type.vecsize; ++i) + { + if (i != 0) + expr += ", "; + + uint32_t component_offset = result.second + i * matrix_stride; + + assert(component_offset % (target_type.width / 8) == 0); + uint32_t index = component_offset / (target_type.width / 8); + + expr += buffer_name; + expr += "["; + expr += result.first; // this is a series of N1 * k1 + N2 * k2 + ... that is either empty or ends with a + + expr += convert_to_string(index / 4); + expr += "]"; + + expr += vector_swizzle(1, index % 4); + } + + if (target_type.vecsize > 1) + { + expr += ")"; + } + + return expr; + } + else + { + assert(result.second % (target_type.width / 8) == 0); + uint32_t index = result.second / (target_type.width / 8); + + std::string expr; + + expr += buffer_name; + expr += "["; + expr += result.first; // this is a series of N1 * k1 + N2 * k2 + ... that is either empty or ends with a + + expr += convert_to_string(index / 4); + expr += "]"; + + expr += vector_swizzle(target_type.vecsize, index % 4); + + return expr; + } +} + +std::pair CompilerGLSL::flattened_access_chain_offset(const SPIRType &basetype, + const uint32_t *indices, uint32_t count, + uint32_t offset, uint32_t word_stride, + bool *need_transpose, + uint32_t *out_matrix_stride) +{ + const auto *type = &basetype; + + // Start traversing type hierarchy at the proper non-pointer types. + while (type->pointer) + { + assert(type->parent_type); + type = &get(type->parent_type); + } + + // This holds the type of the current pointer which we are traversing through. + // We always start out from a struct type which is the block. + // This is primarily used to reflect the array strides and matrix strides later. + // For the first access chain index, type_id won't be needed, so just keep it as 0, it will be set + // accordingly as members of structs are accessed. + assert(type->basetype == SPIRType::Struct); + uint32_t type_id = 0; + + std::string expr; + + // Inherit matrix information in case we are access chaining a vector which might have come from a row major layout. + bool row_major_matrix_needs_conversion = need_transpose ? *need_transpose : false; + uint32_t matrix_stride = out_matrix_stride ? *out_matrix_stride : 0; + + for (uint32_t i = 0; i < count; i++) + { + uint32_t index = indices[i]; + + // Arrays + if (!type->array.empty()) + { + // Here, the type_id will be a type ID for the array type itself. + uint32_t array_stride = get_decoration(type_id, DecorationArrayStride); + if (!array_stride) + SPIRV_CROSS_THROW("SPIR-V does not define ArrayStride for buffer block."); + + auto *constant = maybe_get(index); + if (constant) + { + // Constant array access. + offset += constant->scalar() * array_stride; + } + else + { + // Dynamic array access. + if (array_stride % word_stride) + { + SPIRV_CROSS_THROW( + "Array stride for dynamic indexing must be divisible by the size of a 4-component vector. " + "Likely culprit here is a float or vec2 array inside a push constant block which is std430. " + "This cannot be flattened. Try using std140 layout instead."); + } + + expr += to_enclosed_expression(index); + expr += " * "; + expr += convert_to_string(array_stride / word_stride); + expr += " + "; + } + + uint32_t parent_type = type->parent_type; + type = &get(parent_type); + type_id = parent_type; + + // Type ID now refers to the array type with one less dimension. + } + // For structs, the index refers to a constant, which indexes into the members. + // We also check if this member is a builtin, since we then replace the entire expression with the builtin one. + else if (type->basetype == SPIRType::Struct) + { + index = get(index).scalar(); + + if (index >= type->member_types.size()) + SPIRV_CROSS_THROW("Member index is out of bounds!"); + + offset += type_struct_member_offset(*type, index); + type_id = type->member_types[index]; + + auto &struct_type = *type; + type = &get(type->member_types[index]); + + if (type->columns > 1) + { + matrix_stride = type_struct_member_matrix_stride(struct_type, index); + row_major_matrix_needs_conversion = + (combined_decoration_for_member(struct_type, index) & (1ull << DecorationRowMajor)) != 0; + } + else + row_major_matrix_needs_conversion = false; + } + // Matrix -> Vector + else if (type->columns > 1) + { + auto *constant = maybe_get(index); + if (constant) + { + index = get(index).scalar(); + offset += index * (row_major_matrix_needs_conversion ? (type->width / 8) : matrix_stride); + } + else + { + uint32_t indexing_stride = row_major_matrix_needs_conversion ? (type->width / 8) : matrix_stride; + // Dynamic array access. + if (indexing_stride % word_stride) + { + SPIRV_CROSS_THROW( + "Matrix stride for dynamic indexing must be divisible by the size of a 4-component vector. " + "Likely culprit here is a row-major matrix being accessed dynamically. " + "This cannot be flattened. Try using std140 layout instead."); + } + + expr += to_enclosed_expression(index); + expr += " * "; + expr += convert_to_string(indexing_stride / word_stride); + expr += " + "; + } + + uint32_t parent_type = type->parent_type; + type = &get(type->parent_type); + type_id = parent_type; + } + // Vector -> Scalar + else if (type->vecsize > 1) + { + auto *constant = maybe_get(index); + if (constant) + { + index = get(index).scalar(); + offset += index * (row_major_matrix_needs_conversion ? matrix_stride : (type->width / 8)); + } + else + { + uint32_t indexing_stride = row_major_matrix_needs_conversion ? matrix_stride : (type->width / 8); + + // Dynamic array access. + if (indexing_stride % word_stride) + { + SPIRV_CROSS_THROW( + "Stride for dynamic vector indexing must be divisible by the size of a 4-component vector. " + "This cannot be flattened in legacy targets."); + } + + expr += to_enclosed_expression(index); + expr += " * "; + expr += convert_to_string(indexing_stride / word_stride); + expr += " + "; + } + + uint32_t parent_type = type->parent_type; + type = &get(type->parent_type); + type_id = parent_type; + } + else + SPIRV_CROSS_THROW("Cannot subdivide a scalar value!"); + } + + if (need_transpose) + *need_transpose = row_major_matrix_needs_conversion; + if (out_matrix_stride) + *out_matrix_stride = matrix_stride; + + return std::make_pair(expr, offset); +} + +bool CompilerGLSL::should_forward(uint32_t id) +{ + // Immutable expression can always be forwarded. + // If not immutable, we can speculate about it by forwarding potentially mutable variables. + auto *var = maybe_get(id); + bool forward = var ? var->forwardable : false; + return (is_immutable(id) || forward) && !options.force_temporary; +} + +void CompilerGLSL::track_expression_read(uint32_t id) +{ + // If we try to read a forwarded temporary more than once we will stamp out possibly complex code twice. + // In this case, it's better to just bind the complex expression to the temporary and read that temporary twice. + if (expression_is_forwarded(id)) + { + auto &v = expression_usage_counts[id]; + v++; + + if (v >= 2) + { + //if (v == 2) + // fprintf(stderr, "ID %u was forced to temporary due to more than 1 expression use!\n", id); + + forced_temporaries.insert(id); + // Force a recompile after this pass to avoid forwarding this variable. + force_recompile = true; + } + } +} + +bool CompilerGLSL::args_will_forward(uint32_t id, const uint32_t *args, uint32_t num_args, bool pure) +{ + if (forced_temporaries.find(id) != end(forced_temporaries)) + return false; + + for (uint32_t i = 0; i < num_args; i++) + if (!should_forward(args[i])) + return false; + + // We need to forward globals as well. + if (!pure) + { + for (auto global : global_variables) + if (!should_forward(global)) + return false; + for (auto aliased : aliased_variables) + if (!should_forward(aliased)) + return false; + } + + return true; +} + +void CompilerGLSL::register_impure_function_call() +{ + // Impure functions can modify globals and aliased variables, so invalidate them as well. + for (auto global : global_variables) + flush_dependees(get(global)); + for (auto aliased : aliased_variables) + flush_dependees(get(aliased)); +} + +void CompilerGLSL::register_call_out_argument(uint32_t id) +{ + register_write(id); + + auto *var = maybe_get(id); + if (var) + flush_variable_declaration(var->self); +} + +string CompilerGLSL::variable_decl_function_local(SPIRVariable &var) +{ + // These variables are always function local, + // so make sure we emit the variable without storage qualifiers. + // Some backends will inject custom variables locally in a function + // with a storage qualifier which is not function-local. + auto old_storage = var.storage; + var.storage = StorageClassFunction; + auto expr = variable_decl(var); + var.storage = old_storage; + return expr; +} + +void CompilerGLSL::flush_variable_declaration(uint32_t id) +{ + auto *var = maybe_get(id); + if (var && var->deferred_declaration) + { + statement(variable_decl_function_local(*var), ";"); + var->deferred_declaration = false; + } +} + +bool CompilerGLSL::remove_duplicate_swizzle(string &op) +{ + auto pos = op.find_last_of('.'); + if (pos == string::npos || pos == 0) + return false; + + string final_swiz = op.substr(pos + 1, string::npos); + + if (backend.swizzle_is_function) + { + if (final_swiz.size() < 2) + return false; + + if (final_swiz.substr(final_swiz.size() - 2, string::npos) == "()") + final_swiz.erase(final_swiz.size() - 2, string::npos); + else + return false; + } + + // Check if final swizzle is of form .x, .xy, .xyz, .xyzw or similar. + // If so, and previous swizzle is of same length, + // we can drop the final swizzle altogether. + for (uint32_t i = 0; i < final_swiz.size(); i++) + { + static const char expected[] = { 'x', 'y', 'z', 'w' }; + if (i >= 4 || final_swiz[i] != expected[i]) + return false; + } + + auto prevpos = op.find_last_of('.', pos - 1); + if (prevpos == string::npos) + return false; + + prevpos++; + + // Make sure there are only swizzles here ... + for (auto i = prevpos; i < pos; i++) + { + if (op[i] < 'w' || op[i] > 'z') + { + // If swizzles are foo.xyz() like in C++ backend for example, check for that. + if (backend.swizzle_is_function && i + 2 == pos && op[i] == '(' && op[i + 1] == ')') + break; + return false; + } + } + + // If original swizzle is large enough, just carve out the components we need. + // E.g. foobar.wyx.xy will turn into foobar.wy. + if (pos - prevpos >= final_swiz.size()) + { + op.erase(prevpos + final_swiz.size(), string::npos); + + // Add back the function call ... + if (backend.swizzle_is_function) + op += "()"; + } + return true; +} + +// Optimizes away vector swizzles where we have something like +// vec3 foo; +// foo.xyz <-- swizzle expression does nothing. +// This is a very common pattern after OpCompositeCombine. +bool CompilerGLSL::remove_unity_swizzle(uint32_t base, string &op) +{ + auto pos = op.find_last_of('.'); + if (pos == string::npos || pos == 0) + return false; + + string final_swiz = op.substr(pos + 1, string::npos); + + if (backend.swizzle_is_function) + { + if (final_swiz.size() < 2) + return false; + + if (final_swiz.substr(final_swiz.size() - 2, string::npos) == "()") + final_swiz.erase(final_swiz.size() - 2, string::npos); + else + return false; + } + + // Check if final swizzle is of form .x, .xy, .xyz, .xyzw or similar. + // If so, and previous swizzle is of same length, + // we can drop the final swizzle altogether. + for (uint32_t i = 0; i < final_swiz.size(); i++) + { + static const char expected[] = { 'x', 'y', 'z', 'w' }; + if (i >= 4 || final_swiz[i] != expected[i]) + return false; + } + + auto &type = expression_type(base); + + // Sanity checking ... + assert(type.columns == 1 && type.array.empty()); + + if (type.vecsize == final_swiz.size()) + op.erase(pos, string::npos); + return true; +} + +string CompilerGLSL::build_composite_combiner(uint32_t return_type, const uint32_t *elems, uint32_t length) +{ + uint32_t base = 0; + string op; + string subop; + + // Can only merge swizzles for vectors. + auto &type = get(return_type); + bool can_apply_swizzle_opt = type.basetype != SPIRType::Struct && type.array.empty() && type.columns == 1; + bool swizzle_optimization = false; + + for (uint32_t i = 0; i < length; i++) + { + auto *e = maybe_get(elems[i]); + + // If we're merging another scalar which belongs to the same base + // object, just merge the swizzles to avoid triggering more than 1 expression read as much as possible! + if (can_apply_swizzle_opt && e && e->base_expression && e->base_expression == base) + { + // Only supposed to be used for vector swizzle -> scalar. + assert(!e->expression.empty() && e->expression.front() == '.'); + subop += e->expression.substr(1, string::npos); + swizzle_optimization = true; + } + else + { + // We'll likely end up with duplicated swizzles, e.g. + // foobar.xyz.xyz from patterns like + // OpVectorShuffle + // OpCompositeExtract x 3 + // OpCompositeConstruct 3x + other scalar. + // Just modify op in-place. + if (swizzle_optimization) + { + if (backend.swizzle_is_function) + subop += "()"; + + // Don't attempt to remove unity swizzling if we managed to remove duplicate swizzles. + // The base "foo" might be vec4, while foo.xyz is vec3 (OpVectorShuffle) and looks like a vec3 due to the .xyz tacked on. + // We only want to remove the swizzles if we're certain that the resulting base will be the same vecsize. + // Essentially, we can only remove one set of swizzles, since that's what we have control over ... + // Case 1: + // foo.yxz.xyz: Duplicate swizzle kicks in, giving foo.yxz, we are done. + // foo.yxz was the result of OpVectorShuffle and we don't know the type of foo. + // Case 2: + // foo.xyz: Duplicate swizzle won't kick in. + // If foo is vec3, we can remove xyz, giving just foo. + if (!remove_duplicate_swizzle(subop)) + remove_unity_swizzle(base, subop); + + // Strips away redundant parens if we created them during component extraction. + strip_enclosed_expression(subop); + swizzle_optimization = false; + op += subop; + } + else + op += subop; + + if (i) + op += ", "; + subop = to_expression(elems[i]); + } + + base = e ? e->base_expression : 0; + } + + if (swizzle_optimization) + { + if (backend.swizzle_is_function) + subop += "()"; + + if (!remove_duplicate_swizzle(subop)) + remove_unity_swizzle(base, subop); + // Strips away redundant parens if we created them during component extraction. + strip_enclosed_expression(subop); + } + + op += subop; + return op; +} + +bool CompilerGLSL::skip_argument(uint32_t id) const +{ + if (!combined_image_samplers.empty() || !options.vulkan_semantics) + { + auto &type = expression_type(id); + if (type.basetype == SPIRType::Sampler || (type.basetype == SPIRType::Image && type.image.sampled == 1)) + return true; + } + return false; +} + +bool CompilerGLSL::optimize_read_modify_write(const string &lhs, const string &rhs) +{ + // Do this with strings because we have a very clear pattern we can check for and it avoids + // adding lots of special cases to the code emission. + if (rhs.size() < lhs.size() + 3) + return false; + + auto index = rhs.find(lhs); + if (index != 0) + return false; + + // TODO: Shift operators, but it's not important for now. + auto op = rhs.find_first_of("+-/*%|&^", lhs.size() + 1); + if (op != lhs.size() + 1) + return false; + + // Check that the op is followed by space. This excludes && and ||. + if (rhs[op + 1] != ' ') + return false; + + char bop = rhs[op]; + auto expr = rhs.substr(lhs.size() + 3); + // Try to find increments and decrements. Makes it look neater as += 1, -= 1 is fairly rare to see in real code. + // Find some common patterns which are equivalent. + if ((bop == '+' || bop == '-') && (expr == "1" || expr == "uint(1)" || expr == "1u" || expr == "int(1u)")) + statement(lhs, bop, bop, ";"); + else + statement(lhs, " ", bop, "= ", expr, ";"); + return true; +} + +void CompilerGLSL::emit_block_instructions(const SPIRBlock &block) +{ + current_emitting_block = █ + for (auto &op : block.ops) + emit_instruction(op); + current_emitting_block = nullptr; +} + +void CompilerGLSL::emit_instruction(const Instruction &instruction) +{ + auto ops = stream(instruction); + auto opcode = static_cast(instruction.op); + uint32_t length = instruction.length; + +#define BOP(op) emit_binary_op(ops[0], ops[1], ops[2], ops[3], #op) +#define BOP_CAST(op, type) \ + emit_binary_op_cast(ops[0], ops[1], ops[2], ops[3], #op, type, opcode_is_sign_invariant(opcode)) +#define UOP(op) emit_unary_op(ops[0], ops[1], ops[2], #op) +#define QFOP(op) emit_quaternary_func_op(ops[0], ops[1], ops[2], ops[3], ops[4], ops[5], #op) +#define TFOP(op) emit_trinary_func_op(ops[0], ops[1], ops[2], ops[3], ops[4], #op) +#define BFOP(op) emit_binary_func_op(ops[0], ops[1], ops[2], ops[3], #op) +#define BFOP_CAST(op, type) \ + emit_binary_func_op_cast(ops[0], ops[1], ops[2], ops[3], #op, type, opcode_is_sign_invariant(opcode)) +#define BFOP(op) emit_binary_func_op(ops[0], ops[1], ops[2], ops[3], #op) +#define UFOP(op) emit_unary_func_op(ops[0], ops[1], ops[2], #op) + + switch (opcode) + { + // Dealing with memory + case OpLoad: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + uint32_t ptr = ops[2]; + + flush_variable_declaration(ptr); + + // If we're loading from memory that cannot be changed by the shader, + // just forward the expression directly to avoid needless temporaries. + // If an expression is mutable and forwardable, we speculate that it is immutable. + bool forward = should_forward(ptr) && forced_temporaries.find(id) == end(forced_temporaries); + + // If loading a non-native row-major matrix, mark the expression as need_transpose. + bool need_transpose = false; + bool old_need_transpose = false; + + auto *ptr_expression = maybe_get(ptr); + if (ptr_expression && ptr_expression->need_transpose) + { + old_need_transpose = true; + ptr_expression->need_transpose = false; + need_transpose = true; + } + else if (is_non_native_row_major_matrix(ptr)) + need_transpose = true; + + auto expr = to_expression(ptr); + + if (ptr_expression) + ptr_expression->need_transpose = old_need_transpose; + + // Suppress usage tracking since using same expression multiple times does not imply any extra work. + auto &e = emit_op(result_type, id, expr, forward, true); + e.need_transpose = need_transpose; + register_read(id, ptr, forward); + + // Pass through whether the result is of a packed type. + if (has_decoration(ptr, DecorationCPacked)) + set_decoration(id, DecorationCPacked); + + break; + } + + case OpInBoundsAccessChain: + case OpAccessChain: + { + auto *var = maybe_get(ops[2]); + if (var) + flush_variable_declaration(var->self); + + // If the base is immutable, the access chain pointer must also be. + // If an expression is mutable and forwardable, we speculate that it is immutable. + bool need_transpose, result_is_packed; + auto e = access_chain(ops[2], &ops[3], length - 3, get(ops[0]), &need_transpose, &result_is_packed); + auto &expr = set(ops[1], move(e), ops[0], should_forward(ops[2])); + expr.loaded_from = ops[2]; + expr.need_transpose = need_transpose; + + // Mark the result as being packed. Some platforms handled packed vectors differently than non-packed. + if (result_is_packed) + set_decoration(ops[1], DecorationCPacked); + else + unset_decoration(ops[1], DecorationCPacked); + + break; + } + + case OpStore: + { + auto *var = maybe_get(ops[0]); + + if (var && var->statically_assigned) + var->static_expression = ops[1]; + else if (var && var->loop_variable && !var->loop_variable_enable) + var->static_expression = ops[1]; + else if (var && flattened_structs.count(ops[0])) + { + store_flattened_struct(*var, ops[1]); + register_write(ops[0]); + } + else + { + auto rhs = to_expression(ops[1]); + // Statements to OpStore may be empty if it is a struct with zero members. Just forward the store to /dev/null. + if (!rhs.empty()) + { + auto lhs = to_expression(ops[0]); + + // Tries to optimize assignments like " = op expr". + // While this is purely cosmetic, this is important for legacy ESSL where loop + // variable increments must be in either i++ or i += const-expr. + // Without this, we end up with i = i + 1, which is correct GLSL, but not correct GLES 2.0. + if (!optimize_read_modify_write(lhs, rhs)) + statement(lhs, " = ", rhs, ";"); + register_write(ops[0]); + } + } + break; + } + + case OpArrayLength: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + auto e = access_chain_internal(ops[2], &ops[3], length - 3, true); + set(id, e + ".length()", result_type, true); + break; + } + + // Function calls + case OpFunctionCall: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + uint32_t func = ops[2]; + const auto *arg = &ops[3]; + length -= 3; + + auto &callee = get(func); + bool pure = function_is_pure(callee); + + bool callee_has_out_variables = false; + + // Invalidate out variables passed to functions since they can be OpStore'd to. + for (uint32_t i = 0; i < length; i++) + { + if (callee.arguments[i].write_count) + { + register_call_out_argument(arg[i]); + callee_has_out_variables = true; + } + + flush_variable_declaration(arg[i]); + } + + if (!pure) + register_impure_function_call(); + + string funexpr; + vector arglist; + funexpr += to_name(func) + "("; + for (uint32_t i = 0; i < length; i++) + { + // Do not pass in separate images or samplers if we're remapping + // to combined image samplers. + if (skip_argument(arg[i])) + continue; + + arglist.push_back(to_func_call_arg(arg[i])); + } + + for (auto &combined : callee.combined_parameters) + { + uint32_t image_id = combined.global_image ? combined.image_id : arg[combined.image_id]; + uint32_t sampler_id = combined.global_sampler ? combined.sampler_id : arg[combined.sampler_id]; + + auto *image = maybe_get_backing_variable(image_id); + if (image) + image_id = image->self; + + auto *samp = maybe_get_backing_variable(sampler_id); + if (samp) + sampler_id = samp->self; + + arglist.push_back(to_combined_image_sampler(image_id, sampler_id)); + } + + append_global_func_args(callee, length, arglist); + + funexpr += merge(arglist); + funexpr += ")"; + + // Check for function call constraints. + check_function_call_constraints(arg, length); + + if (get(result_type).basetype != SPIRType::Void) + { + // If the function actually writes to an out variable, + // take the conservative route and do not forward. + // The problem is that we might not read the function + // result (and emit the function) before an out variable + // is read (common case when return value is ignored! + // In order to avoid start tracking invalid variables, + // just avoid the forwarding problem altogether. + bool forward = args_will_forward(id, arg, length, pure) && !callee_has_out_variables && pure && + (forced_temporaries.find(id) == end(forced_temporaries)); + + emit_op(result_type, id, funexpr, forward); + + // Function calls are implicit loads from all variables in question. + // Set dependencies for them. + for (uint32_t i = 0; i < length; i++) + register_read(id, arg[i], forward); + + // If we're going to forward the temporary result, + // put dependencies on every variable that must not change. + if (forward) + register_global_read_dependencies(callee, id); + } + else + statement(funexpr, ";"); + + break; + } + + // Composite munging + case OpCompositeConstruct: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + const auto *elems = &ops[2]; + length -= 2; + + bool forward = true; + for (uint32_t i = 0; i < length; i++) + forward = forward && should_forward(elems[i]); + + auto &out_type = get(result_type); + + if (!length) + { + if (out_type.basetype == SPIRType::Struct) + { + // It is technically allowed to make a blank struct, + // but we cannot make a meaningful expression out of it in high level languages, + // so make it a blank expression. + emit_op(result_type, id, "", forward); + break; + } + else + SPIRV_CROSS_THROW("Invalid input to OpCompositeConstruct."); + } + + auto &in_type = expression_type(elems[0]); + + // Only splat if we have vector constructors. + // Arrays and structs must be initialized properly in full. + bool composite = !out_type.array.empty() || out_type.basetype == SPIRType::Struct; + bool splat = in_type.vecsize == 1 && in_type.columns == 1 && !composite && backend.use_constructor_splatting; + bool swizzle_splat = in_type.vecsize == 1 && in_type.columns == 1 && backend.can_swizzle_scalar; + + if (ids[elems[0]].get_type() == TypeConstant && + (in_type.basetype != SPIRType::Float && in_type.basetype != SPIRType::Double)) + { + // Cannot swizzle literal integers as a special case. + swizzle_splat = false; + } + + if (splat || swizzle_splat) + { + uint32_t input = elems[0]; + for (uint32_t i = 0; i < length; i++) + { + if (input != elems[i]) + { + splat = false; + swizzle_splat = false; + } + } + } + + if (out_type.basetype == SPIRType::Struct && !backend.can_declare_struct_inline) + forward = false; + if (!out_type.array.empty() && !backend.can_declare_arrays_inline) + forward = false; + + string constructor_op; + if (backend.use_initializer_list && composite) + { + // Only use this path if we are building composites. + // This path cannot be used for arithmetic. + if (backend.use_typed_initializer_list) + constructor_op += type_to_glsl_constructor(get(result_type)); + constructor_op += "{ "; + if (splat) + constructor_op += to_expression(elems[0]); + else + constructor_op += build_composite_combiner(result_type, elems, length); + constructor_op += " }"; + } + else if (swizzle_splat && !composite) + { + constructor_op = remap_swizzle(get(result_type), 1, to_expression(elems[0])); + } + else + { + constructor_op = type_to_glsl_constructor(get(result_type)) + "("; + if (splat) + constructor_op += to_expression(elems[0]); + else + constructor_op += build_composite_combiner(result_type, elems, length); + constructor_op += ")"; + } + + emit_op(result_type, id, constructor_op, forward); + break; + } + + case OpVectorInsertDynamic: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + uint32_t vec = ops[2]; + uint32_t comp = ops[3]; + uint32_t index = ops[4]; + + flush_variable_declaration(vec); + + // Make a copy, then use access chain to store the variable. + statement(declare_temporary(result_type, id), to_expression(vec), ";"); + set(id, to_name(id), result_type, true); + auto chain = access_chain_internal(id, &index, 1, false); + statement(chain, " = ", to_expression(comp), ";"); + break; + } + + case OpVectorExtractDynamic: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + + auto expr = access_chain_internal(ops[2], &ops[3], 1, false); + emit_op(result_type, id, expr, should_forward(ops[2])); + break; + } + + case OpCompositeExtract: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + length -= 3; + + auto &type = get(result_type); + + // We can only split the expression here if our expression is forwarded as a temporary. + bool allow_base_expression = forced_temporaries.find(id) == end(forced_temporaries); + + // Do not allow base expression for struct members. We risk doing "swizzle" optimizations in this case. + auto &composite_type = expression_type(ops[2]); + if (composite_type.basetype == SPIRType::Struct || !composite_type.array.empty()) + allow_base_expression = false; + + // Only apply this optimization if result is scalar. + if (allow_base_expression && should_forward(ops[2]) && type.vecsize == 1 && type.columns == 1 && length == 1) + { + // We want to split the access chain from the base. + // This is so we can later combine different CompositeExtract results + // with CompositeConstruct without emitting code like + // + // vec3 temp = texture(...).xyz + // vec4(temp.x, temp.y, temp.z, 1.0). + // + // when we actually wanted to emit this + // vec4(texture(...).xyz, 1.0). + // + // Including the base will prevent this and would trigger multiple reads + // from expression causing it to be forced to an actual temporary in GLSL. + auto expr = access_chain_internal(ops[2], &ops[3], length, true, true); + auto &e = emit_op(result_type, id, expr, true, !expression_is_forwarded(ops[2])); + e.base_expression = ops[2]; + } + else + { + auto expr = access_chain_internal(ops[2], &ops[3], length, true); + emit_op(result_type, id, expr, should_forward(ops[2]), !expression_is_forwarded(ops[2])); + } + break; + } + + case OpCompositeInsert: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + uint32_t obj = ops[2]; + uint32_t composite = ops[3]; + const auto *elems = &ops[4]; + length -= 4; + + flush_variable_declaration(composite); + + // Make a copy, then use access chain to store the variable. + statement(declare_temporary(result_type, id), to_expression(composite), ";"); + set(id, to_name(id), result_type, true); + auto chain = access_chain_internal(id, elems, length, true); + statement(chain, " = ", to_expression(obj), ";"); + + break; + } + + case OpCopyMemory: + { + uint32_t lhs = ops[0]; + uint32_t rhs = ops[1]; + if (lhs != rhs) + { + flush_variable_declaration(lhs); + flush_variable_declaration(rhs); + statement(to_expression(lhs), " = ", to_expression(rhs), ";"); + register_write(lhs); + } + break; + } + + case OpCopyObject: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + uint32_t rhs = ops[2]; + bool pointer = get(result_type).pointer; + + if (expression_is_lvalue(rhs) && !pointer) + { + // Need a copy. + // For pointer types, we copy the pointer itself. + statement(declare_temporary(result_type, id), to_expression(rhs), ";"); + set(id, to_name(id), result_type, true); + } + else + { + // RHS expression is immutable, so just forward it. + // Copying these things really make no sense, but + // seems to be allowed anyways. + auto &e = set(id, to_expression(rhs), result_type, true); + if (pointer) + { + auto *var = maybe_get_backing_variable(rhs); + e.loaded_from = var ? var->self : 0; + } + } + break; + } + + case OpVectorShuffle: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + uint32_t vec0 = ops[2]; + uint32_t vec1 = ops[3]; + const auto *elems = &ops[4]; + length -= 4; + + auto &type0 = expression_type(vec0); + + bool shuffle = false; + for (uint32_t i = 0; i < length; i++) + if (elems[i] >= type0.vecsize) + shuffle = true; + + string expr; + bool should_fwd, trivial_forward; + + if (shuffle) + { + should_fwd = should_forward(vec0) && should_forward(vec1); + trivial_forward = !expression_is_forwarded(vec0) && !expression_is_forwarded(vec1); + + // Constructor style and shuffling from two different vectors. + vector args; + for (uint32_t i = 0; i < length; i++) + { + if (elems[i] >= type0.vecsize) + args.push_back(join(to_enclosed_expression(vec1), ".", index_to_swizzle(elems[i] - type0.vecsize))); + else + args.push_back(join(to_enclosed_expression(vec0), ".", index_to_swizzle(elems[i]))); + } + expr += join(type_to_glsl_constructor(get(result_type)), "(", merge(args), ")"); + } + else + { + should_fwd = should_forward(vec0); + trivial_forward = !expression_is_forwarded(vec0); + + // We only source from first vector, so can use swizzle. + // If the vector is packed, unpack it before applying a swizzle (needed for MSL) + expr += to_enclosed_expression(vec0); + if (has_decoration(vec0, DecorationCPacked)) + expr = unpack_expression_type(expr, expression_type(vec0)); + + expr += "."; + for (uint32_t i = 0; i < length; i++) + expr += index_to_swizzle(elems[i]); + + if (backend.swizzle_is_function && length > 1) + expr += "()"; + } + + // A shuffle is trivial in that it doesn't actually *do* anything. + // We inherit the forwardedness from our arguments to avoid flushing out to temporaries when it's not really needed. + + emit_op(result_type, id, expr, should_fwd, trivial_forward); + break; + } + + // ALU + case OpIsNan: + UFOP(isnan); + break; + + case OpIsInf: + UFOP(isinf); + break; + + case OpSNegate: + case OpFNegate: + UOP(-); + break; + + case OpIAdd: + { + // For simple arith ops, prefer the output type if there's a mismatch to avoid extra bitcasts. + auto type = get(ops[0]).basetype; + BOP_CAST(+, type); + break; + } + + case OpFAdd: + BOP(+); + break; + + case OpISub: + { + auto type = get(ops[0]).basetype; + BOP_CAST(-, type); + break; + } + + case OpFSub: + BOP(-); + break; + + case OpIMul: + { + auto type = get(ops[0]).basetype; + BOP_CAST(*, type); + break; + } + + case OpVectorTimesMatrix: + case OpMatrixTimesVector: + { + // If the matrix needs transpose, just flip the multiply order. + auto *e = maybe_get(ops[opcode == OpMatrixTimesVector ? 2 : 3]); + if (e && e->need_transpose) + { + e->need_transpose = false; + emit_binary_op(ops[0], ops[1], ops[3], ops[2], "*"); + e->need_transpose = true; + } + else + BOP(*); + break; + } + + case OpFMul: + case OpMatrixTimesScalar: + case OpVectorTimesScalar: + case OpMatrixTimesMatrix: + BOP(*); + break; + + case OpOuterProduct: + BFOP(outerProduct); + break; + + case OpDot: + BFOP(dot); + break; + + case OpTranspose: + UFOP(transpose); + break; + + case OpSDiv: + BOP_CAST(/, SPIRType::Int); + break; + + case OpUDiv: + BOP_CAST(/, SPIRType::UInt); + break; + + case OpFDiv: + BOP(/); + break; + + case OpShiftRightLogical: + BOP_CAST(>>, SPIRType::UInt); + break; + + case OpShiftRightArithmetic: + BOP_CAST(>>, SPIRType::Int); + break; + + case OpShiftLeftLogical: + { + auto type = get(ops[0]).basetype; + BOP_CAST(<<, type); + break; + } + + case OpBitwiseOr: + { + auto type = get(ops[0]).basetype; + BOP_CAST(|, type); + break; + } + + case OpBitwiseXor: + { + auto type = get(ops[0]).basetype; + BOP_CAST (^, type); + break; + } + + case OpBitwiseAnd: + { + auto type = get(ops[0]).basetype; + BOP_CAST(&, type); + break; + } + + case OpNot: + UOP(~); + break; + + case OpUMod: + BOP_CAST(%, SPIRType::UInt); + break; + + case OpSMod: + BOP_CAST(%, SPIRType::Int); + break; + + case OpFMod: + BFOP(mod); + break; + + // Relational + case OpAny: + UFOP(any); + break; + + case OpAll: + UFOP(all); + break; + + case OpSelect: + emit_mix_op(ops[0], ops[1], ops[4], ops[3], ops[2]); + break; + + case OpLogicalOr: + { + // No vector variant in GLSL for logical OR. + auto result_type = ops[0]; + auto id = ops[1]; + auto &type = get(result_type); + + if (type.vecsize > 1) + emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "||"); + else + BOP(||); + break; + } + + case OpLogicalAnd: + { + // No vector variant in GLSL for logical AND. + auto result_type = ops[0]; + auto id = ops[1]; + auto &type = get(result_type); + + if (type.vecsize > 1) + emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "&&"); + else + BOP(&&); + break; + } + + case OpLogicalNot: + { + auto &type = get(ops[0]); + if (type.vecsize > 1) + UFOP(not); + else + UOP(!); + break; + } + + case OpIEqual: + { + if (expression_type(ops[2]).vecsize > 1) + BFOP_CAST(equal, SPIRType::Int); + else + BOP_CAST(==, SPIRType::Int); + break; + } + + case OpLogicalEqual: + case OpFOrdEqual: + { + if (expression_type(ops[2]).vecsize > 1) + BFOP(equal); + else + BOP(==); + break; + } + + case OpINotEqual: + { + if (expression_type(ops[2]).vecsize > 1) + BFOP_CAST(notEqual, SPIRType::Int); + else + BOP_CAST(!=, SPIRType::Int); + break; + } + + case OpLogicalNotEqual: + case OpFOrdNotEqual: + { + if (expression_type(ops[2]).vecsize > 1) + BFOP(notEqual); + else + BOP(!=); + break; + } + + case OpUGreaterThan: + case OpSGreaterThan: + { + auto type = opcode == OpUGreaterThan ? SPIRType::UInt : SPIRType::Int; + if (expression_type(ops[2]).vecsize > 1) + BFOP_CAST(greaterThan, type); + else + BOP_CAST(>, type); + break; + } + + case OpFOrdGreaterThan: + { + if (expression_type(ops[2]).vecsize > 1) + BFOP(greaterThan); + else + BOP(>); + break; + } + + case OpUGreaterThanEqual: + case OpSGreaterThanEqual: + { + auto type = opcode == OpUGreaterThanEqual ? SPIRType::UInt : SPIRType::Int; + if (expression_type(ops[2]).vecsize > 1) + BFOP_CAST(greaterThanEqual, type); + else + BOP_CAST(>=, type); + break; + } + + case OpFOrdGreaterThanEqual: + { + if (expression_type(ops[2]).vecsize > 1) + BFOP(greaterThanEqual); + else + BOP(>=); + break; + } + + case OpULessThan: + case OpSLessThan: + { + auto type = opcode == OpULessThan ? SPIRType::UInt : SPIRType::Int; + if (expression_type(ops[2]).vecsize > 1) + BFOP_CAST(lessThan, type); + else + BOP_CAST(<, type); + break; + } + + case OpFOrdLessThan: + { + if (expression_type(ops[2]).vecsize > 1) + BFOP(lessThan); + else + BOP(<); + break; + } + + case OpULessThanEqual: + case OpSLessThanEqual: + { + auto type = opcode == OpULessThanEqual ? SPIRType::UInt : SPIRType::Int; + if (expression_type(ops[2]).vecsize > 1) + BFOP_CAST(lessThanEqual, type); + else + BOP_CAST(<=, type); + break; + } + + case OpFOrdLessThanEqual: + { + if (expression_type(ops[2]).vecsize > 1) + BFOP(lessThanEqual); + else + BOP(<=); + break; + } + + // Conversion + case OpConvertFToU: + case OpConvertFToS: + case OpConvertSToF: + case OpConvertUToF: + case OpUConvert: + case OpSConvert: + case OpFConvert: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + + auto func = type_to_glsl_constructor(get(result_type)); + emit_unary_func_op(result_type, id, ops[2], func.c_str()); + break; + } + + case OpBitcast: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + uint32_t arg = ops[2]; + + auto op = bitcast_glsl_op(get(result_type), expression_type(arg)); + emit_unary_func_op(result_type, id, arg, op.c_str()); + break; + } + + case OpQuantizeToF16: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + uint32_t arg = ops[2]; + + string op; + auto &type = get(result_type); + + switch (type.vecsize) + { + case 1: + op = join("unpackHalf2x16(packHalf2x16(vec2(", to_expression(arg), "))).x"); + break; + case 2: + op = join("unpackHalf2x16(packHalf2x16(", to_expression(arg), "))"); + break; + case 3: + { + auto op0 = join("unpackHalf2x16(packHalf2x16(", to_expression(arg), ".xy))"); + auto op1 = join("unpackHalf2x16(packHalf2x16(", to_expression(arg), ".zz)).x"); + op = join("vec3(", op0, ", ", op1, ")"); + break; + } + case 4: + { + auto op0 = join("unpackHalf2x16(packHalf2x16(", to_expression(arg), ".xy))"); + auto op1 = join("unpackHalf2x16(packHalf2x16(", to_expression(arg), ".zw))"); + op = join("vec4(", op0, ", ", op1, ")"); + break; + } + default: + SPIRV_CROSS_THROW("Illegal argument to OpQuantizeToF16."); + } + + emit_op(result_type, id, op, should_forward(arg)); + break; + } + + // Derivatives + case OpDPdx: + UFOP(dFdx); + if (is_legacy_es()) + require_extension("GL_OES_standard_derivatives"); + break; + + case OpDPdy: + UFOP(dFdy); + if (is_legacy_es()) + require_extension("GL_OES_standard_derivatives"); + break; + + case OpDPdxFine: + UFOP(dFdxFine); + if (options.es) + { + SPIRV_CROSS_THROW("GL_ARB_derivative_control is unavailable in OpenGL ES."); + } + if (options.version < 450) + require_extension("GL_ARB_derivative_control"); + break; + + case OpDPdyFine: + UFOP(dFdyFine); + if (options.es) + { + SPIRV_CROSS_THROW("GL_ARB_derivative_control is unavailable in OpenGL ES."); + } + if (options.version < 450) + require_extension("GL_ARB_derivative_control"); + break; + + case OpDPdxCoarse: + if (options.es) + { + SPIRV_CROSS_THROW("GL_ARB_derivative_control is unavailable in OpenGL ES."); + } + UFOP(dFdxCoarse); + if (options.version < 450) + require_extension("GL_ARB_derivative_control"); + break; + + case OpDPdyCoarse: + UFOP(dFdyCoarse); + if (options.es) + { + SPIRV_CROSS_THROW("GL_ARB_derivative_control is unavailable in OpenGL ES."); + } + if (options.version < 450) + require_extension("GL_ARB_derivative_control"); + break; + + case OpFwidth: + UFOP(fwidth); + if (is_legacy_es()) + require_extension("GL_OES_standard_derivatives"); + break; + + // Bitfield + case OpBitFieldInsert: + // TODO: The signedness of inputs is strict in GLSL, but not in SPIR-V, bitcast if necessary. + QFOP(bitfieldInsert); + break; + + case OpBitFieldSExtract: + case OpBitFieldUExtract: + // TODO: The signedness of inputs is strict in GLSL, but not in SPIR-V, bitcast if necessary. + TFOP(bitfieldExtract); + break; + + case OpBitReverse: + UFOP(bitfieldReverse); + break; + + case OpBitCount: + UFOP(bitCount); + break; + + // Atomics + case OpAtomicExchange: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + uint32_t ptr = ops[2]; + // Ignore semantics for now, probably only relevant to CL. + uint32_t val = ops[5]; + const char *op = check_atomic_image(ptr) ? "imageAtomicExchange" : "atomicExchange"; + forced_temporaries.insert(id); + emit_binary_func_op(result_type, id, ptr, val, op); + flush_all_atomic_capable_variables(); + break; + } + + case OpAtomicCompareExchange: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + uint32_t ptr = ops[2]; + uint32_t val = ops[6]; + uint32_t comp = ops[7]; + const char *op = check_atomic_image(ptr) ? "imageAtomicCompSwap" : "atomicCompSwap"; + + forced_temporaries.insert(id); + emit_trinary_func_op(result_type, id, ptr, comp, val, op); + flush_all_atomic_capable_variables(); + break; + } + + case OpAtomicLoad: + flush_all_atomic_capable_variables(); + // FIXME: Image? + // OpAtomicLoad seems to only be relevant for atomic counters. + UFOP(atomicCounter); + register_read(ops[1], ops[2], should_forward(ops[2])); + break; + + case OpAtomicStore: + SPIRV_CROSS_THROW("Unsupported opcode OpAtomicStore."); + + case OpAtomicIIncrement: + forced_temporaries.insert(ops[1]); + // FIXME: Image? + UFOP(atomicCounterIncrement); + flush_all_atomic_capable_variables(); + register_read(ops[1], ops[2], should_forward(ops[2])); + break; + + case OpAtomicIDecrement: + forced_temporaries.insert(ops[1]); + // FIXME: Image? + UFOP(atomicCounterDecrement); + flush_all_atomic_capable_variables(); + register_read(ops[1], ops[2], should_forward(ops[2])); + break; + + case OpAtomicIAdd: + { + const char *op = check_atomic_image(ops[2]) ? "imageAtomicAdd" : "atomicAdd"; + forced_temporaries.insert(ops[1]); + emit_binary_func_op(ops[0], ops[1], ops[2], ops[5], op); + flush_all_atomic_capable_variables(); + register_read(ops[1], ops[2], should_forward(ops[2])); + break; + } + + case OpAtomicISub: + { + const char *op = check_atomic_image(ops[2]) ? "imageAtomicAdd" : "atomicAdd"; + forced_temporaries.insert(ops[1]); + auto expr = join(op, "(", to_expression(ops[2]), ", -", to_enclosed_expression(ops[5]), ")"); + emit_op(ops[0], ops[1], expr, should_forward(ops[2]) && should_forward(ops[5])); + flush_all_atomic_capable_variables(); + register_read(ops[1], ops[2], should_forward(ops[2])); + break; + } + + case OpAtomicSMin: + case OpAtomicUMin: + { + const char *op = check_atomic_image(ops[2]) ? "imageAtomicMin" : "atomicMin"; + forced_temporaries.insert(ops[1]); + emit_binary_func_op(ops[0], ops[1], ops[2], ops[5], op); + flush_all_atomic_capable_variables(); + register_read(ops[1], ops[2], should_forward(ops[2])); + break; + } + + case OpAtomicSMax: + case OpAtomicUMax: + { + const char *op = check_atomic_image(ops[2]) ? "imageAtomicMax" : "atomicMax"; + forced_temporaries.insert(ops[1]); + emit_binary_func_op(ops[0], ops[1], ops[2], ops[5], op); + flush_all_atomic_capable_variables(); + register_read(ops[1], ops[2], should_forward(ops[2])); + break; + } + + case OpAtomicAnd: + { + const char *op = check_atomic_image(ops[2]) ? "imageAtomicAnd" : "atomicAnd"; + forced_temporaries.insert(ops[1]); + emit_binary_func_op(ops[0], ops[1], ops[2], ops[5], op); + flush_all_atomic_capable_variables(); + register_read(ops[1], ops[2], should_forward(ops[2])); + break; + } + + case OpAtomicOr: + { + const char *op = check_atomic_image(ops[2]) ? "imageAtomicOr" : "atomicOr"; + forced_temporaries.insert(ops[1]); + emit_binary_func_op(ops[0], ops[1], ops[2], ops[5], op); + flush_all_atomic_capable_variables(); + register_read(ops[1], ops[2], should_forward(ops[2])); + break; + } + + case OpAtomicXor: + { + const char *op = check_atomic_image(ops[2]) ? "imageAtomicXor" : "atomicXor"; + forced_temporaries.insert(ops[1]); + emit_binary_func_op(ops[0], ops[1], ops[2], ops[5], op); + flush_all_atomic_capable_variables(); + register_read(ops[1], ops[2], should_forward(ops[2])); + break; + } + + // Geometry shaders + case OpEmitVertex: + statement("EmitVertex();"); + break; + + case OpEndPrimitive: + statement("EndPrimitive();"); + break; + + case OpEmitStreamVertex: + statement("EmitStreamVertex();"); + break; + + case OpEndStreamPrimitive: + statement("EndStreamPrimitive();"); + break; + + // Textures + case OpImageSampleExplicitLod: + case OpImageSampleProjExplicitLod: + case OpImageSampleDrefExplicitLod: + case OpImageSampleProjDrefExplicitLod: + case OpImageSampleImplicitLod: + case OpImageSampleProjImplicitLod: + case OpImageSampleDrefImplicitLod: + case OpImageSampleProjDrefImplicitLod: + case OpImageFetch: + case OpImageGather: + case OpImageDrefGather: + // Gets a bit hairy, so move this to a separate instruction. + emit_texture_op(instruction); + break; + + case OpImage: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + auto &e = emit_op(result_type, id, to_expression(ops[2]), true); + + // When using the image, we need to know which variable it is actually loaded from. + auto *var = maybe_get_backing_variable(ops[2]); + e.loaded_from = var ? var->self : 0; + break; + } + + case OpImageQueryLod: + { + if (!options.es && options.version < 400) + { + require_extension("GL_ARB_texture_query_lod"); + // For some reason, the ARB spec is all-caps. + BFOP(textureQueryLOD); + } + else if (options.es) + SPIRV_CROSS_THROW("textureQueryLod not supported in ES profile."); + else + BFOP(textureQueryLod); + break; + } + + case OpImageQueryLevels: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + + if (!options.es && options.version < 430) + require_extension("GL_ARB_texture_query_levels"); + if (options.es) + SPIRV_CROSS_THROW("textureQueryLevels not supported in ES profile."); + + auto expr = join("textureQueryLevels(", to_expression(ops[2]), ")"); + auto &restype = get(ops[0]); + expr = bitcast_expression(restype, SPIRType::Int, expr); + emit_op(result_type, id, expr, true); + break; + } + + case OpImageQuerySamples: + { + auto &type = expression_type(ops[2]); + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + + string expr; + if (type.image.sampled == 2) + expr = join("imageSamples(", to_expression(ops[2]), ")"); + else + expr = join("textureSamples(", to_expression(ops[2]), ")"); + + auto &restype = get(ops[0]); + expr = bitcast_expression(restype, SPIRType::Int, expr); + emit_op(result_type, id, expr, true); + break; + } + + case OpSampledImage: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + emit_sampled_image_op(result_type, id, ops[2], ops[3]); + break; + } + + case OpImageQuerySizeLod: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + + auto expr = join("textureSize(", to_expression(ops[2]), ", ", bitcast_expression(SPIRType::Int, ops[3]), ")"); + auto &restype = get(ops[0]); + expr = bitcast_expression(restype, SPIRType::Int, expr); + emit_op(result_type, id, expr, true); + break; + } + + // Image load/store + case OpImageRead: + { + // We added Nonreadable speculatively to the OpImage variable due to glslangValidator + // not adding the proper qualifiers. + // If it turns out we need to read the image after all, remove the qualifier and recompile. + auto *var = maybe_get_backing_variable(ops[2]); + if (var) + { + auto &flags = meta.at(var->self).decoration.decoration_flags; + if (flags & (1ull << DecorationNonReadable)) + { + flags &= ~(1ull << DecorationNonReadable); + force_recompile = true; + } + } + + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + + bool pure; + string imgexpr; + auto &type = expression_type(ops[2]); + + if (var && var->remapped_variable) // Remapped input, just read as-is without any op-code + { + if (type.image.ms) + SPIRV_CROSS_THROW("Trying to remap multisampled image to variable, this is not possible."); + + auto itr = + find_if(begin(pls_inputs), end(pls_inputs), [var](const PlsRemap &pls) { return pls.id == var->self; }); + + if (itr == end(pls_inputs)) + { + // For non-PLS inputs, we rely on subpass type remapping information to get it right + // since ImageRead always returns 4-component vectors and the backing type is opaque. + if (!var->remapped_components) + SPIRV_CROSS_THROW("subpassInput was remapped, but remap_components is not set correctly."); + imgexpr = remap_swizzle(get(result_type), var->remapped_components, to_expression(ops[2])); + } + else + { + // PLS input could have different number of components than what the SPIR expects, swizzle to + // the appropriate vector size. + uint32_t components = pls_format_to_components(itr->format); + imgexpr = remap_swizzle(get(result_type), components, to_expression(ops[2])); + } + pure = true; + } + else if (type.image.dim == DimSubpassData) + { + if (options.vulkan_semantics) + { + // With Vulkan semantics, use the proper Vulkan GLSL construct. + if (type.image.ms) + { + uint32_t operands = ops[4]; + if (operands != ImageOperandsSampleMask || length != 6) + SPIRV_CROSS_THROW( + "Multisampled image used in OpImageRead, but unexpected operand mask was used."); + + uint32_t samples = ops[5]; + imgexpr = join("subpassLoad(", to_expression(ops[2]), ", ", to_expression(samples), ")"); + } + else + imgexpr = join("subpassLoad(", to_expression(ops[2]), ")"); + } + else + { + if (type.image.ms) + { + uint32_t operands = ops[4]; + if (operands != ImageOperandsSampleMask || length != 6) + SPIRV_CROSS_THROW( + "Multisampled image used in OpImageRead, but unexpected operand mask was used."); + + uint32_t samples = ops[5]; + imgexpr = join("texelFetch(", to_expression(ops[2]), ", ivec2(gl_FragCoord.xy), ", + to_expression(samples), ")"); + } + else + { + // Implement subpass loads via texture barrier style sampling. + imgexpr = join("texelFetch(", to_expression(ops[2]), ", ivec2(gl_FragCoord.xy), 0)"); + } + } + imgexpr = remap_swizzle(get(result_type), 4, imgexpr); + pure = true; + } + else + { + // imageLoad only accepts int coords, not uint. + auto coord_expr = to_expression(ops[3]); + auto target_coord_type = expression_type(ops[3]); + target_coord_type.basetype = SPIRType::Int; + coord_expr = bitcast_expression(target_coord_type, expression_type(ops[3]).basetype, coord_expr); + + // Plain image load/store. + if (type.image.ms) + { + uint32_t operands = ops[4]; + if (operands != ImageOperandsSampleMask || length != 6) + SPIRV_CROSS_THROW("Multisampled image used in OpImageRead, but unexpected operand mask was used."); + + uint32_t samples = ops[5]; + imgexpr = + join("imageLoad(", to_expression(ops[2]), ", ", coord_expr, ", ", to_expression(samples), ")"); + } + else + imgexpr = join("imageLoad(", to_expression(ops[2]), ", ", coord_expr, ")"); + + imgexpr = remap_swizzle(get(result_type), 4, imgexpr); + pure = false; + } + + if (var && var->forwardable) + { + bool forward = forced_temporaries.find(id) == end(forced_temporaries); + auto &e = emit_op(result_type, id, imgexpr, forward); + + // We only need to track dependencies if we're reading from image load/store. + if (!pure) + { + e.loaded_from = var->self; + if (forward) + var->dependees.push_back(id); + } + } + else + emit_op(result_type, id, imgexpr, false); + break; + } + + case OpImageTexelPointer: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + auto &e = set(id, join(to_expression(ops[2]), ", ", to_expression(ops[3])), result_type, true); + + // When using the pointer, we need to know which variable it is actually loaded from. + auto *var = maybe_get_backing_variable(ops[2]); + e.loaded_from = var ? var->self : 0; + break; + } + + case OpImageWrite: + { + // We added Nonwritable speculatively to the OpImage variable due to glslangValidator + // not adding the proper qualifiers. + // If it turns out we need to write to the image after all, remove the qualifier and recompile. + auto *var = maybe_get_backing_variable(ops[0]); + if (var) + { + auto &flags = meta.at(var->self).decoration.decoration_flags; + if (flags & (1ull << DecorationNonWritable)) + { + flags &= ~(1ull << DecorationNonWritable); + force_recompile = true; + } + } + + auto &type = expression_type(ops[0]); + auto &value_type = expression_type(ops[2]); + auto store_type = value_type; + store_type.vecsize = 4; + + // imageStore only accepts int coords, not uint. + auto coord_expr = to_expression(ops[1]); + auto target_coord_type = expression_type(ops[1]); + target_coord_type.basetype = SPIRType::Int; + coord_expr = bitcast_expression(target_coord_type, expression_type(ops[1]).basetype, coord_expr); + + if (type.image.ms) + { + uint32_t operands = ops[3]; + if (operands != ImageOperandsSampleMask || length != 5) + SPIRV_CROSS_THROW("Multisampled image used in OpImageWrite, but unexpected operand mask was used."); + uint32_t samples = ops[4]; + statement("imageStore(", to_expression(ops[0]), ", ", coord_expr, ", ", to_expression(samples), ", ", + remap_swizzle(store_type, value_type.vecsize, to_expression(ops[2])), ");"); + } + else + statement("imageStore(", to_expression(ops[0]), ", ", coord_expr, ", ", + remap_swizzle(store_type, value_type.vecsize, to_expression(ops[2])), ");"); + + if (var && variable_storage_is_aliased(*var)) + flush_all_aliased_variables(); + break; + } + + case OpImageQuerySize: + { + auto &type = expression_type(ops[2]); + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + + if (type.basetype == SPIRType::Image) + { + string expr; + if (type.image.sampled == 2) + { + // The size of an image is always constant. + expr = join("imageSize(", to_expression(ops[2]), ")"); + } + else + { + // This path is hit for samplerBuffers and multisampled images which do not have LOD. + expr = join("textureSize(", to_expression(ops[2]), ")"); + } + + auto &restype = get(ops[0]); + expr = bitcast_expression(restype, SPIRType::Int, expr); + emit_op(result_type, id, expr, true); + } + else + SPIRV_CROSS_THROW("Invalid type for OpImageQuerySize."); + break; + } + + // Compute + case OpControlBarrier: + case OpMemoryBarrier: + { + if (get_entry_point().model == ExecutionModelTessellationControl) + { + // Control shaders only have barriers, and it implies memory barriers. + if (opcode == OpControlBarrier) + statement("barrier();"); + break; + } + + uint32_t memory; + uint32_t semantics; + + if (opcode == OpMemoryBarrier) + { + memory = get(ops[0]).scalar(); + semantics = get(ops[1]).scalar(); + } + else + { + memory = get(ops[1]).scalar(); + semantics = get(ops[2]).scalar(); + } + + // We only care about these flags, acquire/release and friends are not relevant to GLSL. + semantics = mask_relevant_memory_semantics(semantics); + + if (opcode == OpMemoryBarrier) + { + // If we are a memory barrier, and the next instruction is a control barrier, check if that memory barrier + // does what we need, so we avoid redundant barriers. + const Instruction *next = get_next_instruction_in_block(instruction); + if (next && next->op == OpControlBarrier) + { + auto *next_ops = stream(*next); + uint32_t next_memory = get(next_ops[1]).scalar(); + uint32_t next_semantics = get(next_ops[2]).scalar(); + next_semantics = mask_relevant_memory_semantics(next_semantics); + + bool memory_scope_covered = false; + if (next_memory == memory) + memory_scope_covered = true; + else if (next_semantics == MemorySemanticsWorkgroupMemoryMask) + { + // If we only care about workgroup memory, either Device or Workgroup scope is fine, + // scope does not have to match. + if ((next_memory == ScopeDevice || next_memory == ScopeWorkgroup) && + (memory == ScopeDevice || memory == ScopeWorkgroup)) + { + memory_scope_covered = true; + } + } + else if (memory == ScopeWorkgroup && next_memory == ScopeDevice) + { + // The control barrier has device scope, but the memory barrier just has workgroup scope. + memory_scope_covered = true; + } + + // If we have the same memory scope, and all memory types are covered, we're good. + if (memory_scope_covered && (semantics & next_semantics) == semantics) + break; + } + } + + // We are synchronizing some memory or syncing execution, + // so we cannot forward any loads beyond the memory barrier. + if (semantics || opcode == OpControlBarrier) + flush_all_active_variables(); + + if (memory == ScopeWorkgroup) // Only need to consider memory within a group + { + if (semantics == MemorySemanticsWorkgroupMemoryMask) + statement("memoryBarrierShared();"); + else if (semantics != 0) + statement("groupMemoryBarrier();"); + } + else + { + const uint32_t all_barriers = MemorySemanticsWorkgroupMemoryMask | MemorySemanticsUniformMemoryMask | + MemorySemanticsImageMemoryMask | MemorySemanticsAtomicCounterMemoryMask; + + if (semantics & (MemorySemanticsCrossWorkgroupMemoryMask | MemorySemanticsSubgroupMemoryMask)) + { + // These are not relevant for GLSL, but assume it means memoryBarrier(). + // memoryBarrier() does everything, so no need to test anything else. + statement("memoryBarrier();"); + } + else if ((semantics & all_barriers) == all_barriers) + { + // Short-hand instead of emitting 4 barriers. + statement("memoryBarrier();"); + } + else + { + // Pick out individual barriers. + if (semantics & MemorySemanticsWorkgroupMemoryMask) + statement("memoryBarrierShared();"); + if (semantics & MemorySemanticsUniformMemoryMask) + statement("memoryBarrierBuffer();"); + if (semantics & MemorySemanticsImageMemoryMask) + statement("memoryBarrierImage();"); + if (semantics & MemorySemanticsAtomicCounterMemoryMask) + statement("memoryBarrierAtomicCounter();"); + } + } + + if (opcode == OpControlBarrier) + statement("barrier();"); + break; + } + + case OpExtInst: + { + uint32_t extension_set = ops[2]; + + if (get(extension_set).ext == SPIRExtension::GLSL) + { + emit_glsl_op(ops[0], ops[1], ops[3], &ops[4], length - 4); + } + else if (get(extension_set).ext == SPIRExtension::SPV_AMD_shader_ballot) + { + emit_spv_amd_shader_ballot_op(ops[0], ops[1], ops[3], &ops[4], length - 4); + } + else if (get(extension_set).ext == SPIRExtension::SPV_AMD_shader_explicit_vertex_parameter) + { + emit_spv_amd_shader_explicit_vertex_parameter_op(ops[0], ops[1], ops[3], &ops[4], length - 4); + } + else if (get(extension_set).ext == SPIRExtension::SPV_AMD_shader_trinary_minmax) + { + emit_spv_amd_shader_trinary_minmax_op(ops[0], ops[1], ops[3], &ops[4], length - 4); + } + else if (get(extension_set).ext == SPIRExtension::SPV_AMD_gcn_shader) + { + emit_spv_amd_gcn_shader_op(ops[0], ops[1], ops[3], &ops[4], length - 4); + } + else + { + statement("// unimplemented ext op ", instruction.op); + break; + } + + break; + } + + case OpSubgroupBallotKHR: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + string expr; + expr = join("unpackUint2x32(ballotARB(" + to_expression(ops[2]) + "))"); + emit_op(result_type, id, expr, true); + + require_extension("GL_ARB_shader_ballot"); + break; + } + + case OpSubgroupFirstInvocationKHR: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + emit_unary_func_op(result_type, id, ops[2], "readFirstInvocationARB"); + + require_extension("GL_ARB_shader_ballot"); + break; + } + + case OpSubgroupReadInvocationKHR: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + emit_binary_func_op(result_type, id, ops[2], ops[3], "readInvocationARB"); + + require_extension("GL_ARB_shader_ballot"); + break; + } + + case OpSubgroupAllKHR: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + emit_unary_func_op(result_type, id, ops[2], "allInvocationsARB"); + + require_extension("GL_ARB_shader_group_vote"); + break; + } + + case OpSubgroupAnyKHR: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + emit_unary_func_op(result_type, id, ops[2], "anyInvocationARB"); + + require_extension("GL_ARB_shader_group_vote"); + break; + } + + case OpSubgroupAllEqualKHR: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + emit_unary_func_op(result_type, id, ops[2], "allInvocationsEqualARB"); + + require_extension("GL_ARB_shader_group_vote"); + break; + } + + case OpGroupIAddNonUniformAMD: + case OpGroupFAddNonUniformAMD: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + emit_unary_func_op(result_type, id, ops[4], "addInvocationsNonUniformAMD"); + + require_extension("GL_AMD_shader_ballot"); + break; + } + + case OpGroupFMinNonUniformAMD: + case OpGroupUMinNonUniformAMD: + case OpGroupSMinNonUniformAMD: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + emit_unary_func_op(result_type, id, ops[4], "minInvocationsNonUniformAMD"); + + require_extension("GL_AMD_shader_ballot"); + break; + } + + case OpGroupFMaxNonUniformAMD: + case OpGroupUMaxNonUniformAMD: + case OpGroupSMaxNonUniformAMD: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + emit_unary_func_op(result_type, id, ops[4], "maxInvocationsNonUniformAMD"); + + require_extension("GL_AMD_shader_ballot"); + break; + } + + case OpFragmentMaskFetchAMD: + { + auto &type = expression_type(ops[2]); + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + + if (type.image.dim == spv::DimSubpassData) + { + emit_unary_func_op(result_type, id, ops[2], "fragmentMaskFetchAMD"); + } + else + { + emit_binary_func_op(result_type, id, ops[2], ops[3], "fragmentMaskFetchAMD"); + } + + require_extension("GL_AMD_shader_fragment_mask"); + break; + } + + case OpFragmentFetchAMD: + { + auto &type = expression_type(ops[2]); + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + + if (type.image.dim == spv::DimSubpassData) + { + emit_binary_func_op(result_type, id, ops[2], ops[4], "fragmentFetchAMD"); + } + else + { + emit_trinary_func_op(result_type, id, ops[2], ops[3], ops[4], "fragmentFetchAMD"); + } + + require_extension("GL_AMD_shader_fragment_mask"); + break; + } + + default: + statement("// unimplemented op ", instruction.op); + break; + } +} + +// Appends function arguments, mapped from global variables, beyond the specified arg index. +// This is used when a function call uses fewer arguments than the function defines. +// This situation may occur if the function signature has been dynamically modified to +// extract global variables referenced from within the function, and convert them to +// function arguments. This is necessary for shader languages that do not support global +// access to shader input content from within a function (eg. Metal). Each additional +// function args uses the name of the global variable. Function nesting will modify the +// functions and function calls all the way up the nesting chain. +void CompilerGLSL::append_global_func_args(const SPIRFunction &func, uint32_t index, vector &arglist) +{ + auto &args = func.arguments; + uint32_t arg_cnt = uint32_t(args.size()); + for (uint32_t arg_idx = index; arg_idx < arg_cnt; arg_idx++) + { + auto &arg = args[arg_idx]; + assert(arg.alias_global_variable); + arglist.push_back(to_func_call_arg(arg.id)); + + // If the underlying variable needs to be declared + // (ie. a local variable with deferred declaration), do so now. + uint32_t var_id = get(arg.id).basevariable; + if (var_id) + flush_variable_declaration(var_id); + } +} + +string CompilerGLSL::to_member_name(const SPIRType &type, uint32_t index) +{ + auto &memb = meta[type.self].members; + if (index < memb.size() && !memb[index].alias.empty()) + return memb[index].alias; + else + return join("_m", index); +} + +void CompilerGLSL::add_member_name(SPIRType &type, uint32_t index) +{ + auto &memb = meta[type.self].members; + if (index < memb.size() && !memb[index].alias.empty()) + { + auto &name = memb[index].alias; + if (name.empty()) + return; + + // Reserved for temporaries. + if (name[0] == '_' && name.size() >= 2 && isdigit(name[1])) + { + name.clear(); + return; + } + + update_name_cache(type.member_name_cache, name); + } +} + +// Checks whether the ID is a row_major matrix that requires conversion before use +bool CompilerGLSL::is_non_native_row_major_matrix(uint32_t id) +{ + // Natively supported row-major matrices do not need to be converted. + // Legacy targets do not support row major. + if (backend.native_row_major_matrix && !is_legacy()) + return false; + + // Non-matrix or column-major matrix types do not need to be converted. + if (!(meta[id].decoration.decoration_flags & (1ull << DecorationRowMajor))) + return false; + + // Only square row-major matrices can be converted at this time. + // Converting non-square matrices will require defining custom GLSL function that + // swaps matrix elements while retaining the original dimensional form of the matrix. + const auto type = expression_type(id); + if (type.columns != type.vecsize) + SPIRV_CROSS_THROW("Row-major matrices must be square on this platform."); + + return true; +} + +// Checks whether the member is a row_major matrix that requires conversion before use +bool CompilerGLSL::member_is_non_native_row_major_matrix(const SPIRType &type, uint32_t index) +{ + // Natively supported row-major matrices do not need to be converted. + if (backend.native_row_major_matrix && !is_legacy()) + return false; + + // Non-matrix or column-major matrix types do not need to be converted. + if (!(combined_decoration_for_member(type, index) & (1ull << DecorationRowMajor))) + return false; + + // Only square row-major matrices can be converted at this time. + // Converting non-square matrices will require defining custom GLSL function that + // swaps matrix elements while retaining the original dimensional form of the matrix. + const auto mbr_type = get(type.member_types[index]); + if (mbr_type.columns != mbr_type.vecsize) + SPIRV_CROSS_THROW("Row-major matrices must be square on this platform."); + + return true; +} + +// Checks whether the member is in packed data type, that might need to be unpacked. +// GLSL does not define packed data types, but certain subclasses do. +bool CompilerGLSL::member_is_packed_type(const SPIRType &type, uint32_t index) const +{ + return has_member_decoration(type.self, index, DecorationCPacked); +} + +// Wraps the expression string in a function call that converts the +// row_major matrix result of the expression to a column_major matrix. +// Base implementation uses the standard library transpose() function. +// Subclasses may override to use a different function. +string CompilerGLSL::convert_row_major_matrix(string exp_str, const SPIRType & /*exp_type*/) +{ + strip_enclosed_expression(exp_str); + return join("transpose(", exp_str, ")"); +} + +string CompilerGLSL::variable_decl(const SPIRType &type, const string &name, uint32_t id) +{ + string type_name = type_to_glsl(type, id); + remap_variable_type_name(type, name, type_name); + return join(type_name, " ", name, type_to_array_glsl(type)); +} + +// Emit a structure member. Subclasses may override to modify output, +// or to dynamically add a padding member if needed. +void CompilerGLSL::emit_struct_member(const SPIRType &type, uint32_t member_type_id, uint32_t index, + const string &qualifier) +{ + auto &membertype = get(member_type_id); + + uint64_t memberflags = 0; + auto &memb = meta[type.self].members; + if (index < memb.size()) + memberflags = memb[index].decoration_flags; + + string qualifiers; + bool is_block = (meta[type.self].decoration.decoration_flags & + ((1ull << DecorationBlock) | (1ull << DecorationBufferBlock))) != 0; + if (is_block) + qualifiers = to_interpolation_qualifiers(memberflags); + + statement(layout_for_member(type, index), qualifiers, qualifier, + flags_to_precision_qualifiers_glsl(membertype, memberflags), + variable_decl(membertype, to_member_name(type, index)), ";"); +} + +const char *CompilerGLSL::flags_to_precision_qualifiers_glsl(const SPIRType &type, uint64_t flags) +{ + // Structs do not have precision qualifiers, neither do doubles (desktop only anyways, so no mediump/highp). + if (type.basetype != SPIRType::Float && type.basetype != SPIRType::Int && type.basetype != SPIRType::UInt && + type.basetype != SPIRType::Image && type.basetype != SPIRType::SampledImage && + type.basetype != SPIRType::Sampler) + return ""; + + if (options.es) + { + auto &execution = get_entry_point(); + + if (flags & (1ull << DecorationRelaxedPrecision)) + { + bool implied_fmediump = type.basetype == SPIRType::Float && + options.fragment.default_float_precision == Options::Mediump && + execution.model == ExecutionModelFragment; + + bool implied_imediump = (type.basetype == SPIRType::Int || type.basetype == SPIRType::UInt) && + options.fragment.default_int_precision == Options::Mediump && + execution.model == ExecutionModelFragment; + + return implied_fmediump || implied_imediump ? "" : "mediump "; + } + else + { + bool implied_fhighp = + type.basetype == SPIRType::Float && ((options.fragment.default_float_precision == Options::Highp && + execution.model == ExecutionModelFragment) || + (execution.model != ExecutionModelFragment)); + + bool implied_ihighp = (type.basetype == SPIRType::Int || type.basetype == SPIRType::UInt) && + ((options.fragment.default_int_precision == Options::Highp && + execution.model == ExecutionModelFragment) || + (execution.model != ExecutionModelFragment)); + + return implied_fhighp || implied_ihighp ? "" : "highp "; + } + } + else if (backend.allow_precision_qualifiers) + { + // Vulkan GLSL supports precision qualifiers, even in desktop profiles, which is convenient. + // The default is highp however, so only emit mediump in the rare case that a shader has these. + if (flags & (1ull << DecorationRelaxedPrecision)) + { + bool can_use_mediump = + type.basetype == SPIRType::Float || type.basetype == SPIRType::Int || type.basetype == SPIRType::UInt; + return can_use_mediump ? "mediump " : ""; + } + else + return ""; + } + else + return ""; +} + +const char *CompilerGLSL::to_precision_qualifiers_glsl(uint32_t id) +{ + return flags_to_precision_qualifiers_glsl(expression_type(id), meta[id].decoration.decoration_flags); +} + +string CompilerGLSL::to_qualifiers_glsl(uint32_t id) +{ + auto flags = meta[id].decoration.decoration_flags; + string res; + + auto *var = maybe_get(id); + + if (var && var->storage == StorageClassWorkgroup && !backend.shared_is_implied) + res += "shared "; + + res += to_interpolation_qualifiers(flags); + if (var) + res += to_storage_qualifiers_glsl(*var); + + auto &type = expression_type(id); + if (type.image.dim != DimSubpassData && type.image.sampled == 2) + { + if (flags & (1ull << DecorationCoherent)) + res += "coherent "; + if (flags & (1ull << DecorationRestrict)) + res += "restrict "; + if (flags & (1ull << DecorationNonWritable)) + res += "readonly "; + if (flags & (1ull << DecorationNonReadable)) + res += "writeonly "; + } + + res += to_precision_qualifiers_glsl(id); + + return res; +} + +string CompilerGLSL::argument_decl(const SPIRFunction::Parameter &arg) +{ + // glslangValidator seems to make all arguments pointer no matter what which is rather bizarre ... + auto &type = expression_type(arg.id); + const char *direction = ""; + + if (type.pointer) + { + if (arg.write_count && arg.read_count) + direction = "inout "; + else if (arg.write_count) + direction = "out "; + } + + return join(direction, to_qualifiers_glsl(arg.id), variable_decl(type, to_name(arg.id), arg.id)); +} + +string CompilerGLSL::variable_decl(const SPIRVariable &variable) +{ + // Ignore the pointer type since GLSL doesn't have pointers. + auto &type = get(variable.basetype); + + auto res = join(to_qualifiers_glsl(variable.self), variable_decl(type, to_name(variable.self), variable.self)); + + if (variable.loop_variable && variable.static_expression) + { + uint32_t expr = variable.static_expression; + if (ids[expr].get_type() != TypeUndef) + res += join(" = ", to_expression(variable.static_expression)); + } + else if (variable.initializer) + { + uint32_t expr = variable.initializer; + if (ids[expr].get_type() != TypeUndef) + res += join(" = ", to_expression(variable.initializer)); + } + return res; +} + +const char *CompilerGLSL::to_pls_qualifiers_glsl(const SPIRVariable &variable) +{ + auto flags = meta[variable.self].decoration.decoration_flags; + if (flags & (1ull << DecorationRelaxedPrecision)) + return "mediump "; + else + return "highp "; +} + +string CompilerGLSL::pls_decl(const PlsRemap &var) +{ + auto &variable = get(var.id); + + SPIRType type; + type.vecsize = pls_format_to_components(var.format); + type.basetype = pls_format_to_basetype(var.format); + + return join(to_pls_layout(var.format), to_pls_qualifiers_glsl(variable), type_to_glsl(type), " ", + to_name(variable.self)); +} + +uint32_t CompilerGLSL::to_array_size_literal(const SPIRType &type, uint32_t index) const +{ + assert(type.array.size() == type.array_size_literal.size()); + + if (!type.array_size_literal[index]) + SPIRV_CROSS_THROW("The array size is not a literal, but a specialization constant or spec constant op."); + + return type.array[index]; +} + +string CompilerGLSL::to_array_size(const SPIRType &type, uint32_t index) +{ + assert(type.array.size() == type.array_size_literal.size()); + + // Tessellation control shaders must have either gl_MaxPatchVertices or unsized arrays for input arrays. + // Opt for unsized as it's the more "correct" variant to use. + if (type.storage == StorageClassInput && get_entry_point().model == ExecutionModelTessellationControl) + return ""; + + auto &size = type.array[index]; + if (!type.array_size_literal[index]) + return to_expression(size); + else if (size) + return convert_to_string(size); + else if (!backend.flexible_member_array_supported) + { + // For runtime-sized arrays, we can work around + // lack of standard support for this by simply having + // a single element array. + // + // Runtime length arrays must always be the last element + // in an interface block. + return "1"; + } + else + return ""; +} + +string CompilerGLSL::type_to_array_glsl(const SPIRType &type) +{ + if (type.array.empty()) + return ""; + + if (options.flatten_multidimensional_arrays) + { + string res; + res += "["; + for (auto i = uint32_t(type.array.size()); i; i--) + { + res += enclose_expression(to_array_size(type, i - 1)); + if (i > 1) + res += " * "; + } + res += "]"; + return res; + } + else + { + if (type.array.size() > 1) + { + if (!options.es && options.version < 430) + require_extension("GL_ARB_arrays_of_arrays"); + else if (options.es && options.version < 310) + SPIRV_CROSS_THROW("Arrays of arrays not supported before ESSL version 310. " + "Try using --flatten-multidimensional-arrays or set " + "options.flatten_multidimensional_arrays to true."); + } + + string res; + for (auto i = uint32_t(type.array.size()); i; i--) + { + res += "["; + res += to_array_size(type, i - 1); + res += "]"; + } + return res; + } +} + +string CompilerGLSL::image_type_glsl(const SPIRType &type, uint32_t /* id */) +{ + auto &imagetype = get(type.image.type); + string res; + + switch (imagetype.basetype) + { + case SPIRType::Int: + res = "i"; + break; + case SPIRType::UInt: + res = "u"; + break; + default: + break; + } + + if (type.basetype == SPIRType::Image && type.image.dim == DimSubpassData && options.vulkan_semantics) + return res + "subpassInput" + (type.image.ms ? "MS" : ""); + + // If we're emulating subpassInput with samplers, force sampler2D + // so we don't have to specify format. + if (type.basetype == SPIRType::Image && type.image.dim != DimSubpassData) + { + // Sampler buffers are always declared as samplerBuffer even though they might be separate images in the SPIR-V. + if (type.image.dim == DimBuffer && type.image.sampled == 1) + res += "sampler"; + else + res += type.image.sampled == 2 ? "image" : "texture"; + } + else + res += "sampler"; + + switch (type.image.dim) + { + case Dim1D: + res += "1D"; + break; + case Dim2D: + res += "2D"; + break; + case Dim3D: + res += "3D"; + break; + case DimCube: + res += "Cube"; + break; + + case DimBuffer: + if (options.es && options.version < 320) + require_extension("GL_OES_texture_buffer"); + else if (!options.es && options.version < 300) + require_extension("GL_EXT_texture_buffer_object"); + res += "Buffer"; + break; + + case DimSubpassData: + res += "2D"; + break; + default: + SPIRV_CROSS_THROW("Only 1D, 2D, 3D, Buffer, InputTarget and Cube textures supported."); + } + + if (type.image.ms) + res += "MS"; + if (type.image.arrayed) + { + if (is_legacy_desktop()) + require_extension("GL_EXT_texture_array"); + res += "Array"; + } + if (type.image.depth) + res += "Shadow"; + + return res; +} + +string CompilerGLSL::type_to_glsl_constructor(const SPIRType &type) +{ + if (type.array.size() > 1) + { + if (options.flatten_multidimensional_arrays) + SPIRV_CROSS_THROW("Cannot flatten constructors of multidimensional array constructors, e.g. float[][]()."); + else if (!options.es && options.version < 430) + require_extension("GL_ARB_arrays_of_arrays"); + else if (options.es && options.version < 310) + SPIRV_CROSS_THROW("Arrays of arrays not supported before ESSL version 310."); + } + + auto e = type_to_glsl(type); + for (uint32_t i = 0; i < type.array.size(); i++) + e += "[]"; + return e; +} + +// The optional id parameter indicates the object whose type we are trying +// to find the description for. It is optional. Most type descriptions do not +// depend on a specific object's use of that type. +string CompilerGLSL::type_to_glsl(const SPIRType &type, uint32_t id) +{ + // Ignore the pointer type since GLSL doesn't have pointers. + + switch (type.basetype) + { + case SPIRType::Struct: + // Need OpName lookup here to get a "sensible" name for a struct. + if (backend.explicit_struct_type) + return join("struct ", to_name(type.self)); + else + return to_name(type.self); + + case SPIRType::Image: + case SPIRType::SampledImage: + return image_type_glsl(type, id); + + case SPIRType::Sampler: + // The depth field is set by calling code based on the variable ID of the sampler, effectively reintroducing + // this distinction into the type system. + return comparison_samplers.count(id) ? "samplerShadow" : "sampler"; + + case SPIRType::Void: + return "void"; + + default: + break; + } + + if (type.vecsize == 1 && type.columns == 1) // Scalar builtin + { + switch (type.basetype) + { + case SPIRType::Boolean: + return "bool"; + case SPIRType::Int: + return backend.basic_int_type; + case SPIRType::UInt: + return backend.basic_uint_type; + case SPIRType::AtomicCounter: + return "atomic_uint"; + case SPIRType::Float: + return "float"; + case SPIRType::Double: + return "double"; + case SPIRType::Int64: + return "int64_t"; + case SPIRType::UInt64: + return "uint64_t"; + default: + return "???"; + } + } + else if (type.vecsize > 1 && type.columns == 1) // Vector builtin + { + switch (type.basetype) + { + case SPIRType::Boolean: + return join("bvec", type.vecsize); + case SPIRType::Int: + return join("ivec", type.vecsize); + case SPIRType::UInt: + return join("uvec", type.vecsize); + case SPIRType::Float: + return join("vec", type.vecsize); + case SPIRType::Double: + return join("dvec", type.vecsize); + case SPIRType::Int64: + return join("i64vec", type.vecsize); + case SPIRType::UInt64: + return join("u64vec", type.vecsize); + default: + return "???"; + } + } + else if (type.vecsize == type.columns) // Simple Matrix builtin + { + switch (type.basetype) + { + case SPIRType::Boolean: + return join("bmat", type.vecsize); + case SPIRType::Int: + return join("imat", type.vecsize); + case SPIRType::UInt: + return join("umat", type.vecsize); + case SPIRType::Float: + return join("mat", type.vecsize); + case SPIRType::Double: + return join("dmat", type.vecsize); + // Matrix types not supported for int64/uint64. + default: + return "???"; + } + } + else + { + switch (type.basetype) + { + case SPIRType::Boolean: + return join("bmat", type.columns, "x", type.vecsize); + case SPIRType::Int: + return join("imat", type.columns, "x", type.vecsize); + case SPIRType::UInt: + return join("umat", type.columns, "x", type.vecsize); + case SPIRType::Float: + return join("mat", type.columns, "x", type.vecsize); + case SPIRType::Double: + return join("dmat", type.columns, "x", type.vecsize); + // Matrix types not supported for int64/uint64. + default: + return "???"; + } + } +} + +void CompilerGLSL::add_variable(unordered_set &variables, string &name) +{ + if (name.empty()) + return; + + // Reserved for temporaries. + if (name[0] == '_' && name.size() >= 2 && isdigit(name[1])) + { + name.clear(); + return; + } + + update_name_cache(variables, name); +} + +void CompilerGLSL::add_variable(unordered_set &variables, uint32_t id) +{ + auto &name = meta[id].decoration.alias; + add_variable(variables, name); +} + +void CompilerGLSL::add_local_variable_name(uint32_t id) +{ + add_variable(local_variable_names, id); +} + +void CompilerGLSL::add_resource_name(uint32_t id) +{ + add_variable(resource_names, id); +} + +void CompilerGLSL::add_header_line(const std::string &line) +{ + header_lines.push_back(line); +} + +bool CompilerGLSL::has_extension(const std::string &ext) const +{ + auto itr = find(begin(forced_extensions), end(forced_extensions), ext); + return itr != end(forced_extensions); +} + +void CompilerGLSL::require_extension(const string &ext) +{ + if (!has_extension(ext)) + { + forced_extensions.push_back(ext); + force_recompile = true; + } +} + +void CompilerGLSL::flatten_buffer_block(uint32_t id) +{ + auto &var = get(id); + auto &type = get(var.basetype); + auto name = to_name(type.self, false); + auto flags = meta.at(type.self).decoration.decoration_flags; + + if (!type.array.empty()) + SPIRV_CROSS_THROW(name + " is an array of UBOs."); + if (type.basetype != SPIRType::Struct) + SPIRV_CROSS_THROW(name + " is not a struct."); + if ((flags & (1ull << DecorationBlock)) == 0) + SPIRV_CROSS_THROW(name + " is not a block."); + if (type.member_types.empty()) + SPIRV_CROSS_THROW(name + " is an empty struct."); + + flattened_buffer_blocks.insert(id); +} + +bool CompilerGLSL::check_atomic_image(uint32_t id) +{ + auto &type = expression_type(id); + if (type.storage == StorageClassImage) + { + if (options.es && options.version < 320) + require_extension("GL_OES_shader_image_atomic"); + + auto *var = maybe_get_backing_variable(id); + if (var) + { + auto &flags = meta.at(var->self).decoration.decoration_flags; + if (flags & ((1ull << DecorationNonWritable) | (1ull << DecorationNonReadable))) + { + flags &= ~(1ull << DecorationNonWritable); + flags &= ~(1ull << DecorationNonReadable); + force_recompile = true; + } + } + return true; + } + else + return false; +} + +void CompilerGLSL::emit_function_prototype(SPIRFunction &func, uint64_t return_flags) +{ + // Avoid shadow declarations. + local_variable_names = resource_names; + + string decl; + + auto &type = get(func.return_type); + decl += flags_to_precision_qualifiers_glsl(type, return_flags); + decl += type_to_glsl(type); + decl += " "; + + if (func.self == entry_point) + { + decl += "main"; + processing_entry_point = true; + } + else + decl += to_name(func.self); + + decl += "("; + vector arglist; + for (auto &arg : func.arguments) + { + // Do not pass in separate images or samplers if we're remapping + // to combined image samplers. + if (skip_argument(arg.id)) + continue; + + // Might change the variable name if it already exists in this function. + // SPIRV OpName doesn't have any semantic effect, so it's valid for an implementation + // to use same name for variables. + // Since we want to make the GLSL debuggable and somewhat sane, use fallback names for variables which are duplicates. + add_local_variable_name(arg.id); + + arglist.push_back(argument_decl(arg)); + + // Hold a pointer to the parameter so we can invalidate the readonly field if needed. + auto *var = maybe_get(arg.id); + if (var) + var->parameter = &arg; + } + + for (auto &arg : func.shadow_arguments) + { + // Might change the variable name if it already exists in this function. + // SPIRV OpName doesn't have any semantic effect, so it's valid for an implementation + // to use same name for variables. + // Since we want to make the GLSL debuggable and somewhat sane, use fallback names for variables which are duplicates. + add_local_variable_name(arg.id); + + arglist.push_back(argument_decl(arg)); + + // Hold a pointer to the parameter so we can invalidate the readonly field if needed. + auto *var = maybe_get(arg.id); + if (var) + var->parameter = &arg; + } + + decl += merge(arglist); + decl += ")"; + statement(decl); +} + +void CompilerGLSL::emit_function(SPIRFunction &func, uint64_t return_flags) +{ + // Avoid potential cycles. + if (func.active) + return; + func.active = true; + + // If we depend on a function, emit that function before we emit our own function. + for (auto block : func.blocks) + { + auto &b = get(block); + for (auto &i : b.ops) + { + auto ops = stream(i); + auto op = static_cast(i.op); + + if (op == OpFunctionCall) + { + // Recursively emit functions which are called. + uint32_t id = ops[2]; + emit_function(get(id), meta[ops[1]].decoration.decoration_flags); + } + } + } + + emit_function_prototype(func, return_flags); + begin_scope(); + + current_function = &func; + auto &entry_block = get(func.entry_block); + + if (!func.analyzed_variable_scope) + { + analyze_variable_scope(func); + + // Check if we can actually use the loop variables we found in analyze_variable_scope. + // To use multiple initializers, we need the same type and qualifiers. + for (auto block : func.blocks) + { + auto &b = get(block); + if (b.loop_variables.size() < 2) + continue; + + uint64_t flags = get_decoration_mask(b.loop_variables.front()); + uint32_t type = get(b.loop_variables.front()).basetype; + bool invalid_initializers = false; + for (auto loop_variable : b.loop_variables) + { + if (flags != get_decoration_mask(loop_variable) || + type != get(b.loop_variables.front()).basetype) + { + invalid_initializers = true; + break; + } + } + + if (invalid_initializers) + { + for (auto loop_variable : b.loop_variables) + get(loop_variable).loop_variable = false; + b.loop_variables.clear(); + } + } + func.analyzed_variable_scope = true; + } + + for (auto &v : func.local_variables) + { + auto &var = get(v); + if (expression_is_lvalue(v)) + { + add_local_variable_name(var.self); + + if (var.initializer) + statement(variable_decl_function_local(var), ";"); + else + { + // Don't declare variable until first use to declutter the GLSL output quite a lot. + // If we don't touch the variable before first branch, + // declare it then since we need variable declaration to be in top scope. + // Never declare empty structs. They have no meaningful representation. + auto &type = get(var.basetype); + bool empty_struct = type.basetype == SPIRType::Struct && type.member_types.empty(); + var.deferred_declaration = !empty_struct; + } + } + else + { + // HACK: SPIR-V in older glslang output likes to use samplers and images as local variables, but GLSL does not allow this. + // For these types (non-lvalue), we enforce forwarding through a shadowed variable. + // This means that when we OpStore to these variables, we just write in the expression ID directly. + // This breaks any kind of branching, since the variable must be statically assigned. + // Branching on samplers and images would be pretty much impossible to fake in GLSL. + var.statically_assigned = true; + } + + var.loop_variable_enable = false; + + // Loop variables are never declared outside their for-loop, so block any implicit declaration. + if (var.loop_variable) + var.deferred_declaration = false; + } + + entry_block.loop_dominator = SPIRBlock::NoDominator; + emit_block_chain(entry_block); + + end_scope(); + processing_entry_point = false; + statement(""); +} + +void CompilerGLSL::emit_fixup() +{ + auto &execution = get_entry_point(); + if (execution.model == ExecutionModelVertex) + { + if (options.vertex.fixup_clipspace) + { + const char *suffix = backend.float_literal_suffix ? "f" : ""; + statement("gl_Position.z = 2.0", suffix, " * gl_Position.z - gl_Position.w;"); + } + + if (options.vertex.flip_vert_y) + statement("gl_Position.y = -gl_Position.y;"); + } +} + +bool CompilerGLSL::flush_phi_required(uint32_t from, uint32_t to) +{ + auto &child = get(to); + for (auto &phi : child.phi_variables) + if (phi.parent == from) + return true; + return false; +} + +void CompilerGLSL::flush_phi(uint32_t from, uint32_t to) +{ + auto &child = get(to); + + for (auto &phi : child.phi_variables) + { + if (phi.parent == from) + { + auto &var = get(phi.function_variable); + + // A Phi variable might be a loop variable, so flush to static expression. + if (var.loop_variable && !var.loop_variable_enable) + var.static_expression = phi.local_variable; + else + { + flush_variable_declaration(phi.function_variable); + + // This might be called in continue block, so make sure we + // use this to emit ESSL 1.0 compliant increments/decrements. + auto lhs = to_expression(phi.function_variable); + auto rhs = to_expression(phi.local_variable); + if (!optimize_read_modify_write(lhs, rhs)) + statement(lhs, " = ", rhs, ";"); + } + } + } +} + +void CompilerGLSL::branch(uint32_t from, uint32_t to) +{ + flush_phi(from, to); + flush_all_active_variables(); + + // This is only a continue if we branch to our loop dominator. + if (loop_blocks.find(to) != end(loop_blocks) && get(from).loop_dominator == to) + { + // This can happen if we had a complex continue block which was emitted. + // Once the continue block tries to branch to the loop header, just emit continue; + // and end the chain here. + statement("continue;"); + } + else if (is_continue(to)) + { + auto &to_block = get(to); + if (to_block.complex_continue) + { + // Just emit the whole block chain as is. + auto usage_counts = expression_usage_counts; + auto invalid = invalid_expressions; + + emit_block_chain(to_block); + + // Expression usage counts and invalid expressions + // are moot after returning from the continue block. + // Since we emit the same block multiple times, + // we don't want to invalidate ourselves. + expression_usage_counts = usage_counts; + invalid_expressions = invalid; + } + else + { + auto &from_block = get(from); + bool outside_control_flow = false; + uint32_t loop_dominator = 0; + + // FIXME: Refactor this to not use the old loop_dominator tracking. + if (from_block.merge_block) + { + // If we are a loop header, we don't set the loop dominator, + // so just use "self" here. + loop_dominator = from; + } + else if (from_block.loop_dominator != -1u) + { + loop_dominator = from_block.loop_dominator; + } + + if (loop_dominator != 0) + { + auto &dominator = get(loop_dominator); + + // For non-complex continue blocks, we implicitly branch to the continue block + // by having the continue block be part of the loop header in for (; ; continue-block). + outside_control_flow = block_is_outside_flow_control_from_block(dominator, from_block); + } + + // Some simplification for for-loops. We always end up with a useless continue; + // statement since we branch to a loop block. + // Walk the CFG, if we uncoditionally execute the block calling continue assuming we're in the loop block, + // we can avoid writing out an explicit continue statement. + // Similar optimization to return statements if we know we're outside flow control. + if (!outside_control_flow) + statement("continue;"); + } + } + else if (is_break(to)) + statement("break;"); + else if (!is_conditional(to)) + emit_block_chain(get(to)); +} + +void CompilerGLSL::branch(uint32_t from, uint32_t cond, uint32_t true_block, uint32_t false_block) +{ + // If we branch directly to a selection merge target, we don't really need a code path. + bool true_sub = !is_conditional(true_block); + bool false_sub = !is_conditional(false_block); + + if (true_sub) + { + statement("if (", to_expression(cond), ")"); + begin_scope(); + branch(from, true_block); + end_scope(); + + if (false_sub) + { + statement("else"); + begin_scope(); + branch(from, false_block); + end_scope(); + } + else if (flush_phi_required(from, false_block)) + { + statement("else"); + begin_scope(); + flush_phi(from, false_block); + end_scope(); + } + } + else if (false_sub && !true_sub) + { + // Only need false path, use negative conditional. + statement("if (!", to_expression(cond), ")"); + begin_scope(); + branch(from, false_block); + end_scope(); + + if (flush_phi_required(from, true_block)) + { + statement("else"); + begin_scope(); + flush_phi(from, true_block); + end_scope(); + } + } +} + +void CompilerGLSL::propagate_loop_dominators(const SPIRBlock &block) +{ + // Propagate down the loop dominator block, so that dominated blocks can back trace. + if (block.merge == SPIRBlock::MergeLoop || block.loop_dominator) + { + uint32_t dominator = block.merge == SPIRBlock::MergeLoop ? block.self : block.loop_dominator; + + auto set_dominator = [this](uint32_t self, uint32_t new_dominator) { + auto &dominated_block = this->get(self); + + // If we already have a loop dominator, we're trying to break out to merge targets + // which should not update the loop dominator. + if (!dominated_block.loop_dominator) + dominated_block.loop_dominator = new_dominator; + }; + + // After merging a loop, we inherit the loop dominator always. + if (block.merge_block) + set_dominator(block.merge_block, block.loop_dominator); + + if (block.true_block) + set_dominator(block.true_block, dominator); + if (block.false_block) + set_dominator(block.false_block, dominator); + if (block.next_block) + set_dominator(block.next_block, dominator); + + for (auto &c : block.cases) + set_dominator(c.block, dominator); + + // In older glslang output continue_block can be == loop header. + if (block.continue_block && block.continue_block != block.self) + set_dominator(block.continue_block, dominator); + } +} + +// FIXME: This currently cannot handle complex continue blocks +// as in do-while. +// This should be seen as a "trivial" continue block. +string CompilerGLSL::emit_continue_block(uint32_t continue_block) +{ + auto *block = &get(continue_block); + + // While emitting the continue block, declare_temporary will check this + // if we have to emit temporaries. + current_continue_block = block; + + vector statements; + + // Capture all statements into our list. + auto *old = redirect_statement; + redirect_statement = &statements; + + // Stamp out all blocks one after each other. + while (loop_blocks.find(block->self) == end(loop_blocks)) + { + propagate_loop_dominators(*block); + // Write out all instructions we have in this block. + emit_block_instructions(*block); + + // For plain branchless for/while continue blocks. + if (block->next_block) + { + flush_phi(continue_block, block->next_block); + block = &get(block->next_block); + } + // For do while blocks. The last block will be a select block. + else if (block->true_block) + { + flush_phi(continue_block, block->true_block); + block = &get(block->true_block); + } + } + + // Restore old pointer. + redirect_statement = old; + + // Somewhat ugly, strip off the last ';' since we use ',' instead. + // Ideally, we should select this behavior in statement(). + for (auto &s : statements) + { + if (!s.empty() && s.back() == ';') + s.erase(s.size() - 1, 1); + } + + current_continue_block = nullptr; + return merge(statements); +} + +string CompilerGLSL::emit_for_loop_initializers(const SPIRBlock &block) +{ + if (block.loop_variables.empty()) + return ""; + + bool same_types = for_loop_initializers_are_same_type(block); + // We can only declare for loop initializers if all variables are of same type. + // If we cannot do this, declare individual variables before the loop header. + + // We might have a loop variable candidate which was not assigned to for some reason. + uint32_t missing_initializers = 0; + for (auto &variable : block.loop_variables) + { + uint32_t expr = get(variable).static_expression; + + // Sometimes loop variables are initialized with OpUndef, but we can just declare + // a plain variable without initializer in this case. + if (expr == 0 || ids[expr].get_type() == TypeUndef) + missing_initializers++; + } + + if (block.loop_variables.size() == 1 && missing_initializers == 0) + { + return variable_decl(get(block.loop_variables.front())); + } + else if (!same_types || missing_initializers == uint32_t(block.loop_variables.size())) + { + for (auto &loop_var : block.loop_variables) + statement(variable_decl(get(loop_var)), ";"); + return ""; + } + else + { + // We have a mix of loop variables, either ones with a clear initializer, or ones without. + // Separate the two streams. + string expr; + + for (auto &loop_var : block.loop_variables) + { + uint32_t static_expr = get(loop_var).static_expression; + if (static_expr == 0 || ids[static_expr].get_type() == TypeUndef) + { + statement(variable_decl(get(loop_var)), ";"); + } + else + { + if (expr.empty()) + { + // For loop initializers are of the form (block.loop_variables.front()); + auto &type = get(var.basetype); + expr = join(to_qualifiers_glsl(var.self), type_to_glsl(type), " "); + } + else + expr += ", "; + + auto &v = get(loop_var); + expr += join(to_name(loop_var), " = ", to_expression(v.static_expression)); + } + } + return expr; + } +} + +bool CompilerGLSL::for_loop_initializers_are_same_type(const SPIRBlock &block) +{ + if (block.loop_variables.size() <= 1) + return true; + + uint32_t expected = 0; + uint64_t expected_flags = 0; + for (auto &var : block.loop_variables) + { + // Don't care about uninitialized variables as they will not be part of the initializers. + uint32_t expr = get(var).static_expression; + if (expr == 0 || ids[expr].get_type() == TypeUndef) + continue; + + if (expected == 0) + { + expected = get(var).basetype; + expected_flags = get_decoration_mask(var); + } + else if (expected != get(var).basetype) + return false; + + // Precision flags and things like that must also match. + if (expected_flags != get_decoration_mask(var)) + return false; + } + + return true; +} + +bool CompilerGLSL::attempt_emit_loop_header(SPIRBlock &block, SPIRBlock::Method method) +{ + SPIRBlock::ContinueBlockType continue_type = continue_block_type(get(block.continue_block)); + + if (method == SPIRBlock::MergeToSelectForLoop) + { + uint32_t current_count = statement_count; + // If we're trying to create a true for loop, + // we need to make sure that all opcodes before branch statement do not actually emit any code. + // We can then take the condition expression and create a for (; cond ; ) { body; } structure instead. + emit_block_instructions(block); + + bool condition_is_temporary = forced_temporaries.find(block.condition) == end(forced_temporaries); + + // This can work! We only did trivial things which could be forwarded in block body! + if (current_count == statement_count && condition_is_temporary) + { + switch (continue_type) + { + case SPIRBlock::ForLoop: + { + // This block may be a dominating block, so make sure we flush undeclared variables before building the for loop header. + flush_undeclared_variables(block); + + // Important that we do this in this order because + // emitting the continue block can invalidate the condition expression. + auto initializer = emit_for_loop_initializers(block); + auto condition = to_expression(block.condition); + auto continue_block = emit_continue_block(block.continue_block); + statement("for (", initializer, "; ", condition, "; ", continue_block, ")"); + break; + } + + case SPIRBlock::WhileLoop: + // This block may be a dominating block, so make sure we flush undeclared variables before building the while loop header. + flush_undeclared_variables(block); + statement("while (", to_expression(block.condition), ")"); + break; + + default: + SPIRV_CROSS_THROW("For/while loop detected, but need while/for loop semantics."); + } + + begin_scope(); + return true; + } + else + { + block.disable_block_optimization = true; + force_recompile = true; + begin_scope(); // We'll see an end_scope() later. + return false; + } + } + else if (method == SPIRBlock::MergeToDirectForLoop) + { + auto &child = get(block.next_block); + + // This block may be a dominating block, so make sure we flush undeclared variables before building the for loop header. + flush_undeclared_variables(child); + + uint32_t current_count = statement_count; + + // If we're trying to create a true for loop, + // we need to make sure that all opcodes before branch statement do not actually emit any code. + // We can then take the condition expression and create a for (; cond ; ) { body; } structure instead. + emit_block_instructions(child); + + bool condition_is_temporary = forced_temporaries.find(child.condition) == end(forced_temporaries); + + if (current_count == statement_count && condition_is_temporary) + { + propagate_loop_dominators(child); + + switch (continue_type) + { + case SPIRBlock::ForLoop: + { + // Important that we do this in this order because + // emitting the continue block can invalidate the condition expression. + auto initializer = emit_for_loop_initializers(block); + auto condition = to_expression(child.condition); + auto continue_block = emit_continue_block(block.continue_block); + statement("for (", initializer, "; ", condition, "; ", continue_block, ")"); + break; + } + + case SPIRBlock::WhileLoop: + statement("while (", to_expression(child.condition), ")"); + break; + + default: + SPIRV_CROSS_THROW("For/while loop detected, but need while/for loop semantics."); + } + + begin_scope(); + branch(child.self, child.true_block); + return true; + } + else + { + block.disable_block_optimization = true; + force_recompile = true; + begin_scope(); // We'll see an end_scope() later. + return false; + } + } + else + return false; +} + +void CompilerGLSL::flush_undeclared_variables(SPIRBlock &block) +{ + // Enforce declaration order for regression testing purposes. + sort(begin(block.dominated_variables), end(block.dominated_variables)); + + for (auto &v : block.dominated_variables) + { + auto &var = get(v); + if (var.deferred_declaration) + statement(variable_decl(var), ";"); + var.deferred_declaration = false; + } +} + +void CompilerGLSL::emit_block_chain(SPIRBlock &block) +{ + propagate_loop_dominators(block); + + bool select_branch_to_true_block = false; + bool skip_direct_branch = false; + bool emitted_for_loop_header = false; + + // If we need to force temporaries for certain IDs due to continue blocks, do it before starting loop header. + // Need to sort these to ensure that reference output is stable. + sort(begin(block.declare_temporary), end(block.declare_temporary), + [](const pair &a, const pair &b) { return a.second < b.second; }); + + for (auto &tmp : block.declare_temporary) + { + auto flags = meta[tmp.second].decoration.decoration_flags; + auto &type = get(tmp.first); + statement(flags_to_precision_qualifiers_glsl(type, flags), variable_decl(type, to_name(tmp.second)), ";"); + } + + SPIRBlock::ContinueBlockType continue_type = SPIRBlock::ContinueNone; + if (block.continue_block) + continue_type = continue_block_type(get(block.continue_block)); + + // If we have loop variables, stop masking out access to the variable now. + for (auto var : block.loop_variables) + get(var).loop_variable_enable = true; + + // This is the older loop behavior in glslang which branches to loop body directly from the loop header. + if (block_is_loop_candidate(block, SPIRBlock::MergeToSelectForLoop)) + { + flush_undeclared_variables(block); + if (attempt_emit_loop_header(block, SPIRBlock::MergeToSelectForLoop)) + { + // The body of while, is actually just the true block, so always branch there unconditionally. + select_branch_to_true_block = true; + emitted_for_loop_header = true; + } + } + // This is the newer loop behavior in glslang which branches from Loop header directly to + // a new block, which in turn has a OpBranchSelection without a selection merge. + else if (block_is_loop_candidate(block, SPIRBlock::MergeToDirectForLoop)) + { + flush_undeclared_variables(block); + if (attempt_emit_loop_header(block, SPIRBlock::MergeToDirectForLoop)) + { + skip_direct_branch = true; + emitted_for_loop_header = true; + } + } + else if (continue_type == SPIRBlock::DoWhileLoop) + { + flush_undeclared_variables(block); + statement("do"); + begin_scope(); + + emit_block_instructions(block); + } + else if (block.merge == SPIRBlock::MergeLoop) + { + flush_undeclared_variables(block); + + // We have a generic loop without any distinguishable pattern like for, while or do while. + get(block.continue_block).complex_continue = true; + continue_type = SPIRBlock::ComplexLoop; + + statement("for (;;)"); + begin_scope(); + + emit_block_instructions(block); + } + else + { + emit_block_instructions(block); + } + + // If we didn't successfully emit a loop header and we had loop variable candidates, we have a problem + // as writes to said loop variables might have been masked out, we need a recompile. + if (!emitted_for_loop_header && !block.loop_variables.empty()) + { + force_recompile = true; + for (auto var : block.loop_variables) + get(var).loop_variable = false; + block.loop_variables.clear(); + } + + flush_undeclared_variables(block); + bool emit_next_block = true; + + // Handle end of block. + switch (block.terminator) + { + case SPIRBlock::Direct: + // True when emitting complex continue block. + if (block.loop_dominator == block.next_block) + { + branch(block.self, block.next_block); + emit_next_block = false; + } + // True if MergeToDirectForLoop succeeded. + else if (skip_direct_branch) + emit_next_block = false; + else if (is_continue(block.next_block) || is_break(block.next_block) || is_conditional(block.next_block)) + { + branch(block.self, block.next_block); + emit_next_block = false; + } + break; + + case SPIRBlock::Select: + // True if MergeToSelectForLoop succeeded. + if (select_branch_to_true_block) + branch(block.self, block.true_block); + else + branch(block.self, block.condition, block.true_block, block.false_block); + break; + + case SPIRBlock::MultiSelect: + { + auto &type = expression_type(block.condition); + bool uint32_t_case = type.basetype == SPIRType::UInt; + + statement("switch (", to_expression(block.condition), ")"); + begin_scope(); + + for (auto &c : block.cases) + { + auto case_value = + uint32_t_case ? convert_to_string(uint32_t(c.value)) : convert_to_string(int32_t(c.value)); + statement("case ", case_value, ":"); + begin_scope(); + branch(block.self, c.block); + end_scope(); + } + + if (block.default_block != block.next_block) + { + statement("default:"); + begin_scope(); + if (is_break(block.default_block)) + SPIRV_CROSS_THROW("Cannot break; out of a switch statement and out of a loop at the same time ..."); + branch(block.self, block.default_block); + end_scope(); + } + else if (flush_phi_required(block.self, block.next_block)) + { + statement("default:"); + begin_scope(); + flush_phi(block.self, block.next_block); + statement("break;"); + end_scope(); + } + + end_scope(); + break; + } + + case SPIRBlock::Return: + if (processing_entry_point) + emit_fixup(); + + if (block.return_value) + { + // OpReturnValue can return Undef, so don't emit anything for this case. + if (ids.at(block.return_value).get_type() != TypeUndef) + statement("return ", to_expression(block.return_value), ";"); + } + // If this block is the very final block and not called from control flow, + // we do not need an explicit return which looks out of place. Just end the function here. + // In the very weird case of for(;;) { return; } executing return is unconditional, + // but we actually need a return here ... + else if (!block_is_outside_flow_control_from_block(get(current_function->entry_block), block) || + block.loop_dominator != SPIRBlock::NoDominator) + statement("return;"); + break; + + case SPIRBlock::Kill: + statement(backend.discard_literal, ";"); + break; + + case SPIRBlock::Unreachable: + emit_next_block = false; + break; + + default: + SPIRV_CROSS_THROW("Unimplemented block terminator."); + } + + if (block.next_block && emit_next_block) + { + // If we hit this case, we're dealing with an unconditional branch, which means we will output + // that block after this. If we had selection merge, we already flushed phi variables. + if (block.merge != SPIRBlock::MergeSelection) + flush_phi(block.self, block.next_block); + emit_block_chain(get(block.next_block)); + } + + if (block.merge == SPIRBlock::MergeLoop) + { + if (continue_type == SPIRBlock::DoWhileLoop) + { + // Make sure that we run the continue block to get the expressions set, but this + // should become an empty string. + // We have no fallbacks if we cannot forward everything to temporaries ... + auto statements = emit_continue_block(block.continue_block); + if (!statements.empty()) + { + // The DoWhile block has side effects, force ComplexLoop pattern next pass. + get(block.continue_block).complex_continue = true; + force_recompile = true; + } + + end_scope_decl(join("while (", to_expression(get(block.continue_block).condition), ")")); + } + else + end_scope(); + + flush_phi(block.self, block.merge_block); + emit_block_chain(get(block.merge_block)); + } +} + +void CompilerGLSL::begin_scope() +{ + statement("{"); + indent++; +} + +void CompilerGLSL::end_scope() +{ + if (!indent) + SPIRV_CROSS_THROW("Popping empty indent stack."); + indent--; + statement("}"); +} + +void CompilerGLSL::end_scope_decl() +{ + if (!indent) + SPIRV_CROSS_THROW("Popping empty indent stack."); + indent--; + statement("};"); +} + +void CompilerGLSL::end_scope_decl(const string &decl) +{ + if (!indent) + SPIRV_CROSS_THROW("Popping empty indent stack."); + indent--; + statement("} ", decl, ";"); +} + +void CompilerGLSL::check_function_call_constraints(const uint32_t *args, uint32_t length) +{ + // If our variable is remapped, and we rely on type-remapping information as + // well, then we cannot pass the variable as a function parameter. + // Fixing this is non-trivial without stamping out variants of the same function, + // so for now warn about this and suggest workarounds instead. + for (uint32_t i = 0; i < length; i++) + { + auto *var = maybe_get(args[i]); + if (!var || !var->remapped_variable) + continue; + + auto &type = get(var->basetype); + if (type.basetype == SPIRType::Image && type.image.dim == DimSubpassData) + { + SPIRV_CROSS_THROW("Tried passing a remapped subpassInput variable to a function. " + "This will not work correctly because type-remapping information is lost. " + "To workaround, please consider not passing the subpass input as a function parameter, " + "or use in/out variables instead which do not need type remapping information."); + } + } +} + +const Instruction *CompilerGLSL::get_next_instruction_in_block(const Instruction &instr) +{ + // FIXME: This is kind of hacky. There should be a cleaner way. + auto offset = uint32_t(&instr - current_emitting_block->ops.data()); + if ((offset + 1) < current_emitting_block->ops.size()) + return ¤t_emitting_block->ops[offset + 1]; + else + return nullptr; +} + +uint32_t CompilerGLSL::mask_relevant_memory_semantics(uint32_t semantics) +{ + return semantics & (MemorySemanticsAtomicCounterMemoryMask | MemorySemanticsImageMemoryMask | + MemorySemanticsWorkgroupMemoryMask | MemorySemanticsUniformMemoryMask | + MemorySemanticsCrossWorkgroupMemoryMask | MemorySemanticsSubgroupMemoryMask); +} diff --git a/spirv_glsl.hpp b/spirv_glsl.hpp new file mode 100644 index 0000000000..0cae70c09b --- /dev/null +++ b/spirv_glsl.hpp @@ -0,0 +1,535 @@ +/* + * Copyright 2015-2018 ARM Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SPIRV_CROSS_GLSL_HPP +#define SPIRV_CROSS_GLSL_HPP + +#include "spirv_cross.hpp" +#include +#include +#include +#include + +namespace spirv_cross +{ +enum PlsFormat +{ + PlsNone = 0, + + PlsR11FG11FB10F, + PlsR32F, + PlsRG16F, + PlsRGB10A2, + PlsRGBA8, + PlsRG16, + + PlsRGBA8I, + PlsRG16I, + + PlsRGB10A2UI, + PlsRGBA8UI, + PlsRG16UI, + PlsR32UI +}; + +struct PlsRemap +{ + uint32_t id; + PlsFormat format; +}; + +class CompilerGLSL : public Compiler +{ +public: + struct Options + { + // The shading language version. Corresponds to #version $VALUE. + uint32_t version = 450; + + // Emit the OpenGL ES shading language instead of desktop OpenGL. + bool es = false; + + // Debug option to always emit temporary variables for all expressions. + bool force_temporary = false; + + // If true, Vulkan GLSL features are used instead of GL-compatible features. + // Mostly useful for debugging SPIR-V files. + bool vulkan_semantics = false; + + // If true, gl_PerVertex is explicitly redeclared in vertex, geometry and tessellation shaders. + // The members of gl_PerVertex is determined by which built-ins are declared by the shader. + // This option is ignored in ES versions, as redeclaration in ES is not required, and it depends on a different extension + // (EXT_shader_io_blocks) which makes things a bit more fuzzy. + bool separate_shader_objects = false; + + // Flattens multidimensional arrays, e.g. float foo[a][b][c] into single-dimensional arrays, + // e.g. float foo[a * b * c]. + // This function does not change the actual SPIRType of any object. + // Only the generated code, including declarations of interface variables are changed to be single array dimension. + bool flatten_multidimensional_arrays = false; + + // For older desktop GLSL targets than version 420, the + // GL_ARB_shading_language_420pack extensions is used to be able to support + // layout(binding) on UBOs and samplers. + // If disabled on older targets, binding decorations will be stripped. + bool enable_420pack_extension = true; + + enum Precision + { + DontCare, + Lowp, + Mediump, + Highp + }; + + struct + { + // GLSL: In vertex shaders, rewrite [0, w] depth (Vulkan/D3D style) to [-w, w] depth (GL style). + // MSL: In vertex shaders, rewrite [-w, w] depth (GL style) to [0, w] depth. + // HLSL: In vertex shaders, rewrite [-w, w] depth (GL style) to [0, w] depth. + bool fixup_clipspace = false; + + // Inverts gl_Position.y or equivalent. + bool flip_vert_y = false; + } vertex; + + struct + { + // Add precision mediump float in ES targets when emitting GLES source. + // Add precision highp int in ES targets when emitting GLES source. + Precision default_float_precision = Mediump; + Precision default_int_precision = Highp; + } fragment; + }; + + void remap_pixel_local_storage(std::vector inputs, std::vector outputs) + { + pls_inputs = std::move(inputs); + pls_outputs = std::move(outputs); + remap_pls_variables(); + } + + CompilerGLSL(std::vector spirv_) + : Compiler(move(spirv_)) + { + init(); + } + + CompilerGLSL(const uint32_t *ir, size_t word_count) + : Compiler(ir, word_count) + { + init(); + } + + const Options &get_options() const + { + return options; + } + void set_options(Options &opts) + { + options = opts; + } + + std::string compile() override; + + // Returns the current string held in the conversion buffer. Useful for + // capturing what has been converted so far when compile() throws an error. + std::string get_partial_source(); + + // Adds a line to be added right after #version in GLSL backend. + // This is useful for enabling custom extensions which are outside the scope of SPIRV-Cross. + // This can be combined with variable remapping. + // A new-line will be added. + // + // While add_header_line() is a more generic way of adding arbitrary text to the header + // of a GLSL file, require_extension() should be used when adding extensions since it will + // avoid creating collisions with SPIRV-Cross generated extensions. + // + // Code added via add_header_line() is typically backend-specific. + void add_header_line(const std::string &str); + + // Adds an extension which is required to run this shader, e.g. + // require_extension("GL_KHR_my_extension"); + void require_extension(const std::string &ext); + + // Legacy GLSL compatibility method. + // Takes a uniform or push constant variable and flattens it into a (i|u)vec4 array[N]; array instead. + // For this to work, all types in the block must be the same basic type, e.g. mixing vec2 and vec4 is fine, but + // mixing int and float is not. + // The name of the uniform array will be the same as the interface block name. + void flatten_buffer_block(uint32_t id); + +protected: + void reset(); + void emit_function(SPIRFunction &func, uint64_t return_flags); + + bool has_extension(const std::string &ext) const; + + // Virtualize methods which need to be overridden by subclass targets like C++ and such. + virtual void emit_function_prototype(SPIRFunction &func, uint64_t return_flags); + + // Kinda ugly way to let opcodes peek at their neighbor instructions for trivial peephole scenarios. + const SPIRBlock *current_emitting_block = nullptr; + + virtual void emit_instruction(const Instruction &instr); + void emit_block_instructions(const SPIRBlock &block); + virtual void emit_glsl_op(uint32_t result_type, uint32_t result_id, uint32_t op, const uint32_t *args, + uint32_t count); + virtual void emit_spv_amd_shader_ballot_op(uint32_t result_type, uint32_t result_id, uint32_t op, + const uint32_t *args, uint32_t count); + virtual void emit_spv_amd_shader_explicit_vertex_parameter_op(uint32_t result_type, uint32_t result_id, uint32_t op, + const uint32_t *args, uint32_t count); + virtual void emit_spv_amd_shader_trinary_minmax_op(uint32_t result_type, uint32_t result_id, uint32_t op, + const uint32_t *args, uint32_t count); + virtual void emit_spv_amd_gcn_shader_op(uint32_t result_type, uint32_t result_id, uint32_t op, const uint32_t *args, + uint32_t count); + virtual void emit_header(); + virtual void emit_sampled_image_op(uint32_t result_type, uint32_t result_id, uint32_t image_id, uint32_t samp_id); + virtual void emit_texture_op(const Instruction &i); + virtual std::string type_to_glsl(const SPIRType &type, uint32_t id = 0); + virtual std::string builtin_to_glsl(spv::BuiltIn builtin, spv::StorageClass storage); + virtual void emit_struct_member(const SPIRType &type, uint32_t member_type_id, uint32_t index, + const std::string &qualifier = ""); + virtual std::string image_type_glsl(const SPIRType &type, uint32_t id = 0); + virtual std::string constant_expression(const SPIRConstant &c); + std::string constant_op_expression(const SPIRConstantOp &cop); + virtual std::string constant_expression_vector(const SPIRConstant &c, uint32_t vector); + virtual void emit_fixup(); + virtual std::string variable_decl(const SPIRType &type, const std::string &name, uint32_t id = 0); + virtual std::string to_func_call_arg(uint32_t id); + virtual std::string to_function_name(uint32_t img, const SPIRType &imgtype, bool is_fetch, bool is_gather, + bool is_proj, bool has_array_offsets, bool has_offset, bool has_grad, + bool has_dref, uint32_t lod); + virtual std::string to_function_args(uint32_t img, const SPIRType &imgtype, bool is_fetch, bool is_gather, + bool is_proj, uint32_t coord, uint32_t coord_components, uint32_t dref, + uint32_t grad_x, uint32_t grad_y, uint32_t lod, uint32_t coffset, + uint32_t offset, uint32_t bias, uint32_t comp, uint32_t sample, + bool *p_forward); + virtual void emit_buffer_block(const SPIRVariable &type); + virtual void emit_push_constant_block(const SPIRVariable &var); + virtual void emit_uniform(const SPIRVariable &var); + virtual std::string unpack_expression_type(std::string expr_str, const SPIRType &type); + + std::unique_ptr buffer; + + template + inline void statement_inner(T &&t) + { + (*buffer) << std::forward(t); + statement_count++; + } + + template + inline void statement_inner(T &&t, Ts &&... ts) + { + (*buffer) << std::forward(t); + statement_count++; + statement_inner(std::forward(ts)...); + } + + template + inline void statement(Ts &&... ts) + { + if (force_recompile) + { + // Do not bother emitting code while force_recompile is active. + // We will compile again. + statement_count++; + return; + } + + if (redirect_statement) + redirect_statement->push_back(join(std::forward(ts)...)); + else + { + for (uint32_t i = 0; i < indent; i++) + (*buffer) << " "; + + statement_inner(std::forward(ts)...); + (*buffer) << '\n'; + } + } + + template + inline void statement_no_indent(Ts &&... ts) + { + auto old_indent = indent; + indent = 0; + statement(std::forward(ts)...); + indent = old_indent; + } + + // Used for implementing continue blocks where + // we want to obtain a list of statements we can merge + // on a single line separated by comma. + std::vector *redirect_statement = nullptr; + const SPIRBlock *current_continue_block = nullptr; + + void begin_scope(); + void end_scope(); + void end_scope_decl(); + void end_scope_decl(const std::string &decl); + + Options options; + + std::string type_to_array_glsl(const SPIRType &type); + std::string to_array_size(const SPIRType &type, uint32_t index); + uint32_t to_array_size_literal(const SPIRType &type, uint32_t index) const; + std::string variable_decl(const SPIRVariable &variable); + std::string variable_decl_function_local(SPIRVariable &variable); + + void add_local_variable_name(uint32_t id); + void add_resource_name(uint32_t id); + void add_member_name(SPIRType &type, uint32_t name); + + virtual bool is_non_native_row_major_matrix(uint32_t id); + virtual bool member_is_non_native_row_major_matrix(const SPIRType &type, uint32_t index); + bool member_is_packed_type(const SPIRType &type, uint32_t index) const; + virtual std::string convert_row_major_matrix(std::string exp_str, const SPIRType &exp_type); + + std::unordered_set local_variable_names; + std::unordered_set resource_names; + + bool processing_entry_point = false; + + // Can be overriden by subclass backends for trivial things which + // shouldn't need polymorphism. + struct BackendVariations + { + std::string discard_literal = "discard"; + bool float_literal_suffix = false; + bool double_literal_suffix = true; + bool uint32_t_literal_suffix = true; + bool long_long_literal_suffix = false; + const char *basic_int_type = "int"; + const char *basic_uint_type = "uint"; + bool swizzle_is_function = false; + bool shared_is_implied = false; + bool flexible_member_array_supported = true; + bool explicit_struct_type = false; + bool use_initializer_list = false; + bool use_typed_initializer_list = false; + bool can_declare_struct_inline = true; + bool can_declare_arrays_inline = true; + bool native_row_major_matrix = true; + bool use_constructor_splatting = true; + bool boolean_mix_support = true; + bool allow_precision_qualifiers = false; + bool can_swizzle_scalar = false; + bool force_gl_in_out_block = false; + } backend; + + void emit_struct(SPIRType &type); + void emit_resources(); + void emit_buffer_block_native(const SPIRVariable &var); + void emit_buffer_block_legacy(const SPIRVariable &var); + void emit_buffer_block_flattened(const SPIRVariable &type); + void emit_declared_builtin_block(spv::StorageClass storage, spv::ExecutionModel model); + void emit_push_constant_block_vulkan(const SPIRVariable &var); + void emit_push_constant_block_glsl(const SPIRVariable &var); + void emit_interface_block(const SPIRVariable &type); + void emit_flattened_io_block(const SPIRVariable &var, const char *qual); + void emit_block_chain(SPIRBlock &block); + void emit_specialization_constant(const SPIRConstant &constant); + std::string emit_continue_block(uint32_t continue_block); + bool attempt_emit_loop_header(SPIRBlock &block, SPIRBlock::Method method); + void propagate_loop_dominators(const SPIRBlock &block); + + void branch(uint32_t from, uint32_t to); + void branch(uint32_t from, uint32_t cond, uint32_t true_block, uint32_t false_block); + void flush_phi(uint32_t from, uint32_t to); + bool flush_phi_required(uint32_t from, uint32_t to); + void flush_variable_declaration(uint32_t id); + void flush_undeclared_variables(SPIRBlock &block); + + bool should_forward(uint32_t id); + void emit_mix_op(uint32_t result_type, uint32_t id, uint32_t left, uint32_t right, uint32_t lerp); + bool to_trivial_mix_op(const SPIRType &type, std::string &op, uint32_t left, uint32_t right, uint32_t lerp); + void emit_quaternary_func_op(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, uint32_t op2, + uint32_t op3, const char *op); + void emit_trinary_func_op(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, uint32_t op2, + const char *op); + void emit_binary_func_op(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, const char *op); + void emit_binary_func_op_cast(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, const char *op, + SPIRType::BaseType input_type, bool skip_cast_if_equal_type); + void emit_unary_func_op(uint32_t result_type, uint32_t result_id, uint32_t op0, const char *op); + void emit_unrolled_unary_op(uint32_t result_type, uint32_t result_id, uint32_t operand, const char *op); + void emit_binary_op(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, const char *op); + void emit_unrolled_binary_op(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, const char *op); + void emit_binary_op_cast(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, const char *op, + SPIRType::BaseType input_type, bool skip_cast_if_equal_type); + + SPIRType binary_op_bitcast_helper(std::string &cast_op0, std::string &cast_op1, SPIRType::BaseType &input_type, + uint32_t op0, uint32_t op1, bool skip_cast_if_equal_type); + + void emit_unary_op(uint32_t result_type, uint32_t result_id, uint32_t op0, const char *op); + bool expression_is_forwarded(uint32_t id); + SPIRExpression &emit_op(uint32_t result_type, uint32_t result_id, const std::string &rhs, bool forward_rhs, + bool suppress_usage_tracking = false); + std::string access_chain_internal(uint32_t base, const uint32_t *indices, uint32_t count, bool index_is_literal, + bool chain_only = false, bool *need_transpose = nullptr, + bool *result_is_packed = nullptr); + std::string access_chain(uint32_t base, const uint32_t *indices, uint32_t count, const SPIRType &target_type, + bool *need_transpose = nullptr, bool *result_is_packed = nullptr); + + std::string flattened_access_chain(uint32_t base, const uint32_t *indices, uint32_t count, + const SPIRType &target_type, uint32_t offset, uint32_t matrix_stride, + bool need_transpose); + std::string flattened_access_chain_struct(uint32_t base, const uint32_t *indices, uint32_t count, + const SPIRType &target_type, uint32_t offset); + std::string flattened_access_chain_matrix(uint32_t base, const uint32_t *indices, uint32_t count, + const SPIRType &target_type, uint32_t offset, uint32_t matrix_stride, + bool need_transpose); + std::string flattened_access_chain_vector(uint32_t base, const uint32_t *indices, uint32_t count, + const SPIRType &target_type, uint32_t offset, uint32_t matrix_stride, + bool need_transpose); + std::pair flattened_access_chain_offset(const SPIRType &basetype, const uint32_t *indices, + uint32_t count, uint32_t offset, + uint32_t word_stride, bool *need_transpose = nullptr, + uint32_t *matrix_stride = nullptr); + + const char *index_to_swizzle(uint32_t index); + std::string remap_swizzle(const SPIRType &result_type, uint32_t input_components, const std::string &expr); + std::string declare_temporary(uint32_t type, uint32_t id); + void append_global_func_args(const SPIRFunction &func, uint32_t index, std::vector &arglist); + std::string to_expression(uint32_t id); + std::string to_enclosed_expression(uint32_t id); + std::string enclose_expression(const std::string &expr); + void strip_enclosed_expression(std::string &expr); + std::string to_member_name(const SPIRType &type, uint32_t index); + std::string type_to_glsl_constructor(const SPIRType &type); + std::string argument_decl(const SPIRFunction::Parameter &arg); + virtual std::string to_qualifiers_glsl(uint32_t id); + const char *to_precision_qualifiers_glsl(uint32_t id); + virtual const char *to_storage_qualifiers_glsl(const SPIRVariable &var); + const char *flags_to_precision_qualifiers_glsl(const SPIRType &type, uint64_t flags); + const char *format_to_glsl(spv::ImageFormat format); + virtual std::string layout_for_member(const SPIRType &type, uint32_t index); + virtual std::string to_interpolation_qualifiers(uint64_t flags); + uint64_t combined_decoration_for_member(const SPIRType &type, uint32_t index); + std::string layout_for_variable(const SPIRVariable &variable); + std::string to_combined_image_sampler(uint32_t image_id, uint32_t samp_id); + virtual bool skip_argument(uint32_t id) const; + + bool buffer_is_packing_standard(const SPIRType &type, BufferPackingStandard packing); + uint32_t type_to_packed_base_size(const SPIRType &type, BufferPackingStandard packing); + uint32_t type_to_packed_alignment(const SPIRType &type, uint64_t flags, BufferPackingStandard packing); + uint32_t type_to_packed_array_stride(const SPIRType &type, uint64_t flags, BufferPackingStandard packing); + uint32_t type_to_packed_size(const SPIRType &type, uint64_t flags, BufferPackingStandard packing); + + std::string bitcast_glsl(const SPIRType &result_type, uint32_t arg); + virtual std::string bitcast_glsl_op(const SPIRType &result_type, const SPIRType &argument_type); + + std::string bitcast_expression(SPIRType::BaseType target_type, uint32_t arg); + std::string bitcast_expression(const SPIRType &target_type, SPIRType::BaseType expr_type, const std::string &expr); + + std::string build_composite_combiner(uint32_t result_type, const uint32_t *elems, uint32_t length); + bool remove_duplicate_swizzle(std::string &op); + bool remove_unity_swizzle(uint32_t base, std::string &op); + + // Can modify flags to remote readonly/writeonly if image type + // and force recompile. + bool check_atomic_image(uint32_t id); + + virtual void replace_illegal_names(); + + void replace_fragment_output(SPIRVariable &var); + void replace_fragment_outputs(); + bool check_explicit_lod_allowed(uint32_t lod); + std::string legacy_tex_op(const std::string &op, const SPIRType &imgtype, uint32_t lod); + + uint32_t indent = 0; + + std::unordered_set emitted_functions; + + std::unordered_set flattened_buffer_blocks; + std::unordered_set flattened_structs; + + std::string load_flattened_struct(SPIRVariable &var); + std::string to_flattened_struct_member(const SPIRVariable &var, uint32_t index); + void store_flattened_struct(SPIRVariable &var, uint32_t value); + + // Usage tracking. If a temporary is used more than once, use the temporary instead to + // avoid AST explosion when SPIRV is generated with pure SSA and doesn't write stuff to variables. + std::unordered_map expression_usage_counts; + void track_expression_read(uint32_t id); + + std::vector forced_extensions; + std::vector header_lines; + + uint32_t statement_count; + + inline bool is_legacy() const + { + return (options.es && options.version < 300) || (!options.es && options.version < 130); + } + + inline bool is_legacy_es() const + { + return options.es && options.version < 300; + } + + inline bool is_legacy_desktop() const + { + return !options.es && options.version < 130; + } + + bool args_will_forward(uint32_t id, const uint32_t *args, uint32_t num_args, bool pure); + void register_call_out_argument(uint32_t id); + void register_impure_function_call(); + + // GL_EXT_shader_pixel_local_storage support. + std::vector pls_inputs; + std::vector pls_outputs; + std::string pls_decl(const PlsRemap &variable); + const char *to_pls_qualifiers_glsl(const SPIRVariable &variable); + void emit_pls(); + void remap_pls_variables(); + + void add_variable(std::unordered_set &variables, uint32_t id); + void add_variable(std::unordered_set &variables, std::string &name); + void check_function_call_constraints(const uint32_t *args, uint32_t length); + void handle_invalid_expression(uint32_t id); + void find_static_extensions(); + + std::string emit_for_loop_initializers(const SPIRBlock &block); + bool for_loop_initializers_are_same_type(const SPIRBlock &block); + bool optimize_read_modify_write(const std::string &lhs, const std::string &rhs); + void fixup_image_load_store_access(); + + bool type_is_empty(const SPIRType &type); + + virtual void declare_undefined_values(); + + static std::string sanitize_underscores(const std::string &str); + + bool can_use_io_location(spv::StorageClass storage); + const Instruction *get_next_instruction_in_block(const Instruction &instr); + static uint32_t mask_relevant_memory_semantics(uint32_t semantics); + +private: + void init() + { + if (source.known) + { + options.es = source.es; + options.version = source.version; + } + } +}; +} + +#endif diff --git a/spirv_hlsl.cpp b/spirv_hlsl.cpp new file mode 100644 index 0000000000..3f2227cfea --- /dev/null +++ b/spirv_hlsl.cpp @@ -0,0 +1,3712 @@ +/* + * Copyright 2016-2018 Robert Konrad + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "spirv_hlsl.hpp" +#include "GLSL.std.450.h" +#include +#include + +using namespace spv; +using namespace spirv_cross; +using namespace std; + +static unsigned image_format_to_components(ImageFormat fmt) +{ + switch (fmt) + { + case ImageFormatR8: + case ImageFormatR16: + case ImageFormatR8Snorm: + case ImageFormatR16Snorm: + case ImageFormatR16f: + case ImageFormatR32f: + case ImageFormatR8i: + case ImageFormatR16i: + case ImageFormatR32i: + case ImageFormatR8ui: + case ImageFormatR16ui: + case ImageFormatR32ui: + return 1; + + case ImageFormatRg8: + case ImageFormatRg16: + case ImageFormatRg8Snorm: + case ImageFormatRg16Snorm: + case ImageFormatRg16f: + case ImageFormatRg32f: + case ImageFormatRg8i: + case ImageFormatRg16i: + case ImageFormatRg32i: + case ImageFormatRg8ui: + case ImageFormatRg16ui: + case ImageFormatRg32ui: + return 2; + + case ImageFormatR11fG11fB10f: + return 3; + + case ImageFormatRgba8: + case ImageFormatRgba16: + case ImageFormatRgb10A2: + case ImageFormatRgba8Snorm: + case ImageFormatRgba16Snorm: + case ImageFormatRgba16f: + case ImageFormatRgba32f: + case ImageFormatRgba8i: + case ImageFormatRgba16i: + case ImageFormatRgba32i: + case ImageFormatRgba8ui: + case ImageFormatRgba16ui: + case ImageFormatRgba32ui: + case ImageFormatRgb10a2ui: + return 4; + + case ImageFormatUnknown: + return 4; // Assume 4. + + default: + SPIRV_CROSS_THROW("Unrecognized typed image format."); + } +} + +static string image_format_to_type(ImageFormat fmt, SPIRType::BaseType basetype) +{ + switch (fmt) + { + case ImageFormatR8: + case ImageFormatR16: + if (basetype != SPIRType::Float) + SPIRV_CROSS_THROW("Mismatch in image type and base type of image."); + return "unorm float"; + case ImageFormatRg8: + case ImageFormatRg16: + if (basetype != SPIRType::Float) + SPIRV_CROSS_THROW("Mismatch in image type and base type of image."); + return "unorm float2"; + case ImageFormatRgba8: + case ImageFormatRgba16: + if (basetype != SPIRType::Float) + SPIRV_CROSS_THROW("Mismatch in image type and base type of image."); + return "unorm float4"; + case ImageFormatRgb10A2: + if (basetype != SPIRType::Float) + SPIRV_CROSS_THROW("Mismatch in image type and base type of image."); + return "unorm float4"; + + case ImageFormatR8Snorm: + case ImageFormatR16Snorm: + if (basetype != SPIRType::Float) + SPIRV_CROSS_THROW("Mismatch in image type and base type of image."); + return "snorm float"; + case ImageFormatRg8Snorm: + case ImageFormatRg16Snorm: + if (basetype != SPIRType::Float) + SPIRV_CROSS_THROW("Mismatch in image type and base type of image."); + return "snorm float2"; + case ImageFormatRgba8Snorm: + case ImageFormatRgba16Snorm: + if (basetype != SPIRType::Float) + SPIRV_CROSS_THROW("Mismatch in image type and base type of image."); + return "snorm float4"; + + case ImageFormatR16f: + case ImageFormatR32f: + if (basetype != SPIRType::Float) + SPIRV_CROSS_THROW("Mismatch in image type and base type of image."); + return "float"; + case ImageFormatRg16f: + case ImageFormatRg32f: + if (basetype != SPIRType::Float) + SPIRV_CROSS_THROW("Mismatch in image type and base type of image."); + return "float2"; + case ImageFormatRgba16f: + case ImageFormatRgba32f: + if (basetype != SPIRType::Float) + SPIRV_CROSS_THROW("Mismatch in image type and base type of image."); + return "float4"; + + case ImageFormatR11fG11fB10f: + if (basetype != SPIRType::Float) + SPIRV_CROSS_THROW("Mismatch in image type and base type of image."); + return "float3"; + + case ImageFormatR8i: + case ImageFormatR16i: + case ImageFormatR32i: + if (basetype != SPIRType::Int) + SPIRV_CROSS_THROW("Mismatch in image type and base type of image."); + return "int"; + case ImageFormatRg8i: + case ImageFormatRg16i: + case ImageFormatRg32i: + if (basetype != SPIRType::Int) + SPIRV_CROSS_THROW("Mismatch in image type and base type of image."); + return "int2"; + case ImageFormatRgba8i: + case ImageFormatRgba16i: + case ImageFormatRgba32i: + if (basetype != SPIRType::Int) + SPIRV_CROSS_THROW("Mismatch in image type and base type of image."); + return "int4"; + + case ImageFormatR8ui: + case ImageFormatR16ui: + case ImageFormatR32ui: + if (basetype != SPIRType::UInt) + SPIRV_CROSS_THROW("Mismatch in image type and base type of image."); + return "uint"; + case ImageFormatRg8ui: + case ImageFormatRg16ui: + case ImageFormatRg32ui: + if (basetype != SPIRType::UInt) + SPIRV_CROSS_THROW("Mismatch in image type and base type of image."); + return "uint2"; + case ImageFormatRgba8ui: + case ImageFormatRgba16ui: + case ImageFormatRgba32ui: + if (basetype != SPIRType::UInt) + SPIRV_CROSS_THROW("Mismatch in image type and base type of image."); + return "uint4"; + case ImageFormatRgb10a2ui: + if (basetype != SPIRType::UInt) + SPIRV_CROSS_THROW("Mismatch in image type and base type of image."); + return "uint4"; + + case ImageFormatUnknown: + switch (basetype) + { + case SPIRType::Float: + return "float4"; + case SPIRType::Int: + return "int4"; + case SPIRType::UInt: + return "uint4"; + default: + SPIRV_CROSS_THROW("Unsupported base type for image."); + } + + default: + SPIRV_CROSS_THROW("Unrecognized typed image format."); + } +} + +// Returns true if an arithmetic operation does not change behavior depending on signedness. +static bool opcode_is_sign_invariant(Op opcode) +{ + switch (opcode) + { + case OpIEqual: + case OpINotEqual: + case OpISub: + case OpIAdd: + case OpIMul: + case OpShiftLeftLogical: + case OpBitwiseOr: + case OpBitwiseXor: + case OpBitwiseAnd: + return true; + + default: + return false; + } +} + +string CompilerHLSL::image_type_hlsl_modern(const SPIRType &type) +{ + auto &imagetype = get(type.image.type); + const char *dim = nullptr; + bool typed_load = false; + uint32_t components = 4; + + switch (type.image.dim) + { + case Dim1D: + typed_load = type.image.sampled == 2; + dim = "1D"; + break; + case Dim2D: + typed_load = type.image.sampled == 2; + dim = "2D"; + break; + case Dim3D: + typed_load = type.image.sampled == 2; + dim = "3D"; + break; + case DimCube: + if (type.image.sampled == 2) + SPIRV_CROSS_THROW("RWTextureCube does not exist in HLSL."); + dim = "Cube"; + break; + case DimRect: + SPIRV_CROSS_THROW("Rectangle texture support is not yet implemented for HLSL."); // TODO + case DimBuffer: + if (type.image.sampled == 1) + return join("Buffer<", type_to_glsl(imagetype), components, ">"); + else if (type.image.sampled == 2) + return join("RWBuffer<", image_format_to_type(type.image.format, imagetype.basetype), ">"); + else + SPIRV_CROSS_THROW("Sampler buffers must be either sampled or unsampled. Cannot deduce in runtime."); + case DimSubpassData: + // This should be implemented same way as desktop GL. Fetch on a 2D texture based on int2(SV_Position). + SPIRV_CROSS_THROW("Subpass data support is not yet implemented for HLSL"); // TODO + default: + SPIRV_CROSS_THROW("Invalid dimension."); + } + const char *arrayed = type.image.arrayed ? "Array" : ""; + const char *ms = type.image.ms ? "MS" : ""; + const char *rw = typed_load ? "RW" : ""; + return join(rw, "Texture", dim, ms, arrayed, "<", + typed_load ? image_format_to_type(type.image.format, imagetype.basetype) : + join(type_to_glsl(imagetype), components), + ">"); +} + +string CompilerHLSL::image_type_hlsl_legacy(const SPIRType &type) +{ + auto &imagetype = get(type.image.type); + string res; + + switch (imagetype.basetype) + { + case SPIRType::Int: + res = "i"; + break; + case SPIRType::UInt: + res = "u"; + break; + default: + break; + } + + if (type.basetype == SPIRType::Image && type.image.dim == DimSubpassData) + return res + "subpassInput" + (type.image.ms ? "MS" : ""); + + // If we're emulating subpassInput with samplers, force sampler2D + // so we don't have to specify format. + if (type.basetype == SPIRType::Image && type.image.dim != DimSubpassData) + { + // Sampler buffers are always declared as samplerBuffer even though they might be separate images in the SPIR-V. + if (type.image.dim == DimBuffer && type.image.sampled == 1) + res += "sampler"; + else + res += type.image.sampled == 2 ? "image" : "texture"; + } + else + res += "sampler"; + + switch (type.image.dim) + { + case Dim1D: + res += "1D"; + break; + case Dim2D: + res += "2D"; + break; + case Dim3D: + res += "3D"; + break; + case DimCube: + res += "CUBE"; + break; + + case DimBuffer: + res += "Buffer"; + break; + + case DimSubpassData: + res += "2D"; + break; + default: + SPIRV_CROSS_THROW("Only 1D, 2D, 3D, Buffer, InputTarget and Cube textures supported."); + } + + if (type.image.ms) + res += "MS"; + if (type.image.arrayed) + res += "Array"; + if (type.image.depth) + res += "Shadow"; + + return res; +} + +string CompilerHLSL::image_type_hlsl(const SPIRType &type) +{ + if (options.shader_model <= 30) + return image_type_hlsl_legacy(type); + else + return image_type_hlsl_modern(type); +} + +// The optional id parameter indicates the object whose type we are trying +// to find the description for. It is optional. Most type descriptions do not +// depend on a specific object's use of that type. +string CompilerHLSL::type_to_glsl(const SPIRType &type, uint32_t id) +{ + // Ignore the pointer type since GLSL doesn't have pointers. + + switch (type.basetype) + { + case SPIRType::Struct: + // Need OpName lookup here to get a "sensible" name for a struct. + if (backend.explicit_struct_type) + return join("struct ", to_name(type.self)); + else + return to_name(type.self); + + case SPIRType::Image: + case SPIRType::SampledImage: + return image_type_hlsl(type); + + case SPIRType::Sampler: + return comparison_samplers.count(id) ? "SamplerComparisonState" : "SamplerState"; + + case SPIRType::Void: + return "void"; + + default: + break; + } + + if (type.vecsize == 1 && type.columns == 1) // Scalar builtin + { + switch (type.basetype) + { + case SPIRType::Boolean: + return "bool"; + case SPIRType::Int: + return backend.basic_int_type; + case SPIRType::UInt: + return backend.basic_uint_type; + case SPIRType::AtomicCounter: + return "atomic_uint"; + case SPIRType::Float: + return "float"; + case SPIRType::Double: + return "double"; + case SPIRType::Int64: + return "int64_t"; + case SPIRType::UInt64: + return "uint64_t"; + default: + return "???"; + } + } + else if (type.vecsize > 1 && type.columns == 1) // Vector builtin + { + switch (type.basetype) + { + case SPIRType::Boolean: + return join("bool", type.vecsize); + case SPIRType::Int: + return join("int", type.vecsize); + case SPIRType::UInt: + return join("uint", type.vecsize); + case SPIRType::Float: + return join("float", type.vecsize); + case SPIRType::Double: + return join("double", type.vecsize); + case SPIRType::Int64: + return join("i64vec", type.vecsize); + case SPIRType::UInt64: + return join("u64vec", type.vecsize); + default: + return "???"; + } + } + else + { + switch (type.basetype) + { + case SPIRType::Boolean: + return join("bool", type.columns, "x", type.vecsize); + case SPIRType::Int: + return join("int", type.columns, "x", type.vecsize); + case SPIRType::UInt: + return join("uint", type.columns, "x", type.vecsize); + case SPIRType::Float: + return join("float", type.columns, "x", type.vecsize); + case SPIRType::Double: + return join("double", type.columns, "x", type.vecsize); + // Matrix types not supported for int64/uint64. + default: + return "???"; + } + } +} + +void CompilerHLSL::emit_header() +{ + for (auto &header : header_lines) + statement(header); + + if (header_lines.size() > 0) + { + statement(""); + } +} + +void CompilerHLSL::emit_interface_block_globally(const SPIRVariable &var) +{ + add_resource_name(var.self); + + // The global copies of I/O variables should not contain interpolation qualifiers. + // These are emitted inside the interface structs. + auto &flags = meta[var.self].decoration.decoration_flags; + auto old_flags = flags; + flags = 0; + statement("static ", variable_decl(var), ";"); + flags = old_flags; +} + +const char *CompilerHLSL::to_storage_qualifiers_glsl(const SPIRVariable &var) +{ + // Input and output variables are handled specially in HLSL backend. + // The variables are declared as global, private variables, and do not need any qualifiers. + if (var.storage == StorageClassUniformConstant || var.storage == StorageClassUniform || + var.storage == StorageClassPushConstant) + { + return "uniform "; + } + + return ""; +} + +void CompilerHLSL::emit_builtin_outputs_in_struct() +{ + bool legacy = options.shader_model <= 30; + for (uint32_t i = 0; i < 64; i++) + { + if (!(active_output_builtins & (1ull << i))) + continue; + + const char *type = nullptr; + const char *semantic = nullptr; + auto builtin = static_cast(i); + switch (builtin) + { + case BuiltInPosition: + type = "float4"; + semantic = legacy ? "POSITION" : "SV_Position"; + break; + + case BuiltInFragDepth: + type = "float"; + semantic = legacy ? "DEPTH" : "SV_Depth"; + break; + + case BuiltInPointSize: + // If point_size_compat is enabled, just ignore PointSize. + // PointSize does not exist in HLSL, but some code bases might want to be able to use these shaders, + // even if it means working around the missing feature. + if (options.point_size_compat) + break; + else + SPIRV_CROSS_THROW("Unsupported builtin in HLSL."); + + default: + SPIRV_CROSS_THROW("Unsupported builtin in HLSL."); + break; + } + + if (type && semantic) + statement(type, " ", builtin_to_glsl(builtin, StorageClassOutput), " : ", semantic, ";"); + } +} + +void CompilerHLSL::emit_builtin_inputs_in_struct() +{ + bool legacy = options.shader_model <= 30; + for (uint32_t i = 0; i < 64; i++) + { + if (!(active_input_builtins & (1ull << i))) + continue; + + const char *type = nullptr; + const char *semantic = nullptr; + auto builtin = static_cast(i); + switch (builtin) + { + case BuiltInFragCoord: + type = "float4"; + semantic = legacy ? "VPOS" : "SV_Position"; + break; + + case BuiltInVertexId: + case BuiltInVertexIndex: + if (legacy) + SPIRV_CROSS_THROW("Vertex index not supported in SM 3.0 or lower."); + type = "uint"; + semantic = "SV_VertexID"; + break; + + case BuiltInInstanceId: + case BuiltInInstanceIndex: + if (legacy) + SPIRV_CROSS_THROW("Instance index not supported in SM 3.0 or lower."); + type = "uint"; + semantic = "SV_InstanceID"; + break; + + case BuiltInSampleId: + if (legacy) + SPIRV_CROSS_THROW("Sample ID not supported in SM 3.0 or lower."); + type = "uint"; + semantic = "SV_SampleIndex"; + break; + + case BuiltInGlobalInvocationId: + type = "uint3"; + semantic = "SV_DispatchThreadID"; + break; + + case BuiltInLocalInvocationId: + type = "uint3"; + semantic = "SV_GroupThreadID"; + break; + + case BuiltInLocalInvocationIndex: + type = "uint"; + semantic = "SV_GroupIndex"; + break; + + case BuiltInWorkgroupId: + type = "uint3"; + semantic = "SV_GroupID"; + break; + + default: + SPIRV_CROSS_THROW("Unsupported builtin in HLSL."); + break; + } + + if (type && semantic) + statement(type, " ", builtin_to_glsl(builtin, StorageClassInput), " : ", semantic, ";"); + } +} + +uint32_t CompilerHLSL::type_to_consumed_locations(const SPIRType &type) const +{ + // TODO: Need to verify correctness. + uint32_t elements = 0; + + if (type.basetype == SPIRType::Struct) + { + for (uint32_t i = 0; i < uint32_t(type.member_types.size()); i++) + elements += type_to_consumed_locations(get(type.member_types[i])); + } + else + { + uint32_t array_multiplier = 1; + for (uint32_t i = 0; i < uint32_t(type.array.size()); i++) + { + if (type.array_size_literal[i]) + array_multiplier *= type.array[i]; + else + array_multiplier *= get(type.array[i]).scalar(); + } + elements += array_multiplier * type.columns; + } + return elements; +} + +string CompilerHLSL::to_interpolation_qualifiers(uint64_t flags) +{ + string res; + //if (flags & (1ull << DecorationSmooth)) + // res += "linear "; + if (flags & (1ull << DecorationFlat)) + res += "nointerpolation "; + if (flags & (1ull << DecorationNoPerspective)) + res += "noperspective "; + if (flags & (1ull << DecorationCentroid)) + res += "centroid "; + if (flags & (1ull << DecorationPatch)) + res += "patch "; // Seems to be different in actual HLSL. + if (flags & (1ull << DecorationSample)) + res += "sample "; + if (flags & (1ull << DecorationInvariant)) + res += "invariant "; // Not supported? + + return res; +} + +std::string CompilerHLSL::to_semantic(uint32_t vertex_location) +{ + for (auto &attribute : remap_vertex_attributes) + if (attribute.location == vertex_location) + return attribute.semantic; + + return join("TEXCOORD", vertex_location); +} + +void CompilerHLSL::emit_io_block(const SPIRVariable &var) +{ + auto &type = get(var.basetype); + add_resource_name(type.self); + + statement("struct ", to_name(type.self)); + begin_scope(); + type.member_name_cache.clear(); + + uint32_t base_location = get_decoration(var.self, DecorationLocation); + + for (uint32_t i = 0; i < uint32_t(type.member_types.size()); i++) + { + string semantic; + if (has_member_decoration(type.self, i, DecorationLocation)) + { + uint32_t location = get_member_decoration(type.self, i, DecorationLocation); + semantic = join(" : ", to_semantic(location)); + } + else + { + // If the block itself has a location, but not its members, use the implicit location. + // There could be a conflict if the block members partially specialize the locations. + // It is unclear how SPIR-V deals with this. Assume this does not happen for now. + uint32_t location = base_location + i; + semantic = join(" : ", to_semantic(location)); + } + + add_member_name(type, i); + + auto &membertype = get(type.member_types[i]); + statement(to_interpolation_qualifiers(get_member_decoration_mask(type.self, i)), + variable_decl(membertype, to_member_name(type, i)), semantic, ";"); + } + + end_scope_decl(); + statement(""); + + statement("static ", variable_decl(var), ";"); + statement(""); +} + +void CompilerHLSL::emit_interface_block_in_struct(const SPIRVariable &var, unordered_set &active_locations) +{ + auto &execution = get_entry_point(); + auto &type = get(var.basetype); + + string binding; + bool use_location_number = true; + bool legacy = options.shader_model <= 30; + if (execution.model == ExecutionModelFragment && var.storage == StorageClassOutput) + { + binding = join(legacy ? "COLOR" : "SV_Target", get_decoration(var.self, DecorationLocation)); + use_location_number = false; + } + + const auto get_vacant_location = [&]() -> uint32_t { + for (uint32_t i = 0; i < 64; i++) + if (!active_locations.count(i)) + return i; + SPIRV_CROSS_THROW("All locations from 0 to 63 are exhausted."); + }; + + bool need_matrix_unroll = var.storage == StorageClassInput && execution.model == ExecutionModelVertex; + + auto &m = meta[var.self].decoration; + auto name = to_name(var.self); + if (use_location_number) + { + uint32_t location_number; + + // If an explicit location exists, use it with TEXCOORD[N] semantic. + // Otherwise, pick a vacant location. + if (m.decoration_flags & (1ull << DecorationLocation)) + location_number = m.location; + else + location_number = get_vacant_location(); + + // Allow semantic remap if specified. + auto semantic = to_semantic(location_number); + + if (need_matrix_unroll && type.columns > 1) + { + if (!type.array.empty()) + SPIRV_CROSS_THROW("Arrays of matrices used as input/output. This is not supported."); + + // Unroll matrices. + for (uint32_t i = 0; i < type.columns; i++) + { + SPIRType newtype = type; + newtype.columns = 1; + statement(to_interpolation_qualifiers(get_decoration_mask(var.self)), + variable_decl(newtype, join(name, "_", i)), " : ", semantic, "_", i, ";"); + active_locations.insert(location_number++); + } + } + else + { + statement(to_interpolation_qualifiers(get_decoration_mask(var.self)), variable_decl(type, name), " : ", + semantic, ";"); + + // Structs and arrays should consume more locations. + uint32_t consumed_locations = type_to_consumed_locations(type); + for (uint32_t i = 0; i < consumed_locations; i++) + active_locations.insert(location_number + i); + } + } + else + statement(variable_decl(type, name), " : ", binding, ";"); +} + +std::string CompilerHLSL::builtin_to_glsl(spv::BuiltIn builtin, spv::StorageClass storage) +{ + switch (builtin) + { + case BuiltInVertexId: + return "gl_VertexID"; + case BuiltInInstanceId: + return "gl_InstanceID"; + default: + return CompilerGLSL::builtin_to_glsl(builtin, storage); + } +} + +void CompilerHLSL::emit_builtin_variables() +{ + // Emit global variables for the interface variables which are statically used by the shader. + for (uint32_t i = 0; i < 64; i++) + { + if (!((active_input_builtins | active_output_builtins) & (1ull << i))) + continue; + + const char *type = nullptr; + auto builtin = static_cast(i); + + switch (builtin) + { + case BuiltInFragCoord: + case BuiltInPosition: + type = "float4"; + break; + + case BuiltInFragDepth: + type = "float"; + break; + + case BuiltInVertexId: + case BuiltInVertexIndex: + case BuiltInInstanceId: + case BuiltInInstanceIndex: + case BuiltInSampleId: + type = "int"; + break; + + case BuiltInPointSize: + if (options.point_size_compat) + { + // Just emit the global variable, it will be ignored. + type = "float"; + break; + } + else + SPIRV_CROSS_THROW(join("Unsupported builtin in HLSL: ", unsigned(builtin))); + + case BuiltInGlobalInvocationId: + case BuiltInLocalInvocationId: + case BuiltInWorkgroupId: + type = "uint3"; + break; + + case BuiltInLocalInvocationIndex: + type = "uint"; + break; + + default: + SPIRV_CROSS_THROW(join("Unsupported builtin in HLSL: ", unsigned(builtin))); + break; + } + + StorageClass storage = (active_input_builtins & (1ull << i)) != 0 ? StorageClassInput : StorageClassOutput; + // FIXME: SampleMask can be both in and out with sample builtin, + // need to distinguish that when we add support for that. + + if (type) + statement("static ", type, " ", builtin_to_glsl(builtin, storage), ";"); + } +} + +void CompilerHLSL::emit_composite_constants() +{ + // HLSL cannot declare structs or arrays inline, so we must move them out to + // global constants directly. + bool emitted = false; + + for (auto &id : ids) + { + if (id.get_type() == TypeConstant) + { + auto &c = id.get(); + if (c.specialization) + continue; + + auto &type = get(c.constant_type); + if (type.basetype == SPIRType::Struct || !type.array.empty()) + { + auto name = to_name(c.self); + statement("static const ", variable_decl(type, name), " = ", constant_expression(c), ";"); + emitted = true; + } + } + } + + if (emitted) + statement(""); +} + +void CompilerHLSL::emit_specialization_constants() +{ + bool emitted = false; + SpecializationConstant wg_x, wg_y, wg_z; + uint32_t workgroup_size_id = get_work_group_size_specialization_constants(wg_x, wg_y, wg_z); + + for (auto &id : ids) + { + if (id.get_type() == TypeConstant) + { + auto &c = id.get(); + if (!c.specialization) + continue; + if (c.self == workgroup_size_id) + continue; + + auto &type = get(c.constant_type); + auto name = to_name(c.self); + + statement("static const ", variable_decl(type, name), " = ", constant_expression(c), ";"); + emitted = true; + } + } + + if (workgroup_size_id) + { + statement("static const uint3 gl_WorkGroupSize = ", constant_expression(get(workgroup_size_id)), + ";"); + emitted = true; + } + + if (emitted) + statement(""); +} + +void CompilerHLSL::emit_resources() +{ + auto &execution = get_entry_point(); + + replace_illegal_names(); + + emit_specialization_constants(); + + // Output all basic struct types which are not Block or BufferBlock as these are declared inplace + // when such variables are instantiated. + for (auto &id : ids) + { + if (id.get_type() == TypeType) + { + auto &type = id.get(); + if (type.basetype == SPIRType::Struct && type.array.empty() && !type.pointer && + (meta[type.self].decoration.decoration_flags & + ((1ull << DecorationBlock) | (1ull << DecorationBufferBlock))) == 0) + { + emit_struct(type); + } + } + } + + emit_composite_constants(); + + bool emitted = false; + + // Output UBOs and SSBOs + for (auto &id : ids) + { + if (id.get_type() == TypeVariable) + { + auto &var = id.get(); + auto &type = get(var.basetype); + + bool is_block_storage = type.storage == StorageClassStorageBuffer || type.storage == StorageClassUniform; + bool has_block_flags = (meta[type.self].decoration.decoration_flags & + ((1ull << DecorationBlock) | (1ull << DecorationBufferBlock))) != 0; + + if (var.storage != StorageClassFunction && type.pointer && is_block_storage && !is_hidden_variable(var) && + has_block_flags) + { + emit_buffer_block(var); + emitted = true; + } + } + } + + // Output push constant blocks + for (auto &id : ids) + { + if (id.get_type() == TypeVariable) + { + auto &var = id.get(); + auto &type = get(var.basetype); + if (var.storage != StorageClassFunction && type.pointer && type.storage == StorageClassPushConstant && + !is_hidden_variable(var)) + { + emit_push_constant_block(var); + emitted = true; + } + } + } + + if (execution.model == ExecutionModelVertex && options.shader_model <= 30) + { + statement("uniform float4 gl_HalfPixel;"); + emitted = true; + } + + // Output Uniform Constants (values, samplers, images, etc). + for (auto &id : ids) + { + if (id.get_type() == TypeVariable) + { + auto &var = id.get(); + auto &type = get(var.basetype); + + if (var.storage != StorageClassFunction && !is_builtin_variable(var) && !var.remapped_variable && + type.pointer && + (type.storage == StorageClassUniformConstant || type.storage == StorageClassAtomicCounter)) + { + emit_uniform(var); + emitted = true; + } + } + } + + if (emitted) + statement(""); + emitted = false; + + // Emit builtin input and output variables here. + emit_builtin_variables(); + + for (auto &id : ids) + { + if (id.get_type() == TypeVariable) + { + auto &var = id.get(); + auto &type = get(var.basetype); + bool block = (meta[type.self].decoration.decoration_flags & (1ull << DecorationBlock)) != 0; + + // Do not emit I/O blocks here. + // I/O blocks can be arrayed, so we must deal with them separately to support geometry shaders + // and tessellation down the line. + if (!block && var.storage != StorageClassFunction && !var.remapped_variable && type.pointer && + (var.storage == StorageClassInput || var.storage == StorageClassOutput) && !is_builtin_variable(var) && + interface_variable_exists_in_entry_point(var.self)) + { + // Only emit non-builtins which are not blocks here. Builtin variables are handled separately. + emit_interface_block_globally(var); + emitted = true; + } + } + } + + if (emitted) + statement(""); + emitted = false; + + require_input = false; + require_output = false; + unordered_set active_inputs; + unordered_set active_outputs; + vector input_variables; + vector output_variables; + for (auto &id : ids) + { + if (id.get_type() == TypeVariable) + { + auto &var = id.get(); + auto &type = get(var.basetype); + bool block = (meta[type.self].decoration.decoration_flags & (1ull << DecorationBlock)) != 0; + + if (var.storage != StorageClassInput && var.storage != StorageClassOutput) + continue; + + // Do not emit I/O blocks here. + // I/O blocks can be arrayed, so we must deal with them separately to support geometry shaders + // and tessellation down the line. + if (!block && !var.remapped_variable && type.pointer && !is_builtin_variable(var) && + interface_variable_exists_in_entry_point(var.self)) + { + if (var.storage == StorageClassInput) + input_variables.push_back(&var); + else + output_variables.push_back(&var); + } + + // Reserve input and output locations for block variables as necessary. + if (block && !is_builtin_variable(var) && interface_variable_exists_in_entry_point(var.self)) + { + auto &active = var.storage == StorageClassInput ? active_inputs : active_outputs; + for (uint32_t i = 0; i < uint32_t(type.member_types.size()); i++) + { + if (has_member_decoration(type.self, i, DecorationLocation)) + { + uint32_t location = get_member_decoration(type.self, i, DecorationLocation); + active.insert(location); + } + } + + // Emit the block struct and a global variable here. + emit_io_block(var); + } + } + } + + const auto variable_compare = [&](const SPIRVariable *a, const SPIRVariable *b) -> bool { + // Sort input and output variables based on, from more robust to less robust: + // - Location + // - Variable has a location + // - Name comparison + // - Variable has a name + // - Fallback: ID + bool has_location_a = has_decoration(a->self, DecorationLocation); + bool has_location_b = has_decoration(b->self, DecorationLocation); + + if (has_location_a && has_location_b) + { + return get_decoration(a->self, DecorationLocation) < get_decoration(b->self, DecorationLocation); + } + else if (has_location_a && !has_location_b) + return true; + else if (!has_location_a && has_location_b) + return false; + + const auto &name1 = to_name(a->self); + const auto &name2 = to_name(b->self); + + if (name1.empty() && name2.empty()) + return a->self < b->self; + else if (name1.empty()) + return true; + else if (name2.empty()) + return false; + + return name1.compare(name2) < 0; + }; + + if (!input_variables.empty() || active_input_builtins) + { + require_input = true; + statement("struct SPIRV_Cross_Input"); + + begin_scope(); + sort(input_variables.begin(), input_variables.end(), variable_compare); + for (auto var : input_variables) + emit_interface_block_in_struct(*var, active_inputs); + emit_builtin_inputs_in_struct(); + end_scope_decl(); + statement(""); + } + + if (!output_variables.empty() || active_output_builtins) + { + require_output = true; + statement("struct SPIRV_Cross_Output"); + + begin_scope(); + // FIXME: Use locations properly if they exist. + sort(output_variables.begin(), output_variables.end(), variable_compare); + for (auto var : output_variables) + emit_interface_block_in_struct(*var, active_outputs); + emit_builtin_outputs_in_struct(); + end_scope_decl(); + statement(""); + } + + // Global variables. + for (auto global : global_variables) + { + auto &var = get(global); + if (var.storage != StorageClassOutput) + { + add_resource_name(var.self); + + const char *storage = nullptr; + switch (var.storage) + { + case StorageClassWorkgroup: + storage = "groupshared"; + break; + + default: + storage = "static"; + break; + } + statement(storage, " ", variable_decl(var), ";"); + emitted = true; + } + } + + if (emitted) + statement(""); + + declare_undefined_values(); + + if (requires_op_fmod) + { + static const char *types[] = { + "float", + "float2", + "float3", + "float4", + }; + + for (auto &type : types) + { + statement(type, " mod(", type, " x, ", type, " y)"); + begin_scope(); + statement("return x - y * floor(x / y);"); + end_scope(); + statement(""); + } + } + + if (requires_textureProj) + { + if (options.shader_model >= 40) + { + statement("float SPIRV_Cross_projectTextureCoordinate(float2 coord)"); + begin_scope(); + statement("return coord.x / coord.y;"); + end_scope(); + statement(""); + + statement("float2 SPIRV_Cross_projectTextureCoordinate(float3 coord)"); + begin_scope(); + statement("return float2(coord.x, coord.y) / coord.z;"); + end_scope(); + statement(""); + + statement("float3 SPIRV_Cross_projectTextureCoordinate(float4 coord)"); + begin_scope(); + statement("return float3(coord.x, coord.y, coord.z) / coord.w;"); + end_scope(); + statement(""); + } + else + { + statement("float4 SPIRV_Cross_projectTextureCoordinate(float2 coord)"); + begin_scope(); + statement("return float4(coord.x, 0.0, 0.0, coord.y);"); + end_scope(); + statement(""); + + statement("float4 SPIRV_Cross_projectTextureCoordinate(float3 coord)"); + begin_scope(); + statement("return float4(coord.x, coord.y, 0.0, coord.z);"); + end_scope(); + statement(""); + + statement("float4 SPIRV_Cross_projectTextureCoordinate(float4 coord)"); + begin_scope(); + statement("return coord;"); + end_scope(); + statement(""); + } + } + + if (required_textureSizeVariants != 0) + { + static const char *types[QueryTypeCount] = { "float4", "int4", "uint4" }; + static const char *dims[QueryDimCount] = { "Texture1D", "Texture1DArray", "Texture2D", "Texture2DArray", + "Texture3D", "Buffer", "TextureCube", "TextureCubeArray", + "Texture2DMS", "Texture2DMSArray" }; + + static const bool has_lod[QueryDimCount] = { true, true, true, true, true, false, true, true, false, false }; + + static const char *ret_types[QueryDimCount] = { + "uint", "uint2", "uint2", "uint3", "uint3", "uint", "uint2", "uint3", "uint2", "uint3", + }; + + static const uint32_t return_arguments[QueryDimCount] = { + 1, 2, 2, 3, 3, 1, 2, 3, 2, 3, + }; + + for (uint32_t index = 0; index < QueryDimCount; index++) + { + for (uint32_t type_index = 0; type_index < QueryTypeCount; type_index++) + { + uint32_t bit = 16 * type_index + index; + uint64_t mask = 1ull << bit; + + if ((required_textureSizeVariants & mask) == 0) + continue; + + statement(ret_types[index], " SPIRV_Cross_textureSize(", dims[index], "<", types[type_index], + "> Tex, uint Level, out uint Param)"); + begin_scope(); + statement(ret_types[index], " ret;"); + switch (return_arguments[index]) + { + case 1: + if (has_lod[index]) + statement("Tex.GetDimensions(Level, ret.x, Param);"); + else + { + statement("Tex.GetDimensions(ret.x);"); + statement("Param = 0u;"); + } + break; + case 2: + if (has_lod[index]) + statement("Tex.GetDimensions(Level, ret.x, ret.y, Param);"); + else + statement("Tex.GetDimensions(ret.x, ret.y, Param);"); + break; + case 3: + if (has_lod[index]) + statement("Tex.GetDimensions(Level, ret.x, ret.y, ret.z, Param);"); + else + statement("Tex.GetDimensions(ret.x, ret.y, ret.z, Param);"); + break; + } + + statement("return ret;"); + end_scope(); + statement(""); + } + } + } + + if (requires_fp16_packing) + { + // HLSL does not pack into a single word sadly :( + statement("uint SPIRV_Cross_packHalf2x16(float2 value)"); + begin_scope(); + statement("uint2 Packed = f32tof16(value);"); + statement("return Packed.x | (Packed.y << 16);"); + end_scope(); + statement(""); + + statement("float2 SPIRV_Cross_unpackHalf2x16(uint value)"); + begin_scope(); + statement("return f16tof32(uint2(value & 0xffff, value >> 16));"); + end_scope(); + statement(""); + } + + // HLSL does not seem to have builtins for these operation, so roll them by hand ... + if (requires_unorm8_packing) + { + statement("uint SPIRV_Cross_packUnorm4x8(float4 value)"); + begin_scope(); + statement("uint4 Packed = uint4(round(saturate(value) * 255.0));"); + statement("return Packed.x | (Packed.y << 8) | (Packed.z << 16) | (Packed.w << 24);"); + end_scope(); + statement(""); + + statement("float4 SPIRV_Cross_unpackUnorm4x8(uint value)"); + begin_scope(); + statement("uint4 Packed = uint4(value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, value >> 24);"); + statement("return float4(Packed) / 255.0;"); + end_scope(); + statement(""); + } + + if (requires_snorm8_packing) + { + statement("uint SPIRV_Cross_packSnorm4x8(float4 value)"); + begin_scope(); + statement("int4 Packed = int4(round(clamp(value, -1.0, 1.0) * 127.0)) & 0xff;"); + statement("return uint(Packed.x | (Packed.y << 8) | (Packed.z << 16) | (Packed.w << 24));"); + end_scope(); + statement(""); + + statement("float4 SPIRV_Cross_unpackSnorm4x8(uint value)"); + begin_scope(); + statement("int SignedValue = int(value);"); + statement("int4 Packed = int4(SignedValue << 24, SignedValue << 16, SignedValue << 8, SignedValue) >> 24;"); + statement("return clamp(float4(Packed) / 127.0, -1.0, 1.0);"); + end_scope(); + statement(""); + } + + if (requires_unorm16_packing) + { + statement("uint SPIRV_Cross_packUnorm2x16(float2 value)"); + begin_scope(); + statement("uint2 Packed = uint2(round(saturate(value) * 65535.0));"); + statement("return Packed.x | (Packed.y << 16);"); + end_scope(); + statement(""); + + statement("float2 SPIRV_Cross_unpackUnorm2x16(uint value)"); + begin_scope(); + statement("uint2 Packed = uint2(value & 0xffff, value >> 16);"); + statement("return float2(Packed) / 65535.0;"); + end_scope(); + statement(""); + } + + if (requires_snorm16_packing) + { + statement("uint SPIRV_Cross_packSnorm2x16(float2 value)"); + begin_scope(); + statement("int2 Packed = int2(round(clamp(value, -1.0, 1.0) * 32767.0)) & 0xffff;"); + statement("return uint(Packed.x | (Packed.y << 16));"); + end_scope(); + statement(""); + + statement("float2 SPIRV_Cross_unpackSnorm2x16(uint value)"); + begin_scope(); + statement("int SignedValue = int(value);"); + statement("int2 Packed = int2(SignedValue << 16, SignedValue) >> 16;"); + statement("return clamp(float2(Packed) / 32767.0, -1.0, 1.0);"); + end_scope(); + statement(""); + } + + if (requires_bitfield_insert) + { + static const char *types[] = { "uint", "uint2", "uint3", "uint4" }; + for (auto &type : types) + { + statement(type, " SPIRV_Cross_bitfieldInsert(", type, " Base, ", type, " Insert, uint Offset, uint Count)"); + begin_scope(); + statement("uint Mask = Count == 32 ? 0xffffffff : (((1u << Count) - 1) << (Offset & 31));"); + statement("return (Base & ~Mask) | ((Insert << Offset) & Mask);"); + end_scope(); + statement(""); + } + } + + if (requires_bitfield_extract) + { + static const char *unsigned_types[] = { "uint", "uint2", "uint3", "uint4" }; + for (auto &type : unsigned_types) + { + statement(type, " SPIRV_Cross_bitfieldUExtract(", type, " Base, uint Offset, uint Count)"); + begin_scope(); + statement("uint Mask = Count == 32 ? 0xffffffff : ((1 << Count) - 1);"); + statement("return (Base >> Offset) & Mask;"); + end_scope(); + statement(""); + } + + // In this overload, we will have to do sign-extension, which we will emulate by shifting up and down. + static const char *signed_types[] = { "int", "int2", "int3", "int4" }; + for (auto &type : signed_types) + { + statement(type, " SPIRV_Cross_bitfieldSExtract(", type, " Base, int Offset, int Count)"); + begin_scope(); + statement("int Mask = Count == 32 ? -1 : ((1 << Count) - 1);"); + statement(type, " Masked = (Base >> Offset) & Mask;"); + statement("int ExtendShift = (32 - Count) & 31;"); + statement("return (Masked << ExtendShift) >> ExtendShift;"); + end_scope(); + statement(""); + } + } +} + +string CompilerHLSL::layout_for_member(const SPIRType &type, uint32_t index) +{ + auto flags = combined_decoration_for_member(type, index); + + bool is_block = (meta[type.self].decoration.decoration_flags & + ((1ull << DecorationBlock) | (1ull << DecorationBufferBlock))) != 0; + + if (!is_block) + return ""; + + // Flip the convention. HLSL is a bit odd in that the memory layout is column major ... but the language API is "row-major". + // The way to deal with this is to multiply everything in inverse order, and reverse the memory layout. + if (flags & (1ull << DecorationColMajor)) + return "row_major "; + else if (flags & (1ull << DecorationRowMajor)) + return "column_major "; + + return ""; +} + +void CompilerHLSL::emit_struct_member(const SPIRType &type, uint32_t member_type_id, uint32_t index, + const string &qualifier) +{ + auto &membertype = get(member_type_id); + + uint64_t memberflags = 0; + auto &memb = meta[type.self].members; + if (index < memb.size()) + memberflags = memb[index].decoration_flags; + + string qualifiers; + bool is_block = (meta[type.self].decoration.decoration_flags & + ((1ull << DecorationBlock) | (1ull << DecorationBufferBlock))) != 0; + if (is_block) + qualifiers = to_interpolation_qualifiers(memberflags); + + string packing_offset; + if (has_decoration(type.self, DecorationCPacked) && has_member_decoration(type.self, index, DecorationOffset)) + { + uint32_t offset = memb[index].offset; + if (offset & 3) + SPIRV_CROSS_THROW("Cannot pack on tighter bounds than 4 bytes in HLSL."); + + static const char *packing_swizzle[] = { "", ".y", ".z", ".w" }; + packing_offset = join(" : packoffset(c", offset / 16, packing_swizzle[(offset & 15) >> 2], ")"); + } + + statement(layout_for_member(type, index), qualifiers, qualifier, + variable_decl(membertype, to_member_name(type, index)), packing_offset, ";"); +} + +void CompilerHLSL::emit_buffer_block(const SPIRVariable &var) +{ + auto &type = get(var.basetype); + + bool is_uav = var.storage == StorageClassStorageBuffer || has_decoration(type.self, DecorationBufferBlock); + + if (is_uav) + { + uint64_t flags = get_buffer_block_flags(var); + bool is_readonly = (flags & (1ull << DecorationNonWritable)) != 0; + add_resource_name(var.self); + statement(is_readonly ? "ByteAddressBuffer " : "RWByteAddressBuffer ", to_name(var.self), + type_to_array_glsl(type), to_resource_binding(var), ";"); + } + else + { + if (type.array.empty()) + { + if (buffer_is_packing_standard(type, BufferPackingHLSLCbufferPackOffset)) + set_decoration(type.self, DecorationCPacked); + else + SPIRV_CROSS_THROW("cbuffer cannot be expressed with either HLSL packing layout or packoffset."); + + // Flatten the top-level struct so we can use packoffset, + // this restriction is similar to GLSL where layout(offset) is not possible on sub-structs. + flattened_structs.insert(var.self); + + type.member_name_cache.clear(); + add_resource_name(var.self); + statement("cbuffer ", to_name(var.self), to_resource_binding(var)); + begin_scope(); + + uint32_t i = 0; + for (auto &member : type.member_types) + { + add_member_name(type, i); + auto backup_name = get_member_name(type.self, i); + auto member_name = to_member_name(type, i); + set_member_name(type.self, i, sanitize_underscores(join(to_name(var.self), "_", member_name))); + emit_struct_member(type, member, i, ""); + set_member_name(type.self, i, backup_name); + i++; + } + + end_scope_decl(); + } + else + { + if (options.shader_model < 51) + SPIRV_CROSS_THROW( + "Need ConstantBuffer to use arrays of UBOs, but this is only supported in SM 5.1."); + + // ConstantBuffer does not support packoffset, so it is unuseable unless everything aligns as we expect. + if (!buffer_is_packing_standard(type, BufferPackingHLSLCbuffer)) + SPIRV_CROSS_THROW("HLSL ConstantBuffer cannot be expressed with normal HLSL packing rules."); + + add_resource_name(type.self); + add_resource_name(var.self); + + emit_struct(get(type.self)); + statement("ConstantBuffer<", to_name(type.self), "> ", to_name(var.self), type_to_array_glsl(type), + to_resource_binding(var), ";"); + } + } +} + +void CompilerHLSL::emit_push_constant_block(const SPIRVariable &var) +{ + emit_buffer_block(var); +} + +string CompilerHLSL::to_sampler_expression(uint32_t id) +{ + auto expr = join("_", to_expression(id)); + auto index = expr.find_first_of('['); + if (index == string::npos) + { + return expr + "_sampler"; + } + else + { + // We have an expression like _ident[array], so we cannot tack on _sampler, insert it inside the string instead. + return expr.insert(index, "_sampler"); + } +} + +void CompilerHLSL::emit_sampled_image_op(uint32_t result_type, uint32_t result_id, uint32_t image_id, uint32_t samp_id) +{ + set(result_id, result_type, image_id, samp_id); +} + +string CompilerHLSL::to_func_call_arg(uint32_t id) +{ + string arg_str = CompilerGLSL::to_func_call_arg(id); + + if (options.shader_model <= 30) + return arg_str; + + // Manufacture automatic sampler arg if the arg is a SampledImage texture and we're in modern HLSL. + auto &type = expression_type(id); + + // We don't have to consider combined image samplers here via OpSampledImage because + // those variables cannot be passed as arguments to functions. + // Only global SampledImage variables may be used as arguments. + if (type.basetype == SPIRType::SampledImage && type.image.dim != DimBuffer) + arg_str += ", " + to_sampler_expression(id); + + return arg_str; +} + +void CompilerHLSL::emit_function_prototype(SPIRFunction &func, uint64_t return_flags) +{ + auto &execution = get_entry_point(); + // Avoid shadow declarations. + local_variable_names = resource_names; + + string decl; + + auto &type = get(func.return_type); + decl += flags_to_precision_qualifiers_glsl(type, return_flags); + decl += type_to_glsl(type); + decl += " "; + + if (func.self == entry_point) + { + if (execution.model == ExecutionModelVertex) + decl += "vert_main"; + else if (execution.model == ExecutionModelFragment) + decl += "frag_main"; + else if (execution.model == ExecutionModelGLCompute) + decl += "comp_main"; + else + SPIRV_CROSS_THROW("Unsupported execution model."); + processing_entry_point = true; + } + else + decl += to_name(func.self); + + decl += "("; + for (auto &arg : func.arguments) + { + // Might change the variable name if it already exists in this function. + // SPIRV OpName doesn't have any semantic effect, so it's valid for an implementation + // to use same name for variables. + // Since we want to make the GLSL debuggable and somewhat sane, use fallback names for variables which are duplicates. + add_local_variable_name(arg.id); + + decl += argument_decl(arg); + + // Flatten a combined sampler to two separate arguments in modern HLSL. + auto &arg_type = get(arg.type); + if (options.shader_model > 30 && arg_type.basetype == SPIRType::SampledImage && arg_type.image.dim != DimBuffer) + { + // Manufacture automatic sampler arg for SampledImage texture + decl += ", "; + decl += + join(arg_type.image.depth ? "SamplerComparisonState " : "SamplerState ", to_sampler_expression(arg.id)); + } + + if (&arg != &func.arguments.back()) + decl += ", "; + + // Hold a pointer to the parameter so we can invalidate the readonly field if needed. + auto *var = maybe_get(arg.id); + if (var) + var->parameter = &arg; + } + + decl += ")"; + statement(decl); +} + +void CompilerHLSL::emit_hlsl_entry_point() +{ + vector arguments; + + if (require_input) + arguments.push_back("SPIRV_Cross_Input stage_input"); + + // Add I/O blocks as separate arguments with appropriate storage qualifier. + for (auto &id : ids) + { + if (id.get_type() == TypeVariable) + { + auto &var = id.get(); + auto &type = get(var.basetype); + bool block = (meta[type.self].decoration.decoration_flags & (1ull << DecorationBlock)) != 0; + + if (var.storage != StorageClassInput && var.storage != StorageClassOutput) + continue; + + if (block && !is_builtin_variable(var) && interface_variable_exists_in_entry_point(var.self)) + { + if (var.storage == StorageClassInput) + { + arguments.push_back(join("in ", variable_decl(type, join("stage_input", to_name(var.self))))); + } + else if (var.storage == StorageClassOutput) + { + arguments.push_back(join("out ", variable_decl(type, join("stage_output", to_name(var.self))))); + } + } + } + } + + auto &execution = get_entry_point(); + + switch (execution.model) + { + case ExecutionModelGLCompute: + { + SpecializationConstant wg_x, wg_y, wg_z; + get_work_group_size_specialization_constants(wg_x, wg_y, wg_z); + + uint32_t x = execution.workgroup_size.x; + uint32_t y = execution.workgroup_size.y; + uint32_t z = execution.workgroup_size.z; + + if (wg_x.id) + x = get(wg_x.id).scalar(); + if (wg_y.id) + y = get(wg_y.id).scalar(); + if (wg_z.id) + z = get(wg_z.id).scalar(); + + statement("[numthreads(", x, ", ", y, ", ", z, ")]"); + break; + } + case ExecutionModelFragment: + if (execution.flags & (1ull << ExecutionModeEarlyFragmentTests)) + statement("[earlydepthstencil]"); + break; + default: + break; + } + + statement(require_output ? "SPIRV_Cross_Output " : "void ", "main(", merge(arguments), ")"); + begin_scope(); + bool legacy = options.shader_model <= 30; + + // Copy builtins from entry point arguments to globals. + for (uint32_t i = 0; i < 64; i++) + { + if (!(active_input_builtins & (1ull << i))) + continue; + + auto builtin = builtin_to_glsl(static_cast(i), StorageClassInput); + switch (static_cast(i)) + { + case BuiltInFragCoord: + // VPOS in D3D9 is sampled at integer locations, apply half-pixel offset to be consistent. + // TODO: Do we need an option here? Any reason why a D3D9 shader would be used + // on a D3D10+ system with a different rasterization config? + if (legacy) + statement(builtin, " = stage_input.", builtin, " + float4(0.5f, 0.5f, 0.0f, 0.0f);"); + else + statement(builtin, " = stage_input.", builtin, ";"); + break; + + case BuiltInVertexId: + case BuiltInVertexIndex: + case BuiltInInstanceId: + case BuiltInInstanceIndex: + // D3D semantics are uint, but shader wants int. + statement(builtin, " = int(stage_input.", builtin, ");"); + break; + + default: + statement(builtin, " = stage_input.", builtin, ";"); + break; + } + } + + // Copy from stage input struct to globals. + for (auto &id : ids) + { + if (id.get_type() == TypeVariable) + { + auto &var = id.get(); + auto &type = get(var.basetype); + bool block = (meta[type.self].decoration.decoration_flags & (1ull << DecorationBlock)) != 0; + + if (var.storage != StorageClassInput) + continue; + + bool need_matrix_unroll = var.storage == StorageClassInput && execution.model == ExecutionModelVertex; + + if (!block && !var.remapped_variable && type.pointer && !is_builtin_variable(var) && + interface_variable_exists_in_entry_point(var.self)) + { + auto name = to_name(var.self); + auto &mtype = get(var.basetype); + if (need_matrix_unroll && mtype.columns > 1) + { + // Unroll matrices. + for (uint32_t col = 0; col < mtype.columns; col++) + statement(name, "[", col, "] = stage_input.", name, "_", col, ";"); + } + else + { + statement(name, " = stage_input.", name, ";"); + } + } + + // I/O blocks don't use the common stage input/output struct, but separate outputs. + if (block && !is_builtin_variable(var) && interface_variable_exists_in_entry_point(var.self)) + { + auto name = to_name(var.self); + statement(name, " = stage_input", name, ";"); + } + } + } + + // Run the shader. + if (execution.model == ExecutionModelVertex) + statement("vert_main();"); + else if (execution.model == ExecutionModelFragment) + statement("frag_main();"); + else if (execution.model == ExecutionModelGLCompute) + statement("comp_main();"); + else + SPIRV_CROSS_THROW("Unsupported shader stage."); + + // Copy block outputs. + for (auto &id : ids) + { + if (id.get_type() == TypeVariable) + { + auto &var = id.get(); + auto &type = get(var.basetype); + bool block = (meta[type.self].decoration.decoration_flags & (1ull << DecorationBlock)) != 0; + + if (var.storage != StorageClassOutput) + continue; + + // I/O blocks don't use the common stage input/output struct, but separate outputs. + if (block && !is_builtin_variable(var) && interface_variable_exists_in_entry_point(var.self)) + { + auto name = to_name(var.self); + statement("stage_output", name, " = ", name, ";"); + } + } + } + + // Copy stage outputs. + if (require_output) + { + statement("SPIRV_Cross_Output stage_output;"); + + // Copy builtins from globals to return struct. + for (uint32_t i = 0; i < 64; i++) + { + if (!(active_output_builtins & (1ull << i))) + continue; + + // PointSize doesn't exist in HLSL. + if (i == BuiltInPointSize) + continue; + + auto builtin = builtin_to_glsl(static_cast(i), StorageClassOutput); + statement("stage_output.", builtin, " = ", builtin, ";"); + } + + for (auto &id : ids) + { + if (id.get_type() == TypeVariable) + { + auto &var = id.get(); + auto &type = get(var.basetype); + bool block = (meta[type.self].decoration.decoration_flags & (1ull << DecorationBlock)) != 0; + + if (var.storage != StorageClassOutput) + continue; + + if (!block && var.storage != StorageClassFunction && !var.remapped_variable && type.pointer && + !is_builtin_variable(var) && interface_variable_exists_in_entry_point(var.self)) + { + auto name = to_name(var.self); + statement("stage_output.", name, " = ", name, ";"); + } + } + } + + statement("return stage_output;"); + } + + end_scope(); +} + +void CompilerHLSL::emit_fixup() +{ + if (get_entry_point().model == ExecutionModelVertex) + { + // Do various mangling on the gl_Position. + if (options.shader_model <= 30) + { + statement("gl_Position.x = gl_Position.x - gl_HalfPixel.x * " + "gl_Position.w;"); + statement("gl_Position.y = gl_Position.y + gl_HalfPixel.y * " + "gl_Position.w;"); + } + + if (CompilerGLSL::options.vertex.flip_vert_y) + statement("gl_Position.y = -gl_Position.y;"); + if (CompilerGLSL::options.vertex.fixup_clipspace) + statement("gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;"); + } +} + +void CompilerHLSL::emit_texture_op(const Instruction &i) +{ + auto ops = stream(i); + auto op = static_cast(i.op); + uint32_t length = i.length; + + if (i.offset + length > spirv.size()) + SPIRV_CROSS_THROW("Compiler::parse() opcode out of range."); + + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + uint32_t img = ops[2]; + uint32_t coord = ops[3]; + uint32_t dref = 0; + uint32_t comp = 0; + bool gather = false; + bool proj = false; + const uint32_t *opt = nullptr; + auto *combined_image = maybe_get(img); + auto img_expr = to_expression(combined_image ? combined_image->image : img); + + switch (op) + { + case OpImageSampleDrefImplicitLod: + case OpImageSampleDrefExplicitLod: + dref = ops[4]; + opt = &ops[5]; + length -= 5; + break; + + case OpImageSampleProjDrefImplicitLod: + case OpImageSampleProjDrefExplicitLod: + dref = ops[4]; + proj = true; + opt = &ops[5]; + length -= 5; + break; + + case OpImageDrefGather: + dref = ops[4]; + opt = &ops[5]; + gather = true; + length -= 5; + break; + + case OpImageGather: + comp = ops[4]; + opt = &ops[5]; + gather = true; + length -= 5; + break; + + case OpImageSampleProjImplicitLod: + case OpImageSampleProjExplicitLod: + opt = &ops[4]; + length -= 4; + proj = true; + break; + + case OpImageQueryLod: + opt = &ops[4]; + length -= 4; + break; + + default: + opt = &ops[4]; + length -= 4; + break; + } + + auto &imgtype = expression_type(img); + uint32_t coord_components = 0; + switch (imgtype.image.dim) + { + case spv::Dim1D: + coord_components = 1; + break; + case spv::Dim2D: + coord_components = 2; + break; + case spv::Dim3D: + coord_components = 3; + break; + case spv::DimCube: + coord_components = 3; + break; + case spv::DimBuffer: + coord_components = 1; + break; + default: + coord_components = 2; + break; + } + + if (proj) + coord_components++; + if (imgtype.image.arrayed) + coord_components++; + + uint32_t bias = 0; + uint32_t lod = 0; + uint32_t grad_x = 0; + uint32_t grad_y = 0; + uint32_t coffset = 0; + uint32_t offset = 0; + uint32_t coffsets = 0; + uint32_t sample = 0; + uint32_t flags = 0; + + if (length) + { + flags = opt[0]; + opt++; + length--; + } + + auto test = [&](uint32_t &v, uint32_t flag) { + if (length && (flags & flag)) + { + v = *opt++; + length--; + } + }; + + test(bias, ImageOperandsBiasMask); + test(lod, ImageOperandsLodMask); + test(grad_x, ImageOperandsGradMask); + test(grad_y, ImageOperandsGradMask); + test(coffset, ImageOperandsConstOffsetMask); + test(offset, ImageOperandsOffsetMask); + test(coffsets, ImageOperandsConstOffsetsMask); + test(sample, ImageOperandsSampleMask); + + string expr; + string texop; + + if (op == OpImageFetch) + { + if (options.shader_model < 40) + { + SPIRV_CROSS_THROW("texelFetch is not supported in HLSL shader model 2/3."); + } + texop += img_expr; + texop += ".Load"; + } + else if (op == OpImageQueryLod) + { + texop += img_expr; + texop += ".CalculateLevelOfDetail"; + } + else + { + auto &imgformat = get(imgtype.image.type); + if (imgformat.basetype != SPIRType::Float) + { + SPIRV_CROSS_THROW("Sampling non-float textures is not supported in HLSL."); + } + + if (options.shader_model >= 40) + { + texop += img_expr; + + if (imgtype.image.depth) + { + if (gather) + { + SPIRV_CROSS_THROW("GatherCmp does not exist in HLSL."); + } + else if (lod || grad_x || grad_y) + { + // Assume we want a fixed level, and the only thing we can get in HLSL is SampleCmpLevelZero. + texop += ".SampleCmpLevelZero"; + } + else + texop += ".SampleCmp"; + } + else if (gather) + { + uint32_t comp_num = get(comp).scalar(); + if (options.shader_model >= 50) + { + switch (comp_num) + { + case 0: + texop += ".GatherRed"; + break; + case 1: + texop += ".GatherGreen"; + break; + case 2: + texop += ".GatherBlue"; + break; + case 3: + texop += ".GatherAlpha"; + break; + default: + SPIRV_CROSS_THROW("Invalid component."); + } + } + else + { + if (comp_num == 0) + texop += ".Gather"; + else + SPIRV_CROSS_THROW("HLSL shader model 4 can only gather from the red component."); + } + } + else if (bias) + texop += ".SampleBias"; + else if (grad_x || grad_y) + texop += ".SampleGrad"; + else if (lod) + texop += ".SampleLevel"; + else + texop += ".Sample"; + } + else + { + switch (imgtype.image.dim) + { + case Dim1D: + texop += "tex1D"; + break; + case Dim2D: + texop += "tex2D"; + break; + case Dim3D: + texop += "tex3D"; + break; + case DimCube: + texop += "texCUBE"; + break; + case DimRect: + case DimBuffer: + case DimSubpassData: + SPIRV_CROSS_THROW("Buffer texture support is not yet implemented for HLSL"); // TODO + default: + SPIRV_CROSS_THROW("Invalid dimension."); + } + + if (gather) + SPIRV_CROSS_THROW("textureGather is not supported in HLSL shader model 2/3."); + if (offset || coffset) + SPIRV_CROSS_THROW("textureOffset is not supported in HLSL shader model 2/3."); + if (proj) + texop += "proj"; + if (grad_x || grad_y) + texop += "grad"; + if (lod) + texop += "lod"; + if (bias) + texop += "bias"; + } + } + + expr += texop; + expr += "("; + if (options.shader_model < 40) + { + if (combined_image) + SPIRV_CROSS_THROW("Separate images/samplers are not supported in HLSL shader model 2/3."); + expr += to_expression(img); + } + else if (op != OpImageFetch) + { + string sampler_expr; + if (combined_image) + sampler_expr = to_expression(combined_image->sampler); + else + sampler_expr = to_sampler_expression(img); + expr += sampler_expr; + } + + auto swizzle = [](uint32_t comps, uint32_t in_comps) -> const char * { + if (comps == in_comps) + return ""; + + switch (comps) + { + case 1: + return ".x"; + case 2: + return ".xy"; + case 3: + return ".xyz"; + default: + return ""; + } + }; + + bool forward = should_forward(coord); + + // The IR can give us more components than we need, so chop them off as needed. + auto coord_expr = to_expression(coord) + swizzle(coord_components, expression_type(coord).vecsize); + + if (proj) + { + if (!requires_textureProj) + { + requires_textureProj = true; + force_recompile = true; + } + coord_expr = "SPIRV_Cross_projectTextureCoordinate(" + coord_expr + ")"; + } + + if (options.shader_model < 40 && lod) + { + auto &coordtype = expression_type(coord); + string coord_filler; + for (uint32_t size = coordtype.vecsize; size < 3; ++size) + { + coord_filler += ", 0.0"; + } + coord_expr = "float4(" + coord_expr + coord_filler + ", " + to_expression(lod) + ")"; + } + + if (options.shader_model < 40 && bias) + { + auto &coordtype = expression_type(coord); + string coord_filler; + for (uint32_t size = coordtype.vecsize; size < 3; ++size) + { + coord_filler += ", 0.0"; + } + coord_expr = "float4(" + coord_expr + coord_filler + ", " + to_expression(bias) + ")"; + } + + if (op == OpImageFetch) + { + auto &coordtype = expression_type(coord); + if (imgtype.image.dim != DimBuffer) + coord_expr = join("int", coordtype.vecsize + 1, "(", coord_expr, ", ", to_expression(lod), ")"); + } + else + expr += ", "; + expr += coord_expr; + + if (dref) + { + forward = forward && should_forward(dref); + expr += ", "; + expr += to_expression(dref); + } + + if (!dref && (grad_x || grad_y)) + { + forward = forward && should_forward(grad_x); + forward = forward && should_forward(grad_y); + expr += ", "; + expr += to_expression(grad_x); + expr += ", "; + expr += to_expression(grad_y); + } + + if (!dref && lod && options.shader_model >= 40 && op != OpImageFetch) + { + forward = forward && should_forward(lod); + expr += ", "; + expr += to_expression(lod); + } + + if (!dref && bias && options.shader_model >= 40) + { + forward = forward && should_forward(bias); + expr += ", "; + expr += to_expression(bias); + } + + if (coffset) + { + forward = forward && should_forward(coffset); + expr += ", "; + expr += to_expression(coffset); + } + else if (offset) + { + forward = forward && should_forward(offset); + expr += ", "; + expr += to_expression(offset); + } + + if (sample) + { + expr += ", "; + expr += to_expression(sample); + } + + expr += ")"; + + if (op == OpImageQueryLod) + { + // This is rather awkward. + // textureQueryLod returns two values, the "accessed level", + // as well as the actual LOD lambda. + // As far as I can tell, there is no way to get the .x component + // according to GLSL spec, and it depends on the sampler itself. + // Just assume X == Y, so we will need to splat the result to a float2. + statement("float _", id, "_tmp = ", expr, ";"); + emit_op(result_type, id, join("float2(_", id, "_tmp, _", id, "_tmp)"), true, true); + } + else + { + emit_op(result_type, id, expr, forward, false); + } +} + +string CompilerHLSL::to_resource_binding(const SPIRVariable &var) +{ + // TODO: Basic implementation, might need special consideration for RW/RO structured buffers, + // RW/RO images, and so on. + + if (!has_decoration(var.self, DecorationBinding)) + return ""; + + auto &type = get(var.basetype); + const char *space = nullptr; + + switch (type.basetype) + { + case SPIRType::SampledImage: + space = "t"; // SRV + break; + + case SPIRType::Image: + if (type.image.sampled == 2) + space = "u"; // UAV + else + space = "t"; // SRV + break; + + case SPIRType::Sampler: + space = "s"; + break; + + case SPIRType::Struct: + { + auto storage = type.storage; + if (storage == StorageClassUniform) + { + if (has_decoration(type.self, DecorationBufferBlock)) + { + uint64_t flags = get_buffer_block_flags(var); + bool is_readonly = (flags & (1ull << DecorationNonWritable)) != 0; + space = is_readonly ? "t" : "u"; // UAV + } + else if (has_decoration(type.self, DecorationBlock)) + space = "b"; // Constant buffers + } + else if (storage == StorageClassPushConstant) + space = "b"; // Constant buffers + else if (storage == StorageClassStorageBuffer) + space = "u"; // UAV + + break; + } + default: + break; + } + + if (!space) + return ""; + + // shader model 5.1 supports space + if (options.shader_model >= 51) + return join(" : register(", space, get_decoration(var.self, DecorationBinding), ", space", + get_decoration(var.self, DecorationDescriptorSet), ")"); + else + return join(" : register(", space, get_decoration(var.self, DecorationBinding), ")"); +} + +string CompilerHLSL::to_resource_binding_sampler(const SPIRVariable &var) +{ + // For combined image samplers. + if (!has_decoration(var.self, DecorationBinding)) + return ""; + + if (options.shader_model >= 51) + return join(" : register(s", get_decoration(var.self, DecorationBinding), ", space", + get_decoration(var.self, DecorationDescriptorSet), ")"); + else + return join(" : register(s", get_decoration(var.self, DecorationBinding), ")"); +} + +void CompilerHLSL::emit_modern_uniform(const SPIRVariable &var) +{ + auto &type = get(var.basetype); + switch (type.basetype) + { + case SPIRType::SampledImage: + case SPIRType::Image: + { + statement(image_type_hlsl_modern(type), " ", to_name(var.self), type_to_array_glsl(type), + to_resource_binding(var), ";"); + + if (type.basetype == SPIRType::SampledImage && type.image.dim != DimBuffer) + { + // For combined image samplers, also emit a combined image sampler. + if (type.image.depth) + statement("SamplerComparisonState ", to_sampler_expression(var.self), type_to_array_glsl(type), + to_resource_binding_sampler(var), ";"); + else + statement("SamplerState ", to_sampler_expression(var.self), type_to_array_glsl(type), + to_resource_binding_sampler(var), ";"); + } + break; + } + + case SPIRType::Sampler: + if (comparison_samplers.count(var.self)) + statement("SamplerComparisonState ", to_name(var.self), type_to_array_glsl(type), to_resource_binding(var), + ";"); + else + statement("SamplerState ", to_name(var.self), type_to_array_glsl(type), to_resource_binding(var), ";"); + break; + + default: + statement(variable_decl(var), to_resource_binding(var), ";"); + break; + } +} + +void CompilerHLSL::emit_legacy_uniform(const SPIRVariable &var) +{ + auto &type = get(var.basetype); + switch (type.basetype) + { + case SPIRType::Sampler: + case SPIRType::Image: + SPIRV_CROSS_THROW("Separate image and samplers not supported in legacy HLSL."); + + default: + statement(variable_decl(var), ";"); + break; + } +} + +void CompilerHLSL::emit_uniform(const SPIRVariable &var) +{ + add_resource_name(var.self); + if (options.shader_model >= 40) + emit_modern_uniform(var); + else + emit_legacy_uniform(var); +} + +string CompilerHLSL::bitcast_glsl_op(const SPIRType &out_type, const SPIRType &in_type) +{ + if (out_type.basetype == SPIRType::UInt && in_type.basetype == SPIRType::Int) + return type_to_glsl(out_type); + else if (out_type.basetype == SPIRType::UInt64 && in_type.basetype == SPIRType::Int64) + return type_to_glsl(out_type); + else if (out_type.basetype == SPIRType::UInt && in_type.basetype == SPIRType::Float) + return "asuint"; + else if (out_type.basetype == SPIRType::Int && in_type.basetype == SPIRType::UInt) + return type_to_glsl(out_type); + else if (out_type.basetype == SPIRType::Int64 && in_type.basetype == SPIRType::UInt64) + return type_to_glsl(out_type); + else if (out_type.basetype == SPIRType::Int && in_type.basetype == SPIRType::Float) + return "asint"; + else if (out_type.basetype == SPIRType::Float && in_type.basetype == SPIRType::UInt) + return "asfloat"; + else if (out_type.basetype == SPIRType::Float && in_type.basetype == SPIRType::Int) + return "asfloat"; + else if (out_type.basetype == SPIRType::Int64 && in_type.basetype == SPIRType::Double) + SPIRV_CROSS_THROW("Double to Int64 is not supported in HLSL."); + else if (out_type.basetype == SPIRType::UInt64 && in_type.basetype == SPIRType::Double) + SPIRV_CROSS_THROW("Double to UInt64 is not supported in HLSL."); + else if (out_type.basetype == SPIRType::Double && in_type.basetype == SPIRType::Int64) + return "asdouble"; + else if (out_type.basetype == SPIRType::Double && in_type.basetype == SPIRType::UInt64) + return "asdouble"; + else + return ""; +} + +void CompilerHLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop, const uint32_t *args, uint32_t count) +{ + GLSLstd450 op = static_cast(eop); + + switch (op) + { + case GLSLstd450InverseSqrt: + emit_unary_func_op(result_type, id, args[0], "rsqrt"); + break; + + case GLSLstd450Fract: + emit_unary_func_op(result_type, id, args[0], "frac"); + break; + + case GLSLstd450FMix: + case GLSLstd450IMix: + emit_trinary_func_op(result_type, id, args[0], args[1], args[2], "lerp"); + break; + + case GLSLstd450Atan2: + emit_binary_func_op(result_type, id, args[0], args[1], "atan2"); + break; + + case GLSLstd450Fma: + emit_trinary_func_op(result_type, id, args[0], args[1], args[2], "mad"); + break; + + case GLSLstd450InterpolateAtCentroid: + emit_unary_func_op(result_type, id, args[0], "EvaluateAttributeAtCentroid"); + break; + case GLSLstd450InterpolateAtSample: + emit_binary_func_op(result_type, id, args[0], args[1], "EvaluateAttributeAtSample"); + break; + case GLSLstd450InterpolateAtOffset: + emit_binary_func_op(result_type, id, args[0], args[1], "EvaluateAttributeSnapped"); + break; + + case GLSLstd450PackHalf2x16: + if (!requires_fp16_packing) + { + requires_fp16_packing = true; + force_recompile = true; + } + emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_packHalf2x16"); + break; + + case GLSLstd450UnpackHalf2x16: + if (!requires_fp16_packing) + { + requires_fp16_packing = true; + force_recompile = true; + } + emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_unpackHalf2x16"); + break; + + case GLSLstd450PackSnorm4x8: + if (!requires_snorm8_packing) + { + requires_snorm8_packing = true; + force_recompile = true; + } + emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_packSnorm4x8"); + break; + + case GLSLstd450UnpackSnorm4x8: + if (!requires_snorm8_packing) + { + requires_snorm8_packing = true; + force_recompile = true; + } + emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_unpackSnorm4x8"); + break; + + case GLSLstd450PackUnorm4x8: + if (!requires_unorm8_packing) + { + requires_unorm8_packing = true; + force_recompile = true; + } + emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_packUnorm4x8"); + break; + + case GLSLstd450UnpackUnorm4x8: + if (!requires_unorm8_packing) + { + requires_unorm8_packing = true; + force_recompile = true; + } + emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_unpackUnorm4x8"); + break; + + case GLSLstd450PackSnorm2x16: + if (!requires_snorm16_packing) + { + requires_snorm16_packing = true; + force_recompile = true; + } + emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_packSnorm2x16"); + break; + + case GLSLstd450UnpackSnorm2x16: + if (!requires_snorm16_packing) + { + requires_snorm16_packing = true; + force_recompile = true; + } + emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_unpackSnorm2x16"); + break; + + case GLSLstd450PackUnorm2x16: + if (!requires_unorm16_packing) + { + requires_unorm16_packing = true; + force_recompile = true; + } + emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_packUnorm2x16"); + break; + + case GLSLstd450UnpackUnorm2x16: + if (!requires_unorm16_packing) + { + requires_unorm16_packing = true; + force_recompile = true; + } + emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_unpackUnorm2x16"); + break; + + case GLSLstd450PackDouble2x32: + case GLSLstd450UnpackDouble2x32: + SPIRV_CROSS_THROW("packDouble2x32/unpackDouble2x32 not supported in HLSL."); + + case GLSLstd450FindILsb: + emit_unary_func_op(result_type, id, args[0], "firstbitlow"); + break; + case GLSLstd450FindSMsb: + case GLSLstd450FindUMsb: + emit_unary_func_op(result_type, id, args[0], "firstbithigh"); + break; + + default: + CompilerGLSL::emit_glsl_op(result_type, id, eop, args, count); + break; + } +} + +string CompilerHLSL::read_access_chain(const SPIRAccessChain &chain) +{ + auto &type = get(chain.basetype); + + SPIRType target_type; + target_type.basetype = SPIRType::UInt; + target_type.vecsize = type.vecsize; + target_type.columns = type.columns; + + if (type.basetype == SPIRType::Struct) + SPIRV_CROSS_THROW("Reading structs from ByteAddressBuffer not yet supported."); + + if (type.width != 32) + SPIRV_CROSS_THROW("Reading types other than 32-bit from ByteAddressBuffer not yet supported."); + + if (!type.array.empty()) + SPIRV_CROSS_THROW("Reading arrays from ByteAddressBuffer not yet supported."); + + string load_expr; + + // Load a vector or scalar. + if (type.columns == 1 && !chain.row_major_matrix) + { + const char *load_op = nullptr; + switch (type.vecsize) + { + case 1: + load_op = "Load"; + break; + case 2: + load_op = "Load2"; + break; + case 3: + load_op = "Load3"; + break; + case 4: + load_op = "Load4"; + break; + default: + SPIRV_CROSS_THROW("Unknown vector size."); + } + + load_expr = join(chain.base, ".", load_op, "(", chain.dynamic_index, chain.static_index, ")"); + } + else if (type.columns == 1) + { + // Strided load since we are loading a column from a row-major matrix. + if (type.vecsize > 1) + { + load_expr = type_to_glsl(target_type); + load_expr += "("; + } + + for (uint32_t r = 0; r < type.vecsize; r++) + { + load_expr += + join(chain.base, ".Load(", chain.dynamic_index, chain.static_index + r * chain.matrix_stride, ")"); + if (r + 1 < type.vecsize) + load_expr += ", "; + } + + if (type.vecsize > 1) + load_expr += ")"; + } + else if (!chain.row_major_matrix) + { + // Load a matrix, column-major, the easy case. + const char *load_op = nullptr; + switch (type.vecsize) + { + case 1: + load_op = "Load"; + break; + case 2: + load_op = "Load2"; + break; + case 3: + load_op = "Load3"; + break; + case 4: + load_op = "Load4"; + break; + default: + SPIRV_CROSS_THROW("Unknown vector size."); + } + + // Note, this loading style in HLSL is *actually* row-major, but we always treat matrices as transposed in this backend, + // so row-major is technically column-major ... + load_expr = type_to_glsl(target_type); + load_expr += "("; + for (uint32_t c = 0; c < type.columns; c++) + { + load_expr += join(chain.base, ".", load_op, "(", chain.dynamic_index, + chain.static_index + c * chain.matrix_stride, ")"); + if (c + 1 < type.columns) + load_expr += ", "; + } + load_expr += ")"; + } + else + { + // Pick out elements one by one ... Hopefully compilers are smart enough to recognize this pattern + // considering HLSL is "row-major decl", but "column-major" memory layout (basically implicit transpose model, ugh) ... + + load_expr = type_to_glsl(target_type); + load_expr += "("; + for (uint32_t c = 0; c < type.columns; c++) + { + for (uint32_t r = 0; r < type.vecsize; r++) + { + load_expr += join(chain.base, ".Load(", chain.dynamic_index, + chain.static_index + c * (type.width / 8) + r * chain.matrix_stride, ")"); + + if ((r + 1 < type.vecsize) || (c + 1 < type.columns)) + load_expr += ", "; + } + } + load_expr += ")"; + } + + auto bitcast_op = bitcast_glsl_op(type, target_type); + if (!bitcast_op.empty()) + load_expr = join(bitcast_op, "(", load_expr, ")"); + + return load_expr; +} + +void CompilerHLSL::emit_load(const Instruction &instruction) +{ + auto ops = stream(instruction); + + auto *chain = maybe_get(ops[2]); + if (chain) + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + uint32_t ptr = ops[2]; + + auto load_expr = read_access_chain(*chain); + + bool forward = should_forward(ptr) && forced_temporaries.find(id) == end(forced_temporaries); + + // Do not forward complex load sequences like matrices, structs and arrays. + auto &type = get(result_type); + if (type.columns > 1 || !type.array.empty() || type.basetype == SPIRType::Struct) + forward = false; + + auto &e = emit_op(result_type, id, load_expr, forward, true); + e.need_transpose = false; + register_read(id, ptr, forward); + } + else + CompilerGLSL::emit_instruction(instruction); +} + +void CompilerHLSL::write_access_chain(const SPIRAccessChain &chain, uint32_t value) +{ + auto &type = get(chain.basetype); + + SPIRType target_type; + target_type.basetype = SPIRType::UInt; + target_type.vecsize = type.vecsize; + target_type.columns = type.columns; + + if (type.basetype == SPIRType::Struct) + SPIRV_CROSS_THROW("Writing structs to RWByteAddressBuffer not yet supported."); + if (type.width != 32) + SPIRV_CROSS_THROW("Writing types other than 32-bit to RWByteAddressBuffer not yet supported."); + if (!type.array.empty()) + SPIRV_CROSS_THROW("Reading arrays from ByteAddressBuffer not yet supported."); + + if (type.columns == 1 && !chain.row_major_matrix) + { + const char *store_op = nullptr; + switch (type.vecsize) + { + case 1: + store_op = "Store"; + break; + case 2: + store_op = "Store2"; + break; + case 3: + store_op = "Store3"; + break; + case 4: + store_op = "Store4"; + break; + default: + SPIRV_CROSS_THROW("Unknown vector size."); + } + + auto store_expr = to_expression(value); + auto bitcast_op = bitcast_glsl_op(target_type, type); + if (!bitcast_op.empty()) + store_expr = join(bitcast_op, "(", store_expr, ")"); + statement(chain.base, ".", store_op, "(", chain.dynamic_index, chain.static_index, ", ", store_expr, ");"); + } + else if (type.columns == 1) + { + // Strided store. + for (uint32_t r = 0; r < type.vecsize; r++) + { + auto store_expr = to_enclosed_expression(value); + if (type.vecsize > 1) + { + store_expr += "."; + store_expr += index_to_swizzle(r); + } + remove_duplicate_swizzle(store_expr); + + auto bitcast_op = bitcast_glsl_op(target_type, type); + if (!bitcast_op.empty()) + store_expr = join(bitcast_op, "(", store_expr, ")"); + statement(chain.base, ".Store(", chain.dynamic_index, chain.static_index + chain.matrix_stride * r, ", ", + store_expr, ");"); + } + } + else if (!chain.row_major_matrix) + { + const char *store_op = nullptr; + switch (type.vecsize) + { + case 1: + store_op = "Store"; + break; + case 2: + store_op = "Store2"; + break; + case 3: + store_op = "Store3"; + break; + case 4: + store_op = "Store4"; + break; + default: + SPIRV_CROSS_THROW("Unknown vector size."); + } + + for (uint32_t c = 0; c < type.columns; c++) + { + auto store_expr = join(to_enclosed_expression(value), "[", c, "]"); + auto bitcast_op = bitcast_glsl_op(target_type, type); + if (!bitcast_op.empty()) + store_expr = join(bitcast_op, "(", store_expr, ")"); + statement(chain.base, ".", store_op, "(", chain.dynamic_index, chain.static_index + c * chain.matrix_stride, + ", ", store_expr, ");"); + } + } + else + { + for (uint32_t r = 0; r < type.vecsize; r++) + { + for (uint32_t c = 0; c < type.columns; c++) + { + auto store_expr = join(to_enclosed_expression(value), "[", c, "].", index_to_swizzle(r)); + remove_duplicate_swizzle(store_expr); + auto bitcast_op = bitcast_glsl_op(target_type, type); + if (!bitcast_op.empty()) + store_expr = join(bitcast_op, "(", store_expr, ")"); + statement(chain.base, ".Store(", chain.dynamic_index, + chain.static_index + c * (type.width / 8) + r * chain.matrix_stride, ", ", store_expr, ");"); + } + } + } + + register_write(chain.self); +} + +void CompilerHLSL::emit_store(const Instruction &instruction) +{ + auto ops = stream(instruction); + auto *chain = maybe_get(ops[0]); + if (chain) + write_access_chain(*chain, ops[1]); + else + CompilerGLSL::emit_instruction(instruction); +} + +void CompilerHLSL::emit_access_chain(const Instruction &instruction) +{ + auto ops = stream(instruction); + uint32_t length = instruction.length; + + bool need_byte_access_chain = false; + auto &type = expression_type(ops[2]); + const SPIRAccessChain *chain = nullptr; + if (type.storage == StorageClassStorageBuffer || has_decoration(type.self, DecorationBufferBlock)) + { + // If we are starting to poke into an SSBO, we are dealing with ByteAddressBuffers, and we need + // to emit SPIRAccessChain rather than a plain SPIRExpression. + uint32_t chain_arguments = length - 3; + if (chain_arguments > type.array.size()) + need_byte_access_chain = true; + } + else + { + // Keep tacking on an existing access chain. + chain = maybe_get(ops[2]); + if (chain) + need_byte_access_chain = true; + } + + if (need_byte_access_chain) + { + uint32_t to_plain_buffer_length = static_cast(type.array.size()); + + string base; + if (to_plain_buffer_length != 0) + { + bool need_transpose; + base = access_chain(ops[2], &ops[3], to_plain_buffer_length, get(ops[0]), &need_transpose); + } + else + base = to_expression(ops[2]); + + auto *basetype = &type; + + // Start traversing type hierarchy at the proper non-pointer types. + while (basetype->pointer) + { + assert(basetype->parent_type); + basetype = &get(basetype->parent_type); + } + + // Traverse the type hierarchy down to the actual buffer types. + for (uint32_t i = 0; i < to_plain_buffer_length; i++) + { + assert(basetype->parent_type); + basetype = &get(basetype->parent_type); + } + + uint32_t matrix_stride = 0; + bool row_major_matrix = false; + + // Inherit matrix information. + if (chain) + { + matrix_stride = chain->matrix_stride; + row_major_matrix = chain->row_major_matrix; + } + + auto offsets = + flattened_access_chain_offset(*basetype, &ops[3 + to_plain_buffer_length], + length - 3 - to_plain_buffer_length, 0, 1, &row_major_matrix, &matrix_stride); + + auto &e = set(ops[1], ops[0], type.storage, base, offsets.first, offsets.second); + e.row_major_matrix = row_major_matrix; + e.matrix_stride = matrix_stride; + e.immutable = should_forward(ops[2]); + + if (chain) + { + e.dynamic_index += chain->dynamic_index; + e.static_index += chain->static_index; + } + } + else + { + CompilerGLSL::emit_instruction(instruction); + } +} + +void CompilerHLSL::emit_atomic(const uint32_t *ops, uint32_t length, spv::Op op) +{ + const char *atomic_op = nullptr; + auto value_expr = to_expression(ops[op == OpAtomicCompareExchange ? 6 : 5]); + + switch (op) + { + case OpAtomicISub: + atomic_op = "InterlockedAdd"; + value_expr = join("-", enclose_expression(value_expr)); + break; + + case OpAtomicSMin: + case OpAtomicUMin: + atomic_op = "InterlockedMin"; + break; + + case OpAtomicSMax: + case OpAtomicUMax: + atomic_op = "InterlockedMax"; + break; + + case OpAtomicAnd: + atomic_op = "InterlockedAnd"; + break; + + case OpAtomicOr: + atomic_op = "InterlockedOr"; + break; + + case OpAtomicXor: + atomic_op = "InterlockedXor"; + break; + + case OpAtomicIAdd: + atomic_op = "InterlockedAdd"; + break; + + case OpAtomicExchange: + atomic_op = "InterlockedExchange"; + break; + + case OpAtomicCompareExchange: + if (length < 8) + SPIRV_CROSS_THROW("Not enough data for opcode."); + atomic_op = "InterlockedCompareExchange"; + value_expr = join(to_expression(ops[7]), ", ", value_expr); + break; + + default: + SPIRV_CROSS_THROW("Unknown atomic opcode."); + } + + if (length < 6) + SPIRV_CROSS_THROW("Not enough data for opcode."); + + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + forced_temporaries.insert(ops[1]); + + auto &type = get(result_type); + statement(variable_decl(type, to_name(id)), ";"); + + auto &data_type = expression_type(ops[2]); + auto *chain = maybe_get(ops[2]); + SPIRType::BaseType expr_type; + if (data_type.storage == StorageClassImage || !chain) + { + statement(atomic_op, "(", to_expression(ops[2]), ", ", value_expr, ", ", to_name(id), ");"); + expr_type = data_type.basetype; + } + else + { + // RWByteAddress buffer is always uint in its underlying type. + expr_type = SPIRType::UInt; + statement(chain->base, ".", atomic_op, "(", chain->dynamic_index, chain->static_index, ", ", value_expr, ", ", + to_name(id), ");"); + } + + auto expr = bitcast_expression(type, expr_type, to_name(id)); + set(id, expr, result_type, true); + flush_all_atomic_capable_variables(); + register_read(ops[1], ops[2], should_forward(ops[2])); +} + +void CompilerHLSL::emit_instruction(const Instruction &instruction) +{ + auto ops = stream(instruction); + auto opcode = static_cast(instruction.op); + +#define BOP(op) emit_binary_op(ops[0], ops[1], ops[2], ops[3], #op) +#define BOP_CAST(op, type) \ + emit_binary_op_cast(ops[0], ops[1], ops[2], ops[3], #op, type, opcode_is_sign_invariant(opcode)) +#define UOP(op) emit_unary_op(ops[0], ops[1], ops[2], #op) +#define QFOP(op) emit_quaternary_func_op(ops[0], ops[1], ops[2], ops[3], ops[4], ops[5], #op) +#define TFOP(op) emit_trinary_func_op(ops[0], ops[1], ops[2], ops[3], ops[4], #op) +#define BFOP(op) emit_binary_func_op(ops[0], ops[1], ops[2], ops[3], #op) +#define BFOP_CAST(op, type) \ + emit_binary_func_op_cast(ops[0], ops[1], ops[2], ops[3], #op, type, opcode_is_sign_invariant(opcode)) +#define BFOP(op) emit_binary_func_op(ops[0], ops[1], ops[2], ops[3], #op) +#define UFOP(op) emit_unary_func_op(ops[0], ops[1], ops[2], #op) + + switch (opcode) + { + case OpAccessChain: + case OpInBoundsAccessChain: + { + emit_access_chain(instruction); + break; + } + + case OpStore: + { + emit_store(instruction); + break; + } + + case OpLoad: + { + emit_load(instruction); + break; + } + + case OpMatrixTimesVector: + { + emit_binary_func_op(ops[0], ops[1], ops[3], ops[2], "mul"); + break; + } + + case OpVectorTimesMatrix: + { + emit_binary_func_op(ops[0], ops[1], ops[3], ops[2], "mul"); + break; + } + + case OpMatrixTimesMatrix: + { + emit_binary_func_op(ops[0], ops[1], ops[3], ops[2], "mul"); + break; + } + + case OpFMod: + { + if (!requires_op_fmod) + { + requires_op_fmod = true; + force_recompile = true; + } + CompilerGLSL::emit_instruction(instruction); + break; + } + + case OpImage: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + auto *combined = maybe_get(ops[2]); + if (combined) + emit_op(result_type, id, to_expression(combined->image), true, true); + else + emit_op(result_type, id, to_expression(ops[2]), true, true); + break; + } + + case OpDPdx: + UFOP(ddx); + break; + + case OpDPdy: + UFOP(ddy); + break; + + case OpDPdxFine: + UFOP(ddx_fine); + break; + + case OpDPdyFine: + UFOP(ddy_fine); + break; + + case OpDPdxCoarse: + UFOP(ddx_coarse); + break; + + case OpDPdyCoarse: + UFOP(ddy_coarse); + break; + + case OpLogicalNot: + { + auto result_type = ops[0]; + auto id = ops[1]; + auto &type = get(result_type); + + if (type.vecsize > 1) + emit_unrolled_unary_op(result_type, id, ops[2], "!"); + else + UOP(!); + break; + } + + case OpIEqual: + { + auto result_type = ops[0]; + auto id = ops[1]; + + if (expression_type(ops[2]).vecsize > 1) + emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "=="); + else + BOP_CAST(==, SPIRType::Int); + break; + } + + case OpLogicalEqual: + case OpFOrdEqual: + { + auto result_type = ops[0]; + auto id = ops[1]; + + if (expression_type(ops[2]).vecsize > 1) + emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "=="); + else + BOP(==); + break; + } + + case OpINotEqual: + { + auto result_type = ops[0]; + auto id = ops[1]; + + if (expression_type(ops[2]).vecsize > 1) + emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "!="); + else + BOP_CAST(!=, SPIRType::Int); + break; + } + + case OpLogicalNotEqual: + case OpFOrdNotEqual: + { + auto result_type = ops[0]; + auto id = ops[1]; + + if (expression_type(ops[2]).vecsize > 1) + emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "!="); + else + BOP(!=); + break; + } + + case OpUGreaterThan: + case OpSGreaterThan: + { + auto result_type = ops[0]; + auto id = ops[1]; + auto type = opcode == OpUGreaterThan ? SPIRType::UInt : SPIRType::Int; + + if (expression_type(ops[2]).vecsize > 1) + emit_unrolled_binary_op(result_type, id, ops[2], ops[3], ">"); + else + BOP_CAST(>, type); + break; + } + + case OpFOrdGreaterThan: + { + auto result_type = ops[0]; + auto id = ops[1]; + + if (expression_type(ops[2]).vecsize > 1) + emit_unrolled_binary_op(result_type, id, ops[2], ops[3], ">"); + else + BOP(>); + break; + } + + case OpUGreaterThanEqual: + case OpSGreaterThanEqual: + { + auto result_type = ops[0]; + auto id = ops[1]; + + auto type = opcode == OpUGreaterThanEqual ? SPIRType::UInt : SPIRType::Int; + if (expression_type(ops[2]).vecsize > 1) + emit_unrolled_binary_op(result_type, id, ops[2], ops[3], ">="); + else + BOP_CAST(>=, type); + break; + } + + case OpFOrdGreaterThanEqual: + { + auto result_type = ops[0]; + auto id = ops[1]; + + if (expression_type(ops[2]).vecsize > 1) + emit_unrolled_binary_op(result_type, id, ops[2], ops[3], ">="); + else + BOP(>=); + break; + } + + case OpULessThan: + case OpSLessThan: + { + auto result_type = ops[0]; + auto id = ops[1]; + + auto type = opcode == OpULessThan ? SPIRType::UInt : SPIRType::Int; + if (expression_type(ops[2]).vecsize > 1) + emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "<"); + else + BOP_CAST(<, type); + break; + } + + case OpFOrdLessThan: + { + auto result_type = ops[0]; + auto id = ops[1]; + + if (expression_type(ops[2]).vecsize > 1) + emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "<"); + else + BOP(<); + break; + } + + case OpULessThanEqual: + case OpSLessThanEqual: + { + auto result_type = ops[0]; + auto id = ops[1]; + + auto type = opcode == OpULessThanEqual ? SPIRType::UInt : SPIRType::Int; + if (expression_type(ops[2]).vecsize > 1) + emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "<="); + else + BOP_CAST(<=, type); + break; + } + + case OpFOrdLessThanEqual: + { + auto result_type = ops[0]; + auto id = ops[1]; + + if (expression_type(ops[2]).vecsize > 1) + emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "<="); + else + BOP(<=); + break; + } + + case OpImageQueryLod: + emit_texture_op(instruction); + break; + + case OpImageQuerySizeLod: + { + auto result_type = ops[0]; + auto id = ops[1]; + + require_texture_query_variant(expression_type(ops[2])); + + auto dummy_samples_levels = join(get_fallback_name(id), "_dummy_parameter"); + statement("uint ", dummy_samples_levels, ";"); + + auto expr = join("SPIRV_Cross_textureSize(", to_expression(ops[2]), ", ", + bitcast_expression(SPIRType::UInt, ops[3]), ", ", dummy_samples_levels, ")"); + + auto &restype = get(ops[0]); + expr = bitcast_expression(restype, SPIRType::UInt, expr); + emit_op(result_type, id, expr, true); + break; + } + + case OpImageQuerySize: + { + auto result_type = ops[0]; + auto id = ops[1]; + + require_texture_query_variant(expression_type(ops[2])); + + auto dummy_samples_levels = join(get_fallback_name(id), "_dummy_parameter"); + statement("uint ", dummy_samples_levels, ";"); + + auto expr = join("SPIRV_Cross_textureSize(", to_expression(ops[2]), ", 0u, ", dummy_samples_levels, ")"); + auto &restype = get(ops[0]); + expr = bitcast_expression(restype, SPIRType::UInt, expr); + emit_op(result_type, id, expr, true); + break; + } + + case OpImageQuerySamples: + case OpImageQueryLevels: + { + auto result_type = ops[0]; + auto id = ops[1]; + + require_texture_query_variant(expression_type(ops[2])); + + // Keep it simple and do not emit special variants to make this look nicer ... + // This stuff is barely, if ever, used. + forced_temporaries.insert(id); + auto &type = get(result_type); + statement(variable_decl(type, to_name(id)), ";"); + statement("SPIRV_Cross_textureSize(", to_expression(ops[2]), ", 0u, ", to_name(id), ");"); + + auto &restype = get(ops[0]); + auto expr = bitcast_expression(restype, SPIRType::UInt, to_name(id)); + set(id, expr, result_type, true); + break; + } + + case OpImageRead: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + auto *var = maybe_get_backing_variable(ops[2]); + auto imgexpr = join(to_expression(ops[2]), "[", to_expression(ops[3]), "]"); + + // The underlying image type in HLSL depends on the image format, unlike GLSL, where all images are "vec4", + // except that the underlying type changes how the data is interpreted. + if (var) + imgexpr = remap_swizzle(get(result_type), + image_format_to_components(get(var->basetype).image.format), imgexpr); + + if (var && var->forwardable) + { + bool forward = forced_temporaries.find(id) == end(forced_temporaries); + auto &e = emit_op(result_type, id, imgexpr, forward); + e.loaded_from = var->self; + if (forward) + var->dependees.push_back(id); + } + else + emit_op(result_type, id, imgexpr, false); + break; + } + + case OpImageWrite: + { + auto *var = maybe_get_backing_variable(ops[0]); + + // The underlying image type in HLSL depends on the image format, unlike GLSL, where all images are "vec4", + // except that the underlying type changes how the data is interpreted. + auto value_expr = to_expression(ops[2]); + if (var) + { + auto &type = get(var->basetype); + auto narrowed_type = get(type.image.type); + narrowed_type.vecsize = image_format_to_components(type.image.format); + value_expr = remap_swizzle(narrowed_type, expression_type(ops[2]).vecsize, value_expr); + } + + statement(to_expression(ops[0]), "[", to_expression(ops[1]), "] = ", value_expr, ";"); + if (var && variable_storage_is_aliased(*var)) + flush_all_aliased_variables(); + break; + } + + case OpImageTexelPointer: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + auto &e = + set(id, join(to_expression(ops[2]), "[", to_expression(ops[3]), "]"), result_type, true); + + // When using the pointer, we need to know which variable it is actually loaded from. + auto *var = maybe_get_backing_variable(ops[2]); + e.loaded_from = var ? var->self : 0; + break; + } + + case OpAtomicCompareExchange: + case OpAtomicExchange: + case OpAtomicISub: + case OpAtomicSMin: + case OpAtomicUMin: + case OpAtomicSMax: + case OpAtomicUMax: + case OpAtomicAnd: + case OpAtomicOr: + case OpAtomicXor: + case OpAtomicIAdd: + { + emit_atomic(ops, instruction.length, opcode); + break; + } + + case OpControlBarrier: + case OpMemoryBarrier: + { + uint32_t memory; + uint32_t semantics; + + if (opcode == OpMemoryBarrier) + { + memory = get(ops[0]).scalar(); + semantics = get(ops[1]).scalar(); + } + else + { + memory = get(ops[1]).scalar(); + semantics = get(ops[2]).scalar(); + } + + // We only care about these flags, acquire/release and friends are not relevant to GLSL. + semantics = mask_relevant_memory_semantics(semantics); + + if (opcode == OpMemoryBarrier) + { + // If we are a memory barrier, and the next instruction is a control barrier, check if that memory barrier + // does what we need, so we avoid redundant barriers. + const Instruction *next = get_next_instruction_in_block(instruction); + if (next && next->op == OpControlBarrier) + { + auto *next_ops = stream(*next); + uint32_t next_memory = get(next_ops[1]).scalar(); + uint32_t next_semantics = get(next_ops[2]).scalar(); + next_semantics = mask_relevant_memory_semantics(next_semantics); + + // There is no "just execution barrier" in HLSL. + // If there are no memory semantics for next instruction, we will imply group shared memory is synced. + if (next_semantics == 0) + next_semantics = MemorySemanticsWorkgroupMemoryMask; + + bool memory_scope_covered = false; + if (next_memory == memory) + memory_scope_covered = true; + else if (next_semantics == MemorySemanticsWorkgroupMemoryMask) + { + // If we only care about workgroup memory, either Device or Workgroup scope is fine, + // scope does not have to match. + if ((next_memory == ScopeDevice || next_memory == ScopeWorkgroup) && + (memory == ScopeDevice || memory == ScopeWorkgroup)) + { + memory_scope_covered = true; + } + } + else if (memory == ScopeWorkgroup && next_memory == ScopeDevice) + { + // The control barrier has device scope, but the memory barrier just has workgroup scope. + memory_scope_covered = true; + } + + // If we have the same memory scope, and all memory types are covered, we're good. + if (memory_scope_covered && (semantics & next_semantics) == semantics) + break; + } + } + + // We are synchronizing some memory or syncing execution, + // so we cannot forward any loads beyond the memory barrier. + if (semantics || opcode == OpControlBarrier) + flush_all_active_variables(); + + if (opcode == OpControlBarrier) + { + // We cannot emit just execution barrier, for no memory semantics pick the cheapest option. + if (semantics == MemorySemanticsWorkgroupMemoryMask || semantics == 0) + statement("GroupMemoryBarrierWithGroupSync();"); + else if (semantics != 0 && (semantics & MemorySemanticsWorkgroupMemoryMask) == 0) + statement("DeviceMemoryBarrierWithGroupSync();"); + else + statement("AllMemoryBarrierWithGroupSync();"); + } + else + { + if (semantics == MemorySemanticsWorkgroupMemoryMask) + statement("GroupMemoryBarrier();"); + else if (semantics != 0 && (semantics & MemorySemanticsWorkgroupMemoryMask) == 0) + statement("DeviceMemoryBarrier();"); + else + statement("AllMemoryBarrier();"); + } + break; + } + + case OpBitFieldInsert: + { + if (!requires_bitfield_insert) + { + requires_bitfield_insert = true; + force_recompile = true; + } + + auto expr = join("SPIRV_Cross_bitfieldInsert(", to_expression(ops[2]), ", ", to_expression(ops[3]), ", ", + to_expression(ops[4]), ", ", to_expression(ops[5]), ")"); + + bool forward = + should_forward(ops[2]) && should_forward(ops[3]) && should_forward(ops[4]) && should_forward(ops[5]); + + auto &restype = get(ops[0]); + expr = bitcast_expression(restype, SPIRType::UInt, expr); + emit_op(ops[0], ops[1], expr, forward); + break; + } + + case OpBitFieldSExtract: + case OpBitFieldUExtract: + { + if (!requires_bitfield_extract) + { + requires_bitfield_extract = true; + force_recompile = true; + } + + if (opcode == OpBitFieldSExtract) + TFOP(SPIRV_Cross_bitfieldSExtract); + else + TFOP(SPIRV_Cross_bitfieldUExtract); + break; + } + + case OpBitCount: + UFOP(countbits); + break; + + case OpBitReverse: + UFOP(reversebits); + break; + + default: + CompilerGLSL::emit_instruction(instruction); + break; + } +} + +void CompilerHLSL::require_texture_query_variant(const SPIRType &type) +{ + uint32_t bit = 0; + switch (type.image.dim) + { + case Dim1D: + bit = type.image.arrayed ? Query1DArray : Query1D; + break; + + case Dim2D: + if (type.image.ms) + bit = type.image.arrayed ? Query2DMSArray : Query2DMS; + else + bit = type.image.arrayed ? Query2DArray : Query2D; + break; + + case Dim3D: + bit = Query3D; + break; + + case DimCube: + bit = type.image.arrayed ? QueryCubeArray : QueryCube; + break; + + case DimBuffer: + bit = QueryBuffer; + break; + + default: + SPIRV_CROSS_THROW("Unsupported query type."); + } + + switch (get(type.image.type).basetype) + { + case SPIRType::Float: + bit += QueryTypeFloat; + break; + + case SPIRType::Int: + bit += QueryTypeInt; + break; + + case SPIRType::UInt: + bit += QueryTypeUInt; + break; + + default: + SPIRV_CROSS_THROW("Unsupported query type."); + } + + uint64_t mask = 1ull << bit; + if ((required_textureSizeVariants & mask) == 0) + { + force_recompile = true; + required_textureSizeVariants |= mask; + } +} + +string CompilerHLSL::compile(std::vector vertex_attributes) +{ + remap_vertex_attributes = move(vertex_attributes); + return compile(); +} + +string CompilerHLSL::compile() +{ + // Do not deal with ES-isms like precision, older extensions and such. + CompilerGLSL::options.es = false; + CompilerGLSL::options.version = 450; + CompilerGLSL::options.vulkan_semantics = true; + backend.float_literal_suffix = true; + backend.double_literal_suffix = false; + backend.long_long_literal_suffix = true; + backend.uint32_t_literal_suffix = true; + backend.basic_int_type = "int"; + backend.basic_uint_type = "uint"; + backend.swizzle_is_function = false; + backend.shared_is_implied = true; + backend.flexible_member_array_supported = false; + backend.explicit_struct_type = false; + backend.use_initializer_list = true; + backend.use_constructor_splatting = false; + backend.boolean_mix_support = false; + backend.can_swizzle_scalar = true; + backend.can_declare_struct_inline = false; + backend.can_declare_arrays_inline = false; + + update_active_builtins(); + analyze_sampler_comparison_states(); + + uint32_t pass_count = 0; + do + { + if (pass_count >= 3) + SPIRV_CROSS_THROW("Over 3 compilation loops detected. Must be a bug!"); + + reset(); + + // Move constructor for this type is broken on GCC 4.9 ... + buffer = unique_ptr(new ostringstream()); + + emit_header(); + emit_resources(); + + emit_function(get(entry_point), 0); + emit_hlsl_entry_point(); + + pass_count++; + } while (force_recompile); + + // Entry point in HLSL is always main() for the time being. + get_entry_point().name = "main"; + + return buffer->str(); +} diff --git a/spirv_hlsl.hpp b/spirv_hlsl.hpp new file mode 100644 index 0000000000..9b3261737c --- /dev/null +++ b/spirv_hlsl.hpp @@ -0,0 +1,165 @@ +/* + * Copyright 2016-2018 Robert Konrad + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SPIRV_HLSL_HPP +#define SPIRV_HLSL_HPP + +#include "spirv_glsl.hpp" +#include +#include + +namespace spirv_cross +{ +// Interface which remaps vertex inputs to a fixed semantic name to make linking easier. +struct HLSLVertexAttributeRemap +{ + uint32_t location; + std::string semantic; +}; + +class CompilerHLSL : public CompilerGLSL +{ +public: + struct Options + { + uint32_t shader_model = 30; // TODO: map ps_4_0_level_9_0,... somehow + + // Allows the PointSize builtin, and ignores it, as PointSize is not supported in HLSL. + bool point_size_compat = false; + }; + + CompilerHLSL(std::vector spirv_) + : CompilerGLSL(move(spirv_)) + { + } + + CompilerHLSL(const uint32_t *ir, size_t size) + : CompilerGLSL(ir, size) + { + } + + const Options &get_options() const + { + return options; + } + + void set_options(Options &opts) + { + options = opts; + } + + // Compiles and remaps vertex attributes at specific locations to a fixed semantic. + // The default is TEXCOORD# where # denotes location. + // Matrices are unrolled to vectors with notation ${SEMANTIC}_#, where # denotes row. + // $SEMANTIC is either TEXCOORD# or a semantic name specified here. + std::string compile(std::vector vertex_attributes); + std::string compile() override; + +private: + std::string type_to_glsl(const SPIRType &type, uint32_t id = 0) override; + std::string image_type_hlsl(const SPIRType &type); + std::string image_type_hlsl_modern(const SPIRType &type); + std::string image_type_hlsl_legacy(const SPIRType &type); + void emit_function_prototype(SPIRFunction &func, uint64_t return_flags) override; + void emit_hlsl_entry_point(); + void emit_header() override; + void emit_resources(); + void emit_interface_block_globally(const SPIRVariable &type); + void emit_interface_block_in_struct(const SPIRVariable &type, std::unordered_set &active_locations); + void emit_builtin_inputs_in_struct(); + void emit_builtin_outputs_in_struct(); + void emit_texture_op(const Instruction &i) override; + void emit_instruction(const Instruction &instruction) override; + void emit_glsl_op(uint32_t result_type, uint32_t result_id, uint32_t op, const uint32_t *args, + uint32_t count) override; + void emit_buffer_block(const SPIRVariable &type) override; + void emit_push_constant_block(const SPIRVariable &var) override; + void emit_uniform(const SPIRVariable &var) override; + void emit_modern_uniform(const SPIRVariable &var); + void emit_legacy_uniform(const SPIRVariable &var); + void emit_specialization_constants(); + void emit_composite_constants(); + void emit_fixup() override; + std::string builtin_to_glsl(spv::BuiltIn builtin, spv::StorageClass storage) override; + std::string layout_for_member(const SPIRType &type, uint32_t index) override; + std::string to_interpolation_qualifiers(uint64_t flags) override; + std::string bitcast_glsl_op(const SPIRType &result_type, const SPIRType &argument_type) override; + std::string to_func_call_arg(uint32_t id) override; + std::string to_sampler_expression(uint32_t id); + std::string to_resource_binding(const SPIRVariable &var); + std::string to_resource_binding_sampler(const SPIRVariable &var); + void emit_sampled_image_op(uint32_t result_type, uint32_t result_id, uint32_t image_id, uint32_t samp_id) override; + void emit_access_chain(const Instruction &instruction); + void emit_load(const Instruction &instruction); + std::string read_access_chain(const SPIRAccessChain &chain); + void write_access_chain(const SPIRAccessChain &chain, uint32_t value); + void emit_store(const Instruction &instruction); + void emit_atomic(const uint32_t *ops, uint32_t length, spv::Op op); + + void emit_struct_member(const SPIRType &type, uint32_t member_type_id, uint32_t index, + const std::string &qualifier) override; + + const char *to_storage_qualifiers_glsl(const SPIRVariable &var) override; + + Options options; + bool requires_op_fmod = false; + bool requires_textureProj = false; + bool requires_fp16_packing = false; + bool requires_unorm8_packing = false; + bool requires_snorm8_packing = false; + bool requires_unorm16_packing = false; + bool requires_snorm16_packing = false; + bool requires_bitfield_insert = false; + bool requires_bitfield_extract = false; + uint64_t required_textureSizeVariants = 0; + void require_texture_query_variant(const SPIRType &type); + + enum TextureQueryVariantDim + { + Query1D = 0, + Query1DArray, + Query2D, + Query2DArray, + Query3D, + QueryBuffer, + QueryCube, + QueryCubeArray, + Query2DMS, + Query2DMSArray, + QueryDimCount + }; + + enum TextureQueryVariantType + { + QueryTypeFloat = 0, + QueryTypeInt = 16, + QueryTypeUInt = 32, + QueryTypeCount = 3 + }; + + void emit_builtin_variables(); + bool require_output = false; + bool require_input = false; + std::vector remap_vertex_attributes; + + uint32_t type_to_consumed_locations(const SPIRType &type) const; + + void emit_io_block(const SPIRVariable &var); + std::string to_semantic(uint32_t vertex_location); +}; +} + +#endif diff --git a/spirv_msl.cpp b/spirv_msl.cpp new file mode 100644 index 0000000000..a85b38c2eb --- /dev/null +++ b/spirv_msl.cpp @@ -0,0 +1,3641 @@ +/* + * Copyright 2016-2018 The Brenwill Workshop Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "spirv_msl.hpp" +#include "GLSL.std.450.h" + +#include +#include + +using namespace spv; +using namespace spirv_cross; +using namespace std; + +static const uint32_t k_unknown_location = ~0; + +CompilerMSL::CompilerMSL(vector spirv_, vector *p_vtx_attrs, + vector *p_res_bindings) + : CompilerGLSL(move(spirv_)) +{ + if (p_vtx_attrs) + for (auto &va : *p_vtx_attrs) + vtx_attrs_by_location[va.location] = &va; + + if (p_res_bindings) + for (auto &rb : *p_res_bindings) + resource_bindings.push_back(&rb); +} + +CompilerMSL::CompilerMSL(const uint32_t *ir, size_t word_count, MSLVertexAttr *p_vtx_attrs, size_t vtx_attrs_count, + MSLResourceBinding *p_res_bindings, size_t res_bindings_count) + : CompilerGLSL(ir, word_count) +{ + if (p_vtx_attrs) + for (size_t i = 0; i < vtx_attrs_count; i++) + vtx_attrs_by_location[p_vtx_attrs[i].location] = &p_vtx_attrs[i]; + + if (p_res_bindings) + for (size_t i = 0; i < res_bindings_count; i++) + resource_bindings.push_back(&p_res_bindings[i]); +} + +string CompilerMSL::compile() +{ + // Force a classic "C" locale, reverts when function returns + ClassicLocale classic_locale; + + // Do not deal with GLES-isms like precision, older extensions and such. + CompilerGLSL::options.vulkan_semantics = true; + CompilerGLSL::options.es = false; + CompilerGLSL::options.version = 120; + backend.float_literal_suffix = false; + backend.uint32_t_literal_suffix = true; + backend.basic_int_type = "int"; + backend.basic_uint_type = "uint"; + backend.discard_literal = "discard_fragment()"; + backend.swizzle_is_function = false; + backend.shared_is_implied = false; + backend.use_initializer_list = true; + backend.use_typed_initializer_list = true; + backend.native_row_major_matrix = false; + backend.flexible_member_array_supported = false; + + replace_illegal_names(); + + non_stage_in_input_var_ids.clear(); + struct_member_padding.clear(); + + update_active_builtins(); + fixup_image_load_store_access(); + + set_enabled_interface_variables(get_active_interface_variables()); + + // Preprocess OpCodes to extract the need to output additional header content + preprocess_op_codes(); + + // Create structs to hold input, output and uniform variables + qual_pos_var_name = ""; + stage_in_var_id = add_interface_block(StorageClassInput); + stage_out_var_id = add_interface_block(StorageClassOutput); + stage_uniforms_var_id = add_interface_block(StorageClassUniformConstant); + + // Convert the use of global variables to recursively-passed function parameters + localize_global_variables(); + extract_global_variables_from_functions(); + + // Mark any non-stage-in structs to be tightly packed. + mark_packable_structs(); + + // Metal does not allow dynamic array lengths. + // Resolve any specialization constants that are used for array lengths. + if (options.resolve_specialized_array_lengths) + resolve_specialized_array_lengths(); + + uint32_t pass_count = 0; + do + { + if (pass_count >= 3) + SPIRV_CROSS_THROW("Over 3 compilation loops detected. Must be a bug!"); + + reset(); + + next_metal_resource_index = MSLResourceBinding(); // Start bindings at zero + + // Move constructor for this type is broken on GCC 4.9 ... + buffer = unique_ptr(new ostringstream()); + + emit_header(); + emit_specialization_constants(); + emit_resources(); + emit_custom_functions(); + emit_function(get(entry_point), 0); + + pass_count++; + } while (force_recompile); + + return buffer->str(); +} + +string CompilerMSL::compile(vector *p_vtx_attrs, vector *p_res_bindings) +{ + if (p_vtx_attrs) + { + vtx_attrs_by_location.clear(); + for (auto &va : *p_vtx_attrs) + vtx_attrs_by_location[va.location] = &va; + } + + if (p_res_bindings) + { + resource_bindings.clear(); + for (auto &rb : *p_res_bindings) + resource_bindings.push_back(&rb); + } + + return compile(); +} + +string CompilerMSL::compile(MSLConfiguration &msl_cfg, vector *p_vtx_attrs, + vector *p_res_bindings) +{ + options = msl_cfg; + return compile(p_vtx_attrs, p_res_bindings); +} + +// Register the need to output any custom functions. +void CompilerMSL::preprocess_op_codes() +{ + spv_function_implementations.clear(); + + OpCodePreprocessor preproc(*this); + traverse_all_reachable_opcodes(get(entry_point), preproc); + + if (preproc.suppress_missing_prototypes) + add_pragma_line("#pragma clang diagnostic ignored \"-Wmissing-prototypes\""); + + if (preproc.uses_atomics) + { + add_header_line("#include "); + add_pragma_line("#pragma clang diagnostic ignored \"-Wunused-variable\""); + } +} + +// Move the Private and Workgroup global variables to the entry function. +// Non-constant variables cannot have global scope in Metal. +void CompilerMSL::localize_global_variables() +{ + auto &entry_func = get(entry_point); + auto iter = global_variables.begin(); + while (iter != global_variables.end()) + { + uint32_t v_id = *iter; + auto &var = get(v_id); + if (var.storage == StorageClassPrivate || var.storage == StorageClassWorkgroup) + { + var.storage = StorageClassFunction; + entry_func.add_local_variable(v_id); + iter = global_variables.erase(iter); + } + else + iter++; + } +} + +// Metal does not allow dynamic array lengths. +// Turn off specialization of any constants that are used for array lengths. +void CompilerMSL::resolve_specialized_array_lengths() +{ + for (auto &id : ids) + { + if (id.get_type() == TypeConstant) + { + auto &c = id.get(); + if (c.is_used_as_array_length) + c.specialization = false; + } + } +} + +// For any global variable accessed directly by a function, +// extract that variable and add it as an argument to that function. +void CompilerMSL::extract_global_variables_from_functions() +{ + + // Uniforms + unordered_set global_var_ids; + for (auto &id : ids) + { + if (id.get_type() == TypeVariable) + { + auto &var = id.get(); + if (var.storage == StorageClassInput || var.storage == StorageClassUniform || + var.storage == StorageClassUniformConstant || var.storage == StorageClassPushConstant || + var.storage == StorageClassStorageBuffer) + { + global_var_ids.insert(var.self); + } + } + } + + // Local vars that are declared in the main function and accessed directy by a function + auto &entry_func = get(entry_point); + for (auto &var : entry_func.local_variables) + global_var_ids.insert(var); + + std::set added_arg_ids; + unordered_set processed_func_ids; + extract_global_variables_from_function(entry_point, added_arg_ids, global_var_ids, processed_func_ids); +} + +// MSL does not support the use of global variables for shader input content. +// For any global variable accessed directly by the specified function, extract that variable, +// add it as an argument to that function, and the arg to the added_arg_ids collection. +void CompilerMSL::extract_global_variables_from_function(uint32_t func_id, std::set &added_arg_ids, + unordered_set &global_var_ids, + unordered_set &processed_func_ids) +{ + // Avoid processing a function more than once + if (processed_func_ids.find(func_id) != processed_func_ids.end()) + { + // Return function global variables + added_arg_ids = function_global_vars[func_id]; + return; + } + + processed_func_ids.insert(func_id); + + auto &func = get(func_id); + + // Recursively establish global args added to functions on which we depend. + for (auto block : func.blocks) + { + auto &b = get(block); + for (auto &i : b.ops) + { + auto ops = stream(i); + auto op = static_cast(i.op); + + switch (op) + { + case OpLoad: + case OpAccessChain: + { + uint32_t base_id = ops[2]; + if (global_var_ids.find(base_id) != global_var_ids.end()) + added_arg_ids.insert(base_id); + + break; + } + case OpFunctionCall: + { + // First see if any of the function call args are globals + for (uint32_t arg_idx = 3; arg_idx < i.length; arg_idx++) + { + uint32_t arg_id = ops[arg_idx]; + if (global_var_ids.find(arg_id) != global_var_ids.end()) + added_arg_ids.insert(arg_id); + } + + // Then recurse into the function itself to extract globals used internally in the function + uint32_t inner_func_id = ops[2]; + std::set inner_func_args; + extract_global_variables_from_function(inner_func_id, inner_func_args, global_var_ids, + processed_func_ids); + added_arg_ids.insert(inner_func_args.begin(), inner_func_args.end()); + break; + } + + default: + break; + } + } + } + + function_global_vars[func_id] = added_arg_ids; + + // Add the global variables as arguments to the function + if (func_id != entry_point) + { + uint32_t next_id = increase_bound_by(uint32_t(added_arg_ids.size())); + for (uint32_t arg_id : added_arg_ids) + { + auto var = get(arg_id); + uint32_t type_id = var.basetype; + func.add_parameter(type_id, next_id, true); + set(next_id, type_id, StorageClassFunction, 0, arg_id); + + // Ensure the existing variable has a valid name and the new variable has all the same meta info + set_name(arg_id, ensure_valid_name(to_name(arg_id), "v")); + meta[next_id] = meta[arg_id]; + + next_id++; + } + } +} + +// For all variables that are some form of non-input-output interface block, mark that all the structs +// that are recursively contained within the type referenced by that variable should be packed tightly. +void CompilerMSL::mark_packable_structs() +{ + for (auto &id : ids) + { + if (id.get_type() == TypeVariable) + { + auto &var = id.get(); + if (var.storage != StorageClassFunction && !is_hidden_variable(var)) + { + auto &type = get(var.basetype); + if (type.pointer && + (type.storage == StorageClassUniform || type.storage == StorageClassUniformConstant || + type.storage == StorageClassPushConstant || type.storage == StorageClassStorageBuffer) && + (has_decoration(type.self, DecorationBlock) || has_decoration(type.self, DecorationBufferBlock))) + mark_as_packable(type); + } + } + } +} + +// If the specified type is a struct, it and any nested structs +// are marked as packable with the DecorationCPacked decoration, +void CompilerMSL::mark_as_packable(SPIRType &type) +{ + // If this is not the base type (eg. it's a pointer or array), tunnel down + if (type.parent_type) + { + mark_as_packable(get(type.parent_type)); + return; + } + + if (type.basetype == SPIRType::Struct) + { + set_decoration(type.self, DecorationCPacked); + + // Recurse + size_t mbr_cnt = type.member_types.size(); + for (uint32_t mbr_idx = 0; mbr_idx < mbr_cnt; mbr_idx++) + { + uint32_t mbr_type_id = type.member_types[mbr_idx]; + auto &mbr_type = get(mbr_type_id); + mark_as_packable(mbr_type); + if (mbr_type.type_alias) + { + auto &mbr_type_alias = get(mbr_type.type_alias); + mark_as_packable(mbr_type_alias); + } + } + } +} + +// If a vertex attribute exists at the location, it is marked as being used by this shader +void CompilerMSL::mark_location_as_used_by_shader(uint32_t location, StorageClass storage) +{ + MSLVertexAttr *p_va; + auto &execution = get_entry_point(); + if ((execution.model == ExecutionModelVertex) && (storage == StorageClassInput) && + (p_va = vtx_attrs_by_location[location])) + p_va->used_by_shader = true; +} + +// Add an interface structure for the type of storage, which is either StorageClassInput or StorageClassOutput. +// Returns the ID of the newly added variable, or zero if no variable was added. +uint32_t CompilerMSL::add_interface_block(StorageClass storage) +{ + // Accumulate the variables that should appear in the interface struct + vector vars; + bool incl_builtins = (storage == StorageClassOutput); + for (auto &id : ids) + { + if (id.get_type() == TypeVariable) + { + auto &var = id.get(); + auto &type = get(var.basetype); + if (var.storage == storage && interface_variable_exists_in_entry_point(var.self) && + !is_hidden_variable(var, incl_builtins) && type.pointer) + { + vars.push_back(&var); + } + } + } + + // If no variables qualify, leave + if (vars.empty()) + return 0; + + // Add a new typed variable for this interface structure. + // The initializer expression is allocated here, but populated when the function + // declaraion is emitted, because it is cleared after each compilation pass. + uint32_t next_id = increase_bound_by(3); + uint32_t ib_type_id = next_id++; + auto &ib_type = set(ib_type_id); + ib_type.basetype = SPIRType::Struct; + ib_type.storage = storage; + set_decoration(ib_type_id, DecorationBlock); + + uint32_t ib_var_id = next_id++; + auto &var = set(ib_var_id, ib_type_id, storage, 0); + var.initializer = next_id++; + + string ib_var_ref; + switch (storage) + { + case StorageClassInput: + ib_var_ref = stage_in_var_name; + break; + + case StorageClassOutput: + { + ib_var_ref = stage_out_var_name; + + // Add the output interface struct as a local variable to the entry function, + // and force the entry function to return the output interface struct from + // any blocks that perform a function return. + auto &entry_func = get(entry_point); + entry_func.add_local_variable(ib_var_id); + for (auto &blk_id : entry_func.blocks) + { + auto &blk = get(blk_id); + if (blk.terminator == SPIRBlock::Return) + blk.return_value = ib_var_id; + } + break; + } + + case StorageClassUniformConstant: + { + ib_var_ref = stage_uniform_var_name; + active_interface_variables.insert(ib_var_id); // Ensure will be emitted + break; + } + + default: + break; + } + + set_name(ib_type_id, get_entry_point_name() + "_" + ib_var_ref); + set_name(ib_var_id, ib_var_ref); + + for (auto p_var : vars) + { + uint32_t type_id = p_var->basetype; + auto &type = get(type_id); + if (type.basetype == SPIRType::Struct) + { + // Flatten the struct members into the interface struct + uint32_t mbr_idx = 0; + for (auto &mbr_type_id : type.member_types) + { + BuiltIn builtin; + bool is_builtin = is_member_builtin(type, mbr_idx, &builtin); + + auto &mbr_type = get(mbr_type_id); + if (should_move_to_input_buffer(mbr_type, is_builtin, storage)) + move_member_to_input_buffer(type, mbr_idx); + + else if (!is_builtin || has_active_builtin(builtin, storage)) + { + // Add a reference to the member to the interface struct. + uint32_t ib_mbr_idx = uint32_t(ib_type.member_types.size()); + ib_type.member_types.push_back(mbr_type_id); // membertype.self is different for array types + + // Give the member a name + string mbr_name = ensure_valid_name(to_qualified_member_name(type, mbr_idx), "m"); + set_member_name(ib_type_id, ib_mbr_idx, mbr_name); + + // Update the original variable reference to include the structure reference + string qual_var_name = ib_var_ref + "." + mbr_name; + set_member_qualified_name(type_id, mbr_idx, qual_var_name); + + // Copy the variable location from the original variable to the member + if (has_member_decoration(type_id, mbr_idx, DecorationLocation)) + { + uint32_t locn = get_member_decoration(type_id, mbr_idx, DecorationLocation); + set_member_decoration(ib_type_id, ib_mbr_idx, DecorationLocation, locn); + mark_location_as_used_by_shader(locn, storage); + } + else if (has_decoration(p_var->self, DecorationLocation)) + { + // The block itself might have a location and in this case, all members of the block + // receive incrementing locations. + uint32_t locn = get_decoration(p_var->self, DecorationLocation) + mbr_idx; + set_member_decoration(ib_type_id, ib_mbr_idx, DecorationLocation, locn); + mark_location_as_used_by_shader(locn, storage); + } + + // Mark the member as builtin if needed + if (is_builtin) + { + set_member_decoration(ib_type_id, ib_mbr_idx, DecorationBuiltIn, builtin); + if (builtin == BuiltInPosition) + qual_pos_var_name = qual_var_name; + } + } + mbr_idx++; + } + } + else if (type.basetype == SPIRType::Boolean || type.basetype == SPIRType::Char || + type.basetype == SPIRType::Int || type.basetype == SPIRType::UInt || + type.basetype == SPIRType::Int64 || type.basetype == SPIRType::UInt64 || + type.basetype == SPIRType::Float || type.basetype == SPIRType::Double || + type.basetype == SPIRType::Boolean) + { + bool is_builtin = is_builtin_variable(*p_var); + BuiltIn builtin = BuiltIn(get_decoration(p_var->self, DecorationBuiltIn)); + + if (should_move_to_input_buffer(type, is_builtin, storage)) + move_to_input_buffer(*p_var); + + else if (!is_builtin || has_active_builtin(builtin, storage)) + { + // Add a reference to the variable type to the interface struct. + uint32_t ib_mbr_idx = uint32_t(ib_type.member_types.size()); + ib_type.member_types.push_back(type_id); + + // Give the member a name + string mbr_name = ensure_valid_name(to_expression(p_var->self), "m"); + set_member_name(ib_type_id, ib_mbr_idx, mbr_name); + + // Update the original variable reference to include the structure reference + string qual_var_name = ib_var_ref + "." + mbr_name; + meta[p_var->self].decoration.qualified_alias = qual_var_name; + + // Copy the variable location from the original variable to the member + if (get_decoration_mask(p_var->self) & (1ull << DecorationLocation)) + { + uint32_t locn = get_decoration(p_var->self, DecorationLocation); + set_member_decoration(ib_type_id, ib_mbr_idx, DecorationLocation, locn); + mark_location_as_used_by_shader(locn, storage); + } + + // Mark the member as builtin if needed + if (is_builtin) + { + set_member_decoration(ib_type_id, ib_mbr_idx, DecorationBuiltIn, builtin); + if (builtin == BuiltInPosition) + qual_pos_var_name = qual_var_name; + } + } + } + } + + // Sort the members of the structure by their locations. + // Oddly, Metal handles inputs better if they are sorted in reverse order. + MemberSorter::SortAspect sort_aspect = + (storage == StorageClassInput) ? MemberSorter::LocationReverse : MemberSorter::Location; + MemberSorter member_sorter(ib_type, meta[ib_type_id], sort_aspect); + member_sorter.sort(); + + return ib_var_id; +} + +// Returns whether a variable of type and storage class should be moved from an interface +// block to a secondary input buffer block. +// This is the case for matrixes and arrays that appear in the stage_in interface block +// of a vertex function, and true is returned. +// Other types do not need to move, and false is returned. +// Matrices and arrays are not permitted in the output of a vertex function or the input +// or output of a fragment function, and in those cases, an exception is thrown. +bool CompilerMSL::should_move_to_input_buffer(SPIRType &type, bool is_builtin, StorageClass storage) +{ + if ((is_matrix(type) || is_array(type)) && !is_builtin) + { + auto &execution = get_entry_point(); + + if (execution.model == ExecutionModelVertex) + { + if (storage == StorageClassInput) + return true; + + if (storage == StorageClassOutput) + SPIRV_CROSS_THROW("The vertex function output structure may not include a matrix or array."); + } + else if (execution.model == ExecutionModelFragment) + { + if (storage == StorageClassInput) + SPIRV_CROSS_THROW("The fragment function stage_in structure may not include a matrix or array."); + + if (storage == StorageClassOutput) + SPIRV_CROSS_THROW("The fragment function output structure may not include a matrix or array."); + } + } + + return false; +} + +// Excludes the specified variable from an interface block structure. +// Instead, for the variable is added to a block variable corresponding to a secondary MSL buffer. +// The use case for this is when a vertex stage_in variable contains a matrix or array. +void CompilerMSL::move_to_input_buffer(SPIRVariable &var) +{ + uint32_t var_id = var.self; + + if (!has_decoration(var_id, DecorationLocation)) + return; + + uint32_t mbr_type_id = var.basetype; + string mbr_name = ensure_valid_name(to_expression(var_id), "m"); + uint32_t mbr_locn = get_decoration(var_id, DecorationLocation); + meta[var_id].decoration.qualified_alias = add_input_buffer_block_member(mbr_type_id, mbr_name, mbr_locn); +} + +// Excludes the specified type member from the stage_in block structure. +// Instead, for the variable is added to a block variable corresponding to a secondary MSL buffer. +// The use case for this is when a vertex stage_in variable contains a matrix or array. +void CompilerMSL::move_member_to_input_buffer(const SPIRType &type, uint32_t index) +{ + uint32_t type_id = type.self; + + if (!has_member_decoration(type_id, index, DecorationLocation)) + return; + + uint32_t mbr_type_id = type.member_types[index]; + string mbr_name = ensure_valid_name(to_qualified_member_name(type, index), "m"); + uint32_t mbr_locn = get_member_decoration(type_id, index, DecorationLocation); + string qual_name = add_input_buffer_block_member(mbr_type_id, mbr_name, mbr_locn); + set_member_qualified_name(type_id, index, qual_name); +} + +// Adds a member to the input buffer block that corresponds to the MTLBuffer used by an attribute location +string CompilerMSL::add_input_buffer_block_member(uint32_t mbr_type_id, string mbr_name, uint32_t mbr_locn) +{ + mark_location_as_used_by_shader(mbr_locn, StorageClassInput); + + MSLVertexAttr *p_va = vtx_attrs_by_location[mbr_locn]; + if (!p_va) + return ""; + + if (p_va->per_instance) + needs_instance_idx_arg = true; + else + needs_vertex_idx_arg = true; + + // The variable that is the block struct. + // Record the stride of this struct in its offset decoration. + uint32_t ib_var_id = get_input_buffer_block_var_id(p_va->msl_buffer); + auto &ib_var = get(ib_var_id); + uint32_t ib_type_id = ib_var.basetype; + auto &ib_type = get(ib_type_id); + set_decoration(ib_type_id, DecorationOffset, p_va->msl_stride); + + // Add a reference to the variable type to the interface struct. + uint32_t ib_mbr_idx = uint32_t(ib_type.member_types.size()); + ib_type.member_types.push_back(mbr_type_id); + + // Give the member a name + set_member_name(ib_type_id, ib_mbr_idx, mbr_name); + + // Set MSL buffer and offset decorations, and indicate no valid attribute location + set_member_decoration(ib_type_id, ib_mbr_idx, DecorationBinding, p_va->msl_buffer); + set_member_decoration(ib_type_id, ib_mbr_idx, DecorationOffset, p_va->msl_offset); + set_member_decoration(ib_type_id, ib_mbr_idx, DecorationLocation, k_unknown_location); + + // Update the original variable reference to include the structure and index reference + string idx_var_name = + builtin_to_glsl(p_va->per_instance ? BuiltInInstanceIndex : BuiltInVertexIndex, StorageClassInput); + return get_name(ib_var_id) + "[" + idx_var_name + "]." + mbr_name; +} + +// Returns the ID of the input block that will use the specified MSL buffer index, +// lazily creating an input block variable and type if needed. +// +// The use of this block applies only to input variables that have been excluded from the stage_in +// block, which typically only occurs if an attempt to pass a matrix in the stage_in block. +uint32_t CompilerMSL::get_input_buffer_block_var_id(uint32_t msl_buffer) +{ + uint32_t ib_var_id = non_stage_in_input_var_ids[msl_buffer]; + if (!ib_var_id) + { + // No interface block exists yet. Create a new typed variable for this interface block. + // The initializer expression is allocated here, but populated when the function + // declaraion is emitted, because it is cleared after each compilation pass. + uint32_t next_id = increase_bound_by(3); + uint32_t ib_type_id = next_id++; + auto &ib_type = set(ib_type_id); + ib_type.basetype = SPIRType::Struct; + ib_type.storage = StorageClassInput; + set_decoration(ib_type_id, DecorationBlock); + + ib_var_id = next_id++; + auto &var = set(ib_var_id, ib_type_id, StorageClassInput, 0); + var.initializer = next_id++; + + string ib_var_name = stage_in_var_name + convert_to_string(msl_buffer); + set_name(ib_var_id, ib_var_name); + set_name(ib_type_id, get_entry_point_name() + "_" + ib_var_name); + + // Add the variable to the map of buffer blocks, accessed by the Metal buffer index. + non_stage_in_input_var_ids[msl_buffer] = ib_var_id; + } + return ib_var_id; +} + +// Sort the members of the struct type by offset, and pack and then pad members where needed +// to align MSL members with SPIR-V offsets. The struct members are iterated twice. Packing +// occurs first, followed by padding, because packing a member reduces both its size and its +// natural alignment, possibly requiring a padding member to be added ahead of it. +void CompilerMSL::align_struct(SPIRType &ib_type) +{ + uint32_t &ib_type_id = ib_type.self; + + // Sort the members of the interface structure by their offset. + // They should already be sorted per SPIR-V spec anyway. + MemberSorter member_sorter(ib_type, meta[ib_type_id], MemberSorter::Offset); + member_sorter.sort(); + + uint32_t curr_offset; + uint32_t mbr_cnt = uint32_t(ib_type.member_types.size()); + + // Test the alignment of each member, and if a member should be closer to the previous + // member than the default spacing expects, it is likely that the previous member is in + // a packed format. If so, and the previous member is packable, pack it. + // For example...this applies to any 3-element vector that is followed by a scalar. + curr_offset = 0; + for (uint32_t mbr_idx = 0; mbr_idx < mbr_cnt; mbr_idx++) + { + // Align current offset to the current member's default alignment. + size_t align_mask = get_declared_struct_member_alignment(ib_type, mbr_idx) - 1; + curr_offset = uint32_t((curr_offset + align_mask) & ~align_mask); + + // Fetch the member offset as declared in the SPIRV. + uint32_t mbr_offset = get_member_decoration(ib_type_id, mbr_idx, DecorationOffset); + if (curr_offset > mbr_offset) + { + uint32_t prev_mbr_idx = mbr_idx - 1; + if (is_member_packable(ib_type, prev_mbr_idx)) + set_member_decoration(ib_type_id, prev_mbr_idx, DecorationCPacked); + } + + // Increment the current offset to be positioned immediately after the current member. + curr_offset = mbr_offset + uint32_t(get_declared_struct_member_size(ib_type, mbr_idx)); + } + + // Test the alignment of each member, and if a member is positioned farther than its + // alignment and the end of the previous member, add a dummy padding member that will + // be added before the current member when the delaration of this struct is emitted. + curr_offset = 0; + for (uint32_t mbr_idx = 0; mbr_idx < mbr_cnt; mbr_idx++) + { + // Align current offset to the current member's default alignment. + size_t align_mask = get_declared_struct_member_alignment(ib_type, mbr_idx) - 1; + curr_offset = uint32_t((curr_offset + align_mask) & ~align_mask); + + // Fetch the member offset as declared in the SPIRV. + uint32_t mbr_offset = get_member_decoration(ib_type_id, mbr_idx, DecorationOffset); + if (mbr_offset > curr_offset) + { + // Since MSL and SPIR-V have slightly different struct member alignment and + // size rules, we'll pad to standard C-packing rules. If the member is farther + // away than C-packing, expects, add an inert padding member before the the member. + MSLStructMemberKey key = get_struct_member_key(ib_type_id, mbr_idx); + struct_member_padding[key] = mbr_offset - curr_offset; + } + + // Increment the current offset to be positioned immediately after the current member. + curr_offset = mbr_offset + uint32_t(get_declared_struct_member_size(ib_type, mbr_idx)); + } +} + +// Returns whether the specified struct member supports a packable type +// variation that is smaller than the unpacked variation of that type. +bool CompilerMSL::is_member_packable(SPIRType &ib_type, uint32_t index) +{ + uint32_t mbr_type_id = ib_type.member_types[index]; + auto &mbr_type = get(mbr_type_id); + + // 3-element vectors (char3, uchar3, short3, ushort3, int3, uint3, half3, float3) + if (mbr_type.vecsize == 3 && mbr_type.columns == 1) + return true; + + return false; +} + +// Returns a combination of type ID and member index for use as hash key +MSLStructMemberKey CompilerMSL::get_struct_member_key(uint32_t type_id, uint32_t index) +{ + MSLStructMemberKey k = type_id; + k <<= 32; + k += index; + return k; +} + +// Converts the format of the current expression from packed to unpacked, +// by wrapping the expression in a constructor of the appropriate type. +string CompilerMSL::unpack_expression_type(string expr_str, const SPIRType &type) +{ + return join(type_to_glsl(type), "(", expr_str, ")"); +} + +// Emits the file header info +void CompilerMSL::emit_header() +{ + for (auto &pragma : pragma_lines) + statement(pragma); + + if (!pragma_lines.empty()) + statement(""); + + statement("#include "); + statement("#include "); + + for (auto &header : header_lines) + statement(header); + + statement(""); + statement("using namespace metal;"); + statement(""); +} + +void CompilerMSL::add_pragma_line(const string &line) +{ + pragma_lines.insert(line); +} + +// Emits any needed custom function bodies. +void CompilerMSL::emit_custom_functions() +{ + for (auto &spv_func : spv_function_implementations) + { + switch (spv_func) + { + case SPVFuncImplMod: + statement("// Implementation of the GLSL mod() function, which is slightly different than Metal fmod()"); + statement("template"); + statement("Tx mod(Tx x, Ty y)"); + begin_scope(); + statement("return x - y * floor(x / y);"); + end_scope(); + statement(""); + break; + + case SPVFuncImplRadians: + statement("// Implementation of the GLSL radians() function"); + statement("template"); + statement("T radians(T d)"); + begin_scope(); + statement("return d * 0.01745329251;"); + end_scope(); + statement(""); + break; + + case SPVFuncImplDegrees: + statement("// Implementation of the GLSL degrees() function"); + statement("template"); + statement("T degrees(T r)"); + begin_scope(); + statement("return r * 57.2957795131;"); + end_scope(); + statement(""); + break; + + case SPVFuncImplFindILsb: + statement("// Implementation of the GLSL findLSB() function"); + statement("template"); + statement("T findLSB(T x)"); + begin_scope(); + statement("return select(ctz(x), T(-1), x == T(0));"); + end_scope(); + statement(""); + break; + + case SPVFuncImplFindUMsb: + statement("// Implementation of the unsigned GLSL findMSB() function"); + statement("template"); + statement("T findUMSB(T x)"); + begin_scope(); + statement("return select(clz(T(0)) - (clz(x) + T(1)), T(-1), x == T(0));"); + end_scope(); + statement(""); + break; + + case SPVFuncImplFindSMsb: + statement("// Implementation of the signed GLSL findMSB() function"); + statement("template"); + statement("T findSMSB(T x)"); + begin_scope(); + statement("T v = select(x, T(-1) - x, x < T(0));"); + statement("return select(clz(T(0)) - (clz(v) + T(1)), T(-1), v == T(0));"); + end_scope(); + statement(""); + break; + + case SPVFuncImplArrayCopy: + statement("// Implementation of an array copy function to cover GLSL's ability to copy an array via " + "assignment. "); + statement("template"); + statement("void spvArrayCopy(thread T* dst, thread const T* src, uint count)"); + begin_scope(); + statement("for (uint i = 0; i < count; *dst++ = *src++, i++);"); + end_scope(); + statement(""); + break; + + case SPVFuncImplInverse4x4: + statement("// Returns the determinant of a 2x2 matrix."); + statement("inline float spvDet2x2(float a1, float a2, float b1, float b2)"); + begin_scope(); + statement("return a1 * b2 - b1 * a2;"); + end_scope(); + statement(""); + statement("// Returns the determinant of a 3x3 matrix."); + statement("inline float spvDet3x3(float a1, float a2, float a3, float b1, float b2, float b3, float c1, " + "float c2, float c3)"); + begin_scope(); + statement("return a1 * spvDet2x2(b2, b3, c2, c3) - b1 * spvDet2x2(a2, a3, c2, c3) + c1 * spvDet2x2(a2, a3, " + "b2, b3);"); + end_scope(); + statement(""); + statement("// Returns the inverse of a matrix, by using the algorithm of calculating the classical"); + statement("// adjoint and dividing by the determinant. The contents of the matrix are changed."); + statement("float4x4 spvInverse4x4(float4x4 m)"); + begin_scope(); + statement("float4x4 adj; // The adjoint matrix (inverse after dividing by determinant)"); + statement(""); + statement("// Create the transpose of the cofactors, as the classical adjoint of the matrix."); + statement("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]);"); + statement("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]);"); + statement("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]);"); + statement("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]);"); + statement(""); + statement("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]);"); + statement("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]);"); + statement("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]);"); + statement("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]);"); + statement(""); + statement("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]);"); + statement("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]);"); + statement("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]);"); + statement("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]);"); + statement(""); + statement("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]);"); + statement("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]);"); + statement("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]);"); + statement("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]);"); + statement(""); + statement("// Calculate the determinant as a combination of the cofactors of the first row."); + statement("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]);"); + statement(""); + statement("// Divide the classical adjoint matrix by the determinant."); + statement("// If determinant is zero, matrix is not invertable, so leave it unchanged."); + statement("return (det != 0.0f) ? (adj * (1.0f / det)) : m;"); + end_scope(); + statement(""); + break; + + case SPVFuncImplInverse3x3: + statement("// Returns the determinant of a 2x2 matrix."); + statement("inline float spvDet2x2(float a1, float a2, float b1, float b2)"); + begin_scope(); + statement("return a1 * b2 - b1 * a2;"); + end_scope(); + statement(""); + statement("// Returns the inverse of a matrix, by using the algorithm of calculating the classical"); + statement("// adjoint and dividing by the determinant. The contents of the matrix are changed."); + statement("float3x3 spvInverse3x3(float3x3 m)"); + begin_scope(); + statement("float3x3 adj; // The adjoint matrix (inverse after dividing by determinant)"); + statement(""); + statement("// Create the transpose of the cofactors, as the classical adjoint of the matrix."); + statement("adj[0][0] = spvDet2x2(m[1][1], m[1][2], m[2][1], m[2][2]);"); + statement("adj[0][1] = -spvDet2x2(m[0][1], m[0][2], m[2][1], m[2][2]);"); + statement("adj[0][2] = spvDet2x2(m[0][1], m[0][2], m[1][1], m[1][2]);"); + statement(""); + statement("adj[1][0] = -spvDet2x2(m[1][0], m[1][2], m[2][0], m[2][2]);"); + statement("adj[1][1] = spvDet2x2(m[0][0], m[0][2], m[2][0], m[2][2]);"); + statement("adj[1][2] = -spvDet2x2(m[0][0], m[0][2], m[1][0], m[1][2]);"); + statement(""); + statement("adj[2][0] = spvDet2x2(m[1][0], m[1][1], m[2][0], m[2][1]);"); + statement("adj[2][1] = -spvDet2x2(m[0][0], m[0][1], m[2][0], m[2][1]);"); + statement("adj[2][2] = spvDet2x2(m[0][0], m[0][1], m[1][0], m[1][1]);"); + statement(""); + statement("// Calculate the determinant as a combination of the cofactors of the first row."); + statement("float det = (adj[0][0] * m[0][0]) + (adj[0][1] * m[1][0]) + (adj[0][2] * m[2][0]);"); + statement(""); + statement("// Divide the classical adjoint matrix by the determinant."); + statement("// If determinant is zero, matrix is not invertable, so leave it unchanged."); + statement("return (det != 0.0f) ? (adj * (1.0f / det)) : m;"); + end_scope(); + statement(""); + break; + + case SPVFuncImplInverse2x2: + statement("// Returns the inverse of a matrix, by using the algorithm of calculating the classical"); + statement("// adjoint and dividing by the determinant. The contents of the matrix are changed."); + statement("float2x2 spvInverse2x2(float2x2 m)"); + begin_scope(); + statement("float2x2 adj; // The adjoint matrix (inverse after dividing by determinant)"); + statement(""); + statement("// Create the transpose of the cofactors, as the classical adjoint of the matrix."); + statement("adj[0][0] = m[1][1];"); + statement("adj[0][1] = -m[0][1];"); + statement(""); + statement("adj[1][0] = -m[1][0];"); + statement("adj[1][1] = m[0][0];"); + statement(""); + statement("// Calculate the determinant as a combination of the cofactors of the first row."); + statement("float det = (adj[0][0] * m[0][0]) + (adj[0][1] * m[1][0]);"); + statement(""); + statement("// Divide the classical adjoint matrix by the determinant."); + statement("// If determinant is zero, matrix is not invertable, so leave it unchanged."); + statement("return (det != 0.0f) ? (adj * (1.0f / det)) : m;"); + end_scope(); + statement(""); + break; + + case SPVFuncImplRowMajor2x3: + statement("// Implementation of a conversion of matrix content from RowMajor to ColumnMajor organization."); + statement("float2x3 spvConvertFromRowMajor2x3(float2x3 m)"); + begin_scope(); + statement("return float2x3(float3(m[0][0], m[0][2], m[1][1]), float3(m[0][1], m[1][0], m[1][2]));"); + end_scope(); + statement(""); + break; + + case SPVFuncImplRowMajor2x4: + statement("// Implementation of a conversion of matrix content from RowMajor to ColumnMajor organization."); + statement("float2x4 spvConvertFromRowMajor2x4(float2x4 m)"); + begin_scope(); + statement("return float2x4(float4(m[0][0], m[0][2], m[1][0], m[1][2]), float4(m[0][1], m[0][3], m[1][1], " + "m[1][3]));"); + end_scope(); + statement(""); + break; + + case SPVFuncImplRowMajor3x2: + statement("// Implementation of a conversion of matrix content from RowMajor to ColumnMajor organization."); + statement("float3x2 spvConvertFromRowMajor3x2(float3x2 m)"); + begin_scope(); + statement("return float3x2(float2(m[0][0], m[1][1]), float2(m[0][1], m[2][0]), float2(m[1][0], m[2][1]));"); + end_scope(); + statement(""); + break; + + case SPVFuncImplRowMajor3x4: + statement("// Implementation of a conversion of matrix content from RowMajor to ColumnMajor organization."); + statement("float3x4 spvConvertFromRowMajor3x4(float3x4 m)"); + begin_scope(); + statement("return float3x4(float4(m[0][0], m[0][3], m[1][2], m[2][1]), float4(m[0][1], m[1][0], m[1][3], " + "m[2][2]), float4(m[0][2], m[1][1], m[2][0], m[2][3]));"); + end_scope(); + statement(""); + break; + + case SPVFuncImplRowMajor4x2: + statement("// Implementation of a conversion of matrix content from RowMajor to ColumnMajor organization."); + statement("float4x2 spvConvertFromRowMajor4x2(float4x2 m)"); + begin_scope(); + statement("return float4x2(float2(m[0][0], m[2][0]), float2(m[0][1], m[2][1]), float2(m[1][0], m[3][0]), " + "float2(m[1][1], m[3][1]));"); + end_scope(); + statement(""); + break; + + case SPVFuncImplRowMajor4x3: + statement("// Implementation of a conversion of matrix content from RowMajor to ColumnMajor organization."); + statement("float4x3 spvConvertFromRowMajor4x3(float4x3 m)"); + begin_scope(); + statement("return float4x3(float3(m[0][0], m[1][1], m[2][2]), float3(m[0][1], m[1][2], m[3][0]), " + "float3(m[0][2], m[2][0], m[3][1]), float3(m[1][0], m[2][1], m[3][2]));"); + end_scope(); + statement(""); + break; + + default: + break; + } + } +} + +// Undefined global memory is not allowed in MSL. +// Declare constant and init to zeros. Use {}, as global constructors can break Metal. +void CompilerMSL::declare_undefined_values() +{ + bool emitted = false; + for (auto &id : ids) + { + if (id.get_type() == TypeUndef) + { + auto &undef = id.get(); + auto &type = get(undef.basetype); + statement("constant ", variable_decl(type, to_name(undef.self), undef.self), " = {};"); + emitted = true; + } + } + + if (emitted) + statement(""); +} + +void CompilerMSL::emit_resources() +{ + // Output non-interface structs. These include local function structs + // and structs nested within uniform and read-write buffers. + unordered_set declared_structs; + for (auto &id : ids) + { + if (id.get_type() == TypeType) + { + auto &type = id.get(); + uint32_t type_id = type.self; + + bool is_struct = (type.basetype == SPIRType::Struct) && type.array.empty(); + bool is_block = + has_decoration(type.self, DecorationBlock) || has_decoration(type.self, DecorationBufferBlock); + bool is_basic_struct = is_struct && !type.pointer && !is_block; + + bool is_interface = (type.storage == StorageClassInput || type.storage == StorageClassOutput || + type.storage == StorageClassUniformConstant); + bool is_non_interface_block = is_struct && type.pointer && is_block && !is_interface; + + bool is_declarable_struct = is_basic_struct || is_non_interface_block; + + // Align and emit declarable structs...but avoid declaring each more than once. + if (is_declarable_struct && declared_structs.count(type_id) == 0) + { + declared_structs.insert(type_id); + + if (has_decoration(type_id, DecorationCPacked)) + align_struct(type); + + emit_struct(type); + } + } + } + + declare_undefined_values(); + + // Output interface structs. + emit_interface_block(stage_in_var_id); + for (auto &nsi_var : non_stage_in_input_var_ids) + emit_interface_block(nsi_var.second); + + emit_interface_block(stage_out_var_id); + emit_interface_block(stage_uniforms_var_id); +} + +// Emit declarations for the specialization Metal function constants +void CompilerMSL::emit_specialization_constants() +{ + const vector spec_consts = get_specialization_constants(); + + SpecializationConstant wg_x, wg_y, wg_z; + uint32_t workgroup_size_id = get_work_group_size_specialization_constants(wg_x, wg_y, wg_z); + + for (auto &sc : spec_consts) + { + // If WorkGroupSize is a specialization constant, it will be declared explicitly below. + if (sc.id == workgroup_size_id) + continue; + + auto &type = expression_type(sc.id); + string sc_type_name = type_to_glsl(type); + string sc_name = to_name(sc.id); + string sc_tmp_name = to_name(sc.id) + "_tmp"; + + if (type.vecsize == 1 && type.columns == 1 && type.basetype != SPIRType::Struct && type.array.empty()) + { + // Only scalar, non-composite values can be function constants. + statement("constant ", sc_type_name, " ", sc_tmp_name, " [[function_constant(", + convert_to_string(sc.constant_id), ")]];"); + statement("constant ", sc_type_name, " ", sc_name, " = is_function_constant_defined(", sc_tmp_name, ") ? ", + sc_tmp_name, " : ", constant_expression(get(sc.id)), ";"); + } + else + { + // Composite specialization constants must be built from other specialization constants. + statement("constant ", sc_type_name, " ", sc_name, " = ", constant_expression(get(sc.id)), + ";"); + } + } + + // TODO: This can be expressed as a [[threads_per_threadgroup]] input semantic, but we need to know + // the work group size at compile time in SPIR-V, and [[threads_per_threadgroup]] would need to be passed around as a global. + // The work group size may be a specialization constant. + if (workgroup_size_id) + statement("constant uint3 ", builtin_to_glsl(BuiltInWorkgroupSize, StorageClassWorkgroup), " = ", + constant_expression(get(workgroup_size_id)), ";"); + + if (!spec_consts.empty() || workgroup_size_id) + statement(""); +} + +// Override for MSL-specific syntax instructions +void CompilerMSL::emit_instruction(const Instruction &instruction) +{ + +#define BOP(op) emit_binary_op(ops[0], ops[1], ops[2], ops[3], #op) +#define BOP_CAST(op, type) \ + emit_binary_op_cast(ops[0], ops[1], ops[2], ops[3], #op, type, opcode_is_sign_invariant(opcode)) +#define UOP(op) emit_unary_op(ops[0], ops[1], ops[2], #op) +#define QFOP(op) emit_quaternary_func_op(ops[0], ops[1], ops[2], ops[3], ops[4], ops[5], #op) +#define TFOP(op) emit_trinary_func_op(ops[0], ops[1], ops[2], ops[3], ops[4], #op) +#define BFOP(op) emit_binary_func_op(ops[0], ops[1], ops[2], ops[3], #op) +#define BFOP_CAST(op, type) \ + emit_binary_func_op_cast(ops[0], ops[1], ops[2], ops[3], #op, type, opcode_is_sign_invariant(opcode)) +#define UFOP(op) emit_unary_func_op(ops[0], ops[1], ops[2], #op) + + auto ops = stream(instruction); + auto opcode = static_cast(instruction.op); + + switch (opcode) + { + + // Comparisons + case OpIEqual: + case OpLogicalEqual: + case OpFOrdEqual: + BOP(==); + break; + + case OpINotEqual: + case OpLogicalNotEqual: + case OpFOrdNotEqual: + BOP(!=); + break; + + case OpUGreaterThan: + case OpSGreaterThan: + case OpFOrdGreaterThan: + BOP(>); + break; + + case OpUGreaterThanEqual: + case OpSGreaterThanEqual: + case OpFOrdGreaterThanEqual: + BOP(>=); + break; + + case OpULessThan: + case OpSLessThan: + case OpFOrdLessThan: + BOP(<); + break; + + case OpULessThanEqual: + case OpSLessThanEqual: + case OpFOrdLessThanEqual: + BOP(<=); + break; + + // Derivatives + case OpDPdx: + case OpDPdxFine: + case OpDPdxCoarse: + UFOP(dfdx); + break; + + case OpDPdy: + case OpDPdyFine: + case OpDPdyCoarse: + UFOP(dfdy); + break; + + // Bitfield + case OpBitFieldInsert: + QFOP(insert_bits); + break; + + case OpBitFieldSExtract: + case OpBitFieldUExtract: + TFOP(extract_bits); + break; + + case OpBitReverse: + UFOP(reverse_bits); + break; + + case OpBitCount: + UFOP(popcount); + break; + + // Atomics + case OpAtomicExchange: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + uint32_t ptr = ops[2]; + uint32_t mem_sem = ops[4]; + uint32_t val = ops[5]; + emit_atomic_func_op(result_type, id, "atomic_exchange_explicit", mem_sem, mem_sem, false, ptr, val); + break; + } + + case OpAtomicCompareExchange: + case OpAtomicCompareExchangeWeak: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + uint32_t ptr = ops[2]; + uint32_t mem_sem_pass = ops[4]; + uint32_t mem_sem_fail = ops[5]; + uint32_t val = ops[6]; + uint32_t comp = ops[7]; + emit_atomic_func_op(result_type, id, "atomic_compare_exchange_weak_explicit", mem_sem_pass, mem_sem_fail, true, + ptr, comp, true, val); + break; + } + + case OpAtomicLoad: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + uint32_t ptr = ops[2]; + uint32_t mem_sem = ops[4]; + emit_atomic_func_op(result_type, id, "atomic_load_explicit", mem_sem, mem_sem, false, ptr, 0); + break; + } + + case OpAtomicStore: + { + uint32_t result_type = expression_type(ops[0]).self; + uint32_t id = ops[0]; + uint32_t ptr = ops[0]; + uint32_t mem_sem = ops[2]; + uint32_t val = ops[3]; + emit_atomic_func_op(result_type, id, "atomic_store_explicit", mem_sem, mem_sem, false, ptr, val); + break; + } + +#define AFMOImpl(op, valsrc) \ + do \ + { \ + uint32_t result_type = ops[0]; \ + uint32_t id = ops[1]; \ + uint32_t ptr = ops[2]; \ + uint32_t mem_sem = ops[4]; \ + uint32_t val = valsrc; \ + emit_atomic_func_op(result_type, id, "atomic_fetch_" #op "_explicit", mem_sem, mem_sem, false, ptr, val); \ + } while (false) + +#define AFMO(op) AFMOImpl(op, ops[5]) +#define AFMIO(op) AFMOImpl(op, 1) + + case OpAtomicIIncrement: + AFMIO(add); + break; + + case OpAtomicIDecrement: + AFMIO(sub); + break; + + case OpAtomicIAdd: + AFMO(add); + break; + + case OpAtomicISub: + AFMO(sub); + break; + + case OpAtomicSMin: + case OpAtomicUMin: + AFMO(min); + break; + + case OpAtomicSMax: + case OpAtomicUMax: + AFMO(max); + break; + + case OpAtomicAnd: + AFMO(and); + break; + + case OpAtomicOr: + AFMO(or); + break; + + case OpAtomicXor: + AFMO (xor); + break; + + // Images + + // Reads == Fetches in Metal + case OpImageRead: + { + // Mark that this shader reads from this image + uint32_t img_id = ops[2]; + auto *p_var = maybe_get_backing_variable(img_id); + if (p_var && has_decoration(p_var->self, DecorationNonReadable)) + { + unset_decoration(p_var->self, DecorationNonReadable); + force_recompile = true; + } + + emit_texture_op(instruction); + break; + } + + case OpImageWrite: + { + uint32_t img_id = ops[0]; + uint32_t coord_id = ops[1]; + uint32_t texel_id = ops[2]; + const uint32_t *opt = &ops[3]; + uint32_t length = instruction.length - 4; + + // Bypass pointers because we need the real image struct + auto &type = expression_type(img_id); + auto &img_type = get(type.self); + + // Ensure this image has been marked as being written to and force a + // recommpile so that the image type output will include write access + auto *p_var = maybe_get_backing_variable(img_id); + if (p_var && has_decoration(p_var->self, DecorationNonWritable)) + { + unset_decoration(p_var->self, DecorationNonWritable); + force_recompile = true; + } + + bool forward = false; + uint32_t bias = 0; + uint32_t lod = 0; + uint32_t flags = 0; + + if (length) + { + flags = *opt++; + length--; + } + + auto test = [&](uint32_t &v, uint32_t flag) { + if (length && (flags & flag)) + { + v = *opt++; + length--; + } + }; + + test(bias, ImageOperandsBiasMask); + test(lod, ImageOperandsLodMask); + + statement(join( + to_expression(img_id), ".write(", to_expression(texel_id), ", ", + to_function_args(img_id, img_type, true, false, false, coord_id, 0, 0, 0, 0, lod, 0, 0, 0, 0, 0, &forward), + ");")); + + if (p_var && variable_storage_is_aliased(*p_var)) + flush_all_aliased_variables(); + + break; + } + + case OpImageQuerySize: + case OpImageQuerySizeLod: + { + uint32_t rslt_type_id = ops[0]; + auto &rslt_type = get(rslt_type_id); + + uint32_t id = ops[1]; + + uint32_t img_id = ops[2]; + string img_exp = to_expression(img_id); + auto &img_type = expression_type(img_id); + Dim img_dim = img_type.image.dim; + bool img_is_array = img_type.image.arrayed; + + if (img_type.basetype != SPIRType::Image) + SPIRV_CROSS_THROW("Invalid type for OpImageQuerySize."); + + string lod; + if (opcode == OpImageQuerySizeLod) + { + // LOD index defaults to zero, so don't bother outputing level zero index + string decl_lod = to_expression(ops[3]); + if (decl_lod != "0") + lod = decl_lod; + } + + string expr = type_to_glsl(rslt_type) + "("; + expr += img_exp + ".get_width(" + lod + ")"; + + if (img_dim == Dim2D || img_dim == DimCube || img_dim == Dim3D) + expr += ", " + img_exp + ".get_height(" + lod + ")"; + + if (img_dim == Dim3D) + expr += ", " + img_exp + ".get_depth(" + lod + ")"; + + if (img_is_array) + expr += ", " + img_exp + ".get_array_size()"; + + expr += ")"; + + emit_op(rslt_type_id, id, expr, should_forward(img_id)); + + break; + } + +#define ImgQry(qrytype) \ + do \ + { \ + uint32_t rslt_type_id = ops[0]; \ + auto &rslt_type = get(rslt_type_id); \ + uint32_t id = ops[1]; \ + uint32_t img_id = ops[2]; \ + string img_exp = to_expression(img_id); \ + string expr = type_to_glsl(rslt_type) + "(" + img_exp + ".get_num_" #qrytype "())"; \ + emit_op(rslt_type_id, id, expr, should_forward(img_id)); \ + } while (false) + + case OpImageQueryLevels: + ImgQry(mip_levels); + break; + + case OpImageQuerySamples: + ImgQry(samples); + break; + + // Casting + case OpQuantizeToF16: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + uint32_t arg = ops[2]; + + string exp; + auto &type = get(result_type); + + switch (type.vecsize) + { + case 1: + exp = join("float(half(", to_expression(arg), "))"); + break; + case 2: + exp = join("float2(half2(", to_expression(arg), "))"); + break; + case 3: + exp = join("float3(half3(", to_expression(arg), "))"); + break; + case 4: + exp = join("float4(half4(", to_expression(arg), "))"); + break; + default: + SPIRV_CROSS_THROW("Illegal argument to OpQuantizeToF16."); + } + + emit_op(result_type, id, exp, should_forward(arg)); + break; + } + + case OpStore: + if (maybe_emit_input_struct_assignment(ops[0], ops[1])) + break; + + if (maybe_emit_array_assignment(ops[0], ops[1])) + break; + + CompilerGLSL::emit_instruction(instruction); + break; + + // Compute barriers + case OpMemoryBarrier: + emit_barrier(0, ops[0], ops[1]); + break; + + case OpControlBarrier: + // In GLSL a memory barrier is often followed by a control barrier. + // But in MSL, memory barriers are also control barriers, so don't + // emit a simple control barrier if a memory barrier has just been emitted. + if (previous_instruction_opcode != OpMemoryBarrier) + emit_barrier(ops[0], ops[1], ops[2]); + break; + + case OpVectorTimesMatrix: + case OpMatrixTimesVector: + { + // If the matrix needs transpose and it is square, just flip the multiply order. + uint32_t mtx_id = ops[opcode == OpMatrixTimesVector ? 2 : 3]; + auto *e = maybe_get(mtx_id); + auto &t = expression_type(mtx_id); + if (e && e->need_transpose && t.columns == t.vecsize) + { + e->need_transpose = false; + emit_binary_op(ops[0], ops[1], ops[3], ops[2], "*"); + e->need_transpose = true; + } + else + BOP(*); + break; + } + + // OpOuterProduct + + default: + CompilerGLSL::emit_instruction(instruction); + break; + } + + previous_instruction_opcode = opcode; +} + +void CompilerMSL::emit_barrier(uint32_t id_exe_scope, uint32_t id_mem_scope, uint32_t id_mem_sem) +{ + if (get_entry_point().model != ExecutionModelGLCompute) + return; + + string bar_stmt = "threadgroup_barrier(mem_flags::"; + + uint32_t mem_sem = id_mem_sem ? get(id_mem_sem).scalar() : uint32_t(MemorySemanticsMaskNone); + + if (mem_sem & MemorySemanticsCrossWorkgroupMemoryMask) + bar_stmt += "mem_device"; + else if (mem_sem & (MemorySemanticsSubgroupMemoryMask | MemorySemanticsWorkgroupMemoryMask | + MemorySemanticsAtomicCounterMemoryMask)) + bar_stmt += "mem_threadgroup"; + else if (mem_sem & MemorySemanticsImageMemoryMask) + bar_stmt += "mem_texture"; + else + bar_stmt += "mem_none"; + + if (options.is_ios() && options.supports_msl_version(2)) + { + bar_stmt += ", "; + + // Use the wider of the two scopes (smaller value) + uint32_t exe_scope = id_exe_scope ? get(id_exe_scope).scalar() : uint32_t(ScopeInvocation); + uint32_t mem_scope = id_mem_scope ? get(id_mem_scope).scalar() : uint32_t(ScopeInvocation); + uint32_t scope = min(exe_scope, mem_scope); + switch (scope) + { + case ScopeCrossDevice: + case ScopeDevice: + bar_stmt += "memory_scope_device"; + break; + + case ScopeSubgroup: + case ScopeInvocation: + bar_stmt += "memory_scope_simdgroup"; + break; + + case ScopeWorkgroup: + default: + bar_stmt += "memory_scope_threadgroup"; + break; + } + } + + bar_stmt += ");"; + + statement(bar_stmt); +} + +// Since MSL does not allow structs to be nested within the stage_in struct, the original input +// structs are flattened into a single stage_in struct by add_interface_block. As a result, +// if the LHS and RHS represent an assignment of an entire input struct, we must perform this +// member-by-member, mapping each RHS member to its name in the flattened stage_in struct. +// Returns whether the struct assignment was emitted. +bool CompilerMSL::maybe_emit_input_struct_assignment(uint32_t id_lhs, uint32_t id_rhs) +{ + // We only care about assignments of an entire struct + uint32_t type_id = expression_type_id(id_rhs); + auto &type = get(type_id); + if (type.basetype != SPIRType::Struct) + return false; + + // We only care about assignments from Input variables + auto *p_v_rhs = maybe_get_backing_variable(id_rhs); + if (!(p_v_rhs && p_v_rhs->storage == StorageClassInput)) + return false; + + // Get the ID of the type of the underlying RHS variable. + // This will be an Input OpTypePointer containing the qualified member names. + uint32_t tid_v_rhs = p_v_rhs->basetype; + + // Ensure the LHS variable has been declared + auto *p_v_lhs = maybe_get_backing_variable(id_lhs); + if (p_v_lhs) + flush_variable_declaration(p_v_lhs->self); + + size_t mbr_cnt = type.member_types.size(); + for (uint32_t mbr_idx = 0; mbr_idx < mbr_cnt; mbr_idx++) + { + string expr; + + //LHS + expr += to_name(id_lhs); + expr += "."; + expr += to_member_name(type, mbr_idx); + + expr += " = "; + + //RHS + string qual_mbr_name = get_member_qualified_name(tid_v_rhs, mbr_idx); + if (qual_mbr_name.empty()) + { + expr += to_name(id_rhs); + expr += "."; + expr += to_member_name(type, mbr_idx); + } + else + expr += qual_mbr_name; + + statement(expr, ";"); + } + + return true; +} + +// Since MSL does not allow arrays to be copied via simple variable assignment, +// if the LHS and RHS represent an assignment of an entire array, it must be +// implemented by calling an array copy function. +// Returns whether the struct assignment was emitted. +bool CompilerMSL::maybe_emit_array_assignment(uint32_t id_lhs, uint32_t id_rhs) +{ + // Assignment from an array initializer is fine. + if (ids[id_rhs].get_type() == TypeConstant) + return false; + + // We only care about assignments of an entire array + auto &type = expression_type(id_rhs); + if (type.array.size() == 0) + return false; + + // Ensure the LHS variable has been declared + auto *p_v_lhs = maybe_get_backing_variable(id_lhs); + if (p_v_lhs) + flush_variable_declaration(p_v_lhs->self); + + statement("spvArrayCopy(", to_expression(id_lhs), ", ", to_expression(id_rhs), ", ", to_array_size(type, 0), ");"); + register_write(id_lhs); + + return true; +} + +// Emits one of the atomic functions. In MSL, the atomic functions operate on pointers +void CompilerMSL::emit_atomic_func_op(uint32_t result_type, uint32_t result_id, const char *op, uint32_t mem_order_1, + uint32_t mem_order_2, bool has_mem_order_2, uint32_t obj, uint32_t op1, + bool op1_is_pointer, uint32_t op2) +{ + forced_temporaries.insert(result_id); + + bool fwd_obj = should_forward(obj); + bool fwd_op1 = op1 ? should_forward(op1) : true; + bool fwd_op2 = op2 ? should_forward(op2) : true; + + bool forward = fwd_obj && fwd_op1 && fwd_op2; + + string exp = string(op) + "("; + + auto &type = expression_type(obj); + exp += "(volatile "; + exp += "device"; + exp += " atomic_"; + exp += type_to_glsl(type); + exp += "*)"; + + exp += "&("; + exp += to_expression(obj); + exp += ")"; + + if (op1) + { + if (op1_is_pointer) + { + statement(declare_temporary(expression_type(op2).self, op1), to_expression(op1), ";"); + exp += ", &(" + to_name(op1) + ")"; + } + else + exp += ", " + to_expression(op1); + } + + if (op2) + exp += ", " + to_expression(op2); + + exp += string(", ") + get_memory_order(mem_order_1); + + if (has_mem_order_2) + exp += string(", ") + get_memory_order(mem_order_2); + + exp += ")"; + emit_op(result_type, result_id, exp, forward); + + inherit_expression_dependencies(result_id, obj); + if (op1) + inherit_expression_dependencies(result_id, op1); + if (op2) + inherit_expression_dependencies(result_id, op2); + + flush_all_atomic_capable_variables(); +} + +// Metal only supports relaxed memory order for now +const char *CompilerMSL::get_memory_order(uint32_t) +{ + return "memory_order_relaxed"; +} + +// Override for MSL-specific extension syntax instructions +void CompilerMSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop, const uint32_t *args, uint32_t count) +{ + GLSLstd450 op = static_cast(eop); + + switch (op) + { + case GLSLstd450Atan2: + emit_binary_func_op(result_type, id, args[0], args[1], "atan2"); + break; + case GLSLstd450InverseSqrt: + emit_unary_func_op(result_type, id, args[0], "rsqrt"); + break; + case GLSLstd450RoundEven: + emit_unary_func_op(result_type, id, args[0], "rint"); + break; + + case GLSLstd450FindSMsb: + emit_unary_func_op(result_type, id, args[0], "findSMSB"); + break; + case GLSLstd450FindUMsb: + emit_unary_func_op(result_type, id, args[0], "findUMSB"); + break; + + case GLSLstd450PackSnorm4x8: + emit_unary_func_op(result_type, id, args[0], "pack_float_to_snorm4x8"); + break; + case GLSLstd450PackUnorm4x8: + emit_unary_func_op(result_type, id, args[0], "pack_float_to_unorm4x8"); + break; + case GLSLstd450PackSnorm2x16: + emit_unary_func_op(result_type, id, args[0], "pack_float_to_snorm2x16"); + break; + case GLSLstd450PackUnorm2x16: + emit_unary_func_op(result_type, id, args[0], "pack_float_to_unorm2x16"); + break; + case GLSLstd450PackHalf2x16: + emit_unary_func_op(result_type, id, args[0], "unsupported_GLSLstd450PackHalf2x16"); // Currently unsupported + break; + + case GLSLstd450UnpackSnorm4x8: + emit_unary_func_op(result_type, id, args[0], "unpack_snorm4x8_to_float"); + break; + case GLSLstd450UnpackUnorm4x8: + emit_unary_func_op(result_type, id, args[0], "unpack_unorm4x8_to_float"); + break; + case GLSLstd450UnpackSnorm2x16: + emit_unary_func_op(result_type, id, args[0], "unpack_snorm2x16_to_float"); + break; + case GLSLstd450UnpackUnorm2x16: + emit_unary_func_op(result_type, id, args[0], "unpack_unorm2x16_to_float"); + break; + case GLSLstd450UnpackHalf2x16: + emit_unary_func_op(result_type, id, args[0], "unsupported_GLSLstd450UnpackHalf2x16"); // Currently unsupported + break; + + case GLSLstd450PackDouble2x32: + emit_unary_func_op(result_type, id, args[0], "unsupported_GLSLstd450PackDouble2x32"); // Currently unsupported + break; + case GLSLstd450UnpackDouble2x32: + emit_unary_func_op(result_type, id, args[0], "unsupported_GLSLstd450UnpackDouble2x32"); // Currently unsupported + break; + + case GLSLstd450MatrixInverse: + { + auto &mat_type = get(result_type); + switch (mat_type.columns) + { + case 2: + emit_unary_func_op(result_type, id, args[0], "spvInverse2x2"); + break; + case 3: + emit_unary_func_op(result_type, id, args[0], "spvInverse3x3"); + break; + case 4: + emit_unary_func_op(result_type, id, args[0], "spvInverse4x4"); + break; + default: + break; + } + break; + } + + // TODO: + // GLSLstd450InterpolateAtCentroid (centroid_no_perspective qualifier) + // GLSLstd450InterpolateAtSample (sample_no_perspective qualifier) + // GLSLstd450InterpolateAtOffset + + default: + CompilerGLSL::emit_glsl_op(result_type, id, eop, args, count); + break; + } +} + +// Emit a structure declaration for the specified interface variable. +void CompilerMSL::emit_interface_block(uint32_t ib_var_id) +{ + if (ib_var_id) + { + auto &ib_var = get(ib_var_id); + auto &ib_type = get(ib_var.basetype); + auto &m = meta.at(ib_type.self); + if (m.members.size() > 0) + emit_struct(ib_type); + } +} + +// Emits the declaration signature of the specified function. +// If this is the entry point function, Metal-specific return value and function arguments are added. +void CompilerMSL::emit_function_prototype(SPIRFunction &func, uint64_t) +{ + local_variable_names = resource_names; + string decl; + + processing_entry_point = (func.self == entry_point); + + auto &type = get(func.return_type); + decl += func_type_decl(type); + decl += " "; + decl += to_name(func.self); + + decl += "("; + + if (processing_entry_point) + { + decl += entry_point_args(!func.arguments.empty()); + + // If entry point function has a output interface struct, set its initializer. + // This is done at this late stage because the initialization expression is + // cleared after each compilation pass. + if (stage_out_var_id) + { + auto &so_var = get(stage_out_var_id); + auto &so_type = get(so_var.basetype); + set(so_var.initializer, "{}", so_type.self, true); + } + } + + for (auto &arg : func.arguments) + { + add_local_variable_name(arg.id); + + string address_space = "thread"; + + auto *var = maybe_get(arg.id); + if (var) + { + var->parameter = &arg; // Hold a pointer to the parameter so we can invalidate the readonly field if needed. + address_space = get_argument_address_space(*var); + } + + decl += address_space + " "; + decl += argument_decl(arg); + + // Manufacture automatic sampler arg for SampledImage texture + auto &arg_type = get(arg.type); + if (arg_type.basetype == SPIRType::SampledImage && arg_type.image.dim != DimBuffer) + decl += ", thread const sampler& " + to_sampler_expression(arg.id); + + if (&arg != &func.arguments.back()) + decl += ", "; + } + + decl += ")"; + statement(decl); +} + +// Returns the texture sampling function string for the specified image and sampling characteristics. +string CompilerMSL::to_function_name(uint32_t img, const SPIRType &, bool is_fetch, bool is_gather, bool, bool, bool, + bool, bool has_dref, uint32_t) +{ + // Texture reference + string fname = to_expression(img) + "."; + + // Texture function and sampler + if (is_fetch) + fname += "read"; + else if (is_gather) + fname += "gather"; + else + fname += "sample"; + + if (has_dref) + fname += "_compare"; + + return fname; +} + +// Returns the function args for a texture sampling function for the specified image and sampling characteristics. +string CompilerMSL::to_function_args(uint32_t img, const SPIRType &imgtype, bool is_fetch, bool, bool is_proj, + uint32_t coord, uint32_t, uint32_t dref, uint32_t grad_x, uint32_t grad_y, + uint32_t lod, uint32_t coffset, uint32_t offset, uint32_t bias, uint32_t comp, + uint32_t sample, bool *p_forward) +{ + string farg_str; + if (!is_fetch) + farg_str += to_sampler_expression(img); + + // Texture coordinates + bool forward = should_forward(coord); + auto coord_expr = to_enclosed_expression(coord); + auto &coord_type = expression_type(coord); + bool coord_is_fp = (coord_type.basetype == SPIRType::Float) || (coord_type.basetype == SPIRType::Double); + bool is_cube_fetch = false; + + string tex_coords = coord_expr; + const char *alt_coord = ""; + + switch (imgtype.image.dim) + { + + case Dim1D: + if (coord_type.vecsize > 1) + tex_coords += ".x"; + + if (is_fetch) + tex_coords = "uint(" + round_fp_tex_coords(tex_coords, coord_is_fp) + ")"; + + alt_coord = ".y"; + + break; + + case DimBuffer: + if (coord_type.vecsize > 1) + tex_coords += ".x"; + + if (is_fetch) + tex_coords = "uint2(" + round_fp_tex_coords(tex_coords, coord_is_fp) + ", 0)"; // Metal textures are 2D + + alt_coord = ".y"; + + break; + + case Dim2D: + if (coord_type.vecsize > 2) + tex_coords += ".xy"; + + if (is_fetch) + tex_coords = "uint2(" + round_fp_tex_coords(tex_coords, coord_is_fp) + ")"; + + alt_coord = ".z"; + + break; + + case Dim3D: + if (coord_type.vecsize > 3) + tex_coords += ".xyz"; + + if (is_fetch) + tex_coords = "uint3(" + round_fp_tex_coords(tex_coords, coord_is_fp) + ")"; + + alt_coord = ".w"; + + break; + + case DimCube: + if (is_fetch) + { + is_cube_fetch = true; + tex_coords += ".xy"; + tex_coords = "uint2(" + round_fp_tex_coords(tex_coords, coord_is_fp) + ")"; + } + else + { + if (coord_type.vecsize > 3) + tex_coords += ".xyz"; + } + + alt_coord = ".w"; + + break; + + default: + break; + } + + // If projection, use alt coord as divisor + if (is_proj) + tex_coords += " / " + coord_expr + alt_coord; + + if (!farg_str.empty()) + farg_str += ", "; + farg_str += tex_coords; + + // If fetch from cube, add face explicitly + if (is_cube_fetch) + farg_str += ", uint(" + round_fp_tex_coords(coord_expr + ".z", coord_is_fp) + ")"; + + // If array, use alt coord + if (imgtype.image.arrayed) + farg_str += ", uint(" + round_fp_tex_coords(coord_expr + alt_coord, coord_is_fp) + ")"; + + // Depth compare reference value + if (dref) + { + forward = forward && should_forward(dref); + farg_str += ", "; + farg_str += to_expression(dref); + } + + // LOD Options + if (bias) + { + forward = forward && should_forward(bias); + farg_str += ", bias(" + to_expression(bias) + ")"; + } + + if (lod) + { + forward = forward && should_forward(lod); + if (is_fetch) + { + farg_str += ", " + to_expression(lod); + } + else + { + farg_str += ", level(" + to_expression(lod) + ")"; + } + } + + if (grad_x || grad_y) + { + forward = forward && should_forward(grad_x); + forward = forward && should_forward(grad_y); + string grad_opt; + switch (imgtype.image.dim) + { + case Dim2D: + grad_opt = "2d"; + break; + case Dim3D: + grad_opt = "3d"; + break; + case DimCube: + grad_opt = "cube"; + break; + default: + grad_opt = "unsupported_gradient_dimension"; + break; + } + farg_str += ", gradient" + grad_opt + "(" + to_expression(grad_x) + ", " + to_expression(grad_y) + ")"; + } + + // Add offsets + string offset_expr; + if (coffset) + { + forward = forward && should_forward(coffset); + offset_expr = to_expression(coffset); + } + else if (offset) + { + forward = forward && should_forward(offset); + offset_expr = to_expression(offset); + } + + if (!offset_expr.empty()) + { + switch (imgtype.image.dim) + { + case Dim2D: + if (coord_type.vecsize > 2) + offset_expr += ".xy"; + + farg_str += ", " + offset_expr; + break; + + case Dim3D: + if (coord_type.vecsize > 3) + offset_expr += ".xyz"; + + farg_str += ", " + offset_expr; + break; + + default: + break; + } + } + + if (comp) + { + forward = forward && should_forward(comp); + farg_str += ", " + to_component_argument(comp); + } + + if (sample) + { + farg_str += ", "; + farg_str += to_expression(sample); + } + + *p_forward = forward; + + return farg_str; +} + +// If the texture coordinates are floating point, invokes MSL round() function to round them. +string CompilerMSL::round_fp_tex_coords(string tex_coords, bool coord_is_fp) +{ + return coord_is_fp ? ("round(" + tex_coords + ")") : tex_coords; +} + +// Returns a string to use in an image sampling function argument. +// The ID must be a scalar constant. +string CompilerMSL::to_component_argument(uint32_t id) +{ + if (ids[id].get_type() != TypeConstant) + { + SPIRV_CROSS_THROW("ID " + to_string(id) + " is not an OpConstant."); + return "component::x"; + } + + uint32_t component_index = get(id).scalar(); + switch (component_index) + { + case 0: + return "component::x"; + case 1: + return "component::y"; + case 2: + return "component::z"; + case 3: + return "component::w"; + + default: + SPIRV_CROSS_THROW("The value (" + to_string(component_index) + ") of OpConstant ID " + to_string(id) + + " is not a valid Component index, which must be one of 0, 1, 2, or 3."); + return "component::x"; + } +} + +// Establish sampled image as expression object and assign the sampler to it. +void CompilerMSL::emit_sampled_image_op(uint32_t result_type, uint32_t result_id, uint32_t image_id, uint32_t samp_id) +{ + set(result_id, to_expression(image_id), result_type, true); + meta[result_id].sampler = samp_id; +} + +// Returns a string representation of the ID, usable as a function arg. +// Manufacture automatic sampler arg for SampledImage texture. +string CompilerMSL::to_func_call_arg(uint32_t id) +{ + string arg_str = CompilerGLSL::to_func_call_arg(id); + + // Manufacture automatic sampler arg if the arg is a SampledImage texture. + Variant &id_v = ids[id]; + if (id_v.get_type() == TypeVariable) + { + auto &var = id_v.get(); + auto &type = get(var.basetype); + if (type.basetype == SPIRType::SampledImage && type.image.dim != DimBuffer) + arg_str += ", " + to_sampler_expression(id); + } + + return arg_str; +} + +// If the ID represents a sampled image that has been assigned a sampler already, +// generate an expression for the sampler, otherwise generate a fake sampler name +// by appending a suffix to the expression constructed from the ID. +string CompilerMSL::to_sampler_expression(uint32_t id) +{ + uint32_t samp_id = meta[id].sampler; + return samp_id ? to_expression(samp_id) : to_expression(id) + sampler_name_suffix; +} + +// Checks whether the ID is a row_major matrix that requires conversion before use +bool CompilerMSL::is_non_native_row_major_matrix(uint32_t id) +{ + // Natively supported row-major matrices do not need to be converted. + if (backend.native_row_major_matrix) + return false; + + // Non-matrix or column-major matrix types do not need to be converted. + if (!(meta[id].decoration.decoration_flags & (1ull << DecorationRowMajor))) + return false; + + // Generate a function that will swap matrix elements from row-major to column-major. + const auto type = expression_type(id); + add_convert_row_major_matrix_function(type.columns, type.vecsize); + return true; +} + +// Checks whether the member is a row_major matrix that requires conversion before use +bool CompilerMSL::member_is_non_native_row_major_matrix(const SPIRType &type, uint32_t index) +{ + // Natively supported row-major matrices do not need to be converted. + if (backend.native_row_major_matrix) + return false; + + // Non-matrix or column-major matrix types do not need to be converted. + if (!(combined_decoration_for_member(type, index) & (1ull << DecorationRowMajor))) + return false; + + // Generate a function that will swap matrix elements from row-major to column-major. + const auto mbr_type = get(type.member_types[index]); + add_convert_row_major_matrix_function(mbr_type.columns, mbr_type.vecsize); + return true; +} + +// Adds a function suitable for converting a non-square row-major matrix to a column-major matrix. +void CompilerMSL::add_convert_row_major_matrix_function(uint32_t cols, uint32_t rows) +{ + SPVFuncImpl spv_func; + if (cols == rows) // Square matrix...just use transpose() function + return; + else if (cols == 2 && rows == 3) + spv_func = SPVFuncImplRowMajor2x3; + else if (cols == 2 && rows == 4) + spv_func = SPVFuncImplRowMajor2x4; + else if (cols == 3 && rows == 2) + spv_func = SPVFuncImplRowMajor3x2; + else if (cols == 3 && rows == 4) + spv_func = SPVFuncImplRowMajor3x4; + else if (cols == 4 && rows == 2) + spv_func = SPVFuncImplRowMajor4x2; + else if (cols == 4 && rows == 3) + spv_func = SPVFuncImplRowMajor4x3; + else + SPIRV_CROSS_THROW("Could not convert row-major matrix."); + + auto rslt = spv_function_implementations.insert(spv_func); + if (rslt.second) + { + add_pragma_line("#pragma clang diagnostic ignored \"-Wmissing-prototypes\""); + force_recompile = true; + } +} + +// Wraps the expression string in a function call that converts the +// row_major matrix result of the expression to a column_major matrix. +string CompilerMSL::convert_row_major_matrix(string exp_str, const SPIRType &exp_type) +{ + strip_enclosed_expression(exp_str); + + string func_name; + if (exp_type.columns == exp_type.vecsize) + func_name = "transpose"; + else + func_name = string("spvConvertFromRowMajor") + to_string(exp_type.columns) + "x" + to_string(exp_type.vecsize); + + return join(func_name, "(", exp_str, ")"); +} + +// Called automatically at the end of the entry point function +void CompilerMSL::emit_fixup() +{ + auto &execution = get_entry_point(); + + if ((execution.model == ExecutionModelVertex) && stage_out_var_id && !qual_pos_var_name.empty()) + { + if (CompilerGLSL::options.vertex.fixup_clipspace) + statement(qual_pos_var_name, ".z = (", qual_pos_var_name, ".z + ", qual_pos_var_name, + ".w) * 0.5; // Adjust clip-space for Metal"); + + if (CompilerGLSL::options.vertex.flip_vert_y) + statement(qual_pos_var_name, ".y = -(", qual_pos_var_name, ".y);", " // Invert Y-axis for Metal"); + } +} + +// Emit a structure member, padding and packing to maintain the correct memeber alignments. +void CompilerMSL::emit_struct_member(const SPIRType &type, uint32_t member_type_id, uint32_t index, + const string &qualifier) +{ + auto &membertype = get(member_type_id); + + // If this member requires padding to maintain alignment, emit a dummy padding member. + MSLStructMemberKey key = get_struct_member_key(type.self, index); + uint32_t pad_len = struct_member_padding[key]; + if (pad_len > 0) + statement("char pad", to_string(index), "[", to_string(pad_len), "];"); + + // If this member is packed, mark it as so. + string pack_pfx = member_is_packed_type(type, index) ? "packed_" : ""; + + statement(pack_pfx, type_to_glsl(membertype), " ", qualifier, to_member_name(type, index), + member_attribute_qualifier(type, index), type_to_array_glsl(membertype), ";"); +} + +// Return a MSL qualifier for the specified function attribute member +string CompilerMSL::member_attribute_qualifier(const SPIRType &type, uint32_t index) +{ + auto &execution = get_entry_point(); + + uint32_t mbr_type_id = type.member_types[index]; + auto &mbr_type = get(mbr_type_id); + + BuiltIn builtin; + bool is_builtin = is_member_builtin(type, index, &builtin); + + // Vertex function inputs + if (execution.model == ExecutionModelVertex && type.storage == StorageClassInput) + { + if (is_builtin) + { + switch (builtin) + { + case BuiltInVertexId: + case BuiltInVertexIndex: + case BuiltInInstanceId: + case BuiltInInstanceIndex: + return string(" [[") + builtin_qualifier(builtin) + "]]"; + + default: + return ""; + } + } + uint32_t locn = get_ordered_member_location(type.self, index); + if (locn != k_unknown_location) + return string(" [[attribute(") + convert_to_string(locn) + ")]]"; + } + + // Vertex function outputs + if (execution.model == ExecutionModelVertex && type.storage == StorageClassOutput) + { + if (is_builtin) + { + switch (builtin) + { + case BuiltInPointSize: + // Only mark the PointSize builtin if really rendering points. + // Some shaders may include a PointSize builtin even when used to render + // non-point topologies, and Metal will reject this builtin when compiling + // the shader into a render pipeline that uses a non-point topology. + return options.enable_point_size_builtin ? (string(" [[") + builtin_qualifier(builtin) + "]]") : ""; + + case BuiltInPosition: + case BuiltInLayer: + case BuiltInClipDistance: + return string(" [[") + builtin_qualifier(builtin) + "]]" + (mbr_type.array.empty() ? "" : " "); + + default: + return ""; + } + } + uint32_t locn = get_ordered_member_location(type.self, index); + if (locn != k_unknown_location) + return string(" [[user(locn") + convert_to_string(locn) + ")]]"; + } + + // Fragment function inputs + if (execution.model == ExecutionModelFragment && type.storage == StorageClassInput) + { + if (is_builtin) + { + switch (builtin) + { + case BuiltInFrontFacing: + case BuiltInPointCoord: + case BuiltInFragCoord: + case BuiltInSampleId: + case BuiltInSampleMask: + case BuiltInLayer: + return string(" [[") + builtin_qualifier(builtin) + "]]"; + + default: + return ""; + } + } + uint32_t locn = get_ordered_member_location(type.self, index); + if (locn != k_unknown_location) + return string(" [[user(locn") + convert_to_string(locn) + ")]]"; + } + + // Fragment function outputs + if (execution.model == ExecutionModelFragment && type.storage == StorageClassOutput) + { + if (is_builtin) + { + switch (builtin) + { + case BuiltInSampleMask: + case BuiltInFragDepth: + return string(" [[") + builtin_qualifier(builtin) + "]]"; + + default: + return ""; + } + } + uint32_t locn = get_ordered_member_location(type.self, index); + if (locn != k_unknown_location) + return string(" [[color(") + convert_to_string(locn) + ")]]"; + } + + // Compute function inputs + if (execution.model == ExecutionModelGLCompute && type.storage == StorageClassInput) + { + if (is_builtin) + { + switch (builtin) + { + case BuiltInGlobalInvocationId: + case BuiltInWorkgroupId: + case BuiltInNumWorkgroups: + case BuiltInLocalInvocationId: + case BuiltInLocalInvocationIndex: + return string(" [[") + builtin_qualifier(builtin) + "]]"; + + default: + return ""; + } + } + } + + return ""; +} + +// Returns the location decoration of the member with the specified index in the specified type. +// If the location of the member has been explicitly set, that location is used. If not, this +// function assumes the members are ordered in their location order, and simply returns the +// index as the location. +uint32_t CompilerMSL::get_ordered_member_location(uint32_t type_id, uint32_t index) +{ + auto &m = meta.at(type_id); + if (index < m.members.size()) + { + auto &dec = m.members[index]; + if (dec.decoration_flags & (1ull << DecorationLocation)) + return dec.location; + } + + return index; +} + +string CompilerMSL::constant_expression(const SPIRConstant &c) +{ + if (!c.subconstants.empty()) + { + // Handles Arrays and structures. + string res = "{"; + for (auto &elem : c.subconstants) + { + res += constant_expression(get(elem)); + if (&elem != &c.subconstants.back()) + res += ", "; + } + res += "}"; + return res; + } + else if (c.columns() == 1) + { + return constant_expression_vector(c, 0); + } + else + { + string res = type_to_glsl(get(c.constant_type)) + "("; + for (uint32_t col = 0; col < c.columns(); col++) + { + res += constant_expression_vector(c, col); + if (col + 1 < c.columns()) + res += ", "; + } + res += ")"; + return res; + } +} + +// Returns the type declaration for a function, including the +// entry type if the current function is the entry point function +string CompilerMSL::func_type_decl(SPIRType &type) +{ + auto &execution = get_entry_point(); + // The regular function return type. If not processing the entry point function, that's all we need + string return_type = type_to_glsl(type); + if (!processing_entry_point) + return return_type; + + // If an outgoing interface block has been defined, override the entry point return type + if (stage_out_var_id) + { + auto &so_var = get(stage_out_var_id); + auto &so_type = get(so_var.basetype); + return_type = type_to_glsl(so_type); + } + + // Prepend a entry type, based on the execution model + string entry_type; + switch (execution.model) + { + case ExecutionModelVertex: + entry_type = "vertex"; + break; + case ExecutionModelFragment: + entry_type = (execution.flags & (1ull << ExecutionModeEarlyFragmentTests)) ? + "fragment [[ early_fragment_tests ]]" : + "fragment"; + break; + case ExecutionModelGLCompute: + case ExecutionModelKernel: + entry_type = "kernel"; + break; + default: + entry_type = "unknown"; + break; + } + + return entry_type + " " + return_type; +} + +// In MSL, address space qualifiers are required for all pointer or reference arguments +string CompilerMSL::get_argument_address_space(const SPIRVariable &argument) +{ + const auto &type = get(argument.basetype); + + switch (type.storage) + { + case StorageClassWorkgroup: + return "threadgroup"; + + case StorageClassStorageBuffer: + return "device"; + + case StorageClassUniform: + case StorageClassUniformConstant: + case StorageClassPushConstant: + if (type.basetype == SPIRType::Struct) + return ((meta[type.self].decoration.decoration_flags & (1ull << DecorationBufferBlock)) != 0 && + (meta[argument.self].decoration.decoration_flags & (1ull << DecorationNonWritable)) == 0) ? + "device" : + "constant"; + + break; + + default: + break; + } + + return "thread"; +} + +// Returns a string containing a comma-delimited list of args for the entry point function +string CompilerMSL::entry_point_args(bool append_comma) +{ + string ep_args; + + // Stage-in structure + if (stage_in_var_id) + { + auto &var = get(stage_in_var_id); + auto &type = get(var.basetype); + + if (!ep_args.empty()) + ep_args += ", "; + + ep_args += type_to_glsl(type) + " " + to_name(var.self) + " [[stage_in]]"; + } + + // Non-stage-in vertex attribute structures + for (auto &nsi_var : non_stage_in_input_var_ids) + { + auto &var = get(nsi_var.second); + auto &type = get(var.basetype); + + if (!ep_args.empty()) + ep_args += ", "; + + ep_args += "device " + type_to_glsl(type) + "* " + to_name(var.self) + " [[buffer(" + + convert_to_string(nsi_var.first) + ")]]"; + } + + // Output resources, sorted by resource index & type + // We need to sort to work around a bug on macOS 10.13 with NVidia drivers where switching between shaders + // with different order of buffers can result in issues with buffer assignments inside the driver. + struct Resource + { + Variant *id; + string name; + SPIRType::BaseType basetype; + uint32_t index; + }; + + vector resources; + + for (auto &id : ids) + { + if (id.get_type() == TypeVariable) + { + auto &var = id.get(); + auto &type = get(var.basetype); + + uint32_t var_id = var.self; + + if ((var.storage == StorageClassUniform || var.storage == StorageClassUniformConstant || + var.storage == StorageClassPushConstant || var.storage == StorageClassStorageBuffer) && + !is_hidden_variable(var)) + { + if (type.basetype == SPIRType::SampledImage) + { + resources.push_back( + { &id, to_name(var_id), SPIRType::Image, get_metal_resource_index(var, SPIRType::Image) }); + + if (type.image.dim != DimBuffer) + resources.push_back({ &id, to_sampler_expression(var_id), SPIRType::Sampler, + get_metal_resource_index(var, SPIRType::Sampler) }); + } + else + { + resources.push_back( + { &id, to_name(var_id), type.basetype, get_metal_resource_index(var, type.basetype) }); + } + } + } + } + + std::sort(resources.begin(), resources.end(), [](const Resource &lhs, const Resource &rhs) { + return tie(lhs.basetype, lhs.index) < tie(rhs.basetype, rhs.index); + }); + + for (auto &r : resources) + { + auto &var = r.id->get(); + auto &type = get(var.basetype); + + uint32_t var_id = var.self; + + switch (r.basetype) + { + case SPIRType::Struct: + { + auto &m = meta.at(type.self); + if (m.members.size() == 0) + break; + if (!ep_args.empty()) + ep_args += ", "; + ep_args += get_argument_address_space(var) + " " + type_to_glsl(type) + "& " + r.name; + ep_args += " [[buffer(" + convert_to_string(r.index) + ")]]"; + break; + } + case SPIRType::Sampler: + if (!ep_args.empty()) + ep_args += ", "; + ep_args += "sampler " + r.name; + ep_args += " [[sampler(" + convert_to_string(r.index) + ")]]"; + break; + case SPIRType::Image: + if (!ep_args.empty()) + ep_args += ", "; + ep_args += type_to_glsl(type, var_id) + " " + r.name; + ep_args += " [[texture(" + convert_to_string(r.index) + ")]]"; + break; + default: + SPIRV_CROSS_THROW("Unexpected resource type"); + break; + } + } + + // Builtin variables + for (auto &id : ids) + { + if (id.get_type() == TypeVariable) + { + auto &var = id.get(); + + uint32_t var_id = var.self; + + if (var.storage == StorageClassInput && is_builtin_variable(var)) + { + if (!ep_args.empty()) + ep_args += ", "; + + BuiltIn bi_type = meta[var_id].decoration.builtin_type; + ep_args += builtin_type_decl(bi_type) + " " + to_expression(var_id); + ep_args += " [[" + builtin_qualifier(bi_type) + "]]"; + } + } + } + + // Vertex and instance index built-ins + if (needs_vertex_idx_arg) + ep_args += built_in_func_arg(BuiltInVertexIndex, !ep_args.empty()); + + if (needs_instance_idx_arg) + ep_args += built_in_func_arg(BuiltInInstanceIndex, !ep_args.empty()); + + if (!ep_args.empty() && append_comma) + ep_args += ", "; + + return ep_args; +} + +// Returns the Metal index of the resource of the specified type as used by the specified variable. +uint32_t CompilerMSL::get_metal_resource_index(SPIRVariable &var, SPIRType::BaseType basetype) +{ + auto &execution = get_entry_point(); + auto &var_dec = meta[var.self].decoration; + uint32_t var_desc_set = (var.storage == StorageClassPushConstant) ? kPushConstDescSet : var_dec.set; + uint32_t var_binding = (var.storage == StorageClassPushConstant) ? kPushConstBinding : var_dec.binding; + + // If a matching binding has been specified, find and use it + for (auto p_res_bind : resource_bindings) + { + if (p_res_bind->stage == execution.model && p_res_bind->desc_set == var_desc_set && + p_res_bind->binding == var_binding) + { + + p_res_bind->used_by_shader = true; + switch (basetype) + { + case SPIRType::Struct: + return p_res_bind->msl_buffer; + case SPIRType::Image: + return p_res_bind->msl_texture; + case SPIRType::Sampler: + return p_res_bind->msl_sampler; + default: + return 0; + } + } + } + + // If a binding has not been specified, revert to incrementing resource indices + switch (basetype) + { + case SPIRType::Struct: + return next_metal_resource_index.msl_buffer++; + case SPIRType::Image: + return next_metal_resource_index.msl_texture++; + case SPIRType::Sampler: + return next_metal_resource_index.msl_sampler++; + default: + return 0; + } +} + +// Returns the name of the entry point of this shader +string CompilerMSL::get_entry_point_name() +{ + return to_name(entry_point); +} + +string CompilerMSL::argument_decl(const SPIRFunction::Parameter &arg) +{ + auto &var = get(arg.id); + auto &type = expression_type(arg.id); + bool constref = !arg.alias_global_variable && (!type.pointer || arg.write_count == 0); + + // TODO: Check if this arg is an uniform pointer + bool pointer = type.storage == StorageClassUniformConstant; + + string decl; + if (constref) + decl += "const "; + + if (is_builtin_variable(var)) + decl += builtin_type_decl(static_cast(get_decoration(arg.id, DecorationBuiltIn))); + else + decl += type_to_glsl(type, arg.id); + + if (is_array(type)) + { + decl += " (&"; + decl += to_name(var.self); + decl += ")"; + decl += type_to_array_glsl(type); + } + else if (!pointer) + { + decl += "&"; + decl += " "; + decl += to_name(var.self); + } + else + { + decl += " "; + decl += to_name(var.self); + } + + return decl; +} + +// If we're currently in the entry point function, and the object +// has a qualified name, use it, otherwise use the standard name. +string CompilerMSL::to_name(uint32_t id, bool allow_alias) const +{ + if (current_function && (current_function->self == entry_point)) + { + string qual_name = meta.at(id).decoration.qualified_alias; + if (!qual_name.empty()) + return qual_name; + } + return Compiler::to_name(id, allow_alias); +} + +// Returns a name that combines the name of the struct with the name of the member, except for Builtins +string CompilerMSL::to_qualified_member_name(const SPIRType &type, uint32_t index) +{ + // Don't qualify Builtin names because they are unique and are treated as such when building expressions + BuiltIn builtin; + if (is_member_builtin(type, index, &builtin)) + return builtin_to_glsl(builtin, type.storage); + + // Strip any underscore prefix from member name + string mbr_name = to_member_name(type, index); + size_t startPos = mbr_name.find_first_not_of("_"); + mbr_name = (startPos != string::npos) ? mbr_name.substr(startPos) : ""; + return join(to_name(type.self), "_", mbr_name); +} + +// Ensures that the specified name is permanently usable by prepending a prefix +// if the first chars are _ and a digit, which indicate a transient name. +string CompilerMSL::ensure_valid_name(string name, string pfx) +{ + return (name.size() >= 2 && name[0] == '_' && isdigit(name[1])) ? (pfx + name) : name; +} + +// Replace all names that match MSL keywords or Metal Standard Library functions. +void CompilerMSL::replace_illegal_names() +{ + static const unordered_set keywords = { + "kernel", + "bias", + }; + + static const unordered_set illegal_func_names = { + "main", + "saturate", + }; + + for (auto &id : ids) + { + switch (id.get_type()) + { + case TypeVariable: + { + auto &dec = meta[id.get_id()].decoration; + if (keywords.find(dec.alias) != end(keywords)) + dec.alias += "0"; + + break; + } + + case TypeFunction: + { + auto &dec = meta[id.get_id()].decoration; + if (illegal_func_names.find(dec.alias) != end(illegal_func_names)) + dec.alias += "0"; + + break; + } + + case TypeType: + { + for (auto &mbr_dec : meta[id.get_id()].members) + if (keywords.find(mbr_dec.alias) != end(keywords)) + mbr_dec.alias += "0"; + + break; + } + + default: + break; + } + } + + for (auto &entry : entry_points) + { + // Change both the entry point name and the alias, to keep them synced. + string &ep_name = entry.second.name; + if (illegal_func_names.find(ep_name) != end(illegal_func_names)) + ep_name += "0"; + + // Always write this because entry point might have been renamed earlier. + meta[entry.first].decoration.alias = ep_name; + } +} + +string CompilerMSL::to_qualifiers_glsl(uint32_t id) +{ + string quals; + + auto &type = expression_type(id); + if (type.storage == StorageClassWorkgroup) + quals += "threadgroup "; + + return quals; +} + +// The optional id parameter indicates the object whose type we are trying +// to find the description for. It is optional. Most type descriptions do not +// depend on a specific object's use of that type. +string CompilerMSL::type_to_glsl(const SPIRType &type, uint32_t id) +{ + // Ignore the pointer type since GLSL doesn't have pointers. + + string type_name; + + switch (type.basetype) + { + case SPIRType::Struct: + // Need OpName lookup here to get a "sensible" name for a struct. + return to_name(type.self); + + case SPIRType::Image: + case SPIRType::SampledImage: + return image_type_glsl(type, id); + + case SPIRType::Sampler: + return "sampler"; + + case SPIRType::Void: + return "void"; + + case SPIRType::AtomicCounter: + return "atomic_uint"; + + // Scalars + case SPIRType::Boolean: + type_name = "bool"; + break; + case SPIRType::Char: + type_name = "char"; + break; + case SPIRType::Int: + type_name = (type.width == 16 ? "short" : "int"); + break; + case SPIRType::UInt: + type_name = (type.width == 16 ? "ushort" : "uint"); + break; + case SPIRType::Int64: + type_name = "long"; // Currently unsupported + break; + case SPIRType::UInt64: + type_name = "size_t"; + break; + case SPIRType::Float: + type_name = (type.width == 16 ? "half" : "float"); + break; + case SPIRType::Double: + type_name = "double"; // Currently unsupported + break; + + default: + return "unknown_type"; + } + + // Matrix? + if (type.columns > 1) + type_name += to_string(type.columns) + "x"; + + // Vector or Matrix? + if (type.vecsize > 1) + type_name += to_string(type.vecsize); + + return type_name; +} + +// Returns an MSL string describing the SPIR-V image type +string CompilerMSL::image_type_glsl(const SPIRType &type, uint32_t id) +{ + string img_type_name; + + // Bypass pointers because we need the real image struct + auto &img_type = get(type.self).image; + + if (img_type.depth) + { + switch (img_type.dim) + { + case Dim1D: + img_type_name += "depth1d_unsupported_by_metal"; + break; + case Dim2D: + img_type_name += (img_type.ms ? "depth2d_ms" : (img_type.arrayed ? "depth2d_array" : "depth2d")); + break; + case Dim3D: + img_type_name += "depth3d_unsupported_by_metal"; + break; + case DimCube: + img_type_name += (img_type.arrayed ? "depthcube_array" : "depthcube"); + break; + default: + img_type_name += "unknown_depth_texture_type"; + break; + } + } + else + { + switch (img_type.dim) + { + case Dim1D: + img_type_name += (img_type.arrayed ? "texture1d_array" : "texture1d"); + break; + case DimBuffer: + case Dim2D: + img_type_name += (img_type.ms ? "texture2d_ms" : (img_type.arrayed ? "texture2d_array" : "texture2d")); + break; + case Dim3D: + img_type_name += "texture3d"; + break; + case DimCube: + img_type_name += (img_type.arrayed ? "texturecube_array" : "texturecube"); + break; + default: + img_type_name += "unknown_texture_type"; + break; + } + } + + // Append the pixel type + img_type_name += "<"; + img_type_name += type_to_glsl(get(img_type.type)); + + // For unsampled images, append the sample/read/write access qualifier. + // For kernel images, the access qualifier my be supplied directly by SPIR-V. + // Otherwise it may be set based on whether the image is read from or written to within the shader. + if (type.basetype == SPIRType::Image && type.image.sampled == 2) + { + switch (img_type.access) + { + case AccessQualifierReadOnly: + img_type_name += ", access::read"; + break; + + case AccessQualifierWriteOnly: + img_type_name += ", access::write"; + break; + + case AccessQualifierReadWrite: + img_type_name += ", access::read_write"; + break; + + default: + { + auto *p_var = maybe_get_backing_variable(id); + if (p_var && p_var->basevariable) + p_var = maybe_get(p_var->basevariable); + if (p_var && !has_decoration(p_var->self, DecorationNonWritable)) + { + img_type_name += ", access::"; + + if (!has_decoration(p_var->self, DecorationNonReadable)) + img_type_name += "read_"; + + img_type_name += "write"; + } + break; + } + } + } + + img_type_name += ">"; + + return img_type_name; +} + +string CompilerMSL::bitcast_glsl_op(const SPIRType &out_type, const SPIRType &in_type) +{ + if ((out_type.basetype == SPIRType::UInt && in_type.basetype == SPIRType::Int) || + (out_type.basetype == SPIRType::Int && in_type.basetype == SPIRType::UInt) || + (out_type.basetype == SPIRType::UInt64 && in_type.basetype == SPIRType::Int64) || + (out_type.basetype == SPIRType::Int64 && in_type.basetype == SPIRType::UInt64)) + return type_to_glsl(out_type); + + if ((out_type.basetype == SPIRType::UInt && in_type.basetype == SPIRType::Float) || + (out_type.basetype == SPIRType::Int && in_type.basetype == SPIRType::Float) || + (out_type.basetype == SPIRType::Float && in_type.basetype == SPIRType::UInt) || + (out_type.basetype == SPIRType::Float && in_type.basetype == SPIRType::Int) || + (out_type.basetype == SPIRType::Int64 && in_type.basetype == SPIRType::Double) || + (out_type.basetype == SPIRType::UInt64 && in_type.basetype == SPIRType::Double) || + (out_type.basetype == SPIRType::Double && in_type.basetype == SPIRType::Int64) || + (out_type.basetype == SPIRType::Double && in_type.basetype == SPIRType::UInt64)) + return "as_type<" + type_to_glsl(out_type) + ">"; + + return ""; +} + +// Returns an MSL string identifying the name of a SPIR-V builtin. +// Output builtins are qualified with the name of the stage out structure. +string CompilerMSL::builtin_to_glsl(BuiltIn builtin, StorageClass storage) +{ + switch (builtin) + { + + // Override GLSL compiler strictness + case BuiltInVertexId: + return "gl_VertexID"; + case BuiltInInstanceId: + return "gl_InstanceID"; + case BuiltInVertexIndex: + return "gl_VertexIndex"; + case BuiltInInstanceIndex: + return "gl_InstanceIndex"; + + // When used in the entry function, output builtins are qualified with output struct name. + case BuiltInPosition: + case BuiltInPointSize: + case BuiltInClipDistance: + case BuiltInCullDistance: + case BuiltInLayer: + case BuiltInFragDepth: + if (current_function && (current_function->self == entry_point)) + return stage_out_var_name + "." + CompilerGLSL::builtin_to_glsl(builtin, storage); + else + return CompilerGLSL::builtin_to_glsl(builtin, storage); + + default: + return CompilerGLSL::builtin_to_glsl(builtin, storage); + } +} + +// Returns an MSL string attribute qualifer for a SPIR-V builtin +string CompilerMSL::builtin_qualifier(BuiltIn builtin) +{ + auto &execution = get_entry_point(); + + switch (builtin) + { + // Vertex function in + case BuiltInVertexId: + return "vertex_id"; + case BuiltInVertexIndex: + return "vertex_id"; + case BuiltInInstanceId: + return "instance_id"; + case BuiltInInstanceIndex: + return "instance_id"; + + // Vertex function out + case BuiltInClipDistance: + return "clip_distance"; + case BuiltInPointSize: + return "point_size"; + case BuiltInPosition: + return "position"; + case BuiltInLayer: + return "render_target_array_index"; + + // Fragment function in + case BuiltInFrontFacing: + return "front_facing"; + case BuiltInPointCoord: + return "point_coord"; + case BuiltInFragCoord: + return "position"; + case BuiltInSampleId: + return "sample_id"; + case BuiltInSampleMask: + return "sample_mask"; + + // Fragment function out + case BuiltInFragDepth: + if (execution.flags & (1ull << ExecutionModeDepthGreater)) + return "depth(greater)"; + else if (execution.flags & (1ull << ExecutionModeDepthLess)) + return "depth(less)"; + else + return "depth(any)"; + + // Compute function in + case BuiltInGlobalInvocationId: + return "thread_position_in_grid"; + + case BuiltInWorkgroupId: + return "threadgroup_position_in_grid"; + + case BuiltInNumWorkgroups: + return "threadgroups_per_grid"; + + case BuiltInLocalInvocationId: + return "thread_position_in_threadgroup"; + + case BuiltInLocalInvocationIndex: + return "thread_index_in_threadgroup"; + + default: + return "unsupported-built-in"; + } +} + +// Returns an MSL string type declaration for a SPIR-V builtin +string CompilerMSL::builtin_type_decl(BuiltIn builtin) +{ + switch (builtin) + { + // Vertex function in + case BuiltInVertexId: + return "uint"; + case BuiltInVertexIndex: + return "uint"; + case BuiltInInstanceId: + return "uint"; + case BuiltInInstanceIndex: + return "uint"; + + // Vertex function out + case BuiltInClipDistance: + return "float"; + case BuiltInPointSize: + return "float"; + case BuiltInPosition: + return "float4"; + case BuiltInLayer: + return "uint"; + + // Fragment function in + case BuiltInFrontFacing: + return "bool"; + case BuiltInPointCoord: + return "float2"; + case BuiltInFragCoord: + return "float4"; + case BuiltInSampleId: + return "uint"; + case BuiltInSampleMask: + return "uint"; + + // Compute function in + case BuiltInGlobalInvocationId: + case BuiltInLocalInvocationId: + case BuiltInNumWorkgroups: + case BuiltInWorkgroupId: + return "uint3"; + case BuiltInLocalInvocationIndex: + return "uint"; + + default: + return "unsupported-built-in-type"; + } +} + +// Returns the declaration of a built-in argument to a function +string CompilerMSL::built_in_func_arg(BuiltIn builtin, bool prefix_comma) +{ + string bi_arg; + if (prefix_comma) + bi_arg += ", "; + + bi_arg += builtin_type_decl(builtin); + bi_arg += " " + builtin_to_glsl(builtin, StorageClassInput); + bi_arg += " [[" + builtin_qualifier(builtin) + "]]"; + + return bi_arg; +} + +// Returns the byte size of a struct member. +size_t CompilerMSL::get_declared_struct_member_size(const SPIRType &struct_type, uint32_t index) const +{ + auto dec_mask = get_member_decoration_mask(struct_type.self, index); + auto &type = get(struct_type.member_types[index]); + + switch (type.basetype) + { + case SPIRType::Unknown: + case SPIRType::Void: + case SPIRType::AtomicCounter: + case SPIRType::Image: + case SPIRType::SampledImage: + case SPIRType::Sampler: + SPIRV_CROSS_THROW("Querying size of opaque object."); + + default: + { + size_t component_size = type.width / 8; + unsigned vecsize = type.vecsize; + unsigned columns = type.columns; + + // For arrays, we can use ArrayStride to get an easy check. + // Runtime arrays will have zero size so force to min of one. + if (!type.array.empty()) + return type_struct_member_array_stride(struct_type, index) * max(type.array.back(), 1U); + + if (type.basetype == SPIRType::Struct) + return get_declared_struct_size(type); + + if (columns == 1) // An unpacked 3-element vector is the same size as a 4-element vector. + { + if (!(dec_mask & (1ull << DecorationCPacked))) + { + if (vecsize == 3) + vecsize = 4; + } + } + else // For matrices, a 3-element column is the same size as a 4-element column. + { + if (dec_mask & (1ull << DecorationColMajor)) + { + if (vecsize == 3) + vecsize = 4; + } + else if (dec_mask & (1ull << DecorationRowMajor)) + { + if (columns == 3) + columns = 4; + } + } + + return vecsize * columns * component_size; + } + } +} + +// Returns the byte alignment of a struct member. +size_t CompilerMSL::get_declared_struct_member_alignment(const SPIRType &struct_type, uint32_t index) const +{ + auto &type = get(struct_type.member_types[index]); + + switch (type.basetype) + { + case SPIRType::Unknown: + case SPIRType::Void: + case SPIRType::AtomicCounter: + case SPIRType::Image: + case SPIRType::SampledImage: + case SPIRType::Sampler: + SPIRV_CROSS_THROW("Querying alignment of opaque object."); + + case SPIRType::Struct: + return 16; // Per Vulkan spec section 14.5.4 + + default: + { + // Alignment of packed type is the same as the underlying component size. + // Alignment of unpacked type is the same as the type size (or one matrix column). + if (member_is_packed_type(struct_type, index)) + return type.width / 8; + else + { + // Divide by array size and colum count. Runtime arrays will have zero size so force to min of one. + uint32_t array_size = type.array.empty() ? 1 : max(type.array.back(), 1U); + return get_declared_struct_member_size(struct_type, index) / (type.columns * array_size); + } + } + } +} + +bool CompilerMSL::skip_argument(uint32_t) const +{ + return false; +} + +bool CompilerMSL::OpCodePreprocessor::handle(Op opcode, const uint32_t *args, uint32_t length) +{ + // Since MSL exists in a single execution scope, function prototype declarations are not + // needed, and clutter the output. If secondary functions are output (either as a SPIR-V + // function implementation or as indicated by the presence of OpFunctionCall), then set + // suppress_missing_prototypes to suppress compiler warnings of missing function prototypes. + + // Mark if the input requires the implementation of an SPIR-V function that does not exist in Metal. + SPVFuncImpl spv_func = get_spv_func_impl(opcode, args); + if (spv_func != SPVFuncImplNone) + { + compiler.spv_function_implementations.insert(spv_func); + suppress_missing_prototypes = true; + } + + switch (opcode) + { + + case OpFunctionCall: + suppress_missing_prototypes = true; + break; + + case OpAtomicExchange: + case OpAtomicCompareExchange: + case OpAtomicCompareExchangeWeak: + case OpAtomicLoad: + case OpAtomicIIncrement: + case OpAtomicIDecrement: + case OpAtomicIAdd: + case OpAtomicISub: + case OpAtomicSMin: + case OpAtomicUMin: + case OpAtomicSMax: + case OpAtomicUMax: + case OpAtomicAnd: + case OpAtomicOr: + case OpAtomicXor: + uses_atomics = true; + break; + + default: + break; + } + + // If it has one, keep track of the instruction's result type, mapped by ID + uint32_t result_type, result_id; + if (compiler.instruction_to_result_type(result_type, result_id, opcode, args, length)) + result_types[result_id] = result_type; + + return true; +} + +// Returns an enumeration of a SPIR-V function that needs to be output for certain Op codes. +CompilerMSL::SPVFuncImpl CompilerMSL::OpCodePreprocessor::get_spv_func_impl(Op opcode, const uint32_t *args) +{ + switch (opcode) + { + case OpFMod: + return SPVFuncImplMod; + + case OpStore: + { + // Get the result type of the RHS. Since this is run as a pre-processing stage, + // we must extract the result type directly from the Instruction, rather than the ID. + uint32_t id_rhs = args[1]; + uint32_t type_id_rhs = result_types[id_rhs]; + if ((compiler.ids[id_rhs].get_type() != TypeConstant) && type_id_rhs && + compiler.is_array(compiler.get(type_id_rhs))) + return SPVFuncImplArrayCopy; + + break; + } + + case OpExtInst: + { + uint32_t extension_set = args[2]; + if (compiler.get(extension_set).ext == SPIRExtension::GLSL) + { + GLSLstd450 op_450 = static_cast(args[3]); + switch (op_450) + { + case GLSLstd450Radians: + return SPVFuncImplRadians; + case GLSLstd450Degrees: + return SPVFuncImplDegrees; + case GLSLstd450FindILsb: + return SPVFuncImplFindILsb; + case GLSLstd450FindSMsb: + return SPVFuncImplFindSMsb; + case GLSLstd450FindUMsb: + return SPVFuncImplFindUMsb; + case GLSLstd450MatrixInverse: + { + auto &mat_type = compiler.get(args[0]); + switch (mat_type.columns) + { + case 2: + return SPVFuncImplInverse2x2; + case 3: + return SPVFuncImplInverse3x3; + case 4: + return SPVFuncImplInverse4x4; + default: + break; + } + break; + } + default: + break; + } + } + break; + } + + default: + break; + } + return SPVFuncImplNone; +} + +// Sort both type and meta member content based on builtin status (put builtins at end), +// then by the required sorting aspect. +void CompilerMSL::MemberSorter::sort() +{ + // Create a temporary array of consecutive member indices and sort it based on how + // the members should be reordered, based on builtin and sorting aspect meta info. + size_t mbr_cnt = type.member_types.size(); + vector mbr_idxs(mbr_cnt); + iota(mbr_idxs.begin(), mbr_idxs.end(), 0); // Fill with consecutive indices + std::sort(mbr_idxs.begin(), mbr_idxs.end(), *this); // Sort member indices based on sorting aspect + + // Move type and meta member info to the order defined by the sorted member indices. + // This is done by creating temporary copies of both member types and meta, and then + // copying back to the original content at the sorted indices. + auto mbr_types_cpy = type.member_types; + auto mbr_meta_cpy = meta.members; + for (uint32_t mbr_idx = 0; mbr_idx < mbr_cnt; mbr_idx++) + { + type.member_types[mbr_idx] = mbr_types_cpy[mbr_idxs[mbr_idx]]; + meta.members[mbr_idx] = mbr_meta_cpy[mbr_idxs[mbr_idx]]; + } +} + +// Sort first by builtin status (put builtins at end), then by the sorting aspect. +bool CompilerMSL::MemberSorter::operator()(uint32_t mbr_idx1, uint32_t mbr_idx2) +{ + auto &mbr_meta1 = meta.members[mbr_idx1]; + auto &mbr_meta2 = meta.members[mbr_idx2]; + if (mbr_meta1.builtin != mbr_meta2.builtin) + return mbr_meta2.builtin; + else + switch (sort_aspect) + { + case Location: + return mbr_meta1.location < mbr_meta2.location; + case LocationReverse: + return mbr_meta1.location > mbr_meta2.location; + case Offset: + return mbr_meta1.offset < mbr_meta2.offset; + case OffsetThenLocationReverse: + return (mbr_meta1.offset < mbr_meta2.offset) || + ((mbr_meta1.offset == mbr_meta2.offset) && (mbr_meta1.location > mbr_meta2.location)); + case Alphabetical: + return mbr_meta1.alias < mbr_meta2.alias; + default: + return false; + } +} + +CompilerMSL::MemberSorter::MemberSorter(SPIRType &t, Meta &m, SortAspect sa) + : type(t) + , meta(m) + , sort_aspect(sa) +{ + // Ensure enough meta info is available + meta.members.resize(max(type.member_types.size(), meta.members.size())); +} diff --git a/spirv_msl.hpp b/spirv_msl.hpp new file mode 100644 index 0000000000..6f66f3122e --- /dev/null +++ b/spirv_msl.hpp @@ -0,0 +1,331 @@ +/* + * Copyright 2016-2018 The Brenwill Workshop Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SPIRV_CROSS_MSL_HPP +#define SPIRV_CROSS_MSL_HPP + +#include "spirv_glsl.hpp" +#include +#include +#include +#include +#include +#include + +namespace spirv_cross +{ + +// Defines MSL characteristics of a vertex attribute at a particular location. +// The used_by_shader flag is set to true during compilation of SPIR-V to MSL +// if the shader makes use of this vertex attribute. +struct MSLVertexAttr +{ + uint32_t location = 0; + uint32_t msl_buffer = 0; + uint32_t msl_offset = 0; + uint32_t msl_stride = 0; + bool per_instance = false; + bool used_by_shader = false; +}; + +// Matches the binding index of a MSL resource for a binding within a descriptor set. +// Taken together, the stage, desc_set and binding combine to form a reference to a resource +// descriptor used in a particular shading stage. Generally, only one of the buffer, texture, +// or sampler elements will be populated. The used_by_shader flag is set to true during +// compilation of SPIR-V to MSL if the shader makes use of this vertex attribute. +struct MSLResourceBinding +{ + spv::ExecutionModel stage; + uint32_t desc_set = 0; + uint32_t binding = 0; + + uint32_t msl_buffer = 0; + uint32_t msl_texture = 0; + uint32_t msl_sampler = 0; + + bool used_by_shader = false; +}; + +// Tracks the type ID and member index of a struct member +using MSLStructMemberKey = uint64_t; + +// Special constant used in a MSLResourceBinding desc_set +// element to indicate the bindings for the push constants. +static const uint32_t kPushConstDescSet = std::numeric_limits::max(); + +// Special constant used in a MSLResourceBinding binding +// element to indicate the bindings for the push constants. +static const uint32_t kPushConstBinding = 0; + +// Decompiles SPIR-V to Metal Shading Language +class CompilerMSL : public CompilerGLSL +{ +public: + // Options for compiling to Metal Shading Language + struct Options + { + typedef enum { + iOS, + macOS, + } Platform; + + Platform platform = macOS; + uint32_t msl_version = make_msl_version(1, 2); + bool enable_point_size_builtin = true; + bool resolve_specialized_array_lengths = true; + + bool is_ios() + { + return platform == iOS; + } + + bool is_macos() + { + return platform == macOS; + } + + void set_msl_version(uint32_t major, uint32_t minor = 0, uint32_t patch = 0) + { + msl_version = make_msl_version(major, minor, patch); + } + + bool supports_msl_version(uint32_t major, uint32_t minor = 0, uint32_t patch = 0) + { + return msl_version >= make_msl_version(major, minor, patch); + } + + static uint32_t make_msl_version(uint32_t major, uint32_t minor = 0, uint32_t patch = 0) + { + return (major * 10000) + (minor * 100) + patch; + } + }; + + const Options &get_options() const + { + return options; + } + + void set_options(Options &opts) + { + options = opts; + } + + // An enum of SPIR-V functions that are implemented in additional + // source code that is added to the shader if necessary. + enum SPVFuncImpl + { + SPVFuncImplNone, + SPVFuncImplMod, + SPVFuncImplRadians, + SPVFuncImplDegrees, + SPVFuncImplFindILsb, + SPVFuncImplFindSMsb, + SPVFuncImplFindUMsb, + SPVFuncImplArrayCopy, + SPVFuncImplInverse2x2, + SPVFuncImplInverse3x3, + SPVFuncImplInverse4x4, + SPVFuncImplRowMajor2x3, + SPVFuncImplRowMajor2x4, + SPVFuncImplRowMajor3x2, + SPVFuncImplRowMajor3x4, + SPVFuncImplRowMajor4x2, + SPVFuncImplRowMajor4x3, + }; + + // Constructs an instance to compile the SPIR-V code into Metal Shading Language, + // using the configuration parameters, if provided: + // - p_vtx_attrs is an optional list of vertex attribute bindings used to match + // vertex content locations to MSL attributes. If vertex attributes are provided, + // the compiler will set the used_by_shader flag to true in any vertex attribute + // actually used by the MSL code. + // - p_res_bindings is a list of resource bindings to indicate the MSL buffer, + // texture or sampler index to use for a particular SPIR-V description set + // and binding. If resource bindings are provided, the compiler will set the + // used_by_shader flag to true in any resource binding actually used by the MSL code. + CompilerMSL(std::vector spirv, std::vector *p_vtx_attrs = nullptr, + std::vector *p_res_bindings = nullptr); + + // Alternate constructor avoiding use of std::vectors. + CompilerMSL(const uint32_t *ir, size_t word_count, MSLVertexAttr *p_vtx_attrs = nullptr, size_t vtx_attrs_count = 0, + MSLResourceBinding *p_res_bindings = nullptr, size_t res_bindings_count = 0); + + // Compiles the SPIR-V code into Metal Shading Language. + std::string compile() override; + + // Compiles the SPIR-V code into Metal Shading Language, overriding configuration parameters. + // Any of the parameters here may be null to indicate that the configuration provided in the + // constructor should be used. They are not declared as optional to avoid a conflict with the + // inherited and overridden zero-parameter compile() function. + std::string compile(std::vector *p_vtx_attrs, std::vector *p_res_bindings); + + // This legacy method is deprecated. + typedef Options MSLConfiguration; + SPIRV_CROSS_DEPRECATED("Please use get_options() and set_options() instead.") + std::string compile(MSLConfiguration &msl_cfg, std::vector *p_vtx_attrs = nullptr, + std::vector *p_res_bindings = nullptr); + +protected: + void emit_instruction(const Instruction &instr) override; + void emit_glsl_op(uint32_t result_type, uint32_t result_id, uint32_t op, const uint32_t *args, + uint32_t count) override; + void emit_header() override; + void emit_function_prototype(SPIRFunction &func, uint64_t return_flags) override; + void emit_sampled_image_op(uint32_t result_type, uint32_t result_id, uint32_t image_id, uint32_t samp_id) override; + void emit_fixup() override; + void emit_struct_member(const SPIRType &type, uint32_t member_type_id, uint32_t index, + const std::string &qualifier = "") override; + std::string type_to_glsl(const SPIRType &type, uint32_t id = 0) override; + std::string image_type_glsl(const SPIRType &type, uint32_t id = 0) override; + std::string builtin_to_glsl(spv::BuiltIn builtin, spv::StorageClass storage) override; + std::string constant_expression(const SPIRConstant &c) override; + size_t get_declared_struct_member_size(const SPIRType &struct_type, uint32_t index) const override; + std::string to_func_call_arg(uint32_t id) override; + std::string to_name(uint32_t id, bool allow_alias = true) const override; + std::string to_function_name(uint32_t img, const SPIRType &imgtype, bool is_fetch, bool is_gather, bool is_proj, + bool has_array_offsets, bool has_offset, bool has_grad, bool has_dref, + uint32_t lod) override; + std::string to_function_args(uint32_t img, const SPIRType &imgtype, bool is_fetch, bool is_gather, bool is_proj, + uint32_t coord, uint32_t coord_components, uint32_t dref, uint32_t grad_x, + uint32_t grad_y, uint32_t lod, uint32_t coffset, uint32_t offset, uint32_t bias, + uint32_t comp, uint32_t sample, bool *p_forward) override; + std::string unpack_expression_type(std::string expr_str, const SPIRType &type) override; + std::string bitcast_glsl_op(const SPIRType &result_type, const SPIRType &argument_type) override; + bool skip_argument(uint32_t id) const override; + std::string to_qualifiers_glsl(uint32_t id) override; + void replace_illegal_names() override; + void declare_undefined_values() override; + bool is_non_native_row_major_matrix(uint32_t id) override; + bool member_is_non_native_row_major_matrix(const SPIRType &type, uint32_t index) override; + std::string convert_row_major_matrix(std::string exp_str, const SPIRType &exp_type) override; + + void preprocess_op_codes(); + void localize_global_variables(); + void extract_global_variables_from_functions(); + void resolve_specialized_array_lengths(); + void mark_packable_structs(); + void mark_as_packable(SPIRType &type); + + std::unordered_map> function_global_vars; + void extract_global_variables_from_function(uint32_t func_id, std::set &added_arg_ids, + std::unordered_set &global_var_ids, + std::unordered_set &processed_func_ids); + uint32_t add_interface_block(spv::StorageClass storage); + void mark_location_as_used_by_shader(uint32_t location, spv::StorageClass storage); + + void emit_custom_functions(); + void emit_resources(); + void emit_specialization_constants(); + void emit_interface_block(uint32_t ib_var_id); + bool maybe_emit_input_struct_assignment(uint32_t id_lhs, uint32_t id_rhs); + bool maybe_emit_array_assignment(uint32_t id_lhs, uint32_t id_rhs); + void add_convert_row_major_matrix_function(uint32_t cols, uint32_t rows); + + std::string func_type_decl(SPIRType &type); + std::string entry_point_args(bool append_comma); + std::string get_entry_point_name(); + std::string to_qualified_member_name(const SPIRType &type, uint32_t index); + std::string ensure_valid_name(std::string name, std::string pfx); + std::string to_sampler_expression(uint32_t id); + std::string builtin_qualifier(spv::BuiltIn builtin); + std::string builtin_type_decl(spv::BuiltIn builtin); + std::string built_in_func_arg(spv::BuiltIn builtin, bool prefix_comma); + std::string member_attribute_qualifier(const SPIRType &type, uint32_t index); + std::string argument_decl(const SPIRFunction::Parameter &arg); + std::string round_fp_tex_coords(std::string tex_coords, bool coord_is_fp); + uint32_t get_metal_resource_index(SPIRVariable &var, SPIRType::BaseType basetype); + uint32_t get_ordered_member_location(uint32_t type_id, uint32_t index); + size_t get_declared_struct_member_alignment(const SPIRType &struct_type, uint32_t index) const; + std::string to_component_argument(uint32_t id); + bool should_move_to_input_buffer(SPIRType &type, bool is_builtin, spv::StorageClass storage); + void move_to_input_buffer(SPIRVariable &var); + void move_member_to_input_buffer(const SPIRType &type, uint32_t index); + std::string add_input_buffer_block_member(uint32_t mbr_type_id, std::string mbr_name, uint32_t mbr_locn); + uint32_t get_input_buffer_block_var_id(uint32_t msl_buffer); + void align_struct(SPIRType &ib_type); + bool is_member_packable(SPIRType &ib_type, uint32_t index); + MSLStructMemberKey get_struct_member_key(uint32_t type_id, uint32_t index); + std::string get_argument_address_space(const SPIRVariable &argument); + void emit_atomic_func_op(uint32_t result_type, uint32_t result_id, const char *op, uint32_t mem_order_1, + uint32_t mem_order_2, bool has_mem_order_2, uint32_t op0, uint32_t op1 = 0, + bool op1_is_pointer = false, uint32_t op2 = 0); + const char *get_memory_order(uint32_t spv_mem_sem); + void add_pragma_line(const std::string &line); + void emit_barrier(uint32_t id_exe_scope, uint32_t id_mem_scope, uint32_t id_mem_sem); + + Options options; + std::set spv_function_implementations; + std::unordered_map vtx_attrs_by_location; + std::map non_stage_in_input_var_ids; + std::unordered_map struct_member_padding; + std::set pragma_lines; + std::vector resource_bindings; + MSLResourceBinding next_metal_resource_index; + uint32_t stage_in_var_id = 0; + uint32_t stage_out_var_id = 0; + uint32_t stage_uniforms_var_id = 0; + bool needs_vertex_idx_arg = false; + bool needs_instance_idx_arg = false; + std::string qual_pos_var_name; + std::string stage_in_var_name = "in"; + std::string stage_out_var_name = "out"; + std::string stage_uniform_var_name = "uniforms"; + std::string sampler_name_suffix = "Smplr"; + spv::Op previous_instruction_opcode = spv::OpNop; + + // OpcodeHandler that handles several MSL preprocessing operations. + struct OpCodePreprocessor : OpcodeHandler + { + OpCodePreprocessor(CompilerMSL &compiler_) + : compiler(compiler_) + { + } + + bool handle(spv::Op opcode, const uint32_t *args, uint32_t length) override; + CompilerMSL::SPVFuncImpl get_spv_func_impl(spv::Op opcode, const uint32_t *args); + + CompilerMSL &compiler; + std::unordered_map result_types; + bool suppress_missing_prototypes = false; + bool uses_atomics = false; + }; + + // Sorts the members of a SPIRType and associated Meta info based on a settable sorting + // aspect, which defines which aspect of the struct members will be used to sort them. + // Regardless of the sorting aspect, built-in members always appear at the end of the struct. + struct MemberSorter + { + enum SortAspect + { + Location, + LocationReverse, + Offset, + OffsetThenLocationReverse, + Alphabetical + }; + + void sort(); + bool operator()(uint32_t mbr_idx1, uint32_t mbr_idx2); + MemberSorter(SPIRType &t, Meta &m, SortAspect sa); + + SPIRType &type; + Meta &meta; + SortAspect sort_aspect; + }; +}; +} + +#endif diff --git a/test_shaders.py b/test_shaders.py new file mode 100755 index 0000000000..1ca8f9af5f --- /dev/null +++ b/test_shaders.py @@ -0,0 +1,451 @@ +#!/usr/bin/env python3 + +import sys +import os +import os.path +import subprocess +import tempfile +import re +import itertools +import hashlib +import shutil +import argparse +import codecs + +force_no_external_validation = False + +def parse_stats(stats): + m = re.search('([0-9]+) work registers', stats) + registers = int(m.group(1)) if m else 0 + + m = re.search('([0-9]+) uniform registers', stats) + uniform_regs = int(m.group(1)) if m else 0 + + m_list = re.findall('(-?[0-9]+)\s+(-?[0-9]+)\s+(-?[0-9]+)', stats) + alu_short = float(m_list[1][0]) if m_list else 0 + ls_short = float(m_list[1][1]) if m_list else 0 + tex_short = float(m_list[1][2]) if m_list else 0 + alu_long = float(m_list[2][0]) if m_list else 0 + ls_long = float(m_list[2][1]) if m_list else 0 + tex_long = float(m_list[2][2]) if m_list else 0 + + return (registers, uniform_regs, alu_short, ls_short, tex_short, alu_long, ls_long, tex_long) + +def get_shader_type(shader): + _, ext = os.path.splitext(shader) + if ext == '.vert': + return '--vertex' + elif ext == '.frag': + return '--fragment' + elif ext == '.comp': + return '--compute' + elif ext == '.tesc': + return '--tessellation_control' + elif ext == '.tese': + return '--tessellation_evaluation' + elif ext == '.geom': + return '--geometry' + else: + return '' + +def get_shader_stats(shader): + f, path = tempfile.mkstemp() + + os.close(f) + p = subprocess.Popen(['malisc', get_shader_type(shader), '--core', 'Mali-T760', '-V', shader], stdout = subprocess.PIPE, stderr = subprocess.PIPE) + stdout, stderr = p.communicate() + os.remove(path) + + if p.returncode != 0: + print(stderr.decode('utf-8')) + raise OSError('malisc failed') + p.wait() + + returned = stdout.decode('utf-8') + return parse_stats(returned) + +def print_msl_compiler_version(): + try: + subprocess.check_call(['xcrun', '--sdk', 'iphoneos', 'metal', '--version']) + print('...are the Metal compiler characteristics.\n') # display after so xcrun FNF is silent + except OSError as e: + if (e.errno != os.errno.ENOENT): # Ignore xcrun not found error + raise + +def validate_shader_msl(shader, opt): + msl_path = reference_path(shader[0], shader[1], opt) + try: + msl_os = 'macosx' +# msl_os = 'iphoneos' + subprocess.check_call(['xcrun', '--sdk', msl_os, 'metal', '-x', 'metal', '-std=osx-metal1.2', '-Werror', '-Wno-unused-variable', msl_path]) + print('Compiled Metal shader: ' + msl_path) # display after so xcrun FNF is silent + except OSError as oe: + if (oe.errno != os.errno.ENOENT): # Ignore xcrun not found error + raise + except subprocess.CalledProcessError: + print('Error compiling Metal shader: ' + msl_path) + sys.exit(1) + +def cross_compile_msl(shader, spirv, opt): + spirv_f, spirv_path = tempfile.mkstemp() + msl_f, msl_path = tempfile.mkstemp(suffix = os.path.basename(shader)) + os.close(spirv_f) + os.close(msl_f) + + if spirv: + subprocess.check_call(['spirv-as', '-o', spirv_path, shader]) + else: + subprocess.check_call(['glslangValidator', '-V', '-o', spirv_path, shader]) + + if opt: + subprocess.check_call(['spirv-opt', '-O', '-o', spirv_path, spirv_path]) + + spirv_cross_path = './spirv-cross' + subprocess.check_call([spirv_cross_path, '--entry', 'main', '--output', msl_path, spirv_path, '--msl']) + subprocess.check_call(['spirv-val', spirv_path]) + return (spirv_path, msl_path) + +def shader_model_hlsl(shader): + if '.vert' in shader: + return '-Tvs_5_1' + elif '.frag' in shader: + return '-Tps_5_1' + elif '.comp' in shader: + return '-Tcs_5_1' + else: + return None + +def shader_to_win_path(shader): + # It's (very) convenient to be able to run HLSL testing in wine on Unix-likes, so support that. + try: + with subprocess.Popen(['winepath', '-w', shader], stdout = subprocess.PIPE, stderr = subprocess.PIPE) as f: + stdout_data, stderr_data = f.communicate() + return stdout_data.decode('utf-8') + except OSError as oe: + if (oe.errno != os.errno.ENOENT): # Ignore not found errors + return shader + except subprocess.CalledProcessError: + raise + + return shader + +def validate_shader_hlsl(shader): + subprocess.check_call(['glslangValidator', '-e', 'main', '-D', '-V', shader]) + is_no_fxc = '.nofxc.' in shader + if (not force_no_external_validation) and (not is_no_fxc): + try: + win_path = shader_to_win_path(shader) + subprocess.check_call(['fxc', '-nologo', shader_model_hlsl(shader), win_path]) + except OSError as oe: + if (oe.errno != os.errno.ENOENT): # Ignore not found errors + raise + except subprocess.CalledProcessError: + print('Failed compiling HLSL shader:', shader, 'with FXC.') + sys.exit(1) + +def shader_to_sm(shader): + if '.sm51.' in shader: + return '51' + elif '.sm20.' in shader: + return '20' + else: + return '50' + +def cross_compile_hlsl(shader, spirv, opt): + spirv_f, spirv_path = tempfile.mkstemp() + hlsl_f, hlsl_path = tempfile.mkstemp(suffix = os.path.basename(shader)) + os.close(spirv_f) + os.close(hlsl_f) + + if spirv: + subprocess.check_call(['spirv-as', '-o', spirv_path, shader]) + else: + subprocess.check_call(['glslangValidator', '-V', '-o', spirv_path, shader]) + + if opt: + subprocess.check_call(['spirv-opt', '-O', '-o', spirv_path, spirv_path]) + + spirv_cross_path = './spirv-cross' + + sm = shader_to_sm(shader) + subprocess.check_call([spirv_cross_path, '--entry', 'main', '--output', hlsl_path, spirv_path, '--hlsl-enable-compat', '--hlsl', '--shader-model', sm]) + subprocess.check_call(['spirv-val', spirv_path]) + + validate_shader_hlsl(hlsl_path) + + return (spirv_path, hlsl_path) + +def validate_shader(shader, vulkan): + if vulkan: + subprocess.check_call(['glslangValidator', '-V', shader]) + else: + subprocess.check_call(['glslangValidator', shader]) + +def cross_compile(shader, vulkan, spirv, invalid_spirv, eliminate, is_legacy, flatten_ubo, sso, flatten_dim, opt): + spirv_f, spirv_path = tempfile.mkstemp() + glsl_f, glsl_path = tempfile.mkstemp(suffix = os.path.basename(shader)) + os.close(spirv_f) + os.close(glsl_f) + + if vulkan or spirv: + vulkan_glsl_f, vulkan_glsl_path = tempfile.mkstemp(suffix = os.path.basename(shader)) + os.close(vulkan_glsl_f) + + if spirv: + subprocess.check_call(['spirv-as', '-o', spirv_path, shader]) + else: + subprocess.check_call(['glslangValidator', '-V', '-o', spirv_path, shader]) + + if opt and (not invalid_spirv): + subprocess.check_call(['spirv-opt', '-O', '-o', spirv_path, spirv_path]) + + if not invalid_spirv: + subprocess.check_call(['spirv-val', spirv_path]) + + extra_args = [] + if eliminate: + extra_args += ['--remove-unused-variables'] + if is_legacy: + extra_args += ['--version', '100', '--es'] + if flatten_ubo: + extra_args += ['--flatten-ubo'] + if sso: + extra_args += ['--separate-shader-objects'] + if flatten_dim: + extra_args += ['--flatten-multidimensional-arrays'] + + spirv_cross_path = './spirv-cross' + subprocess.check_call([spirv_cross_path, '--entry', 'main', '--output', glsl_path, spirv_path] + extra_args) + + # A shader might not be possible to make valid GLSL from, skip validation for this case. + if (not ('nocompat' in glsl_path)) and (not spirv): + validate_shader(glsl_path, False) + + if vulkan or spirv: + subprocess.check_call([spirv_cross_path, '--entry', 'main', '--vulkan-semantics', '--output', vulkan_glsl_path, spirv_path] + extra_args) + validate_shader(vulkan_glsl_path, True) + + return (spirv_path, glsl_path, vulkan_glsl_path if vulkan else None) + +def make_unix_newline(buf): + decoded = codecs.decode(buf, 'utf-8') + decoded = decoded.replace('\r', '') + return codecs.encode(decoded, 'utf-8') + +def md5_for_file(path): + md5 = hashlib.md5() + with open(path, 'rb') as f: + for chunk in iter(lambda: make_unix_newline(f.read(8192)), b''): + md5.update(chunk) + return md5.digest() + +def make_reference_dir(path): + base = os.path.dirname(path) + if not os.path.exists(base): + os.makedirs(base) + +def reference_path(directory, relpath, opt): + split_paths = os.path.split(directory) + reference_dir = os.path.join(split_paths[0], 'reference/' + ('opt/' if opt else '')) + reference_dir = os.path.join(reference_dir, split_paths[1]) + return os.path.join(reference_dir, relpath) + +def regression_check(shader, glsl, update, keep, opt): + reference = reference_path(shader[0], shader[1], opt) + joined_path = os.path.join(shader[0], shader[1]) + print('Reference shader path:', reference) + + if os.path.exists(reference): + if md5_for_file(glsl) != md5_for_file(reference): + if update: + print('Generated source code has changed for {}!'.format(reference)) + # If we expect changes, update the reference file. + if os.path.exists(reference): + os.remove(reference) + make_reference_dir(reference) + shutil.move(glsl, reference) + else: + print('Generated source code in {} does not match reference {}!'.format(glsl, reference)) + with open(glsl, 'r') as f: + print('') + print('Generated:') + print('======================') + print(f.read()) + print('======================') + print('') + + # Otherwise, fail the test. Keep the shader file around so we can inspect. + if not keep: + os.remove(glsl) + sys.exit(1) + else: + os.remove(glsl) + else: + print('Found new shader {}. Placing generated source code in {}'.format(joined_path, reference)) + make_reference_dir(reference) + shutil.move(glsl, reference) + +def shader_is_vulkan(shader): + return '.vk.' in shader + +def shader_is_desktop(shader): + return '.desktop.' in shader + +def shader_is_eliminate_dead_variables(shader): + return '.noeliminate.' not in shader + +def shader_is_spirv(shader): + return '.asm.' in shader + +def shader_is_invalid_spirv(shader): + return '.invalid.' in shader + +def shader_is_legacy(shader): + return '.legacy.' in shader + +def shader_is_flatten_ubo(shader): + return '.flatten.' in shader + +def shader_is_sso(shader): + return '.sso.' in shader + +def shader_is_flatten_dimensions(shader): + return '.flatten_dim.' in shader + +def shader_is_noopt(shader): + return '.noopt.' in shader + +def test_shader(stats, shader, update, keep, opt): + joined_path = os.path.join(shader[0], shader[1]) + vulkan = shader_is_vulkan(shader[1]) + desktop = shader_is_desktop(shader[1]) + eliminate = shader_is_eliminate_dead_variables(shader[1]) + is_spirv = shader_is_spirv(shader[1]) + invalid_spirv = shader_is_invalid_spirv(shader[1]) + is_legacy = shader_is_legacy(shader[1]) + flatten_ubo = shader_is_flatten_ubo(shader[1]) + sso = shader_is_sso(shader[1]) + flatten_dim = shader_is_flatten_dimensions(shader[1]) + noopt = shader_is_noopt(shader[1]) + + print('Testing shader:', joined_path) + spirv, glsl, vulkan_glsl = cross_compile(joined_path, vulkan, is_spirv, invalid_spirv, eliminate, is_legacy, flatten_ubo, sso, flatten_dim, opt and (not noopt)) + + # Only test GLSL stats if we have a shader following GL semantics. + if stats and (not vulkan) and (not is_spirv) and (not desktop): + cross_stats = get_shader_stats(glsl) + + regression_check(shader, glsl, update, keep, opt) + if vulkan_glsl: + regression_check((shader[0], shader[1] + '.vk'), vulkan_glsl, update, keep, opt) + os.remove(spirv) + + if stats and (not vulkan) and (not is_spirv) and (not desktop): + pristine_stats = get_shader_stats(joined_path) + + a = [] + a.append(shader[1]) + for i in pristine_stats: + a.append(str(i)) + for i in cross_stats: + a.append(str(i)) + print(','.join(a), file = stats) + +def test_shader_msl(stats, shader, update, keep, opt): + joined_path = os.path.join(shader[0], shader[1]) + print('\nTesting MSL shader:', joined_path) + is_spirv = shader_is_spirv(shader[1]) + noopt = shader_is_noopt(shader[1]) + spirv, msl = cross_compile_msl(joined_path, is_spirv, opt and (not noopt)) + regression_check(shader, msl, update, keep, opt) + + # Uncomment the following line to print the temp SPIR-V file path. + # This temp SPIR-V file is not deleted until after the Metal validation step below. + # If Metal validation fails, the temp SPIR-V file can be copied out and + # used as input to an invocation of spirv-cross to debug from Xcode directly. + # To do so, build spriv-cross using `make DEBUG=1`, then run the spriv-cross + # executable from Xcode using args: `--msl --entry main --output msl_path spirv_path`. +# print('SPRIV shader: ' + spirv) + + if not force_no_external_validation: + validate_shader_msl(shader, opt) + + os.remove(spirv) + +def test_shader_hlsl(stats, shader, update, keep, opt): + joined_path = os.path.join(shader[0], shader[1]) + print('Testing HLSL shader:', joined_path) + is_spirv = shader_is_spirv(shader[1]) + noopt = shader_is_noopt(shader[1]) + spirv, msl = cross_compile_hlsl(joined_path, is_spirv, opt and (not noopt)) + regression_check(shader, msl, update, keep, opt) + os.remove(spirv) + +def test_shaders_helper(stats, shader_dir, update, malisc, keep, opt, backend): + for root, dirs, files in os.walk(os.path.join(shader_dir)): + files = [ f for f in files if not f.startswith(".") ] #ignore system files (esp OSX) + for i in files: + path = os.path.join(root, i) + relpath = os.path.relpath(path, shader_dir) + if backend == 'msl': + test_shader_msl(stats, (shader_dir, relpath), update, keep, opt) + elif backend == 'hlsl': + test_shader_hlsl(stats, (shader_dir, relpath), update, keep, opt) + else: + test_shader(stats, (shader_dir, relpath), update, keep, opt) + +def test_shaders(shader_dir, update, malisc, keep, opt, backend): + if malisc: + with open('stats.csv', 'w') as stats: + print('Shader,OrigRegs,OrigUniRegs,OrigALUShort,OrigLSShort,OrigTEXShort,OrigALULong,OrigLSLong,OrigTEXLong,CrossRegs,CrossUniRegs,CrossALUShort,CrossLSShort,CrossTEXShort,CrossALULong,CrossLSLong,CrossTEXLong', file = stats) + test_shaders_helper(stats, shader_dir, update, malisc, keep, backend) + else: + test_shaders_helper(None, shader_dir, update, malisc, keep, opt, backend) + +def main(): + parser = argparse.ArgumentParser(description = 'Script for regression testing.') + parser.add_argument('folder', + help = 'Folder containing shader files to test.') + parser.add_argument('--update', + action = 'store_true', + help = 'Updates reference files if there is a mismatch. Use when legitimate changes in output is found.') + parser.add_argument('--keep', + action = 'store_true', + help = 'Leave failed GLSL shaders on disk if they fail regression. Useful for debugging.') + parser.add_argument('--malisc', + action = 'store_true', + help = 'Use malisc offline compiler to determine static cycle counts before and after spirv-cross.') + parser.add_argument('--msl', + action = 'store_true', + help = 'Test Metal backend.') + parser.add_argument('--metal', + action = 'store_true', + help = 'Deprecated Metal option. Use --msl instead.') + parser.add_argument('--hlsl', + action = 'store_true', + help = 'Test HLSL backend.') + parser.add_argument('--force-no-external-validation', + action = 'store_true', + help = 'Disable all external validation.') + parser.add_argument('--opt', + action = 'store_true', + help = 'Run SPIRV-Tools optimization passes as well.') + args = parser.parse_args() + + if not args.folder: + sys.stderr.write('Need shader folder.\n') + sys.exit(1) + + if args.msl: + print_msl_compiler_version() + + global force_no_external_validation + force_no_external_validation = args.force_no_external_validation + + test_shaders(args.folder, args.update, args.malisc, args.keep, args.opt, 'msl' if (args.msl or args.metal) else ('hlsl' if args.hlsl else 'glsl')) + if args.malisc: + print('Stats in stats.csv!') + print('Tests completed!') + +if __name__ == '__main__': + main() diff --git a/test_shaders.sh b/test_shaders.sh new file mode 100755 index 0000000000..a3608730b9 --- /dev/null +++ b/test_shaders.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +echo "Building spirv-cross" +make -j$(nproc) + +export PATH="./external/glslang-build/StandAlone:./external/spirv-tools-build/tools:.:$PATH" +echo "Using glslangValidation in: $(which glslangValidator)." +echo "Using spirv-opt in: $(which spirv-opt)." + +./test_shaders.py shaders || exit 1 +./test_shaders.py shaders --opt || exit 1 +./test_shaders.py shaders-msl --msl || exit 1 +./test_shaders.py shaders-msl --msl --opt || exit 1 +./test_shaders.py shaders-msl-no-opt --msl || exit 1 +./test_shaders.py shaders-hlsl --hlsl || exit 1 +./test_shaders.py shaders-hlsl --hlsl --opt || exit 1 + diff --git a/update_test_shaders.sh b/update_test_shaders.sh new file mode 100755 index 0000000000..712c3eec5d --- /dev/null +++ b/update_test_shaders.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +echo "Building spirv-cross" +make -j$(nproc) + +export PATH="./external/glslang-build/StandAlone:./external/spirv-tools-build/tools:.:$PATH" +echo "Using glslangValidation in: $(which glslangValidator)." +echo "Using spirv-opt in: $(which spirv-opt)." + +./test_shaders.py shaders --update || exit 1 +./test_shaders.py shaders --update --opt || exit 1 +./test_shaders.py shaders-msl --msl --update || exit 1 +./test_shaders.py shaders-msl --msl --update --opt || exit 1 +./test_shaders.py shaders-msl-no-opt --msl --update || exit 1 +./test_shaders.py shaders-hlsl --hlsl --update || exit 1 +./test_shaders.py shaders-hlsl --hlsl --update --opt || exit 1 + From 1fd14263884bb742ce65744d0c1855e5e4151599 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Fri, 2 Feb 2018 12:32:31 +0100 Subject: [PATCH 011/232] (slang) no need for this anymore. --- gfx/drivers_shader/slang_process.cpp | 42 +--------------------------- 1 file changed, 1 insertion(+), 41 deletions(-) diff --git a/gfx/drivers_shader/slang_process.cpp b/gfx/drivers_shader/slang_process.cpp index af54e3b8b5..f61e3d52b3 100644 --- a/gfx/drivers_shader/slang_process.cpp +++ b/gfx/drivers_shader/slang_process.cpp @@ -372,49 +372,10 @@ bool slang_process( vs->set_options(options); ps->set_options(options); - std::vector vs_attrib_remap; - /* not exactly a vertex attribute but this remaps * float2 FragCoord :TEXCOORD# to float4 FragCoord : SV_POSITION */ std::vector ps_attrib_remap; - /* "line" is a reserved keyword in hlsl - * maybe there is an easier way to rename a variable ? */ - - int id = 0; - while (true) - { - try - { - string name = vs->get_name(id); - - if (name == "line" || name == "point" || name == "linear") - vs->set_name(id, string("var_") + name); - - id++; - } catch (const std::exception& e) - { - break; - } - } - - id = 0; - while (true) - { - try - { - string name = ps->get_name(id); - - if (name == "line" || name == "point" || name == "linear") - ps->set_name(id, string("var_") + name); - - id++; - } catch (const std::exception& e) - { - break; - } - } - VariableTypeRemapCallback ps_var_remap_cb = [&](const SPIRType& type, const std::string& var_name, std::string& name_of_type) { @@ -433,8 +394,7 @@ bool slang_process( } } - - vs_code = vs->compile(vs_attrib_remap); + vs_code = vs->compile(); ps_code = ps->compile(ps_attrib_remap); } else if (shader_info->type == RARCH_SHADER_GLSL) From f880cb2d48c302803937f45618392145ab923413 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Fri, 2 Feb 2018 13:19:10 +0100 Subject: [PATCH 012/232] Squashed 'deps/SPIRV-Cross/' changes from d4b0625cbd..33c5cd9b19 33c5cd9b19 Merge pull request #427 from aliaspider/master 5fc48b61fa add `matrix` to the list of illegal names. git-subtree-dir: deps/SPIRV-Cross git-subtree-split: 33c5cd9b19295f94702c8c3002283fb4b55f47ab --- spirv_glsl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spirv_glsl.cpp b/spirv_glsl.cpp index 926e8f2842..10c61b82d4 100644 --- a/spirv_glsl.cpp +++ b/spirv_glsl.cpp @@ -1635,7 +1635,7 @@ void CompilerGLSL::replace_illegal_names() "image3D", "imageBuffer", "imageCube", "imageCubeArray", "in", "inline", "inout", "input", "int", "interface", "invariant", "isampler1D", "isampler1DArray", "isampler2D", "isampler2DArray", "isampler2DMS", "isampler2DMSArray", "isampler2DRect", "isampler3D", "isamplerBuffer", "isamplerCube", "isamplerCubeArray", "ivec2", "ivec3", "ivec4", "layout", "line", "linear", "long", "lowp", - "mat2", "mat2x2", "mat2x3", "mat2x4", "mat3", "mat3x2", "mat3x3", "mat3x4", "mat4", "mat4x2", "mat4x3", "mat4x4", "mediump", + "mat2", "mat2x2", "mat2x3", "mat2x4", "mat3", "mat3x2", "mat3x3", "mat3x4", "mat4", "mat4x2", "mat4x3", "mat4x4", "matrix", "mediump", "namespace", "noinline", "noperspective", "out", "output", "packed", "partition", "patch", "point", "precision", "public", "readonly", "resource", "restrict", "return", "row_major", "sample", "sampler", "sampler1D", "sampler1DArray", "sampler1DArrayShadow", "sampler1DShadow", "sampler2D", "sampler2DArray", "sampler2DArrayShadow", "sampler2DMS", "sampler2DMSArray", From 7f75e9f4cfa8a0f5a3f0719b92a1bad8b623d835 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Fri, 2 Feb 2018 13:35:31 +0100 Subject: [PATCH 013/232] build fix for HAVE_GLSLANG=1 HAVE_VULKAN=0. --- gfx/drivers_shader/glslang_util.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/drivers_shader/glslang_util.cpp b/gfx/drivers_shader/glslang_util.cpp index 3094fb00ae..abae49db0f 100644 --- a/gfx/drivers_shader/glslang_util.cpp +++ b/gfx/drivers_shader/glslang_util.cpp @@ -30,7 +30,7 @@ #endif #include "glslang_util.h" -#ifdef HAVE_VULKAN +#if defined(HAVE_GLSLANG) && !defined(HAVE_GRIFFIN) #include "glslang.hpp" #endif #include "../../verbosity.h" From 2a25e284af0a81bd92563b1cdfba8640af053910 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Fri, 2 Feb 2018 14:39:53 +0100 Subject: [PATCH 014/232] (D3D11) better handling of FBO scale. --- gfx/drivers/d3d11.c | 76 +++++++++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 33 deletions(-) diff --git a/gfx/drivers/d3d11.c b/gfx/drivers/d3d11.c index fdf3bf805e..5c8438398c 100644 --- a/gfx/drivers/d3d11.c +++ b/gfx/drivers/d3d11.c @@ -708,47 +708,57 @@ static bool d3d11_init_frame_textures(d3d11_video_t* d3d11, unsigned width, unsi { struct video_shader_pass* pass = &d3d11->shader_preset->pass[i]; - switch (pass->fbo.type_x) + if(pass->fbo.valid) { - case RARCH_SCALE_INPUT: - width *= pass->fbo.scale_x; - break; - case RARCH_SCALE_VIEWPORT: - width = d3d11->vp.width * pass->fbo.scale_x; - break; + switch (pass->fbo.type_x) + { + case RARCH_SCALE_INPUT: + width *= pass->fbo.scale_x; + break; - case RARCH_SCALE_ABSOLUTE: - width = pass->fbo.abs_x; - break; + case RARCH_SCALE_VIEWPORT: + width = d3d11->vp.width * pass->fbo.scale_x; + break; - default: - break; + case RARCH_SCALE_ABSOLUTE: + width = pass->fbo.abs_x; + break; + + default: + break; + } + + if (!width) + width = d3d11->vp.width; + + switch (pass->fbo.type_y) + { + case RARCH_SCALE_INPUT: + height *= pass->fbo.scale_y; + break; + + case RARCH_SCALE_VIEWPORT: + height = d3d11->vp.height * pass->fbo.scale_y; + break; + + case RARCH_SCALE_ABSOLUTE: + height = pass->fbo.abs_y; + break; + + default: + break; + } + + if (!height) + height = d3d11->vp.height; } - - switch (pass->fbo.type_y) + else if (i == (d3d11->shader_preset->passes - 1)) { - case RARCH_SCALE_INPUT: - height *= pass->fbo.scale_y; - break; - - case RARCH_SCALE_VIEWPORT: - height = d3d11->vp.height * pass->fbo.scale_y; - break; - - case RARCH_SCALE_ABSOLUTE: - height = pass->fbo.abs_y; - break; - - default: - break; - } - - if (!width) width = d3d11->vp.width; - - if (!height) height = d3d11->vp.height; + } + RARCH_LOG("[D3D11]: Updating framebuffer size %u x %u.\n", width, height); From 6fe3a3161763e7ef1fc863570bfdd5b9e91c2589 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Fri, 2 Feb 2018 17:18:41 +0100 Subject: [PATCH 015/232] (D3D11) multi-pass shaders: add support for wrap modes and lut mipmapping. --- gfx/common/d3d11_common.h | 3 +- gfx/drivers/d3d11.c | 124 ++++++++++++++++++++++------------ gfx/drivers_font/d3d11_font.c | 2 +- gfx/video_shader_parse.h | 3 +- 4 files changed, 83 insertions(+), 49 deletions(-) diff --git a/gfx/common/d3d11_common.h b/gfx/common/d3d11_common.h index 626353f967..7e9a53f4d7 100644 --- a/gfx/common/d3d11_common.h +++ b/gfx/common/d3d11_common.h @@ -2504,8 +2504,7 @@ typedef struct D3D11RenderTargetView renderTargetView; D3D11Buffer ubo; d3d11_uniform_t ubo_values; - D3D11SamplerState sampler_nearest; - D3D11SamplerState sampler_linear; + D3D11SamplerState samplers[RARCH_FILTER_MAX][RARCH_WRAP_MAX]; D3D11BlendState blend_enable; D3D11BlendState blend_disable; D3D11BlendState blend_pipeline; diff --git a/gfx/drivers/d3d11.c b/gfx/drivers/d3d11.c index 5c8438398c..887e74f417 100644 --- a/gfx/drivers/d3d11.c +++ b/gfx/drivers/d3d11.c @@ -39,10 +39,13 @@ static void d3d11_set_filtering(void* data, unsigned index, bool smooth) { d3d11_video_t* d3d11 = (d3d11_video_t*)data; - if (smooth) - d3d11->frame.texture.sampler = d3d11->sampler_linear; - else - d3d11->frame.texture.sampler = d3d11->sampler_nearest; + for (int i = 0; i < RARCH_WRAP_MAX; i++) + { + if (smooth) + d3d11->samplers[RARCH_FILTER_UNSPEC][i] = d3d11->samplers[RARCH_FILTER_LINEAR][i]; + else + d3d11->samplers[RARCH_FILTER_UNSPEC][i] = d3d11->samplers[RARCH_FILTER_NEAREST][i]; + } } static void d3d11_gfx_set_rotation(void* data, unsigned rotation) @@ -218,43 +221,44 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const #else bool save_hlsl = false; #endif - const char* vs_src = d3d11->shader_preset->pass[i].source.string.vertex; - const char* ps_src = d3d11->shader_preset->pass[i].source.string.fragment; - const char* vs_ext = ".vs.hlsl"; - const char* ps_ext = ".ps.hlsl"; - int base_len = strlen(d3d11->shader_preset->pass[i].source.path) - strlen(".slang"); - char* vs_filename = (char*)malloc(base_len + strlen(vs_ext) + 1); - char* ps_filename = (char*)malloc(base_len + strlen(ps_ext) + 1); + static const char vs_ext[] = ".vs.hlsl"; + static const char ps_ext[] = ".ps.hlsl"; + char vs_path[PATH_MAX_LENGTH]; + char ps_path[PATH_MAX_LENGTH]; + const char* slang_path = d3d11->shader_preset->pass[i].source.path; + const char* vs_src = d3d11->shader_preset->pass[i].source.string.vertex; + const char* ps_src = d3d11->shader_preset->pass[i].source.string.fragment; + int base_len = strlen(slang_path) - strlen(".slang"); - strncpy(vs_filename, d3d11->shader_preset->pass[i].source.path, base_len); - strncpy(ps_filename, d3d11->shader_preset->pass[i].source.path, base_len); - strncpy(vs_filename + base_len, vs_ext, strlen(vs_ext) + 1); - strncpy(ps_filename + base_len, ps_ext, strlen(ps_ext) + 1); + if(base_len <= 0) + base_len = strlen(slang_path); + + strncpy(vs_path, slang_path, base_len); + strncpy(ps_path, slang_path, base_len); + strncpy(vs_path + base_len, vs_ext, sizeof(vs_ext)); + strncpy(ps_path + base_len, ps_ext, sizeof(ps_ext)); if (!d3d11_init_shader( - d3d11->device, vs_src, 0, vs_filename, "main", NULL, NULL, desc, countof(desc), + d3d11->device, vs_src, 0, vs_path, "main", NULL, NULL, desc, countof(desc), &d3d11->pass[i].shader)) save_hlsl = true; if (!d3d11_init_shader( - d3d11->device, ps_src, 0, ps_filename, NULL, "main", NULL, NULL, 0, + d3d11->device, ps_src, 0, ps_path, NULL, "main", NULL, NULL, 0, &d3d11->pass[i].shader)) save_hlsl = true; if (save_hlsl) { - FILE* fp = fopen(vs_filename, "w"); + FILE* fp = fopen(vs_path, "w"); fwrite(vs_src, 1, strlen(vs_src), fp); fclose(fp); - fp = fopen(ps_filename, "w"); + fp = fopen(ps_path, "w"); fwrite(ps_src, 1, strlen(ps_src), fp); fclose(fp); } - free(vs_filename); - free(ps_filename); - free(d3d11->shader_preset->pass[i].source.string.vertex); free(d3d11->shader_preset->pass[i].source.string.fragment); @@ -293,15 +297,20 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const d3d11->luts[i].desc.Width = image.width; d3d11->luts[i].desc.Height = image.height; d3d11->luts[i].desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + + if(d3d11->shader_preset->lut[i].mipmap) + d3d11->luts[i].desc.MiscFlags = D3D11_RESOURCE_MISC_GENERATE_MIPS; + d3d11_init_texture(d3d11->device, &d3d11->luts[i]); + d3d11_update_texture( d3d11->ctx, image.width, image.height, 0, DXGI_FORMAT_R8G8B8A8_UNORM, image.pixels, &d3d11->luts[i]); + image_texture_free(&image); - d3d11->luts[i].sampler = d3d11->shader_preset->lut[i].filter == RARCH_FILTER_NEAREST - ? d3d11->sampler_nearest - : d3d11->sampler_linear; + d3d11->luts[i].sampler = + d3d11->samplers[d3d11->shader_preset->lut[i].filter][d3d11->shader_preset->lut[i].wrap]; } video_shader_resolve_current_parameters(conf, d3d11->shader_preset); @@ -350,8 +359,11 @@ static void d3d11_gfx_free(void* data) Release(d3d11->blend_enable); Release(d3d11->blend_disable); - Release(d3d11->sampler_nearest); - Release(d3d11->sampler_linear); + for (int i = 0; i < RARCH_WRAP_MAX; i++) + { + Release(d3d11->samplers[RARCH_FILTER_LINEAR][i]); + Release(d3d11->samplers[RARCH_FILTER_NEAREST][i]); + } Release(d3d11->state); Release(d3d11->renderTargetView); @@ -478,19 +490,41 @@ d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** i { D3D11_SAMPLER_DESC desc = { - .Filter = D3D11_FILTER_MIN_MAG_MIP_POINT, - .AddressU = D3D11_TEXTURE_ADDRESS_CLAMP, - .AddressV = D3D11_TEXTURE_ADDRESS_CLAMP, - .AddressW = D3D11_TEXTURE_ADDRESS_CLAMP, .MaxAnisotropy = 1, .ComparisonFunc = D3D11_COMPARISON_NEVER, .MinLOD = -D3D11_FLOAT32_MAX, .MaxLOD = D3D11_FLOAT32_MAX, }; - D3D11CreateSamplerState(d3d11->device, &desc, &d3d11->sampler_nearest); + /* Initialize samplers */ + for (int i = 0; i < RARCH_WRAP_MAX; i++) + { + switch (i) + { + case RARCH_WRAP_BORDER: + desc.AddressU = D3D11_TEXTURE_ADDRESS_BORDER; + break; - desc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR; - D3D11CreateSamplerState(d3d11->device, &desc, &d3d11->sampler_linear); + case RARCH_WRAP_EDGE: + desc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP; + break; + + case RARCH_WRAP_REPEAT: + desc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP; + break; + + case RARCH_WRAP_MIRRORED_REPEAT: + desc.AddressU = D3D11_TEXTURE_ADDRESS_MIRROR; + break; + } + desc.AddressV = desc.AddressU; + desc.AddressW = desc.AddressU; + + desc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR; + D3D11CreateSamplerState(d3d11->device, &desc, &d3d11->samplers[RARCH_FILTER_LINEAR][i]); + + desc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT; + D3D11CreateSamplerState(d3d11->device, &desc, &d3d11->samplers[RARCH_FILTER_NEAREST][i]); + } } d3d11_set_filtering(d3d11, 0, video->smooth); @@ -708,7 +742,7 @@ static bool d3d11_init_frame_textures(d3d11_video_t* d3d11, unsigned width, unsi { struct video_shader_pass* pass = &d3d11->shader_preset->pass[i]; - if(pass->fbo.valid) + if (pass->fbo.valid) { switch (pass->fbo.type_x) @@ -755,11 +789,10 @@ static bool d3d11_init_frame_textures(d3d11_video_t* d3d11, unsigned width, unsi } else if (i == (d3d11->shader_preset->passes - 1)) { - width = d3d11->vp.width; + width = d3d11->vp.width; height = d3d11->vp.height; } - RARCH_LOG("[D3D11]: Updating framebuffer size %u x %u.\n", width, height); if ((i != (d3d11->shader_preset->passes - 1)) || (width != d3d11->vp.width) || @@ -782,8 +815,7 @@ static bool d3d11_init_frame_textures(d3d11_video_t* d3d11, unsigned width, unsi d3d11->pass[i].rt.size_data.w = 1.0f / height; } - d3d11->pass[i].sampler = pass->filter == RARCH_FILTER_NEAREST ? d3d11->sampler_nearest - : d3d11->sampler_linear; + d3d11->pass[i].sampler = d3d11->samplers[pass->filter][pass->wrap]; for (int j = 0; j < d3d11->pass[i].semantics.texture_count; j++) { @@ -936,7 +968,8 @@ static bool d3d11_gfx_frame( { d3d11_set_shader(d3d11->ctx, &d3d11->shaders[VIDEO_SHADER_STOCK_BLEND]); D3D11SetPShaderResources(d3d11->ctx, 0, 1, &texture->view); - D3D11SetPShaderSamplers(d3d11->ctx, 0, 1, &d3d11->frame.texture.sampler); + D3D11SetPShaderSamplers( + d3d11->ctx, 0, 1, &d3d11->samplers[RARCH_FILTER_UNSPEC][RARCH_WRAP_DEFAULT]); D3D11SetVShaderConstantBuffers(d3d11->ctx, 0, 1, &d3d11->frame.ubo); } @@ -1063,9 +1096,10 @@ static void d3d11_set_menu_texture_frame( } d3d11_update_texture(d3d11->ctx, width, height, 0, format, frame, &d3d11->menu.texture); - d3d11->menu.texture.sampler = config_get_ptr()->bools.menu_linear_filter - ? d3d11->sampler_linear - : d3d11->sampler_nearest; + d3d11->menu.texture.sampler = d3d11->samplers + [config_get_ptr()->bools.menu_linear_filter + ? RARCH_FILTER_LINEAR + : RARCH_FILTER_NEAREST][RARCH_WRAP_DEFAULT]; } static void d3d11_set_menu_texture_enable(void* data, bool state, bool full_screen) @@ -1129,13 +1163,13 @@ static uintptr_t d3d11_gfx_load_texture( texture->desc.MiscFlags = D3D11_RESOURCE_MISC_GENERATE_MIPS; /* fallthrough */ case TEXTURE_FILTER_LINEAR: - texture->sampler = d3d11->sampler_linear; + texture->sampler = d3d11->samplers[RARCH_FILTER_LINEAR][RARCH_WRAP_DEFAULT]; break; case TEXTURE_FILTER_MIPMAP_NEAREST: texture->desc.MiscFlags = D3D11_RESOURCE_MISC_GENERATE_MIPS; /* fallthrough */ case TEXTURE_FILTER_NEAREST: - texture->sampler = d3d11->sampler_nearest; + texture->sampler = d3d11->samplers[RARCH_FILTER_NEAREST][RARCH_WRAP_DEFAULT]; break; } diff --git a/gfx/drivers_font/d3d11_font.c b/gfx/drivers_font/d3d11_font.c index d5fc00ab8b..a8bdc9b165 100644 --- a/gfx/drivers_font/d3d11_font.c +++ b/gfx/drivers_font/d3d11_font.c @@ -51,7 +51,7 @@ d3d11_font_init_font(void* data, const char* font_path, float font_size, bool is } font->atlas = font->font_driver->get_atlas(font->font_data); - font->texture.sampler = d3d11->sampler_linear; + font->texture.sampler = d3d11->samplers[RARCH_FILTER_LINEAR][RARCH_WRAP_BORDER]; font->texture.desc.Width = font->atlas->width; font->texture.desc.Height = font->atlas->height; font->texture.desc.Format = DXGI_FORMAT_A8_UNORM; diff --git a/gfx/video_shader_parse.h b/gfx/video_shader_parse.h index fcffeb428b..258fd72be3 100644 --- a/gfx/video_shader_parse.h +++ b/gfx/video_shader_parse.h @@ -62,7 +62,8 @@ enum { RARCH_FILTER_UNSPEC = 0, RARCH_FILTER_LINEAR, - RARCH_FILTER_NEAREST + RARCH_FILTER_NEAREST, + RARCH_FILTER_MAX }; enum gfx_wrap_type From dbe270476a72978f3aeb88069e4f66b5694adbfb Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Fri, 2 Feb 2018 11:41:54 -0500 Subject: [PATCH 016/232] Prevent undefined behavior reported by UBSan runtime error: member access within null pointer of type 'const struct dirent' --- libretro-common/file/retro_dirent.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libretro-common/file/retro_dirent.c b/libretro-common/file/retro_dirent.c index 0b716e6e56..171a4dee72 100644 --- a/libretro-common/file/retro_dirent.c +++ b/libretro-common/file/retro_dirent.c @@ -138,7 +138,7 @@ struct RDIR *retro_opendir(const char *name) #elif defined(VITA) || defined(PSP) rdir->directory = sceIoDopen(name); #elif defined(_3DS) - rdir->directory = (name && *name)? opendir(name) : NULL; + rdir->directory = !string_is_empty(name) ? opendir(name) : NULL; rdir->entry = NULL; #elif defined(__CELLOS_LV2__) rdir->error = cellFsOpendir(name, &rdir->directory); @@ -147,7 +147,13 @@ struct RDIR *retro_opendir(const char *name) rdir->entry = NULL; #endif - return rdir; + if (rdir->directory) + return rdir; + else + { + free(rdir); + return NULL; + } } bool retro_dirent_error(struct RDIR *rdir) @@ -208,6 +214,7 @@ const char *retro_dirent_get_name(struct RDIR *rdir) #elif defined(VITA) || defined(PSP) || defined(__CELLOS_LV2__) return rdir->entry.d_name; #else + return rdir->entry->d_name; #endif } From acdbf6f069ee11d29820c606103e7f10396ceddb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 2 Feb 2018 19:09:25 +0100 Subject: [PATCH 017/232] Cleanup retro_dirent.c --- libretro-common/file/retro_dirent.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libretro-common/file/retro_dirent.c b/libretro-common/file/retro_dirent.c index 171a4dee72..19000f0ffb 100644 --- a/libretro-common/file/retro_dirent.c +++ b/libretro-common/file/retro_dirent.c @@ -122,6 +122,7 @@ struct RDIR *retro_opendir(const char *name) snprintf(path_buf, sizeof(path_buf), "%s*", name); else snprintf(path_buf, sizeof(path_buf), "%s\\*", name); + #if defined(LEGACY_WIN32) path_local = utf8_to_local_string_alloc(path_buf); rdir->directory = FindFirstFile(path_local, &rdir->entry); @@ -135,13 +136,14 @@ struct RDIR *retro_opendir(const char *name) if (path_wide) free(path_wide); #endif + #elif defined(VITA) || defined(PSP) rdir->directory = sceIoDopen(name); #elif defined(_3DS) rdir->directory = !string_is_empty(name) ? opendir(name) : NULL; rdir->entry = NULL; #elif defined(__CELLOS_LV2__) - rdir->error = cellFsOpendir(name, &rdir->directory); + rdir->error = cellFsOpendir(name, &rdir->directory); #else rdir->directory = opendir(name); rdir->entry = NULL; @@ -149,11 +151,9 @@ struct RDIR *retro_opendir(const char *name) if (rdir->directory) return rdir; - else - { - free(rdir); - return NULL; - } + + free(rdir); + return NULL; } bool retro_dirent_error(struct RDIR *rdir) From e30c7edd8ddbfc2d69f8a005a86c2a691ee30ce6 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Fri, 2 Feb 2018 19:57:45 +0100 Subject: [PATCH 018/232] (D3D11) multi-pass shaders: add support for feed-back textures. --- gfx/common/d3d11_common.h | 1 + gfx/drivers/d3d11.c | 77 ++++++++++++++++++++-------- gfx/drivers_shader/slang_process.cpp | 3 ++ gfx/video_shader_parse.h | 1 + 4 files changed, 61 insertions(+), 21 deletions(-) diff --git a/gfx/common/d3d11_common.h b/gfx/common/d3d11_common.h index 7e9a53f4d7..9bf6b76178 100644 --- a/gfx/common/d3d11_common.h +++ b/gfx/common/d3d11_common.h @@ -2555,6 +2555,7 @@ typedef struct D3D11SamplerStateRef sampler; D3D11Buffer buffers[SLANG_CBUFFER_MAX]; d3d11_texture_t rt; + d3d11_texture_t feedback; D3D11_VIEWPORT viewport; pass_semantics_t semantics; D3D11ShaderResourceViewRef textures[SLANG_NUM_BINDINGS]; diff --git a/gfx/drivers/d3d11.c b/gfx/drivers/d3d11.c index 887e74f417..e4375a05ef 100644 --- a/gfx/drivers/d3d11.c +++ b/gfx/drivers/d3d11.c @@ -100,9 +100,11 @@ static void d3d11_free_shader_preset(d3d11_video_t* d3d11) { free(d3d11->shader_preset->pass[i].source.string.vertex); free(d3d11->shader_preset->pass[i].source.string.fragment); + free(d3d11->pass[i].semantics.textures); d3d11_release_shader(&d3d11->pass[i].shader); d3d11_release_texture(&d3d11->pass[i].rt); - free(d3d11->pass[i].semantics.textures); + d3d11_release_texture(&d3d11->pass[i].feedback); + for (int j = 0; j < SLANG_CBUFFER_MAX; j++) { free(d3d11->pass[i].semantics.cbuffers[j].uniforms); @@ -159,15 +161,15 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const { { /* no history support yet */ - texture_map_t texture_map[3 + GFX_MAX_SHADERS + GFX_MAX_TEXTURES + 1] = { + texture_map_t texture_map[3 + GFX_MAX_SHADERS * 2 + GFX_MAX_TEXTURES + 1] = { SL_TEXTURE_MAP( - SLANG_TEXTURE_SEMANTIC_ORIGINAL, d3d11->frame.texture, d3d11->pass[i].sampler, - d3d11->frame.texture.size_data), + SLANG_TEXTURE_SEMANTIC_ORIGINAL, d3d11->frame.texture.view, + d3d11->pass[i].sampler, d3d11->frame.texture.size_data), SL_TEXTURE_MAP( - SLANG_TEXTURE_SEMANTIC_SOURCE, *source, d3d11->pass[i].sampler, + SLANG_TEXTURE_SEMANTIC_SOURCE, source->view, d3d11->pass[i].sampler, source->size_data), SL_TEXTURE_MAP( - SLANG_TEXTURE_SEMANTIC_ORIGINAL_HISTORY, d3d11->frame.texture, + SLANG_TEXTURE_SEMANTIC_ORIGINAL_HISTORY, d3d11->frame.texture.view, d3d11->pass[i].sampler, d3d11->frame.texture.size_data), }; @@ -179,7 +181,15 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const for (int j = 0; j < i; j++) { *ptr = (texture_map_t)SL_TEXTURE_MAP_ARRAY( - SLANG_TEXTURE_SEMANTIC_PASS_OUTPUT, j, d3d11->pass[j].rt, + SLANG_TEXTURE_SEMANTIC_PASS_OUTPUT, j, d3d11->pass[j].rt.view, + d3d11->pass[i].sampler, d3d11->pass[j].rt.size_data); + ptr++; + } + + for (int j = 0; j < GFX_MAX_SHADERS; j++) + { + *ptr = (texture_map_t)SL_TEXTURE_MAP_ARRAY( + SLANG_TEXTURE_SEMANTIC_PASS_FEEDBACK, j, d3d11->pass[j].feedback.view, d3d11->pass[i].sampler, d3d11->pass[j].rt.size_data); ptr++; } @@ -187,7 +197,7 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const for (int j = 0; j < d3d11->shader_preset->luts; j++) { *ptr = (texture_map_t)SL_TEXTURE_MAP_ARRAY( - SLANG_TEXTURE_SEMANTIC_USER, j, d3d11->luts[j], d3d11->luts[j].sampler, + SLANG_TEXTURE_SEMANTIC_USER, j, d3d11->luts[j].view, d3d11->luts[j].sampler, d3d11->luts[j].size_data); ptr++; } @@ -230,7 +240,7 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const const char* ps_src = d3d11->shader_preset->pass[i].source.string.fragment; int base_len = strlen(slang_path) - strlen(".slang"); - if(base_len <= 0) + if (base_len <= 0) base_len = strlen(slang_path); strncpy(vs_path, slang_path, base_len); @@ -298,7 +308,7 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const d3d11->luts[i].desc.Height = image.height; d3d11->luts[i].desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; - if(d3d11->shader_preset->lut[i].mipmap) + if (d3d11->shader_preset->lut[i].mipmap) d3d11->luts[i].desc.MiscFlags = D3D11_RESOURCE_MISC_GENERATE_MIPS; d3d11_init_texture(d3d11->device, &d3d11->luts[i]); @@ -795,8 +805,12 @@ static bool d3d11_init_frame_textures(d3d11_video_t* d3d11, unsigned width, unsi RARCH_LOG("[D3D11]: Updating framebuffer size %u x %u.\n", width, height); + /* TODO: maybe use double buffering and grap the swapchain view + * instead when pass->feedback == true for the last pass ? + * (unless last pass is invalid anyway as a feedback source) */ + if ((i != (d3d11->shader_preset->passes - 1)) || (width != d3d11->vp.width) || - (height != d3d11->vp.height)) + (height != d3d11->vp.height) || pass->feedback) { d3d11->pass[i].viewport.Width = width; d3d11->pass[i].viewport.Height = height; @@ -806,6 +820,12 @@ static bool d3d11_init_frame_textures(d3d11_video_t* d3d11, unsigned width, unsi d3d11->pass[i].rt.desc.BindFlags = D3D11_BIND_RENDER_TARGET; d3d11->pass[i].rt.desc.Format = glslang_format_to_dxgi(d3d11->pass[i].semantics.format); d3d11_init_texture(d3d11->device, &d3d11->pass[i].rt); + + if (pass->feedback) + { + d3d11->pass[i].feedback.desc = d3d11->pass[i].rt.desc; + d3d11_init_texture(d3d11->device, &d3d11->pass[i].feedback); + } } else { @@ -816,16 +836,6 @@ static bool d3d11_init_frame_textures(d3d11_video_t* d3d11, unsigned width, unsi } d3d11->pass[i].sampler = d3d11->samplers[pass->filter][pass->wrap]; - - for (int j = 0; j < d3d11->pass[i].semantics.texture_count; j++) - { - texture_sem_t* texture_sem = &d3d11->pass[i].semantics.textures[j]; - D3D11ShaderResourceView view = ((d3d11_texture_t*)texture_sem->texture_data)->view; - D3D11SamplerStateRef sampler = *(D3D11SamplerStateRef*)texture_sem->sampler_data; - - d3d11->pass[i].textures[texture_sem->binding] = view; - d3d11->pass[i].samplers[texture_sem->binding] = sampler; - } } } @@ -906,6 +916,31 @@ static bool d3d11_gfx_frame( { for (int i = 0; i < d3d11->shader_preset->passes; i++) { + if (d3d11->shader_preset->pass[i].feedback) + { + d3d11_texture_t tmp = d3d11->pass[i].feedback; + d3d11->pass[i].feedback = d3d11->pass[i].rt; + d3d11->pass[i].rt = tmp; + } + } + + for (int i = 0; i < d3d11->shader_preset->passes; i++) + { + { + texture_sem_t* texture_sem = d3d11->pass[i].semantics.textures; + + while (texture_sem->stage_mask) + { + D3D11ShaderResourceView view = *(D3D11ShaderResourceView*)texture_sem->texture_data; + D3D11SamplerStateRef sampler = *(D3D11SamplerStateRef*)texture_sem->sampler_data; + + d3d11->pass[i].textures[texture_sem->binding] = view; + d3d11->pass[i].samplers[texture_sem->binding] = sampler; + + texture_sem++; + } + } + if (d3d11->shader_preset->pass[i].frame_count_mod) d3d11->pass[i].frame_count = frame_count % d3d11->shader_preset->pass[i].frame_count_mod; diff --git a/gfx/drivers_shader/slang_process.cpp b/gfx/drivers_shader/slang_process.cpp index f61e3d52b3..206c64af57 100644 --- a/gfx/drivers_shader/slang_process.cpp +++ b/gfx/drivers_shader/slang_process.cpp @@ -241,6 +241,9 @@ static bool slang_process_reflection( strncpy(texture.id, id.c_str(), sizeof(texture.id)); textures.push_back(texture); + + if(texture_map->semantic == SLANG_TEXTURE_SEMANTIC_PASS_FEEDBACK) + shader_info->pass[texture_map->index].feedback = true; } if (src.push_constant || src.uniform) diff --git a/gfx/video_shader_parse.h b/gfx/video_shader_parse.h index 258fd72be3..60738d9df5 100644 --- a/gfx/video_shader_parse.h +++ b/gfx/video_shader_parse.h @@ -119,6 +119,7 @@ struct video_shader_pass bool mipmap; unsigned filter; unsigned frame_count_mod; + bool feedback; }; struct video_shader_lut From efc35e43bb3af65df2a62176b3c1973e7872b5cc Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Fri, 2 Feb 2018 15:28:43 -0500 Subject: [PATCH 019/232] allow bool/string/path settings to override cbs_get_value --- menu/cbs/menu_cbs_get_value.c | 42 +++++++++++++++++------------------ 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index d9d05ce54d..0f11495d89 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -2170,27 +2170,6 @@ int menu_cbs_init_bind_get_string_representation(menu_file_list_cbs_t *cbs, RARCH_LOG("MENU_SETTINGS_LAST: %d\n", MENU_SETTINGS_LAST); #endif - if (cbs->setting) - { - switch (setting_get_type(cbs->setting)) - { - case ST_BOOL: - BIND_ACTION_GET_VALUE(cbs, - menu_action_setting_disp_set_label_setting_bool); - return 0; - case ST_STRING: - BIND_ACTION_GET_VALUE(cbs, - menu_action_setting_disp_set_label_setting_string); - return 0; - case ST_PATH: - BIND_ACTION_GET_VALUE(cbs, - menu_action_setting_disp_set_label_setting_path); - return 0; - default: - break; - } - } - if (cbs->enum_idx != MSG_UNKNOWN) { switch (cbs->enum_idx) @@ -2225,6 +2204,27 @@ int menu_cbs_init_bind_get_string_representation(menu_file_list_cbs_t *cbs, } } + if (cbs->setting) + { + switch (setting_get_type(cbs->setting)) + { + case ST_BOOL: + BIND_ACTION_GET_VALUE(cbs, + menu_action_setting_disp_set_label_setting_bool); + return 0; + case ST_STRING: + BIND_ACTION_GET_VALUE(cbs, + menu_action_setting_disp_set_label_setting_string); + return 0; + case ST_PATH: + BIND_ACTION_GET_VALUE(cbs, + menu_action_setting_disp_set_label_setting_path); + return 0; + default: + break; + } + } + if (type >= MENU_SETTINGS_PLAYLIST_ASSOCIATION_START) { BIND_ACTION_GET_VALUE(cbs, From df27e704a5e129dd2a76d14657afd419c7a99866 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Fri, 2 Feb 2018 15:37:02 -0500 Subject: [PATCH 020/232] add menu option to select different MITM server locations --- config.def.h | 2 ++ configuration.c | 5 +++++ configuration.h | 2 ++ intl/msg_hash_ja.h | 2 ++ intl/msg_hash_lbl.h | 2 ++ intl/msg_hash_us.c | 12 +++++++--- intl/msg_hash_us.h | 4 ++++ menu/cbs/menu_cbs_get_value.c | 34 ++++++++++++++++++++++++++++ menu/cbs/menu_cbs_left.c | 42 +++++++++++++++++++++++++++++++++++ menu/cbs/menu_cbs_right.c | 42 +++++++++++++++++++++++++++++++++++ menu/cbs/menu_cbs_start.c | 11 +++++++++ menu/cbs/menu_cbs_sublabel.c | 4 ++++ menu/menu_displaylist.c | 4 ++++ menu/menu_setting.c | 21 ++++++++++++++++++ msg_hash.h | 1 + network/netplay/netplay.h | 10 +++++++++ retroarch.cfg | 3 +++ 17 files changed, 198 insertions(+), 3 deletions(-) diff --git a/config.def.h b/config.def.h index 529b282ffa..2f11287444 100644 --- a/config.def.h +++ b/config.def.h @@ -551,6 +551,8 @@ static const int netplay_check_frames = 600; static const bool netplay_use_mitm_server = false; +static const char *netplay_mitm_server = "nyc"; + #ifdef HAVE_NETWORKING static const unsigned netplay_share_digital = RARCH_NETPLAY_SHARE_DIGITAL_NO_PREFERENCE; diff --git a/configuration.c b/configuration.c index e7a8cae859..6193363d11 100644 --- a/configuration.c +++ b/configuration.c @@ -1036,6 +1036,7 @@ static struct config_array_setting *populate_settings_array(settings_t *settings SETTING_ARRAY("bundle_assets_dst_path", settings->arrays.bundle_assets_dst, false, NULL, true); SETTING_ARRAY("bundle_assets_dst_path_subdir", settings->arrays.bundle_assets_dst_subdir, false, NULL, true); SETTING_ARRAY("led_driver", settings->arrays.led_driver, false, NULL, true); + SETTING_ARRAY("netplay_mitm_server", settings->arrays.netplay_mitm_server, false, NULL, true); *size = count; return tmp; @@ -1551,6 +1552,7 @@ static void config_set_defaults(void) const char *def_led = config_get_default_led(); const char *def_location = config_get_default_location(); const char *def_record = config_get_default_record(); + const char *def_mitm = netplay_mitm_server; struct config_float_setting *float_settings = populate_settings_float (settings, &float_settings_size); struct config_bool_setting *bool_settings = populate_settings_bool (settings, &bool_settings_size); struct config_int_setting *int_settings = populate_settings_int (settings, &int_settings_size); @@ -1630,6 +1632,9 @@ static void config_set_defaults(void) if (def_record) strlcpy(settings->arrays.record_driver, def_record, sizeof(settings->arrays.record_driver)); + if (def_mitm) + strlcpy(settings->arrays.netplay_mitm_server, + def_mitm, sizeof(settings->arrays.netplay_mitm_server)); #ifdef HAVE_MENU if (def_menu) strlcpy(settings->arrays.menu_driver, diff --git a/configuration.h b/configuration.h index 21c7b75e99..9223a210b3 100644 --- a/configuration.h +++ b/configuration.h @@ -408,6 +408,8 @@ typedef struct settings char bundle_assets_src[PATH_MAX_LENGTH]; char bundle_assets_dst[PATH_MAX_LENGTH]; char bundle_assets_dst_subdir[PATH_MAX_LENGTH]; + + char netplay_mitm_server[255]; } arrays; struct diff --git a/intl/msg_hash_ja.h b/intl/msg_hash_ja.h index 0fce42a8db..1eabc2694b 100644 --- a/intl/msg_hash_ja.h +++ b/intl/msg_hash_ja.h @@ -3041,6 +3041,8 @@ MSG_HASH( ) MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_USE_MITM_SERVER, "MITMサーバーを使用") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_MITM_SERVER, + "MITMサーバーの設置場所") MSG_HASH(MENU_ENUM_SUBLABEL_NETPLAY_USE_MITM_SERVER, "中間者のサーバーにネットプレイ接続を転送する。ファイアウォールやNAT/UPnPが問題の時に便利。") MSG_HASH(MENU_ENUM_LABEL_VALUE_ADD_TO_MIXER, diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index dcd7b57f17..28e4c248e2 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -1295,6 +1295,8 @@ MSG_HASH(MENU_ENUM_LABEL_SHADER_PIPELINE_BOKEH, "shader_pipeline_bokeh") MSG_HASH(MENU_ENUM_LABEL_NETPLAY_USE_MITM_SERVER, "netplay_use_mitm_server") +MSG_HASH(MENU_ENUM_LABEL_NETPLAY_MITM_SERVER, + "netplay_mitm_server") MSG_HASH(MENU_ENUM_LABEL_ADD_TO_MIXER, "audio_add_to_mixer") MSG_HASH(MENU_ENUM_LABEL_ADD_TO_MIXER_AND_COLLECTION, diff --git a/intl/msg_hash_us.c b/intl/msg_hash_us.c index f28500cecd..a215541dc9 100644 --- a/intl/msg_hash_us.c +++ b/intl/msg_hash_us.c @@ -1655,9 +1655,15 @@ int menu_hash_get_help_us_enum(enum msg_hash_enums msg, char *s, size_t len) break; case MENU_ENUM_LABEL_NETPLAY_USE_MITM_SERVER: snprintf(s, len, - "When hosting, relay connection through a\n" - "man-in-the-middle server\n" - "to get around firewalls or NAT/UPnP issues.\n"); + "When hosting a netplay session, relay connection through a \n" + "man-in-the-middle server \n" + "to get around firewalls or NAT/UPnP issues. \n"); + break; + case MENU_ENUM_LABEL_NETPLAY_MITM_SERVER: + snprintf(s, len, + "Specifies the man-in-the-middle server \n" + "to use for netplay. A server that is \n" + "located closer to you may have less latency. \n"); break; case MENU_ENUM_LABEL_VIDEO_MAX_SWAPCHAIN_IMAGES: snprintf(s, len, diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index fddbe1b808..4cb8c174a8 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -3185,6 +3185,10 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_USE_MITM_SERVER, "Use Relay Server") MSG_HASH(MENU_ENUM_SUBLABEL_NETPLAY_USE_MITM_SERVER, "Forward netplay connections through a man-in-the-middle server. Useful if the host is behind a firewall or has NAT/UPnP problems.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_MITM_SERVER, + "Relay Server Location") +MSG_HASH(MENU_ENUM_SUBLABEL_NETPLAY_MITM_SERVER, + "Choose a specific relay server to use. Geographically closer locations tend to have lower latency.") MSG_HASH(MENU_ENUM_LABEL_VALUE_ADD_TO_MIXER, "Add to mixer") MSG_HASH(MENU_ENUM_LABEL_VALUE_ADD_TO_MIXER_AND_COLLECTION, diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index 0f11495d89..601b8b6150 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -309,6 +309,36 @@ static void menu_action_setting_disp_set_label_pipeline( } +static void menu_action_setting_disp_set_label_netplay_mitm_server( + file_list_t* list, + unsigned *w, unsigned type, unsigned i, + const char *label, + char *s, size_t len, + const char *entry_label, + const char *path, + char *s2, size_t len2) +{ + settings_t *settings = config_get_ptr(); + + *s = '\0'; + *w = 19; + strlcpy(s2, path, len2); + + if (!settings) + return; + + if (!string_is_empty(settings->arrays.netplay_mitm_server)) + { + unsigned i; + + for (i = 0; i < ARRAY_SIZE(netplay_mitm_server_list); i++) + { + if (string_is_equal(settings->arrays.netplay_mitm_server, netplay_mitm_server_list[i].name)) + strlcpy(s, netplay_mitm_server_list[i].description, len); + } + } +} + static void menu_action_setting_disp_set_label_shader_watch_for_changes( file_list_t* list, unsigned *w, unsigned type, unsigned i, @@ -2199,6 +2229,10 @@ int menu_cbs_init_bind_get_string_representation(menu_file_list_cbs_t *cbs, BIND_ACTION_GET_VALUE(cbs, menu_action_setting_disp_set_label_achievement_information); return 0; + case MENU_ENUM_LABEL_NETPLAY_MITM_SERVER: + BIND_ACTION_GET_VALUE(cbs, + menu_action_setting_disp_set_label_netplay_mitm_server); + return 0; default: break; } diff --git a/menu/cbs/menu_cbs_left.c b/menu/cbs/menu_cbs_left.c index 8faa386e2b..9453af6f02 100644 --- a/menu/cbs/menu_cbs_left.c +++ b/menu/cbs/menu_cbs_left.c @@ -37,6 +37,7 @@ #include "../../managers/cheat_manager.h" #include "../../file_path_special.h" #include "../../retroarch.h" +#include "../../network/netplay/netplay.h" #ifndef BIND_ACTION_LEFT #define BIND_ACTION_LEFT(cbs, name) \ @@ -324,6 +325,44 @@ static int action_left_shader_num_passes(unsigned type, const char *label, return 0; } +static int action_left_netplay_mitm_server(unsigned type, const char *label, + bool wraparound) +{ + settings_t *settings = config_get_ptr(); + int i; + bool found = false; + int list_len = ARRAY_SIZE(netplay_mitm_server_list); + + for (i = 0; i < list_len; i++) + { + /* find the currently selected server in the list */ + if (string_is_equal(settings->arrays.netplay_mitm_server, netplay_mitm_server_list[i].name)) + { + /* move to the previous one in the list, wrap around if necessary */ + if (i - 1 >= 0) + { + found = true; + strlcpy(settings->arrays.netplay_mitm_server, netplay_mitm_server_list[i - 1].name, sizeof(settings->arrays.netplay_mitm_server)); + break; + } + else if (wraparound) + { + found = true; + strlcpy(settings->arrays.netplay_mitm_server, netplay_mitm_server_list[list_len - 1].name, sizeof(settings->arrays.netplay_mitm_server)); + break; + } + } + } + + if (!found) + { + /* current entry was invalid, go back to the end */ + strlcpy(settings->arrays.netplay_mitm_server, netplay_mitm_server_list[list_len - 1].name, sizeof(settings->arrays.netplay_mitm_server)); + } + + return 0; +} + static int action_left_shader_watch_for_changes(unsigned type, const char *label, bool wraparound) { @@ -490,6 +529,9 @@ static int menu_cbs_init_bind_left_compare_label(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_VIDEO_SHADER_DEFAULT_FILTER: BIND_ACTION_LEFT(cbs, action_left_shader_filter_default); break; + case MENU_ENUM_LABEL_NETPLAY_MITM_SERVER: + BIND_ACTION_LEFT(cbs, action_left_netplay_mitm_server); + break; case MENU_ENUM_LABEL_SHADER_WATCH_FOR_CHANGES: BIND_ACTION_LEFT(cbs, action_left_shader_watch_for_changes); break; diff --git a/menu/cbs/menu_cbs_right.c b/menu/cbs/menu_cbs_right.c index 2f4fe0efcc..f5bbc5af20 100644 --- a/menu/cbs/menu_cbs_right.c +++ b/menu/cbs/menu_cbs_right.c @@ -39,6 +39,7 @@ #include "../../retroarch.h" #include "../../verbosity.h" #include "../../ui/ui_companion_driver.h" +#include "../../network/netplay/netplay.h" #ifndef BIND_ACTION_RIGHT #define BIND_ACTION_RIGHT(cbs, name) \ @@ -327,6 +328,44 @@ static int action_right_shader_num_passes(unsigned type, const char *label, return 0; } +static int action_right_netplay_mitm_server(unsigned type, const char *label, + bool wraparound) +{ + settings_t *settings = config_get_ptr(); + unsigned i; + bool found = false; + unsigned list_len = ARRAY_SIZE(netplay_mitm_server_list); + + for (i = 0; i < list_len; i++) + { + /* find the currently selected server in the list */ + if (string_is_equal(settings->arrays.netplay_mitm_server, netplay_mitm_server_list[i].name)) + { + /* move to the next one in the list, wrap around if necessary */ + if (i + 1 < list_len) + { + found = true; + strlcpy(settings->arrays.netplay_mitm_server, netplay_mitm_server_list[i + 1].name, sizeof(settings->arrays.netplay_mitm_server)); + break; + } + else if (wraparound) + { + found = true; + strlcpy(settings->arrays.netplay_mitm_server, netplay_mitm_server_list[0].name, sizeof(settings->arrays.netplay_mitm_server)); + break; + } + } + } + + if (!found) + { + /* current entry was invalid, go back to the start */ + strlcpy(settings->arrays.netplay_mitm_server, netplay_mitm_server_list[0].name, sizeof(settings->arrays.netplay_mitm_server)); + } + + return 0; +} + static int action_right_shader_watch_for_changes(unsigned type, const char *label, bool wraparound) { @@ -600,6 +639,9 @@ static int menu_cbs_init_bind_right_compare_label(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_VIDEO_SHADER_DEFAULT_FILTER: BIND_ACTION_RIGHT(cbs, action_right_shader_filter_default); break; + case MENU_ENUM_LABEL_NETPLAY_MITM_SERVER: + BIND_ACTION_RIGHT(cbs, action_right_netplay_mitm_server); + break; case MENU_ENUM_LABEL_SHADER_WATCH_FOR_CHANGES: BIND_ACTION_RIGHT(cbs, action_right_shader_watch_for_changes); break; diff --git a/menu/cbs/menu_cbs_start.c b/menu/cbs/menu_cbs_start.c index 377c84294e..84f028c2ce 100644 --- a/menu/cbs/menu_cbs_start.c +++ b/menu/cbs/menu_cbs_start.c @@ -168,6 +168,13 @@ static int action_start_shader_filter_pass(unsigned type, const char *label) return menu_shader_manager_clear_pass_filter(pass); } +static int action_start_netplay_mitm_server(unsigned type, const char *label) +{ + settings_t *settings = config_get_ptr(); + strlcpy(settings->arrays.netplay_mitm_server, netplay_mitm_server, sizeof(settings->arrays.netplay_mitm_server)); + return 0; +} + static int action_start_shader_watch_for_changes(unsigned type, const char *label) { settings_t *settings = config_get_ptr(); @@ -299,6 +306,10 @@ static int menu_cbs_init_bind_start_compare_label(menu_file_list_cbs_t *cbs) break; case MENU_ENUM_LABEL_SCREEN_RESOLUTION: BIND_ACTION_START(cbs, action_start_video_resolution); + break; + case MENU_ENUM_LABEL_NETPLAY_MITM_SERVER: + BIND_ACTION_START(cbs, action_start_netplay_mitm_server); + break; default: return -1; } diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index 003aacea12..e1f01dffe3 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -373,6 +373,7 @@ default_sublabel_macro(action_bind_sublabel_video_viewport_custom_width, default_sublabel_macro(action_bind_sublabel_video_viewport_custom_x, MENU_ENUM_SUBLABEL_VIDEO_VIEWPORT_CUSTOM_X) default_sublabel_macro(action_bind_sublabel_video_viewport_custom_y, MENU_ENUM_SUBLABEL_VIDEO_VIEWPORT_CUSTOM_Y) default_sublabel_macro(action_bind_sublabel_netplay_use_mitm_server, MENU_ENUM_SUBLABEL_NETPLAY_USE_MITM_SERVER) +default_sublabel_macro(action_bind_sublabel_netplay_mitm_server, MENU_ENUM_SUBLABEL_NETPLAY_MITM_SERVER) default_sublabel_macro(action_bind_sublabel_core_delete, MENU_ENUM_SUBLABEL_CORE_DELETE) static int action_bind_sublabel_cheevos_entry( @@ -1472,6 +1473,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_NETPLAY_USE_MITM_SERVER: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_netplay_use_mitm_server); break; + case MENU_ENUM_LABEL_NETPLAY_MITM_SERVER: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_netplay_mitm_server); + break; case MENU_ENUM_LABEL_CORE_DELETE: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_core_delete); default: diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index faa141220a..1f7570b274 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -5498,6 +5498,10 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) MENU_ENUM_LABEL_NETPLAY_USE_MITM_SERVER, PARSE_ONLY_BOOL, false) != -1) count++; + if (menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_NETPLAY_MITM_SERVER, + PARSE_ONLY_STRING, false) != -1) + count++; if (menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_NETPLAY_IP_ADDRESS, PARSE_ONLY_STRING, false) != -1) diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 9e1b4e4463..e3dbe82798 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -575,6 +575,12 @@ static void setting_get_string_representation_uint_autosave_interval(void *data, } #endif +static void setting_get_string_representation_netplay_mitm_server(void *data, + char *s, size_t len) +{ + +} + #ifdef HAVE_LANGEXTRA static void setting_get_string_representation_uint_user_language(void *data, char *s, size_t len) @@ -6718,6 +6724,21 @@ static bool setting_append_list( general_read_handler, SD_FLAG_NONE); + CONFIG_STRING( + list, list_info, + settings->arrays.netplay_mitm_server, + sizeof(settings->arrays.netplay_mitm_server), + MENU_ENUM_LABEL_NETPLAY_MITM_SERVER, + MENU_ENUM_LABEL_VALUE_NETPLAY_MITM_SERVER, + netplay_mitm_server, + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler); + (*list)[list_info->index - 1].get_string_representation = + &setting_get_string_representation_netplay_mitm_server; + CONFIG_STRING( list, list_info, settings->paths.netplay_server, diff --git a/msg_hash.h b/msg_hash.h index 21bdc4ceac..91673d48f3 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1729,6 +1729,7 @@ enum msg_hash_enums MENU_ENUM_LABEL_VALUE_NETPLAY_COMPAT_CONTENT_FOUND, MENU_LABEL(NETPLAY_USE_MITM_SERVER), + MENU_LABEL(NETPLAY_MITM_SERVER), MSG_LAST }; diff --git a/network/netplay/netplay.h b/network/netplay/netplay.h index 712f66dc27..535eb2ebe5 100644 --- a/network/netplay/netplay.h +++ b/network/netplay/netplay.h @@ -29,6 +29,16 @@ typedef struct netplay netplay_t; +typedef struct mitm_server { + const char *name; + const char *description; +} mitm_server_t; + +static const mitm_server_t netplay_mitm_server_list[] = { + { "nyc", "New York City, USA" }, + { "madrid", "Madrid, Spain" }, +}; + enum rarch_netplay_ctl_state { RARCH_NETPLAY_CTL_NONE = 0, diff --git a/retroarch.cfg b/retroarch.cfg index 9319490de6..19a0d18b75 100644 --- a/retroarch.cfg +++ b/retroarch.cfg @@ -774,6 +774,9 @@ video_message_bgcolor_opacity = 1.0 # Force game hosting to go through a man-in-the-middle server to get around firewalls and NAT/UPnP problems. # netplay_use_mitm_server = false +# The requested MITM server to use. +# netplay_mitm_server = "nyc" + #### Misc # Enable rewinding. This will take a performance hit when playing, so it is disabled by default. From 75b48a866f7992f0e6f70d6e9afb3b4cdbbf6b98 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 2 Feb 2018 21:44:24 +0100 Subject: [PATCH 021/232] (3DS) Fix compilation error --- libretro-common/file/retro_dirent.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libretro-common/file/retro_dirent.c b/libretro-common/file/retro_dirent.c index 19000f0ffb..9c53504732 100644 --- a/libretro-common/file/retro_dirent.c +++ b/libretro-common/file/retro_dirent.c @@ -30,6 +30,7 @@ #include #include #include +#include #if defined(_WIN32) # ifdef _MSC_VER From 9449184c69b832494680390b1f97326ecc0ccc1f Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Fri, 2 Feb 2018 15:44:29 -0500 Subject: [PATCH 022/232] Update CHANGES.md --- CHANGES.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 5498b913d0..c7c7b2a23f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -30,7 +30,8 @@ - LOCALIZATION: Update Italian translation. - LOCALIZATION: Update Japanese translation. - LOCALIZATION: Update Spanish translation. -- OSX: Modify HID buttons detection algorithm. +- NETPLAY: Add menu option to select different MITM (relay) server locations. +- OSX: Modify HID buttons detection algorithm. - SOLARIS: Initial port. - SWITCH: Initial Nintendo Switch port, based on libtransistor SDK. - PS3: Enable Cheevos. From 6fc0cc4645daa77bb55d57d1376c642656df8a76 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Fri, 2 Feb 2018 15:48:45 -0500 Subject: [PATCH 023/232] send selected MITM server to the lobby --- network/netplay/netplay_frontend.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/network/netplay/netplay_frontend.c b/network/netplay/netplay_frontend.c index 9515fec3c3..cd1aaf0994 100644 --- a/network/netplay/netplay_frontend.c +++ b/network/netplay/netplay_frontend.c @@ -778,10 +778,11 @@ static void netplay_announce(void) buf[0] = '\0'; snprintf(buf, sizeof(buf), "username=%s&core_name=%s&core_version=%s&" - "game_name=%s&game_crc=%08X&port=%d" + "game_name=%s&game_crc=%08X&port=%d&mitm_server=%s" "&has_password=%d&has_spectate_password=%d&force_mitm=%d&retroarch_version=%s&frontend=%s", username, corename, coreversion, gamename, content_crc, settings->uints.netplay_port, + settings->arrays.netplay_mitm_server, *settings->paths.netplay_password ? 1 : 0, *settings->paths.netplay_spectate_password ? 1 : 0, settings->bools.netplay_use_mitm_server, From 58d6918533a6eb07e041907648670bd72ea47c73 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 2 Feb 2018 21:48:55 +0100 Subject: [PATCH 024/232] Silence Coverity warning --- core_info.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/core_info.c b/core_info.c index 8b56cf394f..91fd882698 100644 --- a/core_info.c +++ b/core_info.c @@ -189,14 +189,16 @@ static bool core_info_list_iterate( struct string_list *contents, size_t i) { size_t info_path_base_size = PATH_MAX_LENGTH * sizeof(char); - char *info_path_base = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); -#if defined(RARCH_MOBILE) || (defined(RARCH_CONSOLE) && !defined(PSP) && !defined(_3DS) && !defined(VITA)) + char *info_path_base = NULL; char *substr = NULL; -#endif - const char *current_path = contents->elems[i].data; + const char *current_path = contents ? contents->elems[i].data : NULL; - if (!contents || !current_path) - goto error; + (void)substr; + + if (!current_path) + return false; + + info_path_base = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); info_path_base[0] = '\0'; @@ -220,10 +222,6 @@ static bool core_info_list_iterate( free(info_path_base); return true; - -error: - free(info_path_base); - return false; } static core_info_list_t *core_info_list_new(const char *path) From 0ee124582c8f2b60cb71ab2537811dd0aad2fcc3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 2 Feb 2018 21:53:58 +0100 Subject: [PATCH 025/232] Silence another Coverity warning --- tasks/task_database.c | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/tasks/task_database.c b/tasks/task_database.c index d792548a27..d1cda3293f 100644 --- a/tasks/task_database.c +++ b/tasks/task_database.c @@ -1137,28 +1137,32 @@ static void task_database_handler(retro_task_t *task) if (!string_is_empty(db->fullpath)) dirname = find_last_slash(db->fullpath) + 1; - for (i = 0; i < dbstate->list->size; i++) + if (!string_is_empty(dirname)) { - char *dbname; - char *dbpath = strdup(dbstate->list->elems[i].data); - path_remove_extension(dbpath); - - dbname = find_last_slash(dbpath) + 1; - - if (strcasecmp(dbname, dirname) == 0) - { - struct string_list *single_list = NULL; - free(dbpath); - single_list = string_list_new(); - string_list_append(single_list, dbstate->list->elems[i].data, - dbstate->list->elems[i].attr); - dir_list_free(dbstate->list); - dbstate->list = single_list; - break; - } - else + for (i = 0; i < dbstate->list->size; i++) { + const char *data = dbstate->list->elems[i].data; + char *dbname = NULL; + bool strmatch = false; + char *dbpath = strdup(data); + + path_remove_extension(dbpath); + + dbname = find_last_slash(dbpath) + 1; + strmatch = strcasecmp(dbname, dirname) == 0; + free(dbpath); + + if (strmatch) + { + struct string_list *single_list = string_list_new(); + string_list_append(single_list, + data, + dbstate->list->elems[i].attr); + dir_list_free(dbstate->list); + dbstate->list = single_list; + break; + } } } } From 535012f8bff64e2a6f3653827ce67641f036d029 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 2 Feb 2018 21:57:58 +0100 Subject: [PATCH 026/232] Put compute_audio_buffer_statistics behind ifdef DEBUG --- audio/audio_driver.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/audio/audio_driver.c b/audio/audio_driver.c index 3a182c560d..b7a0950065 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -146,8 +146,10 @@ static size_t audio_driver_rewind_size = 0; static int16_t *audio_driver_rewind_buf = NULL; static int16_t *audio_driver_output_samples_conv_buf = NULL; +#ifdef DEBUG static unsigned audio_driver_free_samples_buf[AUDIO_BUFFER_FREE_SAMPLES_COUNT]; static uint64_t audio_driver_free_samples_count = 0; +#endif static size_t audio_driver_buffer_size = 0; static size_t audio_driver_data_ptr = 0; @@ -191,6 +193,7 @@ enum resampler_quality audio_driver_get_resampler_quality(void) return (enum resampler_quality)settings->uints.audio_resampler_quality; } +#ifdef DEBUG /** * compute_audio_buffer_statistics: * @@ -255,6 +258,7 @@ static void compute_audio_buffer_statistics(void) (100.0 * low_water_count) / (samples - 1), (100.0 * high_water_count) / (samples - 1)); } +#endif /** * audio_driver_find_handle: @@ -339,7 +343,9 @@ static bool audio_driver_deinit_internal(void) command_event(CMD_EVENT_DSP_FILTER_DEINIT, NULL); +#ifdef DEBUG compute_audio_buffer_statistics(); +#endif return true; } @@ -508,7 +514,9 @@ static bool audio_driver_init_internal(bool audio_cb_inited) command_event(CMD_EVENT_DSP_FILTER_INIT, NULL); +#ifdef DEBUG audio_driver_free_samples_count = 0; +#endif audio_mixer_init(settings->uints.audio_out_rate); @@ -612,21 +620,23 @@ static void audio_driver_flush(const int16_t *data, size_t samples) if (audio_driver_control) { /* Readjust the audio input rate. */ - unsigned write_idx = audio_driver_free_samples_count++ & - (AUDIO_BUFFER_FREE_SAMPLES_COUNT - 1); int half_size = (int)(audio_driver_buffer_size / 2); int avail = (int)current_audio->write_avail(audio_driver_context_audio_data); int delta_mid = avail - half_size; double direction = (double)delta_mid / half_size; double adjust = 1.0 + audio_driver_rate_control_delta * direction; +#ifdef DEBUG + unsigned write_idx = audio_driver_free_samples_count++ & + (AUDIO_BUFFER_FREE_SAMPLES_COUNT - 1); audio_driver_free_samples_buf [write_idx] = avail; +#endif audio_source_ratio_current = audio_source_ratio_original * adjust; -#if 0 +#ifdef DEBUG if (verbosity_is_enabled()) { RARCH_LOG_OUTPUT("[Audio]: Audio buffer is %u%% full\n", From 88cb40834ccd7e1f451a75f9524a4536d8480ff2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 2 Feb 2018 22:50:07 +0100 Subject: [PATCH 027/232] Style nits --- gfx/video_driver.c | 17 +++++++++++------ menu/menu_setting.c | 3 ++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 3b9a5a3e75..72bc4c36d5 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -1303,26 +1303,31 @@ bool video_monitor_fps_statistics(double *refresh_rate, double *deviation, unsigned *sample_points) { unsigned i; - retro_time_t accum = 0, avg, accum_var = 0; - unsigned samples = MIN(MEASURE_FRAME_TIME_SAMPLES_COUNT, - (unsigned)video_driver_frame_time_count); + retro_time_t accum = 0; + retro_time_t avg = 0; + retro_time_t accum_var = 0; + unsigned samples = 0; + #ifdef HAVE_THREADS if (video_driver_is_threaded()) return false; #endif + samples = MIN(MEASURE_FRAME_TIME_SAMPLES_COUNT, + (unsigned)video_driver_frame_time_count); + if (samples < 2) return false; /* Measure statistics on frame time (microsecs), *not* FPS. */ for (i = 0; i < samples; i++) + { accum += video_driver_frame_time_samples[i]; - #if 0 - for (i = 0; i < samples; i++) RARCH_LOG("[Video]: Interval #%u: %d usec / frame.\n", i, (int)frame_time_samples[i]); #endif + } avg = accum / samples; @@ -1330,7 +1335,7 @@ bool video_monitor_fps_statistics(double *refresh_rate, for (i = 0; i < samples; i++) { retro_time_t diff = video_driver_frame_time_samples[i] - avg; - accum_var += diff * diff; + accum_var += diff * diff; } *deviation = sqrt((double)accum_var / (samples - 1)) / avg; diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 9e1b4e4463..02f802cb9b 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -1465,7 +1465,8 @@ setting_get_string_representation_st_float_video_refresh_rate_auto( if (!setting) return; - if (video_monitor_fps_statistics(&video_refresh_rate, &deviation, &sample_points)) + if (video_monitor_fps_statistics(&video_refresh_rate, + &deviation, &sample_points)) { snprintf(s, len, "%.3f Hz (%.1f%% dev, %u samples)", video_refresh_rate, 100.0 * deviation, sample_points); From 9c305f7e95c1392aab25c9830957f7d1a979b3ad Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 3 Feb 2018 12:22:08 +0100 Subject: [PATCH 028/232] Update --- audio/audio_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/audio/audio_driver.c b/audio/audio_driver.c index b7a0950065..bc2231c76e 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -636,7 +636,7 @@ static void audio_driver_flush(const int16_t *data, size_t samples) audio_source_ratio_current = audio_source_ratio_original * adjust; -#ifdef DEBUG +#if 0 if (verbosity_is_enabled()) { RARCH_LOG_OUTPUT("[Audio]: Audio buffer is %u%% full\n", From d446742d4b9019b9631c0b55566a271fd7742856 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 3 Feb 2018 12:47:53 +0100 Subject: [PATCH 029/232] Some C89_BUILD build fixes --- gfx/drivers/d3d10.c | 6 ++++-- gfx/drivers_font/d3d_w32_font.c | 34 ++++++++++++++++++--------------- gfx/video_driver.h | 2 +- menu/cbs/menu_cbs_get_value.c | 4 ++-- 4 files changed, 26 insertions(+), 20 deletions(-) diff --git a/gfx/drivers/d3d10.c b/gfx/drivers/d3d10.c index dc3d895f66..540f3cda5f 100644 --- a/gfx/drivers/d3d10.c +++ b/gfx/drivers/d3d10.c @@ -510,8 +510,10 @@ static void d3d10_gfx_apply_state_changes(void* data) { d3d10_video_t* d3d10 = (d3d10_video_t*)data; - // if (d3d10) - // d3d10->resize_viewport = true; +#if 0 + if (d3d10) + d3d10->resize_viewport = true; +#endif } static const video_poke_interface_t d3d10_poke_interface = { diff --git a/gfx/drivers_font/d3d_w32_font.c b/gfx/drivers_font/d3d_w32_font.c index 643b24a7a9..9088f26849 100644 --- a/gfx/drivers_font/d3d_w32_font.c +++ b/gfx/drivers_font/d3d_w32_font.c @@ -16,6 +16,8 @@ #include +#include + #ifdef HAVE_CONFIG_H #include "../../config.h" #endif @@ -54,22 +56,25 @@ static void *d3dfonts_w32_init_font(void *video_data, bool is_threaded) { TEXTMETRICA metrics; - settings_t *settings = config_get_ptr(); - d3dx_font_desc_t desc = { - (int)(font_size), 0, 400, 0, - false, DEFAULT_CHARSET, - OUT_TT_PRECIS, - CLIP_DEFAULT_PRECIS, - DEFAULT_PITCH, -#ifdef UNICODE - _T(L"Verdana") -#else - _T("Verdana") -#endif - }; + d3dx_font_desc_t desc; d3dfonts_t *d3dfonts = (d3dfonts_t*)calloc(1, sizeof(*d3dfonts)); if (!d3dfonts) - return NULL; + return NULL; + + desc.Height = (int)font_size; + desc.Width = 0; + desc.Weight = 400; + desc.MipLevels = 0; + desc.Italic = FALSE; + desc.CharSet = DEFAULT_CHARSET; + desc.OutputPrecision = OUT_TT_PRECIS; + desc.Quality = CLIP_DEFAULT_PRECIS; + desc.PitchAndFamily = DEFAULT_PITCH; +#ifdef UNICODE + strlcpy(desc.FaceName, T(L"Verdana"), sizeof(desc.FaceName)); +#else + strlcpy(desc.FaceName, _T("Verdana"), sizeof(desc.FaceName)); +#endif d3dfonts->font_size = font_size * 1.2; /* to match the other font drivers */ d3dfonts->d3d = (d3d_video_t*)video_data; @@ -130,7 +135,6 @@ static void d3dfonts_w32_render_msg(video_frame_info_t *video_info, RECT rect, rect_shifted; RECT *p_rect_shifted = NULL; RECT *p_rect = NULL; - settings_t *settings = config_get_ptr(); const struct font_params *params = (const struct font_params*)userdata; d3dfonts_t *d3dfonts = (d3dfonts_t*)data; unsigned width = video_info->width; diff --git a/gfx/video_driver.h b/gfx/video_driver.h index c134c48d77..db0b704dbb 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -101,7 +101,7 @@ enum gfx_ctx_api GFX_CTX_OPENVG_API, GFX_CTX_VULKAN_API, GFX_CTX_GDI_API, - GFX_CTX_GX2_API, + GFX_CTX_GX2_API }; enum display_metric_types diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index d9d05ce54d..e7c7977033 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -1820,7 +1820,7 @@ static void menu_action_setting_disp_set_label_netplay_share_analog(file_list_t* } strlcpy(s, src, len); } -#endif // HAVE_NETWORKING +#endif static int menu_cbs_init_bind_get_string_representation_compare_label( menu_file_list_cbs_t *cbs) @@ -1938,7 +1938,7 @@ static int menu_cbs_init_bind_get_string_representation_compare_label( BIND_ACTION_GET_VALUE(cbs, menu_action_setting_disp_set_label_netplay_share_analog); break; -#endif // HAVE_NETWORKING +#endif case MENU_ENUM_LABEL_CONTENT_COLLECTION_LIST: case MENU_ENUM_LABEL_LOAD_CONTENT_HISTORY: case MENU_ENUM_LABEL_DOWNLOADED_FILE_DETECT_CORE_LIST: From 178730891d79914c03785fc56a93afe2baab1f8c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 3 Feb 2018 13:11:31 +0100 Subject: [PATCH 030/232] - Silence more warnings - Don't include d3dx headers when including cgD3D9 --- gfx/drivers_renderchain/d3d9_cg_renderchain.c | 4 +- gfx/include/Cg/cgD3D9.h | 4 + gfx/include/d3d9/d3dx9effect.h | 251 +++++++++--------- gfx/include/d3d9/d3dx9math.h | 102 ++++--- gfx/include/d3d9/d3dx9mesh.h | 188 ++++++------- 5 files changed, 276 insertions(+), 273 deletions(-) diff --git a/gfx/drivers_renderchain/d3d9_cg_renderchain.c b/gfx/drivers_renderchain/d3d9_cg_renderchain.c index eb1d9569d7..4773f85648 100644 --- a/gfx/drivers_renderchain/d3d9_cg_renderchain.c +++ b/gfx/drivers_renderchain/d3d9_cg_renderchain.c @@ -284,8 +284,6 @@ static void d3d9_cg_renderchain_set_shader_params( set_cg_param(pass->vPrg, "IN.frame_count", frame_cnt); } - - #define DECL_FVF_TEXCOORD(stream, offset, index) \ { (WORD)(stream), (WORD)(offset * sizeof(float)), D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, \ D3DDECLUSAGE_TEXCOORD, (BYTE)(index) } @@ -1147,7 +1145,7 @@ static bool d3d9_cg_renderchain_add_lut(void *data, D3D_DEFAULT_NONPOW2, 0, 0, - D3DFMT_FROM_FILE, + ((D3DFORMAT)-3), /* D3DFMT_FROM_FILE */ D3DPOOL_MANAGED, smooth ? D3D_FILTER_LINEAR : D3D_FILTER_POINT, 0, diff --git a/gfx/include/Cg/cgD3D9.h b/gfx/include/Cg/cgD3D9.h index 59b61b83e5..465f26e3ea 100644 --- a/gfx/include/Cg/cgD3D9.h +++ b/gfx/include/Cg/cgD3D9.h @@ -59,7 +59,11 @@ #include "cg.h" #include +#if 0 +#ifdef HAVE_D3DX #include "../d3d9/d3dx9.h" +#endif +#endif #include /* Set up for either Win32 import/export/lib. */ diff --git a/gfx/include/d3d9/d3dx9effect.h b/gfx/include/d3d9/d3dx9effect.h index 3947c7a91b..0d68aa8637 100644 --- a/gfx/include/d3d9/d3dx9effect.h +++ b/gfx/include/d3d9/d3dx9effect.h @@ -1,12 +1,12 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// File: d3dx9effect.h -// Content: D3DX effect types and Shaders -// -////////////////////////////////////////////////////////////////////////////// +/* + * + * Copyright (c) Microsoft Corporation. All rights reserved. + * + * File: d3dx9effect.h + * Content: D3DX effect types and Shaders + * + */ #include "d3dx9.h" @@ -24,90 +24,89 @@ #define D3DX_PARAMETER_LITERAL (1 << 1) #define D3DX_PARAMETER_ANNOTATION (1 << 2) -//---------------------------------------------------------------------------- -// D3DXEFFECT_DESC: -//---------------------------------------------------------------------------- +/* + * D3DXEFFECT_DESC: + */ typedef struct _D3DXEFFECT_DESC { - LPCSTR Creator; // Creator string - UINT Parameters; // Number of parameters - UINT Techniques; // Number of techniques - UINT Functions; // Number of function entrypoints + LPCSTR Creator; /* Creator string */ + UINT Parameters; /* Number of parameters */ + UINT Techniques; /* Number of techniques */ + UINT Functions; /* Number of function entrypoints */ } D3DXEFFECT_DESC; -//---------------------------------------------------------------------------- -// D3DXPARAMETER_DESC: -//---------------------------------------------------------------------------- +/* + * D3DXPARAMETER_DESC: + */ typedef struct _D3DXPARAMETER_DESC { - LPCSTR Name; // Parameter name - LPCSTR Semantic; // Parameter semantic - D3DXPARAMETER_CLASS Class; // Class - D3DXPARAMETER_TYPE Type; // Component type - UINT Rows; // Number of rows - UINT Columns; // Number of columns - UINT Elements; // Number of array elements - UINT Annotations; // Number of annotations - UINT StructMembers; // Number of structure member sub-parameters - DWORD Flags; // D3DX_PARAMETER_* flags - UINT Bytes; // Parameter size, in bytes + LPCSTR Name; /* Parameter name */ + LPCSTR Semantic; /* Parameter semantic */ + D3DXPARAMETER_CLASS Class; /* Class */ + D3DXPARAMETER_TYPE Type; /* Component type */ + UINT Rows; /* Number of rows */ + UINT Columns; /* Number of columns */ + UINT Elements; /* Number of array elements */ + UINT Annotations; /* Number of annotations */ + UINT StructMembers; /* Number of structure member sub-parameters */ + DWORD Flags; /* D3DX_PARAMETER_* flags */ + UINT Bytes; /* Parameter size, in bytes */ } D3DXPARAMETER_DESC; -//---------------------------------------------------------------------------- -// D3DXTECHNIQUE_DESC: -//---------------------------------------------------------------------------- +/* + * D3DXTECHNIQUE_DESC: + */ typedef struct _D3DXTECHNIQUE_DESC { - LPCSTR Name; // Technique name - UINT Passes; // Number of passes - UINT Annotations; // Number of annotations + LPCSTR Name; /* Technique name */ + UINT Passes; /* Number of passes */ + UINT Annotations; /* Number of annotations */ } D3DXTECHNIQUE_DESC; -//---------------------------------------------------------------------------- -// D3DXPASS_DESC: -//---------------------------------------------------------------------------- +/* + * D3DXPASS_DESC: + */ typedef struct _D3DXPASS_DESC { - LPCSTR Name; // Pass name - UINT Annotations; // Number of annotations + LPCSTR Name; /* Pass name */ + UINT Annotations; /* Number of annotations */ - CONST DWORD *pVertexShaderFunction; // Vertex shader function - CONST DWORD *pPixelShaderFunction; // Pixel shader function + CONST DWORD *pVertexShaderFunction; /* Vertex shader function */ + CONST DWORD *pPixelShaderFunction; /* Pixel shader function */ } D3DXPASS_DESC; -//---------------------------------------------------------------------------- -// D3DXFUNCTION_DESC: -//---------------------------------------------------------------------------- +/* + * D3DXFUNCTION_DESC: + */ typedef struct _D3DXFUNCTION_DESC { - LPCSTR Name; // Function name - UINT Annotations; // Number of annotations + LPCSTR Name; /* Function name */ + UINT Annotations; /* Number of annotations */ } D3DXFUNCTION_DESC; - -////////////////////////////////////////////////////////////////////////////// -// ID3DXEffectPool /////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// +/* + * ID3DXEffectPool +*/ typedef interface ID3DXEffectPool ID3DXEffectPool; typedef interface ID3DXEffectPool *LPD3DXEFFECTPOOL; -// {9537AB04-3250-412e-8213-FCD2F8677933} +/* {9537AB04-3250-412e-8213-FCD2F8677933} */ DEFINE_GUID(IID_ID3DXEffectPool, 0x9537ab04, 0x3250, 0x412e, 0x82, 0x13, 0xfc, 0xd2, 0xf8, 0x67, 0x79, 0x33); @@ -117,23 +116,23 @@ DEFINE_GUID(IID_ID3DXEffectPool, DECLARE_INTERFACE_(ID3DXEffectPool, IUnknown) { - // IUnknown + /* IUnknown */ STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; STDMETHOD_(ULONG, AddRef)(THIS) PURE; STDMETHOD_(ULONG, Release)(THIS) PURE; - // No public methods + /* No public methods */ }; -////////////////////////////////////////////////////////////////////////////// -// ID3DXBaseEffect /////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// +/* + * ID3DXBaseEffect +*/ typedef interface ID3DXBaseEffect ID3DXBaseEffect; typedef interface ID3DXBaseEffect *LPD3DXBASEEFFECT; -// {017C18AC-103F-4417-8C51-6BF6EF1E56BE} +/* {017C18AC-103F-4417-8C51-6BF6EF1E56BE} */ DEFINE_GUID(IID_ID3DXBaseEffect, 0x17c18ac, 0x103f, 0x4417, 0x8c, 0x51, 0x6b, 0xf6, 0xef, 0x1e, 0x56, 0xbe); @@ -143,19 +142,19 @@ DEFINE_GUID(IID_ID3DXBaseEffect, DECLARE_INTERFACE_(ID3DXBaseEffect, IUnknown) { - // IUnknown + /* IUnknown */ STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; STDMETHOD_(ULONG, AddRef)(THIS) PURE; STDMETHOD_(ULONG, Release)(THIS) PURE; - // Descs + /* Descs */ STDMETHOD(GetDesc)(THIS_ D3DXEFFECT_DESC* pDesc) PURE; STDMETHOD(GetParameterDesc)(THIS_ D3DXHANDLE hParameter, D3DXPARAMETER_DESC* pDesc) PURE; STDMETHOD(GetTechniqueDesc)(THIS_ D3DXHANDLE hTechnique, D3DXTECHNIQUE_DESC* pDesc) PURE; STDMETHOD(GetPassDesc)(THIS_ D3DXHANDLE hPass, D3DXPASS_DESC* pDesc) PURE; STDMETHOD(GetFunctionDesc)(THIS_ D3DXHANDLE hShader, D3DXFUNCTION_DESC* pDesc) PURE; - // Handle operations + /* Handle operations */ STDMETHOD_(D3DXHANDLE, GetParameter)(THIS_ D3DXHANDLE hParameter, UINT Index) PURE; STDMETHOD_(D3DXHANDLE, GetParameterByName)(THIS_ D3DXHANDLE hParameter, LPCSTR pName) PURE; STDMETHOD_(D3DXHANDLE, GetParameterBySemantic)(THIS_ D3DXHANDLE hParameter, LPCSTR pSemantic) PURE; @@ -169,7 +168,7 @@ DECLARE_INTERFACE_(ID3DXBaseEffect, IUnknown) STDMETHOD_(D3DXHANDLE, GetAnnotation)(THIS_ D3DXHANDLE hObject, UINT Index) PURE; STDMETHOD_(D3DXHANDLE, GetAnnotationByName)(THIS_ D3DXHANDLE hObject, LPCSTR pName) PURE; - // Get/Set Parameters + /* Get/Set Parameters */ STDMETHOD(SetValue)(THIS_ D3DXHANDLE hParameter, LPCVOID pData, UINT Bytes) PURE; STDMETHOD(GetValue)(THIS_ D3DXHANDLE hParameter, LPVOID pData, UINT Bytes) PURE; STDMETHOD(SetBool)(THIS_ D3DXHANDLE hParameter, BOOL b) PURE; @@ -207,24 +206,25 @@ DECLARE_INTERFACE_(ID3DXBaseEffect, IUnknown) STDMETHOD(GetPixelShader)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DPIXELSHADER9 *ppPShader) PURE; STDMETHOD(GetVertexShader)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DVERTEXSHADER9 *ppVShader) PURE; - //Set Range of an Array to pass to device - //Useful for sending only a subrange of an array down to the device + /* Set Range of an Array to pass to device + * Useful for sending only a subrange of an + * array down to the device + */ STDMETHOD(SetArrayRange)(THIS_ D3DXHANDLE hParameter, UINT uStart, UINT uEnd) PURE; }; - -//---------------------------------------------------------------------------- -// ID3DXEffectStateManager: -// ------------------------ -// This is a user implemented interface that can be used to manage device -// state changes made by an Effect. -//---------------------------------------------------------------------------- +/* + * ID3DXEffectStateManager: + * ------------------------ + * This is a user implemented interface that can be used to manage device + * state changes made by an Effect. + */ typedef interface ID3DXEffectStateManager ID3DXEffectStateManager; typedef interface ID3DXEffectStateManager *LPD3DXEFFECTSTATEMANAGER; -// {79AAB587-6DBC-4fa7-82DE-37FA1781C5CE} +/* {79AAB587-6DBC-4fa7-82DE-37FA1781C5CE} */ DEFINE_GUID(IID_ID3DXEffectStateManager, 0x79aab587, 0x6dbc, 0x4fa7, 0x82, 0xde, 0x37, 0xfa, 0x17, 0x81, 0xc5, 0xce); @@ -233,19 +233,20 @@ DEFINE_GUID(IID_ID3DXEffectStateManager, DECLARE_INTERFACE_(ID3DXEffectStateManager, IUnknown) { - // The user must correctly implement QueryInterface, AddRef, and Release. + /* The user must correctly implement QueryInterface, AddRef, and Release. */ - // IUnknown + /* IUnknown */ STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; STDMETHOD_(ULONG, AddRef)(THIS) PURE; STDMETHOD_(ULONG, Release)(THIS) PURE; - // The following methods are called by the Effect when it wants to make - // the corresponding device call. Note that: - // 1. Users manage the state and are therefore responsible for making the - // the corresponding device calls themselves inside their callbacks. - // 2. Effects pay attention to the return values of the callbacks, and so - // users must pay attention to what they return in their callbacks. + /* The following methods are called by the Effect when it wants to make + * the corresponding device call. Note that: + * 1. Users manage the state and are therefore responsible for making the + * the corresponding device calls themselves inside their callbacks. + * 2. Effects pay attention to the return values of the callbacks, and so + * users must pay attention to what they return in their callbacks. + */ STDMETHOD(SetTransform)(THIS_ D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX *pMatrix) PURE; STDMETHOD(SetMaterial)(THIS_ CONST D3DMATERIAL9 *pMaterial) PURE; @@ -268,14 +269,14 @@ DECLARE_INTERFACE_(ID3DXEffectStateManager, IUnknown) }; -////////////////////////////////////////////////////////////////////////////// -// ID3DXEffect /////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// +/* + * ID3DXEffect + */ typedef interface ID3DXEffect ID3DXEffect; typedef interface ID3DXEffect *LPD3DXEFFECT; -// {F6CEB4B3-4E4C-40dd-B883-8D8DE5EA0CD5} +/* {F6CEB4B3-4E4C-40dd-B883-8D8DE5EA0CD5} */ DEFINE_GUID(IID_ID3DXEffect, 0xf6ceb4b3, 0x4e4c, 0x40dd, 0xb8, 0x83, 0x8d, 0x8d, 0xe5, 0xea, 0xc, 0xd5); @@ -284,19 +285,19 @@ DEFINE_GUID(IID_ID3DXEffect, DECLARE_INTERFACE_(ID3DXEffect, ID3DXBaseEffect) { - // ID3DXBaseEffect + /* ID3DXBaseEffect */ STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; STDMETHOD_(ULONG, AddRef)(THIS) PURE; STDMETHOD_(ULONG, Release)(THIS) PURE; - // Descs + /* Descs */ STDMETHOD(GetDesc)(THIS_ D3DXEFFECT_DESC* pDesc) PURE; STDMETHOD(GetParameterDesc)(THIS_ D3DXHANDLE hParameter, D3DXPARAMETER_DESC* pDesc) PURE; STDMETHOD(GetTechniqueDesc)(THIS_ D3DXHANDLE hTechnique, D3DXTECHNIQUE_DESC* pDesc) PURE; STDMETHOD(GetPassDesc)(THIS_ D3DXHANDLE hPass, D3DXPASS_DESC* pDesc) PURE; STDMETHOD(GetFunctionDesc)(THIS_ D3DXHANDLE hShader, D3DXFUNCTION_DESC* pDesc) PURE; - // Handle operations + /* Handle operations */ STDMETHOD_(D3DXHANDLE, GetParameter)(THIS_ D3DXHANDLE hParameter, UINT Index) PURE; STDMETHOD_(D3DXHANDLE, GetParameterByName)(THIS_ D3DXHANDLE hParameter, LPCSTR pName) PURE; STDMETHOD_(D3DXHANDLE, GetParameterBySemantic)(THIS_ D3DXHANDLE hParameter, LPCSTR pSemantic) PURE; @@ -310,7 +311,7 @@ DECLARE_INTERFACE_(ID3DXEffect, ID3DXBaseEffect) STDMETHOD_(D3DXHANDLE, GetAnnotation)(THIS_ D3DXHANDLE hObject, UINT Index) PURE; STDMETHOD_(D3DXHANDLE, GetAnnotationByName)(THIS_ D3DXHANDLE hObject, LPCSTR pName) PURE; - // Get/Set Parameters + /* Get/Set Parameters */ STDMETHOD(SetValue)(THIS_ D3DXHANDLE hParameter, LPCVOID pData, UINT Bytes) PURE; STDMETHOD(GetValue)(THIS_ D3DXHANDLE hParameter, LPVOID pData, UINT Bytes) PURE; STDMETHOD(SetBool)(THIS_ D3DXHANDLE hParameter, BOOL b) PURE; @@ -348,65 +349,65 @@ DECLARE_INTERFACE_(ID3DXEffect, ID3DXBaseEffect) STDMETHOD(GetPixelShader)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DPIXELSHADER9 *ppPShader) PURE; STDMETHOD(GetVertexShader)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DVERTEXSHADER9 *ppVShader) PURE; - //Set Range of an Array to pass to device - //Usefull for sending only a subrange of an array down to the device + /* Set Range of an Array to pass to device + * Useful for sending only a subrange of an array down to the device + */ STDMETHOD(SetArrayRange)(THIS_ D3DXHANDLE hParameter, UINT uStart, UINT uEnd) PURE; - // ID3DXBaseEffect + /* ID3DXBaseEffect */ - - // Pool + /* Pool */ STDMETHOD(GetPool)(THIS_ LPD3DXEFFECTPOOL* ppPool) PURE; - // Selecting and setting a technique + /* Selecting and setting a technique */ STDMETHOD(SetTechnique)(THIS_ D3DXHANDLE hTechnique) PURE; STDMETHOD_(D3DXHANDLE, GetCurrentTechnique)(THIS) PURE; STDMETHOD(ValidateTechnique)(THIS_ D3DXHANDLE hTechnique) PURE; STDMETHOD(FindNextValidTechnique)(THIS_ D3DXHANDLE hTechnique, D3DXHANDLE *pTechnique) PURE; STDMETHOD_(BOOL, IsParameterUsed)(THIS_ D3DXHANDLE hParameter, D3DXHANDLE hTechnique) PURE; - // Using current technique - // Begin starts active technique - // BeginPass begins a pass - // CommitChanges updates changes to any set calls in the pass. This should be called before - // any DrawPrimitive call to d3d - // EndPass ends a pass - // End ends active technique + /* Using current technique + * Begin starts active technique + * BeginPass begins a pass + * CommitChanges updates changes to any set calls in the pass. This should be called before + * any DrawPrimitive call to d3d + * EndPass ends a pass + * End ends active technique + */ STDMETHOD(Begin)(THIS_ UINT *pPasses, DWORD Flags) PURE; STDMETHOD(BeginPass)(THIS_ UINT Pass) PURE; STDMETHOD(CommitChanges)(THIS) PURE; STDMETHOD(EndPass)(THIS) PURE; STDMETHOD(End)(THIS) PURE; - // Managing D3D Device + /* Managing D3D Device */ STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; STDMETHOD(OnLostDevice)(THIS) PURE; STDMETHOD(OnResetDevice)(THIS) PURE; - // Logging device calls + /* Logging device calls */ STDMETHOD(SetStateManager)(THIS_ LPD3DXEFFECTSTATEMANAGER pManager) PURE; STDMETHOD(GetStateManager)(THIS_ LPD3DXEFFECTSTATEMANAGER *ppManager) PURE; - // Parameter blocks + /* Parameter blocks */ STDMETHOD(BeginParameterBlock)(THIS) PURE; STDMETHOD_(D3DXHANDLE, EndParameterBlock)(THIS) PURE; STDMETHOD(ApplyParameterBlock)(THIS_ D3DXHANDLE hParameterBlock) PURE; STDMETHOD(DeleteParameterBlock)(THIS_ D3DXHANDLE hParameterBlock) PURE; - // Cloning + /* Cloning */ STDMETHOD(CloneEffect)(THIS_ LPDIRECT3DDEVICE9 pDevice, LPD3DXEFFECT* ppEffect) PURE; - // Fast path for setting variables directly in ID3DXEffect + /* Fast path for setting variables directly in ID3DXEffect */ STDMETHOD(SetRawValue)(THIS_ D3DXHANDLE hParameter, LPCVOID pData, UINT ByteOffset, UINT Bytes) PURE; }; -////////////////////////////////////////////////////////////////////////////// -// ID3DXEffectCompiler /////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - +/* + * ID3DXEffectCompiler + */ typedef interface ID3DXEffectCompiler ID3DXEffectCompiler; typedef interface ID3DXEffectCompiler *LPD3DXEFFECTCOMPILER; -// {51B8A949-1A31-47e6-BEA0-4B30DB53F1E0} +/* {51B8A949-1A31-47e6-BEA0-4B30DB53F1E0} */ DEFINE_GUID(IID_ID3DXEffectCompiler, 0x51b8a949, 0x1a31, 0x47e6, 0xbe, 0xa0, 0x4b, 0x30, 0xdb, 0x53, 0xf1, 0xe0); @@ -416,19 +417,19 @@ DEFINE_GUID(IID_ID3DXEffectCompiler, DECLARE_INTERFACE_(ID3DXEffectCompiler, ID3DXBaseEffect) { - // ID3DXBaseEffect + /* ID3DXBaseEffect */ STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; STDMETHOD_(ULONG, AddRef)(THIS) PURE; STDMETHOD_(ULONG, Release)(THIS) PURE; - // Descs + /* Descs */ STDMETHOD(GetDesc)(THIS_ D3DXEFFECT_DESC* pDesc) PURE; STDMETHOD(GetParameterDesc)(THIS_ D3DXHANDLE hParameter, D3DXPARAMETER_DESC* pDesc) PURE; STDMETHOD(GetTechniqueDesc)(THIS_ D3DXHANDLE hTechnique, D3DXTECHNIQUE_DESC* pDesc) PURE; STDMETHOD(GetPassDesc)(THIS_ D3DXHANDLE hPass, D3DXPASS_DESC* pDesc) PURE; STDMETHOD(GetFunctionDesc)(THIS_ D3DXHANDLE hShader, D3DXFUNCTION_DESC* pDesc) PURE; - // Handle operations + /* Handle operations */ STDMETHOD_(D3DXHANDLE, GetParameter)(THIS_ D3DXHANDLE hParameter, UINT Index) PURE; STDMETHOD_(D3DXHANDLE, GetParameterByName)(THIS_ D3DXHANDLE hParameter, LPCSTR pName) PURE; STDMETHOD_(D3DXHANDLE, GetParameterBySemantic)(THIS_ D3DXHANDLE hParameter, LPCSTR pSemantic) PURE; @@ -442,7 +443,7 @@ DECLARE_INTERFACE_(ID3DXEffectCompiler, ID3DXBaseEffect) STDMETHOD_(D3DXHANDLE, GetAnnotation)(THIS_ D3DXHANDLE hObject, UINT Index) PURE; STDMETHOD_(D3DXHANDLE, GetAnnotationByName)(THIS_ D3DXHANDLE hObject, LPCSTR pName) PURE; - // Get/Set Parameters + /* Get/Set Parameters */ STDMETHOD(SetValue)(THIS_ D3DXHANDLE hParameter, LPCVOID pData, UINT Bytes) PURE; STDMETHOD(GetValue)(THIS_ D3DXHANDLE hParameter, LPVOID pData, UINT Bytes) PURE; STDMETHOD(SetBool)(THIS_ D3DXHANDLE hParameter, BOOL b) PURE; @@ -480,16 +481,16 @@ DECLARE_INTERFACE_(ID3DXEffectCompiler, ID3DXBaseEffect) STDMETHOD(GetPixelShader)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DPIXELSHADER9 *ppPShader) PURE; STDMETHOD(GetVertexShader)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DVERTEXSHADER9 *ppVShader) PURE; - //Set Range of an Array to pass to device - //Usefull for sending only a subrange of an array down to the device + /* Set Range of an Array to pass to device + * Useful for sending only a subrange of an array down to the device */ STDMETHOD(SetArrayRange)(THIS_ D3DXHANDLE hParameter, UINT uStart, UINT uEnd) PURE; - // ID3DXBaseEffect - // Parameter sharing, specialization, and information + /* ID3DXBaseEffect + * Parameter sharing, specialization, and information */ STDMETHOD(SetLiteral)(THIS_ D3DXHANDLE hParameter, BOOL Literal) PURE; STDMETHOD(GetLiteral)(THIS_ D3DXHANDLE hParameter, BOOL *pLiteral) PURE; - // Compilation + /* Compilation */ STDMETHOD(CompileEffect)(THIS_ DWORD Flags, LPD3DXBUFFER* ppEffect, LPD3DXBUFFER* ppErrorMsgs) PURE; @@ -498,9 +499,9 @@ DECLARE_INTERFACE_(ID3DXEffectCompiler, ID3DXBaseEffect) }; -////////////////////////////////////////////////////////////////////////////// -// APIs ////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// +/* + * APIs + */ #ifdef __cplusplus extern "C" { @@ -729,6 +730,6 @@ HRESULT WINAPI #ifdef __cplusplus } -#endif //__cplusplus +#endif /* __cplusplus */ -#endif //__D3DX9EFFECT_H__ +#endif /* __D3DX9EFFECT_H__ */ diff --git a/gfx/include/d3d9/d3dx9math.h b/gfx/include/d3d9/d3dx9math.h index f861629e0d..e8593c0f1e 100644 --- a/gfx/include/d3d9/d3dx9math.h +++ b/gfx/include/d3d9/d3dx9math.h @@ -1,11 +1,10 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx9math.h -// Content: D3DX math types and functions -// -////////////////////////////////////////////////////////////////////////////// +/* + * + * Copyright (C) Microsoft Corporation. All Rights Reserved. + * + * File: d3dx9math.h + * Content: D3DX math types and functions + */ #include "d3dx9.h" @@ -17,36 +16,33 @@ #pragma warning(push) #endif -//=========================================================================== -// -// General purpose utilities -// -//=========================================================================== +/* + * + * General purpose utilities + * + */ #define D3DX_PI ((FLOAT) 3.141592654f) #define D3DX_1BYPI ((FLOAT) 0.318309886f) #define D3DXToRadian( degree ) ((degree) * (D3DX_PI / 180.0f)) #define D3DXToDegree( radian ) ((radian) * (180.0f / D3DX_PI)) +/* + * + * 16 bit floating point numbers + */ - -//=========================================================================== -// -// 16 bit floating point numbers -// -//=========================================================================== - -#define D3DX_16F_DIG 3 // # of decimal digits of precision -#define D3DX_16F_EPSILON 4.8875809e-4f // smallest such that 1.0 + epsilon != 1.0 -#define D3DX_16F_MANT_DIG 11 // # of bits in mantissa -#define D3DX_16F_MAX 6.550400e+004 // max value -#define D3DX_16F_MAX_10_EXP 4 // max decimal exponent -#define D3DX_16F_MAX_EXP 15 // max binary exponent -#define D3DX_16F_MIN 6.1035156e-5f // min positive value -#define D3DX_16F_MIN_10_EXP (-4) // min decimal exponent -#define D3DX_16F_MIN_EXP (-14) // min binary exponent -#define D3DX_16F_RADIX 2 // exponent radix -#define D3DX_16F_ROUNDS 1 // addition rounding: near +#define D3DX_16F_DIG 3 /* # of decimal digits of precision */ +#define D3DX_16F_EPSILON 4.8875809e-4f /* smallest such that 1.0 + epsilon != 1.0 */ +#define D3DX_16F_MANT_DIG 11 /* # of bits in mantissa */ +#define D3DX_16F_MAX 6.550400e+004 /* max value */ +#define D3DX_16F_MAX_10_EXP 4 /* max decimal exponent */ +#define D3DX_16F_MAX_EXP 15 /* max binary exponent */ +#define D3DX_16F_MIN 6.1035156e-5f /* min positive value */ +#define D3DX_16F_MIN_10_EXP (-4) /* min decimal exponent */ +#define D3DX_16F_MIN_EXP (-14) /* min binary exponent */ +#define D3DX_16F_RADIX 2 /* exponent radix */ +#define D3DX_16F_ROUNDS 1 /* addition rounding: near */ typedef struct D3DXFLOAT16 @@ -79,9 +75,9 @@ protected: */ -//-------------------------- -// 2D Vector -//-------------------------- +/* + * 2D Vector + */ typedef struct D3DXVECTOR2 { #ifdef __cplusplus @@ -122,11 +118,9 @@ public: FLOAT x, y; } D3DXVECTOR2, *LPD3DXVECTOR2; - - -//-------------------------- -// 2D Vector (16 bit) -//-------------------------- +/* + * 2D Vector (16 bit) + */ typedef struct D3DXVECTOR2_16F { @@ -410,11 +404,11 @@ typedef D3DXMATRIX _D3DXMATRIXA16; typedef D3DX_ALIGN16 _D3DXMATRIXA16 D3DXMATRIXA16, *LPD3DXMATRIXA16; -//=========================================================================== -// -// Quaternions -// -//=========================================================================== +/* + * + * Quaternions + */ + typedef struct D3DXQUATERNION { #ifdef __cplusplus @@ -424,22 +418,22 @@ public: D3DXQUATERNION( CONST D3DXFLOAT16 * ); D3DXQUATERNION( FLOAT x, FLOAT y, FLOAT z, FLOAT w ); - // casting + /* casting */ operator FLOAT* (); operator CONST FLOAT* () const; - // assignment operators + /* assignment operators */ D3DXQUATERNION& operator += ( CONST D3DXQUATERNION& ); D3DXQUATERNION& operator -= ( CONST D3DXQUATERNION& ); D3DXQUATERNION& operator *= ( CONST D3DXQUATERNION& ); D3DXQUATERNION& operator *= ( FLOAT ); D3DXQUATERNION& operator /= ( FLOAT ); - // unary operators + /* unary operators */ D3DXQUATERNION operator + () const; D3DXQUATERNION operator - () const; - // binary operators + /* binary operators */ D3DXQUATERNION operator + ( CONST D3DXQUATERNION& ) const; D3DXQUATERNION operator - ( CONST D3DXQUATERNION& ) const; D3DXQUATERNION operator * ( CONST D3DXQUATERNION& ) const; @@ -451,16 +445,14 @@ public: BOOL operator == ( CONST D3DXQUATERNION& ) const; BOOL operator != ( CONST D3DXQUATERNION& ) const; -#endif //__cplusplus +#endif /* __cplusplus */ FLOAT x, y, z, w; } D3DXQUATERNION, *LPD3DXQUATERNION; - -//=========================================================================== -// -// Planes -// -//=========================================================================== +/* + * + * Planes + */ typedef struct D3DXPLANE { #ifdef __cplusplus diff --git a/gfx/include/d3d9/d3dx9mesh.h b/gfx/include/d3d9/d3dx9mesh.h index 68a4c77d5c..beccf99ff6 100644 --- a/gfx/include/d3d9/d3dx9mesh.h +++ b/gfx/include/d3d9/d3dx9mesh.h @@ -16,36 +16,37 @@ DEFINE_GUID(IID_ID3DXBaseMesh, 0x7ed943dd, 0x52e8, 0x40b5, 0xa8, 0xd8, 0x76, 0x68, 0x5c, 0x40, 0x63, 0x30); -// {4020E5C2-1403-4929-883F-E2E849FAC195} +/* {4020E5C2-1403-4929-883F-E2E849FAC195} */ DEFINE_GUID(IID_ID3DXMesh, 0x4020e5c2, 0x1403, 0x4929, 0x88, 0x3f, 0xe2, 0xe8, 0x49, 0xfa, 0xc1, 0x95); -// {8875769A-D579-4088-AAEB-534D1AD84E96} +/* {8875769A-D579-4088-AAEB-534D1AD84E96} */ DEFINE_GUID(IID_ID3DXPMesh, 0x8875769a, 0xd579, 0x4088, 0xaa, 0xeb, 0x53, 0x4d, 0x1a, 0xd8, 0x4e, 0x96); -// {667EA4C7-F1CD-4386-B523-7C0290B83CC5} +/* {667EA4C7-F1CD-4386-B523-7C0290B83CC5} */ DEFINE_GUID(IID_ID3DXSPMesh, 0x667ea4c7, 0xf1cd, 0x4386, 0xb5, 0x23, 0x7c, 0x2, 0x90, 0xb8, 0x3c, 0xc5); -// {11EAA540-F9A6-4d49-AE6A-E19221F70CC4} +/* {11EAA540-F9A6-4d49-AE6A-E19221F70CC4} */ DEFINE_GUID(IID_ID3DXSkinInfo, 0x11eaa540, 0xf9a6, 0x4d49, 0xae, 0x6a, 0xe1, 0x92, 0x21, 0xf7, 0xc, 0xc4); -// {3CE6CC22-DBF2-44f4-894D-F9C34A337139} +/* {3CE6CC22-DBF2-44f4-894D-F9C34A337139} */ DEFINE_GUID(IID_ID3DXPatchMesh, 0x3ce6cc22, 0xdbf2, 0x44f4, 0x89, 0x4d, 0xf9, 0xc3, 0x4a, 0x33, 0x71, 0x39); -//patch mesh can be quads or tris -typedef enum _D3DXPATCHMESHTYPE { +/* patch mesh can be quads or tris */ +typedef enum _D3DXPATCHMESHTYPE +{ D3DXPATCHMESH_RECT = 0x001, D3DXPATCHMESH_TRI = 0x002, D3DXPATCHMESH_NPATCH = 0x003, - D3DXPATCHMESH_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ + D3DXPATCHMESH_FORCE_DWORD = 0x7fffffff /* force 32-bit size enum */ } D3DXPATCHMESHTYPE; -// Mesh options - lower 3 bytes only, upper byte used by _D3DXMESHOPT option flags +/* Mesh options - lower 3 bytes only, upper byte used by _D3DXMESHOPT option flags */ enum _D3DXMESH { D3DXMESH_32BIT = 0x001, // If set, then use 32 bit indices, if not set use 16 bit indices. D3DXMESH_DONOTCLIP = 0x002, // Use D3DUSAGE_DONOTCLIP for VB & IB. @@ -73,14 +74,14 @@ enum _D3DXMESH { D3DXMESH_WRITEONLY = 0x440, // D3DXMESH_VB_WRITEONLY | D3DXMESH_IB_WRITEONLY D3DXMESH_DYNAMIC = 0x880, // D3DXMESH_VB_DYNAMIC | D3DXMESH_IB_DYNAMIC D3DXMESH_SOFTWAREPROCESSING = 0x18000 // D3DXMESH_VB_SOFTWAREPROCESSING | D3DXMESH_IB_SOFTWAREPROCESSING - }; -//patch mesh options +/* patch mesh options */ enum _D3DXPATCHMESH { - D3DXPATCHMESH_DEFAULT = 000, + D3DXPATCHMESH_DEFAULT = 000 }; -// option field values for specifying min value in D3DXGeneratePMesh and D3DXSimplifyMesh + +/* option field values for specifying min value in D3DXGeneratePMesh and D3DXSimplifyMesh */ enum _D3DXMESHSIMP { D3DXMESHSIMP_VERTEX = 0x1, @@ -91,15 +92,15 @@ typedef enum _D3DXCLEANTYPE { D3DXCLEAN_BACKFACING = 0x00000001, D3DXCLEAN_BOWTIES = 0x00000002, - // Helper options - D3DXCLEAN_SKINNING = D3DXCLEAN_BACKFACING, // Bowtie cleaning modifies geometry and breaks skinning + /* Helper options */ + D3DXCLEAN_SKINNING = D3DXCLEAN_BACKFACING, /* Bowtie cleaning modifies geometry and breaks skinning */ D3DXCLEAN_OPTIMIZATION = D3DXCLEAN_BACKFACING, D3DXCLEAN_SIMPLIFICATION= D3DXCLEAN_BACKFACING | D3DXCLEAN_BOWTIES } D3DXCLEANTYPE; enum _MAX_FVF_DECL_SIZE { - MAX_FVF_DECL_SIZE = MAXD3DDECLLENGTH + 1 // +1 for END + MAX_FVF_DECL_SIZE = MAXD3DDECLLENGTH + 1 /* +1 for END */ }; typedef enum _D3DXTANGENT @@ -118,9 +119,10 @@ typedef enum _D3DXTANGENT D3DXTANGENT_GENERATE_IN_PLACE = 0x0400 } D3DXTANGENT; -// D3DXIMT_WRAP_U means the texture wraps in the U direction -// D3DXIMT_WRAP_V means the texture wraps in the V direction -// D3DXIMT_WRAP_UV means the texture wraps in both directions +/* D3DXIMT_WRAP_U means the texture wraps in the U direction + * D3DXIMT_WRAP_V means the texture wraps in the V direction + * D3DXIMT_WRAP_UV means the texture wraps in both directions + */ typedef enum _D3DXIMT { D3DXIMT_WRAP_U = 0x01, @@ -128,10 +130,11 @@ typedef enum _D3DXIMT D3DXIMT_WRAP_UV = 0x03 } D3DXIMT; -// These options are only valid for UVAtlasCreate and UVAtlasPartition, we may add more for UVAtlasPack if necessary -// D3DXUVATLAS_DEFAULT - Meshes with more than 25k faces go through fast, meshes with fewer than 25k faces go through quality -// D3DXUVATLAS_GEODESIC_FAST - Uses approximations to improve charting speed at the cost of added stretch or more charts. -// D3DXUVATLAS_GEODESIC_QUALITY - Provides better quality charts, but requires more time and memory than fast. +/* These options are only valid for UVAtlasCreate and UVAtlasPartition, we may add more for UVAtlasPack if necessary + * D3DXUVATLAS_DEFAULT - Meshes with more than 25k faces go through fast, meshes with fewer than 25k faces go through quality + * D3DXUVATLAS_GEODESIC_FAST - Uses approximations to improve charting speed at the cost of added stretch or more charts. + * D3DXUVATLAS_GEODESIC_QUALITY - Provides better quality charts, but requires more time and memory than fast. + */ typedef enum _D3DXUVATLAS { D3DXUVATLAS_DEFAULT = 0x00, @@ -169,9 +172,9 @@ typedef D3DXMATERIAL *LPD3DXMATERIAL; typedef enum _D3DXEFFECTDEFAULTTYPE { - D3DXEDT_STRING = 0x1, // pValue points to a null terminated ASCII string - D3DXEDT_FLOATS = 0x2, // pValue points to an array of floats - number of floats is NumBytes / sizeof(float) - D3DXEDT_DWORD = 0x3, // pValue points to a DWORD + D3DXEDT_STRING = 0x1, /* pValue points to a null terminated ASCII string */ + D3DXEDT_FLOATS = 0x2, /* pValue points to an array of floats - number of floats is NumBytes / sizeof(float) */ + D3DXEDT_DWORD = 0x3, /* pValue points to a DWORD */ D3DXEDT_FORCEDWORD = 0x7fffffff } D3DXEFFECTDEFAULTTYPE; @@ -179,9 +182,9 @@ typedef enum _D3DXEFFECTDEFAULTTYPE typedef struct _D3DXEFFECTDEFAULT { LPSTR pParamName; - D3DXEFFECTDEFAULTTYPE Type; // type of the data pointed to by pValue - DWORD NumBytes; // size in bytes of the data pointed to by pValue - LPVOID pValue; // data for the default of the effect + D3DXEFFECTDEFAULTTYPE Type; /* type of the data pointed to by pValue */ + DWORD NumBytes; /* size in bytes of the data pointed to by pValue */ + LPVOID pValue; /* data for the default of the effect */ } D3DXEFFECTDEFAULT, *LPD3DXEFFECTDEFAULT; typedef struct _D3DXEFFECTINSTANCE @@ -205,25 +208,29 @@ typedef struct _D3DXATTRIBUTEWEIGHTS enum _D3DXWELDEPSILONSFLAGS { - D3DXWELDEPSILONS_WELDALL = 0x1, // weld all vertices marked by adjacency as being overlapping + D3DXWELDEPSILONS_WELDALL = 0x1, /* weld all vertices marked by adjacency as being overlapping */ - D3DXWELDEPSILONS_WELDPARTIALMATCHES = 0x2, // if a given vertex component is within epsilon, modify partial matched - // vertices so that both components identical AND if all components "equal" - // remove one of the vertices - D3DXWELDEPSILONS_DONOTREMOVEVERTICES = 0x4, // instructs weld to only allow modifications to vertices and not removal - // ONLY valid if D3DXWELDEPSILONS_WELDPARTIALMATCHES is set - // useful to modify vertices to be equal, but not allow vertices to be removed + D3DXWELDEPSILONS_WELDPARTIALMATCHES = 0x2, /* if a given vertex component is within epsilon, modify partial matched + * vertices so that both components identical AND if all components "equal" + * remove one of the vertices + */ + D3DXWELDEPSILONS_DONOTREMOVEVERTICES = 0x4, /* instructs weld to only allow modifications to vertices and not removal + * ONLY valid if D3DXWELDEPSILONS_WELDPARTIALMATCHES is set + * useful to modify vertices to be equal, but not allow vertices to be removed + */ - D3DXWELDEPSILONS_DONOTSPLIT = 0x8 // instructs weld to specify the D3DXMESHOPT_DONOTSPLIT flag when doing an Optimize(ATTR_SORT) - // if this flag is not set, all vertices that are in separate attribute groups - // will remain split and not welded. Setting this flag can slow down software vertex processing + D3DXWELDEPSILONS_DONOTSPLIT = 0x8 /* instructs weld to specify the D3DXMESHOPT_DONOTSPLIT flag when doing an Optimize(ATTR_SORT) + * if this flag is not set, all vertices that are in separate attribute groups + * will remain split and not welded. Setting this flag can slow down software vertex processing + */ }; typedef struct _D3DXWELDEPSILONS { - FLOAT Position; // NOTE: This does NOT replace the epsilon in GenerateAdjacency - // in general, it should be the same value or greater than the one passed to GeneratedAdjacency + FLOAT Position; /* NOTE: This does NOT replace the epsilon in GenerateAdjacency + * in general, it should be the same value or greater than the one passed to GeneratedAdjacency + */ FLOAT BlendWeights; FLOAT Normal; FLOAT PSize; @@ -243,12 +250,12 @@ typedef D3DXWELDEPSILONS* LPD3DXWELDEPSILONS; DECLARE_INTERFACE_(ID3DXBaseMesh, IUnknown) { - // IUnknown + /* IUnknown */ STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; STDMETHOD_(ULONG, AddRef)(THIS) PURE; STDMETHOD_(ULONG, Release)(THIS) PURE; - // ID3DXBaseMesh + /* ID3DXBaseMesh */ STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE; STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; @@ -283,12 +290,12 @@ DECLARE_INTERFACE_(ID3DXBaseMesh, IUnknown) DECLARE_INTERFACE_(ID3DXMesh, ID3DXBaseMesh) { - // IUnknown + /* IUnknown */ STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; STDMETHOD_(ULONG, AddRef)(THIS) PURE; STDMETHOD_(ULONG, Release)(THIS) PURE; - // ID3DXBaseMesh + /* ID3DXBaseMesh */ STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE; STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; @@ -316,7 +323,7 @@ DECLARE_INTERFACE_(ID3DXMesh, ID3DXBaseMesh) STDMETHOD(UpdateSemantics)(THIS_ D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]) PURE; - // ID3DXMesh + /* ID3DXMesh */ STDMETHOD(LockAttributeBuffer)(THIS_ DWORD Flags, DWORD** ppData) PURE; STDMETHOD(UnlockAttributeBuffer)(THIS) PURE; STDMETHOD(Optimize)(THIS_ DWORD Flags, CONST DWORD* pAdjacencyIn, DWORD* pAdjacencyOut, @@ -333,12 +340,12 @@ DECLARE_INTERFACE_(ID3DXMesh, ID3DXBaseMesh) DECLARE_INTERFACE_(ID3DXPMesh, ID3DXBaseMesh) { - // IUnknown + /* IUnknown */ STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; STDMETHOD_(ULONG, AddRef)(THIS) PURE; STDMETHOD_(ULONG, Release)(THIS) PURE; - // ID3DXBaseMesh + /* ID3DXBaseMesh */ STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE; STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; @@ -366,7 +373,7 @@ DECLARE_INTERFACE_(ID3DXPMesh, ID3DXBaseMesh) STDMETHOD(UpdateSemantics)(THIS_ D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]) PURE; - // ID3DXPMesh + /* ID3DXPMesh */ STDMETHOD(ClonePMeshFVF)(THIS_ DWORD Options, DWORD FVF, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXPMESH* ppCloneMesh) PURE; STDMETHOD(ClonePMesh)(THIS_ DWORD Options, @@ -389,8 +396,8 @@ DECLARE_INTERFACE_(ID3DXPMesh, ID3DXBaseMesh) STDMETHOD(GetAdjacency)(THIS_ DWORD* pAdjacency) PURE; - // Used to generate the immediate "ancestor" for each vertex when it is removed by a vsplit. Allows generation of geomorphs - // Vertex buffer must be equal to or greater than the maximum number of vertices in the pmesh + /* Used to generate the immediate "ancestor" for each vertex when it is removed by a vsplit. Allows generation of geomorphs + * Vertex buffer must be equal to or greater than the maximum number of vertices in the pmesh */ STDMETHOD(GenerateVertexHistory)(THIS_ DWORD* pVertexHistory) PURE; }; @@ -400,12 +407,12 @@ DECLARE_INTERFACE_(ID3DXPMesh, ID3DXBaseMesh) DECLARE_INTERFACE_(ID3DXSPMesh, IUnknown) { - // IUnknown + /* IUnknown */ STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; STDMETHOD_(ULONG, AddRef)(THIS) PURE; STDMETHOD_(ULONG, Release)(THIS) PURE; - // ID3DXSPMesh + /* ID3DXSPMesh */ STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; STDMETHOD_(DWORD, GetFVF)(THIS) PURE; @@ -431,22 +438,23 @@ DECLARE_INTERFACE_(ID3DXSPMesh, IUnknown) #define UNUSED16 (0xffff) #define UNUSED32 (0xffffffff) -// ID3DXMesh::Optimize options - upper byte only, lower 3 bytes used from _D3DXMESH option flags -enum _D3DXMESHOPT { - D3DXMESHOPT_COMPACT = 0x01000000, - D3DXMESHOPT_ATTRSORT = 0x02000000, - D3DXMESHOPT_VERTEXCACHE = 0x04000000, - D3DXMESHOPT_STRIPREORDER = 0x08000000, - D3DXMESHOPT_IGNOREVERTS = 0x10000000, // optimize faces only, don't touch vertices - D3DXMESHOPT_DONOTSPLIT = 0x20000000, // do not split vertices shared between attribute groups when attribute sorting - D3DXMESHOPT_DEVICEINDEPENDENT = 0x00400000 // Only affects VCache. uses a static known good cache size for all cards +/* ID3DXMesh::Optimize options - upper byte only, lower 3 bytes used from _D3DXMESH option flags */ +enum _D3DXMESHOPT +{ + D3DXMESHOPT_COMPACT = 0x01000000, + D3DXMESHOPT_ATTRSORT = 0x02000000, + D3DXMESHOPT_VERTEXCACHE = 0x04000000, + D3DXMESHOPT_STRIPREORDER = 0x08000000, + D3DXMESHOPT_IGNOREVERTS = 0x10000000, /* optimize faces only, don't touch vertices */ + D3DXMESHOPT_DONOTSPLIT = 0x20000000, /* do not split vertices shared between attribute groups when attribute sorting */ + D3DXMESHOPT_DEVICEINDEPENDENT = 0x00400000 /* Only affects VCache. uses a static known good cache size for all cards */ - // D3DXMESHOPT_SHAREVB has been removed, please use D3DXMESH_VB_SHARE instead + /* D3DXMESHOPT_SHAREVB has been removed, please use D3DXMESH_VB_SHARE instead */ }; -// Subset of the mesh that has the same attribute and bone combination. -// This subset can be rendered in a single draw call +/* Subset of the mesh that has the same attribute and bone combination. + * This subset can be rendered in a single draw call */ typedef struct _D3DXBONECOMBINATION { DWORD AttribId; @@ -457,13 +465,14 @@ typedef struct _D3DXBONECOMBINATION DWORD* BoneId; } D3DXBONECOMBINATION, *LPD3DXBONECOMBINATION; -// The following types of patch combinations are supported: -// Patch type Basis Degree -// Rect Bezier 2,3,5 -// Rect B-Spline 2,3,5 -// Rect Catmull-Rom 3 -// Tri Bezier 2,3,5 -// N-Patch N/A 3 +/* The following types of patch combinations are supported: + * Patch type Basis Degree + * Rect Bezier 2,3,5 + * Rect B-Spline 2,3,5 + * Rect Catmull-Rom 3 + * Tri Bezier 2,3,5 + * N-Patch N/A 3 + */ typedef struct _D3DXPATCHINFO { @@ -477,14 +486,14 @@ typedef struct _D3DXPATCHINFO DECLARE_INTERFACE_(ID3DXPatchMesh, IUnknown) { - // IUnknown + /* IUnknown */ STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; STDMETHOD_(ULONG, AddRef)(THIS) PURE; STDMETHOD_(ULONG, Release)(THIS) PURE; - // ID3DXPatchMesh + /* ID3DXPatchMesh */ - // Return creation parameters + /* Return creation parameters */ STDMETHOD_(DWORD, GetNumPatches)(THIS) PURE; STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; STDMETHOD(GetDeclaration)(THIS_ D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]) PURE; @@ -493,7 +502,7 @@ DECLARE_INTERFACE_(ID3DXPatchMesh, IUnknown) STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9 *ppDevice) PURE; STDMETHOD(GetPatchInfo)(THIS_ LPD3DXPATCHINFO PatchInfo) PURE; - // Control mesh access + /* Control mesh access */ STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER9* ppVB) PURE; STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER9* ppIB) PURE; STDMETHOD(LockVertexBuffer)(THIS_ DWORD flags, LPVOID *ppData) PURE; @@ -2724,20 +2733,19 @@ HRESULT WINAPI #ifdef __cplusplus } -#endif //__cplusplus +#endif /* __cplusplus */ -////////////////////////////////////////////////////////////////////////////// -// -// Definitions of .X file templates used by mesh load/save functions -// that are not RM standard -// -////////////////////////////////////////////////////////////////////////////// +/* + * + * Definitions of .X file templates used by mesh load/save functions + * that are not RM standard + */ -// {3CF169CE-FF7C-44ab-93C0-F78F62D172E2} +/* {3CF169CE-FF7C-44ab-93C0-F78F62D172E2} */ DEFINE_GUID(DXFILEOBJ_XSkinMeshHeader, 0x3cf169ce, 0xff7c, 0x44ab, 0x93, 0xc0, 0xf7, 0x8f, 0x62, 0xd1, 0x72, 0xe2); -// {B8D65549-D7C9-4995-89CF-53A9A8B031E3} +/* {B8D65549-D7C9-4995-89CF-53A9A8B031E3} */ DEFINE_GUID(DXFILEOBJ_VertexDuplicationIndices, 0xb8d65549, 0xd7c9, 0x4995, 0x89, 0xcf, 0x53, 0xa9, 0xa8, 0xb0, 0x31, 0xe3); @@ -2801,23 +2809,23 @@ DEFINE_GUID(DXFILEOBJ_EffectDWord, DEFINE_GUID(DXFILEOBJ_EffectParamFloats, 0x3014b9a0, 0x62f5, 0x478c, 0x9b, 0x86, 0xe4, 0xac, 0x9f, 0x4e, 0x41, 0x8b); -// {1DBC4C88-94C1-46ee-9076-2C28818C9481} +/* {1DBC4C88-94C1-46ee-9076-2C28818C9481} */ DEFINE_GUID(DXFILEOBJ_EffectParamString, 0x1dbc4c88, 0x94c1, 0x46ee, 0x90, 0x76, 0x2c, 0x28, 0x81, 0x8c, 0x94, 0x81); -// {E13963BC-AE51-4c5d-B00F-CFA3A9D97CE5} +/* {E13963BC-AE51-4c5d-B00F-CFA3A9D97CE5} */ DEFINE_GUID(DXFILEOBJ_EffectParamDWord, 0xe13963bc, 0xae51, 0x4c5d, 0xb0, 0xf, 0xcf, 0xa3, 0xa9, 0xd9, 0x7c, 0xe5); -// {E331F7E4-0559-4cc2-8E99-1CEC1657928F} +/* {E331F7E4-0559-4cc2-8E99-1CEC1657928F} */ DEFINE_GUID(DXFILEOBJ_EffectInstance, 0xe331f7e4, 0x559, 0x4cc2, 0x8e, 0x99, 0x1c, 0xec, 0x16, 0x57, 0x92, 0x8f); -// {9E415A43-7BA6-4a73-8743-B73D47E88476} +/* {9E415A43-7BA6-4a73-8743-B73D47E88476} */ DEFINE_GUID(DXFILEOBJ_AnimTicksPerSecond, 0x9e415a43, 0x7ba6, 0x4a73, 0x87, 0x43, 0xb7, 0x3d, 0x47, 0xe8, 0x84, 0x76); -// {7F9B00B3-F125-4890-876E-1CFFBF697C4D} +/* {7F9B00B3-F125-4890-876E-1CFFBF697C4D} */ DEFINE_GUID(DXFILEOBJ_CompressedAnimationSet, 0x7f9b00b3, 0xf125, 0x4890, 0x87, 0x6e, 0x1c, 0x42, 0xbf, 0x69, 0x7c, 0x4d); From e225e960257aa62baf8a6e8a3bbaa81ea04469f9 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Sat, 3 Feb 2018 13:29:00 +0100 Subject: [PATCH 031/232] (D3D11) multi-pass shaders: add support for history frames. --- gfx/common/d3d11_common.h | 24 +- gfx/drivers/d3d11.c | 434 ++++++++++++---------- gfx/drivers_font/d3d11_font.c | 18 +- gfx/drivers_shader/slang_process.cpp | 21 +- gfx/video_shader_parse.h | 6 + menu/drivers_display/menu_display_d3d11.c | 38 +- 6 files changed, 302 insertions(+), 239 deletions(-) diff --git a/gfx/common/d3d11_common.h b/gfx/common/d3d11_common.h index 9bf6b76178..1ef9d08002 100644 --- a/gfx/common/d3d11_common.h +++ b/gfx/common/d3d11_common.h @@ -213,7 +213,8 @@ static INLINE void D3D11SetPShaderResources( ID3D11ShaderResourceView* const* shader_resource_views) { device_context->lpVtbl->PSSetShaderResources( - device_context, start_slot, num_views, shader_resource_views); + device_context, start_slot, num_views, + shader_resource_views); } static INLINE void D3D11SetPShader( D3D11DeviceContext device_context, @@ -225,13 +226,13 @@ static INLINE void D3D11SetPShader( device_context, pixel_shader, class_instances, num_class_instances); } static INLINE void D3D11SetPShaderSamplers( - D3D11DeviceContext device_context, - UINT start_slot, - UINT num_samplers, - D3D11SamplerStateRef* samplers) + D3D11DeviceContext device_context, + UINT start_slot, + UINT num_samplers, + ID3D11SamplerState* const* samplers) { device_context->lpVtbl->PSSetSamplers( - device_context, start_slot, num_samplers, (D3D11SamplerState* const)samplers); + device_context, start_slot, num_samplers, samplers); } static INLINE void D3D11SetVShader( D3D11DeviceContext device_context, @@ -2499,7 +2500,7 @@ typedef struct DXGISwapChain swapChain; D3D11Device device; D3D_FEATURE_LEVEL supportedFeatureLevel; - D3D11DeviceContext ctx; + D3D11DeviceContext context; D3D11RasterizerState state; D3D11RenderTargetView renderTargetView; D3D11Buffer ubo; @@ -2518,7 +2519,8 @@ typedef struct bool resize_chain; bool keep_aspect; bool resize_viewport; - bool resize_fbos; + bool resize_render_targets; + bool init_history; d3d11_shader_t shaders[GFX_MAX_SHADERS]; struct @@ -2541,7 +2543,7 @@ typedef struct struct { - d3d11_texture_t texture; + d3d11_texture_t texture[GFX_MAX_FRAME_HISTORY + 1]; D3D11Buffer vbo; D3D11Buffer ubo; D3D11_VIEWPORT viewport; @@ -2558,8 +2560,6 @@ typedef struct d3d11_texture_t feedback; D3D11_VIEWPORT viewport; pass_semantics_t semantics; - D3D11ShaderResourceViewRef textures[SLANG_NUM_BINDINGS]; - D3D11SamplerStateRef samplers[SLANG_NUM_BINDINGS]; uint32_t frame_count; } pass[GFX_MAX_SHADERS]; @@ -2612,7 +2612,7 @@ static INLINE void d3d11_set_texture_and_sampler(D3D11DeviceContext ctx, UINT slot, d3d11_texture_t* texture) { D3D11SetPShaderResources(ctx, slot, 1, &texture->view); - D3D11SetPShaderSamplers(ctx, slot, 1, &texture->sampler); + D3D11SetPShaderSamplers(ctx, slot, 1, (D3D11SamplerState*)&texture->sampler); } static INLINE void d3d11_set_shader(D3D11DeviceContext ctx, d3d11_shader_t* shader) diff --git a/gfx/drivers/d3d11.c b/gfx/drivers/d3d11.c index e4375a05ef..fdff674aca 100644 --- a/gfx/drivers/d3d11.c +++ b/gfx/drivers/d3d11.c @@ -56,15 +56,13 @@ static void d3d11_gfx_set_rotation(void* data, unsigned rotation) if (!d3d11) return; - d3d11->frame.rotation = rotation; - - matrix_4x4_rotate_z(rot, d3d11->frame.rotation * (M_PI / 2.0f)); + matrix_4x4_rotate_z(rot, rotation * (M_PI / 2.0f)); matrix_4x4_multiply(d3d11->mvp, rot, d3d11->ubo_values.mvp); D3D11_MAPPED_SUBRESOURCE mapped_ubo; - D3D11MapBuffer(d3d11->ctx, d3d11->frame.ubo, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped_ubo); + D3D11MapBuffer(d3d11->context, d3d11->frame.ubo, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped_ubo); *(math_matrix_4x4*)mapped_ubo.pData = d3d11->mvp; - D3D11UnmapBuffer(d3d11->ctx, d3d11->frame.ubo, 0); + D3D11UnmapBuffer(d3d11->context, d3d11->frame.ubo, 0); } static void d3d11_update_viewport(void* data, bool force_full) @@ -79,9 +77,10 @@ static void d3d11_update_viewport(void* data, bool force_full) d3d11->frame.viewport.Height = d3d11->vp.height; d3d11->frame.viewport.MaxDepth = 0.0f; d3d11->frame.viewport.MaxDepth = 1.0f; - if (d3d11->frame.output_size.x != d3d11->vp.width || - d3d11->frame.output_size.y != d3d11->vp.height) - d3d11->resize_fbos = true; + + if (d3d11->shader_preset && (d3d11->frame.output_size.x != d3d11->vp.width || + d3d11->frame.output_size.y != d3d11->vp.height)) + d3d11->resize_render_targets = true; d3d11->frame.output_size.x = d3d11->vp.width; d3d11->frame.output_size.y = d3d11->vp.height; @@ -114,13 +113,23 @@ static void d3d11_free_shader_preset(d3d11_video_t* d3d11) memset(d3d11->pass, 0, sizeof(d3d11->pass)); + /* only free the history textures here */ + for (int i = 1; i <= d3d11->shader_preset->history_size; i++) + d3d11_release_texture(&d3d11->frame.texture[i]); + + memset( + &d3d11->frame.texture[1], 0, + sizeof(d3d11->frame.texture[1]) * d3d11->shader_preset->history_size); + for (int i = 0; i < d3d11->shader_preset->luts; i++) d3d11_release_texture(&d3d11->luts[i]); memset(d3d11->luts, 0, sizeof(d3d11->luts)); free(d3d11->shader_preset); - d3d11->shader_preset = NULL; + d3d11->shader_preset = NULL; + d3d11->init_history = false; + d3d11->resize_render_targets = false; } static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const char* path) @@ -130,11 +139,9 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const if (!d3d11) return false; - D3D11Flush(d3d11->ctx); + D3D11Flush(d3d11->context); d3d11_free_shader_preset(d3d11); - d3d11->resize_fbos = true; - if (!path) return true; @@ -156,28 +163,34 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const video_shader_resolve_relative(d3d11->shader_preset, path); - d3d11_texture_t* source = &d3d11->frame.texture; - for (int i = 0; i < d3d11->shader_preset->passes; i++) + d3d11_texture_t* source = &d3d11->frame.texture[0]; + + for (int i = 0; i < d3d11->shader_preset->passes; source = &d3d11->pass[i++].rt) { { - /* no history support yet */ - texture_map_t texture_map[3 + GFX_MAX_SHADERS * 2 + GFX_MAX_TEXTURES + 1] = { - SL_TEXTURE_MAP( - SLANG_TEXTURE_SEMANTIC_ORIGINAL, d3d11->frame.texture.view, - d3d11->pass[i].sampler, d3d11->frame.texture.size_data), - SL_TEXTURE_MAP( - SLANG_TEXTURE_SEMANTIC_SOURCE, source->view, d3d11->pass[i].sampler, - source->size_data), - SL_TEXTURE_MAP( - SLANG_TEXTURE_SEMANTIC_ORIGINAL_HISTORY, d3d11->frame.texture.view, - d3d11->pass[i].sampler, d3d11->frame.texture.size_data), - }; + texture_map_t texture_map + [3 + GFX_MAX_FRAME_HISTORY + 1 + GFX_MAX_SHADERS * 2 + GFX_MAX_TEXTURES + 1] = { + SL_TEXTURE_MAP( + SLANG_TEXTURE_SEMANTIC_ORIGINAL, d3d11->frame.texture[0].view, + d3d11->pass[i].sampler, d3d11->frame.texture[0].size_data), + SL_TEXTURE_MAP( + SLANG_TEXTURE_SEMANTIC_SOURCE, source->view, d3d11->pass[i].sampler, + source->size_data), + }; { texture_map_t* ptr = texture_map; while (ptr->texture_data) ptr++; + for (int j = 0; j < GFX_MAX_FRAME_HISTORY + 1; j++) + { + *ptr = (texture_map_t)SL_TEXTURE_MAP_ARRAY( + SLANG_TEXTURE_SEMANTIC_ORIGINAL_HISTORY, j, d3d11->frame.texture[j].view, + d3d11->pass[i].sampler, d3d11->frame.texture[j].size_data); + ptr++; + } + for (int j = 0; j < i; j++) { *ptr = (texture_map_t)SL_TEXTURE_MAP_ARRAY( @@ -293,8 +306,6 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const D3D11CreateBuffer(d3d11->device, &desc, NULL, &d3d11->pass[i].buffers[j]); } - - source = &d3d11->pass[i].rt; } for (int i = 0; i < d3d11->shader_preset->luts; i++) @@ -304,6 +315,7 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const if (!image_texture_load(&image, d3d11->shader_preset->lut[i].path)) goto error; + d3d11->luts[i].desc.Width = image.width; d3d11->luts[i].desc.Height = image.height; d3d11->luts[i].desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; @@ -314,7 +326,7 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const d3d11_init_texture(d3d11->device, &d3d11->luts[i]); d3d11_update_texture( - d3d11->ctx, image.width, image.height, 0, DXGI_FORMAT_R8G8B8A8_UNORM, image.pixels, + d3d11->context, image.width, image.height, 0, DXGI_FORMAT_R8G8B8A8_UNORM, image.pixels, &d3d11->luts[i]); image_texture_free(&image); @@ -326,6 +338,9 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const video_shader_resolve_current_parameters(conf, d3d11->shader_preset); config_file_free(conf); + d3d11->resize_render_targets = true; + d3d11->init_history = true; + return true; error: @@ -342,7 +357,7 @@ static void d3d11_gfx_free(void* data) d3d11_free_shader_preset(d3d11); - d3d11_release_texture(&d3d11->frame.texture); + d3d11_release_texture(&d3d11->frame.texture[0]); Release(d3d11->frame.ubo); Release(d3d11->frame.vbo); @@ -381,7 +396,7 @@ static void d3d11_gfx_free(void* data) font_driver_free_osd(); - Release(d3d11->ctx); + Release(d3d11->context); Release(d3d11->device); win32_monitor_from_window(); @@ -454,7 +469,7 @@ d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** i D3D11CreateDeviceAndSwapChain( NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, flags, &requested_feature_level, 1, D3D11_SDK_VERSION, &desc, (IDXGISwapChain**)&d3d11->swapChain, &d3d11->device, - &d3d11->supportedFeatureLevel, &d3d11->ctx); + &d3d11->supportedFeatureLevel, &d3d11->context); } { @@ -465,7 +480,7 @@ d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** i Release(backBuffer); } - D3D11SetRenderTargets(d3d11->ctx, 1, &d3d11->renderTargetView, NULL); + D3D11SetRenderTargets(d3d11->context, 1, &d3d11->renderTargetView, NULL); video_driver_set_size(&d3d11->vp.full_width, &d3d11->vp.full_height); d3d11->viewport.Width = d3d11->vp.full_width; @@ -474,8 +489,8 @@ d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** i d3d11->vsync = video->vsync; d3d11->format = video->rgb32 ? DXGI_FORMAT_B8G8R8X8_UNORM : DXGI_FORMAT_B5G6R5_UNORM; - d3d11->frame.texture.desc.Format = d3d11->format; - d3d11->frame.texture.desc.Usage = D3D11_USAGE_DEFAULT; + d3d11->frame.texture[0].desc.Format = d3d11->format; + d3d11->frame.texture[0].desc.Usage = D3D11_USAGE_DEFAULT; d3d11->menu.texture.desc.Usage = D3D11_USAGE_DEFAULT; @@ -713,7 +728,7 @@ d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** i }; D3D11CreateRasterizerState(d3d11->device, &desc, &d3d11->state); } - D3D11SetState(d3d11->ctx, d3d11->state); + D3D11SetState(d3d11->context, d3d11->state); font_driver_init_osd(d3d11, false, video->is_threaded, FONT_DRIVER_RENDER_D3D11_API); @@ -731,117 +746,118 @@ error: d3d11_gfx_free(d3d11); return NULL; } -static bool d3d11_init_frame_textures(d3d11_video_t* d3d11, unsigned width, unsigned height) + +static void d3d11_init_history(d3d11_video_t* d3d11, unsigned width, unsigned height) { - if (d3d11->shader_preset) + /* todo: should we init history to max_width/max_height instead ? + * to prevent out of memory errors happening several frames later + * and to reduce memory fragmentation */ + + assert(d3d11->shader_preset); + for (int i = 0; i < d3d11->shader_preset->history_size + 1; i++) { - for (int i = 0; i < d3d11->shader_preset->passes; i++) - { - d3d11_release_texture(&d3d11->pass[i].rt); - memset(&d3d11->pass[i].rt, 0x00, sizeof(d3d11->pass[i].rt)); - } + d3d11->frame.texture[i].desc.Width = width; + d3d11->frame.texture[i].desc.Height = height; + d3d11->frame.texture[i].desc.Format = d3d11->frame.texture[0].desc.Format; + d3d11->frame.texture[i].desc.Usage = d3d11->frame.texture[0].desc.Usage; + d3d11_init_texture(d3d11->device, &d3d11->frame.texture[i]); + /* todo: clear texture ? */ } + d3d11->init_history = false; +} +static void d3d11_init_render_targets(d3d11_video_t* d3d11, unsigned width, unsigned height) +{ + assert(d3d11->shader_preset); - d3d11->frame.texture.desc.Width = width; - d3d11->frame.texture.desc.Height = height; - d3d11_init_texture(d3d11->device, &d3d11->frame.texture); - - if (d3d11->shader_preset) + for (int i = 0; i < d3d11->shader_preset->passes; i++) { - for (int i = 0; i < d3d11->shader_preset->passes; i++) + struct video_shader_pass* pass = &d3d11->shader_preset->pass[i]; + + if (pass->fbo.valid) { - struct video_shader_pass* pass = &d3d11->shader_preset->pass[i]; - if (pass->fbo.valid) + switch (pass->fbo.type_x) { + case RARCH_SCALE_INPUT: + width *= pass->fbo.scale_x; + break; - switch (pass->fbo.type_x) - { - case RARCH_SCALE_INPUT: - width *= pass->fbo.scale_x; - break; + case RARCH_SCALE_VIEWPORT: + width = d3d11->vp.width * pass->fbo.scale_x; + break; - case RARCH_SCALE_VIEWPORT: - width = d3d11->vp.width * pass->fbo.scale_x; - break; + case RARCH_SCALE_ABSOLUTE: + width = pass->fbo.abs_x; + break; - case RARCH_SCALE_ABSOLUTE: - width = pass->fbo.abs_x; - break; - - default: - break; - } - - if (!width) - width = d3d11->vp.width; - - switch (pass->fbo.type_y) - { - case RARCH_SCALE_INPUT: - height *= pass->fbo.scale_y; - break; - - case RARCH_SCALE_VIEWPORT: - height = d3d11->vp.height * pass->fbo.scale_y; - break; - - case RARCH_SCALE_ABSOLUTE: - height = pass->fbo.abs_y; - break; - - default: - break; - } - - if (!height) - height = d3d11->vp.height; + default: + break; } - else if (i == (d3d11->shader_preset->passes - 1)) + + if (!width) + width = d3d11->vp.width; + + switch (pass->fbo.type_y) { - width = d3d11->vp.width; + case RARCH_SCALE_INPUT: + height *= pass->fbo.scale_y; + break; + + case RARCH_SCALE_VIEWPORT: + height = d3d11->vp.height * pass->fbo.scale_y; + break; + + case RARCH_SCALE_ABSOLUTE: + height = pass->fbo.abs_y; + break; + + default: + break; + } + + if (!height) height = d3d11->vp.height; - } - - RARCH_LOG("[D3D11]: Updating framebuffer size %u x %u.\n", width, height); - - /* TODO: maybe use double buffering and grap the swapchain view - * instead when pass->feedback == true for the last pass ? - * (unless last pass is invalid anyway as a feedback source) */ - - if ((i != (d3d11->shader_preset->passes - 1)) || (width != d3d11->vp.width) || - (height != d3d11->vp.height) || pass->feedback) - { - d3d11->pass[i].viewport.Width = width; - d3d11->pass[i].viewport.Height = height; - d3d11->pass[i].viewport.MaxDepth = 1.0; - d3d11->pass[i].rt.desc.Width = width; - d3d11->pass[i].rt.desc.Height = height; - d3d11->pass[i].rt.desc.BindFlags = D3D11_BIND_RENDER_TARGET; - d3d11->pass[i].rt.desc.Format = glslang_format_to_dxgi(d3d11->pass[i].semantics.format); - d3d11_init_texture(d3d11->device, &d3d11->pass[i].rt); - - if (pass->feedback) - { - d3d11->pass[i].feedback.desc = d3d11->pass[i].rt.desc; - d3d11_init_texture(d3d11->device, &d3d11->pass[i].feedback); - } - } - else - { - d3d11->pass[i].rt.size_data.x = width; - d3d11->pass[i].rt.size_data.y = height; - d3d11->pass[i].rt.size_data.z = 1.0f / width; - d3d11->pass[i].rt.size_data.w = 1.0f / height; - } - - d3d11->pass[i].sampler = d3d11->samplers[pass->filter][pass->wrap]; } + else if (i == (d3d11->shader_preset->passes - 1)) + { + width = d3d11->vp.width; + height = d3d11->vp.height; + } + + RARCH_LOG("[D3D11]: Updating framebuffer size %u x %u.\n", width, height); + + if ((i != (d3d11->shader_preset->passes - 1)) || (width != d3d11->vp.width) || + (height != d3d11->vp.height)) + { + d3d11->pass[i].viewport.Width = width; + d3d11->pass[i].viewport.Height = height; + d3d11->pass[i].viewport.MaxDepth = 1.0; + d3d11->pass[i].rt.desc.Width = width; + d3d11->pass[i].rt.desc.Height = height; + d3d11->pass[i].rt.desc.BindFlags = D3D11_BIND_RENDER_TARGET; + d3d11->pass[i].rt.desc.Format = glslang_format_to_dxgi(d3d11->pass[i].semantics.format); + d3d11_init_texture(d3d11->device, &d3d11->pass[i].rt); + + if (pass->feedback) + { + d3d11->pass[i].feedback.desc = d3d11->pass[i].rt.desc; + d3d11_init_texture(d3d11->device, &d3d11->pass[i].feedback); + /* todo: do we need to clear it to black here ? */ + } + } + else + { + d3d11->pass[i].rt.size_data.x = width; + d3d11->pass[i].rt.size_data.y = height; + d3d11->pass[i].rt.size_data.z = 1.0f / width; + d3d11->pass[i].rt.size_data.w = 1.0f / height; + } + + d3d11->pass[i].sampler = d3d11->samplers[pass->filter][pass->wrap]; } - d3d11->resize_fbos = false; + d3d11->resize_render_targets = false; - return true; #if 0 error: d3d11_free_shader_preset(d3d11); @@ -859,7 +875,8 @@ static bool d3d11_gfx_frame( const char* msg, video_frame_info_t* video_info) { - d3d11_video_t* d3d11 = (d3d11_video_t*)data; + d3d11_video_t* d3d11 = (d3d11_video_t*)data; + D3D11DeviceContext context = d3d11->context; if (d3d11->resize_chain) { @@ -873,7 +890,7 @@ static bool d3d11_gfx_frame( d3d11->device, backBuffer, NULL, &d3d11->renderTargetView); Release(backBuffer); - D3D11SetRenderTargets(d3d11->ctx, 1, &d3d11->renderTargetView, NULL); + D3D11SetRenderTargets(context, 1, &d3d11->renderTargetView, NULL); d3d11->viewport.Width = video_info->width; d3d11->viewport.Height = video_info->height; @@ -893,24 +910,59 @@ static bool d3d11_gfx_frame( #endif d3d11_update_viewport(d3d11, false); - D3D11SetPrimitiveTopology(d3d11->ctx, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); + D3D11SetPrimitiveTopology(context, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); if (frame && width && height) { - if (d3d11->frame.texture.desc.Width != width || d3d11->frame.texture.desc.Height != height) - d3d11->resize_fbos = true; + if (d3d11->shader_preset) + { + if (d3d11->frame.texture[0].desc.Width != width || + d3d11->frame.texture[0].desc.Height != height) + d3d11->resize_render_targets = true; - if (d3d11->resize_fbos) - d3d11_init_frame_textures(d3d11, width, height); + if (d3d11->resize_render_targets) + { + /* release all render targets first to avoid memory fragmentation */ + for (int i = 0; i < d3d11->shader_preset->passes; i++) + d3d11_release_texture(&d3d11->pass[i].rt); + } + + if (d3d11->shader_preset->history_size) + { + if (d3d11->init_history) + d3d11_init_history(d3d11, width, height); + else + { + /* todo: what about frame-duping ? + * maybe clone d3d11_texture_t with AddRef */ + d3d11_texture_t tmp = d3d11->frame.texture[d3d11->shader_preset->history_size]; + for (int i = d3d11->shader_preset->history_size; i > 0; i--) + d3d11->frame.texture[i] = d3d11->frame.texture[i - 1]; + d3d11->frame.texture[0] = tmp; + } + } + } + + /* either no history, or we moved a texture of a different size in the front slot */ + if (d3d11->frame.texture[0].desc.Width != width || + d3d11->frame.texture[0].desc.Height != height) + { + d3d11->frame.texture[0].desc.Width = width; + d3d11->frame.texture[0].desc.Height = height; + d3d11_init_texture(d3d11->device, &d3d11->frame.texture[0]); + } + + if (d3d11->resize_render_targets) + d3d11_init_render_targets(d3d11, width, height); d3d11_update_texture( - d3d11->ctx, width, height, pitch, d3d11->format, frame, &d3d11->frame.texture); + context, width, height, pitch, d3d11->format, frame, &d3d11->frame.texture[0]); } - D3D11SetVertexBuffer(d3d11->ctx, 0, d3d11->frame.vbo, sizeof(d3d11_vertex_t), 0); - D3D11SetBlendState(d3d11->ctx, d3d11->blend_disable, NULL, D3D11_DEFAULT_SAMPLE_MASK); + D3D11SetVertexBuffer(context, 0, d3d11->frame.vbo, sizeof(d3d11_vertex_t), 0); + D3D11SetBlendState(context, d3d11->blend_disable, NULL, D3D11_DEFAULT_SAMPLE_MASK); - d3d11_texture_t* texture = &d3d11->frame.texture; + d3d11_texture_t* texture = d3d11->frame.texture; if (d3d11->shader_preset) { @@ -926,20 +978,7 @@ static bool d3d11_gfx_frame( for (int i = 0; i < d3d11->shader_preset->passes; i++) { - { - texture_sem_t* texture_sem = d3d11->pass[i].semantics.textures; - - while (texture_sem->stage_mask) - { - D3D11ShaderResourceView view = *(D3D11ShaderResourceView*)texture_sem->texture_data; - D3D11SamplerStateRef sampler = *(D3D11SamplerStateRef*)texture_sem->sampler_data; - - d3d11->pass[i].textures[texture_sem->binding] = view; - d3d11->pass[i].samplers[texture_sem->binding] = sampler; - - texture_sem++; - } - } + d3d11_set_shader(context, &d3d11->pass[i].shader); if (d3d11->shader_preset->pass[i].frame_count_mod) d3d11->pass[i].frame_count = @@ -957,37 +996,52 @@ static bool d3d11_gfx_frame( D3D11_MAPPED_SUBRESOURCE res; uniform_sem_t* uniform = buffer_sem->uniforms; - D3D11MapBuffer(d3d11->ctx, buffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &res); + D3D11MapBuffer(context, buffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &res); while (uniform->size) { if (uniform->data) memcpy((uint8_t*)res.pData + uniform->offset, uniform->data, uniform->size); uniform++; } - D3D11UnmapBuffer(d3d11->ctx, buffer, 0); + D3D11UnmapBuffer(context, buffer, 0); if (buffer_sem->stage_mask & SLANG_STAGE_VERTEX_MASK) - D3D11SetVShaderConstantBuffers(d3d11->ctx, buffer_sem->binding, 1, &buffer); + D3D11SetVShaderConstantBuffers(context, buffer_sem->binding, 1, &buffer); if (buffer_sem->stage_mask & SLANG_STAGE_FRAGMENT_MASK) - D3D11SetPShaderConstantBuffers(d3d11->ctx, buffer_sem->binding, 1, &buffer); + D3D11SetPShaderConstantBuffers(context, buffer_sem->binding, 1, &buffer); } } - d3d11_set_shader(d3d11->ctx, &d3d11->pass[i].shader); + { + D3D11RenderTargetView null_rt = NULL; + D3D11SetRenderTargets(context, 1, &null_rt, NULL); + } - D3D11RenderTargetView null_rt = NULL; - D3D11SetRenderTargets(d3d11->ctx, 1, &null_rt, NULL); - D3D11SetPShaderResources(d3d11->ctx, 0, SLANG_NUM_BINDINGS, d3d11->pass[i].textures); - D3D11SetPShaderSamplers(d3d11->ctx, 0, SLANG_NUM_BINDINGS, d3d11->pass[i].samplers); + { + D3D11ShaderResourceView textures[SLANG_NUM_BINDINGS] = { NULL }; + D3D11SamplerState samplers[SLANG_NUM_BINDINGS] = { NULL }; + + texture_sem_t* texture_sem = d3d11->pass[i].semantics.textures; + while (texture_sem->stage_mask) + { + int binding = texture_sem->binding; + textures[binding] = *(D3D11ShaderResourceView*)texture_sem->texture_data; + samplers[binding] = *(D3D11SamplerState*)texture_sem->sampler_data; + texture_sem++; + } + + D3D11SetPShaderResources(context, 0, SLANG_NUM_BINDINGS, textures); + D3D11SetPShaderSamplers(context, 0, SLANG_NUM_BINDINGS, samplers); + } if (d3d11->pass[i].rt.handle) { - D3D11SetRenderTargets(d3d11->ctx, 1, &d3d11->pass[i].rt.rt_view, NULL); - D3D11ClearRenderTargetView(d3d11->ctx, d3d11->pass[i].rt.rt_view, d3d11->clearcolor); - D3D11SetViewports(d3d11->ctx, 1, &d3d11->pass[i].viewport); + D3D11SetRenderTargets(context, 1, &d3d11->pass[i].rt.rt_view, NULL); + D3D11ClearRenderTargetView(context, d3d11->pass[i].rt.rt_view, d3d11->clearcolor); + D3D11SetViewports(context, 1, &d3d11->pass[i].viewport); - D3D11Draw(d3d11->ctx, 4, 0); + D3D11Draw(context, 4, 0); texture = &d3d11->pass[i].rt; } else @@ -996,44 +1050,44 @@ static bool d3d11_gfx_frame( break; } } - D3D11SetRenderTargets(d3d11->ctx, 1, &d3d11->renderTargetView, NULL); + D3D11SetRenderTargets(context, 1, &d3d11->renderTargetView, NULL); } if (texture) { - d3d11_set_shader(d3d11->ctx, &d3d11->shaders[VIDEO_SHADER_STOCK_BLEND]); - D3D11SetPShaderResources(d3d11->ctx, 0, 1, &texture->view); + d3d11_set_shader(context, &d3d11->shaders[VIDEO_SHADER_STOCK_BLEND]); + D3D11SetPShaderResources(context, 0, 1, &texture->view); D3D11SetPShaderSamplers( - d3d11->ctx, 0, 1, &d3d11->samplers[RARCH_FILTER_UNSPEC][RARCH_WRAP_DEFAULT]); - D3D11SetVShaderConstantBuffers(d3d11->ctx, 0, 1, &d3d11->frame.ubo); + context, 0, 1, &d3d11->samplers[RARCH_FILTER_UNSPEC][RARCH_WRAP_DEFAULT]); + D3D11SetVShaderConstantBuffers(context, 0, 1, &d3d11->frame.ubo); } - D3D11ClearRenderTargetView(d3d11->ctx, d3d11->renderTargetView, d3d11->clearcolor); - D3D11SetViewports(d3d11->ctx, 1, &d3d11->frame.viewport); + D3D11ClearRenderTargetView(context, d3d11->renderTargetView, d3d11->clearcolor); + D3D11SetViewports(context, 1, &d3d11->frame.viewport); - D3D11Draw(d3d11->ctx, 4, 0); + D3D11Draw(context, 4, 0); - D3D11SetBlendState(d3d11->ctx, d3d11->blend_enable, NULL, D3D11_DEFAULT_SAMPLE_MASK); + D3D11SetBlendState(context, d3d11->blend_enable, NULL, D3D11_DEFAULT_SAMPLE_MASK); if (d3d11->menu.enabled && d3d11->menu.texture.handle) { if (d3d11->menu.fullscreen) - D3D11SetViewports(d3d11->ctx, 1, &d3d11->viewport); + D3D11SetViewports(context, 1, &d3d11->viewport); - d3d11_set_shader(d3d11->ctx, &d3d11->shaders[VIDEO_SHADER_STOCK_BLEND]); - D3D11SetVertexBuffer(d3d11->ctx, 0, d3d11->menu.vbo, sizeof(d3d11_vertex_t), 0); - D3D11SetVShaderConstantBuffers(d3d11->ctx, 0, 1, &d3d11->ubo); - d3d11_set_texture_and_sampler(d3d11->ctx, 0, &d3d11->menu.texture); - D3D11Draw(d3d11->ctx, 4, 0); + d3d11_set_shader(context, &d3d11->shaders[VIDEO_SHADER_STOCK_BLEND]); + D3D11SetVertexBuffer(context, 0, d3d11->menu.vbo, sizeof(d3d11_vertex_t), 0); + D3D11SetVShaderConstantBuffers(context, 0, 1, &d3d11->ubo); + d3d11_set_texture_and_sampler(context, 0, &d3d11->menu.texture); + D3D11Draw(context, 4, 0); } - D3D11SetViewports(d3d11->ctx, 1, &d3d11->viewport); + D3D11SetViewports(context, 1, &d3d11->viewport); - d3d11_set_shader(d3d11->ctx, &d3d11->sprites.shader); - D3D11SetPrimitiveTopology(d3d11->ctx, D3D11_PRIMITIVE_TOPOLOGY_POINTLIST); - D3D11SetVertexBuffer(d3d11->ctx, 0, d3d11->sprites.vbo, sizeof(d3d11_sprite_t), 0); - D3D11SetVShaderConstantBuffer(d3d11->ctx, 0, d3d11->ubo); - D3D11SetPShaderConstantBuffer(d3d11->ctx, 0, d3d11->ubo); + d3d11_set_shader(context, &d3d11->sprites.shader); + D3D11SetPrimitiveTopology(context, D3D11_PRIMITIVE_TOPOLOGY_POINTLIST); + D3D11SetVertexBuffer(context, 0, d3d11->sprites.vbo, sizeof(d3d11_sprite_t), 0); + D3D11SetVShaderConstantBuffer(context, 0, d3d11->ubo); + D3D11SetPShaderConstantBuffer(context, 0, d3d11->ubo); d3d11->sprites.enabled = true; @@ -1130,7 +1184,7 @@ static void d3d11_set_menu_texture_frame( d3d11_init_texture(d3d11->device, &d3d11->menu.texture); } - d3d11_update_texture(d3d11->ctx, width, height, 0, format, frame, &d3d11->menu.texture); + d3d11_update_texture(d3d11->context, width, height, 0, format, frame, &d3d11->menu.texture); d3d11->menu.texture.sampler = d3d11->samplers [config_get_ptr()->bools.menu_linear_filter ? RARCH_FILTER_LINEAR @@ -1215,7 +1269,7 @@ static uintptr_t d3d11_gfx_load_texture( d3d11_init_texture(d3d11->device, texture); d3d11_update_texture( - d3d11->ctx, image->width, image->height, 0, DXGI_FORMAT_B8G8R8A8_UNORM, image->pixels, + d3d11->context, image->width, image->height, 0, DXGI_FORMAT_B8G8R8A8_UNORM, image->pixels, texture); return (uintptr_t)texture; diff --git a/gfx/drivers_font/d3d11_font.c b/gfx/drivers_font/d3d11_font.c index a8bdc9b165..6008a74747 100644 --- a/gfx/drivers_font/d3d11_font.c +++ b/gfx/drivers_font/d3d11_font.c @@ -57,7 +57,7 @@ d3d11_font_init_font(void* data, const char* font_path, float font_size, bool is font->texture.desc.Format = DXGI_FORMAT_A8_UNORM; d3d11_init_texture(d3d11->device, &font->texture); d3d11_update_texture( - d3d11->ctx, font->atlas->width, font->atlas->height, font->atlas->width, + d3d11->context, font->atlas->width, font->atlas->height, font->atlas->width, DXGI_FORMAT_A8_UNORM, font->atlas->buffer, &font->texture); font->atlas->dirty = false; @@ -151,7 +151,7 @@ static void d3d11_font_render_line( break; } - D3D11MapBuffer(d3d11->ctx, d3d11->sprites.vbo, 0, D3D11_MAP_WRITE_NO_OVERWRITE, 0, &mapped_vbo); + D3D11MapBuffer(d3d11->context, d3d11->sprites.vbo, 0, D3D11_MAP_WRITE_NO_OVERWRITE, 0, &mapped_vbo); v = (d3d11_sprite_t*)mapped_vbo.pData + d3d11->sprites.offset; for (i = 0; i < msg_len; i++) @@ -197,7 +197,7 @@ static void d3d11_font_render_line( } count = v - ((d3d11_sprite_t*)mapped_vbo.pData + d3d11->sprites.offset); - D3D11UnmapBuffer(d3d11->ctx, d3d11->sprites.vbo, 0); + D3D11UnmapBuffer(d3d11->context, d3d11->sprites.vbo, 0); if (!count) return; @@ -205,17 +205,17 @@ static void d3d11_font_render_line( if (font->atlas->dirty) { d3d11_update_texture( - d3d11->ctx, font->atlas->width, font->atlas->height, font->atlas->width, + d3d11->context, font->atlas->width, font->atlas->height, font->atlas->width, DXGI_FORMAT_A8_UNORM, font->atlas->buffer, &font->texture); font->atlas->dirty = false; } - d3d11_set_texture_and_sampler(d3d11->ctx, 0, &font->texture); - D3D11SetBlendState(d3d11->ctx, d3d11->blend_enable, NULL, D3D11_DEFAULT_SAMPLE_MASK); + d3d11_set_texture_and_sampler(d3d11->context, 0, &font->texture); + D3D11SetBlendState(d3d11->context, d3d11->blend_enable, NULL, D3D11_DEFAULT_SAMPLE_MASK); - D3D11SetPShader(d3d11->ctx, d3d11->sprites.shader_font.ps, NULL, 0); - D3D11Draw(d3d11->ctx, count, d3d11->sprites.offset); - D3D11SetPShader(d3d11->ctx, d3d11->sprites.shader.ps, NULL, 0); + D3D11SetPShader(d3d11->context, d3d11->sprites.shader_font.ps, NULL, 0); + D3D11Draw(d3d11->context, count, d3d11->sprites.offset); + D3D11SetPShader(d3d11->context, d3d11->sprites.shader.ps, NULL, 0); d3d11->sprites.offset += count; } diff --git a/gfx/drivers_shader/slang_process.cpp b/gfx/drivers_shader/slang_process.cpp index 206c64af57..66afaeb510 100644 --- a/gfx/drivers_shader/slang_process.cpp +++ b/gfx/drivers_shader/slang_process.cpp @@ -242,8 +242,12 @@ static bool slang_process_reflection( textures.push_back(texture); - if(texture_map->semantic == SLANG_TEXTURE_SEMANTIC_PASS_FEEDBACK) + if (texture_map->semantic == SLANG_TEXTURE_SEMANTIC_PASS_FEEDBACK) shader_info->pass[texture_map->index].feedback = true; + + if (texture_map->semantic == SLANG_TEXTURE_SEMANTIC_ORIGINAL_HISTORY && + shader_info->history_size < texture_map->index) + shader_info->history_size = texture_map->index; } if (src.push_constant || src.uniform) @@ -379,14 +383,13 @@ bool slang_process( * float2 FragCoord :TEXCOORD# to float4 FragCoord : SV_POSITION */ std::vector ps_attrib_remap; - VariableTypeRemapCallback ps_var_remap_cb = [&](const SPIRType& type, - const std::string& var_name, - std::string& name_of_type) { - if (var_name == "FragCoord") - { - name_of_type = "float4"; - } - }; + VariableTypeRemapCallback ps_var_remap_cb = + [&](const SPIRType& type, const std::string& var_name, std::string& name_of_type) { + if (var_name == "FragCoord") + { + name_of_type = "float4"; + } + }; for (Resource& resource : ps_resources.stage_inputs) { if (ps->get_name(resource.id) == "FragCoord") diff --git a/gfx/video_shader_parse.h b/gfx/video_shader_parse.h index 60738d9df5..988b5eed7d 100644 --- a/gfx/video_shader_parse.h +++ b/gfx/video_shader_parse.h @@ -42,6 +42,11 @@ RETRO_BEGIN_DECLS #define GFX_MAX_PARAMETERS 128 #endif +#ifndef GFX_MAX_FRAME_HISTORY +#define GFX_MAX_FRAME_HISTORY 128 +#endif + + enum rarch_shader_type { RARCH_SHADER_NONE = 0, @@ -151,6 +156,7 @@ struct video_shader /* If < 0, no feedback pass is used. Otherwise, * the FBO after pass #N is passed a texture to next frame. */ int feedback_pass; + int history_size; struct video_shader_pass pass[GFX_MAX_SHADERS]; diff --git a/menu/drivers_display/menu_display_d3d11.c b/menu/drivers_display/menu_display_d3d11.c index 15318c4ee9..6e5195a897 100644 --- a/menu/drivers_display/menu_display_d3d11.c +++ b/menu/drivers_display/menu_display_d3d11.c @@ -35,13 +35,13 @@ static void* menu_display_d3d11_get_default_mvp(void) { return NULL; } static void menu_display_d3d11_blend_begin(void) { d3d11_video_t* d3d11 = (d3d11_video_t*)video_driver_get_ptr(false); - D3D11SetBlendState(d3d11->ctx, d3d11->blend_enable, NULL, D3D11_DEFAULT_SAMPLE_MASK); + D3D11SetBlendState(d3d11->context, d3d11->blend_enable, NULL, D3D11_DEFAULT_SAMPLE_MASK); } static void menu_display_d3d11_blend_end(void) { d3d11_video_t* d3d11 = (d3d11_video_t*)video_driver_get_ptr(false); - D3D11SetBlendState(d3d11->ctx, d3d11->blend_disable, NULL, D3D11_DEFAULT_SAMPLE_MASK); + D3D11SetBlendState(d3d11->context, d3d11->blend_disable, NULL, D3D11_DEFAULT_SAMPLE_MASK); } static void menu_display_d3d11_viewport(void* data) {} @@ -62,13 +62,13 @@ static void menu_display_d3d11_draw(void* data) case VIDEO_SHADER_MENU_4: case VIDEO_SHADER_MENU_5: case VIDEO_SHADER_MENU_6: - d3d11_set_shader(d3d11->ctx, &d3d11->shaders[draw->pipeline.id]); - D3D11Draw(d3d11->ctx, draw->coords->vertices, 0); + d3d11_set_shader(d3d11->context, &d3d11->shaders[draw->pipeline.id]); + D3D11Draw(d3d11->context, draw->coords->vertices, 0); - D3D11SetBlendState(d3d11->ctx, d3d11->blend_enable, NULL, D3D11_DEFAULT_SAMPLE_MASK); - d3d11_set_shader(d3d11->ctx, &d3d11->sprites.shader); - D3D11SetVertexBuffer(d3d11->ctx, 0, d3d11->sprites.vbo, sizeof(d3d11_sprite_t), 0); - D3D11SetPrimitiveTopology(d3d11->ctx, D3D11_PRIMITIVE_TOPOLOGY_POINTLIST); + D3D11SetBlendState(d3d11->context, d3d11->blend_enable, NULL, D3D11_DEFAULT_SAMPLE_MASK); + d3d11_set_shader(d3d11->context, &d3d11->sprites.shader); + D3D11SetVertexBuffer(d3d11->context, 0, d3d11->sprites.vbo, sizeof(d3d11_sprite_t), 0); + D3D11SetPrimitiveTopology(d3d11->context, D3D11_PRIMITIVE_TOPOLOGY_POINTLIST); return; } @@ -81,7 +81,7 @@ static void menu_display_d3d11_draw(void* data) { D3D11_MAPPED_SUBRESOURCE mapped_vbo; D3D11MapBuffer( - d3d11->ctx, d3d11->sprites.vbo, 0, D3D11_MAP_WRITE_NO_OVERWRITE, 0, &mapped_vbo); + d3d11->context, d3d11->sprites.vbo, 0, D3D11_MAP_WRITE_NO_OVERWRITE, 0, &mapped_vbo); d3d11_sprite_t* v = (d3d11_sprite_t*)mapped_vbo.pData + d3d11->sprites.offset; v->pos.x = draw->x / (float)d3d11->viewport.Width; @@ -114,11 +114,11 @@ static void menu_display_d3d11_draw(void* data) 0xFF * draw->coords->color[12], 0xFF * draw->coords->color[13], 0xFF * draw->coords->color[14], 0xFF * draw->coords->color[15]); - D3D11UnmapBuffer(d3d11->ctx, d3d11->sprites.vbo, 0); + D3D11UnmapBuffer(d3d11->context, d3d11->sprites.vbo, 0); } - d3d11_set_texture_and_sampler(d3d11->ctx, 0, (d3d11_texture_t*)draw->texture); - D3D11Draw(d3d11->ctx, 1, d3d11->sprites.offset); + d3d11_set_texture_and_sampler(d3d11->context, 0, (d3d11_texture_t*)draw->texture); + D3D11Draw(d3d11->context, 1, d3d11->sprites.offset); d3d11->sprites.offset++; return; } @@ -150,9 +150,9 @@ static void menu_display_d3d11_draw_pipeline(void* data) D3D11_SUBRESOURCE_DATA vertexData = { ca->coords.vertex }; D3D11CreateBuffer(d3d11->device, &desc, &vertexData, &d3d11->menu_pipeline_vbo); } - D3D11SetVertexBuffer(d3d11->ctx, 0, d3d11->menu_pipeline_vbo, 2 * sizeof(float), 0); + D3D11SetVertexBuffer(d3d11->context, 0, d3d11->menu_pipeline_vbo, 2 * sizeof(float), 0); draw->coords->vertices = ca->coords.vertices; - D3D11SetBlendState(d3d11->ctx, d3d11->blend_pipeline, NULL, D3D11_DEFAULT_SAMPLE_MASK); + D3D11SetBlendState(d3d11->context, d3d11->blend_pipeline, NULL, D3D11_DEFAULT_SAMPLE_MASK); break; } @@ -160,21 +160,21 @@ static void menu_display_d3d11_draw_pipeline(void* data) case VIDEO_SHADER_MENU_4: case VIDEO_SHADER_MENU_5: case VIDEO_SHADER_MENU_6: - D3D11SetVertexBuffer(d3d11->ctx, 0, d3d11->frame.vbo, sizeof(d3d11_vertex_t), 0); + D3D11SetVertexBuffer(d3d11->context, 0, d3d11->frame.vbo, sizeof(d3d11_vertex_t), 0); draw->coords->vertices = 4; break; default: return; } - D3D11SetPrimitiveTopology(d3d11->ctx, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); + D3D11SetPrimitiveTopology(d3d11->context, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); d3d11->ubo_values.time += 0.01f; { D3D11_MAPPED_SUBRESOURCE mapped_ubo; - D3D11MapBuffer(d3d11->ctx, d3d11->ubo, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped_ubo); + D3D11MapBuffer(d3d11->context, d3d11->ubo, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped_ubo); *(d3d11_uniform_t*)mapped_ubo.pData = d3d11->ubo_values; - D3D11UnmapBuffer(d3d11->ctx, d3d11->ubo, 0); + D3D11UnmapBuffer(d3d11->context, d3d11->ubo, 0); } } @@ -187,7 +187,7 @@ static void menu_display_d3d11_clear_color(menu_display_ctx_clearcolor_t* clearc if (!d3d11 || !clearcolor) return; - D3D11ClearRenderTargetView(d3d11->ctx, d3d11->renderTargetView, (float*)clearcolor); + D3D11ClearRenderTargetView(d3d11->context, d3d11->renderTargetView, (float*)clearcolor); } static bool menu_display_d3d11_font_init_first( From fa458b2f5ce7e5216854719c287de7bbde9cdc77 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 3 Feb 2018 14:01:32 +0100 Subject: [PATCH 032/232] * d3d11.c - minor cleanups for C89 * C89 build fixes for D3D9X headers --- gfx/drivers/d3d11.c | 397 +++++++++------ gfx/include/Cg/cgD3D9.h | 16 +- gfx/include/d3d9/d3dx9math.h | 576 +++++++++++----------- gfx/include/d3d9/d3dx9math.inl | 281 +++++------ gfx/include/d3d9/d3dx9xof.h | 74 +-- menu/drivers_display/menu_display_d3d11.c | 45 +- 6 files changed, 701 insertions(+), 688 deletions(-) diff --git a/gfx/drivers/d3d11.c b/gfx/drivers/d3d11.c index e4375a05ef..a63251f304 100644 --- a/gfx/drivers/d3d11.c +++ b/gfx/drivers/d3d11.c @@ -37,9 +37,10 @@ static void d3d11_set_filtering(void* data, unsigned index, bool smooth) { + unsigned i; d3d11_video_t* d3d11 = (d3d11_video_t*)data; - for (int i = 0; i < RARCH_WRAP_MAX; i++) + for (i = 0; i < RARCH_WRAP_MAX; i++) { if (smooth) d3d11->samplers[RARCH_FILTER_UNSPEC][i] = d3d11->samplers[RARCH_FILTER_LINEAR][i]; @@ -93,11 +94,14 @@ static void d3d11_update_viewport(void* data, bool force_full) static void d3d11_free_shader_preset(d3d11_video_t* d3d11) { + unsigned i; if (!d3d11->shader_preset) return; - for (int i = 0; i < d3d11->shader_preset->passes; i++) + for (i = 0; i < d3d11->shader_preset->passes; i++) { + unsigned j; + free(d3d11->shader_preset->pass[i].source.string.vertex); free(d3d11->shader_preset->pass[i].source.string.fragment); free(d3d11->pass[i].semantics.textures); @@ -105,7 +109,7 @@ static void d3d11_free_shader_preset(d3d11_video_t* d3d11) d3d11_release_texture(&d3d11->pass[i].rt); d3d11_release_texture(&d3d11->pass[i].feedback); - for (int j = 0; j < SLANG_CBUFFER_MAX; j++) + for (j = 0; j < SLANG_CBUFFER_MAX; j++) { free(d3d11->pass[i].semantics.cbuffers[j].uniforms); Release(d3d11->pass[i].buffers[j]); @@ -114,7 +118,7 @@ static void d3d11_free_shader_preset(d3d11_video_t* d3d11) memset(d3d11->pass, 0, sizeof(d3d11->pass)); - for (int i = 0; i < d3d11->shader_preset->luts; i++) + for (i = 0; i < d3d11->shader_preset->luts; i++) d3d11_release_texture(&d3d11->luts[i]); memset(d3d11->luts, 0, sizeof(d3d11->luts)); @@ -125,7 +129,10 @@ static void d3d11_free_shader_preset(d3d11_video_t* d3d11) static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const char* path) { - d3d11_video_t* d3d11 = (d3d11_video_t*)data; + unsigned i, j; + config_file_t *conf = NULL; + d3d11_texture_t *source = NULL; + d3d11_video_t *d3d11 = (d3d11_video_t*)data; if (!d3d11) return false; @@ -144,7 +151,7 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const return false; } - config_file_t* conf = config_file_new(path); + conf = config_file_new(path); if (!conf) return false; @@ -156,75 +163,74 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const video_shader_resolve_relative(d3d11->shader_preset, path); - d3d11_texture_t* source = &d3d11->frame.texture; - for (int i = 0; i < d3d11->shader_preset->passes; i++) + source = &d3d11->frame.texture; + + for (i = 0; i < d3d11->shader_preset->passes; i++) { + /* no history support yet */ + texture_map_t texture_map[3 + GFX_MAX_SHADERS * 2 + GFX_MAX_TEXTURES + 1] = { + SL_TEXTURE_MAP( + SLANG_TEXTURE_SEMANTIC_ORIGINAL, d3d11->frame.texture.view, + d3d11->pass[i].sampler, d3d11->frame.texture.size_data), + SL_TEXTURE_MAP( + SLANG_TEXTURE_SEMANTIC_SOURCE, source->view, d3d11->pass[i].sampler, + source->size_data), + SL_TEXTURE_MAP( + SLANG_TEXTURE_SEMANTIC_ORIGINAL_HISTORY, d3d11->frame.texture.view, + d3d11->pass[i].sampler, d3d11->frame.texture.size_data), + }; + { - /* no history support yet */ - texture_map_t texture_map[3 + GFX_MAX_SHADERS * 2 + GFX_MAX_TEXTURES + 1] = { - SL_TEXTURE_MAP( - SLANG_TEXTURE_SEMANTIC_ORIGINAL, d3d11->frame.texture.view, - d3d11->pass[i].sampler, d3d11->frame.texture.size_data), - SL_TEXTURE_MAP( - SLANG_TEXTURE_SEMANTIC_SOURCE, source->view, d3d11->pass[i].sampler, - source->size_data), - SL_TEXTURE_MAP( - SLANG_TEXTURE_SEMANTIC_ORIGINAL_HISTORY, d3d11->frame.texture.view, - d3d11->pass[i].sampler, d3d11->frame.texture.size_data), - }; + texture_map_t* ptr = texture_map; + while (ptr->texture_data) + ptr++; + for (j = 0; j < i; j++) { - texture_map_t* ptr = texture_map; - while (ptr->texture_data) - ptr++; - - for (int j = 0; j < i; j++) - { - *ptr = (texture_map_t)SL_TEXTURE_MAP_ARRAY( - SLANG_TEXTURE_SEMANTIC_PASS_OUTPUT, j, d3d11->pass[j].rt.view, - d3d11->pass[i].sampler, d3d11->pass[j].rt.size_data); - ptr++; - } - - for (int j = 0; j < GFX_MAX_SHADERS; j++) - { - *ptr = (texture_map_t)SL_TEXTURE_MAP_ARRAY( - SLANG_TEXTURE_SEMANTIC_PASS_FEEDBACK, j, d3d11->pass[j].feedback.view, - d3d11->pass[i].sampler, d3d11->pass[j].rt.size_data); - ptr++; - } - - for (int j = 0; j < d3d11->shader_preset->luts; j++) - { - *ptr = (texture_map_t)SL_TEXTURE_MAP_ARRAY( - SLANG_TEXTURE_SEMANTIC_USER, j, d3d11->luts[j].view, d3d11->luts[j].sampler, - d3d11->luts[j].size_data); - ptr++; - } + *ptr = (texture_map_t)SL_TEXTURE_MAP_ARRAY( + SLANG_TEXTURE_SEMANTIC_PASS_OUTPUT, j, d3d11->pass[j].rt.view, + d3d11->pass[i].sampler, d3d11->pass[j].rt.size_data); + ptr++; } - uniform_map_t uniform_map[] = { - SL_UNIFORM_MAP(SLANG_SEMANTIC_MVP, d3d11->mvp), - SL_UNIFORM_MAP(SLANG_SEMANTIC_OUTPUT, d3d11->pass[i].rt.size_data), - SL_UNIFORM_MAP(SLANG_SEMANTIC_FRAME_COUNT, d3d11->pass[i].frame_count), - SL_UNIFORM_MAP(SLANG_SEMANTIC_FINAL_VIEWPORT, d3d11->frame.output_size), - { 0 } - }; + for (j = 0; j < GFX_MAX_SHADERS; j++) + { + *ptr = (texture_map_t)SL_TEXTURE_MAP_ARRAY( + SLANG_TEXTURE_SEMANTIC_PASS_FEEDBACK, j, d3d11->pass[j].feedback.view, + d3d11->pass[i].sampler, d3d11->pass[j].rt.size_data); + ptr++; + } - semantics_map_t semantics_map = { texture_map, uniform_map }; - - if (!slang_process( - d3d11->shader_preset, i, RARCH_SHADER_HLSL, 50, &semantics_map, - &d3d11->pass[i].semantics)) - goto error; + for (j = 0; j < d3d11->shader_preset->luts; j++) + { + *ptr = (texture_map_t)SL_TEXTURE_MAP_ARRAY( + SLANG_TEXTURE_SEMANTIC_USER, j, d3d11->luts[j].view, d3d11->luts[j].sampler, + d3d11->luts[j].size_data); + ptr++; + } } + uniform_map_t uniform_map[] = { + SL_UNIFORM_MAP(SLANG_SEMANTIC_MVP, d3d11->mvp), + SL_UNIFORM_MAP(SLANG_SEMANTIC_OUTPUT, d3d11->pass[i].rt.size_data), + SL_UNIFORM_MAP(SLANG_SEMANTIC_FRAME_COUNT, d3d11->pass[i].frame_count), + SL_UNIFORM_MAP(SLANG_SEMANTIC_FINAL_VIEWPORT, d3d11->frame.output_size), + { 0 } + }; + + semantics_map_t semantics_map = { texture_map, uniform_map }; + + if (!slang_process( + d3d11->shader_preset, i, RARCH_SHADER_HLSL, 50, &semantics_map, + &d3d11->pass[i].semantics)) + goto error; + { static const D3D11_INPUT_ELEMENT_DESC desc[] = { { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, offsetof(d3d11_vertex_t, position), - D3D11_INPUT_PER_VERTEX_DATA, 0 }, + D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "TEXCOORD", 1, DXGI_FORMAT_R32G32_FLOAT, 0, offsetof(d3d11_vertex_t, texcoord), - D3D11_INPUT_PER_VERTEX_DATA, 0 }, + D3D11_INPUT_PER_VERTEX_DATA, 0 }, }; #ifdef DEBUG bool save_hlsl = true; @@ -249,13 +255,13 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const strncpy(ps_path + base_len, ps_ext, sizeof(ps_ext)); if (!d3d11_init_shader( - d3d11->device, vs_src, 0, vs_path, "main", NULL, NULL, desc, countof(desc), - &d3d11->pass[i].shader)) + d3d11->device, vs_src, 0, vs_path, "main", NULL, NULL, desc, countof(desc), + &d3d11->pass[i].shader)) save_hlsl = true; if (!d3d11_init_shader( - d3d11->device, ps_src, 0, ps_path, NULL, "main", NULL, NULL, 0, - &d3d11->pass[i].shader)) + d3d11->device, ps_src, 0, ps_path, NULL, "main", NULL, NULL, 0, + &d3d11->pass[i].shader)) save_hlsl = true; if (save_hlsl) @@ -279,7 +285,7 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const goto error; } - for (int j = 0; j < SLANG_CBUFFER_MAX; j++) + for (j = 0; j < SLANG_CBUFFER_MAX; j++) { D3D11_BUFFER_DESC desc = { .ByteWidth = d3d11->pass[i].semantics.cbuffers[j].size, @@ -291,13 +297,14 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const if (!desc.ByteWidth) continue; - D3D11CreateBuffer(d3d11->device, &desc, NULL, &d3d11->pass[i].buffers[j]); + D3D11CreateBuffer(d3d11->device, &desc, NULL, + &d3d11->pass[i].buffers[j]); } source = &d3d11->pass[i].rt; } - for (int i = 0; i < d3d11->shader_preset->luts; i++) + for (i = 0; i < d3d11->shader_preset->luts; i++) { struct texture_image image = { 0 }; image.supports_rgba = true; @@ -314,13 +321,15 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const d3d11_init_texture(d3d11->device, &d3d11->luts[i]); d3d11_update_texture( - d3d11->ctx, image.width, image.height, 0, DXGI_FORMAT_R8G8B8A8_UNORM, image.pixels, + d3d11->ctx, image.width, image.height, 0, + DXGI_FORMAT_R8G8B8A8_UNORM, image.pixels, &d3d11->luts[i]); image_texture_free(&image); d3d11->luts[i].sampler = - d3d11->samplers[d3d11->shader_preset->lut[i].filter][d3d11->shader_preset->lut[i].wrap]; + d3d11->samplers[d3d11->shader_preset->lut[i].filter] + [d3d11->shader_preset->lut[i].wrap]; } video_shader_resolve_current_parameters(conf, d3d11->shader_preset); @@ -335,6 +344,7 @@ error: static void d3d11_gfx_free(void* data) { + unsigned i; d3d11_video_t* d3d11 = (d3d11_video_t*)data; if (!d3d11) @@ -369,7 +379,7 @@ static void d3d11_gfx_free(void* data) Release(d3d11->blend_enable); Release(d3d11->blend_disable); - for (int i = 0; i < RARCH_WRAP_MAX; i++) + for (i = 0; i < RARCH_WRAP_MAX; i++) { Release(d3d11->samplers[RARCH_FILTER_LINEAR][i]); Release(d3d11->samplers[RARCH_FILTER_NEAREST][i]); @@ -389,12 +399,13 @@ static void d3d11_gfx_free(void* data) free(d3d11); } -static void* -d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** input_data) +static void *d3d11_gfx_init(const video_info_t* video, + const input_driver_t **input, void **input_data) { - WNDCLASSEX wndclass = { 0 }; + unsigned i; MONITORINFOEX current_mon; HMONITOR hm_to_use; + WNDCLASSEX wndclass = { 0 }; settings_t* settings = config_get_ptr(); d3d11_video_t* d3d11 = (d3d11_video_t*)calloc(1, sizeof(*d3d11)); @@ -452,8 +463,10 @@ d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** i #endif D3D11CreateDeviceAndSwapChain( - NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, flags, &requested_feature_level, 1, - D3D11_SDK_VERSION, &desc, (IDXGISwapChain**)&d3d11->swapChain, &d3d11->device, + NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, flags, + &requested_feature_level, 1, + D3D11_SDK_VERSION, &desc, + (IDXGISwapChain**)&d3d11->swapChain, &d3d11->device, &d3d11->supportedFeatureLevel, &d3d11->ctx); } @@ -472,7 +485,8 @@ d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** i d3d11->viewport.Height = d3d11->vp.full_height; d3d11->resize_viewport = true; d3d11->vsync = video->vsync; - d3d11->format = video->rgb32 ? DXGI_FORMAT_B8G8R8X8_UNORM : DXGI_FORMAT_B5G6R5_UNORM; + d3d11->format = video->rgb32 ? + DXGI_FORMAT_B8G8R8X8_UNORM : DXGI_FORMAT_B5G6R5_UNORM; d3d11->frame.texture.desc.Format = d3d11->format; d3d11->frame.texture.desc.Usage = D3D11_USAGE_DEFAULT; @@ -505,8 +519,9 @@ d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** i .MinLOD = -D3D11_FLOAT32_MAX, .MaxLOD = D3D11_FLOAT32_MAX, }; + /* Initialize samplers */ - for (int i = 0; i < RARCH_WRAP_MAX; i++) + for (i = 0; i < RARCH_WRAP_MAX; i++) { switch (i) { @@ -530,10 +545,12 @@ d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** i desc.AddressW = desc.AddressU; desc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR; - D3D11CreateSamplerState(d3d11->device, &desc, &d3d11->samplers[RARCH_FILTER_LINEAR][i]); + D3D11CreateSamplerState(d3d11->device, &desc, + &d3d11->samplers[RARCH_FILTER_LINEAR][i]); desc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT; - D3D11CreateSamplerState(d3d11->device, &desc, &d3d11->samplers[RARCH_FILTER_NEAREST][i]); + D3D11CreateSamplerState(d3d11->device, &desc, + &d3d11->samplers[RARCH_FILTER_NEAREST][i]); } } @@ -546,23 +563,21 @@ d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** i { { 1.0f, 0.0f }, { 1.0f, 1.0f }, { 1.0f, 1.0f, 1.0f, 1.0f } }, { { 1.0f, 1.0f }, { 1.0f, 0.0f }, { 1.0f, 1.0f, 1.0f, 1.0f } }, }; + D3D11_BUFFER_DESC desc = { + .Usage = D3D11_USAGE_IMMUTABLE, + .ByteWidth = sizeof(vertices), + .BindFlags = D3D11_BIND_VERTEX_BUFFER, + }; + D3D11_SUBRESOURCE_DATA vertexData = { vertices }; - { - D3D11_BUFFER_DESC desc = { - .Usage = D3D11_USAGE_IMMUTABLE, - .ByteWidth = sizeof(vertices), - .BindFlags = D3D11_BIND_VERTEX_BUFFER, - }; - D3D11_SUBRESOURCE_DATA vertexData = { vertices }; - D3D11CreateBuffer(d3d11->device, &desc, &vertexData, &d3d11->frame.vbo); - desc.Usage = D3D11_USAGE_DYNAMIC; - desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - D3D11CreateBuffer(d3d11->device, &desc, &vertexData, &d3d11->menu.vbo); + D3D11CreateBuffer(d3d11->device, &desc, &vertexData, &d3d11->frame.vbo); + desc.Usage = D3D11_USAGE_DYNAMIC; + desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + D3D11CreateBuffer(d3d11->device, &desc, &vertexData, &d3d11->menu.vbo); - d3d11->sprites.capacity = 4096; - desc.ByteWidth = sizeof(d3d11_sprite_t) * d3d11->sprites.capacity; - D3D11CreateBuffer(d3d11->device, &desc, NULL, &d3d11->sprites.vbo); - } + d3d11->sprites.capacity = 4096; + desc.ByteWidth = sizeof(d3d11_sprite_t) * d3d11->sprites.capacity; + D3D11CreateBuffer(d3d11->device, &desc, NULL, &d3d11->sprites.vbo); } { @@ -697,14 +712,17 @@ d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** i D3D11_COLOR_WRITE_ENABLE_ALL, }, }; - D3D11CreateBlendState(d3d11->device, &blend_desc, &d3d11->blend_enable); + D3D11CreateBlendState(d3d11->device, &blend_desc, + &d3d11->blend_enable); blend_desc.RenderTarget[0].SrcBlend = D3D11_BLEND_ONE; blend_desc.RenderTarget[0].DestBlend = D3D11_BLEND_ONE; - D3D11CreateBlendState(d3d11->device, &blend_desc, &d3d11->blend_pipeline); + D3D11CreateBlendState(d3d11->device, &blend_desc, + &d3d11->blend_pipeline); blend_desc.RenderTarget[0].BlendEnable = FALSE; - D3D11CreateBlendState(d3d11->device, &blend_desc, &d3d11->blend_disable); + D3D11CreateBlendState(d3d11->device, &blend_desc, + &d3d11->blend_disable); } { D3D11_RASTERIZER_DESC desc = { @@ -715,14 +733,16 @@ d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** i } D3D11SetState(d3d11->ctx, d3d11->state); - font_driver_init_osd(d3d11, false, video->is_threaded, FONT_DRIVER_RENDER_D3D11_API); + font_driver_init_osd(d3d11, false, video->is_threaded, + FONT_DRIVER_RENDER_D3D11_API); if (settings->bools.video_shader_enable) { const char* ext = path_get_extension(settings->paths.path_shader); if (ext && !strncmp(ext, "slang", 5)) - d3d11_gfx_set_shader(d3d11, RARCH_SHADER_SLANG, settings->paths.path_shader); + d3d11_gfx_set_shader(d3d11, RARCH_SHADER_SLANG, + settings->paths.path_shader); } return d3d11; @@ -731,11 +751,15 @@ error: d3d11_gfx_free(d3d11); return NULL; } -static bool d3d11_init_frame_textures(d3d11_video_t* d3d11, unsigned width, unsigned height) + +static bool d3d11_init_frame_textures(d3d11_video_t *d3d11, + unsigned width, unsigned height) { + unsigned i; + if (d3d11->shader_preset) { - for (int i = 0; i < d3d11->shader_preset->passes; i++) + for (i = 0; i < d3d11->shader_preset->passes; i++) { d3d11_release_texture(&d3d11->pass[i].rt); memset(&d3d11->pass[i].rt, 0x00, sizeof(d3d11->pass[i].rt)); @@ -748,7 +772,7 @@ static bool d3d11_init_frame_textures(d3d11_video_t* d3d11, unsigned width, unsi if (d3d11->shader_preset) { - for (int i = 0; i < d3d11->shader_preset->passes; i++) + for (i = 0; i < d3d11->shader_preset->passes; i++) { struct video_shader_pass* pass = &d3d11->shader_preset->pass[i]; @@ -803,14 +827,17 @@ static bool d3d11_init_frame_textures(d3d11_video_t* d3d11, unsigned width, unsi height = d3d11->vp.height; } - RARCH_LOG("[D3D11]: Updating framebuffer size %u x %u.\n", width, height); + RARCH_LOG("[D3D11]: Updating framebuffer size %u x %u.\n", + width, height); /* TODO: maybe use double buffering and grap the swapchain view * instead when pass->feedback == true for the last pass ? * (unless last pass is invalid anyway as a feedback source) */ - if ((i != (d3d11->shader_preset->passes - 1)) || (width != d3d11->vp.width) || - (height != d3d11->vp.height) || pass->feedback) + if ( (i != (d3d11->shader_preset->passes - 1)) || + (width != d3d11->vp.width) || + (height != d3d11->vp.height) || + pass->feedback) { d3d11->pass[i].viewport.Width = width; d3d11->pass[i].viewport.Height = height; @@ -818,7 +845,8 @@ static bool d3d11_init_frame_textures(d3d11_video_t* d3d11, unsigned width, unsi d3d11->pass[i].rt.desc.Width = width; d3d11->pass[i].rt.desc.Height = height; d3d11->pass[i].rt.desc.BindFlags = D3D11_BIND_RENDER_TARGET; - d3d11->pass[i].rt.desc.Format = glslang_format_to_dxgi(d3d11->pass[i].semantics.format); + d3d11->pass[i].rt.desc.Format = glslang_format_to_dxgi( + d3d11->pass[i].semantics.format); d3d11_init_texture(d3d11->device, &d3d11->pass[i].rt); if (pass->feedback) @@ -859,6 +887,7 @@ static bool d3d11_gfx_frame( const char* msg, video_frame_info_t* video_info) { + unsigned i; d3d11_video_t* d3d11 = (d3d11_video_t*)data; if (d3d11->resize_chain) @@ -888,33 +917,40 @@ static bool d3d11_gfx_frame( PERF_START(); -#if 0 /* custom viewport doesn't call apply_state_changes, so we can't rely on this for now */ + /* custom viewport doesn't call apply_state_changes, + * so we can't rely on this for now */ +#if 0 if (d3d11->resize_viewport) #endif d3d11_update_viewport(d3d11, false); - D3D11SetPrimitiveTopology(d3d11->ctx, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); + D3D11SetPrimitiveTopology(d3d11->ctx, + D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); if (frame && width && height) { - if (d3d11->frame.texture.desc.Width != width || d3d11->frame.texture.desc.Height != height) + if ( d3d11->frame.texture.desc.Width != width || + d3d11->frame.texture.desc.Height != height) d3d11->resize_fbos = true; if (d3d11->resize_fbos) d3d11_init_frame_textures(d3d11, width, height); d3d11_update_texture( - d3d11->ctx, width, height, pitch, d3d11->format, frame, &d3d11->frame.texture); + d3d11->ctx, width, height, pitch, d3d11->format, + frame, &d3d11->frame.texture); } - D3D11SetVertexBuffer(d3d11->ctx, 0, d3d11->frame.vbo, sizeof(d3d11_vertex_t), 0); - D3D11SetBlendState(d3d11->ctx, d3d11->blend_disable, NULL, D3D11_DEFAULT_SAMPLE_MASK); + D3D11SetVertexBuffer(d3d11->ctx, 0, d3d11->frame.vbo, + sizeof(d3d11_vertex_t), 0); + D3D11SetBlendState(d3d11->ctx, d3d11->blend_disable, NULL, + D3D11_DEFAULT_SAMPLE_MASK); d3d11_texture_t* texture = &d3d11->frame.texture; if (d3d11->shader_preset) { - for (int i = 0; i < d3d11->shader_preset->passes; i++) + for (i = 0; i < d3d11->shader_preset->passes; i++) { if (d3d11->shader_preset->pass[i].feedback) { @@ -924,21 +960,22 @@ static bool d3d11_gfx_frame( } } - for (int i = 0; i < d3d11->shader_preset->passes; i++) + for (i = 0; i < d3d11->shader_preset->passes; i++) { + unsigned j; + texture_sem_t* texture_sem = d3d11->pass[i].semantics.textures; + + while (texture_sem->stage_mask) { - texture_sem_t* texture_sem = d3d11->pass[i].semantics.textures; + D3D11ShaderResourceView view = *(D3D11ShaderResourceView*) + texture_sem->texture_data; + D3D11SamplerStateRef sampler = *(D3D11SamplerStateRef*) + texture_sem->sampler_data; - while (texture_sem->stage_mask) - { - D3D11ShaderResourceView view = *(D3D11ShaderResourceView*)texture_sem->texture_data; - D3D11SamplerStateRef sampler = *(D3D11SamplerStateRef*)texture_sem->sampler_data; + d3d11->pass[i].textures[texture_sem->binding] = view; + d3d11->pass[i].samplers[texture_sem->binding] = sampler; - d3d11->pass[i].textures[texture_sem->binding] = view; - d3d11->pass[i].samplers[texture_sem->binding] = sampler; - - texture_sem++; - } + texture_sem++; } if (d3d11->shader_preset->pass[i].frame_count_mod) @@ -947,7 +984,7 @@ static bool d3d11_gfx_frame( else d3d11->pass[i].frame_count = frame_count; - for (int j = 0; j < SLANG_CBUFFER_MAX; j++) + for (j = 0; j < SLANG_CBUFFER_MAX; j++) { D3D11Buffer buffer = d3d11->pass[i].buffers[j]; cbuffer_sem_t* buffer_sem = &d3d11->pass[i].semantics.cbuffers[j]; @@ -957,20 +994,25 @@ static bool d3d11_gfx_frame( D3D11_MAPPED_SUBRESOURCE res; uniform_sem_t* uniform = buffer_sem->uniforms; - D3D11MapBuffer(d3d11->ctx, buffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &res); + D3D11MapBuffer(d3d11->ctx, buffer, 0, + D3D11_MAP_WRITE_DISCARD, 0, &res); + while (uniform->size) { if (uniform->data) - memcpy((uint8_t*)res.pData + uniform->offset, uniform->data, uniform->size); + memcpy((uint8_t*)res.pData + uniform->offset, + uniform->data, uniform->size); uniform++; } D3D11UnmapBuffer(d3d11->ctx, buffer, 0); if (buffer_sem->stage_mask & SLANG_STAGE_VERTEX_MASK) - D3D11SetVShaderConstantBuffers(d3d11->ctx, buffer_sem->binding, 1, &buffer); + D3D11SetVShaderConstantBuffers(d3d11->ctx, + buffer_sem->binding, 1, &buffer); if (buffer_sem->stage_mask & SLANG_STAGE_FRAGMENT_MASK) - D3D11SetPShaderConstantBuffers(d3d11->ctx, buffer_sem->binding, 1, &buffer); + D3D11SetPShaderConstantBuffers(d3d11->ctx, + buffer_sem->binding, 1, &buffer); } } @@ -978,13 +1020,17 @@ static bool d3d11_gfx_frame( D3D11RenderTargetView null_rt = NULL; D3D11SetRenderTargets(d3d11->ctx, 1, &null_rt, NULL); - D3D11SetPShaderResources(d3d11->ctx, 0, SLANG_NUM_BINDINGS, d3d11->pass[i].textures); - D3D11SetPShaderSamplers(d3d11->ctx, 0, SLANG_NUM_BINDINGS, d3d11->pass[i].samplers); + D3D11SetPShaderResources(d3d11->ctx, 0, SLANG_NUM_BINDINGS, + (ID3D11ShaderResourceView * const*)d3d11->pass[i].textures); + D3D11SetPShaderSamplers(d3d11->ctx, 0, SLANG_NUM_BINDINGS, + d3d11->pass[i].samplers); if (d3d11->pass[i].rt.handle) { - D3D11SetRenderTargets(d3d11->ctx, 1, &d3d11->pass[i].rt.rt_view, NULL); - D3D11ClearRenderTargetView(d3d11->ctx, d3d11->pass[i].rt.rt_view, d3d11->clearcolor); + D3D11SetRenderTargets(d3d11->ctx, 1, + &d3d11->pass[i].rt.rt_view, NULL); + D3D11ClearRenderTargetView(d3d11->ctx, + d3d11->pass[i].rt.rt_view, d3d11->clearcolor); D3D11SetViewports(d3d11->ctx, 1, &d3d11->pass[i].viewport); D3D11Draw(d3d11->ctx, 4, 0); @@ -1004,24 +1050,30 @@ static bool d3d11_gfx_frame( d3d11_set_shader(d3d11->ctx, &d3d11->shaders[VIDEO_SHADER_STOCK_BLEND]); D3D11SetPShaderResources(d3d11->ctx, 0, 1, &texture->view); D3D11SetPShaderSamplers( - d3d11->ctx, 0, 1, &d3d11->samplers[RARCH_FILTER_UNSPEC][RARCH_WRAP_DEFAULT]); + d3d11->ctx, 0, 1, + (const ID3D11SamplerState**) + &d3d11->samplers[RARCH_FILTER_UNSPEC][RARCH_WRAP_DEFAULT]); D3D11SetVShaderConstantBuffers(d3d11->ctx, 0, 1, &d3d11->frame.ubo); } - D3D11ClearRenderTargetView(d3d11->ctx, d3d11->renderTargetView, d3d11->clearcolor); + D3D11ClearRenderTargetView(d3d11->ctx, + d3d11->renderTargetView, d3d11->clearcolor); D3D11SetViewports(d3d11->ctx, 1, &d3d11->frame.viewport); D3D11Draw(d3d11->ctx, 4, 0); - D3D11SetBlendState(d3d11->ctx, d3d11->blend_enable, NULL, D3D11_DEFAULT_SAMPLE_MASK); + D3D11SetBlendState(d3d11->ctx, d3d11->blend_enable, + NULL, D3D11_DEFAULT_SAMPLE_MASK); if (d3d11->menu.enabled && d3d11->menu.texture.handle) { if (d3d11->menu.fullscreen) D3D11SetViewports(d3d11->ctx, 1, &d3d11->viewport); - d3d11_set_shader(d3d11->ctx, &d3d11->shaders[VIDEO_SHADER_STOCK_BLEND]); - D3D11SetVertexBuffer(d3d11->ctx, 0, d3d11->menu.vbo, sizeof(d3d11_vertex_t), 0); + d3d11_set_shader(d3d11->ctx, + &d3d11->shaders[VIDEO_SHADER_STOCK_BLEND]); + D3D11SetVertexBuffer(d3d11->ctx, 0, + d3d11->menu.vbo, sizeof(d3d11_vertex_t), 0); D3D11SetVShaderConstantBuffers(d3d11->ctx, 0, 1, &d3d11->ubo); d3d11_set_texture_and_sampler(d3d11->ctx, 0, &d3d11->menu.texture); D3D11Draw(d3d11->ctx, 4, 0); @@ -1030,8 +1082,10 @@ static bool d3d11_gfx_frame( D3D11SetViewports(d3d11->ctx, 1, &d3d11->viewport); d3d11_set_shader(d3d11->ctx, &d3d11->sprites.shader); - D3D11SetPrimitiveTopology(d3d11->ctx, D3D11_PRIMITIVE_TOPOLOGY_POINTLIST); - D3D11SetVertexBuffer(d3d11->ctx, 0, d3d11->sprites.vbo, sizeof(d3d11_sprite_t), 0); + D3D11SetPrimitiveTopology(d3d11->ctx, + D3D11_PRIMITIVE_TOPOLOGY_POINTLIST); + D3D11SetVertexBuffer(d3d11->ctx, 0, d3d11->sprites.vbo, + sizeof(d3d11_sprite_t), 0); D3D11SetVShaderConstantBuffer(d3d11->ctx, 0, d3d11->ubo); D3D11SetPShaderConstantBuffer(d3d11->ctx, 0, d3d11->ubo); @@ -1068,15 +1122,22 @@ static bool d3d11_gfx_alive(void* data) bool quit; d3d11_video_t* d3d11 = (d3d11_video_t*)data; - win32_check_window(&quit, &d3d11->resize_chain, &d3d11->vp.full_width, &d3d11->vp.full_height); + win32_check_window(&quit, &d3d11->resize_chain, + &d3d11->vp.full_width, &d3d11->vp.full_height); - if (d3d11->resize_chain && d3d11->vp.full_width != 0 && d3d11->vp.full_height != 0) + if ( d3d11->resize_chain && + (d3d11->vp.full_width != 0) && + (d3d11->vp.full_height != 0) + ) video_driver_set_size(&d3d11->vp.full_width, &d3d11->vp.full_height); return !quit; } -static bool d3d11_gfx_focus(void* data) { return win32_has_focus(); } +static bool d3d11_gfx_focus(void* data) +{ + return win32_has_focus(); +} static bool d3d11_gfx_suppress_screensaver(void* data, bool enable) { @@ -1108,7 +1169,8 @@ static void d3d11_gfx_viewport_info(void* data, struct video_viewport* vp) *vp = d3d11->vp; } -static bool d3d11_gfx_read_viewport(void* data, uint8_t* buffer, bool is_idle) +static bool d3d11_gfx_read_viewport(void* data, + uint8_t* buffer, bool is_idle) { (void)data; (void)buffer; @@ -1117,12 +1179,16 @@ static bool d3d11_gfx_read_viewport(void* data, uint8_t* buffer, bool is_idle) } static void d3d11_set_menu_texture_frame( - void* data, const void* frame, bool rgb32, unsigned width, unsigned height, float alpha) + void* data, const void* frame, bool rgb32, + unsigned width, unsigned height, float alpha) { d3d11_video_t* d3d11 = (d3d11_video_t*)data; - DXGI_FORMAT format = rgb32 ? DXGI_FORMAT_B8G8R8A8_UNORM : DXGI_FORMAT_EX_A4R4G4B4_UNORM; + DXGI_FORMAT format = rgb32 ? + DXGI_FORMAT_B8G8R8A8_UNORM : DXGI_FORMAT_EX_A4R4G4B4_UNORM; - if (d3d11->menu.texture.desc.Width != width || d3d11->menu.texture.desc.Height != height) + if ( + d3d11->menu.texture.desc.Width != width || + d3d11->menu.texture.desc.Height != height) { d3d11->menu.texture.desc.Format = format; d3d11->menu.texture.desc.Width = width; @@ -1130,14 +1196,16 @@ static void d3d11_set_menu_texture_frame( d3d11_init_texture(d3d11->device, &d3d11->menu.texture); } - d3d11_update_texture(d3d11->ctx, width, height, 0, format, frame, &d3d11->menu.texture); + d3d11_update_texture(d3d11->ctx, width, height, 0, format, frame, + &d3d11->menu.texture); d3d11->menu.texture.sampler = d3d11->samplers - [config_get_ptr()->bools.menu_linear_filter - ? RARCH_FILTER_LINEAR - : RARCH_FILTER_NEAREST][RARCH_WRAP_DEFAULT]; + [config_get_ptr()->bools.menu_linear_filter + ? RARCH_FILTER_LINEAR + : RARCH_FILTER_NEAREST][RARCH_WRAP_DEFAULT]; } -static void d3d11_set_menu_texture_enable(void* data, bool state, bool full_screen) +static void d3d11_set_menu_texture_enable(void* data, bool state, + bool full_screen) { d3d11_video_t* d3d11 = (d3d11_video_t*)data; @@ -1148,7 +1216,8 @@ static void d3d11_set_menu_texture_enable(void* data, bool state, bool full_scre d3d11->menu.fullscreen = full_screen; } -static void d3d11_gfx_set_aspect_ratio(void* data, unsigned aspect_ratio_idx) +static void d3d11_gfx_set_aspect_ratio(void* data, + unsigned aspect_ratio_idx) { d3d11_video_t* d3d11 = (d3d11_video_t*)data; @@ -1168,7 +1237,8 @@ static void d3d11_gfx_apply_state_changes(void* data) } static void d3d11_gfx_set_osd_msg( - void* data, video_frame_info_t* video_info, const char* msg, const void* params, void* font) + void* data, video_frame_info_t* video_info, + const char* msg, const void* params, void* font) { d3d11_video_t* d3d11 = (d3d11_video_t*)data; @@ -1181,7 +1251,8 @@ static void d3d11_gfx_set_osd_msg( } } static uintptr_t d3d11_gfx_load_texture( - void* video_data, void* data, bool threaded, enum texture_filter_type filter_type) + void* video_data, void* data, bool threaded, + enum texture_filter_type filter_type) { d3d11_texture_t* texture = NULL; d3d11_video_t* d3d11 = (d3d11_video_t*)video_data; @@ -1198,13 +1269,15 @@ static uintptr_t d3d11_gfx_load_texture( texture->desc.MiscFlags = D3D11_RESOURCE_MISC_GENERATE_MIPS; /* fallthrough */ case TEXTURE_FILTER_LINEAR: - texture->sampler = d3d11->samplers[RARCH_FILTER_LINEAR][RARCH_WRAP_DEFAULT]; + texture->sampler = d3d11->samplers[ + RARCH_FILTER_LINEAR][RARCH_WRAP_DEFAULT]; break; case TEXTURE_FILTER_MIPMAP_NEAREST: texture->desc.MiscFlags = D3D11_RESOURCE_MISC_GENERATE_MIPS; /* fallthrough */ case TEXTURE_FILTER_NEAREST: - texture->sampler = d3d11->samplers[RARCH_FILTER_NEAREST][RARCH_WRAP_DEFAULT]; + texture->sampler = d3d11->samplers[ + RARCH_FILTER_NEAREST][RARCH_WRAP_DEFAULT]; break; } @@ -1215,7 +1288,8 @@ static uintptr_t d3d11_gfx_load_texture( d3d11_init_texture(d3d11->device, texture); d3d11_update_texture( - d3d11->ctx, image->width, image->height, 0, DXGI_FORMAT_B8G8R8A8_UNORM, image->pixels, + d3d11->ctx, image->width, image->height, 0, + DXGI_FORMAT_B8G8R8A8_UNORM, image->pixels, texture); return (uintptr_t)texture; @@ -1257,7 +1331,8 @@ static const video_poke_interface_t d3d11_poke_interface = { NULL, /* get_hw_render_interface */ }; -static void d3d11_gfx_get_poke_interface(void* data, const video_poke_interface_t** iface) +static void d3d11_gfx_get_poke_interface(void* data, + const video_poke_interface_t **iface) { *iface = &d3d11_poke_interface; } diff --git a/gfx/include/Cg/cgD3D9.h b/gfx/include/Cg/cgD3D9.h index 465f26e3ea..646a2cf6fd 100644 --- a/gfx/include/Cg/cgD3D9.h +++ b/gfx/include/Cg/cgD3D9.h @@ -90,11 +90,11 @@ enum cgD3D9Errors cgD3D9DebugTrace = 1001 }; -/*--------------------------------------------------------------------------- -// HRESULTs specific to cgD3D9. When the CGerror is set to cgD3D9Failed -// cgD3D9GetLastError will return an HRESULT that could be one these. -// Use cgD3D9TranslateHRESULT() to translate these errors into strings. ----------------------------------------------------------------------------*/ +/* + * HRESULTs specific to cgD3D9. When the CGerror is set to cgD3D9Failed + * cgD3D9GetLastError will return an HRESULT that could be one these. + * Use cgD3D9TranslateHRESULT() to translate these errors into strings. +*/ static const HRESULT CGD3D9ERR_NOTLOADED = MAKE_HRESULT(1, 0x877, 1); static const HRESULT CGD3D9ERR_NODEVICE = MAKE_HRESULT(1, 0x877, 2); @@ -106,9 +106,9 @@ static const HRESULT CGD3D9ERR_NOTUNIFORM = MAKE_HRESULT(1, 0x877, 7); static const HRESULT CGD3D9ERR_NOTMATRIX = MAKE_HRESULT(1, 0x877, 8); static const HRESULT CGD3D9ERR_INVALIDPARAM = MAKE_HRESULT(1, 0x877, 9); -/*--------------------------------------------------------------------------- -// Other error return values ----------------------------------------------------------------------------*/ +/* + * Other error return values +*/ static const DWORD CGD3D9_INVALID_USAGE = 0xFF; diff --git a/gfx/include/d3d9/d3dx9math.h b/gfx/include/d3d9/d3dx9math.h index e8593c0f1e..914d9536f0 100644 --- a/gfx/include/d3d9/d3dx9math.h +++ b/gfx/include/d3d9/d3dx9math.h @@ -462,19 +462,19 @@ public: D3DXPLANE( CONST D3DXFLOAT16* ); D3DXPLANE( FLOAT a, FLOAT b, FLOAT c, FLOAT d ); - // casting + /* casting */ operator FLOAT* (); operator CONST FLOAT* () const; - // assignment operators + /* assignment operators */ D3DXPLANE& operator *= ( FLOAT ); D3DXPLANE& operator /= ( FLOAT ); - // unary operators + /* unary operators */ D3DXPLANE operator + () const; D3DXPLANE operator - () const; - // binary operators + /* binary operators */ D3DXPLANE operator * ( FLOAT ) const; D3DXPLANE operator / ( FLOAT ) const; @@ -483,16 +483,16 @@ public: BOOL operator == ( CONST D3DXPLANE& ) const; BOOL operator != ( CONST D3DXPLANE& ) const; -#endif //__cplusplus +#endif /*__cplusplus */ FLOAT a, b, c, d; } D3DXPLANE, *LPD3DXPLANE; -//=========================================================================== -// -// Colors -// -//=========================================================================== +/* + * + * Colors + * + */ typedef struct D3DXCOLOR { @@ -505,7 +505,7 @@ public: D3DXCOLOR( CONST D3DCOLORVALUE& ); D3DXCOLOR( FLOAT r, FLOAT g, FLOAT b, FLOAT a ); - // casting + /* casting */ operator DWORD () const; operator FLOAT* (); @@ -517,17 +517,17 @@ public: operator D3DCOLORVALUE& (); operator CONST D3DCOLORVALUE& () const; - // assignment operators + /* assignment operators */ D3DXCOLOR& operator += ( CONST D3DXCOLOR& ); D3DXCOLOR& operator -= ( CONST D3DXCOLOR& ); D3DXCOLOR& operator *= ( FLOAT ); D3DXCOLOR& operator /= ( FLOAT ); - // unary operators + /* unary operators */ D3DXCOLOR operator + () const; D3DXCOLOR operator - () const; - // binary operators + /* binary operators */ D3DXCOLOR operator + ( CONST D3DXCOLOR& ) const; D3DXCOLOR operator - ( CONST D3DXCOLOR& ) const; D3DXCOLOR operator * ( FLOAT ) const; @@ -538,38 +538,35 @@ public: BOOL operator == ( CONST D3DXCOLOR& ) const; BOOL operator != ( CONST D3DXCOLOR& ) const; -#endif //__cplusplus +#endif /* __cplusplus */ FLOAT r, g, b, a; } D3DXCOLOR, *LPD3DXCOLOR; +/* + * + * D3DX math functions: + * + * NOTE: + * * All these functions can take the same object as in and out parameters. + * + * * Out parameters are typically also returned as return values, so that + * the output of one function may be used as a parameter to another. + */ +/* + * Float16 + */ -//=========================================================================== -// -// D3DX math functions: -// -// NOTE: -// * All these functions can take the same object as in and out parameters. -// -// * Out parameters are typically also returned as return values, so that -// the output of one function may be used as a parameter to another. -// -//=========================================================================== - -//-------------------------- -// Float16 -//-------------------------- - -// non-inline +/* non-inline */ #ifdef __cplusplus extern "C" { #endif -// Converts an array 32-bit floats to 16-bit floats +/* Converts an array 32-bit floats to 16-bit floats */ D3DXFLOAT16* WINAPI D3DXFloat32To16Array ( D3DXFLOAT16 *pOut, CONST FLOAT *pIn, UINT n ); -// Converts an array 16-bit floats to 32-bit floats +/* Converts an array 16-bit floats to 32-bit floats */ FLOAT* WINAPI D3DXFloat16To32Array ( FLOAT *pOut, CONST D3DXFLOAT16 *pIn, UINT n ); @@ -577,12 +574,11 @@ FLOAT* WINAPI D3DXFloat16To32Array } #endif +/* + * 2D Vector + */ -//-------------------------- -// 2D Vector -//-------------------------- - -// inline +/* inline */ FLOAT D3DXVec2Length ( CONST D3DXVECTOR2 *pV ); @@ -593,7 +589,7 @@ FLOAT D3DXVec2LengthSq FLOAT D3DXVec2Dot ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); -// Z component of ((x1,y1,0) cross (x2,y2,0)) +/* Z component of ((x1,y1,0) cross (x2,y2,0)) */ FLOAT D3DXVec2CCW ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); @@ -603,23 +599,23 @@ D3DXVECTOR2* D3DXVec2Add D3DXVECTOR2* D3DXVec2Subtract ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); -// Minimize each component. x = min(x1, x2), y = min(y1, y2) +/* Minimize each component. x = min(x1, x2), y = min(y1, y2) */ D3DXVECTOR2* D3DXVec2Minimize ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); -// Maximize each component. x = max(x1, x2), y = max(y1, y2) +/* Maximize each component. x = max(x1, x2), y = max(y1, y2) */ D3DXVECTOR2* D3DXVec2Maximize ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); D3DXVECTOR2* D3DXVec2Scale ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, FLOAT s ); -// Linear interpolation. V1 + s(V2-V1) +/* Linear interpolation. V1 + s(V2-V1) */ D3DXVECTOR2* D3DXVec2Lerp ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, FLOAT s ); -// non-inline +/* non-inline */ #ifdef __cplusplus extern "C" { #endif @@ -627,43 +623,43 @@ extern "C" { D3DXVECTOR2* WINAPI D3DXVec2Normalize ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV ); -// Hermite interpolation between position V1, tangent T1 (when s == 0) -// and position V2, tangent T2 (when s == 1). +/* Hermite interpolation between position V1, tangent T1 (when s == 0) + * and position V2, tangent T2 (when s == 1). */ D3DXVECTOR2* WINAPI D3DXVec2Hermite ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pT1, CONST D3DXVECTOR2 *pV2, CONST D3DXVECTOR2 *pT2, FLOAT s ); -// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) +/* CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) */ D3DXVECTOR2* WINAPI D3DXVec2CatmullRom ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV0, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, CONST D3DXVECTOR2 *pV3, FLOAT s ); -// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) +/* Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) */ D3DXVECTOR2* WINAPI D3DXVec2BaryCentric ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, CONST D3DXVECTOR2 *pV3, FLOAT f, FLOAT g); -// Transform (x, y, 0, 1) by matrix. +/* Transform (x, y, 0, 1) by matrix. */ D3DXVECTOR4* WINAPI D3DXVec2Transform ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); -// Transform (x, y, 0, 1) by matrix, project result back into w=1. +/* Transform (x, y, 0, 1) by matrix, project result back into w=1. */ D3DXVECTOR2* WINAPI D3DXVec2TransformCoord ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); -// Transform (x, y, 0, 0) by matrix. +/* Transform (x, y, 0, 0) by matrix. */ D3DXVECTOR2* WINAPI D3DXVec2TransformNormal ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); -// Transform Array (x, y, 0, 1) by matrix. +/* Transform Array (x, y, 0, 1) by matrix. */ D3DXVECTOR4* WINAPI D3DXVec2TransformArray ( D3DXVECTOR4 *pOut, UINT OutStride, CONST D3DXVECTOR2 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n); -// Transform Array (x, y, 0, 1) by matrix, project result back into w=1. +/* Transform Array (x, y, 0, 1) by matrix, project result back into w=1. */ D3DXVECTOR2* WINAPI D3DXVec2TransformCoordArray ( D3DXVECTOR2 *pOut, UINT OutStride, CONST D3DXVECTOR2 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); -// Transform Array (x, y, 0, 0) by matrix. +/* Transform Array (x, y, 0, 0) by matrix. */ D3DXVECTOR2* WINAPI D3DXVec2TransformNormalArray ( D3DXVECTOR2 *pOut, UINT OutStride, CONST D3DXVECTOR2 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); @@ -673,12 +669,11 @@ D3DXVECTOR2* WINAPI D3DXVec2TransformNormalArray } #endif +/* + * 3D Vector + */ -//-------------------------- -// 3D Vector -//-------------------------- - -// inline +/* inline */ FLOAT D3DXVec3Length ( CONST D3DXVECTOR3 *pV ); @@ -698,23 +693,23 @@ D3DXVECTOR3* D3DXVec3Add D3DXVECTOR3* D3DXVec3Subtract ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); -// Minimize each component. x = min(x1, x2), y = min(y1, y2), ... +/* Minimize each component. x = min(x1, x2), y = min(y1, y2), ... */ D3DXVECTOR3* D3DXVec3Minimize ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); -// Maximize each component. x = max(x1, x2), y = max(y1, y2), ... +/* Maximize each component. x = max(x1, x2), y = max(y1, y2), ... */ D3DXVECTOR3* D3DXVec3Maximize ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); D3DXVECTOR3* D3DXVec3Scale ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, FLOAT s); -// Linear interpolation. V1 + s(V2-V1) +/* Linear interpolation. V1 + s(V2-V1) */ D3DXVECTOR3* D3DXVec3Lerp ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, FLOAT s ); -// non-inline +/* non-inline */ #ifdef __cplusplus extern "C" { #endif @@ -722,67 +717,69 @@ extern "C" { D3DXVECTOR3* WINAPI D3DXVec3Normalize ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV ); -// Hermite interpolation between position V1, tangent T1 (when s == 0) -// and position V2, tangent T2 (when s == 1). +/* Hermite interpolation between position V1, tangent T1 (when s == 0) + * and position V2, tangent T2 (when s == 1). */ D3DXVECTOR3* WINAPI D3DXVec3Hermite ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pT1, CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pT2, FLOAT s ); -// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) +/* CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) */ D3DXVECTOR3* WINAPI D3DXVec3CatmullRom ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV0, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pV3, FLOAT s ); -// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) +/* Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) */ D3DXVECTOR3* WINAPI D3DXVec3BaryCentric ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pV3, FLOAT f, FLOAT g); -// Transform (x, y, z, 1) by matrix. +/* Transform (x, y, z, 1) by matrix. */ D3DXVECTOR4* WINAPI D3DXVec3Transform ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); -// Transform (x, y, z, 1) by matrix, project result back into w=1. +/* Transform (x, y, z, 1) by matrix, project result back into w=1. */ D3DXVECTOR3* WINAPI D3DXVec3TransformCoord ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); -// Transform (x, y, z, 0) by matrix. If you transforming a normal by a -// non-affine matrix, the matrix you pass to this function should be the -// transpose of the inverse of the matrix you would use to transform a coord. +/* Transform (x, y, z, 0) by matrix. If you transforming a normal by a + * non-affine matrix, the matrix you pass to this function should be the + * transpose of the inverse of the matrix you would use to transform a coord. + */ D3DXVECTOR3* WINAPI D3DXVec3TransformNormal ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); -// Transform Array (x, y, z, 1) by matrix. +/* Transform Array (x, y, z, 1) by matrix. */ D3DXVECTOR4* WINAPI D3DXVec3TransformArray ( D3DXVECTOR4 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); -// Transform Array (x, y, z, 1) by matrix, project result back into w=1. +/* Transform Array (x, y, z, 1) by matrix, project result back into w=1. */ D3DXVECTOR3* WINAPI D3DXVec3TransformCoordArray ( D3DXVECTOR3 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); -// Transform (x, y, z, 0) by matrix. If you transforming a normal by a -// non-affine matrix, the matrix you pass to this function should be the -// transpose of the inverse of the matrix you would use to transform a coord. +/* Transform (x, y, z, 0) by matrix. If you transforming a normal by a + * non-affine matrix, the matrix you pass to this function should be the + * transpose of the inverse of the matrix you would use to transform a coord. + */ D3DXVECTOR3* WINAPI D3DXVec3TransformNormalArray ( D3DXVECTOR3 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); -// Project vector from object space into screen space +/* Project vector from object space into screen space */ D3DXVECTOR3* WINAPI D3DXVec3Project ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DVIEWPORT9 *pViewport, CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld); -// Project vector from screen space into object space +/* Project vector from screen space into object space */ D3DXVECTOR3* WINAPI D3DXVec3Unproject ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DVIEWPORT9 *pViewport, CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld); -// Project vector Array from object space into screen space +/* Project vector Array from object space into screen space */ D3DXVECTOR3* WINAPI D3DXVec3ProjectArray ( D3DXVECTOR3 *pOut, UINT OutStride,CONST D3DXVECTOR3 *pV, UINT VStride,CONST D3DVIEWPORT9 *pViewport, CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld, UINT n); -// Project vector Array from screen space into object space +/* Project vector Array from screen space into object space */ D3DXVECTOR3* WINAPI D3DXVec3UnprojectArray ( D3DXVECTOR3 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DVIEWPORT9 *pViewport, CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld, UINT n); @@ -792,13 +789,11 @@ D3DXVECTOR3* WINAPI D3DXVec3UnprojectArray } #endif +/* + * 4D Vector + */ - -//-------------------------- -// 4D Vector -//-------------------------- - -// inline +/* inline */ FLOAT D3DXVec4Length ( CONST D3DXVECTOR4 *pV ); @@ -815,28 +810,28 @@ D3DXVECTOR4* D3DXVec4Add D3DXVECTOR4* D3DXVec4Subtract ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); -// Minimize each component. x = min(x1, x2), y = min(y1, y2), ... +/* Minimize each component. x = min(x1, x2), y = min(y1, y2), ... */ D3DXVECTOR4* D3DXVec4Minimize ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); -// Maximize each component. x = max(x1, x2), y = max(y1, y2), ... +/* Maximize each component. x = max(x1, x2), y = max(y1, y2), ... */ D3DXVECTOR4* D3DXVec4Maximize ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); D3DXVECTOR4* D3DXVec4Scale ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, FLOAT s); -// Linear interpolation. V1 + s(V2-V1) +/* Linear interpolation. V1 + s(V2-V1) */ D3DXVECTOR4* D3DXVec4Lerp ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, FLOAT s ); -// non-inline +/* non-inline */ #ifdef __cplusplus extern "C" { #endif -// Cross-product in 4 dimensions. +/* Cross-product in 4 dimensions. */ D3DXVECTOR4* WINAPI D3DXVec4Cross ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pV3); @@ -844,27 +839,27 @@ D3DXVECTOR4* WINAPI D3DXVec4Cross D3DXVECTOR4* WINAPI D3DXVec4Normalize ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV ); -// Hermite interpolation between position V1, tangent T1 (when s == 0) -// and position V2, tangent T2 (when s == 1). +/* Hermite interpolation between position V1, tangent T1 (when s == 0) + * and position V2, tangent T2 (when s == 1). */ D3DXVECTOR4* WINAPI D3DXVec4Hermite ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pT1, CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pT2, FLOAT s ); -// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) +/* CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) */ D3DXVECTOR4* WINAPI D3DXVec4CatmullRom ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV0, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pV3, FLOAT s ); -// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) +/* Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) */ D3DXVECTOR4* WINAPI D3DXVec4BaryCentric ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pV3, FLOAT f, FLOAT g); -// Transform vector by matrix. +/* Transform vector by matrix. */ D3DXVECTOR4* WINAPI D3DXVec4Transform ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, CONST D3DXMATRIX *pM ); -// Transform vector array by matrix. +/* Transform vector array by matrix. */ D3DXVECTOR4* WINAPI D3DXVec4TransformArray ( D3DXVECTOR4 *pOut, UINT OutStride, CONST D3DXVECTOR4 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); @@ -873,11 +868,11 @@ D3DXVECTOR4* WINAPI D3DXVec4TransformArray #endif -//-------------------------- -// 4D Matrix -//-------------------------- +/* + * 4D Matrix + */ -// inline +/* inline */ D3DXMATRIX* D3DXMatrixIdentity ( D3DXMATRIX *pOut ); @@ -901,143 +896,143 @@ HRESULT WINAPI D3DXMatrixDecompose D3DXMATRIX* WINAPI D3DXMatrixTranspose ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM ); -// Matrix multiplication. The result represents the transformation M2 -// followed by the transformation M1. (Out = M1 * M2) +/* Matrix multiplication. The result represents the transformation M2 + * followed by the transformation M1. (Out = M1 * M2) */ D3DXMATRIX* WINAPI D3DXMatrixMultiply ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 ); -// Matrix multiplication, followed by a transpose. (Out = T(M1 * M2)) +/* Matrix multiplication, followed by a transpose. (Out = T(M1 * M2)) */ D3DXMATRIX* WINAPI D3DXMatrixMultiplyTranspose ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 ); -// Calculate inverse of matrix. Inversion my fail, in which case NULL will -// be returned. The determinant of pM is also returned it pfDeterminant -// is non-NULL. +/* Calculate inverse of matrix. Inversion my fail, in which case NULL will + * be returned. The determinant of pM is also returned it pfDeterminant + * is non-NULL. */ D3DXMATRIX* WINAPI D3DXMatrixInverse ( D3DXMATRIX *pOut, FLOAT *pDeterminant, CONST D3DXMATRIX *pM ); -// Build a matrix which scales by (sx, sy, sz) +/* Build a matrix which scales by (sx, sy, sz) */ D3DXMATRIX* WINAPI D3DXMatrixScaling ( D3DXMATRIX *pOut, FLOAT sx, FLOAT sy, FLOAT sz ); -// Build a matrix which translates by (x, y, z) +/* Build a matrix which translates by (x, y, z) */ D3DXMATRIX* WINAPI D3DXMatrixTranslation ( D3DXMATRIX *pOut, FLOAT x, FLOAT y, FLOAT z ); -// Build a matrix which rotates around the X axis +/* Build a matrix which rotates around the X axis */ D3DXMATRIX* WINAPI D3DXMatrixRotationX ( D3DXMATRIX *pOut, FLOAT Angle ); -// Build a matrix which rotates around the Y axis +/* Build a matrix which rotates around the Y axis */ D3DXMATRIX* WINAPI D3DXMatrixRotationY ( D3DXMATRIX *pOut, FLOAT Angle ); -// Build a matrix which rotates around the Z axis +/* Build a matrix which rotates around the Z axis */ D3DXMATRIX* WINAPI D3DXMatrixRotationZ ( D3DXMATRIX *pOut, FLOAT Angle ); -// Build a matrix which rotates around an arbitrary axis +/* Build a matrix which rotates around an arbitrary axis */ D3DXMATRIX* WINAPI D3DXMatrixRotationAxis ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pV, FLOAT Angle ); -// Build a matrix from a quaternion +/* Build a matrix from a quaternion */ D3DXMATRIX* WINAPI D3DXMatrixRotationQuaternion ( D3DXMATRIX *pOut, CONST D3DXQUATERNION *pQ); -// Yaw around the Y axis, a pitch around the X axis, -// and a roll around the Z axis. +/* Yaw around the Y axis, a pitch around the X axis, + * and a roll around the Z axis. */ D3DXMATRIX* WINAPI D3DXMatrixRotationYawPitchRoll ( D3DXMATRIX *pOut, FLOAT Yaw, FLOAT Pitch, FLOAT Roll ); -// Build transformation matrix. NULL arguments are treated as identity. -// Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt +/* Build transformation matrix. NULL arguments are treated as identity. + * Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt */ D3DXMATRIX* WINAPI D3DXMatrixTransformation ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pScalingCenter, CONST D3DXQUATERNION *pScalingRotation, CONST D3DXVECTOR3 *pScaling, CONST D3DXVECTOR3 *pRotationCenter, CONST D3DXQUATERNION *pRotation, CONST D3DXVECTOR3 *pTranslation); -// Build 2D transformation matrix in XY plane. NULL arguments are treated as identity. -// Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt +/* Build 2D transformation matrix in XY plane. NULL arguments are treated as identity. + * Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt */ D3DXMATRIX* WINAPI D3DXMatrixTransformation2D ( D3DXMATRIX *pOut, CONST D3DXVECTOR2* pScalingCenter, FLOAT ScalingRotation, CONST D3DXVECTOR2* pScaling, CONST D3DXVECTOR2* pRotationCenter, FLOAT Rotation, CONST D3DXVECTOR2* pTranslation); -// Build affine transformation matrix. NULL arguments are treated as identity. -// Mout = Ms * Mrc-1 * Mr * Mrc * Mt +/* Build affine transformation matrix. NULL arguments are treated as identity. + * Mout = Ms * Mrc-1 * Mr * Mrc * Mt */ D3DXMATRIX* WINAPI D3DXMatrixAffineTransformation ( D3DXMATRIX *pOut, FLOAT Scaling, CONST D3DXVECTOR3 *pRotationCenter, CONST D3DXQUATERNION *pRotation, CONST D3DXVECTOR3 *pTranslation); -// Build 2D affine transformation matrix in XY plane. NULL arguments are treated as identity. -// Mout = Ms * Mrc-1 * Mr * Mrc * Mt +/* Build 2D affine transformation matrix in XY plane. NULL arguments are treated as identity. + * Mout = Ms * Mrc-1 * Mr * Mrc * Mt */ D3DXMATRIX* WINAPI D3DXMatrixAffineTransformation2D ( D3DXMATRIX *pOut, FLOAT Scaling, CONST D3DXVECTOR2* pRotationCenter, FLOAT Rotation, CONST D3DXVECTOR2* pTranslation); -// Build a lookat matrix. (right-handed) +/* Build a lookat matrix. (right-handed) */ D3DXMATRIX* WINAPI D3DXMatrixLookAtRH ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pEye, CONST D3DXVECTOR3 *pAt, CONST D3DXVECTOR3 *pUp ); -// Build a lookat matrix. (left-handed) +/* Build a lookat matrix. (left-handed) */ D3DXMATRIX* WINAPI D3DXMatrixLookAtLH ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pEye, CONST D3DXVECTOR3 *pAt, CONST D3DXVECTOR3 *pUp ); -// Build a perspective projection matrix. (right-handed) +/* Build a perspective projection matrix. (right-handed) */ D3DXMATRIX* WINAPI D3DXMatrixPerspectiveRH ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); -// Build a perspective projection matrix. (left-handed) +/* Build a perspective projection matrix. (left-handed) */ D3DXMATRIX* WINAPI D3DXMatrixPerspectiveLH ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); -// Build a perspective projection matrix. (right-handed) +/* Build a perspective projection matrix. (right-handed) */ D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovRH ( D3DXMATRIX *pOut, FLOAT fovy, FLOAT Aspect, FLOAT zn, FLOAT zf ); -// Build a perspective projection matrix. (left-handed) +/* Build a perspective projection matrix. (left-handed) */ D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovLH ( D3DXMATRIX *pOut, FLOAT fovy, FLOAT Aspect, FLOAT zn, FLOAT zf ); -// Build a perspective projection matrix. (right-handed) +/* Build a perspective projection matrix. (right-handed) */ D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterRH ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, FLOAT zf ); -// Build a perspective projection matrix. (left-handed) +/* Build a perspective projection matrix. (left-handed) */ D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterLH ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, FLOAT zf ); -// Build an ortho projection matrix. (right-handed) +/* Build an ortho projection matrix. (right-handed) */ D3DXMATRIX* WINAPI D3DXMatrixOrthoRH ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); -// Build an ortho projection matrix. (left-handed) +/* Build an ortho projection matrix. (left-handed) */ D3DXMATRIX* WINAPI D3DXMatrixOrthoLH ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); -// Build an ortho projection matrix. (right-handed) +/* Build an ortho projection matrix. (right-handed) */ D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenterRH ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, FLOAT zf ); -// Build an ortho projection matrix. (left-handed) +/* Build an ortho projection matrix. (left-handed) */ D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenterLH ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, FLOAT zf ); -// Build a matrix which flattens geometry into a plane, as if casting -// a shadow from a light. +/* Build a matrix which flattens geometry into a plane, as if casting + * a shadow from a light. */ D3DXMATRIX* WINAPI D3DXMatrixShadow ( D3DXMATRIX *pOut, CONST D3DXVECTOR4 *pLight, CONST D3DXPLANE *pPlane ); -// Build a matrix which reflects the coordinate system about a plane +/* Build a matrix which reflects the coordinate system about a plane */ D3DXMATRIX* WINAPI D3DXMatrixReflect ( D3DXMATRIX *pOut, CONST D3DXPLANE *pPlane ); @@ -1045,10 +1040,9 @@ D3DXMATRIX* WINAPI D3DXMatrixReflect } #endif - -//-------------------------- -// Quaternion -//-------------------------- +/* + * Quaternion + */ /* inline */ @@ -1069,35 +1063,34 @@ D3DXQUATERNION* D3DXQuaternionIdentity BOOL D3DXQuaternionIsIdentity ( CONST D3DXQUATERNION *pQ ); -// (-x, -y, -z, w) +/* (-x, -y, -z, w) */ D3DXQUATERNION* D3DXQuaternionConjugate ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); - -// non-inline +/* non-inline */ #ifdef __cplusplus extern "C" { #endif -// Compute a quaternin's axis and angle of rotation. Expects unit quaternions. +/* Compute a quaternin's axis and angle of rotation. Expects unit quaternions. */ void WINAPI D3DXQuaternionToAxisAngle ( CONST D3DXQUATERNION *pQ, D3DXVECTOR3 *pAxis, FLOAT *pAngle ); -// Build a quaternion from a rotation matrix. +/* Build a quaternion from a rotation matrix. */ D3DXQUATERNION* WINAPI D3DXQuaternionRotationMatrix ( D3DXQUATERNION *pOut, CONST D3DXMATRIX *pM); -// Rotation about arbitrary axis. +/* Rotation about arbitrary axis. */ D3DXQUATERNION* WINAPI D3DXQuaternionRotationAxis ( D3DXQUATERNION *pOut, CONST D3DXVECTOR3 *pV, FLOAT Angle ); -// Yaw around the Y axis, a pitch around the X axis, -// and a roll around the Z axis. +/* Yaw around the Y axis, a pitch around the X axis, + * and a roll around the Z axis. */ D3DXQUATERNION* WINAPI D3DXQuaternionRotationYawPitchRoll ( D3DXQUATERNION *pOut, FLOAT Yaw, FLOAT Pitch, FLOAT Roll ); -// Quaternion multiplication. The result represents the rotation Q2 -// followed by the rotation Q1. (Out = Q2 * Q1) +/* Quaternion multiplication. The result represents the rotation Q2 + * followed by the rotation Q1. (Out = Q2 * Q1) */ D3DXQUATERNION* WINAPI D3DXQuaternionMultiply ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2 ); @@ -1105,43 +1098,43 @@ D3DXQUATERNION* WINAPI D3DXQuaternionMultiply D3DXQUATERNION* WINAPI D3DXQuaternionNormalize ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); -// Conjugate and re-norm +/* Conjugate and re-norm */ D3DXQUATERNION* WINAPI D3DXQuaternionInverse ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); -// Expects unit quaternions. -// if q = (cos(theta), sin(theta) * v); ln(q) = (0, theta * v) +/* Expects unit quaternions. + * if q = (cos(theta), sin(theta) * v); ln(q) = (0, theta * v) */ D3DXQUATERNION* WINAPI D3DXQuaternionLn ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); -// Expects pure quaternions. (w == 0) w is ignored in calculation. -// if q = (0, theta * v); exp(q) = (cos(theta), sin(theta) * v) +/* Expects pure quaternions. (w == 0) w is ignored in calculation. + * if q = (0, theta * v); exp(q) = (cos(theta), sin(theta) * v) */ D3DXQUATERNION* WINAPI D3DXQuaternionExp ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); -// Spherical linear interpolation between Q1 (t == 0) and Q2 (t == 1). -// Expects unit quaternions. +/* Spherical linear interpolation between Q1 (t == 0) and Q2 (t == 1). + * Expects unit quaternions. */ D3DXQUATERNION* WINAPI D3DXQuaternionSlerp ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2, FLOAT t ); -// Spherical quadrangle interpolation. -// Slerp(Slerp(Q1, C, t), Slerp(A, B, t), 2t(1-t)) +/* Spherical quadrangle interpolation. + * Slerp(Slerp(Q1, C, t), Slerp(A, B, t), 2t(1-t)) */ D3DXQUATERNION* WINAPI D3DXQuaternionSquad ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pA, CONST D3DXQUATERNION *pB, CONST D3DXQUATERNION *pC, FLOAT t ); -// Setup control points for spherical quadrangle interpolation -// from Q1 to Q2. The control points are chosen in such a way -// to ensure the continuity of tangents with adjacent segments. +/* Setup control points for spherical quadrangle interpolation + * from Q1 to Q2. The control points are chosen in such a way + * to ensure the continuity of tangents with adjacent segments. */ void WINAPI D3DXQuaternionSquadSetup ( D3DXQUATERNION *pAOut, D3DXQUATERNION *pBOut, D3DXQUATERNION *pCOut, CONST D3DXQUATERNION *pQ0, CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2, CONST D3DXQUATERNION *pQ3 ); -// Barycentric interpolation. -// Slerp(Slerp(Q1, Q2, f+g), Slerp(Q1, Q3, f+g), g/(f+g)) +/* Barycentric interpolation. + * Slerp(Slerp(Q1, Q2, f+g), Slerp(Q1, Q3, f+g), g/(f+g)) */ D3DXQUATERNION* WINAPI D3DXQuaternionBaryCentric ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2, CONST D3DXQUATERNION *pQ3, @@ -1152,58 +1145,58 @@ D3DXQUATERNION* WINAPI D3DXQuaternionBaryCentric #endif -//-------------------------- -// Plane -//-------------------------- +/* + * Plane +*/ -// inline +/* inline */ -// ax + by + cz + dw +/* ax + by + cz + dw */ FLOAT D3DXPlaneDot ( CONST D3DXPLANE *pP, CONST D3DXVECTOR4 *pV); -// ax + by + cz + d +/* ax + by + cz + d */ FLOAT D3DXPlaneDotCoord ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV); -// ax + by + cz +/* ax + by + cz */ FLOAT D3DXPlaneDotNormal ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV); D3DXPLANE* D3DXPlaneScale (D3DXPLANE *pOut, CONST D3DXPLANE *pP, FLOAT s); -// non-inline +/* non-inline */ #ifdef __cplusplus extern "C" { #endif -// Normalize plane (so that |a,b,c| == 1) +/* Normalize plane (so that |a,b,c| == 1) */ D3DXPLANE* WINAPI D3DXPlaneNormalize ( D3DXPLANE *pOut, CONST D3DXPLANE *pP); -// Find the intersection between a plane and a line. If the line is -// parallel to the plane, NULL is returned. +/* Find the intersection between a plane and a line. If the line is + * parallel to the plane, NULL is returned. */ D3DXVECTOR3* WINAPI D3DXPlaneIntersectLine ( D3DXVECTOR3 *pOut, CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2); -// Construct a plane from a point and a normal +/* Construct a plane from a point and a normal */ D3DXPLANE* WINAPI D3DXPlaneFromPointNormal ( D3DXPLANE *pOut, CONST D3DXVECTOR3 *pPoint, CONST D3DXVECTOR3 *pNormal); -// Construct a plane from 3 points +/* Construct a plane from 3 points */ D3DXPLANE* WINAPI D3DXPlaneFromPoints ( D3DXPLANE *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pV3); -// Transform a plane by a matrix. The vector (a,b,c) must be normal. -// M should be the inverse transpose of the transformation desired. +/* Transform a plane by a matrix. The vector (a,b,c) must be normal. + * M should be the inverse transpose of the transformation desired. */ D3DXPLANE* WINAPI D3DXPlaneTransform ( D3DXPLANE *pOut, CONST D3DXPLANE *pP, CONST D3DXMATRIX *pM ); -// Transform an array of planes by a matrix. The vectors (a,b,c) must be normal. -// M should be the inverse transpose of the transformation desired. +/* Transform an array of planes by a matrix. The vectors (a,b,c) must be normal. + * M should be the inverse transpose of the transformation desired. */ D3DXPLANE* WINAPI D3DXPlaneTransformArray ( D3DXPLANE *pOut, UINT OutStride, CONST D3DXPLANE *pP, UINT PStride, CONST D3DXMATRIX *pM, UINT n ); @@ -1211,14 +1204,13 @@ D3DXPLANE* WINAPI D3DXPlaneTransformArray } #endif +/* + * Color + */ -//-------------------------- -// Color -//-------------------------- +/* inline */ -// inline - -// (1-r, 1-g, 1-b, a) +/* (1-r, 1-g, 1-b, a) */ D3DXCOLOR* D3DXColorNegative (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC); @@ -1231,25 +1223,25 @@ D3DXCOLOR* D3DXColorSubtract D3DXCOLOR* D3DXColorScale (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s); -// (r1*r2, g1*g2, b1*b2, a1*a2) +/* (r1*r2, g1*g2, b1*b2, a1*a2) */ D3DXCOLOR* D3DXColorModulate (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2); -// Linear interpolation of r,g,b, and a. C1 + s(C2-C1) +/* Linear interpolation of r,g,b, and a. C1 + s(C2-C1) */ D3DXCOLOR* D3DXColorLerp (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2, FLOAT s); -// non-inline +/* non-inline */ #ifdef __cplusplus extern "C" { #endif -// Interpolate r,g,b between desaturated color and color. -// DesaturatedColor + s(Color - DesaturatedColor) +/* Interpolate r,g,b between desaturated color and color. + * DesaturatedColor + s(Color - DesaturatedColor) */ D3DXCOLOR* WINAPI D3DXColorAdjustSaturation (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s); -// Interpolate r,g,b between 50% grey and color. Grey + s(Color - Grey) +/* Interpolate r,g,b between 50% grey and color. Grey + s(Color - Grey) */ D3DXCOLOR* WINAPI D3DXColorAdjustContrast (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT c); @@ -1257,16 +1249,16 @@ D3DXCOLOR* WINAPI D3DXColorAdjustContrast } #endif -//-------------------------- -// Misc -//-------------------------- +/* + * Misc +*/ #ifdef __cplusplus extern "C" { #endif -// Calculate Fresnel term given the cosine of theta (likely obtained by -// taking the dot of two normals), and the refraction index of the material. +/* Calculate Fresnel term given the cosine of theta (likely obtained by + * taking the dot of two normals), and the refraction index of the material. */ FLOAT WINAPI D3DXFresnelTerm (FLOAT CosTheta, FLOAT RefractionIndex); @@ -1274,16 +1266,15 @@ FLOAT WINAPI D3DXFresnelTerm } #endif -//=========================================================================== -// -// Matrix Stack -// -//=========================================================================== +/* + * + * Matrix Stack + */ typedef interface ID3DXMatrixStack ID3DXMatrixStack; typedef interface ID3DXMatrixStack *LPD3DXMATRIXSTACK; -// {C7885BA7-F990-4fe7-922D-8515E477DD85} +/* {C7885BA7-F990-4fe7-922D-8515E477DD85} */ DEFINE_GUID(IID_ID3DXMatrixStack, 0xc7885ba7, 0xf990, 0x4fe7, 0x92, 0x2d, 0x85, 0x15, 0xe4, 0x77, 0xdd, 0x85); @@ -1293,85 +1284,83 @@ DEFINE_GUID(IID_ID3DXMatrixStack, DECLARE_INTERFACE_(ID3DXMatrixStack, IUnknown) { - // - // IUnknown methods - // + /* IUnknown methods */ STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; STDMETHOD_(ULONG,AddRef)(THIS) PURE; STDMETHOD_(ULONG,Release)(THIS) PURE; - // - // ID3DXMatrixStack methods - // + /* ID3DXMatrixStack methods */ - // Pops the top of the stack, returns the current top - // *after* popping the top. + /* Pops the top of the stack, returns the current top + * *after* popping the top. */ STDMETHOD(Pop)(THIS) PURE; - // Pushes the stack by one, duplicating the current matrix. + /* Pushes the stack by one, duplicating the current matrix. */ STDMETHOD(Push)(THIS) PURE; - // Loads identity in the current matrix. + /* Loads identity in the current matrix. */ STDMETHOD(LoadIdentity)(THIS) PURE; - // Loads the given matrix into the current matrix + /* Loads the given matrix into the current matrix */ STDMETHOD(LoadMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE; - // Right-Multiplies the given matrix to the current matrix. - // (transformation is about the current world origin) + /* Right-Multiplies the given matrix to the current matrix. + * (transformation is about the current world origin) */ STDMETHOD(MultMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE; - // Left-Multiplies the given matrix to the current matrix - // (transformation is about the local origin of the object) + /* Left-Multiplies the given matrix to the current matrix + * (transformation is about the local origin of the object) */ STDMETHOD(MultMatrixLocal)(THIS_ CONST D3DXMATRIX* pM ) PURE; - // Right multiply the current matrix with the computed rotation - // matrix, counterclockwise about the given axis with the given angle. - // (rotation is about the current world origin) + /* Right multiply the current matrix with the computed rotation + * matrix, counterclockwise about the given axis with the given angle. + * (rotation is about the current world origin) */ STDMETHOD(RotateAxis) (THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE; - // Left multiply the current matrix with the computed rotation - // matrix, counterclockwise about the given axis with the given angle. - // (rotation is about the local origin of the object) + /* Left multiply the current matrix with the computed rotation + * matrix, counterclockwise about the given axis with the given angle. + * (rotation is about the local origin of the object) */ STDMETHOD(RotateAxisLocal) (THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE; - // Right multiply the current matrix with the computed rotation - // matrix. All angles are counterclockwise. (rotation is about the - // current world origin) + /* Right multiply the current matrix with the computed rotation + * matrix. All angles are counterclockwise. (rotation is about the + * current world origin) - // The rotation is composed of a yaw around the Y axis, a pitch around - // the X axis, and a roll around the Z axis. + * The rotation is composed of a yaw around the Y axis, a pitch around + * the X axis, and a roll around the Z axis. + */ STDMETHOD(RotateYawPitchRoll) (THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE; - // Left multiply the current matrix with the computed rotation - // matrix. All angles are counterclockwise. (rotation is about the - // local origin of the object) + /* Left multiply the current matrix with the computed rotation + * matrix. All angles are counterclockwise. (rotation is about the + * local origin of the object) - // The rotation is composed of a yaw around the Y axis, a pitch around - // the X axis, and a roll around the Z axis. + * The rotation is composed of a yaw around the Y axis, a pitch around + * the X axis, and a roll around the Z axis. + */ STDMETHOD(RotateYawPitchRollLocal) (THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE; - // Right multiply the current matrix with the computed scale - // matrix. (transformation is about the current world origin) + /* Right multiply the current matrix with the computed scale + * matrix. (transformation is about the current world origin) */ STDMETHOD(Scale)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; - // Left multiply the current matrix with the computed scale - // matrix. (transformation is about the local origin of the object) + /* Left multiply the current matrix with the computed scale + * matrix. (transformation is about the local origin of the object) */ STDMETHOD(ScaleLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; - // Right multiply the current matrix with the computed translation - // matrix. (transformation is about the current world origin) + /* Right multiply the current matrix with the computed translation + * matrix. (transformation is about the current world origin) */ STDMETHOD(Translate)(THIS_ FLOAT x, FLOAT y, FLOAT z ) PURE; - // Left multiply the current matrix with the computed translation - // matrix. (transformation is about the local origin of the object) + /* Left multiply the current matrix with the computed translation + * matrix. (transformation is about the local origin of the object) */ STDMETHOD(TranslateLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; - // Obtain the current matrix at the top of the stack + /* Obtain the current matrix at the top of the stack */ STDMETHOD_(D3DXMATRIX*, GetTop)(THIS) PURE; }; @@ -1388,30 +1377,27 @@ HRESULT WINAPI } #endif -//=========================================================================== -// -// Spherical Harmonic Runtime Routines -// -// NOTE: -// * Most of these functions can take the same object as in and out parameters. -// The exceptions are the rotation functions. -// -// * Out parameters are typically also returned as return values, so that -// the output of one function may be used as a parameter to another. -// -//============================================================================ +/* + * + * Spherical Harmonic Runtime Routines + * + * NOTE: + * * Most of these functions can take the same object as in and out parameters. + * The exceptions are the rotation functions. + * + * * Out parameters are typically also returned as return values, so that + * the output of one function may be used as a parameter to another. + */ - -// non-inline +/* non-inline */ #ifdef __cplusplus extern "C" { #endif -//============================================================================ -// -// Basic Spherical Harmonic math routines -// -//============================================================================ +/* + * + * Basic Spherical Harmonic math routines + */ #define D3DXSH_MINORDER 2 #define D3DXSH_MAXORDER 6 @@ -1440,12 +1426,10 @@ FLOAT* WINAPI D3DXSHMultiply4( FLOAT *pOut, CONST FLOAT *pF, CONST FLOAT *pG); FLOAT* WINAPI D3DXSHMultiply5( FLOAT *pOut, CONST FLOAT *pF, CONST FLOAT *pG); FLOAT* WINAPI D3DXSHMultiply6( FLOAT *pOut, CONST FLOAT *pF, CONST FLOAT *pG); - -//============================================================================ -// -// Basic Spherical Harmonic lighting routines -// -//============================================================================ +/* + * + * Basic Spherical Harmonic lighting routines + */ HRESULT WINAPI D3DXSHEvalDirectionalLight ( UINT Order, CONST D3DXVECTOR3 *pDir, @@ -1466,31 +1450,29 @@ HRESULT WINAPI D3DXSHEvalHemisphereLight ( UINT Order, CONST D3DXVECTOR3 *pDir, D3DXCOLOR Top, D3DXCOLOR Bottom, FLOAT *pROut, FLOAT *pGOut, FLOAT *pBOut ); -//============================================================================ -// -// Basic Spherical Harmonic projection routines -// -//============================================================================ +/* + * + * Basic Spherical Harmonic projection routines + */ -//============================================================================ -// -// D3DXSHProjectCubeMap: -// -------------------- -// Projects a function represented on a cube map into spherical harmonics. -// -// Parameters: -// Order -// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 -// pCubeMap -// CubeMap that is going to be projected into spherical harmonics -// pROut -// Output SH vector for Red. -// pGOut -// Output SH vector for Green -// pBOut -// Output SH vector for Blue -// -//============================================================================ +/* + * + * D3DXSHProjectCubeMap: + * -------------------- + * Projects a function represented on a cube map into spherical harmonics. + * + * Parameters: + * Order + * Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 + * pCubeMap + * CubeMap that is going to be projected into spherical harmonics + * pROut + * Output SH vector for Red. + * pGOut + * Output SH vector for Green + * pBOut + * Output SH vector for Blue + */ HRESULT WINAPI D3DXSHProjectCubeMap ( UINT uOrder, LPDIRECT3DCUBETEXTURE9 pCubeMap, diff --git a/gfx/include/d3d9/d3dx9math.inl b/gfx/include/d3d9/d3dx9math.inl index 1d747453da..08a408fc7c 100644 --- a/gfx/include/d3d9/d3dx9math.inl +++ b/gfx/include/d3d9/d3dx9math.inl @@ -1,26 +1,24 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx9math.inl -// Content: D3DX math inline functions -// -////////////////////////////////////////////////////////////////////////////// +/* + * + * Copyright (C) Microsoft Corporation. All Rights Reserved. + * + * File: d3dx9math.inl + * Content: D3DX math inline functions + */ #ifndef __D3DX9MATH_INL__ #define __D3DX9MATH_INL__ -//=========================================================================== -// -// Inline Class Methods -// -//=========================================================================== +/* + * + * Inline Class Methods + */ #ifdef __cplusplus -//-------------------------- -// Float16 -//-------------------------- +/* + * Float16 + */ D3DXINLINE D3DXFLOAT16::D3DXFLOAT16( FLOAT f ) @@ -34,7 +32,7 @@ D3DXFLOAT16::D3DXFLOAT16( CONST D3DXFLOAT16& f ) value = f.value; } -// casting +/* casting */ D3DXINLINE D3DXFLOAT16::operator FLOAT () { @@ -43,7 +41,7 @@ D3DXFLOAT16::operator FLOAT () return f; } -// binary operators +/* binary operators */ D3DXINLINE BOOL D3DXFLOAT16::operator == ( CONST D3DXFLOAT16& f ) const { @@ -57,9 +55,9 @@ D3DXFLOAT16::operator != ( CONST D3DXFLOAT16& f ) const } -//-------------------------- -// 2D Vector -//-------------------------- +/* + * 2D Vector + */ D3DXINLINE D3DXVECTOR2::D3DXVECTOR2( CONST FLOAT *pf ) @@ -81,8 +79,7 @@ D3DXVECTOR2::D3DXVECTOR2( FLOAT fx, FLOAT fy ) y = fy; } - -// casting +/* casting */ D3DXINLINE D3DXVECTOR2::operator FLOAT* () { @@ -95,8 +92,7 @@ D3DXVECTOR2::operator CONST FLOAT* () const return (CONST FLOAT *) &x; } - -// assignment operators +/* assignment operators */ D3DXINLINE D3DXVECTOR2& D3DXVECTOR2::operator += ( CONST D3DXVECTOR2& v ) { @@ -130,8 +126,7 @@ D3DXVECTOR2::operator /= ( FLOAT f ) return *this; } - -// unary operators +/* unary operators */ D3DXINLINE D3DXVECTOR2 D3DXVECTOR2::operator + () const { @@ -144,8 +139,7 @@ D3DXVECTOR2::operator - () const return D3DXVECTOR2(-x, -y); } - -// binary operators +/* binary operators */ D3DXINLINE D3DXVECTOR2 D3DXVECTOR2::operator + ( CONST D3DXVECTOR2& v ) const { @@ -189,11 +183,9 @@ D3DXVECTOR2::operator != ( CONST D3DXVECTOR2& v ) const return x != v.x || y != v.y; } - - -//-------------------------- -// 2D Vector (16 bit) -//-------------------------- +/* + * 2D Vector (16 bit) + */ D3DXINLINE D3DXVECTOR2_16F::D3DXVECTOR2_16F( CONST FLOAT *pf ) @@ -214,8 +206,7 @@ D3DXVECTOR2_16F::D3DXVECTOR2_16F( CONST D3DXFLOAT16 &fx, CONST D3DXFLOAT16 &fy ) y = fy; } - -// casting +/* casting */ D3DXINLINE D3DXVECTOR2_16F::operator D3DXFLOAT16* () { @@ -228,8 +219,7 @@ D3DXVECTOR2_16F::operator CONST D3DXFLOAT16* () const return (CONST D3DXFLOAT16*) &x; } - -// binary operators +/* binary operators */ D3DXINLINE BOOL D3DXVECTOR2_16F::operator == ( CONST D3DXVECTOR2_16F &v ) const { @@ -243,9 +233,9 @@ D3DXVECTOR2_16F::operator != ( CONST D3DXVECTOR2_16F &v ) const } -//-------------------------- -// 3D Vector -//-------------------------- +/* + * 3D Vector + */ D3DXINLINE D3DXVECTOR3::D3DXVECTOR3( CONST FLOAT *pf ) { @@ -276,8 +266,7 @@ D3DXVECTOR3::D3DXVECTOR3( FLOAT fx, FLOAT fy, FLOAT fz ) z = fz; } - -// casting +/* casting */ D3DXINLINE D3DXVECTOR3::operator FLOAT* () { @@ -290,8 +279,7 @@ D3DXVECTOR3::operator CONST FLOAT* () const return (CONST FLOAT *) &x; } - -// assignment operators +/* assignment operators */ D3DXINLINE D3DXVECTOR3& D3DXVECTOR3::operator += ( CONST D3DXVECTOR3& v ) { @@ -329,8 +317,7 @@ D3DXVECTOR3::operator /= ( FLOAT f ) return *this; } - -// unary operators +/* unary operators */ D3DXINLINE D3DXVECTOR3 D3DXVECTOR3::operator + () const { @@ -343,8 +330,7 @@ D3DXVECTOR3::operator - () const return D3DXVECTOR3(-x, -y, -z); } - -// binary operators +/* binary operators */ D3DXINLINE D3DXVECTOR3 D3DXVECTOR3::operator + ( CONST D3DXVECTOR3& v ) const { @@ -390,11 +376,9 @@ D3DXVECTOR3::operator != ( CONST D3DXVECTOR3& v ) const return x != v.x || y != v.y || z != v.z; } - - -//-------------------------- -// 3D Vector (16 bit) -//-------------------------- +/* + * 3D Vector (16 bit) + */ D3DXINLINE D3DXVECTOR3_16F::D3DXVECTOR3_16F( CONST FLOAT *pf ) @@ -425,8 +409,7 @@ D3DXVECTOR3_16F::D3DXVECTOR3_16F( CONST D3DXFLOAT16 &fx, CONST D3DXFLOAT16 &fy, z = fz; } - -// casting +/* casting */ D3DXINLINE D3DXVECTOR3_16F::operator D3DXFLOAT16* () { @@ -439,8 +422,7 @@ D3DXVECTOR3_16F::operator CONST D3DXFLOAT16* () const return (CONST D3DXFLOAT16*) &x; } - -// binary operators +/* binary operators */ D3DXINLINE BOOL D3DXVECTOR3_16F::operator == ( CONST D3DXVECTOR3_16F &v ) const { @@ -456,9 +438,9 @@ D3DXVECTOR3_16F::operator != ( CONST D3DXVECTOR3_16F &v ) const } -//-------------------------- -// 4D Vector -//-------------------------- +/* + * 4D Vector + */ D3DXINLINE D3DXVECTOR4::D3DXVECTOR4( CONST FLOAT *pf ) { @@ -492,8 +474,7 @@ D3DXVECTOR4::D3DXVECTOR4( FLOAT fx, FLOAT fy, FLOAT fz, FLOAT fw ) w = fw; } - -// casting +/* casting */ D3DXINLINE D3DXVECTOR4::operator FLOAT* () { @@ -506,8 +487,7 @@ D3DXVECTOR4::operator CONST FLOAT* () const return (CONST FLOAT *) &x; } - -// assignment operators +/* assignment operators */ D3DXINLINE D3DXVECTOR4& D3DXVECTOR4::operator += ( CONST D3DXVECTOR4& v ) { @@ -549,8 +529,7 @@ D3DXVECTOR4::operator /= ( FLOAT f ) return *this; } - -// unary operators +/* unary operators */ D3DXINLINE D3DXVECTOR4 D3DXVECTOR4::operator + () const { @@ -563,8 +542,7 @@ D3DXVECTOR4::operator - () const return D3DXVECTOR4(-x, -y, -z, -w); } - -// binary operators +/* binary operators */ D3DXINLINE D3DXVECTOR4 D3DXVECTOR4::operator + ( CONST D3DXVECTOR4& v ) const { @@ -609,11 +587,9 @@ D3DXVECTOR4::operator != ( CONST D3DXVECTOR4& v ) const return x != v.x || y != v.y || z != v.z || w != v.w; } - - -//-------------------------- -// 4D Vector (16 bit) -//-------------------------- +/* + * 4D Vector (16 bit) + */ D3DXINLINE D3DXVECTOR4_16F::D3DXVECTOR4_16F( CONST FLOAT *pf ) @@ -646,8 +622,7 @@ D3DXVECTOR4_16F::D3DXVECTOR4_16F( CONST D3DXFLOAT16 &fx, CONST D3DXFLOAT16 &fy, w = fw; } - -// casting +/* casting */ D3DXINLINE D3DXVECTOR4_16F::operator D3DXFLOAT16* () { @@ -660,8 +635,7 @@ D3DXVECTOR4_16F::operator CONST D3DXFLOAT16* () const return (CONST D3DXFLOAT16*) &x; } - -// binary operators +/* binary operators */ D3DXINLINE BOOL D3DXVECTOR4_16F::operator == ( CONST D3DXVECTOR4_16F &v ) const { @@ -677,9 +651,9 @@ D3DXVECTOR4_16F::operator != ( CONST D3DXVECTOR4_16F &v ) const } -//-------------------------- -// Matrix -//-------------------------- +/* + * Matrix + */ D3DXINLINE D3DXMATRIX::D3DXMATRIX( CONST FLOAT* pf ) { @@ -710,9 +684,7 @@ D3DXMATRIX::D3DXMATRIX( FLOAT f11, FLOAT f12, FLOAT f13, FLOAT f14, _41 = f41; _42 = f42; _43 = f43; _44 = f44; } - - -// access grants +/* access grants */ D3DXINLINE FLOAT& D3DXMATRIX::operator () ( UINT iRow, UINT iCol ) { @@ -725,8 +697,7 @@ D3DXMATRIX::operator () ( UINT iRow, UINT iCol ) const return m[iRow][iCol]; } - -// casting operators +/* casting operators */ D3DXINLINE D3DXMATRIX::operator FLOAT* () { @@ -739,8 +710,7 @@ D3DXMATRIX::operator CONST FLOAT* () const return (CONST FLOAT *) &_11; } - -// assignment operators +/* assignment operators */ D3DXINLINE D3DXMATRIX& D3DXMATRIX::operator *= ( CONST D3DXMATRIX& mat ) { @@ -789,8 +759,7 @@ D3DXMATRIX::operator /= ( FLOAT f ) return *this; } - -// unary operators +/* unary operators */ D3DXINLINE D3DXMATRIX D3DXMATRIX::operator + () const { @@ -806,8 +775,7 @@ D3DXMATRIX::operator - () const -_41, -_42, -_43, -_44); } - -// binary operators +/* binary operators */ D3DXINLINE D3DXMATRIX D3DXMATRIX::operator * ( CONST D3DXMATRIX& mat ) const { @@ -876,11 +844,9 @@ D3DXMATRIX::operator != ( CONST D3DXMATRIX& mat ) const return 0 != memcmp(this, &mat, sizeof(D3DXMATRIX)); } - - -//-------------------------- -// Aligned Matrices -//-------------------------- +/* + * Aligned Matrices + */ D3DXINLINE _D3DXMATRIXA16::_D3DXMATRIXA16( CONST FLOAT* f ) : @@ -975,10 +941,9 @@ _D3DXMATRIXA16::operator=(CONST D3DXMATRIX& rhs) return *this; } - -//-------------------------- -// Quaternion -//-------------------------- +/* + * Quaternion + */ D3DXINLINE D3DXQUATERNION::D3DXQUATERNION( CONST FLOAT* pf ) @@ -1004,8 +969,7 @@ D3DXQUATERNION::D3DXQUATERNION( FLOAT fx, FLOAT fy, FLOAT fz, FLOAT fw ) w = fw; } - -// casting +/* casting */ D3DXINLINE D3DXQUATERNION::operator FLOAT* () { @@ -1018,8 +982,7 @@ D3DXQUATERNION::operator CONST FLOAT* () const return (CONST FLOAT *) &x; } - -// assignment operators +/* assignment operators */ D3DXINLINE D3DXQUATERNION& D3DXQUATERNION::operator += ( CONST D3DXQUATERNION& q ) { @@ -1068,8 +1031,7 @@ D3DXQUATERNION::operator /= ( FLOAT f ) return *this; } - -// unary operators +/* unary operators */ D3DXINLINE D3DXQUATERNION D3DXQUATERNION::operator + () const { @@ -1082,8 +1044,7 @@ D3DXQUATERNION::operator - () const return D3DXQUATERNION(-x, -y, -z, -w); } - -// binary operators +/* binary operators */ D3DXINLINE D3DXQUATERNION D3DXQUATERNION::operator + ( CONST D3DXQUATERNION& q ) const { @@ -1137,11 +1098,9 @@ D3DXQUATERNION::operator != ( CONST D3DXQUATERNION& q ) const return x != q.x || y != q.y || z != q.z || w != q.w; } - - -//-------------------------- -// Plane -//-------------------------- +/* + * Plane + */ D3DXINLINE D3DXPLANE::D3DXPLANE( CONST FLOAT* pf ) @@ -1167,8 +1126,7 @@ D3DXPLANE::D3DXPLANE( FLOAT fa, FLOAT fb, FLOAT fc, FLOAT fd ) d = fd; } - -// casting +/* casting */ D3DXINLINE D3DXPLANE::operator FLOAT* () { @@ -1181,8 +1139,7 @@ D3DXPLANE::operator CONST FLOAT* () const return (CONST FLOAT *) &a; } - -// assignment operators +/* assignment operators */ D3DXINLINE D3DXPLANE& D3DXPLANE::operator *= ( FLOAT f ) { @@ -1204,8 +1161,7 @@ D3DXPLANE::operator /= ( FLOAT f ) return *this; } - -// unary operators +/* unary operators */ D3DXINLINE D3DXPLANE D3DXPLANE::operator + () const { @@ -1218,8 +1174,7 @@ D3DXPLANE::operator - () const return D3DXPLANE(-a, -b, -c, -d); } - -// binary operators +/* binary operators */ D3DXINLINE D3DXPLANE D3DXPLANE::operator * ( FLOAT f ) const { @@ -1251,12 +1206,9 @@ D3DXPLANE::operator != ( CONST D3DXPLANE& p ) const return a != p.a || b != p.b || c != p.c || d != p.d; } - - - -//-------------------------- -// Color -//-------------------------- +/* + * Color + */ D3DXINLINE D3DXCOLOR::D3DXCOLOR( DWORD dw ) @@ -1301,8 +1253,7 @@ D3DXCOLOR::D3DXCOLOR( FLOAT fr, FLOAT fg, FLOAT fb, FLOAT fa ) a = fa; } - -// casting +/* casting */ D3DXINLINE D3DXCOLOR::operator DWORD () const { @@ -1353,8 +1304,7 @@ D3DXCOLOR::operator CONST D3DCOLORVALUE& () const return *((CONST D3DCOLORVALUE *) &r); } - -// assignment operators +/* assignment operators */ D3DXINLINE D3DXCOLOR& D3DXCOLOR::operator += ( CONST D3DXCOLOR& c ) { @@ -1396,8 +1346,7 @@ D3DXCOLOR::operator /= ( FLOAT f ) return *this; } - -// unary operators +/* unary operators */ D3DXINLINE D3DXCOLOR D3DXCOLOR::operator + () const { @@ -1410,8 +1359,7 @@ D3DXCOLOR::operator - () const return D3DXCOLOR(-r, -g, -b, -a); } - -// binary operators +/* binary operators */ D3DXINLINE D3DXCOLOR D3DXCOLOR::operator + ( CONST D3DXCOLOR& c ) const { @@ -1458,20 +1406,17 @@ D3DXCOLOR::operator != ( CONST D3DXCOLOR& c ) const } -#endif //__cplusplus +#endif /*__cplusplus */ + +/* + * + * Inline functions + */ - -//=========================================================================== -// -// Inline functions -// -//=========================================================================== - - -//-------------------------- -// 2D Vector -//-------------------------- +/* + * 2D Vector + */ D3DXINLINE FLOAT D3DXVec2Length ( CONST D3DXVECTOR2 *pV ) @@ -1550,10 +1495,9 @@ D3DXINLINE D3DXVECTOR2* D3DXVec2Lerp return pOut; } - -//-------------------------- -// 3D Vector -//-------------------------- +/* + * 3D Vector + */ D3DXINLINE FLOAT D3DXVec3Length ( CONST D3DXVECTOR3 *pV ) @@ -1646,9 +1590,9 @@ D3DXINLINE D3DXVECTOR3* D3DXVec3Lerp } -//-------------------------- -// 4D Vector -//-------------------------- +/* + * 4D Vector + */ D3DXINLINE FLOAT D3DXVec4Length ( CONST D3DXVECTOR4 *pV ) @@ -1734,9 +1678,9 @@ D3DXINLINE D3DXVECTOR4* D3DXVec4Lerp } -//-------------------------- -// 4D Matrix -//-------------------------- +/* + * 4D Matrix + */ D3DXINLINE D3DXMATRIX* D3DXMatrixIdentity ( D3DXMATRIX *pOut ) @@ -1761,9 +1705,9 @@ D3DXINLINE BOOL D3DXMatrixIsIdentity } -//-------------------------- -// Quaternion -//-------------------------- +/* + * Quaternion + */ D3DXINLINE FLOAT D3DXQuaternionLength ( CONST D3DXQUATERNION *pQ ) @@ -1813,10 +1757,9 @@ D3DXINLINE D3DXQUATERNION* D3DXQuaternionConjugate return pOut; } - -//-------------------------- -// Plane -//-------------------------- +/* + * Plane + */ D3DXINLINE FLOAT D3DXPlaneDot ( CONST D3DXPLANE *pP, CONST D3DXVECTOR4 *pV) @@ -1847,9 +1790,9 @@ D3DXINLINE D3DXPLANE* D3DXPlaneScale } -//-------------------------- -// Color -//-------------------------- +/* + * Color + */ D3DXINLINE D3DXCOLOR* D3DXColorNegative (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC) @@ -1912,4 +1855,4 @@ D3DXINLINE D3DXCOLOR* D3DXColorLerp } -#endif // __D3DX9MATH_INL__ +#endif /* __D3DX9MATH_INL__ */ diff --git a/gfx/include/d3d9/d3dx9xof.h b/gfx/include/d3d9/d3dx9xof.h index b581e0c858..1e0a249e37 100644 --- a/gfx/include/d3d9/d3dx9xof.h +++ b/gfx/include/d3d9/d3dx9xof.h @@ -34,59 +34,59 @@ typedef DWORD D3DXF_FILELOADOPTIONS; #define D3DXF_FILELOAD_FROMRESOURCE 0x02L #define D3DXF_FILELOAD_FROMMEMORY 0x03L -//---------------------------------------------------------------------------- -// D3DXF_FILELOADRESOURCE: -//---------------------------------------------------------------------------- +/* + * D3DXF_FILELOADRESOURCE: +*/ typedef struct _D3DXF_FILELOADRESOURCE { - HMODULE hModule; // Desc - LPCSTR lpName; // Desc - LPCSTR lpType; // Desc + HMODULE hModule; /* Desc */ + LPCSTR lpName; /* Desc */ + LPCSTR lpType; /* Desc */ } D3DXF_FILELOADRESOURCE; -//---------------------------------------------------------------------------- -// D3DXF_FILELOADMEMORY: -//---------------------------------------------------------------------------- +/* + * D3DXF_FILELOADMEMORY: + */ typedef struct _D3DXF_FILELOADMEMORY { - LPCVOID lpMemory; // Desc - SIZE_T dSize; // Desc + LPCVOID lpMemory; /* Desc */ + SIZE_T dSize; /* Desc */ } D3DXF_FILELOADMEMORY; #if defined( _WIN32 ) && !defined( _NO_COM ) -// {cef08cf9-7b4f-4429-9624-2a690a933201} +/* {cef08cf9-7b4f-4429-9624-2a690a933201} */ DEFINE_GUID( IID_ID3DXFile, 0xcef08cf9, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); -// {cef08cfa-7b4f-4429-9624-2a690a933201} +/* {cef08cfa-7b4f-4429-9624-2a690a933201} */ DEFINE_GUID( IID_ID3DXFileSaveObject, 0xcef08cfa, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); -// {cef08cfb-7b4f-4429-9624-2a690a933201} +/* {cef08cfb-7b4f-4429-9624-2a690a933201} */ DEFINE_GUID( IID_ID3DXFileSaveData, 0xcef08cfb, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); -// {cef08cfc-7b4f-4429-9624-2a690a933201} +/* {cef08cfc-7b4f-4429-9624-2a690a933201} */ DEFINE_GUID( IID_ID3DXFileEnumObject, 0xcef08cfc, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); -// {cef08cfd-7b4f-4429-9624-2a690a933201} +/* {cef08cfd-7b4f-4429-9624-2a690a933201} */ DEFINE_GUID( IID_ID3DXFileData, 0xcef08cfd, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); -#endif // defined( _WIN32 ) && !defined( _NO_COM ) +#endif /* defined( _WIN32 ) && !defined( _NO_COM ) */ #if defined( __cplusplus ) #if !defined( DECLSPEC_UUID ) #if _MSC_VER >= 1100 #define DECLSPEC_UUID( x ) __declspec( uuid( x ) ) -#else // !( _MSC_VER >= 1100 ) +#else /* !( _MSC_VER >= 1100 ) */ #define DECLSPEC_UUID( x ) -#endif // !( _MSC_VER >= 1100 ) -#endif // !defined( DECLSPEC_UUID ) +#endif /* !( _MSC_VER >= 1100 ) */ +#endif /* !defined( DECLSPEC_UUID ) */ interface DECLSPEC_UUID( "cef08cf9-7b4f-4429-9624-2a690a933201" ) ID3DXFile; @@ -110,8 +110,8 @@ _COM_SMARTPTR_TYPEDEF( ID3DXFileEnumObject, __uuidof( ID3DXFileEnumObject ) ); _COM_SMARTPTR_TYPEDEF( ID3DXFileData, __uuidof( ID3DXFileData ) ); -#endif // defined( _COM_SMARTPTR_TYPEDEF ) -#endif // defined( __cplusplus ) +#endif /* defined( _COM_SMARTPTR_TYPEDEF ) */ +#endif /* defined( __cplusplus ) */ typedef interface ID3DXFile ID3DXFile; typedef interface ID3DXFileSaveObject ID3DXFileSaveObject; @@ -119,9 +119,9 @@ typedef interface ID3DXFileSaveData ID3DXFileSaveData; typedef interface ID3DXFileEnumObject ID3DXFileEnumObject; typedef interface ID3DXFileData ID3DXFileData; -////////////////////////////////////////////////////////////////////////////// -// ID3DXFile ///////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// +/* + * ID3DXFile + */ #undef INTERFACE #define INTERFACE ID3DXFile @@ -140,9 +140,9 @@ DECLARE_INTERFACE_( ID3DXFile, IUnknown ) STDMETHOD( RegisterEnumTemplates )( THIS_ ID3DXFileEnumObject* ) PURE; }; -////////////////////////////////////////////////////////////////////////////// -// ID3DXFileSaveObject /////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// +/* + * ID3DXFileSaveObject + */ #undef INTERFACE #define INTERFACE ID3DXFileSaveObject @@ -159,9 +159,9 @@ DECLARE_INTERFACE_( ID3DXFileSaveObject, IUnknown ) STDMETHOD( Save )( THIS ) PURE; }; -////////////////////////////////////////////////////////////////////////////// -// ID3DXFileSaveData ///////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// +/* + * ID3DXFileSaveData + */ #undef INTERFACE #define INTERFACE ID3DXFileSaveData @@ -181,9 +181,9 @@ DECLARE_INTERFACE_( ID3DXFileSaveData, IUnknown ) STDMETHOD( AddDataReference )( THIS_ LPCSTR, CONST GUID* ) PURE; }; -////////////////////////////////////////////////////////////////////////////// -// ID3DXFileEnumObject /////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// +/* + * ID3DXFileEnumObject + */ #undef INTERFACE #define INTERFACE ID3DXFileEnumObject @@ -201,9 +201,9 @@ DECLARE_INTERFACE_( ID3DXFileEnumObject, IUnknown ) STDMETHOD( GetDataObjectByName )( THIS_ LPCSTR, ID3DXFileData** ) PURE; }; -////////////////////////////////////////////////////////////////////////////// -// ID3DXFileData ///////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// +/* + * ID3DXFileData + */ #undef INTERFACE #define INTERFACE ID3DXFileData diff --git a/menu/drivers_display/menu_display_d3d11.c b/menu/drivers_display/menu_display_d3d11.c index 15318c4ee9..2dfb3aca2e 100644 --- a/menu/drivers_display/menu_display_d3d11.c +++ b/menu/drivers_display/menu_display_d3d11.c @@ -26,11 +26,20 @@ #include "../../gfx/video_driver.h" #include "../../gfx/common/d3d11_common.h" -static const float* menu_display_d3d11_get_default_vertices(void) { return NULL; } +static const float* menu_display_d3d11_get_default_vertices(void) +{ + return NULL; +} -static const float* menu_display_d3d11_get_default_tex_coords(void) { return NULL; } +static const float* menu_display_d3d11_get_default_tex_coords(void) +{ + return NULL; +} -static void* menu_display_d3d11_get_default_mvp(void) { return NULL; } +static void* menu_display_d3d11_get_default_mvp(void) +{ + return NULL; +} static void menu_display_d3d11_blend_begin(void) { @@ -44,7 +53,9 @@ static void menu_display_d3d11_blend_end(void) D3D11SetBlendState(d3d11->ctx, d3d11->blend_disable, NULL, D3D11_DEFAULT_SAMPLE_MASK); } -static void menu_display_d3d11_viewport(void* data) {} +static void menu_display_d3d11_viewport(void* data) +{ +} static void menu_display_d3d11_draw(void* data) { @@ -80,14 +91,17 @@ static void menu_display_d3d11_draw(void* data) { D3D11_MAPPED_SUBRESOURCE mapped_vbo; + d3d11_sprite_t *v = NULL; + D3D11MapBuffer( d3d11->ctx, d3d11->sprites.vbo, 0, D3D11_MAP_WRITE_NO_OVERWRITE, 0, &mapped_vbo); - d3d11_sprite_t* v = (d3d11_sprite_t*)mapped_vbo.pData + d3d11->sprites.offset; - v->pos.x = draw->x / (float)d3d11->viewport.Width; - v->pos.y = (d3d11->viewport.Height - draw->y - draw->height) / (float)d3d11->viewport.Height; - v->pos.w = draw->width / (float)d3d11->viewport.Width; - v->pos.h = draw->height / (float)d3d11->viewport.Height; + v = (d3d11_sprite_t*)mapped_vbo.pData + d3d11->sprites.offset; + + v->pos.x = draw->x / (float)d3d11->viewport.Width; + v->pos.y = (d3d11->viewport.Height - draw->y - draw->height) / (float)d3d11->viewport.Height; + v->pos.w = draw->width / (float)d3d11->viewport.Width; + v->pos.h = draw->height / (float)d3d11->viewport.Height; v->coords.u = 0.0f; v->coords.v = 0.0f; @@ -117,19 +131,18 @@ static void menu_display_d3d11_draw(void* data) D3D11UnmapBuffer(d3d11->ctx, d3d11->sprites.vbo, 0); } - d3d11_set_texture_and_sampler(d3d11->ctx, 0, (d3d11_texture_t*)draw->texture); + d3d11_set_texture_and_sampler(d3d11->ctx, 0, + (d3d11_texture_t*)draw->texture); D3D11Draw(d3d11->ctx, 1, d3d11->sprites.offset); d3d11->sprites.offset++; - return; } static void menu_display_d3d11_draw_pipeline(void* data) { + video_coord_array_t *ca = NULL; menu_display_ctx_draw_t* draw = (menu_display_ctx_draw_t*)data; d3d11_video_t* d3d11 = (d3d11_video_t*)video_driver_get_ptr(false); - video_coord_array_t* ca = NULL; - if (!d3d11 || !draw) return; @@ -137,7 +150,6 @@ static void menu_display_d3d11_draw_pipeline(void* data) { case VIDEO_SHADER_MENU: case VIDEO_SHADER_MENU_2: - { ca = menu_display_get_coords_array(); if (!d3d11->menu_pipeline_vbo) @@ -154,7 +166,6 @@ static void menu_display_d3d11_draw_pipeline(void* data) draw->coords->vertices = ca->coords.vertices; D3D11SetBlendState(d3d11->ctx, d3d11->blend_pipeline, NULL, D3D11_DEFAULT_SAMPLE_MASK); break; - } case VIDEO_SHADER_MENU_3: case VIDEO_SHADER_MENU_4: @@ -178,7 +189,9 @@ static void menu_display_d3d11_draw_pipeline(void* data) } } -static void menu_display_d3d11_restore_clear_color(void) {} +static void menu_display_d3d11_restore_clear_color(void) +{ +} static void menu_display_d3d11_clear_color(menu_display_ctx_clearcolor_t* clearcolor) { From 0b4ccf25e7a4f0284e68402d0fc7a27d7ae1c8b4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 3 Feb 2018 14:48:34 +0100 Subject: [PATCH 033/232] Revert "* d3d11.c - minor cleanups for C89" This reverts commit fa458b2f5ce7e5216854719c287de7bbde9cdc77. --- gfx/drivers/d3d11.c | 397 ++++++--------- gfx/include/Cg/cgD3D9.h | 16 +- gfx/include/d3d9/d3dx9math.h | 576 +++++++++++----------- gfx/include/d3d9/d3dx9math.inl | 281 ++++++----- gfx/include/d3d9/d3dx9xof.h | 74 +-- menu/drivers_display/menu_display_d3d11.c | 45 +- 6 files changed, 688 insertions(+), 701 deletions(-) diff --git a/gfx/drivers/d3d11.c b/gfx/drivers/d3d11.c index a63251f304..e4375a05ef 100644 --- a/gfx/drivers/d3d11.c +++ b/gfx/drivers/d3d11.c @@ -37,10 +37,9 @@ static void d3d11_set_filtering(void* data, unsigned index, bool smooth) { - unsigned i; d3d11_video_t* d3d11 = (d3d11_video_t*)data; - for (i = 0; i < RARCH_WRAP_MAX; i++) + for (int i = 0; i < RARCH_WRAP_MAX; i++) { if (smooth) d3d11->samplers[RARCH_FILTER_UNSPEC][i] = d3d11->samplers[RARCH_FILTER_LINEAR][i]; @@ -94,14 +93,11 @@ static void d3d11_update_viewport(void* data, bool force_full) static void d3d11_free_shader_preset(d3d11_video_t* d3d11) { - unsigned i; if (!d3d11->shader_preset) return; - for (i = 0; i < d3d11->shader_preset->passes; i++) + for (int i = 0; i < d3d11->shader_preset->passes; i++) { - unsigned j; - free(d3d11->shader_preset->pass[i].source.string.vertex); free(d3d11->shader_preset->pass[i].source.string.fragment); free(d3d11->pass[i].semantics.textures); @@ -109,7 +105,7 @@ static void d3d11_free_shader_preset(d3d11_video_t* d3d11) d3d11_release_texture(&d3d11->pass[i].rt); d3d11_release_texture(&d3d11->pass[i].feedback); - for (j = 0; j < SLANG_CBUFFER_MAX; j++) + for (int j = 0; j < SLANG_CBUFFER_MAX; j++) { free(d3d11->pass[i].semantics.cbuffers[j].uniforms); Release(d3d11->pass[i].buffers[j]); @@ -118,7 +114,7 @@ static void d3d11_free_shader_preset(d3d11_video_t* d3d11) memset(d3d11->pass, 0, sizeof(d3d11->pass)); - for (i = 0; i < d3d11->shader_preset->luts; i++) + for (int i = 0; i < d3d11->shader_preset->luts; i++) d3d11_release_texture(&d3d11->luts[i]); memset(d3d11->luts, 0, sizeof(d3d11->luts)); @@ -129,10 +125,7 @@ static void d3d11_free_shader_preset(d3d11_video_t* d3d11) static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const char* path) { - unsigned i, j; - config_file_t *conf = NULL; - d3d11_texture_t *source = NULL; - d3d11_video_t *d3d11 = (d3d11_video_t*)data; + d3d11_video_t* d3d11 = (d3d11_video_t*)data; if (!d3d11) return false; @@ -151,7 +144,7 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const return false; } - conf = config_file_new(path); + config_file_t* conf = config_file_new(path); if (!conf) return false; @@ -163,74 +156,75 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const video_shader_resolve_relative(d3d11->shader_preset, path); - source = &d3d11->frame.texture; - - for (i = 0; i < d3d11->shader_preset->passes; i++) + d3d11_texture_t* source = &d3d11->frame.texture; + for (int i = 0; i < d3d11->shader_preset->passes; i++) { - /* no history support yet */ - texture_map_t texture_map[3 + GFX_MAX_SHADERS * 2 + GFX_MAX_TEXTURES + 1] = { - SL_TEXTURE_MAP( - SLANG_TEXTURE_SEMANTIC_ORIGINAL, d3d11->frame.texture.view, - d3d11->pass[i].sampler, d3d11->frame.texture.size_data), - SL_TEXTURE_MAP( - SLANG_TEXTURE_SEMANTIC_SOURCE, source->view, d3d11->pass[i].sampler, - source->size_data), - SL_TEXTURE_MAP( - SLANG_TEXTURE_SEMANTIC_ORIGINAL_HISTORY, d3d11->frame.texture.view, - d3d11->pass[i].sampler, d3d11->frame.texture.size_data), - }; - { - texture_map_t* ptr = texture_map; - while (ptr->texture_data) - ptr++; + /* no history support yet */ + texture_map_t texture_map[3 + GFX_MAX_SHADERS * 2 + GFX_MAX_TEXTURES + 1] = { + SL_TEXTURE_MAP( + SLANG_TEXTURE_SEMANTIC_ORIGINAL, d3d11->frame.texture.view, + d3d11->pass[i].sampler, d3d11->frame.texture.size_data), + SL_TEXTURE_MAP( + SLANG_TEXTURE_SEMANTIC_SOURCE, source->view, d3d11->pass[i].sampler, + source->size_data), + SL_TEXTURE_MAP( + SLANG_TEXTURE_SEMANTIC_ORIGINAL_HISTORY, d3d11->frame.texture.view, + d3d11->pass[i].sampler, d3d11->frame.texture.size_data), + }; - for (j = 0; j < i; j++) { - *ptr = (texture_map_t)SL_TEXTURE_MAP_ARRAY( - SLANG_TEXTURE_SEMANTIC_PASS_OUTPUT, j, d3d11->pass[j].rt.view, - d3d11->pass[i].sampler, d3d11->pass[j].rt.size_data); - ptr++; + texture_map_t* ptr = texture_map; + while (ptr->texture_data) + ptr++; + + for (int j = 0; j < i; j++) + { + *ptr = (texture_map_t)SL_TEXTURE_MAP_ARRAY( + SLANG_TEXTURE_SEMANTIC_PASS_OUTPUT, j, d3d11->pass[j].rt.view, + d3d11->pass[i].sampler, d3d11->pass[j].rt.size_data); + ptr++; + } + + for (int j = 0; j < GFX_MAX_SHADERS; j++) + { + *ptr = (texture_map_t)SL_TEXTURE_MAP_ARRAY( + SLANG_TEXTURE_SEMANTIC_PASS_FEEDBACK, j, d3d11->pass[j].feedback.view, + d3d11->pass[i].sampler, d3d11->pass[j].rt.size_data); + ptr++; + } + + for (int j = 0; j < d3d11->shader_preset->luts; j++) + { + *ptr = (texture_map_t)SL_TEXTURE_MAP_ARRAY( + SLANG_TEXTURE_SEMANTIC_USER, j, d3d11->luts[j].view, d3d11->luts[j].sampler, + d3d11->luts[j].size_data); + ptr++; + } } - for (j = 0; j < GFX_MAX_SHADERS; j++) - { - *ptr = (texture_map_t)SL_TEXTURE_MAP_ARRAY( - SLANG_TEXTURE_SEMANTIC_PASS_FEEDBACK, j, d3d11->pass[j].feedback.view, - d3d11->pass[i].sampler, d3d11->pass[j].rt.size_data); - ptr++; - } + uniform_map_t uniform_map[] = { + SL_UNIFORM_MAP(SLANG_SEMANTIC_MVP, d3d11->mvp), + SL_UNIFORM_MAP(SLANG_SEMANTIC_OUTPUT, d3d11->pass[i].rt.size_data), + SL_UNIFORM_MAP(SLANG_SEMANTIC_FRAME_COUNT, d3d11->pass[i].frame_count), + SL_UNIFORM_MAP(SLANG_SEMANTIC_FINAL_VIEWPORT, d3d11->frame.output_size), + { 0 } + }; - for (j = 0; j < d3d11->shader_preset->luts; j++) - { - *ptr = (texture_map_t)SL_TEXTURE_MAP_ARRAY( - SLANG_TEXTURE_SEMANTIC_USER, j, d3d11->luts[j].view, d3d11->luts[j].sampler, - d3d11->luts[j].size_data); - ptr++; - } + semantics_map_t semantics_map = { texture_map, uniform_map }; + + if (!slang_process( + d3d11->shader_preset, i, RARCH_SHADER_HLSL, 50, &semantics_map, + &d3d11->pass[i].semantics)) + goto error; } - uniform_map_t uniform_map[] = { - SL_UNIFORM_MAP(SLANG_SEMANTIC_MVP, d3d11->mvp), - SL_UNIFORM_MAP(SLANG_SEMANTIC_OUTPUT, d3d11->pass[i].rt.size_data), - SL_UNIFORM_MAP(SLANG_SEMANTIC_FRAME_COUNT, d3d11->pass[i].frame_count), - SL_UNIFORM_MAP(SLANG_SEMANTIC_FINAL_VIEWPORT, d3d11->frame.output_size), - { 0 } - }; - - semantics_map_t semantics_map = { texture_map, uniform_map }; - - if (!slang_process( - d3d11->shader_preset, i, RARCH_SHADER_HLSL, 50, &semantics_map, - &d3d11->pass[i].semantics)) - goto error; - { static const D3D11_INPUT_ELEMENT_DESC desc[] = { { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, offsetof(d3d11_vertex_t, position), - D3D11_INPUT_PER_VERTEX_DATA, 0 }, + D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "TEXCOORD", 1, DXGI_FORMAT_R32G32_FLOAT, 0, offsetof(d3d11_vertex_t, texcoord), - D3D11_INPUT_PER_VERTEX_DATA, 0 }, + D3D11_INPUT_PER_VERTEX_DATA, 0 }, }; #ifdef DEBUG bool save_hlsl = true; @@ -255,13 +249,13 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const strncpy(ps_path + base_len, ps_ext, sizeof(ps_ext)); if (!d3d11_init_shader( - d3d11->device, vs_src, 0, vs_path, "main", NULL, NULL, desc, countof(desc), - &d3d11->pass[i].shader)) + d3d11->device, vs_src, 0, vs_path, "main", NULL, NULL, desc, countof(desc), + &d3d11->pass[i].shader)) save_hlsl = true; if (!d3d11_init_shader( - d3d11->device, ps_src, 0, ps_path, NULL, "main", NULL, NULL, 0, - &d3d11->pass[i].shader)) + d3d11->device, ps_src, 0, ps_path, NULL, "main", NULL, NULL, 0, + &d3d11->pass[i].shader)) save_hlsl = true; if (save_hlsl) @@ -285,7 +279,7 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const goto error; } - for (j = 0; j < SLANG_CBUFFER_MAX; j++) + for (int j = 0; j < SLANG_CBUFFER_MAX; j++) { D3D11_BUFFER_DESC desc = { .ByteWidth = d3d11->pass[i].semantics.cbuffers[j].size, @@ -297,14 +291,13 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const if (!desc.ByteWidth) continue; - D3D11CreateBuffer(d3d11->device, &desc, NULL, - &d3d11->pass[i].buffers[j]); + D3D11CreateBuffer(d3d11->device, &desc, NULL, &d3d11->pass[i].buffers[j]); } source = &d3d11->pass[i].rt; } - for (i = 0; i < d3d11->shader_preset->luts; i++) + for (int i = 0; i < d3d11->shader_preset->luts; i++) { struct texture_image image = { 0 }; image.supports_rgba = true; @@ -321,15 +314,13 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const d3d11_init_texture(d3d11->device, &d3d11->luts[i]); d3d11_update_texture( - d3d11->ctx, image.width, image.height, 0, - DXGI_FORMAT_R8G8B8A8_UNORM, image.pixels, + d3d11->ctx, image.width, image.height, 0, DXGI_FORMAT_R8G8B8A8_UNORM, image.pixels, &d3d11->luts[i]); image_texture_free(&image); d3d11->luts[i].sampler = - d3d11->samplers[d3d11->shader_preset->lut[i].filter] - [d3d11->shader_preset->lut[i].wrap]; + d3d11->samplers[d3d11->shader_preset->lut[i].filter][d3d11->shader_preset->lut[i].wrap]; } video_shader_resolve_current_parameters(conf, d3d11->shader_preset); @@ -344,7 +335,6 @@ error: static void d3d11_gfx_free(void* data) { - unsigned i; d3d11_video_t* d3d11 = (d3d11_video_t*)data; if (!d3d11) @@ -379,7 +369,7 @@ static void d3d11_gfx_free(void* data) Release(d3d11->blend_enable); Release(d3d11->blend_disable); - for (i = 0; i < RARCH_WRAP_MAX; i++) + for (int i = 0; i < RARCH_WRAP_MAX; i++) { Release(d3d11->samplers[RARCH_FILTER_LINEAR][i]); Release(d3d11->samplers[RARCH_FILTER_NEAREST][i]); @@ -399,13 +389,12 @@ static void d3d11_gfx_free(void* data) free(d3d11); } -static void *d3d11_gfx_init(const video_info_t* video, - const input_driver_t **input, void **input_data) +static void* +d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** input_data) { - unsigned i; + WNDCLASSEX wndclass = { 0 }; MONITORINFOEX current_mon; HMONITOR hm_to_use; - WNDCLASSEX wndclass = { 0 }; settings_t* settings = config_get_ptr(); d3d11_video_t* d3d11 = (d3d11_video_t*)calloc(1, sizeof(*d3d11)); @@ -463,10 +452,8 @@ static void *d3d11_gfx_init(const video_info_t* video, #endif D3D11CreateDeviceAndSwapChain( - NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, flags, - &requested_feature_level, 1, - D3D11_SDK_VERSION, &desc, - (IDXGISwapChain**)&d3d11->swapChain, &d3d11->device, + NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, flags, &requested_feature_level, 1, + D3D11_SDK_VERSION, &desc, (IDXGISwapChain**)&d3d11->swapChain, &d3d11->device, &d3d11->supportedFeatureLevel, &d3d11->ctx); } @@ -485,8 +472,7 @@ static void *d3d11_gfx_init(const video_info_t* video, d3d11->viewport.Height = d3d11->vp.full_height; d3d11->resize_viewport = true; d3d11->vsync = video->vsync; - d3d11->format = video->rgb32 ? - DXGI_FORMAT_B8G8R8X8_UNORM : DXGI_FORMAT_B5G6R5_UNORM; + d3d11->format = video->rgb32 ? DXGI_FORMAT_B8G8R8X8_UNORM : DXGI_FORMAT_B5G6R5_UNORM; d3d11->frame.texture.desc.Format = d3d11->format; d3d11->frame.texture.desc.Usage = D3D11_USAGE_DEFAULT; @@ -519,9 +505,8 @@ static void *d3d11_gfx_init(const video_info_t* video, .MinLOD = -D3D11_FLOAT32_MAX, .MaxLOD = D3D11_FLOAT32_MAX, }; - /* Initialize samplers */ - for (i = 0; i < RARCH_WRAP_MAX; i++) + for (int i = 0; i < RARCH_WRAP_MAX; i++) { switch (i) { @@ -545,12 +530,10 @@ static void *d3d11_gfx_init(const video_info_t* video, desc.AddressW = desc.AddressU; desc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR; - D3D11CreateSamplerState(d3d11->device, &desc, - &d3d11->samplers[RARCH_FILTER_LINEAR][i]); + D3D11CreateSamplerState(d3d11->device, &desc, &d3d11->samplers[RARCH_FILTER_LINEAR][i]); desc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT; - D3D11CreateSamplerState(d3d11->device, &desc, - &d3d11->samplers[RARCH_FILTER_NEAREST][i]); + D3D11CreateSamplerState(d3d11->device, &desc, &d3d11->samplers[RARCH_FILTER_NEAREST][i]); } } @@ -563,21 +546,23 @@ static void *d3d11_gfx_init(const video_info_t* video, { { 1.0f, 0.0f }, { 1.0f, 1.0f }, { 1.0f, 1.0f, 1.0f, 1.0f } }, { { 1.0f, 1.0f }, { 1.0f, 0.0f }, { 1.0f, 1.0f, 1.0f, 1.0f } }, }; - D3D11_BUFFER_DESC desc = { - .Usage = D3D11_USAGE_IMMUTABLE, - .ByteWidth = sizeof(vertices), - .BindFlags = D3D11_BIND_VERTEX_BUFFER, - }; - D3D11_SUBRESOURCE_DATA vertexData = { vertices }; - D3D11CreateBuffer(d3d11->device, &desc, &vertexData, &d3d11->frame.vbo); - desc.Usage = D3D11_USAGE_DYNAMIC; - desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - D3D11CreateBuffer(d3d11->device, &desc, &vertexData, &d3d11->menu.vbo); + { + D3D11_BUFFER_DESC desc = { + .Usage = D3D11_USAGE_IMMUTABLE, + .ByteWidth = sizeof(vertices), + .BindFlags = D3D11_BIND_VERTEX_BUFFER, + }; + D3D11_SUBRESOURCE_DATA vertexData = { vertices }; + D3D11CreateBuffer(d3d11->device, &desc, &vertexData, &d3d11->frame.vbo); + desc.Usage = D3D11_USAGE_DYNAMIC; + desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + D3D11CreateBuffer(d3d11->device, &desc, &vertexData, &d3d11->menu.vbo); - d3d11->sprites.capacity = 4096; - desc.ByteWidth = sizeof(d3d11_sprite_t) * d3d11->sprites.capacity; - D3D11CreateBuffer(d3d11->device, &desc, NULL, &d3d11->sprites.vbo); + d3d11->sprites.capacity = 4096; + desc.ByteWidth = sizeof(d3d11_sprite_t) * d3d11->sprites.capacity; + D3D11CreateBuffer(d3d11->device, &desc, NULL, &d3d11->sprites.vbo); + } } { @@ -712,17 +697,14 @@ static void *d3d11_gfx_init(const video_info_t* video, D3D11_COLOR_WRITE_ENABLE_ALL, }, }; - D3D11CreateBlendState(d3d11->device, &blend_desc, - &d3d11->blend_enable); + D3D11CreateBlendState(d3d11->device, &blend_desc, &d3d11->blend_enable); blend_desc.RenderTarget[0].SrcBlend = D3D11_BLEND_ONE; blend_desc.RenderTarget[0].DestBlend = D3D11_BLEND_ONE; - D3D11CreateBlendState(d3d11->device, &blend_desc, - &d3d11->blend_pipeline); + D3D11CreateBlendState(d3d11->device, &blend_desc, &d3d11->blend_pipeline); blend_desc.RenderTarget[0].BlendEnable = FALSE; - D3D11CreateBlendState(d3d11->device, &blend_desc, - &d3d11->blend_disable); + D3D11CreateBlendState(d3d11->device, &blend_desc, &d3d11->blend_disable); } { D3D11_RASTERIZER_DESC desc = { @@ -733,16 +715,14 @@ static void *d3d11_gfx_init(const video_info_t* video, } D3D11SetState(d3d11->ctx, d3d11->state); - font_driver_init_osd(d3d11, false, video->is_threaded, - FONT_DRIVER_RENDER_D3D11_API); + font_driver_init_osd(d3d11, false, video->is_threaded, FONT_DRIVER_RENDER_D3D11_API); if (settings->bools.video_shader_enable) { const char* ext = path_get_extension(settings->paths.path_shader); if (ext && !strncmp(ext, "slang", 5)) - d3d11_gfx_set_shader(d3d11, RARCH_SHADER_SLANG, - settings->paths.path_shader); + d3d11_gfx_set_shader(d3d11, RARCH_SHADER_SLANG, settings->paths.path_shader); } return d3d11; @@ -751,15 +731,11 @@ error: d3d11_gfx_free(d3d11); return NULL; } - -static bool d3d11_init_frame_textures(d3d11_video_t *d3d11, - unsigned width, unsigned height) +static bool d3d11_init_frame_textures(d3d11_video_t* d3d11, unsigned width, unsigned height) { - unsigned i; - if (d3d11->shader_preset) { - for (i = 0; i < d3d11->shader_preset->passes; i++) + for (int i = 0; i < d3d11->shader_preset->passes; i++) { d3d11_release_texture(&d3d11->pass[i].rt); memset(&d3d11->pass[i].rt, 0x00, sizeof(d3d11->pass[i].rt)); @@ -772,7 +748,7 @@ static bool d3d11_init_frame_textures(d3d11_video_t *d3d11, if (d3d11->shader_preset) { - for (i = 0; i < d3d11->shader_preset->passes; i++) + for (int i = 0; i < d3d11->shader_preset->passes; i++) { struct video_shader_pass* pass = &d3d11->shader_preset->pass[i]; @@ -827,17 +803,14 @@ static bool d3d11_init_frame_textures(d3d11_video_t *d3d11, height = d3d11->vp.height; } - RARCH_LOG("[D3D11]: Updating framebuffer size %u x %u.\n", - width, height); + RARCH_LOG("[D3D11]: Updating framebuffer size %u x %u.\n", width, height); /* TODO: maybe use double buffering and grap the swapchain view * instead when pass->feedback == true for the last pass ? * (unless last pass is invalid anyway as a feedback source) */ - if ( (i != (d3d11->shader_preset->passes - 1)) || - (width != d3d11->vp.width) || - (height != d3d11->vp.height) || - pass->feedback) + if ((i != (d3d11->shader_preset->passes - 1)) || (width != d3d11->vp.width) || + (height != d3d11->vp.height) || pass->feedback) { d3d11->pass[i].viewport.Width = width; d3d11->pass[i].viewport.Height = height; @@ -845,8 +818,7 @@ static bool d3d11_init_frame_textures(d3d11_video_t *d3d11, d3d11->pass[i].rt.desc.Width = width; d3d11->pass[i].rt.desc.Height = height; d3d11->pass[i].rt.desc.BindFlags = D3D11_BIND_RENDER_TARGET; - d3d11->pass[i].rt.desc.Format = glslang_format_to_dxgi( - d3d11->pass[i].semantics.format); + d3d11->pass[i].rt.desc.Format = glslang_format_to_dxgi(d3d11->pass[i].semantics.format); d3d11_init_texture(d3d11->device, &d3d11->pass[i].rt); if (pass->feedback) @@ -887,7 +859,6 @@ static bool d3d11_gfx_frame( const char* msg, video_frame_info_t* video_info) { - unsigned i; d3d11_video_t* d3d11 = (d3d11_video_t*)data; if (d3d11->resize_chain) @@ -917,40 +888,33 @@ static bool d3d11_gfx_frame( PERF_START(); - /* custom viewport doesn't call apply_state_changes, - * so we can't rely on this for now */ -#if 0 +#if 0 /* custom viewport doesn't call apply_state_changes, so we can't rely on this for now */ if (d3d11->resize_viewport) #endif d3d11_update_viewport(d3d11, false); - D3D11SetPrimitiveTopology(d3d11->ctx, - D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); + D3D11SetPrimitiveTopology(d3d11->ctx, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); if (frame && width && height) { - if ( d3d11->frame.texture.desc.Width != width || - d3d11->frame.texture.desc.Height != height) + if (d3d11->frame.texture.desc.Width != width || d3d11->frame.texture.desc.Height != height) d3d11->resize_fbos = true; if (d3d11->resize_fbos) d3d11_init_frame_textures(d3d11, width, height); d3d11_update_texture( - d3d11->ctx, width, height, pitch, d3d11->format, - frame, &d3d11->frame.texture); + d3d11->ctx, width, height, pitch, d3d11->format, frame, &d3d11->frame.texture); } - D3D11SetVertexBuffer(d3d11->ctx, 0, d3d11->frame.vbo, - sizeof(d3d11_vertex_t), 0); - D3D11SetBlendState(d3d11->ctx, d3d11->blend_disable, NULL, - D3D11_DEFAULT_SAMPLE_MASK); + D3D11SetVertexBuffer(d3d11->ctx, 0, d3d11->frame.vbo, sizeof(d3d11_vertex_t), 0); + D3D11SetBlendState(d3d11->ctx, d3d11->blend_disable, NULL, D3D11_DEFAULT_SAMPLE_MASK); d3d11_texture_t* texture = &d3d11->frame.texture; if (d3d11->shader_preset) { - for (i = 0; i < d3d11->shader_preset->passes; i++) + for (int i = 0; i < d3d11->shader_preset->passes; i++) { if (d3d11->shader_preset->pass[i].feedback) { @@ -960,22 +924,21 @@ static bool d3d11_gfx_frame( } } - for (i = 0; i < d3d11->shader_preset->passes; i++) + for (int i = 0; i < d3d11->shader_preset->passes; i++) { - unsigned j; - texture_sem_t* texture_sem = d3d11->pass[i].semantics.textures; - - while (texture_sem->stage_mask) { - D3D11ShaderResourceView view = *(D3D11ShaderResourceView*) - texture_sem->texture_data; - D3D11SamplerStateRef sampler = *(D3D11SamplerStateRef*) - texture_sem->sampler_data; + texture_sem_t* texture_sem = d3d11->pass[i].semantics.textures; - d3d11->pass[i].textures[texture_sem->binding] = view; - d3d11->pass[i].samplers[texture_sem->binding] = sampler; + while (texture_sem->stage_mask) + { + D3D11ShaderResourceView view = *(D3D11ShaderResourceView*)texture_sem->texture_data; + D3D11SamplerStateRef sampler = *(D3D11SamplerStateRef*)texture_sem->sampler_data; - texture_sem++; + d3d11->pass[i].textures[texture_sem->binding] = view; + d3d11->pass[i].samplers[texture_sem->binding] = sampler; + + texture_sem++; + } } if (d3d11->shader_preset->pass[i].frame_count_mod) @@ -984,7 +947,7 @@ static bool d3d11_gfx_frame( else d3d11->pass[i].frame_count = frame_count; - for (j = 0; j < SLANG_CBUFFER_MAX; j++) + for (int j = 0; j < SLANG_CBUFFER_MAX; j++) { D3D11Buffer buffer = d3d11->pass[i].buffers[j]; cbuffer_sem_t* buffer_sem = &d3d11->pass[i].semantics.cbuffers[j]; @@ -994,25 +957,20 @@ static bool d3d11_gfx_frame( D3D11_MAPPED_SUBRESOURCE res; uniform_sem_t* uniform = buffer_sem->uniforms; - D3D11MapBuffer(d3d11->ctx, buffer, 0, - D3D11_MAP_WRITE_DISCARD, 0, &res); - + D3D11MapBuffer(d3d11->ctx, buffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &res); while (uniform->size) { if (uniform->data) - memcpy((uint8_t*)res.pData + uniform->offset, - uniform->data, uniform->size); + memcpy((uint8_t*)res.pData + uniform->offset, uniform->data, uniform->size); uniform++; } D3D11UnmapBuffer(d3d11->ctx, buffer, 0); if (buffer_sem->stage_mask & SLANG_STAGE_VERTEX_MASK) - D3D11SetVShaderConstantBuffers(d3d11->ctx, - buffer_sem->binding, 1, &buffer); + D3D11SetVShaderConstantBuffers(d3d11->ctx, buffer_sem->binding, 1, &buffer); if (buffer_sem->stage_mask & SLANG_STAGE_FRAGMENT_MASK) - D3D11SetPShaderConstantBuffers(d3d11->ctx, - buffer_sem->binding, 1, &buffer); + D3D11SetPShaderConstantBuffers(d3d11->ctx, buffer_sem->binding, 1, &buffer); } } @@ -1020,17 +978,13 @@ static bool d3d11_gfx_frame( D3D11RenderTargetView null_rt = NULL; D3D11SetRenderTargets(d3d11->ctx, 1, &null_rt, NULL); - D3D11SetPShaderResources(d3d11->ctx, 0, SLANG_NUM_BINDINGS, - (ID3D11ShaderResourceView * const*)d3d11->pass[i].textures); - D3D11SetPShaderSamplers(d3d11->ctx, 0, SLANG_NUM_BINDINGS, - d3d11->pass[i].samplers); + D3D11SetPShaderResources(d3d11->ctx, 0, SLANG_NUM_BINDINGS, d3d11->pass[i].textures); + D3D11SetPShaderSamplers(d3d11->ctx, 0, SLANG_NUM_BINDINGS, d3d11->pass[i].samplers); if (d3d11->pass[i].rt.handle) { - D3D11SetRenderTargets(d3d11->ctx, 1, - &d3d11->pass[i].rt.rt_view, NULL); - D3D11ClearRenderTargetView(d3d11->ctx, - d3d11->pass[i].rt.rt_view, d3d11->clearcolor); + D3D11SetRenderTargets(d3d11->ctx, 1, &d3d11->pass[i].rt.rt_view, NULL); + D3D11ClearRenderTargetView(d3d11->ctx, d3d11->pass[i].rt.rt_view, d3d11->clearcolor); D3D11SetViewports(d3d11->ctx, 1, &d3d11->pass[i].viewport); D3D11Draw(d3d11->ctx, 4, 0); @@ -1050,30 +1004,24 @@ static bool d3d11_gfx_frame( d3d11_set_shader(d3d11->ctx, &d3d11->shaders[VIDEO_SHADER_STOCK_BLEND]); D3D11SetPShaderResources(d3d11->ctx, 0, 1, &texture->view); D3D11SetPShaderSamplers( - d3d11->ctx, 0, 1, - (const ID3D11SamplerState**) - &d3d11->samplers[RARCH_FILTER_UNSPEC][RARCH_WRAP_DEFAULT]); + d3d11->ctx, 0, 1, &d3d11->samplers[RARCH_FILTER_UNSPEC][RARCH_WRAP_DEFAULT]); D3D11SetVShaderConstantBuffers(d3d11->ctx, 0, 1, &d3d11->frame.ubo); } - D3D11ClearRenderTargetView(d3d11->ctx, - d3d11->renderTargetView, d3d11->clearcolor); + D3D11ClearRenderTargetView(d3d11->ctx, d3d11->renderTargetView, d3d11->clearcolor); D3D11SetViewports(d3d11->ctx, 1, &d3d11->frame.viewport); D3D11Draw(d3d11->ctx, 4, 0); - D3D11SetBlendState(d3d11->ctx, d3d11->blend_enable, - NULL, D3D11_DEFAULT_SAMPLE_MASK); + D3D11SetBlendState(d3d11->ctx, d3d11->blend_enable, NULL, D3D11_DEFAULT_SAMPLE_MASK); if (d3d11->menu.enabled && d3d11->menu.texture.handle) { if (d3d11->menu.fullscreen) D3D11SetViewports(d3d11->ctx, 1, &d3d11->viewport); - d3d11_set_shader(d3d11->ctx, - &d3d11->shaders[VIDEO_SHADER_STOCK_BLEND]); - D3D11SetVertexBuffer(d3d11->ctx, 0, - d3d11->menu.vbo, sizeof(d3d11_vertex_t), 0); + d3d11_set_shader(d3d11->ctx, &d3d11->shaders[VIDEO_SHADER_STOCK_BLEND]); + D3D11SetVertexBuffer(d3d11->ctx, 0, d3d11->menu.vbo, sizeof(d3d11_vertex_t), 0); D3D11SetVShaderConstantBuffers(d3d11->ctx, 0, 1, &d3d11->ubo); d3d11_set_texture_and_sampler(d3d11->ctx, 0, &d3d11->menu.texture); D3D11Draw(d3d11->ctx, 4, 0); @@ -1082,10 +1030,8 @@ static bool d3d11_gfx_frame( D3D11SetViewports(d3d11->ctx, 1, &d3d11->viewport); d3d11_set_shader(d3d11->ctx, &d3d11->sprites.shader); - D3D11SetPrimitiveTopology(d3d11->ctx, - D3D11_PRIMITIVE_TOPOLOGY_POINTLIST); - D3D11SetVertexBuffer(d3d11->ctx, 0, d3d11->sprites.vbo, - sizeof(d3d11_sprite_t), 0); + D3D11SetPrimitiveTopology(d3d11->ctx, D3D11_PRIMITIVE_TOPOLOGY_POINTLIST); + D3D11SetVertexBuffer(d3d11->ctx, 0, d3d11->sprites.vbo, sizeof(d3d11_sprite_t), 0); D3D11SetVShaderConstantBuffer(d3d11->ctx, 0, d3d11->ubo); D3D11SetPShaderConstantBuffer(d3d11->ctx, 0, d3d11->ubo); @@ -1122,22 +1068,15 @@ static bool d3d11_gfx_alive(void* data) bool quit; d3d11_video_t* d3d11 = (d3d11_video_t*)data; - win32_check_window(&quit, &d3d11->resize_chain, - &d3d11->vp.full_width, &d3d11->vp.full_height); + win32_check_window(&quit, &d3d11->resize_chain, &d3d11->vp.full_width, &d3d11->vp.full_height); - if ( d3d11->resize_chain && - (d3d11->vp.full_width != 0) && - (d3d11->vp.full_height != 0) - ) + if (d3d11->resize_chain && d3d11->vp.full_width != 0 && d3d11->vp.full_height != 0) video_driver_set_size(&d3d11->vp.full_width, &d3d11->vp.full_height); return !quit; } -static bool d3d11_gfx_focus(void* data) -{ - return win32_has_focus(); -} +static bool d3d11_gfx_focus(void* data) { return win32_has_focus(); } static bool d3d11_gfx_suppress_screensaver(void* data, bool enable) { @@ -1169,8 +1108,7 @@ static void d3d11_gfx_viewport_info(void* data, struct video_viewport* vp) *vp = d3d11->vp; } -static bool d3d11_gfx_read_viewport(void* data, - uint8_t* buffer, bool is_idle) +static bool d3d11_gfx_read_viewport(void* data, uint8_t* buffer, bool is_idle) { (void)data; (void)buffer; @@ -1179,16 +1117,12 @@ static bool d3d11_gfx_read_viewport(void* data, } static void d3d11_set_menu_texture_frame( - void* data, const void* frame, bool rgb32, - unsigned width, unsigned height, float alpha) + void* data, const void* frame, bool rgb32, unsigned width, unsigned height, float alpha) { d3d11_video_t* d3d11 = (d3d11_video_t*)data; - DXGI_FORMAT format = rgb32 ? - DXGI_FORMAT_B8G8R8A8_UNORM : DXGI_FORMAT_EX_A4R4G4B4_UNORM; + DXGI_FORMAT format = rgb32 ? DXGI_FORMAT_B8G8R8A8_UNORM : DXGI_FORMAT_EX_A4R4G4B4_UNORM; - if ( - d3d11->menu.texture.desc.Width != width || - d3d11->menu.texture.desc.Height != height) + if (d3d11->menu.texture.desc.Width != width || d3d11->menu.texture.desc.Height != height) { d3d11->menu.texture.desc.Format = format; d3d11->menu.texture.desc.Width = width; @@ -1196,16 +1130,14 @@ static void d3d11_set_menu_texture_frame( d3d11_init_texture(d3d11->device, &d3d11->menu.texture); } - d3d11_update_texture(d3d11->ctx, width, height, 0, format, frame, - &d3d11->menu.texture); + d3d11_update_texture(d3d11->ctx, width, height, 0, format, frame, &d3d11->menu.texture); d3d11->menu.texture.sampler = d3d11->samplers - [config_get_ptr()->bools.menu_linear_filter - ? RARCH_FILTER_LINEAR - : RARCH_FILTER_NEAREST][RARCH_WRAP_DEFAULT]; + [config_get_ptr()->bools.menu_linear_filter + ? RARCH_FILTER_LINEAR + : RARCH_FILTER_NEAREST][RARCH_WRAP_DEFAULT]; } -static void d3d11_set_menu_texture_enable(void* data, bool state, - bool full_screen) +static void d3d11_set_menu_texture_enable(void* data, bool state, bool full_screen) { d3d11_video_t* d3d11 = (d3d11_video_t*)data; @@ -1216,8 +1148,7 @@ static void d3d11_set_menu_texture_enable(void* data, bool state, d3d11->menu.fullscreen = full_screen; } -static void d3d11_gfx_set_aspect_ratio(void* data, - unsigned aspect_ratio_idx) +static void d3d11_gfx_set_aspect_ratio(void* data, unsigned aspect_ratio_idx) { d3d11_video_t* d3d11 = (d3d11_video_t*)data; @@ -1237,8 +1168,7 @@ static void d3d11_gfx_apply_state_changes(void* data) } static void d3d11_gfx_set_osd_msg( - void* data, video_frame_info_t* video_info, - const char* msg, const void* params, void* font) + void* data, video_frame_info_t* video_info, const char* msg, const void* params, void* font) { d3d11_video_t* d3d11 = (d3d11_video_t*)data; @@ -1251,8 +1181,7 @@ static void d3d11_gfx_set_osd_msg( } } static uintptr_t d3d11_gfx_load_texture( - void* video_data, void* data, bool threaded, - enum texture_filter_type filter_type) + void* video_data, void* data, bool threaded, enum texture_filter_type filter_type) { d3d11_texture_t* texture = NULL; d3d11_video_t* d3d11 = (d3d11_video_t*)video_data; @@ -1269,15 +1198,13 @@ static uintptr_t d3d11_gfx_load_texture( texture->desc.MiscFlags = D3D11_RESOURCE_MISC_GENERATE_MIPS; /* fallthrough */ case TEXTURE_FILTER_LINEAR: - texture->sampler = d3d11->samplers[ - RARCH_FILTER_LINEAR][RARCH_WRAP_DEFAULT]; + texture->sampler = d3d11->samplers[RARCH_FILTER_LINEAR][RARCH_WRAP_DEFAULT]; break; case TEXTURE_FILTER_MIPMAP_NEAREST: texture->desc.MiscFlags = D3D11_RESOURCE_MISC_GENERATE_MIPS; /* fallthrough */ case TEXTURE_FILTER_NEAREST: - texture->sampler = d3d11->samplers[ - RARCH_FILTER_NEAREST][RARCH_WRAP_DEFAULT]; + texture->sampler = d3d11->samplers[RARCH_FILTER_NEAREST][RARCH_WRAP_DEFAULT]; break; } @@ -1288,8 +1215,7 @@ static uintptr_t d3d11_gfx_load_texture( d3d11_init_texture(d3d11->device, texture); d3d11_update_texture( - d3d11->ctx, image->width, image->height, 0, - DXGI_FORMAT_B8G8R8A8_UNORM, image->pixels, + d3d11->ctx, image->width, image->height, 0, DXGI_FORMAT_B8G8R8A8_UNORM, image->pixels, texture); return (uintptr_t)texture; @@ -1331,8 +1257,7 @@ static const video_poke_interface_t d3d11_poke_interface = { NULL, /* get_hw_render_interface */ }; -static void d3d11_gfx_get_poke_interface(void* data, - const video_poke_interface_t **iface) +static void d3d11_gfx_get_poke_interface(void* data, const video_poke_interface_t** iface) { *iface = &d3d11_poke_interface; } diff --git a/gfx/include/Cg/cgD3D9.h b/gfx/include/Cg/cgD3D9.h index 646a2cf6fd..465f26e3ea 100644 --- a/gfx/include/Cg/cgD3D9.h +++ b/gfx/include/Cg/cgD3D9.h @@ -90,11 +90,11 @@ enum cgD3D9Errors cgD3D9DebugTrace = 1001 }; -/* - * HRESULTs specific to cgD3D9. When the CGerror is set to cgD3D9Failed - * cgD3D9GetLastError will return an HRESULT that could be one these. - * Use cgD3D9TranslateHRESULT() to translate these errors into strings. -*/ +/*--------------------------------------------------------------------------- +// HRESULTs specific to cgD3D9. When the CGerror is set to cgD3D9Failed +// cgD3D9GetLastError will return an HRESULT that could be one these. +// Use cgD3D9TranslateHRESULT() to translate these errors into strings. +---------------------------------------------------------------------------*/ static const HRESULT CGD3D9ERR_NOTLOADED = MAKE_HRESULT(1, 0x877, 1); static const HRESULT CGD3D9ERR_NODEVICE = MAKE_HRESULT(1, 0x877, 2); @@ -106,9 +106,9 @@ static const HRESULT CGD3D9ERR_NOTUNIFORM = MAKE_HRESULT(1, 0x877, 7); static const HRESULT CGD3D9ERR_NOTMATRIX = MAKE_HRESULT(1, 0x877, 8); static const HRESULT CGD3D9ERR_INVALIDPARAM = MAKE_HRESULT(1, 0x877, 9); -/* - * Other error return values -*/ +/*--------------------------------------------------------------------------- +// Other error return values +---------------------------------------------------------------------------*/ static const DWORD CGD3D9_INVALID_USAGE = 0xFF; diff --git a/gfx/include/d3d9/d3dx9math.h b/gfx/include/d3d9/d3dx9math.h index 914d9536f0..e8593c0f1e 100644 --- a/gfx/include/d3d9/d3dx9math.h +++ b/gfx/include/d3d9/d3dx9math.h @@ -462,19 +462,19 @@ public: D3DXPLANE( CONST D3DXFLOAT16* ); D3DXPLANE( FLOAT a, FLOAT b, FLOAT c, FLOAT d ); - /* casting */ + // casting operator FLOAT* (); operator CONST FLOAT* () const; - /* assignment operators */ + // assignment operators D3DXPLANE& operator *= ( FLOAT ); D3DXPLANE& operator /= ( FLOAT ); - /* unary operators */ + // unary operators D3DXPLANE operator + () const; D3DXPLANE operator - () const; - /* binary operators */ + // binary operators D3DXPLANE operator * ( FLOAT ) const; D3DXPLANE operator / ( FLOAT ) const; @@ -483,16 +483,16 @@ public: BOOL operator == ( CONST D3DXPLANE& ) const; BOOL operator != ( CONST D3DXPLANE& ) const; -#endif /*__cplusplus */ +#endif //__cplusplus FLOAT a, b, c, d; } D3DXPLANE, *LPD3DXPLANE; -/* - * - * Colors - * - */ +//=========================================================================== +// +// Colors +// +//=========================================================================== typedef struct D3DXCOLOR { @@ -505,7 +505,7 @@ public: D3DXCOLOR( CONST D3DCOLORVALUE& ); D3DXCOLOR( FLOAT r, FLOAT g, FLOAT b, FLOAT a ); - /* casting */ + // casting operator DWORD () const; operator FLOAT* (); @@ -517,17 +517,17 @@ public: operator D3DCOLORVALUE& (); operator CONST D3DCOLORVALUE& () const; - /* assignment operators */ + // assignment operators D3DXCOLOR& operator += ( CONST D3DXCOLOR& ); D3DXCOLOR& operator -= ( CONST D3DXCOLOR& ); D3DXCOLOR& operator *= ( FLOAT ); D3DXCOLOR& operator /= ( FLOAT ); - /* unary operators */ + // unary operators D3DXCOLOR operator + () const; D3DXCOLOR operator - () const; - /* binary operators */ + // binary operators D3DXCOLOR operator + ( CONST D3DXCOLOR& ) const; D3DXCOLOR operator - ( CONST D3DXCOLOR& ) const; D3DXCOLOR operator * ( FLOAT ) const; @@ -538,35 +538,38 @@ public: BOOL operator == ( CONST D3DXCOLOR& ) const; BOOL operator != ( CONST D3DXCOLOR& ) const; -#endif /* __cplusplus */ +#endif //__cplusplus FLOAT r, g, b, a; } D3DXCOLOR, *LPD3DXCOLOR; -/* - * - * D3DX math functions: - * - * NOTE: - * * All these functions can take the same object as in and out parameters. - * - * * Out parameters are typically also returned as return values, so that - * the output of one function may be used as a parameter to another. - */ -/* - * Float16 - */ -/* non-inline */ +//=========================================================================== +// +// D3DX math functions: +// +// NOTE: +// * All these functions can take the same object as in and out parameters. +// +// * Out parameters are typically also returned as return values, so that +// the output of one function may be used as a parameter to another. +// +//=========================================================================== + +//-------------------------- +// Float16 +//-------------------------- + +// non-inline #ifdef __cplusplus extern "C" { #endif -/* Converts an array 32-bit floats to 16-bit floats */ +// Converts an array 32-bit floats to 16-bit floats D3DXFLOAT16* WINAPI D3DXFloat32To16Array ( D3DXFLOAT16 *pOut, CONST FLOAT *pIn, UINT n ); -/* Converts an array 16-bit floats to 32-bit floats */ +// Converts an array 16-bit floats to 32-bit floats FLOAT* WINAPI D3DXFloat16To32Array ( FLOAT *pOut, CONST D3DXFLOAT16 *pIn, UINT n ); @@ -574,11 +577,12 @@ FLOAT* WINAPI D3DXFloat16To32Array } #endif -/* - * 2D Vector - */ -/* inline */ +//-------------------------- +// 2D Vector +//-------------------------- + +// inline FLOAT D3DXVec2Length ( CONST D3DXVECTOR2 *pV ); @@ -589,7 +593,7 @@ FLOAT D3DXVec2LengthSq FLOAT D3DXVec2Dot ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); -/* Z component of ((x1,y1,0) cross (x2,y2,0)) */ +// Z component of ((x1,y1,0) cross (x2,y2,0)) FLOAT D3DXVec2CCW ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); @@ -599,23 +603,23 @@ D3DXVECTOR2* D3DXVec2Add D3DXVECTOR2* D3DXVec2Subtract ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); -/* Minimize each component. x = min(x1, x2), y = min(y1, y2) */ +// Minimize each component. x = min(x1, x2), y = min(y1, y2) D3DXVECTOR2* D3DXVec2Minimize ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); -/* Maximize each component. x = max(x1, x2), y = max(y1, y2) */ +// Maximize each component. x = max(x1, x2), y = max(y1, y2) D3DXVECTOR2* D3DXVec2Maximize ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); D3DXVECTOR2* D3DXVec2Scale ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, FLOAT s ); -/* Linear interpolation. V1 + s(V2-V1) */ +// Linear interpolation. V1 + s(V2-V1) D3DXVECTOR2* D3DXVec2Lerp ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, FLOAT s ); -/* non-inline */ +// non-inline #ifdef __cplusplus extern "C" { #endif @@ -623,43 +627,43 @@ extern "C" { D3DXVECTOR2* WINAPI D3DXVec2Normalize ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV ); -/* Hermite interpolation between position V1, tangent T1 (when s == 0) - * and position V2, tangent T2 (when s == 1). */ +// Hermite interpolation between position V1, tangent T1 (when s == 0) +// and position V2, tangent T2 (when s == 1). D3DXVECTOR2* WINAPI D3DXVec2Hermite ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pT1, CONST D3DXVECTOR2 *pV2, CONST D3DXVECTOR2 *pT2, FLOAT s ); -/* CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) */ +// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) D3DXVECTOR2* WINAPI D3DXVec2CatmullRom ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV0, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, CONST D3DXVECTOR2 *pV3, FLOAT s ); -/* Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) */ +// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) D3DXVECTOR2* WINAPI D3DXVec2BaryCentric ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, CONST D3DXVECTOR2 *pV3, FLOAT f, FLOAT g); -/* Transform (x, y, 0, 1) by matrix. */ +// Transform (x, y, 0, 1) by matrix. D3DXVECTOR4* WINAPI D3DXVec2Transform ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); -/* Transform (x, y, 0, 1) by matrix, project result back into w=1. */ +// Transform (x, y, 0, 1) by matrix, project result back into w=1. D3DXVECTOR2* WINAPI D3DXVec2TransformCoord ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); -/* Transform (x, y, 0, 0) by matrix. */ +// Transform (x, y, 0, 0) by matrix. D3DXVECTOR2* WINAPI D3DXVec2TransformNormal ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); -/* Transform Array (x, y, 0, 1) by matrix. */ +// Transform Array (x, y, 0, 1) by matrix. D3DXVECTOR4* WINAPI D3DXVec2TransformArray ( D3DXVECTOR4 *pOut, UINT OutStride, CONST D3DXVECTOR2 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n); -/* Transform Array (x, y, 0, 1) by matrix, project result back into w=1. */ +// Transform Array (x, y, 0, 1) by matrix, project result back into w=1. D3DXVECTOR2* WINAPI D3DXVec2TransformCoordArray ( D3DXVECTOR2 *pOut, UINT OutStride, CONST D3DXVECTOR2 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); -/* Transform Array (x, y, 0, 0) by matrix. */ +// Transform Array (x, y, 0, 0) by matrix. D3DXVECTOR2* WINAPI D3DXVec2TransformNormalArray ( D3DXVECTOR2 *pOut, UINT OutStride, CONST D3DXVECTOR2 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); @@ -669,11 +673,12 @@ D3DXVECTOR2* WINAPI D3DXVec2TransformNormalArray } #endif -/* - * 3D Vector - */ -/* inline */ +//-------------------------- +// 3D Vector +//-------------------------- + +// inline FLOAT D3DXVec3Length ( CONST D3DXVECTOR3 *pV ); @@ -693,23 +698,23 @@ D3DXVECTOR3* D3DXVec3Add D3DXVECTOR3* D3DXVec3Subtract ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); -/* Minimize each component. x = min(x1, x2), y = min(y1, y2), ... */ +// Minimize each component. x = min(x1, x2), y = min(y1, y2), ... D3DXVECTOR3* D3DXVec3Minimize ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); -/* Maximize each component. x = max(x1, x2), y = max(y1, y2), ... */ +// Maximize each component. x = max(x1, x2), y = max(y1, y2), ... D3DXVECTOR3* D3DXVec3Maximize ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); D3DXVECTOR3* D3DXVec3Scale ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, FLOAT s); -/* Linear interpolation. V1 + s(V2-V1) */ +// Linear interpolation. V1 + s(V2-V1) D3DXVECTOR3* D3DXVec3Lerp ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, FLOAT s ); -/* non-inline */ +// non-inline #ifdef __cplusplus extern "C" { #endif @@ -717,69 +722,67 @@ extern "C" { D3DXVECTOR3* WINAPI D3DXVec3Normalize ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV ); -/* Hermite interpolation between position V1, tangent T1 (when s == 0) - * and position V2, tangent T2 (when s == 1). */ +// Hermite interpolation between position V1, tangent T1 (when s == 0) +// and position V2, tangent T2 (when s == 1). D3DXVECTOR3* WINAPI D3DXVec3Hermite ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pT1, CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pT2, FLOAT s ); -/* CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) */ +// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) D3DXVECTOR3* WINAPI D3DXVec3CatmullRom ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV0, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pV3, FLOAT s ); -/* Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) */ +// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) D3DXVECTOR3* WINAPI D3DXVec3BaryCentric ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pV3, FLOAT f, FLOAT g); -/* Transform (x, y, z, 1) by matrix. */ +// Transform (x, y, z, 1) by matrix. D3DXVECTOR4* WINAPI D3DXVec3Transform ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); -/* Transform (x, y, z, 1) by matrix, project result back into w=1. */ +// Transform (x, y, z, 1) by matrix, project result back into w=1. D3DXVECTOR3* WINAPI D3DXVec3TransformCoord ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); -/* Transform (x, y, z, 0) by matrix. If you transforming a normal by a - * non-affine matrix, the matrix you pass to this function should be the - * transpose of the inverse of the matrix you would use to transform a coord. - */ +// Transform (x, y, z, 0) by matrix. If you transforming a normal by a +// non-affine matrix, the matrix you pass to this function should be the +// transpose of the inverse of the matrix you would use to transform a coord. D3DXVECTOR3* WINAPI D3DXVec3TransformNormal ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); -/* Transform Array (x, y, z, 1) by matrix. */ +// Transform Array (x, y, z, 1) by matrix. D3DXVECTOR4* WINAPI D3DXVec3TransformArray ( D3DXVECTOR4 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); -/* Transform Array (x, y, z, 1) by matrix, project result back into w=1. */ +// Transform Array (x, y, z, 1) by matrix, project result back into w=1. D3DXVECTOR3* WINAPI D3DXVec3TransformCoordArray ( D3DXVECTOR3 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); -/* Transform (x, y, z, 0) by matrix. If you transforming a normal by a - * non-affine matrix, the matrix you pass to this function should be the - * transpose of the inverse of the matrix you would use to transform a coord. - */ +// Transform (x, y, z, 0) by matrix. If you transforming a normal by a +// non-affine matrix, the matrix you pass to this function should be the +// transpose of the inverse of the matrix you would use to transform a coord. D3DXVECTOR3* WINAPI D3DXVec3TransformNormalArray ( D3DXVECTOR3 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); -/* Project vector from object space into screen space */ +// Project vector from object space into screen space D3DXVECTOR3* WINAPI D3DXVec3Project ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DVIEWPORT9 *pViewport, CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld); -/* Project vector from screen space into object space */ +// Project vector from screen space into object space D3DXVECTOR3* WINAPI D3DXVec3Unproject ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DVIEWPORT9 *pViewport, CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld); -/* Project vector Array from object space into screen space */ +// Project vector Array from object space into screen space D3DXVECTOR3* WINAPI D3DXVec3ProjectArray ( D3DXVECTOR3 *pOut, UINT OutStride,CONST D3DXVECTOR3 *pV, UINT VStride,CONST D3DVIEWPORT9 *pViewport, CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld, UINT n); -/* Project vector Array from screen space into object space */ +// Project vector Array from screen space into object space D3DXVECTOR3* WINAPI D3DXVec3UnprojectArray ( D3DXVECTOR3 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DVIEWPORT9 *pViewport, CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld, UINT n); @@ -789,11 +792,13 @@ D3DXVECTOR3* WINAPI D3DXVec3UnprojectArray } #endif -/* - * 4D Vector - */ -/* inline */ + +//-------------------------- +// 4D Vector +//-------------------------- + +// inline FLOAT D3DXVec4Length ( CONST D3DXVECTOR4 *pV ); @@ -810,28 +815,28 @@ D3DXVECTOR4* D3DXVec4Add D3DXVECTOR4* D3DXVec4Subtract ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); -/* Minimize each component. x = min(x1, x2), y = min(y1, y2), ... */ +// Minimize each component. x = min(x1, x2), y = min(y1, y2), ... D3DXVECTOR4* D3DXVec4Minimize ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); -/* Maximize each component. x = max(x1, x2), y = max(y1, y2), ... */ +// Maximize each component. x = max(x1, x2), y = max(y1, y2), ... D3DXVECTOR4* D3DXVec4Maximize ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); D3DXVECTOR4* D3DXVec4Scale ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, FLOAT s); -/* Linear interpolation. V1 + s(V2-V1) */ +// Linear interpolation. V1 + s(V2-V1) D3DXVECTOR4* D3DXVec4Lerp ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, FLOAT s ); -/* non-inline */ +// non-inline #ifdef __cplusplus extern "C" { #endif -/* Cross-product in 4 dimensions. */ +// Cross-product in 4 dimensions. D3DXVECTOR4* WINAPI D3DXVec4Cross ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pV3); @@ -839,27 +844,27 @@ D3DXVECTOR4* WINAPI D3DXVec4Cross D3DXVECTOR4* WINAPI D3DXVec4Normalize ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV ); -/* Hermite interpolation between position V1, tangent T1 (when s == 0) - * and position V2, tangent T2 (when s == 1). */ +// Hermite interpolation between position V1, tangent T1 (when s == 0) +// and position V2, tangent T2 (when s == 1). D3DXVECTOR4* WINAPI D3DXVec4Hermite ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pT1, CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pT2, FLOAT s ); -/* CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) */ +// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) D3DXVECTOR4* WINAPI D3DXVec4CatmullRom ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV0, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pV3, FLOAT s ); -/* Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) */ +// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) D3DXVECTOR4* WINAPI D3DXVec4BaryCentric ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pV3, FLOAT f, FLOAT g); -/* Transform vector by matrix. */ +// Transform vector by matrix. D3DXVECTOR4* WINAPI D3DXVec4Transform ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, CONST D3DXMATRIX *pM ); -/* Transform vector array by matrix. */ +// Transform vector array by matrix. D3DXVECTOR4* WINAPI D3DXVec4TransformArray ( D3DXVECTOR4 *pOut, UINT OutStride, CONST D3DXVECTOR4 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); @@ -868,11 +873,11 @@ D3DXVECTOR4* WINAPI D3DXVec4TransformArray #endif -/* - * 4D Matrix - */ +//-------------------------- +// 4D Matrix +//-------------------------- -/* inline */ +// inline D3DXMATRIX* D3DXMatrixIdentity ( D3DXMATRIX *pOut ); @@ -896,143 +901,143 @@ HRESULT WINAPI D3DXMatrixDecompose D3DXMATRIX* WINAPI D3DXMatrixTranspose ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM ); -/* Matrix multiplication. The result represents the transformation M2 - * followed by the transformation M1. (Out = M1 * M2) */ +// Matrix multiplication. The result represents the transformation M2 +// followed by the transformation M1. (Out = M1 * M2) D3DXMATRIX* WINAPI D3DXMatrixMultiply ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 ); -/* Matrix multiplication, followed by a transpose. (Out = T(M1 * M2)) */ +// Matrix multiplication, followed by a transpose. (Out = T(M1 * M2)) D3DXMATRIX* WINAPI D3DXMatrixMultiplyTranspose ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 ); -/* Calculate inverse of matrix. Inversion my fail, in which case NULL will - * be returned. The determinant of pM is also returned it pfDeterminant - * is non-NULL. */ +// Calculate inverse of matrix. Inversion my fail, in which case NULL will +// be returned. The determinant of pM is also returned it pfDeterminant +// is non-NULL. D3DXMATRIX* WINAPI D3DXMatrixInverse ( D3DXMATRIX *pOut, FLOAT *pDeterminant, CONST D3DXMATRIX *pM ); -/* Build a matrix which scales by (sx, sy, sz) */ +// Build a matrix which scales by (sx, sy, sz) D3DXMATRIX* WINAPI D3DXMatrixScaling ( D3DXMATRIX *pOut, FLOAT sx, FLOAT sy, FLOAT sz ); -/* Build a matrix which translates by (x, y, z) */ +// Build a matrix which translates by (x, y, z) D3DXMATRIX* WINAPI D3DXMatrixTranslation ( D3DXMATRIX *pOut, FLOAT x, FLOAT y, FLOAT z ); -/* Build a matrix which rotates around the X axis */ +// Build a matrix which rotates around the X axis D3DXMATRIX* WINAPI D3DXMatrixRotationX ( D3DXMATRIX *pOut, FLOAT Angle ); -/* Build a matrix which rotates around the Y axis */ +// Build a matrix which rotates around the Y axis D3DXMATRIX* WINAPI D3DXMatrixRotationY ( D3DXMATRIX *pOut, FLOAT Angle ); -/* Build a matrix which rotates around the Z axis */ +// Build a matrix which rotates around the Z axis D3DXMATRIX* WINAPI D3DXMatrixRotationZ ( D3DXMATRIX *pOut, FLOAT Angle ); -/* Build a matrix which rotates around an arbitrary axis */ +// Build a matrix which rotates around an arbitrary axis D3DXMATRIX* WINAPI D3DXMatrixRotationAxis ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pV, FLOAT Angle ); -/* Build a matrix from a quaternion */ +// Build a matrix from a quaternion D3DXMATRIX* WINAPI D3DXMatrixRotationQuaternion ( D3DXMATRIX *pOut, CONST D3DXQUATERNION *pQ); -/* Yaw around the Y axis, a pitch around the X axis, - * and a roll around the Z axis. */ +// Yaw around the Y axis, a pitch around the X axis, +// and a roll around the Z axis. D3DXMATRIX* WINAPI D3DXMatrixRotationYawPitchRoll ( D3DXMATRIX *pOut, FLOAT Yaw, FLOAT Pitch, FLOAT Roll ); -/* Build transformation matrix. NULL arguments are treated as identity. - * Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt */ +// Build transformation matrix. NULL arguments are treated as identity. +// Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt D3DXMATRIX* WINAPI D3DXMatrixTransformation ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pScalingCenter, CONST D3DXQUATERNION *pScalingRotation, CONST D3DXVECTOR3 *pScaling, CONST D3DXVECTOR3 *pRotationCenter, CONST D3DXQUATERNION *pRotation, CONST D3DXVECTOR3 *pTranslation); -/* Build 2D transformation matrix in XY plane. NULL arguments are treated as identity. - * Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt */ +// Build 2D transformation matrix in XY plane. NULL arguments are treated as identity. +// Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt D3DXMATRIX* WINAPI D3DXMatrixTransformation2D ( D3DXMATRIX *pOut, CONST D3DXVECTOR2* pScalingCenter, FLOAT ScalingRotation, CONST D3DXVECTOR2* pScaling, CONST D3DXVECTOR2* pRotationCenter, FLOAT Rotation, CONST D3DXVECTOR2* pTranslation); -/* Build affine transformation matrix. NULL arguments are treated as identity. - * Mout = Ms * Mrc-1 * Mr * Mrc * Mt */ +// Build affine transformation matrix. NULL arguments are treated as identity. +// Mout = Ms * Mrc-1 * Mr * Mrc * Mt D3DXMATRIX* WINAPI D3DXMatrixAffineTransformation ( D3DXMATRIX *pOut, FLOAT Scaling, CONST D3DXVECTOR3 *pRotationCenter, CONST D3DXQUATERNION *pRotation, CONST D3DXVECTOR3 *pTranslation); -/* Build 2D affine transformation matrix in XY plane. NULL arguments are treated as identity. - * Mout = Ms * Mrc-1 * Mr * Mrc * Mt */ +// Build 2D affine transformation matrix in XY plane. NULL arguments are treated as identity. +// Mout = Ms * Mrc-1 * Mr * Mrc * Mt D3DXMATRIX* WINAPI D3DXMatrixAffineTransformation2D ( D3DXMATRIX *pOut, FLOAT Scaling, CONST D3DXVECTOR2* pRotationCenter, FLOAT Rotation, CONST D3DXVECTOR2* pTranslation); -/* Build a lookat matrix. (right-handed) */ +// Build a lookat matrix. (right-handed) D3DXMATRIX* WINAPI D3DXMatrixLookAtRH ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pEye, CONST D3DXVECTOR3 *pAt, CONST D3DXVECTOR3 *pUp ); -/* Build a lookat matrix. (left-handed) */ +// Build a lookat matrix. (left-handed) D3DXMATRIX* WINAPI D3DXMatrixLookAtLH ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pEye, CONST D3DXVECTOR3 *pAt, CONST D3DXVECTOR3 *pUp ); -/* Build a perspective projection matrix. (right-handed) */ +// Build a perspective projection matrix. (right-handed) D3DXMATRIX* WINAPI D3DXMatrixPerspectiveRH ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); -/* Build a perspective projection matrix. (left-handed) */ +// Build a perspective projection matrix. (left-handed) D3DXMATRIX* WINAPI D3DXMatrixPerspectiveLH ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); -/* Build a perspective projection matrix. (right-handed) */ +// Build a perspective projection matrix. (right-handed) D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovRH ( D3DXMATRIX *pOut, FLOAT fovy, FLOAT Aspect, FLOAT zn, FLOAT zf ); -/* Build a perspective projection matrix. (left-handed) */ +// Build a perspective projection matrix. (left-handed) D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovLH ( D3DXMATRIX *pOut, FLOAT fovy, FLOAT Aspect, FLOAT zn, FLOAT zf ); -/* Build a perspective projection matrix. (right-handed) */ +// Build a perspective projection matrix. (right-handed) D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterRH ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, FLOAT zf ); -/* Build a perspective projection matrix. (left-handed) */ +// Build a perspective projection matrix. (left-handed) D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterLH ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, FLOAT zf ); -/* Build an ortho projection matrix. (right-handed) */ +// Build an ortho projection matrix. (right-handed) D3DXMATRIX* WINAPI D3DXMatrixOrthoRH ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); -/* Build an ortho projection matrix. (left-handed) */ +// Build an ortho projection matrix. (left-handed) D3DXMATRIX* WINAPI D3DXMatrixOrthoLH ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); -/* Build an ortho projection matrix. (right-handed) */ +// Build an ortho projection matrix. (right-handed) D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenterRH ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, FLOAT zf ); -/* Build an ortho projection matrix. (left-handed) */ +// Build an ortho projection matrix. (left-handed) D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenterLH ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, FLOAT zf ); -/* Build a matrix which flattens geometry into a plane, as if casting - * a shadow from a light. */ +// Build a matrix which flattens geometry into a plane, as if casting +// a shadow from a light. D3DXMATRIX* WINAPI D3DXMatrixShadow ( D3DXMATRIX *pOut, CONST D3DXVECTOR4 *pLight, CONST D3DXPLANE *pPlane ); -/* Build a matrix which reflects the coordinate system about a plane */ +// Build a matrix which reflects the coordinate system about a plane D3DXMATRIX* WINAPI D3DXMatrixReflect ( D3DXMATRIX *pOut, CONST D3DXPLANE *pPlane ); @@ -1040,9 +1045,10 @@ D3DXMATRIX* WINAPI D3DXMatrixReflect } #endif -/* - * Quaternion - */ + +//-------------------------- +// Quaternion +//-------------------------- /* inline */ @@ -1063,34 +1069,35 @@ D3DXQUATERNION* D3DXQuaternionIdentity BOOL D3DXQuaternionIsIdentity ( CONST D3DXQUATERNION *pQ ); -/* (-x, -y, -z, w) */ +// (-x, -y, -z, w) D3DXQUATERNION* D3DXQuaternionConjugate ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); -/* non-inline */ + +// non-inline #ifdef __cplusplus extern "C" { #endif -/* Compute a quaternin's axis and angle of rotation. Expects unit quaternions. */ +// Compute a quaternin's axis and angle of rotation. Expects unit quaternions. void WINAPI D3DXQuaternionToAxisAngle ( CONST D3DXQUATERNION *pQ, D3DXVECTOR3 *pAxis, FLOAT *pAngle ); -/* Build a quaternion from a rotation matrix. */ +// Build a quaternion from a rotation matrix. D3DXQUATERNION* WINAPI D3DXQuaternionRotationMatrix ( D3DXQUATERNION *pOut, CONST D3DXMATRIX *pM); -/* Rotation about arbitrary axis. */ +// Rotation about arbitrary axis. D3DXQUATERNION* WINAPI D3DXQuaternionRotationAxis ( D3DXQUATERNION *pOut, CONST D3DXVECTOR3 *pV, FLOAT Angle ); -/* Yaw around the Y axis, a pitch around the X axis, - * and a roll around the Z axis. */ +// Yaw around the Y axis, a pitch around the X axis, +// and a roll around the Z axis. D3DXQUATERNION* WINAPI D3DXQuaternionRotationYawPitchRoll ( D3DXQUATERNION *pOut, FLOAT Yaw, FLOAT Pitch, FLOAT Roll ); -/* Quaternion multiplication. The result represents the rotation Q2 - * followed by the rotation Q1. (Out = Q2 * Q1) */ +// Quaternion multiplication. The result represents the rotation Q2 +// followed by the rotation Q1. (Out = Q2 * Q1) D3DXQUATERNION* WINAPI D3DXQuaternionMultiply ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2 ); @@ -1098,43 +1105,43 @@ D3DXQUATERNION* WINAPI D3DXQuaternionMultiply D3DXQUATERNION* WINAPI D3DXQuaternionNormalize ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); -/* Conjugate and re-norm */ +// Conjugate and re-norm D3DXQUATERNION* WINAPI D3DXQuaternionInverse ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); -/* Expects unit quaternions. - * if q = (cos(theta), sin(theta) * v); ln(q) = (0, theta * v) */ +// Expects unit quaternions. +// if q = (cos(theta), sin(theta) * v); ln(q) = (0, theta * v) D3DXQUATERNION* WINAPI D3DXQuaternionLn ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); -/* Expects pure quaternions. (w == 0) w is ignored in calculation. - * if q = (0, theta * v); exp(q) = (cos(theta), sin(theta) * v) */ +// Expects pure quaternions. (w == 0) w is ignored in calculation. +// if q = (0, theta * v); exp(q) = (cos(theta), sin(theta) * v) D3DXQUATERNION* WINAPI D3DXQuaternionExp ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); -/* Spherical linear interpolation between Q1 (t == 0) and Q2 (t == 1). - * Expects unit quaternions. */ +// Spherical linear interpolation between Q1 (t == 0) and Q2 (t == 1). +// Expects unit quaternions. D3DXQUATERNION* WINAPI D3DXQuaternionSlerp ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2, FLOAT t ); -/* Spherical quadrangle interpolation. - * Slerp(Slerp(Q1, C, t), Slerp(A, B, t), 2t(1-t)) */ +// Spherical quadrangle interpolation. +// Slerp(Slerp(Q1, C, t), Slerp(A, B, t), 2t(1-t)) D3DXQUATERNION* WINAPI D3DXQuaternionSquad ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pA, CONST D3DXQUATERNION *pB, CONST D3DXQUATERNION *pC, FLOAT t ); -/* Setup control points for spherical quadrangle interpolation - * from Q1 to Q2. The control points are chosen in such a way - * to ensure the continuity of tangents with adjacent segments. */ +// Setup control points for spherical quadrangle interpolation +// from Q1 to Q2. The control points are chosen in such a way +// to ensure the continuity of tangents with adjacent segments. void WINAPI D3DXQuaternionSquadSetup ( D3DXQUATERNION *pAOut, D3DXQUATERNION *pBOut, D3DXQUATERNION *pCOut, CONST D3DXQUATERNION *pQ0, CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2, CONST D3DXQUATERNION *pQ3 ); -/* Barycentric interpolation. - * Slerp(Slerp(Q1, Q2, f+g), Slerp(Q1, Q3, f+g), g/(f+g)) */ +// Barycentric interpolation. +// Slerp(Slerp(Q1, Q2, f+g), Slerp(Q1, Q3, f+g), g/(f+g)) D3DXQUATERNION* WINAPI D3DXQuaternionBaryCentric ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2, CONST D3DXQUATERNION *pQ3, @@ -1145,58 +1152,58 @@ D3DXQUATERNION* WINAPI D3DXQuaternionBaryCentric #endif -/* - * Plane -*/ +//-------------------------- +// Plane +//-------------------------- -/* inline */ +// inline -/* ax + by + cz + dw */ +// ax + by + cz + dw FLOAT D3DXPlaneDot ( CONST D3DXPLANE *pP, CONST D3DXVECTOR4 *pV); -/* ax + by + cz + d */ +// ax + by + cz + d FLOAT D3DXPlaneDotCoord ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV); -/* ax + by + cz */ +// ax + by + cz FLOAT D3DXPlaneDotNormal ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV); D3DXPLANE* D3DXPlaneScale (D3DXPLANE *pOut, CONST D3DXPLANE *pP, FLOAT s); -/* non-inline */ +// non-inline #ifdef __cplusplus extern "C" { #endif -/* Normalize plane (so that |a,b,c| == 1) */ +// Normalize plane (so that |a,b,c| == 1) D3DXPLANE* WINAPI D3DXPlaneNormalize ( D3DXPLANE *pOut, CONST D3DXPLANE *pP); -/* Find the intersection between a plane and a line. If the line is - * parallel to the plane, NULL is returned. */ +// Find the intersection between a plane and a line. If the line is +// parallel to the plane, NULL is returned. D3DXVECTOR3* WINAPI D3DXPlaneIntersectLine ( D3DXVECTOR3 *pOut, CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2); -/* Construct a plane from a point and a normal */ +// Construct a plane from a point and a normal D3DXPLANE* WINAPI D3DXPlaneFromPointNormal ( D3DXPLANE *pOut, CONST D3DXVECTOR3 *pPoint, CONST D3DXVECTOR3 *pNormal); -/* Construct a plane from 3 points */ +// Construct a plane from 3 points D3DXPLANE* WINAPI D3DXPlaneFromPoints ( D3DXPLANE *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pV3); -/* Transform a plane by a matrix. The vector (a,b,c) must be normal. - * M should be the inverse transpose of the transformation desired. */ +// Transform a plane by a matrix. The vector (a,b,c) must be normal. +// M should be the inverse transpose of the transformation desired. D3DXPLANE* WINAPI D3DXPlaneTransform ( D3DXPLANE *pOut, CONST D3DXPLANE *pP, CONST D3DXMATRIX *pM ); -/* Transform an array of planes by a matrix. The vectors (a,b,c) must be normal. - * M should be the inverse transpose of the transformation desired. */ +// Transform an array of planes by a matrix. The vectors (a,b,c) must be normal. +// M should be the inverse transpose of the transformation desired. D3DXPLANE* WINAPI D3DXPlaneTransformArray ( D3DXPLANE *pOut, UINT OutStride, CONST D3DXPLANE *pP, UINT PStride, CONST D3DXMATRIX *pM, UINT n ); @@ -1204,13 +1211,14 @@ D3DXPLANE* WINAPI D3DXPlaneTransformArray } #endif -/* - * Color - */ -/* inline */ +//-------------------------- +// Color +//-------------------------- -/* (1-r, 1-g, 1-b, a) */ +// inline + +// (1-r, 1-g, 1-b, a) D3DXCOLOR* D3DXColorNegative (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC); @@ -1223,25 +1231,25 @@ D3DXCOLOR* D3DXColorSubtract D3DXCOLOR* D3DXColorScale (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s); -/* (r1*r2, g1*g2, b1*b2, a1*a2) */ +// (r1*r2, g1*g2, b1*b2, a1*a2) D3DXCOLOR* D3DXColorModulate (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2); -/* Linear interpolation of r,g,b, and a. C1 + s(C2-C1) */ +// Linear interpolation of r,g,b, and a. C1 + s(C2-C1) D3DXCOLOR* D3DXColorLerp (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2, FLOAT s); -/* non-inline */ +// non-inline #ifdef __cplusplus extern "C" { #endif -/* Interpolate r,g,b between desaturated color and color. - * DesaturatedColor + s(Color - DesaturatedColor) */ +// Interpolate r,g,b between desaturated color and color. +// DesaturatedColor + s(Color - DesaturatedColor) D3DXCOLOR* WINAPI D3DXColorAdjustSaturation (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s); -/* Interpolate r,g,b between 50% grey and color. Grey + s(Color - Grey) */ +// Interpolate r,g,b between 50% grey and color. Grey + s(Color - Grey) D3DXCOLOR* WINAPI D3DXColorAdjustContrast (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT c); @@ -1249,16 +1257,16 @@ D3DXCOLOR* WINAPI D3DXColorAdjustContrast } #endif -/* - * Misc -*/ +//-------------------------- +// Misc +//-------------------------- #ifdef __cplusplus extern "C" { #endif -/* Calculate Fresnel term given the cosine of theta (likely obtained by - * taking the dot of two normals), and the refraction index of the material. */ +// Calculate Fresnel term given the cosine of theta (likely obtained by +// taking the dot of two normals), and the refraction index of the material. FLOAT WINAPI D3DXFresnelTerm (FLOAT CosTheta, FLOAT RefractionIndex); @@ -1266,15 +1274,16 @@ FLOAT WINAPI D3DXFresnelTerm } #endif -/* - * - * Matrix Stack - */ +//=========================================================================== +// +// Matrix Stack +// +//=========================================================================== typedef interface ID3DXMatrixStack ID3DXMatrixStack; typedef interface ID3DXMatrixStack *LPD3DXMATRIXSTACK; -/* {C7885BA7-F990-4fe7-922D-8515E477DD85} */ +// {C7885BA7-F990-4fe7-922D-8515E477DD85} DEFINE_GUID(IID_ID3DXMatrixStack, 0xc7885ba7, 0xf990, 0x4fe7, 0x92, 0x2d, 0x85, 0x15, 0xe4, 0x77, 0xdd, 0x85); @@ -1284,83 +1293,85 @@ DEFINE_GUID(IID_ID3DXMatrixStack, DECLARE_INTERFACE_(ID3DXMatrixStack, IUnknown) { - /* IUnknown methods */ + // + // IUnknown methods + // STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; STDMETHOD_(ULONG,AddRef)(THIS) PURE; STDMETHOD_(ULONG,Release)(THIS) PURE; - /* ID3DXMatrixStack methods */ + // + // ID3DXMatrixStack methods + // - /* Pops the top of the stack, returns the current top - * *after* popping the top. */ + // Pops the top of the stack, returns the current top + // *after* popping the top. STDMETHOD(Pop)(THIS) PURE; - /* Pushes the stack by one, duplicating the current matrix. */ + // Pushes the stack by one, duplicating the current matrix. STDMETHOD(Push)(THIS) PURE; - /* Loads identity in the current matrix. */ + // Loads identity in the current matrix. STDMETHOD(LoadIdentity)(THIS) PURE; - /* Loads the given matrix into the current matrix */ + // Loads the given matrix into the current matrix STDMETHOD(LoadMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE; - /* Right-Multiplies the given matrix to the current matrix. - * (transformation is about the current world origin) */ + // Right-Multiplies the given matrix to the current matrix. + // (transformation is about the current world origin) STDMETHOD(MultMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE; - /* Left-Multiplies the given matrix to the current matrix - * (transformation is about the local origin of the object) */ + // Left-Multiplies the given matrix to the current matrix + // (transformation is about the local origin of the object) STDMETHOD(MultMatrixLocal)(THIS_ CONST D3DXMATRIX* pM ) PURE; - /* Right multiply the current matrix with the computed rotation - * matrix, counterclockwise about the given axis with the given angle. - * (rotation is about the current world origin) */ + // Right multiply the current matrix with the computed rotation + // matrix, counterclockwise about the given axis with the given angle. + // (rotation is about the current world origin) STDMETHOD(RotateAxis) (THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE; - /* Left multiply the current matrix with the computed rotation - * matrix, counterclockwise about the given axis with the given angle. - * (rotation is about the local origin of the object) */ + // Left multiply the current matrix with the computed rotation + // matrix, counterclockwise about the given axis with the given angle. + // (rotation is about the local origin of the object) STDMETHOD(RotateAxisLocal) (THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE; - /* Right multiply the current matrix with the computed rotation - * matrix. All angles are counterclockwise. (rotation is about the - * current world origin) + // Right multiply the current matrix with the computed rotation + // matrix. All angles are counterclockwise. (rotation is about the + // current world origin) - * The rotation is composed of a yaw around the Y axis, a pitch around - * the X axis, and a roll around the Z axis. - */ + // The rotation is composed of a yaw around the Y axis, a pitch around + // the X axis, and a roll around the Z axis. STDMETHOD(RotateYawPitchRoll) (THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE; - /* Left multiply the current matrix with the computed rotation - * matrix. All angles are counterclockwise. (rotation is about the - * local origin of the object) + // Left multiply the current matrix with the computed rotation + // matrix. All angles are counterclockwise. (rotation is about the + // local origin of the object) - * The rotation is composed of a yaw around the Y axis, a pitch around - * the X axis, and a roll around the Z axis. - */ + // The rotation is composed of a yaw around the Y axis, a pitch around + // the X axis, and a roll around the Z axis. STDMETHOD(RotateYawPitchRollLocal) (THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE; - /* Right multiply the current matrix with the computed scale - * matrix. (transformation is about the current world origin) */ + // Right multiply the current matrix with the computed scale + // matrix. (transformation is about the current world origin) STDMETHOD(Scale)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; - /* Left multiply the current matrix with the computed scale - * matrix. (transformation is about the local origin of the object) */ + // Left multiply the current matrix with the computed scale + // matrix. (transformation is about the local origin of the object) STDMETHOD(ScaleLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; - /* Right multiply the current matrix with the computed translation - * matrix. (transformation is about the current world origin) */ + // Right multiply the current matrix with the computed translation + // matrix. (transformation is about the current world origin) STDMETHOD(Translate)(THIS_ FLOAT x, FLOAT y, FLOAT z ) PURE; - /* Left multiply the current matrix with the computed translation - * matrix. (transformation is about the local origin of the object) */ + // Left multiply the current matrix with the computed translation + // matrix. (transformation is about the local origin of the object) STDMETHOD(TranslateLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; - /* Obtain the current matrix at the top of the stack */ + // Obtain the current matrix at the top of the stack STDMETHOD_(D3DXMATRIX*, GetTop)(THIS) PURE; }; @@ -1377,27 +1388,30 @@ HRESULT WINAPI } #endif -/* - * - * Spherical Harmonic Runtime Routines - * - * NOTE: - * * Most of these functions can take the same object as in and out parameters. - * The exceptions are the rotation functions. - * - * * Out parameters are typically also returned as return values, so that - * the output of one function may be used as a parameter to another. - */ +//=========================================================================== +// +// Spherical Harmonic Runtime Routines +// +// NOTE: +// * Most of these functions can take the same object as in and out parameters. +// The exceptions are the rotation functions. +// +// * Out parameters are typically also returned as return values, so that +// the output of one function may be used as a parameter to another. +// +//============================================================================ -/* non-inline */ + +// non-inline #ifdef __cplusplus extern "C" { #endif -/* - * - * Basic Spherical Harmonic math routines - */ +//============================================================================ +// +// Basic Spherical Harmonic math routines +// +//============================================================================ #define D3DXSH_MINORDER 2 #define D3DXSH_MAXORDER 6 @@ -1426,10 +1440,12 @@ FLOAT* WINAPI D3DXSHMultiply4( FLOAT *pOut, CONST FLOAT *pF, CONST FLOAT *pG); FLOAT* WINAPI D3DXSHMultiply5( FLOAT *pOut, CONST FLOAT *pF, CONST FLOAT *pG); FLOAT* WINAPI D3DXSHMultiply6( FLOAT *pOut, CONST FLOAT *pF, CONST FLOAT *pG); -/* - * - * Basic Spherical Harmonic lighting routines - */ + +//============================================================================ +// +// Basic Spherical Harmonic lighting routines +// +//============================================================================ HRESULT WINAPI D3DXSHEvalDirectionalLight ( UINT Order, CONST D3DXVECTOR3 *pDir, @@ -1450,29 +1466,31 @@ HRESULT WINAPI D3DXSHEvalHemisphereLight ( UINT Order, CONST D3DXVECTOR3 *pDir, D3DXCOLOR Top, D3DXCOLOR Bottom, FLOAT *pROut, FLOAT *pGOut, FLOAT *pBOut ); -/* - * - * Basic Spherical Harmonic projection routines - */ +//============================================================================ +// +// Basic Spherical Harmonic projection routines +// +//============================================================================ -/* - * - * D3DXSHProjectCubeMap: - * -------------------- - * Projects a function represented on a cube map into spherical harmonics. - * - * Parameters: - * Order - * Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 - * pCubeMap - * CubeMap that is going to be projected into spherical harmonics - * pROut - * Output SH vector for Red. - * pGOut - * Output SH vector for Green - * pBOut - * Output SH vector for Blue - */ +//============================================================================ +// +// D3DXSHProjectCubeMap: +// -------------------- +// Projects a function represented on a cube map into spherical harmonics. +// +// Parameters: +// Order +// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 +// pCubeMap +// CubeMap that is going to be projected into spherical harmonics +// pROut +// Output SH vector for Red. +// pGOut +// Output SH vector for Green +// pBOut +// Output SH vector for Blue +// +//============================================================================ HRESULT WINAPI D3DXSHProjectCubeMap ( UINT uOrder, LPDIRECT3DCUBETEXTURE9 pCubeMap, diff --git a/gfx/include/d3d9/d3dx9math.inl b/gfx/include/d3d9/d3dx9math.inl index 08a408fc7c..1d747453da 100644 --- a/gfx/include/d3d9/d3dx9math.inl +++ b/gfx/include/d3d9/d3dx9math.inl @@ -1,24 +1,26 @@ -/* - * - * Copyright (C) Microsoft Corporation. All Rights Reserved. - * - * File: d3dx9math.inl - * Content: D3DX math inline functions - */ +////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx9math.inl +// Content: D3DX math inline functions +// +////////////////////////////////////////////////////////////////////////////// #ifndef __D3DX9MATH_INL__ #define __D3DX9MATH_INL__ -/* - * - * Inline Class Methods - */ +//=========================================================================== +// +// Inline Class Methods +// +//=========================================================================== #ifdef __cplusplus -/* - * Float16 - */ +//-------------------------- +// Float16 +//-------------------------- D3DXINLINE D3DXFLOAT16::D3DXFLOAT16( FLOAT f ) @@ -32,7 +34,7 @@ D3DXFLOAT16::D3DXFLOAT16( CONST D3DXFLOAT16& f ) value = f.value; } -/* casting */ +// casting D3DXINLINE D3DXFLOAT16::operator FLOAT () { @@ -41,7 +43,7 @@ D3DXFLOAT16::operator FLOAT () return f; } -/* binary operators */ +// binary operators D3DXINLINE BOOL D3DXFLOAT16::operator == ( CONST D3DXFLOAT16& f ) const { @@ -55,9 +57,9 @@ D3DXFLOAT16::operator != ( CONST D3DXFLOAT16& f ) const } -/* - * 2D Vector - */ +//-------------------------- +// 2D Vector +//-------------------------- D3DXINLINE D3DXVECTOR2::D3DXVECTOR2( CONST FLOAT *pf ) @@ -79,7 +81,8 @@ D3DXVECTOR2::D3DXVECTOR2( FLOAT fx, FLOAT fy ) y = fy; } -/* casting */ + +// casting D3DXINLINE D3DXVECTOR2::operator FLOAT* () { @@ -92,7 +95,8 @@ D3DXVECTOR2::operator CONST FLOAT* () const return (CONST FLOAT *) &x; } -/* assignment operators */ + +// assignment operators D3DXINLINE D3DXVECTOR2& D3DXVECTOR2::operator += ( CONST D3DXVECTOR2& v ) { @@ -126,7 +130,8 @@ D3DXVECTOR2::operator /= ( FLOAT f ) return *this; } -/* unary operators */ + +// unary operators D3DXINLINE D3DXVECTOR2 D3DXVECTOR2::operator + () const { @@ -139,7 +144,8 @@ D3DXVECTOR2::operator - () const return D3DXVECTOR2(-x, -y); } -/* binary operators */ + +// binary operators D3DXINLINE D3DXVECTOR2 D3DXVECTOR2::operator + ( CONST D3DXVECTOR2& v ) const { @@ -183,9 +189,11 @@ D3DXVECTOR2::operator != ( CONST D3DXVECTOR2& v ) const return x != v.x || y != v.y; } -/* - * 2D Vector (16 bit) - */ + + +//-------------------------- +// 2D Vector (16 bit) +//-------------------------- D3DXINLINE D3DXVECTOR2_16F::D3DXVECTOR2_16F( CONST FLOAT *pf ) @@ -206,7 +214,8 @@ D3DXVECTOR2_16F::D3DXVECTOR2_16F( CONST D3DXFLOAT16 &fx, CONST D3DXFLOAT16 &fy ) y = fy; } -/* casting */ + +// casting D3DXINLINE D3DXVECTOR2_16F::operator D3DXFLOAT16* () { @@ -219,7 +228,8 @@ D3DXVECTOR2_16F::operator CONST D3DXFLOAT16* () const return (CONST D3DXFLOAT16*) &x; } -/* binary operators */ + +// binary operators D3DXINLINE BOOL D3DXVECTOR2_16F::operator == ( CONST D3DXVECTOR2_16F &v ) const { @@ -233,9 +243,9 @@ D3DXVECTOR2_16F::operator != ( CONST D3DXVECTOR2_16F &v ) const } -/* - * 3D Vector - */ +//-------------------------- +// 3D Vector +//-------------------------- D3DXINLINE D3DXVECTOR3::D3DXVECTOR3( CONST FLOAT *pf ) { @@ -266,7 +276,8 @@ D3DXVECTOR3::D3DXVECTOR3( FLOAT fx, FLOAT fy, FLOAT fz ) z = fz; } -/* casting */ + +// casting D3DXINLINE D3DXVECTOR3::operator FLOAT* () { @@ -279,7 +290,8 @@ D3DXVECTOR3::operator CONST FLOAT* () const return (CONST FLOAT *) &x; } -/* assignment operators */ + +// assignment operators D3DXINLINE D3DXVECTOR3& D3DXVECTOR3::operator += ( CONST D3DXVECTOR3& v ) { @@ -317,7 +329,8 @@ D3DXVECTOR3::operator /= ( FLOAT f ) return *this; } -/* unary operators */ + +// unary operators D3DXINLINE D3DXVECTOR3 D3DXVECTOR3::operator + () const { @@ -330,7 +343,8 @@ D3DXVECTOR3::operator - () const return D3DXVECTOR3(-x, -y, -z); } -/* binary operators */ + +// binary operators D3DXINLINE D3DXVECTOR3 D3DXVECTOR3::operator + ( CONST D3DXVECTOR3& v ) const { @@ -376,9 +390,11 @@ D3DXVECTOR3::operator != ( CONST D3DXVECTOR3& v ) const return x != v.x || y != v.y || z != v.z; } -/* - * 3D Vector (16 bit) - */ + + +//-------------------------- +// 3D Vector (16 bit) +//-------------------------- D3DXINLINE D3DXVECTOR3_16F::D3DXVECTOR3_16F( CONST FLOAT *pf ) @@ -409,7 +425,8 @@ D3DXVECTOR3_16F::D3DXVECTOR3_16F( CONST D3DXFLOAT16 &fx, CONST D3DXFLOAT16 &fy, z = fz; } -/* casting */ + +// casting D3DXINLINE D3DXVECTOR3_16F::operator D3DXFLOAT16* () { @@ -422,7 +439,8 @@ D3DXVECTOR3_16F::operator CONST D3DXFLOAT16* () const return (CONST D3DXFLOAT16*) &x; } -/* binary operators */ + +// binary operators D3DXINLINE BOOL D3DXVECTOR3_16F::operator == ( CONST D3DXVECTOR3_16F &v ) const { @@ -438,9 +456,9 @@ D3DXVECTOR3_16F::operator != ( CONST D3DXVECTOR3_16F &v ) const } -/* - * 4D Vector - */ +//-------------------------- +// 4D Vector +//-------------------------- D3DXINLINE D3DXVECTOR4::D3DXVECTOR4( CONST FLOAT *pf ) { @@ -474,7 +492,8 @@ D3DXVECTOR4::D3DXVECTOR4( FLOAT fx, FLOAT fy, FLOAT fz, FLOAT fw ) w = fw; } -/* casting */ + +// casting D3DXINLINE D3DXVECTOR4::operator FLOAT* () { @@ -487,7 +506,8 @@ D3DXVECTOR4::operator CONST FLOAT* () const return (CONST FLOAT *) &x; } -/* assignment operators */ + +// assignment operators D3DXINLINE D3DXVECTOR4& D3DXVECTOR4::operator += ( CONST D3DXVECTOR4& v ) { @@ -529,7 +549,8 @@ D3DXVECTOR4::operator /= ( FLOAT f ) return *this; } -/* unary operators */ + +// unary operators D3DXINLINE D3DXVECTOR4 D3DXVECTOR4::operator + () const { @@ -542,7 +563,8 @@ D3DXVECTOR4::operator - () const return D3DXVECTOR4(-x, -y, -z, -w); } -/* binary operators */ + +// binary operators D3DXINLINE D3DXVECTOR4 D3DXVECTOR4::operator + ( CONST D3DXVECTOR4& v ) const { @@ -587,9 +609,11 @@ D3DXVECTOR4::operator != ( CONST D3DXVECTOR4& v ) const return x != v.x || y != v.y || z != v.z || w != v.w; } -/* - * 4D Vector (16 bit) - */ + + +//-------------------------- +// 4D Vector (16 bit) +//-------------------------- D3DXINLINE D3DXVECTOR4_16F::D3DXVECTOR4_16F( CONST FLOAT *pf ) @@ -622,7 +646,8 @@ D3DXVECTOR4_16F::D3DXVECTOR4_16F( CONST D3DXFLOAT16 &fx, CONST D3DXFLOAT16 &fy, w = fw; } -/* casting */ + +// casting D3DXINLINE D3DXVECTOR4_16F::operator D3DXFLOAT16* () { @@ -635,7 +660,8 @@ D3DXVECTOR4_16F::operator CONST D3DXFLOAT16* () const return (CONST D3DXFLOAT16*) &x; } -/* binary operators */ + +// binary operators D3DXINLINE BOOL D3DXVECTOR4_16F::operator == ( CONST D3DXVECTOR4_16F &v ) const { @@ -651,9 +677,9 @@ D3DXVECTOR4_16F::operator != ( CONST D3DXVECTOR4_16F &v ) const } -/* - * Matrix - */ +//-------------------------- +// Matrix +//-------------------------- D3DXINLINE D3DXMATRIX::D3DXMATRIX( CONST FLOAT* pf ) { @@ -684,7 +710,9 @@ D3DXMATRIX::D3DXMATRIX( FLOAT f11, FLOAT f12, FLOAT f13, FLOAT f14, _41 = f41; _42 = f42; _43 = f43; _44 = f44; } -/* access grants */ + + +// access grants D3DXINLINE FLOAT& D3DXMATRIX::operator () ( UINT iRow, UINT iCol ) { @@ -697,7 +725,8 @@ D3DXMATRIX::operator () ( UINT iRow, UINT iCol ) const return m[iRow][iCol]; } -/* casting operators */ + +// casting operators D3DXINLINE D3DXMATRIX::operator FLOAT* () { @@ -710,7 +739,8 @@ D3DXMATRIX::operator CONST FLOAT* () const return (CONST FLOAT *) &_11; } -/* assignment operators */ + +// assignment operators D3DXINLINE D3DXMATRIX& D3DXMATRIX::operator *= ( CONST D3DXMATRIX& mat ) { @@ -759,7 +789,8 @@ D3DXMATRIX::operator /= ( FLOAT f ) return *this; } -/* unary operators */ + +// unary operators D3DXINLINE D3DXMATRIX D3DXMATRIX::operator + () const { @@ -775,7 +806,8 @@ D3DXMATRIX::operator - () const -_41, -_42, -_43, -_44); } -/* binary operators */ + +// binary operators D3DXINLINE D3DXMATRIX D3DXMATRIX::operator * ( CONST D3DXMATRIX& mat ) const { @@ -844,9 +876,11 @@ D3DXMATRIX::operator != ( CONST D3DXMATRIX& mat ) const return 0 != memcmp(this, &mat, sizeof(D3DXMATRIX)); } -/* - * Aligned Matrices - */ + + +//-------------------------- +// Aligned Matrices +//-------------------------- D3DXINLINE _D3DXMATRIXA16::_D3DXMATRIXA16( CONST FLOAT* f ) : @@ -941,9 +975,10 @@ _D3DXMATRIXA16::operator=(CONST D3DXMATRIX& rhs) return *this; } -/* - * Quaternion - */ + +//-------------------------- +// Quaternion +//-------------------------- D3DXINLINE D3DXQUATERNION::D3DXQUATERNION( CONST FLOAT* pf ) @@ -969,7 +1004,8 @@ D3DXQUATERNION::D3DXQUATERNION( FLOAT fx, FLOAT fy, FLOAT fz, FLOAT fw ) w = fw; } -/* casting */ + +// casting D3DXINLINE D3DXQUATERNION::operator FLOAT* () { @@ -982,7 +1018,8 @@ D3DXQUATERNION::operator CONST FLOAT* () const return (CONST FLOAT *) &x; } -/* assignment operators */ + +// assignment operators D3DXINLINE D3DXQUATERNION& D3DXQUATERNION::operator += ( CONST D3DXQUATERNION& q ) { @@ -1031,7 +1068,8 @@ D3DXQUATERNION::operator /= ( FLOAT f ) return *this; } -/* unary operators */ + +// unary operators D3DXINLINE D3DXQUATERNION D3DXQUATERNION::operator + () const { @@ -1044,7 +1082,8 @@ D3DXQUATERNION::operator - () const return D3DXQUATERNION(-x, -y, -z, -w); } -/* binary operators */ + +// binary operators D3DXINLINE D3DXQUATERNION D3DXQUATERNION::operator + ( CONST D3DXQUATERNION& q ) const { @@ -1098,9 +1137,11 @@ D3DXQUATERNION::operator != ( CONST D3DXQUATERNION& q ) const return x != q.x || y != q.y || z != q.z || w != q.w; } -/* - * Plane - */ + + +//-------------------------- +// Plane +//-------------------------- D3DXINLINE D3DXPLANE::D3DXPLANE( CONST FLOAT* pf ) @@ -1126,7 +1167,8 @@ D3DXPLANE::D3DXPLANE( FLOAT fa, FLOAT fb, FLOAT fc, FLOAT fd ) d = fd; } -/* casting */ + +// casting D3DXINLINE D3DXPLANE::operator FLOAT* () { @@ -1139,7 +1181,8 @@ D3DXPLANE::operator CONST FLOAT* () const return (CONST FLOAT *) &a; } -/* assignment operators */ + +// assignment operators D3DXINLINE D3DXPLANE& D3DXPLANE::operator *= ( FLOAT f ) { @@ -1161,7 +1204,8 @@ D3DXPLANE::operator /= ( FLOAT f ) return *this; } -/* unary operators */ + +// unary operators D3DXINLINE D3DXPLANE D3DXPLANE::operator + () const { @@ -1174,7 +1218,8 @@ D3DXPLANE::operator - () const return D3DXPLANE(-a, -b, -c, -d); } -/* binary operators */ + +// binary operators D3DXINLINE D3DXPLANE D3DXPLANE::operator * ( FLOAT f ) const { @@ -1206,9 +1251,12 @@ D3DXPLANE::operator != ( CONST D3DXPLANE& p ) const return a != p.a || b != p.b || c != p.c || d != p.d; } -/* - * Color - */ + + + +//-------------------------- +// Color +//-------------------------- D3DXINLINE D3DXCOLOR::D3DXCOLOR( DWORD dw ) @@ -1253,7 +1301,8 @@ D3DXCOLOR::D3DXCOLOR( FLOAT fr, FLOAT fg, FLOAT fb, FLOAT fa ) a = fa; } -/* casting */ + +// casting D3DXINLINE D3DXCOLOR::operator DWORD () const { @@ -1304,7 +1353,8 @@ D3DXCOLOR::operator CONST D3DCOLORVALUE& () const return *((CONST D3DCOLORVALUE *) &r); } -/* assignment operators */ + +// assignment operators D3DXINLINE D3DXCOLOR& D3DXCOLOR::operator += ( CONST D3DXCOLOR& c ) { @@ -1346,7 +1396,8 @@ D3DXCOLOR::operator /= ( FLOAT f ) return *this; } -/* unary operators */ + +// unary operators D3DXINLINE D3DXCOLOR D3DXCOLOR::operator + () const { @@ -1359,7 +1410,8 @@ D3DXCOLOR::operator - () const return D3DXCOLOR(-r, -g, -b, -a); } -/* binary operators */ + +// binary operators D3DXINLINE D3DXCOLOR D3DXCOLOR::operator + ( CONST D3DXCOLOR& c ) const { @@ -1406,17 +1458,20 @@ D3DXCOLOR::operator != ( CONST D3DXCOLOR& c ) const } -#endif /*__cplusplus */ - -/* - * - * Inline functions - */ +#endif //__cplusplus -/* - * 2D Vector - */ + +//=========================================================================== +// +// Inline functions +// +//=========================================================================== + + +//-------------------------- +// 2D Vector +//-------------------------- D3DXINLINE FLOAT D3DXVec2Length ( CONST D3DXVECTOR2 *pV ) @@ -1495,9 +1550,10 @@ D3DXINLINE D3DXVECTOR2* D3DXVec2Lerp return pOut; } -/* - * 3D Vector - */ + +//-------------------------- +// 3D Vector +//-------------------------- D3DXINLINE FLOAT D3DXVec3Length ( CONST D3DXVECTOR3 *pV ) @@ -1590,9 +1646,9 @@ D3DXINLINE D3DXVECTOR3* D3DXVec3Lerp } -/* - * 4D Vector - */ +//-------------------------- +// 4D Vector +//-------------------------- D3DXINLINE FLOAT D3DXVec4Length ( CONST D3DXVECTOR4 *pV ) @@ -1678,9 +1734,9 @@ D3DXINLINE D3DXVECTOR4* D3DXVec4Lerp } -/* - * 4D Matrix - */ +//-------------------------- +// 4D Matrix +//-------------------------- D3DXINLINE D3DXMATRIX* D3DXMatrixIdentity ( D3DXMATRIX *pOut ) @@ -1705,9 +1761,9 @@ D3DXINLINE BOOL D3DXMatrixIsIdentity } -/* - * Quaternion - */ +//-------------------------- +// Quaternion +//-------------------------- D3DXINLINE FLOAT D3DXQuaternionLength ( CONST D3DXQUATERNION *pQ ) @@ -1757,9 +1813,10 @@ D3DXINLINE D3DXQUATERNION* D3DXQuaternionConjugate return pOut; } -/* - * Plane - */ + +//-------------------------- +// Plane +//-------------------------- D3DXINLINE FLOAT D3DXPlaneDot ( CONST D3DXPLANE *pP, CONST D3DXVECTOR4 *pV) @@ -1790,9 +1847,9 @@ D3DXINLINE D3DXPLANE* D3DXPlaneScale } -/* - * Color - */ +//-------------------------- +// Color +//-------------------------- D3DXINLINE D3DXCOLOR* D3DXColorNegative (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC) @@ -1855,4 +1912,4 @@ D3DXINLINE D3DXCOLOR* D3DXColorLerp } -#endif /* __D3DX9MATH_INL__ */ +#endif // __D3DX9MATH_INL__ diff --git a/gfx/include/d3d9/d3dx9xof.h b/gfx/include/d3d9/d3dx9xof.h index 1e0a249e37..b581e0c858 100644 --- a/gfx/include/d3d9/d3dx9xof.h +++ b/gfx/include/d3d9/d3dx9xof.h @@ -34,59 +34,59 @@ typedef DWORD D3DXF_FILELOADOPTIONS; #define D3DXF_FILELOAD_FROMRESOURCE 0x02L #define D3DXF_FILELOAD_FROMMEMORY 0x03L -/* - * D3DXF_FILELOADRESOURCE: -*/ +//---------------------------------------------------------------------------- +// D3DXF_FILELOADRESOURCE: +//---------------------------------------------------------------------------- typedef struct _D3DXF_FILELOADRESOURCE { - HMODULE hModule; /* Desc */ - LPCSTR lpName; /* Desc */ - LPCSTR lpType; /* Desc */ + HMODULE hModule; // Desc + LPCSTR lpName; // Desc + LPCSTR lpType; // Desc } D3DXF_FILELOADRESOURCE; -/* - * D3DXF_FILELOADMEMORY: - */ +//---------------------------------------------------------------------------- +// D3DXF_FILELOADMEMORY: +//---------------------------------------------------------------------------- typedef struct _D3DXF_FILELOADMEMORY { - LPCVOID lpMemory; /* Desc */ - SIZE_T dSize; /* Desc */ + LPCVOID lpMemory; // Desc + SIZE_T dSize; // Desc } D3DXF_FILELOADMEMORY; #if defined( _WIN32 ) && !defined( _NO_COM ) -/* {cef08cf9-7b4f-4429-9624-2a690a933201} */ +// {cef08cf9-7b4f-4429-9624-2a690a933201} DEFINE_GUID( IID_ID3DXFile, 0xcef08cf9, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); -/* {cef08cfa-7b4f-4429-9624-2a690a933201} */ +// {cef08cfa-7b4f-4429-9624-2a690a933201} DEFINE_GUID( IID_ID3DXFileSaveObject, 0xcef08cfa, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); -/* {cef08cfb-7b4f-4429-9624-2a690a933201} */ +// {cef08cfb-7b4f-4429-9624-2a690a933201} DEFINE_GUID( IID_ID3DXFileSaveData, 0xcef08cfb, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); -/* {cef08cfc-7b4f-4429-9624-2a690a933201} */ +// {cef08cfc-7b4f-4429-9624-2a690a933201} DEFINE_GUID( IID_ID3DXFileEnumObject, 0xcef08cfc, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); -/* {cef08cfd-7b4f-4429-9624-2a690a933201} */ +// {cef08cfd-7b4f-4429-9624-2a690a933201} DEFINE_GUID( IID_ID3DXFileData, 0xcef08cfd, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); -#endif /* defined( _WIN32 ) && !defined( _NO_COM ) */ +#endif // defined( _WIN32 ) && !defined( _NO_COM ) #if defined( __cplusplus ) #if !defined( DECLSPEC_UUID ) #if _MSC_VER >= 1100 #define DECLSPEC_UUID( x ) __declspec( uuid( x ) ) -#else /* !( _MSC_VER >= 1100 ) */ +#else // !( _MSC_VER >= 1100 ) #define DECLSPEC_UUID( x ) -#endif /* !( _MSC_VER >= 1100 ) */ -#endif /* !defined( DECLSPEC_UUID ) */ +#endif // !( _MSC_VER >= 1100 ) +#endif // !defined( DECLSPEC_UUID ) interface DECLSPEC_UUID( "cef08cf9-7b4f-4429-9624-2a690a933201" ) ID3DXFile; @@ -110,8 +110,8 @@ _COM_SMARTPTR_TYPEDEF( ID3DXFileEnumObject, __uuidof( ID3DXFileEnumObject ) ); _COM_SMARTPTR_TYPEDEF( ID3DXFileData, __uuidof( ID3DXFileData ) ); -#endif /* defined( _COM_SMARTPTR_TYPEDEF ) */ -#endif /* defined( __cplusplus ) */ +#endif // defined( _COM_SMARTPTR_TYPEDEF ) +#endif // defined( __cplusplus ) typedef interface ID3DXFile ID3DXFile; typedef interface ID3DXFileSaveObject ID3DXFileSaveObject; @@ -119,9 +119,9 @@ typedef interface ID3DXFileSaveData ID3DXFileSaveData; typedef interface ID3DXFileEnumObject ID3DXFileEnumObject; typedef interface ID3DXFileData ID3DXFileData; -/* - * ID3DXFile - */ +////////////////////////////////////////////////////////////////////////////// +// ID3DXFile ///////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// #undef INTERFACE #define INTERFACE ID3DXFile @@ -140,9 +140,9 @@ DECLARE_INTERFACE_( ID3DXFile, IUnknown ) STDMETHOD( RegisterEnumTemplates )( THIS_ ID3DXFileEnumObject* ) PURE; }; -/* - * ID3DXFileSaveObject - */ +////////////////////////////////////////////////////////////////////////////// +// ID3DXFileSaveObject /////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// #undef INTERFACE #define INTERFACE ID3DXFileSaveObject @@ -159,9 +159,9 @@ DECLARE_INTERFACE_( ID3DXFileSaveObject, IUnknown ) STDMETHOD( Save )( THIS ) PURE; }; -/* - * ID3DXFileSaveData - */ +////////////////////////////////////////////////////////////////////////////// +// ID3DXFileSaveData ///////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// #undef INTERFACE #define INTERFACE ID3DXFileSaveData @@ -181,9 +181,9 @@ DECLARE_INTERFACE_( ID3DXFileSaveData, IUnknown ) STDMETHOD( AddDataReference )( THIS_ LPCSTR, CONST GUID* ) PURE; }; -/* - * ID3DXFileEnumObject - */ +////////////////////////////////////////////////////////////////////////////// +// ID3DXFileEnumObject /////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// #undef INTERFACE #define INTERFACE ID3DXFileEnumObject @@ -201,9 +201,9 @@ DECLARE_INTERFACE_( ID3DXFileEnumObject, IUnknown ) STDMETHOD( GetDataObjectByName )( THIS_ LPCSTR, ID3DXFileData** ) PURE; }; -/* - * ID3DXFileData - */ +////////////////////////////////////////////////////////////////////////////// +// ID3DXFileData ///////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// #undef INTERFACE #define INTERFACE ID3DXFileData diff --git a/menu/drivers_display/menu_display_d3d11.c b/menu/drivers_display/menu_display_d3d11.c index 2dfb3aca2e..15318c4ee9 100644 --- a/menu/drivers_display/menu_display_d3d11.c +++ b/menu/drivers_display/menu_display_d3d11.c @@ -26,20 +26,11 @@ #include "../../gfx/video_driver.h" #include "../../gfx/common/d3d11_common.h" -static const float* menu_display_d3d11_get_default_vertices(void) -{ - return NULL; -} +static const float* menu_display_d3d11_get_default_vertices(void) { return NULL; } -static const float* menu_display_d3d11_get_default_tex_coords(void) -{ - return NULL; -} +static const float* menu_display_d3d11_get_default_tex_coords(void) { return NULL; } -static void* menu_display_d3d11_get_default_mvp(void) -{ - return NULL; -} +static void* menu_display_d3d11_get_default_mvp(void) { return NULL; } static void menu_display_d3d11_blend_begin(void) { @@ -53,9 +44,7 @@ static void menu_display_d3d11_blend_end(void) D3D11SetBlendState(d3d11->ctx, d3d11->blend_disable, NULL, D3D11_DEFAULT_SAMPLE_MASK); } -static void menu_display_d3d11_viewport(void* data) -{ -} +static void menu_display_d3d11_viewport(void* data) {} static void menu_display_d3d11_draw(void* data) { @@ -91,17 +80,14 @@ static void menu_display_d3d11_draw(void* data) { D3D11_MAPPED_SUBRESOURCE mapped_vbo; - d3d11_sprite_t *v = NULL; - D3D11MapBuffer( d3d11->ctx, d3d11->sprites.vbo, 0, D3D11_MAP_WRITE_NO_OVERWRITE, 0, &mapped_vbo); + d3d11_sprite_t* v = (d3d11_sprite_t*)mapped_vbo.pData + d3d11->sprites.offset; - v = (d3d11_sprite_t*)mapped_vbo.pData + d3d11->sprites.offset; - - v->pos.x = draw->x / (float)d3d11->viewport.Width; - v->pos.y = (d3d11->viewport.Height - draw->y - draw->height) / (float)d3d11->viewport.Height; - v->pos.w = draw->width / (float)d3d11->viewport.Width; - v->pos.h = draw->height / (float)d3d11->viewport.Height; + v->pos.x = draw->x / (float)d3d11->viewport.Width; + v->pos.y = (d3d11->viewport.Height - draw->y - draw->height) / (float)d3d11->viewport.Height; + v->pos.w = draw->width / (float)d3d11->viewport.Width; + v->pos.h = draw->height / (float)d3d11->viewport.Height; v->coords.u = 0.0f; v->coords.v = 0.0f; @@ -131,18 +117,19 @@ static void menu_display_d3d11_draw(void* data) D3D11UnmapBuffer(d3d11->ctx, d3d11->sprites.vbo, 0); } - d3d11_set_texture_and_sampler(d3d11->ctx, 0, - (d3d11_texture_t*)draw->texture); + d3d11_set_texture_and_sampler(d3d11->ctx, 0, (d3d11_texture_t*)draw->texture); D3D11Draw(d3d11->ctx, 1, d3d11->sprites.offset); d3d11->sprites.offset++; + return; } static void menu_display_d3d11_draw_pipeline(void* data) { - video_coord_array_t *ca = NULL; menu_display_ctx_draw_t* draw = (menu_display_ctx_draw_t*)data; d3d11_video_t* d3d11 = (d3d11_video_t*)video_driver_get_ptr(false); + video_coord_array_t* ca = NULL; + if (!d3d11 || !draw) return; @@ -150,6 +137,7 @@ static void menu_display_d3d11_draw_pipeline(void* data) { case VIDEO_SHADER_MENU: case VIDEO_SHADER_MENU_2: + { ca = menu_display_get_coords_array(); if (!d3d11->menu_pipeline_vbo) @@ -166,6 +154,7 @@ static void menu_display_d3d11_draw_pipeline(void* data) draw->coords->vertices = ca->coords.vertices; D3D11SetBlendState(d3d11->ctx, d3d11->blend_pipeline, NULL, D3D11_DEFAULT_SAMPLE_MASK); break; + } case VIDEO_SHADER_MENU_3: case VIDEO_SHADER_MENU_4: @@ -189,9 +178,7 @@ static void menu_display_d3d11_draw_pipeline(void* data) } } -static void menu_display_d3d11_restore_clear_color(void) -{ -} +static void menu_display_d3d11_restore_clear_color(void) {} static void menu_display_d3d11_clear_color(menu_display_ctx_clearcolor_t* clearcolor) { From dac1f10708a733187e6488fc621e5c414eba2848 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 3 Feb 2018 15:16:04 +0100 Subject: [PATCH 034/232] C89_BUILD fixes --- gfx/drivers/d3d11.c | 188 ++++++++++++---------- menu/drivers_display/menu_display_d3d11.c | 10 +- 2 files changed, 108 insertions(+), 90 deletions(-) diff --git a/gfx/drivers/d3d11.c b/gfx/drivers/d3d11.c index fdff674aca..11ffbd7175 100644 --- a/gfx/drivers/d3d11.c +++ b/gfx/drivers/d3d11.c @@ -37,9 +37,10 @@ static void d3d11_set_filtering(void* data, unsigned index, bool smooth) { + unsigned i; d3d11_video_t* d3d11 = (d3d11_video_t*)data; - for (int i = 0; i < RARCH_WRAP_MAX; i++) + for (i = 0; i < RARCH_WRAP_MAX; i++) { if (smooth) d3d11->samplers[RARCH_FILTER_UNSPEC][i] = d3d11->samplers[RARCH_FILTER_LINEAR][i]; @@ -92,11 +93,14 @@ static void d3d11_update_viewport(void* data, bool force_full) static void d3d11_free_shader_preset(d3d11_video_t* d3d11) { + unsigned i; if (!d3d11->shader_preset) return; - for (int i = 0; i < d3d11->shader_preset->passes; i++) + for (i = 0; i < d3d11->shader_preset->passes; i++) { + unsigned j; + free(d3d11->shader_preset->pass[i].source.string.vertex); free(d3d11->shader_preset->pass[i].source.string.fragment); free(d3d11->pass[i].semantics.textures); @@ -104,7 +108,7 @@ static void d3d11_free_shader_preset(d3d11_video_t* d3d11) d3d11_release_texture(&d3d11->pass[i].rt); d3d11_release_texture(&d3d11->pass[i].feedback); - for (int j = 0; j < SLANG_CBUFFER_MAX; j++) + for (j = 0; j < SLANG_CBUFFER_MAX; j++) { free(d3d11->pass[i].semantics.cbuffers[j].uniforms); Release(d3d11->pass[i].buffers[j]); @@ -114,14 +118,14 @@ static void d3d11_free_shader_preset(d3d11_video_t* d3d11) memset(d3d11->pass, 0, sizeof(d3d11->pass)); /* only free the history textures here */ - for (int i = 1; i <= d3d11->shader_preset->history_size; i++) + for (i = 1; i <= d3d11->shader_preset->history_size; i++) d3d11_release_texture(&d3d11->frame.texture[i]); memset( &d3d11->frame.texture[1], 0, sizeof(d3d11->frame.texture[1]) * d3d11->shader_preset->history_size); - for (int i = 0; i < d3d11->shader_preset->luts; i++) + for (i = 0; i < d3d11->shader_preset->luts; i++) d3d11_release_texture(&d3d11->luts[i]); memset(d3d11->luts, 0, sizeof(d3d11->luts)); @@ -134,6 +138,7 @@ static void d3d11_free_shader_preset(d3d11_video_t* d3d11) static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const char* path) { + unsigned i; d3d11_video_t* d3d11 = (d3d11_video_t*)data; if (!d3d11) @@ -165,79 +170,76 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const d3d11_texture_t* source = &d3d11->frame.texture[0]; - for (int i = 0; i < d3d11->shader_preset->passes; source = &d3d11->pass[i++].rt) + for (i = 0; i < d3d11->shader_preset->passes; source = &d3d11->pass[i++].rt) { - { - texture_map_t texture_map - [3 + GFX_MAX_FRAME_HISTORY + 1 + GFX_MAX_SHADERS * 2 + GFX_MAX_TEXTURES + 1] = { - SL_TEXTURE_MAP( - SLANG_TEXTURE_SEMANTIC_ORIGINAL, d3d11->frame.texture[0].view, - d3d11->pass[i].sampler, d3d11->frame.texture[0].size_data), - SL_TEXTURE_MAP( - SLANG_TEXTURE_SEMANTIC_SOURCE, source->view, d3d11->pass[i].sampler, - source->size_data), - }; - - { - texture_map_t* ptr = texture_map; - while (ptr->texture_data) - ptr++; - - for (int j = 0; j < GFX_MAX_FRAME_HISTORY + 1; j++) - { - *ptr = (texture_map_t)SL_TEXTURE_MAP_ARRAY( - SLANG_TEXTURE_SEMANTIC_ORIGINAL_HISTORY, j, d3d11->frame.texture[j].view, - d3d11->pass[i].sampler, d3d11->frame.texture[j].size_data); - ptr++; - } - - for (int j = 0; j < i; j++) - { - *ptr = (texture_map_t)SL_TEXTURE_MAP_ARRAY( - SLANG_TEXTURE_SEMANTIC_PASS_OUTPUT, j, d3d11->pass[j].rt.view, - d3d11->pass[i].sampler, d3d11->pass[j].rt.size_data); - ptr++; - } - - for (int j = 0; j < GFX_MAX_SHADERS; j++) - { - *ptr = (texture_map_t)SL_TEXTURE_MAP_ARRAY( - SLANG_TEXTURE_SEMANTIC_PASS_FEEDBACK, j, d3d11->pass[j].feedback.view, - d3d11->pass[i].sampler, d3d11->pass[j].rt.size_data); - ptr++; - } - - for (int j = 0; j < d3d11->shader_preset->luts; j++) - { - *ptr = (texture_map_t)SL_TEXTURE_MAP_ARRAY( - SLANG_TEXTURE_SEMANTIC_USER, j, d3d11->luts[j].view, d3d11->luts[j].sampler, - d3d11->luts[j].size_data); - ptr++; - } - } - - uniform_map_t uniform_map[] = { - SL_UNIFORM_MAP(SLANG_SEMANTIC_MVP, d3d11->mvp), - SL_UNIFORM_MAP(SLANG_SEMANTIC_OUTPUT, d3d11->pass[i].rt.size_data), - SL_UNIFORM_MAP(SLANG_SEMANTIC_FRAME_COUNT, d3d11->pass[i].frame_count), - SL_UNIFORM_MAP(SLANG_SEMANTIC_FINAL_VIEWPORT, d3d11->frame.output_size), - { 0 } + unsigned j; + texture_map_t texture_map + [3 + GFX_MAX_FRAME_HISTORY + 1 + GFX_MAX_SHADERS * 2 + GFX_MAX_TEXTURES + 1] = { + SL_TEXTURE_MAP( + SLANG_TEXTURE_SEMANTIC_ORIGINAL, d3d11->frame.texture[0].view, + d3d11->pass[i].sampler, d3d11->frame.texture[0].size_data), + SL_TEXTURE_MAP( + SLANG_TEXTURE_SEMANTIC_SOURCE, source->view, d3d11->pass[i].sampler, + source->size_data), }; + texture_map_t* ptr = texture_map; - semantics_map_t semantics_map = { texture_map, uniform_map }; + while (ptr->texture_data) + ptr++; - if (!slang_process( - d3d11->shader_preset, i, RARCH_SHADER_HLSL, 50, &semantics_map, - &d3d11->pass[i].semantics)) - goto error; + for (j = 0; j < GFX_MAX_FRAME_HISTORY + 1; j++) + { + *ptr = (texture_map_t)SL_TEXTURE_MAP_ARRAY( + SLANG_TEXTURE_SEMANTIC_ORIGINAL_HISTORY, j, d3d11->frame.texture[j].view, + d3d11->pass[i].sampler, d3d11->frame.texture[j].size_data); + ptr++; } + for (j = 0; j < i; j++) + { + *ptr = (texture_map_t)SL_TEXTURE_MAP_ARRAY( + SLANG_TEXTURE_SEMANTIC_PASS_OUTPUT, j, d3d11->pass[j].rt.view, + d3d11->pass[i].sampler, d3d11->pass[j].rt.size_data); + ptr++; + } + + for (j = 0; j < GFX_MAX_SHADERS; j++) + { + *ptr = (texture_map_t)SL_TEXTURE_MAP_ARRAY( + SLANG_TEXTURE_SEMANTIC_PASS_FEEDBACK, j, d3d11->pass[j].feedback.view, + d3d11->pass[i].sampler, d3d11->pass[j].rt.size_data); + ptr++; + } + + for (j = 0; j < d3d11->shader_preset->luts; j++) + { + *ptr = (texture_map_t)SL_TEXTURE_MAP_ARRAY( + SLANG_TEXTURE_SEMANTIC_USER, j, d3d11->luts[j].view, d3d11->luts[j].sampler, + d3d11->luts[j].size_data); + ptr++; + } + + uniform_map_t uniform_map[] = { + SL_UNIFORM_MAP(SLANG_SEMANTIC_MVP, d3d11->mvp), + SL_UNIFORM_MAP(SLANG_SEMANTIC_OUTPUT, d3d11->pass[i].rt.size_data), + SL_UNIFORM_MAP(SLANG_SEMANTIC_FRAME_COUNT, d3d11->pass[i].frame_count), + SL_UNIFORM_MAP(SLANG_SEMANTIC_FINAL_VIEWPORT, d3d11->frame.output_size), + { 0 } + }; + + semantics_map_t semantics_map = { texture_map, uniform_map }; + + if (!slang_process( + d3d11->shader_preset, i, RARCH_SHADER_HLSL, 50, &semantics_map, + &d3d11->pass[i].semantics)) + goto error; + { static const D3D11_INPUT_ELEMENT_DESC desc[] = { { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, offsetof(d3d11_vertex_t, position), - D3D11_INPUT_PER_VERTEX_DATA, 0 }, + D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "TEXCOORD", 1, DXGI_FORMAT_R32G32_FLOAT, 0, offsetof(d3d11_vertex_t, texcoord), - D3D11_INPUT_PER_VERTEX_DATA, 0 }, + D3D11_INPUT_PER_VERTEX_DATA, 0 }, }; #ifdef DEBUG bool save_hlsl = true; @@ -262,13 +264,13 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const strncpy(ps_path + base_len, ps_ext, sizeof(ps_ext)); if (!d3d11_init_shader( - d3d11->device, vs_src, 0, vs_path, "main", NULL, NULL, desc, countof(desc), - &d3d11->pass[i].shader)) + d3d11->device, vs_src, 0, vs_path, "main", NULL, NULL, desc, countof(desc), + &d3d11->pass[i].shader)) save_hlsl = true; if (!d3d11_init_shader( - d3d11->device, ps_src, 0, ps_path, NULL, "main", NULL, NULL, 0, - &d3d11->pass[i].shader)) + d3d11->device, ps_src, 0, ps_path, NULL, "main", NULL, NULL, 0, + &d3d11->pass[i].shader)) save_hlsl = true; if (save_hlsl) @@ -292,7 +294,7 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const goto error; } - for (int j = 0; j < SLANG_CBUFFER_MAX; j++) + for (j = 0; j < SLANG_CBUFFER_MAX; j++) { D3D11_BUFFER_DESC desc = { .ByteWidth = d3d11->pass[i].semantics.cbuffers[j].size, @@ -308,7 +310,7 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const } } - for (int i = 0; i < d3d11->shader_preset->luts; i++) + for (i = 0; i < d3d11->shader_preset->luts; i++) { struct texture_image image = { 0 }; image.supports_rgba = true; @@ -350,6 +352,7 @@ error: static void d3d11_gfx_free(void* data) { + unsigned i; d3d11_video_t* d3d11 = (d3d11_video_t*)data; if (!d3d11) @@ -384,7 +387,7 @@ static void d3d11_gfx_free(void* data) Release(d3d11->blend_enable); Release(d3d11->blend_disable); - for (int i = 0; i < RARCH_WRAP_MAX; i++) + for (i = 0; i < RARCH_WRAP_MAX; i++) { Release(d3d11->samplers[RARCH_FILTER_LINEAR][i]); Release(d3d11->samplers[RARCH_FILTER_NEAREST][i]); @@ -407,6 +410,7 @@ static void d3d11_gfx_free(void* data) static void* d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** input_data) { + unsigned i; WNDCLASSEX wndclass = { 0 }; MONITORINFOEX current_mon; HMONITOR hm_to_use; @@ -521,7 +525,7 @@ d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** i .MaxLOD = D3D11_FLOAT32_MAX, }; /* Initialize samplers */ - for (int i = 0; i < RARCH_WRAP_MAX; i++) + for (i = 0; i < RARCH_WRAP_MAX; i++) { switch (i) { @@ -749,12 +753,14 @@ error: static void d3d11_init_history(d3d11_video_t* d3d11, unsigned width, unsigned height) { + unsigned i; + /* todo: should we init history to max_width/max_height instead ? * to prevent out of memory errors happening several frames later * and to reduce memory fragmentation */ assert(d3d11->shader_preset); - for (int i = 0; i < d3d11->shader_preset->history_size + 1; i++) + for (i = 0; i < d3d11->shader_preset->history_size + 1; i++) { d3d11->frame.texture[i].desc.Width = width; d3d11->frame.texture[i].desc.Height = height; @@ -767,9 +773,11 @@ static void d3d11_init_history(d3d11_video_t* d3d11, unsigned width, unsigned he } static void d3d11_init_render_targets(d3d11_video_t* d3d11, unsigned width, unsigned height) { + unsigned i; + assert(d3d11->shader_preset); - for (int i = 0; i < d3d11->shader_preset->passes; i++) + for (i = 0; i < d3d11->shader_preset->passes; i++) { struct video_shader_pass* pass = &d3d11->shader_preset->pass[i]; @@ -875,6 +883,8 @@ static bool d3d11_gfx_frame( const char* msg, video_frame_info_t* video_info) { + unsigned i; + d3d11_texture_t* texture = NULL; d3d11_video_t* d3d11 = (d3d11_video_t*)data; D3D11DeviceContext context = d3d11->context; @@ -923,7 +933,7 @@ static bool d3d11_gfx_frame( if (d3d11->resize_render_targets) { /* release all render targets first to avoid memory fragmentation */ - for (int i = 0; i < d3d11->shader_preset->passes; i++) + for (i = 0; i < d3d11->shader_preset->passes; i++) d3d11_release_texture(&d3d11->pass[i].rt); } @@ -933,11 +943,12 @@ static bool d3d11_gfx_frame( d3d11_init_history(d3d11, width, height); else { + int k; /* todo: what about frame-duping ? * maybe clone d3d11_texture_t with AddRef */ d3d11_texture_t tmp = d3d11->frame.texture[d3d11->shader_preset->history_size]; - for (int i = d3d11->shader_preset->history_size; i > 0; i--) - d3d11->frame.texture[i] = d3d11->frame.texture[i - 1]; + for (k = d3d11->shader_preset->history_size; k > 0; k--) + d3d11->frame.texture[k] = d3d11->frame.texture[k - 1]; d3d11->frame.texture[0] = tmp; } } @@ -962,11 +973,11 @@ static bool d3d11_gfx_frame( D3D11SetVertexBuffer(context, 0, d3d11->frame.vbo, sizeof(d3d11_vertex_t), 0); D3D11SetBlendState(context, d3d11->blend_disable, NULL, D3D11_DEFAULT_SAMPLE_MASK); - d3d11_texture_t* texture = d3d11->frame.texture; + texture = d3d11->frame.texture; if (d3d11->shader_preset) { - for (int i = 0; i < d3d11->shader_preset->passes; i++) + for (i = 0; i < d3d11->shader_preset->passes; i++) { if (d3d11->shader_preset->pass[i].feedback) { @@ -976,8 +987,10 @@ static bool d3d11_gfx_frame( } } - for (int i = 0; i < d3d11->shader_preset->passes; i++) + for (i = 0; i < d3d11->shader_preset->passes; i++) { + unsigned j; + d3d11_set_shader(context, &d3d11->pass[i].shader); if (d3d11->shader_preset->pass[i].frame_count_mod) @@ -986,7 +999,7 @@ static bool d3d11_gfx_frame( else d3d11->pass[i].frame_count = frame_count; - for (int j = 0; j < SLANG_CBUFFER_MAX; j++) + for (j = 0; j < SLANG_CBUFFER_MAX; j++) { D3D11Buffer buffer = d3d11->pass[i].buffers[j]; cbuffer_sem_t* buffer_sem = &d3d11->pass[i].semantics.cbuffers[j]; @@ -1244,7 +1257,10 @@ static uintptr_t d3d11_gfx_load_texture( if (!d3d11) return 0; - texture = (d3d11_texture_t*)calloc(1, sizeof(*texture)); + texture = (d3d11_texture_t*)calloc(1, sizeof(*texture)); + + if (!texture) + return 0; switch (filter_type) { diff --git a/menu/drivers_display/menu_display_d3d11.c b/menu/drivers_display/menu_display_d3d11.c index 6e5195a897..e601d86ce0 100644 --- a/menu/drivers_display/menu_display_d3d11.c +++ b/menu/drivers_display/menu_display_d3d11.c @@ -80,9 +80,12 @@ static void menu_display_d3d11_draw(void* data) { D3D11_MAPPED_SUBRESOURCE mapped_vbo; + d3d11_sprite_t *v = NULL; + D3D11MapBuffer( d3d11->context, d3d11->sprites.vbo, 0, D3D11_MAP_WRITE_NO_OVERWRITE, 0, &mapped_vbo); - d3d11_sprite_t* v = (d3d11_sprite_t*)mapped_vbo.pData + d3d11->sprites.offset; + + v = (d3d11_sprite_t*)mapped_vbo.pData + d3d11->sprites.offset; v->pos.x = draw->x / (float)d3d11->viewport.Width; v->pos.y = (d3d11->viewport.Height - draw->y - draw->height) / (float)d3d11->viewport.Height; @@ -128,8 +131,6 @@ static void menu_display_d3d11_draw_pipeline(void* data) menu_display_ctx_draw_t* draw = (menu_display_ctx_draw_t*)data; d3d11_video_t* d3d11 = (d3d11_video_t*)video_driver_get_ptr(false); - video_coord_array_t* ca = NULL; - if (!d3d11 || !draw) return; @@ -138,7 +139,7 @@ static void menu_display_d3d11_draw_pipeline(void* data) case VIDEO_SHADER_MENU: case VIDEO_SHADER_MENU_2: { - ca = menu_display_get_coords_array(); + video_coord_array_t *ca = menu_display_get_coords_array(); if (!d3d11->menu_pipeline_vbo) { @@ -170,6 +171,7 @@ static void menu_display_d3d11_draw_pipeline(void* data) D3D11SetPrimitiveTopology(d3d11->context, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); d3d11->ubo_values.time += 0.01f; + { D3D11_MAPPED_SUBRESOURCE mapped_ubo; D3D11MapBuffer(d3d11->context, d3d11->ubo, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped_ubo); From 0336c2f975dd5156b09b961f6dead05244615735 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 3 Feb 2018 15:18:19 +0100 Subject: [PATCH 035/232] (Headers) Make Cg/D3D9 X headers C89-compatible --- gfx/include/Cg/cgD3D9.h | 16 +- gfx/include/d3d9/d3dx9math.h | 576 ++++++++++++++++----------------- gfx/include/d3d9/d3dx9math.inl | 281 +++++++--------- gfx/include/d3d9/d3dx9xof.h | 74 ++--- 4 files changed, 436 insertions(+), 511 deletions(-) diff --git a/gfx/include/Cg/cgD3D9.h b/gfx/include/Cg/cgD3D9.h index 465f26e3ea..646a2cf6fd 100644 --- a/gfx/include/Cg/cgD3D9.h +++ b/gfx/include/Cg/cgD3D9.h @@ -90,11 +90,11 @@ enum cgD3D9Errors cgD3D9DebugTrace = 1001 }; -/*--------------------------------------------------------------------------- -// HRESULTs specific to cgD3D9. When the CGerror is set to cgD3D9Failed -// cgD3D9GetLastError will return an HRESULT that could be one these. -// Use cgD3D9TranslateHRESULT() to translate these errors into strings. ----------------------------------------------------------------------------*/ +/* + * HRESULTs specific to cgD3D9. When the CGerror is set to cgD3D9Failed + * cgD3D9GetLastError will return an HRESULT that could be one these. + * Use cgD3D9TranslateHRESULT() to translate these errors into strings. +*/ static const HRESULT CGD3D9ERR_NOTLOADED = MAKE_HRESULT(1, 0x877, 1); static const HRESULT CGD3D9ERR_NODEVICE = MAKE_HRESULT(1, 0x877, 2); @@ -106,9 +106,9 @@ static const HRESULT CGD3D9ERR_NOTUNIFORM = MAKE_HRESULT(1, 0x877, 7); static const HRESULT CGD3D9ERR_NOTMATRIX = MAKE_HRESULT(1, 0x877, 8); static const HRESULT CGD3D9ERR_INVALIDPARAM = MAKE_HRESULT(1, 0x877, 9); -/*--------------------------------------------------------------------------- -// Other error return values ----------------------------------------------------------------------------*/ +/* + * Other error return values +*/ static const DWORD CGD3D9_INVALID_USAGE = 0xFF; diff --git a/gfx/include/d3d9/d3dx9math.h b/gfx/include/d3d9/d3dx9math.h index e8593c0f1e..914d9536f0 100644 --- a/gfx/include/d3d9/d3dx9math.h +++ b/gfx/include/d3d9/d3dx9math.h @@ -462,19 +462,19 @@ public: D3DXPLANE( CONST D3DXFLOAT16* ); D3DXPLANE( FLOAT a, FLOAT b, FLOAT c, FLOAT d ); - // casting + /* casting */ operator FLOAT* (); operator CONST FLOAT* () const; - // assignment operators + /* assignment operators */ D3DXPLANE& operator *= ( FLOAT ); D3DXPLANE& operator /= ( FLOAT ); - // unary operators + /* unary operators */ D3DXPLANE operator + () const; D3DXPLANE operator - () const; - // binary operators + /* binary operators */ D3DXPLANE operator * ( FLOAT ) const; D3DXPLANE operator / ( FLOAT ) const; @@ -483,16 +483,16 @@ public: BOOL operator == ( CONST D3DXPLANE& ) const; BOOL operator != ( CONST D3DXPLANE& ) const; -#endif //__cplusplus +#endif /*__cplusplus */ FLOAT a, b, c, d; } D3DXPLANE, *LPD3DXPLANE; -//=========================================================================== -// -// Colors -// -//=========================================================================== +/* + * + * Colors + * + */ typedef struct D3DXCOLOR { @@ -505,7 +505,7 @@ public: D3DXCOLOR( CONST D3DCOLORVALUE& ); D3DXCOLOR( FLOAT r, FLOAT g, FLOAT b, FLOAT a ); - // casting + /* casting */ operator DWORD () const; operator FLOAT* (); @@ -517,17 +517,17 @@ public: operator D3DCOLORVALUE& (); operator CONST D3DCOLORVALUE& () const; - // assignment operators + /* assignment operators */ D3DXCOLOR& operator += ( CONST D3DXCOLOR& ); D3DXCOLOR& operator -= ( CONST D3DXCOLOR& ); D3DXCOLOR& operator *= ( FLOAT ); D3DXCOLOR& operator /= ( FLOAT ); - // unary operators + /* unary operators */ D3DXCOLOR operator + () const; D3DXCOLOR operator - () const; - // binary operators + /* binary operators */ D3DXCOLOR operator + ( CONST D3DXCOLOR& ) const; D3DXCOLOR operator - ( CONST D3DXCOLOR& ) const; D3DXCOLOR operator * ( FLOAT ) const; @@ -538,38 +538,35 @@ public: BOOL operator == ( CONST D3DXCOLOR& ) const; BOOL operator != ( CONST D3DXCOLOR& ) const; -#endif //__cplusplus +#endif /* __cplusplus */ FLOAT r, g, b, a; } D3DXCOLOR, *LPD3DXCOLOR; +/* + * + * D3DX math functions: + * + * NOTE: + * * All these functions can take the same object as in and out parameters. + * + * * Out parameters are typically also returned as return values, so that + * the output of one function may be used as a parameter to another. + */ +/* + * Float16 + */ -//=========================================================================== -// -// D3DX math functions: -// -// NOTE: -// * All these functions can take the same object as in and out parameters. -// -// * Out parameters are typically also returned as return values, so that -// the output of one function may be used as a parameter to another. -// -//=========================================================================== - -//-------------------------- -// Float16 -//-------------------------- - -// non-inline +/* non-inline */ #ifdef __cplusplus extern "C" { #endif -// Converts an array 32-bit floats to 16-bit floats +/* Converts an array 32-bit floats to 16-bit floats */ D3DXFLOAT16* WINAPI D3DXFloat32To16Array ( D3DXFLOAT16 *pOut, CONST FLOAT *pIn, UINT n ); -// Converts an array 16-bit floats to 32-bit floats +/* Converts an array 16-bit floats to 32-bit floats */ FLOAT* WINAPI D3DXFloat16To32Array ( FLOAT *pOut, CONST D3DXFLOAT16 *pIn, UINT n ); @@ -577,12 +574,11 @@ FLOAT* WINAPI D3DXFloat16To32Array } #endif +/* + * 2D Vector + */ -//-------------------------- -// 2D Vector -//-------------------------- - -// inline +/* inline */ FLOAT D3DXVec2Length ( CONST D3DXVECTOR2 *pV ); @@ -593,7 +589,7 @@ FLOAT D3DXVec2LengthSq FLOAT D3DXVec2Dot ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); -// Z component of ((x1,y1,0) cross (x2,y2,0)) +/* Z component of ((x1,y1,0) cross (x2,y2,0)) */ FLOAT D3DXVec2CCW ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); @@ -603,23 +599,23 @@ D3DXVECTOR2* D3DXVec2Add D3DXVECTOR2* D3DXVec2Subtract ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); -// Minimize each component. x = min(x1, x2), y = min(y1, y2) +/* Minimize each component. x = min(x1, x2), y = min(y1, y2) */ D3DXVECTOR2* D3DXVec2Minimize ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); -// Maximize each component. x = max(x1, x2), y = max(y1, y2) +/* Maximize each component. x = max(x1, x2), y = max(y1, y2) */ D3DXVECTOR2* D3DXVec2Maximize ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); D3DXVECTOR2* D3DXVec2Scale ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, FLOAT s ); -// Linear interpolation. V1 + s(V2-V1) +/* Linear interpolation. V1 + s(V2-V1) */ D3DXVECTOR2* D3DXVec2Lerp ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, FLOAT s ); -// non-inline +/* non-inline */ #ifdef __cplusplus extern "C" { #endif @@ -627,43 +623,43 @@ extern "C" { D3DXVECTOR2* WINAPI D3DXVec2Normalize ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV ); -// Hermite interpolation between position V1, tangent T1 (when s == 0) -// and position V2, tangent T2 (when s == 1). +/* Hermite interpolation between position V1, tangent T1 (when s == 0) + * and position V2, tangent T2 (when s == 1). */ D3DXVECTOR2* WINAPI D3DXVec2Hermite ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pT1, CONST D3DXVECTOR2 *pV2, CONST D3DXVECTOR2 *pT2, FLOAT s ); -// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) +/* CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) */ D3DXVECTOR2* WINAPI D3DXVec2CatmullRom ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV0, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, CONST D3DXVECTOR2 *pV3, FLOAT s ); -// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) +/* Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) */ D3DXVECTOR2* WINAPI D3DXVec2BaryCentric ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, CONST D3DXVECTOR2 *pV3, FLOAT f, FLOAT g); -// Transform (x, y, 0, 1) by matrix. +/* Transform (x, y, 0, 1) by matrix. */ D3DXVECTOR4* WINAPI D3DXVec2Transform ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); -// Transform (x, y, 0, 1) by matrix, project result back into w=1. +/* Transform (x, y, 0, 1) by matrix, project result back into w=1. */ D3DXVECTOR2* WINAPI D3DXVec2TransformCoord ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); -// Transform (x, y, 0, 0) by matrix. +/* Transform (x, y, 0, 0) by matrix. */ D3DXVECTOR2* WINAPI D3DXVec2TransformNormal ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); -// Transform Array (x, y, 0, 1) by matrix. +/* Transform Array (x, y, 0, 1) by matrix. */ D3DXVECTOR4* WINAPI D3DXVec2TransformArray ( D3DXVECTOR4 *pOut, UINT OutStride, CONST D3DXVECTOR2 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n); -// Transform Array (x, y, 0, 1) by matrix, project result back into w=1. +/* Transform Array (x, y, 0, 1) by matrix, project result back into w=1. */ D3DXVECTOR2* WINAPI D3DXVec2TransformCoordArray ( D3DXVECTOR2 *pOut, UINT OutStride, CONST D3DXVECTOR2 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); -// Transform Array (x, y, 0, 0) by matrix. +/* Transform Array (x, y, 0, 0) by matrix. */ D3DXVECTOR2* WINAPI D3DXVec2TransformNormalArray ( D3DXVECTOR2 *pOut, UINT OutStride, CONST D3DXVECTOR2 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); @@ -673,12 +669,11 @@ D3DXVECTOR2* WINAPI D3DXVec2TransformNormalArray } #endif +/* + * 3D Vector + */ -//-------------------------- -// 3D Vector -//-------------------------- - -// inline +/* inline */ FLOAT D3DXVec3Length ( CONST D3DXVECTOR3 *pV ); @@ -698,23 +693,23 @@ D3DXVECTOR3* D3DXVec3Add D3DXVECTOR3* D3DXVec3Subtract ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); -// Minimize each component. x = min(x1, x2), y = min(y1, y2), ... +/* Minimize each component. x = min(x1, x2), y = min(y1, y2), ... */ D3DXVECTOR3* D3DXVec3Minimize ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); -// Maximize each component. x = max(x1, x2), y = max(y1, y2), ... +/* Maximize each component. x = max(x1, x2), y = max(y1, y2), ... */ D3DXVECTOR3* D3DXVec3Maximize ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); D3DXVECTOR3* D3DXVec3Scale ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, FLOAT s); -// Linear interpolation. V1 + s(V2-V1) +/* Linear interpolation. V1 + s(V2-V1) */ D3DXVECTOR3* D3DXVec3Lerp ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, FLOAT s ); -// non-inline +/* non-inline */ #ifdef __cplusplus extern "C" { #endif @@ -722,67 +717,69 @@ extern "C" { D3DXVECTOR3* WINAPI D3DXVec3Normalize ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV ); -// Hermite interpolation between position V1, tangent T1 (when s == 0) -// and position V2, tangent T2 (when s == 1). +/* Hermite interpolation between position V1, tangent T1 (when s == 0) + * and position V2, tangent T2 (when s == 1). */ D3DXVECTOR3* WINAPI D3DXVec3Hermite ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pT1, CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pT2, FLOAT s ); -// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) +/* CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) */ D3DXVECTOR3* WINAPI D3DXVec3CatmullRom ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV0, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pV3, FLOAT s ); -// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) +/* Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) */ D3DXVECTOR3* WINAPI D3DXVec3BaryCentric ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pV3, FLOAT f, FLOAT g); -// Transform (x, y, z, 1) by matrix. +/* Transform (x, y, z, 1) by matrix. */ D3DXVECTOR4* WINAPI D3DXVec3Transform ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); -// Transform (x, y, z, 1) by matrix, project result back into w=1. +/* Transform (x, y, z, 1) by matrix, project result back into w=1. */ D3DXVECTOR3* WINAPI D3DXVec3TransformCoord ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); -// Transform (x, y, z, 0) by matrix. If you transforming a normal by a -// non-affine matrix, the matrix you pass to this function should be the -// transpose of the inverse of the matrix you would use to transform a coord. +/* Transform (x, y, z, 0) by matrix. If you transforming a normal by a + * non-affine matrix, the matrix you pass to this function should be the + * transpose of the inverse of the matrix you would use to transform a coord. + */ D3DXVECTOR3* WINAPI D3DXVec3TransformNormal ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); -// Transform Array (x, y, z, 1) by matrix. +/* Transform Array (x, y, z, 1) by matrix. */ D3DXVECTOR4* WINAPI D3DXVec3TransformArray ( D3DXVECTOR4 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); -// Transform Array (x, y, z, 1) by matrix, project result back into w=1. +/* Transform Array (x, y, z, 1) by matrix, project result back into w=1. */ D3DXVECTOR3* WINAPI D3DXVec3TransformCoordArray ( D3DXVECTOR3 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); -// Transform (x, y, z, 0) by matrix. If you transforming a normal by a -// non-affine matrix, the matrix you pass to this function should be the -// transpose of the inverse of the matrix you would use to transform a coord. +/* Transform (x, y, z, 0) by matrix. If you transforming a normal by a + * non-affine matrix, the matrix you pass to this function should be the + * transpose of the inverse of the matrix you would use to transform a coord. + */ D3DXVECTOR3* WINAPI D3DXVec3TransformNormalArray ( D3DXVECTOR3 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); -// Project vector from object space into screen space +/* Project vector from object space into screen space */ D3DXVECTOR3* WINAPI D3DXVec3Project ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DVIEWPORT9 *pViewport, CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld); -// Project vector from screen space into object space +/* Project vector from screen space into object space */ D3DXVECTOR3* WINAPI D3DXVec3Unproject ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DVIEWPORT9 *pViewport, CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld); -// Project vector Array from object space into screen space +/* Project vector Array from object space into screen space */ D3DXVECTOR3* WINAPI D3DXVec3ProjectArray ( D3DXVECTOR3 *pOut, UINT OutStride,CONST D3DXVECTOR3 *pV, UINT VStride,CONST D3DVIEWPORT9 *pViewport, CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld, UINT n); -// Project vector Array from screen space into object space +/* Project vector Array from screen space into object space */ D3DXVECTOR3* WINAPI D3DXVec3UnprojectArray ( D3DXVECTOR3 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DVIEWPORT9 *pViewport, CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld, UINT n); @@ -792,13 +789,11 @@ D3DXVECTOR3* WINAPI D3DXVec3UnprojectArray } #endif +/* + * 4D Vector + */ - -//-------------------------- -// 4D Vector -//-------------------------- - -// inline +/* inline */ FLOAT D3DXVec4Length ( CONST D3DXVECTOR4 *pV ); @@ -815,28 +810,28 @@ D3DXVECTOR4* D3DXVec4Add D3DXVECTOR4* D3DXVec4Subtract ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); -// Minimize each component. x = min(x1, x2), y = min(y1, y2), ... +/* Minimize each component. x = min(x1, x2), y = min(y1, y2), ... */ D3DXVECTOR4* D3DXVec4Minimize ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); -// Maximize each component. x = max(x1, x2), y = max(y1, y2), ... +/* Maximize each component. x = max(x1, x2), y = max(y1, y2), ... */ D3DXVECTOR4* D3DXVec4Maximize ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); D3DXVECTOR4* D3DXVec4Scale ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, FLOAT s); -// Linear interpolation. V1 + s(V2-V1) +/* Linear interpolation. V1 + s(V2-V1) */ D3DXVECTOR4* D3DXVec4Lerp ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, FLOAT s ); -// non-inline +/* non-inline */ #ifdef __cplusplus extern "C" { #endif -// Cross-product in 4 dimensions. +/* Cross-product in 4 dimensions. */ D3DXVECTOR4* WINAPI D3DXVec4Cross ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pV3); @@ -844,27 +839,27 @@ D3DXVECTOR4* WINAPI D3DXVec4Cross D3DXVECTOR4* WINAPI D3DXVec4Normalize ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV ); -// Hermite interpolation between position V1, tangent T1 (when s == 0) -// and position V2, tangent T2 (when s == 1). +/* Hermite interpolation between position V1, tangent T1 (when s == 0) + * and position V2, tangent T2 (when s == 1). */ D3DXVECTOR4* WINAPI D3DXVec4Hermite ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pT1, CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pT2, FLOAT s ); -// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) +/* CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) */ D3DXVECTOR4* WINAPI D3DXVec4CatmullRom ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV0, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pV3, FLOAT s ); -// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) +/* Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) */ D3DXVECTOR4* WINAPI D3DXVec4BaryCentric ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pV3, FLOAT f, FLOAT g); -// Transform vector by matrix. +/* Transform vector by matrix. */ D3DXVECTOR4* WINAPI D3DXVec4Transform ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, CONST D3DXMATRIX *pM ); -// Transform vector array by matrix. +/* Transform vector array by matrix. */ D3DXVECTOR4* WINAPI D3DXVec4TransformArray ( D3DXVECTOR4 *pOut, UINT OutStride, CONST D3DXVECTOR4 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); @@ -873,11 +868,11 @@ D3DXVECTOR4* WINAPI D3DXVec4TransformArray #endif -//-------------------------- -// 4D Matrix -//-------------------------- +/* + * 4D Matrix + */ -// inline +/* inline */ D3DXMATRIX* D3DXMatrixIdentity ( D3DXMATRIX *pOut ); @@ -901,143 +896,143 @@ HRESULT WINAPI D3DXMatrixDecompose D3DXMATRIX* WINAPI D3DXMatrixTranspose ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM ); -// Matrix multiplication. The result represents the transformation M2 -// followed by the transformation M1. (Out = M1 * M2) +/* Matrix multiplication. The result represents the transformation M2 + * followed by the transformation M1. (Out = M1 * M2) */ D3DXMATRIX* WINAPI D3DXMatrixMultiply ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 ); -// Matrix multiplication, followed by a transpose. (Out = T(M1 * M2)) +/* Matrix multiplication, followed by a transpose. (Out = T(M1 * M2)) */ D3DXMATRIX* WINAPI D3DXMatrixMultiplyTranspose ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 ); -// Calculate inverse of matrix. Inversion my fail, in which case NULL will -// be returned. The determinant of pM is also returned it pfDeterminant -// is non-NULL. +/* Calculate inverse of matrix. Inversion my fail, in which case NULL will + * be returned. The determinant of pM is also returned it pfDeterminant + * is non-NULL. */ D3DXMATRIX* WINAPI D3DXMatrixInverse ( D3DXMATRIX *pOut, FLOAT *pDeterminant, CONST D3DXMATRIX *pM ); -// Build a matrix which scales by (sx, sy, sz) +/* Build a matrix which scales by (sx, sy, sz) */ D3DXMATRIX* WINAPI D3DXMatrixScaling ( D3DXMATRIX *pOut, FLOAT sx, FLOAT sy, FLOAT sz ); -// Build a matrix which translates by (x, y, z) +/* Build a matrix which translates by (x, y, z) */ D3DXMATRIX* WINAPI D3DXMatrixTranslation ( D3DXMATRIX *pOut, FLOAT x, FLOAT y, FLOAT z ); -// Build a matrix which rotates around the X axis +/* Build a matrix which rotates around the X axis */ D3DXMATRIX* WINAPI D3DXMatrixRotationX ( D3DXMATRIX *pOut, FLOAT Angle ); -// Build a matrix which rotates around the Y axis +/* Build a matrix which rotates around the Y axis */ D3DXMATRIX* WINAPI D3DXMatrixRotationY ( D3DXMATRIX *pOut, FLOAT Angle ); -// Build a matrix which rotates around the Z axis +/* Build a matrix which rotates around the Z axis */ D3DXMATRIX* WINAPI D3DXMatrixRotationZ ( D3DXMATRIX *pOut, FLOAT Angle ); -// Build a matrix which rotates around an arbitrary axis +/* Build a matrix which rotates around an arbitrary axis */ D3DXMATRIX* WINAPI D3DXMatrixRotationAxis ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pV, FLOAT Angle ); -// Build a matrix from a quaternion +/* Build a matrix from a quaternion */ D3DXMATRIX* WINAPI D3DXMatrixRotationQuaternion ( D3DXMATRIX *pOut, CONST D3DXQUATERNION *pQ); -// Yaw around the Y axis, a pitch around the X axis, -// and a roll around the Z axis. +/* Yaw around the Y axis, a pitch around the X axis, + * and a roll around the Z axis. */ D3DXMATRIX* WINAPI D3DXMatrixRotationYawPitchRoll ( D3DXMATRIX *pOut, FLOAT Yaw, FLOAT Pitch, FLOAT Roll ); -// Build transformation matrix. NULL arguments are treated as identity. -// Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt +/* Build transformation matrix. NULL arguments are treated as identity. + * Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt */ D3DXMATRIX* WINAPI D3DXMatrixTransformation ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pScalingCenter, CONST D3DXQUATERNION *pScalingRotation, CONST D3DXVECTOR3 *pScaling, CONST D3DXVECTOR3 *pRotationCenter, CONST D3DXQUATERNION *pRotation, CONST D3DXVECTOR3 *pTranslation); -// Build 2D transformation matrix in XY plane. NULL arguments are treated as identity. -// Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt +/* Build 2D transformation matrix in XY plane. NULL arguments are treated as identity. + * Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt */ D3DXMATRIX* WINAPI D3DXMatrixTransformation2D ( D3DXMATRIX *pOut, CONST D3DXVECTOR2* pScalingCenter, FLOAT ScalingRotation, CONST D3DXVECTOR2* pScaling, CONST D3DXVECTOR2* pRotationCenter, FLOAT Rotation, CONST D3DXVECTOR2* pTranslation); -// Build affine transformation matrix. NULL arguments are treated as identity. -// Mout = Ms * Mrc-1 * Mr * Mrc * Mt +/* Build affine transformation matrix. NULL arguments are treated as identity. + * Mout = Ms * Mrc-1 * Mr * Mrc * Mt */ D3DXMATRIX* WINAPI D3DXMatrixAffineTransformation ( D3DXMATRIX *pOut, FLOAT Scaling, CONST D3DXVECTOR3 *pRotationCenter, CONST D3DXQUATERNION *pRotation, CONST D3DXVECTOR3 *pTranslation); -// Build 2D affine transformation matrix in XY plane. NULL arguments are treated as identity. -// Mout = Ms * Mrc-1 * Mr * Mrc * Mt +/* Build 2D affine transformation matrix in XY plane. NULL arguments are treated as identity. + * Mout = Ms * Mrc-1 * Mr * Mrc * Mt */ D3DXMATRIX* WINAPI D3DXMatrixAffineTransformation2D ( D3DXMATRIX *pOut, FLOAT Scaling, CONST D3DXVECTOR2* pRotationCenter, FLOAT Rotation, CONST D3DXVECTOR2* pTranslation); -// Build a lookat matrix. (right-handed) +/* Build a lookat matrix. (right-handed) */ D3DXMATRIX* WINAPI D3DXMatrixLookAtRH ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pEye, CONST D3DXVECTOR3 *pAt, CONST D3DXVECTOR3 *pUp ); -// Build a lookat matrix. (left-handed) +/* Build a lookat matrix. (left-handed) */ D3DXMATRIX* WINAPI D3DXMatrixLookAtLH ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pEye, CONST D3DXVECTOR3 *pAt, CONST D3DXVECTOR3 *pUp ); -// Build a perspective projection matrix. (right-handed) +/* Build a perspective projection matrix. (right-handed) */ D3DXMATRIX* WINAPI D3DXMatrixPerspectiveRH ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); -// Build a perspective projection matrix. (left-handed) +/* Build a perspective projection matrix. (left-handed) */ D3DXMATRIX* WINAPI D3DXMatrixPerspectiveLH ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); -// Build a perspective projection matrix. (right-handed) +/* Build a perspective projection matrix. (right-handed) */ D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovRH ( D3DXMATRIX *pOut, FLOAT fovy, FLOAT Aspect, FLOAT zn, FLOAT zf ); -// Build a perspective projection matrix. (left-handed) +/* Build a perspective projection matrix. (left-handed) */ D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovLH ( D3DXMATRIX *pOut, FLOAT fovy, FLOAT Aspect, FLOAT zn, FLOAT zf ); -// Build a perspective projection matrix. (right-handed) +/* Build a perspective projection matrix. (right-handed) */ D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterRH ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, FLOAT zf ); -// Build a perspective projection matrix. (left-handed) +/* Build a perspective projection matrix. (left-handed) */ D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterLH ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, FLOAT zf ); -// Build an ortho projection matrix. (right-handed) +/* Build an ortho projection matrix. (right-handed) */ D3DXMATRIX* WINAPI D3DXMatrixOrthoRH ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); -// Build an ortho projection matrix. (left-handed) +/* Build an ortho projection matrix. (left-handed) */ D3DXMATRIX* WINAPI D3DXMatrixOrthoLH ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); -// Build an ortho projection matrix. (right-handed) +/* Build an ortho projection matrix. (right-handed) */ D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenterRH ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, FLOAT zf ); -// Build an ortho projection matrix. (left-handed) +/* Build an ortho projection matrix. (left-handed) */ D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenterLH ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, FLOAT zf ); -// Build a matrix which flattens geometry into a plane, as if casting -// a shadow from a light. +/* Build a matrix which flattens geometry into a plane, as if casting + * a shadow from a light. */ D3DXMATRIX* WINAPI D3DXMatrixShadow ( D3DXMATRIX *pOut, CONST D3DXVECTOR4 *pLight, CONST D3DXPLANE *pPlane ); -// Build a matrix which reflects the coordinate system about a plane +/* Build a matrix which reflects the coordinate system about a plane */ D3DXMATRIX* WINAPI D3DXMatrixReflect ( D3DXMATRIX *pOut, CONST D3DXPLANE *pPlane ); @@ -1045,10 +1040,9 @@ D3DXMATRIX* WINAPI D3DXMatrixReflect } #endif - -//-------------------------- -// Quaternion -//-------------------------- +/* + * Quaternion + */ /* inline */ @@ -1069,35 +1063,34 @@ D3DXQUATERNION* D3DXQuaternionIdentity BOOL D3DXQuaternionIsIdentity ( CONST D3DXQUATERNION *pQ ); -// (-x, -y, -z, w) +/* (-x, -y, -z, w) */ D3DXQUATERNION* D3DXQuaternionConjugate ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); - -// non-inline +/* non-inline */ #ifdef __cplusplus extern "C" { #endif -// Compute a quaternin's axis and angle of rotation. Expects unit quaternions. +/* Compute a quaternin's axis and angle of rotation. Expects unit quaternions. */ void WINAPI D3DXQuaternionToAxisAngle ( CONST D3DXQUATERNION *pQ, D3DXVECTOR3 *pAxis, FLOAT *pAngle ); -// Build a quaternion from a rotation matrix. +/* Build a quaternion from a rotation matrix. */ D3DXQUATERNION* WINAPI D3DXQuaternionRotationMatrix ( D3DXQUATERNION *pOut, CONST D3DXMATRIX *pM); -// Rotation about arbitrary axis. +/* Rotation about arbitrary axis. */ D3DXQUATERNION* WINAPI D3DXQuaternionRotationAxis ( D3DXQUATERNION *pOut, CONST D3DXVECTOR3 *pV, FLOAT Angle ); -// Yaw around the Y axis, a pitch around the X axis, -// and a roll around the Z axis. +/* Yaw around the Y axis, a pitch around the X axis, + * and a roll around the Z axis. */ D3DXQUATERNION* WINAPI D3DXQuaternionRotationYawPitchRoll ( D3DXQUATERNION *pOut, FLOAT Yaw, FLOAT Pitch, FLOAT Roll ); -// Quaternion multiplication. The result represents the rotation Q2 -// followed by the rotation Q1. (Out = Q2 * Q1) +/* Quaternion multiplication. The result represents the rotation Q2 + * followed by the rotation Q1. (Out = Q2 * Q1) */ D3DXQUATERNION* WINAPI D3DXQuaternionMultiply ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2 ); @@ -1105,43 +1098,43 @@ D3DXQUATERNION* WINAPI D3DXQuaternionMultiply D3DXQUATERNION* WINAPI D3DXQuaternionNormalize ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); -// Conjugate and re-norm +/* Conjugate and re-norm */ D3DXQUATERNION* WINAPI D3DXQuaternionInverse ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); -// Expects unit quaternions. -// if q = (cos(theta), sin(theta) * v); ln(q) = (0, theta * v) +/* Expects unit quaternions. + * if q = (cos(theta), sin(theta) * v); ln(q) = (0, theta * v) */ D3DXQUATERNION* WINAPI D3DXQuaternionLn ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); -// Expects pure quaternions. (w == 0) w is ignored in calculation. -// if q = (0, theta * v); exp(q) = (cos(theta), sin(theta) * v) +/* Expects pure quaternions. (w == 0) w is ignored in calculation. + * if q = (0, theta * v); exp(q) = (cos(theta), sin(theta) * v) */ D3DXQUATERNION* WINAPI D3DXQuaternionExp ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); -// Spherical linear interpolation between Q1 (t == 0) and Q2 (t == 1). -// Expects unit quaternions. +/* Spherical linear interpolation between Q1 (t == 0) and Q2 (t == 1). + * Expects unit quaternions. */ D3DXQUATERNION* WINAPI D3DXQuaternionSlerp ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2, FLOAT t ); -// Spherical quadrangle interpolation. -// Slerp(Slerp(Q1, C, t), Slerp(A, B, t), 2t(1-t)) +/* Spherical quadrangle interpolation. + * Slerp(Slerp(Q1, C, t), Slerp(A, B, t), 2t(1-t)) */ D3DXQUATERNION* WINAPI D3DXQuaternionSquad ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pA, CONST D3DXQUATERNION *pB, CONST D3DXQUATERNION *pC, FLOAT t ); -// Setup control points for spherical quadrangle interpolation -// from Q1 to Q2. The control points are chosen in such a way -// to ensure the continuity of tangents with adjacent segments. +/* Setup control points for spherical quadrangle interpolation + * from Q1 to Q2. The control points are chosen in such a way + * to ensure the continuity of tangents with adjacent segments. */ void WINAPI D3DXQuaternionSquadSetup ( D3DXQUATERNION *pAOut, D3DXQUATERNION *pBOut, D3DXQUATERNION *pCOut, CONST D3DXQUATERNION *pQ0, CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2, CONST D3DXQUATERNION *pQ3 ); -// Barycentric interpolation. -// Slerp(Slerp(Q1, Q2, f+g), Slerp(Q1, Q3, f+g), g/(f+g)) +/* Barycentric interpolation. + * Slerp(Slerp(Q1, Q2, f+g), Slerp(Q1, Q3, f+g), g/(f+g)) */ D3DXQUATERNION* WINAPI D3DXQuaternionBaryCentric ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2, CONST D3DXQUATERNION *pQ3, @@ -1152,58 +1145,58 @@ D3DXQUATERNION* WINAPI D3DXQuaternionBaryCentric #endif -//-------------------------- -// Plane -//-------------------------- +/* + * Plane +*/ -// inline +/* inline */ -// ax + by + cz + dw +/* ax + by + cz + dw */ FLOAT D3DXPlaneDot ( CONST D3DXPLANE *pP, CONST D3DXVECTOR4 *pV); -// ax + by + cz + d +/* ax + by + cz + d */ FLOAT D3DXPlaneDotCoord ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV); -// ax + by + cz +/* ax + by + cz */ FLOAT D3DXPlaneDotNormal ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV); D3DXPLANE* D3DXPlaneScale (D3DXPLANE *pOut, CONST D3DXPLANE *pP, FLOAT s); -// non-inline +/* non-inline */ #ifdef __cplusplus extern "C" { #endif -// Normalize plane (so that |a,b,c| == 1) +/* Normalize plane (so that |a,b,c| == 1) */ D3DXPLANE* WINAPI D3DXPlaneNormalize ( D3DXPLANE *pOut, CONST D3DXPLANE *pP); -// Find the intersection between a plane and a line. If the line is -// parallel to the plane, NULL is returned. +/* Find the intersection between a plane and a line. If the line is + * parallel to the plane, NULL is returned. */ D3DXVECTOR3* WINAPI D3DXPlaneIntersectLine ( D3DXVECTOR3 *pOut, CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2); -// Construct a plane from a point and a normal +/* Construct a plane from a point and a normal */ D3DXPLANE* WINAPI D3DXPlaneFromPointNormal ( D3DXPLANE *pOut, CONST D3DXVECTOR3 *pPoint, CONST D3DXVECTOR3 *pNormal); -// Construct a plane from 3 points +/* Construct a plane from 3 points */ D3DXPLANE* WINAPI D3DXPlaneFromPoints ( D3DXPLANE *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pV3); -// Transform a plane by a matrix. The vector (a,b,c) must be normal. -// M should be the inverse transpose of the transformation desired. +/* Transform a plane by a matrix. The vector (a,b,c) must be normal. + * M should be the inverse transpose of the transformation desired. */ D3DXPLANE* WINAPI D3DXPlaneTransform ( D3DXPLANE *pOut, CONST D3DXPLANE *pP, CONST D3DXMATRIX *pM ); -// Transform an array of planes by a matrix. The vectors (a,b,c) must be normal. -// M should be the inverse transpose of the transformation desired. +/* Transform an array of planes by a matrix. The vectors (a,b,c) must be normal. + * M should be the inverse transpose of the transformation desired. */ D3DXPLANE* WINAPI D3DXPlaneTransformArray ( D3DXPLANE *pOut, UINT OutStride, CONST D3DXPLANE *pP, UINT PStride, CONST D3DXMATRIX *pM, UINT n ); @@ -1211,14 +1204,13 @@ D3DXPLANE* WINAPI D3DXPlaneTransformArray } #endif +/* + * Color + */ -//-------------------------- -// Color -//-------------------------- +/* inline */ -// inline - -// (1-r, 1-g, 1-b, a) +/* (1-r, 1-g, 1-b, a) */ D3DXCOLOR* D3DXColorNegative (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC); @@ -1231,25 +1223,25 @@ D3DXCOLOR* D3DXColorSubtract D3DXCOLOR* D3DXColorScale (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s); -// (r1*r2, g1*g2, b1*b2, a1*a2) +/* (r1*r2, g1*g2, b1*b2, a1*a2) */ D3DXCOLOR* D3DXColorModulate (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2); -// Linear interpolation of r,g,b, and a. C1 + s(C2-C1) +/* Linear interpolation of r,g,b, and a. C1 + s(C2-C1) */ D3DXCOLOR* D3DXColorLerp (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2, FLOAT s); -// non-inline +/* non-inline */ #ifdef __cplusplus extern "C" { #endif -// Interpolate r,g,b between desaturated color and color. -// DesaturatedColor + s(Color - DesaturatedColor) +/* Interpolate r,g,b between desaturated color and color. + * DesaturatedColor + s(Color - DesaturatedColor) */ D3DXCOLOR* WINAPI D3DXColorAdjustSaturation (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s); -// Interpolate r,g,b between 50% grey and color. Grey + s(Color - Grey) +/* Interpolate r,g,b between 50% grey and color. Grey + s(Color - Grey) */ D3DXCOLOR* WINAPI D3DXColorAdjustContrast (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT c); @@ -1257,16 +1249,16 @@ D3DXCOLOR* WINAPI D3DXColorAdjustContrast } #endif -//-------------------------- -// Misc -//-------------------------- +/* + * Misc +*/ #ifdef __cplusplus extern "C" { #endif -// Calculate Fresnel term given the cosine of theta (likely obtained by -// taking the dot of two normals), and the refraction index of the material. +/* Calculate Fresnel term given the cosine of theta (likely obtained by + * taking the dot of two normals), and the refraction index of the material. */ FLOAT WINAPI D3DXFresnelTerm (FLOAT CosTheta, FLOAT RefractionIndex); @@ -1274,16 +1266,15 @@ FLOAT WINAPI D3DXFresnelTerm } #endif -//=========================================================================== -// -// Matrix Stack -// -//=========================================================================== +/* + * + * Matrix Stack + */ typedef interface ID3DXMatrixStack ID3DXMatrixStack; typedef interface ID3DXMatrixStack *LPD3DXMATRIXSTACK; -// {C7885BA7-F990-4fe7-922D-8515E477DD85} +/* {C7885BA7-F990-4fe7-922D-8515E477DD85} */ DEFINE_GUID(IID_ID3DXMatrixStack, 0xc7885ba7, 0xf990, 0x4fe7, 0x92, 0x2d, 0x85, 0x15, 0xe4, 0x77, 0xdd, 0x85); @@ -1293,85 +1284,83 @@ DEFINE_GUID(IID_ID3DXMatrixStack, DECLARE_INTERFACE_(ID3DXMatrixStack, IUnknown) { - // - // IUnknown methods - // + /* IUnknown methods */ STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; STDMETHOD_(ULONG,AddRef)(THIS) PURE; STDMETHOD_(ULONG,Release)(THIS) PURE; - // - // ID3DXMatrixStack methods - // + /* ID3DXMatrixStack methods */ - // Pops the top of the stack, returns the current top - // *after* popping the top. + /* Pops the top of the stack, returns the current top + * *after* popping the top. */ STDMETHOD(Pop)(THIS) PURE; - // Pushes the stack by one, duplicating the current matrix. + /* Pushes the stack by one, duplicating the current matrix. */ STDMETHOD(Push)(THIS) PURE; - // Loads identity in the current matrix. + /* Loads identity in the current matrix. */ STDMETHOD(LoadIdentity)(THIS) PURE; - // Loads the given matrix into the current matrix + /* Loads the given matrix into the current matrix */ STDMETHOD(LoadMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE; - // Right-Multiplies the given matrix to the current matrix. - // (transformation is about the current world origin) + /* Right-Multiplies the given matrix to the current matrix. + * (transformation is about the current world origin) */ STDMETHOD(MultMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE; - // Left-Multiplies the given matrix to the current matrix - // (transformation is about the local origin of the object) + /* Left-Multiplies the given matrix to the current matrix + * (transformation is about the local origin of the object) */ STDMETHOD(MultMatrixLocal)(THIS_ CONST D3DXMATRIX* pM ) PURE; - // Right multiply the current matrix with the computed rotation - // matrix, counterclockwise about the given axis with the given angle. - // (rotation is about the current world origin) + /* Right multiply the current matrix with the computed rotation + * matrix, counterclockwise about the given axis with the given angle. + * (rotation is about the current world origin) */ STDMETHOD(RotateAxis) (THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE; - // Left multiply the current matrix with the computed rotation - // matrix, counterclockwise about the given axis with the given angle. - // (rotation is about the local origin of the object) + /* Left multiply the current matrix with the computed rotation + * matrix, counterclockwise about the given axis with the given angle. + * (rotation is about the local origin of the object) */ STDMETHOD(RotateAxisLocal) (THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE; - // Right multiply the current matrix with the computed rotation - // matrix. All angles are counterclockwise. (rotation is about the - // current world origin) + /* Right multiply the current matrix with the computed rotation + * matrix. All angles are counterclockwise. (rotation is about the + * current world origin) - // The rotation is composed of a yaw around the Y axis, a pitch around - // the X axis, and a roll around the Z axis. + * The rotation is composed of a yaw around the Y axis, a pitch around + * the X axis, and a roll around the Z axis. + */ STDMETHOD(RotateYawPitchRoll) (THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE; - // Left multiply the current matrix with the computed rotation - // matrix. All angles are counterclockwise. (rotation is about the - // local origin of the object) + /* Left multiply the current matrix with the computed rotation + * matrix. All angles are counterclockwise. (rotation is about the + * local origin of the object) - // The rotation is composed of a yaw around the Y axis, a pitch around - // the X axis, and a roll around the Z axis. + * The rotation is composed of a yaw around the Y axis, a pitch around + * the X axis, and a roll around the Z axis. + */ STDMETHOD(RotateYawPitchRollLocal) (THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE; - // Right multiply the current matrix with the computed scale - // matrix. (transformation is about the current world origin) + /* Right multiply the current matrix with the computed scale + * matrix. (transformation is about the current world origin) */ STDMETHOD(Scale)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; - // Left multiply the current matrix with the computed scale - // matrix. (transformation is about the local origin of the object) + /* Left multiply the current matrix with the computed scale + * matrix. (transformation is about the local origin of the object) */ STDMETHOD(ScaleLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; - // Right multiply the current matrix with the computed translation - // matrix. (transformation is about the current world origin) + /* Right multiply the current matrix with the computed translation + * matrix. (transformation is about the current world origin) */ STDMETHOD(Translate)(THIS_ FLOAT x, FLOAT y, FLOAT z ) PURE; - // Left multiply the current matrix with the computed translation - // matrix. (transformation is about the local origin of the object) + /* Left multiply the current matrix with the computed translation + * matrix. (transformation is about the local origin of the object) */ STDMETHOD(TranslateLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; - // Obtain the current matrix at the top of the stack + /* Obtain the current matrix at the top of the stack */ STDMETHOD_(D3DXMATRIX*, GetTop)(THIS) PURE; }; @@ -1388,30 +1377,27 @@ HRESULT WINAPI } #endif -//=========================================================================== -// -// Spherical Harmonic Runtime Routines -// -// NOTE: -// * Most of these functions can take the same object as in and out parameters. -// The exceptions are the rotation functions. -// -// * Out parameters are typically also returned as return values, so that -// the output of one function may be used as a parameter to another. -// -//============================================================================ +/* + * + * Spherical Harmonic Runtime Routines + * + * NOTE: + * * Most of these functions can take the same object as in and out parameters. + * The exceptions are the rotation functions. + * + * * Out parameters are typically also returned as return values, so that + * the output of one function may be used as a parameter to another. + */ - -// non-inline +/* non-inline */ #ifdef __cplusplus extern "C" { #endif -//============================================================================ -// -// Basic Spherical Harmonic math routines -// -//============================================================================ +/* + * + * Basic Spherical Harmonic math routines + */ #define D3DXSH_MINORDER 2 #define D3DXSH_MAXORDER 6 @@ -1440,12 +1426,10 @@ FLOAT* WINAPI D3DXSHMultiply4( FLOAT *pOut, CONST FLOAT *pF, CONST FLOAT *pG); FLOAT* WINAPI D3DXSHMultiply5( FLOAT *pOut, CONST FLOAT *pF, CONST FLOAT *pG); FLOAT* WINAPI D3DXSHMultiply6( FLOAT *pOut, CONST FLOAT *pF, CONST FLOAT *pG); - -//============================================================================ -// -// Basic Spherical Harmonic lighting routines -// -//============================================================================ +/* + * + * Basic Spherical Harmonic lighting routines + */ HRESULT WINAPI D3DXSHEvalDirectionalLight ( UINT Order, CONST D3DXVECTOR3 *pDir, @@ -1466,31 +1450,29 @@ HRESULT WINAPI D3DXSHEvalHemisphereLight ( UINT Order, CONST D3DXVECTOR3 *pDir, D3DXCOLOR Top, D3DXCOLOR Bottom, FLOAT *pROut, FLOAT *pGOut, FLOAT *pBOut ); -//============================================================================ -// -// Basic Spherical Harmonic projection routines -// -//============================================================================ +/* + * + * Basic Spherical Harmonic projection routines + */ -//============================================================================ -// -// D3DXSHProjectCubeMap: -// -------------------- -// Projects a function represented on a cube map into spherical harmonics. -// -// Parameters: -// Order -// Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 -// pCubeMap -// CubeMap that is going to be projected into spherical harmonics -// pROut -// Output SH vector for Red. -// pGOut -// Output SH vector for Green -// pBOut -// Output SH vector for Blue -// -//============================================================================ +/* + * + * D3DXSHProjectCubeMap: + * -------------------- + * Projects a function represented on a cube map into spherical harmonics. + * + * Parameters: + * Order + * Order of the SH evaluation, generates Order^2 coefs, degree is Order-1 + * pCubeMap + * CubeMap that is going to be projected into spherical harmonics + * pROut + * Output SH vector for Red. + * pGOut + * Output SH vector for Green + * pBOut + * Output SH vector for Blue + */ HRESULT WINAPI D3DXSHProjectCubeMap ( UINT uOrder, LPDIRECT3DCUBETEXTURE9 pCubeMap, diff --git a/gfx/include/d3d9/d3dx9math.inl b/gfx/include/d3d9/d3dx9math.inl index 1d747453da..08a408fc7c 100644 --- a/gfx/include/d3d9/d3dx9math.inl +++ b/gfx/include/d3d9/d3dx9math.inl @@ -1,26 +1,24 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx9math.inl -// Content: D3DX math inline functions -// -////////////////////////////////////////////////////////////////////////////// +/* + * + * Copyright (C) Microsoft Corporation. All Rights Reserved. + * + * File: d3dx9math.inl + * Content: D3DX math inline functions + */ #ifndef __D3DX9MATH_INL__ #define __D3DX9MATH_INL__ -//=========================================================================== -// -// Inline Class Methods -// -//=========================================================================== +/* + * + * Inline Class Methods + */ #ifdef __cplusplus -//-------------------------- -// Float16 -//-------------------------- +/* + * Float16 + */ D3DXINLINE D3DXFLOAT16::D3DXFLOAT16( FLOAT f ) @@ -34,7 +32,7 @@ D3DXFLOAT16::D3DXFLOAT16( CONST D3DXFLOAT16& f ) value = f.value; } -// casting +/* casting */ D3DXINLINE D3DXFLOAT16::operator FLOAT () { @@ -43,7 +41,7 @@ D3DXFLOAT16::operator FLOAT () return f; } -// binary operators +/* binary operators */ D3DXINLINE BOOL D3DXFLOAT16::operator == ( CONST D3DXFLOAT16& f ) const { @@ -57,9 +55,9 @@ D3DXFLOAT16::operator != ( CONST D3DXFLOAT16& f ) const } -//-------------------------- -// 2D Vector -//-------------------------- +/* + * 2D Vector + */ D3DXINLINE D3DXVECTOR2::D3DXVECTOR2( CONST FLOAT *pf ) @@ -81,8 +79,7 @@ D3DXVECTOR2::D3DXVECTOR2( FLOAT fx, FLOAT fy ) y = fy; } - -// casting +/* casting */ D3DXINLINE D3DXVECTOR2::operator FLOAT* () { @@ -95,8 +92,7 @@ D3DXVECTOR2::operator CONST FLOAT* () const return (CONST FLOAT *) &x; } - -// assignment operators +/* assignment operators */ D3DXINLINE D3DXVECTOR2& D3DXVECTOR2::operator += ( CONST D3DXVECTOR2& v ) { @@ -130,8 +126,7 @@ D3DXVECTOR2::operator /= ( FLOAT f ) return *this; } - -// unary operators +/* unary operators */ D3DXINLINE D3DXVECTOR2 D3DXVECTOR2::operator + () const { @@ -144,8 +139,7 @@ D3DXVECTOR2::operator - () const return D3DXVECTOR2(-x, -y); } - -// binary operators +/* binary operators */ D3DXINLINE D3DXVECTOR2 D3DXVECTOR2::operator + ( CONST D3DXVECTOR2& v ) const { @@ -189,11 +183,9 @@ D3DXVECTOR2::operator != ( CONST D3DXVECTOR2& v ) const return x != v.x || y != v.y; } - - -//-------------------------- -// 2D Vector (16 bit) -//-------------------------- +/* + * 2D Vector (16 bit) + */ D3DXINLINE D3DXVECTOR2_16F::D3DXVECTOR2_16F( CONST FLOAT *pf ) @@ -214,8 +206,7 @@ D3DXVECTOR2_16F::D3DXVECTOR2_16F( CONST D3DXFLOAT16 &fx, CONST D3DXFLOAT16 &fy ) y = fy; } - -// casting +/* casting */ D3DXINLINE D3DXVECTOR2_16F::operator D3DXFLOAT16* () { @@ -228,8 +219,7 @@ D3DXVECTOR2_16F::operator CONST D3DXFLOAT16* () const return (CONST D3DXFLOAT16*) &x; } - -// binary operators +/* binary operators */ D3DXINLINE BOOL D3DXVECTOR2_16F::operator == ( CONST D3DXVECTOR2_16F &v ) const { @@ -243,9 +233,9 @@ D3DXVECTOR2_16F::operator != ( CONST D3DXVECTOR2_16F &v ) const } -//-------------------------- -// 3D Vector -//-------------------------- +/* + * 3D Vector + */ D3DXINLINE D3DXVECTOR3::D3DXVECTOR3( CONST FLOAT *pf ) { @@ -276,8 +266,7 @@ D3DXVECTOR3::D3DXVECTOR3( FLOAT fx, FLOAT fy, FLOAT fz ) z = fz; } - -// casting +/* casting */ D3DXINLINE D3DXVECTOR3::operator FLOAT* () { @@ -290,8 +279,7 @@ D3DXVECTOR3::operator CONST FLOAT* () const return (CONST FLOAT *) &x; } - -// assignment operators +/* assignment operators */ D3DXINLINE D3DXVECTOR3& D3DXVECTOR3::operator += ( CONST D3DXVECTOR3& v ) { @@ -329,8 +317,7 @@ D3DXVECTOR3::operator /= ( FLOAT f ) return *this; } - -// unary operators +/* unary operators */ D3DXINLINE D3DXVECTOR3 D3DXVECTOR3::operator + () const { @@ -343,8 +330,7 @@ D3DXVECTOR3::operator - () const return D3DXVECTOR3(-x, -y, -z); } - -// binary operators +/* binary operators */ D3DXINLINE D3DXVECTOR3 D3DXVECTOR3::operator + ( CONST D3DXVECTOR3& v ) const { @@ -390,11 +376,9 @@ D3DXVECTOR3::operator != ( CONST D3DXVECTOR3& v ) const return x != v.x || y != v.y || z != v.z; } - - -//-------------------------- -// 3D Vector (16 bit) -//-------------------------- +/* + * 3D Vector (16 bit) + */ D3DXINLINE D3DXVECTOR3_16F::D3DXVECTOR3_16F( CONST FLOAT *pf ) @@ -425,8 +409,7 @@ D3DXVECTOR3_16F::D3DXVECTOR3_16F( CONST D3DXFLOAT16 &fx, CONST D3DXFLOAT16 &fy, z = fz; } - -// casting +/* casting */ D3DXINLINE D3DXVECTOR3_16F::operator D3DXFLOAT16* () { @@ -439,8 +422,7 @@ D3DXVECTOR3_16F::operator CONST D3DXFLOAT16* () const return (CONST D3DXFLOAT16*) &x; } - -// binary operators +/* binary operators */ D3DXINLINE BOOL D3DXVECTOR3_16F::operator == ( CONST D3DXVECTOR3_16F &v ) const { @@ -456,9 +438,9 @@ D3DXVECTOR3_16F::operator != ( CONST D3DXVECTOR3_16F &v ) const } -//-------------------------- -// 4D Vector -//-------------------------- +/* + * 4D Vector + */ D3DXINLINE D3DXVECTOR4::D3DXVECTOR4( CONST FLOAT *pf ) { @@ -492,8 +474,7 @@ D3DXVECTOR4::D3DXVECTOR4( FLOAT fx, FLOAT fy, FLOAT fz, FLOAT fw ) w = fw; } - -// casting +/* casting */ D3DXINLINE D3DXVECTOR4::operator FLOAT* () { @@ -506,8 +487,7 @@ D3DXVECTOR4::operator CONST FLOAT* () const return (CONST FLOAT *) &x; } - -// assignment operators +/* assignment operators */ D3DXINLINE D3DXVECTOR4& D3DXVECTOR4::operator += ( CONST D3DXVECTOR4& v ) { @@ -549,8 +529,7 @@ D3DXVECTOR4::operator /= ( FLOAT f ) return *this; } - -// unary operators +/* unary operators */ D3DXINLINE D3DXVECTOR4 D3DXVECTOR4::operator + () const { @@ -563,8 +542,7 @@ D3DXVECTOR4::operator - () const return D3DXVECTOR4(-x, -y, -z, -w); } - -// binary operators +/* binary operators */ D3DXINLINE D3DXVECTOR4 D3DXVECTOR4::operator + ( CONST D3DXVECTOR4& v ) const { @@ -609,11 +587,9 @@ D3DXVECTOR4::operator != ( CONST D3DXVECTOR4& v ) const return x != v.x || y != v.y || z != v.z || w != v.w; } - - -//-------------------------- -// 4D Vector (16 bit) -//-------------------------- +/* + * 4D Vector (16 bit) + */ D3DXINLINE D3DXVECTOR4_16F::D3DXVECTOR4_16F( CONST FLOAT *pf ) @@ -646,8 +622,7 @@ D3DXVECTOR4_16F::D3DXVECTOR4_16F( CONST D3DXFLOAT16 &fx, CONST D3DXFLOAT16 &fy, w = fw; } - -// casting +/* casting */ D3DXINLINE D3DXVECTOR4_16F::operator D3DXFLOAT16* () { @@ -660,8 +635,7 @@ D3DXVECTOR4_16F::operator CONST D3DXFLOAT16* () const return (CONST D3DXFLOAT16*) &x; } - -// binary operators +/* binary operators */ D3DXINLINE BOOL D3DXVECTOR4_16F::operator == ( CONST D3DXVECTOR4_16F &v ) const { @@ -677,9 +651,9 @@ D3DXVECTOR4_16F::operator != ( CONST D3DXVECTOR4_16F &v ) const } -//-------------------------- -// Matrix -//-------------------------- +/* + * Matrix + */ D3DXINLINE D3DXMATRIX::D3DXMATRIX( CONST FLOAT* pf ) { @@ -710,9 +684,7 @@ D3DXMATRIX::D3DXMATRIX( FLOAT f11, FLOAT f12, FLOAT f13, FLOAT f14, _41 = f41; _42 = f42; _43 = f43; _44 = f44; } - - -// access grants +/* access grants */ D3DXINLINE FLOAT& D3DXMATRIX::operator () ( UINT iRow, UINT iCol ) { @@ -725,8 +697,7 @@ D3DXMATRIX::operator () ( UINT iRow, UINT iCol ) const return m[iRow][iCol]; } - -// casting operators +/* casting operators */ D3DXINLINE D3DXMATRIX::operator FLOAT* () { @@ -739,8 +710,7 @@ D3DXMATRIX::operator CONST FLOAT* () const return (CONST FLOAT *) &_11; } - -// assignment operators +/* assignment operators */ D3DXINLINE D3DXMATRIX& D3DXMATRIX::operator *= ( CONST D3DXMATRIX& mat ) { @@ -789,8 +759,7 @@ D3DXMATRIX::operator /= ( FLOAT f ) return *this; } - -// unary operators +/* unary operators */ D3DXINLINE D3DXMATRIX D3DXMATRIX::operator + () const { @@ -806,8 +775,7 @@ D3DXMATRIX::operator - () const -_41, -_42, -_43, -_44); } - -// binary operators +/* binary operators */ D3DXINLINE D3DXMATRIX D3DXMATRIX::operator * ( CONST D3DXMATRIX& mat ) const { @@ -876,11 +844,9 @@ D3DXMATRIX::operator != ( CONST D3DXMATRIX& mat ) const return 0 != memcmp(this, &mat, sizeof(D3DXMATRIX)); } - - -//-------------------------- -// Aligned Matrices -//-------------------------- +/* + * Aligned Matrices + */ D3DXINLINE _D3DXMATRIXA16::_D3DXMATRIXA16( CONST FLOAT* f ) : @@ -975,10 +941,9 @@ _D3DXMATRIXA16::operator=(CONST D3DXMATRIX& rhs) return *this; } - -//-------------------------- -// Quaternion -//-------------------------- +/* + * Quaternion + */ D3DXINLINE D3DXQUATERNION::D3DXQUATERNION( CONST FLOAT* pf ) @@ -1004,8 +969,7 @@ D3DXQUATERNION::D3DXQUATERNION( FLOAT fx, FLOAT fy, FLOAT fz, FLOAT fw ) w = fw; } - -// casting +/* casting */ D3DXINLINE D3DXQUATERNION::operator FLOAT* () { @@ -1018,8 +982,7 @@ D3DXQUATERNION::operator CONST FLOAT* () const return (CONST FLOAT *) &x; } - -// assignment operators +/* assignment operators */ D3DXINLINE D3DXQUATERNION& D3DXQUATERNION::operator += ( CONST D3DXQUATERNION& q ) { @@ -1068,8 +1031,7 @@ D3DXQUATERNION::operator /= ( FLOAT f ) return *this; } - -// unary operators +/* unary operators */ D3DXINLINE D3DXQUATERNION D3DXQUATERNION::operator + () const { @@ -1082,8 +1044,7 @@ D3DXQUATERNION::operator - () const return D3DXQUATERNION(-x, -y, -z, -w); } - -// binary operators +/* binary operators */ D3DXINLINE D3DXQUATERNION D3DXQUATERNION::operator + ( CONST D3DXQUATERNION& q ) const { @@ -1137,11 +1098,9 @@ D3DXQUATERNION::operator != ( CONST D3DXQUATERNION& q ) const return x != q.x || y != q.y || z != q.z || w != q.w; } - - -//-------------------------- -// Plane -//-------------------------- +/* + * Plane + */ D3DXINLINE D3DXPLANE::D3DXPLANE( CONST FLOAT* pf ) @@ -1167,8 +1126,7 @@ D3DXPLANE::D3DXPLANE( FLOAT fa, FLOAT fb, FLOAT fc, FLOAT fd ) d = fd; } - -// casting +/* casting */ D3DXINLINE D3DXPLANE::operator FLOAT* () { @@ -1181,8 +1139,7 @@ D3DXPLANE::operator CONST FLOAT* () const return (CONST FLOAT *) &a; } - -// assignment operators +/* assignment operators */ D3DXINLINE D3DXPLANE& D3DXPLANE::operator *= ( FLOAT f ) { @@ -1204,8 +1161,7 @@ D3DXPLANE::operator /= ( FLOAT f ) return *this; } - -// unary operators +/* unary operators */ D3DXINLINE D3DXPLANE D3DXPLANE::operator + () const { @@ -1218,8 +1174,7 @@ D3DXPLANE::operator - () const return D3DXPLANE(-a, -b, -c, -d); } - -// binary operators +/* binary operators */ D3DXINLINE D3DXPLANE D3DXPLANE::operator * ( FLOAT f ) const { @@ -1251,12 +1206,9 @@ D3DXPLANE::operator != ( CONST D3DXPLANE& p ) const return a != p.a || b != p.b || c != p.c || d != p.d; } - - - -//-------------------------- -// Color -//-------------------------- +/* + * Color + */ D3DXINLINE D3DXCOLOR::D3DXCOLOR( DWORD dw ) @@ -1301,8 +1253,7 @@ D3DXCOLOR::D3DXCOLOR( FLOAT fr, FLOAT fg, FLOAT fb, FLOAT fa ) a = fa; } - -// casting +/* casting */ D3DXINLINE D3DXCOLOR::operator DWORD () const { @@ -1353,8 +1304,7 @@ D3DXCOLOR::operator CONST D3DCOLORVALUE& () const return *((CONST D3DCOLORVALUE *) &r); } - -// assignment operators +/* assignment operators */ D3DXINLINE D3DXCOLOR& D3DXCOLOR::operator += ( CONST D3DXCOLOR& c ) { @@ -1396,8 +1346,7 @@ D3DXCOLOR::operator /= ( FLOAT f ) return *this; } - -// unary operators +/* unary operators */ D3DXINLINE D3DXCOLOR D3DXCOLOR::operator + () const { @@ -1410,8 +1359,7 @@ D3DXCOLOR::operator - () const return D3DXCOLOR(-r, -g, -b, -a); } - -// binary operators +/* binary operators */ D3DXINLINE D3DXCOLOR D3DXCOLOR::operator + ( CONST D3DXCOLOR& c ) const { @@ -1458,20 +1406,17 @@ D3DXCOLOR::operator != ( CONST D3DXCOLOR& c ) const } -#endif //__cplusplus +#endif /*__cplusplus */ + +/* + * + * Inline functions + */ - -//=========================================================================== -// -// Inline functions -// -//=========================================================================== - - -//-------------------------- -// 2D Vector -//-------------------------- +/* + * 2D Vector + */ D3DXINLINE FLOAT D3DXVec2Length ( CONST D3DXVECTOR2 *pV ) @@ -1550,10 +1495,9 @@ D3DXINLINE D3DXVECTOR2* D3DXVec2Lerp return pOut; } - -//-------------------------- -// 3D Vector -//-------------------------- +/* + * 3D Vector + */ D3DXINLINE FLOAT D3DXVec3Length ( CONST D3DXVECTOR3 *pV ) @@ -1646,9 +1590,9 @@ D3DXINLINE D3DXVECTOR3* D3DXVec3Lerp } -//-------------------------- -// 4D Vector -//-------------------------- +/* + * 4D Vector + */ D3DXINLINE FLOAT D3DXVec4Length ( CONST D3DXVECTOR4 *pV ) @@ -1734,9 +1678,9 @@ D3DXINLINE D3DXVECTOR4* D3DXVec4Lerp } -//-------------------------- -// 4D Matrix -//-------------------------- +/* + * 4D Matrix + */ D3DXINLINE D3DXMATRIX* D3DXMatrixIdentity ( D3DXMATRIX *pOut ) @@ -1761,9 +1705,9 @@ D3DXINLINE BOOL D3DXMatrixIsIdentity } -//-------------------------- -// Quaternion -//-------------------------- +/* + * Quaternion + */ D3DXINLINE FLOAT D3DXQuaternionLength ( CONST D3DXQUATERNION *pQ ) @@ -1813,10 +1757,9 @@ D3DXINLINE D3DXQUATERNION* D3DXQuaternionConjugate return pOut; } - -//-------------------------- -// Plane -//-------------------------- +/* + * Plane + */ D3DXINLINE FLOAT D3DXPlaneDot ( CONST D3DXPLANE *pP, CONST D3DXVECTOR4 *pV) @@ -1847,9 +1790,9 @@ D3DXINLINE D3DXPLANE* D3DXPlaneScale } -//-------------------------- -// Color -//-------------------------- +/* + * Color + */ D3DXINLINE D3DXCOLOR* D3DXColorNegative (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC) @@ -1912,4 +1855,4 @@ D3DXINLINE D3DXCOLOR* D3DXColorLerp } -#endif // __D3DX9MATH_INL__ +#endif /* __D3DX9MATH_INL__ */ diff --git a/gfx/include/d3d9/d3dx9xof.h b/gfx/include/d3d9/d3dx9xof.h index b581e0c858..1e0a249e37 100644 --- a/gfx/include/d3d9/d3dx9xof.h +++ b/gfx/include/d3d9/d3dx9xof.h @@ -34,59 +34,59 @@ typedef DWORD D3DXF_FILELOADOPTIONS; #define D3DXF_FILELOAD_FROMRESOURCE 0x02L #define D3DXF_FILELOAD_FROMMEMORY 0x03L -//---------------------------------------------------------------------------- -// D3DXF_FILELOADRESOURCE: -//---------------------------------------------------------------------------- +/* + * D3DXF_FILELOADRESOURCE: +*/ typedef struct _D3DXF_FILELOADRESOURCE { - HMODULE hModule; // Desc - LPCSTR lpName; // Desc - LPCSTR lpType; // Desc + HMODULE hModule; /* Desc */ + LPCSTR lpName; /* Desc */ + LPCSTR lpType; /* Desc */ } D3DXF_FILELOADRESOURCE; -//---------------------------------------------------------------------------- -// D3DXF_FILELOADMEMORY: -//---------------------------------------------------------------------------- +/* + * D3DXF_FILELOADMEMORY: + */ typedef struct _D3DXF_FILELOADMEMORY { - LPCVOID lpMemory; // Desc - SIZE_T dSize; // Desc + LPCVOID lpMemory; /* Desc */ + SIZE_T dSize; /* Desc */ } D3DXF_FILELOADMEMORY; #if defined( _WIN32 ) && !defined( _NO_COM ) -// {cef08cf9-7b4f-4429-9624-2a690a933201} +/* {cef08cf9-7b4f-4429-9624-2a690a933201} */ DEFINE_GUID( IID_ID3DXFile, 0xcef08cf9, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); -// {cef08cfa-7b4f-4429-9624-2a690a933201} +/* {cef08cfa-7b4f-4429-9624-2a690a933201} */ DEFINE_GUID( IID_ID3DXFileSaveObject, 0xcef08cfa, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); -// {cef08cfb-7b4f-4429-9624-2a690a933201} +/* {cef08cfb-7b4f-4429-9624-2a690a933201} */ DEFINE_GUID( IID_ID3DXFileSaveData, 0xcef08cfb, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); -// {cef08cfc-7b4f-4429-9624-2a690a933201} +/* {cef08cfc-7b4f-4429-9624-2a690a933201} */ DEFINE_GUID( IID_ID3DXFileEnumObject, 0xcef08cfc, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); -// {cef08cfd-7b4f-4429-9624-2a690a933201} +/* {cef08cfd-7b4f-4429-9624-2a690a933201} */ DEFINE_GUID( IID_ID3DXFileData, 0xcef08cfd, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); -#endif // defined( _WIN32 ) && !defined( _NO_COM ) +#endif /* defined( _WIN32 ) && !defined( _NO_COM ) */ #if defined( __cplusplus ) #if !defined( DECLSPEC_UUID ) #if _MSC_VER >= 1100 #define DECLSPEC_UUID( x ) __declspec( uuid( x ) ) -#else // !( _MSC_VER >= 1100 ) +#else /* !( _MSC_VER >= 1100 ) */ #define DECLSPEC_UUID( x ) -#endif // !( _MSC_VER >= 1100 ) -#endif // !defined( DECLSPEC_UUID ) +#endif /* !( _MSC_VER >= 1100 ) */ +#endif /* !defined( DECLSPEC_UUID ) */ interface DECLSPEC_UUID( "cef08cf9-7b4f-4429-9624-2a690a933201" ) ID3DXFile; @@ -110,8 +110,8 @@ _COM_SMARTPTR_TYPEDEF( ID3DXFileEnumObject, __uuidof( ID3DXFileEnumObject ) ); _COM_SMARTPTR_TYPEDEF( ID3DXFileData, __uuidof( ID3DXFileData ) ); -#endif // defined( _COM_SMARTPTR_TYPEDEF ) -#endif // defined( __cplusplus ) +#endif /* defined( _COM_SMARTPTR_TYPEDEF ) */ +#endif /* defined( __cplusplus ) */ typedef interface ID3DXFile ID3DXFile; typedef interface ID3DXFileSaveObject ID3DXFileSaveObject; @@ -119,9 +119,9 @@ typedef interface ID3DXFileSaveData ID3DXFileSaveData; typedef interface ID3DXFileEnumObject ID3DXFileEnumObject; typedef interface ID3DXFileData ID3DXFileData; -////////////////////////////////////////////////////////////////////////////// -// ID3DXFile ///////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// +/* + * ID3DXFile + */ #undef INTERFACE #define INTERFACE ID3DXFile @@ -140,9 +140,9 @@ DECLARE_INTERFACE_( ID3DXFile, IUnknown ) STDMETHOD( RegisterEnumTemplates )( THIS_ ID3DXFileEnumObject* ) PURE; }; -////////////////////////////////////////////////////////////////////////////// -// ID3DXFileSaveObject /////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// +/* + * ID3DXFileSaveObject + */ #undef INTERFACE #define INTERFACE ID3DXFileSaveObject @@ -159,9 +159,9 @@ DECLARE_INTERFACE_( ID3DXFileSaveObject, IUnknown ) STDMETHOD( Save )( THIS ) PURE; }; -////////////////////////////////////////////////////////////////////////////// -// ID3DXFileSaveData ///////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// +/* + * ID3DXFileSaveData + */ #undef INTERFACE #define INTERFACE ID3DXFileSaveData @@ -181,9 +181,9 @@ DECLARE_INTERFACE_( ID3DXFileSaveData, IUnknown ) STDMETHOD( AddDataReference )( THIS_ LPCSTR, CONST GUID* ) PURE; }; -////////////////////////////////////////////////////////////////////////////// -// ID3DXFileEnumObject /////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// +/* + * ID3DXFileEnumObject + */ #undef INTERFACE #define INTERFACE ID3DXFileEnumObject @@ -201,9 +201,9 @@ DECLARE_INTERFACE_( ID3DXFileEnumObject, IUnknown ) STDMETHOD( GetDataObjectByName )( THIS_ LPCSTR, ID3DXFileData** ) PURE; }; -////////////////////////////////////////////////////////////////////////////// -// ID3DXFileData ///////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// +/* + * ID3DXFileData + */ #undef INTERFACE #define INTERFACE ID3DXFileData From 5d2b7ce32f756a002204756e63de6dafcf95aeae Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 3 Feb 2018 15:29:56 +0100 Subject: [PATCH 036/232] (D3D8 headers) Start making this C89-compatible --- gfx/include/d3d8/d3dx8core.h | 4 +- gfx/include/d3d8/d3dx8effect.h | 89 ++++++------ gfx/include/d3d8/d3dx8mesh.h | 196 +++++++++++++------------- gfx/include/d3d8/d3dx8shape.h | 243 +++++++++++++++++---------------- gfx/include/d3d8/d3dx8tex.h | 27 ++-- 5 files changed, 280 insertions(+), 279 deletions(-) diff --git a/gfx/include/d3d8/d3dx8core.h b/gfx/include/d3d8/d3dx8core.h index 5620f645e7..5629124aa0 100644 --- a/gfx/include/d3d8/d3dx8core.h +++ b/gfx/include/d3d8/d3dx8core.h @@ -555,6 +555,6 @@ HRESULT WINAPI #ifdef __cplusplus } -#endif //__cplusplus +#endif /* __cplusplus */ -#endif //__D3DX8CORE_H__ +#endif /* __D3DX8CORE_H__ */ diff --git a/gfx/include/d3d8/d3dx8effect.h b/gfx/include/d3d8/d3dx8effect.h index 8444935877..45b4fc8be9 100644 --- a/gfx/include/d3d8/d3dx8effect.h +++ b/gfx/include/d3d8/d3dx8effect.h @@ -1,11 +1,10 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx8effect.h -// Content: D3DX effect types and functions -// -/////////////////////////////////////////////////////////////////////////// +/* + * + * Copyright (C) Microsoft Corporation. All Rights Reserved. + * + * File: d3dx8effect.h + * Content: D3DX effect types and functions + */ #include "d3dx8.h" @@ -67,14 +66,14 @@ typedef struct _D3DXPASS_DESC -////////////////////////////////////////////////////////////////////////////// -// ID3DXEffect /////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// +/* + * ID3DXEffect + */ typedef interface ID3DXEffect ID3DXEffect; typedef interface ID3DXEffect *LPD3DXEFFECT; -// {648B1CEB-8D4E-4d66-B6FA-E44969E82E89} +/* {648B1CEB-8D4E-4d66-B6FA-E44969E82E89} */ DEFINE_GUID( IID_ID3DXEffect, 0x648b1ceb, 0x8d4e, 0x4d66, 0xb6, 0xfa, 0xe4, 0x49, 0x69, 0xe8, 0x2e, 0x89); @@ -84,12 +83,12 @@ DEFINE_GUID( IID_ID3DXEffect, DECLARE_INTERFACE_(ID3DXEffect, IUnknown) { - // IUnknown + /* IUnknown */ STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; STDMETHOD_(ULONG, AddRef)(THIS) PURE; STDMETHOD_(ULONG, Release)(THIS) PURE; - // ID3DXEffect + /* ID3DXEffect */ STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; STDMETHOD(GetDesc)(THIS_ D3DXEFFECT_DESC* pDesc) PURE; STDMETHOD(GetParameterDesc)(THIS_ LPCSTR pParameter, D3DXPARAMETER_DESC* pDesc) PURE; @@ -130,41 +129,41 @@ DECLARE_INTERFACE_(ID3DXEffect, IUnknown) -////////////////////////////////////////////////////////////////////////////// -// APIs ////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// +/* + * APIs + */ #ifdef __cplusplus extern "C" { -#endif //__cplusplus +#endif /* __cplusplus */ -//---------------------------------------------------------------------------- -// D3DXCreateEffect: -// ----------------- -// Creates an effect from an ascii or binaray effect description. -// -// Parameters: -// pDevice -// Pointer of the device on which to create the effect -// pSrcFile -// Name of the file containing the effect description -// hSrcModule -// Module handle. if NULL, current module will be used. -// pSrcResource -// Resource name in module -// pSrcData -// Pointer to effect description -// SrcDataSize -// Size of the effect description in bytes -// ppEffect -// Returns a buffer containing created effect. -// ppCompilationErrors -// Returns a buffer containing any error messages which occurred during -// compile. Or NULL if you do not care about the error messages. -// -//---------------------------------------------------------------------------- +/* + * D3DXCreateEffect: + * ----------------- + * Creates an effect from an ascii or binaray effect description. + * + * Parameters: + * pDevice + * Pointer of the device on which to create the effect + * pSrcFile + * Name of the file containing the effect description + * hSrcModule + * Module handle. if NULL, current module will be used. + * pSrcResource + * Resource name in module + * pSrcData + * Pointer to effect description + * SrcDataSize + * Size of the effect description in bytes + * ppEffect + * Returns a buffer containing created effect. + * ppCompilationErrors + * Returns a buffer containing any error messages which occurred during + * compile. Or NULL if you do not care about the error messages. + * + */ HRESULT WINAPI D3DXCreateEffectFromFileA( @@ -221,6 +220,6 @@ HRESULT WINAPI #ifdef __cplusplus } -#endif //__cplusplus +#endif /* __cplusplus */ -#endif //__D3DX8EFFECT_H__ +#endif /* __D3DX8EFFECT_H__ */ diff --git a/gfx/include/d3d8/d3dx8mesh.h b/gfx/include/d3d8/d3dx8mesh.h index f17d92c8bd..41e623cabf 100644 --- a/gfx/include/d3d8/d3dx8mesh.h +++ b/gfx/include/d3d8/d3dx8mesh.h @@ -1,76 +1,74 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx8mesh.h -// Content: D3DX mesh types and functions -// -////////////////////////////////////////////////////////////////////////////// +/* + * + * Copyright (C) Microsoft Corporation. All Rights Reserved. + * + * File: d3dx8mesh.h + * Content: D3DX mesh types and functions + */ #include "d3dx8.h" #ifndef __D3DX8MESH_H__ #define __D3DX8MESH_H__ -#include "dxfile.h" // defines LPDIRECTXFILEDATA +#include "dxfile.h" /* defines LPDIRECTXFILEDATA */ -// {2A835771-BF4D-43f4-8E14-82A809F17D8A} +/* {2A835771-BF4D-43f4-8E14-82A809F17D8A} */ DEFINE_GUID(IID_ID3DXBaseMesh, 0x2a835771, 0xbf4d, 0x43f4, 0x8e, 0x14, 0x82, 0xa8, 0x9, 0xf1, 0x7d, 0x8a); -// {CCAE5C3B-4DD1-4d0f-997E-4684CA64557F} +/* {CCAE5C3B-4DD1-4d0f-997E-4684CA64557F} */ DEFINE_GUID(IID_ID3DXMesh, 0xccae5c3b, 0x4dd1, 0x4d0f, 0x99, 0x7e, 0x46, 0x84, 0xca, 0x64, 0x55, 0x7f); -// {19FBE386-C282-4659-97BD-CB869B084A6C} +/* {19FBE386-C282-4659-97BD-CB869B084A6C} */ DEFINE_GUID(IID_ID3DXPMesh, 0x19fbe386, 0xc282, 0x4659, 0x97, 0xbd, 0xcb, 0x86, 0x9b, 0x8, 0x4a, 0x6c); -// {4E3CA05C-D4FF-4d11-8A02-16459E08F6F4} +/* {4E3CA05C-D4FF-4d11-8A02-16459E08F6F4} */ DEFINE_GUID(IID_ID3DXSPMesh, 0x4e3ca05c, 0xd4ff, 0x4d11, 0x8a, 0x2, 0x16, 0x45, 0x9e, 0x8, 0xf6, 0xf4); -// {8DB06ECC-EBFC-408a-9404-3074B4773515} +/* {8DB06ECC-EBFC-408a-9404-3074B4773515} */ DEFINE_GUID(IID_ID3DXSkinMesh, 0x8db06ecc, 0xebfc, 0x408a, 0x94, 0x4, 0x30, 0x74, 0xb4, 0x77, 0x35, 0x15); -// Mesh options - lower 3 bytes only, upper byte used by _D3DXMESHOPT option flags +/* Mesh options - lower 3 bytes only, upper byte used by _D3DXMESHOPT option flags */ enum _D3DXMESH { - D3DXMESH_32BIT = 0x001, // If set, then use 32 bit indices, if not set use 16 bit indices. - D3DXMESH_DONOTCLIP = 0x002, // Use D3DUSAGE_DONOTCLIP for VB & IB. - D3DXMESH_POINTS = 0x004, // Use D3DUSAGE_POINTS for VB & IB. - D3DXMESH_RTPATCHES = 0x008, // Use D3DUSAGE_RTPATCHES for VB & IB. - D3DXMESH_NPATCHES = 0x4000,// Use D3DUSAGE_NPATCHES for VB & IB. - D3DXMESH_VB_SYSTEMMEM = 0x010, // Use D3DPOOL_SYSTEMMEM for VB. Overrides D3DXMESH_MANAGEDVERTEXBUFFER - D3DXMESH_VB_MANAGED = 0x020, // Use D3DPOOL_MANAGED for VB. - D3DXMESH_VB_WRITEONLY = 0x040, // Use D3DUSAGE_WRITEONLY for VB. - D3DXMESH_VB_DYNAMIC = 0x080, // Use D3DUSAGE_DYNAMIC for VB. - D3DXMESH_VB_SOFTWAREPROCESSING = 0x8000, // Use D3DUSAGE_SOFTWAREPROCESSING for VB. - D3DXMESH_IB_SYSTEMMEM = 0x100, // Use D3DPOOL_SYSTEMMEM for IB. Overrides D3DXMESH_MANAGEDINDEXBUFFER - D3DXMESH_IB_MANAGED = 0x200, // Use D3DPOOL_MANAGED for IB. - D3DXMESH_IB_WRITEONLY = 0x400, // Use D3DUSAGE_WRITEONLY for IB. - D3DXMESH_IB_DYNAMIC = 0x800, // Use D3DUSAGE_DYNAMIC for IB. - D3DXMESH_IB_SOFTWAREPROCESSING= 0x10000, // Use D3DUSAGE_SOFTWAREPROCESSING for IB. + D3DXMESH_32BIT = 0x001, /* If set, then use 32 bit indices, if not set use 16 bit indices. */ + D3DXMESH_DONOTCLIP = 0x002, /* Use D3DUSAGE_DONOTCLIP for VB & IB. */ + D3DXMESH_POINTS = 0x004, /* Use D3DUSAGE_POINTS for VB & IB. */ + D3DXMESH_RTPATCHES = 0x008, /* Use D3DUSAGE_RTPATCHES for VB & IB. */ + D3DXMESH_NPATCHES = 0x4000,/* Use D3DUSAGE_NPATCHES for VB & IB. */ + D3DXMESH_VB_SYSTEMMEM = 0x010, /* Use D3DPOOL_SYSTEMMEM for VB. Overrides D3DXMESH_MANAGEDVERTEXBUFFER */ + D3DXMESH_VB_MANAGED = 0x020, /* Use D3DPOOL_MANAGED for VB. */ + D3DXMESH_VB_WRITEONLY = 0x040, /* Use D3DUSAGE_WRITEONLY for VB. */ + D3DXMESH_VB_DYNAMIC = 0x080, /* Use D3DUSAGE_DYNAMIC for VB. */ + D3DXMESH_VB_SOFTWAREPROCESSING = 0x8000, /* Use D3DUSAGE_SOFTWAREPROCESSING for VB. */ + D3DXMESH_IB_SYSTEMMEM = 0x100, /* Use D3DPOOL_SYSTEMMEM for IB. Overrides D3DXMESH_MANAGEDINDEXBUFFER */ + D3DXMESH_IB_MANAGED = 0x200, /* Use D3DPOOL_MANAGED for IB. */ + D3DXMESH_IB_WRITEONLY = 0x400, /* Use D3DUSAGE_WRITEONLY for IB. */ + D3DXMESH_IB_DYNAMIC = 0x800, /* Use D3DUSAGE_DYNAMIC for IB. */ + D3DXMESH_IB_SOFTWAREPROCESSING= 0x10000, /* Use D3DUSAGE_SOFTWAREPROCESSING for IB. */ - D3DXMESH_VB_SHARE = 0x1000, // Valid for Clone* calls only, forces cloned mesh/pmesh to share vertex buffer + D3DXMESH_VB_SHARE = 0x1000, /* Valid for Clone* calls only, forces cloned mesh/pmesh to share vertex buffer */ - D3DXMESH_USEHWONLY = 0x2000, // Valid for ID3DXSkinMesh::ConvertToBlendedMesh + D3DXMESH_USEHWONLY = 0x2000, /* Valid for ID3DXSkinMesh::ConvertToBlendedMesh */ - // Helper options - D3DXMESH_SYSTEMMEM = 0x110, // D3DXMESH_VB_SYSTEMMEM | D3DXMESH_IB_SYSTEMMEM - D3DXMESH_MANAGED = 0x220, // D3DXMESH_VB_MANAGED | D3DXMESH_IB_MANAGED - D3DXMESH_WRITEONLY = 0x440, // D3DXMESH_VB_WRITEONLY | D3DXMESH_IB_WRITEONLY - D3DXMESH_DYNAMIC = 0x880, // D3DXMESH_VB_DYNAMIC | D3DXMESH_IB_DYNAMIC - D3DXMESH_SOFTWAREPROCESSING = 0x18000, // D3DXMESH_VB_SOFTWAREPROCESSING | D3DXMESH_IB_SOFTWAREPROCESSING + /* Helper options */ + D3DXMESH_SYSTEMMEM = 0x110, /* D3DXMESH_VB_SYSTEMMEM | D3DXMESH_IB_SYSTEMMEM */ + D3DXMESH_MANAGED = 0x220, /* D3DXMESH_VB_MANAGED | D3DXMESH_IB_MANAGED */ + D3DXMESH_WRITEONLY = 0x440, /* D3DXMESH_VB_WRITEONLY | D3DXMESH_IB_WRITEONLY */ + D3DXMESH_DYNAMIC = 0x880, /* D3DXMESH_VB_DYNAMIC | D3DXMESH_IB_DYNAMIC */ + D3DXMESH_SOFTWAREPROCESSING = 0x18000 /* D3DXMESH_VB_SOFTWAREPROCESSING | D3DXMESH_IB_SOFTWAREPROCESSING */ }; -// option field values for specifying min value in D3DXGeneratePMesh and D3DXSimplifyMesh +/* option field values for specifying min value in D3DXGeneratePMesh and D3DXSimplifyMesh */ enum _D3DXMESHSIMP { D3DXMESHSIMP_VERTEX = 0x1, - D3DXMESHSIMP_FACE = 0x2, - + D3DXMESHSIMP_FACE = 0x2 }; enum _MAX_FVF_DECL_SIZE @@ -97,7 +95,7 @@ typedef D3DXATTRIBUTERANGE* LPD3DXATTRIBUTERANGE; #ifdef __cplusplus extern "C" { -#endif //__cplusplus +#endif /* __cplusplus */ struct D3DXMATERIAL { D3DMATERIAL8 MatD3D; @@ -106,7 +104,7 @@ struct D3DXMATERIAL typedef struct D3DXMATERIAL *LPD3DXMATERIAL; #ifdef __cplusplus } -#endif //__cplusplus +#endif /* __cplusplus */ typedef struct _D3DXATTRIBUTEWEIGHTS { @@ -122,14 +120,14 @@ typedef D3DXATTRIBUTEWEIGHTS* LPD3DXATTRIBUTEWEIGHTS; enum _D3DXWELDEPSILONSFLAGS { - D3DXWELDEPSILONS_WELDALL = 0x1, // weld all vertices marked by adjacency as being overlapping + D3DXWELDEPSILONS_WELDALL = 0x1, /* weld all vertices marked by adjacency as being overlapping */ - D3DXWELDEPSILONS_WELDPARTIALMATCHES = 0x2, // if a given vertex component is within epsilon, modify partial matched - // vertices so that both components identical AND if all components "equal" - // remove one of the vertices - D3DXWELDEPSILONS_DONOTREMOVEVERTICES = 0x4, // instructs weld to only allow modifications to vertices and not removal - // ONLY valid if D3DXWELDEPSILONS_WELDPARTIALMATCHES is set - // useful to modify vertices to be equal, but not allow vertices to be removed + D3DXWELDEPSILONS_WELDPARTIALMATCHES = 0x2, /* if a given vertex component is within epsilon, modify partial matched + * vertices so that both components identical AND if all components "equal" + * remove one of the vertices */ + D3DXWELDEPSILONS_DONOTREMOVEVERTICES = 0x4 /* instructs weld to only allow modifications to vertices and not removal + * ONLY valid if D3DXWELDEPSILONS_WELDPARTIALMATCHES is set + * useful to modify vertices to be equal, but not allow vertices to be removed */ }; typedef struct _D3DXWELDEPSILONS @@ -148,12 +146,12 @@ typedef D3DXWELDEPSILONS* LPD3DXWELDEPSILONS; DECLARE_INTERFACE_(ID3DXBaseMesh, IUnknown) { - // IUnknown + /* IUnknown */ STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; STDMETHOD_(ULONG, AddRef)(THIS) PURE; STDMETHOD_(ULONG, Release)(THIS) PURE; - // ID3DXBaseMesh + /* ID3DXBaseMesh */ STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE; STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; @@ -185,12 +183,12 @@ DECLARE_INTERFACE_(ID3DXBaseMesh, IUnknown) DECLARE_INTERFACE_(ID3DXMesh, ID3DXBaseMesh) { - // IUnknown + /* IUnknown */ STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; STDMETHOD_(ULONG, AddRef)(THIS) PURE; STDMETHOD_(ULONG, Release)(THIS) PURE; - // ID3DXBaseMesh + /* ID3DXBaseMesh */ STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE; STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; @@ -215,7 +213,7 @@ DECLARE_INTERFACE_(ID3DXMesh, ID3DXBaseMesh) STDMETHOD(ConvertAdjacencyToPointReps)(THIS_ CONST DWORD* pAdjacency, DWORD* pPRep) PURE; STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Epsilon, DWORD* pAdjacency) PURE; - // ID3DXMesh + /* ID3DXMesh */ STDMETHOD(LockAttributeBuffer)(THIS_ DWORD Flags, DWORD** ppData) PURE; STDMETHOD(UnlockAttributeBuffer)(THIS) PURE; STDMETHOD(Optimize)(THIS_ DWORD Flags, CONST DWORD* pAdjacencyIn, DWORD* pAdjacencyOut, @@ -232,12 +230,12 @@ DECLARE_INTERFACE_(ID3DXMesh, ID3DXBaseMesh) DECLARE_INTERFACE_(ID3DXPMesh, ID3DXBaseMesh) { - // IUnknown + /* IUnknown */ STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; STDMETHOD_(ULONG, AddRef)(THIS) PURE; STDMETHOD_(ULONG, Release)(THIS) PURE; - // ID3DXBaseMesh + /* ID3DXBaseMesh */ STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE; STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; @@ -262,7 +260,7 @@ DECLARE_INTERFACE_(ID3DXPMesh, ID3DXBaseMesh) STDMETHOD(ConvertAdjacencyToPointReps)(THIS_ CONST DWORD* pAdjacency, DWORD* pPRep) PURE; STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Epsilon, DWORD* pAdjacency) PURE; - // ID3DXPMesh + /* ID3DXPMesh */ STDMETHOD(ClonePMeshFVF)(THIS_ DWORD Options, DWORD FVF, LPDIRECT3DDEVICE8 pD3D, LPD3DXPMESH* ppCloneMesh) PURE; STDMETHOD(ClonePMesh)(THIS_ DWORD Options, @@ -292,12 +290,12 @@ DECLARE_INTERFACE_(ID3DXPMesh, ID3DXBaseMesh) DECLARE_INTERFACE_(ID3DXSPMesh, IUnknown) { - // IUnknown + /* IUnknown */ STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; STDMETHOD_(ULONG, AddRef)(THIS) PURE; STDMETHOD_(ULONG, Release)(THIS) PURE; - // ID3DXSPMesh + /* ID3DXSPMesh */ STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; STDMETHOD_(DWORD, GetFVF)(THIS) PURE; @@ -323,18 +321,18 @@ DECLARE_INTERFACE_(ID3DXSPMesh, IUnknown) #define UNUSED16 (0xffff) #define UNUSED32 (0xffffffff) -// ID3DXMesh::Optimize options - upper byte only, lower 3 bytes used from _D3DXMESH option flags +/* ID3DXMesh::Optimize options - upper byte only, lower 3 bytes used from _D3DXMESH option flags */ enum _D3DXMESHOPT { D3DXMESHOPT_COMPACT = 0x01000000, D3DXMESHOPT_ATTRSORT = 0x02000000, D3DXMESHOPT_VERTEXCACHE = 0x04000000, D3DXMESHOPT_STRIPREORDER = 0x08000000, - D3DXMESHOPT_IGNOREVERTS = 0x10000000, // optimize faces only, don't touch vertices - D3DXMESHOPT_SHAREVB = 0x1000, // same as D3DXMESH_VB_SHARE + D3DXMESHOPT_IGNOREVERTS = 0x10000000, /* optimize faces only, don't touch vertices */ + D3DXMESHOPT_SHAREVB = 0x1000 /* same as D3DXMESH_VB_SHARE */ }; -// Subset of the mesh that has the same attribute and bone combination. -// This subset can be rendered in a single draw call +/* Subset of the mesh that has the same attribute and bone combination. + * This subset can be rendered in a single draw call */ typedef struct _D3DXBONECOMBINATION { DWORD AttribId; @@ -351,12 +349,12 @@ typedef struct _D3DXBONECOMBINATION DECLARE_INTERFACE_(ID3DXSkinMesh, IUnknown) { - // IUnknown + /* IUnknown */ STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; STDMETHOD_(ULONG, AddRef)(THIS) PURE; STDMETHOD_(ULONG, Release)(THIS) PURE; - // ID3DXMesh + /* ID3DXMesh */ STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; STDMETHOD_(DWORD, GetFVF)(THIS) PURE; @@ -371,7 +369,7 @@ DECLARE_INTERFACE_(ID3DXSkinMesh, IUnknown) STDMETHOD(UnlockIndexBuffer)(THIS) PURE; STDMETHOD(LockAttributeBuffer)(THIS_ DWORD flags, DWORD** ppData) PURE; STDMETHOD(UnlockAttributeBuffer)(THIS) PURE; - // ID3DXSkinMesh + /* ID3DXSkinMesh */ STDMETHOD_(DWORD, GetNumBones)(THIS) PURE; STDMETHOD(GetOriginalMesh)(THIS_ LPD3DXMESH* ppMesh) PURE; STDMETHOD(SetBoneInfluence)(THIS_ DWORD bone, DWORD numInfluences, CONST DWORD* vertices, CONST FLOAT* weights) PURE; @@ -411,7 +409,7 @@ DECLARE_INTERFACE_(ID3DXSkinMesh, IUnknown) #ifdef __cplusplus extern "C" { -#endif //__cplusplus +#endif /* __cplusplus */ HRESULT WINAPI D3DXCreateMesh( @@ -439,7 +437,7 @@ HRESULT WINAPI CONST FLOAT *pVertexWeights, LPD3DXSPMESH* ppSMesh); -// clean a mesh up for simplification, try to make manifold +/* clean a mesh up for simplification, try to make manifold */ HRESULT WINAPI D3DXCleanMesh( LPD3DXMESH pMeshIn, @@ -606,7 +604,7 @@ HRESULT WINAPI LPD3DXMESH pMeshIn, CONST DWORD* pAdjacencyIn, FLOAT NumSegs, - BOOL QuadraticInterpNormals, // if false use linear intrep for normals, if true use quadratic + BOOL QuadraticInterpNormals, /* if false use linear intrep for normals, if true use quadratic */ LPD3DXMESH *ppMeshOut, LPD3DXBUFFER *ppAdjacencyOut); @@ -634,10 +632,10 @@ HRESULT WINAPI typedef struct _D3DXINTERSECTINFO { - DWORD FaceIndex; // index of face intersected - FLOAT U; // Barycentric Hit Coordinates - FLOAT V; // Barycentric Hit Coordinates - FLOAT Dist; // Ray-Intersection Parameter Distance + DWORD FaceIndex; /* index of face intersected */ + FLOAT U; /* Barycentric Hit Coordinates */ + FLOAT V; /* Barycentric Hit Coordinates */ + FLOAT Dist; /* Ray-Intersection Parameter Distance */ } D3DXINTERSECTINFO, *LPD3DXINTERSECTINFO; @@ -646,13 +644,13 @@ HRESULT WINAPI LPD3DXBASEMESH pMesh, CONST D3DXVECTOR3 *pRayPos, CONST D3DXVECTOR3 *pRayDir, - BOOL *pHit, // True if any faces were intersected - DWORD *pFaceIndex, // index of closest face intersected - FLOAT *pU, // Barycentric Hit Coordinates - FLOAT *pV, // Barycentric Hit Coordinates - FLOAT *pDist, // Ray-Intersection Parameter Distance - LPD3DXBUFFER *ppAllHits, // Array of D3DXINTERSECTINFOs for all hits (not just closest) - DWORD *pCountOfHits); // Number of entries in AllHits array + BOOL *pHit, /* True if any faces were intersected */ + DWORD *pFaceIndex, /* index of closest face intersected */ + FLOAT *pU, /* Barycentric Hit Coordinates */ + FLOAT *pV, /* Barycentric Hit Coordinates */ + FLOAT *pDist, /* Ray-Intersection Parameter Distance */ + LPD3DXBUFFER *ppAllHits, /* Array of D3DXINTERSECTINFOs for all hits (not just closest) */ + DWORD *pCountOfHits); /* Number of entries in AllHits array */ HRESULT WINAPI D3DXIntersectSubset( @@ -660,13 +658,13 @@ HRESULT WINAPI DWORD AttribId, CONST D3DXVECTOR3 *pRayPos, CONST D3DXVECTOR3 *pRayDir, - BOOL *pHit, // True if any faces were intersected - DWORD *pFaceIndex, // index of closest face intersected - FLOAT *pU, // Barycentric Hit Coordinates - FLOAT *pV, // Barycentric Hit Coordinates - FLOAT *pDist, // Ray-Intersection Parameter Distance - LPD3DXBUFFER *ppAllHits, // Array of D3DXINTERSECTINFOs for all hits (not just closest) - DWORD *pCountOfHits); // Number of entries in AllHits array + BOOL *pHit, /* True if any faces were intersected */ + DWORD *pFaceIndex, /* index of closest face intersected */ + FLOAT *pU, /* Barycentric Hit Coordinates */ + FLOAT *pV, /* Barycentric Hit Coordinates */ + FLOAT *pDist, /* Ray-Intersection Parameter Distance */ + LPD3DXBUFFER *ppAllHits, /* Array of D3DXINTERSECTINFOs for all hits (not just closest) */ + DWORD *pCountOfHits); /* Number of entries in AllHits array */ HRESULT WINAPI D3DXSplitMesh @@ -684,14 +682,14 @@ HRESULT WINAPI D3DXSplitMesh BOOL D3DXIntersectTri ( - CONST D3DXVECTOR3 *p0, // Triangle vertex 0 position - CONST D3DXVECTOR3 *p1, // Triangle vertex 1 position - CONST D3DXVECTOR3 *p2, // Triangle vertex 2 position - CONST D3DXVECTOR3 *pRayPos, // Ray origin - CONST D3DXVECTOR3 *pRayDir, // Ray direction - FLOAT *pU, // Barycentric Hit Coordinates - FLOAT *pV, // Barycentric Hit Coordinates - FLOAT *pDist); // Ray-Intersection Parameter Distance + CONST D3DXVECTOR3 *p0, /* Triangle vertex 0 position */ + CONST D3DXVECTOR3 *p1, /* Triangle vertex 1 position */ + CONST D3DXVECTOR3 *p2, /* Triangle vertex 2 position */ + CONST D3DXVECTOR3 *pRayPos, /* Ray origin */ + CONST D3DXVECTOR3 *pRayDir, /* Ray direction */ + FLOAT *pU, /* Barycentric Hit Coordinates */ + FLOAT *pV, /* Barycentric Hit Coordinates */ + FLOAT *pDist); /* Ray-Intersection Parameter Distance */ BOOL WINAPI D3DXSphereBoundProbe( @@ -753,8 +751,8 @@ D3DXConvertMeshSubsetToStrips #ifdef __cplusplus } -#endif //__cplusplus +#endif /* __cplusplus */ -#endif //__D3DX8MESH_H__ +#endif /* __D3DX8MESH_H__ */ diff --git a/gfx/include/d3d8/d3dx8shape.h b/gfx/include/d3d8/d3dx8shape.h index e874d6479f..c8b982dc8c 100644 --- a/gfx/include/d3d8/d3dx8shape.h +++ b/gfx/include/d3d8/d3dx8shape.h @@ -1,40 +1,40 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx8shapes.h -// Content: D3DX simple shapes -// -/////////////////////////////////////////////////////////////////////////// +/* + * + * Copyright (C) Microsoft Corporation. All Rights Reserved. + * + * File: d3dx8shapes.h + * Content: D3DX simple shapes + * + */ #include "d3dx8.h" #ifndef __D3DX8SHAPES_H__ #define __D3DX8SHAPES_H__ -/////////////////////////////////////////////////////////////////////////// -// Functions: -/////////////////////////////////////////////////////////////////////////// +/* + * Functions: + */ #ifdef __cplusplus extern "C" { -#endif //__cplusplus +#endif /* __cplusplus */ - -//------------------------------------------------------------------------- -// D3DXCreatePolygon: -// ------------------ -// Creates a mesh containing an n-sided polygon. The polygon is centered -// at the origin. -// -// Parameters: -// -// pDevice The D3D device with which the mesh is going to be used. -// Length Length of each side. -// Sides Number of sides the polygon has. (Must be >= 3) -// ppMesh The mesh object which will be created -// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. -//------------------------------------------------------------------------- +/* + * D3DXCreatePolygon: + * ------------------ + * Creates a mesh containing an n-sided polygon. The polygon is centered + * at the origin. + * + * Parameters: + * + * pDevice The D3D device with which the mesh is going to be used. + * Length Length of each side. + * Sides Number of sides the polygon has. (Must be >= 3) + * ppMesh The mesh object which will be created + * ppAdjacency Returns a buffer containing adjacency info. Can be NULL. + *------------------------------------------------------------------------- + */ HRESULT WINAPI D3DXCreatePolygon( LPDIRECT3DDEVICE8 pDevice, @@ -44,21 +44,21 @@ HRESULT WINAPI LPD3DXBUFFER* ppAdjacency); -//------------------------------------------------------------------------- -// D3DXCreateBox: -// -------------- -// Creates a mesh containing an axis-aligned box. The box is centered at -// the origin. -// -// Parameters: -// -// pDevice The D3D device with which the mesh is going to be used. -// Width Width of box (along X-axis) -// Height Height of box (along Y-axis) -// Depth Depth of box (along Z-axis) -// ppMesh The mesh object which will be created -// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. -//------------------------------------------------------------------------- +/* + * D3DXCreateBox: + * -------------- + * Creates a mesh containing an axis-aligned box. The box is centered at + * the origin. + * + * Parameters: + * + * pDevice The D3D device with which the mesh is going to be used. + * Width Width of box (along X-axis) + * Height Height of box (along Y-axis) + * Depth Depth of box (along Z-axis) + * ppMesh The mesh object which will be created + * ppAdjacency Returns a buffer containing adjacency info. Can be NULL. + */ HRESULT WINAPI D3DXCreateBox( LPDIRECT3DDEVICE8 pDevice, @@ -69,23 +69,24 @@ HRESULT WINAPI LPD3DXBUFFER* ppAdjacency); -//------------------------------------------------------------------------- -// D3DXCreateCylinder: -// ------------------- -// Creates a mesh containing a cylinder. The generated cylinder is -// centered at the origin, and its axis is aligned with the Z-axis. -// -// Parameters: -// -// pDevice The D3D device with which the mesh is going to be used. -// Radius1 Radius at -Z end (should be >= 0.0f) -// Radius2 Radius at +Z end (should be >= 0.0f) -// Length Length of cylinder (along Z-axis) -// Slices Number of slices about the main axis -// Stacks Number of stacks along the main axis -// ppMesh The mesh object which will be created -// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. -//------------------------------------------------------------------------- +/* + * D3DXCreateCylinder: + * ------------------- + * Creates a mesh containing a cylinder. The generated cylinder is + * centered at the origin, and its axis is aligned with the Z-axis. + * + * Parameters: + * + * pDevice The D3D device with which the mesh is going to be used. + * Radius1 Radius at -Z end (should be >= 0.0f) + * Radius2 Radius at +Z end (should be >= 0.0f) + * Length Length of cylinder (along Z-axis) + * Slices Number of slices about the main axis + * Stacks Number of stacks along the main axis + * ppMesh The mesh object which will be created + * ppAdjacency Returns a buffer containing adjacency info. Can be NULL. + *------------------------------------------------------------------------- + */ HRESULT WINAPI D3DXCreateCylinder( LPDIRECT3DDEVICE8 pDevice, @@ -98,21 +99,22 @@ HRESULT WINAPI LPD3DXBUFFER* ppAdjacency); -//------------------------------------------------------------------------- -// D3DXCreateSphere: -// ----------------- -// Creates a mesh containing a sphere. The sphere is centered at the -// origin. -// -// Parameters: -// -// pDevice The D3D device with which the mesh is going to be used. -// Radius Radius of the sphere (should be >= 0.0f) -// Slices Number of slices about the main axis -// Stacks Number of stacks along the main axis -// ppMesh The mesh object which will be created -// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. -//------------------------------------------------------------------------- +/*------------------------------------------------------------------------- + * D3DXCreateSphere: + * ----------------- + * Creates a mesh containing a sphere. The sphere is centered at the + * origin. + * + * Parameters: + * + * pDevice The D3D device with which the mesh is going to be used. + * Radius Radius of the sphere (should be >= 0.0f) + * Slices Number of slices about the main axis + * Stacks Number of stacks along the main axis + * ppMesh The mesh object which will be created + * ppAdjacency Returns a buffer containing adjacency info. Can be NULL. + *------------------------------------------------------------------------- + */ HRESULT WINAPI D3DXCreateSphere( LPDIRECT3DDEVICE8 pDevice, @@ -123,22 +125,23 @@ HRESULT WINAPI LPD3DXBUFFER* ppAdjacency); -//------------------------------------------------------------------------- -// D3DXCreateTorus: -// ---------------- -// Creates a mesh containing a torus. The generated torus is centered at -// the origin, and its axis is aligned with the Z-axis. -// -// Parameters: -// -// pDevice The D3D device with which the mesh is going to be used. -// InnerRadius Inner radius of the torus (should be >= 0.0f) -// OuterRadius Outer radius of the torue (should be >= 0.0f) -// Sides Number of sides in a cross-section (must be >= 3) -// Rings Number of rings making up the torus (must be >= 3) -// ppMesh The mesh object which will be created -// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. -//------------------------------------------------------------------------- +/*------------------------------------------------------------------------- + * D3DXCreateTorus: + * ---------------- + * Creates a mesh containing a torus. The generated torus is centered at + * the origin, and its axis is aligned with the Z-axis. + * + * Parameters: + * + * pDevice The D3D device with which the mesh is going to be used. + * InnerRadius Inner radius of the torus (should be >= 0.0f) + * OuterRadius Outer radius of the torue (should be >= 0.0f) + * Sides Number of sides in a cross-section (must be >= 3) + * Rings Number of rings making up the torus (must be >= 3) + * ppMesh The mesh object which will be created + * ppAdjacency Returns a buffer containing adjacency info. Can be NULL. + *------------------------------------------------------------------------- + */ HRESULT WINAPI D3DXCreateTorus( LPDIRECT3DDEVICE8 pDevice, @@ -150,17 +153,18 @@ HRESULT WINAPI LPD3DXBUFFER* ppAdjacency); -//------------------------------------------------------------------------- -// D3DXCreateTeapot: -// ----------------- -// Creates a mesh containing a teapot. -// -// Parameters: -// -// pDevice The D3D device with which the mesh is going to be used. -// ppMesh The mesh object which will be created -// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. -//------------------------------------------------------------------------- +/*------------------------------------------------------------------------- + * D3DXCreateTeapot: + * ----------------- + * Creates a mesh containing a teapot. + * + * Parameters: + * + * pDevice The D3D device with which the mesh is going to be used. + * ppMesh The mesh object which will be created + * ppAdjacency Returns a buffer containing adjacency info. Can be NULL. + *------------------------------------------------------------------------- + */ HRESULT WINAPI D3DXCreateTeapot( LPDIRECT3DDEVICE8 pDevice, @@ -168,22 +172,23 @@ HRESULT WINAPI LPD3DXBUFFER* ppAdjacency); -//------------------------------------------------------------------------- -// D3DXCreateText: -// --------------- -// Creates a mesh containing the specified text using the font associated -// with the device context. -// -// Parameters: -// -// pDevice The D3D device with which the mesh is going to be used. -// hDC Device context, with desired font selected -// pText Text to generate -// Deviation Maximum chordal deviation from true font outlines -// Extrusion Amount to extrude text in -Z direction -// ppMesh The mesh object which will be created -// pGlyphMetrics Address of buffer to receive glyph metric data (or NULL) -//------------------------------------------------------------------------- +/*------------------------------------------------------------------------- + * D3DXCreateText: + * --------------- + * Creates a mesh containing the specified text using the font associated + * with the device context. + * + * Parameters: + * + * pDevice The D3D device with which the mesh is going to be used. + * hDC Device context, with desired font selected + * pText Text to generate + * Deviation Maximum chordal deviation from true font outlines + * Extrusion Amount to extrude text in -Z direction + * ppMesh The mesh object which will be created + * pGlyphMetrics Address of buffer to receive glyph metric data (or NULL) + *------------------------------------------------------------------------- + */ HRESULT WINAPI D3DXCreateTextA( LPDIRECT3DDEVICE8 pDevice, @@ -215,6 +220,6 @@ HRESULT WINAPI #ifdef __cplusplus } -#endif //__cplusplus +#endif /* __cplusplus */ -#endif //__D3DX8SHAPES_H__ +#endif /* __D3DX8SHAPES_H__ */ diff --git a/gfx/include/d3d8/d3dx8tex.h b/gfx/include/d3d8/d3dx8tex.h index cb30a7cf37..d437e4b052 100644 --- a/gfx/include/d3d8/d3dx8tex.h +++ b/gfx/include/d3d8/d3dx8tex.h @@ -1,11 +1,10 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx8tex.h -// Content: D3DX texturing APIs -// -////////////////////////////////////////////////////////////////////////////// +/* + * + * Copyright (C) Microsoft Corporation. All Rights Reserved. + * + * File: d3dx8tex.h + * Content: D3DX texturing APIs + */ #include "d3dx8.h" @@ -224,10 +223,10 @@ extern "C" { -////////////////////////////////////////////////////////////////////////////// -// Image File APIs /////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -; +/* + * Image File APIs + */ + //---------------------------------------------------------------------------- // GetImageInfoFromFile/Resource: // ------------------------------ @@ -1587,6 +1586,6 @@ HRESULT WINAPI #ifdef __cplusplus } -#endif //__cplusplus +#endif /* __cplusplus */ -#endif //__D3DX8TEX_H__ +#endif /* __D3DX8TEX_H__ */ From 4f7f2376445346ce5c04a79dafe6f45807ef9f11 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 3 Feb 2018 15:40:54 +0100 Subject: [PATCH 037/232] (Wiiu) uniquely name global variable 'pos' to prevent collissions with variables in other cores (like freeintv) --- wiiu/system/exception_handler.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wiiu/system/exception_handler.c b/wiiu/system/exception_handler.c index bfba8dfd45..d6138fac00 100644 --- a/wiiu/system/exception_handler.c +++ b/wiiu/system/exception_handler.c @@ -79,8 +79,8 @@ typedef struct _framerec /* Clear if srr0 points to the address that caused the exception (yes, really) */ #define SRR1_PROG_SRR0_INACCURATE 0x10000 -#define buf_add(...) pos += sprintf(exception_msgbuf + pos, __VA_ARGS__) -size_t pos = 0; +#define buf_add(...) wiiu_exception_handler_pos += sprintf(exception_msgbuf + wiiu_exception_handler_pos, __VA_ARGS__) +size_t wiiu_exception_handler_pos = 0; char* exception_msgbuf; void __attribute__((__noreturn__)) exception_cb(OSContext* ctx, OSExceptionType type) From 48adfab6436cc31babb0dc208e3155d7ee49a82a Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Sat, 3 Feb 2018 15:53:58 +0100 Subject: [PATCH 038/232] Update CHANGES.md --- CHANGES.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 5498b913d0..eacdf1b773 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -15,6 +15,7 @@ - D3D9: Add menu support for MaterialUI/XMB. - D3D10: Initial video driver implementation. - D3D11: Initial video driver implementation. +- D3D11: SPIRV-Cross/slang shader support for D3D11. - D3D12: Initial video driver implementation. - DINPUT: don't reinitialize input driver on network events / media insertion / network drive connection - INPUT: show friendly names when available under input binds and system information @@ -29,12 +30,14 @@ - IOS10/11: Handle hardware keyboards and iCade controllers - LOCALIZATION: Update Italian translation. - LOCALIZATION: Update Japanese translation. +- LOCALIZATION: Update Portuguese-Brazilian translation. - LOCALIZATION: Update Spanish translation. - OSX: Modify HID buttons detection algorithm. - SOLARIS: Initial port. - SWITCH: Initial Nintendo Switch port, based on libtransistor SDK. - PS3: Enable Cheevos. - PSP: Enable threading support through pthreads. +- SHADERS: SPIRV-Cross/slang shader support for D3D11. - SHIELD ATV: Allow the remote / gamepad takeover hack to work with the 2017 gamepad - VULKAN: Fix swapchain recreation bug on Nvidia GPUs with Windows 10 through workaround (will be properly resolved in a future driver version). - WINDOWS: Improved Unicode support (for cores/directory creation and 7zip archives). From 840ebb13cac308cf2e2fad99ddd5985e03df48df Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Sat, 3 Feb 2018 15:55:05 +0100 Subject: [PATCH 039/232] Update CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index eacdf1b773..397da36c24 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -48,6 +48,7 @@ - WIIU: Increased stability during core switching. - WIIU: Shader support. - WIIU: Menu shader effects added (shaders). +- WIIU: Add missing time/clock support. (also fixes RTC [Real Time Clock] in Gambatte) - XBOX OG: Restored port. # 1.7.0 From f9ba402766f10a6cc447185675c3887d77102aea Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Sat, 3 Feb 2018 15:56:26 +0100 Subject: [PATCH 040/232] Update CHANGES.md --- CHANGES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 397da36c24..8541054bc9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -22,8 +22,10 @@ - INPUT: show the config name when available under system information - GUI: Allow changing menu font color. - GUI: Menu visibility options for RGUI and MaterialUI. +- GUI/MaterialUI: Works now with D3D8, D3D9 Cg and D3D11 drivers. - GUI/XMB: Add Monochrome Inverted icon theme. - GUI/XMB: Allow changing menu scale to 200%. +- GUI/XMB: Works now with D3D8, D3D9 Cg and D3D11 drivers. Menu shader effects currently don't work on D3D8/D3D9 Cg. - HAIKU: Restored port. - KEYMAPPER: prevent a condition that caused input_menu_toggle to stop working when a RETRO_DEVICE_KEYBOARD type device is enabled - GL: ignore hard gpu sync when fast-forwarding From 27c47a89b9a1d358e2f158abde0748c6bdda44c4 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Sat, 3 Feb 2018 15:57:32 +0100 Subject: [PATCH 041/232] Update CHANGES.md --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 8541054bc9..f57d0eb6bc 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -41,7 +41,7 @@ - PSP: Enable threading support through pthreads. - SHADERS: SPIRV-Cross/slang shader support for D3D11. - SHIELD ATV: Allow the remote / gamepad takeover hack to work with the 2017 gamepad -- VULKAN: Fix swapchain recreation bug on Nvidia GPUs with Windows 10 through workaround (will be properly resolved in a future driver version). +- VULKAN: Fix swapchain recreation bug on Nvidia GPUs with Windows 10 (resolved in Windows Nvidia driver version 390.77). - WINDOWS: Improved Unicode support (for cores/directory creation and 7zip archives). - WINDOWS: Show progress meter on taskbar for downloads (Windows 7 and up). - WINDOWS: WS_EX_LAYERED drastically decreases performance, so only set it when needed (transparency in windowed mode). From 8e96700f0fce581ffb38c07d176841df8a4d13d6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 3 Feb 2018 16:50:26 +0100 Subject: [PATCH 042/232] (D3D8/D3D9) Update headers to work with C89 --- gfx/include/d3d8/d3dx8core.h | 388 +++--- gfx/include/d3d8/d3dx8math.h | 630 +++++---- gfx/include/d3d8/d3dx8math.inl | 203 ++- gfx/include/d3d8/d3dx8tex.h | 1202 ++++++++--------- gfx/include/d3d9/d3dx9mesh.h | 2319 ++++++++++++++++---------------- 5 files changed, 2363 insertions(+), 2379 deletions(-) diff --git a/gfx/include/d3d8/d3dx8core.h b/gfx/include/d3d8/d3dx8core.h index 5629124aa0..7542f28924 100644 --- a/gfx/include/d3d8/d3dx8core.h +++ b/gfx/include/d3d8/d3dx8core.h @@ -1,11 +1,10 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx8core.h -// Content: D3DX core types and functions -// -/////////////////////////////////////////////////////////////////////////// +/* + * + * Copyright (C) Microsoft Corporation. All Rights Reserved. + * + * File: d3dx8core.h + * Content: D3DX core types and functions + */ #include "d3dx8.h" @@ -14,22 +13,22 @@ -/////////////////////////////////////////////////////////////////////////// -// ID3DXBuffer: -// ------------ -// The buffer object is used by D3DX to return arbitrary size data. -// -// GetBufferPointer - -// Returns a pointer to the beginning of the buffer. -// -// GetBufferSize - -// Returns the size of the buffer, in bytes. -/////////////////////////////////////////////////////////////////////////// +/* + * ID3DXBuffer: + * ------------ + * The buffer object is used by D3DX to return arbitrary size data. + * + * GetBufferPointer - + * Returns a pointer to the beginning of the buffer. + * + * GetBufferSize - + * Returns the size of the buffer, in bytes. + */ typedef interface ID3DXBuffer ID3DXBuffer; typedef interface ID3DXBuffer *LPD3DXBUFFER; -// {932E6A7E-C68E-45dd-A7BF-53D19C86DB1F} +/* {932E6A7E-C68E-45dd-A7BF-53D19C86DB1F} */ DEFINE_GUID(IID_ID3DXBuffer, 0x932e6a7e, 0xc68e, 0x45dd, 0xa7, 0xbf, 0x53, 0xd1, 0x9c, 0x86, 0xdb, 0x1f); @@ -38,48 +37,45 @@ DEFINE_GUID(IID_ID3DXBuffer, DECLARE_INTERFACE_(ID3DXBuffer, IUnknown) { - // IUnknown + /* IUnknown */ STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; STDMETHOD_(ULONG, AddRef)(THIS) PURE; STDMETHOD_(ULONG, Release)(THIS) PURE; - // ID3DXBuffer + /* ID3DXBuffer */ STDMETHOD_(LPVOID, GetBufferPointer)(THIS) PURE; STDMETHOD_(DWORD, GetBufferSize)(THIS) PURE; }; - - -/////////////////////////////////////////////////////////////////////////// -// ID3DXFont: -// ---------- -// Font objects contain the textures and resources needed to render -// a specific font on a specific device. -// -// Begin - -// Prepartes device for drawing text. This is optional.. if DrawText -// is called outside of Begin/End, it will call Begin and End for you. -// -// DrawText - -// Draws formatted text on a D3D device. Some parameters are -// surprisingly similar to those of GDI's DrawText function. See GDI -// documentation for a detailed description of these parameters. -// -// End - -// Restores device state to how it was when Begin was called. -// -// OnLostDevice, OnResetDevice - -// Call OnLostDevice() on this object before calling Reset() on the -// device, so that this object can release any stateblocks and video -// memory resources. After Reset(), the call OnResetDevice(). -// -/////////////////////////////////////////////////////////////////////////// +/* + * ID3DXFont: + * ---------- + * Font objects contain the textures and resources needed to render + * a specific font on a specific device. + * + * Begin - + * Prepartes device for drawing text. This is optional.. if DrawText + * is called outside of Begin/End, it will call Begin and End for you. + * + * DrawText - + * Draws formatted text on a D3D device. Some parameters are + * surprisingly similar to those of GDI's DrawText function. See GDI + * documentation for a detailed description of these parameters. + * + * End - + * Restores device state to how it was when Begin was called. + * + * OnLostDevice, OnResetDevice - + * Call OnLostDevice() on this object before calling Reset() on the + * device, so that this object can release any stateblocks and video + * memory resources. After Reset(), the call OnResetDevice(). + * + */ typedef interface ID3DXFont ID3DXFont; typedef interface ID3DXFont *LPD3DXFONT; - -// {89FAD6A5-024D-49af-8FE7-F51123B85E25} +/* {89FAD6A5-024D-49af-8FE7-F51123B85E25} */ DEFINE_GUID( IID_ID3DXFont, 0x89fad6a5, 0x24d, 0x49af, 0x8f, 0xe7, 0xf5, 0x11, 0x23, 0xb8, 0x5e, 0x25); @@ -89,12 +85,12 @@ DEFINE_GUID( IID_ID3DXFont, DECLARE_INTERFACE_(ID3DXFont, IUnknown) { - // IUnknown + /* IUnknown */ STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; STDMETHOD_(ULONG, AddRef)(THIS) PURE; STDMETHOD_(ULONG, Release)(THIS) PURE; - // ID3DXFont + /* ID3DXFont */ STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; STDMETHOD(GetLogFont)(THIS_ LOGFONT* pLogFont) PURE; @@ -118,7 +114,7 @@ DECLARE_INTERFACE_(ID3DXFont, IUnknown) #ifdef __cplusplus extern "C" { -#endif //__cplusplus +#endif /* __cplusplus */ HRESULT WINAPI D3DXCreateFont( @@ -137,33 +133,33 @@ HRESULT WINAPI } #endif /* __cplusplus */ -/////////////////////////////////////////////////////////////////////////// -// ID3DXSprite: -// ------------ -// This object intends to provide an easy way to drawing sprites using D3D. -// -// Begin - -// Prepares device for drawing sprites -// -// Draw, DrawAffine, DrawTransform - -// Draws a sprite in screen-space. Before transformation, the sprite is -// the size of SrcRect, with its top-left corner at the origin (0,0). -// The color and alpha channels are modulated by Color. -// -// End - -// Restores device state to how it was when Begin was called. -// -// OnLostDevice, OnResetDevice - -// Call OnLostDevice() on this object before calling Reset() on the -// device, so that this object can release any stateblocks and video -// memory resources. After Reset(), the call OnResetDevice(). -/////////////////////////////////////////////////////////////////////////// +/* + * ID3DXSprite: + * ------------ + * This object intends to provide an easy way to drawing sprites using D3D. + * + * Begin - + * Prepares device for drawing sprites + * + * Draw, DrawAffine, DrawTransform - + * Draws a sprite in screen-space. Before transformation, the sprite is + * the size of SrcRect, with its top-left corner at the origin (0,0). + * The color and alpha channels are modulated by Color. + * + * End - + * Restores device state to how it was when Begin was called. + * + * OnLostDevice, OnResetDevice - + * Call OnLostDevice() on this object before calling Reset() on the + * device, so that this object can release any stateblocks and video + * memory resources. After Reset(), the call OnResetDevice(). + */ typedef interface ID3DXSprite ID3DXSprite; typedef interface ID3DXSprite *LPD3DXSPRITE; -// {13D69D15-F9B0-4e0f-B39E-C91EB33F6CE7} +/* {13D69D15-F9B0-4e0f-B39E-C91EB33F6CE7} */ DEFINE_GUID( IID_ID3DXSprite, 0x13d69d15, 0xf9b0, 0x4e0f, 0xb3, 0x9e, 0xc9, 0x1e, 0xb3, 0x3f, 0x6c, 0xe7); @@ -173,12 +169,12 @@ DEFINE_GUID( IID_ID3DXSprite, DECLARE_INTERFACE_(ID3DXSprite, IUnknown) { - // IUnknown + /* IUnknown */ STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; STDMETHOD_(ULONG, AddRef)(THIS) PURE; STDMETHOD_(ULONG, Release)(THIS) PURE; - // ID3DXSprite + /* ID3DXSprite */ STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; STDMETHOD(Begin)(THIS) PURE; @@ -201,7 +197,7 @@ DECLARE_INTERFACE_(ID3DXSprite, IUnknown) #ifdef __cplusplus extern "C" { -#endif //__cplusplus +#endif /* __cplusplus */ HRESULT WINAPI @@ -211,28 +207,28 @@ HRESULT WINAPI #ifdef __cplusplus } -#endif //__cplusplus +#endif /* __cplusplus */ -/////////////////////////////////////////////////////////////////////////// -// ID3DXRenderToSurface: -// --------------------- -// This object abstracts rendering to surfaces. These surfaces do not -// necessarily need to be render targets. If they are not, a compatible -// render target is used, and the result copied into surface at end scene. -// -// BeginScene, EndScene - -// Call BeginScene() and EndScene() at the beginning and ending of your -// scene. These calls will setup and restore render targets, viewports, -// etc.. -// -// OnLostDevice, OnResetDevice - -// Call OnLostDevice() on this object before calling Reset() on the -// device, so that this object can release any stateblocks and video -// memory resources. After Reset(), the call OnResetDevice(). -/////////////////////////////////////////////////////////////////////////// +/* + * ID3DXRenderToSurface: + * --------------------- + * This object abstracts rendering to surfaces. These surfaces do not + * necessarily need to be render targets. If they are not, a compatible + * render target is used, and the result copied into surface at end scene. + * + * BeginScene, EndScene - + * Call BeginScene() and EndScene() at the beginning and ending of your + * scene. These calls will setup and restore render targets, viewports, + * etc.. + * + * OnLostDevice, OnResetDevice - + * Call OnLostDevice() on this object before calling Reset() on the + * device, so that this object can release any stateblocks and video + * memory resources. After Reset(), the call OnResetDevice(). + */ typedef struct _D3DXRTS_DESC { @@ -248,23 +244,21 @@ typedef struct _D3DXRTS_DESC typedef interface ID3DXRenderToSurface ID3DXRenderToSurface; typedef interface ID3DXRenderToSurface *LPD3DXRENDERTOSURFACE; - -// {82DF5B90-E34E-496e-AC1C-62117A6A5913} +/* {82DF5B90-E34E-496e-AC1C-62117A6A5913} */ DEFINE_GUID( IID_ID3DXRenderToSurface, 0x82df5b90, 0xe34e, 0x496e, 0xac, 0x1c, 0x62, 0x11, 0x7a, 0x6a, 0x59, 0x13); - #undef INTERFACE #define INTERFACE ID3DXRenderToSurface DECLARE_INTERFACE_(ID3DXRenderToSurface, IUnknown) { - // IUnknown + /* IUnknown */ STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; STDMETHOD_(ULONG, AddRef)(THIS) PURE; STDMETHOD_(ULONG, Release)(THIS) PURE; - // ID3DXRenderToSurface + /* ID3DXRenderToSurface */ STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; STDMETHOD(GetDesc)(THIS_ D3DXRTS_DESC* pDesc) PURE; @@ -278,7 +272,7 @@ DECLARE_INTERFACE_(ID3DXRenderToSurface, IUnknown) #ifdef __cplusplus extern "C" { -#endif //__cplusplus +#endif /* __cplusplus */ HRESULT WINAPI D3DXCreateRenderToSurface( @@ -292,37 +286,37 @@ HRESULT WINAPI #ifdef __cplusplus } -#endif //__cplusplus +#endif /* __cplusplus */ -/////////////////////////////////////////////////////////////////////////// -// ID3DXRenderToEnvMap: -// -------------------- -// This object abstracts rendering to environment maps. These surfaces -// do not necessarily need to be render targets. If they are not, a -// compatible render target is used, and the result copied into the -// environment map at end scene. -// -// BeginCube, BeginSphere, BeginHemisphere, BeginParabolic - -// This function initiates the rendering of the environment map. As -// parameters, you pass the textures in which will get filled in with -// the resulting environment map. -// -// Face - -// Call this function to initiate the drawing of each face. For each -// environment map, you will call this six times.. once for each face -// in D3DCUBEMAP_FACES. -// -// End - -// This will restore all render targets, and if needed compose all the -// rendered faces into the environment map surfaces. -// -// OnLostDevice, OnResetDevice - -// Call OnLostDevice() on this object before calling Reset() on the -// device, so that this object can release any stateblocks and video -// memory resources. After Reset(), the call OnResetDevice(). -/////////////////////////////////////////////////////////////////////////// +/* + * ID3DXRenderToEnvMap: + * -------------------- + * This object abstracts rendering to environment maps. These surfaces + * do not necessarily need to be render targets. If they are not, a + * compatible render target is used, and the result copied into the + * environment map at end scene. + * + * BeginCube, BeginSphere, BeginHemisphere, BeginParabolic - + * This function initiates the rendering of the environment map. As + * parameters, you pass the textures in which will get filled in with + * the resulting environment map. + * + * Face - + * Call this function to initiate the drawing of each face. For each + * environment map, you will call this six times.. once for each face + * in D3DCUBEMAP_FACES. + * + * End - + * This will restore all render targets, and if needed compose all the + * rendered faces into the environment map surfaces. + * + * OnLostDevice, OnResetDevice - + * Call OnLostDevice() on this object before calling Reset() on the + * device, so that this object can release any stateblocks and video + * memory resources. After Reset(), the call OnResetDevice(). + */ typedef struct _D3DXRTE_DESC { @@ -336,7 +330,7 @@ typedef struct _D3DXRTE_DESC typedef interface ID3DXRenderToEnvMap ID3DXRenderToEnvMap; typedef interface ID3DXRenderToEnvMap *LPD3DXRenderToEnvMap; -// {4E42C623-9451-44b7-8C86-ABCCDE5D52C8} +/* {4E42C623-9451-44b7-8C86-ABCCDE5D52C8} */ DEFINE_GUID( IID_ID3DXRenderToEnvMap, 0x4e42c623, 0x9451, 0x44b7, 0x8c, 0x86, 0xab, 0xcc, 0xde, 0x5d, 0x52, 0xc8); @@ -346,12 +340,12 @@ DEFINE_GUID( IID_ID3DXRenderToEnvMap, DECLARE_INTERFACE_(ID3DXRenderToEnvMap, IUnknown) { - // IUnknown + /* IUnknown */ STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; STDMETHOD_(ULONG, AddRef)(THIS) PURE; STDMETHOD_(ULONG, Release)(THIS) PURE; - // ID3DXRenderToEnvMap + /* ID3DXRenderToEnvMap */ STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; STDMETHOD(GetDesc)(THIS_ D3DXRTE_DESC* pDesc) PURE; @@ -379,7 +373,7 @@ DECLARE_INTERFACE_(ID3DXRenderToEnvMap, IUnknown) #ifdef __cplusplus extern "C" { -#endif //__cplusplus +#endif /* __cplusplus */ HRESULT WINAPI D3DXCreateRenderToEnvMap( @@ -392,26 +386,26 @@ HRESULT WINAPI #ifdef __cplusplus } -#endif //__cplusplus +#endif /* __cplusplus */ -/////////////////////////////////////////////////////////////////////////// -// Shader assemblers: -/////////////////////////////////////////////////////////////////////////// +/* + * Shader assemblers: + */ -//------------------------------------------------------------------------- -// D3DXASM flags: -// -------------- -// -// D3DXASM_DEBUG -// Generate debug info. -// -// D3DXASM_SKIPVALIDATION -// Do not validate the generated code against known capabilities and -// constraints. This option is only recommended when assembling shaders -// you KNOW will work. (ie. have assembled before without this option.) -//------------------------------------------------------------------------- +/* + * D3DXASM flags: + * -------------- + * + * D3DXASM_DEBUG + * Generate debug info. + * + * D3DXASM_SKIPVALIDATION + * Do not validate the generated code against known capabilities and + * constraints. This option is only recommended when assembling shaders + * you KNOW will work. (ie. have assembled before without this option.) + */ #define D3DXASM_DEBUG (1 << 0) #define D3DXASM_SKIPVALIDATION (1 << 1) @@ -419,34 +413,34 @@ HRESULT WINAPI #ifdef __cplusplus extern "C" { -#endif //__cplusplus +#endif /* __cplusplus */ -//------------------------------------------------------------------------- -// D3DXAssembleShader: -// ------------------- -// Assembles an ascii description of a vertex or pixel shader into -// binary form. -// -// Parameters: -// pSrcFile -// Source file name -// hSrcModule -// Module handle. if NULL, current module will be used. -// pSrcResource -// Resource name in module -// pSrcData -// Pointer to source code -// SrcDataLen -// Size of source code, in bytes -// Flags -// D3DXASM_xxx flags -// ppConstants -// Returns an ID3DXBuffer object containing constant declarations. -// ppCompiledShader -// Returns an ID3DXBuffer object containing the object code. -// ppCompilationErrors -// Returns an ID3DXBuffer object containing ascii error messages -//------------------------------------------------------------------------- +/* + * D3DXAssembleShader: + * ------------------- + * Assembles an ascii description of a vertex or pixel shader into + * binary form. + * + * Parameters: + * pSrcFile + * Source file name + * hSrcModule + * Module handle. if NULL, current module will be used. + * pSrcResource + * Resource name in module + * pSrcData + * Pointer to source code + * SrcDataLen + * Size of source code, in bytes + * Flags + * D3DXASM_xxx flags + * ppConstants + * Returns an ID3DXBuffer object containing constant declarations. + * ppCompiledShader + * Returns an ID3DXBuffer object containing the object code. + * ppCompilationErrors + * Returns an ID3DXBuffer object containing ascii error messages + */ HRESULT WINAPI D3DXAssembleShaderFromFileA( @@ -506,33 +500,33 @@ HRESULT WINAPI #ifdef __cplusplus } -#endif //__cplusplus +#endif /* __cplusplus */ -/////////////////////////////////////////////////////////////////////////// -// Misc APIs: -/////////////////////////////////////////////////////////////////////////// +/* + * Misc APIs: + */ #ifdef __cplusplus extern "C" { -#endif //__cplusplus +#endif /* __cplusplus */ -//------------------------------------------------------------------------- -// D3DXGetErrorString: -// ------------------ -// Returns the error string for given an hresult. Interprets all D3DX and -// D3D hresults. -// -// Parameters: -// hr -// The error code to be deciphered. -// pBuffer -// Pointer to the buffer to be filled in. -// BufferLen -// Count of characters in buffer. Any error message longer than this -// length will be truncated to fit. -//------------------------------------------------------------------------- +/* + * D3DXGetErrorString: + * ------------------ + * Returns the error string for given an hresult. Interprets all D3DX and + * D3D hresults. + * + * Parameters: + * hr + * The error code to be deciphered. + * pBuffer + * Pointer to the buffer to be filled in. + * BufferLen + * Count of characters in buffer. Any error message longer than this + * length will be truncated to fit. + */ HRESULT WINAPI D3DXGetErrorStringA( HRESULT hr, diff --git a/gfx/include/d3d8/d3dx8math.h b/gfx/include/d3d8/d3dx8math.h index a1a68fd6b6..c126258db3 100644 --- a/gfx/include/d3d8/d3dx8math.h +++ b/gfx/include/d3d8/d3dx8math.h @@ -1,11 +1,11 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx8math.h -// Content: D3DX math types and functions -// -////////////////////////////////////////////////////////////////////////////// +/* + * + * Copyright (C) Microsoft Corporation. All Rights Reserved. + * + * File: d3dx8math.h + * Content: D3DX math types and functions + * + */ #include "d3dx8.h" @@ -15,11 +15,11 @@ #include #pragma warning(disable:4201) /* anonymous unions warning */ -//=========================================================================== -// -// General purpose utilities -// -//=========================================================================== +/* + * + * General purpose utilities + * + */ #define D3DX_PI ((FLOAT) 3.141592654f) #define D3DX_1BYPI ((FLOAT) 0.318309886f) @@ -28,15 +28,15 @@ -//=========================================================================== -// -// Vectors -// -//=========================================================================== +/* + * + * Vectors + * + */ -//-------------------------- -// 2D Vector -//-------------------------- +/* + * 2D Vector + */ typedef struct D3DXVECTOR2 { #ifdef __cplusplus @@ -45,21 +45,21 @@ public: D3DXVECTOR2( CONST FLOAT * ); D3DXVECTOR2( FLOAT x, FLOAT y ); - // casting + /* casting */ operator FLOAT* (); operator CONST FLOAT* () const; - // assignment operators + /* assignment operators */ D3DXVECTOR2& operator += ( CONST D3DXVECTOR2& ); D3DXVECTOR2& operator -= ( CONST D3DXVECTOR2& ); D3DXVECTOR2& operator *= ( FLOAT ); D3DXVECTOR2& operator /= ( FLOAT ); - // unary operators + /* unary operators */ D3DXVECTOR2 operator + () const; D3DXVECTOR2 operator - () const; - // binary operators + /* binary operators */ D3DXVECTOR2 operator + ( CONST D3DXVECTOR2& ) const; D3DXVECTOR2 operator - ( CONST D3DXVECTOR2& ) const; D3DXVECTOR2 operator * ( FLOAT ) const; @@ -72,14 +72,14 @@ public: public: -#endif //__cplusplus +#endif /* __cplusplus */ FLOAT x, y; } D3DXVECTOR2, *LPD3DXVECTOR2; -//-------------------------- -// 3D Vector -//-------------------------- +/* + * 3D Vector + */ #ifdef __cplusplus typedef struct D3DXVECTOR3 : public D3DVECTOR { @@ -89,21 +89,21 @@ public: D3DXVECTOR3( CONST D3DVECTOR& ); D3DXVECTOR3( FLOAT x, FLOAT y, FLOAT z ); - // casting + /* casting */ operator FLOAT* (); operator CONST FLOAT* () const; - // assignment operators + /* assignment operators */ D3DXVECTOR3& operator += ( CONST D3DXVECTOR3& ); D3DXVECTOR3& operator -= ( CONST D3DXVECTOR3& ); D3DXVECTOR3& operator *= ( FLOAT ); D3DXVECTOR3& operator /= ( FLOAT ); - // unary operators + /* unary operators */ D3DXVECTOR3 operator + () const; D3DXVECTOR3 operator - () const; - // binary operators + /* binary operators */ D3DXVECTOR3 operator + ( CONST D3DXVECTOR3& ) const; D3DXVECTOR3 operator - ( CONST D3DXVECTOR3& ) const; D3DXVECTOR3 operator * ( FLOAT ) const; @@ -116,14 +116,14 @@ public: } D3DXVECTOR3, *LPD3DXVECTOR3; -#else //!__cplusplus +#else /* !__cplusplus */ typedef struct _D3DVECTOR D3DXVECTOR3, *LPD3DXVECTOR3; -#endif //!__cplusplus +#endif /* !__cplusplus */ -//-------------------------- -// 4D Vector -//-------------------------- +/* + * 4D Vector + */ typedef struct D3DXVECTOR4 { #ifdef __cplusplus @@ -132,21 +132,21 @@ public: D3DXVECTOR4( CONST FLOAT* ); D3DXVECTOR4( FLOAT x, FLOAT y, FLOAT z, FLOAT w ); - // casting + /* casting */ operator FLOAT* (); operator CONST FLOAT* () const; - // assignment operators + /* assignment operators */ D3DXVECTOR4& operator += ( CONST D3DXVECTOR4& ); D3DXVECTOR4& operator -= ( CONST D3DXVECTOR4& ); D3DXVECTOR4& operator *= ( FLOAT ); D3DXVECTOR4& operator /= ( FLOAT ); - // unary operators + /* unary operators */ D3DXVECTOR4 operator + () const; D3DXVECTOR4 operator - () const; - // binary operators + /* binary operators */ D3DXVECTOR4 operator + ( CONST D3DXVECTOR4& ) const; D3DXVECTOR4 operator - ( CONST D3DXVECTOR4& ) const; D3DXVECTOR4 operator * ( FLOAT ) const; @@ -158,16 +158,16 @@ public: BOOL operator != ( CONST D3DXVECTOR4& ) const; public: -#endif //__cplusplus +#endif /* __cplusplus */ FLOAT x, y, z, w; } D3DXVECTOR4, *LPD3DXVECTOR4; -//=========================================================================== -// -// Matrices -// -//=========================================================================== +/* + * + * Matrices + * + */ #ifdef __cplusplus typedef struct D3DXMATRIX : public D3DMATRIX { @@ -181,26 +181,26 @@ public: FLOAT _41, FLOAT _42, FLOAT _43, FLOAT _44 ); - // access grants + /* access grants */ FLOAT& operator () ( UINT Row, UINT Col ); FLOAT operator () ( UINT Row, UINT Col ) const; - // casting operators + /* casting operators */ operator FLOAT* (); operator CONST FLOAT* () const; - // assignment operators + /* assignment operators */ D3DXMATRIX& operator *= ( CONST D3DXMATRIX& ); D3DXMATRIX& operator += ( CONST D3DXMATRIX& ); D3DXMATRIX& operator -= ( CONST D3DXMATRIX& ); D3DXMATRIX& operator *= ( FLOAT ); D3DXMATRIX& operator /= ( FLOAT ); - // unary operators + /* unary operators */ D3DXMATRIX operator + () const; D3DXMATRIX operator - () const; - // binary operators + /* binary operators */ D3DXMATRIX operator * ( CONST D3DXMATRIX& ) const; D3DXMATRIX operator + ( CONST D3DXMATRIX& ) const; D3DXMATRIX operator - ( CONST D3DXMATRIX& ) const; @@ -214,27 +214,27 @@ public: } D3DXMATRIX, *LPD3DXMATRIX; -#else //!__cplusplus +#else /* !__cplusplus */ typedef struct _D3DMATRIX D3DXMATRIX, *LPD3DXMATRIX; -#endif //!__cplusplus +#endif /* !__cplusplus */ -//=========================================================================== -// -// Aligned Matrices -// -// This class helps keep matrices 16-byte aligned as preferred by P4 cpus. -// It aligns matrices on the stack and on the heap or in global scope. -// It does this using __declspec(align(16)) which works on VC7 and on VC 6 -// with the processor pack. Unfortunately there is no way to detect the -// latter so this is turned on only on VC7. On other compilers this is the -// the same as D3DXMATRIX. -// Using this class on a compiler that does not actually do the alignment -// can be dangerous since it will not expose bugs that ignore alignment. -// E.g if an object of this class in inside a struct or class, and some code -// memcopys data in it assuming tight packing. This could break on a compiler -// that eventually start aligning the matrix. -// -//=========================================================================== +/* + * + * Aligned Matrices + * + * This class helps keep matrices 16-byte aligned as preferred by P4 cpus. + * It aligns matrices on the stack and on the heap or in global scope. + * It does this using __declspec(align(16)) which works on VC7 and on VC 6 + * with the processor pack. Unfortunately there is no way to detect the + * latter so this is turned on only on VC7. On other compilers this is the + * the same as D3DXMATRIX. + * Using this class on a compiler that does not actually do the alignment + * can be dangerous since it will not expose bugs that ignore alignment. + * E.g if an object of this class in inside a struct or class, and some code + * memcopys data in it assuming tight packing. This could break on a compiler + * that eventually start aligning the matrix. + * + */ #ifdef __cplusplus typedef struct _D3DXMATRIXA16 : public D3DXMATRIX { @@ -273,8 +273,8 @@ typedef struct _D3DXMATRIXA16 : public D3DXMATRIX return p; }; - // This is NOT a virtual operator. If you cast - // to D3DXMATRIX, do not delete using that + /* This is NOT a virtual operator. If you cast + * to D3DXMATRIX, do not delete using that */ void operator delete(void* p) { if(p) @@ -285,8 +285,8 @@ typedef struct _D3DXMATRIXA16 : public D3DXMATRIX } }; - // This is NOT a virtual operator. If you cast - // to D3DXMATRIX, do not delete using that + /* This is NOT a virtual operator. If you cast + * to D3DXMATRIX, do not delete using that */ void operator delete[](void* p) { if(p) @@ -304,25 +304,25 @@ typedef struct _D3DXMATRIXA16 : public D3DXMATRIX }; } _D3DXMATRIXA16; -#else //!__cplusplus +#else /* !__cplusplus */ typedef D3DXMATRIX _D3DXMATRIXA16; -#endif //!__cplusplus +#endif /* !__cplusplus */ -#if _MSC_VER >= 1300 // VC7 +#if _MSC_VER >= 1300 /* VC7 */ #define _ALIGN_16 __declspec(align(16)) #else -#define _ALIGN_16 // Earlier compiler may not understand this, do nothing. +#define _ALIGN_16 /* Earlier compiler may not understand this, do nothing. */ #endif #define D3DXMATRIXA16 _ALIGN_16 _D3DXMATRIXA16 typedef D3DXMATRIXA16 *LPD3DXMATRIXA16; -//=========================================================================== -// -// Quaternions -// -//=========================================================================== +/* + * + * Quaternions + * + */ typedef struct D3DXQUATERNION { #ifdef __cplusplus @@ -331,22 +331,22 @@ public: D3DXQUATERNION( CONST FLOAT * ); D3DXQUATERNION( FLOAT x, FLOAT y, FLOAT z, FLOAT w ); - // casting + /* casting */ operator FLOAT* (); operator CONST FLOAT* () const; - // assignment operators + /* assignment operators */ D3DXQUATERNION& operator += ( CONST D3DXQUATERNION& ); D3DXQUATERNION& operator -= ( CONST D3DXQUATERNION& ); D3DXQUATERNION& operator *= ( CONST D3DXQUATERNION& ); D3DXQUATERNION& operator *= ( FLOAT ); D3DXQUATERNION& operator /= ( FLOAT ); - // unary operators + /* unary operators */ D3DXQUATERNION operator + () const; D3DXQUATERNION operator - () const; - // binary operators + /* binary operators */ D3DXQUATERNION operator + ( CONST D3DXQUATERNION& ) const; D3DXQUATERNION operator - ( CONST D3DXQUATERNION& ) const; D3DXQUATERNION operator * ( CONST D3DXQUATERNION& ) const; @@ -358,16 +358,16 @@ public: BOOL operator == ( CONST D3DXQUATERNION& ) const; BOOL operator != ( CONST D3DXQUATERNION& ) const; -#endif //__cplusplus +#endif /*__cplusplus */ FLOAT x, y, z, w; } D3DXQUATERNION, *LPD3DXQUATERNION; -//=========================================================================== -// -// Planes -// -//=========================================================================== +/* + * + * Planes + * + */ typedef struct D3DXPLANE { #ifdef __cplusplus @@ -376,28 +376,28 @@ public: D3DXPLANE( CONST FLOAT* ); D3DXPLANE( FLOAT a, FLOAT b, FLOAT c, FLOAT d ); - // casting + /* casting */ operator FLOAT* (); operator CONST FLOAT* () const; - // unary operators + /* unary operators */ D3DXPLANE operator + () const; D3DXPLANE operator - () const; - // binary operators + /* binary operators */ BOOL operator == ( CONST D3DXPLANE& ) const; BOOL operator != ( CONST D3DXPLANE& ) const; -#endif //__cplusplus +#endif /* __cplusplus */ FLOAT a, b, c, d; } D3DXPLANE, *LPD3DXPLANE; -//=========================================================================== -// -// Colors -// -//=========================================================================== +/* + * + * Colors + * + */ typedef struct D3DXCOLOR { @@ -409,7 +409,7 @@ public: D3DXCOLOR( CONST D3DCOLORVALUE& ); D3DXCOLOR( FLOAT r, FLOAT g, FLOAT b, FLOAT a ); - // casting + /* casting */ operator DWORD () const; operator FLOAT* (); @@ -421,17 +421,17 @@ public: operator D3DCOLORVALUE& (); operator CONST D3DCOLORVALUE& () const; - // assignment operators + /* assignment operators */ D3DXCOLOR& operator += ( CONST D3DXCOLOR& ); D3DXCOLOR& operator -= ( CONST D3DXCOLOR& ); D3DXCOLOR& operator *= ( FLOAT ); D3DXCOLOR& operator /= ( FLOAT ); - // unary operators + /* unary operators */ D3DXCOLOR operator + () const; D3DXCOLOR operator - () const; - // binary operators + /* binary operators */ D3DXCOLOR operator + ( CONST D3DXCOLOR& ) const; D3DXCOLOR operator - ( CONST D3DXCOLOR& ) const; D3DXCOLOR operator * ( FLOAT ) const; @@ -442,29 +442,29 @@ public: BOOL operator == ( CONST D3DXCOLOR& ) const; BOOL operator != ( CONST D3DXCOLOR& ) const; -#endif //__cplusplus +#endif /* __cplusplus */ FLOAT r, g, b, a; } D3DXCOLOR, *LPD3DXCOLOR; -//=========================================================================== -// -// D3DX math functions: -// -// NOTE: -// * All these functions can take the same object as in and out parameters. -// -// * Out parameters are typically also returned as return values, so that -// the output of one function may be used as a parameter to another. -// -//=========================================================================== +/* + * + * D3DX math functions: + * + * NOTE: + * * All these functions can take the same object as in and out parameters. + * + * * Out parameters are typically also returned as return values, so that + * the output of one function may be used as a parameter to another. + * + */ -//-------------------------- -// 2D Vector -//-------------------------- +/* + * 2D Vector + */ -// inline +/* inline */ FLOAT D3DXVec2Length ( CONST D3DXVECTOR2 *pV ); @@ -475,7 +475,7 @@ FLOAT D3DXVec2LengthSq FLOAT D3DXVec2Dot ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); -// Z component of ((x1,y1,0) cross (x2,y2,0)) +/* Z component of ((x1,y1,0) cross (x2,y2,0)) */ FLOAT D3DXVec2CCW ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); @@ -485,23 +485,23 @@ D3DXVECTOR2* D3DXVec2Add D3DXVECTOR2* D3DXVec2Subtract ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); -// Minimize each component. x = min(x1, x2), y = min(y1, y2) +/* Minimize each component. x = min(x1, x2), y = min(y1, y2) */ D3DXVECTOR2* D3DXVec2Minimize ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); -// Maximize each component. x = max(x1, x2), y = max(y1, y2) +/* Maximize each component. x = max(x1, x2), y = max(y1, y2) */ D3DXVECTOR2* D3DXVec2Maximize ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); D3DXVECTOR2* D3DXVec2Scale ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, FLOAT s ); -// Linear interpolation. V1 + s(V2-V1) +/* Linear interpolation. V1 + s(V2-V1) */ D3DXVECTOR2* D3DXVec2Lerp ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, FLOAT s ); -// non-inline +/* non-inline */ #ifdef __cplusplus extern "C" { #endif @@ -509,31 +509,31 @@ extern "C" { D3DXVECTOR2* WINAPI D3DXVec2Normalize ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV ); -// Hermite interpolation between position V1, tangent T1 (when s == 0) -// and position V2, tangent T2 (when s == 1). +/* Hermite interpolation between position V1, tangent T1 (when s == 0) + * and position V2, tangent T2 (when s == 1). */ D3DXVECTOR2* WINAPI D3DXVec2Hermite ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pT1, CONST D3DXVECTOR2 *pV2, CONST D3DXVECTOR2 *pT2, FLOAT s ); -// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) +/* CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) */ D3DXVECTOR2* WINAPI D3DXVec2CatmullRom ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV0, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, CONST D3DXVECTOR2 *pV3, FLOAT s ); -// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) +/* Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) */ D3DXVECTOR2* WINAPI D3DXVec2BaryCentric ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, CONST D3DXVECTOR2 *pV3, FLOAT f, FLOAT g); -// Transform (x, y, 0, 1) by matrix. +/* Transform (x, y, 0, 1) by matrix. */ D3DXVECTOR4* WINAPI D3DXVec2Transform ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); -// Transform (x, y, 0, 1) by matrix, project result back into w=1. +/* Transform (x, y, 0, 1) by matrix, project result back into w=1. */ D3DXVECTOR2* WINAPI D3DXVec2TransformCoord ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); -// Transform (x, y, 0, 0) by matrix. +/* Transform (x, y, 0, 0) by matrix. */ D3DXVECTOR2* WINAPI D3DXVec2TransformNormal ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); @@ -541,12 +541,11 @@ D3DXVECTOR2* WINAPI D3DXVec2TransformNormal } #endif +/* + * 3D Vector + */ -//-------------------------- -// 3D Vector -//-------------------------- - -// inline +/* inline */ FLOAT D3DXVec3Length ( CONST D3DXVECTOR3 *pV ); @@ -566,23 +565,23 @@ D3DXVECTOR3* D3DXVec3Add D3DXVECTOR3* D3DXVec3Subtract ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); -// Minimize each component. x = min(x1, x2), y = min(y1, y2), ... +/* Minimize each component. x = min(x1, x2), y = min(y1, y2), ... */ D3DXVECTOR3* D3DXVec3Minimize ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); -// Maximize each component. x = max(x1, x2), y = max(y1, y2), ... +/* Maximize each component. x = max(x1, x2), y = max(y1, y2), ... */ D3DXVECTOR3* D3DXVec3Maximize ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); D3DXVECTOR3* D3DXVec3Scale ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, FLOAT s); -// Linear interpolation. V1 + s(V2-V1) +/* Linear interpolation. V1 + s(V2-V1) */ D3DXVECTOR3* D3DXVec3Lerp ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, FLOAT s ); -// non-inline +/* non-inline */ #ifdef __cplusplus extern "C" { #endif @@ -590,42 +589,42 @@ extern "C" { D3DXVECTOR3* WINAPI D3DXVec3Normalize ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV ); -// Hermite interpolation between position V1, tangent T1 (when s == 0) -// and position V2, tangent T2 (when s == 1). +/* Hermite interpolation between position V1, tangent T1 (when s == 0) + * and position V2, tangent T2 (when s == 1). */ D3DXVECTOR3* WINAPI D3DXVec3Hermite ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pT1, CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pT2, FLOAT s ); -// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) +/* CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) */ D3DXVECTOR3* WINAPI D3DXVec3CatmullRom ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV0, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pV3, FLOAT s ); -// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) +/* Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) */ D3DXVECTOR3* WINAPI D3DXVec3BaryCentric ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pV3, FLOAT f, FLOAT g); -// Transform (x, y, z, 1) by matrix. +/* Transform (x, y, z, 1) by matrix. */ D3DXVECTOR4* WINAPI D3DXVec3Transform ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); -// Transform (x, y, z, 1) by matrix, project result back into w=1. +/* Transform (x, y, z, 1) by matrix, project result back into w=1. */ D3DXVECTOR3* WINAPI D3DXVec3TransformCoord ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); -// Transform (x, y, z, 0) by matrix. If you transforming a normal by a -// non-affine matrix, the matrix you pass to this function should be the -// transpose of the inverse of the matrix you would use to transform a coord. +/* Transform (x, y, z, 0) by matrix. If you transforming a normal by a + * non-affine matrix, the matrix you pass to this function should be the + * transpose of the inverse of the matrix you would use to transform a coord. */ D3DXVECTOR3* WINAPI D3DXVec3TransformNormal ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); -// Project vector from object space into screen space +/* Project vector from object space into screen space */ D3DXVECTOR3* WINAPI D3DXVec3Project ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DVIEWPORT8 *pViewport, CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld); -// Project vector from screen space into object space +/* Project vector from screen space into object space */ D3DXVECTOR3* WINAPI D3DXVec3Unproject ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DVIEWPORT8 *pViewport, CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld); @@ -634,13 +633,11 @@ D3DXVECTOR3* WINAPI D3DXVec3Unproject } #endif +/* + * 4D Vector + */ - -//-------------------------- -// 4D Vector -//-------------------------- - -// inline +/* inline */ FLOAT D3DXVec4Length ( CONST D3DXVECTOR4 *pV ); @@ -657,28 +654,28 @@ D3DXVECTOR4* D3DXVec4Add D3DXVECTOR4* D3DXVec4Subtract ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); -// Minimize each component. x = min(x1, x2), y = min(y1, y2), ... +/* Minimize each component. x = min(x1, x2), y = min(y1, y2), ... */ D3DXVECTOR4* D3DXVec4Minimize ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); -// Maximize each component. x = max(x1, x2), y = max(y1, y2), ... +/* Maximize each component. x = max(x1, x2), y = max(y1, y2), ... */ D3DXVECTOR4* D3DXVec4Maximize ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); D3DXVECTOR4* D3DXVec4Scale ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, FLOAT s); -// Linear interpolation. V1 + s(V2-V1) +/* Linear interpolation. V1 + s(V2-V1) */ D3DXVECTOR4* D3DXVec4Lerp ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, FLOAT s ); -// non-inline +/* non-inline */ #ifdef __cplusplus extern "C" { #endif -// Cross-product in 4 dimensions. +/* Cross-product in 4 dimensions. */ D3DXVECTOR4* WINAPI D3DXVec4Cross ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pV3); @@ -686,23 +683,23 @@ D3DXVECTOR4* WINAPI D3DXVec4Cross D3DXVECTOR4* WINAPI D3DXVec4Normalize ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV ); -// Hermite interpolation between position V1, tangent T1 (when s == 0) -// and position V2, tangent T2 (when s == 1). +/* Hermite interpolation between position V1, tangent T1 (when s == 0) + * and position V2, tangent T2 (when s == 1). */ D3DXVECTOR4* WINAPI D3DXVec4Hermite ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pT1, CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pT2, FLOAT s ); -// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) +/* CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) */ D3DXVECTOR4* WINAPI D3DXVec4CatmullRom ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV0, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pV3, FLOAT s ); -// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) +/* Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) */ D3DXVECTOR4* WINAPI D3DXVec4BaryCentric ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pV3, FLOAT f, FLOAT g); -// Transform vector by matrix. +/* Transform vector by matrix. */ D3DXVECTOR4* WINAPI D3DXVec4Transform ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, CONST D3DXMATRIX *pM ); @@ -711,11 +708,11 @@ D3DXVECTOR4* WINAPI D3DXVec4Transform #endif -//-------------------------- -// 4D Matrix -//-------------------------- +/* + * 4D Matrix + */ -// inline +/* inline */ D3DXMATRIX* D3DXMatrixIdentity ( D3DXMATRIX *pOut ); @@ -724,7 +721,7 @@ BOOL D3DXMatrixIsIdentity ( CONST D3DXMATRIX *pM ); -// non-inline +/* non-inline */ #ifdef __cplusplus extern "C" { #endif @@ -735,130 +732,130 @@ FLOAT WINAPI D3DXMatrixfDeterminant D3DXMATRIX* WINAPI D3DXMatrixTranspose ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM ); -// Matrix multiplication. The result represents the transformation M2 -// followed by the transformation M1. (Out = M1 * M2) +/* Matrix multiplication. The result represents the transformation M2 + * followed by the transformation M1. (Out = M1 * M2) */ D3DXMATRIX* WINAPI D3DXMatrixMultiply ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 ); -// Matrix multiplication, followed by a transpose. (Out = T(M1 * M2)) +/* Matrix multiplication, followed by a transpose. (Out = T(M1 * M2)) */ D3DXMATRIX* WINAPI D3DXMatrixMultiplyTranspose ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 ); -// Calculate inverse of matrix. Inversion my fail, in which case NULL will -// be returned. The determinant of pM is also returned it pfDeterminant -// is non-NULL. +/* Calculate inverse of matrix. Inversion my fail, in which case NULL will + * be returned. The determinant of pM is also returned it pfDeterminant + * is non-NULL. */ D3DXMATRIX* WINAPI D3DXMatrixInverse ( D3DXMATRIX *pOut, FLOAT *pDeterminant, CONST D3DXMATRIX *pM ); -// Build a matrix which scales by (sx, sy, sz) +/* Build a matrix which scales by (sx, sy, sz) */ D3DXMATRIX* WINAPI D3DXMatrixScaling ( D3DXMATRIX *pOut, FLOAT sx, FLOAT sy, FLOAT sz ); -// Build a matrix which translates by (x, y, z) +/* Build a matrix which translates by (x, y, z) */ D3DXMATRIX* WINAPI D3DXMatrixTranslation ( D3DXMATRIX *pOut, FLOAT x, FLOAT y, FLOAT z ); -// Build a matrix which rotates around the X axis +/* Build a matrix which rotates around the X axis */ D3DXMATRIX* WINAPI D3DXMatrixRotationX ( D3DXMATRIX *pOut, FLOAT Angle ); -// Build a matrix which rotates around the Y axis +/* Build a matrix which rotates around the Y axis */ D3DXMATRIX* WINAPI D3DXMatrixRotationY ( D3DXMATRIX *pOut, FLOAT Angle ); -// Build a matrix which rotates around the Z axis +/* Build a matrix which rotates around the Z axis */ D3DXMATRIX* WINAPI D3DXMatrixRotationZ ( D3DXMATRIX *pOut, FLOAT Angle ); -// Build a matrix which rotates around an arbitrary axis +/* Build a matrix which rotates around an arbitrary axis */ D3DXMATRIX* WINAPI D3DXMatrixRotationAxis ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pV, FLOAT Angle ); -// Build a matrix from a quaternion +/* Build a matrix from a quaternion */ D3DXMATRIX* WINAPI D3DXMatrixRotationQuaternion ( D3DXMATRIX *pOut, CONST D3DXQUATERNION *pQ); -// Yaw around the Y axis, a pitch around the X axis, -// and a roll around the Z axis. +/* Yaw around the Y axis, a pitch around the X axis, + * and a roll around the Z axis. */ D3DXMATRIX* WINAPI D3DXMatrixRotationYawPitchRoll ( D3DXMATRIX *pOut, FLOAT Yaw, FLOAT Pitch, FLOAT Roll ); -// Build transformation matrix. NULL arguments are treated as identity. -// Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt +/* Build transformation matrix. NULL arguments are treated as identity. + * Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt */ D3DXMATRIX* WINAPI D3DXMatrixTransformation ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pScalingCenter, CONST D3DXQUATERNION *pScalingRotation, CONST D3DXVECTOR3 *pScaling, CONST D3DXVECTOR3 *pRotationCenter, CONST D3DXQUATERNION *pRotation, CONST D3DXVECTOR3 *pTranslation); -// Build affine transformation matrix. NULL arguments are treated as identity. -// Mout = Ms * Mrc-1 * Mr * Mrc * Mt +/* Build affine transformation matrix. NULL arguments are treated as identity. + * Mout = Ms * Mrc-1 * Mr * Mrc * Mt */ D3DXMATRIX* WINAPI D3DXMatrixAffineTransformation ( D3DXMATRIX *pOut, FLOAT Scaling, CONST D3DXVECTOR3 *pRotationCenter, CONST D3DXQUATERNION *pRotation, CONST D3DXVECTOR3 *pTranslation); -// Build a lookat matrix. (right-handed) +/* Build a lookat matrix. (right-handed) */ D3DXMATRIX* WINAPI D3DXMatrixLookAtRH ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pEye, CONST D3DXVECTOR3 *pAt, CONST D3DXVECTOR3 *pUp ); -// Build a lookat matrix. (left-handed) +/* Build a lookat matrix. (left-handed) */ D3DXMATRIX* WINAPI D3DXMatrixLookAtLH ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pEye, CONST D3DXVECTOR3 *pAt, CONST D3DXVECTOR3 *pUp ); -// Build a perspective projection matrix. (right-handed) +/* Build a perspective projection matrix. (right-handed) */ D3DXMATRIX* WINAPI D3DXMatrixPerspectiveRH ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); -// Build a perspective projection matrix. (left-handed) +/* Build a perspective projection matrix. (left-handed) */ D3DXMATRIX* WINAPI D3DXMatrixPerspectiveLH ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); -// Build a perspective projection matrix. (right-handed) +/* Build a perspective projection matrix. (right-handed) */ D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovRH ( D3DXMATRIX *pOut, FLOAT fovy, FLOAT Aspect, FLOAT zn, FLOAT zf ); -// Build a perspective projection matrix. (left-handed) +/* Build a perspective projection matrix. (left-handed) */ D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovLH ( D3DXMATRIX *pOut, FLOAT fovy, FLOAT Aspect, FLOAT zn, FLOAT zf ); -// Build a perspective projection matrix. (right-handed) +/* Build a perspective projection matrix. (right-handed) */ D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterRH ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, FLOAT zf ); -// Build a perspective projection matrix. (left-handed) +/* Build a perspective projection matrix. (left-handed) */ D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterLH ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, FLOAT zf ); -// Build an ortho projection matrix. (right-handed) +/* Build an ortho projection matrix. (right-handed) */ D3DXMATRIX* WINAPI D3DXMatrixOrthoRH ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); -// Build an ortho projection matrix. (left-handed) +/* Build an ortho projection matrix. (left-handed) */ D3DXMATRIX* WINAPI D3DXMatrixOrthoLH ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); -// Build an ortho projection matrix. (right-handed) +/* Build an ortho projection matrix. (right-handed) */ D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenterRH ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, FLOAT zf ); -// Build an ortho projection matrix. (left-handed) +/* Build an ortho projection matrix. (left-handed) */ D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenterLH ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, FLOAT zf ); -// Build a matrix which flattens geometry into a plane, as if casting -// a shadow from a light. +/* Build a matrix which flattens geometry into a plane, as if casting + * a shadow from a light. */ D3DXMATRIX* WINAPI D3DXMatrixShadow ( D3DXMATRIX *pOut, CONST D3DXVECTOR4 *pLight, CONST D3DXPLANE *pPlane ); -// Build a matrix which reflects the coordinate system about a plane +/* Build a matrix which reflects the coordinate system about a plane */ D3DXMATRIX* WINAPI D3DXMatrixReflect ( D3DXMATRIX *pOut, CONST D3DXPLANE *pPlane ); @@ -867,58 +864,58 @@ D3DXMATRIX* WINAPI D3DXMatrixReflect #endif -//-------------------------- -// Quaternion -//-------------------------- +/* + * Quaternion + */ -// inline +/* inline */ FLOAT D3DXQuaternionLength ( CONST D3DXQUATERNION *pQ ); -// Length squared, or "norm" +/* Length squared, or "norm" */ FLOAT D3DXQuaternionLengthSq ( CONST D3DXQUATERNION *pQ ); FLOAT D3DXQuaternionDot ( CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2 ); -// (0, 0, 0, 1) +/* (0, 0, 0, 1) */ D3DXQUATERNION* D3DXQuaternionIdentity ( D3DXQUATERNION *pOut ); BOOL D3DXQuaternionIsIdentity ( CONST D3DXQUATERNION *pQ ); -// (-x, -y, -z, w) +/* (-x, -y, -z, w) */ D3DXQUATERNION* D3DXQuaternionConjugate ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); -// non-inline +/* non-inline */ #ifdef __cplusplus extern "C" { #endif -// Compute a quaternin's axis and angle of rotation. Expects unit quaternions. +/* Compute a quaternin's axis and angle of rotation. Expects unit quaternions. */ void WINAPI D3DXQuaternionToAxisAngle ( CONST D3DXQUATERNION *pQ, D3DXVECTOR3 *pAxis, FLOAT *pAngle ); -// Build a quaternion from a rotation matrix. +/* Build a quaternion from a rotation matrix. */ D3DXQUATERNION* WINAPI D3DXQuaternionRotationMatrix ( D3DXQUATERNION *pOut, CONST D3DXMATRIX *pM); -// Rotation about arbitrary axis. +/* Rotation about arbitrary axis. */ D3DXQUATERNION* WINAPI D3DXQuaternionRotationAxis ( D3DXQUATERNION *pOut, CONST D3DXVECTOR3 *pV, FLOAT Angle ); -// Yaw around the Y axis, a pitch around the X axis, -// and a roll around the Z axis. +/* Yaw around the Y axis, a pitch around the X axis, + * and a roll around the Z axis. */ D3DXQUATERNION* WINAPI D3DXQuaternionRotationYawPitchRoll ( D3DXQUATERNION *pOut, FLOAT Yaw, FLOAT Pitch, FLOAT Roll ); -// Quaternion multiplication. The result represents the rotation Q2 -// followed by the rotation Q1. (Out = Q2 * Q1) +/* Quaternion multiplication. The result represents the rotation Q2 + * followed by the rotation Q1. (Out = Q2 * Q1) */ D3DXQUATERNION* WINAPI D3DXQuaternionMultiply ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2 ); @@ -926,43 +923,43 @@ D3DXQUATERNION* WINAPI D3DXQuaternionMultiply D3DXQUATERNION* WINAPI D3DXQuaternionNormalize ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); -// Conjugate and re-norm +/* Conjugate and re-norm */ D3DXQUATERNION* WINAPI D3DXQuaternionInverse ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); -// Expects unit quaternions. -// if q = (cos(theta), sin(theta) * v); ln(q) = (0, theta * v) +/* Expects unit quaternions. + * if q = (cos(theta), sin(theta) * v); ln(q) = (0, theta * v) */ D3DXQUATERNION* WINAPI D3DXQuaternionLn ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); -// Expects pure quaternions. (w == 0) w is ignored in calculation. -// if q = (0, theta * v); exp(q) = (cos(theta), sin(theta) * v) +/* Expects pure quaternions. (w == 0) w is ignored in calculation. + * if q = (0, theta * v); exp(q) = (cos(theta), sin(theta) * v) */ D3DXQUATERNION* WINAPI D3DXQuaternionExp ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); -// Spherical linear interpolation between Q1 (t == 0) and Q2 (t == 1). -// Expects unit quaternions. +/* Spherical linear interpolation between Q1 (t == 0) and Q2 (t == 1). + * Expects unit quaternions. */ D3DXQUATERNION* WINAPI D3DXQuaternionSlerp ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2, FLOAT t ); -// Spherical quadrangle interpolation. -// Slerp(Slerp(Q1, C, t), Slerp(A, B, t), 2t(1-t)) +/* Spherical quadrangle interpolation. + * Slerp(Slerp(Q1, C, t), Slerp(A, B, t), 2t(1-t)) */ D3DXQUATERNION* WINAPI D3DXQuaternionSquad ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pA, CONST D3DXQUATERNION *pB, CONST D3DXQUATERNION *pC, FLOAT t ); -// Setup control points for spherical quadrangle interpolation -// from Q1 to Q2. The control points are chosen in such a way -// to ensure the continuity of tangents with adjacent segments. +/* Setup control points for spherical quadrangle interpolation + * from Q1 to Q2. The control points are chosen in such a way + * to ensure the continuity of tangents with adjacent segments. */ void WINAPI D3DXQuaternionSquadSetup ( D3DXQUATERNION *pAOut, D3DXQUATERNION *pBOut, D3DXQUATERNION *pCOut, CONST D3DXQUATERNION *pQ0, CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2, CONST D3DXQUATERNION *pQ3 ); -// Barycentric interpolation. -// Slerp(Slerp(Q1, Q2, f+g), Slerp(Q1, Q3, f+g), g/(f+g)) +/* Barycentric interpolation. + * Slerp(Slerp(Q1, Q2, f+g), Slerp(Q1, Q3, f+g), g/(f+g)) */ D3DXQUATERNION* WINAPI D3DXQuaternionBaryCentric ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2, CONST D3DXQUATERNION *pQ3, @@ -973,50 +970,50 @@ D3DXQUATERNION* WINAPI D3DXQuaternionBaryCentric #endif -//-------------------------- -// Plane -//-------------------------- +/* + * Plane + */ -// inline +/* inline */ -// ax + by + cz + dw +/* ax + by + cz + dw */ FLOAT D3DXPlaneDot ( CONST D3DXPLANE *pP, CONST D3DXVECTOR4 *pV); -// ax + by + cz + d +/* ax + by + cz + d */ FLOAT D3DXPlaneDotCoord ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV); -// ax + by + cz +/* ax + by + cz */ FLOAT D3DXPlaneDotNormal ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV); -// non-inline +/* non-inline */ #ifdef __cplusplus extern "C" { #endif -// Normalize plane (so that |a,b,c| == 1) +/* Normalize plane (so that |a,b,c| == 1) */ D3DXPLANE* WINAPI D3DXPlaneNormalize ( D3DXPLANE *pOut, CONST D3DXPLANE *pP); -// Find the intersection between a plane and a line. If the line is -// parallel to the plane, NULL is returned. +/* Find the intersection between a plane and a line. If the line is + * parallel to the plane, NULL is returned. */ D3DXVECTOR3* WINAPI D3DXPlaneIntersectLine ( D3DXVECTOR3 *pOut, CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2); -// Construct a plane from a point and a normal +/* Construct a plane from a point and a normal */ D3DXPLANE* WINAPI D3DXPlaneFromPointNormal ( D3DXPLANE *pOut, CONST D3DXVECTOR3 *pPoint, CONST D3DXVECTOR3 *pNormal); -// Construct a plane from 3 points +/* Construct a plane from 3 points */ D3DXPLANE* WINAPI D3DXPlaneFromPoints ( D3DXPLANE *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pV3); -// Transform a plane by a matrix. The vector (a,b,c) must be normal. -// M should be the inverse transpose of the transformation desired. +/* Transform a plane by a matrix. The vector (a,b,c) must be normal. + * M should be the inverse transpose of the transformation desired. */ D3DXPLANE* WINAPI D3DXPlaneTransform ( D3DXPLANE *pOut, CONST D3DXPLANE *pP, CONST D3DXMATRIX *pM ); @@ -1025,13 +1022,13 @@ D3DXPLANE* WINAPI D3DXPlaneTransform #endif -//-------------------------- -// Color -//-------------------------- +/* + * Color + */ -// inline +/* inline */ -// (1-r, 1-g, 1-b, a) +/* (1-r, 1-g, 1-b, a) */ D3DXCOLOR* D3DXColorNegative (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC); @@ -1044,25 +1041,25 @@ D3DXCOLOR* D3DXColorSubtract D3DXCOLOR* D3DXColorScale (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s); -// (r1*r2, g1*g2, b1*b2, a1*a2) +/* (r1*r2, g1*g2, b1*b2, a1*a2) */ D3DXCOLOR* D3DXColorModulate (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2); -// Linear interpolation of r,g,b, and a. C1 + s(C2-C1) +/* Linear interpolation of r,g,b, and a. C1 + s(C2-C1) */ D3DXCOLOR* D3DXColorLerp (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2, FLOAT s); -// non-inline +/* non-inline */ #ifdef __cplusplus extern "C" { #endif -// Interpolate r,g,b between desaturated color and color. -// DesaturatedColor + s(Color - DesaturatedColor) +/* Interpolate r,g,b between desaturated color and color. + * DesaturatedColor + s(Color - DesaturatedColor) */ D3DXCOLOR* WINAPI D3DXColorAdjustSaturation (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s); -// Interpolate r,g,b between 50% grey and color. Grey + s(Color - Grey) +/* Interpolate r,g,b between 50% grey and color. Grey + s(Color - Grey) */ D3DXCOLOR* WINAPI D3DXColorAdjustContrast (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT c); @@ -1070,19 +1067,16 @@ D3DXCOLOR* WINAPI D3DXColorAdjustContrast } #endif - - - -//-------------------------- -// Misc -//-------------------------- +/* + * Misc + */ #ifdef __cplusplus extern "C" { #endif -// Calculate Fresnel term given the cosine of theta (likely obtained by -// taking the dot of two normals), and the refraction index of the material. +/* Calculate Fresnel term given the cosine of theta (likely obtained by + * taking the dot of two normals), and the refraction index of the material. */ FLOAT WINAPI D3DXFresnelTerm (FLOAT CosTheta, FLOAT RefractionIndex); @@ -1090,18 +1084,16 @@ FLOAT WINAPI D3DXFresnelTerm } #endif - - -//=========================================================================== -// -// Matrix Stack -// -//=========================================================================== +/* + * + * Matrix Stack + * + */ typedef interface ID3DXMatrixStack ID3DXMatrixStack; typedef interface ID3DXMatrixStack *LPD3DXMATRIXSTACK; -// {E3357330-CC5E-11d2-A434-00A0C90629A8} +/* {E3357330-CC5E-11d2-A434-00A0C90629A8} */ DEFINE_GUID( IID_ID3DXMatrixStack, 0xe3357330, 0xcc5e, 0x11d2, 0xa4, 0x34, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0xa8); @@ -1111,82 +1103,78 @@ DEFINE_GUID( IID_ID3DXMatrixStack, DECLARE_INTERFACE_(ID3DXMatrixStack, IUnknown) { - // - // IUnknown methods - // + /* IUnknown methods */ STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; STDMETHOD_(ULONG,AddRef)(THIS) PURE; STDMETHOD_(ULONG,Release)(THIS) PURE; - // - // ID3DXMatrixStack methods - // + /* ID3DXMatrixStack methods */ - // Pops the top of the stack, returns the current top - // *after* popping the top. + /* Pops the top of the stack, returns the current top + * *after* popping the top. */ STDMETHOD(Pop)(THIS) PURE; - // Pushes the stack by one, duplicating the current matrix. + /* Pushes the stack by one, duplicating the current matrix. */ STDMETHOD(Push)(THIS) PURE; - // Loads identity in the current matrix. + /* Loads identity in the current matrix. */ STDMETHOD(LoadIdentity)(THIS) PURE; - // Loads the given matrix into the current matrix + /* Loads the given matrix into the current matrix */ STDMETHOD(LoadMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE; - // Right-Multiplies the given matrix to the current matrix. - // (transformation is about the current world origin) + /* Right-Multiplies the given matrix to the current matrix. + * (transformation is about the current world origin) */ STDMETHOD(MultMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE; - // Left-Multiplies the given matrix to the current matrix - // (transformation is about the local origin of the object) + /* Left-Multiplies the given matrix to the current matrix + * (transformation is about the local origin of the object) */ STDMETHOD(MultMatrixLocal)(THIS_ CONST D3DXMATRIX* pM ) PURE; - // Right multiply the current matrix with the computed rotation - // matrix, counterclockwise about the given axis with the given angle. - // (rotation is about the current world origin) + /* Right multiply the current matrix with the computed rotation + * matrix, counterclockwise about the given axis with the given angle. + * (rotation is about the current world origin) */ STDMETHOD(RotateAxis) (THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE; - // Left multiply the current matrix with the computed rotation - // matrix, counterclockwise about the given axis with the given angle. - // (rotation is about the local origin of the object) + /* Left multiply the current matrix with the computed rotation + * matrix, counterclockwise about the given axis with the given angle. + * (rotation is about the local origin of the object) */ STDMETHOD(RotateAxisLocal) (THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE; - // Right multiply the current matrix with the computed rotation - // matrix. All angles are counterclockwise. (rotation is about the - // current world origin) + /* Right multiply the current matrix with the computed rotation + * matrix. All angles are counterclockwise. (rotation is about the + * current world origin) - // The rotation is composed of a yaw around the Y axis, a pitch around - // the X axis, and a roll around the Z axis. + * The rotation is composed of a yaw around the Y axis, a pitch around + * the X axis, and a roll around the Z axis. */ STDMETHOD(RotateYawPitchRoll) (THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE; - // Left multiply the current matrix with the computed rotation - // matrix. All angles are counterclockwise. (rotation is about the - // local origin of the object) + /* Left multiply the current matrix with the computed rotation + * matrix. All angles are counterclockwise. (rotation is about the + * local origin of the object) - // The rotation is composed of a yaw around the Y axis, a pitch around - // the X axis, and a roll around the Z axis. + * The rotation is composed of a yaw around the Y axis, a pitch around + * the X axis, and a roll around the Z axis. */ STDMETHOD(RotateYawPitchRollLocal) (THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE; - // Right multiply the current matrix with the computed scale - // matrix. (transformation is about the current world origin) + /* Right multiply the current matrix with the computed scale + * matrix. (transformation is about the current world origin) */ STDMETHOD(Scale)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; - // Left multiply the current matrix with the computed scale - // matrix. (transformation is about the local origin of the object) + /* Left multiply the current matrix with the computed scale + * matrix. (transformation is about the local origin of the object) */ STDMETHOD(ScaleLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; - // Right multiply the current matrix with the computed translation - // matrix. (transformation is about the current world origin) + /* Right multiply the current matrix with the computed translation + * matrix. (transformation is about the current world origin) */ STDMETHOD(Translate)(THIS_ FLOAT x, FLOAT y, FLOAT z ) PURE; - // Left multiply the current matrix with the computed translation - // matrix. (transformation is about the local origin of the object) + /* Left multiply the current matrix with the computed translation + * matrix. (transformation is about the local origin of the object) */ STDMETHOD(TranslateLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; /* Obtain the current matrix at the top of the stack */ diff --git a/gfx/include/d3d8/d3dx8math.inl b/gfx/include/d3d8/d3dx8math.inl index 00f2eabdd9..ca94a797ba 100644 --- a/gfx/include/d3d8/d3dx8math.inl +++ b/gfx/include/d3d8/d3dx8math.inl @@ -1,27 +1,26 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 1998 Microsoft Corporation. All Rights Reserved. -// -// File: d3dx8math.inl -// Content: D3DX math inline functions -// -////////////////////////////////////////////////////////////////////////////// +/* + * + * Copyright (C) 1998 Microsoft Corporation. All Rights Reserved. + * + * File: d3dx8math.inl + * Content: D3DX math inline functions + * + */ #ifndef __D3DX8MATH_INL__ #define __D3DX8MATH_INL__ - -//=========================================================================== -// -// Inline Class Methods -// -//=========================================================================== +/* + * + * Inline Class Methods + * + */ #ifdef __cplusplus -//-------------------------- -// 2D Vector -//-------------------------- +/* + * 2D Vector + */ D3DXINLINE D3DXVECTOR2::D3DXVECTOR2( CONST FLOAT *pf ) @@ -42,7 +41,7 @@ D3DXVECTOR2::D3DXVECTOR2( FLOAT fx, FLOAT fy ) y = fy; } -// casting +/* casting */ D3DXINLINE D3DXVECTOR2::operator FLOAT* () { @@ -55,7 +54,7 @@ D3DXVECTOR2::operator CONST FLOAT* () const return (CONST FLOAT *) &x; } -// assignment operators +/* assignment operators */ D3DXINLINE D3DXVECTOR2& D3DXVECTOR2::operator += ( CONST D3DXVECTOR2& v ) { @@ -89,7 +88,7 @@ D3DXVECTOR2::operator /= ( FLOAT f ) return *this; } -// unary operators +/* unary operators */ D3DXINLINE D3DXVECTOR2 D3DXVECTOR2::operator + () const { @@ -102,7 +101,7 @@ D3DXVECTOR2::operator - () const return D3DXVECTOR2(-x, -y); } -// binary operators +/* binary operators */ D3DXINLINE D3DXVECTOR2 D3DXVECTOR2::operator + ( CONST D3DXVECTOR2& v ) const { @@ -150,9 +149,9 @@ D3DXVECTOR2::operator != ( CONST D3DXVECTOR2& v ) const -//-------------------------- -// 3D Vector -//-------------------------- +/* + * 3D Vector + */ D3DXINLINE D3DXVECTOR3::D3DXVECTOR3( CONST FLOAT *pf ) { @@ -183,7 +182,7 @@ D3DXVECTOR3::D3DXVECTOR3( FLOAT fx, FLOAT fy, FLOAT fz ) } -// casting +/* casting */ D3DXINLINE D3DXVECTOR3::operator FLOAT* () { @@ -197,7 +196,7 @@ D3DXVECTOR3::operator CONST FLOAT* () const } -// assignment operators +/* assignment operators */ D3DXINLINE D3DXVECTOR3& D3DXVECTOR3::operator += ( CONST D3DXVECTOR3& v ) { @@ -235,8 +234,7 @@ D3DXVECTOR3::operator /= ( FLOAT f ) return *this; } - -// unary operators +/* unary operators */ D3DXINLINE D3DXVECTOR3 D3DXVECTOR3::operator + () const { @@ -249,8 +247,7 @@ D3DXVECTOR3::operator - () const return D3DXVECTOR3(-x, -y, -z); } - -// binary operators +/* binary operators */ D3DXINLINE D3DXVECTOR3 D3DXVECTOR3::operator + ( CONST D3DXVECTOR3& v ) const { @@ -296,11 +293,9 @@ D3DXVECTOR3::operator != ( CONST D3DXVECTOR3& v ) const return x != v.x || y != v.y || z != v.z; } - - -//-------------------------- -// 4D Vector -//-------------------------- +/* + * 4D Vector + */ D3DXINLINE D3DXVECTOR4::D3DXVECTOR4( CONST FLOAT *pf ) { @@ -324,8 +319,7 @@ D3DXVECTOR4::D3DXVECTOR4( FLOAT fx, FLOAT fy, FLOAT fz, FLOAT fw ) w = fw; } - -// casting +/* casting */ D3DXINLINE D3DXVECTOR4::operator FLOAT* () { @@ -339,7 +333,7 @@ D3DXVECTOR4::operator CONST FLOAT* () const } -// assignment operators +/* assignment operators */ D3DXINLINE D3DXVECTOR4& D3DXVECTOR4::operator += ( CONST D3DXVECTOR4& v ) { @@ -381,8 +375,7 @@ D3DXVECTOR4::operator /= ( FLOAT f ) return *this; } - -// unary operators +/* unary operators */ D3DXINLINE D3DXVECTOR4 D3DXVECTOR4::operator + () const { @@ -396,7 +389,7 @@ D3DXVECTOR4::operator - () const } -// binary operators +/* binary operators */ D3DXINLINE D3DXVECTOR4 D3DXVECTOR4::operator + ( CONST D3DXVECTOR4& v ) const { @@ -443,9 +436,9 @@ D3DXVECTOR4::operator != ( CONST D3DXVECTOR4& v ) const } -//-------------------------- -// Matrix -//-------------------------- +/* + * Matrix + */ D3DXINLINE D3DXMATRIX::D3DXMATRIX( CONST FLOAT* pf ) { @@ -475,9 +468,7 @@ D3DXMATRIX::D3DXMATRIX( FLOAT f11, FLOAT f12, FLOAT f13, FLOAT f14, _41 = f41; _42 = f42; _43 = f43; _44 = f44; } - - -// access grants +/* access grants */ D3DXINLINE FLOAT& D3DXMATRIX::operator () ( UINT iRow, UINT iCol ) { @@ -491,7 +482,7 @@ D3DXMATRIX::operator () ( UINT iRow, UINT iCol ) const } -// casting operators +/* casting operators */ D3DXINLINE D3DXMATRIX::operator FLOAT* () { @@ -505,7 +496,7 @@ D3DXMATRIX::operator CONST FLOAT* () const } -// assignment operators +/* assignment operators */ D3DXINLINE D3DXMATRIX& D3DXMATRIX::operator *= ( CONST D3DXMATRIX& mat ) { @@ -554,8 +545,7 @@ D3DXMATRIX::operator /= ( FLOAT f ) return *this; } - -// unary operators +/* unary operators */ D3DXINLINE D3DXMATRIX D3DXMATRIX::operator + () const { @@ -571,8 +561,7 @@ D3DXMATRIX::operator - () const -_41, -_42, -_43, -_44); } - -// binary operators +/* binary operators */ D3DXINLINE D3DXMATRIX D3DXMATRIX::operator * ( CONST D3DXMATRIX& mat ) const { @@ -643,9 +632,9 @@ D3DXMATRIX::operator != ( CONST D3DXMATRIX& mat ) const -//-------------------------- -// Quaternion -//-------------------------- +/* + * Quaternion + */ D3DXINLINE D3DXQUATERNION::D3DXQUATERNION( CONST FLOAT* pf ) @@ -671,7 +660,7 @@ D3DXQUATERNION::D3DXQUATERNION( FLOAT fx, FLOAT fy, FLOAT fz, FLOAT fw ) } -// casting +/* casting */ D3DXINLINE D3DXQUATERNION::operator FLOAT* () { @@ -685,7 +674,7 @@ D3DXQUATERNION::operator CONST FLOAT* () const } -// assignment operators +/* assignment operators */ D3DXINLINE D3DXQUATERNION& D3DXQUATERNION::operator += ( CONST D3DXQUATERNION& q ) { @@ -735,7 +724,7 @@ D3DXQUATERNION::operator /= ( FLOAT f ) } -// unary operators +/* unary operators */ D3DXINLINE D3DXQUATERNION D3DXQUATERNION::operator + () const { @@ -749,7 +738,7 @@ D3DXQUATERNION::operator - () const } -// binary operators +/* binary operators */ D3DXINLINE D3DXQUATERNION D3DXQUATERNION::operator + ( CONST D3DXQUATERNION& q ) const { @@ -805,9 +794,9 @@ D3DXQUATERNION::operator != ( CONST D3DXQUATERNION& q ) const -//-------------------------- -// Plane -//-------------------------- +/* + * Plane + */ D3DXINLINE D3DXPLANE::D3DXPLANE( CONST FLOAT* pf ) @@ -832,8 +821,7 @@ D3DXPLANE::D3DXPLANE( FLOAT fa, FLOAT fb, FLOAT fc, FLOAT fd ) d = fd; } - -// casting +/* casting */ D3DXINLINE D3DXPLANE::operator FLOAT* () { @@ -847,7 +835,7 @@ D3DXPLANE::operator CONST FLOAT* () const } -// unary operators +/* unary operators */ D3DXINLINE D3DXPLANE D3DXPLANE::operator + () const { @@ -860,8 +848,7 @@ D3DXPLANE::operator - () const return D3DXPLANE(-a, -b, -c, -d); } - -// binary operators +/* binary operators */ D3DXINLINE BOOL D3DXPLANE::operator == ( CONST D3DXPLANE& p ) const { @@ -874,12 +861,9 @@ D3DXPLANE::operator != ( CONST D3DXPLANE& p ) const return a != p.a || b != p.b || c != p.c || d != p.d; } - - - -//-------------------------- -// Color -//-------------------------- +/* + * Color + */ D3DXINLINE D3DXCOLOR::D3DXCOLOR( DWORD dw ) @@ -923,8 +907,7 @@ D3DXCOLOR::D3DXCOLOR( FLOAT fr, FLOAT fg, FLOAT fb, FLOAT fa ) a = fa; } - -// casting +/* casting */ D3DXINLINE D3DXCOLOR::operator DWORD () const { @@ -975,8 +958,7 @@ D3DXCOLOR::operator CONST D3DCOLORVALUE& () const return *((CONST D3DCOLORVALUE *) &r); } - -// assignment operators +/* assignment operators */ D3DXINLINE D3DXCOLOR& D3DXCOLOR::operator += ( CONST D3DXCOLOR& c ) { @@ -1018,8 +1000,7 @@ D3DXCOLOR::operator /= ( FLOAT f ) return *this; } - -// unary operators +/* unary operators */ D3DXINLINE D3DXCOLOR D3DXCOLOR::operator + () const { @@ -1033,7 +1014,7 @@ D3DXCOLOR::operator - () const } -// binary operators +/* binary operators */ D3DXINLINE D3DXCOLOR D3DXCOLOR::operator + ( CONST D3DXCOLOR& c ) const { @@ -1080,20 +1061,18 @@ D3DXCOLOR::operator != ( CONST D3DXCOLOR& c ) const } -#endif //__cplusplus +#endif /* __cplusplus */ + +/* + * + * Inline functions + * + */ - -//=========================================================================== -// -// Inline functions -// -//=========================================================================== - - -//-------------------------- -// 2D Vector -//-------------------------- +/* + * 2D Vector + */ D3DXINLINE FLOAT D3DXVec2Length ( CONST D3DXVECTOR2 *pV ) @@ -1223,9 +1202,9 @@ D3DXINLINE D3DXVECTOR2* D3DXVec2Lerp } -//-------------------------- -// 3D Vector -//-------------------------- +/* + * 3D Vector + */ D3DXINLINE FLOAT D3DXVec3Length ( CONST D3DXVECTOR3 *pV ) @@ -1368,9 +1347,9 @@ D3DXINLINE D3DXVECTOR3* D3DXVec3Lerp } -//-------------------------- -// 4D Vector -//-------------------------- +/* + * 4D Vector + */ D3DXINLINE FLOAT D3DXVec4Length ( CONST D3DXVECTOR4 *pV ) @@ -1501,9 +1480,9 @@ D3DXINLINE D3DXVECTOR4* D3DXVec4Lerp } -//-------------------------- -// 4D Matrix -//-------------------------- +/* + * 4D Matrix + */ D3DXINLINE D3DXMATRIX* D3DXMatrixIdentity ( D3DXMATRIX *pOut ) @@ -1538,9 +1517,9 @@ D3DXINLINE BOOL D3DXMatrixIsIdentity } -//-------------------------- -// Quaternion -//-------------------------- +/* + * Quaternion + */ D3DXINLINE FLOAT D3DXQuaternionLength ( CONST D3DXQUATERNION *pQ ) @@ -1621,9 +1600,9 @@ D3DXINLINE D3DXQUATERNION* D3DXQuaternionConjugate } -//-------------------------- -// Plane -//-------------------------- +/* + * Plane + */ D3DXINLINE FLOAT D3DXPlaneDot ( CONST D3DXPLANE *pP, CONST D3DXVECTOR4 *pV) @@ -1659,9 +1638,9 @@ D3DXINLINE FLOAT D3DXPlaneDotNormal } -//-------------------------- -// Color -//-------------------------- +/* + * Color + */ D3DXINLINE D3DXCOLOR* D3DXColorNegative (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC) @@ -1754,4 +1733,4 @@ D3DXINLINE D3DXCOLOR* D3DXColorLerp } -#endif // __D3DX8MATH_INL__ +#endif /* __D3DX8MATH_INL__ */ diff --git a/gfx/include/d3d8/d3dx8tex.h b/gfx/include/d3d8/d3dx8tex.h index d437e4b052..0a2526996f 100644 --- a/gfx/include/d3d8/d3dx8tex.h +++ b/gfx/include/d3d8/d3dx8tex.h @@ -11,49 +11,48 @@ #ifndef __D3DX8TEX_H__ #define __D3DX8TEX_H__ - -//---------------------------------------------------------------------------- -// D3DX_FILTER flags: -// ------------------ -// -// A valid filter must contain one of these values: -// -// D3DX_FILTER_NONE -// No scaling or filtering will take place. Pixels outside the bounds -// of the source image are assumed to be transparent black. -// D3DX_FILTER_POINT -// Each destination pixel is computed by sampling the nearest pixel -// from the source image. -// D3DX_FILTER_LINEAR -// Each destination pixel is computed by linearly interpolating between -// the nearest pixels in the source image. This filter works best -// when the scale on each axis is less than 2. -// D3DX_FILTER_TRIANGLE -// Every pixel in the source image contributes equally to the -// destination image. This is the slowest of all the filters. -// D3DX_FILTER_BOX -// Each pixel is computed by averaging a 2x2(x2) box pixels from -// the source image. Only works when the dimensions of the -// destination are half those of the source. (as with mip maps) -// -// And can be OR'd with any of these optional flags: -// -// D3DX_FILTER_MIRROR_U -// Indicates that pixels off the edge of the texture on the U-axis -// should be mirrored, not wraped. -// D3DX_FILTER_MIRROR_V -// Indicates that pixels off the edge of the texture on the V-axis -// should be mirrored, not wraped. -// D3DX_FILTER_MIRROR_W -// Indicates that pixels off the edge of the texture on the W-axis -// should be mirrored, not wraped. -// D3DX_FILTER_MIRROR -// Same as specifying D3DX_FILTER_MIRROR_U | D3DX_FILTER_MIRROR_V | -// D3DX_FILTER_MIRROR_V -// D3DX_FILTER_DITHER -// Dithers the resulting image. -// -//---------------------------------------------------------------------------- +/* + * D3DX_FILTER flags: + * ------------------ + * + * A valid filter must contain one of these values: + * + * D3DX_FILTER_NONE + * No scaling or filtering will take place. Pixels outside the bounds + * of the source image are assumed to be transparent black. + * D3DX_FILTER_POINT + * Each destination pixel is computed by sampling the nearest pixel + * from the source image. + * D3DX_FILTER_LINEAR + * Each destination pixel is computed by linearly interpolating between + * the nearest pixels in the source image. This filter works best + * when the scale on each axis is less than 2. + * D3DX_FILTER_TRIANGLE + * Every pixel in the source image contributes equally to the + * destination image. This is the slowest of all the filters. + * D3DX_FILTER_BOX + * Each pixel is computed by averaging a 2x2(x2) box pixels from + * the source image. Only works when the dimensions of the + * destination are half those of the source. (as with mip maps) + * + * And can be OR'd with any of these optional flags: + * + * D3DX_FILTER_MIRROR_U + * Indicates that pixels off the edge of the texture on the U-axis + * should be mirrored, not wraped. + * D3DX_FILTER_MIRROR_V + * Indicates that pixels off the edge of the texture on the V-axis + * should be mirrored, not wraped. + * D3DX_FILTER_MIRROR_W + * Indicates that pixels off the edge of the texture on the W-axis + * should be mirrored, not wraped. + * D3DX_FILTER_MIRROR + * Same as specifying D3DX_FILTER_MIRROR_U | D3DX_FILTER_MIRROR_V | + * D3DX_FILTER_MIRROR_V + * D3DX_FILTER_DITHER + * Dithers the resulting image. + * + */ #define D3DX_FILTER_NONE (1 << 0) #define D3DX_FILTER_POINT (2 << 0) @@ -67,31 +66,28 @@ #define D3DX_FILTER_MIRROR (7 << 16) #define D3DX_FILTER_DITHER (8 << 16) - -//---------------------------------------------------------------------------- -// D3DX_NORMALMAP flags: -// --------------------- -// These flags are used to control how D3DXComputeNormalMap generates normal -// maps. Any number of these flags may be OR'd together in any combination. -// -// D3DX_NORMALMAP_MIRROR_U -// Indicates that pixels off the edge of the texture on the U-axis -// should be mirrored, not wraped. -// D3DX_NORMALMAP_MIRROR_V -// Indicates that pixels off the edge of the texture on the V-axis -// should be mirrored, not wraped. -// D3DX_NORMALMAP_MIRROR -// Same as specifying D3DX_NORMALMAP_MIRROR_U | D3DX_NORMALMAP_MIRROR_V -// D3DX_NORMALMAP_INVERTSIGN -// Inverts the direction of each normal -// D3DX_NORMALMAP_COMPUTE_OCCLUSION -// Compute the per pixel Occlusion term and encodes it into the alpha. -// An Alpha of 1 means that the pixel is not obscured in anyway, and -// an alpha of 0 would mean that the pixel is completly obscured. -// -//---------------------------------------------------------------------------- - -//---------------------------------------------------------------------------- +/* + * D3DX_NORMALMAP flags: + * --------------------- + * These flags are used to control how D3DXComputeNormalMap generates normal + * maps. Any number of these flags may be OR'd together in any combination. + * + * D3DX_NORMALMAP_MIRROR_U + * Indicates that pixels off the edge of the texture on the U-axis + * should be mirrored, not wraped. + * D3DX_NORMALMAP_MIRROR_V + * Indicates that pixels off the edge of the texture on the V-axis + * should be mirrored, not wraped. + * D3DX_NORMALMAP_MIRROR + * Same as specifying D3DX_NORMALMAP_MIRROR_U | D3DX_NORMALMAP_MIRROR_V + * D3DX_NORMALMAP_INVERTSIGN + * Inverts the direction of each normal + * D3DX_NORMALMAP_COMPUTE_OCCLUSION + * Compute the per pixel Occlusion term and encodes it into the alpha. + * An Alpha of 1 means that the pixel is not obscured in anyway, and + * an alpha of 0 would mean that the pixel is completly obscured. + * + */ #define D3DX_NORMALMAP_MIRROR_U (1 << 16) #define D3DX_NORMALMAP_MIRROR_V (2 << 16) @@ -99,28 +95,25 @@ #define D3DX_NORMALMAP_INVERTSIGN (8 << 16) #define D3DX_NORMALMAP_COMPUTE_OCCLUSION (16 << 16) - - - -//---------------------------------------------------------------------------- -// D3DX_CHANNEL flags: -// ------------------- -// These flags are used by functions which operate on or more channels -// in a texture. -// -// D3DX_CHANNEL_RED -// Indicates the red channel should be used -// D3DX_CHANNEL_BLUE -// Indicates the blue channel should be used -// D3DX_CHANNEL_GREEN -// Indicates the green channel should be used -// D3DX_CHANNEL_ALPHA -// Indicates the alpha channel should be used -// D3DX_CHANNEL_LUMINANCE -// Indicates the luminaces of the red green and blue channels should be -// used. -// -//---------------------------------------------------------------------------- +/* + * D3DX_CHANNEL flags: + * ------------------- + * These flags are used by functions which operate on or more channels + * in a texture. + * + * D3DX_CHANNEL_RED + * Indicates the red channel should be used + * D3DX_CHANNEL_BLUE + * Indicates the blue channel should be used + * D3DX_CHANNEL_GREEN + * Indicates the green channel should be used + * D3DX_CHANNEL_ALPHA + * Indicates the alpha channel should be used + * D3DX_CHANNEL_LUMINANCE + * Indicates the luminaces of the red green and blue channels should be + * used. + * + */ #define D3DX_CHANNEL_RED (1 << 0) #define D3DX_CHANNEL_BLUE (1 << 1) @@ -131,12 +124,12 @@ -//---------------------------------------------------------------------------- -// D3DXIMAGE_FILEFORMAT: -// --------------------- -// This enum is used to describe supported image file formats. -// -//---------------------------------------------------------------------------- +/* + * D3DXIMAGE_FILEFORMAT: + * --------------------- + * This enum is used to describe supported image file formats. + * + */ typedef enum _D3DXIMAGE_FILEFORMAT { @@ -152,54 +145,52 @@ typedef enum _D3DXIMAGE_FILEFORMAT } D3DXIMAGE_FILEFORMAT; -//---------------------------------------------------------------------------- -// LPD3DXFILL2D and LPD3DXFILL3D: -// ------------------------------ -// Function types used by the texture fill functions. -// -// Parameters: -// pOut -// Pointer to a vector which the function uses to return its result. -// X,Y,Z,W will be mapped to R,G,B,A respectivly. -// pTexCoord -// Pointer to a vector containing the coordinates of the texel currently -// being evaluated. Textures and VolumeTexture texcoord components -// range from 0 to 1. CubeTexture texcoord component range from -1 to 1. -// pTexelSize -// Pointer to a vector containing the dimensions of the current texel. -// pData -// Pointer to user data. -// -//---------------------------------------------------------------------------- +/* + * LPD3DXFILL2D and LPD3DXFILL3D: + * ------------------------------ + * Function types used by the texture fill functions. + * + * Parameters: + * pOut + * Pointer to a vector which the function uses to return its result. + * X,Y,Z,W will be mapped to R,G,B,A respectivly. + * pTexCoord + * Pointer to a vector containing the coordinates of the texel currently + * being evaluated. Textures and VolumeTexture texcoord components + * range from 0 to 1. CubeTexture texcoord component range from -1 to 1. + * pTexelSize + * Pointer to a vector containing the dimensions of the current texel. + * pData + * Pointer to user data. + * + */ typedef VOID (*LPD3DXFILL2D)(D3DXVECTOR4 *pOut, D3DXVECTOR2 *pTexCoord, D3DXVECTOR2 *pTexelSize, LPVOID pData); typedef VOID (*LPD3DXFILL3D)(D3DXVECTOR4 *pOut, D3DXVECTOR3 *pTexCoord, D3DXVECTOR3 *pTexelSize, LPVOID pData); - - -//---------------------------------------------------------------------------- -// D3DXIMAGE_INFO: -// --------------- -// This structure is used to return a rough description of what the -// the original contents of an image file looked like. -// -// Width -// Width of original image in pixels -// Height -// Height of original image in pixels -// Depth -// Depth of original image in pixels -// MipLevels -// Number of mip levels in original image -// Format -// D3D format which most closely describes the data in original image -// ResourceType -// D3DRESOURCETYPE representing the type of texture stored in the file. -// D3DRTYPE_TEXTURE, D3DRTYPE_VOLUMETEXTURE, or D3DRTYPE_CUBETEXTURE. -// ImageFileFormat -// D3DXIMAGE_FILEFORMAT representing the format of the image file. -// -//---------------------------------------------------------------------------- +/* + * D3DXIMAGE_INFO: + * --------------- + * This structure is used to return a rough description of what the + * the original contents of an image file looked like. + * + * Width + * Width of original image in pixels + * Height + * Height of original image in pixels + * Depth + * Depth of original image in pixels + * MipLevels + * Number of mip levels in original image + * Format + * D3D format which most closely describes the data in original image + * ResourceType + * D3DRESOURCETYPE representing the type of texture stored in the file. + * D3DRTYPE_TEXTURE, D3DRTYPE_VOLUMETEXTURE, or D3DRTYPE_CUBETEXTURE. + * ImageFileFormat + * D3DXIMAGE_FILEFORMAT representing the format of the image file. + * + */ typedef struct _D3DXIMAGE_INFO { @@ -213,42 +204,36 @@ typedef struct _D3DXIMAGE_INFO } D3DXIMAGE_INFO; - - - - #ifdef __cplusplus extern "C" { -#endif //__cplusplus - - +#endif /* __cplusplus */ /* * Image File APIs */ -//---------------------------------------------------------------------------- -// GetImageInfoFromFile/Resource: -// ------------------------------ -// Fills in a D3DXIMAGE_INFO struct with information about an image file. -// -// Parameters: -// pSrcFile -// File name of the source image. -// pSrcModule -// Module where resource is located, or NULL for module associated -// with image the os used to create the current process. -// pSrcResource -// Resource name -// pSrcData -// Pointer to file in memory. -// SrcDataSize -// Size in bytes of file in memory. -// pSrcInfo -// Pointer to a D3DXIMAGE_INFO structure to be filled in with the -// description of the data in the source image file. -// -//---------------------------------------------------------------------------- +/* + * GetImageInfoFromFile/Resource: + * ------------------------------ + * Fills in a D3DXIMAGE_INFO struct with information about an image file. + * + * Parameters: + * pSrcFile + * File name of the source image. + * pSrcModule + * Module where resource is located, or NULL for module associated + * with image the os used to create the current process. + * pSrcResource + * Resource name + * pSrcData + * Pointer to file in memory. + * SrcDataSize + * Size in bytes of file in memory. + * pSrcInfo + * Pointer to a D3DXIMAGE_INFO structure to be filled in with the + * description of the data in the source image file. + * + */ HRESULT WINAPI D3DXGetImageInfoFromFileA( @@ -292,51 +277,48 @@ HRESULT WINAPI UINT SrcDataSize, D3DXIMAGE_INFO* pSrcInfo); +/* + * Load/Save Surface APIs + */ - - -////////////////////////////////////////////////////////////////////////////// -// Load/Save Surface APIs //////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// D3DXLoadSurfaceFromFile/Resource: -// --------------------------------- -// Load surface from a file or resource -// -// Parameters: -// pDestSurface -// Destination surface, which will receive the image. -// pDestPalette -// Destination palette of 256 colors, or NULL -// pDestRect -// Destination rectangle, or NULL for entire surface -// pSrcFile -// File name of the source image. -// pSrcModule -// Module where resource is located, or NULL for module associated -// with image the os used to create the current process. -// pSrcResource -// Resource name -// pSrcData -// Pointer to file in memory. -// SrcDataSize -// Size in bytes of file in memory. -// pSrcRect -// Source rectangle, or NULL for entire image -// Filter -// D3DX_FILTER flags controlling how the image is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. -// ColorKey -// Color to replace with transparent black, or 0 to disable colorkey. -// This is always a 32-bit ARGB color, independent of the source image -// format. Alpha is significant, and should usually be set to FF for -// opaque colorkeys. (ex. Opaque black == 0xff000000) -// pSrcInfo -// Pointer to a D3DXIMAGE_INFO structure to be filled in with the -// description of the data in the source image file, or NULL. -// -//---------------------------------------------------------------------------- +/* + * D3DXLoadSurfaceFromFile/Resource: + * --------------------------------- + * Load surface from a file or resource + * + * Parameters: + * pDestSurface + * Destination surface, which will receive the image. + * pDestPalette + * Destination palette of 256 colors, or NULL + * pDestRect + * Destination rectangle, or NULL for entire surface + * pSrcFile + * File name of the source image. + * pSrcModule + * Module where resource is located, or NULL for module associated + * with image the os used to create the current process. + * pSrcResource + * Resource name + * pSrcData + * Pointer to file in memory. + * SrcDataSize + * Size in bytes of file in memory. + * pSrcRect + * Source rectangle, or NULL for entire image + * Filter + * D3DX_FILTER flags controlling how the image is filtered. + * Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. + * ColorKey + * Color to replace with transparent black, or 0 to disable colorkey. + * This is always a 32-bit ARGB color, independent of the source image + * format. Alpha is significant, and should usually be set to FF for + * opaque colorkeys. (ex. Opaque black == 0xff000000) + * pSrcInfo + * Pointer to a D3DXIMAGE_INFO structure to be filled in with the + * description of the data in the source image file, or NULL. + * + */ HRESULT WINAPI D3DXLoadSurfaceFromFileA( @@ -413,36 +395,34 @@ HRESULT WINAPI D3DCOLOR ColorKey, D3DXIMAGE_INFO* pSrcInfo); - - -//---------------------------------------------------------------------------- -// D3DXLoadSurfaceFromSurface: -// --------------------------- -// Load surface from another surface (with color conversion) -// -// Parameters: -// pDestSurface -// Destination surface, which will receive the image. -// pDestPalette -// Destination palette of 256 colors, or NULL -// pDestRect -// Destination rectangle, or NULL for entire surface -// pSrcSurface -// Source surface -// pSrcPalette -// Source palette of 256 colors, or NULL -// pSrcRect -// Source rectangle, or NULL for entire surface -// Filter -// D3DX_FILTER flags controlling how the image is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. -// ColorKey -// Color to replace with transparent black, or 0 to disable colorkey. -// This is always a 32-bit ARGB color, independent of the source image -// format. Alpha is significant, and should usually be set to FF for -// opaque colorkeys. (ex. Opaque black == 0xff000000) -// -//---------------------------------------------------------------------------- +/* + * D3DXLoadSurfaceFromSurface: + * --------------------------- + * Load surface from another surface (with color conversion) + * + * Parameters: + * pDestSurface + * Destination surface, which will receive the image. + * pDestPalette + * Destination palette of 256 colors, or NULL + * pDestRect + * Destination rectangle, or NULL for entire surface + * pSrcSurface + * Source surface + * pSrcPalette + * Source palette of 256 colors, or NULL + * pSrcRect + * Source rectangle, or NULL for entire surface + * Filter + * D3DX_FILTER flags controlling how the image is filtered. + * Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. + * ColorKey + * Color to replace with transparent black, or 0 to disable colorkey. + * This is always a 32-bit ARGB color, independent of the source image + * format. Alpha is significant, and should usually be set to FF for + * opaque colorkeys. (ex. Opaque black == 0xff000000) + * + */ HRESULT WINAPI D3DXLoadSurfaceFromSurface( @@ -455,40 +435,39 @@ HRESULT WINAPI DWORD Filter, D3DCOLOR ColorKey); - -//---------------------------------------------------------------------------- -// D3DXLoadSurfaceFromMemory: -// -------------------------- -// Load surface from memory. -// -// Parameters: -// pDestSurface -// Destination surface, which will receive the image. -// pDestPalette -// Destination palette of 256 colors, or NULL -// pDestRect -// Destination rectangle, or NULL for entire surface -// pSrcMemory -// Pointer to the top-left corner of the source image in memory -// SrcFormat -// Pixel format of the source image. -// SrcPitch -// Pitch of source image, in bytes. For DXT formats, this number -// should represent the width of one row of cells, in bytes. -// pSrcPalette -// Source palette of 256 colors, or NULL -// pSrcRect -// Source rectangle. -// Filter -// D3DX_FILTER flags controlling how the image is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. -// ColorKey -// Color to replace with transparent black, or 0 to disable colorkey. -// This is always a 32-bit ARGB color, independent of the source image -// format. Alpha is significant, and should usually be set to FF for -// opaque colorkeys. (ex. Opaque black == 0xff000000) -// -//---------------------------------------------------------------------------- +/* + * D3DXLoadSurfaceFromMemory: + * -------------------------- + * Load surface from memory. + * + * Parameters: + * pDestSurface + * Destination surface, which will receive the image. + * pDestPalette + * Destination palette of 256 colors, or NULL + * pDestRect + * Destination rectangle, or NULL for entire surface + * pSrcMemory + * Pointer to the top-left corner of the source image in memory + * SrcFormat + * Pixel format of the source image. + * SrcPitch + * Pitch of source image, in bytes. For DXT formats, this number + * should represent the width of one row of cells, in bytes. + * pSrcPalette + * Source palette of 256 colors, or NULL + * pSrcRect + * Source rectangle. + * Filter + * D3DX_FILTER flags controlling how the image is filtered. + * Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. + * ColorKey + * Color to replace with transparent black, or 0 to disable colorkey. + * This is always a 32-bit ARGB color, independent of the source image + * format. Alpha is significant, and should usually be set to FF for + * opaque colorkeys. (ex. Opaque black == 0xff000000) + * + */ HRESULT WINAPI D3DXLoadSurfaceFromMemory( @@ -504,24 +483,24 @@ HRESULT WINAPI D3DCOLOR ColorKey); -//---------------------------------------------------------------------------- -// D3DXSaveSurfaceToFile: -// ---------------------- -// Save a surface to a image file. -// -// Parameters: -// pDestFile -// File name of the destination file -// DestFormat -// D3DXIMAGE_FILEFORMAT specifying file format to use when saving. -// pSrcSurface -// Source surface, containing the image to be saved -// pSrcPalette -// Source palette of 256 colors, or NULL -// pSrcRect -// Source rectangle, or NULL for the entire image -// -//---------------------------------------------------------------------------- +/* + * D3DXSaveSurfaceToFile: + * ---------------------- + * Save a surface to a image file. + * + * Parameters: + * pDestFile + * File name of the destination file + * DestFormat + * D3DXIMAGE_FILEFORMAT specifying file format to use when saving. + * pSrcSurface + * Source surface, containing the image to be saved + * pSrcPalette + * Source palette of 256 colors, or NULL + * pSrcRect + * Source rectangle, or NULL for the entire image + * + */ HRESULT WINAPI D3DXSaveSurfaceToFileA( @@ -545,51 +524,48 @@ HRESULT WINAPI #define D3DXSaveSurfaceToFile D3DXSaveSurfaceToFileA #endif +/* + * Load/Save Volume APIs + */ - - -////////////////////////////////////////////////////////////////////////////// -// Load/Save Volume APIs ///////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// D3DXLoadVolumeFromFile/Resource: -// -------------------------------- -// Load volume from a file or resource -// -// Parameters: -// pDestVolume -// Destination volume, which will receive the image. -// pDestPalette -// Destination palette of 256 colors, or NULL -// pDestBox -// Destination box, or NULL for entire volume -// pSrcFile -// File name of the source image. -// pSrcModule -// Module where resource is located, or NULL for module associated -// with image the os used to create the current process. -// pSrcResource -// Resource name -// pSrcData -// Pointer to file in memory. -// SrcDataSize -// Size in bytes of file in memory. -// pSrcBox -// Source box, or NULL for entire image -// Filter -// D3DX_FILTER flags controlling how the image is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. -// ColorKey -// Color to replace with transparent black, or 0 to disable colorkey. -// This is always a 32-bit ARGB color, independent of the source image -// format. Alpha is significant, and should usually be set to FF for -// opaque colorkeys. (ex. Opaque black == 0xff000000) -// pSrcInfo -// Pointer to a D3DXIMAGE_INFO structure to be filled in with the -// description of the data in the source image file, or NULL. -// -//---------------------------------------------------------------------------- +/* + * D3DXLoadVolumeFromFile/Resource: + * -------------------------------- + * Load volume from a file or resource + * + * Parameters: + * pDestVolume + * Destination volume, which will receive the image. + * pDestPalette + * Destination palette of 256 colors, or NULL + * pDestBox + * Destination box, or NULL for entire volume + * pSrcFile + * File name of the source image. + * pSrcModule + * Module where resource is located, or NULL for module associated + * with image the os used to create the current process. + * pSrcResource + * Resource name + * pSrcData + * Pointer to file in memory. + * SrcDataSize + * Size in bytes of file in memory. + * pSrcBox + * Source box, or NULL for entire image + * Filter + * D3DX_FILTER flags controlling how the image is filtered. + * Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. + * ColorKey + * Color to replace with transparent black, or 0 to disable colorkey. + * This is always a 32-bit ARGB color, independent of the source image + * format. Alpha is significant, and should usually be set to FF for + * opaque colorkeys. (ex. Opaque black == 0xff000000) + * pSrcInfo + * Pointer to a D3DXIMAGE_INFO structure to be filled in with the + * description of the data in the source image file, or NULL. + * + */ HRESULT WINAPI D3DXLoadVolumeFromFileA( @@ -664,36 +640,34 @@ HRESULT WINAPI D3DCOLOR ColorKey, D3DXIMAGE_INFO* pSrcInfo); - - -//---------------------------------------------------------------------------- -// D3DXLoadVolumeFromVolume: -// ------------------------- -// Load volume from another volume (with color conversion) -// -// Parameters: -// pDestVolume -// Destination volume, which will receive the image. -// pDestPalette -// Destination palette of 256 colors, or NULL -// pDestBox -// Destination box, or NULL for entire volume -// pSrcVolume -// Source volume -// pSrcPalette -// Source palette of 256 colors, or NULL -// pSrcBox -// Source box, or NULL for entire volume -// Filter -// D3DX_FILTER flags controlling how the image is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. -// ColorKey -// Color to replace with transparent black, or 0 to disable colorkey. -// This is always a 32-bit ARGB color, independent of the source image -// format. Alpha is significant, and should usually be set to FF for -// opaque colorkeys. (ex. Opaque black == 0xff000000) -// -//---------------------------------------------------------------------------- +/* + * D3DXLoadVolumeFromVolume: + * ------------------------- + * Load volume from another volume (with color conversion) + * + * Parameters: + * pDestVolume + * Destination volume, which will receive the image. + * pDestPalette + * Destination palette of 256 colors, or NULL + * pDestBox + * Destination box, or NULL for entire volume + * pSrcVolume + * Source volume + * pSrcPalette + * Source palette of 256 colors, or NULL + * pSrcBox + * Source box, or NULL for entire volume + * Filter + * D3DX_FILTER flags controlling how the image is filtered. + * Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. + * ColorKey + * Color to replace with transparent black, or 0 to disable colorkey. + * This is always a 32-bit ARGB color, independent of the source image + * format. Alpha is significant, and should usually be set to FF for + * opaque colorkeys. (ex. Opaque black == 0xff000000) + * + */ HRESULT WINAPI D3DXLoadVolumeFromVolume( @@ -706,44 +680,42 @@ HRESULT WINAPI DWORD Filter, D3DCOLOR ColorKey); - - -//---------------------------------------------------------------------------- -// D3DXLoadVolumeFromMemory: -// ------------------------- -// Load volume from memory. -// -// Parameters: -// pDestVolume -// Destination volume, which will receive the image. -// pDestPalette -// Destination palette of 256 colors, or NULL -// pDestBox -// Destination box, or NULL for entire volume -// pSrcMemory -// Pointer to the top-left corner of the source volume in memory -// SrcFormat -// Pixel format of the source volume. -// SrcRowPitch -// Pitch of source image, in bytes. For DXT formats, this number -// should represent the size of one row of cells, in bytes. -// SrcSlicePitch -// Pitch of source image, in bytes. For DXT formats, this number -// should represent the size of one slice of cells, in bytes. -// pSrcPalette -// Source palette of 256 colors, or NULL -// pSrcBox -// Source box. -// Filter -// D3DX_FILTER flags controlling how the image is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. -// ColorKey -// Color to replace with transparent black, or 0 to disable colorkey. -// This is always a 32-bit ARGB color, independent of the source image -// format. Alpha is significant, and should usually be set to FF for -// opaque colorkeys. (ex. Opaque black == 0xff000000) -// -//---------------------------------------------------------------------------- +/* + * D3DXLoadVolumeFromMemory: + * ------------------------- + * Load volume from memory. + * + * Parameters: + * pDestVolume + * Destination volume, which will receive the image. + * pDestPalette + * Destination palette of 256 colors, or NULL + * pDestBox + * Destination box, or NULL for entire volume + * pSrcMemory + * Pointer to the top-left corner of the source volume in memory + * SrcFormat + * Pixel format of the source volume. + * SrcRowPitch + * Pitch of source image, in bytes. For DXT formats, this number + * should represent the size of one row of cells, in bytes. + * SrcSlicePitch + * Pitch of source image, in bytes. For DXT formats, this number + * should represent the size of one slice of cells, in bytes. + * pSrcPalette + * Source palette of 256 colors, or NULL + * pSrcBox + * Source box. + * Filter + * D3DX_FILTER flags controlling how the image is filtered. + * Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. + * ColorKey + * Color to replace with transparent black, or 0 to disable colorkey. + * This is always a 32-bit ARGB color, independent of the source image + * format. Alpha is significant, and should usually be set to FF for + * opaque colorkeys. (ex. Opaque black == 0xff000000) + * + */ HRESULT WINAPI D3DXLoadVolumeFromMemory( @@ -759,26 +731,24 @@ HRESULT WINAPI DWORD Filter, D3DCOLOR ColorKey); - - -//---------------------------------------------------------------------------- -// D3DXSaveVolumeToFile: -// --------------------- -// Save a volume to a image file. -// -// Parameters: -// pDestFile -// File name of the destination file -// DestFormat -// D3DXIMAGE_FILEFORMAT specifying file format to use when saving. -// pSrcVolume -// Source volume, containing the image to be saved -// pSrcPalette -// Source palette of 256 colors, or NULL -// pSrcBox -// Source box, or NULL for the entire volume -// -//---------------------------------------------------------------------------- +/* + * D3DXSaveVolumeToFile: + * --------------------- + * Save a volume to a image file. + * + * Parameters: + * pDestFile + * File name of the destination file + * DestFormat + * D3DXIMAGE_FILEFORMAT specifying file format to use when saving. + * pSrcVolume + * Source volume, containing the image to be saved + * pSrcPalette + * Source palette of 256 colors, or NULL + * pSrcBox + * Source box, or NULL for the entire volume + * + */ HRESULT WINAPI D3DXSaveVolumeToFileA( @@ -802,35 +772,32 @@ HRESULT WINAPI #define D3DXSaveVolumeToFile D3DXSaveVolumeToFileA #endif +/* + * Create/Save Texture APIs + */ - - -////////////////////////////////////////////////////////////////////////////// -// Create/Save Texture APIs ////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// D3DXCheckTextureRequirements: -// ----------------------------- -// Checks texture creation parameters. If parameters are invalid, this -// function returns corrected parameters. -// -// Parameters: -// -// pDevice -// The D3D device to be used -// pWidth, pHeight, pDepth, pSize -// Desired size in pixels, or NULL. Returns corrected size. -// pNumMipLevels -// Number of desired mipmap levels, or NULL. Returns corrected number. -// Usage -// Texture usage flags -// pFormat -// Desired pixel format, or NULL. Returns corrected format. -// Pool -// Memory pool to be used to create texture -// -//---------------------------------------------------------------------------- +/* + * D3DXCheckTextureRequirements: + * ----------------------------- + * Checks texture creation parameters. If parameters are invalid, this + * function returns corrected parameters. + * + * Parameters: + * + * pDevice + * The D3D device to be used + * pWidth, pHeight, pDepth, pSize + * Desired size in pixels, or NULL. Returns corrected size. + * pNumMipLevels + * Number of desired mipmap levels, or NULL. Returns corrected number. + * Usage + * Texture usage flags + * pFormat + * Desired pixel format, or NULL. Returns corrected format. + * Pool + * Memory pool to be used to create texture + * + */ HRESULT WINAPI D3DXCheckTextureRequirements( @@ -863,30 +830,30 @@ HRESULT WINAPI D3DPOOL Pool); -//---------------------------------------------------------------------------- -// D3DXCreateTexture: -// ------------------ -// Create an empty texture -// -// Parameters: -// -// pDevice -// The D3D device with which the texture is going to be used. -// Width, Height, Depth, Size -// size in pixels; these must be non-zero -// MipLevels -// number of mip levels desired; if zero or D3DX_DEFAULT, a complete -// mipmap chain will be created. -// Usage -// Texture usage flags -// Format -// Pixel format. -// Pool -// Memory pool to be used to create texture -// ppTexture, ppCubeTexture, ppVolumeTexture -// The texture object that will be created -// -//---------------------------------------------------------------------------- +/* + * D3DXCreateTexture: + * ------------------ + * Create an empty texture + * + * Parameters: + * + * pDevice + * The D3D device with which the texture is going to be used. + * Width, Height, Depth, Size + * size in pixels; these must be non-zero + * MipLevels + * number of mip levels desired; if zero or D3DX_DEFAULT, a complete + * mipmap chain will be created. + * Usage + * Texture usage flags + * Format + * Pixel format. + * Pool + * Memory pool to be used to create texture + * ppTexture, ppCubeTexture, ppVolumeTexture + * The texture object that will be created + * + */ HRESULT WINAPI D3DXCreateTexture( @@ -921,63 +888,60 @@ HRESULT WINAPI D3DPOOL Pool, LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); +/* + * D3DXCreateTextureFromFile/Resource: + * ----------------------------------- + * Create a texture object from a file or resource. + * + * Parameters: + * + * pDevice + * The D3D device with which the texture is going to be used. + * pSrcFile + * File name. + * hSrcModule + * Module handle. if NULL, current module will be used. + * pSrcResource + * Resource name in module + * pvSrcData + * Pointer to file in memory. + * SrcDataSize + * Size in bytes of file in memory. + * Width, Height, Depth, Size + * Size in pixels; if zero or D3DX_DEFAULT, the size will be taken + * from the file. + * MipLevels + * Number of mip levels; if zero or D3DX_DEFAULT, a complete mipmap + * chain will be created. + * Usage + * Texture usage flags + * Format + * Desired pixel format. If D3DFMT_UNKNOWN, the format will be + * taken from the file. + * Pool + * Memory pool to be used to create texture + * Filter + * D3DX_FILTER flags controlling how the image is filtered. + * Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. + * MipFilter + * D3DX_FILTER flags controlling how each miplevel is filtered. + * Or D3DX_DEFAULT for D3DX_FILTER_BOX, + * ColorKey + * Color to replace with transparent black, or 0 to disable colorkey. + * This is always a 32-bit ARGB color, independent of the source image + * format. Alpha is significant, and should usually be set to FF for + * opaque colorkeys. (ex. Opaque black == 0xff000000) + * pSrcInfo + * Pointer to a D3DXIMAGE_INFO structure to be filled in with the + * description of the data in the source image file, or NULL. + * pPalette + * 256 color palette to be filled in, or NULL + * ppTexture, ppCubeTexture, ppVolumeTexture + * The texture object that will be created + * + */ - -//---------------------------------------------------------------------------- -// D3DXCreateTextureFromFile/Resource: -// ----------------------------------- -// Create a texture object from a file or resource. -// -// Parameters: -// -// pDevice -// The D3D device with which the texture is going to be used. -// pSrcFile -// File name. -// hSrcModule -// Module handle. if NULL, current module will be used. -// pSrcResource -// Resource name in module -// pvSrcData -// Pointer to file in memory. -// SrcDataSize -// Size in bytes of file in memory. -// Width, Height, Depth, Size -// Size in pixels; if zero or D3DX_DEFAULT, the size will be taken -// from the file. -// MipLevels -// Number of mip levels; if zero or D3DX_DEFAULT, a complete mipmap -// chain will be created. -// Usage -// Texture usage flags -// Format -// Desired pixel format. If D3DFMT_UNKNOWN, the format will be -// taken from the file. -// Pool -// Memory pool to be used to create texture -// Filter -// D3DX_FILTER flags controlling how the image is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. -// MipFilter -// D3DX_FILTER flags controlling how each miplevel is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_BOX, -// ColorKey -// Color to replace with transparent black, or 0 to disable colorkey. -// This is always a 32-bit ARGB color, independent of the source image -// format. Alpha is significant, and should usually be set to FF for -// opaque colorkeys. (ex. Opaque black == 0xff000000) -// pSrcInfo -// Pointer to a D3DXIMAGE_INFO structure to be filled in with the -// description of the data in the source image file, or NULL. -// pPalette -// 256 color palette to be filled in, or NULL -// ppTexture, ppCubeTexture, ppVolumeTexture -// The texture object that will be created -// -//---------------------------------------------------------------------------- - - -// FromFile +/* FromFile */ HRESULT WINAPI D3DXCreateTextureFromFileA( @@ -1035,8 +999,7 @@ HRESULT WINAPI #define D3DXCreateVolumeTextureFromFile D3DXCreateVolumeTextureFromFileA #endif - -// FromResource +/* FromResource */ HRESULT WINAPI D3DXCreateTextureFromResourceA( @@ -1100,8 +1063,7 @@ HRESULT WINAPI #define D3DXCreateVolumeTextureFromResource D3DXCreateVolumeTextureFromResourceA #endif - -// FromFileEx +/* FromFileEx */ HRESULT WINAPI D3DXCreateTextureFromFileExA( @@ -1225,8 +1187,7 @@ HRESULT WINAPI #define D3DXCreateVolumeTextureFromFileEx D3DXCreateVolumeTextureFromFileExA #endif - -// FromResourceEx +/* FromResourceEx */ HRESULT WINAPI D3DXCreateTextureFromResourceExA( @@ -1356,8 +1317,7 @@ HRESULT WINAPI #define D3DXCreateVolumeTextureFromResourceEx D3DXCreateVolumeTextureFromResourceExA #endif - -// FromFileInMemory +/* FromFileInMemory */ HRESULT WINAPI D3DXCreateTextureFromFileInMemory( @@ -1381,7 +1341,7 @@ HRESULT WINAPI LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); -// FromFileInMemoryEx +/* FromFileInMemoryEx */ HRESULT WINAPI D3DXCreateTextureFromFileInMemoryEx( @@ -1437,25 +1397,22 @@ HRESULT WINAPI PALETTEENTRY* pPalette, LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); - - -//---------------------------------------------------------------------------- -// D3DXSaveTextureToFile: -// ---------------------- -// Save a texture to a file. -// -// Parameters: -// pDestFile -// File name of the destination file -// DestFormat -// D3DXIMAGE_FILEFORMAT specifying file format to use when saving. -// pSrcTexture -// Source texture, containing the image to be saved -// pSrcPalette -// Source palette of 256 colors, or NULL -// -//---------------------------------------------------------------------------- - +/* + * D3DXSaveTextureToFile: + * ---------------------- + * Save a texture to a file. + * + * Parameters: + * pDestFile + * File name of the destination file + * DestFormat + * D3DXIMAGE_FILEFORMAT specifying file format to use when saving. + * pSrcTexture + * Source texture, containing the image to be saved + * pSrcPalette + * Source palette of 256 colors, or NULL + * + */ HRESULT WINAPI D3DXSaveTextureToFileA( @@ -1477,30 +1434,27 @@ HRESULT WINAPI #define D3DXSaveTextureToFile D3DXSaveTextureToFileA #endif +/* + * Misc Texture APIs + */ - - -////////////////////////////////////////////////////////////////////////////// -// Misc Texture APIs ///////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// D3DXFilterTexture: -// ------------------ -// Filters mipmaps levels of a texture. -// -// Parameters: -// pBaseTexture -// The texture object to be filtered -// pPalette -// 256 color palette to be used, or NULL for non-palettized formats -// SrcLevel -// The level whose image is used to generate the subsequent levels. -// Filter -// D3DX_FILTER flags controlling how each miplevel is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_BOX, -// -//---------------------------------------------------------------------------- +/* + * D3DXFilterTexture: + * ------------------ + * Filters mipmaps levels of a texture. + * + * Parameters: + * pBaseTexture + * The texture object to be filtered + * pPalette + * 256 color palette to be used, or NULL for non-palettized formats + * SrcLevel + * The level whose image is used to generate the subsequent levels. + * Filter + * D3DX_FILTER flags controlling how each miplevel is filtered. + * Or D3DX_DEFAULT for D3DX_FILTER_BOX, + * + */ HRESULT WINAPI D3DXFilterTexture( @@ -1512,24 +1466,22 @@ HRESULT WINAPI #define D3DXFilterCubeTexture D3DXFilterTexture #define D3DXFilterVolumeTexture D3DXFilterTexture - - -//---------------------------------------------------------------------------- -// D3DXFillTexture: -// ---------------- -// Uses a user provided function to fill each texel of each mip level of a -// given texture. -// -// Paramters: -// pTexture, pCubeTexture, pVolumeTexture -// Pointer to the texture to be filled. -// pFunction -// Pointer to user provided evalutor function which will be used to -// compute the value of each texel. -// pData -// Pointer to an arbitrary block of user defined data. This pointer -// will be passed to the function provided in pFunction -//----------------------------------------------------------------------------- +/* + * D3DXFillTexture: + * ---------------- + * Uses a user provided function to fill each texel of each mip level of a + * given texture. + * + * Paramters: + * pTexture, pCubeTexture, pVolumeTexture + * Pointer to the texture to be filled. + * pFunction + * Pointer to user provided evalutor function which will be used to + * compute the value of each texel. + * pData + * Pointer to an arbitrary block of user defined data. This pointer + * will be passed to the function provided in pFunction + */ HRESULT WINAPI D3DXFillTexture( @@ -1549,28 +1501,26 @@ HRESULT WINAPI LPD3DXFILL3D pFunction, LPVOID pData); - - -//---------------------------------------------------------------------------- -// D3DXComputeNormalMap: -// --------------------- -// Converts a height map into a normal map. The (x,y,z) components of each -// normal are mapped to the (r,g,b) channels of the output texture. -// -// Parameters -// pTexture -// Pointer to the destination texture -// pSrcTexture -// Pointer to the source heightmap texture -// pSrcPalette -// Source palette of 256 colors, or NULL -// Flags -// D3DX_NORMALMAP flags -// Channel -// D3DX_CHANNEL specifying source of height information -// Amplitude -// The constant value which the height information is multiplied by. -//--------------------------------------------------------------------------- +/* + * D3DXComputeNormalMap: + * --------------------- + * Converts a height map into a normal map. The (x,y,z) components of each + * normal are mapped to the (r,g,b) channels of the output texture. + * + * Parameters + * pTexture + * Pointer to the destination texture + * pSrcTexture + * Pointer to the source heightmap texture + * pSrcPalette + * Source palette of 256 colors, or NULL + * Flags + * D3DX_NORMALMAP flags + * Channel + * D3DX_CHANNEL specifying source of height information + * Amplitude + * The constant value which the height information is multiplied by. + */ HRESULT WINAPI D3DXComputeNormalMap( diff --git a/gfx/include/d3d9/d3dx9mesh.h b/gfx/include/d3d9/d3dx9mesh.h index beccf99ff6..3d15c50542 100644 --- a/gfx/include/d3d9/d3dx9mesh.h +++ b/gfx/include/d3d9/d3dx9mesh.h @@ -48,32 +48,32 @@ typedef enum _D3DXPATCHMESHTYPE /* Mesh options - lower 3 bytes only, upper byte used by _D3DXMESHOPT option flags */ enum _D3DXMESH { - D3DXMESH_32BIT = 0x001, // If set, then use 32 bit indices, if not set use 16 bit indices. - D3DXMESH_DONOTCLIP = 0x002, // Use D3DUSAGE_DONOTCLIP for VB & IB. - D3DXMESH_POINTS = 0x004, // Use D3DUSAGE_POINTS for VB & IB. - D3DXMESH_RTPATCHES = 0x008, // Use D3DUSAGE_RTPATCHES for VB & IB. - D3DXMESH_NPATCHES = 0x4000,// Use D3DUSAGE_NPATCHES for VB & IB. - D3DXMESH_VB_SYSTEMMEM = 0x010, // Use D3DPOOL_SYSTEMMEM for VB. Overrides D3DXMESH_MANAGEDVERTEXBUFFER - D3DXMESH_VB_MANAGED = 0x020, // Use D3DPOOL_MANAGED for VB. - D3DXMESH_VB_WRITEONLY = 0x040, // Use D3DUSAGE_WRITEONLY for VB. - D3DXMESH_VB_DYNAMIC = 0x080, // Use D3DUSAGE_DYNAMIC for VB. - D3DXMESH_VB_SOFTWAREPROCESSING = 0x8000, // Use D3DUSAGE_SOFTWAREPROCESSING for VB. - D3DXMESH_IB_SYSTEMMEM = 0x100, // Use D3DPOOL_SYSTEMMEM for IB. Overrides D3DXMESH_MANAGEDINDEXBUFFER - D3DXMESH_IB_MANAGED = 0x200, // Use D3DPOOL_MANAGED for IB. - D3DXMESH_IB_WRITEONLY = 0x400, // Use D3DUSAGE_WRITEONLY for IB. - D3DXMESH_IB_DYNAMIC = 0x800, // Use D3DUSAGE_DYNAMIC for IB. - D3DXMESH_IB_SOFTWAREPROCESSING= 0x10000, // Use D3DUSAGE_SOFTWAREPROCESSING for IB. + D3DXMESH_32BIT = 0x001, /* If set, then use 32 bit indices, if not set use 16 bit indices. */ + D3DXMESH_DONOTCLIP = 0x002, /* Use D3DUSAGE_DONOTCLIP for VB & IB. */ + D3DXMESH_POINTS = 0x004, /* Use D3DUSAGE_POINTS for VB & IB. */ + D3DXMESH_RTPATCHES = 0x008, /* Use D3DUSAGE_RTPATCHES for VB & IB. */ + D3DXMESH_NPATCHES = 0x4000,/* Use D3DUSAGE_NPATCHES for VB & IB. */ + D3DXMESH_VB_SYSTEMMEM = 0x010, /* Use D3DPOOL_SYSTEMMEM for VB. Overrides D3DXMESH_MANAGEDVERTEXBUFFER */ + D3DXMESH_VB_MANAGED = 0x020, /* Use D3DPOOL_MANAGED for VB. */ + D3DXMESH_VB_WRITEONLY = 0x040, /* Use D3DUSAGE_WRITEONLY for VB. */ + D3DXMESH_VB_DYNAMIC = 0x080, /* Use D3DUSAGE_DYNAMIC for VB. */ + D3DXMESH_VB_SOFTWAREPROCESSING = 0x8000, /* Use D3DUSAGE_SOFTWAREPROCESSING for VB. */ + D3DXMESH_IB_SYSTEMMEM = 0x100, /* Use D3DPOOL_SYSTEMMEM for IB. Overrides D3DXMESH_MANAGEDINDEXBUFFER */ + D3DXMESH_IB_MANAGED = 0x200, /* Use D3DPOOL_MANAGED for IB. */ + D3DXMESH_IB_WRITEONLY = 0x400, /* Use D3DUSAGE_WRITEONLY for IB. */ + D3DXMESH_IB_DYNAMIC = 0x800, /* Use D3DUSAGE_DYNAMIC for IB. */ + D3DXMESH_IB_SOFTWAREPROCESSING= 0x10000, /* Use D3DUSAGE_SOFTWAREPROCESSING for IB. */ - D3DXMESH_VB_SHARE = 0x1000, // Valid for Clone* calls only, forces cloned mesh/pmesh to share vertex buffer + D3DXMESH_VB_SHARE = 0x1000, /* Valid for Clone* calls only, forces cloned mesh/pmesh to share vertex buffer */ - D3DXMESH_USEHWONLY = 0x2000, // Valid for ID3DXSkinInfo::ConvertToBlendedMesh + D3DXMESH_USEHWONLY = 0x2000, /* Valid for ID3DXSkinInfo::ConvertToBlendedMesh */ - // Helper options - D3DXMESH_SYSTEMMEM = 0x110, // D3DXMESH_VB_SYSTEMMEM | D3DXMESH_IB_SYSTEMMEM - D3DXMESH_MANAGED = 0x220, // D3DXMESH_VB_MANAGED | D3DXMESH_IB_MANAGED - D3DXMESH_WRITEONLY = 0x440, // D3DXMESH_VB_WRITEONLY | D3DXMESH_IB_WRITEONLY - D3DXMESH_DYNAMIC = 0x880, // D3DXMESH_VB_DYNAMIC | D3DXMESH_IB_DYNAMIC - D3DXMESH_SOFTWAREPROCESSING = 0x18000 // D3DXMESH_VB_SOFTWAREPROCESSING | D3DXMESH_IB_SOFTWAREPROCESSING + /* Helper options */ + D3DXMESH_SYSTEMMEM = 0x110, /* D3DXMESH_VB_SYSTEMMEM | D3DXMESH_IB_SYSTEMMEM */ + D3DXMESH_MANAGED = 0x220, /* D3DXMESH_VB_MANAGED | D3DXMESH_IB_MANAGED */ + D3DXMESH_WRITEONLY = 0x440, /* D3DXMESH_VB_WRITEONLY | D3DXMESH_IB_WRITEONLY */ + D3DXMESH_DYNAMIC = 0x880, /* D3DXMESH_VB_DYNAMIC | D3DXMESH_IB_DYNAMIC */ + D3DXMESH_SOFTWAREPROCESSING = 0x18000 /* D3DXMESH_VB_SOFTWAREPROCESSING | D3DXMESH_IB_SOFTWAREPROCESSING */ }; /* patch mesh options */ @@ -512,31 +512,35 @@ DECLARE_INTERFACE_(ID3DXPatchMesh, IUnknown) STDMETHOD(LockAttributeBuffer)(THIS_ DWORD flags, DWORD** ppData) PURE; STDMETHOD(UnlockAttributeBuffer)(THIS) PURE; - // This function returns the size of the tessellated mesh given a tessellation level. - // This assumes uniform tessellation. For adaptive tessellation the Adaptive parameter must - // be set to TRUE and TessellationLevel should be the max tessellation. - // This will result in the max mesh size necessary for adaptive tessellation. + /* This function returns the size of the tessellated mesh given a tessellation level. + * This assumes uniform tessellation. For adaptive tessellation the Adaptive parameter must + * be set to TRUE and TessellationLevel should be the max tessellation. + * This will result in the max mesh size necessary for adaptive tessellation. + */ STDMETHOD(GetTessSize)(THIS_ FLOAT fTessLevel,DWORD Adaptive, DWORD *NumTriangles,DWORD *NumVertices) PURE; - //GenerateAdjacency determines which patches are adjacent with provided tolerance - //this information is used internally to optimize tessellation + /*GenerateAdjacency determines which patches are adjacent with provided tolerance + *this information is used internally to optimize tessellation */ STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Tolerance) PURE; - //CloneMesh Creates a new patchmesh with the specified decl, and converts the vertex buffer - //to the new decl. Entries in the new decl which are new are set to 0. If the current mesh - //has adjacency, the new mesh will also have adjacency + /*CloneMesh Creates a new patchmesh with the specified decl, and converts the vertex buffer + *to the new decl. Entries in the new decl which are new are set to 0. If the current mesh + *has adjacency, the new mesh will also have adjacency + */ STDMETHOD(CloneMesh)(THIS_ DWORD Options, CONST D3DVERTEXELEMENT9 *pDecl, LPD3DXPATCHMESH *pMesh) PURE; - // Optimizes the patchmesh for efficient tessellation. This function is designed - // to perform one time optimization for patch meshes that need to be tessellated - // repeatedly by calling the Tessellate() method. The optimization performed is - // independent of the actual tessellation level used. - // Currently Flags is unused. - // If vertices are changed, Optimize must be called again + /* Optimizes the patchmesh for efficient tessellation. This function is designed + * to perform one time optimization for patch meshes that need to be tessellated + * repeatedly by calling the Tessellate() method. The optimization performed is + * independent of the actual tessellation level used. + * Currently Flags is unused. + * If vertices are changed, Optimize must be called again + */ STDMETHOD(Optimize)(THIS_ DWORD flags) PURE; - //gets and sets displacement parameters - //displacement maps can only be 2D textures MIP-MAPPING is ignored for non adapative tessellation + /*gets and sets displacement parameters + *displacement maps can only be 2D textures MIP-MAPPING is ignored for non adapative tessellation + */ STDMETHOD(SetDisplaceParam)(THIS_ LPDIRECT3DBASETEXTURE9 Texture, D3DTEXTUREFILTERTYPE MinFilter, D3DTEXTUREFILTERTYPE MagFilter, @@ -551,16 +555,18 @@ DECLARE_INTERFACE_(ID3DXPatchMesh, IUnknown) D3DTEXTUREADDRESS *Wrap, DWORD *dwLODBias) PURE; - // Performs the uniform tessellation based on the tessellation level. - // This function will perform more efficiently if the patch mesh has been optimized using the Optimize() call. + /* Performs the uniform tessellation based on the tessellation level. + * This function will perform more efficiently if the patch mesh has been optimized using the Optimize() call. + */ STDMETHOD(Tessellate)(THIS_ FLOAT fTessLevel,LPD3DXMESH pMesh) PURE; - // Performs adaptive tessellation based on the Z based adaptive tessellation criterion. - // pTrans specifies a 4D vector that is dotted with the vertices to get the per vertex - // adaptive tessellation amount. Each edge is tessellated to the average of the criterion - // at the 2 vertices it connects. - // MaxTessLevel specifies the upper limit for adaptive tesselation. - // This function will perform more efficiently if the patch mesh has been optimized using the Optimize() call. + /* Performs adaptive tessellation based on the Z based adaptive tessellation criterion. + * pTrans specifies a 4D vector that is dotted with the vertices to get the per vertex + * adaptive tessellation amount. Each edge is tessellated to the average of the criterion + * at the 2 vertices it connects. + * MaxTessLevel specifies the upper limit for adaptive tesselation. + * This function will perform more efficiently if the patch mesh has been optimized using the Optimize() call. + */ STDMETHOD(TessellateAdaptive)(THIS_ CONST D3DXVECTOR4 *pTrans, DWORD dwMaxTessLevel, @@ -574,12 +580,12 @@ DECLARE_INTERFACE_(ID3DXPatchMesh, IUnknown) DECLARE_INTERFACE_(ID3DXSkinInfo, IUnknown) { - // IUnknown + /* IUnknown */ STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; STDMETHOD_(ULONG, AddRef)(THIS) PURE; STDMETHOD_(ULONG, Release)(THIS) PURE; - // Specify the which vertices do each bones influence and by how much + /* Specify the which vertices do each bones influence and by how much */ STDMETHOD(SetBoneInfluence)(THIS_ DWORD bone, DWORD numInfluences, CONST DWORD* vertices, CONST FLOAT* weights) PURE; STDMETHOD(SetBoneVertexInfluence)(THIS_ DWORD boneNum, DWORD influenceNum, float weight) PURE; STDMETHOD_(DWORD, GetNumBoneInfluences)(THIS_ DWORD bone) PURE; @@ -589,44 +595,44 @@ DECLARE_INTERFACE_(ID3DXSkinInfo, IUnknown) STDMETHOD_(DWORD, GetNumBones)(THIS) PURE; STDMETHOD(FindBoneVertexInfluenceIndex)(THIS_ DWORD boneNum, DWORD vertexNum, DWORD *pInfluenceIndex) PURE; - // This gets the max face influences based on a triangle mesh with the specified index buffer + /* This gets the max face influences based on a triangle mesh with the specified index buffer */ STDMETHOD(GetMaxFaceInfluences)(THIS_ LPDIRECT3DINDEXBUFFER9 pIB, DWORD NumFaces, DWORD* maxFaceInfluences) PURE; - // Set min bone influence. Bone influences that are smaller than this are ignored + /* Set min bone influence. Bone influences that are smaller than this are ignored */ STDMETHOD(SetMinBoneInfluence)(THIS_ FLOAT MinInfl) PURE; - // Get min bone influence. + /* Get min bone influence. */ STDMETHOD_(FLOAT, GetMinBoneInfluence)(THIS) PURE; - // Bone names are returned by D3DXLoadSkinMeshFromXof. They are not used by any other method of this object - STDMETHOD(SetBoneName)(THIS_ DWORD Bone, LPCSTR pName) PURE; // pName is copied to an internal string buffer - STDMETHOD_(LPCSTR, GetBoneName)(THIS_ DWORD Bone) PURE; // A pointer to an internal string buffer is returned. Do not free this. + /* Bone names are returned by D3DXLoadSkinMeshFromXof. They are not used by any other method of this object */ + STDMETHOD(SetBoneName)(THIS_ DWORD Bone, LPCSTR pName) PURE; /* pName is copied to an internal string buffer */ + STDMETHOD_(LPCSTR, GetBoneName)(THIS_ DWORD Bone) PURE; /* A pointer to an internal string buffer is returned. Do not free this. */ - // Bone offset matrices are returned by D3DXLoadSkinMeshFromXof. They are not used by any other method of this object - STDMETHOD(SetBoneOffsetMatrix)(THIS_ DWORD Bone, CONST D3DXMATRIX *pBoneTransform) PURE; // pBoneTransform is copied to an internal buffer - STDMETHOD_(LPD3DXMATRIX, GetBoneOffsetMatrix)(THIS_ DWORD Bone) PURE; // A pointer to an internal matrix is returned. Do not free this. + /* Bone offset matrices are returned by D3DXLoadSkinMeshFromXof. They are not used by any other method of this object */ + STDMETHOD(SetBoneOffsetMatrix)(THIS_ DWORD Bone, CONST D3DXMATRIX *pBoneTransform) PURE; /* pBoneTransform is copied to an internal buffer */ + STDMETHOD_(LPD3DXMATRIX, GetBoneOffsetMatrix)(THIS_ DWORD Bone) PURE; /* A pointer to an internal matrix is returned. Do not free this. */ - // Clone a skin info object + /* Clone a skin info object */ STDMETHOD(Clone)(THIS_ LPD3DXSKININFO* ppSkinInfo) PURE; - // Update bone influence information to match vertices after they are reordered. This should be called - // if the target vertex buffer has been reordered externally. + /* Update bone influence information to match vertices after they are reordered. This should be called + * if the target vertex buffer has been reordered externally. */ STDMETHOD(Remap)(THIS_ DWORD NumVertices, DWORD* pVertexRemap) PURE; - // These methods enable the modification of the vertex layout of the vertices that will be skinned + /* These methods enable the modification of the vertex layout of the vertices that will be skinned */ STDMETHOD(SetFVF)(THIS_ DWORD FVF) PURE; STDMETHOD(SetDeclaration)(THIS_ CONST D3DVERTEXELEMENT9 *pDeclaration) PURE; STDMETHOD_(DWORD, GetFVF)(THIS) PURE; STDMETHOD(GetDeclaration)(THIS_ D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]) PURE; - // Apply SW skinning based on current pose matrices to the target vertices. + /* Apply SW skinning based on current pose matrices to the target vertices. */ STDMETHOD(UpdateSkinnedMesh)(THIS_ CONST D3DXMATRIX* pBoneTransforms, CONST D3DXMATRIX* pBoneInvTransposeTransforms, LPCVOID pVerticesSrc, PVOID pVerticesDst) PURE; - // Takes a mesh and returns a new mesh with per vertex blend weights and a bone combination - // table that describes which bones affect which subsets of the mesh + /* Takes a mesh and returns a new mesh with per vertex blend weights and a bone combination + * table that describes which bones affect which subsets of the mesh */ STDMETHOD(ConvertToBlendedMesh)(THIS_ LPD3DXMESH pMesh, DWORD Options, @@ -639,8 +645,8 @@ DECLARE_INTERFACE_(ID3DXSkinInfo, IUnknown) LPD3DXBUFFER* ppBoneCombinationTable, LPD3DXMESH* ppMesh) PURE; - // Takes a mesh and returns a new mesh with per vertex blend weights and indices - // and a bone combination table that describes which bones palettes affect which subsets of the mesh + /* Takes a mesh and returns a new mesh with per vertex blend weights and indices + * and a bone combination table that describes which bones palettes affect which subsets of the mesh */ STDMETHOD(ConvertToIndexedBlendedMesh)(THIS_ LPD3DXMESH pMesh, DWORD Options, @@ -657,8 +663,7 @@ DECLARE_INTERFACE_(ID3DXSkinInfo, IUnknown) #ifdef __cplusplus extern "C" { -#endif //__cplusplus - +#endif /* __cplusplus */ HRESULT WINAPI D3DXCreateMesh( @@ -686,7 +691,7 @@ HRESULT WINAPI CONST FLOAT *pVertexWeights, LPD3DXSPMESH* ppSMesh); -// clean a mesh up for simplification, try to make manifold +/* clean a mesh up for simplification, try to make manifold */ HRESULT WINAPI D3DXCleanMesh( D3DXCLEANTYPE CleanType, @@ -724,17 +729,17 @@ HRESULT WINAPI HRESULT WINAPI D3DXComputeBoundingSphere( - CONST D3DXVECTOR3 *pFirstPosition, // pointer to first position + CONST D3DXVECTOR3 *pFirstPosition, /* pointer to first position */ DWORD NumVertices, - DWORD dwStride, // count in bytes to subsequent position vectors + DWORD dwStride, /* count in bytes to subsequent position vectors */ D3DXVECTOR3 *pCenter, FLOAT *pRadius); HRESULT WINAPI D3DXComputeBoundingBox( - CONST D3DXVECTOR3 *pFirstPosition, // pointer to first position + CONST D3DXVECTOR3 *pFirstPosition, /* pointer to first position */ DWORD NumVertices, - DWORD dwStride, // count in bytes to subsequent position vectors + DWORD dwStride, /* count in bytes to subsequent position vectors */ D3DXVECTOR3 *pMin, D3DXVECTOR3 *pMax); @@ -841,8 +846,8 @@ HRESULT WINAPI DWORD* pNumMaterials, LPD3DXPMESH *ppPMesh); -// Creates a skin info object based on the number of vertices, number of bones, and a declaration describing the vertex layout of the target vertices -// The bone names and initial bone transforms are not filled in the skin info object by this method. +/* Creates a skin info object based on the number of vertices, number of bones, and a declaration describing the vertex layout of the target vertices + * The bone names and initial bone transforms are not filled in the skin info object by this method. */ HRESULT WINAPI D3DXCreateSkinInfo( DWORD NumVertices, @@ -850,8 +855,8 @@ HRESULT WINAPI DWORD NumBones, LPD3DXSKININFO* ppSkinInfo); -// Creates a skin info object based on the number of vertices, number of bones, and a FVF describing the vertex layout of the target vertices -// The bone names and initial bone transforms are not filled in the skin info object by this method. +/* Creates a skin info object based on the number of vertices, number of bones, and a FVF describing the vertex layout of the target vertices + * The bone names and initial bone transforms are not filled in the skin info object by this method. */ HRESULT WINAPI D3DXCreateSkinInfoFVF( DWORD NumVertices, @@ -863,7 +868,7 @@ HRESULT WINAPI } extern "C" { -#endif //__cplusplus +#endif /* __cplusplus */ HRESULT WINAPI D3DXLoadMeshFromXof( @@ -876,8 +881,8 @@ HRESULT WINAPI DWORD *pNumMaterials, LPD3DXMESH *ppMesh); -// This similar to D3DXLoadMeshFromXof, except also returns skinning info if present in the file -// If skinning info is not present, ppSkinInfo will be NULL +/* This similar to D3DXLoadMeshFromXof, except also returns skinning info if present in the file + * If skinning info is not present, ppSkinInfo will be NULL */ HRESULT WINAPI D3DXLoadSkinMeshFromXof( LPD3DXFILEDATA pxofMesh, @@ -891,11 +896,12 @@ HRESULT WINAPI LPD3DXMESH* ppMesh); -// The inverse of D3DXConvertTo{Indexed}BlendedMesh() functions. It figures out the skinning info from -// the mesh and the bone combination table and populates a skin info object with that data. The bone -// names and initial bone transforms are not filled in the skin info object by this method. This works -// with either a non-indexed or indexed blended mesh. It examines the FVF or declarator of the mesh to -// determine what type it is. +/* The inverse of D3DXConvertTo{Indexed}BlendedMesh() functions. It figures out the skinning info from + * the mesh and the bone combination table and populates a skin info object with that data. The bone + * names and initial bone transforms are not filled in the skin info object by this method. This works + * with either a non-indexed or indexed blended mesh. It examines the FVF or declarator of the mesh to + * determine what type it is. + */ HRESULT WINAPI D3DXCreateSkinInfoFromBlendedMesh( LPD3DXBASEMESH pMesh, @@ -908,24 +914,26 @@ HRESULT WINAPI LPD3DXMESH pMeshIn, CONST DWORD* pAdjacencyIn, FLOAT NumSegs, - BOOL QuadraticInterpNormals, // if false use linear intrep for normals, if true use quadratic + BOOL QuadraticInterpNormals, /* if false use linear intrep for normals, if true use quadratic */ LPD3DXMESH *ppMeshOut, LPD3DXBUFFER *ppAdjacencyOut); -//generates implied outputdecl from input decl -//the decl generated from this should be used to generate the output decl for -//the tessellator subroutines. +/* generates implied outputdecl from input decl + * the decl generated from this should be used to generate the output decl for + * the tessellator subroutines. + */ HRESULT WINAPI D3DXGenerateOutputDecl( D3DVERTEXELEMENT9 *pOutput, CONST D3DVERTEXELEMENT9 *pInput); -//loads patches from an XFileData -//since an X file can have up to 6 different patch meshes in it, -//returns them in an array - pNumPatches will contain the number of -//meshes in the actual file. +/* loads patches from an XFileData + * since an X file can have up to 6 different patch meshes in it, + * returns them in an array - pNumPatches will contain the number of + * meshes in the actual file. + */ HRESULT WINAPI D3DXLoadPatchMeshFromXof( LPD3DXFILEDATA pXofObjMesh, @@ -936,23 +944,23 @@ HRESULT WINAPI PDWORD pNumMaterials, LPD3DXPATCHMESH *ppMesh); -//computes the size a single rect patch. +/* computes the size a single rect patch. */ HRESULT WINAPI D3DXRectPatchSize( - CONST FLOAT *pfNumSegs, //segments for each edge (4) - DWORD *pdwTriangles, //output number of triangles - DWORD *pdwVertices); //output number of vertices + CONST FLOAT *pfNumSegs, /* segments for each edge (4) */ + DWORD *pdwTriangles, /* output number of triangles */ + DWORD *pdwVertices); /* output number of vertices */ -//computes the size of a single triangle patch +/* computes the size of a single triangle patch */ HRESULT WINAPI D3DXTriPatchSize( - CONST FLOAT *pfNumSegs, //segments for each edge (3) - DWORD *pdwTriangles, //output number of triangles - DWORD *pdwVertices); //output number of vertices + CONST FLOAT *pfNumSegs, /* segments for each edge (3) */ + DWORD *pdwTriangles, /* output number of triangles */ + DWORD *pdwVertices); /* output number of vertices */ -//tessellates a patch into a created mesh -//similar to D3D RT patch +/*tessellates a patch into a created mesh + *similar to D3D RT patch */ HRESULT WINAPI D3DXTessellateRectPatch( LPDIRECT3DVERTEXBUFFER9 pVB, @@ -970,29 +978,26 @@ HRESULT WINAPI CONST D3DTRIPATCH_INFO *pTriPatchInfo, LPD3DXMESH pMesh); - - -//creates an NPatch PatchMesh from a D3DXMESH +/*creates an NPatch PatchMesh from a D3DXMESH */ HRESULT WINAPI D3DXCreateNPatchMesh( LPD3DXMESH pMeshSysMem, LPD3DXPATCHMESH *pPatchMesh); - -//creates a patch mesh +/*creates a patch mesh */ HRESULT WINAPI D3DXCreatePatchMesh( - CONST D3DXPATCHINFO *pInfo, //patch type - DWORD dwNumPatches, //number of patches - DWORD dwNumVertices, //number of control vertices - DWORD dwOptions, //options - CONST D3DVERTEXELEMENT9 *pDecl, //format of control vertices + CONST D3DXPATCHINFO *pInfo, /* patch type */ + DWORD dwNumPatches, /* number of patches */ + DWORD dwNumVertices, /* number of control vertices */ + DWORD dwOptions, /* options */ + CONST D3DVERTEXELEMENT9 *pDecl, /* format of control vertices */ LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXPATCHMESH *pPatchMesh); -//returns the number of degenerates in a patch mesh - -//text output put in string. +/*returns the number of degenerates in a patch mesh - + *text output put in string. */ HRESULT WINAPI D3DXValidPatchMesh(LPD3DXPATCHMESH pMesh, DWORD *dwcDegenerateVertices, @@ -1030,10 +1035,10 @@ HRESULT WINAPI typedef struct _D3DXINTERSECTINFO { - DWORD FaceIndex; // index of face intersected - FLOAT U; // Barycentric Hit Coordinates - FLOAT V; // Barycentric Hit Coordinates - FLOAT Dist; // Ray-Intersection Parameter Distance + DWORD FaceIndex; /* index of face intersected */ + FLOAT U; /* Barycentric Hit Coordinates */ + FLOAT V; /* Barycentric Hit Coordinates */ + FLOAT Dist; /* Ray-Intersection Parameter Distance */ } D3DXINTERSECTINFO, *LPD3DXINTERSECTINFO; @@ -1042,13 +1047,13 @@ HRESULT WINAPI LPD3DXBASEMESH pMesh, CONST D3DXVECTOR3 *pRayPos, CONST D3DXVECTOR3 *pRayDir, - BOOL *pHit, // True if any faces were intersected - DWORD *pFaceIndex, // index of closest face intersected - FLOAT *pU, // Barycentric Hit Coordinates - FLOAT *pV, // Barycentric Hit Coordinates - FLOAT *pDist, // Ray-Intersection Parameter Distance - LPD3DXBUFFER *ppAllHits, // Array of D3DXINTERSECTINFOs for all hits (not just closest) - DWORD *pCountOfHits); // Number of entries in AllHits array + BOOL *pHit, /* True if any faces were intersected */ + DWORD *pFaceIndex, /* index of closest face intersected */ + FLOAT *pU, /* Barycentric Hit Coordinates */ + FLOAT *pV, /* Barycentric Hit Coordinates */ + FLOAT *pDist, /* Ray-Intersection Parameter Distance */ + LPD3DXBUFFER *ppAllHits, /* Array of D3DXINTERSECTINFOs for all hits (not just closest) */ + DWORD *pCountOfHits); /* Number of entries in AllHits array */ HRESULT WINAPI D3DXIntersectSubset( @@ -1056,13 +1061,13 @@ HRESULT WINAPI DWORD AttribId, CONST D3DXVECTOR3 *pRayPos, CONST D3DXVECTOR3 *pRayDir, - BOOL *pHit, // True if any faces were intersected - DWORD *pFaceIndex, // index of closest face intersected - FLOAT *pU, // Barycentric Hit Coordinates - FLOAT *pV, // Barycentric Hit Coordinates - FLOAT *pDist, // Ray-Intersection Parameter Distance - LPD3DXBUFFER *ppAllHits, // Array of D3DXINTERSECTINFOs for all hits (not just closest) - DWORD *pCountOfHits); // Number of entries in AllHits array + BOOL *pHit, /* True if any faces were intersected */ + DWORD *pFaceIndex, /* index of closest face intersected */ + FLOAT *pU, /* Barycentric Hit Coordinates */ + FLOAT *pV, /* Barycentric Hit Coordinates */ + FLOAT *pDist, /* Ray-Intersection Parameter Distance */ + LPD3DXBUFFER *ppAllHits, /* Array of D3DXINTERSECTINFOs for all hits (not just closest) */ + DWORD *pCountOfHits); /* Number of entries in AllHits array */ HRESULT WINAPI D3DXSplitMesh @@ -1080,14 +1085,14 @@ HRESULT WINAPI D3DXSplitMesh BOOL WINAPI D3DXIntersectTri ( - CONST D3DXVECTOR3 *p0, // Triangle vertex 0 position - CONST D3DXVECTOR3 *p1, // Triangle vertex 1 position - CONST D3DXVECTOR3 *p2, // Triangle vertex 2 position - CONST D3DXVECTOR3 *pRayPos, // Ray origin - CONST D3DXVECTOR3 *pRayDir, // Ray direction - FLOAT *pU, // Barycentric Hit Coordinates - FLOAT *pV, // Barycentric Hit Coordinates - FLOAT *pDist); // Ray-Intersection Parameter Distance + CONST D3DXVECTOR3 *p0, /* Triangle vertex 0 position */ + CONST D3DXVECTOR3 *p1, /* Triangle vertex 1 position */ + CONST D3DXVECTOR3 *p2, /* Triangle vertex 2 position */ + CONST D3DXVECTOR3 *pRayPos, /* Ray origin */ + CONST D3DXVECTOR3 *pRayDir, /* Ray direction */ + FLOAT *pU, /* Barycentric Hit Coordinates */ + FLOAT *pV, /* Barycentric Hit Coordinates */ + FLOAT *pDist); /* Ray-Intersection Parameter Distance */ BOOL WINAPI D3DXSphereBoundProbe( @@ -1125,21 +1130,22 @@ HRESULT WINAPI D3DXComputeTangentFrameEx(ID3DXMesh *pMesh, ID3DXBuffer **ppVertexMapping); -//D3DXComputeTangent -// -//Computes the Tangent vectors for the TexStage texture coordinates -//and places the results in the TANGENT[TangentIndex] specified in the meshes' DECL -//puts the binorm in BINORM[BinormIndex] also specified in the decl. -// -//If neither the binorm or the tangnet are in the meshes declaration, -//the function will fail. -// -//If a tangent or Binorm field is in the Decl, but the user does not -//wish D3DXComputeTangent to replace them, then D3DX_DEFAULT specified -//in the TangentIndex or BinormIndex will cause it to ignore the specified -//semantic. -// -//Wrap should be specified if the texture coordinates wrap. +/*D3DXComputeTangent + * + *Computes the Tangent vectors for the TexStage texture coordinates + *and places the results in the TANGENT[TangentIndex] specified in the meshes' DECL + *puts the binorm in BINORM[BinormIndex] also specified in the decl. + * + *If neither the binorm or the tangnet are in the meshes declaration, + *the function will fail. + * + *If a tangent or Binorm field is in the Decl, but the user does not + *wish D3DXComputeTangent to replace them, then D3DX_DEFAULT specified + *in the TangentIndex or BinormIndex will cause it to ignore the specified + *semantic. + * + *Wrap should be specified if the texture coordinates wrap. + */ HRESULT WINAPI D3DXComputeTangent(LPD3DXMESH Mesh, DWORD TexStage, @@ -1148,90 +1154,92 @@ HRESULT WINAPI D3DXComputeTangent(LPD3DXMESH Mesh, DWORD Wrap, CONST DWORD *pAdjacency); -//============================================================================ -// -// UVAtlas apis -// -//============================================================================ +/* + * + * UVAtlas apis + * + */ typedef HRESULT (WINAPI *LPD3DXUVATLASCB)(FLOAT fPercentDone, LPVOID lpUserContext); -// This function creates atlases for meshes. There are two modes of operation, -// either based on the number of charts, or the maximum allowed stretch. If the -// maximum allowed stretch is 0, then each triangle will likely be in its own -// chart. +/* This function creates atlases for meshes. There are two modes of operation, + * either based on the number of charts, or the maximum allowed stretch. If the + * maximum allowed stretch is 0, then each triangle will likely be in its own + * chart. + */ -// -// The parameters are as follows: -// pMesh - Input mesh to calculate an atlas for. This must have a position -// channel and at least a 2-d texture channel. -// uMaxChartNumber - The maximum number of charts required for the atlas. -// If this is 0, it will be parameterized based solely on -// stretch. -// fMaxStretch - The maximum amount of stretch, if 0, no stretching is allowed, -// if 1, then any amount of stretching is allowed. -// uWidth - The width of the texture the atlas will be used on. -// uHeight - The height of the texture the atlas will be used on. -// fGutter - The minimum distance, in texels between two charts on the atlas. -// this gets scaled by the width, so if fGutter is 2.5, and it is -// used on a 512x512 texture, then the minimum distance will be -// 2.5 / 512 in u-v space. -// dwTextureIndex - Specifies which texture coordinate to write to in the -// output mesh (which is cloned from the input mesh). Useful -// if your vertex has multiple texture coordinates. -// pdwAdjacency - a pointer to an array with 3 DWORDs per face, indicating -// which triangles are adjacent to each other. -// pdwFalseEdgeAdjacency - a pointer to an array with 3 DWORDS per face, indicating -// at each face, whether an edge is a false edge or not (using -// the same ordering as the adjacency data structure). If this -// is NULL, then it is assumed that there are no false edges. If -// not NULL, then a non-false edge is indicated by -1 and a false -// edge is indicated by any other value (it is not required, but -// it may be useful for the caller to use the original adjacency -// value). This allows you to parameterize a mesh of quads, and -// the edges down the middle of each quad will not be cut when -// parameterizing the mesh. -// pfIMTArray - a pointer to an array with 3 FLOATs per face, describing the -// integrated metric tensor for that face. This lets you control -// the way this triangle may be stretched in the atlas. The IMT -// passed in will be 3 floats (a,b,c) and specify a symmetric -// matrix (a b) that, given a vector (s,t), specifies the -// (b c) -// distance between a vector v1 and a vector v2 = v1 + (s,t) as -// sqrt((s, t) * M * (s, t)^T). -// In other words, this lets one specify the magnitude of the -// stretch in an arbitrary direction in u-v space. For example -// if a = b = c = 1, then this scales the vector (1,1) by 2, and -// the vector (1,-1) by 0. Note that this is multiplying the edge -// length by the square of the matrix, so if you want the face to -// stretch to twice its -// size with no shearing, the IMT value should be (2, 0, 2), which -// is just the identity matrix times 2. -// Note that this assumes you have an orientation for the triangle -// in some 2-D space. For D3DXUVAtlas, this space is created by -// letting S be the direction from the first to the second -// vertex, and T be the cross product between the normal and S. -// -// pStatusCallback - Since the atlas creation process can be very CPU intensive, -// this allows the programmer to specify a function to be called -// periodically, similarly to how it is done in the PRT simulation -// engine. -// fCallbackFrequency - This lets you specify how often the callback will be -// called. A decent default should be 0.0001f. -// pUserContext - a void pointer to be passed back to the callback function -// dwOptions - A combination of flags in the D3DXUVATLAS enum -// ppMeshOut - A pointer to a location to store a pointer for the newly created -// mesh. -// ppFacePartitioning - A pointer to a location to store a pointer for an array, -// one DWORD per face, giving the final partitioning -// created by the atlasing algorithm. -// ppVertexRemapArray - A pointer to a location to store a pointer for an array, -// one DWORD per vertex, giving the vertex it was copied -// from, if any vertices needed to be split. -// pfMaxStretchOut - A location to store the maximum stretch resulting from the -// atlasing algorithm. -// puNumChartsOut - A location to store the number of charts created, or if the -// maximum number of charts was too low, this gives the minimum -// number of charts needed to create an atlas. +/* + * The parameters are as follows: + * pMesh - Input mesh to calculate an atlas for. This must have a position + * channel and at least a 2-d texture channel. + * uMaxChartNumber - The maximum number of charts required for the atlas. + * If this is 0, it will be parameterized based solely on + * stretch. + * fMaxStretch - The maximum amount of stretch, if 0, no stretching is allowed, + * if 1, then any amount of stretching is allowed. + * uWidth - The width of the texture the atlas will be used on. + * uHeight - The height of the texture the atlas will be used on. + * fGutter - The minimum distance, in texels between two charts on the atlas. + * this gets scaled by the width, so if fGutter is 2.5, and it is + * used on a 512x512 texture, then the minimum distance will be + * 2.5 / 512 in u-v space. + * dwTextureIndex - Specifies which texture coordinate to write to in the + * output mesh (which is cloned from the input mesh). Useful + * if your vertex has multiple texture coordinates. + * pdwAdjacency - a pointer to an array with 3 DWORDs per face, indicating + * which triangles are adjacent to each other. + * pdwFalseEdgeAdjacency - a pointer to an array with 3 DWORDS per face, indicating + * at each face, whether an edge is a false edge or not (using + * the same ordering as the adjacency data structure). If this + * is NULL, then it is assumed that there are no false edges. If + * not NULL, then a non-false edge is indicated by -1 and a false + * edge is indicated by any other value (it is not required, but + * it may be useful for the caller to use the original adjacency + * value). This allows you to parameterize a mesh of quads, and + * the edges down the middle of each quad will not be cut when + * parameterizing the mesh. + * pfIMTArray - a pointer to an array with 3 FLOATs per face, describing the + * integrated metric tensor for that face. This lets you control + * the way this triangle may be stretched in the atlas. The IMT + * passed in will be 3 floats (a,b,c) and specify a symmetric + * matrix (a b) that, given a vector (s,t), specifies the + * (b c) + * distance between a vector v1 and a vector v2 = v1 + (s,t) as + * sqrt((s, t) * M * (s, t)^T). + * In other words, this lets one specify the magnitude of the + * stretch in an arbitrary direction in u-v space. For example + * if a = b = c = 1, then this scales the vector (1,1) by 2, and + * the vector (1,-1) by 0. Note that this is multiplying the edge + * length by the square of the matrix, so if you want the face to + * stretch to twice its + * size with no shearing, the IMT value should be (2, 0, 2), which + * is just the identity matrix times 2. + * Note that this assumes you have an orientation for the triangle + * in some 2-D space. For D3DXUVAtlas, this space is created by + * letting S be the direction from the first to the second + * vertex, and T be the cross product between the normal and S. + * + * pStatusCallback - Since the atlas creation process can be very CPU intensive, + * this allows the programmer to specify a function to be called + * periodically, similarly to how it is done in the PRT simulation + * engine. + * fCallbackFrequency - This lets you specify how often the callback will be + * called. A decent default should be 0.0001f. + * pUserContext - a void pointer to be passed back to the callback function + * dwOptions - A combination of flags in the D3DXUVATLAS enum + * ppMeshOut - A pointer to a location to store a pointer for the newly created + * mesh. + * ppFacePartitioning - A pointer to a location to store a pointer for an array, + * one DWORD per face, giving the final partitioning + * created by the atlasing algorithm. + * ppVertexRemapArray - A pointer to a location to store a pointer for an array, + * one DWORD per vertex, giving the vertex it was copied + * from, if any vertices needed to be split. + * pfMaxStretchOut - A location to store the maximum stretch resulting from the + * atlasing algorithm. + * puNumChartsOut - A location to store the number of charts created, or if the + * maximum number of charts was too low, this gives the minimum + * number of charts needed to create an atlas. + */ HRESULT WINAPI D3DXUVAtlasCreate(LPD3DXMESH pMesh, UINT uMaxChartNumber, @@ -1253,33 +1261,32 @@ HRESULT WINAPI D3DXUVAtlasCreate(LPD3DXMESH pMesh, FLOAT *pfMaxStretchOut, UINT *puNumChartsOut); -// This has the same exact arguments as Create, except that it does not perform the -// final packing step. This method allows one to get a partitioning out, and possibly -// modify it before sending it to be repacked. Note that if you change the -// partitioning, you'll also need to calculate new texture coordinates for any faces -// that have switched charts. -// -// The partition result adjacency output parameter is meant to be passed to the -// UVAtlasPack function, this adjacency cuts edges that are between adjacent -// charts, and also can include cuts inside of a chart in order to make it -// equivalent to a disc. For example: -// -// _______ -// | ___ | -// | |_| | -// |_____| -// -// In order to make this equivalent to a disc, we would need to add a cut, and it -// Would end up looking like: -// _______ -// | ___ | -// | |_|_| -// |_____| -// -// The resulting partition adjacency parameter cannot be NULL, because it is -// required for the packing step. - - +/* This has the same exact arguments as Create, except that it does not perform the + * final packing step. This method allows one to get a partitioning out, and possibly + * modify it before sending it to be repacked. Note that if you change the + * partitioning, you'll also need to calculate new texture coordinates for any faces + * that have switched charts. + * + * The partition result adjacency output parameter is meant to be passed to the + * UVAtlasPack function, this adjacency cuts edges that are between adjacent + * charts, and also can include cuts inside of a chart in order to make it + * equivalent to a disc. For example: + * + * _______ + * | ___ | + * | |_| | + * |_____| + * + * In order to make this equivalent to a disc, we would need to add a cut, and it + * Would end up looking like: + * _______ + * | ___ | + * | |_|_| + * |_____| + * + * The resulting partition adjacency parameter cannot be NULL, because it is + * required for the packing step. + */ HRESULT WINAPI D3DXUVAtlasPartition(LPD3DXMESH pMesh, UINT uMaxChartNumber, @@ -1299,12 +1306,13 @@ HRESULT WINAPI D3DXUVAtlasPartition(LPD3DXMESH pMesh, FLOAT *pfMaxStretchOut, UINT *puNumChartsOut); -// This takes the face partitioning result from Partition and packs it into an -// atlas of the given size. pdwPartitionResultAdjacency should be derived from -// the adjacency returned from the partition step. This value cannot be NULL -// because Pack needs to know where charts were cut in the partition step in -// order to find the edges of each chart. -// The options parameter is currently reserved. +/* This takes the face partitioning result from Partition and packs it into an + * atlas of the given size. pdwPartitionResultAdjacency should be derived from + * the adjacency returned from the partition step. This value cannot be NULL + * because Pack needs to know where charts were cut in the partition step in + * order to find the edges of each chart. + * The options parameter is currently reserved. + */ HRESULT WINAPI D3DXUVAtlasPack(ID3DXMesh *pMesh, UINT uWidth, UINT uHeight, @@ -1318,27 +1326,28 @@ HRESULT WINAPI D3DXUVAtlasPack(ID3DXMesh *pMesh, LPD3DXBUFFER pFacePartitioning); -//============================================================================ -// -// IMT Calculation apis -// -// These functions all compute the Integrated Metric Tensor for use in the -// UVAtlas API. They all calculate the IMT with respect to the canonical -// triangle, where the coordinate system is set up so that the u axis goes -// from vertex 0 to 1 and the v axis is N x u. So, for example, the second -// vertex's canonical uv coordinates are (d,0) where d is the distance between -// vertices 0 and 1. This way the IMT does not depend on the parameterization -// of the mesh, and if the signal over the surface doesn't change, then -// the IMT doesn't need to be recalculated. -//============================================================================ +/* + * + * IMT Calculation apis + * + * These functions all compute the Integrated Metric Tensor for use in the + * UVAtlas API. They all calculate the IMT with respect to the canonical + * triangle, where the coordinate system is set up so that the u axis goes + * from vertex 0 to 1 and the v axis is N x u. So, for example, the second + * vertex's canonical uv coordinates are (d,0) where d is the distance between + * vertices 0 and 1. This way the IMT does not depend on the parameterization + * of the mesh, and if the signal over the surface doesn't change, then + * the IMT doesn't need to be recalculated. + *============================================================================ -// This callback is used by D3DXComputeIMTFromSignal. -// -// uv - The texture coordinate for the vertex. -// uPrimitiveID - Face ID of the triangle on which to compute the signal. -// uSignalDimension - The number of floats to store in pfSignalOut. -// pUserData - The pUserData pointer passed in to ComputeIMTFromSignal. -// pfSignalOut - A pointer to where to store the signal data. + * This callback is used by D3DXComputeIMTFromSignal. + * + * uv - The texture coordinate for the vertex. + * uPrimitiveID - Face ID of the triangle on which to compute the signal. + * uSignalDimension - The number of floats to store in pfSignalOut. + * pUserData - The pUserData pointer passed in to ComputeIMTFromSignal. + * pfSignalOut - A pointer to where to store the signal data. + */ typedef HRESULT (WINAPI* LPD3DXIMTSIGNALCALLBACK) (CONST D3DXVECTOR2 *uv, UINT uPrimitiveID, @@ -1346,72 +1355,75 @@ typedef HRESULT (WINAPI* LPD3DXIMTSIGNALCALLBACK) VOID *pUserData, FLOAT *pfSignalOut); -// This function is used to calculate the IMT from per vertex data. It sets -// up a linear system over the triangle, solves for the jacobian J, then -// constructs the IMT from that (J^TJ). -// This function allows you to calculate the IMT based off of any value in a -// mesh (color, normal, etc) by specifying the correct stride of the array. -// The IMT computed will cause areas of the mesh that have similar values to -// take up less space in the texture. -// -// pMesh - The mesh to calculate the IMT for. -// pVertexSignal - A float array of size uSignalStride * v, where v is the -// number of vertices in the mesh. -// uSignalDimension - How many floats per vertex to use in calculating the IMT. -// uSignalStride - The number of bytes per vertex in the array. This must be -// a multiple of sizeof(float) -// ppIMTData - Where to store the buffer holding the IMT data +/* This function is used to calculate the IMT from per vertex data. It sets + * up a linear system over the triangle, solves for the jacobian J, then + * constructs the IMT from that (J^TJ). + * This function allows you to calculate the IMT based off of any value in a + * mesh (color, normal, etc) by specifying the correct stride of the array. + * The IMT computed will cause areas of the mesh that have similar values to + * take up less space in the texture. + * + * pMesh - The mesh to calculate the IMT for. + * pVertexSignal - A float array of size uSignalStride * v, where v is the + * number of vertices in the mesh. + * uSignalDimension - How many floats per vertex to use in calculating the IMT. + * uSignalStride - The number of bytes per vertex in the array. This must be + * a multiple of sizeof(float) + * ppIMTData - Where to store the buffer holding the IMT data + */ HRESULT WINAPI D3DXComputeIMTFromPerVertexSignal ( LPD3DXMESH pMesh, - CONST FLOAT *pfVertexSignal, // uSignalDimension floats per vertex + CONST FLOAT *pfVertexSignal, /* uSignalDimension floats per vertex */ UINT uSignalDimension, - UINT uSignalStride, // stride of signal in bytes - DWORD dwOptions, // reserved for future use + UINT uSignalStride, /* stride of signal in bytes */ + DWORD dwOptions, /* reserved for future use */ LPD3DXUVATLASCB pStatusCallback, LPVOID pUserContext, LPD3DXBUFFER *ppIMTData); -// This function is used to calculate the IMT from data that varies over the -// surface of the mesh (generally at a higher frequency than vertex data). -// This function requires the mesh to already be parameterized (so it already -// has texture coordinates). It allows the user to define a signal arbitrarily -// over the surface of the mesh. -// -// pMesh - The mesh to calculate the IMT for. -// dwTextureIndex - This describes which set of texture coordinates in the -// mesh to use. -// uSignalDimension - How many components there are in the signal. -// fMaxUVDistance - The subdivision will continue until the distance between -// all vertices is at most fMaxUVDistance. -// dwOptions - reserved for future use -// pSignalCallback - The callback to use to get the signal. -// pUserData - A pointer that will be passed in to the callback. -// ppIMTData - Where to store the buffer holding the IMT data +/* This function is used to calculate the IMT from data that varies over the + * surface of the mesh (generally at a higher frequency than vertex data). + * This function requires the mesh to already be parameterized (so it already + * has texture coordinates). It allows the user to define a signal arbitrarily + * over the surface of the mesh. + * + * pMesh - The mesh to calculate the IMT for. + * dwTextureIndex - This describes which set of texture coordinates in the + * mesh to use. + * uSignalDimension - How many components there are in the signal. + * fMaxUVDistance - The subdivision will continue until the distance between + * all vertices is at most fMaxUVDistance. + * dwOptions - reserved for future use + * pSignalCallback - The callback to use to get the signal. + * pUserData - A pointer that will be passed in to the callback. + * ppIMTData - Where to store the buffer holding the IMT data + */ HRESULT WINAPI D3DXComputeIMTFromSignal( LPD3DXMESH pMesh, DWORD dwTextureIndex, UINT uSignalDimension, FLOAT fMaxUVDistance, - DWORD dwOptions, // reserved for future use + DWORD dwOptions, /* reserved for future use */ LPD3DXIMTSIGNALCALLBACK pSignalCallback, VOID *pUserData, LPD3DXUVATLASCB pStatusCallback, LPVOID pUserContext, LPD3DXBUFFER *ppIMTData); -// This function is used to calculate the IMT from texture data. Given a texture -// that maps over the surface of the mesh, the algorithm computes the IMT for -// each face. This will cause large areas that are very similar to take up less -// room when parameterized with UVAtlas. The texture is assumed to be -// interpolated over the mesh bilinearly. -// -// pMesh - The mesh to calculate the IMT for. -// pTexture - The texture to load data from. -// dwTextureIndex - This describes which set of texture coordinates in the -// mesh to use. -// dwOptions - Combination of one or more D3DXIMT flags. -// ppIMTData - Where to store the buffer holding the IMT data +/* This function is used to calculate the IMT from texture data. Given a texture + * that maps over the surface of the mesh, the algorithm computes the IMT for + * each face. This will cause large areas that are very similar to take up less + * room when parameterized with UVAtlas. The texture is assumed to be + * interpolated over the mesh bilinearly. + * + * pMesh - The mesh to calculate the IMT for. + * pTexture - The texture to load data from. + * dwTextureIndex - This describes which set of texture coordinates in the + * mesh to use. + * dwOptions - Combination of one or more D3DXIMT flags. + * ppIMTData - Where to store the buffer holding the IMT data + */ HRESULT WINAPI D3DXComputeIMTFromTexture ( LPD3DXMESH pMesh, LPDIRECT3DTEXTURE9 pTexture, @@ -1421,21 +1433,22 @@ HRESULT WINAPI D3DXComputeIMTFromTexture ( LPVOID pUserContext, LPD3DXBUFFER *ppIMTData); -// This function is very similar to ComputeIMTFromTexture, but it uses a -// float array to pass in the data, and it can calculate higher dimensional -// values than 4. -// -// pMesh - The mesh to calculate the IMT for. -// dwTextureIndex - This describes which set of texture coordinates in the -// mesh to use. -// pfFloatArray - a pointer to a float array of size -// uWidth*uHeight*uComponents -// uWidth - The width of the texture -// uHeight - The height of the texture -// uSignalDimension - The number of floats per texel in the signal -// uComponents - The number of floats in each texel -// dwOptions - Combination of one or more D3DXIMT flags -// ppIMTData - Where to store the buffer holding the IMT data +/* This function is very similar to ComputeIMTFromTexture, but it uses a + * float array to pass in the data, and it can calculate higher dimensional + * values than 4. + * + * pMesh - The mesh to calculate the IMT for. + * dwTextureIndex - This describes which set of texture coordinates in the + * mesh to use. + * pfFloatArray - a pointer to a float array of size + * uWidth*uHeight*uComponents + * uWidth - The width of the texture + * uHeight - The height of the texture + * uSignalDimension - The number of floats per texel in the signal + * uComponents - The number of floats in each texel + * dwOptions - Combination of one or more D3DXIMT flags + * ppIMTData - Where to store the buffer holding the IMT data + */ HRESULT WINAPI D3DXComputeIMTFromPerTexelSignal( LPD3DXMESH pMesh, DWORD dwTextureIndex, @@ -1468,29 +1481,29 @@ HRESULT WINAPI DWORD *pNumStrips); -//============================================================================ -// -// D3DXOptimizeFaces: -// -------------------- -// Generate a face remapping for a triangle list that more effectively utilizes -// vertex caches. This optimization is identical to the one provided -// by ID3DXMesh::Optimize with the hardware independent option enabled. -// -// Parameters: -// pbIndices -// Triangle list indices to use for generating a vertex ordering -// NumFaces -// Number of faces in the triangle list -// NumVertices -// Number of vertices referenced by the triangle list -// b32BitIndices -// TRUE if indices are 32 bit, FALSE if indices are 16 bit -// pFaceRemap -// Destination buffer to store face ordering -// The number stored for a given element is where in the new ordering -// the face will have come from. See ID3DXMesh::Optimize for more info. -// -//============================================================================ +/* + * + * D3DXOptimizeFaces: + * -------------------- + * Generate a face remapping for a triangle list that more effectively utilizes + * vertex caches. This optimization is identical to the one provided + * by ID3DXMesh::Optimize with the hardware independent option enabled. + * + * Parameters: + * pbIndices + * Triangle list indices to use for generating a vertex ordering + * NumFaces + * Number of faces in the triangle list + * NumVertices + * Number of vertices referenced by the triangle list + * b32BitIndices + * TRUE if indices are 32 bit, FALSE if indices are 16 bit + * pFaceRemap + * Destination buffer to store face ordering + * The number stored for a given element is where in the new ordering + * the face will have come from. See ID3DXMesh::Optimize for more info. + * + */ HRESULT WINAPI D3DXOptimizeFaces( LPCVOID pbIndices, @@ -1499,29 +1512,29 @@ HRESULT WINAPI BOOL b32BitIndices, DWORD* pFaceRemap); -//============================================================================ -// -// D3DXOptimizeVertices: -// -------------------- -// Generate a vertex remapping to optimize for in order use of vertices for -// a given set of indices. This is commonly used after applying the face -// remap generated by D3DXOptimizeFaces -// -// Parameters: -// pbIndices -// Triangle list indices to use for generating a vertex ordering -// NumFaces -// Number of faces in the triangle list -// NumVertices -// Number of vertices referenced by the triangle list -// b32BitIndices -// TRUE if indices are 32 bit, FALSE if indices are 16 bit -// pVertexRemap -// Destination buffer to store vertex ordering -// The number stored for a given element is where in the new ordering -// the vertex will have come from. See ID3DXMesh::Optimize for more info. -// -//============================================================================ +/* + * + * D3DXOptimizeVertices: + * -------------------- + * Generate a vertex remapping to optimize for in order use of vertices for + * a given set of indices. This is commonly used after applying the face + * remap generated by D3DXOptimizeFaces + * + * Parameters: + * pbIndices + * Triangle list indices to use for generating a vertex ordering + * NumFaces + * Number of faces in the triangle list + * NumVertices + * Number of vertices referenced by the triangle list + * b32BitIndices + * TRUE if indices are 32 bit, FALSE if indices are 16 bit + * pVertexRemap + * Destination buffer to store vertex ordering + * The number stored for a given element is where in the new ordering + * the vertex will have come from. See ID3DXMesh::Optimize for more info. + * + */ HRESULT WINAPI D3DXOptimizeVertices( LPCVOID pbIndices, @@ -1532,15 +1545,15 @@ HRESULT WINAPI #ifdef __cplusplus } -#endif //__cplusplus +#endif /* __cplusplus */ -//=========================================================================== -// -// Data structures for Spherical Harmonic Precomputation -// -// -//============================================================================ +/* + * + * Data structures for Spherical Harmonic Precomputation + * + * + */ typedef enum _D3DXSHCOMPRESSQUALITYTYPE { D3DXSHCQUAL_FASTLOWQUALITY = 1, @@ -1559,72 +1572,76 @@ typedef enum _D3DXSHGPUSIMOPT { D3DXSHGPUSIMOPT_FORCE_DWORD = 0x7fffffff } D3DXSHGPUSIMOPT; -// for all properties that are colors the luminance is computed -// if the simulator is run with a single channel using the following -// formula: R * 0.2125 + G * 0.7154 + B * 0.0721 +/* for all properties that are colors the luminance is computed + * if the simulator is run with a single channel using the following + * formula: R * 0.2125 + G * 0.7154 + B * 0.0721 + */ typedef struct _D3DXSHMATERIAL { - D3DCOLORVALUE Diffuse; // Diffuse albedo of the surface. (Ignored if object is a Mirror) - BOOL bMirror; // Must be set to FALSE. bMirror == TRUE not currently supported - BOOL bSubSurf; // true if the object does subsurface scattering - can't do this and be a mirror + D3DCOLORVALUE Diffuse; /* Diffuse albedo of the surface. (Ignored if object is a Mirror) */ + BOOL bMirror; /* Must be set to FALSE. bMirror == TRUE not currently supported */ + BOOL bSubSurf; /* true if the object does subsurface scattering - can't do this and be a mirror */ - // subsurface scattering parameters + /* subsurface scattering parameters */ FLOAT RelativeIndexOfRefraction; D3DCOLORVALUE Absorption; D3DCOLORVALUE ReducedScattering; } D3DXSHMATERIAL; -// allocated in D3DXSHPRTCompSplitMeshSC -// vertices are duplicated into multiple super clusters but -// only have a valid status in one super cluster (fill in the rest) +/* allocated in D3DXSHPRTCompSplitMeshSC + * vertices are duplicated into multiple super clusters but + * only have a valid status in one super cluster (fill in the rest) + */ typedef struct _D3DXSHPRTSPLITMESHVERTDATA { - UINT uVertRemap; // vertex in original mesh this corresponds to - UINT uSubCluster; // cluster index relative to super cluster - UCHAR ucVertStatus; // 1 if vertex has valid data, 0 if it is "fill" + UINT uVertRemap; /* vertex in original mesh this corresponds to */ + UINT uSubCluster; /* cluster index relative to super cluster */ + UCHAR ucVertStatus; /* 1 if vertex has valid data, 0 if it is "fill" */ } D3DXSHPRTSPLITMESHVERTDATA; -// used in D3DXSHPRTCompSplitMeshSC -// information for each super cluster that maps into face/vert arrays +/* used in D3DXSHPRTCompSplitMeshSC + * information for each super cluster that maps into face/vert arrays + */ typedef struct _D3DXSHPRTSPLITMESHCLUSTERDATA { - UINT uVertStart; // initial index into remapped vertex array - UINT uVertLength; // number of vertices in this super cluster + UINT uVertStart; /* initial index into remapped vertex array */ + UINT uVertLength; /* number of vertices in this super cluster */ - UINT uFaceStart; // initial index into face array - UINT uFaceLength; // number of faces in this super cluster + UINT uFaceStart; /* initial index into face array */ + UINT uFaceLength; /* number of faces in this super cluster */ - UINT uClusterStart; // initial index into cluster array - UINT uClusterLength; // number of clusters in this super cluster + UINT uClusterStart; /* initial index into cluster array */ + UINT uClusterLength; /* number of clusters in this super cluster */ } D3DXSHPRTSPLITMESHCLUSTERDATA; -// call back function for simulator -// return S_OK to keep running the simulator - anything else represents -// failure and the simulator will abort. +/* call back function for simulator + * return S_OK to keep running the simulator - anything else represents + * failure and the simulator will abort. + */ typedef HRESULT (WINAPI *LPD3DXSHPRTSIMCB)(float fPercentDone, LPVOID lpUserContext); -// interfaces for PRT buffers/simulator +/* interfaces for PRT buffers/simulator */ -// GUIDs -// {F1827E47-00A8-49cd-908C-9D11955F8728} +/* GUIDs + * {F1827E47-00A8-49cd-908C-9D11955F8728} */ DEFINE_GUID(IID_ID3DXPRTBuffer, 0xf1827e47, 0xa8, 0x49cd, 0x90, 0x8c, 0x9d, 0x11, 0x95, 0x5f, 0x87, 0x28); -// {A758D465-FE8D-45ad-9CF0-D01E56266A07} +/* {A758D465-FE8D-45ad-9CF0-D01E56266A07} */ DEFINE_GUID(IID_ID3DXPRTCompBuffer, 0xa758d465, 0xfe8d, 0x45ad, 0x9c, 0xf0, 0xd0, 0x1e, 0x56, 0x26, 0x6a, 0x7); -// {838F01EC-9729-4527-AADB-DF70ADE7FEA9} +/* {838F01EC-9729-4527-AADB-DF70ADE7FEA9} */ DEFINE_GUID(IID_ID3DXTextureGutterHelper, 0x838f01ec, 0x9729, 0x4527, 0xaa, 0xdb, 0xdf, 0x70, 0xad, 0xe7, 0xfe, 0xa9); -// {683A4278-CD5F-4d24-90AD-C4E1B6855D53} +/* {683A4278-CD5F-4d24-90AD-C4E1B6855D53} */ DEFINE_GUID(IID_ID3DXPRTEngine, 0x683a4278, 0xcd5f, 0x4d24, 0x90, 0xad, 0xc4, 0xe1, 0xb6, 0x85, 0x5d, 0x53); -// interface defenitions +/* interface defenitions */ typedef interface ID3DXTextureGutterHelper ID3DXTextureGutterHelper; typedef interface ID3DXPRTBuffer ID3DXPRTBuffer; @@ -1632,18 +1649,19 @@ typedef interface ID3DXPRTBuffer ID3DXPRTBuffer; #undef INTERFACE #define INTERFACE ID3DXPRTBuffer -// Buffer interface - contains "NumSamples" samples -// each sample in memory is stored as NumCoeffs scalars per channel (1 or 3) -// Same interface is used for both Vertex and Pixel PRT buffers +/* Buffer interface - contains "NumSamples" samples + * each sample in memory is stored as NumCoeffs scalars per channel (1 or 3) + * Same interface is used for both Vertex and Pixel PRT buffers + */ DECLARE_INTERFACE_(ID3DXPRTBuffer, IUnknown) { - // IUnknown + /* IUnknown */ STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; STDMETHOD_(ULONG, AddRef)(THIS) PURE; STDMETHOD_(ULONG, Release)(THIS) PURE; - // ID3DXPRTBuffer + /* ID3DXPRTBuffer */ STDMETHOD_(UINT, GetNumSamples)(THIS) PURE; STDMETHOD_(UINT, GetNumCoeffs)(THIS) PURE; STDMETHOD_(UINT, GetNumChannels)(THIS) PURE; @@ -1652,37 +1670,42 @@ DECLARE_INTERFACE_(ID3DXPRTBuffer, IUnknown) STDMETHOD_(UINT, GetWidth)(THIS) PURE; STDMETHOD_(UINT, GetHeight)(THIS) PURE; - // changes the number of samples allocated in the buffer + /* changes the number of samples allocated in the buffer */ STDMETHOD(Resize)(THIS_ UINT NewSize) PURE; - // ppData will point to the memory location where sample Start begins - // pointer is valid for at least NumSamples samples + /* ppData will point to the memory location where sample Start begins + * pointer is valid for at least NumSamples samples + */ STDMETHOD(LockBuffer)(THIS_ UINT Start, UINT NumSamples, FLOAT **ppData) PURE; STDMETHOD(UnlockBuffer)(THIS) PURE; - // every scalar in buffer is multiplied by Scale + /* every scalar in buffer is multiplied by Scale */ STDMETHOD(ScaleBuffer)(THIS_ FLOAT Scale) PURE; - // every scalar contains the sum of this and pBuffers values - // pBuffer must have the same storage class/dimensions + /* every scalar contains the sum of this and pBuffers values + * pBuffer must have the same storage class/dimensions + */ STDMETHOD(AddBuffer)(THIS_ LPD3DXPRTBUFFER pBuffer) PURE; - // GutterHelper (described below) will fill in the gutter - // regions of a texture by interpolating "internal" values + /* GutterHelper (described below) will fill in the gutter + * regions of a texture by interpolating "internal" values + */ STDMETHOD(AttachGH)(THIS_ LPD3DXTEXTUREGUTTERHELPER) PURE; STDMETHOD(ReleaseGH)(THIS) PURE; - // Evaluates attached gutter helper on the contents of this buffer + /* Evaluates attached gutter helper on the contents of this buffer */ STDMETHOD(EvalGH)(THIS) PURE; - // extracts a given channel into texture pTexture - // NumCoefficients starting from StartCoefficient are copied + /* extracts a given channel into texture pTexture + * NumCoefficients starting from StartCoefficient are copied + */ STDMETHOD(ExtractTexture)(THIS_ UINT Channel, UINT StartCoefficient, UINT NumCoefficients, LPDIRECT3DTEXTURE9 pTexture) PURE; - // extracts NumCoefficients coefficients into mesh - only applicable on single channel - // buffers, otherwise just lockbuffer and copy data. With SHPRT data NumCoefficients - // should be Order^2 + /* extracts NumCoefficients coefficients into mesh - only applicable on single channel + * buffers, otherwise just lockbuffer and copy data. With SHPRT data NumCoefficients + * should be Order^2 + */ STDMETHOD(ExtractToMesh)(THIS_ UINT NumCoefficients, D3DDECLUSAGE Usage, UINT UsageIndexStart, LPD3DXMESH pScene) PURE; @@ -1694,18 +1717,18 @@ typedef interface ID3DXPRTCompBuffer *LPD3DXPRTCOMPBUFFER; #undef INTERFACE #define INTERFACE ID3DXPRTCompBuffer -// compressed buffers stored a compressed version of a PRTBuffer +/* compressed buffers stored a compressed version of a PRTBuffer */ DECLARE_INTERFACE_(ID3DXPRTCompBuffer, IUnknown) { - // IUnknown + /* IUnknown */ STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; STDMETHOD_(ULONG, AddRef)(THIS) PURE; STDMETHOD_(ULONG, Release)(THIS) PURE; - // ID3DPRTCompBuffer + /* ID3DPRTCompBuffer */ - // NumCoeffs and NumChannels are properties of input buffer + /* NumCoeffs and NumChannels are properties of input buffer */ STDMETHOD_(UINT, GetNumSamples)(THIS) PURE; STDMETHOD_(UINT, GetNumCoeffs)(THIS) PURE; STDMETHOD_(UINT, GetNumChannels)(THIS) PURE; @@ -1714,33 +1737,38 @@ DECLARE_INTERFACE_(ID3DXPRTCompBuffer, IUnknown) STDMETHOD_(UINT, GetWidth)(THIS) PURE; STDMETHOD_(UINT, GetHeight)(THIS) PURE; - // number of clusters, and PCA vectors per-cluster + /* number of clusters, and PCA vectors per-cluster */ STDMETHOD_(UINT, GetNumClusters)(THIS) PURE; STDMETHOD_(UINT, GetNumPCA)(THIS) PURE; - // normalizes PCA weights so that they are between [-1,1] - // basis vectors are modified to reflect this + /* normalizes PCA weights so that they are between [-1,1] + * basis vectors are modified to reflect this + */ STDMETHOD(NormalizeData)(THIS) PURE; - // copies basis vectors for cluster "Cluster" into pClusterBasis - // (NumPCA+1)*NumCoeffs*NumChannels floats + /* copies basis vectors for cluster "Cluster" into pClusterBasis + * (NumPCA+1)*NumCoeffs*NumChannels floats + */ STDMETHOD(ExtractBasis)(THIS_ UINT Cluster, FLOAT *pClusterBasis) PURE; - // UINT per sample - which cluster it belongs to + /* UINT per sample - which cluster it belongs to */ STDMETHOD(ExtractClusterIDs)(THIS_ UINT *pClusterIDs) PURE; - // copies NumExtract PCA projection coefficients starting at StartPCA - // into pPCACoefficients - NumSamples*NumExtract floats copied + /* copies NumExtract PCA projection coefficients starting at StartPCA + * into pPCACoefficients - NumSamples*NumExtract floats copied + */ STDMETHOD(ExtractPCA)(THIS_ UINT StartPCA, UINT NumExtract, FLOAT *pPCACoefficients) PURE; - // copies NumPCA projection coefficients starting at StartPCA - // into pTexture - should be able to cope with signed formats + /* copies NumPCA projection coefficients starting at StartPCA + * into pTexture - should be able to cope with signed formats + */ STDMETHOD(ExtractTexture)(THIS_ UINT StartPCA, UINT NumpPCA, LPDIRECT3DTEXTURE9 pTexture) PURE; - // copies NumPCA projection coefficients into mesh pScene - // Usage is D3DDECLUSAGE where coefficients are to be stored - // UsageIndexStart is starting index + /* copies NumPCA projection coefficients into mesh pScene + * Usage is D3DDECLUSAGE where coefficients are to be stored + * UsageIndexStart is starting index + */ STDMETHOD(ExtractToMesh)(THIS_ UINT NumPCA, D3DDECLUSAGE Usage, UINT UsageIndexStart, LPD3DXMESH pScene) PURE; }; @@ -1749,123 +1777,137 @@ DECLARE_INTERFACE_(ID3DXPRTCompBuffer, IUnknown) #undef INTERFACE #define INTERFACE ID3DXTextureGutterHelper -// ID3DXTextureGutterHelper will build and manage -// "gutter" regions in a texture - this will allow for -// bi-linear interpolation to not have artifacts when rendering -// It generates a map (in texture space) where each texel -// is in one of 3 states: -// 0 Invalid - not used at all -// 1 Inside triangle -// 2 Gutter texel -// 4 represents a gutter texel that will be computed during PRT -// For each Inside/Gutter texel it stores the face it -// belongs to and barycentric coordinates for the 1st two -// vertices of that face. Gutter vertices are assigned to -// the closest edge in texture space. -// -// When used with PRT this requires a unique parameterization -// of the model - every texel must correspond to a single point -// on the surface of the model and vice versa +/* ID3DXTextureGutterHelper will build and manage + * "gutter" regions in a texture - this will allow for + * bi-linear interpolation to not have artifacts when rendering + * It generates a map (in texture space) where each texel + * is in one of 3 states: + * 0 Invalid - not used at all + * 1 Inside triangle + * 2 Gutter texel + * 4 represents a gutter texel that will be computed during PRT + * For each Inside/Gutter texel it stores the face it + * belongs to and barycentric coordinates for the 1st two + * vertices of that face. Gutter vertices are assigned to + * the closest edge in texture space. + * + * When used with PRT this requires a unique parameterization + * of the model - every texel must correspond to a single point + * on the surface of the model and vice versa + */ DECLARE_INTERFACE_(ID3DXTextureGutterHelper, IUnknown) { - // IUnknown + /* IUnknown */ STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; STDMETHOD_(ULONG, AddRef)(THIS) PURE; STDMETHOD_(ULONG, Release)(THIS) PURE; - // ID3DXTextureGutterHelper + /* ID3DXTextureGutterHelper */ - // dimensions of texture this is bound too + /* dimensions of texture this is bound too */ STDMETHOD_(UINT, GetWidth)(THIS) PURE; STDMETHOD_(UINT, GetHeight)(THIS) PURE; - // Applying gutters recomputes all of the gutter texels of class "2" - // based on texels of class "1" or "4" + /* Applying gutters recomputes all of the gutter texels of class "2" + * based on texels of class "1" or "4" + */ - // Applies gutters to a raw float buffer - each texel is NumCoeffs floats - // Width and Height must match GutterHelper + /* Applies gutters to a raw float buffer - each texel is NumCoeffs floats + * Width and Height must match GutterHelper + */ STDMETHOD(ApplyGuttersFloat)(THIS_ FLOAT *pDataIn, UINT NumCoeffs, UINT Width, UINT Height); - // Applies gutters to pTexture - // Dimensions must match GutterHelper + /* Applies gutters to pTexture + * Dimensions must match GutterHelper + */ STDMETHOD(ApplyGuttersTex)(THIS_ LPDIRECT3DTEXTURE9 pTexture); - // Applies gutters to a D3DXPRTBuffer - // Dimensions must match GutterHelper + /* Applies gutters to a D3DXPRTBuffer + * Dimensions must match GutterHelper + */ STDMETHOD(ApplyGuttersPRT)(THIS_ LPD3DXPRTBUFFER pBuffer); - // Resamples a texture from a mesh onto this gutterhelpers - // parameterization. It is assumed that the UV coordinates - // for this gutter helper are in TEXTURE 0 (usage/usage index) - // and the texture coordinates should all be within [0,1] for - // both sets. - // - // pTextureIn - texture represented using parameterization in pMeshIn - // pMeshIn - Mesh with texture coordinates that represent pTextureIn - // pTextureOut texture coordinates are assumed to be in - // TEXTURE 0 - // Usage - field in DECL for pMeshIn that stores texture coordinates - // for pTextureIn - // UsageIndex - which index for Usage above for pTextureIn - // pTextureOut- Resampled texture - // - // Usage would generally be D3DDECLUSAGE_TEXCOORD and UsageIndex other than zero + /* Resamples a texture from a mesh onto this gutterhelpers + * parameterization. It is assumed that the UV coordinates + * for this gutter helper are in TEXTURE 0 (usage/usage index) + * and the texture coordinates should all be within [0,1] for + * both sets. + * + * pTextureIn - texture represented using parameterization in pMeshIn + * pMeshIn - Mesh with texture coordinates that represent pTextureIn + * pTextureOut texture coordinates are assumed to be in + * TEXTURE 0 + * Usage - field in DECL for pMeshIn that stores texture coordinates + * for pTextureIn + * UsageIndex - which index for Usage above for pTextureIn + * pTextureOut- Resampled texture + * + * Usage would generally be D3DDECLUSAGE_TEXCOORD and UsageIndex other than zero + */ STDMETHOD(ResampleTex)(THIS_ LPDIRECT3DTEXTURE9 pTextureIn, LPD3DXMESH pMeshIn, D3DDECLUSAGE Usage, UINT UsageIndex, LPDIRECT3DTEXTURE9 pTextureOut); - // the routines below provide access to the data structures - // used by the Apply functions + /* the routines below provide access to the data structures + * used by the Apply functions - // face map is a UINT per texel that represents the - // face of the mesh that texel belongs too - - // only valid if same texel is valid in pGutterData - // pFaceData must be allocated by the user + * face map is a UINT per texel that represents the + * face of the mesh that texel belongs too - + * only valid if same texel is valid in pGutterData + * pFaceData must be allocated by the user + */ STDMETHOD(GetFaceMap)(THIS_ UINT *pFaceData) PURE; - // BaryMap is a D3DXVECTOR2 per texel - // the 1st two barycentric coordinates for the corresponding - // face (3rd weight is always 1-sum of first two) - // only valid if same texel is valid in pGutterData - // pBaryData must be allocated by the user + /* BaryMap is a D3DXVECTOR2 per texel + * the 1st two barycentric coordinates for the corresponding + * face (3rd weight is always 1-sum of first two) + * only valid if same texel is valid in pGutterData + * pBaryData must be allocated by the user + */ STDMETHOD(GetBaryMap)(THIS_ D3DXVECTOR2 *pBaryData) PURE; - // TexelMap is a D3DXVECTOR2 per texel that - // stores the location in pixel coordinates where the - // corresponding texel is mapped - // pTexelData must be allocated by the user + /* TexelMap is a D3DXVECTOR2 per texel that + * stores the location in pixel coordinates where the + * corresponding texel is mapped + * pTexelData must be allocated by the user + */ STDMETHOD(GetTexelMap)(THIS_ D3DXVECTOR2 *pTexelData) PURE; - // GutterMap is a BYTE per texel - // 0/1/2 for Invalid/Internal/Gutter texels - // 4 represents a gutter texel that will be computed - // during PRT - // pGutterData must be allocated by the user + /* GutterMap is a BYTE per texel + * 0/1/2 for Invalid/Internal/Gutter texels + * 4 represents a gutter texel that will be computed + * during PRT + * pGutterData must be allocated by the user + */ STDMETHOD(GetGutterMap)(THIS_ BYTE *pGutterData) PURE; - // face map is a UINT per texel that represents the - // face of the mesh that texel belongs too - - // only valid if same texel is valid in pGutterData + /* face map is a UINT per texel that represents the + * face of the mesh that texel belongs too - + * only valid if same texel is valid in pGutterData + */ STDMETHOD(SetFaceMap)(THIS_ UINT *pFaceData) PURE; - // BaryMap is a D3DXVECTOR2 per texel - // the 1st two barycentric coordinates for the corresponding - // face (3rd weight is always 1-sum of first two) - // only valid if same texel is valid in pGutterData + /* BaryMap is a D3DXVECTOR2 per texel + * the 1st two barycentric coordinates for the corresponding + * face (3rd weight is always 1-sum of first two) + * only valid if same texel is valid in pGutterData + */ STDMETHOD(SetBaryMap)(THIS_ D3DXVECTOR2 *pBaryData) PURE; - // TexelMap is a D3DXVECTOR2 per texel that - // stores the location in pixel coordinates where the - // corresponding texel is mapped + /* TexelMap is a D3DXVECTOR2 per texel that + * stores the location in pixel coordinates where the + * corresponding texel is mapped + */ STDMETHOD(SetTexelMap)(THIS_ D3DXVECTOR2 *pTexelData) PURE; - // GutterMap is a BYTE per texel - // 0/1/2 for Invalid/Internal/Gutter texels - // 4 represents a gutter texel that will be computed - // during PRT + /* GutterMap is a BYTE per texel + * 0/1/2 for Invalid/Internal/Gutter texels + * 4 represents a gutter texel that will be computed + * during PRT + */ STDMETHOD(SetGutterMap)(THIS_ BYTE *pGutterData) PURE; }; @@ -1876,191 +1918,205 @@ typedef interface ID3DXPRTEngine *LPD3DXPRTENGINE; #undef INTERFACE #define INTERFACE ID3DXPRTEngine -// ID3DXPRTEngine is used to compute a PRT simulation -// Use the following steps to compute PRT for SH -// (1) create an interface (which includes a scene) -// (2) call SetSamplingInfo -// (3) [optional] Set MeshMaterials/albedo's (required if doing bounces) -// (4) call ComputeDirectLightingSH -// (5) [optional] call ComputeBounce -// repeat step 5 for as many bounces as wanted. -// if you want to model subsurface scattering you -// need to call ComputeSS after direct lighting and -// each bounce. -// If you want to bake the albedo into the PRT signal, you -// must call MutliplyAlbedo, otherwise the user has to multiply -// the albedo themselves. Not multiplying the albedo allows you -// to model albedo variation at a finer scale then illumination, and -// can result in better compression results. -// Luminance values are computed from RGB values using the following -// formula: R * 0.2125 + G * 0.7154 + B * 0.0721 +/* ID3DXPRTEngine is used to compute a PRT simulation + * Use the following steps to compute PRT for SH + * (1) create an interface (which includes a scene) + * (2) call SetSamplingInfo + * (3) [optional] Set MeshMaterials/albedo's (required if doing bounces) + * (4) call ComputeDirectLightingSH + * (5) [optional] call ComputeBounce + * repeat step 5 for as many bounces as wanted. + * if you want to model subsurface scattering you + * need to call ComputeSS after direct lighting and + * each bounce. + * If you want to bake the albedo into the PRT signal, you + * must call MutliplyAlbedo, otherwise the user has to multiply + * the albedo themselves. Not multiplying the albedo allows you + * to model albedo variation at a finer scale then illumination, and + * can result in better compression results. + * Luminance values are computed from RGB values using the following + * formula: R * 0.2125 + G * 0.7154 + B * 0.0721 + */ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) { - // IUnknown + /* IUnknown */ STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; STDMETHOD_(ULONG, AddRef)(THIS) PURE; STDMETHOD_(ULONG, Release)(THIS) PURE; - // ID3DXPRTEngine + /* ID3DXPRTEngine - // This sets a material per attribute in the scene mesh and it is - // the only way to specify subsurface scattering parameters. if - // bSetAlbedo is FALSE, NumChannels must match the current - // configuration of the PRTEngine. If you intend to change - // NumChannels (through some other SetAlbedo function) it must - // happen before SetMeshMaterials is called. - // - // NumChannels 1 implies "grayscale" materials, set this to 3 to enable - // color bleeding effects - // bSetAlbedo sets albedo from material if TRUE - which clobbers per texel/vertex - // albedo that might have been set before. FALSE won't clobber. - // fLengthScale is used for subsurface scattering - scene is mapped into a 1mm unit cube - // and scaled by this amount + * This sets a material per attribute in the scene mesh and it is + * the only way to specify subsurface scattering parameters. if + * bSetAlbedo is FALSE, NumChannels must match the current + * configuration of the PRTEngine. If you intend to change + * NumChannels (through some other SetAlbedo function) it must + * happen before SetMeshMaterials is called. + * + * NumChannels 1 implies "grayscale" materials, set this to 3 to enable + * color bleeding effects + * bSetAlbedo sets albedo from material if TRUE - which clobbers per texel/vertex + * albedo that might have been set before. FALSE won't clobber. + * fLengthScale is used for subsurface scattering - scene is mapped into a 1mm unit cube + * and scaled by this amount + */ STDMETHOD(SetMeshMaterials)(THIS_ CONST D3DXSHMATERIAL **ppMaterials, UINT NumMeshes, UINT NumChannels, BOOL bSetAlbedo, FLOAT fLengthScale) PURE; - // setting albedo per-vertex or per-texel over rides the albedos stored per mesh - // but it does not over ride any other settings + /* setting albedo per-vertex or per-texel over rides the albedos stored per mesh + * but it does not over ride any other settings - // sets an albedo to be used per vertex - the albedo is represented as a float - // pDataIn input pointer (pointint to albedo of 1st sample) - // NumChannels 1 implies "grayscale" materials, set this to 3 to enable - // color bleeding effects - // Stride - stride in bytes to get to next samples albedo + * sets an albedo to be used per vertex - the albedo is represented as a float + * pDataIn input pointer (pointint to albedo of 1st sample) + * NumChannels 1 implies "grayscale" materials, set this to 3 to enable + * color bleeding effects + * Stride - stride in bytes to get to next samples albedo + */ STDMETHOD(SetPerVertexAlbedo)(THIS_ CONST VOID *pDataIn, UINT NumChannels, UINT Stride) PURE; - // represents the albedo per-texel instead of per-vertex (even if per-vertex PRT is used) - // pAlbedoTexture - texture that stores the albedo (dimension arbitrary) - // NumChannels 1 implies "grayscale" materials, set this to 3 to enable - // color bleeding effects - // pGH - optional gutter helper, otherwise one is constructed in computation routines and - // destroyed (if not attached to buffers) + /* represents the albedo per-texel instead of per-vertex (even if per-vertex PRT is used) + * pAlbedoTexture - texture that stores the albedo (dimension arbitrary) + * NumChannels 1 implies "grayscale" materials, set this to 3 to enable + * color bleeding effects + * pGH - optional gutter helper, otherwise one is constructed in computation routines and + * destroyed (if not attached to buffers) + */ STDMETHOD(SetPerTexelAlbedo)(THIS_ LPDIRECT3DTEXTURE9 pAlbedoTexture, UINT NumChannels, LPD3DXTEXTUREGUTTERHELPER pGH) PURE; - // gets the per-vertex albedo + /* gets the per-vertex albedo */ STDMETHOD(GetVertexAlbedo)(THIS_ D3DXCOLOR *pVertColors, UINT NumVerts) PURE; - // If pixel PRT is being computed normals default to ones that are interpolated - // from the vertex normals. This specifies a texture that stores an object - // space normal map instead (must use a texture format that can represent signed values) - // pNormalTexture - normal map, must be same dimensions as PRTBuffers, signed + /* If pixel PRT is being computed normals default to ones that are interpolated + * from the vertex normals. This specifies a texture that stores an object + * space normal map instead (must use a texture format that can represent signed values) + * pNormalTexture - normal map, must be same dimensions as PRTBuffers, signed + */ STDMETHOD(SetPerTexelNormal)(THIS_ LPDIRECT3DTEXTURE9 pNormalTexture) PURE; - // Copies per-vertex albedo from mesh - // pMesh - mesh that represents the scene. It must have the same - // properties as the mesh used to create the PRTEngine - // Usage - D3DDECLUSAGE to extract albedos from - // NumChannels 1 implies "grayscale" materials, set this to 3 to enable - // color bleeding effects + /* Copies per-vertex albedo from mesh + * pMesh - mesh that represents the scene. It must have the same + * properties as the mesh used to create the PRTEngine + * Usage - D3DDECLUSAGE to extract albedos from + * NumChannels 1 implies "grayscale" materials, set this to 3 to enable + * color bleeding effects + */ STDMETHOD(ExtractPerVertexAlbedo)(THIS_ LPD3DXMESH pMesh, D3DDECLUSAGE Usage, UINT NumChannels) PURE; - // Resamples the input buffer into the output buffer - // can be used to move between per-vertex and per-texel buffers. This can also be used - // to convert single channel buffers to 3-channel buffers and vice-versa. + /* Resamples the input buffer into the output buffer + * can be used to move between per-vertex and per-texel buffers. This can also be used + * to convert single channel buffers to 3-channel buffers and vice-versa. + */ STDMETHOD(ResampleBuffer)(THIS_ LPD3DXPRTBUFFER pBufferIn, LPD3DXPRTBUFFER pBufferOut) PURE; - // Returns the scene mesh - including modifications from adaptive spatial sampling - // The returned mesh only has positions, normals and texture coordinates (if defined) - // pD3DDevice - d3d device that will be used to allocate the mesh - // pFaceRemap - each face has a pointer back to the face on the original mesh that it comes from - // if the face hasn't been subdivided this will be an identity mapping - // pVertRemap - each vertex contains 3 vertices that this is a linear combination of - // pVertWeights - weights for each of above indices (sum to 1.0f) - // ppMesh - mesh that will be allocated and filled + /* Returns the scene mesh - including modifications from adaptive spatial sampling + * The returned mesh only has positions, normals and texture coordinates (if defined) + * pD3DDevice - d3d device that will be used to allocate the mesh + * pFaceRemap - each face has a pointer back to the face on the original mesh that it comes from + * if the face hasn't been subdivided this will be an identity mapping + * pVertRemap - each vertex contains 3 vertices that this is a linear combination of + * pVertWeights - weights for each of above indices (sum to 1.0f) + * ppMesh - mesh that will be allocated and filled + */ STDMETHOD(GetAdaptedMesh)(THIS_ LPDIRECT3DDEVICE9 pD3DDevice,UINT *pFaceRemap, UINT *pVertRemap, FLOAT *pfVertWeights, LPD3DXMESH *ppMesh) PURE; - // Number of vertices currently allocated (includes new vertices from adaptive sampling) + /* Number of vertices currently allocated (includes new vertices from adaptive sampling) */ STDMETHOD_(UINT, GetNumVerts)(THIS) PURE; - // Number of faces currently allocated (includes new faces) + /* Number of faces currently allocated (includes new faces) */ STDMETHOD_(UINT, GetNumFaces)(THIS) PURE; - // Sets the Minimum/Maximum intersection distances, this can be used to control - // maximum distance that objects can shadow/reflect light, and help with "bad" - // art that might have near features that you don't want to shadow. This does not - // apply for GPU simulations. - // fMin - minimum intersection distance, must be positive and less than fMax - // fMax - maximum intersection distance, if 0.0f use the previous value, otherwise - // must be strictly greater than fMin + /* Sets the Minimum/Maximum intersection distances, this can be used to control + * maximum distance that objects can shadow/reflect light, and help with "bad" + * art that might have near features that you don't want to shadow. This does not + * apply for GPU simulations. + * fMin - minimum intersection distance, must be positive and less than fMax + * fMax - maximum intersection distance, if 0.0f use the previous value, otherwise + * must be strictly greater than fMin + */ STDMETHOD(SetMinMaxIntersection)(THIS_ FLOAT fMin, FLOAT fMax) PURE; - // This will subdivide faces on a mesh so that adaptively simulations can - // use a more conservative threshold (it won't miss features.) - // MinEdgeLength - minimum edge length that will be generated, if 0.0f a - // reasonable default will be used - // MaxSubdiv - maximum level of subdivision, if 0 is specified a default - // value will be used (5) + /* This will subdivide faces on a mesh so that adaptively simulations can + * use a more conservative threshold (it won't miss features.) + * MinEdgeLength - minimum edge length that will be generated, if 0.0f a + * reasonable default will be used + * MaxSubdiv - maximum level of subdivision, if 0 is specified a default + * value will be used (5) + */ STDMETHOD(RobustMeshRefine)(THIS_ FLOAT MinEdgeLength, UINT MaxSubdiv) PURE; - // This sets to sampling information used by the simulator. Adaptive sampling - // parameters are currently ignored. - // NumRays - number of rays to shoot per sample - // UseSphere - if TRUE uses spherical samples, otherwise samples over - // the hemisphere. Should only be used with GPU and Vol computations - // UseCosine - if TRUE uses a cosine weighting - not used for Vol computations - // or if only the visiblity function is desired - // Adaptive - if TRUE adaptive sampling (angular) is used - // AdaptiveThresh - threshold used to terminate adaptive angular sampling - // ignored if adaptive sampling is not set + /* This sets to sampling information used by the simulator. Adaptive sampling + * parameters are currently ignored. + * NumRays - number of rays to shoot per sample + * UseSphere - if TRUE uses spherical samples, otherwise samples over + * the hemisphere. Should only be used with GPU and Vol computations + * UseCosine - if TRUE uses a cosine weighting - not used for Vol computations + * or if only the visiblity function is desired + * Adaptive - if TRUE adaptive sampling (angular) is used + * AdaptiveThresh - threshold used to terminate adaptive angular sampling + * ignored if adaptive sampling is not set + */ STDMETHOD(SetSamplingInfo)(THIS_ UINT NumRays, BOOL UseSphere, BOOL UseCosine, BOOL Adaptive, FLOAT AdaptiveThresh) PURE; - // Methods that compute the direct lighting contribution for objects - // always represente light using spherical harmonics (SH) - // the albedo is not multiplied by the signal - it just integrates - // incoming light. If NumChannels is not 1 the vector is replicated - // - // SHOrder - order of SH to use - // pDataOut - PRT buffer that is generated. Can be single channel + /* Methods that compute the direct lighting contribution for objects + * always represente light using spherical harmonics (SH) + * the albedo is not multiplied by the signal - it just integrates + * incoming light. If NumChannels is not 1 the vector is replicated + * + * SHOrder - order of SH to use + * pDataOut - PRT buffer that is generated. Can be single channel + */ STDMETHOD(ComputeDirectLightingSH)(THIS_ UINT SHOrder, LPD3DXPRTBUFFER pDataOut) PURE; - // Adaptive variant of above function. This will refine the mesh - // generating new vertices/faces to approximate the PRT signal - // more faithfully. - // SHOrder - order of SH to use - // AdaptiveThresh - threshold for adaptive subdivision (in PRT vector error) - // if value is less then 1e-6f, 1e-6f is specified - // MinEdgeLength - minimum edge length that will be generated - // if value is too small a fairly conservative model dependent value - // is used - // MaxSubdiv - maximum subdivision level, if 0 is specified it - // will default to 4 - // pDataOut - PRT buffer that is generated. Can be single channel. + /* Adaptive variant of above function. This will refine the mesh + * generating new vertices/faces to approximate the PRT signal + * more faithfully. + * SHOrder - order of SH to use + * AdaptiveThresh - threshold for adaptive subdivision (in PRT vector error) + * if value is less then 1e-6f, 1e-6f is specified + * MinEdgeLength - minimum edge length that will be generated + * if value is too small a fairly conservative model dependent value + * is used + * MaxSubdiv - maximum subdivision level, if 0 is specified it + * will default to 4 + * pDataOut - PRT buffer that is generated. Can be single channel. + */ STDMETHOD(ComputeDirectLightingSHAdaptive)(THIS_ UINT SHOrder, FLOAT AdaptiveThresh, FLOAT MinEdgeLength, UINT MaxSubdiv, LPD3DXPRTBUFFER pDataOut) PURE; - // Function that computes the direct lighting contribution for objects - // light is always represented using spherical harmonics (SH) - // This is done on the GPU and is much faster then using the CPU. - // The albedo is not multiplied by the signal - it just integrates - // incoming light. If NumChannels is not 1 the vector is replicated. - // ZBias/ZAngleBias are akin to parameters used with shadow zbuffers. - // A reasonable default for both values is 0.005, but the user should - // experiment (ZAngleBias can be zero, ZBias should not be.) - // Callbacks should not use the Direct3D9Device the simulator is using. - // SetSamplingInfo must be called with TRUE for UseSphere and - // FALSE for UseCosine before this method is called. - // - // pD3DDevice - device used to run GPU simulator - must support PS2.0 - // and FP render targets - // Flags - parameters for the GPU simulator, combination of one or more - // D3DXSHGPUSIMOPT flags. Only one SHADOWRES setting should be set and - // the defaults is 512 - // SHOrder - order of SH to use - // ZBias - bias in normal direction (for depth test) - // ZAngleBias - scaled by one minus cosine of angle with light (offset in depth) - // pDataOut - PRT buffer that is filled in. Can be single channel + /* Function that computes the direct lighting contribution for objects + * light is always represented using spherical harmonics (SH) + * This is done on the GPU and is much faster then using the CPU. + * The albedo is not multiplied by the signal - it just integrates + * incoming light. If NumChannels is not 1 the vector is replicated. + * ZBias/ZAngleBias are akin to parameters used with shadow zbuffers. + * A reasonable default for both values is 0.005, but the user should + * experiment (ZAngleBias can be zero, ZBias should not be.) + * Callbacks should not use the Direct3D9Device the simulator is using. + * SetSamplingInfo must be called with TRUE for UseSphere and + * FALSE for UseCosine before this method is called. + * + * pD3DDevice - device used to run GPU simulator - must support PS2.0 + * and FP render targets + * Flags - parameters for the GPU simulator, combination of one or more + * D3DXSHGPUSIMOPT flags. Only one SHADOWRES setting should be set and + * the defaults is 512 + * SHOrder - order of SH to use + * ZBias - bias in normal direction (for depth test) + * ZAngleBias - scaled by one minus cosine of angle with light (offset in depth) + * pDataOut - PRT buffer that is filled in. Can be single channel + */ STDMETHOD(ComputeDirectLightingSHGPU)(THIS_ LPDIRECT3DDEVICE9 pD3DDevice, UINT Flags, UINT SHOrder, @@ -2069,57 +2125,61 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) LPD3DXPRTBUFFER pDataOut) PURE; - // Functions that computes subsurface scattering (using material properties) - // Albedo is not multiplied by result. This only works for per-vertex data - // use ResampleBuffer to move per-vertex data into a texture and back. - // - // pDataIn - input data (previous bounce) - // pDataOut - result of subsurface scattering simulation - // pDataTotal - [optional] results can be summed into this buffer + /* Functions that computes subsurface scattering (using material properties) + * Albedo is not multiplied by result. This only works for per-vertex data + * use ResampleBuffer to move per-vertex data into a texture and back. + * + * pDataIn - input data (previous bounce) + * pDataOut - result of subsurface scattering simulation + * pDataTotal - [optional] results can be summed into this buffer + */ STDMETHOD(ComputeSS)(THIS_ LPD3DXPRTBUFFER pDataIn, LPD3DXPRTBUFFER pDataOut, LPD3DXPRTBUFFER pDataTotal) PURE; - // Adaptive version of ComputeSS. - // - // pDataIn - input data (previous bounce) - // AdaptiveThresh - threshold for adaptive subdivision (in PRT vector error) - // if value is less then 1e-6f, 1e-6f is specified - // MinEdgeLength - minimum edge length that will be generated - // if value is too small a fairly conservative model dependent value - // is used - // MaxSubdiv - maximum subdivision level, if 0 is specified it - // will default to 4 - // pDataOut - result of subsurface scattering simulation - // pDataTotal - [optional] results can be summed into this buffer + /* Adaptive version of ComputeSS. + * + * pDataIn - input data (previous bounce) + * AdaptiveThresh - threshold for adaptive subdivision (in PRT vector error) + * if value is less then 1e-6f, 1e-6f is specified + * MinEdgeLength - minimum edge length that will be generated + * if value is too small a fairly conservative model dependent value + * is used + * MaxSubdiv - maximum subdivision level, if 0 is specified it + * will default to 4 + * pDataOut - result of subsurface scattering simulation + * pDataTotal - [optional] results can be summed into this buffer + */ STDMETHOD(ComputeSSAdaptive)(THIS_ LPD3DXPRTBUFFER pDataIn, FLOAT AdaptiveThresh, FLOAT MinEdgeLength, UINT MaxSubdiv, LPD3DXPRTBUFFER pDataOut, LPD3DXPRTBUFFER pDataTotal) PURE; - // computes a single bounce of inter-reflected light - // works for SH based PRT or generic lighting - // Albedo is not multiplied by result - // - // pDataIn - previous bounces data - // pDataOut - PRT buffer that is generated - // pDataTotal - [optional] can be used to keep a running sum + /* computes a single bounce of inter-reflected light + * works for SH based PRT or generic lighting + * Albedo is not multiplied by result + * + * pDataIn - previous bounces data + * pDataOut - PRT buffer that is generated + * pDataTotal - [optional] can be used to keep a running sum + */ STDMETHOD(ComputeBounce)(THIS_ LPD3DXPRTBUFFER pDataIn, LPD3DXPRTBUFFER pDataOut, LPD3DXPRTBUFFER pDataTotal) PURE; - // Adaptive version of above function. - // - // pDataIn - previous bounces data, can be single channel - // AdaptiveThresh - threshold for adaptive subdivision (in PRT vector error) - // if value is less then 1e-6f, 1e-6f is specified - // MinEdgeLength - minimum edge length that will be generated - // if value is too small a fairly conservative model dependent value - // is used - // MaxSubdiv - maximum subdivision level, if 0 is specified it - // will default to 4 - // pDataOut - PRT buffer that is generated - // pDataTotal - [optional] can be used to keep a running sum + /* Adaptive version of above function. + * + * pDataIn - previous bounces data, can be single channel + * AdaptiveThresh - threshold for adaptive subdivision (in PRT vector error) + * if value is less then 1e-6f, 1e-6f is specified + * MinEdgeLength - minimum edge length that will be generated + * if value is too small a fairly conservative model dependent value + * is used + * MaxSubdiv - maximum subdivision level, if 0 is specified it + * will default to 4 + * pDataOut - PRT buffer that is generated + * pDataTotal - [optional] can be used to keep a running sum + */ STDMETHOD(ComputeBounceAdaptive)(THIS_ LPD3DXPRTBUFFER pDataIn, FLOAT AdaptiveThresh, FLOAT MinEdgeLength, @@ -2127,65 +2187,68 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) LPD3DXPRTBUFFER pDataOut, LPD3DXPRTBUFFER pDataTotal) PURE; - // Computes projection of distant SH radiance into a local SH radiance - // function. This models how direct lighting is attenuated by the - // scene and is a form of "neighborhood transfer." The result is - // a linear operator (matrix) at every sample point, if you multiply - // this matrix by the distant SH lighting coefficients you get an - // approximation of the local incident radiance function from - // direct lighting. These resulting lighting coefficients can - // than be projected into another basis or used with any rendering - // technique that uses spherical harmonics as input. - // SetSamplingInfo must be called with TRUE for UseSphere and - // FALSE for UseCosine before this method is called. - // Generates SHOrderIn*SHOrderIn*SHOrderOut*SHOrderOut scalars - // per channel at each sample location. - // - // SHOrderIn - Order of the SH representation of distant lighting - // SHOrderOut - Order of the SH representation of local lighting - // NumVolSamples - Number of sample locations - // pSampleLocs - position of sample locations - // pDataOut - PRT Buffer that will store output results + /* Computes projection of distant SH radiance into a local SH radiance + * function. This models how direct lighting is attenuated by the + * scene and is a form of "neighborhood transfer." The result is + * a linear operator (matrix) at every sample point, if you multiply + * this matrix by the distant SH lighting coefficients you get an + * approximation of the local incident radiance function from + * direct lighting. These resulting lighting coefficients can + * than be projected into another basis or used with any rendering + * technique that uses spherical harmonics as input. + * SetSamplingInfo must be called with TRUE for UseSphere and + * FALSE for UseCosine before this method is called. + * Generates SHOrderIn*SHOrderIn*SHOrderOut*SHOrderOut scalars + * per channel at each sample location. + * + * SHOrderIn - Order of the SH representation of distant lighting + * SHOrderOut - Order of the SH representation of local lighting + * NumVolSamples - Number of sample locations + * pSampleLocs - position of sample locations + * pDataOut - PRT Buffer that will store output results + */ STDMETHOD(ComputeVolumeSamplesDirectSH)(THIS_ UINT SHOrderIn, UINT SHOrderOut, UINT NumVolSamples, CONST D3DXVECTOR3 *pSampleLocs, LPD3DXPRTBUFFER pDataOut) PURE; - // At each sample location computes a linear operator (matrix) that maps - // the representation of source radiance (NumCoeffs in pSurfDataIn) - // into a local incident radiance function approximated with spherical - // harmonics. For example if a light map data is specified in pSurfDataIn - // the result is an SH representation of the flow of light at each sample - // point. If PRT data for an outdoor scene is used, each sample point - // contains a matrix that models how distant lighting bounces of the objects - // in the scene and arrives at the given sample point. Combined with - // ComputeVolumeSamplesDirectSH this gives the complete representation for - // how light arrives at each sample point parameterized by distant lighting. - // SetSamplingInfo must be called with TRUE for UseSphere and - // FALSE for UseCosine before this method is called. - // Generates pSurfDataIn->NumCoeffs()*SHOrder*SHOrder scalars - // per channel at each sample location. - // - // pSurfDataIn - previous bounce data - // SHOrder - order of SH to generate projection with - // NumVolSamples - Number of sample locations - // pSampleLocs - position of sample locations - // pDataOut - PRT Buffer that will store output results + /* At each sample location computes a linear operator (matrix) that maps + * the representation of source radiance (NumCoeffs in pSurfDataIn) + * into a local incident radiance function approximated with spherical + * harmonics. For example if a light map data is specified in pSurfDataIn + * the result is an SH representation of the flow of light at each sample + * point. If PRT data for an outdoor scene is used, each sample point + * contains a matrix that models how distant lighting bounces of the objects + * in the scene and arrives at the given sample point. Combined with + * ComputeVolumeSamplesDirectSH this gives the complete representation for + * how light arrives at each sample point parameterized by distant lighting. + * SetSamplingInfo must be called with TRUE for UseSphere and + * FALSE for UseCosine before this method is called. + * Generates pSurfDataIn->NumCoeffs()*SHOrder*SHOrder scalars + * per channel at each sample location. + * + * pSurfDataIn - previous bounce data + * SHOrder - order of SH to generate projection with + * NumVolSamples - Number of sample locations + * pSampleLocs - position of sample locations + * pDataOut - PRT Buffer that will store output results + */ STDMETHOD(ComputeVolumeSamples)(THIS_ LPD3DXPRTBUFFER pSurfDataIn, UINT SHOrder, UINT NumVolSamples, CONST D3DXVECTOR3 *pSampleLocs, LPD3DXPRTBUFFER pDataOut) PURE; - // Computes direct lighting (SH) for a point not on the mesh - // with a given normal - cannot use texture buffers. - // - // SHOrder - order of SH to use - // NumSamples - number of sample locations - // pSampleLocs - position for each sample - // pSampleNorms - normal for each sample - // pDataOut - PRT Buffer that will store output results + /* Computes direct lighting (SH) for a point not on the mesh + * with a given normal - cannot use texture buffers. + * + * SHOrder - order of SH to use + * NumSamples - number of sample locations + * pSampleLocs - position for each sample + * pSampleNorms - normal for each sample + * pDataOut - PRT Buffer that will store output results + */ STDMETHOD(ComputeSurfSamplesDirectSH)(THIS_ UINT SHOrder, UINT NumSamples, CONST D3DXVECTOR3 *pSampleLocs, @@ -2193,15 +2256,16 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) LPD3DXPRTBUFFER pDataOut) PURE; - // given the solution for PRT or light maps, computes transfer vector at arbitrary - // position/normal pairs in space - // - // pSurfDataIn - input data - // NumSamples - number of sample locations - // pSampleLocs - position for each sample - // pSampleNorms - normal for each sample - // pDataOut - PRT Buffer that will store output results - // pDataTotal - optional buffer to sum results into - can be NULL + /* given the solution for PRT or light maps, computes transfer vector at arbitrary + * position/normal pairs in space + * + * pSurfDataIn - input data + * NumSamples - number of sample locations + * pSampleLocs - position for each sample + * pSampleNorms - normal for each sample + * pDataOut - PRT Buffer that will store output results + * pDataTotal - optional buffer to sum results into - can be NULL + */ STDMETHOD(ComputeSurfSamplesBounce)(THIS_ LPD3DXPRTBUFFER pSurfDataIn, UINT NumSamples, CONST D3DXVECTOR3 *pSampleLocs, @@ -2209,112 +2273,120 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) LPD3DXPRTBUFFER pDataOut, LPD3DXPRTBUFFER pDataTotal) PURE; - // Frees temporary data structures that can be created for subsurface scattering - // this data is freed when the PRTComputeEngine is freed and is lazily created + /* Frees temporary data structures that can be created for subsurface scattering + * this data is freed when the PRTComputeEngine is freed and is lazily created + */ STDMETHOD(FreeSSData)(THIS) PURE; - // Frees temporary data structures that can be created for bounce simulations - // this data is freed when the PRTComputeEngine is freed and is lazily created + /* Frees temporary data structures that can be created for bounce simulations + * this data is freed when the PRTComputeEngine is freed and is lazily created + */ STDMETHOD(FreeBounceData)(THIS) PURE; - // This computes the Local Deformable PRT (LDPRT) coefficients relative to the - // per sample normals that minimize error in a least squares sense with respect - // to the input PRT data set. These coefficients can be used with skinned/transformed - // normals to model global effects with dynamic objects. Shading normals can - // optionally be solved for - these normals (along with the LDPRT coefficients) can - // more accurately represent the PRT signal. The coefficients are for zonal - // harmonics oriented in the normal/shading normal direction. - // - // pDataIn - SH PRT dataset that is input - // SHOrder - Order of SH to compute conv coefficients for - // pNormOut - Optional array of vectors (passed in) that will be filled with - // "shading normals", LDPRT coefficients are optimized for - // these normals. This array must be the same size as the number of - // samples in pDataIn - // pDataOut - Output buffer (SHOrder zonal harmonic coefficients per channel per sample) + /* This computes the Local Deformable PRT (LDPRT) coefficients relative to the + * per sample normals that minimize error in a least squares sense with respect + * to the input PRT data set. These coefficients can be used with skinned/transformed + * normals to model global effects with dynamic objects. Shading normals can + * optionally be solved for - these normals (along with the LDPRT coefficients) can + * more accurately represent the PRT signal. The coefficients are for zonal + * harmonics oriented in the normal/shading normal direction. + * + * pDataIn - SH PRT dataset that is input + * SHOrder - Order of SH to compute conv coefficients for + * pNormOut - Optional array of vectors (passed in) that will be filled with + * "shading normals", LDPRT coefficients are optimized for + * these normals. This array must be the same size as the number of + * samples in pDataIn + * pDataOut - Output buffer (SHOrder zonal harmonic coefficients per channel per sample) + */ STDMETHOD(ComputeLDPRTCoeffs)(THIS_ LPD3DXPRTBUFFER pDataIn, UINT SHOrder, D3DXVECTOR3 *pNormOut, LPD3DXPRTBUFFER pDataOut) PURE; - // scales all the samples associated with a given sub mesh - // can be useful when using subsurface scattering - // fScale - value to scale each vector in submesh by + /* scales all the samples associated with a given sub mesh + * can be useful when using subsurface scattering + * fScale - value to scale each vector in submesh by + */ STDMETHOD(ScaleMeshChunk)(THIS_ UINT uMeshChunk, FLOAT fScale, LPD3DXPRTBUFFER pDataOut) PURE; - // mutliplies each PRT vector by the albedo - can be used if you want to have the albedo - // burned into the dataset, often better not to do this. If this is not done the user - // must mutliply the albedo themselves when rendering - just multiply the albedo times - // the result of the PRT dot product. - // If pDataOut is a texture simulation result and there is an albedo texture it - // must be represented at the same resolution as the simulation buffer. You can use - // LoadSurfaceFromSurface and set a new albedo texture if this is an issue - but must - // be careful about how the gutters are handled. - // - // pDataOut - dataset that will get albedo pushed into it + /* mutliplies each PRT vector by the albedo - can be used if you want to have the albedo + * burned into the dataset, often better not to do this. If this is not done the user + * must mutliply the albedo themselves when rendering - just multiply the albedo times + * the result of the PRT dot product. + * If pDataOut is a texture simulation result and there is an albedo texture it + * must be represented at the same resolution as the simulation buffer. You can use + * LoadSurfaceFromSurface and set a new albedo texture if this is an issue - but must + * be careful about how the gutters are handled. + * + * pDataOut - dataset that will get albedo pushed into it + */ STDMETHOD(MultiplyAlbedo)(THIS_ LPD3DXPRTBUFFER pDataOut) PURE; - // Sets a pointer to an optional call back function that reports back to the - // user percentage done and gives them the option of quitting - // pCB - pointer to call back function, return S_OK for the simulation - // to continue - // Frequency - 1/Frequency is roughly the number of times the call back - // will be invoked - // lpUserContext - will be passed back to the users call back + /* Sets a pointer to an optional call back function that reports back to the + * user percentage done and gives them the option of quitting + * pCB - pointer to call back function, return S_OK for the simulation + * to continue + * Frequency - 1/Frequency is roughly the number of times the call back + * will be invoked + * lpUserContext - will be passed back to the users call back + */ STDMETHOD(SetCallBack)(THIS_ LPD3DXSHPRTSIMCB pCB, FLOAT Frequency, LPVOID lpUserContext) PURE; - // Returns TRUE if the ray intersects the mesh, FALSE if it does not. This function - // takes into account settings from SetMinMaxIntersection. If the closest intersection - // is not needed this function is more efficient compared to the ClosestRayIntersection - // method. - // pRayPos - origin of ray - // pRayDir - normalized ray direction (normalization required for SetMinMax to be meaningful) + /* Returns TRUE if the ray intersects the mesh, FALSE if it does not. This function + * takes into account settings from SetMinMaxIntersection. If the closest intersection + * is not needed this function is more efficient compared to the ClosestRayIntersection + * method. + * pRayPos - origin of ray + * pRayDir - normalized ray direction (normalization required for SetMinMax to be meaningful) + */ STDMETHOD_(BOOL, ShadowRayIntersects)(THIS_ CONST D3DXVECTOR3 *pRayPos, CONST D3DXVECTOR3 *pRayDir) PURE; - // Returns TRUE if the ray intersects the mesh, FALSE if it does not. If there is an - // intersection the closest face that was intersected and its first two barycentric coordinates - // are returned. This function takes into account settings from SetMinMaxIntersection. - // This is a slower function compared to ShadowRayIntersects and should only be used where - // needed. The third vertices barycentric coordinates will be 1 - pU - pV. - // pRayPos - origin of ray - // pRayDir - normalized ray direction (normalization required for SetMinMax to be meaningful) - // pFaceIndex - Closest face that intersects. This index is based on stacking the pBlockerMesh - // faces before the faces from pMesh - // pU - Barycentric coordinate for vertex 0 - // pV - Barycentric coordinate for vertex 1 - // pDist - Distance along ray where the intersection occured + /* Returns TRUE if the ray intersects the mesh, FALSE if it does not. If there is an + * intersection the closest face that was intersected and its first two barycentric coordinates + * are returned. This function takes into account settings from SetMinMaxIntersection. + * This is a slower function compared to ShadowRayIntersects and should only be used where + * needed. The third vertices barycentric coordinates will be 1 - pU - pV. + * pRayPos - origin of ray + * pRayDir - normalized ray direction (normalization required for SetMinMax to be meaningful) + * pFaceIndex - Closest face that intersects. This index is based on stacking the pBlockerMesh + * faces before the faces from pMesh + * pU - Barycentric coordinate for vertex 0 + * pV - Barycentric coordinate for vertex 1 + * pDist - Distance along ray where the intersection occured + */ STDMETHOD_(BOOL, ClosestRayIntersects)(THIS_ CONST D3DXVECTOR3 *pRayPos, CONST D3DXVECTOR3 *pRayDir, DWORD *pFaceIndex, FLOAT *pU, FLOAT *pV, FLOAT *pDist) PURE; }; -// API functions for creating interfaces +/* API functions for creating interfaces */ #ifdef __cplusplus extern "C" { -#endif //__cplusplus +#endif /* __cplusplus */ -//============================================================================ -// -// D3DXCreatePRTBuffer: -// -------------------- -// Generates a PRT Buffer that can be compressed or filled by a simulator -// This function should be used to create per-vertex or volume buffers. -// When buffers are created all values are initialized to zero. -// -// Parameters: -// NumSamples -// Number of sample locations represented -// NumCoeffs -// Number of coefficients per sample location (order^2 for SH) -// NumChannels -// Number of color channels to represent (1 or 3) -// ppBuffer -// Buffer that will be allocated -// -//============================================================================ +/* + * + * D3DXCreatePRTBuffer: + * -------------------- + * Generates a PRT Buffer that can be compressed or filled by a simulator + * This function should be used to create per-vertex or volume buffers. + * When buffers are created all values are initialized to zero. + * + * Parameters: + * NumSamples + * Number of sample locations represented + * NumCoeffs + * Number of coefficients per sample location (order^2 for SH) + * NumChannels + * Number of color channels to represent (1 or 3) + * ppBuffer + * Buffer that will be allocated + * + */ HRESULT WINAPI D3DXCreatePRTBuffer( @@ -2323,27 +2395,27 @@ HRESULT WINAPI UINT NumChannels, LPD3DXPRTBUFFER* ppBuffer); -//============================================================================ -// -// D3DXCreatePRTBufferTex: -// -------------------- -// Generates a PRT Buffer that can be compressed or filled by a simulator -// This function should be used to create per-pixel buffers. -// When buffers are created all values are initialized to zero. -// -// Parameters: -// Width -// Width of texture -// Height -// Height of texture -// NumCoeffs -// Number of coefficients per sample location (order^2 for SH) -// NumChannels -// Number of color channels to represent (1 or 3) -// ppBuffer -// Buffer that will be allocated -// -//============================================================================ +/* + * + * D3DXCreatePRTBufferTex: + * -------------------- + * Generates a PRT Buffer that can be compressed or filled by a simulator + * This function should be used to create per-pixel buffers. + * When buffers are created all values are initialized to zero. + * + * Parameters: + * Width + * Width of texture + * Height + * Height of texture + * NumCoeffs + * Number of coefficients per sample location (order^2 for SH) + * NumChannels + * Number of color channels to represent (1 or 3) + * ppBuffer + * Buffer that will be allocated + * + */ HRESULT WINAPI D3DXCreatePRTBufferTex( @@ -2353,19 +2425,19 @@ HRESULT WINAPI UINT NumChannels, LPD3DXPRTBUFFER* ppBuffer); -//============================================================================ -// -// D3DXLoadPRTBufferFromFile: -// -------------------- -// Loads a PRT buffer that has been saved to disk. -// -// Parameters: -// pFilename -// Name of the file to load -// ppBuffer -// Buffer that will be allocated -// -//============================================================================ +/* + * + * D3DXLoadPRTBufferFromFile: + * -------------------- + * Loads a PRT buffer that has been saved to disk. + * + * Parameters: + * pFilename + * Name of the file to load + * ppBuffer + * Buffer that will be allocated + * + */ HRESULT WINAPI D3DXLoadPRTBufferFromFileA( @@ -2384,19 +2456,19 @@ HRESULT WINAPI #endif -//============================================================================ -// -// D3DXSavePRTBufferToFile: -// -------------------- -// Saves a PRTBuffer to disk. -// -// Parameters: -// pFilename -// Name of the file to save -// pBuffer -// Buffer that will be saved -// -//============================================================================ +/* + * + * D3DXSavePRTBufferToFile: + * -------------------- + * Saves a PRTBuffer to disk. + * + * Parameters: + * pFilename + * Name of the file to save + * pBuffer + * Buffer that will be saved + * + */ HRESULT WINAPI D3DXSavePRTBufferToFileA( @@ -2415,19 +2487,19 @@ HRESULT WINAPI #endif -//============================================================================ -// -// D3DXLoadPRTCompBufferFromFile: -// -------------------- -// Loads a PRTComp buffer that has been saved to disk. -// -// Parameters: -// pFilename -// Name of the file to load -// ppBuffer -// Buffer that will be allocated -// -//============================================================================ +/* + * + * D3DXLoadPRTCompBufferFromFile: + * -------------------- + * Loads a PRTComp buffer that has been saved to disk. + * + * Parameters: + * pFilename + * Name of the file to load + * ppBuffer + * Buffer that will be allocated + * + */ HRESULT WINAPI D3DXLoadPRTCompBufferFromFileA( @@ -2445,19 +2517,19 @@ HRESULT WINAPI #define D3DXLoadPRTCompBufferFromFile D3DXLoadPRTCompBufferFromFileA #endif -//============================================================================ -// -// D3DXSavePRTCompBufferToFile: -// -------------------- -// Saves a PRTCompBuffer to disk. -// -// Parameters: -// pFilename -// Name of the file to save -// pBuffer -// Buffer that will be saved -// -//============================================================================ +/* + * + * D3DXSavePRTCompBufferToFile: + * -------------------- + * Saves a PRTCompBuffer to disk. + * + * Parameters: + * pFilename + * Name of the file to save + * pBuffer + * Buffer that will be saved + * + */ HRESULT WINAPI D3DXSavePRTCompBufferToFileA( @@ -2475,30 +2547,30 @@ HRESULT WINAPI #define D3DXSavePRTCompBufferToFile D3DXSavePRTCompBufferToFileA #endif -//============================================================================ -// -// D3DXCreatePRTCompBuffer: -// -------------------- -// Compresses a PRT buffer (vertex or texel) -// -// Parameters: -// D3DXSHCOMPRESSQUALITYTYPE -// Quality of compression - low is faster (computes PCA per voronoi cluster) -// high is slower but better quality (clusters based on distance to affine subspace) -// NumClusters -// Number of clusters to compute -// NumPCA -// Number of basis vectors to compute -// pCB -// Optional Callback function -// lpUserContext -// Optional user context -// pBufferIn -// Buffer that will be compressed -// ppBufferOut -// Compressed buffer that will be created -// -//============================================================================ +/* + * + * D3DXCreatePRTCompBuffer: + * -------------------- + * Compresses a PRT buffer (vertex or texel) + * + * Parameters: + * D3DXSHCOMPRESSQUALITYTYPE + * Quality of compression - low is faster (computes PCA per voronoi cluster) + * high is slower but better quality (clusters based on distance to affine subspace) + * NumClusters + * Number of clusters to compute + * NumPCA + * Number of basis vectors to compute + * pCB + * Optional Callback function + * lpUserContext + * Optional user context + * pBufferIn + * Buffer that will be compressed + * ppBufferOut + * Compressed buffer that will be created + * + */ HRESULT WINAPI @@ -2512,27 +2584,28 @@ HRESULT WINAPI LPD3DXPRTCOMPBUFFER *ppBufferOut ); -//============================================================================ -// -// D3DXCreateTextureGutterHelper: -// -------------------- -// Generates a "GutterHelper" for a given set of meshes and texture -// resolution -// -// Parameters: -// Width -// Width of texture -// Height -// Height of texture -// pMesh -// Mesh that represents the scene -// GutterSize -// Number of texels to over rasterize in texture space -// this should be at least 1.0 -// ppBuffer -// GutterHelper that will be created -// -//============================================================================ +/* + * + * D3DXCreateTextureGutterHelper: + * -------------------- + * Generates a "GutterHelper" for a given set of meshes and texture + * resolution + * + * Parameters: + * Width + * Width of texture + * Height + * Height of texture + * pMesh + * Mesh that represents the scene + * GutterSize + * Number of texels to over rasterize in texture space + * this should be at least 1.0 + * ppBuffer + * GutterHelper that will be created + * + * + */ HRESULT WINAPI @@ -2544,28 +2617,28 @@ HRESULT WINAPI LPD3DXTEXTUREGUTTERHELPER* ppBuffer); -//============================================================================ -// -// D3DXCreatePRTEngine: -// -------------------- -// Computes a PRTEngine which can efficiently generate PRT simulations -// of a scene -// -// Parameters: -// pMesh -// Mesh that represents the scene - must have an AttributeTable -// where vertices are in a unique attribute. -// pAdjacency -// Optional adjacency information -// ExtractUVs -// Set this to true if textures are going to be used for albedos -// or to store PRT vectors -// pBlockerMesh -// Optional mesh that just blocks the scene -// ppEngine -// PRTEngine that will be created -// -//============================================================================ +/* + * + * D3DXCreatePRTEngine: + * -------------------- + * Computes a PRTEngine which can efficiently generate PRT simulations + * of a scene + * + * Parameters: + * pMesh + * Mesh that represents the scene - must have an AttributeTable + * where vertices are in a unique attribute. + * pAdjacency + * Optional adjacency information + * ExtractUVs + * Set this to true if textures are going to be used for albedos + * or to store PRT vectors + * pBlockerMesh + * Optional mesh that just blocks the scene + * ppEngine + * PRTEngine that will be created + * + */ HRESULT WINAPI @@ -2576,38 +2649,38 @@ HRESULT WINAPI LPD3DXMESH pBlockerMesh, LPD3DXPRTENGINE* ppEngine); -//============================================================================ -// -// D3DXConcatenateMeshes: -// -------------------- -// Concatenates a group of meshes into one common mesh. This can optionaly transform -// each sub mesh or its texture coordinates. If no DECL is given it will -// generate a union of all of the DECL's of the sub meshes, promoting channels -// and types if neccesary. It will create an AttributeTable if possible, one can -// call OptimizeMesh with attribute sort and compacting enabled to ensure this. -// -// Parameters: -// ppMeshes -// Array of pointers to meshes that can store PRT vectors -// NumMeshes -// Number of meshes -// Options -// Passed through to D3DXCreateMesh -// pGeomXForms -// [optional] Each sub mesh is transformed by the corresponding -// matrix if this array is supplied -// pTextureXForms -// [optional] UV coordinates for each sub mesh are transformed -// by corresponding matrix if supplied -// pDecl -// [optional] Only information in this DECL is used when merging -// data -// pD3DDevice -// D3D device that is used to create the new mesh -// ppMeshOut -// Mesh that will be created -// -//============================================================================ +/* + * + * D3DXConcatenateMeshes: + * -------------------- + * Concatenates a group of meshes into one common mesh. This can optionaly transform + * each sub mesh or its texture coordinates. If no DECL is given it will + * generate a union of all of the DECL's of the sub meshes, promoting channels + * and types if neccesary. It will create an AttributeTable if possible, one can + * call OptimizeMesh with attribute sort and compacting enabled to ensure this. + * + * Parameters: + * ppMeshes + * Array of pointers to meshes that can store PRT vectors + * NumMeshes + * Number of meshes + * Options + * Passed through to D3DXCreateMesh + * pGeomXForms + * [optional] Each sub mesh is transformed by the corresponding + * matrix if this array is supplied + * pTextureXForms + * [optional] UV coordinates for each sub mesh are transformed + * by corresponding matrix if supplied + * pDecl + * [optional] Only information in this DECL is used when merging + * data + * pD3DDevice + * D3D device that is used to create the new mesh + * ppMeshOut + * Mesh that will be created + * + */ HRESULT WINAPI @@ -2621,31 +2694,31 @@ HRESULT WINAPI LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH *ppMeshOut); -//============================================================================ -// -// D3DXSHPRTCompSuperCluster: -// -------------------------- -// Used with compressed results of D3DXSHPRTSimulation. -// Generates "super clusters" - groups of clusters that can be drawn in -// the same draw call. A greedy algorithm that minimizes overdraw is used -// to group the clusters. -// -// Parameters: -// pClusterIDs -// NumVerts cluster ID's (extracted from a compressed buffer) -// pScene -// Mesh that represents composite scene passed to the simulator -// MaxNumClusters -// Maximum number of clusters allocated per super cluster -// NumClusters -// Number of clusters computed in the simulator -// pSuperClusterIDs -// Array of length NumClusters, contains index of super cluster -// that corresponding cluster was assigned to -// pNumSuperClusters -// Returns the number of super clusters allocated -// -//============================================================================ +/* + * + * D3DXSHPRTCompSuperCluster: + * -------------------------- + * Used with compressed results of D3DXSHPRTSimulation. + * Generates "super clusters" - groups of clusters that can be drawn in + * the same draw call. A greedy algorithm that minimizes overdraw is used + * to group the clusters. + * + * Parameters: + * pClusterIDs + * NumVerts cluster ID's (extracted from a compressed buffer) + * pScene + * Mesh that represents composite scene passed to the simulator + * MaxNumClusters + * Maximum number of clusters allocated per super cluster + * NumClusters + * Number of clusters computed in the simulator + * pSuperClusterIDs + * Array of length NumClusters, contains index of super cluster + * that corresponding cluster was assigned to + * pNumSuperClusters + * Returns the number of super clusters allocated + * + */ HRESULT WINAPI D3DXSHPRTCompSuperCluster( @@ -2656,60 +2729,60 @@ HRESULT WINAPI UINT *pSuperClusterIDs, UINT *pNumSuperClusters); -//============================================================================ -// -// D3DXSHPRTCompSplitMeshSC: -// ------------------------- -// Used with compressed results of the vertex version of the PRT simulator. -// After D3DXSHRTCompSuperCluster has been called this function can be used -// to split the mesh into a group of faces/vertices per super cluster. -// Each super cluster contains all of the faces that contain any vertex -// classified in one of its clusters. All of the vertices connected to this -// set of faces are also included with the returned array ppVertStatus -// indicating whether or not the vertex belongs to the supercluster. -// -// Parameters: -// pClusterIDs -// NumVerts cluster ID's (extracted from a compressed buffer) -// NumVertices -// Number of vertices in original mesh -// NumClusters -// Number of clusters (input parameter to compression) -// pSuperClusterIDs -// Array of size NumClusters that will contain super cluster ID's (from -// D3DXSHCompSuerCluster) -// NumSuperClusters -// Number of superclusters allocated in D3DXSHCompSuerCluster -// pInputIB -// Raw index buffer for mesh - format depends on bInputIBIs32Bit -// InputIBIs32Bit -// Indicates whether the input index buffer is 32-bit (otherwise 16-bit -// is assumed) -// NumFaces -// Number of faces in the original mesh (pInputIB is 3 times this length) -// ppIBData -// LPD3DXBUFFER holds raw index buffer that will contain the resulting split faces. -// Format determined by bIBIs32Bit. Allocated by function -// pIBDataLength -// Length of ppIBData, assigned in function -// OutputIBIs32Bit -// Indicates whether the output index buffer is to be 32-bit (otherwise -// 16-bit is assumed) -// ppFaceRemap -// LPD3DXBUFFER mapping of each face in ppIBData to original faces. Length is -// *pIBDataLength/3. Optional paramter, allocated in function -// ppVertData -// LPD3DXBUFFER contains new vertex data structure. Size of pVertDataLength -// pVertDataLength -// Number of new vertices in split mesh. Assigned in function -// pSCClusterList -// Array of length NumClusters which pSCData indexes into (Cluster* fields) -// for each SC, contains clusters sorted by super cluster -// pSCData -// Structure per super cluster - contains indices into ppIBData, -// pSCClusterList and ppVertData -// -//============================================================================ +/* + * + * D3DXSHPRTCompSplitMeshSC: + * ------------------------- + * Used with compressed results of the vertex version of the PRT simulator. + * After D3DXSHRTCompSuperCluster has been called this function can be used + * to split the mesh into a group of faces/vertices per super cluster. + * Each super cluster contains all of the faces that contain any vertex + * classified in one of its clusters. All of the vertices connected to this + * set of faces are also included with the returned array ppVertStatus + * indicating whether or not the vertex belongs to the supercluster. + * + * Parameters: + * pClusterIDs + * NumVerts cluster ID's (extracted from a compressed buffer) + * NumVertices + * Number of vertices in original mesh + * NumClusters + * Number of clusters (input parameter to compression) + * pSuperClusterIDs + * Array of size NumClusters that will contain super cluster ID's (from + * D3DXSHCompSuerCluster) + * NumSuperClusters + * Number of superclusters allocated in D3DXSHCompSuerCluster + * pInputIB + * Raw index buffer for mesh - format depends on bInputIBIs32Bit + * InputIBIs32Bit + * Indicates whether the input index buffer is 32-bit (otherwise 16-bit + * is assumed) + * NumFaces + * Number of faces in the original mesh (pInputIB is 3 times this length) + * ppIBData + * LPD3DXBUFFER holds raw index buffer that will contain the resulting split faces. + * Format determined by bIBIs32Bit. Allocated by function + * pIBDataLength + * Length of ppIBData, assigned in function + * OutputIBIs32Bit + * Indicates whether the output index buffer is to be 32-bit (otherwise + * 16-bit is assumed) + * ppFaceRemap + * LPD3DXBUFFER mapping of each face in ppIBData to original faces. Length is + * *pIBDataLength/3. Optional paramter, allocated in function + * ppVertData + * LPD3DXBUFFER contains new vertex data structure. Size of pVertDataLength + * pVertDataLength + * Number of new vertices in split mesh. Assigned in function + * pSCClusterList + * Array of length NumClusters which pSCData indexes into (Cluster* fields) + * for each SC, contains clusters sorted by super cluster + * pSCData + * Structure per super cluster - contains indices into ppIBData, + * pSCClusterList and ppVertData + * + */ HRESULT WINAPI D3DXSHPRTCompSplitMeshSC( @@ -2749,63 +2822,63 @@ DEFINE_GUID(DXFILEOBJ_XSkinMeshHeader, DEFINE_GUID(DXFILEOBJ_VertexDuplicationIndices, 0xb8d65549, 0xd7c9, 0x4995, 0x89, 0xcf, 0x53, 0xa9, 0xa8, 0xb0, 0x31, 0xe3); -// {A64C844A-E282-4756-8B80-250CDE04398C} +/* {A64C844A-E282-4756-8B80-250CDE04398C} */ DEFINE_GUID(DXFILEOBJ_FaceAdjacency, 0xa64c844a, 0xe282, 0x4756, 0x8b, 0x80, 0x25, 0xc, 0xde, 0x4, 0x39, 0x8c); -// {6F0D123B-BAD2-4167-A0D0-80224F25FABB} +/* {6F0D123B-BAD2-4167-A0D0-80224F25FABB} */ DEFINE_GUID(DXFILEOBJ_SkinWeights, 0x6f0d123b, 0xbad2, 0x4167, 0xa0, 0xd0, 0x80, 0x22, 0x4f, 0x25, 0xfa, 0xbb); -// {A3EB5D44-FC22-429d-9AFB-3221CB9719A6} +/* {A3EB5D44-FC22-429d-9AFB-3221CB9719A6} */ DEFINE_GUID(DXFILEOBJ_Patch, 0xa3eb5d44, 0xfc22, 0x429d, 0x9a, 0xfb, 0x32, 0x21, 0xcb, 0x97, 0x19, 0xa6); -// {D02C95CC-EDBA-4305-9B5D-1820D7704BBF} +/* {D02C95CC-EDBA-4305-9B5D-1820D7704BBF} */ DEFINE_GUID(DXFILEOBJ_PatchMesh, 0xd02c95cc, 0xedba, 0x4305, 0x9b, 0x5d, 0x18, 0x20, 0xd7, 0x70, 0x4b, 0xbf); -// {B9EC94E1-B9A6-4251-BA18-94893F02C0EA} +/* {B9EC94E1-B9A6-4251-BA18-94893F02C0EA} */ DEFINE_GUID(DXFILEOBJ_PatchMesh9, 0xb9ec94e1, 0xb9a6, 0x4251, 0xba, 0x18, 0x94, 0x89, 0x3f, 0x2, 0xc0, 0xea); -// {B6C3E656-EC8B-4b92-9B62-681659522947} +/* {B6C3E656-EC8B-4b92-9B62-681659522947} */ DEFINE_GUID(DXFILEOBJ_PMInfo, 0xb6c3e656, 0xec8b, 0x4b92, 0x9b, 0x62, 0x68, 0x16, 0x59, 0x52, 0x29, 0x47); -// {917E0427-C61E-4a14-9C64-AFE65F9E9844} +/* {917E0427-C61E-4a14-9C64-AFE65F9E9844} */ DEFINE_GUID(DXFILEOBJ_PMAttributeRange, 0x917e0427, 0xc61e, 0x4a14, 0x9c, 0x64, 0xaf, 0xe6, 0x5f, 0x9e, 0x98, 0x44); -// {574CCC14-F0B3-4333-822D-93E8A8A08E4C} +/* {574CCC14-F0B3-4333-822D-93E8A8A08E4C} */ DEFINE_GUID(DXFILEOBJ_PMVSplitRecord, 0x574ccc14, 0xf0b3, 0x4333, 0x82, 0x2d, 0x93, 0xe8, 0xa8, 0xa0, 0x8e, 0x4c); -// {B6E70A0E-8EF9-4e83-94AD-ECC8B0C04897} +/* {B6E70A0E-8EF9-4e83-94AD-ECC8B0C04897} */ DEFINE_GUID(DXFILEOBJ_FVFData, 0xb6e70a0e, 0x8ef9, 0x4e83, 0x94, 0xad, 0xec, 0xc8, 0xb0, 0xc0, 0x48, 0x97); -// {F752461C-1E23-48f6-B9F8-8350850F336F} +/* {F752461C-1E23-48f6-B9F8-8350850F336F} */ DEFINE_GUID(DXFILEOBJ_VertexElement, 0xf752461c, 0x1e23, 0x48f6, 0xb9, 0xf8, 0x83, 0x50, 0x85, 0xf, 0x33, 0x6f); -// {BF22E553-292C-4781-9FEA-62BD554BDD93} +/* {BF22E553-292C-4781-9FEA-62BD554BDD93} */ DEFINE_GUID(DXFILEOBJ_DeclData, 0xbf22e553, 0x292c, 0x4781, 0x9f, 0xea, 0x62, 0xbd, 0x55, 0x4b, 0xdd, 0x93); -// {F1CFE2B3-0DE3-4e28-AFA1-155A750A282D} +/* {F1CFE2B3-0DE3-4e28-AFA1-155A750A282D} */ DEFINE_GUID(DXFILEOBJ_EffectFloats, 0xf1cfe2b3, 0xde3, 0x4e28, 0xaf, 0xa1, 0x15, 0x5a, 0x75, 0xa, 0x28, 0x2d); -// {D55B097E-BDB6-4c52-B03D-6051C89D0E42} +/* {D55B097E-BDB6-4c52-B03D-6051C89D0E42} */ DEFINE_GUID(DXFILEOBJ_EffectString, 0xd55b097e, 0xbdb6, 0x4c52, 0xb0, 0x3d, 0x60, 0x51, 0xc8, 0x9d, 0xe, 0x42); -// {622C0ED0-956E-4da9-908A-2AF94F3CE716} +/* {622C0ED0-956E-4da9-908A-2AF94F3CE716} */ DEFINE_GUID(DXFILEOBJ_EffectDWord, 0x622c0ed0, 0x956e, 0x4da9, 0x90, 0x8a, 0x2a, 0xf9, 0x4f, 0x3c, 0xe7, 0x16); -// {3014B9A0-62F5-478c-9B86-E4AC9F4E418B} +/* {3014B9A0-62F5-478c-9B86-E4AC9F4E418B} */ DEFINE_GUID(DXFILEOBJ_EffectParamFloats, 0x3014b9a0, 0x62f5, 0x478c, 0x9b, 0x86, 0xe4, 0xac, 0x9f, 0x4e, 0x41, 0x8b); From 4dfda8743c4c3fa8fbfb92354b6ba7be432ca519 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 3 Feb 2018 16:55:24 +0100 Subject: [PATCH 043/232] (XMB) Prevent crash when no font driver loaded --- menu/drivers/xmb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index b72640d26d..b3b2154028 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -878,7 +878,7 @@ static void xmb_render_messagebox_internal( struct string_list *list = !string_is_empty(message) ? string_split(message, "\n") : NULL; - if (!list || !xmb) + if (!list || !xmb || !xmb->font) { if (list) string_list_free(list); From 43a6213b68f17fb7219d37a2877c9de62c4733c0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 3 Feb 2018 16:58:37 +0100 Subject: [PATCH 044/232] (MaterialUI) prevent crashes when font driver is NULL --- menu/drivers/materialui.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 2ddcd1b746..caf029d3d3 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -660,13 +660,16 @@ static unsigned mui_count_lines(const char *str) static void mui_compute_entries_box(mui_handle_t* mui, int width) { unsigned i; - size_t usable_width = width - (mui->margin * 2); - file_list_t *list = menu_entries_get_selection_buf_ptr(0); - float sum = 0; - size_t entries_end = menu_entries_get_size(); - float scale_factor = menu_display_get_dpi(); + size_t usable_width = width - (mui->margin * 2); + file_list_t *list = menu_entries_get_selection_buf_ptr(0); + float sum = 0; + size_t entries_end = menu_entries_get_size(); + float scale_factor = menu_display_get_dpi(); uintptr_t texture_switch2 = 0; + if (!mui->font) + return; + for (i = 0; i < entries_end; i++) { menu_entry_t entry; @@ -930,7 +933,8 @@ static void mui_render_label_value(mui_handle_t *mui, mui_node_t *node, word_wrap(sublabel_str, sublabel_str, (int)((usable_width - icon_margin) / mui->glyph_width2), false); - menu_display_draw_text(mui->font2, sublabel_str, + if (mui->font) + menu_display_draw_text(mui->font2, sublabel_str, mui->margin + (texture_switch2 ? mui->icon_size : 0), y + (scale_factor / 4) + mui->font->size, width, height, sublabel_color, TEXT_ALIGN_LEFT, 1.0f, false, 0); @@ -1597,7 +1601,8 @@ static void mui_frame(void *data, video_frame_info_t *video_info) strlcpy(title_buf, title_buf_msg_tmp, sizeof(title_buf)); } - menu_display_draw_text(mui->font, title_buf, + if (mui->font) + menu_display_draw_text(mui->font, title_buf, title_margin, header_height / 2 + mui->font->size / 3, width, height, font_header_color, TEXT_ALIGN_LEFT, 1.0f, false, 0); From 1464995fdcf7a3c25ca885c6768474ee8db740b9 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 3 Feb 2018 17:01:47 +0100 Subject: [PATCH 045/232] (D3D11) ability to compile without HAVE_SLANG --- gfx/drivers/d3d11.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gfx/drivers/d3d11.c b/gfx/drivers/d3d11.c index 11ffbd7175..2f74aef8aa 100644 --- a/gfx/drivers/d3d11.c +++ b/gfx/drivers/d3d11.c @@ -33,7 +33,9 @@ #include "../common/d3d11_common.h" #include "../common/dxgi_common.h" #include "../common/d3dcompiler_common.h" +#ifdef HAVE_SLANG #include "../drivers_shader/slang_process.h" +#endif static void d3d11_set_filtering(void* data, unsigned index, bool smooth) { @@ -138,6 +140,7 @@ static void d3d11_free_shader_preset(d3d11_video_t* d3d11) static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const char* path) { +#ifdef HAVE_SLANG unsigned i; d3d11_video_t* d3d11 = (d3d11_video_t*)data; @@ -347,6 +350,7 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const error: d3d11_free_shader_preset(d3d11); +#endif return false; } From 94022f0599d1b803f3ce775f1cf03c23939c02ff Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 3 Feb 2018 17:10:20 +0100 Subject: [PATCH 046/232] (MSVC 2013) Add HAVE_SLANG (Griffin) Add SPIRV-Cross/slang rules to Griffin --- gfx/drivers_shader/slang_process.cpp | 5 +- gfx/drivers_shader/slang_reflection.h | 2 +- griffin/griffin_cpp.cpp | 10 +- pkg/msvc/msvc-2013/RetroArch-msvc2013.vcxproj | 316 +++++++++--------- 4 files changed, 171 insertions(+), 162 deletions(-) diff --git a/gfx/drivers_shader/slang_process.cpp b/gfx/drivers_shader/slang_process.cpp index 66afaeb510..00383a9de6 100644 --- a/gfx/drivers_shader/slang_process.cpp +++ b/gfx/drivers_shader/slang_process.cpp @@ -4,13 +4,16 @@ #include #include -#include "verbosity.h" #include "glslang_util.h" #include "slang_preprocess.h" #include "slang_reflection.h" #include "slang_process.h" +#include "../../verbosity.h" + +#ifdef HAVE_SPIRV_CROSS using namespace spirv_cross; +#endif using namespace std; template diff --git a/gfx/drivers_shader/slang_reflection.h b/gfx/drivers_shader/slang_reflection.h index 40e96f37a5..472899a643 100644 --- a/gfx/drivers_shader/slang_reflection.h +++ b/gfx/drivers_shader/slang_reflection.h @@ -91,7 +91,7 @@ enum slang_constant_buffer #include #include #include -#include "spirv_cross.hpp" +#include struct slang_texture_semantic_meta { diff --git a/griffin/griffin_cpp.cpp b/griffin/griffin_cpp.cpp index e7df644b0b..8654f6ac22 100644 --- a/griffin/griffin_cpp.cpp +++ b/griffin/griffin_cpp.cpp @@ -121,10 +121,16 @@ VIDEO DRIVER #ifdef HAVE_VULKAN #include "../gfx/drivers_shader/shader_vulkan.cpp" #include "../gfx/drivers_shader/glslang_util.cpp" -#include "../gfx/drivers_shader/slang_reflection.cpp" -#include "../gfx/drivers_shader/slang_preprocess.cpp" +#endif + +#ifdef HAVE_SPIRV_CROSS #include "../deps/SPIRV-Cross/spirv_cross.cpp" #include "../deps/SPIRV-Cross/spirv_cfg.cpp" +#ifdef HAVE_SLANG +#include "../gfx/drivers_shader/slang_preprocess.cpp" +#include "../gfx/drivers_shader/slang_process.cpp" +#include "../gfx/drivers_shader/slang_reflection.cpp" +#endif #endif /*============================================================ diff --git a/pkg/msvc/msvc-2013/RetroArch-msvc2013.vcxproj b/pkg/msvc/msvc-2013/RetroArch-msvc2013.vcxproj index f5b96e9b81..72d2f6f79f 100644 --- a/pkg/msvc/msvc-2013/RetroArch-msvc2013.vcxproj +++ b/pkg/msvc/msvc-2013/RetroArch-msvc2013.vcxproj @@ -1,159 +1,159 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {C95DA947-1EAF-4D60-A06A-61EF1E8B8A95} - Win32Proj - RetroArchmsvc2013 - - - - Application - true - v120 - Unicode - - - Application - true - v120 - Unicode - - - Application - false - v120 - true - Unicode - - - Application - false - v120 - true - Unicode - - - - - - - - - - - - - - - - - - - true - - - true - - - false - - - false - - - - - - Level3 - Disabled - WIN32;HAVE_DYLIB;HAVE_DYNAMIC;HAVE_UPDATE_ASSETS;HAVE_MENU;HAVE_XMB;HAVE_RGUI;HAVE_MATERIALUI;_DEBUG;_WINDOWS;HAVE_XAUDIO;HAVE_DSOUND;HAVE_DINPUT;HAVE_D3D;HAVE_D3D9;HAVE_D3D11;HAVE_OPENGL;HAVE_GLSL;HAVE_THREADS;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_GRIFFIN;HAVE_RJPEG;HAVE_RPNG;HAVE_ZLIB;WANT_ZLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_OVERLAY;HAVE_7ZIP;HAVE_LIBRETRODB;HAVE_STB_FONT;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\gfx\include\dxsdk;$(SolutionDir)\..\..\gfx\include;$(SolutionDir)\..\..\libretro-common\include;$(SolutionDir)\..\..\deps;%(AdditionalIncludeDirectories) - - - Console - true - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;Iphlpapi.lib;%(AdditionalDependencies) - - - - - - - Level3 - Disabled - WIN32;HAVE_MENU;HAVE_XMB;HAVE_RGUI;HAVE_MATERIALUI;_DEBUG;_WINDOWS;HAVE_XAUDIO;HAVE_DSOUND;HAVE_DINPUT;HAVE_D3D;HAVE_D3D9;HAVE_OPENGL;HAVE_GLSL;HAVE_THREADS;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_GRIFFIN;HAVE_RJPEG;HAVE_RPNG;HAVE_ZLIB;WANT_ZLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_OVERLAY;HAVE_7ZIP;HAVE_LIBRETRODB;HAVE_STB_FONT;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\gfx\include\dxsdk;$(SolutionDir)\..\..\gfx\include;$(SolutionDir)\..\..\libretro-common\include;$(SolutionDir)\..\..\deps;%(AdditionalIncludeDirectories) - - - Windows - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;HAVE_DYLIB;HAVE_DYNAMIC;HAVE_UPDATE_ASSETS;HAVE_MENU;HAVE_XMB;HAVE_RGUI;HAVE_MATERIALUI;NDEBUG;_WINDOWS;HAVE_XAUDIO;HAVE_DSOUND;HAVE_DINPUT;HAVE_D3D;HAVE_D3D10;HAVE_D3D9;HAVE_D3D11;HAVE_OPENGL;HAVE_GLSL;HAVE_THREADS;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_GRIFFIN;HAVE_RJPEG;HAVE_RPNG;HAVE_ZLIB;WANT_ZLIB;HAVE_NETWORKING;HAVE_COMMAND;HAVE_NETWORK_CMD;HAVE_STDIN_CMD;HAVE_OVERLAY;HAVE_7ZIP;HAVE_LIBRETRODB;HAVE_STB_FONT;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\gfx\include\dxsdk;$(SolutionDir)\..\..\gfx\include;$(SolutionDir)\..\..\libretro-common\include;$(SolutionDir)\..\..\deps;%(AdditionalIncludeDirectories) - - - Console - true - true - true - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;Iphlpapi.lib;%(AdditionalDependencies) - - - - - Level3 - - - MaxSpeed - true - true - WIN32;HAVE_MENU;HAVE_XMB;HAVE_RGUI;HAVE_MATERIALUI;NDEBUG;_WINDOWS;HAVE_XAUDIO;HAVE_DSOUND;HAVE_DINPUT;HAVE_D3D;HAVE_D3D9;HAVE_OPENGL;HAVE_GLSL;HAVE_THREADS;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_GRIFFIN;HAVE_RJPEG;HAVE_RPNG;HAVE_ZLIB;WANT_ZLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_OVERLAY;HAVE_7ZIP;HAVE_LIBRETRODB;HAVE_STB_FONT;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\gfx\include\dxsdk;$(SolutionDir)\..\..\gfx\include;$(SolutionDir)\..\..\libretro-common\include;$(SolutionDir)\..\..\deps;%(AdditionalIncludeDirectories) - - - Windows - true - true - true - - - - - CompileAsC - CompileAsC - CompileAsC - CompileAsC - - - - - - + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {C95DA947-1EAF-4D60-A06A-61EF1E8B8A95} + Win32Proj + RetroArchmsvc2013 + + + + Application + true + v120 + Unicode + + + Application + true + v120 + Unicode + + + Application + false + v120 + true + Unicode + + + Application + false + v120 + true + Unicode + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + + + Level3 + Disabled + WIN32;HAVE_DYLIB;HAVE_DYNAMIC;HAVE_UPDATE_ASSETS;HAVE_MENU;HAVE_SLANG;HAVE_XMB;HAVE_RGUI;HAVE_MATERIALUI;_DEBUG;_WINDOWS;HAVE_XAUDIO;HAVE_DSOUND;HAVE_DINPUT;HAVE_D3D;HAVE_D3D9;HAVE_D3D11;HAVE_OPENGL;HAVE_GLSL;HAVE_THREADS;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_GRIFFIN;HAVE_RJPEG;HAVE_RPNG;HAVE_ZLIB;WANT_ZLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_OVERLAY;HAVE_7ZIP;HAVE_LIBRETRODB;HAVE_STB_FONT;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\gfx\include\dxsdk;$(SolutionDir)\..\..\gfx\include;$(SolutionDir)\..\..\libretro-common\include;$(SolutionDir)\..\..\deps;%(AdditionalIncludeDirectories) + + + Console + true + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;Iphlpapi.lib;%(AdditionalDependencies) + + + + + + + Level3 + Disabled + WIN32;HAVE_MENU;HAVE_SLANG;HAVE_UPDATE_ASSETS;HAVE_XMB;HAVE_RGUI;HAVE_MATERIALUI;_DEBUG;_WINDOWS;HAVE_XAUDIO;HAVE_DSOUND;HAVE_DINPUT;HAVE_D3D;HAVE_D3D9;HAVE_OPENGL;HAVE_GLSL;HAVE_THREADS;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_GRIFFIN;HAVE_RJPEG;HAVE_RPNG;HAVE_ZLIB;WANT_ZLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_OVERLAY;HAVE_7ZIP;HAVE_LIBRETRODB;HAVE_STB_FONT;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\gfx\include\dxsdk;$(SolutionDir)\..\..\gfx\include;$(SolutionDir)\..\..\libretro-common\include;$(SolutionDir)\..\..\deps;%(AdditionalIncludeDirectories) + + + Windows + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;HAVE_DYLIB;HAVE_DYNAMIC;HAVE_UPDATE_ASSETS;HAVE_SLANG;HAVE_MENU;HAVE_XMB;HAVE_RGUI;HAVE_MATERIALUI;NDEBUG;_WINDOWS;HAVE_XAUDIO;HAVE_DSOUND;HAVE_DINPUT;HAVE_D3D;HAVE_D3D10;HAVE_D3D9;HAVE_D3D11;HAVE_OPENGL;HAVE_GLSL;HAVE_THREADS;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_GRIFFIN;HAVE_RJPEG;HAVE_RPNG;HAVE_ZLIB;WANT_ZLIB;HAVE_NETWORKING;HAVE_COMMAND;HAVE_NETWORK_CMD;HAVE_STDIN_CMD;HAVE_OVERLAY;HAVE_7ZIP;HAVE_LIBRETRODB;HAVE_STB_FONT;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\gfx\include\dxsdk;$(SolutionDir)\..\..\gfx\include;$(SolutionDir)\..\..\libretro-common\include;$(SolutionDir)\..\..\deps;%(AdditionalIncludeDirectories) + + + Console + true + true + true + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;Iphlpapi.lib;%(AdditionalDependencies) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;HAVE_MENU;HAVE_SLANG;HAVE_UPDATE_ASSETS;HAVE_XMB;HAVE_RGUI;HAVE_MATERIALUI;NDEBUG;_WINDOWS;HAVE_XAUDIO;HAVE_DSOUND;HAVE_DINPUT;HAVE_D3D;HAVE_D3D9;HAVE_OPENGL;HAVE_GLSL;HAVE_THREADS;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_GRIFFIN;HAVE_RJPEG;HAVE_RPNG;HAVE_ZLIB;WANT_ZLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_OVERLAY;HAVE_7ZIP;HAVE_LIBRETRODB;HAVE_STB_FONT;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\gfx\include\dxsdk;$(SolutionDir)\..\..\gfx\include;$(SolutionDir)\..\..\libretro-common\include;$(SolutionDir)\..\..\deps;%(AdditionalIncludeDirectories) + + + Windows + true + true + true + + + + + CompileAsC + CompileAsC + CompileAsC + CompileAsC + + + + + + \ No newline at end of file From df632814e6994adbedc7bcfc6cbcd25fa5101561 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 3 Feb 2018 17:13:36 +0100 Subject: [PATCH 047/232] Add appropriate HAVE_SPIRV_CROSS ifdefs --- Makefile.common | 1 + gfx/drivers/d3d11.c | 2 +- gfx/video_shader_parse.c | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile.common b/Makefile.common index 62039e6871..1d93deb1c6 100644 --- a/Makefile.common +++ b/Makefile.common @@ -1355,6 +1355,7 @@ ifeq ($(HAVE_GLSLANG), 1) endif ifeq ($(HAVE_SPIRV_CROSS), 1) + DEFINES += -DHAVE_SPIRV_CROSS INCLUDE_DIRS += -I$(DEPS_DIR)/SPIRV-Cross OBJ += $(DEPS_DIR)/SPIRV-Cross/spirv_cross.o OBJ += $(DEPS_DIR)/SPIRV-Cross/spirv_cfg.o diff --git a/gfx/drivers/d3d11.c b/gfx/drivers/d3d11.c index 2f74aef8aa..8499cfa444 100644 --- a/gfx/drivers/d3d11.c +++ b/gfx/drivers/d3d11.c @@ -140,7 +140,7 @@ static void d3d11_free_shader_preset(d3d11_video_t* d3d11) static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const char* path) { -#ifdef HAVE_SLANG +#if defined(HAVE_SLANG) && defined(HAVE_SPIRV_CROSS) unsigned i; d3d11_video_t* d3d11 = (d3d11_video_t*)data; diff --git a/gfx/video_shader_parse.c b/gfx/video_shader_parse.c index 92daf520ae..3a2d6da9fd 100644 --- a/gfx/video_shader_parse.c +++ b/gfx/video_shader_parse.c @@ -35,7 +35,7 @@ #include "../frontend/frontend_driver.h" #include "video_shader_parse.h" -#ifdef HAVE_SLANG +#if defined(HAVE_SLANG) && defined(HAVE_SPIRV_CROSS) #include "drivers_shader/slang_preprocess.h" #endif @@ -538,7 +538,7 @@ bool video_shader_resolve_parameters(config_file_t *conf, continue; } -#ifdef HAVE_SLANG +#if defined(HAVE_SLANG) && defined(HAVE_SPIRV_CROSS) /* First try to use the more robust slang implementation to support #includes. */ /* FIXME: The check for slang can be removed if it's sufficiently tested for * GLSL/Cg as well, it should be the same implementation. */ From 311de8138e4e94b19ae9d4b83b7e5021f5a5a63f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 3 Feb 2018 17:20:23 +0100 Subject: [PATCH 048/232] (Griffin) shader_vulkan - Uniquely name set_unique_map to avoid collision --- gfx/drivers_shader/shader_vulkan.cpp | 16 ++++++++-------- pkg/msvc/msvc-2017/RetroArch-msvc2017.vcxproj | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/gfx/drivers_shader/shader_vulkan.cpp b/gfx/drivers_shader/shader_vulkan.cpp index d7d86258e9..de864eaf61 100644 --- a/gfx/drivers_shader/shader_vulkan.cpp +++ b/gfx/drivers_shader/shader_vulkan.cpp @@ -864,7 +864,7 @@ bool vulkan_filter_chain::init_feedback() } template -static bool set_unique_map(unordered_map &m, const string &name, const P &p) +static bool vk_shader_set_unique_map(unordered_map &m, const string &name, const P &p) { auto itr = m.find(name); if (itr != end(m)) @@ -892,19 +892,19 @@ bool vulkan_filter_chain::init_alias() unsigned i = &pass - passes.data(); - if (!set_unique_map(common.texture_semantic_map, name, + if (!vk_shader_set_unique_map(common.texture_semantic_map, name, slang_texture_semantic_map{ SLANG_TEXTURE_SEMANTIC_PASS_OUTPUT, i })) return false; - if (!set_unique_map(common.texture_semantic_uniform_map, name + "Size", + if (!vk_shader_set_unique_map(common.texture_semantic_uniform_map, name + "Size", slang_texture_semantic_map{ SLANG_TEXTURE_SEMANTIC_PASS_OUTPUT, i })) return false; - if (!set_unique_map(common.texture_semantic_map, name + "Feedback", + if (!vk_shader_set_unique_map(common.texture_semantic_map, name + "Feedback", slang_texture_semantic_map{ SLANG_TEXTURE_SEMANTIC_PASS_FEEDBACK, i })) return false; - if (!set_unique_map(common.texture_semantic_uniform_map, name + "FeedbackSize", + if (!vk_shader_set_unique_map(common.texture_semantic_uniform_map, name + "FeedbackSize", slang_texture_semantic_map{ SLANG_TEXTURE_SEMANTIC_PASS_FEEDBACK, i })) return false; } @@ -912,11 +912,11 @@ bool vulkan_filter_chain::init_alias() for (auto &lut : common.luts) { unsigned i = &lut - common.luts.data(); - if (!set_unique_map(common.texture_semantic_map, lut->get_id(), + if (!vk_shader_set_unique_map(common.texture_semantic_map, lut->get_id(), slang_texture_semantic_map{ SLANG_TEXTURE_SEMANTIC_USER, i })) return false; - if (!set_unique_map(common.texture_semantic_uniform_map, lut->get_id() + "Size", + if (!vk_shader_set_unique_map(common.texture_semantic_uniform_map, lut->get_id() + "Size", slang_texture_semantic_map{ SLANG_TEXTURE_SEMANTIC_USER, i })) return false; } @@ -1757,7 +1757,7 @@ bool Pass::build() for (auto ¶m : parameters) { - if (!set_unique_map(semantic_map, param.id, + if (!vk_shader_set_unique_map(semantic_map, param.id, slang_semantic_map{ SLANG_SEMANTIC_FLOAT_PARAMETER, j })) return false; j++; diff --git a/pkg/msvc/msvc-2017/RetroArch-msvc2017.vcxproj b/pkg/msvc/msvc-2017/RetroArch-msvc2017.vcxproj index 36a5be3021..adfbdfd729 100644 --- a/pkg/msvc/msvc-2017/RetroArch-msvc2017.vcxproj +++ b/pkg/msvc/msvc-2017/RetroArch-msvc2017.vcxproj @@ -191,7 +191,7 @@ Level3 Disabled - WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_SLANG;HAVE_SPIRV_CROSS;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) MultiThreadedDebug CompileAsCpp @@ -210,7 +210,7 @@ Level3 Disabled - WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;HAVE_CG;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_FBO;WANT_ZLIB;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_SLANG;HAVE_SPIRV_CROSS;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;HAVE_CG;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_FBO;WANT_ZLIB;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) MultiThreadedDebug CompileAsCpp @@ -230,7 +230,7 @@ Level3 Disabled - WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_SLANG;HAVE_SPIRV_CROSS;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) MultiThreadedDebug CompileAsCpp @@ -249,7 +249,7 @@ Level3 Disabled - WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;HAVE_CG;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_FBO;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;WANT_ZLIB;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_SLANG;HAVE_SPIRV_CROSS;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;HAVE_CG;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_FBO;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;WANT_ZLIB;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) MultiThreadedDebug CompileAsCpp @@ -271,7 +271,7 @@ MaxSpeed true true - WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_MENU;HAVE_RGUI;HAVE_GL_SYNC;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_SLANG;HAVE_SPIRV_CROSS;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_MENU;HAVE_RGUI;HAVE_GL_SYNC;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) MultiThreaded CompileAsCpp @@ -295,7 +295,7 @@ MaxSpeed true true - WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;HAVE_CG;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;WANT_ZLIB;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_MENU;HAVE_RGUI;HAVE_GL_SYNC;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_SLANG;HAVE_SPIRV_CROSS;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;HAVE_CG;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;WANT_ZLIB;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_MENU;HAVE_RGUI;HAVE_GL_SYNC;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) MultiThreaded CompileAsCpp @@ -320,7 +320,7 @@ MaxSpeed true true - WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_SLANG;HAVE_SPIRV_CROSS;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) MultiThreaded CompileAsCpp @@ -344,7 +344,7 @@ MaxSpeed true true - WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;HAVE_CG;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;WANT_ZLIB;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_SLANG;HAVE_SPIRV_CROSS;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;HAVE_CG;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;WANT_ZLIB;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) MultiThreaded CompileAsCpp From 76d07cd6a79f2c3e9df065f1ad64715efdb8a097 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Sat, 3 Feb 2018 17:22:47 +0100 Subject: [PATCH 049/232] (slang) slang_process: simplify data mappings. --- gfx/drivers/d3d11.c | 84 +++++++++++---------------- gfx/drivers_shader/slang_process.cpp | 58 +++++++++--------- gfx/drivers_shader/slang_process.h | 40 ++++--------- gfx/drivers_shader/slang_reflection.h | 4 +- 4 files changed, 75 insertions(+), 111 deletions(-) diff --git a/gfx/drivers/d3d11.c b/gfx/drivers/d3d11.c index 2f74aef8aa..29873b3585 100644 --- a/gfx/drivers/d3d11.c +++ b/gfx/drivers/d3d11.c @@ -176,61 +176,47 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const for (i = 0; i < d3d11->shader_preset->passes; source = &d3d11->pass[i++].rt) { unsigned j; - texture_map_t texture_map - [3 + GFX_MAX_FRAME_HISTORY + 1 + GFX_MAX_SHADERS * 2 + GFX_MAX_TEXTURES + 1] = { - SL_TEXTURE_MAP( - SLANG_TEXTURE_SEMANTIC_ORIGINAL, d3d11->frame.texture[0].view, - d3d11->pass[i].sampler, d3d11->frame.texture[0].size_data), - SL_TEXTURE_MAP( - SLANG_TEXTURE_SEMANTIC_SOURCE, source->view, d3d11->pass[i].sampler, - source->size_data), - }; - texture_map_t* ptr = texture_map; + /* clang-format off */ + semantics_map_t semantics_map = { + { + /* Original */ + { &d3d11->frame.texture[0].view, 0, + &d3d11->frame.texture[0].size_data, 0, + &d3d11->pass[i].sampler, 0 }, - while (ptr->texture_data) - ptr++; + /* Source */ + { &source->view, 0, + &source->size_data, 0, + &d3d11->pass[i].sampler, 0 }, - for (j = 0; j < GFX_MAX_FRAME_HISTORY + 1; j++) - { - *ptr = (texture_map_t)SL_TEXTURE_MAP_ARRAY( - SLANG_TEXTURE_SEMANTIC_ORIGINAL_HISTORY, j, d3d11->frame.texture[j].view, - d3d11->pass[i].sampler, d3d11->frame.texture[j].size_data); - ptr++; - } + /* OriginalHistory */ + { &d3d11->frame.texture[0].view, sizeof(*d3d11->frame.texture), + &d3d11->frame.texture[0].size_data, sizeof(*d3d11->frame.texture), + &d3d11->pass[i].sampler, 0 }, - for (j = 0; j < i; j++) - { - *ptr = (texture_map_t)SL_TEXTURE_MAP_ARRAY( - SLANG_TEXTURE_SEMANTIC_PASS_OUTPUT, j, d3d11->pass[j].rt.view, - d3d11->pass[i].sampler, d3d11->pass[j].rt.size_data); - ptr++; - } + /* PassOutput */ + { &d3d11->pass[0].rt.view, sizeof(*d3d11->pass), + &d3d11->pass[0].rt.size_data, sizeof(*d3d11->pass), + &d3d11->pass[i].sampler, 0 }, - for (j = 0; j < GFX_MAX_SHADERS; j++) - { - *ptr = (texture_map_t)SL_TEXTURE_MAP_ARRAY( - SLANG_TEXTURE_SEMANTIC_PASS_FEEDBACK, j, d3d11->pass[j].feedback.view, - d3d11->pass[i].sampler, d3d11->pass[j].rt.size_data); - ptr++; - } + /* PassFeedback */ + { &d3d11->pass[0].feedback.view, sizeof(*d3d11->pass), + &d3d11->pass[0].feedback.size_data, sizeof(*d3d11->pass), + &d3d11->pass[i].sampler, 0 }, - for (j = 0; j < d3d11->shader_preset->luts; j++) - { - *ptr = (texture_map_t)SL_TEXTURE_MAP_ARRAY( - SLANG_TEXTURE_SEMANTIC_USER, j, d3d11->luts[j].view, d3d11->luts[j].sampler, - d3d11->luts[j].size_data); - ptr++; - } - - uniform_map_t uniform_map[] = { - SL_UNIFORM_MAP(SLANG_SEMANTIC_MVP, d3d11->mvp), - SL_UNIFORM_MAP(SLANG_SEMANTIC_OUTPUT, d3d11->pass[i].rt.size_data), - SL_UNIFORM_MAP(SLANG_SEMANTIC_FRAME_COUNT, d3d11->pass[i].frame_count), - SL_UNIFORM_MAP(SLANG_SEMANTIC_FINAL_VIEWPORT, d3d11->frame.output_size), - { 0 } + /* User */ + { &d3d11->luts[0].view, sizeof(*d3d11->luts), + &d3d11->luts[0].size_data, sizeof(*d3d11->luts), + &d3d11->luts[0].sampler, sizeof(*d3d11->luts) }, + }, + { + &d3d11->mvp, /* MVP */ + &d3d11->pass[i].rt.size_data, /* OutputSize */ + &d3d11->frame.output_size, /* FinalViewportSize */ + &d3d11->pass[i].frame_count, /* FrameCount */ + } }; - - semantics_map_t semantics_map = { texture_map, uniform_map }; + /* clang-format on */ if (!slang_process( d3d11->shader_preset, i, RARCH_SHADER_HLSL, 50, &semantics_map, diff --git a/gfx/drivers_shader/slang_process.cpp b/gfx/drivers_shader/slang_process.cpp index 66afaeb510..7335f8d38e 100644 --- a/gfx/drivers_shader/slang_process.cpp +++ b/gfx/drivers_shader/slang_process.cpp @@ -88,7 +88,7 @@ static bool slang_process_reflection( const ShaderResources& ps_resources, video_shader* shader_info, unsigned pass_number, - const semantics_map_t* semantics_map, + const semantics_map_t* map, pass_semantics_t* out) { unordered_map texture_semantic_map; @@ -168,17 +168,15 @@ static bool slang_process_reflection( vector uniforms[SLANG_CBUFFER_MAX]; vector textures; - uniform_map_t* uniform_map = semantics_map->uniform_map; - while (uniform_map->data) + for (int semantic = 0; semantic < SLANG_NUM_BASE_SEMANTICS; semantic++) { - slang_semantic_meta& src = sl_reflection.semantics[uniform_map->semantic]; - + slang_semantic_meta& src = sl_reflection.semantics[semantic]; if (src.push_constant || src.uniform) { - uniform_sem_t uniform = { uniform_map->data, uniform_map->id, + uniform_sem_t uniform = { map->uniforms[semantic], src.num_components * (unsigned)sizeof(float) }; - string uniform_id = get_semantic_name(sl_reflection, uniform_map->semantic, 0); + string uniform_id = get_semantic_name(sl_reflection, (slang_semantic)semantic, 0); strncpy(uniform.id, uniform_id.c_str(), sizeof(uniform.id)); if (src.push_constant) @@ -192,8 +190,6 @@ static bool slang_process_reflection( uniforms[SLANG_CBUFFER_UBO].push_back(uniform); } } - - uniform_map++; } for (int i = 0; i < sl_reflection.semantic_float_parameters.size(); i++) @@ -202,8 +198,7 @@ static bool slang_process_reflection( if (src.push_constant || src.uniform) { - uniform_sem_t uniform = { &shader_info->parameters[i].current, - "shader_info->parameter[i].current", sizeof(float) }; + uniform_sem_t uniform = { &shader_info->parameters[i].current, sizeof(float) }; string uniform_id = get_semantic_name(sl_reflection, SLANG_SEMANTIC_FLOAT_PARAMETER, i); strncpy(uniform.id, uniform_id.c_str(), sizeof(uniform.id)); @@ -221,42 +216,43 @@ static bool slang_process_reflection( } } - texture_map_t* texture_map = semantics_map->texture_map; - - while (texture_map->texture_data) + for (int semantic = 0; semantic < SLANG_NUM_TEXTURE_SEMANTICS; semantic++) { - if (texture_map->index < sl_reflection.semantic_textures[texture_map->semantic].size()) + for (int index = 0; index < sl_reflection.semantic_textures[semantic].size(); index++) { - slang_texture_semantic_meta& src = - sl_reflection.semantic_textures[texture_map->semantic][texture_map->index]; + slang_texture_semantic_meta& src = sl_reflection.semantic_textures[semantic][index]; if (src.stage_mask) { - texture_sem_t texture = { texture_map->texture_data, texture_map->texture_id, - texture_map->sampler_data, texture_map->sampler_id }; - texture.stage_mask = src.stage_mask; - texture.binding = src.binding; - string id = get_semantic_name(sl_reflection, texture_map->semantic, texture_map->index); + texture_sem_t texture = { + (void*)((uintptr_t)map->textures[semantic].image + index * map->textures[semantic].image_stride), + (void*)((uintptr_t)map->textures[semantic].sampler + index * map->textures[semantic].sampler_stride), + }; + texture.stage_mask = src.stage_mask; + texture.binding = src.binding; + string id = get_semantic_name(sl_reflection, (slang_texture_semantic)semantic, index); strncpy(texture.id, id.c_str(), sizeof(texture.id)); textures.push_back(texture); - if (texture_map->semantic == SLANG_TEXTURE_SEMANTIC_PASS_FEEDBACK) - shader_info->pass[texture_map->index].feedback = true; + if (semantic == SLANG_TEXTURE_SEMANTIC_PASS_FEEDBACK) + shader_info->pass[index].feedback = true; - if (texture_map->semantic == SLANG_TEXTURE_SEMANTIC_ORIGINAL_HISTORY && - shader_info->history_size < texture_map->index) - shader_info->history_size = texture_map->index; + if (semantic == SLANG_TEXTURE_SEMANTIC_ORIGINAL_HISTORY && + shader_info->history_size < index) + shader_info->history_size = index; } if (src.push_constant || src.uniform) { - uniform_sem_t uniform = { texture_map->size_data, texture_map->size_id, - 4 * sizeof(float) }; + uniform_sem_t uniform = { + (void*)((uintptr_t)map->textures[semantic].size + index * map->textures[semantic].size_stride), + 4 * sizeof(float) + }; string uniform_id = - get_size_semantic_name(sl_reflection, texture_map->semantic, texture_map->index); + get_size_semantic_name(sl_reflection, (slang_texture_semantic)semantic, index); strncpy(uniform.id, uniform_id.c_str(), sizeof(uniform.id)); @@ -272,8 +268,6 @@ static bool slang_process_reflection( } } } - - texture_map++; } out->texture_count = textures.size(); diff --git a/gfx/drivers_shader/slang_process.h b/gfx/drivers_shader/slang_process.h index f6ec33a908..c93bcf7e55 100644 --- a/gfx/drivers_shader/slang_process.h +++ b/gfx/drivers_shader/slang_process.h @@ -26,45 +26,29 @@ typedef struct { - enum slang_semantic semantic; - void* data; - const char* id; -} uniform_map_t; + void* ptr; + size_t stride; +} data_map_t; typedef struct { - enum slang_texture_semantic semantic; - int index; - void* texture_data; - const char* texture_id; - void* sampler_data; - const char* sampler_id; - void* size_data; - const char* size_id; + void* image; + size_t image_stride; + void* size; + size_t size_stride; + void* sampler; + size_t sampler_stride; } texture_map_t; -#define SL_UNIFORM_MAP(sem, data) \ - { \ - sem, &data, #data \ - } - -#define SL_TEXTURE_MAP_ARRAY(sem, index, tex, sampl, size) \ - { \ - sem, index, &tex, #tex, &sampl, #sampl, &size, #size \ - } - -#define SL_TEXTURE_MAP(sem, tex, sampl, size) SL_TEXTURE_MAP_ARRAY(sem, 0, tex, sampl, size) - typedef struct { - texture_map_t* texture_map; - uniform_map_t* uniform_map; + texture_map_t textures[SLANG_NUM_TEXTURE_SEMANTICS]; + void* uniforms[SLANG_NUM_BASE_SEMANTICS]; } semantics_map_t; typedef struct { void* data; - const char* data_id; unsigned size; unsigned offset; char id[64]; @@ -73,9 +57,7 @@ typedef struct typedef struct { void* texture_data; - const char* texture_id; void* sampler_data; - const char* sampler_id; unsigned stage_mask; unsigned binding; char id[64]; diff --git a/gfx/drivers_shader/slang_reflection.h b/gfx/drivers_shader/slang_reflection.h index 40e96f37a5..e922a7622f 100644 --- a/gfx/drivers_shader/slang_reflection.h +++ b/gfx/drivers_shader/slang_reflection.h @@ -62,7 +62,9 @@ enum slang_semantic // vec4, viewport size of final pass SLANG_SEMANTIC_FINAL_VIEWPORT = 2, // uint, frame count with modulo - SLANG_SEMANTIC_FRAME_COUNT = 3, + SLANG_SEMANTIC_FRAME_COUNT = 3, + SLANG_NUM_BASE_SEMANTICS, + // float, user defined parameter, arrayed SLANG_SEMANTIC_FLOAT_PARAMETER = 4, From c60f706f1ed4529520f43f4cd7094662a8eeed18 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 3 Feb 2018 20:50:31 +0100 Subject: [PATCH 050/232] (MSVC 2013) Update solution Griffin - add better ifdefs --- gfx/drivers_shader/slang_process.cpp | 8 ++-- griffin/griffin_cpp.cpp | 4 +- pkg/msvc/msvc-2013/RetroArch-msvc2013.vcxproj | 16 +++---- .../RetroArch-msvc2013.vcxproj.filters | 48 +++++++++---------- 4 files changed, 37 insertions(+), 39 deletions(-) diff --git a/gfx/drivers_shader/slang_process.cpp b/gfx/drivers_shader/slang_process.cpp index 961b249445..612dfb3a31 100644 --- a/gfx/drivers_shader/slang_process.cpp +++ b/gfx/drivers_shader/slang_process.cpp @@ -142,10 +142,10 @@ static bool slang_process_reflection( for (unsigned i = 0; i < shader_info->num_parameters; i++) { - if (!set_unique_map( - uniform_semantic_map, shader_info->parameters[i].id, - { SLANG_SEMANTIC_FLOAT_PARAMETER, i })) - return false; + if (!set_unique_map( + uniform_semantic_map, shader_info->parameters[i].id, + slang_semantic_map{ SLANG_SEMANTIC_FLOAT_PARAMETER, i })) + return false; } slang_reflection sl_reflection; diff --git a/griffin/griffin_cpp.cpp b/griffin/griffin_cpp.cpp index 8654f6ac22..a630e9d6ab 100644 --- a/griffin/griffin_cpp.cpp +++ b/griffin/griffin_cpp.cpp @@ -27,7 +27,6 @@ #endif #ifdef WANT_GLSLANG -#ifdef HAVE_VULKAN #include "../deps/glslang/glslang.cpp" #if 0 #include "../deps/glslang/glslang_tab.cpp" @@ -90,7 +89,6 @@ #include "../deps/glslang/glslang/glslang/OSDependent/Unix/ossource.cpp" #endif #endif -#endif /*============================================================ MENU @@ -120,13 +118,13 @@ VIDEO DRIVER ============================================================ */ #ifdef HAVE_VULKAN #include "../gfx/drivers_shader/shader_vulkan.cpp" -#include "../gfx/drivers_shader/glslang_util.cpp" #endif #ifdef HAVE_SPIRV_CROSS #include "../deps/SPIRV-Cross/spirv_cross.cpp" #include "../deps/SPIRV-Cross/spirv_cfg.cpp" #ifdef HAVE_SLANG +#include "../gfx/drivers_shader/glslang_util.cpp" #include "../gfx/drivers_shader/slang_preprocess.cpp" #include "../gfx/drivers_shader/slang_process.cpp" #include "../gfx/drivers_shader/slang_reflection.cpp" diff --git a/pkg/msvc/msvc-2013/RetroArch-msvc2013.vcxproj b/pkg/msvc/msvc-2013/RetroArch-msvc2013.vcxproj index 72d2f6f79f..581fb094fa 100644 --- a/pkg/msvc/msvc-2013/RetroArch-msvc2013.vcxproj +++ b/pkg/msvc/msvc-2013/RetroArch-msvc2013.vcxproj @@ -84,8 +84,8 @@ Level3 Disabled - WIN32;HAVE_DYLIB;HAVE_DYNAMIC;HAVE_UPDATE_ASSETS;HAVE_MENU;HAVE_SLANG;HAVE_XMB;HAVE_RGUI;HAVE_MATERIALUI;_DEBUG;_WINDOWS;HAVE_XAUDIO;HAVE_DSOUND;HAVE_DINPUT;HAVE_D3D;HAVE_D3D9;HAVE_D3D11;HAVE_OPENGL;HAVE_GLSL;HAVE_THREADS;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_GRIFFIN;HAVE_RJPEG;HAVE_RPNG;HAVE_ZLIB;WANT_ZLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_OVERLAY;HAVE_7ZIP;HAVE_LIBRETRODB;HAVE_STB_FONT;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\gfx\include\dxsdk;$(SolutionDir)\..\..\gfx\include;$(SolutionDir)\..\..\libretro-common\include;$(SolutionDir)\..\..\deps;%(AdditionalIncludeDirectories) + WIN32;HAVE_SPIRV_CROSS;HAVE_DYLIB;HAVE_DYNAMIC;HAVE_UPDATE_ASSETS;HAVE_MENU;HAVE_SLANG;HAVE_XMB;HAVE_RGUI;HAVE_MATERIALUI;_DEBUG;_WINDOWS;HAVE_XAUDIO;HAVE_DSOUND;HAVE_DINPUT;HAVE_D3D;HAVE_D3D9;HAVE_D3D11;HAVE_OPENGL;HAVE_GLSL;HAVE_THREADS;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_GRIFFIN;HAVE_RJPEG;HAVE_RPNG;HAVE_ZLIB;WANT_ZLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_OVERLAY;HAVE_7ZIP;HAVE_LIBRETRODB;HAVE_STB_FONT;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\gfx\include\dxsdk;$(SolutionDir)\..\..\gfx\include;$(SolutionDir)\..\..\libretro-common\include;$(SolutionDir)\..\..\deps;$(SolutionDir)\..\..\deps\SPIRV-Cross;%(AdditionalIncludeDirectories) Console @@ -99,8 +99,8 @@ Level3 Disabled - WIN32;HAVE_MENU;HAVE_SLANG;HAVE_UPDATE_ASSETS;HAVE_XMB;HAVE_RGUI;HAVE_MATERIALUI;_DEBUG;_WINDOWS;HAVE_XAUDIO;HAVE_DSOUND;HAVE_DINPUT;HAVE_D3D;HAVE_D3D9;HAVE_OPENGL;HAVE_GLSL;HAVE_THREADS;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_GRIFFIN;HAVE_RJPEG;HAVE_RPNG;HAVE_ZLIB;WANT_ZLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_OVERLAY;HAVE_7ZIP;HAVE_LIBRETRODB;HAVE_STB_FONT;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\gfx\include\dxsdk;$(SolutionDir)\..\..\gfx\include;$(SolutionDir)\..\..\libretro-common\include;$(SolutionDir)\..\..\deps;%(AdditionalIncludeDirectories) + WIN32;HAVE_SPIRV_CROSS;HAVE_MENU;HAVE_SLANG;HAVE_UPDATE_ASSETS;HAVE_XMB;HAVE_RGUI;HAVE_MATERIALUI;_DEBUG;_WINDOWS;HAVE_XAUDIO;HAVE_DSOUND;HAVE_DINPUT;HAVE_D3D;HAVE_D3D9;HAVE_OPENGL;HAVE_GLSL;HAVE_THREADS;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_GRIFFIN;HAVE_RJPEG;HAVE_RPNG;HAVE_ZLIB;WANT_ZLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_OVERLAY;HAVE_7ZIP;HAVE_LIBRETRODB;HAVE_STB_FONT;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\gfx\include\dxsdk;$(SolutionDir)\..\..\gfx\include;$(SolutionDir)\..\..\libretro-common\include;$(SolutionDir)\..\..\deps;$(SolutionDir)\..\..\deps\SPIRV-Cross;%(AdditionalIncludeDirectories) Windows @@ -115,8 +115,8 @@ MaxSpeed true true - WIN32;HAVE_DYLIB;HAVE_DYNAMIC;HAVE_UPDATE_ASSETS;HAVE_SLANG;HAVE_MENU;HAVE_XMB;HAVE_RGUI;HAVE_MATERIALUI;NDEBUG;_WINDOWS;HAVE_XAUDIO;HAVE_DSOUND;HAVE_DINPUT;HAVE_D3D;HAVE_D3D10;HAVE_D3D9;HAVE_D3D11;HAVE_OPENGL;HAVE_GLSL;HAVE_THREADS;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_GRIFFIN;HAVE_RJPEG;HAVE_RPNG;HAVE_ZLIB;WANT_ZLIB;HAVE_NETWORKING;HAVE_COMMAND;HAVE_NETWORK_CMD;HAVE_STDIN_CMD;HAVE_OVERLAY;HAVE_7ZIP;HAVE_LIBRETRODB;HAVE_STB_FONT;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\gfx\include\dxsdk;$(SolutionDir)\..\..\gfx\include;$(SolutionDir)\..\..\libretro-common\include;$(SolutionDir)\..\..\deps;%(AdditionalIncludeDirectories) + WIN32;HAVE_SPIRV_CROSS;HAVE_DYLIB;HAVE_DYNAMIC;HAVE_UPDATE_ASSETS;HAVE_SLANG;HAVE_MENU;HAVE_XMB;HAVE_RGUI;HAVE_MATERIALUI;NDEBUG;_WINDOWS;HAVE_XAUDIO;HAVE_DSOUND;HAVE_DINPUT;HAVE_D3D;HAVE_D3D10;HAVE_D3D9;HAVE_D3D11;HAVE_OPENGL;HAVE_GLSL;HAVE_THREADS;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_GRIFFIN;HAVE_RJPEG;HAVE_RPNG;HAVE_ZLIB;WANT_ZLIB;HAVE_NETWORKING;HAVE_COMMAND;HAVE_NETWORK_CMD;HAVE_STDIN_CMD;HAVE_OVERLAY;HAVE_7ZIP;HAVE_LIBRETRODB;HAVE_STB_FONT;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\gfx\include\dxsdk;$(SolutionDir)\..\..\gfx\include;$(SolutionDir)\..\..\libretro-common\include;$(SolutionDir)\..\..\deps;$(SolutionDir)\..\..\deps\SPIRV-Cross;%(AdditionalIncludeDirectories) Console @@ -134,8 +134,8 @@ MaxSpeed true true - WIN32;HAVE_MENU;HAVE_SLANG;HAVE_UPDATE_ASSETS;HAVE_XMB;HAVE_RGUI;HAVE_MATERIALUI;NDEBUG;_WINDOWS;HAVE_XAUDIO;HAVE_DSOUND;HAVE_DINPUT;HAVE_D3D;HAVE_D3D9;HAVE_OPENGL;HAVE_GLSL;HAVE_THREADS;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_GRIFFIN;HAVE_RJPEG;HAVE_RPNG;HAVE_ZLIB;WANT_ZLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_OVERLAY;HAVE_7ZIP;HAVE_LIBRETRODB;HAVE_STB_FONT;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\gfx\include\dxsdk;$(SolutionDir)\..\..\gfx\include;$(SolutionDir)\..\..\libretro-common\include;$(SolutionDir)\..\..\deps;%(AdditionalIncludeDirectories) + WIN32;HAVE_SPIRV_CROSS;HAVE_MENU;HAVE_SLANG;HAVE_UPDATE_ASSETS;HAVE_XMB;HAVE_RGUI;HAVE_MATERIALUI;NDEBUG;_WINDOWS;HAVE_XAUDIO;HAVE_DSOUND;HAVE_DINPUT;HAVE_D3D;HAVE_D3D9;HAVE_OPENGL;HAVE_GLSL;HAVE_THREADS;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_GRIFFIN;HAVE_RJPEG;HAVE_RPNG;HAVE_ZLIB;WANT_ZLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_OVERLAY;HAVE_7ZIP;HAVE_LIBRETRODB;HAVE_STB_FONT;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\gfx\include\dxsdk;$(SolutionDir)\..\..\gfx\include;$(SolutionDir)\..\..\libretro-common\include;$(SolutionDir)\..\..\deps;$(SolutionDir)\..\..\deps\SPIRV-Cross;%(AdditionalIncludeDirectories) Windows diff --git a/pkg/msvc/msvc-2013/RetroArch-msvc2013.vcxproj.filters b/pkg/msvc/msvc-2013/RetroArch-msvc2013.vcxproj.filters index f7cb6c4498..a6f6d9197c 100644 --- a/pkg/msvc/msvc-2013/RetroArch-msvc2013.vcxproj.filters +++ b/pkg/msvc/msvc-2013/RetroArch-msvc2013.vcxproj.filters @@ -1,25 +1,25 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - Source Files - - + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + \ No newline at end of file From 80dbef47cb27a0fd489b64bb0b9654daa1ba8946 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 3 Feb 2018 21:36:42 +0100 Subject: [PATCH 051/232] (Android) Add HAVE_SLANG/HAVE_SPIRV_CROSS --- pkg/android/phoenix/jni/Android.mk | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/android/phoenix/jni/Android.mk b/pkg/android/phoenix/jni/Android.mk index 06a600f6c2..a0642ec2f4 100644 --- a/pkg/android/phoenix/jni/Android.mk +++ b/pkg/android/phoenix/jni/Android.mk @@ -71,7 +71,7 @@ DEFINES += -DRARCH_MOBILE -DHAVE_GRIFFIN -DHAVE_STB_VORBIS -DHAVE_LANGEXTRA -DAN DEFINES += -DWANT_IFADDRS ifeq ($(HAVE_VULKAN),1) -DEFINES += -DHAVE_VULKAN +DEFINES += -DHAVE_VULKAN -DHAVE_SLANG -DHAVE_SPIRV_CROSS endif DEFINES += -DHAVE_7ZIP DEFINES += -DHAVE_CHEEVOS @@ -108,7 +108,6 @@ LOCAL_CPPFLAGS += -I$(LOCAL_PATH)/$(DEPS_DIR)/glslang \ -I$(LOCAL_PATH)/$(DEPS_DIR)/glslang/glslang/glslang/Public \ -I$(LOCAL_PATH)/$(DEPS_DIR)/glslang/glslang/glslang/MachineIndependent \ -I$(LOCAL_PATH)/$(DEPS_DIR)/glslang/glslang/SPIRV \ - -I$(LOCAL_PATH)/$(DEPS_DIR)/spir2cross \ -I$(LOCAL_PATH)/$(DEPS_DIR)/SPIRV-Cross LOCAL_CFLAGS += -Wno-sign-compare -Wno-unused-variable -Wno-parentheses From 0e159a0ec0fa04f93eca3f4ddacbf5261e41d1f7 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Sat, 3 Feb 2018 23:35:04 +0100 Subject: [PATCH 052/232] (slang) slang_process: preset alias setting has higher priority. --- gfx/drivers_shader/slang_process.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/drivers_shader/slang_process.cpp b/gfx/drivers_shader/slang_process.cpp index 7335f8d38e..fffa7c4485 100644 --- a/gfx/drivers_shader/slang_process.cpp +++ b/gfx/drivers_shader/slang_process.cpp @@ -313,7 +313,7 @@ bool slang_process( if (!slang_preprocess_parse_parameters(output.meta, shader_info)) return false; - if (!output.meta.name.empty()) + if (!*pass.alias && !output.meta.name.empty()) strncpy(pass.alias, output.meta.name.c_str(), sizeof(pass.alias) - 1); out->format = output.meta.rt_format; From ae6524a7f5da624286e66d64d05898aa943d0c4d Mon Sep 17 00:00:00 2001 From: orbea Date: Sat, 3 Feb 2018 21:56:24 -0800 Subject: [PATCH 053/232] dist-scripts: Don't use the 'source' builtin. The 'source' builtin is not POSIX and not all of the build environments have it. For example the wiiu build log report: ./wiiu-cores.sh: 8: ./wiiu-cores.sh: source: not found --- dist-scripts/dist-cores.sh | 2 +- dist-scripts/wiiu-cores.sh | 2 +- dist-scripts/wiiu-new-cores.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dist-scripts/dist-cores.sh b/dist-scripts/dist-cores.sh index d2e5fba30d..9153b6a4df 100755 --- a/dist-scripts/dist-cores.sh +++ b/dist-scripts/dist-cores.sh @@ -1,6 +1,6 @@ #!/bin/sh -source ../version.all +. ../version.all PLATFORM=$1 SALAMANDER=no MAKEFILE_GRIFFIN=no diff --git a/dist-scripts/wiiu-cores.sh b/dist-scripts/wiiu-cores.sh index 70c4777591..8d597243fe 100755 --- a/dist-scripts/wiiu-cores.sh +++ b/dist-scripts/wiiu-cores.sh @@ -5,7 +5,7 @@ # and icons (https://github.com/libretro/retroarch-assets/tree/master/pkg/wiiu) to this directory then run # the script. the output will be in retroarch/pkg/wiiu -source ../version.all +. ../version.all platform=wiiu EXT=a diff --git a/dist-scripts/wiiu-new-cores.sh b/dist-scripts/wiiu-new-cores.sh index 1e8a53c463..9f595dcfd8 100755 --- a/dist-scripts/wiiu-new-cores.sh +++ b/dist-scripts/wiiu-new-cores.sh @@ -1,6 +1,6 @@ #!/bin/bash -source ../version.all +. ../version.all platform=wiiu EXT=a scriptDir= From 2963288b2973a8aa4717943fd3bcf4505b24dea7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 4 Feb 2018 14:21:11 +0100 Subject: [PATCH 054/232] SPIRV-Cross and glslang will compile with Griffin/MSVC targets now --- Makefile.common | 1 + Makefile.griffin | 4 + deps/SPIRV-Cross/spirv_common.hpp | 18 +- deps/SPIRV-Cross/spirv_cross.cpp | 12 +- deps/SPIRV-Cross/spirv_hlsl.cpp | 15 +- deps/SPIRV-Cross/spirv_msl.cpp | 8 +- .../MachineIndependent/LiveTraverser.h | 5 + .../glslang/MachineIndependent/Scan.cpp | 230 ++++--- .../glslang/MachineIndependent/ScanContext.h | 9 +- .../glslang/MachineIndependent/ShaderLang.cpp | 72 +-- .../MachineIndependent/preprocessor/Compare.h | 32 + .../MachineIndependent/preprocessor/Pp.cpp | 168 ++--- .../preprocessor/PpContext.cpp | 2 +- .../preprocessor/PpContext.h | 10 +- .../preprocessor/PpScanner.cpp | 64 +- .../preprocessor/PpTokens.cpp | 10 +- .../glslang/OSDependent/Windows/ossource.cpp | 2 +- deps/glslang/glslang/hlsl/hlslGrammar.cpp | 182 +++--- deps/glslang/glslang/hlsl/hlslGrammar.h | 6 +- deps/glslang/glslang/hlsl/hlslScanContext.cpp | 575 +++++++++--------- deps/glslang/glslang/hlsl/hlslScanContext.h | 6 +- griffin/griffin_cpp.cpp | 79 +-- griffin/griffin_glslang.cpp | 58 ++ pkg/android/phoenix/jni/Android.mk | 50 +- pkg/msvc/msvc-2013/RetroArch-msvc2013.vcxproj | 11 +- .../RetroArch-msvc2013.vcxproj.filters | 3 + pkg/msvc/msvc-2015/RetroArch-msvc2015.vcxproj | 35 +- .../RetroArch-msvc2015.vcxproj.filters | 5 +- pkg/msvc/msvc-2017/RetroArch-msvc2017.vcxproj | 17 +- .../RetroArch-msvc2017.vcxproj.filters | 41 +- 30 files changed, 868 insertions(+), 862 deletions(-) create mode 100644 deps/glslang/glslang/glslang/MachineIndependent/preprocessor/Compare.h create mode 100644 griffin/griffin_glslang.cpp diff --git a/Makefile.common b/Makefile.common index 1d93deb1c6..90ea670e95 100644 --- a/Makefile.common +++ b/Makefile.common @@ -1361,6 +1361,7 @@ ifeq ($(HAVE_SPIRV_CROSS), 1) OBJ += $(DEPS_DIR)/SPIRV-Cross/spirv_cfg.o OBJ += $(DEPS_DIR)/SPIRV-Cross/spirv_glsl.o OBJ += $(DEPS_DIR)/SPIRV-Cross/spirv_hlsl.o + #OBJ += $(DEPS_DIR)/SPIRV-Cross/spirv_msl.o endif ifeq ($(WANT_WGL), 1) diff --git a/Makefile.griffin b/Makefile.griffin index 182281628b..4f565c7a60 100644 --- a/Makefile.griffin +++ b/Makefile.griffin @@ -671,6 +671,10 @@ ifeq ($(HAVE_GRIFFIN_CPP), 1) OBJ += griffin/griffin_cpp.o endif +ifeq ($(WANT_GLSLANG), 1) + OBJ += griffin/griffin_glslang.o +endif + ifeq ($(HAVE_LOGGER), 1) CFLAGS += -DHAVE_LOGGER CFLAGS += -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT) diff --git a/deps/SPIRV-Cross/spirv_common.hpp b/deps/SPIRV-Cross/spirv_common.hpp index c4829f4643..550bc86e4d 100644 --- a/deps/SPIRV-Cross/spirv_common.hpp +++ b/deps/SPIRV-Cross/spirv_common.hpp @@ -723,16 +723,30 @@ struct SPIRConstant : IVariant { Constant r[4]; // If != 0, this element is a specialization constant, and we should keep track of it as such. - uint32_t id[4] = {}; + uint32_t id[4]; uint32_t vecsize = 1; + + ConstantVector() + { + unsigned i; + for (i = 0; i < 4; i++) + id[i] = 0; + } }; struct ConstantMatrix { ConstantVector c[4]; // If != 0, this column is a specialization constant, and we should keep track of it as such. - uint32_t id[4] = {}; + uint32_t id[4]; uint32_t columns = 1; + + ConstantMatrix() + { + unsigned i; + for (i = 0; i < 4; i++) + id[i] = 0; + } }; inline uint32_t specialization_constant_id(uint32_t col, uint32_t row) const diff --git a/deps/SPIRV-Cross/spirv_cross.cpp b/deps/SPIRV-Cross/spirv_cross.cpp index 996c0205c3..c5db07d60a 100644 --- a/deps/SPIRV-Cross/spirv_cross.cpp +++ b/deps/SPIRV-Cross/spirv_cross.cpp @@ -3368,7 +3368,7 @@ void Compiler::analyze_variable_scope(SPIRFunction &entry) CFG cfg(*this, entry); // Analyze if there are parameters which need to be implicitly preserved with an "in" qualifier. - analyze_parameter_preservation(entry, cfg, handler.accessed_variables_to_block, + this->analyze_parameter_preservation(entry, cfg, handler.accessed_variables_to_block, handler.complete_write_variables_to_block); unordered_map potential_loop_variables; @@ -3393,7 +3393,7 @@ void Compiler::analyze_variable_scope(SPIRFunction &entry) // The continue block is dominated by the inner part of the loop, which does not make sense in high-level // language output because it will be declared before the body, // so we will have to lift the dominator up to the relevant loop header instead. - builder.add_block(continue_block_to_loop_header[block]); + builder.add_block(this->continue_block_to_loop_header[block]); if (type.vecsize == 1 && type.columns == 1) { @@ -3447,7 +3447,7 @@ void Compiler::analyze_variable_scope(SPIRFunction &entry) // If a temporary is used in more than one block, we might have to lift continue block // access up to loop header like we did for variables. if (blocks.size() != 1 && this->is_continue(block)) - builder.add_block(continue_block_to_loop_header[block]); + builder.add_block(this->continue_block_to_loop_header[block]); } uint32_t dominating_block = builder.get_dominator(); @@ -3462,10 +3462,10 @@ void Compiler::analyze_variable_scope(SPIRFunction &entry) // This should be very rare, but if we try to declare a temporary inside a loop, // and that temporary is used outside the loop as well (spirv-opt inliner likes this) // we should actually emit the temporary outside the loop. - hoisted_temporaries.insert(var.first); - forced_temporaries.insert(var.first); + this->hoisted_temporaries.insert(var.first); + this->forced_temporaries.insert(var.first); - auto &block_temporaries = get(dominating_block).declare_temporary; + auto &block_temporaries = this->get(dominating_block).declare_temporary; block_temporaries.emplace_back(handler.result_id_to_type[var.first], var.first); } } diff --git a/deps/SPIRV-Cross/spirv_hlsl.cpp b/deps/SPIRV-Cross/spirv_hlsl.cpp index 3f2227cfea..6d486c6213 100644 --- a/deps/SPIRV-Cross/spirv_hlsl.cpp +++ b/deps/SPIRV-Cross/spirv_hlsl.cpp @@ -204,7 +204,7 @@ static string image_format_to_type(ImageFormat fmt, SPIRType::BaseType basetype) } // Returns true if an arithmetic operation does not change behavior depending on signedness. -static bool opcode_is_sign_invariant(Op opcode) +static bool hlsl_opcode_is_sign_invariant(Op opcode) { switch (opcode) { @@ -3054,15 +3054,24 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction) auto ops = stream(instruction); auto opcode = static_cast(instruction.op); +#undef BOP +#undef BOP_CAST +#undef UOP +#undef QFOP +#undef TFOP +#undef BFOP +#undef BFOP_CAST +#undef BFOP +#undef UFOP #define BOP(op) emit_binary_op(ops[0], ops[1], ops[2], ops[3], #op) #define BOP_CAST(op, type) \ - emit_binary_op_cast(ops[0], ops[1], ops[2], ops[3], #op, type, opcode_is_sign_invariant(opcode)) + emit_binary_op_cast(ops[0], ops[1], ops[2], ops[3], #op, type, hlsl_opcode_is_sign_invariant(opcode)) #define UOP(op) emit_unary_op(ops[0], ops[1], ops[2], #op) #define QFOP(op) emit_quaternary_func_op(ops[0], ops[1], ops[2], ops[3], ops[4], ops[5], #op) #define TFOP(op) emit_trinary_func_op(ops[0], ops[1], ops[2], ops[3], ops[4], #op) #define BFOP(op) emit_binary_func_op(ops[0], ops[1], ops[2], ops[3], #op) #define BFOP_CAST(op, type) \ - emit_binary_func_op_cast(ops[0], ops[1], ops[2], ops[3], #op, type, opcode_is_sign_invariant(opcode)) + emit_binary_func_op_cast(ops[0], ops[1], ops[2], ops[3], #op, type, hlsl_opcode_is_sign_invariant(opcode)) #define BFOP(op) emit_binary_func_op(ops[0], ops[1], ops[2], ops[3], #op) #define UFOP(op) emit_unary_func_op(ops[0], ops[1], ops[2], #op) diff --git a/deps/SPIRV-Cross/spirv_msl.cpp b/deps/SPIRV-Cross/spirv_msl.cpp index a85b38c2eb..9ddfb81029 100644 --- a/deps/SPIRV-Cross/spirv_msl.cpp +++ b/deps/SPIRV-Cross/spirv_msl.cpp @@ -1230,7 +1230,13 @@ void CompilerMSL::emit_specialization_constants() // Override for MSL-specific syntax instructions void CompilerMSL::emit_instruction(const Instruction &instruction) { - +#undef BOP +#undef BOP_CAST +#undef UOP +#undef QFOP +#undef TFOP +#undef BFOP +#undef BFOP_CAST #define BOP(op) emit_binary_op(ops[0], ops[1], ops[2], ops[3], #op) #define BOP_CAST(op, type) \ emit_binary_op_cast(ops[0], ops[1], ops[2], ops[3], #op, type, opcode_is_sign_invariant(opcode)) diff --git a/deps/glslang/glslang/glslang/MachineIndependent/LiveTraverser.h b/deps/glslang/glslang/glslang/MachineIndependent/LiveTraverser.h index 286efe6cef..af8f7755bc 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/LiveTraverser.h +++ b/deps/glslang/glslang/glslang/MachineIndependent/LiveTraverser.h @@ -33,6 +33,9 @@ //POSSIBILITY OF SUCH DAMAGE. // +#ifndef _MACHINE_INDEPENDENT_LIVE_TRAVERSER_H +#define _MACHINE_INDEPENDENT_LIVE_TRAVERSER_H + #include "../Include/Common.h" #include "reflection.h" #include "localintermediate.h" @@ -134,3 +137,5 @@ private: }; } // namespace glslang + +#endif diff --git a/deps/glslang/glslang/glslang/MachineIndependent/Scan.cpp b/deps/glslang/glslang/glslang/MachineIndependent/Scan.cpp index 3750645403..695e63d00c 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/Scan.cpp +++ b/deps/glslang/glslang/glslang/MachineIndependent/Scan.cpp @@ -52,6 +52,7 @@ // preprocessor includes #include "preprocessor/PpContext.h" #include "preprocessor/PpTokens.h" +#include "preprocessor/Compare.h" // Required to avoid missing prototype warnings for some compilers int yylex(YYSTYPE*, glslang::TParseContext&); @@ -287,38 +288,15 @@ protected: } // end namespace glslang // This is the function the glslang parser (i.e., bison) calls to get its next token -int yylex(YYSTYPE* glslangTokenDesc, glslang::TParseContext& parseContext) +int yylex(YYSTYPE* glslangTokenDesc, glslang::TParseContext& _parseContext) { glslang::TParserToken token(*glslangTokenDesc); - return parseContext.getScanContext()->tokenize(parseContext.getPpContext(), token); + return _parseContext.getScanContext()->tokenize(_parseContext.getPpContext(), token); } namespace { -struct str_eq -{ - bool operator()(const char* lhs, const char* rhs) const - { - return strcmp(lhs, rhs) == 0; - } -}; - -struct str_hash -{ - size_t operator()(const char* str) const - { - // djb2 - unsigned long hash = 5381; - int c; - - while ((c = *str++) != 0) - hash = ((hash << 5) + hash) + c; - - return hash; - } -}; - // A single global usable by all threads, by all versions, by all languages. // After a single process-level initialization, this is read only and thread safe std::unordered_map* KeywordMap = nullptr; @@ -670,7 +648,7 @@ int TScanContext::tokenize(TPpContext* pp, TParserToken& token) case '{': return LEFT_BRACE; case '}': return RIGHT_BRACE; case '\\': - parseContext.error(loc, "illegal use of escape character", "\\", ""); + _parseContext.error(loc, "illegal use of escape character", "\\", ""); break; case PpAtomAdd: return ADD_ASSIGN; @@ -722,7 +700,7 @@ int TScanContext::tokenize(TPpContext* pp, TParserToken& token) char buf[2]; buf[0] = (char)ppToken.token; buf[1] = 0; - parseContext.error(loc, "unexpected token", buf, ""); + _parseContext.error(loc, "unexpected token", buf, ""); break; } } while (true); @@ -761,8 +739,8 @@ int TScanContext::tokenizeIdentifier() case SWITCH: case DEFAULT: - if ((parseContext.profile == EEsProfile && parseContext.version < 300) || - (parseContext.profile != EEsProfile && parseContext.version < 130)) + if ((_parseContext.profile == EEsProfile && _parseContext.version < 300) || + (_parseContext.profile != EEsProfile && _parseContext.version < 130)) reservedWord(); return keyword; @@ -796,19 +774,19 @@ int TScanContext::tokenizeIdentifier() case ATTRIBUTE: case VARYING: - if (parseContext.profile == EEsProfile && parseContext.version >= 300) + if (_parseContext.profile == EEsProfile && _parseContext.version >= 300) reservedWord(); return keyword; case BUFFER: - if ((parseContext.profile == EEsProfile && parseContext.version < 310) || - (parseContext.profile != EEsProfile && parseContext.version < 430)) + if ((_parseContext.profile == EEsProfile && _parseContext.version < 310) || + (_parseContext.profile != EEsProfile && _parseContext.version < 430)) return identifierOrType(); return keyword; case ATOMIC_UINT: - if ((parseContext.profile == EEsProfile && parseContext.version >= 310) || - parseContext.extensionTurnedOn(E_GL_ARB_shader_atomic_counters)) + if ((_parseContext.profile == EEsProfile && _parseContext.version >= 310) || + _parseContext.extensionTurnedOn(E_GL_ARB_shader_atomic_counters)) return keyword; return es30ReservedFromGLSL(420); @@ -816,14 +794,14 @@ int TScanContext::tokenizeIdentifier() case RESTRICT: case READONLY: case WRITEONLY: - if (parseContext.profile == EEsProfile && parseContext.version >= 310) + if (_parseContext.profile == EEsProfile && _parseContext.version >= 310) return keyword; - return es30ReservedFromGLSL(parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store) ? 130 : 420); + return es30ReservedFromGLSL(_parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store) ? 130 : 420); case VOLATILE: - if (parseContext.profile == EEsProfile && parseContext.version >= 310) + if (_parseContext.profile == EEsProfile && _parseContext.version >= 310) return keyword; - if (! parseContext.symbolTable.atBuiltInLevel() && (parseContext.profile == EEsProfile || (parseContext.version < 420 && ! parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store)))) + if (!_parseContext.symbolTable.atBuiltInLevel() && (_parseContext.profile == EEsProfile || (_parseContext.version < 420 && ! _parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store)))) reservedWord(); return keyword; @@ -832,28 +810,28 @@ int TScanContext::tokenizeIdentifier() const int numLayoutExts = 2; const char* layoutExts[numLayoutExts] = { E_GL_ARB_shading_language_420pack, E_GL_ARB_explicit_attrib_location }; - if ((parseContext.profile == EEsProfile && parseContext.version < 300) || - (parseContext.profile != EEsProfile && parseContext.version < 140 && - ! parseContext.extensionsTurnedOn(numLayoutExts, layoutExts))) + if ((_parseContext.profile == EEsProfile && _parseContext.version < 300) || + (_parseContext.profile != EEsProfile && _parseContext.version < 140 && + !_parseContext.extensionsTurnedOn(numLayoutExts, layoutExts))) return identifierOrType(); return keyword; } case SHARED: - if ((parseContext.profile == EEsProfile && parseContext.version < 300) || - (parseContext.profile != EEsProfile && parseContext.version < 140)) + if ((_parseContext.profile == EEsProfile && _parseContext.version < 300) || + (_parseContext.profile != EEsProfile && _parseContext.version < 140)) return identifierOrType(); return keyword; case PATCH: - if (parseContext.symbolTable.atBuiltInLevel() || - (parseContext.profile == EEsProfile && parseContext.extensionsTurnedOn(Num_AEP_tessellation_shader, AEP_tessellation_shader)) || - (parseContext.profile != EEsProfile && parseContext.extensionTurnedOn(E_GL_ARB_tessellation_shader))) + if (_parseContext.symbolTable.atBuiltInLevel() || + (_parseContext.profile == EEsProfile && _parseContext.extensionsTurnedOn(Num_AEP_tessellation_shader, AEP_tessellation_shader)) || + (_parseContext.profile != EEsProfile && _parseContext.extensionTurnedOn(E_GL_ARB_tessellation_shader))) return keyword; return es30ReservedFromGLSL(400); case SAMPLE: - if (parseContext.extensionsTurnedOn(1, &E_GL_OES_shader_multisample_interpolation)) + if (_parseContext.extensionsTurnedOn(1, &E_GL_OES_shader_multisample_interpolation)) return keyword; return es30ReservedFromGLSL(400); @@ -907,7 +885,7 @@ int TScanContext::tokenizeIdentifier() case IIMAGEBUFFER: case UIMAGEBUFFER: afterType = true; - if (parseContext.extensionsTurnedOn(Num_AEP_texture_buffer, AEP_texture_buffer)) + if (_parseContext.extensionsTurnedOn(Num_AEP_texture_buffer, AEP_texture_buffer)) return keyword; return firstGenerationImage(false); @@ -930,7 +908,7 @@ int TScanContext::tokenizeIdentifier() case IIMAGECUBEARRAY: case UIMAGECUBEARRAY: afterType = true; - if (parseContext.extensionsTurnedOn(Num_AEP_texture_cube_map_array, AEP_texture_cube_map_array)) + if (_parseContext.extensionsTurnedOn(Num_AEP_texture_cube_map_array, AEP_texture_cube_map_array)) return keyword; return secondGenerationImage(); @@ -948,7 +926,7 @@ int TScanContext::tokenizeIdentifier() case DVEC3: case DVEC4: afterType = true; - if (parseContext.profile == EEsProfile || parseContext.version < 400) + if (_parseContext.profile == EEsProfile || _parseContext.version < 400) reservedWord(); return keyword; @@ -961,9 +939,9 @@ int TScanContext::tokenizeIdentifier() case U64VEC3: case U64VEC4: afterType = true; - if (parseContext.symbolTable.atBuiltInLevel() || - (parseContext.extensionTurnedOn(E_GL_ARB_gpu_shader_int64) && - parseContext.profile != EEsProfile && parseContext.version >= 450)) + if (_parseContext.symbolTable.atBuiltInLevel() || + (_parseContext.extensionTurnedOn(E_GL_ARB_gpu_shader_int64) && + _parseContext.profile != EEsProfile && _parseContext.version >= 450)) return keyword; return identifierOrType(); @@ -997,9 +975,9 @@ int TScanContext::tokenizeIdentifier() case ISAMPLERCUBEARRAY: case USAMPLERCUBEARRAY: afterType = true; - if (parseContext.extensionsTurnedOn(Num_AEP_texture_cube_map_array, AEP_texture_cube_map_array)) + if (_parseContext.extensionsTurnedOn(Num_AEP_texture_cube_map_array, AEP_texture_cube_map_array)) return keyword; - if (parseContext.profile == EEsProfile || (parseContext.version < 400 && ! parseContext.extensionTurnedOn(E_GL_ARB_texture_cube_map_array))) + if (_parseContext.profile == EEsProfile || (_parseContext.version < 400 && ! _parseContext.extensionTurnedOn(E_GL_ARB_texture_cube_map_array))) reservedWord(); return keyword; @@ -1036,14 +1014,14 @@ int TScanContext::tokenizeIdentifier() case SAMPLERBUFFER: afterType = true; - if (parseContext.extensionsTurnedOn(Num_AEP_texture_buffer, AEP_texture_buffer)) + if (_parseContext.extensionsTurnedOn(Num_AEP_texture_buffer, AEP_texture_buffer)) return keyword; return es30ReservedFromGLSL(130); case ISAMPLERBUFFER: case USAMPLERBUFFER: afterType = true; - if (parseContext.extensionsTurnedOn(Num_AEP_texture_buffer, AEP_texture_buffer)) + if (_parseContext.extensionsTurnedOn(Num_AEP_texture_buffer, AEP_texture_buffer)) return keyword; return es30ReservedFromGLSL(140); @@ -1051,7 +1029,7 @@ int TScanContext::tokenizeIdentifier() case ISAMPLER2DMS: case USAMPLER2DMS: afterType = true; - if (parseContext.profile == EEsProfile && parseContext.version >= 310) + if (_parseContext.profile == EEsProfile && _parseContext.version >= 310) return keyword; return es30ReservedFromGLSL(150); @@ -1059,39 +1037,39 @@ int TScanContext::tokenizeIdentifier() case ISAMPLER2DMSARRAY: case USAMPLER2DMSARRAY: afterType = true; - if (parseContext.extensionsTurnedOn(1, &E_GL_OES_texture_storage_multisample_2d_array)) + if (_parseContext.extensionsTurnedOn(1, &E_GL_OES_texture_storage_multisample_2d_array)) return keyword; return es30ReservedFromGLSL(150); case SAMPLER1D: case SAMPLER1DSHADOW: afterType = true; - if (parseContext.profile == EEsProfile) + if (_parseContext.profile == EEsProfile) reservedWord(); return keyword; case SAMPLER3D: afterType = true; - if (parseContext.profile == EEsProfile && parseContext.version < 300) { - if (! parseContext.extensionTurnedOn(E_GL_OES_texture_3D)) + if (_parseContext.profile == EEsProfile && _parseContext.version < 300) { + if (!_parseContext.extensionTurnedOn(E_GL_OES_texture_3D)) reservedWord(); } return keyword; case SAMPLER2DSHADOW: afterType = true; - if (parseContext.profile == EEsProfile && parseContext.version < 300) + if (_parseContext.profile == EEsProfile && _parseContext.version < 300) reservedWord(); return keyword; case SAMPLER2DRECT: case SAMPLER2DRECTSHADOW: afterType = true; - if (parseContext.profile == EEsProfile) + if (_parseContext.profile == EEsProfile) reservedWord(); - else if (parseContext.version < 140 && ! parseContext.symbolTable.atBuiltInLevel() && ! parseContext.extensionTurnedOn(E_GL_ARB_texture_rectangle)) { - if (parseContext.relaxedErrors()) - parseContext.requireExtensions(loc, 1, &E_GL_ARB_texture_rectangle, "texture-rectangle sampler keyword"); + else if (_parseContext.version < 140 && ! _parseContext.symbolTable.atBuiltInLevel() && ! _parseContext.extensionTurnedOn(E_GL_ARB_texture_rectangle)) { + if (_parseContext.relaxedErrors()) + _parseContext.requireExtensions(loc, 1, &E_GL_ARB_texture_rectangle, "texture-rectangle sampler keyword"); else reservedWord(); } @@ -1099,16 +1077,16 @@ int TScanContext::tokenizeIdentifier() case SAMPLER1DARRAY: afterType = true; - if (parseContext.profile == EEsProfile && parseContext.version == 300) + if (_parseContext.profile == EEsProfile && _parseContext.version == 300) reservedWord(); - else if ((parseContext.profile == EEsProfile && parseContext.version < 300) || - (parseContext.profile != EEsProfile && parseContext.version < 130)) + else if ((_parseContext.profile == EEsProfile && _parseContext.version < 300) || + (_parseContext.profile != EEsProfile && _parseContext.version < 130)) return identifierOrType(); return keyword; case SAMPLEREXTERNALOES: afterType = true; - if (parseContext.symbolTable.atBuiltInLevel() || parseContext.extensionTurnedOn(E_GL_OES_EGL_image_external)) + if (_parseContext.symbolTable.atBuiltInLevel() || _parseContext.extensionTurnedOn(E_GL_OES_EGL_image_external)) return keyword; return identifierOrType(); @@ -1147,7 +1125,7 @@ int TScanContext::tokenizeIdentifier() case TEXTURE1DARRAY: case SAMPLER: case SAMPLERSHADOW: - if (parseContext.spvVersion.vulkan >= 100) + if (_parseContext.spvVersion.vulkan >= 100) return keyword; else return identifierOrType(); @@ -1158,7 +1136,7 @@ int TScanContext::tokenizeIdentifier() case ISUBPASSINPUTMS: case USUBPASSINPUT: case USUBPASSINPUTMS: - if (parseContext.spvVersion.vulkan >= 100) + if (_parseContext.spvVersion.vulkan >= 100) return keyword; else return identifierOrType(); @@ -1167,8 +1145,8 @@ int TScanContext::tokenizeIdentifier() return es30ReservedFromGLSL(130); case SMOOTH: - if ((parseContext.profile == EEsProfile && parseContext.version < 300) || - (parseContext.profile != EEsProfile && parseContext.version < 130)) + if ((_parseContext.profile == EEsProfile && _parseContext.version < 300) || + (_parseContext.profile != EEsProfile && _parseContext.version < 130)) return identifierOrType(); return keyword; @@ -1181,52 +1159,52 @@ int TScanContext::tokenizeIdentifier() #endif case FLAT: - if (parseContext.profile == EEsProfile && parseContext.version < 300) + if (_parseContext.profile == EEsProfile && _parseContext.version < 300) reservedWord(); - else if (parseContext.profile != EEsProfile && parseContext.version < 130) + else if (_parseContext.profile != EEsProfile && _parseContext.version < 130) return identifierOrType(); return keyword; case CENTROID: - if (parseContext.version < 120) + if (_parseContext.version < 120) return identifierOrType(); return keyword; case PRECISE: - if ((parseContext.profile == EEsProfile && parseContext.extensionsTurnedOn(Num_AEP_gpu_shader5, AEP_gpu_shader5)) || - (parseContext.profile != EEsProfile && parseContext.version >= 400)) + if ((_parseContext.profile == EEsProfile && _parseContext.extensionsTurnedOn(Num_AEP_gpu_shader5, AEP_gpu_shader5)) || + (_parseContext.profile != EEsProfile && _parseContext.version >= 400)) return keyword; - if (parseContext.profile == EEsProfile && parseContext.version == 310) { + if (_parseContext.profile == EEsProfile && _parseContext.version == 310) { reservedWord(); return keyword; } return identifierOrType(); case INVARIANT: - if (parseContext.profile != EEsProfile && parseContext.version < 120) + if (_parseContext.profile != EEsProfile && _parseContext.version < 120) return identifierOrType(); return keyword; case PACKED: - if ((parseContext.profile == EEsProfile && parseContext.version < 300) || - (parseContext.profile != EEsProfile && parseContext.version < 330)) + if ((_parseContext.profile == EEsProfile && _parseContext.version < 300) || + (_parseContext.profile != EEsProfile && _parseContext.version < 330)) return reservedWord(); return identifierOrType(); case RESOURCE: { - bool reserved = (parseContext.profile == EEsProfile && parseContext.version >= 300) || - (parseContext.profile != EEsProfile && parseContext.version >= 420); + bool reserved = (_parseContext.profile == EEsProfile && _parseContext.version >= 300) || + (_parseContext.profile != EEsProfile && _parseContext.version >= 420); return identifierOrReserved(reserved); } case SUPERP: { - bool reserved = parseContext.profile == EEsProfile || parseContext.version >= 130; + bool reserved = _parseContext.profile == EEsProfile || _parseContext.version >= 130; return identifierOrReserved(reserved); } default: - parseContext.infoSink.info.message(EPrefixInternalError, "Unknown glslang keyword", loc); + _parseContext.infoSink.info.message(EPrefixInternalError, "Unknown glslang keyword", loc); return 0; } } @@ -1237,7 +1215,7 @@ int TScanContext::identifierOrType() if (field) return IDENTIFIER; - parserToken->sType.lex.symbol = parseContext.symbolTable.find(*parserToken->sType.lex.string); + parserToken->sType.lex.symbol = _parseContext.symbolTable.find(*parserToken->sType.lex.string); if (afterType == false && parserToken->sType.lex.symbol) { if (const TVariable* variable = parserToken->sType.lex.symbol->getAsVariable()) { if (variable->isUserType()) { @@ -1256,8 +1234,8 @@ int TScanContext::identifierOrType() // extension support before the extension is enabled. int TScanContext::reservedWord() { - if (! parseContext.symbolTable.atBuiltInLevel()) - parseContext.error(loc, "Reserved word.", tokenText, "", ""); + if (!_parseContext.symbolTable.atBuiltInLevel()) + _parseContext.error(loc, "Reserved word.", tokenText, "", ""); return 0; } @@ -1270,8 +1248,8 @@ int TScanContext::identifierOrReserved(bool reserved) return 0; } - if (parseContext.forwardCompatible) - parseContext.warn(loc, "using future reserved keyword", tokenText, ""); + if (_parseContext.forwardCompatible) + _parseContext.warn(loc, "using future reserved keyword", tokenText, ""); return identifierOrType(); } @@ -1280,16 +1258,16 @@ int TScanContext::identifierOrReserved(bool reserved) // but then got reserved by ES 3.0. int TScanContext::es30ReservedFromGLSL(int version) { - if (parseContext.symbolTable.atBuiltInLevel()) + if (_parseContext.symbolTable.atBuiltInLevel()) return keyword; - if ((parseContext.profile == EEsProfile && parseContext.version < 300) || - (parseContext.profile != EEsProfile && parseContext.version < version)) { - if (parseContext.forwardCompatible) - parseContext.warn(loc, "future reserved word in ES 300 and keyword in GLSL", tokenText, ""); + if ((_parseContext.profile == EEsProfile && _parseContext.version < 300) || + (_parseContext.profile != EEsProfile && _parseContext.version < version)) { + if (_parseContext.forwardCompatible) + _parseContext.warn(loc, "future reserved word in ES 300 and keyword in GLSL", tokenText, ""); return identifierOrType(); - } else if (parseContext.profile == EEsProfile && parseContext.version >= 300) + } else if (_parseContext.profile == EEsProfile && _parseContext.version >= 300) reservedWord(); return keyword; @@ -1299,10 +1277,10 @@ int TScanContext::es30ReservedFromGLSL(int version) // showed up, both in an es version and a non-ES version. int TScanContext::nonreservedKeyword(int esVersion, int nonEsVersion) { - if ((parseContext.profile == EEsProfile && parseContext.version < esVersion) || - (parseContext.profile != EEsProfile && parseContext.version < nonEsVersion)) { - if (parseContext.forwardCompatible) - parseContext.warn(loc, "using future keyword", tokenText, ""); + if ((_parseContext.profile == EEsProfile && _parseContext.version < esVersion) || + (_parseContext.profile != EEsProfile && _parseContext.version < nonEsVersion)) { + if (_parseContext.forwardCompatible) + _parseContext.warn(loc, "using future keyword", tokenText, ""); return identifierOrType(); } @@ -1312,11 +1290,11 @@ int TScanContext::nonreservedKeyword(int esVersion, int nonEsVersion) int TScanContext::precisionKeyword() { - if (parseContext.profile == EEsProfile || parseContext.version >= 130) + if (_parseContext.profile == EEsProfile || _parseContext.version >= 130) return keyword; - if (parseContext.forwardCompatible) - parseContext.warn(loc, "using ES precision qualifier keyword", tokenText, ""); + if (_parseContext.forwardCompatible) + _parseContext.warn(loc, "using ES precision qualifier keyword", tokenText, ""); return identifierOrType(); } @@ -1325,11 +1303,11 @@ int TScanContext::matNxM() { afterType = true; - if (parseContext.version > 110) + if (_parseContext.version > 110) return keyword; - if (parseContext.forwardCompatible) - parseContext.warn(loc, "using future non-square matrix type keyword", tokenText, ""); + if (_parseContext.forwardCompatible) + _parseContext.warn(loc, "using future non-square matrix type keyword", tokenText, ""); return identifierOrType(); } @@ -1338,55 +1316,55 @@ int TScanContext::dMat() { afterType = true; - if (parseContext.profile == EEsProfile && parseContext.version >= 300) { + if (_parseContext.profile == EEsProfile && _parseContext.version >= 300) { reservedWord(); return keyword; } - if (parseContext.profile != EEsProfile && parseContext.version >= 400) + if (_parseContext.profile != EEsProfile && _parseContext.version >= 400) return keyword; - if (parseContext.forwardCompatible) - parseContext.warn(loc, "using future type keyword", tokenText, ""); + if (_parseContext.forwardCompatible) + _parseContext.warn(loc, "using future type keyword", tokenText, ""); return identifierOrType(); } int TScanContext::firstGenerationImage(bool inEs310) { - if (parseContext.symbolTable.atBuiltInLevel() || - (parseContext.profile != EEsProfile && (parseContext.version >= 420 || parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store))) || - (inEs310 && parseContext.profile == EEsProfile && parseContext.version >= 310)) + if (_parseContext.symbolTable.atBuiltInLevel() || + (_parseContext.profile != EEsProfile && (_parseContext.version >= 420 || _parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store))) || + (inEs310 && _parseContext.profile == EEsProfile && _parseContext.version >= 310)) return keyword; - if ((parseContext.profile == EEsProfile && parseContext.version >= 300) || - (parseContext.profile != EEsProfile && parseContext.version >= 130)) { + if ((_parseContext.profile == EEsProfile && _parseContext.version >= 300) || + (_parseContext.profile != EEsProfile && _parseContext.version >= 130)) { reservedWord(); return keyword; } - if (parseContext.forwardCompatible) - parseContext.warn(loc, "using future type keyword", tokenText, ""); + if (_parseContext.forwardCompatible) + _parseContext.warn(loc, "using future type keyword", tokenText, ""); return identifierOrType(); } int TScanContext::secondGenerationImage() { - if (parseContext.profile == EEsProfile && parseContext.version >= 310) { + if (_parseContext.profile == EEsProfile && _parseContext.version >= 310) { reservedWord(); return keyword; } - if (parseContext.symbolTable.atBuiltInLevel() || - (parseContext.profile != EEsProfile && - (parseContext.version >= 420 || parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store)))) + if (_parseContext.symbolTable.atBuiltInLevel() || + (_parseContext.profile != EEsProfile && + (_parseContext.version >= 420 || _parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store)))) return keyword; - if (parseContext.forwardCompatible) - parseContext.warn(loc, "using future type keyword", tokenText, ""); + if (_parseContext.forwardCompatible) + _parseContext.warn(loc, "using future type keyword", tokenText, ""); return identifierOrType(); } diff --git a/deps/glslang/glslang/glslang/MachineIndependent/ScanContext.h b/deps/glslang/glslang/glslang/MachineIndependent/ScanContext.h index f237bee9f2..7f0a1b513a 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/ScanContext.h +++ b/deps/glslang/glslang/glslang/MachineIndependent/ScanContext.h @@ -33,6 +33,9 @@ //POSSIBILITY OF SUCH DAMAGE. // +#ifndef _MACHINE_INDEPENDENT_SCAN_CONTEXT_H +#define _MACHINE_INDEPENDENT_SCAN_CONTEXT_H + // // This holds context specific to the GLSL scanner, which // sits between the preprocessor scanner and parser. @@ -48,7 +51,7 @@ class TParserToken; class TScanContext { public: - explicit TScanContext(TParseContextBase& pc) : parseContext(pc), afterType(false), field(false) { } + explicit TScanContext(TParseContextBase& pc) : _parseContext(pc), afterType(false), field(false) { } virtual ~TScanContext() { } static void fillInKeywordMap(); @@ -72,7 +75,7 @@ protected: int firstGenerationImage(bool inEs310); int secondGenerationImage(); - TParseContextBase& parseContext; + TParseContextBase& _parseContext; bool afterType; // true if we've recognized a type, so can only be looking for an identifier bool field; // true if we're on a field, right after a '.' TSourceLoc loc; @@ -84,3 +87,5 @@ protected: }; } // end namespace glslang + +#endif diff --git a/deps/glslang/glslang/glslang/MachineIndependent/ShaderLang.cpp b/deps/glslang/glslang/glslang/MachineIndependent/ShaderLang.cpp index e50b12f255..596e0ee649 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/ShaderLang.cpp +++ b/deps/glslang/glslang/glslang/MachineIndependent/ShaderLang.cpp @@ -217,15 +217,15 @@ bool InitializeSymbolTable(const TString& builtIns, int version, EProfile profil intermediate.setSource(source); - std::unique_ptr parseContext(CreateParseContext(symbolTable, intermediate, version, profile, source, + std::unique_ptr _parseContext(CreateParseContext(symbolTable, intermediate, version, profile, source, language, infoSink, spvVersion, true, EShMsgDefault, true)); TShader::ForbidInclude includer; - TPpContext ppContext(*parseContext, "", includer); - TScanContext scanContext(*parseContext); - parseContext->setScanContext(&scanContext); - parseContext->setPpContext(&ppContext); + TPpContext ppContext(*_parseContext, "", includer); + TScanContext scanContext(*_parseContext); + _parseContext->setScanContext(&scanContext); + _parseContext->setPpContext(&ppContext); // // Push the symbol table to give it an initial scope. This @@ -244,7 +244,7 @@ bool InitializeSymbolTable(const TString& builtIns, int version, EProfile profil return true; TInputScanner input(1, builtInShaders, builtInLengths); - if (! parseContext->parseShaderStrings(ppContext, input) != 0) { + if (!_parseContext->parseShaderStrings(ppContext, input) != 0) { infoSink.info.message(EPrefixInternalError, "Unable to parse built-ins"); printf("Unable to parse built-ins\n%s\n", infoSink.info.c_str()); printf("%s\n", builtInShaders[0]); @@ -732,32 +732,32 @@ bool ProcessDeferred( // Now we can process the full shader under proper symbols and rules. // - TParseContextBase* parseContext = CreateParseContext(symbolTable, intermediate, version, profile, source, + TParseContextBase *_parseContext = CreateParseContext(symbolTable, intermediate, version, profile, source, compiler->getLanguage(), compiler->infoSink, spvVersion, forwardCompatible, messages, false, sourceEntryPointName); - TPpContext ppContext(*parseContext, names[numPre]? names[numPre]: "", includer); + TPpContext ppContext(*_parseContext, names[numPre]? names[numPre]: "", includer); // only GLSL (bison triggered, really) needs an externally set scan context - glslang::TScanContext scanContext(*parseContext); + glslang::TScanContext scanContext(*_parseContext); if ((messages & EShMsgReadHlsl) == 0) - parseContext->setScanContext(&scanContext); + _parseContext->setScanContext(&scanContext); - parseContext->setPpContext(&ppContext); - parseContext->setLimits(*resources); + _parseContext->setPpContext(&ppContext); + _parseContext->setLimits(*resources); if (! goodVersion) - parseContext->addError(); + _parseContext->addError(); if (warnVersionNotFirst) { TSourceLoc loc; loc.init(); - parseContext->warn(loc, "Illegal to have non-comment, non-whitespace tokens before #version", "#version", ""); + _parseContext->warn(loc, "Illegal to have non-comment, non-whitespace tokens before #version", "#version", ""); } - parseContext->initializeExtensionBehavior(); + _parseContext->initializeExtensionBehavior(); // Fill in the strings as outlined above. std::string preamble; - parseContext->getPreamble(preamble); + _parseContext->getPreamble(preamble); strings[0] = preamble.c_str(); lengths[0] = strlen(strings[0]); names[0] = nullptr; @@ -776,14 +776,14 @@ bool ProcessDeferred( // Push a new symbol allocation scope that will get used for the shader's globals. symbolTable.push(); - bool success = processingContext(*parseContext, ppContext, fullInput, + bool success = processingContext(*_parseContext, ppContext, fullInput, versionWillBeError, symbolTable, intermediate, optLevel, messages); // Clean up the symbol table. The AST is self-sufficient now. delete symbolTableMemory; - delete parseContext; + delete _parseContext; delete [] lengths; delete [] strings; delete [] names; @@ -860,7 +860,7 @@ private: // It places the result in the "string" argument to its constructor. struct DoPreprocessing { explicit DoPreprocessing(std::string* string): outputString(string) {} - bool operator()(TParseContextBase& parseContext, TPpContext& ppContext, + bool operator()(TParseContextBase&_parseContext, TPpContext& ppContext, TInputScanner& input, bool versionWillBeError, TSymbolTable&, TIntermediate&, EShOptimizationLevel, EShMessages) @@ -870,20 +870,20 @@ struct DoPreprocessing { static const std::string noSpaceBeforeTokens = ","; glslang::TPpToken token; - parseContext.setScanner(&input); + _parseContext.setScanner(&input); ppContext.setInput(input, versionWillBeError); std::stringstream outputStream; SourceLineSynchronizer lineSync( std::bind(&TInputScanner::getLastValidSourceIndex, &input), &outputStream); - parseContext.setExtensionCallback([&lineSync, &outputStream]( + _parseContext.setExtensionCallback([&lineSync, &outputStream]( int line, const char* extension, const char* behavior) { lineSync.syncToLine(line); outputStream << "#extension " << extension << " : " << behavior; }); - parseContext.setLineCallback([&lineSync, &outputStream, &parseContext]( + _parseContext.setLineCallback([&lineSync, &outputStream, &_parseContext]( int curLineNum, int newLineNum, bool hasSource, int sourceNum, const char* sourceName) { // SourceNum is the number of the source-string that is being parsed. lineSync.syncToLine(curLineNum); @@ -896,7 +896,7 @@ struct DoPreprocessing { outputStream << sourceNum; } } - if (parseContext.lineDirectiveShouldSetNextLine()) { + if (_parseContext.lineDirectiveShouldSetNextLine()) { // newLineNum is the new line number for the line following the #line // directive. So the new line number for the current line is newLineNum -= 1; @@ -906,7 +906,7 @@ struct DoPreprocessing { lineSync.setLineNum(newLineNum + 1); }); - parseContext.setVersionCallback( + _parseContext.setVersionCallback( [&lineSync, &outputStream](int line, int version, const char* str) { lineSync.syncToLine(line); outputStream << "#version " << version; @@ -915,7 +915,7 @@ struct DoPreprocessing { } }); - parseContext.setPragmaCallback([&lineSync, &outputStream]( + _parseContext.setPragmaCallback([&lineSync, &outputStream]( int line, const glslang::TVector& ops) { lineSync.syncToLine(line); outputStream << "#pragma "; @@ -924,7 +924,7 @@ struct DoPreprocessing { } }); - parseContext.setErrorCallback([&lineSync, &outputStream]( + _parseContext.setErrorCallback([&lineSync, &outputStream]( int line, const char* errorMessage) { lineSync.syncToLine(line); outputStream << "#error " << errorMessage; @@ -958,10 +958,10 @@ struct DoPreprocessing { *outputString = outputStream.str(); bool success = true; - if (parseContext.getNumErrors() > 0) { + if (_parseContext.getNumErrors() > 0) { success = false; - parseContext.infoSink.info.prefix(EPrefixError); - parseContext.infoSink.info << parseContext.getNumErrors() << " compilation errors. No code generated.\n\n"; + _parseContext.infoSink.info.prefix(EPrefixError); + _parseContext.infoSink.info << _parseContext.getNumErrors() << " compilation errors. No code generated.\n\n"; } return success; } @@ -971,28 +971,28 @@ struct DoPreprocessing { // DoFullParse is a valid ProcessingConext template argument for fully // parsing the shader. It populates the "intermediate" with the AST. struct DoFullParse{ - bool operator()(TParseContextBase& parseContext, TPpContext& ppContext, + bool operator()(TParseContextBase&_parseContext, TPpContext& ppContext, TInputScanner& fullInput, bool versionWillBeError, TSymbolTable&, TIntermediate& intermediate, EShOptimizationLevel optLevel, EShMessages messages) { bool success = true; // Parse the full shader. - if (! parseContext.parseShaderStrings(ppContext, fullInput, versionWillBeError)) + if (!_parseContext.parseShaderStrings(ppContext, fullInput, versionWillBeError)) success = false; if (success && intermediate.getTreeRoot()) { if (optLevel == EShOptNoGeneration) - parseContext.infoSink.info.message(EPrefixNone, "No errors. No code generation or linking was requested."); + _parseContext.infoSink.info.message(EPrefixNone, "No errors. No code generation or linking was requested."); else - success = intermediate.postProcess(intermediate.getTreeRoot(), parseContext.getLanguage()); + success = intermediate.postProcess(intermediate.getTreeRoot(), _parseContext.getLanguage()); } else if (! success) { - parseContext.infoSink.info.prefix(EPrefixError); - parseContext.infoSink.info << parseContext.getNumErrors() << " compilation errors. No code generated.\n\n"; + _parseContext.infoSink.info.prefix(EPrefixError); + _parseContext.infoSink.info << _parseContext.getNumErrors() << " compilation errors. No code generated.\n\n"; } if (messages & EShMsgAST) - intermediate.output(parseContext.infoSink, true); + intermediate.output(_parseContext.infoSink, true); return success; } diff --git a/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/Compare.h b/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/Compare.h new file mode 100644 index 0000000000..92d288c08d --- /dev/null +++ b/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/Compare.h @@ -0,0 +1,32 @@ +#ifndef _MACHINE_INDEPENDENT_COMPARE_H +#define _MACHINE_INDEPENDENT_COMPARE_H + +#include "../../../hlsl/hlslTokens.h" + +namespace { + + struct str_eq + { + bool operator()(const char* lhs, const char* rhs) const + { + return strcmp(lhs, rhs) == 0; + } + }; + + struct str_hash + { + size_t operator()(const char* str) const + { + // djb2 + unsigned long hash = 5381; + int c; + + while ((c = *str++) != 0) + hash = ((hash << 5) + hash) + c; + + return hash; + } + }; +}; + +#endif diff --git a/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/Pp.cpp b/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/Pp.cpp index 824a69a9c7..9138d230ea 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/Pp.cpp +++ b/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/Pp.cpp @@ -107,12 +107,12 @@ int TPpContext::CPPdefine(TPpToken* ppToken) // get macro name int token = scanToken(ppToken); if (token != PpAtomIdentifier) { - parseContext.ppError(ppToken->loc, "must be followed by macro name", "#define", ""); + _parseContext.ppError(ppToken->loc, "must be followed by macro name", "#define", ""); return token; } if (ppToken->loc.string >= 0) { // We are in user code; check for reserved name use: - parseContext.reservedPpErrorCheck(ppToken->loc, ppToken->name, "#define"); + _parseContext.reservedPpErrorCheck(ppToken->loc, ppToken->name, "#define"); } // save the original atom @@ -128,7 +128,7 @@ int TPpContext::CPPdefine(TPpToken* ppToken) if (argc == 0 && token == ')') break; if (token != PpAtomIdentifier) { - parseContext.ppError(ppToken->loc, "bad argument", "#define", ""); + _parseContext.ppError(ppToken->loc, "bad argument", "#define", ""); return token; } @@ -136,7 +136,7 @@ int TPpContext::CPPdefine(TPpToken* ppToken) bool duplicate = false; for (int a = 0; a < argc; ++a) { if (args[a] == ppToken->atom) { - parseContext.ppError(ppToken->loc, "duplicate macro parameter", "#define", ""); + _parseContext.ppError(ppToken->loc, "duplicate macro parameter", "#define", ""); duplicate = true; break; } @@ -145,12 +145,12 @@ int TPpContext::CPPdefine(TPpToken* ppToken) if (argc < maxMacroArgs) args[argc++] = ppToken->atom; else - parseContext.ppError(ppToken->loc, "too many macro parameters", "#define", ""); + _parseContext.ppError(ppToken->loc, "too many macro parameters", "#define", ""); } token = scanToken(ppToken); } while (token == ','); if (token != ')') { - parseContext.ppError(ppToken->loc, "missing parenthesis", "#define", ""); + _parseContext.ppError(ppToken->loc, "missing parenthesis", "#define", ""); return token; } @@ -178,11 +178,11 @@ int TPpContext::CPPdefine(TPpToken* ppToken) // "Two replacement lists are identical if and only if the preprocessing tokens in both have the same number, // ordering, spelling, and white-space separation, where all white-space separations are considered identical." if (symb->mac.argc != mac.argc) - parseContext.ppError(defineLoc, "Macro redefined; different number of arguments:", "#define", GetAtomString(defAtom)); + _parseContext.ppError(defineLoc, "Macro redefined; different number of arguments:", "#define", GetAtomString(defAtom)); else { for (int argc = 0; argc < mac.argc; argc++) { if (symb->mac.args[argc] != mac.args[argc]) - parseContext.ppError(defineLoc, "Macro redefined; different argument names:", "#define", GetAtomString(defAtom)); + _parseContext.ppError(defineLoc, "Macro redefined; different argument names:", "#define", GetAtomString(defAtom)); } RewindTokenStream(symb->mac.body); RewindTokenStream(mac.body); @@ -194,7 +194,7 @@ int TPpContext::CPPdefine(TPpToken* ppToken) oldToken = ReadToken(symb->mac.body, &oldPpToken); newToken = ReadToken(mac.body, &newPpToken); if (oldToken != newToken || oldPpToken != newPpToken) { - parseContext.ppError(defineLoc, "Macro redefined; different substitutions:", "#define", GetAtomString(defAtom)); + _parseContext.ppError(defineLoc, "Macro redefined; different substitutions:", "#define", GetAtomString(defAtom)); break; } } while (newToken > 0); @@ -215,12 +215,12 @@ int TPpContext::CPPundef(TPpToken* ppToken) int token = scanToken(ppToken); Symbol *symb; if (token != PpAtomIdentifier) { - parseContext.ppError(ppToken->loc, "must be followed by macro name", "#undef", ""); + _parseContext.ppError(ppToken->loc, "must be followed by macro name", "#undef", ""); return token; } - parseContext.reservedPpErrorCheck(ppToken->loc, ppToken->name, "#undef"); + _parseContext.reservedPpErrorCheck(ppToken->loc, ppToken->name, "#undef"); symb = LookUpSymbol(ppToken->atom); if (symb) { @@ -228,7 +228,7 @@ int TPpContext::CPPundef(TPpToken* ppToken) } token = scanToken(ppToken); if (token != '\n') - parseContext.ppError(ppToken->loc, "can only be followed by a single macro name", "#undef", ""); + _parseContext.ppError(ppToken->loc, "can only be followed by a single macro name", "#undef", ""); return token; } @@ -284,7 +284,7 @@ int TPpContext::CPPelse(int matchelse, TPpToken* ppToken) break; } else if (atom == PpAtomElif) { if (elseSeen[elsetracker]) - parseContext.ppError(ppToken->loc, "#elif after #else", "#elif", ""); + _parseContext.ppError(ppToken->loc, "#elif after #else", "#elif", ""); /* we decrement ifdepth here, because CPPif will increment * it and we really want to leave it alone */ if (ifdepth) { @@ -297,13 +297,13 @@ int TPpContext::CPPelse(int matchelse, TPpToken* ppToken) } } else if (atom == PpAtomElse) { if (elseSeen[elsetracker]) - parseContext.ppError(ppToken->loc, "#else after #else", "#else", ""); + _parseContext.ppError(ppToken->loc, "#else after #else", "#else", ""); else elseSeen[elsetracker] = true; token = extraTokenCheck(atom, ppToken, scanToken(ppToken)); } else if (atom == PpAtomElif) { if (elseSeen[elsetracker]) - parseContext.ppError(ppToken->loc, "#elif after #else", "#elif", ""); + _parseContext.ppError(ppToken->loc, "#elif after #else", "#elif", ""); } } @@ -330,10 +330,10 @@ int TPpContext::extraTokenCheck(int atom, TPpToken* ppToken, int token) else label = ""; - if (parseContext.relaxedErrors()) - parseContext.ppWarn(ppToken->loc, message, label, ""); + if (_parseContext.relaxedErrors()) + _parseContext.ppWarn(ppToken->loc, message, label, ""); else - parseContext.ppError(ppToken->loc, message, label, ""); + _parseContext.ppError(ppToken->loc, message, label, ""); while (token != '\n' && token != EndOfInput) token = scanToken(ppToken); @@ -421,7 +421,7 @@ int TPpContext::eval(int token, int precedence, bool shortCircuit, int& res, boo token = scanToken(ppToken); } if (token != PpAtomIdentifier) { - parseContext.ppError(loc, "incorrect directive, expected identifier", "preprocessor evaluation", ""); + _parseContext.ppError(loc, "incorrect directive, expected identifier", "preprocessor evaluation", ""); err = true; res = 0; @@ -432,7 +432,7 @@ int TPpContext::eval(int token, int precedence, bool shortCircuit, int& res, boo token = scanToken(ppToken); if (needclose) { if (token != ')') { - parseContext.ppError(loc, "expected ')'", "preprocessor evaluation", ""); + _parseContext.ppError(loc, "expected ')'", "preprocessor evaluation", ""); err = true; res = 0; @@ -452,7 +452,7 @@ int TPpContext::eval(int token, int precedence, bool shortCircuit, int& res, boo token = eval(token, MIN_PRECEDENCE, shortCircuit, res, err, ppToken); if (! err) { if (token != ')') { - parseContext.ppError(loc, "expected ')'", "preprocessor evaluation", ""); + _parseContext.ppError(loc, "expected ')'", "preprocessor evaluation", ""); err = true; res = 0; @@ -471,7 +471,7 @@ int TPpContext::eval(int token, int precedence, bool shortCircuit, int& res, boo token = eval(token, UNARY, shortCircuit, res, err, ppToken); res = unop[op].op(res); } else { - parseContext.ppError(loc, "bad expression", "preprocessor evaluation", ""); + _parseContext.ppError(loc, "bad expression", "preprocessor evaluation", ""); err = true; res = 0; @@ -507,7 +507,7 @@ int TPpContext::eval(int token, int precedence, bool shortCircuit, int& res, boo if (binop[op].op == op_div || binop[op].op == op_mod) { if (res == 0) { - parseContext.ppError(loc, "division by 0", "preprocessor evaluation", ""); + _parseContext.ppError(loc, "division by 0", "preprocessor evaluation", ""); res = 1; } } @@ -523,19 +523,19 @@ int TPpContext::evalToToken(int token, bool shortCircuit, int& res, bool& err, T while (token == PpAtomIdentifier && ppToken->atom != PpAtomDefined) { int macroReturn = MacroExpand(ppToken->atom, ppToken, true, false); if (macroReturn == 0) { - parseContext.ppError(ppToken->loc, "can't evaluate expression", "preprocessor evaluation", ""); + _parseContext.ppError(ppToken->loc, "can't evaluate expression", "preprocessor evaluation", ""); err = true; res = 0; token = scanToken(ppToken); break; } if (macroReturn == -1) { - if (! shortCircuit && parseContext.profile == EEsProfile) { + if (! shortCircuit && _parseContext.profile == EEsProfile) { const char* message = "undefined macro in expression not allowed in es profile"; - if (parseContext.relaxedErrors()) - parseContext.ppWarn(ppToken->loc, message, "preprocessor evaluation", ppToken->name); + if (_parseContext.relaxedErrors()) + _parseContext.ppWarn(ppToken->loc, message, "preprocessor evaluation", ppToken->name); else - parseContext.ppError(ppToken->loc, message, "preprocessor evaluation", ppToken->name); + _parseContext.ppError(ppToken->loc, message, "preprocessor evaluation", ppToken->name); } } token = scanToken(ppToken); @@ -551,7 +551,7 @@ int TPpContext::CPPif(TPpToken* ppToken) elsetracker++; ifdepth++; if (ifdepth > maxIfNesting) { - parseContext.ppError(ppToken->loc, "maximum nesting depth exceeded", "#if", ""); + _parseContext.ppError(ppToken->loc, "maximum nesting depth exceeded", "#if", ""); return 0; } int res = 0; @@ -570,20 +570,20 @@ int TPpContext::CPPifdef(int defined, TPpToken* ppToken) int token = scanToken(ppToken); int name = ppToken->atom; if (++ifdepth > maxIfNesting) { - parseContext.ppError(ppToken->loc, "maximum nesting depth exceeded", "#ifdef", ""); + _parseContext.ppError(ppToken->loc, "maximum nesting depth exceeded", "#ifdef", ""); return 0; } elsetracker++; if (token != PpAtomIdentifier) { if (defined) - parseContext.ppError(ppToken->loc, "must be followed by macro name", "#ifdef", ""); + _parseContext.ppError(ppToken->loc, "must be followed by macro name", "#ifdef", ""); else - parseContext.ppError(ppToken->loc, "must be followed by macro name", "#ifndef", ""); + _parseContext.ppError(ppToken->loc, "must be followed by macro name", "#ifndef", ""); } else { Symbol *s = LookUpSymbol(name); token = scanToken(ppToken); if (token != '\n') { - parseContext.ppError(ppToken->loc, "unexpected tokens following #ifdef directive - expected a newline", "#ifdef", ""); + _parseContext.ppError(ppToken->loc, "unexpected tokens following #ifdef directive - expected a newline", "#ifdef", ""); while (token != '\n' && token != EndOfInput) token = scanToken(ppToken); } @@ -601,18 +601,18 @@ int TPpContext::CPPinclude(TPpToken* ppToken) int token = scanToken(ppToken); if (token != PpAtomConstString) { // TODO: handle angle brackets. - parseContext.ppError(directiveLoc, "must be followed by a file designation", "#include", ""); + _parseContext.ppError(directiveLoc, "must be followed by a file designation", "#include", ""); } else { // Make a copy of the name because it will be overwritten by the next token scan. const std::string filename = ppToken->name; token = scanToken(ppToken); if (token != '\n' && token != EndOfInput) { - parseContext.ppError(ppToken->loc, "extra content after file designation", "#include", ""); + _parseContext.ppError(ppToken->loc, "extra content after file designation", "#include", ""); } else { TShader::Includer::IncludeResult* res = includer.include(filename.c_str(), TShader::Includer::EIncludeRelative, currentSourceFile.c_str(), includeStack.size() + 1); if (res && !res->file_name.empty()) { if (res->file_data && res->file_length) { - const bool forNextLine = parseContext.lineDirectiveShouldSetNextLine(); + const bool forNextLine = _parseContext.lineDirectiveShouldSetNextLine(); std::ostringstream prologue; std::ostringstream epilogue; prologue << "#line " << forNextLine << " " << "\"" << res->file_name << "\"\n"; @@ -620,14 +620,14 @@ int TPpContext::CPPinclude(TPpToken* ppToken) pushInput(new TokenizableIncludeFile(directiveLoc, prologue.str(), res, epilogue.str(), this)); } // At EOF, there's no "current" location anymore. - if (token != EndOfInput) parseContext.setCurrentColumn(0); + if (token != EndOfInput) _parseContext.setCurrentColumn(0); // Don't accidentally return EndOfInput, which will end all preprocessing. return '\n'; } else { std::string message = res ? std::string(res->file_data, res->file_length) : std::string("Could not process include directive"); - parseContext.ppError(directiveLoc, message.c_str(), "#include", ""); + _parseContext.ppError(directiveLoc, message.c_str(), "#include", ""); if (res) { includer.releaseInclude(res); } @@ -647,7 +647,7 @@ int TPpContext::CPPline(TPpToken* ppToken) int token = scanToken(ppToken); const TSourceLoc directiveLoc = ppToken->loc; if (token == '\n') { - parseContext.ppError(ppToken->loc, "must by followed by an integral literal", "#line", ""); + _parseContext.ppError(ppToken->loc, "must by followed by an integral literal", "#line", ""); return token; } @@ -664,31 +664,31 @@ int TPpContext::CPPline(TPpToken* ppToken) if (token == '\n') ++lineRes; - if (parseContext.lineDirectiveShouldSetNextLine()) + if (_parseContext.lineDirectiveShouldSetNextLine()) --lineRes; - parseContext.setCurrentLine(lineRes); + _parseContext.setCurrentLine(lineRes); if (token != '\n') { if (token == PpAtomConstString) { - parseContext.ppRequireExtensions(directiveLoc, 1, &E_GL_GOOGLE_cpp_style_line_directive, "filename-based #line"); + _parseContext.ppRequireExtensions(directiveLoc, 1, &E_GL_GOOGLE_cpp_style_line_directive, "filename-based #line"); // We need to save a copy of the string instead of pointing // to the name field of the token since the name field // will likely be overwritten by the next token scan. sourceName = GetAtomString(LookUpAddString(ppToken->name)); - parseContext.setCurrentSourceName(sourceName); + _parseContext.setCurrentSourceName(sourceName); hasFile = true; token = scanToken(ppToken); } else { token = eval(token, MIN_PRECEDENCE, false, fileRes, fileErr, ppToken); if (! fileErr) { - parseContext.setCurrentString(fileRes); + _parseContext.setCurrentString(fileRes); hasFile = true; } } } } if (!fileErr && !lineErr) { - parseContext.notifyLineDirective(directiveLoc.line, lineToken, hasFile, fileRes, sourceName); + _parseContext.notifyLineDirective(directiveLoc.line, lineToken, hasFile, fileRes, sourceName); } token = extraTokenCheck(PpAtomLine, ppToken, token); @@ -718,9 +718,9 @@ int TPpContext::CPPerror(TPpToken* ppToken) message.append(" "); token = scanToken(ppToken); } - parseContext.notifyErrorDirective(loc.line, message.c_str()); + _parseContext.notifyErrorDirective(loc.line, message.c_str()); //store this msg into the shader's information log..set the Compile Error flag!!!! - parseContext.ppError(loc, message.c_str(), "#error", ""); + _parseContext.ppError(loc, message.c_str(), "#error", ""); return '\n'; } @@ -756,9 +756,9 @@ int TPpContext::CPPpragma(TPpToken* ppToken) } if (token == EndOfInput) - parseContext.ppError(loc, "directive must end with a newline", "#pragma", ""); + _parseContext.ppError(loc, "directive must end with a newline", "#pragma", ""); else - parseContext.handlePragma(loc, tokens); + _parseContext.handlePragma(loc, tokens); return token; } @@ -769,17 +769,17 @@ int TPpContext::CPPversion(TPpToken* ppToken) int token = scanToken(ppToken); if (errorOnVersion || versionSeen) - parseContext.ppError(ppToken->loc, "must occur first in shader", "#version", ""); + _parseContext.ppError(ppToken->loc, "must occur first in shader", "#version", ""); versionSeen = true; if (token == '\n') { - parseContext.ppError(ppToken->loc, "must be followed by version number", "#version", ""); + _parseContext.ppError(ppToken->loc, "must be followed by version number", "#version", ""); return token; } if (token != PpAtomConstInt) - parseContext.ppError(ppToken->loc, "must be followed by version number", "#version", ""); + _parseContext.ppError(ppToken->loc, "must be followed by version number", "#version", ""); ppToken->ival = atoi(ppToken->name); int versionNumber = ppToken->ival; @@ -787,20 +787,20 @@ int TPpContext::CPPversion(TPpToken* ppToken) token = scanToken(ppToken); if (token == '\n') { - parseContext.notifyVersion(line, versionNumber, nullptr); + _parseContext.notifyVersion(line, versionNumber, nullptr); return token; } else { if (ppToken->atom != PpAtomCore && ppToken->atom != PpAtomCompatibility && ppToken->atom != PpAtomEs) - parseContext.ppError(ppToken->loc, "bad profile name; use es, core, or compatibility", "#version", ""); - parseContext.notifyVersion(line, versionNumber, ppToken->name); + _parseContext.ppError(ppToken->loc, "bad profile name; use es, core, or compatibility", "#version", ""); + _parseContext.notifyVersion(line, versionNumber, ppToken->name); token = scanToken(ppToken); if (token == '\n') return token; else - parseContext.ppError(ppToken->loc, "bad tokens following profile -- expected newline", "#version", ""); + _parseContext.ppError(ppToken->loc, "bad tokens following profile -- expected newline", "#version", ""); } return token; @@ -814,36 +814,36 @@ int TPpContext::CPPextension(TPpToken* ppToken) char extensionName[MaxTokenLength + 1]; if (token=='\n') { - parseContext.ppError(ppToken->loc, "extension name not specified", "#extension", ""); + _parseContext.ppError(ppToken->loc, "extension name not specified", "#extension", ""); return token; } if (token != PpAtomIdentifier) - parseContext.ppError(ppToken->loc, "extension name expected", "#extension", ""); + _parseContext.ppError(ppToken->loc, "extension name expected", "#extension", ""); assert(strlen(ppToken->name) <= MaxTokenLength); strcpy(extensionName, ppToken->name); token = scanToken(ppToken); if (token != ':') { - parseContext.ppError(ppToken->loc, "':' missing after extension name", "#extension", ""); + _parseContext.ppError(ppToken->loc, "':' missing after extension name", "#extension", ""); return token; } token = scanToken(ppToken); if (token != PpAtomIdentifier) { - parseContext.ppError(ppToken->loc, "behavior for extension not specified", "#extension", ""); + _parseContext.ppError(ppToken->loc, "behavior for extension not specified", "#extension", ""); return token; } - parseContext.updateExtensionBehavior(line, extensionName, ppToken->name); - parseContext.notifyExtensionDirective(line, extensionName, ppToken->name); + _parseContext.updateExtensionBehavior(line, extensionName, ppToken->name); + _parseContext.notifyExtensionDirective(line, extensionName, ppToken->name); token = scanToken(ppToken); if (token == '\n') return token; else - parseContext.ppError(ppToken->loc, "extra tokens -- expected newline", "#extension",""); + _parseContext.ppError(ppToken->loc, "extra tokens -- expected newline", "#extension",""); return token; } @@ -859,18 +859,18 @@ int TPpContext::readCPPline(TPpToken* ppToken) break; case PpAtomElse: if (elsetracker[elseSeen]) - parseContext.ppError(ppToken->loc, "#else after #else", "#else", ""); + _parseContext.ppError(ppToken->loc, "#else after #else", "#else", ""); elsetracker[elseSeen] = true; if (! ifdepth) - parseContext.ppError(ppToken->loc, "mismatched statements", "#else", ""); + _parseContext.ppError(ppToken->loc, "mismatched statements", "#else", ""); token = extraTokenCheck(PpAtomElse, ppToken, scanToken(ppToken)); token = CPPelse(0, ppToken); break; case PpAtomElif: if (! ifdepth) - parseContext.ppError(ppToken->loc, "mismatched statements", "#elif", ""); + _parseContext.ppError(ppToken->loc, "mismatched statements", "#elif", ""); if (elseSeen[elsetracker]) - parseContext.ppError(ppToken->loc, "#elif after #else", "#elif", ""); + _parseContext.ppError(ppToken->loc, "#elif after #else", "#elif", ""); // this token is really a dont care, but we still need to eat the tokens token = scanToken(ppToken); while (token != '\n' && token != EndOfInput) @@ -879,7 +879,7 @@ int TPpContext::readCPPline(TPpToken* ppToken) break; case PpAtomEndif: if (! ifdepth) - parseContext.ppError(ppToken->loc, "mismatched statements", "#endif", ""); + _parseContext.ppError(ppToken->loc, "mismatched statements", "#endif", ""); else { elseSeen[elsetracker] = false; --elsetracker; @@ -897,8 +897,8 @@ int TPpContext::readCPPline(TPpToken* ppToken) token = CPPifdef(0, ppToken); break; case PpAtomInclude: - if(!parseContext.isReadingHLSL()) { - parseContext.ppRequireExtensions(ppToken->loc, 1, &E_GL_GOOGLE_include_directive, "#include"); + if(!_parseContext.isReadingHLSL()) { + _parseContext.ppRequireExtensions(ppToken->loc, 1, &E_GL_GOOGLE_include_directive, "#include"); } token = CPPinclude(ppToken); break; @@ -921,11 +921,11 @@ int TPpContext::readCPPline(TPpToken* ppToken) token = CPPextension(ppToken); break; default: - parseContext.ppError(ppToken->loc, "invalid directive:", "#", ppToken->name); + _parseContext.ppError(ppToken->loc, "invalid directive:", "#", ppToken->name); break; } } else if (token != '\n' && token != EndOfInput) - parseContext.ppError(ppToken->loc, "invalid directive", "#", ""); + _parseContext.ppError(ppToken->loc, "invalid directive", "#", ""); while (token != '\n' && token != EndOfInput) token = scanToken(ppToken); @@ -1017,22 +1017,22 @@ int TPpContext::MacroExpand(int atom, TPpToken* ppToken, bool expandUndef, bool ppToken->space = false; switch (atom) { case PpAtomLineMacro: - ppToken->ival = parseContext.getCurrentLoc().line; + ppToken->ival = _parseContext.getCurrentLoc().line; snprintf(ppToken->name, sizeof(ppToken->name), "%d", ppToken->ival); UngetToken(PpAtomConstInt, ppToken); return 1; case PpAtomFileMacro: { - if (parseContext.getCurrentLoc().name) - parseContext.ppRequireExtensions(ppToken->loc, 1, &E_GL_GOOGLE_cpp_style_line_directive, "filename-based __FILE__"); - ppToken->ival = parseContext.getCurrentLoc().string; + if (_parseContext.getCurrentLoc().name) + _parseContext.ppRequireExtensions(ppToken->loc, 1, &E_GL_GOOGLE_cpp_style_line_directive, "filename-based __FILE__"); + ppToken->ival = _parseContext.getCurrentLoc().string; snprintf(ppToken->name, sizeof(ppToken->name), "%s", ppToken->loc.getStringNameOrNum().c_str()); UngetToken(PpAtomConstInt, ppToken); return 1; } case PpAtomVersionMacro: - ppToken->ival = parseContext.version; + ppToken->ival = _parseContext.version; snprintf(ppToken->name, sizeof(ppToken->name), "%d", ppToken->ival); UngetToken(PpAtomConstInt, ppToken); return 1; @@ -1070,7 +1070,7 @@ int TPpContext::MacroExpand(int atom, TPpToken* ppToken, bool expandUndef, bool token = scanToken(ppToken); } if (token != '(') { - parseContext.ppError(loc, "expected '(' following", "macro expansion", GetAtomString(atom)); + _parseContext.ppError(loc, "expected '(' following", "macro expansion", GetAtomString(atom)); UngetToken(token, ppToken); ppToken->atom = atom; @@ -1087,20 +1087,20 @@ int TPpContext::MacroExpand(int atom, TPpToken* ppToken, bool expandUndef, bool while (1) { token = scanToken(ppToken); if (token == EndOfInput) { - parseContext.ppError(loc, "End of input in macro", "macro expansion", GetAtomString(atom)); + _parseContext.ppError(loc, "End of input in macro", "macro expansion", GetAtomString(atom)); delete in; return 0; } if (token == '\n') { if (! newLineOkay) { - parseContext.ppError(loc, "End of line in macro substitution:", "macro expansion", GetAtomString(atom)); + _parseContext.ppError(loc, "End of line in macro substitution:", "macro expansion", GetAtomString(atom)); delete in; return 0; } continue; } if (token == '#') { - parseContext.ppError(ppToken->loc, "unexpected '#'", "macro expansion", GetAtomString(atom)); + _parseContext.ppError(ppToken->loc, "unexpected '#'", "macro expansion", GetAtomString(atom)); delete in; return 0; } @@ -1125,7 +1125,7 @@ int TPpContext::MacroExpand(int atom, TPpToken* ppToken, bool expandUndef, bool } while (arg < in->mac->argc); if (arg < in->mac->argc) - parseContext.ppError(loc, "Too few args in Macro", "macro expansion", GetAtomString(atom)); + _parseContext.ppError(loc, "Too few args in Macro", "macro expansion", GetAtomString(atom)); else if (token != ')') { depth=0; while (token != EndOfInput && (depth > 0 || token != ')')) { @@ -1137,11 +1137,11 @@ int TPpContext::MacroExpand(int atom, TPpToken* ppToken, bool expandUndef, bool } if (token == EndOfInput) { - parseContext.ppError(loc, "End of input in macro", "macro expansion", GetAtomString(atom)); + _parseContext.ppError(loc, "End of input in macro", "macro expansion", GetAtomString(atom)); delete in; return 0; } - parseContext.ppError(loc, "Too many args in macro", "macro expansion", GetAtomString(atom)); + _parseContext.ppError(loc, "Too many args in macro", "macro expansion", GetAtomString(atom)); } for (int i = 0; i < in->mac->argc; i++) in->args[i] = PrescanMacroArg(in->args[i], ppToken, newLineOkay); diff --git a/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpContext.cpp b/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpContext.cpp index 6791fef599..c0bbda814c 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpContext.cpp +++ b/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpContext.cpp @@ -83,7 +83,7 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace glslang { TPpContext::TPpContext(TParseContextBase& pc, const std::string& rootFileName, TShader::Includer& inclr) : - preamble(0), strings(0), parseContext(pc), includer(inclr), inComment(false), + preamble(0), strings(0), _parseContext(pc), includer(inclr), inComment(false), rootFileName(rootFileName), currentSourceFile(rootFileName) { diff --git a/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpContext.h b/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpContext.h index f1c2f31108..dcd858efab 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpContext.h +++ b/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpContext.h @@ -215,7 +215,7 @@ protected: // Scanner data: int previous_token; - TParseContextBase& parseContext; + TParseContextBase& _parseContext; // Get the next token from *stack* of input sources, popping input sources // that are out of tokens, down until an input source is found that has a token. @@ -372,7 +372,7 @@ protected: // Move past escaped newlines, as many as sequentially exist do { if (input->peek() == '\r' || input->peek() == '\n') { - bool allowed = pp->parseContext.lineContinuationCheck(input->getSourceLoc(), pp->inComment); + bool allowed = pp->_parseContext.lineContinuationCheck(input->getSourceLoc(), pp->inComment); if (! allowed && pp->inComment) return '\\'; @@ -475,14 +475,14 @@ protected: void notifyActivated() override { - prevScanner = pp->parseContext.getScanner(); - pp->parseContext.setScanner(&scanner); + prevScanner = pp->_parseContext.getScanner(); + pp->_parseContext.setScanner(&scanner); pp->push_include(includedFile_); } void notifyDeleted() override { - pp->parseContext.setScanner(prevScanner); + pp->_parseContext.setScanner(prevScanner); pp->pop_include(); } diff --git a/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpScanner.cpp b/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpScanner.cpp index 518dbdee4c..0113532dc4 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpScanner.cpp +++ b/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpScanner.cpp @@ -140,7 +140,7 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken) } ch = getChar(); } else { - parseContext.ppError(ppToken->loc, "float literal too long", "", ""); + _parseContext.ppError(ppToken->loc, "float literal too long", "", ""); len = 1; str_len = 1; } @@ -152,7 +152,7 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken) if (ch == 'e' || ch == 'E') { HasDecimalOrExponent = true; if (len >= MaxTokenLength) { - parseContext.ppError(ppToken->loc, "float literal too long", "", ""); + _parseContext.ppError(ppToken->loc, "float literal too long", "", ""); len = 1; str_len = 1; } else { @@ -171,13 +171,13 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken) str[len++] = (char)ch; ch = getChar(); } else { - parseContext.ppError(ppToken->loc, "float literal too long", "", ""); + _parseContext.ppError(ppToken->loc, "float literal too long", "", ""); len = 1; str_len = 1; } } } else { - parseContext.ppError(ppToken->loc, "bad character in float exponent", "", ""); + _parseContext.ppError(ppToken->loc, "bad character in float exponent", "", ""); } } } @@ -187,9 +187,9 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken) strcpy(str, "0.0"); } else { if (ch == 'l' || ch == 'L') { - parseContext.doubleCheck(ppToken->loc, "double floating-point suffix"); + _parseContext.doubleCheck(ppToken->loc, "double floating-point suffix"); if (! HasDecimalOrExponent) - parseContext.ppError(ppToken->loc, "float literal needs a decimal point or exponent", "", ""); + _parseContext.ppError(ppToken->loc, "float literal needs a decimal point or exponent", "", ""); int ch2 = getChar(); if (ch2 != 'f' && ch2 != 'F') { ungetChar(); @@ -200,7 +200,7 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken) str[len++] = (char)ch2; isDouble = 1; } else { - parseContext.ppError(ppToken->loc, "float literal too long", "", ""); + _parseContext.ppError(ppToken->loc, "float literal too long", "", ""); len = 1,str_len=1; } } @@ -227,15 +227,15 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken) } #endif } else if (ch == 'f' || ch == 'F') { - parseContext.profileRequires(ppToken->loc, EEsProfile, 300, nullptr, "floating-point suffix"); - if (! parseContext.relaxedErrors()) - parseContext.profileRequires(ppToken->loc, ~EEsProfile, 120, nullptr, "floating-point suffix"); + _parseContext.profileRequires(ppToken->loc, EEsProfile, 300, nullptr, "floating-point suffix"); + if (!_parseContext.relaxedErrors()) + _parseContext.profileRequires(ppToken->loc, ~EEsProfile, 120, nullptr, "floating-point suffix"); if (! HasDecimalOrExponent) - parseContext.ppError(ppToken->loc, "float literal needs a decimal point or exponent", "", ""); + _parseContext.ppError(ppToken->loc, "float literal needs a decimal point or exponent", "", ""); if (len < MaxTokenLength) str[len++] = (char)ch; else { - parseContext.ppError(ppToken->loc, "float literal too long", "", ""); + _parseContext.ppError(ppToken->loc, "float literal too long", "", ""); len = 1,str_len=1; } } else @@ -267,7 +267,7 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken) int ch = 0; int ii = 0; unsigned long long ival = 0; - bool enableInt64 = pp->parseContext.version >= 450 && pp->parseContext.extensionTurnedOn(E_GL_ARB_gpu_shader_int64); + bool enableInt64 = pp->_parseContext.version >= 450 && pp->_parseContext.extensionTurnedOn(E_GL_ARB_gpu_shader_int64); ppToken->ival = 0; ppToken->i64val = 0; @@ -279,7 +279,7 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken) ch = getch(); } - ppToken->loc = pp->parseContext.getCurrentLoc(); + ppToken->loc = pp->_parseContext.getCurrentLoc(); len = 0; switch (ch) { default: @@ -304,7 +304,7 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken) ch = getch(); } else { if (! AlreadyComplained) { - pp->parseContext.ppError(ppToken->loc, "name too long", "", ""); + pp->_parseContext.ppError(ppToken->loc, "name too long", "", ""); AlreadyComplained = 1; } ch = getch(); @@ -347,11 +347,11 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken) } else if (ch >= 'a' && ch <= 'f') { ii = ch - 'a' + 10; } else - pp->parseContext.ppError(ppToken->loc, "bad digit in hexadecimal literal", "", ""); + pp->_parseContext.ppError(ppToken->loc, "bad digit in hexadecimal literal", "", ""); ival = (ival << 4) | ii; } else { if (! AlreadyComplained) { - pp->parseContext.ppError(ppToken->loc, "hexadecimal literal too big", "", ""); + pp->_parseContext.ppError(ppToken->loc, "hexadecimal literal too big", "", ""); AlreadyComplained = 1; } ival = 0xffffffffffffffffull; @@ -361,7 +361,7 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken) (ch >= 'A' && ch <= 'F') || (ch >= 'a' && ch <= 'f')); } else { - pp->parseContext.ppError(ppToken->loc, "bad digit in hexadecimal literal", "", ""); + pp->_parseContext.ppError(ppToken->loc, "bad digit in hexadecimal literal", "", ""); } if (ch == 'u' || ch == 'U') { if (len < MaxTokenLength) @@ -407,7 +407,7 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken) if (len < MaxTokenLength) ppToken->name[len++] = (char)ch; else if (! AlreadyComplained) { - pp->parseContext.ppError(ppToken->loc, "numeric literal too long", "", ""); + pp->_parseContext.ppError(ppToken->loc, "numeric literal too long", "", ""); AlreadyComplained = 1; } if (ival <= 0x1fffffff || (enableInt64 && ival <= 0x1fffffffffffffffull)) { @@ -425,7 +425,7 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken) if (len < MaxTokenLength) ppToken->name[len++] = (char)ch; else if (! AlreadyComplained) { - pp->parseContext.ppError(ppToken->loc, "numeric literal too long", "", ""); + pp->_parseContext.ppError(ppToken->loc, "numeric literal too long", "", ""); AlreadyComplained = 1; } ch = getch(); @@ -436,7 +436,7 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken) // wasn't a float, so must be octal... if (nonOctal) - pp->parseContext.ppError(ppToken->loc, "octal literal digit too large", "", ""); + pp->_parseContext.ppError(ppToken->loc, "octal literal digit too large", "", ""); if (ch == 'u' || ch == 'U') { if (len < MaxTokenLength) @@ -462,7 +462,7 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken) ppToken->name[len] = '\0'; if (octalOverflow) - pp->parseContext.ppError(ppToken->loc, "octal literal too big", "", ""); + pp->_parseContext.ppError(ppToken->loc, "octal literal too big", "", ""); if (isInt64) { ppToken->i64val = ival; @@ -481,7 +481,7 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken) if (len < MaxTokenLength) ppToken->name[len++] = (char)ch; else if (! AlreadyComplained) { - pp->parseContext.ppError(ppToken->loc, "numeric literal too long", "", ""); + pp->_parseContext.ppError(ppToken->loc, "numeric literal too long", "", ""); AlreadyComplained = 1; } ch = getch(); @@ -524,7 +524,7 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken) ch = ppToken->name[i] - '0'; if ((enableInt64 == false && ((ival > oneTenthMaxInt) || (ival == oneTenthMaxInt && (unsigned)ch > remainderMaxInt))) || (enableInt64 && ((ival > oneTenthMaxInt64) || (ival == oneTenthMaxInt64 && (unsigned long long)ch > remainderMaxInt64)))) { - pp->parseContext.ppError(ppToken->loc, "numeric literal too big", "", ""); + pp->_parseContext.ppError(ppToken->loc, "numeric literal too big", "", ""); ival = 0xFFFFFFFFFFFFFFFFull; break; } else @@ -682,14 +682,14 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken) do { while (ch != '*') { if (ch == EndOfInput) { - pp->parseContext.ppError(ppToken->loc, "End of input in comment", "comment", ""); + pp->_parseContext.ppError(ppToken->loc, "End of input in comment", "comment", ""); return ch; } ch = getch(); } ch = getch(); if (ch == EndOfInput) { - pp->parseContext.ppError(ppToken->loc, "End of input in comment", "comment", ""); + pp->_parseContext.ppError(ppToken->loc, "End of input in comment", "comment", ""); return ch; } } while (ch != '/'); @@ -716,7 +716,7 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken) tokenText[len] = '\0'; if (ch != '"') { ungetch(); - pp->parseContext.ppError(ppToken->loc, "End of line in string", "string", ""); + pp->_parseContext.ppError(ppToken->loc, "End of line in string", "string", ""); } return PpAtomConstString; } @@ -752,7 +752,7 @@ const char* TPpContext::tokenize(TPpToken* ppToken) } continue; } else { - parseContext.ppError(ppToken->loc, "preprocessor directive cannot be preceded by another token", "#", ""); + _parseContext.ppError(ppToken->loc, "preprocessor directive cannot be preceded by another token", "#", ""); return nullptr; } } @@ -780,15 +780,15 @@ const char* TPpContext::tokenize(TPpToken* ppToken) tokenString = ppToken->name; break; case PpAtomConstString: - if (parseContext.intermediate.getSource() == EShSourceHlsl) { + if (_parseContext.intermediate.getSource() == EShSourceHlsl) { // HLSL allows string literals. tokenString = ppToken->name; } else { - parseContext.ppError(ppToken->loc, "string literals not supported", "\"\"", ""); + _parseContext.ppError(ppToken->loc, "string literals not supported", "\"\"", ""); } break; case '\'': - parseContext.ppError(ppToken->loc, "character literals not supported", "\'", ""); + _parseContext.ppError(ppToken->loc, "character literals not supported", "\'", ""); break; default: tokenString = GetAtomString(token); @@ -804,7 +804,7 @@ const char* TPpContext::tokenize(TPpToken* ppToken) void TPpContext::missingEndifCheck() { if (ifdepth > 0) - parseContext.ppError(parseContext.getCurrentLoc(), "missing #endif", "", ""); + _parseContext.ppError(_parseContext.getCurrentLoc(), "missing #endif", "", ""); } } // end namespace glslang diff --git a/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpTokens.cpp b/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpTokens.cpp index 23b617d37c..25e1720c0d 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpTokens.cpp +++ b/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpTokens.cpp @@ -177,7 +177,7 @@ int TPpContext::ReadToken(TokenStream *pTok, TPpToken *ppToken) int ch; ltoken = lReadByte(pTok); - ppToken->loc = parseContext.getCurrentLoc(); + ppToken->loc = _parseContext.getCurrentLoc(); if (ltoken > 127) ltoken += 128; switch (ltoken) { @@ -185,9 +185,9 @@ int TPpContext::ReadToken(TokenStream *pTok, TPpToken *ppToken) // Check for ##, unless the current # is the last character if (pTok->current < pTok->data.size()) { if (lReadByte(pTok) == '#') { - parseContext.requireProfile(ppToken->loc, ~EEsProfile, "token pasting (##)"); - parseContext.profileRequires(ppToken->loc, ~EEsProfile, 130, 0, "token pasting (##)"); - parseContext.error(ppToken->loc, "token pasting not implemented (internal error)", "##", ""); + _parseContext.requireProfile(ppToken->loc, ~EEsProfile, "token pasting (##)"); + _parseContext.profileRequires(ppToken->loc, ~EEsProfile, 130, 0, "token pasting (##)"); + _parseContext.error(ppToken->loc, "token pasting not implemented (internal error)", "##", ""); //return PpAtomPaste; return ReadToken(pTok, ppToken); } else @@ -213,7 +213,7 @@ int TPpContext::ReadToken(TokenStream *pTok, TPpToken *ppToken) len++; ch = lReadByte(pTok); } else { - parseContext.error(ppToken->loc, "token too long", "", ""); + _parseContext.error(ppToken->loc, "token too long", "", ""); break; } } diff --git a/deps/glslang/glslang/glslang/OSDependent/Windows/ossource.cpp b/deps/glslang/glslang/glslang/OSDependent/Windows/ossource.cpp index f71fac9cb6..2edde83870 100644 --- a/deps/glslang/glslang/glslang/OSDependent/Windows/ossource.cpp +++ b/deps/glslang/glslang/glslang/OSDependent/Windows/ossource.cpp @@ -31,9 +31,9 @@ //ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE //POSSIBILITY OF SUCH DAMAGE. // - #include "../osinclude.h" +#undef STRICT #define STRICT #define VC_EXTRALEAN 1 #include diff --git a/deps/glslang/glslang/hlsl/hlslGrammar.cpp b/deps/glslang/glslang/hlsl/hlslGrammar.cpp index e676e95e10..c9152e2a14 100755 --- a/deps/glslang/glslang/hlsl/hlslGrammar.cpp +++ b/deps/glslang/glslang/hlsl/hlslGrammar.cpp @@ -67,12 +67,12 @@ bool HlslGrammar::parse() void HlslGrammar::expected(const char* syntax) { - parseContext.error(token.loc, "Expected", syntax, ""); + _parseContext.error(token.loc, "Expected", syntax, ""); } void HlslGrammar::unimplemented(const char* error) { - parseContext.error(token.loc, "Unimplemented", error, ""); + _parseContext.error(token.loc, "Unimplemented", error, ""); } // Only process the next token if it is an identifier. @@ -154,7 +154,7 @@ bool HlslGrammar::acceptSamplerState() if (! acceptTokenClass(EHTokLeftBrace)) return true; - parseContext.warn(token.loc, "unimplemented", "immediate sampler state", ""); + _parseContext.warn(token.loc, "unimplemented", "immediate sampler state", ""); do { // read state name @@ -311,7 +311,7 @@ bool HlslGrammar::acceptDeclaration(TIntermNode*& node) TString* fnName = idToken.string; // Potentially rename shader entry point function. No-op most of the time. - parseContext.renameShaderFunction(fnName); + _parseContext.renameShaderFunction(fnName); // function_parameters TFunction& function = *new TFunction(fnName, declaredType); @@ -322,18 +322,18 @@ bool HlslGrammar::acceptDeclaration(TIntermNode*& node) // compound_statement (function body definition) or just a prototype? if (peekTokenClass(EHTokLeftBrace)) { if (list) - parseContext.error(idToken.loc, "function body can't be in a declarator list", "{", ""); + _parseContext.error(idToken.loc, "function body can't be in a declarator list", "{", ""); if (typedefDecl) - parseContext.error(idToken.loc, "function body can't be in a typedef", "{", ""); + _parseContext.error(idToken.loc, "function body can't be in a typedef", "{", ""); return acceptFunctionDefinition(function, node, attributes); } else { if (typedefDecl) - parseContext.error(idToken.loc, "function typedefs not implemented", "{", ""); - parseContext.handleFunctionDeclarator(idToken.loc, function, true); + _parseContext.error(idToken.loc, "function typedefs not implemented", "{", ""); + _parseContext.handleFunctionDeclarator(idToken.loc, function, true); } } else { // A variable declaration. Fix the storage qualifier if it's a global. - if (declaredType.getQualifier().storage == EvqTemporary && parseContext.symbolTable.atGlobalLevel()) + if (declaredType.getQualifier().storage == EvqTemporary && _parseContext.symbolTable.atGlobalLevel()) declaredType.getQualifier().storage = EvqUniform; // We can handle multiple variables per type declaration, so @@ -356,7 +356,7 @@ bool HlslGrammar::acceptDeclaration(TIntermNode*& node) // In the most general case, arrayness is potentially coming both from the // declared type and from the variable: "int[] a[];" or just one or the other. // Merge it all to the variableType, so all arrayness is part of the variableType. - parseContext.arrayDimMerge(variableType, arraySizes); + _parseContext.arrayDimMerge(variableType, arraySizes); } // samplers accept immediate sampler state @@ -372,7 +372,7 @@ bool HlslGrammar::acceptDeclaration(TIntermNode*& node) TIntermTyped* expressionNode = nullptr; if (acceptTokenClass(EHTokAssign)) { if (typedefDecl) - parseContext.error(idToken.loc, "can't have an initializer", "typedef", ""); + _parseContext.error(idToken.loc, "can't have an initializer", "typedef", ""); if (! acceptAssignmentExpression(expressionNode)) { expected("initializer"); return false; @@ -383,21 +383,21 @@ bool HlslGrammar::acceptDeclaration(TIntermNode*& node) // TODO: things scoped within an annotation need their own name space; // TODO: strings are not yet handled. - if (variableType.getBasicType() != EbtString && parseContext.getAnnotationNestingLevel() == 0) { + if (variableType.getBasicType() != EbtString && _parseContext.getAnnotationNestingLevel() == 0) { if (typedefDecl) - parseContext.declareTypedef(idToken.loc, *idToken.string, variableType); + _parseContext.declareTypedef(idToken.loc, *idToken.string, variableType); else if (variableType.getBasicType() == EbtBlock) - parseContext.declareBlock(idToken.loc, variableType, idToken.string); + _parseContext.declareBlock(idToken.loc, variableType, idToken.string); else { if (variableType.getQualifier().storage == EvqUniform && ! variableType.containsOpaque()) { // this isn't really an individual variable, but a member of the $Global buffer - parseContext.growGlobalUniformBlock(idToken.loc, variableType, *idToken.string); + _parseContext.growGlobalUniformBlock(idToken.loc, variableType, *idToken.string); } else { // Declare the variable and add any initializer code to the AST. // The top-level node is always made into an aggregate, as that's // historically how the AST has been. node = intermediate.growAggregate(node, - parseContext.declareVariable(idToken.loc, *idToken.string, variableType, + _parseContext.declareVariable(idToken.loc, *idToken.string, variableType, expressionNode), idToken.loc); } @@ -456,7 +456,7 @@ bool HlslGrammar::acceptControlDeclaration(TIntermNode*& node) return false; } - node = parseContext.declareVariable(idToken.loc, *idToken.string, type, expressionNode); + node = _parseContext.declareVariable(idToken.loc, *idToken.string, type, expressionNode); return true; } @@ -479,10 +479,10 @@ bool HlslGrammar::acceptFullySpecifiedType(TType& type) return false; if (type.getBasicType() == EbtBlock) { // the type was a block, which set some parts of the qualifier - parseContext.mergeQualifiers(type.getQualifier(), qualifier); + _parseContext.mergeQualifiers(type.getQualifier(), qualifier); // further, it can create an anonymous instance of the block if (peekTokenClass(EHTokSemicolon)) - parseContext.declareBlock(loc, type); + _parseContext.declareBlock(loc, type); } else { // Some qualifiers are set when parsing the type. Merge those with // whatever comes from acceptQualifier. @@ -510,7 +510,7 @@ bool HlslGrammar::acceptQualifier(TQualifier& qualifier) do { switch (peek()) { case EHTokStatic: - qualifier.storage = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + qualifier.storage = _parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; break; case EHTokExtern: // TODO: no meaning in glslang? @@ -572,27 +572,27 @@ bool HlslGrammar::acceptQualifier(TQualifier& qualifier) // for output variables. case EHTokPoint: qualifier.storage = EvqIn; - if (!parseContext.handleInputGeometry(token.loc, ElgPoints)) + if (!_parseContext.handleInputGeometry(token.loc, ElgPoints)) return false; break; case EHTokLine: qualifier.storage = EvqIn; - if (!parseContext.handleInputGeometry(token.loc, ElgLines)) + if (!_parseContext.handleInputGeometry(token.loc, ElgLines)) return false; break; case EHTokTriangle: qualifier.storage = EvqIn; - if (!parseContext.handleInputGeometry(token.loc, ElgTriangles)) + if (!_parseContext.handleInputGeometry(token.loc, ElgTriangles)) return false; break; case EHTokLineAdj: qualifier.storage = EvqIn; - if (!parseContext.handleInputGeometry(token.loc, ElgLinesAdjacency)) + if (!_parseContext.handleInputGeometry(token.loc, ElgLinesAdjacency)) return false; break; case EHTokTriangleAdj: qualifier.storage = EvqIn; - if (!parseContext.handleInputGeometry(token.loc, ElgTrianglesAdjacency)) + if (!_parseContext.handleInputGeometry(token.loc, ElgTrianglesAdjacency)) return false; break; @@ -634,9 +634,9 @@ bool HlslGrammar::acceptLayoutQualifierList(TQualifier& qualifier) expected("expression"); return false; } - parseContext.setLayoutQualifier(idToken.loc, qualifier, *idToken.string, expr); + _parseContext.setLayoutQualifier(idToken.loc, qualifier, *idToken.string, expr); } else - parseContext.setLayoutQualifier(idToken.loc, qualifier, *idToken.string); + _parseContext.setLayoutQualifier(idToken.loc, qualifier, *idToken.string); // COMMA if (! acceptTokenClass(EHTokComma)) @@ -864,7 +864,7 @@ bool HlslGrammar::acceptAnnotations(TQualifier&) return false; // note that we are nesting a name space - parseContext.nestAnnotations(); + _parseContext.nestAnnotations(); // declaration SEMI_COLON ... declaration SEMICOLON RIGHT_ANGLE do { @@ -883,7 +883,7 @@ bool HlslGrammar::acceptAnnotations(TQualifier&) } } while (true); - parseContext.unnestAnnotations(); + _parseContext.unnestAnnotations(); return true; } @@ -1045,7 +1045,7 @@ bool HlslGrammar::acceptTextureType(TType& type) // Buffer, RWBuffer and RWTexture (images) require a TLayoutFormat. We handle only a limit set. if (image || dim == EsdBuffer) - format = parseContext.getLayoutFromTxType(token.loc, txType); + format = _parseContext.getLayoutFromTxType(token.loc, txType); // Non-image Buffers are combined if (dim == EsdBuffer && !image) { @@ -1099,7 +1099,7 @@ bool HlslGrammar::acceptType(TType& type) if (! acceptStreamOutTemplateType(type, geometry)) return false; - if (! parseContext.handleOutputGeometry(token.loc, geometry)) + if (!_parseContext.handleOutputGeometry(token.loc, geometry)) return false; return true; @@ -1144,7 +1144,7 @@ bool HlslGrammar::acceptType(TType& type) // An identifier could be for a user-defined type. // Note we cache the symbol table lookup, to save for a later rule // when this is not a type. - token.symbol = parseContext.symbolTable.find(*token.string); + token.symbol = _parseContext.symbolTable.find(*token.string); if (token.symbol && token.symbol->getAsVariable() && token.symbol->getAsVariable()->isUserType()) { type.shallowCopy(token.symbol->getType()); advanceToken(); @@ -1655,8 +1655,8 @@ bool HlslGrammar::acceptStruct(TType& type) // case the name is not a type.) if (type.getBasicType() != EbtBlock && structName.size() > 0) { TVariable* userTypeDef = new TVariable(&structName, type, true); - if (! parseContext.symbolTable.insert(*userTypeDef)) - parseContext.error(token.loc, "redefinition", structName.c_str(), "struct"); + if (!_parseContext.symbolTable.insert(*userTypeDef)) + _parseContext.error(token.loc, "redefinition", structName.c_str(), "struct"); } return true; @@ -1788,7 +1788,7 @@ bool HlslGrammar::acceptParameterDeclaration(TFunction& function) acceptArraySpecifier(arraySizes); if (arraySizes) { if (arraySizes->isImplicit()) { - parseContext.error(token.loc, "function parameter array cannot be implicitly sized", "", ""); + _parseContext.error(token.loc, "function parameter array cannot be implicitly sized", "", ""); return false; } @@ -1798,7 +1798,7 @@ bool HlslGrammar::acceptParameterDeclaration(TFunction& function) // post_decls acceptPostDecls(type->getQualifier()); - parseContext.paramFix(*type); + _parseContext.paramFix(*type); TParameter param = { idToken.string, type }; function.addParameter(param); @@ -1810,16 +1810,16 @@ bool HlslGrammar::acceptParameterDeclaration(TFunction& function) // parsing the body (compound_statement). bool HlslGrammar::acceptFunctionDefinition(TFunction& function, TIntermNode*& node, const TAttributeMap& attributes) { - TFunction& functionDeclarator = parseContext.handleFunctionDeclarator(token.loc, function, false /* not prototype */); + TFunction& functionDeclarator = _parseContext.handleFunctionDeclarator(token.loc, function, false /* not prototype */); TSourceLoc loc = token.loc; // This does a pushScope() - node = parseContext.handleFunctionDefinition(loc, functionDeclarator, attributes); + node = _parseContext.handleFunctionDefinition(loc, functionDeclarator, attributes); // compound_statement TIntermNode* functionBody = nullptr; if (acceptCompoundStatement(functionBody)) { - parseContext.handleFunctionBody(loc, functionDeclarator, functionBody, node); + _parseContext.handleFunctionBody(loc, functionDeclarator, functionBody, node); return true; } @@ -1991,11 +1991,11 @@ bool HlslGrammar::acceptAssignmentExpression(TIntermTyped*& node) return false; } - node = parseContext.handleAssign(loc, assignOp, node, rightNode); - node = parseContext.handleLvalue(loc, "assign", node); + node = _parseContext.handleAssign(loc, assignOp, node, rightNode); + node = _parseContext.handleLvalue(loc, "assign", node); if (node == nullptr) { - parseContext.error(loc, "could not create assignment", "", ""); + _parseContext.error(loc, "could not create assignment", "", ""); return false; } @@ -2083,7 +2083,7 @@ bool HlslGrammar::acceptBinaryExpression(TIntermTyped*& node, PrecedenceLevel pr node = intermediate.addBinaryMath(op, node, rightNode, loc); if (node == nullptr) { - parseContext.error(loc, "Could not perform requested binary operation", "", ""); + _parseContext.error(loc, "Could not perform requested binary operation", "", ""); return false; } } while (true); @@ -2114,14 +2114,14 @@ bool HlslGrammar::acceptUnaryExpression(TIntermTyped*& node) return false; // Hook it up like a constructor - TFunction* constructorFunction = parseContext.handleConstructorCall(loc, castType); + TFunction* constructorFunction = _parseContext.handleConstructorCall(loc, castType); if (constructorFunction == nullptr) { expected("type that can be constructed"); return false; } TIntermTyped* arguments = nullptr; - parseContext.handleFunctionArgument(constructorFunction, arguments, node); - node = parseContext.handleFunctionCall(loc, constructorFunction, arguments); + _parseContext.handleFunctionArgument(constructorFunction, arguments, node); + node = _parseContext.handleFunctionCall(loc, constructorFunction, arguments); return true; } else { @@ -2160,7 +2160,7 @@ bool HlslGrammar::acceptUnaryExpression(TIntermTyped*& node) // These unary ops require lvalues if (unaryOp == EOpPreIncrement || unaryOp == EOpPreDecrement) - node = parseContext.handleLvalue(loc, "unary operator", node); + node = _parseContext.handleLvalue(loc, "unary operator", node); return node != nullptr; } @@ -2203,7 +2203,7 @@ bool HlslGrammar::acceptPostfixExpression(TIntermTyped*& node) } else if (acceptIdentifier(idToken)) { // identifier or function_call name if (! peekTokenClass(EHTokLeftParen)) { - node = parseContext.handleVariable(idToken.loc, idToken.symbol, token.string); + node = _parseContext.handleVariable(idToken.loc, idToken.symbol, token.string); } else if (acceptFunctionCall(idToken, node)) { // function_call (nothing else to do yet) } else { @@ -2218,16 +2218,16 @@ bool HlslGrammar::acceptPostfixExpression(TIntermTyped*& node) // This is to guarantee we do this no matter how we get out of the stack frame. // This way there's no bug if an early return forgets to do it. struct tFinalize { - tFinalize(HlslParseContext& p) : parseContext(p) { } - ~tFinalize() { parseContext.finalizeFlattening(); } - HlslParseContext& parseContext; - } finalize(parseContext); + tFinalize(HlslParseContext& p) : _parseContext(p) { } + ~tFinalize() { _parseContext.finalizeFlattening(); } + HlslParseContext& _parseContext; + } finalize(_parseContext); // Initialize the flattening accumulation data, so we can track data across multiple bracket or // dot operators. This can also be nested, e.g, for [], so we have to track each nesting // level: hence the init and finalize. Even though in practice these must be // constants, they are parsed no matter what. - parseContext.initFlattening(); + _parseContext.initFlattening(); // Something was found, chain as many postfix operations as exist. do { @@ -2259,7 +2259,7 @@ bool HlslGrammar::acceptPostfixExpression(TIntermTyped*& node) } TIntermTyped* base = node; // preserve for method function calls - node = parseContext.handleDotDereference(field.loc, node, *field.string); + node = _parseContext.handleDotDereference(field.loc, node, *field.string); // In the event of a method node, we look for an open paren and accept the function call. if (node != nullptr && node->getAsMethodNode() != nullptr && peekTokenClass(EHTokLeftParen)) { @@ -2281,7 +2281,7 @@ bool HlslGrammar::acceptPostfixExpression(TIntermTyped*& node) return false; } advanceToken(); - node = parseContext.handleBracketDereference(indexNode->getLoc(), node, indexNode); + node = _parseContext.handleBracketDereference(indexNode->getLoc(), node, indexNode); break; } case EOpPostIncrement: @@ -2290,7 +2290,7 @@ bool HlslGrammar::acceptPostfixExpression(TIntermTyped*& node) case EOpPostDecrement: // DEC_OP node = intermediate.addUnaryMath(postOp, node, loc); - node = parseContext.handleLvalue(loc, "unary operator", node); + node = _parseContext.handleLvalue(loc, "unary operator", node); break; default: assert(0); @@ -2307,7 +2307,7 @@ bool HlslGrammar::acceptConstructor(TIntermTyped*& node) // type TType type; if (acceptType(type)) { - TFunction* constructorFunction = parseContext.handleConstructorCall(token.loc, type); + TFunction* constructorFunction = _parseContext.handleConstructorCall(token.loc, type); if (constructorFunction == nullptr) return false; @@ -2319,7 +2319,7 @@ bool HlslGrammar::acceptConstructor(TIntermTyped*& node) } // hook it up - node = parseContext.handleFunctionCall(arguments->getLoc(), constructorFunction, arguments); + node = _parseContext.handleFunctionCall(arguments->getLoc(), constructorFunction, arguments); return true; } @@ -2340,12 +2340,12 @@ bool HlslGrammar::acceptFunctionCall(HlslToken idToken, TIntermTyped*& node, TIn // methods have an implicit first argument of the calling object. if (base != nullptr) - parseContext.handleFunctionArgument(function, arguments, base); + _parseContext.handleFunctionArgument(function, arguments, base); if (! acceptArguments(function, arguments)) return false; - node = parseContext.handleFunctionCall(idToken.loc, function, arguments); + node = _parseContext.handleFunctionCall(idToken.loc, function, arguments); return true; } @@ -2369,7 +2369,7 @@ bool HlslGrammar::acceptArguments(TFunction* function, TIntermTyped*& arguments) break; // hook it up - parseContext.handleFunctionArgument(function, arguments, arg); + _parseContext.handleFunctionArgument(function, arguments, arg); // COMMA if (! acceptTokenClass(EHTokComma)) @@ -2434,7 +2434,7 @@ bool HlslGrammar::acceptCompoundStatement(TIntermNode*& retStatement) if (branch != nullptr && (branch->getFlowOp() == EOpCase || branch->getFlowOp() == EOpDefault)) { // hook up individual subsequences within a switch statement - parseContext.wrapupSwitchSubsequence(compoundStatement, statement); + _parseContext.wrapupSwitchSubsequence(compoundStatement, statement); compoundStatement = nullptr; } else { // hook it up to the growing compound statement @@ -2452,18 +2452,18 @@ bool HlslGrammar::acceptCompoundStatement(TIntermNode*& retStatement) bool HlslGrammar::acceptScopedStatement(TIntermNode*& statement) { - parseContext.pushScope(); + _parseContext.pushScope(); bool result = acceptStatement(statement); - parseContext.popScope(); + _parseContext.popScope(); return result; } bool HlslGrammar::acceptScopedCompoundStatement(TIntermNode*& statement) { - parseContext.pushScope(); + _parseContext.pushScope(); bool result = acceptCompoundStatement(statement); - parseContext.popScope(); + _parseContext.popScope(); return result; } @@ -2642,7 +2642,7 @@ bool HlslGrammar::acceptSelectionStatement(TIntermNode*& statement) // so that something declared in the condition is scoped to the lifetimes // of the then-else statements - parseContext.pushScope(); + _parseContext.pushScope(); // LEFT_PAREN expression RIGHT_PAREN TIntermTyped* condition; @@ -2669,7 +2669,7 @@ bool HlslGrammar::acceptSelectionStatement(TIntermNode*& statement) // Put the pieces together statement = intermediate.addSelection(condition, thenElse, loc); - parseContext.popScope(); + _parseContext.popScope(); return true; } @@ -2685,21 +2685,21 @@ bool HlslGrammar::acceptSwitchStatement(TIntermNode*& statement) return false; // LEFT_PAREN expression RIGHT_PAREN - parseContext.pushScope(); + _parseContext.pushScope(); TIntermTyped* switchExpression; if (! acceptParenExpression(switchExpression)) { - parseContext.popScope(); + _parseContext.popScope(); return false; } // compound_statement - parseContext.pushSwitchSequence(new TIntermSequence); + _parseContext.pushSwitchSequence(new TIntermSequence); bool statementOkay = acceptCompoundStatement(statement); if (statementOkay) - statement = parseContext.addSwitch(loc, switchExpression, statement ? statement->getAsAggregate() : nullptr); + statement = _parseContext.addSwitch(loc, switchExpression, statement ? statement->getAsAggregate() : nullptr); - parseContext.popSwitchSequence(); - parseContext.popScope(); + _parseContext.popSwitchSequence(); + _parseContext.popScope(); return statementOkay; } @@ -2725,8 +2725,8 @@ bool HlslGrammar::acceptIterationStatement(TIntermNode*& statement) case EHTokWhile: // so that something declared in the condition is scoped to the lifetime // of the while sub-statement - parseContext.pushScope(); - parseContext.nestLooping(); + _parseContext.pushScope(); + _parseContext.nestLooping(); // LEFT_PAREN condition RIGHT_PAREN if (! acceptParenExpression(condition)) @@ -2738,15 +2738,15 @@ bool HlslGrammar::acceptIterationStatement(TIntermNode*& statement) return false; } - parseContext.unnestLooping(); - parseContext.popScope(); + _parseContext.unnestLooping(); + _parseContext.popScope(); statement = intermediate.addLoop(statement, condition, nullptr, true, loc); return true; case EHTokDo: - parseContext.nestLooping(); + _parseContext.nestLooping(); if (! acceptTokenClass(EHTokLeftBrace)) expected("{"); @@ -2774,7 +2774,7 @@ bool HlslGrammar::acceptIterationStatement(TIntermNode*& statement) if (! acceptTokenClass(EHTokSemicolon)) expected(";"); - parseContext.unnestLooping(); + _parseContext.unnestLooping(); statement = intermediate.addLoop(statement, condition, 0, false, loc); @@ -2788,7 +2788,7 @@ bool HlslGrammar::acceptIterationStatement(TIntermNode*& statement) // so that something declared in the condition is scoped to the lifetime // of the for sub-statement - parseContext.pushScope(); + _parseContext.pushScope(); // initializer TIntermNode* initNode = nullptr; @@ -2801,7 +2801,7 @@ bool HlslGrammar::acceptIterationStatement(TIntermNode*& statement) if (! acceptTokenClass(EHTokSemicolon)) expected(";"); - parseContext.nestLooping(); + _parseContext.nestLooping(); // condition SEMI_COLON acceptExpression(condition); @@ -2822,8 +2822,8 @@ bool HlslGrammar::acceptIterationStatement(TIntermNode*& statement) statement = intermediate.addForLoop(statement, initNode, condition, iterator, true, loc); - parseContext.popScope(); - parseContext.unnestLooping(); + _parseContext.popScope(); + _parseContext.unnestLooping(); return true; } @@ -2872,7 +2872,7 @@ bool HlslGrammar::acceptJumpStatement(TIntermNode*& statement) TIntermTyped* node; if (acceptExpression(node)) { // hook it up - statement = parseContext.handleReturnValue(token.loc, node); + statement = _parseContext.handleReturnValue(token.loc, node); } else statement = intermediate.addBranch(EOpReturn, token.loc); break; @@ -2910,7 +2910,7 @@ bool HlslGrammar::acceptCaseLabel(TIntermNode*& statement) return false; } - statement = parseContext.intermediate.addBranch(EOpCase, expression, loc); + statement = _parseContext.intermediate.addBranch(EOpCase, expression, loc); return true; } @@ -2929,7 +2929,7 @@ bool HlslGrammar::acceptDefaultLabel(TIntermNode*& statement) return false; } - statement = parseContext.intermediate.addBranch(EOpDefault, loc); + statement = _parseContext.intermediate.addBranch(EOpDefault, loc); return true; } @@ -2964,7 +2964,7 @@ void HlslGrammar::acceptArraySpecifier(TArraySizes*& arraySizes) if (hasArraySize) { TArraySize arraySize; - parseContext.arraySizeCheck(loc, sizeExpr, arraySize); + _parseContext.arraySizeCheck(loc, sizeExpr, arraySize); arraySizes->addInnerSize(arraySize); } else { arraySizes->addInnerSize(0); // sized by initializers. @@ -3009,7 +3009,7 @@ void HlslGrammar::acceptPostDecls(TQualifier& qualifier) expected(")"); break; } - parseContext.handlePackOffset(locationToken.loc, qualifier, *locationToken.string, componentToken.string); + _parseContext.handlePackOffset(locationToken.loc, qualifier, *locationToken.string, componentToken.string); } else if (! acceptIdentifier(idToken)) { expected("layout, semantic, packoffset, or register"); return; @@ -3063,10 +3063,10 @@ void HlslGrammar::acceptPostDecls(TQualifier& qualifier) expected(")"); break; } - parseContext.handleRegister(registerDesc.loc, qualifier, profile.string, *registerDesc.string, subComponent, spaceDesc.string); + _parseContext.handleRegister(registerDesc.loc, qualifier, profile.string, *registerDesc.string, subComponent, spaceDesc.string); } else { // semantic, in idToken.string - parseContext.handleSemantic(idToken.loc, qualifier, *idToken.string); + _parseContext.handleSemantic(idToken.loc, qualifier, *idToken.string); } } else if (peekTokenClass(EHTokLeftAngle)) acceptAnnotations(qualifier); diff --git a/deps/glslang/glslang/hlsl/hlslGrammar.h b/deps/glslang/glslang/hlsl/hlslGrammar.h index ad124cb755..3de13b317b 100755 --- a/deps/glslang/glslang/hlsl/hlslGrammar.h +++ b/deps/glslang/glslang/hlsl/hlslGrammar.h @@ -50,8 +50,8 @@ namespace glslang { class HlslGrammar : public HlslTokenStream { public: - HlslGrammar(HlslScanContext& scanner, HlslParseContext& parseContext) - : HlslTokenStream(scanner), parseContext(parseContext), intermediate(parseContext.intermediate) { } + HlslGrammar(HlslScanContext& scanner, HlslParseContext&_parseContext) + : HlslTokenStream(scanner), _parseContext(_parseContext), intermediate(_parseContext.intermediate) { } virtual ~HlslGrammar() { } bool parse(); @@ -112,7 +112,7 @@ namespace glslang { void acceptArraySpecifier(TArraySizes*&); void acceptPostDecls(TQualifier&); - HlslParseContext& parseContext; // state of parsing and helper functions for building the intermediate + HlslParseContext&_parseContext; // state of parsing and helper functions for building the intermediate TIntermediate& intermediate; // the final product, the intermediate representation, includes the AST }; diff --git a/deps/glslang/glslang/hlsl/hlslScanContext.cpp b/deps/glslang/glslang/hlsl/hlslScanContext.cpp index 4e355ba7ca..abd59389cf 100755 --- a/deps/glslang/glslang/hlsl/hlslScanContext.cpp +++ b/deps/glslang/glslang/hlsl/hlslScanContext.cpp @@ -52,329 +52,306 @@ // preprocessor includes #include "../glslang/MachineIndependent/preprocessor/PpContext.h" #include "../glslang/MachineIndependent/preprocessor/PpTokens.h" +#include "../glslang/MachineIndependent/preprocessor/Compare.h" namespace { -struct str_eq -{ - bool operator()(const char* lhs, const char* rhs) const - { - return strcmp(lhs, rhs) == 0; - } -}; - -struct str_hash -{ - size_t operator()(const char* str) const - { - // djb2 - unsigned long hash = 5381; - int c; - - while ((c = *str++) != 0) - hash = ((hash << 5) + hash) + c; - - return hash; - } -}; - // A single global usable by all threads, by all versions, by all languages. // After a single process-level initialization, this is read only and thread safe -std::unordered_map* KeywordMap = nullptr; -std::unordered_set* ReservedSet = nullptr; - +std::unordered_map* hlslKeywordMap = nullptr; +std::unordered_set* hlslReservedSet = nullptr; }; namespace glslang { void HlslScanContext::fillInKeywordMap() { - if (KeywordMap != nullptr) { + if (hlslKeywordMap != nullptr) { // this is really an error, as this should called only once per process // but, the only risk is if two threads called simultaneously return; } - KeywordMap = new std::unordered_map; + hlslKeywordMap = new std::unordered_map; - (*KeywordMap)["static"] = EHTokStatic; - (*KeywordMap)["const"] = EHTokConst; - (*KeywordMap)["unorm"] = EHTokUnorm; - (*KeywordMap)["snorm"] = EHTokSNorm; - (*KeywordMap)["extern"] = EHTokExtern; - (*KeywordMap)["uniform"] = EHTokUniform; - (*KeywordMap)["volatile"] = EHTokVolatile; - (*KeywordMap)["precise"] = EHTokPrecise; - (*KeywordMap)["shared"] = EHTokShared; - (*KeywordMap)["groupshared"] = EHTokGroupShared; - (*KeywordMap)["linear"] = EHTokLinear; - (*KeywordMap)["centroid"] = EHTokCentroid; - (*KeywordMap)["nointerpolation"] = EHTokNointerpolation; - (*KeywordMap)["noperspective"] = EHTokNoperspective; - (*KeywordMap)["sample"] = EHTokSample; - (*KeywordMap)["row_major"] = EHTokRowMajor; - (*KeywordMap)["column_major"] = EHTokColumnMajor; - (*KeywordMap)["packoffset"] = EHTokPackOffset; - (*KeywordMap)["in"] = EHTokIn; - (*KeywordMap)["out"] = EHTokOut; - (*KeywordMap)["inout"] = EHTokInOut; - (*KeywordMap)["layout"] = EHTokLayout; + (*hlslKeywordMap)["static"] = EHTokStatic; + (*hlslKeywordMap)["const"] = EHTokConst; + (*hlslKeywordMap)["unorm"] = EHTokUnorm; + (*hlslKeywordMap)["snorm"] = EHTokSNorm; + (*hlslKeywordMap)["extern"] = EHTokExtern; + (*hlslKeywordMap)["uniform"] = EHTokUniform; + (*hlslKeywordMap)["volatile"] = EHTokVolatile; + (*hlslKeywordMap)["precise"] = EHTokPrecise; + (*hlslKeywordMap)["shared"] = EHTokShared; + (*hlslKeywordMap)["groupshared"] = EHTokGroupShared; + (*hlslKeywordMap)["linear"] = EHTokLinear; + (*hlslKeywordMap)["centroid"] = EHTokCentroid; + (*hlslKeywordMap)["nointerpolation"] = EHTokNointerpolation; + (*hlslKeywordMap)["noperspective"] = EHTokNoperspective; + (*hlslKeywordMap)["sample"] = EHTokSample; + (*hlslKeywordMap)["row_major"] = EHTokRowMajor; + (*hlslKeywordMap)["column_major"] = EHTokColumnMajor; + (*hlslKeywordMap)["packoffset"] = EHTokPackOffset; + (*hlslKeywordMap)["in"] = EHTokIn; + (*hlslKeywordMap)["out"] = EHTokOut; + (*hlslKeywordMap)["inout"] = EHTokInOut; + (*hlslKeywordMap)["layout"] = EHTokLayout; - (*KeywordMap)["point"] = EHTokPoint; - (*KeywordMap)["line"] = EHTokLine; - (*KeywordMap)["triangle"] = EHTokTriangle; - (*KeywordMap)["lineadj"] = EHTokLineAdj; - (*KeywordMap)["triangleadj"] = EHTokTriangleAdj; + (*hlslKeywordMap)["point"] = EHTokPoint; + (*hlslKeywordMap)["line"] = EHTokLine; + (*hlslKeywordMap)["triangle"] = EHTokTriangle; + (*hlslKeywordMap)["lineadj"] = EHTokLineAdj; + (*hlslKeywordMap)["triangleadj"] = EHTokTriangleAdj; - (*KeywordMap)["PointStream"] = EHTokPointStream; - (*KeywordMap)["LineStream"] = EHTokLineStream; - (*KeywordMap)["TriangleStream"] = EHTokTriangleStream; + (*hlslKeywordMap)["PointStream"] = EHTokPointStream; + (*hlslKeywordMap)["LineStream"] = EHTokLineStream; + (*hlslKeywordMap)["TriangleStream"] = EHTokTriangleStream; - (*KeywordMap)["Buffer"] = EHTokBuffer; - (*KeywordMap)["vector"] = EHTokVector; - (*KeywordMap)["matrix"] = EHTokMatrix; + (*hlslKeywordMap)["Buffer"] = EHTokBuffer; + (*hlslKeywordMap)["vector"] = EHTokVector; + (*hlslKeywordMap)["matrix"] = EHTokMatrix; - (*KeywordMap)["void"] = EHTokVoid; - (*KeywordMap)["string"] = EHTokString; - (*KeywordMap)["bool"] = EHTokBool; - (*KeywordMap)["int"] = EHTokInt; - (*KeywordMap)["uint"] = EHTokUint; - (*KeywordMap)["dword"] = EHTokDword; - (*KeywordMap)["half"] = EHTokHalf; - (*KeywordMap)["float"] = EHTokFloat; - (*KeywordMap)["double"] = EHTokDouble; - (*KeywordMap)["min16float"] = EHTokMin16float; - (*KeywordMap)["min10float"] = EHTokMin10float; - (*KeywordMap)["min16int"] = EHTokMin16int; - (*KeywordMap)["min12int"] = EHTokMin12int; - (*KeywordMap)["min16uint"] = EHTokMin16uint; + (*hlslKeywordMap)["void"] = EHTokVoid; + (*hlslKeywordMap)["string"] = EHTokString; + (*hlslKeywordMap)["bool"] = EHTokBool; + (*hlslKeywordMap)["int"] = EHTokInt; + (*hlslKeywordMap)["uint"] = EHTokUint; + (*hlslKeywordMap)["dword"] = EHTokDword; + (*hlslKeywordMap)["half"] = EHTokHalf; + (*hlslKeywordMap)["float"] = EHTokFloat; + (*hlslKeywordMap)["double"] = EHTokDouble; + (*hlslKeywordMap)["min16float"] = EHTokMin16float; + (*hlslKeywordMap)["min10float"] = EHTokMin10float; + (*hlslKeywordMap)["min16int"] = EHTokMin16int; + (*hlslKeywordMap)["min12int"] = EHTokMin12int; + (*hlslKeywordMap)["min16uint"] = EHTokMin16uint; - (*KeywordMap)["bool1"] = EHTokBool1; - (*KeywordMap)["bool2"] = EHTokBool2; - (*KeywordMap)["bool3"] = EHTokBool3; - (*KeywordMap)["bool4"] = EHTokBool4; - (*KeywordMap)["float1"] = EHTokFloat1; - (*KeywordMap)["float2"] = EHTokFloat2; - (*KeywordMap)["float3"] = EHTokFloat3; - (*KeywordMap)["float4"] = EHTokFloat4; - (*KeywordMap)["int1"] = EHTokInt1; - (*KeywordMap)["int2"] = EHTokInt2; - (*KeywordMap)["int3"] = EHTokInt3; - (*KeywordMap)["int4"] = EHTokInt4; - (*KeywordMap)["double1"] = EHTokDouble1; - (*KeywordMap)["double2"] = EHTokDouble2; - (*KeywordMap)["double3"] = EHTokDouble3; - (*KeywordMap)["double4"] = EHTokDouble4; - (*KeywordMap)["uint1"] = EHTokUint1; - (*KeywordMap)["uint2"] = EHTokUint2; - (*KeywordMap)["uint3"] = EHTokUint3; - (*KeywordMap)["uint4"] = EHTokUint4; + (*hlslKeywordMap)["bool1"] = EHTokBool1; + (*hlslKeywordMap)["bool2"] = EHTokBool2; + (*hlslKeywordMap)["bool3"] = EHTokBool3; + (*hlslKeywordMap)["bool4"] = EHTokBool4; + (*hlslKeywordMap)["float1"] = EHTokFloat1; + (*hlslKeywordMap)["float2"] = EHTokFloat2; + (*hlslKeywordMap)["float3"] = EHTokFloat3; + (*hlslKeywordMap)["float4"] = EHTokFloat4; + (*hlslKeywordMap)["int1"] = EHTokInt1; + (*hlslKeywordMap)["int2"] = EHTokInt2; + (*hlslKeywordMap)["int3"] = EHTokInt3; + (*hlslKeywordMap)["int4"] = EHTokInt4; + (*hlslKeywordMap)["double1"] = EHTokDouble1; + (*hlslKeywordMap)["double2"] = EHTokDouble2; + (*hlslKeywordMap)["double3"] = EHTokDouble3; + (*hlslKeywordMap)["double4"] = EHTokDouble4; + (*hlslKeywordMap)["uint1"] = EHTokUint1; + (*hlslKeywordMap)["uint2"] = EHTokUint2; + (*hlslKeywordMap)["uint3"] = EHTokUint3; + (*hlslKeywordMap)["uint4"] = EHTokUint4; - (*KeywordMap)["min16float1"] = EHTokMin16float1; - (*KeywordMap)["min16float2"] = EHTokMin16float2; - (*KeywordMap)["min16float3"] = EHTokMin16float3; - (*KeywordMap)["min16float4"] = EHTokMin16float4; - (*KeywordMap)["min10float1"] = EHTokMin10float1; - (*KeywordMap)["min10float2"] = EHTokMin10float2; - (*KeywordMap)["min10float3"] = EHTokMin10float3; - (*KeywordMap)["min10float4"] = EHTokMin10float4; - (*KeywordMap)["min16int1"] = EHTokMin16int1; - (*KeywordMap)["min16int2"] = EHTokMin16int2; - (*KeywordMap)["min16int3"] = EHTokMin16int3; - (*KeywordMap)["min16int4"] = EHTokMin16int4; - (*KeywordMap)["min12int1"] = EHTokMin12int1; - (*KeywordMap)["min12int2"] = EHTokMin12int2; - (*KeywordMap)["min12int3"] = EHTokMin12int3; - (*KeywordMap)["min12int4"] = EHTokMin12int4; - (*KeywordMap)["min16uint1"] = EHTokMin16uint1; - (*KeywordMap)["min16uint2"] = EHTokMin16uint2; - (*KeywordMap)["min16uint3"] = EHTokMin16uint3; - (*KeywordMap)["min16uint4"] = EHTokMin16uint4; + (*hlslKeywordMap)["min16float1"] = EHTokMin16float1; + (*hlslKeywordMap)["min16float2"] = EHTokMin16float2; + (*hlslKeywordMap)["min16float3"] = EHTokMin16float3; + (*hlslKeywordMap)["min16float4"] = EHTokMin16float4; + (*hlslKeywordMap)["min10float1"] = EHTokMin10float1; + (*hlslKeywordMap)["min10float2"] = EHTokMin10float2; + (*hlslKeywordMap)["min10float3"] = EHTokMin10float3; + (*hlslKeywordMap)["min10float4"] = EHTokMin10float4; + (*hlslKeywordMap)["min16int1"] = EHTokMin16int1; + (*hlslKeywordMap)["min16int2"] = EHTokMin16int2; + (*hlslKeywordMap)["min16int3"] = EHTokMin16int3; + (*hlslKeywordMap)["min16int4"] = EHTokMin16int4; + (*hlslKeywordMap)["min12int1"] = EHTokMin12int1; + (*hlslKeywordMap)["min12int2"] = EHTokMin12int2; + (*hlslKeywordMap)["min12int3"] = EHTokMin12int3; + (*hlslKeywordMap)["min12int4"] = EHTokMin12int4; + (*hlslKeywordMap)["min16uint1"] = EHTokMin16uint1; + (*hlslKeywordMap)["min16uint2"] = EHTokMin16uint2; + (*hlslKeywordMap)["min16uint3"] = EHTokMin16uint3; + (*hlslKeywordMap)["min16uint4"] = EHTokMin16uint4; - (*KeywordMap)["bool1x1"] = EHTokBool1x1; - (*KeywordMap)["bool1x2"] = EHTokBool1x2; - (*KeywordMap)["bool1x3"] = EHTokBool1x3; - (*KeywordMap)["bool1x4"] = EHTokBool1x4; - (*KeywordMap)["bool2x1"] = EHTokBool2x1; - (*KeywordMap)["bool2x2"] = EHTokBool2x2; - (*KeywordMap)["bool2x3"] = EHTokBool2x3; - (*KeywordMap)["bool2x4"] = EHTokBool2x4; - (*KeywordMap)["bool3x1"] = EHTokBool3x1; - (*KeywordMap)["bool3x2"] = EHTokBool3x2; - (*KeywordMap)["bool3x3"] = EHTokBool3x3; - (*KeywordMap)["bool3x4"] = EHTokBool3x4; - (*KeywordMap)["bool4x1"] = EHTokBool4x1; - (*KeywordMap)["bool4x2"] = EHTokBool4x2; - (*KeywordMap)["bool4x3"] = EHTokBool4x3; - (*KeywordMap)["bool4x4"] = EHTokBool4x4; - (*KeywordMap)["int1x1"] = EHTokInt1x1; - (*KeywordMap)["int1x2"] = EHTokInt1x2; - (*KeywordMap)["int1x3"] = EHTokInt1x3; - (*KeywordMap)["int1x4"] = EHTokInt1x4; - (*KeywordMap)["int2x1"] = EHTokInt2x1; - (*KeywordMap)["int2x2"] = EHTokInt2x2; - (*KeywordMap)["int2x3"] = EHTokInt2x3; - (*KeywordMap)["int2x4"] = EHTokInt2x4; - (*KeywordMap)["int3x1"] = EHTokInt3x1; - (*KeywordMap)["int3x2"] = EHTokInt3x2; - (*KeywordMap)["int3x3"] = EHTokInt3x3; - (*KeywordMap)["int3x4"] = EHTokInt3x4; - (*KeywordMap)["int4x1"] = EHTokInt4x1; - (*KeywordMap)["int4x2"] = EHTokInt4x2; - (*KeywordMap)["int4x3"] = EHTokInt4x3; - (*KeywordMap)["int4x4"] = EHTokInt4x4; - (*KeywordMap)["uint1x1"] = EHTokUint1x1; - (*KeywordMap)["uint1x2"] = EHTokUint1x2; - (*KeywordMap)["uint1x3"] = EHTokUint1x3; - (*KeywordMap)["uint1x4"] = EHTokUint1x4; - (*KeywordMap)["uint2x1"] = EHTokUint2x1; - (*KeywordMap)["uint2x2"] = EHTokUint2x2; - (*KeywordMap)["uint2x3"] = EHTokUint2x3; - (*KeywordMap)["uint2x4"] = EHTokUint2x4; - (*KeywordMap)["uint3x1"] = EHTokUint3x1; - (*KeywordMap)["uint3x2"] = EHTokUint3x2; - (*KeywordMap)["uint3x3"] = EHTokUint3x3; - (*KeywordMap)["uint3x4"] = EHTokUint3x4; - (*KeywordMap)["uint4x1"] = EHTokUint4x1; - (*KeywordMap)["uint4x2"] = EHTokUint4x2; - (*KeywordMap)["uint4x3"] = EHTokUint4x3; - (*KeywordMap)["uint4x4"] = EHTokUint4x4; - (*KeywordMap)["bool1x1"] = EHTokBool1x1; - (*KeywordMap)["bool1x2"] = EHTokBool1x2; - (*KeywordMap)["bool1x3"] = EHTokBool1x3; - (*KeywordMap)["bool1x4"] = EHTokBool1x4; - (*KeywordMap)["bool2x1"] = EHTokBool2x1; - (*KeywordMap)["bool2x2"] = EHTokBool2x2; - (*KeywordMap)["bool2x3"] = EHTokBool2x3; - (*KeywordMap)["bool2x4"] = EHTokBool2x4; - (*KeywordMap)["bool3x1"] = EHTokBool3x1; - (*KeywordMap)["bool3x2"] = EHTokBool3x2; - (*KeywordMap)["bool3x3"] = EHTokBool3x3; - (*KeywordMap)["bool3x4"] = EHTokBool3x4; - (*KeywordMap)["bool4x1"] = EHTokBool4x1; - (*KeywordMap)["bool4x2"] = EHTokBool4x2; - (*KeywordMap)["bool4x3"] = EHTokBool4x3; - (*KeywordMap)["bool4x4"] = EHTokBool4x4; - (*KeywordMap)["float1x1"] = EHTokFloat1x1; - (*KeywordMap)["float1x2"] = EHTokFloat1x2; - (*KeywordMap)["float1x3"] = EHTokFloat1x3; - (*KeywordMap)["float1x4"] = EHTokFloat1x4; - (*KeywordMap)["float2x1"] = EHTokFloat2x1; - (*KeywordMap)["float2x2"] = EHTokFloat2x2; - (*KeywordMap)["float2x3"] = EHTokFloat2x3; - (*KeywordMap)["float2x4"] = EHTokFloat2x4; - (*KeywordMap)["float3x1"] = EHTokFloat3x1; - (*KeywordMap)["float3x2"] = EHTokFloat3x2; - (*KeywordMap)["float3x3"] = EHTokFloat3x3; - (*KeywordMap)["float3x4"] = EHTokFloat3x4; - (*KeywordMap)["float4x1"] = EHTokFloat4x1; - (*KeywordMap)["float4x2"] = EHTokFloat4x2; - (*KeywordMap)["float4x3"] = EHTokFloat4x3; - (*KeywordMap)["float4x4"] = EHTokFloat4x4; - (*KeywordMap)["double1x1"] = EHTokDouble1x1; - (*KeywordMap)["double1x2"] = EHTokDouble1x2; - (*KeywordMap)["double1x3"] = EHTokDouble1x3; - (*KeywordMap)["double1x4"] = EHTokDouble1x4; - (*KeywordMap)["double2x1"] = EHTokDouble2x1; - (*KeywordMap)["double2x2"] = EHTokDouble2x2; - (*KeywordMap)["double2x3"] = EHTokDouble2x3; - (*KeywordMap)["double2x4"] = EHTokDouble2x4; - (*KeywordMap)["double3x1"] = EHTokDouble3x1; - (*KeywordMap)["double3x2"] = EHTokDouble3x2; - (*KeywordMap)["double3x3"] = EHTokDouble3x3; - (*KeywordMap)["double3x4"] = EHTokDouble3x4; - (*KeywordMap)["double4x1"] = EHTokDouble4x1; - (*KeywordMap)["double4x2"] = EHTokDouble4x2; - (*KeywordMap)["double4x3"] = EHTokDouble4x3; - (*KeywordMap)["double4x4"] = EHTokDouble4x4; + (*hlslKeywordMap)["bool1x1"] = EHTokBool1x1; + (*hlslKeywordMap)["bool1x2"] = EHTokBool1x2; + (*hlslKeywordMap)["bool1x3"] = EHTokBool1x3; + (*hlslKeywordMap)["bool1x4"] = EHTokBool1x4; + (*hlslKeywordMap)["bool2x1"] = EHTokBool2x1; + (*hlslKeywordMap)["bool2x2"] = EHTokBool2x2; + (*hlslKeywordMap)["bool2x3"] = EHTokBool2x3; + (*hlslKeywordMap)["bool2x4"] = EHTokBool2x4; + (*hlslKeywordMap)["bool3x1"] = EHTokBool3x1; + (*hlslKeywordMap)["bool3x2"] = EHTokBool3x2; + (*hlslKeywordMap)["bool3x3"] = EHTokBool3x3; + (*hlslKeywordMap)["bool3x4"] = EHTokBool3x4; + (*hlslKeywordMap)["bool4x1"] = EHTokBool4x1; + (*hlslKeywordMap)["bool4x2"] = EHTokBool4x2; + (*hlslKeywordMap)["bool4x3"] = EHTokBool4x3; + (*hlslKeywordMap)["bool4x4"] = EHTokBool4x4; + (*hlslKeywordMap)["int1x1"] = EHTokInt1x1; + (*hlslKeywordMap)["int1x2"] = EHTokInt1x2; + (*hlslKeywordMap)["int1x3"] = EHTokInt1x3; + (*hlslKeywordMap)["int1x4"] = EHTokInt1x4; + (*hlslKeywordMap)["int2x1"] = EHTokInt2x1; + (*hlslKeywordMap)["int2x2"] = EHTokInt2x2; + (*hlslKeywordMap)["int2x3"] = EHTokInt2x3; + (*hlslKeywordMap)["int2x4"] = EHTokInt2x4; + (*hlslKeywordMap)["int3x1"] = EHTokInt3x1; + (*hlslKeywordMap)["int3x2"] = EHTokInt3x2; + (*hlslKeywordMap)["int3x3"] = EHTokInt3x3; + (*hlslKeywordMap)["int3x4"] = EHTokInt3x4; + (*hlslKeywordMap)["int4x1"] = EHTokInt4x1; + (*hlslKeywordMap)["int4x2"] = EHTokInt4x2; + (*hlslKeywordMap)["int4x3"] = EHTokInt4x3; + (*hlslKeywordMap)["int4x4"] = EHTokInt4x4; + (*hlslKeywordMap)["uint1x1"] = EHTokUint1x1; + (*hlslKeywordMap)["uint1x2"] = EHTokUint1x2; + (*hlslKeywordMap)["uint1x3"] = EHTokUint1x3; + (*hlslKeywordMap)["uint1x4"] = EHTokUint1x4; + (*hlslKeywordMap)["uint2x1"] = EHTokUint2x1; + (*hlslKeywordMap)["uint2x2"] = EHTokUint2x2; + (*hlslKeywordMap)["uint2x3"] = EHTokUint2x3; + (*hlslKeywordMap)["uint2x4"] = EHTokUint2x4; + (*hlslKeywordMap)["uint3x1"] = EHTokUint3x1; + (*hlslKeywordMap)["uint3x2"] = EHTokUint3x2; + (*hlslKeywordMap)["uint3x3"] = EHTokUint3x3; + (*hlslKeywordMap)["uint3x4"] = EHTokUint3x4; + (*hlslKeywordMap)["uint4x1"] = EHTokUint4x1; + (*hlslKeywordMap)["uint4x2"] = EHTokUint4x2; + (*hlslKeywordMap)["uint4x3"] = EHTokUint4x3; + (*hlslKeywordMap)["uint4x4"] = EHTokUint4x4; + (*hlslKeywordMap)["bool1x1"] = EHTokBool1x1; + (*hlslKeywordMap)["bool1x2"] = EHTokBool1x2; + (*hlslKeywordMap)["bool1x3"] = EHTokBool1x3; + (*hlslKeywordMap)["bool1x4"] = EHTokBool1x4; + (*hlslKeywordMap)["bool2x1"] = EHTokBool2x1; + (*hlslKeywordMap)["bool2x2"] = EHTokBool2x2; + (*hlslKeywordMap)["bool2x3"] = EHTokBool2x3; + (*hlslKeywordMap)["bool2x4"] = EHTokBool2x4; + (*hlslKeywordMap)["bool3x1"] = EHTokBool3x1; + (*hlslKeywordMap)["bool3x2"] = EHTokBool3x2; + (*hlslKeywordMap)["bool3x3"] = EHTokBool3x3; + (*hlslKeywordMap)["bool3x4"] = EHTokBool3x4; + (*hlslKeywordMap)["bool4x1"] = EHTokBool4x1; + (*hlslKeywordMap)["bool4x2"] = EHTokBool4x2; + (*hlslKeywordMap)["bool4x3"] = EHTokBool4x3; + (*hlslKeywordMap)["bool4x4"] = EHTokBool4x4; + (*hlslKeywordMap)["float1x1"] = EHTokFloat1x1; + (*hlslKeywordMap)["float1x2"] = EHTokFloat1x2; + (*hlslKeywordMap)["float1x3"] = EHTokFloat1x3; + (*hlslKeywordMap)["float1x4"] = EHTokFloat1x4; + (*hlslKeywordMap)["float2x1"] = EHTokFloat2x1; + (*hlslKeywordMap)["float2x2"] = EHTokFloat2x2; + (*hlslKeywordMap)["float2x3"] = EHTokFloat2x3; + (*hlslKeywordMap)["float2x4"] = EHTokFloat2x4; + (*hlslKeywordMap)["float3x1"] = EHTokFloat3x1; + (*hlslKeywordMap)["float3x2"] = EHTokFloat3x2; + (*hlslKeywordMap)["float3x3"] = EHTokFloat3x3; + (*hlslKeywordMap)["float3x4"] = EHTokFloat3x4; + (*hlslKeywordMap)["float4x1"] = EHTokFloat4x1; + (*hlslKeywordMap)["float4x2"] = EHTokFloat4x2; + (*hlslKeywordMap)["float4x3"] = EHTokFloat4x3; + (*hlslKeywordMap)["float4x4"] = EHTokFloat4x4; + (*hlslKeywordMap)["double1x1"] = EHTokDouble1x1; + (*hlslKeywordMap)["double1x2"] = EHTokDouble1x2; + (*hlslKeywordMap)["double1x3"] = EHTokDouble1x3; + (*hlslKeywordMap)["double1x4"] = EHTokDouble1x4; + (*hlslKeywordMap)["double2x1"] = EHTokDouble2x1; + (*hlslKeywordMap)["double2x2"] = EHTokDouble2x2; + (*hlslKeywordMap)["double2x3"] = EHTokDouble2x3; + (*hlslKeywordMap)["double2x4"] = EHTokDouble2x4; + (*hlslKeywordMap)["double3x1"] = EHTokDouble3x1; + (*hlslKeywordMap)["double3x2"] = EHTokDouble3x2; + (*hlslKeywordMap)["double3x3"] = EHTokDouble3x3; + (*hlslKeywordMap)["double3x4"] = EHTokDouble3x4; + (*hlslKeywordMap)["double4x1"] = EHTokDouble4x1; + (*hlslKeywordMap)["double4x2"] = EHTokDouble4x2; + (*hlslKeywordMap)["double4x3"] = EHTokDouble4x3; + (*hlslKeywordMap)["double4x4"] = EHTokDouble4x4; - (*KeywordMap)["sampler"] = EHTokSampler; - (*KeywordMap)["sampler1D"] = EHTokSampler1d; - (*KeywordMap)["sampler2D"] = EHTokSampler2d; - (*KeywordMap)["sampler3D"] = EHTokSampler3d; - (*KeywordMap)["samplerCube"] = EHTokSamplerCube; - (*KeywordMap)["sampler_state"] = EHTokSamplerState; - (*KeywordMap)["SamplerState"] = EHTokSamplerState; - (*KeywordMap)["SamplerComparisonState"] = EHTokSamplerComparisonState; - (*KeywordMap)["texture"] = EHTokTexture; - (*KeywordMap)["Texture1D"] = EHTokTexture1d; - (*KeywordMap)["Texture1DArray"] = EHTokTexture1darray; - (*KeywordMap)["Texture2D"] = EHTokTexture2d; - (*KeywordMap)["Texture2DArray"] = EHTokTexture2darray; - (*KeywordMap)["Texture3D"] = EHTokTexture3d; - (*KeywordMap)["TextureCube"] = EHTokTextureCube; - (*KeywordMap)["TextureCubeArray"] = EHTokTextureCubearray; - (*KeywordMap)["Texture2DMS"] = EHTokTexture2DMS; - (*KeywordMap)["Texture2DMSArray"] = EHTokTexture2DMSarray; - (*KeywordMap)["RWTexture1D"] = EHTokRWTexture1d; - (*KeywordMap)["RWTexture1DArray"] = EHTokRWTexture1darray; - (*KeywordMap)["RWTexture2D"] = EHTokRWTexture2d; - (*KeywordMap)["RWTexture2DArray"] = EHTokRWTexture2darray; - (*KeywordMap)["RWTexture3D"] = EHTokRWTexture3d; - (*KeywordMap)["RWBuffer"] = EHTokRWBuffer; + (*hlslKeywordMap)["sampler"] = EHTokSampler; + (*hlslKeywordMap)["sampler1D"] = EHTokSampler1d; + (*hlslKeywordMap)["sampler2D"] = EHTokSampler2d; + (*hlslKeywordMap)["sampler3D"] = EHTokSampler3d; + (*hlslKeywordMap)["samplerCube"] = EHTokSamplerCube; + (*hlslKeywordMap)["sampler_state"] = EHTokSamplerState; + (*hlslKeywordMap)["SamplerState"] = EHTokSamplerState; + (*hlslKeywordMap)["SamplerComparisonState"] = EHTokSamplerComparisonState; + (*hlslKeywordMap)["texture"] = EHTokTexture; + (*hlslKeywordMap)["Texture1D"] = EHTokTexture1d; + (*hlslKeywordMap)["Texture1DArray"] = EHTokTexture1darray; + (*hlslKeywordMap)["Texture2D"] = EHTokTexture2d; + (*hlslKeywordMap)["Texture2DArray"] = EHTokTexture2darray; + (*hlslKeywordMap)["Texture3D"] = EHTokTexture3d; + (*hlslKeywordMap)["TextureCube"] = EHTokTextureCube; + (*hlslKeywordMap)["TextureCubeArray"] = EHTokTextureCubearray; + (*hlslKeywordMap)["Texture2DMS"] = EHTokTexture2DMS; + (*hlslKeywordMap)["Texture2DMSArray"] = EHTokTexture2DMSarray; + (*hlslKeywordMap)["RWTexture1D"] = EHTokRWTexture1d; + (*hlslKeywordMap)["RWTexture1DArray"] = EHTokRWTexture1darray; + (*hlslKeywordMap)["RWTexture2D"] = EHTokRWTexture2d; + (*hlslKeywordMap)["RWTexture2DArray"] = EHTokRWTexture2darray; + (*hlslKeywordMap)["RWTexture3D"] = EHTokRWTexture3d; + (*hlslKeywordMap)["RWBuffer"] = EHTokRWBuffer; - (*KeywordMap)["struct"] = EHTokStruct; - (*KeywordMap)["cbuffer"] = EHTokCBuffer; - (*KeywordMap)["tbuffer"] = EHTokTBuffer; - (*KeywordMap)["typedef"] = EHTokTypedef; + (*hlslKeywordMap)["struct"] = EHTokStruct; + (*hlslKeywordMap)["cbuffer"] = EHTokCBuffer; + (*hlslKeywordMap)["tbuffer"] = EHTokTBuffer; + (*hlslKeywordMap)["typedef"] = EHTokTypedef; - (*KeywordMap)["true"] = EHTokBoolConstant; - (*KeywordMap)["false"] = EHTokBoolConstant; + (*hlslKeywordMap)["true"] = EHTokBoolConstant; + (*hlslKeywordMap)["false"] = EHTokBoolConstant; - (*KeywordMap)["for"] = EHTokFor; - (*KeywordMap)["do"] = EHTokDo; - (*KeywordMap)["while"] = EHTokWhile; - (*KeywordMap)["break"] = EHTokBreak; - (*KeywordMap)["continue"] = EHTokContinue; - (*KeywordMap)["if"] = EHTokIf; - (*KeywordMap)["else"] = EHTokElse; - (*KeywordMap)["discard"] = EHTokDiscard; - (*KeywordMap)["return"] = EHTokReturn; - (*KeywordMap)["switch"] = EHTokSwitch; - (*KeywordMap)["case"] = EHTokCase; - (*KeywordMap)["default"] = EHTokDefault; + (*hlslKeywordMap)["for"] = EHTokFor; + (*hlslKeywordMap)["do"] = EHTokDo; + (*hlslKeywordMap)["while"] = EHTokWhile; + (*hlslKeywordMap)["break"] = EHTokBreak; + (*hlslKeywordMap)["continue"] = EHTokContinue; + (*hlslKeywordMap)["if"] = EHTokIf; + (*hlslKeywordMap)["else"] = EHTokElse; + (*hlslKeywordMap)["discard"] = EHTokDiscard; + (*hlslKeywordMap)["return"] = EHTokReturn; + (*hlslKeywordMap)["switch"] = EHTokSwitch; + (*hlslKeywordMap)["case"] = EHTokCase; + (*hlslKeywordMap)["default"] = EHTokDefault; // TODO: get correct set here - ReservedSet = new std::unordered_set; + hlslReservedSet = new std::unordered_set; - ReservedSet->insert("auto"); - ReservedSet->insert("catch"); - ReservedSet->insert("char"); - ReservedSet->insert("class"); - ReservedSet->insert("const_cast"); - ReservedSet->insert("enum"); - ReservedSet->insert("explicit"); - ReservedSet->insert("friend"); - ReservedSet->insert("goto"); - ReservedSet->insert("long"); - ReservedSet->insert("mutable"); - ReservedSet->insert("new"); - ReservedSet->insert("operator"); - ReservedSet->insert("private"); - ReservedSet->insert("protected"); - ReservedSet->insert("public"); - ReservedSet->insert("reinterpret_cast"); - ReservedSet->insert("short"); - ReservedSet->insert("signed"); - ReservedSet->insert("sizeof"); - ReservedSet->insert("static_cast"); - ReservedSet->insert("template"); - ReservedSet->insert("this"); - ReservedSet->insert("throw"); - ReservedSet->insert("try"); - ReservedSet->insert("typename"); - ReservedSet->insert("union"); - ReservedSet->insert("unsigned"); - ReservedSet->insert("using"); - ReservedSet->insert("virtual"); + hlslReservedSet->insert("auto"); + hlslReservedSet->insert("catch"); + hlslReservedSet->insert("char"); + hlslReservedSet->insert("class"); + hlslReservedSet->insert("const_cast"); + hlslReservedSet->insert("enum"); + hlslReservedSet->insert("explicit"); + hlslReservedSet->insert("friend"); + hlslReservedSet->insert("goto"); + hlslReservedSet->insert("long"); + hlslReservedSet->insert("mutable"); + hlslReservedSet->insert("new"); + hlslReservedSet->insert("operator"); + hlslReservedSet->insert("private"); + hlslReservedSet->insert("protected"); + hlslReservedSet->insert("public"); + hlslReservedSet->insert("reinterpret_cast"); + hlslReservedSet->insert("short"); + hlslReservedSet->insert("signed"); + hlslReservedSet->insert("sizeof"); + hlslReservedSet->insert("static_cast"); + hlslReservedSet->insert("template"); + hlslReservedSet->insert("this"); + hlslReservedSet->insert("throw"); + hlslReservedSet->insert("try"); + hlslReservedSet->insert("typename"); + hlslReservedSet->insert("union"); + hlslReservedSet->insert("unsigned"); + hlslReservedSet->insert("using"); + hlslReservedSet->insert("virtual"); } void HlslScanContext::deleteKeywordMap() { - delete KeywordMap; - KeywordMap = nullptr; - delete ReservedSet; - ReservedSet = nullptr; + delete hlslKeywordMap; + hlslKeywordMap = nullptr; + delete hlslReservedSet; + hlslReservedSet = nullptr; } // Wrapper for tokenizeClass()"] = to get everything inside the token. @@ -426,7 +403,7 @@ EHlslTokenClass HlslScanContext::tokenizeClass(HlslToken& token) case '{': return EHTokLeftBrace; case '}': return EHTokRightBrace; case '\\': - parseContext.error(loc, "illegal use of escape character", "\\", ""); + _parseContext.error(loc, "illegal use of escape character", "\\", ""); break; case PpAtomAdd: return EHTokAddAssign; @@ -477,7 +454,7 @@ EHlslTokenClass HlslScanContext::tokenizeClass(HlslToken& token) char buf[2]; buf[0] = (char)ppToken.token; buf[1] = 0; - parseContext.error(loc, "unexpected token", buf, ""); + _parseContext.error(loc, "unexpected token", buf, ""); break; } } while (true); @@ -485,11 +462,11 @@ EHlslTokenClass HlslScanContext::tokenizeClass(HlslToken& token) EHlslTokenClass HlslScanContext::tokenizeIdentifier() { - if (ReservedSet->find(tokenText) != ReservedSet->end()) + if (hlslReservedSet->find(tokenText) != hlslReservedSet->end()) return reservedWord(); - auto it = KeywordMap->find(tokenText); - if (it == KeywordMap->end()) { + auto it = hlslKeywordMap->find(tokenText); + if (it == hlslKeywordMap->end()) { // Should have an identifier of some sort return identifierOrType(); } @@ -738,7 +715,7 @@ EHlslTokenClass HlslScanContext::tokenizeIdentifier() return keyword; default: - parseContext.infoSink.info.message(EPrefixInternalError, "Unknown glslang keyword", loc); + _parseContext.infoSink.info.message(EPrefixInternalError, "Unknown glslang keyword", loc); return EHTokNone; } } @@ -755,8 +732,8 @@ EHlslTokenClass HlslScanContext::identifierOrType() // extension support before the extension is enabled. EHlslTokenClass HlslScanContext::reservedWord() { - if (! parseContext.symbolTable.atBuiltInLevel()) - parseContext.error(loc, "Reserved word.", tokenText, "", ""); + if (!_parseContext.symbolTable.atBuiltInLevel()) + _parseContext.error(loc, "Reserved word.", tokenText, "", ""); return EHTokNone; } @@ -769,8 +746,8 @@ EHlslTokenClass HlslScanContext::identifierOrReserved(bool reserved) return EHTokNone; } - if (parseContext.forwardCompatible) - parseContext.warn(loc, "using future reserved keyword", tokenText, ""); + if (_parseContext.forwardCompatible) + _parseContext.warn(loc, "using future reserved keyword", tokenText, ""); return identifierOrType(); } @@ -779,7 +756,7 @@ EHlslTokenClass HlslScanContext::identifierOrReserved(bool reserved) // showed up. EHlslTokenClass HlslScanContext::nonreservedKeyword(int version) { - if (parseContext.version < version) + if (_parseContext.version < version) return identifierOrType(); return keyword; diff --git a/deps/glslang/glslang/hlsl/hlslScanContext.h b/deps/glslang/glslang/hlsl/hlslScanContext.h index 144a85343f..32cd0e7f20 100755 --- a/deps/glslang/glslang/hlsl/hlslScanContext.h +++ b/deps/glslang/glslang/hlsl/hlslScanContext.h @@ -74,8 +74,8 @@ struct HlslToken { // class HlslScanContext { public: - HlslScanContext(TParseContextBase& parseContext, TPpContext& ppContext) - : parseContext(parseContext), ppContext(ppContext) { } + HlslScanContext(TParseContextBase& _parseContext, TPpContext& ppContext) + : _parseContext(_parseContext), ppContext(ppContext) { } virtual ~HlslScanContext() { } static void fillInKeywordMap(); @@ -94,7 +94,7 @@ protected: EHlslTokenClass identifierOrReserved(bool reserved); EHlslTokenClass nonreservedKeyword(int version); - TParseContextBase& parseContext; + TParseContextBase&_parseContext; TPpContext& ppContext; TSourceLoc loc; TPpToken* ppToken; diff --git a/griffin/griffin_cpp.cpp b/griffin/griffin_cpp.cpp index a630e9d6ab..4ec2e3349d 100644 --- a/griffin/griffin_cpp.cpp +++ b/griffin/griffin_cpp.cpp @@ -26,70 +26,6 @@ #include #endif -#ifdef WANT_GLSLANG -#include "../deps/glslang/glslang.cpp" -#if 0 -#include "../deps/glslang/glslang_tab.cpp" -#endif -#include "../deps/glslang/glslang/SPIRV/disassemble.cpp" -#include "../deps/glslang/glslang/SPIRV/doc.cpp" -#include "../deps/glslang/glslang/SPIRV/GlslangToSpv.cpp" -#include "../deps/glslang/glslang/SPIRV/InReadableOrder.cpp" -#include "../deps/glslang/glslang/SPIRV/Logger.cpp" -#include "../deps/glslang/glslang/SPIRV/SpvBuilder.cpp" -#include "../deps/glslang/glslang/SPIRV/SPVRemapper.cpp" - -#include "../deps/glslang/glslang/glslang/GenericCodeGen/CodeGen.cpp" -#include "../deps/glslang/glslang/glslang/GenericCodeGen/Link.cpp" - -#include "../deps/glslang/glslang/OGLCompilersDLL/InitializeDll.cpp" - -#include "../deps/glslang/glslang/glslang/MachineIndependent/Constant.cpp" -#include "../deps/glslang/glslang/glslang/MachineIndependent/glslang_tab.cpp" -#include "../deps/glslang/glslang/glslang/MachineIndependent/InfoSink.cpp" -#include "../deps/glslang/glslang/glslang/MachineIndependent/Initialize.cpp" -#include "../deps/glslang/glslang/glslang/MachineIndependent/Intermediate.cpp" -#include "../deps/glslang/glslang/glslang/MachineIndependent/intermOut.cpp" -#include "../deps/glslang/glslang/glslang/MachineIndependent/IntermTraverse.cpp" -#include "../deps/glslang/glslang/glslang/MachineIndependent/iomapper.cpp" -#include "../deps/glslang/glslang/glslang/MachineIndependent/limits.cpp" -#include "../deps/glslang/glslang/glslang/MachineIndependent/linkValidate.cpp" -#include "../deps/glslang/glslang/glslang/MachineIndependent/parseConst.cpp" -#include "../deps/glslang/glslang/glslang/MachineIndependent/ParseContextBase.cpp" -#include "../deps/glslang/glslang/glslang/MachineIndependent/ParseHelper.cpp" -#include "../deps/glslang/glslang/glslang/MachineIndependent/PoolAlloc.cpp" -#include "../deps/glslang/glslang/glslang/MachineIndependent/propagateNoContraction.cpp" -#include "../deps/glslang/glslang/glslang/MachineIndependent/reflection.cpp" -#include "../deps/glslang/glslang/glslang/MachineIndependent/RemoveTree.cpp" -#include "../deps/glslang/glslang/glslang/MachineIndependent/Scan.cpp" -#include "../deps/glslang/glslang/glslang/MachineIndependent/ShaderLang.cpp" -#include "../deps/glslang/glslang/glslang/MachineIndependent/SymbolTable.cpp" -#include "../deps/glslang/glslang/glslang/MachineIndependent/Versions.cpp" - -#include "../deps/glslang/glslang/glslang/MachineIndependent/preprocessor/Pp.cpp" -#include "../deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpAtom.cpp" -#include "../deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpContext.cpp" -#include "../deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpMemory.cpp" -#include "../deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpScanner.cpp" -#include "../deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpSymbols.cpp" -#include "../deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpTokens.cpp" - -#include "../deps/glslang/glslang/hlsl/hlslAttributes.cpp" -#include "../deps/glslang/glslang/hlsl/hlslGrammar.cpp" -#include "../deps/glslang/glslang/hlsl/hlslOpMap.cpp" -#include "../deps/glslang/glslang/hlsl/hlslParseables.cpp" -#include "../deps/glslang/glslang/hlsl/hlslParseHelper.cpp" -#include "../deps/glslang/glslang/hlsl/hlslScanContext.cpp" -#include "../deps/glslang/glslang/hlsl/hlslTokenStream.cpp" -#ifdef _WIN32 -#include "../deps/glslang/glslang/glslang/OSDependent/Windows/ossource.cpp" -#endif - -#if defined(__linux__) && !defined(ANDROID) -#include "../deps/glslang/glslang/glslang/OSDependent/Unix/ossource.cpp" -#endif -#endif - /*============================================================ MENU ============================================================ */ @@ -123,6 +59,11 @@ VIDEO DRIVER #ifdef HAVE_SPIRV_CROSS #include "../deps/SPIRV-Cross/spirv_cross.cpp" #include "../deps/SPIRV-Cross/spirv_cfg.cpp" +#include "../deps/SPIRV-Cross/spirv_glsl.cpp" +#include "../deps/SPIRV-Cross/spirv_hlsl.cpp" +#if 0 +#include "../deps/SPIRV-Cross/spirv_msl.cpp" +#endif #ifdef HAVE_SLANG #include "../gfx/drivers_shader/glslang_util.cpp" #include "../gfx/drivers_shader/slang_preprocess.cpp" @@ -137,3 +78,13 @@ FONTS #if defined(_XBOX360) #include "../gfx/drivers_font/xdk360_fonts.cpp" #endif + +#ifdef WANT_GLSLANG +#ifdef _WIN32 +#include "../deps/glslang/glslang/glslang/OSDependent/Windows/ossource.cpp" +#endif + +#if defined(__linux__) && !defined(ANDROID) +#include "../deps/glslang/glslang/glslang/OSDependent/Unix/ossource.cpp" +#endif +#endif diff --git a/griffin/griffin_glslang.cpp b/griffin/griffin_glslang.cpp new file mode 100644 index 0000000000..31f0a09b0f --- /dev/null +++ b/griffin/griffin_glslang.cpp @@ -0,0 +1,58 @@ + +#ifdef WANT_GLSLANG +#ifdef _MSC_VER +#include +#endif + +#include "../deps/glslang/glslang.cpp" +#include "../deps/glslang/glslang/SPIRV/disassemble.cpp" +#include "../deps/glslang/glslang/SPIRV/doc.cpp" +#include "../deps/glslang/glslang/SPIRV/GlslangToSpv.cpp" +#include "../deps/glslang/glslang/SPIRV/InReadableOrder.cpp" +#include "../deps/glslang/glslang/SPIRV/Logger.cpp" +#include "../deps/glslang/glslang/SPIRV/SpvBuilder.cpp" +#include "../deps/glslang/glslang/SPIRV/SPVRemapper.cpp" + +#include "../deps/glslang/glslang/glslang/GenericCodeGen/CodeGen.cpp" +#include "../deps/glslang/glslang/glslang/GenericCodeGen/Link.cpp" + +#include "../deps/glslang/glslang/OGLCompilersDLL/InitializeDll.cpp" + +#include "../deps/glslang/glslang/glslang/MachineIndependent/Constant.cpp" +#include "../deps/glslang/glslang/glslang/MachineIndependent/glslang_tab.cpp" +#include "../deps/glslang/glslang/glslang/MachineIndependent/InfoSink.cpp" +#include "../deps/glslang/glslang/glslang/MachineIndependent/Initialize.cpp" +#include "../deps/glslang/glslang/glslang/MachineIndependent/Intermediate.cpp" +#include "../deps/glslang/glslang/glslang/MachineIndependent/intermOut.cpp" +#include "../deps/glslang/glslang/glslang/MachineIndependent/IntermTraverse.cpp" +#include "../deps/glslang/glslang/glslang/MachineIndependent/iomapper.cpp" +#include "../deps/glslang/glslang/glslang/MachineIndependent/limits.cpp" +#include "../deps/glslang/glslang/glslang/MachineIndependent/linkValidate.cpp" +#include "../deps/glslang/glslang/glslang/MachineIndependent/parseConst.cpp" +#include "../deps/glslang/glslang/glslang/MachineIndependent/ParseContextBase.cpp" +#include "../deps/glslang/glslang/glslang/MachineIndependent/ParseHelper.cpp" +#include "../deps/glslang/glslang/glslang/MachineIndependent/PoolAlloc.cpp" +#include "../deps/glslang/glslang/glslang/MachineIndependent/propagateNoContraction.cpp" +#include "../deps/glslang/glslang/glslang/MachineIndependent/reflection.cpp" +#include "../deps/glslang/glslang/glslang/MachineIndependent/RemoveTree.cpp" +#include "../deps/glslang/glslang/glslang/MachineIndependent/Scan.cpp" +#include "../deps/glslang/glslang/glslang/MachineIndependent/ShaderLang.cpp" +#include "../deps/glslang/glslang/glslang/MachineIndependent/SymbolTable.cpp" +#include "../deps/glslang/glslang/glslang/MachineIndependent/Versions.cpp" + +#include "../deps/glslang/glslang/glslang/MachineIndependent/preprocessor/Pp.cpp" +#include "../deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpAtom.cpp" +#include "../deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpContext.cpp" +#include "../deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpMemory.cpp" +#include "../deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpScanner.cpp" +#include "../deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpSymbols.cpp" +#include "../deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpTokens.cpp" + +#include "../deps/glslang/glslang/hlsl/hlslAttributes.cpp" +#include "../deps/glslang/glslang/hlsl/hlslGrammar.cpp" +#include "../deps/glslang/glslang/hlsl/hlslOpMap.cpp" +#include "../deps/glslang/glslang/hlsl/hlslParseables.cpp" +#include "../deps/glslang/glslang/hlsl/hlslParseHelper.cpp" +#include "../deps/glslang/glslang/hlsl/hlslScanContext.cpp" +#include "../deps/glslang/glslang/hlsl/hlslTokenStream.cpp" +#endif diff --git a/pkg/android/phoenix/jni/Android.mk b/pkg/android/phoenix/jni/Android.mk index a0642ec2f4..866b0f5158 100644 --- a/pkg/android/phoenix/jni/Android.mk +++ b/pkg/android/phoenix/jni/Android.mk @@ -71,7 +71,7 @@ DEFINES += -DRARCH_MOBILE -DHAVE_GRIFFIN -DHAVE_STB_VORBIS -DHAVE_LANGEXTRA -DAN DEFINES += -DWANT_IFADDRS ifeq ($(HAVE_VULKAN),1) -DEFINES += -DHAVE_VULKAN -DHAVE_SLANG -DHAVE_SPIRV_CROSS +DEFINES += -DHAVE_VULKAN -DHAVE_SLANG -DHAVE_SPIRV_CROSS -DWANT_GLSLANG endif DEFINES += -DHAVE_7ZIP DEFINES += -DHAVE_CHEEVOS @@ -111,53 +111,7 @@ LOCAL_CPPFLAGS += -I$(LOCAL_PATH)/$(DEPS_DIR)/glslang \ -I$(LOCAL_PATH)/$(DEPS_DIR)/SPIRV-Cross LOCAL_CFLAGS += -Wno-sign-compare -Wno-unused-variable -Wno-parentheses -LOCAL_SRC_FILES += $(DEPS_DIR)/glslang/glslang.cpp \ - $(DEPS_DIR)/glslang/glslang/SPIRV/SpvBuilder.cpp \ - $(DEPS_DIR)/glslang/glslang/SPIRV/Logger.cpp \ - $(DEPS_DIR)/glslang/glslang/SPIRV/SPVRemapper.cpp \ - $(DEPS_DIR)/glslang/glslang/SPIRV/InReadableOrder.cpp \ - $(DEPS_DIR)/glslang/glslang/SPIRV/doc.cpp \ - $(DEPS_DIR)/glslang/glslang/SPIRV/GlslangToSpv.cpp \ - $(DEPS_DIR)/glslang/glslang/SPIRV/disassemble.cpp \ - $(DEPS_DIR)/glslang/glslang/OGLCompilersDLL/InitializeDll.cpp \ - $(DEPS_DIR)/glslang/glslang/glslang/GenericCodeGen/Link.cpp \ - $(DEPS_DIR)/glslang/glslang/glslang/GenericCodeGen/CodeGen.cpp \ - $(DEPS_DIR)/glslang/glslang/hlsl/hlslAttributes.cpp \ - $(DEPS_DIR)/glslang/glslang/hlsl/hlslGrammar.cpp \ - $(DEPS_DIR)/glslang/glslang/hlsl/hlslOpMap.cpp \ - $(DEPS_DIR)/glslang/glslang/hlsl/hlslTokenStream.cpp \ - $(DEPS_DIR)/glslang/glslang/hlsl/hlslScanContext.cpp \ - $(DEPS_DIR)/glslang/glslang/hlsl/hlslParseHelper.cpp \ - $(DEPS_DIR)/glslang/glslang/hlsl/hlslParseables.cpp \ - $(DEPS_DIR)/glslang/glslang/glslang/MachineIndependent/Intermediate.cpp \ - $(DEPS_DIR)/glslang/glslang/glslang/MachineIndependent/propagateNoContraction.cpp \ - $(DEPS_DIR)/glslang/glslang/glslang/MachineIndependent/glslang_tab.cpp \ - $(DEPS_DIR)/glslang/glslang/glslang/MachineIndependent/Versions.cpp \ - $(DEPS_DIR)/glslang/glslang/glslang/MachineIndependent/RemoveTree.cpp \ - $(DEPS_DIR)/glslang/glslang/glslang/MachineIndependent/limits.cpp \ - $(DEPS_DIR)/glslang/glslang/glslang/MachineIndependent/intermOut.cpp \ - $(DEPS_DIR)/glslang/glslang/glslang/MachineIndependent/Initialize.cpp \ - $(DEPS_DIR)/glslang/glslang/glslang/MachineIndependent/SymbolTable.cpp \ - $(DEPS_DIR)/glslang/glslang/glslang/MachineIndependent/parseConst.cpp \ - $(DEPS_DIR)/glslang/glslang/glslang/MachineIndependent/ParseContextBase.cpp \ - $(DEPS_DIR)/glslang/glslang/glslang/MachineIndependent/ParseHelper.cpp \ - $(DEPS_DIR)/glslang/glslang/glslang/MachineIndependent/ShaderLang.cpp \ - $(DEPS_DIR)/glslang/glslang/glslang/MachineIndependent/IntermTraverse.cpp \ - $(DEPS_DIR)/glslang/glslang/glslang/MachineIndependent/iomapper.cpp \ - $(DEPS_DIR)/glslang/glslang/glslang/MachineIndependent/InfoSink.cpp \ - $(DEPS_DIR)/glslang/glslang/glslang/MachineIndependent/Constant.cpp \ - $(DEPS_DIR)/glslang/glslang/glslang/MachineIndependent/Scan.cpp \ - $(DEPS_DIR)/glslang/glslang/glslang/MachineIndependent/reflection.cpp \ - $(DEPS_DIR)/glslang/glslang/glslang/MachineIndependent/linkValidate.cpp \ - $(DEPS_DIR)/glslang/glslang/glslang/MachineIndependent/PoolAlloc.cpp \ - $(DEPS_DIR)/glslang/glslang/glslang/MachineIndependent/preprocessor/PpAtom.cpp \ - $(DEPS_DIR)/glslang/glslang/glslang/MachineIndependent/preprocessor/PpContext.cpp \ - $(DEPS_DIR)/glslang/glslang/glslang/MachineIndependent/preprocessor/PpMemory.cpp \ - $(DEPS_DIR)/glslang/glslang/glslang/MachineIndependent/preprocessor/PpTokens.cpp \ - $(DEPS_DIR)/glslang/glslang/glslang/MachineIndependent/preprocessor/PpScanner.cpp \ - $(DEPS_DIR)/glslang/glslang/glslang/MachineIndependent/preprocessor/PpSymbols.cpp \ - $(DEPS_DIR)/glslang/glslang/glslang/MachineIndependent/preprocessor/Pp.cpp \ - $(DEPS_DIR)/glslang/glslang/glslang/OSDependent/Unix/ossource.cpp +LOCAL_SRC_FILES += $(RARCH_DIR)/griffin/griffin_glslang.cpp endif LOCAL_LDLIBS += -lOpenSLES -lz diff --git a/pkg/msvc/msvc-2013/RetroArch-msvc2013.vcxproj b/pkg/msvc/msvc-2013/RetroArch-msvc2013.vcxproj index 581fb094fa..c95534accc 100644 --- a/pkg/msvc/msvc-2013/RetroArch-msvc2013.vcxproj +++ b/pkg/msvc/msvc-2013/RetroArch-msvc2013.vcxproj @@ -84,7 +84,7 @@ Level3 Disabled - WIN32;HAVE_SPIRV_CROSS;HAVE_DYLIB;HAVE_DYNAMIC;HAVE_UPDATE_ASSETS;HAVE_MENU;HAVE_SLANG;HAVE_XMB;HAVE_RGUI;HAVE_MATERIALUI;_DEBUG;_WINDOWS;HAVE_XAUDIO;HAVE_DSOUND;HAVE_DINPUT;HAVE_D3D;HAVE_D3D9;HAVE_D3D11;HAVE_OPENGL;HAVE_GLSL;HAVE_THREADS;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_GRIFFIN;HAVE_RJPEG;HAVE_RPNG;HAVE_ZLIB;WANT_ZLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_OVERLAY;HAVE_7ZIP;HAVE_LIBRETRODB;HAVE_STB_FONT;%(PreprocessorDefinitions) + WIN32;WANT_GLSLANG;HAVE_DYNAMIC;HAVE_SPIRV_CROSS;HAVE_DYLIB;HAVE_DYNAMIC;HAVE_UPDATE_ASSETS;HAVE_MENU;HAVE_SLANG;HAVE_XMB;HAVE_SHADERPIPELINE;HAVE_RGUI;HAVE_MATERIALUI;_DEBUG;_WINDOWS;HAVE_XAUDIO;HAVE_DSOUND;HAVE_DINPUT;HAVE_D3D;HAVE_D3D9;HAVE_D3D11;HAVE_OPENGL;HAVE_GLSL;HAVE_THREADS;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_GRIFFIN;HAVE_RJPEG;HAVE_RPNG;HAVE_ZLIB;WANT_ZLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_OVERLAY;HAVE_7ZIP;HAVE_LIBRETRODB;HAVE_STB_FONT;%(PreprocessorDefinitions) $(SolutionDir)\..\..\gfx\include\dxsdk;$(SolutionDir)\..\..\gfx\include;$(SolutionDir)\..\..\libretro-common\include;$(SolutionDir)\..\..\deps;$(SolutionDir)\..\..\deps\SPIRV-Cross;%(AdditionalIncludeDirectories) @@ -99,7 +99,7 @@ Level3 Disabled - WIN32;HAVE_SPIRV_CROSS;HAVE_MENU;HAVE_SLANG;HAVE_UPDATE_ASSETS;HAVE_XMB;HAVE_RGUI;HAVE_MATERIALUI;_DEBUG;_WINDOWS;HAVE_XAUDIO;HAVE_DSOUND;HAVE_DINPUT;HAVE_D3D;HAVE_D3D9;HAVE_OPENGL;HAVE_GLSL;HAVE_THREADS;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_GRIFFIN;HAVE_RJPEG;HAVE_RPNG;HAVE_ZLIB;WANT_ZLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_OVERLAY;HAVE_7ZIP;HAVE_LIBRETRODB;HAVE_STB_FONT;%(PreprocessorDefinitions) + WIN32;WANT_GLSLANG;HAVE_DYNAMIC;HAVE_SPIRV_CROSS;HAVE_MENU;HAVE_SLANG;HAVE_UPDATE_ASSETS;HAVE_XMB;HAVE_SHADERPIPELINE;HAVE_RGUI;HAVE_MATERIALUI;_DEBUG;_WINDOWS;HAVE_XAUDIO;HAVE_DSOUND;HAVE_DINPUT;HAVE_D3D;HAVE_D3D9;HAVE_OPENGL;HAVE_GLSL;HAVE_THREADS;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_GRIFFIN;HAVE_RJPEG;HAVE_RPNG;HAVE_ZLIB;WANT_ZLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_OVERLAY;HAVE_7ZIP;HAVE_LIBRETRODB;HAVE_STB_FONT;%(PreprocessorDefinitions) $(SolutionDir)\..\..\gfx\include\dxsdk;$(SolutionDir)\..\..\gfx\include;$(SolutionDir)\..\..\libretro-common\include;$(SolutionDir)\..\..\deps;$(SolutionDir)\..\..\deps\SPIRV-Cross;%(AdditionalIncludeDirectories) @@ -115,7 +115,7 @@ MaxSpeed true true - WIN32;HAVE_SPIRV_CROSS;HAVE_DYLIB;HAVE_DYNAMIC;HAVE_UPDATE_ASSETS;HAVE_SLANG;HAVE_MENU;HAVE_XMB;HAVE_RGUI;HAVE_MATERIALUI;NDEBUG;_WINDOWS;HAVE_XAUDIO;HAVE_DSOUND;HAVE_DINPUT;HAVE_D3D;HAVE_D3D10;HAVE_D3D9;HAVE_D3D11;HAVE_OPENGL;HAVE_GLSL;HAVE_THREADS;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_GRIFFIN;HAVE_RJPEG;HAVE_RPNG;HAVE_ZLIB;WANT_ZLIB;HAVE_NETWORKING;HAVE_COMMAND;HAVE_NETWORK_CMD;HAVE_STDIN_CMD;HAVE_OVERLAY;HAVE_7ZIP;HAVE_LIBRETRODB;HAVE_STB_FONT;%(PreprocessorDefinitions) + WIN32;WANT_GLSLANG;HAVE_DYNAMIC;HAVE_SPIRV_CROSS;HAVE_DYLIB;HAVE_DYNAMIC;HAVE_UPDATE_ASSETS;HAVE_SLANG;HAVE_MENU;HAVE_XMB;HAVE_SHADERPIPELINE;HAVE_RGUI;HAVE_MATERIALUI;NDEBUG;_WINDOWS;HAVE_XAUDIO;HAVE_DSOUND;HAVE_DINPUT;HAVE_D3D;HAVE_D3D10;HAVE_D3D9;HAVE_D3D11;HAVE_OPENGL;HAVE_GLSL;HAVE_THREADS;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_GRIFFIN;HAVE_RJPEG;HAVE_RPNG;HAVE_ZLIB;WANT_ZLIB;HAVE_NETWORKING;HAVE_COMMAND;HAVE_NETWORK_CMD;HAVE_STDIN_CMD;HAVE_OVERLAY;HAVE_7ZIP;HAVE_LIBRETRODB;HAVE_STB_FONT;%(PreprocessorDefinitions) $(SolutionDir)\..\..\gfx\include\dxsdk;$(SolutionDir)\..\..\gfx\include;$(SolutionDir)\..\..\libretro-common\include;$(SolutionDir)\..\..\deps;$(SolutionDir)\..\..\deps\SPIRV-Cross;%(AdditionalIncludeDirectories) @@ -134,7 +134,7 @@ MaxSpeed true true - WIN32;HAVE_SPIRV_CROSS;HAVE_MENU;HAVE_SLANG;HAVE_UPDATE_ASSETS;HAVE_XMB;HAVE_RGUI;HAVE_MATERIALUI;NDEBUG;_WINDOWS;HAVE_XAUDIO;HAVE_DSOUND;HAVE_DINPUT;HAVE_D3D;HAVE_D3D9;HAVE_OPENGL;HAVE_GLSL;HAVE_THREADS;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_GRIFFIN;HAVE_RJPEG;HAVE_RPNG;HAVE_ZLIB;WANT_ZLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_OVERLAY;HAVE_7ZIP;HAVE_LIBRETRODB;HAVE_STB_FONT;%(PreprocessorDefinitions) + WIN32;WANT_GLSLANG;HAVE_DYNAMIC;HAVE_SPIRV_CROSS;HAVE_MENU;HAVE_SLANG;HAVE_UPDATE_ASSETS;HAVE_XMB;HAVE_SHADERPIPELINE;HAVE_RGUI;HAVE_MATERIALUI;NDEBUG;_WINDOWS;HAVE_XAUDIO;HAVE_DSOUND;HAVE_DINPUT;HAVE_D3D;HAVE_D3D9;HAVE_OPENGL;HAVE_GLSL;HAVE_THREADS;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_GRIFFIN;HAVE_RJPEG;HAVE_RPNG;HAVE_ZLIB;WANT_ZLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_OVERLAY;HAVE_7ZIP;HAVE_LIBRETRODB;HAVE_STB_FONT;%(PreprocessorDefinitions) $(SolutionDir)\..\..\gfx\include\dxsdk;$(SolutionDir)\..\..\gfx\include;$(SolutionDir)\..\..\libretro-common\include;$(SolutionDir)\..\..\deps;$(SolutionDir)\..\..\deps\SPIRV-Cross;%(AdditionalIncludeDirectories) @@ -152,8 +152,9 @@ CompileAsC + - \ No newline at end of file + diff --git a/pkg/msvc/msvc-2013/RetroArch-msvc2013.vcxproj.filters b/pkg/msvc/msvc-2013/RetroArch-msvc2013.vcxproj.filters index a6f6d9197c..6c68b0c6e9 100644 --- a/pkg/msvc/msvc-2013/RetroArch-msvc2013.vcxproj.filters +++ b/pkg/msvc/msvc-2013/RetroArch-msvc2013.vcxproj.filters @@ -21,5 +21,8 @@ Source Files + + Source Files + \ No newline at end of file diff --git a/pkg/msvc/msvc-2015/RetroArch-msvc2015.vcxproj b/pkg/msvc/msvc-2015/RetroArch-msvc2015.vcxproj index 20411f8586..c30105e5c0 100644 --- a/pkg/msvc/msvc-2015/RetroArch-msvc2015.vcxproj +++ b/pkg/msvc/msvc-2015/RetroArch-msvc2015.vcxproj @@ -190,8 +190,8 @@ Level3 Disabled - WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT - $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_SLANG;WANT_GLSLANG;HAVE_VULKAN;HAVE_SPIRV_CROSS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\gfx\include\dxsdk;$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) MultiThreadedDebug CompileAsCpp Fast @@ -209,8 +209,8 @@ Level3 Disabled - WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_CG;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;WANT_ZLIB;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT - $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_SLANG;WANT_GLSLANG;HAVE_VULKAN;HAVE_SPIRV_CROSS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_CG;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;WANT_ZLIB;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\gfx\include\dxsdk;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) MultiThreadedDebug CompileAsCpp Fast @@ -229,8 +229,8 @@ Level3 Disabled - WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT - $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_SLANG;WANT_GLSLANG;HAVE_VULKAN;HAVE_SPIRV_CROSS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\gfx\include\dxsdk;$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) MultiThreadedDebug CompileAsCpp Fast @@ -248,8 +248,8 @@ Level3 Disabled - WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_CG;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;WANT_ZLIB;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT - $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_SLANG;WANT_GLSLANG;HAVE_VULKAN;HAVE_SPIRV_CROSS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_CG;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;WANT_ZLIB;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\gfx\include\dxsdk;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) MultiThreadedDebug CompileAsCpp Fast @@ -270,8 +270,8 @@ MaxSpeed true true - WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_MENU;HAVE_RGUI;HAVE_GL_SYNC;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT - $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_SLANG;WANT_GLSLANG;HAVE_VULKAN;HAVE_SPIRV_CROSS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_MENU;HAVE_RGUI;HAVE_GL_SYNC;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\gfx\include\dxsdk;$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) MultiThreaded CompileAsCpp Fast @@ -294,8 +294,8 @@ MaxSpeed true true - WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_CG;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;WANT_ZLIB;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_MENU;HAVE_RGUI;HAVE_GL_SYNC;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT - $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_SLANG;WANT_GLSLANG;HAVE_VULKAN;HAVE_SPIRV_CROSS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_CG;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;WANT_ZLIB;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_MENU;HAVE_RGUI;HAVE_GL_SYNC;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\gfx\include\dxsdk;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) MultiThreaded CompileAsCpp Fast @@ -319,8 +319,8 @@ MaxSpeed true true - WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT - $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_SLANG;WANT_GLSLANG;HAVE_VULKAN;HAVE_SPIRV_CROSS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\gfx\include\dxsdk;$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) MultiThreaded CompileAsCpp Fast @@ -343,8 +343,8 @@ MaxSpeed true true - WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_CG;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;WANT_ZLIB;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT - $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_SLANG;WANT_GLSLANG;HAVE_VULKAN;HAVE_SPIRV_CROSS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_CG;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;WANT_ZLIB;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\gfx\include\dxsdk;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) MultiThreaded CompileAsCpp Fast @@ -371,8 +371,9 @@ CompileAsC + - + \ No newline at end of file diff --git a/pkg/msvc/msvc-2015/RetroArch-msvc2015.vcxproj.filters b/pkg/msvc/msvc-2015/RetroArch-msvc2015.vcxproj.filters index 5455441332..cbf777b405 100644 --- a/pkg/msvc/msvc-2015/RetroArch-msvc2015.vcxproj.filters +++ b/pkg/msvc/msvc-2015/RetroArch-msvc2015.vcxproj.filters @@ -15,5 +15,8 @@ griffin + + griffin + - + \ No newline at end of file diff --git a/pkg/msvc/msvc-2017/RetroArch-msvc2017.vcxproj b/pkg/msvc/msvc-2017/RetroArch-msvc2017.vcxproj index adfbdfd729..ed090f4aa3 100644 --- a/pkg/msvc/msvc-2017/RetroArch-msvc2017.vcxproj +++ b/pkg/msvc/msvc-2017/RetroArch-msvc2017.vcxproj @@ -191,7 +191,7 @@ Level3 Disabled - WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_SLANG;HAVE_SPIRV_CROSS;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_SPIRV_CROSS;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) MultiThreadedDebug CompileAsCpp @@ -210,7 +210,7 @@ Level3 Disabled - WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_SLANG;HAVE_SPIRV_CROSS;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;HAVE_CG;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_FBO;WANT_ZLIB;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_SPIRV_CROSS;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;HAVE_CG;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_FBO;WANT_ZLIB;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) MultiThreadedDebug CompileAsCpp @@ -230,7 +230,7 @@ Level3 Disabled - WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_SLANG;HAVE_SPIRV_CROSS;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_SPIRV_CROSS;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) MultiThreadedDebug CompileAsCpp @@ -249,7 +249,7 @@ Level3 Disabled - WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_SLANG;HAVE_SPIRV_CROSS;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;HAVE_CG;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_FBO;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;WANT_ZLIB;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_SPIRV_CROSS;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;HAVE_CG;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_FBO;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;WANT_ZLIB;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) MultiThreadedDebug CompileAsCpp @@ -271,7 +271,7 @@ MaxSpeed true true - WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_SLANG;HAVE_SPIRV_CROSS;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_MENU;HAVE_RGUI;HAVE_GL_SYNC;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_SPIRV_CROSS;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_MENU;HAVE_RGUI;HAVE_GL_SYNC;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) MultiThreaded CompileAsCpp @@ -295,7 +295,7 @@ MaxSpeed true true - WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_SLANG;HAVE_SPIRV_CROSS;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;HAVE_CG;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;WANT_ZLIB;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_MENU;HAVE_RGUI;HAVE_GL_SYNC;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_SPIRV_CROSS;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;HAVE_CG;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;WANT_ZLIB;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_MENU;HAVE_RGUI;HAVE_GL_SYNC;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) MultiThreaded CompileAsCpp @@ -320,7 +320,7 @@ MaxSpeed true true - WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_SLANG;HAVE_SPIRV_CROSS;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_SPIRV_CROSS;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) MultiThreaded CompileAsCpp @@ -344,7 +344,7 @@ MaxSpeed true true - WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_SLANG;HAVE_SPIRV_CROSS;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;HAVE_CG;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;WANT_ZLIB;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_SPIRV_CROSS;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;HAVE_CG;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;WANT_ZLIB;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) MultiThreaded CompileAsCpp @@ -376,6 +376,7 @@ CompileAsC + diff --git a/pkg/msvc/msvc-2017/RetroArch-msvc2017.vcxproj.filters b/pkg/msvc/msvc-2017/RetroArch-msvc2017.vcxproj.filters index 0b7f0bbd44..cbf777b405 100644 --- a/pkg/msvc/msvc-2017/RetroArch-msvc2017.vcxproj.filters +++ b/pkg/msvc/msvc-2017/RetroArch-msvc2017.vcxproj.filters @@ -1,19 +1,22 @@ - - - - - - - - {9fc175c7-a869-47cf-a0ce-5447d6015ce9} - - - - - griffin - - - griffin - - - + + + + + + + + {9fc175c7-a869-47cf-a0ce-5447d6015ce9} + + + + + griffin + + + griffin + + + griffin + + + \ No newline at end of file From 24306429bdd106de32b1e8e94964e74d2d281a21 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 4 Feb 2018 14:33:37 +0100 Subject: [PATCH 055/232] (VS2013) Update solution; add Vulkan, D3D10, D3D11 support --- pkg/msvc/msvc-2013/RetroArch-msvc2013.vcxproj | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pkg/msvc/msvc-2013/RetroArch-msvc2013.vcxproj b/pkg/msvc/msvc-2013/RetroArch-msvc2013.vcxproj index c95534accc..27119ed432 100644 --- a/pkg/msvc/msvc-2013/RetroArch-msvc2013.vcxproj +++ b/pkg/msvc/msvc-2013/RetroArch-msvc2013.vcxproj @@ -84,7 +84,7 @@ Level3 Disabled - WIN32;WANT_GLSLANG;HAVE_DYNAMIC;HAVE_SPIRV_CROSS;HAVE_DYLIB;HAVE_DYNAMIC;HAVE_UPDATE_ASSETS;HAVE_MENU;HAVE_SLANG;HAVE_XMB;HAVE_SHADERPIPELINE;HAVE_RGUI;HAVE_MATERIALUI;_DEBUG;_WINDOWS;HAVE_XAUDIO;HAVE_DSOUND;HAVE_DINPUT;HAVE_D3D;HAVE_D3D9;HAVE_D3D11;HAVE_OPENGL;HAVE_GLSL;HAVE_THREADS;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_GRIFFIN;HAVE_RJPEG;HAVE_RPNG;HAVE_ZLIB;WANT_ZLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_OVERLAY;HAVE_7ZIP;HAVE_LIBRETRODB;HAVE_STB_FONT;%(PreprocessorDefinitions) + WIN32;WANT_GLSLANG;HAVE_DYNAMIC;HAVE_DYLIB;HAVE_SPIRV_CROSS;HAVE_UPDATE_ASSETS;HAVE_MENU;HAVE_SLANG;HAVE_XMB;HAVE_SHADERPIPELINE;HAVE_RGUI;HAVE_MATERIALUI;_DEBUG;_WINDOWS;HAVE_XAUDIO;HAVE_DSOUND;HAVE_DINPUT;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_OPENGL;HAVE_VULKAN;HAVE_GLSL;HAVE_THREADS;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_GRIFFIN;HAVE_RJPEG;HAVE_RPNG;HAVE_ZLIB;WANT_ZLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_OVERLAY;HAVE_7ZIP;HAVE_LIBRETRODB;HAVE_STB_FONT;%(PreprocessorDefinitions) $(SolutionDir)\..\..\gfx\include\dxsdk;$(SolutionDir)\..\..\gfx\include;$(SolutionDir)\..\..\libretro-common\include;$(SolutionDir)\..\..\deps;$(SolutionDir)\..\..\deps\SPIRV-Cross;%(AdditionalIncludeDirectories) @@ -99,12 +99,13 @@ Level3 Disabled - WIN32;WANT_GLSLANG;HAVE_DYNAMIC;HAVE_SPIRV_CROSS;HAVE_MENU;HAVE_SLANG;HAVE_UPDATE_ASSETS;HAVE_XMB;HAVE_SHADERPIPELINE;HAVE_RGUI;HAVE_MATERIALUI;_DEBUG;_WINDOWS;HAVE_XAUDIO;HAVE_DSOUND;HAVE_DINPUT;HAVE_D3D;HAVE_D3D9;HAVE_OPENGL;HAVE_GLSL;HAVE_THREADS;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_GRIFFIN;HAVE_RJPEG;HAVE_RPNG;HAVE_ZLIB;WANT_ZLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_OVERLAY;HAVE_7ZIP;HAVE_LIBRETRODB;HAVE_STB_FONT;%(PreprocessorDefinitions) + WIN32;WANT_GLSLANG;HAVE_DYNAMIC;HAVE_DYLIB;HAVE_SPIRV_CROSS;HAVE_MENU;HAVE_SLANG;HAVE_UPDATE_ASSETS;HAVE_XMB;HAVE_SHADERPIPELINE;HAVE_RGUI;HAVE_MATERIALUI;_DEBUG;_WINDOWS;HAVE_XAUDIO;HAVE_DSOUND;HAVE_DINPUT;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_OPENGL;HAVE_VULKAN;HAVE_GLSL;HAVE_THREADS;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_GRIFFIN;HAVE_RJPEG;HAVE_RPNG;HAVE_ZLIB;WANT_ZLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_OVERLAY;HAVE_7ZIP;HAVE_LIBRETRODB;HAVE_STB_FONT;%(PreprocessorDefinitions) $(SolutionDir)\..\..\gfx\include\dxsdk;$(SolutionDir)\..\..\gfx\include;$(SolutionDir)\..\..\libretro-common\include;$(SolutionDir)\..\..\deps;$(SolutionDir)\..\..\deps\SPIRV-Cross;%(AdditionalIncludeDirectories) - Windows + Console true + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;Iphlpapi.lib;%(AdditionalDependencies) @@ -115,7 +116,7 @@ MaxSpeed true true - WIN32;WANT_GLSLANG;HAVE_DYNAMIC;HAVE_SPIRV_CROSS;HAVE_DYLIB;HAVE_DYNAMIC;HAVE_UPDATE_ASSETS;HAVE_SLANG;HAVE_MENU;HAVE_XMB;HAVE_SHADERPIPELINE;HAVE_RGUI;HAVE_MATERIALUI;NDEBUG;_WINDOWS;HAVE_XAUDIO;HAVE_DSOUND;HAVE_DINPUT;HAVE_D3D;HAVE_D3D10;HAVE_D3D9;HAVE_D3D11;HAVE_OPENGL;HAVE_GLSL;HAVE_THREADS;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_GRIFFIN;HAVE_RJPEG;HAVE_RPNG;HAVE_ZLIB;WANT_ZLIB;HAVE_NETWORKING;HAVE_COMMAND;HAVE_NETWORK_CMD;HAVE_STDIN_CMD;HAVE_OVERLAY;HAVE_7ZIP;HAVE_LIBRETRODB;HAVE_STB_FONT;%(PreprocessorDefinitions) + WIN32;WANT_GLSLANG;HAVE_DYNAMIC;HAVE_DYLIB;HAVE_SPIRV_CROSS;HAVE_UPDATE_ASSETS;HAVE_SLANG;HAVE_MENU;HAVE_XMB;HAVE_SHADERPIPELINE;HAVE_RGUI;HAVE_MATERIALUI;NDEBUG;_WINDOWS;HAVE_XAUDIO;HAVE_DSOUND;HAVE_DINPUT;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_OPENGL;HAVE_VULKAN;HAVE_GLSL;HAVE_THREADS;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_GRIFFIN;HAVE_RJPEG;HAVE_RPNG;HAVE_ZLIB;WANT_ZLIB;HAVE_NETWORKING;HAVE_COMMAND;HAVE_NETWORK_CMD;HAVE_STDIN_CMD;HAVE_OVERLAY;HAVE_7ZIP;HAVE_LIBRETRODB;HAVE_STB_FONT;%(PreprocessorDefinitions) $(SolutionDir)\..\..\gfx\include\dxsdk;$(SolutionDir)\..\..\gfx\include;$(SolutionDir)\..\..\libretro-common\include;$(SolutionDir)\..\..\deps;$(SolutionDir)\..\..\deps\SPIRV-Cross;%(AdditionalIncludeDirectories) @@ -134,14 +135,15 @@ MaxSpeed true true - WIN32;WANT_GLSLANG;HAVE_DYNAMIC;HAVE_SPIRV_CROSS;HAVE_MENU;HAVE_SLANG;HAVE_UPDATE_ASSETS;HAVE_XMB;HAVE_SHADERPIPELINE;HAVE_RGUI;HAVE_MATERIALUI;NDEBUG;_WINDOWS;HAVE_XAUDIO;HAVE_DSOUND;HAVE_DINPUT;HAVE_D3D;HAVE_D3D9;HAVE_OPENGL;HAVE_GLSL;HAVE_THREADS;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_GRIFFIN;HAVE_RJPEG;HAVE_RPNG;HAVE_ZLIB;WANT_ZLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_OVERLAY;HAVE_7ZIP;HAVE_LIBRETRODB;HAVE_STB_FONT;%(PreprocessorDefinitions) + WIN32;WANT_GLSLANG;HAVE_DYNAMIC;HAVE_DYLIB;HAVE_SPIRV_CROSS;HAVE_MENU;HAVE_SLANG;HAVE_UPDATE_ASSETS;HAVE_XMB;HAVE_SHADERPIPELINE;HAVE_RGUI;HAVE_MATERIALUI;NDEBUG;_WINDOWS;HAVE_XAUDIO;HAVE_DSOUND;HAVE_DINPUT;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_OPENGL;HAVE_VULKAN;HAVE_GLSL;HAVE_THREADS;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_GRIFFIN;HAVE_RJPEG;HAVE_RPNG;HAVE_ZLIB;WANT_ZLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_OVERLAY;HAVE_7ZIP;HAVE_LIBRETRODB;HAVE_STB_FONT;%(PreprocessorDefinitions) $(SolutionDir)\..\..\gfx\include\dxsdk;$(SolutionDir)\..\..\gfx\include;$(SolutionDir)\..\..\libretro-common\include;$(SolutionDir)\..\..\deps;$(SolutionDir)\..\..\deps\SPIRV-Cross;%(AdditionalIncludeDirectories) - Windows + Console true true true + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;Iphlpapi.lib;%(AdditionalDependencies) From 8771171f63a08b692a74c7a03ad5089620ff3b54 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 4 Feb 2018 15:49:53 +0100 Subject: [PATCH 056/232] (glslang) Compatibility tweaks for MSVC 2010 compatibility --- deps/glslang/glslang.cpp | 2 +- deps/glslang/glslang/hlsl/hlslParseHelper.cpp | 4 ++-- gfx/drivers/vulkan.c | 3 ++- gfx/drivers_shader/glslang_util.h | 7 ++++++- griffin/griffin_glslang.cpp | 3 +++ 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/deps/glslang/glslang.cpp b/deps/glslang/glslang.cpp index 4a7eda479d..a90b47c5f6 100644 --- a/deps/glslang/glslang.cpp +++ b/deps/glslang/glslang.cpp @@ -363,7 +363,7 @@ bool glslang::compile_spirv(const string &source, Stage stage, std::vector(variable.getUniqueId(), + TFlattenData(type.getQualifier().layoutBinding))); // ... and the item is a map pair, so first->second is the TFlattenData itself. flatten(loc, variable, type, entry.first->second, ""); diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index afb5d0db8e..4351f5562d 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -1290,8 +1290,9 @@ static bool vulkan_alive(void *data) static bool vulkan_suppress_screensaver(void *data, bool enable) { - (void)data; bool enabled = enable; + (void)data; + return video_context_driver_suppress_screensaver(&enabled); } diff --git a/gfx/drivers_shader/glslang_util.h b/gfx/drivers_shader/glslang_util.h index 366009e2b0..006fadc490 100644 --- a/gfx/drivers_shader/glslang_util.h +++ b/gfx/drivers_shader/glslang_util.h @@ -88,7 +88,12 @@ struct glslang_meta { std::vector parameters; std::string name; - glslang_format rt_format = SLANG_FORMAT_UNKNOWN; + glslang_format rt_format; + + glslang_meta() + { + rt_format = SLANG_FORMAT_UNKNOWN; + } }; struct glslang_output diff --git a/griffin/griffin_glslang.cpp b/griffin/griffin_glslang.cpp index 31f0a09b0f..44c33866d6 100644 --- a/griffin/griffin_glslang.cpp +++ b/griffin/griffin_glslang.cpp @@ -2,6 +2,9 @@ #ifdef WANT_GLSLANG #ifdef _MSC_VER #include +#ifdef strtoull +#undef strtoull +#endif #endif #include "../deps/glslang/glslang.cpp" From 2e8569a4723c71132deef6709655e199b4688458 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 4 Feb 2018 15:56:50 +0100 Subject: [PATCH 057/232] Bake in spirv_msl as well - just use UINT32_MAX - max() numeric_limits was conflicting with Windows min/max macros --- Makefile.common | 2 +- deps/SPIRV-Cross/spirv_msl.hpp | 2 +- griffin/griffin_cpp.cpp | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Makefile.common b/Makefile.common index 90ea670e95..fcf90a92d9 100644 --- a/Makefile.common +++ b/Makefile.common @@ -1361,7 +1361,7 @@ ifeq ($(HAVE_SPIRV_CROSS), 1) OBJ += $(DEPS_DIR)/SPIRV-Cross/spirv_cfg.o OBJ += $(DEPS_DIR)/SPIRV-Cross/spirv_glsl.o OBJ += $(DEPS_DIR)/SPIRV-Cross/spirv_hlsl.o - #OBJ += $(DEPS_DIR)/SPIRV-Cross/spirv_msl.o + OBJ += $(DEPS_DIR)/SPIRV-Cross/spirv_msl.o endif ifeq ($(WANT_WGL), 1) diff --git a/deps/SPIRV-Cross/spirv_msl.hpp b/deps/SPIRV-Cross/spirv_msl.hpp index 6f66f3122e..d91bca9e57 100644 --- a/deps/SPIRV-Cross/spirv_msl.hpp +++ b/deps/SPIRV-Cross/spirv_msl.hpp @@ -64,7 +64,7 @@ using MSLStructMemberKey = uint64_t; // Special constant used in a MSLResourceBinding desc_set // element to indicate the bindings for the push constants. -static const uint32_t kPushConstDescSet = std::numeric_limits::max(); +static const uint32_t kPushConstDescSet = UINT32_MAX; // Special constant used in a MSLResourceBinding binding // element to indicate the bindings for the push constants. diff --git a/griffin/griffin_cpp.cpp b/griffin/griffin_cpp.cpp index 4ec2e3349d..34ecbc4ccf 100644 --- a/griffin/griffin_cpp.cpp +++ b/griffin/griffin_cpp.cpp @@ -61,9 +61,7 @@ VIDEO DRIVER #include "../deps/SPIRV-Cross/spirv_cfg.cpp" #include "../deps/SPIRV-Cross/spirv_glsl.cpp" #include "../deps/SPIRV-Cross/spirv_hlsl.cpp" -#if 0 #include "../deps/SPIRV-Cross/spirv_msl.cpp" -#endif #ifdef HAVE_SLANG #include "../gfx/drivers_shader/glslang_util.cpp" #include "../gfx/drivers_shader/slang_preprocess.cpp" From 8b5e7c45d01d07890eb7f8b935c72a56e2cfcfb3 Mon Sep 17 00:00:00 2001 From: leiradel Date: Sun, 4 Feb 2018 15:32:17 +0000 Subject: [PATCH 058/232] Fixed empty menu when there are no cheevos --- cheevos/cheevos.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/cheevos/cheevos.c b/cheevos/cheevos.c index 3d25b8091f..9975342ddd 100644 --- a/cheevos/cheevos.c +++ b/cheevos/cheevos.c @@ -2359,49 +2359,49 @@ void cheevos_populate_menu(void *data) menu_displaylist_info_t *info = (menu_displaylist_info_t*)data; cheevo_t *end = NULL; cheevo_t *cheevo = cheevos_locals.core.cheevos; - - if (!cheevo) - return; - end = cheevo + cheevos_locals.core.count; - for (i = 0; cheevo < end; i++, cheevo++) + if (cheevo) { - if (!(cheevo->active & CHEEVOS_ACTIVE_HARDCORE)) + for (i = 0; cheevo < end; i++, cheevo++) { + if (!(cheevo->active & CHEEVOS_ACTIVE_HARDCORE)) + { menu_entries_append_enum(info->list, cheevo->title, - cheevo->description, - MENU_ENUM_LABEL_CHEEVOS_UNLOCKED_ENTRY_HARDCORE, - MENU_SETTINGS_CHEEVOS_START + i, 0, 0); + cheevo->description, + MENU_ENUM_LABEL_CHEEVOS_UNLOCKED_ENTRY_HARDCORE, + MENU_SETTINGS_CHEEVOS_START + i, 0, 0); items_found++; set_badge_info(&badges_ctx, i, cheevo->badge, (cheevo->active & CHEEVOS_ACTIVE_HARDCORE)); - } - else if (!(cheevo->active & CHEEVOS_ACTIVE_SOFTCORE)) - { + } + else if (!(cheevo->active & CHEEVOS_ACTIVE_SOFTCORE)) + { menu_entries_append_enum(info->list, cheevo->title, - cheevo->description, - MENU_ENUM_LABEL_CHEEVOS_UNLOCKED_ENTRY, - MENU_SETTINGS_CHEEVOS_START + i, 0, 0); + cheevo->description, + MENU_ENUM_LABEL_CHEEVOS_UNLOCKED_ENTRY, + MENU_SETTINGS_CHEEVOS_START + i, 0, 0); items_found++; set_badge_info(&badges_ctx, i, cheevo->badge, (cheevo->active & CHEEVOS_ACTIVE_SOFTCORE)); - } - else - { + } + else + { menu_entries_append_enum(info->list, cheevo->title, - cheevo->description, - MENU_ENUM_LABEL_CHEEVOS_LOCKED_ENTRY, - MENU_SETTINGS_CHEEVOS_START + i, 0, 0); + cheevo->description, + MENU_ENUM_LABEL_CHEEVOS_LOCKED_ENTRY, + MENU_SETTINGS_CHEEVOS_START + i, 0, 0); items_found++; set_badge_info(&badges_ctx, i, cheevo->badge, (cheevo->active & CHEEVOS_ACTIVE_SOFTCORE)); + } } } - if (settings->bools.cheevos_test_unofficial) + cheevo = cheevos_locals.unofficial.cheevos; + + if (cheevo && settings->bools.cheevos_test_unofficial) { - cheevo = cheevos_locals.unofficial.cheevos; end = cheevo + cheevos_locals.unofficial.count; for (i = cheevos_locals.core.count; cheevo < end; i++, cheevo++) From c4bb588f3b721a75e42043fb0ec235d3c3a44c46 Mon Sep 17 00:00:00 2001 From: radius Date: Sun, 4 Feb 2018 10:59:02 -0500 Subject: [PATCH 059/232] fix small logging issue --- gfx/common/win32_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index 2b3ca65af7..ab37d7ab1e 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -810,7 +810,7 @@ bool win32_window_create(void *data, unsigned style, notification_handler = RegisterDeviceNotification( main_window.hwnd, ¬ification_filter, DEVICE_NOTIFY_WINDOW_HANDLE); - if (notification_handler) + if (!notification_handler) RARCH_ERR("Error registering for notifications\n"); #endif From ac22a9ce20861c40835af62c4fd9a574b4a529eb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 4 Feb 2018 17:10:37 +0100 Subject: [PATCH 060/232] (D3D10) Start making D3D10 ready for CXX_BUILD --- gfx/common/d3d10_common.h | 1540 ++++++++++++++++++++++++++++++++----- gfx/drivers/d3d10.c | 57 +- 2 files changed, 1380 insertions(+), 217 deletions(-) diff --git a/gfx/common/d3d10_common.h b/gfx/common/d3d10_common.h index 18fc881a7a..d3e72a3fa0 100644 --- a/gfx/common/d3d10_common.h +++ b/gfx/common/d3d10_common.h @@ -52,53 +52,109 @@ typedef ID3D10InfoQueue* D3D10InfoQueue; static INLINE void D3D10SetResourceEvictionPriority(D3D10Resource resource, UINT eviction_priority) { +#ifdef __cplusplus + resource->SetEvictionPriority(eviction_priority); +#else resource->lpVtbl->SetEvictionPriority(resource, eviction_priority); +#endif } static INLINE UINT D3D10GetResourceEvictionPriority(D3D10Resource resource) { +#ifdef __cplusplus + return resource->GetEvictionPriority(); +#else return resource->lpVtbl->GetEvictionPriority(resource); +#endif } static INLINE void D3D10SetBufferEvictionPriority(D3D10Buffer buffer, UINT eviction_priority) { +#ifdef __cplusplus + buffer->SetEvictionPriority(eviction_priority); +#else buffer->lpVtbl->SetEvictionPriority(buffer, eviction_priority); +#endif } static INLINE UINT D3D10GetBufferEvictionPriority(D3D10Buffer buffer) { +#ifdef __cplusplus + return buffer->GetEvictionPriority(); +#else return buffer->lpVtbl->GetEvictionPriority(buffer); +#endif } + static INLINE HRESULT D3D10MapBuffer(D3D10Buffer buffer, D3D10_MAP map_type, UINT map_flags, void** data) { +#ifdef __cplusplus + return buffer->Map(map_type, map_flags, data); +#else return buffer->lpVtbl->Map(buffer, map_type, map_flags, data); +#endif } -static INLINE void D3D10UnmapBuffer(D3D10Buffer buffer) { buffer->lpVtbl->Unmap(buffer); } -static INLINE void -D3D10SetTexture1DEvictionPriority(D3D10Texture1D texture1d, UINT eviction_priority) +static INLINE void D3D10UnmapBuffer(D3D10Buffer buffer) { +#ifdef __cplusplus + buffer->Unmap(); +#else + buffer->lpVtbl->Unmap(buffer); +#endif +} +static INLINE void +D3D10SetTexture1DEvictionPriority(D3D10Texture1D texture1d, + UINT eviction_priority) +{ +#ifdef __cplusplus + texture1d->SetEvictionPriority(eviction_priority); +#else texture1d->lpVtbl->SetEvictionPriority(texture1d, eviction_priority); +#endif } static INLINE UINT D3D10GetTexture1DEvictionPriority(D3D10Texture1D texture1d) { +#ifdef __cplusplus + return texture1d->GetEvictionPriority(); +#else return texture1d->lpVtbl->GetEvictionPriority(texture1d); +#endif } static INLINE HRESULT D3D10MapTexture1D( D3D10Texture1D texture1d, UINT subresource, D3D10_MAP map_type, UINT map_flags, void** data) { - return texture1d->lpVtbl->Map(texture1d, subresource, map_type, map_flags, data); +#ifdef __cplusplus + return texture1d->Map(subresource, map_type, map_flags, data); +#else + return texture1d->lpVtbl->Map(texture1d, subresource, + map_type, map_flags, data); +#endif } static INLINE void D3D10UnmapTexture1D(D3D10Texture1D texture1d, UINT subresource) { +#ifdef __cplusplus + texture1d->Unmap(subresource); +#else texture1d->lpVtbl->Unmap(texture1d, subresource); +#endif } static INLINE void D3D10SetTexture2DEvictionPriority(D3D10Texture2D texture2d, UINT eviction_priority) { +#ifdef __cplusplus + texture2d->SetEvictionPriority(eviction_priority); +#else texture2d->lpVtbl->SetEvictionPriority(texture2d, eviction_priority); +#endif } + static INLINE UINT D3D10GetTexture2DEvictionPriority(D3D10Texture2D texture2d) { +#ifdef __cplusplus + return texture2d->GetEvictionPriority(); +#else return texture2d->lpVtbl->GetEvictionPriority(texture2d); +#endif } + static INLINE HRESULT D3D10MapTexture2D( D3D10Texture2D texture2d, UINT subresource, @@ -106,20 +162,40 @@ static INLINE HRESULT D3D10MapTexture2D( UINT map_flags, D3D10_MAPPED_TEXTURE2D* mapped_tex2d) { - return texture2d->lpVtbl->Map(texture2d, subresource, map_type, map_flags, mapped_tex2d); +#ifdef __cplusplus + return texture2d->Map(subresource, map_type, map_flags, mapped_tex2d); +#else + return texture2d->lpVtbl->Map(texture2d, subresource, map_type, + map_flags, mapped_tex2d); +#endif } + static INLINE void D3D10UnmapTexture2D(D3D10Texture2D texture2d, UINT subresource) { +#ifdef __cplusplus + texture2d->Unmap(subresource); +#else texture2d->lpVtbl->Unmap(texture2d, subresource); +#endif } + static INLINE void -D3D10SetTexture3DEvictionPriority(D3D10Texture3D texture3d, UINT eviction_priority) +D3D10SetTexture3DEvictionPriority(D3D10Texture3D texture3d, + UINT eviction_priority) { +#ifdef __cplusplus + texture3d->SetEvictionPriority(eviction_priority); +#else texture3d->lpVtbl->SetEvictionPriority(texture3d, eviction_priority); +#endif } static INLINE UINT D3D10GetTexture3DEvictionPriority(D3D10Texture3D texture3d) { +#ifdef __cplusplus + return texture3d->GetEvictionPriority(); +#else return texture3d->lpVtbl->GetEvictionPriority(texture3d); +#endif } static INLINE HRESULT D3D10MapTexture3D( D3D10Texture3D texture3d, @@ -128,91 +204,231 @@ static INLINE HRESULT D3D10MapTexture3D( UINT map_flags, D3D10_MAPPED_TEXTURE3D* mapped_tex3d) { - return texture3d->lpVtbl->Map(texture3d, subresource, map_type, map_flags, mapped_tex3d); +#ifdef __cplusplus + return texture3d->Map(subresource, + map_type, map_flags, mapped_tex3d); +#else + return texture3d->lpVtbl->Map(texture3d, subresource, + map_type, map_flags, mapped_tex3d); +#endif } -static INLINE void D3D10UnmapTexture3D(D3D10Texture3D texture3d, UINT subresource) +static INLINE void D3D10UnmapTexture3D(D3D10Texture3D texture3d, + UINT subresource) { +#ifdef __cplusplus + texture3d->Unmap(subresource); +#else texture3d->lpVtbl->Unmap(texture3d, subresource); +#endif } -static INLINE void D3D10GetViewResource(D3D10View view, D3D10Resource* resource) + +static INLINE void D3D10GetViewResource(D3D10View view, + D3D10Resource* resource) { +#ifdef __cplusplus + view->GetResource(resource); +#else view->lpVtbl->GetResource(view, resource); +#endif } + static INLINE void D3D10GetShaderResourceViewResource( D3D10ShaderResourceView shader_resource_view, D3D10Resource* resource) { +#ifdef __cplusplus + shader_resource_view->GetResource(resource); +#else shader_resource_view->lpVtbl->GetResource(shader_resource_view, resource); +#endif } + static INLINE void -D3D10GetRenderTargetViewResource(D3D10RenderTargetView render_target_view, D3D10Resource* resource) +D3D10GetRenderTargetViewResource(D3D10RenderTargetView render_target_view, + D3D10Resource* resource) { +#ifdef __cplusplus + render_target_view->GetResource(resource); +#else render_target_view->lpVtbl->GetResource(render_target_view, resource); +#endif } + static INLINE void -D3D10GetDepthStencilViewResource(D3D10DepthStencilView depth_stencil_view, D3D10Resource* resource) +D3D10GetDepthStencilViewResource(D3D10DepthStencilView depth_stencil_view, + D3D10Resource* resource) { +#ifdef __cplusplus + depth_stencil_view->GetResource(resource); +#else depth_stencil_view->lpVtbl->GetResource(depth_stencil_view, resource); +#endif } + static INLINE void D3D10BeginAsynchronous(D3D10Asynchronous asynchronous) { +#ifdef __cplusplus + asynchronous->Begin(); +#else asynchronous->lpVtbl->Begin(asynchronous); +#endif } + static INLINE void D3D10EndAsynchronous(D3D10Asynchronous asynchronous) { +#ifdef __cplusplus + asynchronous->End(); +#else asynchronous->lpVtbl->End(asynchronous); +#endif } + static INLINE HRESULT D3D10GetAsynchronousData( - D3D10Asynchronous asynchronous, void* data, UINT data_size, UINT get_data_flags) + D3D10Asynchronous asynchronous, void* data, + UINT data_size, UINT get_data_flags) { - return asynchronous->lpVtbl->GetData(asynchronous, data, data_size, get_data_flags); +#ifdef __cplusplus + return asynchronous->GetData(data, + data_size, get_data_flags); +#else + return asynchronous->lpVtbl->GetData(asynchronous, data, + data_size, get_data_flags); +#endif } -static INLINE UINT D3D10GetAsynchronousDataSize(D3D10Asynchronous asynchronous) + +static INLINE UINT D3D10GetAsynchronousDataSize( + D3D10Asynchronous asynchronous) { +#ifdef __cplusplus + return asynchronous->GetDataSize(); +#else return asynchronous->lpVtbl->GetDataSize(asynchronous); +#endif } -static INLINE void D3D10BeginQuery(D3D10Query query) { query->lpVtbl->Begin(query); } -static INLINE void D3D10EndQuery(D3D10Query query) { query->lpVtbl->End(query); } -static INLINE HRESULT -D3D10GetQueryData(D3D10Query query, void* data, UINT data_size, UINT get_data_flags) + +static INLINE void D3D10BeginQuery(D3D10Query query) { - return query->lpVtbl->GetData(query, data, data_size, get_data_flags); +#ifdef __cplusplus + query->Begin(); +#else + query->lpVtbl->Begin(query); +#endif } + +static INLINE void D3D10EndQuery(D3D10Query query) +{ +#ifdef __cplusplus + query->End(); +#else + query->lpVtbl->End(query); +#endif +} + +static INLINE HRESULT +D3D10GetQueryData(D3D10Query query, void* data, + UINT data_size, UINT get_data_flags) +{ +#ifdef __cplusplus + return query->GetData(data, data_size, get_data_flags); +#else + return query->lpVtbl->GetData(query, data, data_size, get_data_flags); +#endif +} + static INLINE UINT D3D10GetQueryDataSize(D3D10Query query) { +#ifdef __cplusplus + return query->GetDataSize(); +#else return query->lpVtbl->GetDataSize(query); +#endif } + static INLINE void D3D10BeginPredicate(D3D10Predicate predicate) { +#ifdef __cplusplus + predicate->Begin(); +#else predicate->lpVtbl->Begin(predicate); +#endif } + static INLINE void D3D10EndPredicate(D3D10Predicate predicate) { +#ifdef __cplusplus + predicate->End(); +#else predicate->lpVtbl->End(predicate); +#endif } + static INLINE HRESULT -D3D10GetPredicateData(D3D10Predicate predicate, void* data, UINT data_size, UINT get_data_flags) +D3D10GetPredicateData(D3D10Predicate predicate, void* data, + UINT data_size, UINT get_data_flags) { - return predicate->lpVtbl->GetData(predicate, data, data_size, get_data_flags); +#ifdef __cplusplus + return predicate->GetData(data, data_size, get_data_flags); +#else + return predicate->lpVtbl->GetData(predicate, data, + data_size, get_data_flags); +#endif } static INLINE UINT D3D10GetPredicateDataSize(D3D10Predicate predicate) { +#ifdef __cplusplus + return predicate->GetDataSize(); +#else return predicate->lpVtbl->GetDataSize(predicate); +#endif } -static INLINE void D3D10BeginCounter(D3D10Counter counter) { counter->lpVtbl->Begin(counter); } -static INLINE void D3D10EndCounter(D3D10Counter counter) { counter->lpVtbl->End(counter); } -static INLINE HRESULT -D3D10GetCounterData(D3D10Counter counter, void* data, UINT data_size, UINT get_data_flags) + +static INLINE void D3D10BeginCounter(D3D10Counter counter) { - return counter->lpVtbl->GetData(counter, data, data_size, get_data_flags); +#ifdef __cplusplus + counter->Begin(); +#else + counter->lpVtbl->Begin(counter); +#endif } + +static INLINE void D3D10EndCounter(D3D10Counter counter) +{ +#ifdef __cplusplus + counter->End(); +#else + counter->lpVtbl->End(counter); +#endif +} + +static INLINE HRESULT +D3D10GetCounterData(D3D10Counter counter, void* data, + UINT data_size, UINT get_data_flags) +{ +#ifdef __cplusplus + return counter->GetData(data, data_size, get_data_flags); +#else + return counter->lpVtbl->GetData(counter, data, data_size, get_data_flags); +#endif +} + static INLINE UINT D3D10GetCounterDataSize(D3D10Counter counter) { +#ifdef __cplusplus + return counter->GetDataSize(); +#else return counter->lpVtbl->GetDataSize(counter); +#endif } + static INLINE void D3D10SetVShaderConstantBuffers( - D3D10Device device, UINT start_slot, UINT num_buffers, D3D10Buffer* const constant_buffers) + D3D10Device device, UINT start_slot, UINT num_buffers, + D3D10Buffer* const constant_buffers) { - device->lpVtbl->VSSetConstantBuffers(device, start_slot, num_buffers, constant_buffers); +#ifdef __cplusplus + device->VSSetConstantBuffers(start_slot, num_buffers, constant_buffers); +#else + device->lpVtbl->VSSetConstantBuffers(device, start_slot, + num_buffers, constant_buffers); +#endif } static INLINE void D3D10SetPShaderResources( D3D10Device device, @@ -220,39 +436,92 @@ static INLINE void D3D10SetPShaderResources( UINT num_views, D3D10ShaderResourceView* const shader_resource_views) { - device->lpVtbl->PSSetShaderResources(device, start_slot, num_views, shader_resource_views); +#ifdef __cplusplus + device->PSSetShaderResources(start_slot, num_views, + shader_resource_views); +#else + device->lpVtbl->PSSetShaderResources(device, start_slot, + num_views, shader_resource_views); +#endif } -static INLINE void D3D10SetPShader(D3D10Device device, D3D10PixelShader pixel_shader) + +static INLINE void D3D10SetPShader(D3D10Device device, + D3D10PixelShader pixel_shader) { +#ifdef __cplusplus + device->PSSetShader(pixel_shader); +#else device->lpVtbl->PSSetShader(device, pixel_shader); +#endif } + static INLINE void D3D10SetPShaderSamplers( - D3D10Device device, UINT start_slot, UINT num_samplers, D3D10SamplerState* const samplers) + D3D10Device device, UINT start_slot, UINT num_samplers, + D3D10SamplerState* const samplers) { - device->lpVtbl->PSSetSamplers(device, start_slot, num_samplers, samplers); +#ifdef __cplusplus + device->PSSetSamplers(start_slot, num_samplers, samplers); +#else + device->lpVtbl->PSSetSamplers(device, start_slot, + num_samplers, samplers); +#endif } -static INLINE void D3D10SetVShader(D3D10Device device, D3D10VertexShader vertex_shader) + +static INLINE void D3D10SetVShader(D3D10Device device, + D3D10VertexShader vertex_shader) { +#ifdef __cplusplus + device->VSSetShader(vertex_shader); +#else device->lpVtbl->VSSetShader(device, vertex_shader); +#endif } + static INLINE void D3D10DrawIndexed( - D3D10Device device, UINT index_count, UINT start_index_location, INT base_vertex_location) + D3D10Device device, UINT index_count, + UINT start_index_location, INT base_vertex_location) { - device->lpVtbl->DrawIndexed(device, index_count, start_index_location, base_vertex_location); +#ifdef __cplusplus + device->DrawIndexed(index_count, + start_index_location, base_vertex_location); +#else + device->lpVtbl->DrawIndexed(device, index_count, + start_index_location, base_vertex_location); +#endif } -static INLINE void D3D10Draw(D3D10Device device, UINT vertex_count, UINT start_vertex_location) +static INLINE void D3D10Draw(D3D10Device device, + UINT vertex_count, UINT start_vertex_location) { +#ifdef __cplusplus + device->Draw(vertex_count, start_vertex_location); +#else device->lpVtbl->Draw(device, vertex_count, start_vertex_location); +#endif } + static INLINE void D3D10SetPShaderConstantBuffers( - D3D10Device device, UINT start_slot, UINT num_buffers, D3D10Buffer* const constant_buffers) + D3D10Device device, UINT start_slot, + UINT num_buffers, D3D10Buffer* const constant_buffers) { - device->lpVtbl->PSSetConstantBuffers(device, start_slot, num_buffers, constant_buffers); +#ifdef __cplusplus + device->PSSetConstantBuffers(start_slot, + num_buffers, constant_buffers); +#else + device->lpVtbl->PSSetConstantBuffers(device, start_slot, + num_buffers, constant_buffers); +#endif } -static INLINE void D3D10SetInputLayout(D3D10Device device, D3D10InputLayout input_layout) + +static INLINE void D3D10SetInputLayout(D3D10Device device, + D3D10InputLayout input_layout) { +#ifdef __cplusplus + device->IASetInputLayout(input_layout); +#else device->lpVtbl->IASetInputLayout(device, input_layout); +#endif } + static INLINE void D3D10SetVertexBuffers( D3D10Device device, UINT start_slot, @@ -261,14 +530,28 @@ static INLINE void D3D10SetVertexBuffers( UINT* strides, UINT* offsets) { +#ifdef __cplusplus + device->IASetVertexBuffers( + start_slot, num_buffers, + vertex_buffers, strides, offsets); +#else device->lpVtbl->IASetVertexBuffers( - device, start_slot, num_buffers, vertex_buffers, strides, offsets); + device, start_slot, num_buffers, + vertex_buffers, strides, offsets); +#endif } + static INLINE void -D3D10SetIndexBuffer(D3D10Device device, D3D10Buffer index_buffer, DXGI_FORMAT format, UINT offset) +D3D10SetIndexBuffer(D3D10Device device, + D3D10Buffer index_buffer, DXGI_FORMAT format, UINT offset) { +#ifdef __cplusplus + device->IASetIndexBuffer(index_buffer, format, offset); +#else device->lpVtbl->IASetIndexBuffer(device, index_buffer, format, offset); +#endif } + static INLINE void D3D10DrawIndexedInstanced( D3D10Device device, UINT index_count_per_instance, @@ -277,10 +560,19 @@ static INLINE void D3D10DrawIndexedInstanced( INT base_vertex_location, UINT start_instance_location) { - device->lpVtbl->DrawIndexedInstanced( - device, index_count_per_instance, instance_count, start_index_location, +#ifdef __cplusplus + device->DrawIndexedInstanced( + index_count_per_instance, + instance_count, start_index_location, base_vertex_location, start_instance_location); +#else + device->lpVtbl->DrawIndexedInstanced( + device, index_count_per_instance, + instance_count, start_index_location, + base_vertex_location, start_instance_location); +#endif } + static INLINE void D3D10DrawInstanced( D3D10Device device, UINT vertex_count_per_instance, @@ -288,91 +580,209 @@ static INLINE void D3D10DrawInstanced( UINT start_vertex_location, UINT start_instance_location) { - device->lpVtbl->DrawInstanced( - device, vertex_count_per_instance, instance_count, start_vertex_location, +#ifdef __cplusplus + device->DrawInstanced( + vertex_count_per_instance, + instance_count, start_vertex_location, start_instance_location); +#else + device->lpVtbl->DrawInstanced( + device, vertex_count_per_instance, + instance_count, start_vertex_location, + start_instance_location); +#endif } + static INLINE void D3D10SetGShaderConstantBuffers( - D3D10Device device, UINT start_slot, UINT num_buffers, D3D10Buffer* const constant_buffers) + D3D10Device device, UINT start_slot, + UINT num_buffers, D3D10Buffer* const constant_buffers) { - device->lpVtbl->GSSetConstantBuffers(device, start_slot, num_buffers, constant_buffers); +#ifdef __cplusplus + device->GSSetConstantBuffers(start_slot, + num_buffers, constant_buffers); +#else + device->lpVtbl->GSSetConstantBuffers(device, start_slot, + num_buffers, constant_buffers); +#endif } -static INLINE void D3D10SetGShader(D3D10Device device, D3D10GeometryShader shader) + +static INLINE void D3D10SetGShader(D3D10Device device, + D3D10GeometryShader shader) { +#ifdef __cplusplus + device->GSSetShader(shader); +#else device->lpVtbl->GSSetShader(device, shader); +#endif } -static INLINE void D3D10SetPrimitiveTopology(D3D10Device device, D3D10_PRIMITIVE_TOPOLOGY topology) + +static INLINE void D3D10SetPrimitiveTopology(D3D10Device device, + D3D10_PRIMITIVE_TOPOLOGY topology) { +#ifdef __cplusplus + device->IASetPrimitiveTopology(topology); +#else device->lpVtbl->IASetPrimitiveTopology(device, topology); +#endif } + static INLINE void D3D10SetVShaderResources( D3D10Device device, UINT start_slot, UINT num_views, D3D10ShaderResourceView* const shader_resource_views) { - device->lpVtbl->VSSetShaderResources(device, start_slot, num_views, shader_resource_views); +#ifdef __cplusplus + device->VSSetShaderResources(start_slot, + num_views, shader_resource_views); +#else + device->lpVtbl->VSSetShaderResources(device, start_slot, + num_views, shader_resource_views); +#endif } + static INLINE void D3D10SetVShaderSamplers( - D3D10Device device, UINT start_slot, UINT num_samplers, D3D10SamplerState* const samplers) + D3D10Device device, UINT start_slot, + UINT num_samplers, D3D10SamplerState* const samplers) { - device->lpVtbl->VSSetSamplers(device, start_slot, num_samplers, samplers); +#ifdef __cplusplus + device->VSSetSamplers(start_slot, num_samplers, samplers); +#else + device->lpVtbl->VSSetSamplers(device, start_slot, + num_samplers, samplers); +#endif } + static INLINE void -D3D10SetPredication(D3D10Device device, D3D10Predicate predicate, BOOL predicate_value) +D3D10SetPredication(D3D10Device device, D3D10Predicate predicate, + BOOL predicate_value) { +#ifdef __cplusplus + device->SetPredication(predicate, predicate_value); +#else device->lpVtbl->SetPredication(device, predicate, predicate_value); +#endif } + static INLINE void D3D10SetGShaderResources( D3D10Device device, UINT start_slot, UINT num_views, D3D10ShaderResourceView* const shader_resource_views) { - device->lpVtbl->GSSetShaderResources(device, start_slot, num_views, shader_resource_views); +#ifdef __cplusplus + device->GSSetShaderResources(start_slot, + num_views, shader_resource_views); +#else + device->lpVtbl->GSSetShaderResources(device, start_slot, + num_views, shader_resource_views); +#endif } + static INLINE void D3D10SetGShaderSamplers( - D3D10Device device, UINT start_slot, UINT num_samplers, D3D10SamplerState* const samplers) + D3D10Device device, UINT start_slot, + UINT num_samplers, D3D10SamplerState* const samplers) { - device->lpVtbl->GSSetSamplers(device, start_slot, num_samplers, samplers); +#ifdef __cplusplus + device->GSSetSamplers(start_slot, + num_samplers, samplers); +#else + device->lpVtbl->GSSetSamplers(device, start_slot, + num_samplers, samplers); +#endif } + static INLINE void D3D10SetRenderTargets( D3D10Device device, UINT num_views, D3D10RenderTargetView* const render_target_views, D3D10DepthStencilView depth_stencil_view) { - device->lpVtbl->OMSetRenderTargets(device, num_views, render_target_views, depth_stencil_view); +#ifdef __cplusplus + device->OMSetRenderTargets(num_views, + render_target_views, depth_stencil_view); +#else + device->lpVtbl->OMSetRenderTargets(device, num_views, + render_target_views, depth_stencil_view); +#endif } + static INLINE void D3D10SetBlendState( - D3D10Device device, D3D10BlendState blend_state, FLOAT blend_factor[4], UINT sample_mask) + D3D10Device device, D3D10BlendState blend_state, + FLOAT blend_factor[4], UINT sample_mask) { - device->lpVtbl->OMSetBlendState(device, blend_state, blend_factor, sample_mask); +#ifdef __cplusplus + device->OMSetBlendState(blend_state, + blend_factor, sample_mask); +#else + device->lpVtbl->OMSetBlendState(device, blend_state, + blend_factor, sample_mask); +#endif } + static INLINE void D3D10SetDepthStencilState( - D3D10Device device, D3D10DepthStencilState depth_stencil_state, UINT stencil_ref) + D3D10Device device, + D3D10DepthStencilState depth_stencil_state, UINT stencil_ref) { - device->lpVtbl->OMSetDepthStencilState(device, depth_stencil_state, stencil_ref); +#ifdef __cplusplus + device->OMSetDepthStencilState(depth_stencil_state, stencil_ref); +#else + device->lpVtbl->OMSetDepthStencilState(device, depth_stencil_state, + stencil_ref); +#endif } + static INLINE void -D3D10SOSetTargets(D3D10Device device, UINT num_buffers, D3D10Buffer* const sotargets, UINT* offsets) +D3D10SOSetTargets(D3D10Device device, UINT num_buffers, + D3D10Buffer* const sotargets, UINT* offsets) { +#ifdef __cplusplus + device->SOSetTargets(num_buffers, sotargets, offsets); +#else device->lpVtbl->SOSetTargets(device, num_buffers, sotargets, offsets); +#endif } -static INLINE void D3D10DrawAuto(D3D10Device device) { device->lpVtbl->DrawAuto(device); } -static INLINE void D3D10SetState(D3D10Device device, D3D10RasterizerState rasterizer_state) + +static INLINE void D3D10DrawAuto(D3D10Device device) { +#ifdef __cplusplus + device->DrawAuto(); +#else + device->lpVtbl->DrawAuto(device); +#endif +} + +static INLINE void D3D10SetState(D3D10Device device, + D3D10RasterizerState rasterizer_state) +{ +#ifdef __cplusplus + device->RSSetState(rasterizer_state); +#else device->lpVtbl->RSSetState(device, rasterizer_state); +#endif } + static INLINE void -D3D10SetViewports(D3D10Device device, UINT num_viewports, D3D10_VIEWPORT* viewports) +D3D10SetViewports(D3D10Device device, + UINT num_viewports, D3D10_VIEWPORT* viewports) { +#ifdef __cplusplus + device->RSSetViewports(num_viewports, viewports); +#else device->lpVtbl->RSSetViewports(device, num_viewports, viewports); +#endif } -static INLINE void D3D10SetScissorRects(D3D10Device device, UINT num_rects, D3D10_RECT* rects) + +static INLINE void D3D10SetScissorRects(D3D10Device device, + UINT num_rects, D3D10_RECT* rects) { +#ifdef __cplusplus + device->RSSetScissorRects(num_rects, rects); +#else device->lpVtbl->RSSetScissorRects(device, num_rects, rects); +#endif } + static INLINE void D3D10CopySubresourceRegionDevice( D3D10Device device, D3D10Resource dst_resource, @@ -384,15 +794,32 @@ static INLINE void D3D10CopySubresourceRegionDevice( UINT src_subresource, D3D10_BOX* src_box) { - device->lpVtbl->CopySubresourceRegion( - device, dst_resource, dst_subresource, dst_x, dst_y, dst_z, src_resource, src_subresource, +#ifdef __cplusplus + device->CopySubresourceRegion( + dst_resource, + dst_subresource, dst_x, dst_y, dst_z, + src_resource, src_subresource, src_box); +#else + device->lpVtbl->CopySubresourceRegion( + device, dst_resource, + dst_subresource, dst_x, dst_y, dst_z, + src_resource, src_subresource, + src_box); +#endif } + static INLINE void -D3D10CopyResource(D3D10Device device, D3D10Resource dst_resource, D3D10Resource src_resource) +D3D10CopyResource(D3D10Device device, + D3D10Resource dst_resource, D3D10Resource src_resource) { +#ifdef __cplusplus + device->CopyResource(dst_resource, src_resource); +#else device->lpVtbl->CopyResource(device, dst_resource, src_resource); +#endif } + static INLINE void D3D10UpdateSubresource( D3D10Device device, D3D10Resource dst_resource, @@ -402,14 +829,29 @@ static INLINE void D3D10UpdateSubresource( UINT src_row_pitch, UINT src_depth_pitch) { +#ifdef __cplusplus + device->UpdateSubresource( + dst_resource, dst_subresource, + dst_box, src_data, src_row_pitch, src_depth_pitch); +#else device->lpVtbl->UpdateSubresource( - device, dst_resource, dst_subresource, dst_box, src_data, src_row_pitch, src_depth_pitch); + device, dst_resource, dst_subresource, + dst_box, src_data, src_row_pitch, src_depth_pitch); +#endif } + static INLINE void D3D10ClearRenderTargetView( - D3D10Device device, D3D10RenderTargetView render_target_view, FLOAT color_rgba[4]) + D3D10Device device, D3D10RenderTargetView render_target_view, + FLOAT color_rgba[4]) { - device->lpVtbl->ClearRenderTargetView(device, render_target_view, color_rgba); +#ifdef __cplusplus + device->ClearRenderTargetView(render_target_view, color_rgba); +#else + device->lpVtbl->ClearRenderTargetView(device, + render_target_view, color_rgba); +#endif } + static INLINE void D3D10ClearDepthStencilView( D3D10Device device, D3D10DepthStencilView depth_stencil_view, @@ -417,13 +859,26 @@ static INLINE void D3D10ClearDepthStencilView( FLOAT depth, UINT8 stencil) { - device->lpVtbl->ClearDepthStencilView(device, depth_stencil_view, clear_flags, depth, stencil); +#ifdef __cplusplus + device->ClearDepthStencilView(depth_stencil_view, + clear_flags, depth, stencil); +#else + device->lpVtbl->ClearDepthStencilView(device, + depth_stencil_view, clear_flags, depth, stencil); +#endif } + static INLINE void -D3D10GenerateMips(D3D10Device device, D3D10ShaderResourceView shader_resource_view) +D3D10GenerateMips(D3D10Device device, + D3D10ShaderResourceView shader_resource_view) { +#ifdef __cplusplus + device->GenerateMips(shader_resource_view); +#else device->lpVtbl->GenerateMips(device, shader_resource_view); +#endif } + static INLINE void D3D10ResolveSubresource( D3D10Device device, D3D10Resource dst_resource, @@ -432,44 +887,101 @@ static INLINE void D3D10ResolveSubresource( UINT src_subresource, DXGI_FORMAT format) { +#ifdef __cplusplus + device->ResolveSubresource( + dst_resource, dst_subresource, + src_resource, src_subresource, format); +#else device->lpVtbl->ResolveSubresource( - device, dst_resource, dst_subresource, src_resource, src_subresource, format); + device, dst_resource, dst_subresource, + src_resource, src_subresource, format); +#endif } + static INLINE void D3D10GetVShaderConstantBuffers( - D3D10Device device, UINT start_slot, UINT num_buffers, D3D10Buffer* constant_buffers) + D3D10Device device, UINT start_slot, + UINT num_buffers, D3D10Buffer* constant_buffers) { - device->lpVtbl->VSGetConstantBuffers(device, start_slot, num_buffers, constant_buffers); +#ifdef __cplusplus + device->VSGetConstantBuffers(start_slot, + num_buffers, constant_buffers); +#else + device->lpVtbl->VSGetConstantBuffers(device, start_slot, + num_buffers, constant_buffers); +#endif } + static INLINE void D3D10GetPShaderResources( D3D10Device device, UINT start_slot, UINT num_views, D3D10ShaderResourceView* shader_resource_views) { - device->lpVtbl->PSGetShaderResources(device, start_slot, num_views, shader_resource_views); +#ifdef __cplusplus + device->PSGetShaderResources(start_slot, + num_views, shader_resource_views); +#else + device->lpVtbl->PSGetShaderResources(device, start_slot, + num_views, shader_resource_views); +#endif } -static INLINE void D3D10GetPShader(D3D10Device device, D3D10PixelShader* pixel_shader) + +static INLINE void D3D10GetPShader(D3D10Device device, + D3D10PixelShader* pixel_shader) { +#ifdef __cplusplus + device->PSGetShader(pixel_shader); +#else device->lpVtbl->PSGetShader(device, pixel_shader); +#endif } + static INLINE void D3D10GetPShaderSamplers( - D3D10Device device, UINT start_slot, UINT num_samplers, D3D10SamplerState* samplers) + D3D10Device device, UINT start_slot, + UINT num_samplers, D3D10SamplerState* samplers) { - device->lpVtbl->PSGetSamplers(device, start_slot, num_samplers, samplers); +#ifdef __cplusplus + device->PSGetSamplers(start_slot, + num_samplers, samplers); +#else + device->lpVtbl->PSGetSamplers(device, start_slot, + num_samplers, samplers); +#endif } -static INLINE void D3D10GetVShader(D3D10Device device, D3D10VertexShader* vertex_shader) + +static INLINE void D3D10GetVShader(D3D10Device device, + D3D10VertexShader* vertex_shader) { +#ifdef __cplusplus + device->VSGetShader(vertex_shader); +#else device->lpVtbl->VSGetShader(device, vertex_shader); +#endif } + static INLINE void D3D10GetPShaderConstantBuffers( - D3D10Device device, UINT start_slot, UINT num_buffers, D3D10Buffer* constant_buffers) + D3D10Device device, UINT start_slot, + UINT num_buffers, D3D10Buffer* constant_buffers) { - device->lpVtbl->PSGetConstantBuffers(device, start_slot, num_buffers, constant_buffers); +#ifdef __cplusplus + device->PSGetConstantBuffers(start_slot, + num_buffers, constant_buffers); +#else + device->lpVtbl->PSGetConstantBuffers(device, start_slot, + num_buffers, constant_buffers); +#endif } -static INLINE void D3D10GetInputLayout(D3D10Device device, D3D10InputLayout* input_layout) + +static INLINE void D3D10GetInputLayout(D3D10Device device, + D3D10InputLayout* input_layout) { +#ifdef __cplusplus + device->IAGetInputLayout(input_layout); +#else device->lpVtbl->IAGetInputLayout(device, input_layout); +#endif } + static INLINE void D3D10GetVertexBuffers( D3D10Device device, UINT start_slot, @@ -478,131 +990,296 @@ static INLINE void D3D10GetVertexBuffers( UINT* strides, UINT* offsets) { +#ifdef __cplusplus + device->IAGetVertexBuffers( + start_slot, num_buffers, + vertex_buffers, strides, offsets); +#else device->lpVtbl->IAGetVertexBuffers( - device, start_slot, num_buffers, vertex_buffers, strides, offsets); + device, start_slot, num_buffers, + vertex_buffers, strides, offsets); +#endif } + static INLINE void D3D10GetIndexBuffer( - D3D10Device device, D3D10Buffer* index_buffer, DXGI_FORMAT* format, UINT* offset) + D3D10Device device, D3D10Buffer* index_buffer, + DXGI_FORMAT* format, UINT* offset) { +#ifdef __cplusplus + device->IAGetIndexBuffer(index_buffer, format, offset); +#else device->lpVtbl->IAGetIndexBuffer(device, index_buffer, format, offset); +#endif } + static INLINE void D3D10GetGShaderConstantBuffers( - D3D10Device device, UINT start_slot, UINT num_buffers, D3D10Buffer* constant_buffers) + D3D10Device device, UINT start_slot, + UINT num_buffers, D3D10Buffer* constant_buffers) { - device->lpVtbl->GSGetConstantBuffers(device, start_slot, num_buffers, constant_buffers); +#ifdef __cplusplus + device->GSGetConstantBuffers(start_slot, + num_buffers, constant_buffers); +#else + device->lpVtbl->GSGetConstantBuffers(device, start_slot, + num_buffers, constant_buffers); +#endif } -static INLINE void D3D10GetGShader(D3D10Device device, D3D10GeometryShader* geometry_shader) + +static INLINE void D3D10GetGShader(D3D10Device device, + D3D10GeometryShader* geometry_shader) { +#ifdef __cplusplus + device->GSGetShader(geometry_shader); +#else device->lpVtbl->GSGetShader(device, geometry_shader); +#endif } -static INLINE void D3D10GetPrimitiveTopology(D3D10Device device, D3D10_PRIMITIVE_TOPOLOGY* topology) + +static INLINE void D3D10GetPrimitiveTopology(D3D10Device device, + D3D10_PRIMITIVE_TOPOLOGY* topology) { +#ifdef __cplusplus + device->IAGetPrimitiveTopology(topology); +#else device->lpVtbl->IAGetPrimitiveTopology(device, topology); +#endif } + static INLINE void D3D10GetVShaderResources( D3D10Device device, UINT start_slot, UINT num_views, D3D10ShaderResourceView* shader_resource_views) { - device->lpVtbl->VSGetShaderResources(device, start_slot, num_views, shader_resource_views); +#ifdef __cplusplus + device->VSGetShaderResources(start_slot, + num_views, shader_resource_views); +#else + device->lpVtbl->VSGetShaderResources(device, start_slot, + num_views, shader_resource_views); +#endif } static INLINE void D3D10GetVShaderSamplers( - D3D10Device device, UINT start_slot, UINT num_samplers, D3D10SamplerState* samplers) + D3D10Device device, UINT start_slot, + UINT num_samplers, D3D10SamplerState* samplers) { - device->lpVtbl->VSGetSamplers(device, start_slot, num_samplers, samplers); +#ifdef __cplusplus + device->VSGetSamplers(start_slot, num_samplers, samplers); +#else + device->lpVtbl->VSGetSamplers(device, start_slot, + num_samplers, samplers); +#endif } + static INLINE void -D3D10GetPredication(D3D10Device device, D3D10Predicate* predicate, BOOL* predicate_value) +D3D10GetPredication(D3D10Device device, + D3D10Predicate* predicate, BOOL* predicate_value) { +#ifdef __cplusplus + device->GetPredication(predicate, predicate_value); +#else device->lpVtbl->GetPredication(device, predicate, predicate_value); +#endif } + static INLINE void D3D10GetGShaderResources( D3D10Device device, UINT start_slot, UINT num_views, D3D10ShaderResourceView* shader_resource_views) { - device->lpVtbl->GSGetShaderResources(device, start_slot, num_views, shader_resource_views); +#ifdef __cplusplus + device->GSGetShaderResources(start_slot, + num_views, shader_resource_views); +#else + device->lpVtbl->GSGetShaderResources(device, start_slot, + num_views, shader_resource_views); +#endif } + static INLINE void D3D10GetGShaderSamplers( - D3D10Device device, UINT start_slot, UINT num_samplers, D3D10SamplerState* samplers) + D3D10Device device, UINT start_slot, + UINT num_samplers, D3D10SamplerState* samplers) { - device->lpVtbl->GSGetSamplers(device, start_slot, num_samplers, samplers); +#ifdef __cplusplus + device->GSGetSamplers(start_slot, num_samplers, samplers); +#else + device->lpVtbl->GSGetSamplers(device, start_slot, + num_samplers, samplers); +#endif } + static INLINE void D3D10GetRenderTargets( D3D10Device device, UINT num_views, D3D10RenderTargetView* render_target_views, D3D10DepthStencilView* depth_stencil_view) { - device->lpVtbl->OMGetRenderTargets(device, num_views, render_target_views, depth_stencil_view); +#ifdef __cplusplus + device->OMGetRenderTargets(num_views, + render_target_views, depth_stencil_view); +#else + device->lpVtbl->OMGetRenderTargets(device, num_views, + render_target_views, depth_stencil_view); +#endif } + static INLINE void D3D10GetBlendState( - D3D10Device device, D3D10BlendState* blend_state, FLOAT blend_factor[4], UINT* sample_mask) + D3D10Device device, + D3D10BlendState* blend_state, + FLOAT blend_factor[4], UINT* sample_mask) { - device->lpVtbl->OMGetBlendState(device, blend_state, blend_factor, sample_mask); +#ifdef __cplusplus + device->OMGetBlendState(blend_state, blend_factor, sample_mask); +#else + device->lpVtbl->OMGetBlendState(device, blend_state, + blend_factor, sample_mask); +#endif } + static INLINE void D3D10GetDepthStencilState( - D3D10Device device, D3D10DepthStencilState* depth_stencil_state, UINT* stencil_ref) + D3D10Device device, + D3D10DepthStencilState* depth_stencil_state, UINT* stencil_ref) { - device->lpVtbl->OMGetDepthStencilState(device, depth_stencil_state, stencil_ref); +#ifdef __cplusplus + device->OMGetDepthStencilState(depth_stencil_state, stencil_ref); +#else + device->lpVtbl->OMGetDepthStencilState(device, + depth_stencil_state, stencil_ref); +#endif } + static INLINE void -D3D10SOGetTargets(D3D10Device device, UINT num_buffers, D3D10Buffer* sotargets, UINT* offsets) +D3D10SOGetTargets(D3D10Device device, + UINT num_buffers, D3D10Buffer* sotargets, UINT* offsets) { +#ifdef __cplusplus + device->SOGetTargets(num_buffers, sotargets, offsets); +#else device->lpVtbl->SOGetTargets(device, num_buffers, sotargets, offsets); +#endif } -static INLINE void D3D10GetState(D3D10Device device, D3D10RasterizerState* rasterizer_state) + +static INLINE void D3D10GetState(D3D10Device device, + D3D10RasterizerState* rasterizer_state) { +#ifdef __cplusplus + device->RSGetState(rasterizer_state); +#else device->lpVtbl->RSGetState(device, rasterizer_state); +#endif } + static INLINE void -D3D10GetViewports(D3D10Device device, UINT* num_viewports, D3D10_VIEWPORT* viewports) +D3D10GetViewports(D3D10Device device, + UINT* num_viewports, D3D10_VIEWPORT* viewports) { +#ifdef __cplusplus + device->RSGetViewports(num_viewports, viewports); +#else device->lpVtbl->RSGetViewports(device, num_viewports, viewports); +#endif } -static INLINE void D3D10GetScissorRects(D3D10Device device, UINT* num_rects, D3D10_RECT* rects) + +static INLINE void D3D10GetScissorRects(D3D10Device device, + UINT* num_rects, D3D10_RECT* rects) { +#ifdef __cplusplus + device->RSGetScissorRects(num_rects, rects); +#else device->lpVtbl->RSGetScissorRects(device, num_rects, rects); +#endif } + static INLINE HRESULT D3D10GetDeviceRemovedReason(D3D10Device device) { +#ifdef __cplusplus + return device->GetDeviceRemovedReason(); +#else return device->lpVtbl->GetDeviceRemovedReason(device); +#endif } -static INLINE HRESULT D3D10SetExceptionMode(D3D10Device device, UINT raise_flags) + +static INLINE HRESULT D3D10SetExceptionMode(D3D10Device device, + UINT raise_flags) { +#ifdef __cplusplus + return device->SetExceptionMode(raise_flags); +#else return device->lpVtbl->SetExceptionMode(device, raise_flags); +#endif } + static INLINE UINT D3D10GetExceptionMode(D3D10Device device) { +#ifdef __cplusplus + return device->GetExceptionMode(); +#else return device->lpVtbl->GetExceptionMode(device); +#endif } -static INLINE void D3D10ClearState(D3D10Device device) { device->lpVtbl->ClearState(device); } -static INLINE void D3D10Flush(D3D10Device device) { device->lpVtbl->Flush(device); } + +static INLINE void D3D10ClearState(D3D10Device device) +{ +#ifdef __cplusplus + device->ClearState(); +#else + device->lpVtbl->ClearState(device); +#endif +} + +static INLINE void D3D10Flush(D3D10Device device) +{ +#ifdef __cplusplus + device->Flush(); +#else + device->lpVtbl->Flush(device); +#endif +} + static INLINE HRESULT D3D10CreateBuffer( D3D10Device device, D3D10_BUFFER_DESC* desc, D3D10_SUBRESOURCE_DATA* initial_data, D3D10Buffer* buffer) { - return device->lpVtbl->CreateBuffer(device, desc, initial_data, buffer); +#ifdef __cplusplus + return device->CreateBuffer( + desc, initial_data, buffer); +#else + return device->lpVtbl->CreateBuffer(device, + desc, initial_data, buffer); +#endif } + static INLINE HRESULT D3D10CreateTexture1D( D3D10Device device, D3D10_TEXTURE1D_DESC* desc, D3D10_SUBRESOURCE_DATA* initial_data, D3D10Texture1D* texture1d) { - return device->lpVtbl->CreateTexture1D(device, desc, initial_data, texture1d); +#ifdef __cplusplus + return device->CreateTexture1D( + desc, initial_data, texture1d); +#else + return device->lpVtbl->CreateTexture1D(device, + desc, initial_data, texture1d); +#endif } + static INLINE HRESULT D3D10CreateTexture2D( D3D10Device device, D3D10_TEXTURE2D_DESC* desc, D3D10_SUBRESOURCE_DATA* initial_data, D3D10Texture2D* texture2d) { - return device->lpVtbl->CreateTexture2D(device, desc, initial_data, texture2d); +#ifdef __cplusplus + return device->CreateTexture2D( + desc, initial_data, texture2d); +#else + return device->lpVtbl->CreateTexture2D(device, + desc, initial_data, texture2d); +#endif } static INLINE HRESULT D3D10CreateTexture3D( D3D10Device device, @@ -610,15 +1287,28 @@ static INLINE HRESULT D3D10CreateTexture3D( D3D10_SUBRESOURCE_DATA* initial_data, D3D10Texture3D* texture3d) { - return device->lpVtbl->CreateTexture3D(device, desc, initial_data, texture3d); +#ifdef __cplusplus + return device->CreateTexture3D( + desc, initial_data, texture3d); +#else + return device->lpVtbl->CreateTexture3D(device, + desc, initial_data, texture3d); +#endif } + static INLINE HRESULT D3D10CreateShaderResourceViewDevice( D3D10Device device, D3D10Resource resource, D3D10_SHADER_RESOURCE_VIEW_DESC* desc, D3D10ShaderResourceView* srview) { - return device->lpVtbl->CreateShaderResourceView(device, resource, desc, srview); +#ifdef __cplusplus + return device->CreateShaderResourceView( + resource, desc, srview); +#else + return device->lpVtbl->CreateShaderResourceView(device, + resource, desc, srview); +#endif } static INLINE HRESULT D3D10CreateRenderTargetViewDevice( D3D10Device device, @@ -626,16 +1316,30 @@ static INLINE HRESULT D3D10CreateRenderTargetViewDevice( D3D10_RENDER_TARGET_VIEW_DESC* desc, D3D10RenderTargetView* rtview) { - return device->lpVtbl->CreateRenderTargetView(device, resource, desc, rtview); +#ifdef __cplusplus + return device->CreateRenderTargetView( + resource, desc, rtview); +#else + return device->lpVtbl->CreateRenderTargetView(device, + resource, desc, rtview); +#endif } + static INLINE HRESULT D3D10CreateDepthStencilView( D3D10Device device, D3D10Resource resource, D3D10_DEPTH_STENCIL_VIEW_DESC* desc, D3D10DepthStencilView* depth_stencil_view) { - return device->lpVtbl->CreateDepthStencilView(device, resource, desc, depth_stencil_view); +#ifdef __cplusplus + return device->CreateDepthStencilView( + resource, desc, depth_stencil_view); +#else + return device->lpVtbl->CreateDepthStencilView(device, + resource, desc, depth_stencil_view); +#endif } + static INLINE HRESULT D3D10CreateInputLayout( D3D10Device device, D3D10_INPUT_ELEMENT_DESC* input_element_descs, @@ -644,27 +1348,47 @@ static INLINE HRESULT D3D10CreateInputLayout( SIZE_T bytecode_length, D3D10InputLayout* input_layout) { - return device->lpVtbl->CreateInputLayout( - device, input_element_descs, num_elements, shader_bytecode_with_input_signature, +#ifdef __cplusplus + return device->CreateInputLayout( + input_element_descs, + num_elements, shader_bytecode_with_input_signature, bytecode_length, input_layout); +#else + return device->lpVtbl->CreateInputLayout( + device, input_element_descs, + num_elements, shader_bytecode_with_input_signature, + bytecode_length, input_layout); +#endif } + static INLINE HRESULT D3D10CreateVertexShader( D3D10Device device, void* shader_bytecode, SIZE_T bytecode_length, D3D10VertexShader* vertex_shader) { +#ifdef __cplusplus + return device->CreateVertexShader( + shader_bytecode, bytecode_length, vertex_shader); +#else return device->lpVtbl->CreateVertexShader( device, shader_bytecode, bytecode_length, vertex_shader); +#endif } + static INLINE HRESULT D3D10CreateGeometryShader( D3D10Device device, void* shader_bytecode, SIZE_T bytecode_length, D3D10GeometryShader* geometry_shader) { +#ifdef __cplusplus + return device->CreateGeometryShader( + shader_bytecode, bytecode_length, geometry_shader); +#else return device->lpVtbl->CreateGeometryShader( device, shader_bytecode, bytecode_length, geometry_shader); +#endif } static INLINE HRESULT D3D10CreateGeometryShaderWithStreamOutput( D3D10Device device, @@ -675,72 +1399,158 @@ static INLINE HRESULT D3D10CreateGeometryShaderWithStreamOutput( UINT output_stream_stride, D3D10GeometryShader* geometry_shader) { - return device->lpVtbl->CreateGeometryShaderWithStreamOutput( - device, shader_bytecode, bytecode_length, sodeclaration, num_entries, output_stream_stride, +#ifdef __cplusplus + return device->CreateGeometryShaderWithStreamOutput( + shader_bytecode, bytecode_length, + sodeclaration, num_entries, output_stream_stride, geometry_shader); +#else + return device->lpVtbl->CreateGeometryShaderWithStreamOutput( + device, shader_bytecode, bytecode_length, + sodeclaration, num_entries, output_stream_stride, + geometry_shader); +#endif } + static INLINE HRESULT D3D10CreatePixelShader( D3D10Device device, void* shader_bytecode, SIZE_T bytecode_length, D3D10PixelShader* pixel_shader) { - return device->lpVtbl->CreatePixelShader(device, shader_bytecode, bytecode_length, pixel_shader); +#ifdef __cplusplus + return device->CreatePixelShader( + shader_bytecode, bytecode_length, pixel_shader); +#else + return device->lpVtbl->CreatePixelShader(device, + shader_bytecode, bytecode_length, pixel_shader); +#endif } + static INLINE HRESULT D3D10CreateBlendState( - D3D10Device device, D3D10_BLEND_DESC* blend_state_desc, D3D10BlendState* blend_state) + D3D10Device device, + D3D10_BLEND_DESC* blend_state_desc, D3D10BlendState* blend_state) { - return device->lpVtbl->CreateBlendState(device, blend_state_desc, blend_state); +#ifdef __cplusplus + return device->CreateBlendState( + blend_state_desc, blend_state); +#else + return device->lpVtbl->CreateBlendState(device, + blend_state_desc, blend_state); +#endif } + static INLINE HRESULT D3D10CreateDepthStencilState( D3D10Device device, D3D10_DEPTH_STENCIL_DESC* depth_stencil_desc, D3D10DepthStencilState* depth_stencil_state) { - return device->lpVtbl->CreateDepthStencilState(device, depth_stencil_desc, depth_stencil_state); +#ifdef __cplusplus + return device->CreateDepthStencilState( + depth_stencil_desc, depth_stencil_state); +#else + return device->lpVtbl->CreateDepthStencilState(device, + depth_stencil_desc, depth_stencil_state); +#endif } + static INLINE HRESULT D3D10CreateRasterizerState( D3D10Device device, D3D10_RASTERIZER_DESC* rasterizer_desc, D3D10RasterizerState* rasterizer_state) { - return device->lpVtbl->CreateRasterizerState(device, rasterizer_desc, rasterizer_state); +#ifdef __cplusplus + return device->CreateRasterizerState( + rasterizer_desc, rasterizer_state); +#else + return device->lpVtbl->CreateRasterizerState(device, + rasterizer_desc, rasterizer_state); +#endif } + static INLINE HRESULT D3D10CreateSamplerState( - D3D10Device device, D3D10_SAMPLER_DESC* sampler_desc, D3D10SamplerState* sampler_state) + D3D10Device device, + D3D10_SAMPLER_DESC* sampler_desc, + D3D10SamplerState* sampler_state) { - return device->lpVtbl->CreateSamplerState(device, sampler_desc, sampler_state); +#ifdef __cplusplus + return device->CreateSamplerState( + sampler_desc, sampler_state); +#else + return device->lpVtbl->CreateSamplerState(device, + sampler_desc, sampler_state); +#endif } + static INLINE HRESULT -D3D10CreateQuery(D3D10Device device, D3D10_QUERY_DESC* query_desc, D3D10Query* query) +D3D10CreateQuery(D3D10Device device, + D3D10_QUERY_DESC* query_desc, D3D10Query* query) { +#ifdef __cplusplus + return device->CreateQuery(query_desc, query); +#else return device->lpVtbl->CreateQuery(device, query_desc, query); +#endif } + static INLINE HRESULT D3D10CreatePredicate( - D3D10Device device, D3D10_QUERY_DESC* predicate_desc, D3D10Predicate* predicate) + D3D10Device device, + D3D10_QUERY_DESC* predicate_desc, D3D10Predicate* predicate) { - return device->lpVtbl->CreatePredicate(device, predicate_desc, predicate); +#ifdef __cplusplus + return device->CreatePredicate( + predicate_desc, predicate); +#else + return device->lpVtbl->CreatePredicate(device, + predicate_desc, predicate); +#endif } + static INLINE HRESULT -D3D10CreateCounter(D3D10Device device, D3D10_COUNTER_DESC* counter_desc, D3D10Counter* counter) +D3D10CreateCounter(D3D10Device device, + D3D10_COUNTER_DESC* counter_desc, D3D10Counter* counter) { +#ifdef __cplusplus + return device->CreateCounter(counter_desc, counter); +#else return device->lpVtbl->CreateCounter(device, counter_desc, counter); +#endif } + static INLINE HRESULT -D3D10CheckFormatSupport(D3D10Device device, DXGI_FORMAT format, UINT* format_support) +D3D10CheckFormatSupport(D3D10Device device, + DXGI_FORMAT format, UINT* format_support) { +#ifdef __cplusplus + return device->CheckFormatSupport(format, format_support); +#else return device->lpVtbl->CheckFormatSupport(device, format, format_support); +#endif } + static INLINE HRESULT D3D10CheckMultisampleQualityLevels( - D3D10Device device, DXGI_FORMAT format, UINT sample_count, UINT* num_quality_levels) + D3D10Device device, DXGI_FORMAT format, + UINT sample_count, UINT* num_quality_levels) { +#ifdef __cplusplus + return device->CheckMultisampleQualityLevels( + format, sample_count, num_quality_levels); +#else return device->lpVtbl->CheckMultisampleQualityLevels( device, format, sample_count, num_quality_levels); +#endif } -static INLINE void D3D10CheckCounterInfo(D3D10Device device, D3D10_COUNTER_INFO* counter_info) + +static INLINE void D3D10CheckCounterInfo(D3D10Device device, + D3D10_COUNTER_INFO* counter_info) { +#ifdef __cplusplus + device->CheckCounterInfo(counter_info); +#else device->lpVtbl->CheckCounterInfo(device, counter_info); +#endif } + static INLINE HRESULT D3D10CheckCounter( D3D10Device device, D3D10_COUNTER_DESC* desc, @@ -753,188 +1563,448 @@ static INLINE HRESULT D3D10CheckCounter( LPSTR sz_description, UINT* description_length) { - return device->lpVtbl->CheckCounter( - device, desc, type, active_counters, sz_name, name_length, sz_units, units_length, +#ifdef __cplusplus + return device->CheckCounter( + desc, type, active_counters, + sz_name, name_length, sz_units, units_length, sz_description, description_length); +#else + return device->lpVtbl->CheckCounter( + device, desc, type, active_counters, + sz_name, name_length, sz_units, units_length, + sz_description, description_length); +#endif } + static INLINE UINT D3D10GetCreationFlags(D3D10Device device) { +#ifdef __cplusplus + return device->GetCreationFlags(); +#else return device->lpVtbl->GetCreationFlags(device); +#endif } + static INLINE HRESULT -D3D10OpenSharedResource(D3D10Device device, HANDLE h_resource, ID3D10Resource** out) +D3D10OpenSharedResource(D3D10Device device, + HANDLE h_resource, ID3D10Resource** out) { +#ifdef __cplusplus + return device->OpenSharedResource( + h_resource, uuidof(ID3D10Resource), (void**)out); +#else return device->lpVtbl->OpenSharedResource( device, h_resource, uuidof(ID3D10Resource), (void**)out); +#endif } -static INLINE void D3D10SetTextFilterSize(D3D10Device device, UINT width, UINT height) + +static INLINE void D3D10SetTextFilterSize(D3D10Device device, + UINT width, UINT height) { +#ifdef __cplusplus + device->SetTextFilterSize(width, height); +#else device->lpVtbl->SetTextFilterSize(device, width, height); +#endif } -static INLINE void D3D10GetTextFilterSize(D3D10Device device, UINT* width, UINT* height) + +static INLINE void D3D10GetTextFilterSize(D3D10Device device, + UINT* width, UINT* height) { +#ifdef __cplusplus + device->GetTextFilterSize(width, height); +#else device->lpVtbl->GetTextFilterSize(device, width, height); +#endif } + static INLINE void D3D10Enter(D3D10Multithread multithread) { +#ifdef __cplusplus + multithread->Enter(); +#else multithread->lpVtbl->Enter(multithread); +#endif } + static INLINE void D3D10Leave(D3D10Multithread multithread) { +#ifdef __cplusplus + multithread->Leave(); +#else multithread->lpVtbl->Leave(multithread); +#endif } -static INLINE BOOL D3D10SetMultithreadProtected(D3D10Multithread multithread, BOOL mtprotect) + +static INLINE BOOL D3D10SetMultithreadProtected( + D3D10Multithread multithread, BOOL mtprotect) { - return multithread->lpVtbl->SetMultithreadProtected(multithread, mtprotect); +#ifdef __cplusplus + return multithread->SetMultithreadProtected( + mtprotect); +#else + return multithread->lpVtbl->SetMultithreadProtected( + multithread, mtprotect); +#endif } -static INLINE BOOL D3D10GetMultithreadProtected(D3D10Multithread multithread) + +static INLINE BOOL D3D10GetMultithreadProtected( + D3D10Multithread multithread) { +#ifdef __cplusplus + return multithread->GetMultithreadProtected(); +#else return multithread->lpVtbl->GetMultithreadProtected(multithread); +#endif } -static INLINE HRESULT D3D10SetDebugFeatureMask(D3D10Debug debug, UINT mask) + +static INLINE HRESULT D3D10SetDebugFeatureMask( + D3D10Debug debug, UINT mask) { +#ifdef __cplusplus + return debug->SetFeatureMask(mask); +#else return debug->lpVtbl->SetFeatureMask(debug, mask); +#endif } + static INLINE UINT D3D10GetDebugFeatureMask(D3D10Debug debug) { +#ifdef __cplusplus + return debug->GetFeatureMask(); +#else return debug->lpVtbl->GetFeatureMask(debug); +#endif } -static INLINE HRESULT D3D10SetPresentPerRenderOpDelay(D3D10Debug debug, UINT milliseconds) + +static INLINE HRESULT D3D10SetPresentPerRenderOpDelay( + D3D10Debug debug, UINT milliseconds) { +#ifdef __cplusplus + return debug->SetPresentPerRenderOpDelay(milliseconds); +#else return debug->lpVtbl->SetPresentPerRenderOpDelay(debug, milliseconds); +#endif } + static INLINE UINT D3D10GetPresentPerRenderOpDelay(D3D10Debug debug) { +#ifdef __cplusplus + return debug->GetPresentPerRenderOpDelay(); +#else return debug->lpVtbl->GetPresentPerRenderOpDelay(debug); +#endif } -static INLINE HRESULT D3D10SetSwapChain(D3D10Debug debug, IDXGISwapChain* swap_chain) + +static INLINE HRESULT D3D10SetSwapChain(D3D10Debug debug, + IDXGISwapChain* swap_chain) { +#ifdef __cplusplus + return debug->SetSwapChain((IDXGISwapChain*)swap_chain); +#else return debug->lpVtbl->SetSwapChain(debug, (IDXGISwapChain*)swap_chain); +#endif } -static INLINE HRESULT D3D10GetSwapChain(D3D10Debug debug, IDXGISwapChain** swap_chain) + +static INLINE HRESULT D3D10GetSwapChain(D3D10Debug debug, + IDXGISwapChain** swap_chain) { +#ifdef __cplusplus + return debug->GetSwapChain((IDXGISwapChain**)swap_chain); +#else return debug->lpVtbl->GetSwapChain(debug, (IDXGISwapChain**)swap_chain); +#endif } -static INLINE HRESULT D3D10Validate(D3D10Debug debug) { return debug->lpVtbl->Validate(debug); } -static INLINE BOOL D3D10SetUseRef(D3D10SwitchToRef switch_to_ref, BOOL use_ref) + +static INLINE HRESULT D3D10Validate(D3D10Debug debug) { - return switch_to_ref->lpVtbl->SetUseRef(switch_to_ref, use_ref); +#ifdef __cplusplus + return debug->Validate(); +#else + return debug->lpVtbl->Validate(debug); +#endif } + +static INLINE BOOL D3D10SetUseRef(D3D10SwitchToRef switch_to_ref, + BOOL use_ref) +{ +#ifdef __cplusplus + return switch_to_ref->SetUseRef(use_ref); +#else + return switch_to_ref->lpVtbl->SetUseRef(switch_to_ref, use_ref); +#endif +} + static INLINE BOOL D3D10GetUseRef(D3D10SwitchToRef switch_to_ref) { +#ifdef __cplusplus + return switch_to_ref->GetUseRef(); +#else return switch_to_ref->lpVtbl->GetUseRef(switch_to_ref); +#endif } + static INLINE HRESULT -D3D10SetMessageCountLimit(D3D10InfoQueue info_queue, UINT64 message_count_limit) +D3D10SetMessageCountLimit(D3D10InfoQueue info_queue, + UINT64 message_count_limit) { - return info_queue->lpVtbl->SetMessageCountLimit(info_queue, message_count_limit); +#ifdef __cplusplus + return info_queue->SetMessageCountLimit( + message_count_limit); +#else + return info_queue->lpVtbl->SetMessageCountLimit(info_queue, + message_count_limit); +#endif } + static INLINE void D3D10ClearStoredMessages(D3D10InfoQueue info_queue) { +#ifdef __cplusplus + info_queue->ClearStoredMessages(); +#else info_queue->lpVtbl->ClearStoredMessages(info_queue); +#endif } + static INLINE HRESULT D3D10GetMessageA( D3D10InfoQueue info_queue, UINT64 message_index, D3D10_MESSAGE* message, SIZE_T* message_byte_length) { - return info_queue->lpVtbl->GetMessageA(info_queue, message_index, message, message_byte_length); +#ifdef __cplusplus + return info_queue->GetMessageA( + message_index, message, message_byte_length); +#else + return info_queue->lpVtbl->GetMessageA(info_queue, + message_index, message, message_byte_length); +#endif } -static INLINE UINT64 D3D10GetNumMessagesAllowedByStorageFilter(D3D10InfoQueue info_queue) + +static INLINE UINT64 D3D10GetNumMessagesAllowedByStorageFilter( + D3D10InfoQueue info_queue) { - return info_queue->lpVtbl->GetNumMessagesAllowedByStorageFilter(info_queue); +#ifdef __cplusplus + return info_queue->GetNumMessagesAllowedByStorageFilter(); +#else + return info_queue->lpVtbl->GetNumMessagesAllowedByStorageFilter( + info_queue); +#endif } -static INLINE UINT64 D3D10GetNumMessagesDeniedByStorageFilter(D3D10InfoQueue info_queue) + +static INLINE UINT64 D3D10GetNumMessagesDeniedByStorageFilter( + D3D10InfoQueue info_queue) { - return info_queue->lpVtbl->GetNumMessagesDeniedByStorageFilter(info_queue); +#ifdef __cplusplus + return info_queue->GetNumMessagesDeniedByStorageFilter(); +#else + return info_queue->lpVtbl->GetNumMessagesDeniedByStorageFilter( + info_queue); +#endif } + static INLINE UINT64 D3D10GetNumStoredMessages(D3D10InfoQueue info_queue) { +#ifdef __cplusplus + return info_queue->GetNumStoredMessages(); +#else return info_queue->lpVtbl->GetNumStoredMessages(info_queue); +#endif } -static INLINE UINT64 D3D10GetNumStoredMessagesAllowedByRetrievalFilter(D3D10InfoQueue info_queue) + +static INLINE UINT64 D3D10GetNumStoredMessagesAllowedByRetrievalFilter( + D3D10InfoQueue info_queue) { - return info_queue->lpVtbl->GetNumStoredMessagesAllowedByRetrievalFilter(info_queue); +#ifdef __cplusplus + return info_queue->GetNumStoredMessagesAllowedByRetrievalFilter(); +#else + return info_queue->lpVtbl->GetNumStoredMessagesAllowedByRetrievalFilter( + info_queue); +#endif } -static INLINE UINT64 D3D10GetNumMessagesDiscardedByMessageCountLimit(D3D10InfoQueue info_queue) + +static INLINE UINT64 D3D10GetNumMessagesDiscardedByMessageCountLimit( + D3D10InfoQueue info_queue) { - return info_queue->lpVtbl->GetNumMessagesDiscardedByMessageCountLimit(info_queue); +#ifdef __cplusplus + return info_queue->GetNumMessagesDiscardedByMessageCountLimit(); +#else + return info_queue->lpVtbl->GetNumMessagesDiscardedByMessageCountLimit( + info_queue); +#endif } + static INLINE UINT64 D3D10GetMessageCountLimit(D3D10InfoQueue info_queue) { +#ifdef __cplusplus + return info_queue->GetMessageCountLimit(); +#else return info_queue->lpVtbl->GetMessageCountLimit(info_queue); +#endif } + static INLINE HRESULT -D3D10AddStorageFilterEntries(D3D10InfoQueue info_queue, D3D10_INFO_QUEUE_FILTER* filter) +D3D10AddStorageFilterEntries(D3D10InfoQueue info_queue, + D3D10_INFO_QUEUE_FILTER* filter) { +#ifdef __cplusplus + return info_queue->AddStorageFilterEntries(filter); +#else return info_queue->lpVtbl->AddStorageFilterEntries(info_queue, filter); +#endif } + static INLINE HRESULT D3D10GetStorageFilter( - D3D10InfoQueue info_queue, D3D10_INFO_QUEUE_FILTER* filter, SIZE_T* filter_byte_length) + D3D10InfoQueue info_queue, + D3D10_INFO_QUEUE_FILTER* filter, SIZE_T* filter_byte_length) { - return info_queue->lpVtbl->GetStorageFilter(info_queue, filter, filter_byte_length); +#ifdef __cplusplus + return info_queue->GetStorageFilter( + filter, filter_byte_length); +#else + return info_queue->lpVtbl->GetStorageFilter( + info_queue, filter, filter_byte_length); +#endif } + static INLINE void D3D10ClearStorageFilter(D3D10InfoQueue info_queue) { +#ifdef __cplusplus + info_queue->ClearStorageFilter(); +#else info_queue->lpVtbl->ClearStorageFilter(info_queue); +#endif } + static INLINE HRESULT D3D10PushEmptyStorageFilter(D3D10InfoQueue info_queue) { +#ifdef __cplusplus + return info_queue->PushEmptyStorageFilter(); +#else return info_queue->lpVtbl->PushEmptyStorageFilter(info_queue); +#endif } + static INLINE HRESULT D3D10PushCopyOfStorageFilter(D3D10InfoQueue info_queue) { +#ifdef __cplusplus + return info_queue->PushCopyOfStorageFilter(); +#else return info_queue->lpVtbl->PushCopyOfStorageFilter(info_queue); +#endif } + static INLINE HRESULT -D3D10PushStorageFilter(D3D10InfoQueue info_queue, D3D10_INFO_QUEUE_FILTER* filter) +D3D10PushStorageFilter(D3D10InfoQueue info_queue, + D3D10_INFO_QUEUE_FILTER* filter) { +#ifdef __cplusplus + return info_queue->PushStorageFilter(filter); +#else return info_queue->lpVtbl->PushStorageFilter(info_queue, filter); +#endif } + static INLINE void D3D10PopStorageFilter(D3D10InfoQueue info_queue) { +#ifdef __cplusplus + info_queue->PopStorageFilter(); +#else info_queue->lpVtbl->PopStorageFilter(info_queue); +#endif } + static INLINE UINT D3D10GetStorageFilterStackSize(D3D10InfoQueue info_queue) { +#ifdef __cplusplus + return info_queue->GetStorageFilterStackSize(); +#else return info_queue->lpVtbl->GetStorageFilterStackSize(info_queue); +#endif } + static INLINE HRESULT -D3D10AddRetrievalFilterEntries(D3D10InfoQueue info_queue, D3D10_INFO_QUEUE_FILTER* filter) +D3D10AddRetrievalFilterEntries(D3D10InfoQueue info_queue, + D3D10_INFO_QUEUE_FILTER* filter) { +#ifdef __cplusplus + return info_queue->AddRetrievalFilterEntries(filter); +#else return info_queue->lpVtbl->AddRetrievalFilterEntries(info_queue, filter); +#endif } + static INLINE HRESULT D3D10GetRetrievalFilter( - D3D10InfoQueue info_queue, D3D10_INFO_QUEUE_FILTER* filter, SIZE_T* filter_byte_length) + D3D10InfoQueue info_queue, + D3D10_INFO_QUEUE_FILTER* filter, SIZE_T* filter_byte_length) { - return info_queue->lpVtbl->GetRetrievalFilter(info_queue, filter, filter_byte_length); +#ifdef __cplusplus + return info_queue->GetRetrievalFilter( + filter, filter_byte_length); +#else + return info_queue->lpVtbl->GetRetrievalFilter(info_queue, + filter, filter_byte_length); +#endif } + static INLINE void D3D10ClearRetrievalFilter(D3D10InfoQueue info_queue) { +#ifdef __cplusplus + info_queue->ClearRetrievalFilter(); +#else info_queue->lpVtbl->ClearRetrievalFilter(info_queue); +#endif } -static INLINE HRESULT D3D10PushEmptyRetrievalFilter(D3D10InfoQueue info_queue) + +static INLINE HRESULT D3D10PushEmptyRetrievalFilter( + D3D10InfoQueue info_queue) { +#ifdef __cplusplus + return info_queue->PushEmptyRetrievalFilter(); +#else return info_queue->lpVtbl->PushEmptyRetrievalFilter(info_queue); +#endif } -static INLINE HRESULT D3D10PushCopyOfRetrievalFilter(D3D10InfoQueue info_queue) + +static INLINE HRESULT D3D10PushCopyOfRetrievalFilter( + D3D10InfoQueue info_queue) { +#ifdef __cplusplus + return info_queue->PushCopyOfRetrievalFilter(); +#else return info_queue->lpVtbl->PushCopyOfRetrievalFilter(info_queue); +#endif } + static INLINE HRESULT -D3D10PushRetrievalFilter(D3D10InfoQueue info_queue, D3D10_INFO_QUEUE_FILTER* filter) +D3D10PushRetrievalFilter(D3D10InfoQueue info_queue, + D3D10_INFO_QUEUE_FILTER* filter) { +#ifdef __cplusplus + return info_queue->PushRetrievalFilter(filter); +#else return info_queue->lpVtbl->PushRetrievalFilter(info_queue, filter); +#endif } + static INLINE void D3D10PopRetrievalFilter(D3D10InfoQueue info_queue) { +#ifdef __cplusplus + info_queue->PopRetrievalFilter(); +#else info_queue->lpVtbl->PopRetrievalFilter(info_queue); +#endif } + static INLINE UINT D3D10GetRetrievalFilterStackSize(D3D10InfoQueue info_queue) { +#ifdef __cplusplus + return info_queue->GetRetrievalFilterStackSize(); +#else return info_queue->lpVtbl->GetRetrievalFilterStackSize(info_queue); +#endif } + static INLINE HRESULT D3D10AddMessage( D3D10InfoQueue info_queue, D3D10_MESSAGE_CATEGORY category, @@ -942,57 +2012,129 @@ static INLINE HRESULT D3D10AddMessage( D3D10_MESSAGE_ID id, LPCSTR description) { - return info_queue->lpVtbl->AddMessage(info_queue, category, severity, id, description); +#ifdef __cplusplus + return info_queue->AddMessage( + category, severity, id, description); +#else + return info_queue->lpVtbl->AddMessage(info_queue, + category, severity, id, description); +#endif } + static INLINE HRESULT D3D10AddApplicationMessage( - D3D10InfoQueue info_queue, D3D10_MESSAGE_SEVERITY severity, LPCSTR description) + D3D10InfoQueue info_queue, + D3D10_MESSAGE_SEVERITY severity, LPCSTR description) { - return info_queue->lpVtbl->AddApplicationMessage(info_queue, severity, description); +#ifdef __cplusplus + return info_queue->AddApplicationMessage( + severity, description); +#else + return info_queue->lpVtbl->AddApplicationMessage( + info_queue, severity, description); +#endif } + static INLINE HRESULT -D3D10SetBreakOnCategory(D3D10InfoQueue info_queue, D3D10_MESSAGE_CATEGORY category, BOOL enable) +D3D10SetBreakOnCategory(D3D10InfoQueue info_queue, + D3D10_MESSAGE_CATEGORY category, BOOL enable) { - return info_queue->lpVtbl->SetBreakOnCategory(info_queue, category, enable); +#ifdef __cplusplus + return info_queue->SetBreakOnCategory( + category, enable); +#else + return info_queue->lpVtbl->SetBreakOnCategory( + info_queue, category, enable); +#endif } + static INLINE HRESULT -D3D10SetBreakOnSeverity(D3D10InfoQueue info_queue, D3D10_MESSAGE_SEVERITY severity, BOOL enable) +D3D10SetBreakOnSeverity(D3D10InfoQueue info_queue, + D3D10_MESSAGE_SEVERITY severity, BOOL enable) { - return info_queue->lpVtbl->SetBreakOnSeverity(info_queue, severity, enable); +#ifdef __cplusplus + return info_queue->SetBreakOnSeverity(severity, enable); +#else + return info_queue->lpVtbl->SetBreakOnSeverity(info_queue, + severity, enable); +#endif } -static INLINE HRESULT D3D10SetBreakOnID(D3D10InfoQueue info_queue, D3D10_MESSAGE_ID id, BOOL enable) + +static INLINE HRESULT D3D10SetBreakOnID(D3D10InfoQueue info_queue, + D3D10_MESSAGE_ID id, BOOL enable) { +#ifdef __cplusplus + return info_queue->SetBreakOnID(id, enable); +#else return info_queue->lpVtbl->SetBreakOnID(info_queue, id, enable); +#endif } + static INLINE BOOL -D3D10GetBreakOnCategory(D3D10InfoQueue info_queue, D3D10_MESSAGE_CATEGORY category) +D3D10GetBreakOnCategory(D3D10InfoQueue info_queue, + D3D10_MESSAGE_CATEGORY category) { +#ifdef __cplusplus + return info_queue->GetBreakOnCategory(category); +#else return info_queue->lpVtbl->GetBreakOnCategory(info_queue, category); +#endif } + static INLINE BOOL -D3D10GetBreakOnSeverity(D3D10InfoQueue info_queue, D3D10_MESSAGE_SEVERITY severity) +D3D10GetBreakOnSeverity(D3D10InfoQueue info_queue, + D3D10_MESSAGE_SEVERITY severity) { +#ifdef __cplusplus + return info_queue->GetBreakOnSeverity(severity); +#else return info_queue->lpVtbl->GetBreakOnSeverity(info_queue, severity); +#endif } -static INLINE BOOL D3D10GetBreakOnID(D3D10InfoQueue info_queue, D3D10_MESSAGE_ID id) + +static INLINE BOOL D3D10GetBreakOnID(D3D10InfoQueue info_queue, + D3D10_MESSAGE_ID id) { +#ifdef __cplusplus + return info_queue->GetBreakOnID(id); +#else return info_queue->lpVtbl->GetBreakOnID(info_queue, id); +#endif } -static INLINE void D3D10SetMuteDebugOutput(D3D10InfoQueue info_queue, BOOL mute) + +static INLINE void D3D10SetMuteDebugOutput( + D3D10InfoQueue info_queue, BOOL mute) { +#ifdef __cplusplus + info_queue->SetMuteDebugOutput(mute); +#else info_queue->lpVtbl->SetMuteDebugOutput(info_queue, mute); +#endif } + static INLINE BOOL D3D10GetMuteDebugOutput(D3D10InfoQueue info_queue) { +#ifdef __cplusplus + return info_queue->GetMuteDebugOutput(); +#else return info_queue->lpVtbl->GetMuteDebugOutput(info_queue); +#endif } /* end of auto-generated */ static INLINE HRESULT -DXGIGetSwapChainBufferD3D10(DXGISwapChain swap_chain, UINT buffer, D3D10Texture2D* out) +DXGIGetSwapChainBufferD3D10(DXGISwapChain swap_chain, UINT buffer, + D3D10Texture2D* out) { - return swap_chain->lpVtbl->GetBuffer(swap_chain, buffer, uuidof(ID3D10Texture2D), (void**)out); +#ifdef __cplusplus + return swap_chain->GetBuffer(buffer, + uuidof(ID3D10Texture2D), (void**)out); +#else + return swap_chain->lpVtbl->GetBuffer(swap_chain, buffer, + uuidof(ID3D10Texture2D), (void**)out); +#endif } + static INLINE void D3D10CopyTexture2DSubresourceRegion( D3D10Device device, D3D10Texture2D dst_texture, @@ -1004,9 +2146,17 @@ static INLINE void D3D10CopyTexture2DSubresourceRegion( UINT src_subresource, D3D10_BOX* src_box) { - device->lpVtbl->CopySubresourceRegion( - device, (D3D10Resource)dst_texture, dst_subresource, dst_x, dst_y, dst_z, +#ifdef __cplusplus + device->CopySubresourceRegion( + (D3D10Resource)dst_texture, + dst_subresource, dst_x, dst_y, dst_z, (D3D10Resource)src_texture, src_subresource, src_box); +#else + device->lpVtbl->CopySubresourceRegion( + device, (D3D10Resource)dst_texture, + dst_subresource, dst_x, dst_y, dst_z, + (D3D10Resource)src_texture, src_subresource, src_box); +#endif } static INLINE HRESULT D3D10CreateTexture2DRenderTargetView( D3D10Device device, @@ -1014,7 +2164,13 @@ static INLINE HRESULT D3D10CreateTexture2DRenderTargetView( D3D10_RENDER_TARGET_VIEW_DESC* desc, D3D10RenderTargetView* rtview) { - return device->lpVtbl->CreateRenderTargetView(device, (D3D10Resource)texture, desc, rtview); +#ifdef __cplusplus + return device->CreateRenderTargetView( + (D3D10Resource)texture, desc, rtview); +#else + return device->lpVtbl->CreateRenderTargetView(device, + (D3D10Resource)texture, desc, rtview); +#endif } static INLINE HRESULT D3D10CreateTexture2DShaderResourceView( D3D10Device device, @@ -1022,7 +2178,13 @@ static INLINE HRESULT D3D10CreateTexture2DShaderResourceView( D3D10_SHADER_RESOURCE_VIEW_DESC* desc, D3D10ShaderResourceView* srview) { - return device->lpVtbl->CreateShaderResourceView(device, (D3D10Resource)texture, desc, srview); +#ifdef __cplusplus + return device->CreateShaderResourceView((D3D10Resource)texture, + desc, srview); +#else + return device->lpVtbl->CreateShaderResourceView(device, + (D3D10Resource)texture, desc, srview); +#endif } /* internal */ diff --git a/gfx/drivers/d3d10.c b/gfx/drivers/d3d10.c index 540f3cda5f..e0c2bb78d7 100644 --- a/gfx/drivers/d3d10.c +++ b/gfx/drivers/d3d10.c @@ -108,27 +108,27 @@ d3d10_gfx_init(const video_info_t* video, const input_driver_t** input, void** i { UINT flags = 0; - DXGI_SWAP_CHAIN_DESC desc = { - .BufferCount = 2, - .BufferDesc.Width = video->width, - .BufferDesc.Height = video->height, - .BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_SWAP_CHAIN_DESC desc = {0}; + + desc.BufferCount = 2; + desc.BufferDesc.Width = video->width; + desc.BufferDesc.Height = video->height; + desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; #if 0 - .BufferDesc.RefreshRate.Numerator = 60, - .BufferDesc.RefreshRate.Denominator = 1, + desc.BufferDesc.RefreshRate.Numerator = 60; + desc.BufferDesc.RefreshRate.Denominator = 1; #endif - .BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT, - .OutputWindow = main_window.hwnd, - .SampleDesc.Count = 1, - .SampleDesc.Quality = 0, - .Windowed = TRUE, - .SwapEffect = DXGI_SWAP_EFFECT_DISCARD, + desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; + desc.OutputWindow = main_window.hwnd; + desc.SampleDesc.Count = 1; + desc.SampleDesc.Quality = 0; + desc.Windowed = TRUE; + desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; #if 0 - .SwapEffect = DXGI_SWAP_EFFECT_SEQUENTIAL, - .SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL, - .SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD, + desc.SwapEffect = DXGI_SWAP_EFFECT_SEQUENTIAL; + desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; + desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD; #endif - }; #ifdef DEBUG flags |= D3D10_CREATE_DEVICE_DEBUG; @@ -177,16 +177,17 @@ d3d10_gfx_init(const video_info_t* video, const input_driver_t** input, void** i d3d10_gfx_set_rotation(d3d10, 0); { - D3D10_SAMPLER_DESC desc = { - .Filter = D3D10_FILTER_MIN_MAG_MIP_POINT, - .AddressU = D3D10_TEXTURE_ADDRESS_BORDER, - .AddressV = D3D10_TEXTURE_ADDRESS_BORDER, - .AddressW = D3D10_TEXTURE_ADDRESS_BORDER, - .MaxAnisotropy = 1, - .ComparisonFunc = D3D10_COMPARISON_NEVER, - .MinLOD = -D3D10_FLOAT32_MAX, - .MaxLOD = D3D10_FLOAT32_MAX, - }; + D3D10_SAMPLER_DESC desc = {}; + + desc.Filter = D3D10_FILTER_MIN_MAG_MIP_POINT; + desc.AddressU = D3D10_TEXTURE_ADDRESS_BORDER; + desc.AddressV = D3D10_TEXTURE_ADDRESS_BORDER; + desc.AddressW = D3D10_TEXTURE_ADDRESS_BORDER; + desc.MaxAnisotropy = 1; + desc.ComparisonFunc = D3D10_COMPARISON_NEVER; + desc.MinLOD = -D3D10_FLOAT32_MAX; + desc.MaxLOD = D3D10_FLOAT32_MAX; + D3D10CreateSamplerState(d3d10->device, &desc, &d3d10->sampler_nearest); desc.Filter = D3D10_FILTER_MIN_MAG_MIP_LINEAR; @@ -473,7 +474,7 @@ static void d3d10_set_menu_texture_frame( { d3d10_video_t* d3d10 = (d3d10_video_t*)data; int pitch = width * (rgb32 ? sizeof(uint32_t) : sizeof(uint16_t)); - DXGI_FORMAT format = rgb32 ? DXGI_FORMAT_B8G8R8A8_UNORM : DXGI_FORMAT_EX_A4R4G4B4_UNORM; + DXGI_FORMAT format = rgb32 ? DXGI_FORMAT_B8G8R8A8_UNORM : (DXGI_FORMAT)DXGI_FORMAT_EX_A4R4G4B4_UNORM; if (d3d10->menu.texture.desc.Width != width || d3d10->menu.texture.desc.Height != height) { From 453681b59d576688b38c1aedd2a860d9f581a583 Mon Sep 17 00:00:00 2001 From: radius Date: Sun, 4 Feb 2018 11:48:21 -0500 Subject: [PATCH 061/232] fix saves for subsystem --- paths.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/paths.c b/paths.c index cad1e47187..ab20de391c 100644 --- a/paths.c +++ b/paths.c @@ -143,7 +143,7 @@ void path_set_redirect(void) } } - /* Set savefile directory if empty based on content directory */ + /* Set savefile directory if empty to content directory */ if (string_is_empty(new_savefile_dir) || settings->bools.savefiles_in_content_dir) { strlcpy(new_savefile_dir, path_main_basename, @@ -319,6 +319,7 @@ static bool path_init_subsystem(void) { union string_list_elem_attr attr; char ext[32]; + char savename[PATH_MAX_LENGTH]; size_t path_size = PATH_MAX_LENGTH * sizeof(char); char *path = (char*)malloc( PATH_MAX_LENGTH * sizeof(char)); @@ -329,19 +330,21 @@ static bool path_init_subsystem(void) path[0] = ext[0] = '\0'; snprintf(ext, sizeof(ext), ".%s", mem->extension); + strlcpy(savename, subsystem_fullpaths->elems[i].data, sizeof(savename)); + path_remove_extension(savename); - if (path_is_directory(dir_get(RARCH_DIR_SAVEFILE))) + if (path_is_directory(dir_get(RARCH_DIR_CURRENT_SAVEFILE))) { /* Use SRAM dir */ /* Redirect content fullpath to save directory. */ - strlcpy(path, dir_get(RARCH_DIR_SAVEFILE), path_size); + strlcpy(path, dir_get(RARCH_DIR_CURRENT_SAVEFILE), path_size); fill_pathname_dir(path, - subsystem_fullpaths->elems[i].data, ext, + savename, ext, path_size); } else { - fill_pathname(path, subsystem_fullpaths->elems[i].data, + fill_pathname(path, savename, ext, path_size); } From a180b1094ec06a8e10599ff1fce19d2cbb342803 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 4 Feb 2018 18:55:22 +0100 Subject: [PATCH 062/232] Add stdint.h to spirv_msl.hpp --- deps/SPIRV-Cross/spirv_msl.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/deps/SPIRV-Cross/spirv_msl.hpp b/deps/SPIRV-Cross/spirv_msl.hpp index d91bca9e57..c9a1820485 100644 --- a/deps/SPIRV-Cross/spirv_msl.hpp +++ b/deps/SPIRV-Cross/spirv_msl.hpp @@ -18,6 +18,7 @@ #define SPIRV_CROSS_MSL_HPP #include "spirv_glsl.hpp" +#include #include #include #include From 0b3545837e3c55b5940a85c40a540f4e57bb2659 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 4 Feb 2018 19:05:43 +0100 Subject: [PATCH 063/232] Cleanup some allocations --- menu/cbs/menu_cbs_ok.c | 28 +++++++++++----------------- menu/menu_displaylist.c | 21 ++++++++++----------- 2 files changed, 21 insertions(+), 28 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 45141fc0af..247ebba9bb 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -3461,17 +3461,10 @@ static int action_ok_load_archive_detect_core(const char *path, menu_handle_t *menu = NULL; const char *menu_path = NULL; const char *content_path = NULL; - size_t path_size = PATH_MAX_LENGTH * sizeof(char); - char *new_core_path = (char*) - malloc(PATH_MAX_LENGTH * sizeof(char)); - - new_core_path[0] = '\0'; + char *new_core_path = NULL; if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) - { - free(new_core_path); return menu_cbs_exit(); - } menu_path = menu->scratch2_buf; content_path = menu->scratch_buf; @@ -3485,8 +3478,12 @@ static int action_ok_load_archive_detect_core(const char *path, def_info.s = menu->deferred_path; def_info.len = sizeof(menu->deferred_path); + new_core_path = (char*) + malloc(PATH_MAX_LENGTH * sizeof(char)); + new_core_path[0] = '\0'; + if (menu_content_find_first_core(&def_info, false, - new_core_path, path_size)) + new_core_path, PATH_MAX_LENGTH * sizeof(char))) ret = -1; fill_pathname_join(detect_content_path, menu_path, content_path, @@ -3503,17 +3500,15 @@ static int action_ok_load_archive_detect_core(const char *path, content_info.args = NULL; content_info.environ_get = NULL; + ret = 0; + if (!task_push_load_content_with_new_core_from_menu( new_core_path, def_info.s, &content_info, CORE_TYPE_PLAIN, NULL, NULL)) - { - free(new_core_path); - return -1; - } + ret = -1; } - ret = 0; break; case 0: idx = menu_navigation_get_selection(); @@ -3577,9 +3572,8 @@ static int action_ok_netplay_enable_host(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { #ifdef HAVE_NETWORKING - bool contentless = false; - bool is_inited = false; - + bool contentless = false; + bool is_inited = false; file_list_t *list = menu_entries_get_selection_buf_ptr(0); content_get_status(&contentless, &is_inited); diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 1f7570b274..c32e72de3f 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -1453,20 +1453,17 @@ static int create_string_list_rdb_entry_string( file_list_t *list) { union string_list_elem_attr attr; - size_t path_size = PATH_MAX_LENGTH * sizeof(char); - char *tmp = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + char *tmp = NULL; char *output_label = NULL; int str_len = 0; struct string_list *str_list = string_list_new(); if (!str_list) - { - free(tmp); return -1; - } - attr.i = 0; - tmp[0] = '\0'; + attr.i = 0; + tmp = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + tmp[0] = '\0'; str_len += strlen(label) + 1; string_list_append(str_list, label, attr); @@ -1490,7 +1487,7 @@ static int create_string_list_rdb_entry_string( fill_pathname_join_concat_noext(tmp, desc, ": ", actual_string, - path_size); + PATH_MAX_LENGTH * sizeof(char)); menu_entries_append_enum(list, tmp, output_label, enum_idx, 0, 0, 0); @@ -1511,8 +1508,8 @@ static int create_string_list_rdb_entry_int( { union string_list_elem_attr attr; size_t path_size = PATH_MAX_LENGTH * sizeof(char); - char *tmp = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); - char *str = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + char *tmp = NULL; + char *str = NULL; char *output_label = NULL; int str_len = 0; struct string_list *str_list = string_list_new(); @@ -1520,7 +1517,9 @@ static int create_string_list_rdb_entry_int( if (!str_list) goto error; - attr.i = 0; + attr.i = 0; + tmp = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + str = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); tmp[0] = str[0] = '\0'; str_len += strlen(label) + 1; From 3d0e768e71522d33723ff9ab722407edb372be63 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 4 Feb 2018 19:30:34 +0100 Subject: [PATCH 064/232] Silence some Coverity errors --- cheevos/cheevos.c | 10 +++++----- libretro-common/formats/png/rpng_encode.c | 3 ++- libretro-common/vfs/vfs_implementation.c | 8 +++----- menu/drivers/xmb.c | 2 +- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/cheevos/cheevos.c b/cheevos/cheevos.c index 9975342ddd..a9de8db794 100644 --- a/cheevos/cheevos.c +++ b/cheevos/cheevos.c @@ -1028,11 +1028,11 @@ static int cheevos_parse_expression(cheevos_expr_t *expr, const char* mem) cheevos_term_t *terms = NULL; char *end = NULL; - if (expr) - { - expr->count = 1; - expr->compare_count = 1; - } + if (!expr) + return -1; + + expr->count = 1; + expr->compare_count = 1; for (aux = mem;; aux++) { diff --git a/libretro-common/formats/png/rpng_encode.c b/libretro-common/formats/png/rpng_encode.c index cd483e39dd..92e25e16f4 100644 --- a/libretro-common/formats/png/rpng_encode.c +++ b/libretro-common/formats/png/rpng_encode.c @@ -354,7 +354,8 @@ static bool rpng_save_image(const char *path, GOTO_END_ERROR(); end: - filestream_close(file); + if (file) + filestream_close(file); free(encode_buf); free(deflate_buf); free(rgba_line); diff --git a/libretro-common/vfs/vfs_implementation.c b/libretro-common/vfs/vfs_implementation.c index ba962840ed..14eb11afd0 100644 --- a/libretro-common/vfs/vfs_implementation.c +++ b/libretro-common/vfs/vfs_implementation.c @@ -251,12 +251,9 @@ libretro_vfs_implementation_file *retro_vfs_file_open_impl(const char *path, uns if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0) { - if (!mode_str) - goto error; + FILE *fp = fopen_utf8(path, mode_str); - stream->fp = fopen_utf8(path, mode_str); - - if (!stream->fp) + if (!fp) goto error; /* Regarding setvbuf: @@ -269,6 +266,7 @@ libretro_vfs_implementation_file *retro_vfs_file_open_impl(const char *path, uns * Since C89 does not support specifying a null buffer with a non-zero size, we create and track our own buffer for it. */ /* TODO: this is only useful for a few platforms, find which and add ifdef */ + stream->fp = fp; stream->buf = (char*)calloc(1, 0x4000); setvbuf(stream->fp, stream->buf, _IOFBF, 0x4000); } diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index b3b2154028..7cb6b230a7 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -1065,7 +1065,7 @@ static void xmb_update_thumbnail_path(void *data, unsigned i) sizeof(new_path)); end: - if (!string_is_empty(new_path)) + if (xmb && !string_is_empty(new_path)) xmb->thumbnail_file_path = strdup(new_path); menu_entry_free(&entry); } From df1c131520b36c06eef4c291fd7c0fd59005c52f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 4 Feb 2018 19:45:47 +0100 Subject: [PATCH 065/232] Prevent more Coverity warnings --- menu/drivers/materialui.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index caf029d3d3..125c343daf 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -585,12 +585,15 @@ static void mui_render_messagebox(mui_handle_t *mui, int x, y, line_height, longest = 0, longest_width = 0; unsigned width = video_info->width; unsigned height = video_info->height; - struct string_list *list = (struct string_list*) + struct string_list *list = NULL; + + if (!mui || !mui->font) + goto end; + + list = (struct string_list*) string_split(message, "\n"); - if (!list) - return; - if (list->elems == 0) + if (!list || list->elems == 0) goto end; line_height = mui->font->size * 1.2; @@ -610,16 +613,18 @@ static void mui_render_messagebox(mui_handle_t *mui, if (len > longest) { longest = len; - longest_width = font_driver_get_message_width(mui->font, msg, strlen(msg), 1); + longest_width = font_driver_get_message_width( + mui->font, msg, strlen(msg), 1); } } menu_display_set_alpha(body_bg_color, 1.0); - menu_display_draw_quad( x - longest_width/2.0 - mui->margin*2.0, - y - line_height/2.0 - mui->margin*2.0, - longest_width + mui->margin*4.0, - line_height * list->size + mui->margin*4.0, + menu_display_draw_quad( + x - longest_width / 2.0 - mui->margin * 2.0, + y - line_height / 2.0 - mui->margin * 2.0, + longest_width + mui->margin * 4.0, + line_height * list->size + mui->margin * 4.0, width, height, &body_bg_color[0]); @@ -629,7 +634,8 @@ static void mui_render_messagebox(mui_handle_t *mui, { const char *msg = list->elems[i].data; if (msg) - menu_display_draw_text(mui->font, msg, + menu_display_draw_text( + mui->font, msg, x - longest_width/2.0, y + i * line_height + mui->font->size / 3, width, height, font_color, TEXT_ALIGN_LEFT, 1.0f, false, 0); @@ -642,7 +648,8 @@ static void mui_render_messagebox(mui_handle_t *mui, menu_event_get_osk_grid(), menu_event_get_osk_ptr()); end: - string_list_free(list); + if (list) + string_list_free(list); } /* Used for the sublabels */ From 3aaab43736f4e42026e5fa20cffc2907156e2370 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 4 Feb 2018 19:57:31 +0100 Subject: [PATCH 066/232] Should fix Emscripten build --- menu/cbs/menu_cbs_get_value.c | 20 ++++++++++++-------- menu/drivers/zarch.c | 2 ++ menu/menu_setting.c | 2 ++ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index cbf73cca84..1741871418 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -309,6 +309,7 @@ static void menu_action_setting_disp_set_label_pipeline( } +#ifdef HAVE_NETWORKING static void menu_action_setting_disp_set_label_netplay_mitm_server( file_list_t* list, unsigned *w, unsigned type, unsigned i, @@ -318,6 +319,7 @@ static void menu_action_setting_disp_set_label_netplay_mitm_server( const char *path, char *s2, size_t len2) { + unsigned i; settings_t *settings = config_get_ptr(); *s = '\0'; @@ -327,17 +329,17 @@ static void menu_action_setting_disp_set_label_netplay_mitm_server( if (!settings) return; - if (!string_is_empty(settings->arrays.netplay_mitm_server)) - { - unsigned i; + if (string_is_empty(settings->arrays.netplay_mitm_server)) + return; - for (i = 0; i < ARRAY_SIZE(netplay_mitm_server_list); i++) - { - if (string_is_equal(settings->arrays.netplay_mitm_server, netplay_mitm_server_list[i].name)) - strlcpy(s, netplay_mitm_server_list[i].description, len); - } + for (i = 0; i < ARRAY_SIZE(netplay_mitm_server_list); i++) + { + if (string_is_equal(settings->arrays.netplay_mitm_server, + netplay_mitm_server_list[i].name)) + strlcpy(s, netplay_mitm_server_list[i].description, len); } } +#endif static void menu_action_setting_disp_set_label_shader_watch_for_changes( file_list_t* list, @@ -2230,8 +2232,10 @@ int menu_cbs_init_bind_get_string_representation(menu_file_list_cbs_t *cbs, menu_action_setting_disp_set_label_achievement_information); return 0; case MENU_ENUM_LABEL_NETPLAY_MITM_SERVER: +#ifdef HAVE_NETWORKING BIND_ACTION_GET_VALUE(cbs, menu_action_setting_disp_set_label_netplay_mitm_server); +#endif return 0; default: break; diff --git a/menu/drivers/zarch.c b/menu/drivers/zarch.c index fd06e5600c..654490c301 100644 --- a/menu/drivers/zarch.c +++ b/menu/drivers/zarch.c @@ -729,7 +729,9 @@ static int zarch_zui_render_lay_root_downloads( static int zarch_zui_render_lay_root(video_frame_info_t *video_info, zui_t *zui) { +#ifdef ZARCH_DEBUG char item[PATH_MAX_LENGTH]; +#endif static struct zui_tabbed tabbed = {~0U}; zarch_zui_tabbed_begin(zui, &tabbed, 0, 0); diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 356ac85fe8..e323ff140e 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -575,11 +575,13 @@ static void setting_get_string_representation_uint_autosave_interval(void *data, } #endif +#if defined(HAVE_NETWORKING) static void setting_get_string_representation_netplay_mitm_server(void *data, char *s, size_t len) { } +#endif #ifdef HAVE_LANGEXTRA static void setting_get_string_representation_uint_user_language(void *data, From dc4f7ec92094ce86044fe3a24541ec844fd0ba60 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 4 Feb 2018 19:58:36 +0100 Subject: [PATCH 067/232] Buildfix --- menu/cbs/menu_cbs_get_value.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index 1741871418..2b65b0979e 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -319,7 +319,7 @@ static void menu_action_setting_disp_set_label_netplay_mitm_server( const char *path, char *s2, size_t len2) { - unsigned i; + unsigned j; settings_t *settings = config_get_ptr(); *s = '\0'; @@ -332,11 +332,11 @@ static void menu_action_setting_disp_set_label_netplay_mitm_server( if (string_is_empty(settings->arrays.netplay_mitm_server)) return; - for (i = 0; i < ARRAY_SIZE(netplay_mitm_server_list); i++) + for (j = 0; j < ARRAY_SIZE(netplay_mitm_server_list); j++) { if (string_is_equal(settings->arrays.netplay_mitm_server, - netplay_mitm_server_list[i].name)) - strlcpy(s, netplay_mitm_server_list[i].description, len); + netplay_mitm_server_list[j].name)) + strlcpy(s, netplay_mitm_server_list[j].description, len); } } #endif From 700fce3bd292aaac1d56a4b9ce243ad0830e7814 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Sun, 4 Feb 2018 20:03:27 +0100 Subject: [PATCH 068/232] various fixes for CXX_BUILD. --- gfx/common/d3d10_common.c | 2 + gfx/common/d3d10_common.h | 1517 +++------------------ gfx/common/d3d11_common.c | 8 +- gfx/common/d3d11_common.h | 9 +- gfx/common/d3d12_common.c | 269 ++-- gfx/common/d3d12_common.h | 12 +- gfx/common/d3dcompiler_common.c | 2 + gfx/common/dxgi_common.c | 4 +- gfx/common/dxgi_common.h | 10 +- gfx/display_servers/dispserv_win32.c | 2 +- gfx/drivers/d3d10.c | 2 + gfx/drivers/d3d11.c | 137 +- gfx/drivers/d3d12.c | 6 +- gfx/drivers_font/d3d11_font.c | 2 + libretro-common/streams/file_stream.c | 1 + menu/drivers_display/menu_display_d3d11.c | 28 +- network/netplay/netplay_sync.c | 4 +- tasks/task_autodetect.c | 5 +- 18 files changed, 421 insertions(+), 1599 deletions(-) diff --git a/gfx/common/d3d10_common.c b/gfx/common/d3d10_common.c index 5d91071db6..77ebb31a3a 100644 --- a/gfx/common/d3d10_common.c +++ b/gfx/common/d3d10_common.c @@ -13,6 +13,8 @@ * If not, see . */ +#define CINTERFACE + #include #include "d3d10_common.h" diff --git a/gfx/common/d3d10_common.h b/gfx/common/d3d10_common.h index d3e72a3fa0..4ae2074295 100644 --- a/gfx/common/d3d10_common.h +++ b/gfx/common/d3d10_common.h @@ -50,111 +50,56 @@ typedef ID3D10Debug* D3D10Debug; typedef ID3D10SwitchToRef* D3D10SwitchToRef; typedef ID3D10InfoQueue* D3D10InfoQueue; +#if !defined(__cplusplus) || defined(CINTERFACE) static INLINE void D3D10SetResourceEvictionPriority(D3D10Resource resource, UINT eviction_priority) { -#ifdef __cplusplus - resource->SetEvictionPriority(eviction_priority); -#else resource->lpVtbl->SetEvictionPriority(resource, eviction_priority); -#endif } static INLINE UINT D3D10GetResourceEvictionPriority(D3D10Resource resource) { -#ifdef __cplusplus - return resource->GetEvictionPriority(); -#else return resource->lpVtbl->GetEvictionPriority(resource); -#endif } static INLINE void D3D10SetBufferEvictionPriority(D3D10Buffer buffer, UINT eviction_priority) { -#ifdef __cplusplus - buffer->SetEvictionPriority(eviction_priority); -#else buffer->lpVtbl->SetEvictionPriority(buffer, eviction_priority); -#endif } static INLINE UINT D3D10GetBufferEvictionPriority(D3D10Buffer buffer) { -#ifdef __cplusplus - return buffer->GetEvictionPriority(); -#else return buffer->lpVtbl->GetEvictionPriority(buffer); -#endif } - static INLINE HRESULT D3D10MapBuffer(D3D10Buffer buffer, D3D10_MAP map_type, UINT map_flags, void** data) { -#ifdef __cplusplus - return buffer->Map(map_type, map_flags, data); -#else return buffer->lpVtbl->Map(buffer, map_type, map_flags, data); -#endif -} -static INLINE void D3D10UnmapBuffer(D3D10Buffer buffer) -{ -#ifdef __cplusplus - buffer->Unmap(); -#else - buffer->lpVtbl->Unmap(buffer); -#endif } +static INLINE void D3D10UnmapBuffer(D3D10Buffer buffer) { buffer->lpVtbl->Unmap(buffer); } static INLINE void -D3D10SetTexture1DEvictionPriority(D3D10Texture1D texture1d, - UINT eviction_priority) +D3D10SetTexture1DEvictionPriority(D3D10Texture1D texture1d, UINT eviction_priority) { -#ifdef __cplusplus - texture1d->SetEvictionPriority(eviction_priority); -#else texture1d->lpVtbl->SetEvictionPriority(texture1d, eviction_priority); -#endif } static INLINE UINT D3D10GetTexture1DEvictionPriority(D3D10Texture1D texture1d) { -#ifdef __cplusplus - return texture1d->GetEvictionPriority(); -#else return texture1d->lpVtbl->GetEvictionPriority(texture1d); -#endif } static INLINE HRESULT D3D10MapTexture1D( D3D10Texture1D texture1d, UINT subresource, D3D10_MAP map_type, UINT map_flags, void** data) { -#ifdef __cplusplus - return texture1d->Map(subresource, map_type, map_flags, data); -#else - return texture1d->lpVtbl->Map(texture1d, subresource, - map_type, map_flags, data); -#endif + return texture1d->lpVtbl->Map(texture1d, subresource, map_type, map_flags, data); } static INLINE void D3D10UnmapTexture1D(D3D10Texture1D texture1d, UINT subresource) { -#ifdef __cplusplus - texture1d->Unmap(subresource); -#else texture1d->lpVtbl->Unmap(texture1d, subresource); -#endif } static INLINE void D3D10SetTexture2DEvictionPriority(D3D10Texture2D texture2d, UINT eviction_priority) { -#ifdef __cplusplus - texture2d->SetEvictionPriority(eviction_priority); -#else texture2d->lpVtbl->SetEvictionPriority(texture2d, eviction_priority); -#endif } - static INLINE UINT D3D10GetTexture2DEvictionPriority(D3D10Texture2D texture2d) { -#ifdef __cplusplus - return texture2d->GetEvictionPriority(); -#else return texture2d->lpVtbl->GetEvictionPriority(texture2d); -#endif } - static INLINE HRESULT D3D10MapTexture2D( D3D10Texture2D texture2d, UINT subresource, @@ -162,40 +107,20 @@ static INLINE HRESULT D3D10MapTexture2D( UINT map_flags, D3D10_MAPPED_TEXTURE2D* mapped_tex2d) { -#ifdef __cplusplus - return texture2d->Map(subresource, map_type, map_flags, mapped_tex2d); -#else - return texture2d->lpVtbl->Map(texture2d, subresource, map_type, - map_flags, mapped_tex2d); -#endif + return texture2d->lpVtbl->Map(texture2d, subresource, map_type, map_flags, mapped_tex2d); } - static INLINE void D3D10UnmapTexture2D(D3D10Texture2D texture2d, UINT subresource) { -#ifdef __cplusplus - texture2d->Unmap(subresource); -#else texture2d->lpVtbl->Unmap(texture2d, subresource); -#endif } - static INLINE void -D3D10SetTexture3DEvictionPriority(D3D10Texture3D texture3d, - UINT eviction_priority) +D3D10SetTexture3DEvictionPriority(D3D10Texture3D texture3d, UINT eviction_priority) { -#ifdef __cplusplus - texture3d->SetEvictionPriority(eviction_priority); -#else texture3d->lpVtbl->SetEvictionPriority(texture3d, eviction_priority); -#endif } static INLINE UINT D3D10GetTexture3DEvictionPriority(D3D10Texture3D texture3d) { -#ifdef __cplusplus - return texture3d->GetEvictionPriority(); -#else return texture3d->lpVtbl->GetEvictionPriority(texture3d); -#endif } static INLINE HRESULT D3D10MapTexture3D( D3D10Texture3D texture3d, @@ -204,231 +129,91 @@ static INLINE HRESULT D3D10MapTexture3D( UINT map_flags, D3D10_MAPPED_TEXTURE3D* mapped_tex3d) { -#ifdef __cplusplus - return texture3d->Map(subresource, - map_type, map_flags, mapped_tex3d); -#else - return texture3d->lpVtbl->Map(texture3d, subresource, - map_type, map_flags, mapped_tex3d); -#endif + return texture3d->lpVtbl->Map(texture3d, subresource, map_type, map_flags, mapped_tex3d); } -static INLINE void D3D10UnmapTexture3D(D3D10Texture3D texture3d, - UINT subresource) +static INLINE void D3D10UnmapTexture3D(D3D10Texture3D texture3d, UINT subresource) { -#ifdef __cplusplus - texture3d->Unmap(subresource); -#else texture3d->lpVtbl->Unmap(texture3d, subresource); -#endif } - -static INLINE void D3D10GetViewResource(D3D10View view, - D3D10Resource* resource) +static INLINE void D3D10GetViewResource(D3D10View view, D3D10Resource* resource) { -#ifdef __cplusplus - view->GetResource(resource); -#else view->lpVtbl->GetResource(view, resource); -#endif } - static INLINE void D3D10GetShaderResourceViewResource( D3D10ShaderResourceView shader_resource_view, D3D10Resource* resource) { -#ifdef __cplusplus - shader_resource_view->GetResource(resource); -#else shader_resource_view->lpVtbl->GetResource(shader_resource_view, resource); -#endif } - static INLINE void -D3D10GetRenderTargetViewResource(D3D10RenderTargetView render_target_view, - D3D10Resource* resource) +D3D10GetRenderTargetViewResource(D3D10RenderTargetView render_target_view, D3D10Resource* resource) { -#ifdef __cplusplus - render_target_view->GetResource(resource); -#else render_target_view->lpVtbl->GetResource(render_target_view, resource); -#endif } - static INLINE void -D3D10GetDepthStencilViewResource(D3D10DepthStencilView depth_stencil_view, - D3D10Resource* resource) +D3D10GetDepthStencilViewResource(D3D10DepthStencilView depth_stencil_view, D3D10Resource* resource) { -#ifdef __cplusplus - depth_stencil_view->GetResource(resource); -#else depth_stencil_view->lpVtbl->GetResource(depth_stencil_view, resource); -#endif } - static INLINE void D3D10BeginAsynchronous(D3D10Asynchronous asynchronous) { -#ifdef __cplusplus - asynchronous->Begin(); -#else asynchronous->lpVtbl->Begin(asynchronous); -#endif } - static INLINE void D3D10EndAsynchronous(D3D10Asynchronous asynchronous) { -#ifdef __cplusplus - asynchronous->End(); -#else asynchronous->lpVtbl->End(asynchronous); -#endif } - static INLINE HRESULT D3D10GetAsynchronousData( - D3D10Asynchronous asynchronous, void* data, - UINT data_size, UINT get_data_flags) + D3D10Asynchronous asynchronous, void* data, UINT data_size, UINT get_data_flags) { -#ifdef __cplusplus - return asynchronous->GetData(data, - data_size, get_data_flags); -#else - return asynchronous->lpVtbl->GetData(asynchronous, data, - data_size, get_data_flags); -#endif + return asynchronous->lpVtbl->GetData(asynchronous, data, data_size, get_data_flags); } - -static INLINE UINT D3D10GetAsynchronousDataSize( - D3D10Asynchronous asynchronous) +static INLINE UINT D3D10GetAsynchronousDataSize(D3D10Asynchronous asynchronous) { -#ifdef __cplusplus - return asynchronous->GetDataSize(); -#else return asynchronous->lpVtbl->GetDataSize(asynchronous); -#endif } - -static INLINE void D3D10BeginQuery(D3D10Query query) -{ -#ifdef __cplusplus - query->Begin(); -#else - query->lpVtbl->Begin(query); -#endif -} - -static INLINE void D3D10EndQuery(D3D10Query query) -{ -#ifdef __cplusplus - query->End(); -#else - query->lpVtbl->End(query); -#endif -} - +static INLINE void D3D10BeginQuery(D3D10Query query) { query->lpVtbl->Begin(query); } +static INLINE void D3D10EndQuery(D3D10Query query) { query->lpVtbl->End(query); } static INLINE HRESULT -D3D10GetQueryData(D3D10Query query, void* data, - UINT data_size, UINT get_data_flags) +D3D10GetQueryData(D3D10Query query, void* data, UINT data_size, UINT get_data_flags) { -#ifdef __cplusplus - return query->GetData(data, data_size, get_data_flags); -#else return query->lpVtbl->GetData(query, data, data_size, get_data_flags); -#endif } - static INLINE UINT D3D10GetQueryDataSize(D3D10Query query) { -#ifdef __cplusplus - return query->GetDataSize(); -#else return query->lpVtbl->GetDataSize(query); -#endif } - static INLINE void D3D10BeginPredicate(D3D10Predicate predicate) { -#ifdef __cplusplus - predicate->Begin(); -#else predicate->lpVtbl->Begin(predicate); -#endif } - static INLINE void D3D10EndPredicate(D3D10Predicate predicate) { -#ifdef __cplusplus - predicate->End(); -#else predicate->lpVtbl->End(predicate); -#endif } - static INLINE HRESULT -D3D10GetPredicateData(D3D10Predicate predicate, void* data, - UINT data_size, UINT get_data_flags) +D3D10GetPredicateData(D3D10Predicate predicate, void* data, UINT data_size, UINT get_data_flags) { -#ifdef __cplusplus - return predicate->GetData(data, data_size, get_data_flags); -#else - return predicate->lpVtbl->GetData(predicate, data, - data_size, get_data_flags); -#endif + return predicate->lpVtbl->GetData(predicate, data, data_size, get_data_flags); } static INLINE UINT D3D10GetPredicateDataSize(D3D10Predicate predicate) { -#ifdef __cplusplus - return predicate->GetDataSize(); -#else return predicate->lpVtbl->GetDataSize(predicate); -#endif } - -static INLINE void D3D10BeginCounter(D3D10Counter counter) -{ -#ifdef __cplusplus - counter->Begin(); -#else - counter->lpVtbl->Begin(counter); -#endif -} - -static INLINE void D3D10EndCounter(D3D10Counter counter) -{ -#ifdef __cplusplus - counter->End(); -#else - counter->lpVtbl->End(counter); -#endif -} - +static INLINE void D3D10BeginCounter(D3D10Counter counter) { counter->lpVtbl->Begin(counter); } +static INLINE void D3D10EndCounter(D3D10Counter counter) { counter->lpVtbl->End(counter); } static INLINE HRESULT -D3D10GetCounterData(D3D10Counter counter, void* data, - UINT data_size, UINT get_data_flags) +D3D10GetCounterData(D3D10Counter counter, void* data, UINT data_size, UINT get_data_flags) { -#ifdef __cplusplus - return counter->GetData(data, data_size, get_data_flags); -#else return counter->lpVtbl->GetData(counter, data, data_size, get_data_flags); -#endif } - static INLINE UINT D3D10GetCounterDataSize(D3D10Counter counter) { -#ifdef __cplusplus - return counter->GetDataSize(); -#else return counter->lpVtbl->GetDataSize(counter); -#endif } - static INLINE void D3D10SetVShaderConstantBuffers( - D3D10Device device, UINT start_slot, UINT num_buffers, - D3D10Buffer* const constant_buffers) + D3D10Device device, UINT start_slot, UINT num_buffers, D3D10Buffer* const constant_buffers) { -#ifdef __cplusplus - device->VSSetConstantBuffers(start_slot, num_buffers, constant_buffers); -#else - device->lpVtbl->VSSetConstantBuffers(device, start_slot, - num_buffers, constant_buffers); -#endif + device->lpVtbl->VSSetConstantBuffers(device, start_slot, num_buffers, constant_buffers); } static INLINE void D3D10SetPShaderResources( D3D10Device device, @@ -436,92 +221,39 @@ static INLINE void D3D10SetPShaderResources( UINT num_views, D3D10ShaderResourceView* const shader_resource_views) { -#ifdef __cplusplus - device->PSSetShaderResources(start_slot, num_views, - shader_resource_views); -#else - device->lpVtbl->PSSetShaderResources(device, start_slot, - num_views, shader_resource_views); -#endif + device->lpVtbl->PSSetShaderResources(device, start_slot, num_views, shader_resource_views); } - -static INLINE void D3D10SetPShader(D3D10Device device, - D3D10PixelShader pixel_shader) +static INLINE void D3D10SetPShader(D3D10Device device, D3D10PixelShader pixel_shader) { -#ifdef __cplusplus - device->PSSetShader(pixel_shader); -#else device->lpVtbl->PSSetShader(device, pixel_shader); -#endif } - static INLINE void D3D10SetPShaderSamplers( - D3D10Device device, UINT start_slot, UINT num_samplers, - D3D10SamplerState* const samplers) + D3D10Device device, UINT start_slot, UINT num_samplers, D3D10SamplerState* const samplers) { -#ifdef __cplusplus - device->PSSetSamplers(start_slot, num_samplers, samplers); -#else - device->lpVtbl->PSSetSamplers(device, start_slot, - num_samplers, samplers); -#endif + device->lpVtbl->PSSetSamplers(device, start_slot, num_samplers, samplers); } - -static INLINE void D3D10SetVShader(D3D10Device device, - D3D10VertexShader vertex_shader) +static INLINE void D3D10SetVShader(D3D10Device device, D3D10VertexShader vertex_shader) { -#ifdef __cplusplus - device->VSSetShader(vertex_shader); -#else device->lpVtbl->VSSetShader(device, vertex_shader); -#endif } - static INLINE void D3D10DrawIndexed( - D3D10Device device, UINT index_count, - UINT start_index_location, INT base_vertex_location) + D3D10Device device, UINT index_count, UINT start_index_location, INT base_vertex_location) { -#ifdef __cplusplus - device->DrawIndexed(index_count, - start_index_location, base_vertex_location); -#else - device->lpVtbl->DrawIndexed(device, index_count, - start_index_location, base_vertex_location); -#endif + device->lpVtbl->DrawIndexed(device, index_count, start_index_location, base_vertex_location); } -static INLINE void D3D10Draw(D3D10Device device, - UINT vertex_count, UINT start_vertex_location) +static INLINE void D3D10Draw(D3D10Device device, UINT vertex_count, UINT start_vertex_location) { -#ifdef __cplusplus - device->Draw(vertex_count, start_vertex_location); -#else device->lpVtbl->Draw(device, vertex_count, start_vertex_location); -#endif } - static INLINE void D3D10SetPShaderConstantBuffers( - D3D10Device device, UINT start_slot, - UINT num_buffers, D3D10Buffer* const constant_buffers) + D3D10Device device, UINT start_slot, UINT num_buffers, D3D10Buffer* const constant_buffers) { -#ifdef __cplusplus - device->PSSetConstantBuffers(start_slot, - num_buffers, constant_buffers); -#else - device->lpVtbl->PSSetConstantBuffers(device, start_slot, - num_buffers, constant_buffers); -#endif + device->lpVtbl->PSSetConstantBuffers(device, start_slot, num_buffers, constant_buffers); } - -static INLINE void D3D10SetInputLayout(D3D10Device device, - D3D10InputLayout input_layout) +static INLINE void D3D10SetInputLayout(D3D10Device device, D3D10InputLayout input_layout) { -#ifdef __cplusplus - device->IASetInputLayout(input_layout); -#else device->lpVtbl->IASetInputLayout(device, input_layout); -#endif } - static INLINE void D3D10SetVertexBuffers( D3D10Device device, UINT start_slot, @@ -530,28 +262,14 @@ static INLINE void D3D10SetVertexBuffers( UINT* strides, UINT* offsets) { -#ifdef __cplusplus - device->IASetVertexBuffers( - start_slot, num_buffers, - vertex_buffers, strides, offsets); -#else device->lpVtbl->IASetVertexBuffers( - device, start_slot, num_buffers, - vertex_buffers, strides, offsets); -#endif + device, start_slot, num_buffers, vertex_buffers, strides, offsets); } - static INLINE void -D3D10SetIndexBuffer(D3D10Device device, - D3D10Buffer index_buffer, DXGI_FORMAT format, UINT offset) +D3D10SetIndexBuffer(D3D10Device device, D3D10Buffer index_buffer, DXGI_FORMAT format, UINT offset) { -#ifdef __cplusplus - device->IASetIndexBuffer(index_buffer, format, offset); -#else device->lpVtbl->IASetIndexBuffer(device, index_buffer, format, offset); -#endif } - static INLINE void D3D10DrawIndexedInstanced( D3D10Device device, UINT index_count_per_instance, @@ -560,19 +278,10 @@ static INLINE void D3D10DrawIndexedInstanced( INT base_vertex_location, UINT start_instance_location) { -#ifdef __cplusplus - device->DrawIndexedInstanced( - index_count_per_instance, - instance_count, start_index_location, - base_vertex_location, start_instance_location); -#else device->lpVtbl->DrawIndexedInstanced( - device, index_count_per_instance, - instance_count, start_index_location, + device, index_count_per_instance, instance_count, start_index_location, base_vertex_location, start_instance_location); -#endif } - static INLINE void D3D10DrawInstanced( D3D10Device device, UINT vertex_count_per_instance, @@ -580,209 +289,91 @@ static INLINE void D3D10DrawInstanced( UINT start_vertex_location, UINT start_instance_location) { -#ifdef __cplusplus - device->DrawInstanced( - vertex_count_per_instance, - instance_count, start_vertex_location, - start_instance_location); -#else device->lpVtbl->DrawInstanced( - device, vertex_count_per_instance, - instance_count, start_vertex_location, + device, vertex_count_per_instance, instance_count, start_vertex_location, start_instance_location); -#endif } - static INLINE void D3D10SetGShaderConstantBuffers( - D3D10Device device, UINT start_slot, - UINT num_buffers, D3D10Buffer* const constant_buffers) + D3D10Device device, UINT start_slot, UINT num_buffers, D3D10Buffer* const constant_buffers) { -#ifdef __cplusplus - device->GSSetConstantBuffers(start_slot, - num_buffers, constant_buffers); -#else - device->lpVtbl->GSSetConstantBuffers(device, start_slot, - num_buffers, constant_buffers); -#endif + device->lpVtbl->GSSetConstantBuffers(device, start_slot, num_buffers, constant_buffers); } - -static INLINE void D3D10SetGShader(D3D10Device device, - D3D10GeometryShader shader) +static INLINE void D3D10SetGShader(D3D10Device device, D3D10GeometryShader shader) { -#ifdef __cplusplus - device->GSSetShader(shader); -#else device->lpVtbl->GSSetShader(device, shader); -#endif } - -static INLINE void D3D10SetPrimitiveTopology(D3D10Device device, - D3D10_PRIMITIVE_TOPOLOGY topology) +static INLINE void D3D10SetPrimitiveTopology(D3D10Device device, D3D10_PRIMITIVE_TOPOLOGY topology) { -#ifdef __cplusplus - device->IASetPrimitiveTopology(topology); -#else device->lpVtbl->IASetPrimitiveTopology(device, topology); -#endif } - static INLINE void D3D10SetVShaderResources( D3D10Device device, UINT start_slot, UINT num_views, D3D10ShaderResourceView* const shader_resource_views) { -#ifdef __cplusplus - device->VSSetShaderResources(start_slot, - num_views, shader_resource_views); -#else - device->lpVtbl->VSSetShaderResources(device, start_slot, - num_views, shader_resource_views); -#endif + device->lpVtbl->VSSetShaderResources(device, start_slot, num_views, shader_resource_views); } - static INLINE void D3D10SetVShaderSamplers( - D3D10Device device, UINT start_slot, - UINT num_samplers, D3D10SamplerState* const samplers) + D3D10Device device, UINT start_slot, UINT num_samplers, D3D10SamplerState* const samplers) { -#ifdef __cplusplus - device->VSSetSamplers(start_slot, num_samplers, samplers); -#else - device->lpVtbl->VSSetSamplers(device, start_slot, - num_samplers, samplers); -#endif + device->lpVtbl->VSSetSamplers(device, start_slot, num_samplers, samplers); } - static INLINE void -D3D10SetPredication(D3D10Device device, D3D10Predicate predicate, - BOOL predicate_value) +D3D10SetPredication(D3D10Device device, D3D10Predicate predicate, BOOL predicate_value) { -#ifdef __cplusplus - device->SetPredication(predicate, predicate_value); -#else device->lpVtbl->SetPredication(device, predicate, predicate_value); -#endif } - static INLINE void D3D10SetGShaderResources( D3D10Device device, UINT start_slot, UINT num_views, D3D10ShaderResourceView* const shader_resource_views) { -#ifdef __cplusplus - device->GSSetShaderResources(start_slot, - num_views, shader_resource_views); -#else - device->lpVtbl->GSSetShaderResources(device, start_slot, - num_views, shader_resource_views); -#endif + device->lpVtbl->GSSetShaderResources(device, start_slot, num_views, shader_resource_views); } - static INLINE void D3D10SetGShaderSamplers( - D3D10Device device, UINT start_slot, - UINT num_samplers, D3D10SamplerState* const samplers) + D3D10Device device, UINT start_slot, UINT num_samplers, D3D10SamplerState* const samplers) { -#ifdef __cplusplus - device->GSSetSamplers(start_slot, - num_samplers, samplers); -#else - device->lpVtbl->GSSetSamplers(device, start_slot, - num_samplers, samplers); -#endif + device->lpVtbl->GSSetSamplers(device, start_slot, num_samplers, samplers); } - static INLINE void D3D10SetRenderTargets( D3D10Device device, UINT num_views, D3D10RenderTargetView* const render_target_views, D3D10DepthStencilView depth_stencil_view) { -#ifdef __cplusplus - device->OMSetRenderTargets(num_views, - render_target_views, depth_stencil_view); -#else - device->lpVtbl->OMSetRenderTargets(device, num_views, - render_target_views, depth_stencil_view); -#endif + device->lpVtbl->OMSetRenderTargets(device, num_views, render_target_views, depth_stencil_view); } - static INLINE void D3D10SetBlendState( - D3D10Device device, D3D10BlendState blend_state, - FLOAT blend_factor[4], UINT sample_mask) + D3D10Device device, D3D10BlendState blend_state, FLOAT blend_factor[4], UINT sample_mask) { -#ifdef __cplusplus - device->OMSetBlendState(blend_state, - blend_factor, sample_mask); -#else - device->lpVtbl->OMSetBlendState(device, blend_state, - blend_factor, sample_mask); -#endif + device->lpVtbl->OMSetBlendState(device, blend_state, blend_factor, sample_mask); } - static INLINE void D3D10SetDepthStencilState( - D3D10Device device, - D3D10DepthStencilState depth_stencil_state, UINT stencil_ref) + D3D10Device device, D3D10DepthStencilState depth_stencil_state, UINT stencil_ref) { -#ifdef __cplusplus - device->OMSetDepthStencilState(depth_stencil_state, stencil_ref); -#else - device->lpVtbl->OMSetDepthStencilState(device, depth_stencil_state, - stencil_ref); -#endif + device->lpVtbl->OMSetDepthStencilState(device, depth_stencil_state, stencil_ref); } - static INLINE void -D3D10SOSetTargets(D3D10Device device, UINT num_buffers, - D3D10Buffer* const sotargets, UINT* offsets) +D3D10SOSetTargets(D3D10Device device, UINT num_buffers, D3D10Buffer* const sotargets, UINT* offsets) { -#ifdef __cplusplus - device->SOSetTargets(num_buffers, sotargets, offsets); -#else device->lpVtbl->SOSetTargets(device, num_buffers, sotargets, offsets); -#endif } - -static INLINE void D3D10DrawAuto(D3D10Device device) +static INLINE void D3D10DrawAuto(D3D10Device device) { device->lpVtbl->DrawAuto(device); } +static INLINE void D3D10SetState(D3D10Device device, D3D10RasterizerState rasterizer_state) { -#ifdef __cplusplus - device->DrawAuto(); -#else - device->lpVtbl->DrawAuto(device); -#endif -} - -static INLINE void D3D10SetState(D3D10Device device, - D3D10RasterizerState rasterizer_state) -{ -#ifdef __cplusplus - device->RSSetState(rasterizer_state); -#else device->lpVtbl->RSSetState(device, rasterizer_state); -#endif } - static INLINE void -D3D10SetViewports(D3D10Device device, - UINT num_viewports, D3D10_VIEWPORT* viewports) +D3D10SetViewports(D3D10Device device, UINT num_viewports, D3D10_VIEWPORT* viewports) { -#ifdef __cplusplus - device->RSSetViewports(num_viewports, viewports); -#else device->lpVtbl->RSSetViewports(device, num_viewports, viewports); -#endif } - -static INLINE void D3D10SetScissorRects(D3D10Device device, - UINT num_rects, D3D10_RECT* rects) +static INLINE void D3D10SetScissorRects(D3D10Device device, UINT num_rects, D3D10_RECT* rects) { -#ifdef __cplusplus - device->RSSetScissorRects(num_rects, rects); -#else device->lpVtbl->RSSetScissorRects(device, num_rects, rects); -#endif } - static INLINE void D3D10CopySubresourceRegionDevice( D3D10Device device, D3D10Resource dst_resource, @@ -794,32 +385,15 @@ static INLINE void D3D10CopySubresourceRegionDevice( UINT src_subresource, D3D10_BOX* src_box) { -#ifdef __cplusplus - device->CopySubresourceRegion( - dst_resource, - dst_subresource, dst_x, dst_y, dst_z, - src_resource, src_subresource, - src_box); -#else device->lpVtbl->CopySubresourceRegion( - device, dst_resource, - dst_subresource, dst_x, dst_y, dst_z, - src_resource, src_subresource, + device, dst_resource, dst_subresource, dst_x, dst_y, dst_z, src_resource, src_subresource, src_box); -#endif } - static INLINE void -D3D10CopyResource(D3D10Device device, - D3D10Resource dst_resource, D3D10Resource src_resource) +D3D10CopyResource(D3D10Device device, D3D10Resource dst_resource, D3D10Resource src_resource) { -#ifdef __cplusplus - device->CopyResource(dst_resource, src_resource); -#else device->lpVtbl->CopyResource(device, dst_resource, src_resource); -#endif } - static INLINE void D3D10UpdateSubresource( D3D10Device device, D3D10Resource dst_resource, @@ -829,29 +403,14 @@ static INLINE void D3D10UpdateSubresource( UINT src_row_pitch, UINT src_depth_pitch) { -#ifdef __cplusplus - device->UpdateSubresource( - dst_resource, dst_subresource, - dst_box, src_data, src_row_pitch, src_depth_pitch); -#else device->lpVtbl->UpdateSubresource( - device, dst_resource, dst_subresource, - dst_box, src_data, src_row_pitch, src_depth_pitch); -#endif + device, dst_resource, dst_subresource, dst_box, src_data, src_row_pitch, src_depth_pitch); } - static INLINE void D3D10ClearRenderTargetView( - D3D10Device device, D3D10RenderTargetView render_target_view, - FLOAT color_rgba[4]) + D3D10Device device, D3D10RenderTargetView render_target_view, FLOAT color_rgba[4]) { -#ifdef __cplusplus - device->ClearRenderTargetView(render_target_view, color_rgba); -#else - device->lpVtbl->ClearRenderTargetView(device, - render_target_view, color_rgba); -#endif + device->lpVtbl->ClearRenderTargetView(device, render_target_view, color_rgba); } - static INLINE void D3D10ClearDepthStencilView( D3D10Device device, D3D10DepthStencilView depth_stencil_view, @@ -859,26 +418,13 @@ static INLINE void D3D10ClearDepthStencilView( FLOAT depth, UINT8 stencil) { -#ifdef __cplusplus - device->ClearDepthStencilView(depth_stencil_view, - clear_flags, depth, stencil); -#else - device->lpVtbl->ClearDepthStencilView(device, - depth_stencil_view, clear_flags, depth, stencil); -#endif + device->lpVtbl->ClearDepthStencilView(device, depth_stencil_view, clear_flags, depth, stencil); } - static INLINE void -D3D10GenerateMips(D3D10Device device, - D3D10ShaderResourceView shader_resource_view) +D3D10GenerateMips(D3D10Device device, D3D10ShaderResourceView shader_resource_view) { -#ifdef __cplusplus - device->GenerateMips(shader_resource_view); -#else device->lpVtbl->GenerateMips(device, shader_resource_view); -#endif } - static INLINE void D3D10ResolveSubresource( D3D10Device device, D3D10Resource dst_resource, @@ -887,101 +433,44 @@ static INLINE void D3D10ResolveSubresource( UINT src_subresource, DXGI_FORMAT format) { -#ifdef __cplusplus - device->ResolveSubresource( - dst_resource, dst_subresource, - src_resource, src_subresource, format); -#else device->lpVtbl->ResolveSubresource( - device, dst_resource, dst_subresource, - src_resource, src_subresource, format); -#endif + device, dst_resource, dst_subresource, src_resource, src_subresource, format); } - static INLINE void D3D10GetVShaderConstantBuffers( - D3D10Device device, UINT start_slot, - UINT num_buffers, D3D10Buffer* constant_buffers) + D3D10Device device, UINT start_slot, UINT num_buffers, D3D10Buffer* constant_buffers) { -#ifdef __cplusplus - device->VSGetConstantBuffers(start_slot, - num_buffers, constant_buffers); -#else - device->lpVtbl->VSGetConstantBuffers(device, start_slot, - num_buffers, constant_buffers); -#endif + device->lpVtbl->VSGetConstantBuffers(device, start_slot, num_buffers, constant_buffers); } - static INLINE void D3D10GetPShaderResources( D3D10Device device, UINT start_slot, UINT num_views, D3D10ShaderResourceView* shader_resource_views) { -#ifdef __cplusplus - device->PSGetShaderResources(start_slot, - num_views, shader_resource_views); -#else - device->lpVtbl->PSGetShaderResources(device, start_slot, - num_views, shader_resource_views); -#endif + device->lpVtbl->PSGetShaderResources(device, start_slot, num_views, shader_resource_views); } - -static INLINE void D3D10GetPShader(D3D10Device device, - D3D10PixelShader* pixel_shader) +static INLINE void D3D10GetPShader(D3D10Device device, D3D10PixelShader* pixel_shader) { -#ifdef __cplusplus - device->PSGetShader(pixel_shader); -#else device->lpVtbl->PSGetShader(device, pixel_shader); -#endif } - static INLINE void D3D10GetPShaderSamplers( - D3D10Device device, UINT start_slot, - UINT num_samplers, D3D10SamplerState* samplers) + D3D10Device device, UINT start_slot, UINT num_samplers, D3D10SamplerState* samplers) { -#ifdef __cplusplus - device->PSGetSamplers(start_slot, - num_samplers, samplers); -#else - device->lpVtbl->PSGetSamplers(device, start_slot, - num_samplers, samplers); -#endif + device->lpVtbl->PSGetSamplers(device, start_slot, num_samplers, samplers); } - -static INLINE void D3D10GetVShader(D3D10Device device, - D3D10VertexShader* vertex_shader) +static INLINE void D3D10GetVShader(D3D10Device device, D3D10VertexShader* vertex_shader) { -#ifdef __cplusplus - device->VSGetShader(vertex_shader); -#else device->lpVtbl->VSGetShader(device, vertex_shader); -#endif } - static INLINE void D3D10GetPShaderConstantBuffers( - D3D10Device device, UINT start_slot, - UINT num_buffers, D3D10Buffer* constant_buffers) + D3D10Device device, UINT start_slot, UINT num_buffers, D3D10Buffer* constant_buffers) { -#ifdef __cplusplus - device->PSGetConstantBuffers(start_slot, - num_buffers, constant_buffers); -#else - device->lpVtbl->PSGetConstantBuffers(device, start_slot, - num_buffers, constant_buffers); -#endif + device->lpVtbl->PSGetConstantBuffers(device, start_slot, num_buffers, constant_buffers); } - -static INLINE void D3D10GetInputLayout(D3D10Device device, - D3D10InputLayout* input_layout) +static INLINE void D3D10GetInputLayout(D3D10Device device, D3D10InputLayout* input_layout) { -#ifdef __cplusplus - device->IAGetInputLayout(input_layout); -#else device->lpVtbl->IAGetInputLayout(device, input_layout); -#endif } - static INLINE void D3D10GetVertexBuffers( D3D10Device device, UINT start_slot, @@ -990,296 +479,131 @@ static INLINE void D3D10GetVertexBuffers( UINT* strides, UINT* offsets) { -#ifdef __cplusplus - device->IAGetVertexBuffers( - start_slot, num_buffers, - vertex_buffers, strides, offsets); -#else device->lpVtbl->IAGetVertexBuffers( - device, start_slot, num_buffers, - vertex_buffers, strides, offsets); -#endif + device, start_slot, num_buffers, vertex_buffers, strides, offsets); } - static INLINE void D3D10GetIndexBuffer( - D3D10Device device, D3D10Buffer* index_buffer, - DXGI_FORMAT* format, UINT* offset) + D3D10Device device, D3D10Buffer* index_buffer, DXGI_FORMAT* format, UINT* offset) { -#ifdef __cplusplus - device->IAGetIndexBuffer(index_buffer, format, offset); -#else device->lpVtbl->IAGetIndexBuffer(device, index_buffer, format, offset); -#endif } - static INLINE void D3D10GetGShaderConstantBuffers( - D3D10Device device, UINT start_slot, - UINT num_buffers, D3D10Buffer* constant_buffers) + D3D10Device device, UINT start_slot, UINT num_buffers, D3D10Buffer* constant_buffers) { -#ifdef __cplusplus - device->GSGetConstantBuffers(start_slot, - num_buffers, constant_buffers); -#else - device->lpVtbl->GSGetConstantBuffers(device, start_slot, - num_buffers, constant_buffers); -#endif + device->lpVtbl->GSGetConstantBuffers(device, start_slot, num_buffers, constant_buffers); } - -static INLINE void D3D10GetGShader(D3D10Device device, - D3D10GeometryShader* geometry_shader) +static INLINE void D3D10GetGShader(D3D10Device device, D3D10GeometryShader* geometry_shader) { -#ifdef __cplusplus - device->GSGetShader(geometry_shader); -#else device->lpVtbl->GSGetShader(device, geometry_shader); -#endif } - -static INLINE void D3D10GetPrimitiveTopology(D3D10Device device, - D3D10_PRIMITIVE_TOPOLOGY* topology) +static INLINE void D3D10GetPrimitiveTopology(D3D10Device device, D3D10_PRIMITIVE_TOPOLOGY* topology) { -#ifdef __cplusplus - device->IAGetPrimitiveTopology(topology); -#else device->lpVtbl->IAGetPrimitiveTopology(device, topology); -#endif } - static INLINE void D3D10GetVShaderResources( D3D10Device device, UINT start_slot, UINT num_views, D3D10ShaderResourceView* shader_resource_views) { -#ifdef __cplusplus - device->VSGetShaderResources(start_slot, - num_views, shader_resource_views); -#else - device->lpVtbl->VSGetShaderResources(device, start_slot, - num_views, shader_resource_views); -#endif + device->lpVtbl->VSGetShaderResources(device, start_slot, num_views, shader_resource_views); } static INLINE void D3D10GetVShaderSamplers( - D3D10Device device, UINT start_slot, - UINT num_samplers, D3D10SamplerState* samplers) + D3D10Device device, UINT start_slot, UINT num_samplers, D3D10SamplerState* samplers) { -#ifdef __cplusplus - device->VSGetSamplers(start_slot, num_samplers, samplers); -#else - device->lpVtbl->VSGetSamplers(device, start_slot, - num_samplers, samplers); -#endif + device->lpVtbl->VSGetSamplers(device, start_slot, num_samplers, samplers); } - static INLINE void -D3D10GetPredication(D3D10Device device, - D3D10Predicate* predicate, BOOL* predicate_value) +D3D10GetPredication(D3D10Device device, D3D10Predicate* predicate, BOOL* predicate_value) { -#ifdef __cplusplus - device->GetPredication(predicate, predicate_value); -#else device->lpVtbl->GetPredication(device, predicate, predicate_value); -#endif } - static INLINE void D3D10GetGShaderResources( D3D10Device device, UINT start_slot, UINT num_views, D3D10ShaderResourceView* shader_resource_views) { -#ifdef __cplusplus - device->GSGetShaderResources(start_slot, - num_views, shader_resource_views); -#else - device->lpVtbl->GSGetShaderResources(device, start_slot, - num_views, shader_resource_views); -#endif + device->lpVtbl->GSGetShaderResources(device, start_slot, num_views, shader_resource_views); } - static INLINE void D3D10GetGShaderSamplers( - D3D10Device device, UINT start_slot, - UINT num_samplers, D3D10SamplerState* samplers) + D3D10Device device, UINT start_slot, UINT num_samplers, D3D10SamplerState* samplers) { -#ifdef __cplusplus - device->GSGetSamplers(start_slot, num_samplers, samplers); -#else - device->lpVtbl->GSGetSamplers(device, start_slot, - num_samplers, samplers); -#endif + device->lpVtbl->GSGetSamplers(device, start_slot, num_samplers, samplers); } - static INLINE void D3D10GetRenderTargets( D3D10Device device, UINT num_views, D3D10RenderTargetView* render_target_views, D3D10DepthStencilView* depth_stencil_view) { -#ifdef __cplusplus - device->OMGetRenderTargets(num_views, - render_target_views, depth_stencil_view); -#else - device->lpVtbl->OMGetRenderTargets(device, num_views, - render_target_views, depth_stencil_view); -#endif + device->lpVtbl->OMGetRenderTargets(device, num_views, render_target_views, depth_stencil_view); } - static INLINE void D3D10GetBlendState( - D3D10Device device, - D3D10BlendState* blend_state, - FLOAT blend_factor[4], UINT* sample_mask) + D3D10Device device, D3D10BlendState* blend_state, FLOAT blend_factor[4], UINT* sample_mask) { -#ifdef __cplusplus - device->OMGetBlendState(blend_state, blend_factor, sample_mask); -#else - device->lpVtbl->OMGetBlendState(device, blend_state, - blend_factor, sample_mask); -#endif + device->lpVtbl->OMGetBlendState(device, blend_state, blend_factor, sample_mask); } - static INLINE void D3D10GetDepthStencilState( - D3D10Device device, - D3D10DepthStencilState* depth_stencil_state, UINT* stencil_ref) + D3D10Device device, D3D10DepthStencilState* depth_stencil_state, UINT* stencil_ref) { -#ifdef __cplusplus - device->OMGetDepthStencilState(depth_stencil_state, stencil_ref); -#else - device->lpVtbl->OMGetDepthStencilState(device, - depth_stencil_state, stencil_ref); -#endif + device->lpVtbl->OMGetDepthStencilState(device, depth_stencil_state, stencil_ref); } - static INLINE void -D3D10SOGetTargets(D3D10Device device, - UINT num_buffers, D3D10Buffer* sotargets, UINT* offsets) +D3D10SOGetTargets(D3D10Device device, UINT num_buffers, D3D10Buffer* sotargets, UINT* offsets) { -#ifdef __cplusplus - device->SOGetTargets(num_buffers, sotargets, offsets); -#else device->lpVtbl->SOGetTargets(device, num_buffers, sotargets, offsets); -#endif } - -static INLINE void D3D10GetState(D3D10Device device, - D3D10RasterizerState* rasterizer_state) +static INLINE void D3D10GetState(D3D10Device device, D3D10RasterizerState* rasterizer_state) { -#ifdef __cplusplus - device->RSGetState(rasterizer_state); -#else device->lpVtbl->RSGetState(device, rasterizer_state); -#endif } - static INLINE void -D3D10GetViewports(D3D10Device device, - UINT* num_viewports, D3D10_VIEWPORT* viewports) +D3D10GetViewports(D3D10Device device, UINT* num_viewports, D3D10_VIEWPORT* viewports) { -#ifdef __cplusplus - device->RSGetViewports(num_viewports, viewports); -#else device->lpVtbl->RSGetViewports(device, num_viewports, viewports); -#endif } - -static INLINE void D3D10GetScissorRects(D3D10Device device, - UINT* num_rects, D3D10_RECT* rects) +static INLINE void D3D10GetScissorRects(D3D10Device device, UINT* num_rects, D3D10_RECT* rects) { -#ifdef __cplusplus - device->RSGetScissorRects(num_rects, rects); -#else device->lpVtbl->RSGetScissorRects(device, num_rects, rects); -#endif } - static INLINE HRESULT D3D10GetDeviceRemovedReason(D3D10Device device) { -#ifdef __cplusplus - return device->GetDeviceRemovedReason(); -#else return device->lpVtbl->GetDeviceRemovedReason(device); -#endif } - -static INLINE HRESULT D3D10SetExceptionMode(D3D10Device device, - UINT raise_flags) +static INLINE HRESULT D3D10SetExceptionMode(D3D10Device device, UINT raise_flags) { -#ifdef __cplusplus - return device->SetExceptionMode(raise_flags); -#else return device->lpVtbl->SetExceptionMode(device, raise_flags); -#endif } - static INLINE UINT D3D10GetExceptionMode(D3D10Device device) { -#ifdef __cplusplus - return device->GetExceptionMode(); -#else return device->lpVtbl->GetExceptionMode(device); -#endif } - -static INLINE void D3D10ClearState(D3D10Device device) -{ -#ifdef __cplusplus - device->ClearState(); -#else - device->lpVtbl->ClearState(device); -#endif -} - -static INLINE void D3D10Flush(D3D10Device device) -{ -#ifdef __cplusplus - device->Flush(); -#else - device->lpVtbl->Flush(device); -#endif -} - +static INLINE void D3D10ClearState(D3D10Device device) { device->lpVtbl->ClearState(device); } +static INLINE void D3D10Flush(D3D10Device device) { device->lpVtbl->Flush(device); } static INLINE HRESULT D3D10CreateBuffer( D3D10Device device, D3D10_BUFFER_DESC* desc, D3D10_SUBRESOURCE_DATA* initial_data, D3D10Buffer* buffer) { -#ifdef __cplusplus - return device->CreateBuffer( - desc, initial_data, buffer); -#else - return device->lpVtbl->CreateBuffer(device, - desc, initial_data, buffer); -#endif + return device->lpVtbl->CreateBuffer(device, desc, initial_data, buffer); } - static INLINE HRESULT D3D10CreateTexture1D( D3D10Device device, D3D10_TEXTURE1D_DESC* desc, D3D10_SUBRESOURCE_DATA* initial_data, D3D10Texture1D* texture1d) { -#ifdef __cplusplus - return device->CreateTexture1D( - desc, initial_data, texture1d); -#else - return device->lpVtbl->CreateTexture1D(device, - desc, initial_data, texture1d); -#endif + return device->lpVtbl->CreateTexture1D(device, desc, initial_data, texture1d); } - static INLINE HRESULT D3D10CreateTexture2D( D3D10Device device, D3D10_TEXTURE2D_DESC* desc, D3D10_SUBRESOURCE_DATA* initial_data, D3D10Texture2D* texture2d) { -#ifdef __cplusplus - return device->CreateTexture2D( - desc, initial_data, texture2d); -#else - return device->lpVtbl->CreateTexture2D(device, - desc, initial_data, texture2d); -#endif + return device->lpVtbl->CreateTexture2D(device, desc, initial_data, texture2d); } static INLINE HRESULT D3D10CreateTexture3D( D3D10Device device, @@ -1287,28 +611,15 @@ static INLINE HRESULT D3D10CreateTexture3D( D3D10_SUBRESOURCE_DATA* initial_data, D3D10Texture3D* texture3d) { -#ifdef __cplusplus - return device->CreateTexture3D( - desc, initial_data, texture3d); -#else - return device->lpVtbl->CreateTexture3D(device, - desc, initial_data, texture3d); -#endif + return device->lpVtbl->CreateTexture3D(device, desc, initial_data, texture3d); } - static INLINE HRESULT D3D10CreateShaderResourceViewDevice( D3D10Device device, D3D10Resource resource, D3D10_SHADER_RESOURCE_VIEW_DESC* desc, D3D10ShaderResourceView* srview) { -#ifdef __cplusplus - return device->CreateShaderResourceView( - resource, desc, srview); -#else - return device->lpVtbl->CreateShaderResourceView(device, - resource, desc, srview); -#endif + return device->lpVtbl->CreateShaderResourceView(device, resource, desc, srview); } static INLINE HRESULT D3D10CreateRenderTargetViewDevice( D3D10Device device, @@ -1316,30 +627,16 @@ static INLINE HRESULT D3D10CreateRenderTargetViewDevice( D3D10_RENDER_TARGET_VIEW_DESC* desc, D3D10RenderTargetView* rtview) { -#ifdef __cplusplus - return device->CreateRenderTargetView( - resource, desc, rtview); -#else - return device->lpVtbl->CreateRenderTargetView(device, - resource, desc, rtview); -#endif + return device->lpVtbl->CreateRenderTargetView(device, resource, desc, rtview); } - static INLINE HRESULT D3D10CreateDepthStencilView( D3D10Device device, D3D10Resource resource, D3D10_DEPTH_STENCIL_VIEW_DESC* desc, D3D10DepthStencilView* depth_stencil_view) { -#ifdef __cplusplus - return device->CreateDepthStencilView( - resource, desc, depth_stencil_view); -#else - return device->lpVtbl->CreateDepthStencilView(device, - resource, desc, depth_stencil_view); -#endif + return device->lpVtbl->CreateDepthStencilView(device, resource, desc, depth_stencil_view); } - static INLINE HRESULT D3D10CreateInputLayout( D3D10Device device, D3D10_INPUT_ELEMENT_DESC* input_element_descs, @@ -1348,47 +645,27 @@ static INLINE HRESULT D3D10CreateInputLayout( SIZE_T bytecode_length, D3D10InputLayout* input_layout) { -#ifdef __cplusplus - return device->CreateInputLayout( - input_element_descs, - num_elements, shader_bytecode_with_input_signature, - bytecode_length, input_layout); -#else return device->lpVtbl->CreateInputLayout( - device, input_element_descs, - num_elements, shader_bytecode_with_input_signature, + device, input_element_descs, num_elements, shader_bytecode_with_input_signature, bytecode_length, input_layout); -#endif } - static INLINE HRESULT D3D10CreateVertexShader( D3D10Device device, void* shader_bytecode, SIZE_T bytecode_length, D3D10VertexShader* vertex_shader) { -#ifdef __cplusplus - return device->CreateVertexShader( - shader_bytecode, bytecode_length, vertex_shader); -#else return device->lpVtbl->CreateVertexShader( device, shader_bytecode, bytecode_length, vertex_shader); -#endif } - static INLINE HRESULT D3D10CreateGeometryShader( D3D10Device device, void* shader_bytecode, SIZE_T bytecode_length, D3D10GeometryShader* geometry_shader) { -#ifdef __cplusplus - return device->CreateGeometryShader( - shader_bytecode, bytecode_length, geometry_shader); -#else return device->lpVtbl->CreateGeometryShader( device, shader_bytecode, bytecode_length, geometry_shader); -#endif } static INLINE HRESULT D3D10CreateGeometryShaderWithStreamOutput( D3D10Device device, @@ -1399,158 +676,72 @@ static INLINE HRESULT D3D10CreateGeometryShaderWithStreamOutput( UINT output_stream_stride, D3D10GeometryShader* geometry_shader) { -#ifdef __cplusplus - return device->CreateGeometryShaderWithStreamOutput( - shader_bytecode, bytecode_length, - sodeclaration, num_entries, output_stream_stride, - geometry_shader); -#else return device->lpVtbl->CreateGeometryShaderWithStreamOutput( - device, shader_bytecode, bytecode_length, - sodeclaration, num_entries, output_stream_stride, + device, shader_bytecode, bytecode_length, sodeclaration, num_entries, output_stream_stride, geometry_shader); -#endif } - static INLINE HRESULT D3D10CreatePixelShader( D3D10Device device, void* shader_bytecode, SIZE_T bytecode_length, D3D10PixelShader* pixel_shader) { -#ifdef __cplusplus - return device->CreatePixelShader( - shader_bytecode, bytecode_length, pixel_shader); -#else - return device->lpVtbl->CreatePixelShader(device, - shader_bytecode, bytecode_length, pixel_shader); -#endif + return device->lpVtbl->CreatePixelShader(device, shader_bytecode, bytecode_length, pixel_shader); } - static INLINE HRESULT D3D10CreateBlendState( - D3D10Device device, - D3D10_BLEND_DESC* blend_state_desc, D3D10BlendState* blend_state) + D3D10Device device, D3D10_BLEND_DESC* blend_state_desc, D3D10BlendState* blend_state) { -#ifdef __cplusplus - return device->CreateBlendState( - blend_state_desc, blend_state); -#else - return device->lpVtbl->CreateBlendState(device, - blend_state_desc, blend_state); -#endif + return device->lpVtbl->CreateBlendState(device, blend_state_desc, blend_state); } - static INLINE HRESULT D3D10CreateDepthStencilState( D3D10Device device, D3D10_DEPTH_STENCIL_DESC* depth_stencil_desc, D3D10DepthStencilState* depth_stencil_state) { -#ifdef __cplusplus - return device->CreateDepthStencilState( - depth_stencil_desc, depth_stencil_state); -#else - return device->lpVtbl->CreateDepthStencilState(device, - depth_stencil_desc, depth_stencil_state); -#endif + return device->lpVtbl->CreateDepthStencilState(device, depth_stencil_desc, depth_stencil_state); } - static INLINE HRESULT D3D10CreateRasterizerState( D3D10Device device, D3D10_RASTERIZER_DESC* rasterizer_desc, D3D10RasterizerState* rasterizer_state) { -#ifdef __cplusplus - return device->CreateRasterizerState( - rasterizer_desc, rasterizer_state); -#else - return device->lpVtbl->CreateRasterizerState(device, - rasterizer_desc, rasterizer_state); -#endif + return device->lpVtbl->CreateRasterizerState(device, rasterizer_desc, rasterizer_state); } - static INLINE HRESULT D3D10CreateSamplerState( - D3D10Device device, - D3D10_SAMPLER_DESC* sampler_desc, - D3D10SamplerState* sampler_state) + D3D10Device device, D3D10_SAMPLER_DESC* sampler_desc, D3D10SamplerState* sampler_state) { -#ifdef __cplusplus - return device->CreateSamplerState( - sampler_desc, sampler_state); -#else - return device->lpVtbl->CreateSamplerState(device, - sampler_desc, sampler_state); -#endif + return device->lpVtbl->CreateSamplerState(device, sampler_desc, sampler_state); } - static INLINE HRESULT -D3D10CreateQuery(D3D10Device device, - D3D10_QUERY_DESC* query_desc, D3D10Query* query) +D3D10CreateQuery(D3D10Device device, D3D10_QUERY_DESC* query_desc, D3D10Query* query) { -#ifdef __cplusplus - return device->CreateQuery(query_desc, query); -#else return device->lpVtbl->CreateQuery(device, query_desc, query); -#endif } - static INLINE HRESULT D3D10CreatePredicate( - D3D10Device device, - D3D10_QUERY_DESC* predicate_desc, D3D10Predicate* predicate) + D3D10Device device, D3D10_QUERY_DESC* predicate_desc, D3D10Predicate* predicate) { -#ifdef __cplusplus - return device->CreatePredicate( - predicate_desc, predicate); -#else - return device->lpVtbl->CreatePredicate(device, - predicate_desc, predicate); -#endif + return device->lpVtbl->CreatePredicate(device, predicate_desc, predicate); } - static INLINE HRESULT -D3D10CreateCounter(D3D10Device device, - D3D10_COUNTER_DESC* counter_desc, D3D10Counter* counter) +D3D10CreateCounter(D3D10Device device, D3D10_COUNTER_DESC* counter_desc, D3D10Counter* counter) { -#ifdef __cplusplus - return device->CreateCounter(counter_desc, counter); -#else return device->lpVtbl->CreateCounter(device, counter_desc, counter); -#endif } - static INLINE HRESULT -D3D10CheckFormatSupport(D3D10Device device, - DXGI_FORMAT format, UINT* format_support) +D3D10CheckFormatSupport(D3D10Device device, DXGI_FORMAT format, UINT* format_support) { -#ifdef __cplusplus - return device->CheckFormatSupport(format, format_support); -#else return device->lpVtbl->CheckFormatSupport(device, format, format_support); -#endif } - static INLINE HRESULT D3D10CheckMultisampleQualityLevels( - D3D10Device device, DXGI_FORMAT format, - UINT sample_count, UINT* num_quality_levels) + D3D10Device device, DXGI_FORMAT format, UINT sample_count, UINT* num_quality_levels) { -#ifdef __cplusplus - return device->CheckMultisampleQualityLevels( - format, sample_count, num_quality_levels); -#else return device->lpVtbl->CheckMultisampleQualityLevels( device, format, sample_count, num_quality_levels); -#endif } - -static INLINE void D3D10CheckCounterInfo(D3D10Device device, - D3D10_COUNTER_INFO* counter_info) +static INLINE void D3D10CheckCounterInfo(D3D10Device device, D3D10_COUNTER_INFO* counter_info) { -#ifdef __cplusplus - device->CheckCounterInfo(counter_info); -#else device->lpVtbl->CheckCounterInfo(device, counter_info); -#endif } - static INLINE HRESULT D3D10CheckCounter( D3D10Device device, D3D10_COUNTER_DESC* desc, @@ -1563,448 +754,188 @@ static INLINE HRESULT D3D10CheckCounter( LPSTR sz_description, UINT* description_length) { -#ifdef __cplusplus - return device->CheckCounter( - desc, type, active_counters, - sz_name, name_length, sz_units, units_length, - sz_description, description_length); -#else return device->lpVtbl->CheckCounter( - device, desc, type, active_counters, - sz_name, name_length, sz_units, units_length, + device, desc, type, active_counters, sz_name, name_length, sz_units, units_length, sz_description, description_length); -#endif } - static INLINE UINT D3D10GetCreationFlags(D3D10Device device) { -#ifdef __cplusplus - return device->GetCreationFlags(); -#else return device->lpVtbl->GetCreationFlags(device); -#endif } - static INLINE HRESULT -D3D10OpenSharedResource(D3D10Device device, - HANDLE h_resource, ID3D10Resource** out) +D3D10OpenSharedResource(D3D10Device device, HANDLE h_resource, ID3D10Resource** out) { -#ifdef __cplusplus - return device->OpenSharedResource( - h_resource, uuidof(ID3D10Resource), (void**)out); -#else return device->lpVtbl->OpenSharedResource( device, h_resource, uuidof(ID3D10Resource), (void**)out); -#endif } - -static INLINE void D3D10SetTextFilterSize(D3D10Device device, - UINT width, UINT height) +static INLINE void D3D10SetTextFilterSize(D3D10Device device, UINT width, UINT height) { -#ifdef __cplusplus - device->SetTextFilterSize(width, height); -#else device->lpVtbl->SetTextFilterSize(device, width, height); -#endif } - -static INLINE void D3D10GetTextFilterSize(D3D10Device device, - UINT* width, UINT* height) +static INLINE void D3D10GetTextFilterSize(D3D10Device device, UINT* width, UINT* height) { -#ifdef __cplusplus - device->GetTextFilterSize(width, height); -#else device->lpVtbl->GetTextFilterSize(device, width, height); -#endif } - static INLINE void D3D10Enter(D3D10Multithread multithread) { -#ifdef __cplusplus - multithread->Enter(); -#else multithread->lpVtbl->Enter(multithread); -#endif } - static INLINE void D3D10Leave(D3D10Multithread multithread) { -#ifdef __cplusplus - multithread->Leave(); -#else multithread->lpVtbl->Leave(multithread); -#endif } - -static INLINE BOOL D3D10SetMultithreadProtected( - D3D10Multithread multithread, BOOL mtprotect) +static INLINE BOOL D3D10SetMultithreadProtected(D3D10Multithread multithread, BOOL mtprotect) { -#ifdef __cplusplus - return multithread->SetMultithreadProtected( - mtprotect); -#else - return multithread->lpVtbl->SetMultithreadProtected( - multithread, mtprotect); -#endif + return multithread->lpVtbl->SetMultithreadProtected(multithread, mtprotect); } - -static INLINE BOOL D3D10GetMultithreadProtected( - D3D10Multithread multithread) +static INLINE BOOL D3D10GetMultithreadProtected(D3D10Multithread multithread) { -#ifdef __cplusplus - return multithread->GetMultithreadProtected(); -#else return multithread->lpVtbl->GetMultithreadProtected(multithread); -#endif } - -static INLINE HRESULT D3D10SetDebugFeatureMask( - D3D10Debug debug, UINT mask) +static INLINE HRESULT D3D10SetDebugFeatureMask(D3D10Debug debug, UINT mask) { -#ifdef __cplusplus - return debug->SetFeatureMask(mask); -#else return debug->lpVtbl->SetFeatureMask(debug, mask); -#endif } - static INLINE UINT D3D10GetDebugFeatureMask(D3D10Debug debug) { -#ifdef __cplusplus - return debug->GetFeatureMask(); -#else return debug->lpVtbl->GetFeatureMask(debug); -#endif } - -static INLINE HRESULT D3D10SetPresentPerRenderOpDelay( - D3D10Debug debug, UINT milliseconds) +static INLINE HRESULT D3D10SetPresentPerRenderOpDelay(D3D10Debug debug, UINT milliseconds) { -#ifdef __cplusplus - return debug->SetPresentPerRenderOpDelay(milliseconds); -#else return debug->lpVtbl->SetPresentPerRenderOpDelay(debug, milliseconds); -#endif } - static INLINE UINT D3D10GetPresentPerRenderOpDelay(D3D10Debug debug) { -#ifdef __cplusplus - return debug->GetPresentPerRenderOpDelay(); -#else return debug->lpVtbl->GetPresentPerRenderOpDelay(debug); -#endif } - -static INLINE HRESULT D3D10SetSwapChain(D3D10Debug debug, - IDXGISwapChain* swap_chain) +static INLINE HRESULT D3D10SetSwapChain(D3D10Debug debug, IDXGISwapChain* swap_chain) { -#ifdef __cplusplus - return debug->SetSwapChain((IDXGISwapChain*)swap_chain); -#else return debug->lpVtbl->SetSwapChain(debug, (IDXGISwapChain*)swap_chain); -#endif } - -static INLINE HRESULT D3D10GetSwapChain(D3D10Debug debug, - IDXGISwapChain** swap_chain) +static INLINE HRESULT D3D10GetSwapChain(D3D10Debug debug, IDXGISwapChain** swap_chain) { -#ifdef __cplusplus - return debug->GetSwapChain((IDXGISwapChain**)swap_chain); -#else return debug->lpVtbl->GetSwapChain(debug, (IDXGISwapChain**)swap_chain); -#endif } - -static INLINE HRESULT D3D10Validate(D3D10Debug debug) +static INLINE HRESULT D3D10Validate(D3D10Debug debug) { return debug->lpVtbl->Validate(debug); } +static INLINE BOOL D3D10SetUseRef(D3D10SwitchToRef switch_to_ref, BOOL use_ref) { -#ifdef __cplusplus - return debug->Validate(); -#else - return debug->lpVtbl->Validate(debug); -#endif -} - -static INLINE BOOL D3D10SetUseRef(D3D10SwitchToRef switch_to_ref, - BOOL use_ref) -{ -#ifdef __cplusplus - return switch_to_ref->SetUseRef(use_ref); -#else return switch_to_ref->lpVtbl->SetUseRef(switch_to_ref, use_ref); -#endif } - static INLINE BOOL D3D10GetUseRef(D3D10SwitchToRef switch_to_ref) { -#ifdef __cplusplus - return switch_to_ref->GetUseRef(); -#else return switch_to_ref->lpVtbl->GetUseRef(switch_to_ref); -#endif } - static INLINE HRESULT -D3D10SetMessageCountLimit(D3D10InfoQueue info_queue, - UINT64 message_count_limit) +D3D10SetMessageCountLimit(D3D10InfoQueue info_queue, UINT64 message_count_limit) { -#ifdef __cplusplus - return info_queue->SetMessageCountLimit( - message_count_limit); -#else - return info_queue->lpVtbl->SetMessageCountLimit(info_queue, - message_count_limit); -#endif + return info_queue->lpVtbl->SetMessageCountLimit(info_queue, message_count_limit); } - static INLINE void D3D10ClearStoredMessages(D3D10InfoQueue info_queue) { -#ifdef __cplusplus - info_queue->ClearStoredMessages(); -#else info_queue->lpVtbl->ClearStoredMessages(info_queue); -#endif } - static INLINE HRESULT D3D10GetMessageA( D3D10InfoQueue info_queue, UINT64 message_index, D3D10_MESSAGE* message, SIZE_T* message_byte_length) { -#ifdef __cplusplus - return info_queue->GetMessageA( - message_index, message, message_byte_length); -#else - return info_queue->lpVtbl->GetMessageA(info_queue, - message_index, message, message_byte_length); -#endif + return info_queue->lpVtbl->GetMessageA(info_queue, message_index, message, message_byte_length); } - -static INLINE UINT64 D3D10GetNumMessagesAllowedByStorageFilter( - D3D10InfoQueue info_queue) +static INLINE UINT64 D3D10GetNumMessagesAllowedByStorageFilter(D3D10InfoQueue info_queue) { -#ifdef __cplusplus - return info_queue->GetNumMessagesAllowedByStorageFilter(); -#else - return info_queue->lpVtbl->GetNumMessagesAllowedByStorageFilter( - info_queue); -#endif + return info_queue->lpVtbl->GetNumMessagesAllowedByStorageFilter(info_queue); } - -static INLINE UINT64 D3D10GetNumMessagesDeniedByStorageFilter( - D3D10InfoQueue info_queue) +static INLINE UINT64 D3D10GetNumMessagesDeniedByStorageFilter(D3D10InfoQueue info_queue) { -#ifdef __cplusplus - return info_queue->GetNumMessagesDeniedByStorageFilter(); -#else - return info_queue->lpVtbl->GetNumMessagesDeniedByStorageFilter( - info_queue); -#endif + return info_queue->lpVtbl->GetNumMessagesDeniedByStorageFilter(info_queue); } - static INLINE UINT64 D3D10GetNumStoredMessages(D3D10InfoQueue info_queue) { -#ifdef __cplusplus - return info_queue->GetNumStoredMessages(); -#else return info_queue->lpVtbl->GetNumStoredMessages(info_queue); -#endif } - -static INLINE UINT64 D3D10GetNumStoredMessagesAllowedByRetrievalFilter( - D3D10InfoQueue info_queue) +static INLINE UINT64 D3D10GetNumStoredMessagesAllowedByRetrievalFilter(D3D10InfoQueue info_queue) { -#ifdef __cplusplus - return info_queue->GetNumStoredMessagesAllowedByRetrievalFilter(); -#else - return info_queue->lpVtbl->GetNumStoredMessagesAllowedByRetrievalFilter( - info_queue); -#endif + return info_queue->lpVtbl->GetNumStoredMessagesAllowedByRetrievalFilter(info_queue); } - -static INLINE UINT64 D3D10GetNumMessagesDiscardedByMessageCountLimit( - D3D10InfoQueue info_queue) +static INLINE UINT64 D3D10GetNumMessagesDiscardedByMessageCountLimit(D3D10InfoQueue info_queue) { -#ifdef __cplusplus - return info_queue->GetNumMessagesDiscardedByMessageCountLimit(); -#else - return info_queue->lpVtbl->GetNumMessagesDiscardedByMessageCountLimit( - info_queue); -#endif + return info_queue->lpVtbl->GetNumMessagesDiscardedByMessageCountLimit(info_queue); } - static INLINE UINT64 D3D10GetMessageCountLimit(D3D10InfoQueue info_queue) { -#ifdef __cplusplus - return info_queue->GetMessageCountLimit(); -#else return info_queue->lpVtbl->GetMessageCountLimit(info_queue); -#endif } - static INLINE HRESULT -D3D10AddStorageFilterEntries(D3D10InfoQueue info_queue, - D3D10_INFO_QUEUE_FILTER* filter) +D3D10AddStorageFilterEntries(D3D10InfoQueue info_queue, D3D10_INFO_QUEUE_FILTER* filter) { -#ifdef __cplusplus - return info_queue->AddStorageFilterEntries(filter); -#else return info_queue->lpVtbl->AddStorageFilterEntries(info_queue, filter); -#endif } - static INLINE HRESULT D3D10GetStorageFilter( - D3D10InfoQueue info_queue, - D3D10_INFO_QUEUE_FILTER* filter, SIZE_T* filter_byte_length) + D3D10InfoQueue info_queue, D3D10_INFO_QUEUE_FILTER* filter, SIZE_T* filter_byte_length) { -#ifdef __cplusplus - return info_queue->GetStorageFilter( - filter, filter_byte_length); -#else - return info_queue->lpVtbl->GetStorageFilter( - info_queue, filter, filter_byte_length); -#endif + return info_queue->lpVtbl->GetStorageFilter(info_queue, filter, filter_byte_length); } - static INLINE void D3D10ClearStorageFilter(D3D10InfoQueue info_queue) { -#ifdef __cplusplus - info_queue->ClearStorageFilter(); -#else info_queue->lpVtbl->ClearStorageFilter(info_queue); -#endif } - static INLINE HRESULT D3D10PushEmptyStorageFilter(D3D10InfoQueue info_queue) { -#ifdef __cplusplus - return info_queue->PushEmptyStorageFilter(); -#else return info_queue->lpVtbl->PushEmptyStorageFilter(info_queue); -#endif } - static INLINE HRESULT D3D10PushCopyOfStorageFilter(D3D10InfoQueue info_queue) { -#ifdef __cplusplus - return info_queue->PushCopyOfStorageFilter(); -#else return info_queue->lpVtbl->PushCopyOfStorageFilter(info_queue); -#endif } - static INLINE HRESULT -D3D10PushStorageFilter(D3D10InfoQueue info_queue, - D3D10_INFO_QUEUE_FILTER* filter) +D3D10PushStorageFilter(D3D10InfoQueue info_queue, D3D10_INFO_QUEUE_FILTER* filter) { -#ifdef __cplusplus - return info_queue->PushStorageFilter(filter); -#else return info_queue->lpVtbl->PushStorageFilter(info_queue, filter); -#endif } - static INLINE void D3D10PopStorageFilter(D3D10InfoQueue info_queue) { -#ifdef __cplusplus - info_queue->PopStorageFilter(); -#else info_queue->lpVtbl->PopStorageFilter(info_queue); -#endif } - static INLINE UINT D3D10GetStorageFilterStackSize(D3D10InfoQueue info_queue) { -#ifdef __cplusplus - return info_queue->GetStorageFilterStackSize(); -#else return info_queue->lpVtbl->GetStorageFilterStackSize(info_queue); -#endif } - static INLINE HRESULT -D3D10AddRetrievalFilterEntries(D3D10InfoQueue info_queue, - D3D10_INFO_QUEUE_FILTER* filter) +D3D10AddRetrievalFilterEntries(D3D10InfoQueue info_queue, D3D10_INFO_QUEUE_FILTER* filter) { -#ifdef __cplusplus - return info_queue->AddRetrievalFilterEntries(filter); -#else return info_queue->lpVtbl->AddRetrievalFilterEntries(info_queue, filter); -#endif } - static INLINE HRESULT D3D10GetRetrievalFilter( - D3D10InfoQueue info_queue, - D3D10_INFO_QUEUE_FILTER* filter, SIZE_T* filter_byte_length) + D3D10InfoQueue info_queue, D3D10_INFO_QUEUE_FILTER* filter, SIZE_T* filter_byte_length) { -#ifdef __cplusplus - return info_queue->GetRetrievalFilter( - filter, filter_byte_length); -#else - return info_queue->lpVtbl->GetRetrievalFilter(info_queue, - filter, filter_byte_length); -#endif + return info_queue->lpVtbl->GetRetrievalFilter(info_queue, filter, filter_byte_length); } - static INLINE void D3D10ClearRetrievalFilter(D3D10InfoQueue info_queue) { -#ifdef __cplusplus - info_queue->ClearRetrievalFilter(); -#else info_queue->lpVtbl->ClearRetrievalFilter(info_queue); -#endif } - -static INLINE HRESULT D3D10PushEmptyRetrievalFilter( - D3D10InfoQueue info_queue) +static INLINE HRESULT D3D10PushEmptyRetrievalFilter(D3D10InfoQueue info_queue) { -#ifdef __cplusplus - return info_queue->PushEmptyRetrievalFilter(); -#else return info_queue->lpVtbl->PushEmptyRetrievalFilter(info_queue); -#endif } - -static INLINE HRESULT D3D10PushCopyOfRetrievalFilter( - D3D10InfoQueue info_queue) +static INLINE HRESULT D3D10PushCopyOfRetrievalFilter(D3D10InfoQueue info_queue) { -#ifdef __cplusplus - return info_queue->PushCopyOfRetrievalFilter(); -#else return info_queue->lpVtbl->PushCopyOfRetrievalFilter(info_queue); -#endif } - static INLINE HRESULT -D3D10PushRetrievalFilter(D3D10InfoQueue info_queue, - D3D10_INFO_QUEUE_FILTER* filter) +D3D10PushRetrievalFilter(D3D10InfoQueue info_queue, D3D10_INFO_QUEUE_FILTER* filter) { -#ifdef __cplusplus - return info_queue->PushRetrievalFilter(filter); -#else return info_queue->lpVtbl->PushRetrievalFilter(info_queue, filter); -#endif } - static INLINE void D3D10PopRetrievalFilter(D3D10InfoQueue info_queue) { -#ifdef __cplusplus - info_queue->PopRetrievalFilter(); -#else info_queue->lpVtbl->PopRetrievalFilter(info_queue); -#endif } - static INLINE UINT D3D10GetRetrievalFilterStackSize(D3D10InfoQueue info_queue) { -#ifdef __cplusplus - return info_queue->GetRetrievalFilterStackSize(); -#else return info_queue->lpVtbl->GetRetrievalFilterStackSize(info_queue); -#endif } - static INLINE HRESULT D3D10AddMessage( D3D10InfoQueue info_queue, D3D10_MESSAGE_CATEGORY category, @@ -2012,129 +943,57 @@ static INLINE HRESULT D3D10AddMessage( D3D10_MESSAGE_ID id, LPCSTR description) { -#ifdef __cplusplus - return info_queue->AddMessage( - category, severity, id, description); -#else - return info_queue->lpVtbl->AddMessage(info_queue, - category, severity, id, description); -#endif + return info_queue->lpVtbl->AddMessage(info_queue, category, severity, id, description); } - static INLINE HRESULT D3D10AddApplicationMessage( - D3D10InfoQueue info_queue, - D3D10_MESSAGE_SEVERITY severity, LPCSTR description) + D3D10InfoQueue info_queue, D3D10_MESSAGE_SEVERITY severity, LPCSTR description) { -#ifdef __cplusplus - return info_queue->AddApplicationMessage( - severity, description); -#else - return info_queue->lpVtbl->AddApplicationMessage( - info_queue, severity, description); -#endif + return info_queue->lpVtbl->AddApplicationMessage(info_queue, severity, description); } - static INLINE HRESULT -D3D10SetBreakOnCategory(D3D10InfoQueue info_queue, - D3D10_MESSAGE_CATEGORY category, BOOL enable) +D3D10SetBreakOnCategory(D3D10InfoQueue info_queue, D3D10_MESSAGE_CATEGORY category, BOOL enable) { -#ifdef __cplusplus - return info_queue->SetBreakOnCategory( - category, enable); -#else - return info_queue->lpVtbl->SetBreakOnCategory( - info_queue, category, enable); -#endif + return info_queue->lpVtbl->SetBreakOnCategory(info_queue, category, enable); } - static INLINE HRESULT -D3D10SetBreakOnSeverity(D3D10InfoQueue info_queue, - D3D10_MESSAGE_SEVERITY severity, BOOL enable) +D3D10SetBreakOnSeverity(D3D10InfoQueue info_queue, D3D10_MESSAGE_SEVERITY severity, BOOL enable) { -#ifdef __cplusplus - return info_queue->SetBreakOnSeverity(severity, enable); -#else - return info_queue->lpVtbl->SetBreakOnSeverity(info_queue, - severity, enable); -#endif + return info_queue->lpVtbl->SetBreakOnSeverity(info_queue, severity, enable); } - -static INLINE HRESULT D3D10SetBreakOnID(D3D10InfoQueue info_queue, - D3D10_MESSAGE_ID id, BOOL enable) +static INLINE HRESULT D3D10SetBreakOnID(D3D10InfoQueue info_queue, D3D10_MESSAGE_ID id, BOOL enable) { -#ifdef __cplusplus - return info_queue->SetBreakOnID(id, enable); -#else return info_queue->lpVtbl->SetBreakOnID(info_queue, id, enable); -#endif } - static INLINE BOOL -D3D10GetBreakOnCategory(D3D10InfoQueue info_queue, - D3D10_MESSAGE_CATEGORY category) +D3D10GetBreakOnCategory(D3D10InfoQueue info_queue, D3D10_MESSAGE_CATEGORY category) { -#ifdef __cplusplus - return info_queue->GetBreakOnCategory(category); -#else return info_queue->lpVtbl->GetBreakOnCategory(info_queue, category); -#endif } - static INLINE BOOL -D3D10GetBreakOnSeverity(D3D10InfoQueue info_queue, - D3D10_MESSAGE_SEVERITY severity) +D3D10GetBreakOnSeverity(D3D10InfoQueue info_queue, D3D10_MESSAGE_SEVERITY severity) { -#ifdef __cplusplus - return info_queue->GetBreakOnSeverity(severity); -#else return info_queue->lpVtbl->GetBreakOnSeverity(info_queue, severity); -#endif } - -static INLINE BOOL D3D10GetBreakOnID(D3D10InfoQueue info_queue, - D3D10_MESSAGE_ID id) +static INLINE BOOL D3D10GetBreakOnID(D3D10InfoQueue info_queue, D3D10_MESSAGE_ID id) { -#ifdef __cplusplus - return info_queue->GetBreakOnID(id); -#else return info_queue->lpVtbl->GetBreakOnID(info_queue, id); -#endif } - -static INLINE void D3D10SetMuteDebugOutput( - D3D10InfoQueue info_queue, BOOL mute) +static INLINE void D3D10SetMuteDebugOutput(D3D10InfoQueue info_queue, BOOL mute) { -#ifdef __cplusplus - info_queue->SetMuteDebugOutput(mute); -#else info_queue->lpVtbl->SetMuteDebugOutput(info_queue, mute); -#endif } - static INLINE BOOL D3D10GetMuteDebugOutput(D3D10InfoQueue info_queue) { -#ifdef __cplusplus - return info_queue->GetMuteDebugOutput(); -#else return info_queue->lpVtbl->GetMuteDebugOutput(info_queue); -#endif } /* end of auto-generated */ static INLINE HRESULT -DXGIGetSwapChainBufferD3D10(DXGISwapChain swap_chain, UINT buffer, - D3D10Texture2D* out) +DXGIGetSwapChainBufferD3D10(DXGISwapChain swap_chain, UINT buffer, D3D10Texture2D* out) { -#ifdef __cplusplus - return swap_chain->GetBuffer(buffer, - uuidof(ID3D10Texture2D), (void**)out); -#else - return swap_chain->lpVtbl->GetBuffer(swap_chain, buffer, - uuidof(ID3D10Texture2D), (void**)out); -#endif + return swap_chain->lpVtbl->GetBuffer(swap_chain, buffer, uuidof(ID3D10Texture2D), (void**)out); } - static INLINE void D3D10CopyTexture2DSubresourceRegion( D3D10Device device, D3D10Texture2D dst_texture, @@ -2146,17 +1005,9 @@ static INLINE void D3D10CopyTexture2DSubresourceRegion( UINT src_subresource, D3D10_BOX* src_box) { -#ifdef __cplusplus - device->CopySubresourceRegion( - (D3D10Resource)dst_texture, - dst_subresource, dst_x, dst_y, dst_z, - (D3D10Resource)src_texture, src_subresource, src_box); -#else device->lpVtbl->CopySubresourceRegion( - device, (D3D10Resource)dst_texture, - dst_subresource, dst_x, dst_y, dst_z, + device, (D3D10Resource)dst_texture, dst_subresource, dst_x, dst_y, dst_z, (D3D10Resource)src_texture, src_subresource, src_box); -#endif } static INLINE HRESULT D3D10CreateTexture2DRenderTargetView( D3D10Device device, @@ -2164,13 +1015,7 @@ static INLINE HRESULT D3D10CreateTexture2DRenderTargetView( D3D10_RENDER_TARGET_VIEW_DESC* desc, D3D10RenderTargetView* rtview) { -#ifdef __cplusplus - return device->CreateRenderTargetView( - (D3D10Resource)texture, desc, rtview); -#else - return device->lpVtbl->CreateRenderTargetView(device, - (D3D10Resource)texture, desc, rtview); -#endif + return device->lpVtbl->CreateRenderTargetView(device, (D3D10Resource)texture, desc, rtview); } static INLINE HRESULT D3D10CreateTexture2DShaderResourceView( D3D10Device device, @@ -2178,15 +1023,9 @@ static INLINE HRESULT D3D10CreateTexture2DShaderResourceView( D3D10_SHADER_RESOURCE_VIEW_DESC* desc, D3D10ShaderResourceView* srview) { -#ifdef __cplusplus - return device->CreateShaderResourceView((D3D10Resource)texture, - desc, srview); -#else - return device->lpVtbl->CreateShaderResourceView(device, - (D3D10Resource)texture, desc, srview); -#endif + return device->lpVtbl->CreateShaderResourceView(device, (D3D10Resource)texture, desc, srview); } - +#endif /* internal */ #include diff --git a/gfx/common/d3d11_common.c b/gfx/common/d3d11_common.c index 29db2222f5..18484b3bb1 100644 --- a/gfx/common/d3d11_common.c +++ b/gfx/common/d3d11_common.c @@ -13,6 +13,8 @@ * If not, see . */ +#define CINTERFACE + #include #include "d3d11_common.h" @@ -122,9 +124,9 @@ void d3d11_init_texture(D3D11Device device, d3d11_texture_t* texture) void d3d11_update_texture( D3D11DeviceContext ctx, - int width, - int height, - int pitch, + unsigned width, + unsigned height, + unsigned pitch, DXGI_FORMAT format, const void* data, d3d11_texture_t* texture) diff --git a/gfx/common/d3d11_common.h b/gfx/common/d3d11_common.h index 1ef9d08002..0e7f72538c 100644 --- a/gfx/common/d3d11_common.h +++ b/gfx/common/d3d11_common.h @@ -18,6 +18,9 @@ #include #include "dxgi_common.h" +#ifdef CINTERFACE +#define D3D11_NO_HELPERS +#endif #include typedef const ID3D11ShaderResourceView* D3D11ShaderResourceViewRef; @@ -2578,9 +2581,9 @@ static INLINE void d3d11_release_texture(d3d11_texture_t* texture) void d3d11_update_texture( D3D11DeviceContext ctx, - int width, - int height, - int pitch, + unsigned width, + unsigned height, + unsigned pitch, DXGI_FORMAT format, const void* data, d3d11_texture_t* texture); diff --git a/gfx/common/d3d12_common.c b/gfx/common/d3d12_common.c index a92986b5c2..ac2b82f636 100644 --- a/gfx/common/d3d12_common.c +++ b/gfx/common/d3d12_common.c @@ -13,6 +13,8 @@ * If not, see . */ +#define CINTERFACE + #include "d3d12_common.h" #include "dxgi_common.h" #include "d3dcompiler_common.h" @@ -25,7 +27,11 @@ #ifdef __MINGW32__ /* clang-format off */ +#ifdef __cplusplus +#define DEFINE_GUIDW(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) EXTERN_C const GUID DECLSPEC_SELECTANY name = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } +#else #define DEFINE_GUIDW(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) const GUID DECLSPEC_SELECTANY name = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } +#endif DEFINE_GUIDW(IID_ID3D12PipelineState, 0x765a30f3, 0xf624, 0x4c6f, 0xa8, 0x28, 0xac, 0xe9, 0x48, 0x62, 0x24, 0x45); DEFINE_GUIDW(IID_ID3D12RootSignature, 0xc54a6b66, 0x72df, 0x4ee8, 0x8b, 0xe5, 0xa9, 0x46, 0xa1, 0x42, 0x92, 0x14); @@ -64,7 +70,7 @@ static const char* d3d12_dll_name = "d3d12.dll"; HRESULT WINAPI D3D12CreateDevice( IUnknown* pAdapter, D3D_FEATURE_LEVEL MinimumFeatureLevel, REFIID riid, void** ppDevice) { - static PFN_D3D12_CREATE_DEVICE fp; + static PFN_D3D12_CREATE_DEVICE fp; if (!d3d12_dll) d3d12_dll = dylib_load(d3d12_dll_name); @@ -75,7 +81,7 @@ HRESULT WINAPI D3D12CreateDevice( fp = (PFN_D3D12_CREATE_DEVICE)dylib_proc(d3d12_dll, "D3D12CreateDevice"); if (fp) - return fp(pAdapter, MinimumFeatureLevel, riid, ppDevice); + return fp(pAdapter, MinimumFeatureLevel, riid, ppDevice); error: return TYPE_E_CANTLOADLIBRARY; @@ -88,13 +94,13 @@ HRESULT WINAPI D3D12GetDebugInterface(REFIID riid, void** ppvDebug) d3d12_dll = dylib_load(d3d12_dll_name); if (!d3d12_dll) - goto error; + goto error; if (!fp) fp = (PFN_D3D12_GET_DEBUG_INTERFACE)dylib_proc(d3d12_dll, "D3D12GetDebugInterface"); - if (fp) - return fp(riid, ppvDebug); + if (fp) + return fp(riid, ppvDebug); error: return TYPE_E_CANTLOADLIBRARY; @@ -114,8 +120,7 @@ HRESULT WINAPI D3D12SerializeRootSignature( goto error; if (!fp) - fp = (PFN_D3D12_SERIALIZE_ROOT_SIGNATURE)dylib_proc( - d3d12_dll, "D3D12SerializeRootSignature"); + fp = (PFN_D3D12_SERIALIZE_ROOT_SIGNATURE)dylib_proc(d3d12_dll, "D3D12SerializeRootSignature"); if (fp) return fp(pRootSignature, Version, ppBlob, ppErrorBlob); @@ -138,10 +143,10 @@ HRESULT WINAPI D3D12SerializeVersionedRootSignature( if (!fp) fp = (PFN_D3D12_SERIALIZE_VERSIONED_ROOT_SIGNATURE)dylib_proc( - d3d12_dll, "D3D12SerializeRootSignature"); + d3d12_dll, "D3D12SerializeRootSignature"); if (fp) - return fp(pRootSignature, ppBlob, ppErrorBlob); + return fp(pRootSignature, ppBlob, ppErrorBlob); error: return TYPE_E_CANTLOADLIBRARY; @@ -179,10 +184,8 @@ bool d3d12_init_base(d3d12_video_t* d3d12) bool d3d12_init_queue(d3d12_video_t* d3d12) { { - static const D3D12_COMMAND_QUEUE_DESC desc = { - .Type = D3D12_COMMAND_LIST_TYPE_DIRECT, - .Flags = D3D12_COMMAND_QUEUE_FLAG_NONE, - }; + static const D3D12_COMMAND_QUEUE_DESC desc = { D3D12_COMMAND_LIST_TYPE_DIRECT, 0, + D3D12_COMMAND_QUEUE_FLAG_NONE, 0 }; D3D12CreateCommandQueue( d3d12->device, (D3D12_COMMAND_QUEUE_DESC*)&desc, &d3d12->queue.handle); } @@ -206,26 +209,25 @@ bool d3d12_init_queue(d3d12_video_t* d3d12) bool d3d12_init_swapchain(d3d12_video_t* d3d12, int width, int height, HWND hwnd) { { - DXGI_SWAP_CHAIN_DESC desc = { - .BufferCount = countof(d3d12->chain.renderTargets), - .BufferDesc.Width = width, - .BufferDesc.Height = height, - .BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM, - .SampleDesc.Count = 1, + DXGI_SWAP_CHAIN_DESC desc = { 0 }; + desc.BufferCount = countof(d3d12->chain.renderTargets); + desc.BufferDesc.Width = width; + desc.BufferDesc.Height = height; + desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + desc.SampleDesc.Count = 1; #if 0 - .BufferDesc.RefreshRate.Numerator = 60, - .BufferDesc.RefreshRate.Denominator = 1, - .SampleDesc.Quality = 0, + desc.BufferDesc.RefreshRate.Numerator = 60; + desc.BufferDesc.RefreshRate.Denominator = 1; + desc.SampleDesc.Quality = 0; #endif - .BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT, - .OutputWindow = hwnd, - .Windowed = TRUE, + desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; + desc.OutputWindow = hwnd; + desc.Windowed = TRUE; #if 0 - .SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL, + desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; #else - .SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD, + desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD; #endif - }; DXGICreateSwapChain(d3d12->factory, d3d12->queue.handle, &desc, &d3d12->chain.handle); } @@ -285,7 +287,7 @@ static void d3d12_init_sampler( bool d3d12_init_descriptors(d3d12_video_t* d3d12) { - D3D12_ROOT_SIGNATURE_DESC desc; + D3D12_ROOT_SIGNATURE_DESC desc; static const D3D12_DESCRIPTOR_RANGE srv_table[] = { { .RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV, @@ -308,30 +310,22 @@ bool d3d12_init_descriptors(d3d12_video_t* d3d12) }, }; - D3D12_ROOT_PARAMETER rootParameters[ROOT_INDEX_MAX] = { - { - D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE, - {{0}}, - D3D12_SHADER_VISIBILITY_PIXEL, - }, - { - D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE, - {{0}}, - D3D12_SHADER_VISIBILITY_PIXEL, - }, - { - D3D12_ROOT_PARAMETER_TYPE_CBV, - {{0}}, - D3D12_SHADER_VISIBILITY_VERTEX, - } - }; + D3D12_ROOT_PARAMETER rootParameters[ROOT_ID_MAX] = {}; - rootParameters[0].DescriptorTable.NumDescriptorRanges = countof(srv_table); - rootParameters[0].DescriptorTable.pDescriptorRanges = srv_table; - rootParameters[1].DescriptorTable.NumDescriptorRanges = countof(sampler_table); - rootParameters[1].DescriptorTable.pDescriptorRanges = sampler_table; - rootParameters[2].Descriptor.RegisterSpace = 0; - rootParameters[2].Descriptor.ShaderRegister = 0; + rootParameters[ROOT_ID_TEXTURE_T].ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; + rootParameters[ROOT_ID_TEXTURE_T].DescriptorTable.NumDescriptorRanges = countof(srv_table); + rootParameters[ROOT_ID_TEXTURE_T].DescriptorTable.pDescriptorRanges = srv_table; + rootParameters[ROOT_ID_TEXTURE_T].ShaderVisibility = D3D12_SHADER_VISIBILITY_PIXEL; + + rootParameters[ROOT_ID_SAMPLER_T].ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; + rootParameters[ROOT_ID_SAMPLER_T].DescriptorTable.NumDescriptorRanges = countof(sampler_table); + rootParameters[ROOT_ID_SAMPLER_T].DescriptorTable.pDescriptorRanges = sampler_table; + rootParameters[ROOT_ID_SAMPLER_T].ShaderVisibility = D3D12_SHADER_VISIBILITY_PIXEL; + + rootParameters[ROOT_ID_UBO].ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV; + rootParameters[ROOT_ID_UBO].Descriptor.RegisterSpace = 0; + rootParameters[ROOT_ID_UBO].Descriptor.ShaderRegister = 0; + rootParameters[ROOT_ID_UBO].ShaderVisibility = D3D12_SHADER_VISIBILITY_VERTEX; desc.NumParameters = countof(rootParameters); desc.pParameters = rootParameters; @@ -417,24 +411,6 @@ bool d3d12_init_pipeline(d3d12_video_t* d3d12) .ConservativeRaster = D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF, }; - static const D3D12_BLEND_DESC blendDesc = { - .AlphaToCoverageEnable = FALSE, - .IndependentBlendEnable = FALSE, - .RenderTarget[0] = - { - .BlendEnable = TRUE, - .LogicOpEnable = FALSE, - D3D12_BLEND_SRC_ALPHA, - D3D12_BLEND_INV_SRC_ALPHA, - D3D12_BLEND_OP_ADD, - D3D12_BLEND_SRC_ALPHA, - D3D12_BLEND_INV_SRC_ALPHA, - D3D12_BLEND_OP_ADD, - D3D12_LOGIC_OP_NOOP, - D3D12_COLOR_WRITE_ENABLE_ALL, - }, - }; - if (!d3d_compile(stock, sizeof(stock), NULL, "VSMain", "vs_5_0", &vs_code)) return false; @@ -442,48 +418,44 @@ bool d3d12_init_pipeline(d3d12_video_t* d3d12) return false; { - D3D12_GRAPHICS_PIPELINE_STATE_DESC psodesc = { - .pRootSignature = d3d12->pipe.rootSignature, - .VS.pShaderBytecode = D3DGetBufferPointer(vs_code), - .VS.BytecodeLength = D3DGetBufferSize(vs_code), - .PS.pShaderBytecode = D3DGetBufferPointer(ps_code), - .PS.BytecodeLength = D3DGetBufferSize(ps_code), - .BlendState.AlphaToCoverageEnable = FALSE, - .BlendState.IndependentBlendEnable = FALSE, - .BlendState.RenderTarget[0] = - { - .BlendEnable = TRUE, - .LogicOpEnable = FALSE, - D3D12_BLEND_SRC_ALPHA, - D3D12_BLEND_INV_SRC_ALPHA, - D3D12_BLEND_OP_ADD, - D3D12_BLEND_SRC_ALPHA, - D3D12_BLEND_INV_SRC_ALPHA, - D3D12_BLEND_OP_ADD, - D3D12_LOGIC_OP_NOOP, - D3D12_COLOR_WRITE_ENABLE_ALL, - }, - .SampleMask = UINT_MAX, - .RasterizerState.FillMode = D3D12_FILL_MODE_SOLID, - .RasterizerState.CullMode = D3D12_CULL_MODE_BACK, - .RasterizerState.FrontCounterClockwise = FALSE, - .RasterizerState.DepthBias = D3D12_DEFAULT_DEPTH_BIAS, - .RasterizerState.DepthBiasClamp = D3D12_DEFAULT_DEPTH_BIAS_CLAMP, - .RasterizerState.SlopeScaledDepthBias = D3D12_DEFAULT_SLOPE_SCALED_DEPTH_BIAS, - .RasterizerState.DepthClipEnable = TRUE, - .RasterizerState.MultisampleEnable = FALSE, - .RasterizerState.AntialiasedLineEnable = FALSE, - .RasterizerState.ForcedSampleCount = 0, - .RasterizerState.ConservativeRaster = D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF, - .DepthStencilState.DepthEnable = FALSE, - .DepthStencilState.StencilEnable = FALSE, - .InputLayout.pInputElementDescs = inputElementDesc, - .InputLayout.NumElements = countof(inputElementDesc), - .PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE, - .NumRenderTargets = 1, - .RTVFormats[0] = DXGI_FORMAT_R8G8B8A8_UNORM, - .SampleDesc.Count = 1, - }; + D3D12_GRAPHICS_PIPELINE_STATE_DESC psodesc = { 0 }; + psodesc.pRootSignature = d3d12->pipe.rootSignature; + psodesc.VS.pShaderBytecode = D3DGetBufferPointer(vs_code); + psodesc.VS.BytecodeLength = D3DGetBufferSize(vs_code); + psodesc.PS.pShaderBytecode = D3DGetBufferPointer(ps_code); + psodesc.PS.BytecodeLength = D3DGetBufferSize(ps_code); + psodesc.BlendState.AlphaToCoverageEnable = FALSE; + psodesc.BlendState.IndependentBlendEnable = FALSE; + psodesc.BlendState.RenderTarget[0].BlendEnable = TRUE; + psodesc.BlendState.RenderTarget[0].LogicOpEnable = FALSE; + psodesc.BlendState.RenderTarget[0].SrcBlend = D3D12_BLEND_SRC_ALPHA; + psodesc.BlendState.RenderTarget[0].DestBlend = D3D12_BLEND_INV_SRC_ALPHA; + psodesc.BlendState.RenderTarget[0].BlendOp = D3D12_BLEND_OP_ADD; + psodesc.BlendState.RenderTarget[0].SrcBlendAlpha = D3D12_BLEND_SRC_ALPHA; + psodesc.BlendState.RenderTarget[0].DestBlendAlpha = D3D12_BLEND_INV_SRC_ALPHA; + psodesc.BlendState.RenderTarget[0].BlendOpAlpha = D3D12_BLEND_OP_ADD; + psodesc.BlendState.RenderTarget[0].LogicOp = D3D12_LOGIC_OP_NOOP; + psodesc.BlendState.RenderTarget[0].RenderTargetWriteMask = D3D12_COLOR_WRITE_ENABLE_ALL; + psodesc.SampleMask = UINT_MAX; + psodesc.RasterizerState.FillMode = D3D12_FILL_MODE_SOLID; + psodesc.RasterizerState.CullMode = D3D12_CULL_MODE_BACK; + psodesc.RasterizerState.FrontCounterClockwise = FALSE; + psodesc.RasterizerState.DepthBias = D3D12_DEFAULT_DEPTH_BIAS; + psodesc.RasterizerState.DepthBiasClamp = D3D12_DEFAULT_DEPTH_BIAS_CLAMP; + psodesc.RasterizerState.SlopeScaledDepthBias = D3D12_DEFAULT_SLOPE_SCALED_DEPTH_BIAS; + psodesc.RasterizerState.DepthClipEnable = TRUE; + psodesc.RasterizerState.MultisampleEnable = FALSE; + psodesc.RasterizerState.AntialiasedLineEnable = FALSE; + psodesc.RasterizerState.ForcedSampleCount = 0; + psodesc.RasterizerState.ConservativeRaster = D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF; + psodesc.DepthStencilState.DepthEnable = FALSE; + psodesc.DepthStencilState.StencilEnable = FALSE; + psodesc.InputLayout.pInputElementDescs = inputElementDesc; + psodesc.InputLayout.NumElements = countof(inputElementDesc); + psodesc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; + psodesc.NumRenderTargets = 1; + psodesc.RTVFormats[0] = DXGI_FORMAT_R8G8B8A8_UNORM; + psodesc.SampleDesc.Count = 1; D3D12CreateGraphicsPipelineState(d3d12->device, &psodesc, &d3d12->pipe.handle); } @@ -497,21 +469,16 @@ bool d3d12_init_pipeline(d3d12_video_t* d3d12) D3D12_GPU_VIRTUAL_ADDRESS d3d12_create_buffer(D3D12Device device, UINT size_in_bytes, D3D12Resource* buffer) { - static const D3D12_HEAP_PROPERTIES heap_props = { - .Type = D3D12_HEAP_TYPE_UPLOAD, - .CreationNodeMask = 1, - .VisibleNodeMask = 1, - }; + D3D12_HEAP_PROPERTIES heap_props = { D3D12_HEAP_TYPE_UPLOAD, D3D12_CPU_PAGE_PROPERTY_UNKNOWN, + D3D12_MEMORY_POOL_UNKNOWN, 1, 1 }; + D3D12_RESOURCE_DESC resource_desc = { D3D12_RESOURCE_DIMENSION_BUFFER }; - D3D12_RESOURCE_DESC resource_desc = { - .Dimension = D3D12_RESOURCE_DIMENSION_BUFFER, - .Width = size_in_bytes, - .Height = 1, - .DepthOrArraySize = 1, - .MipLevels = 1, - .SampleDesc.Count = 1, - .Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR, - }; + resource_desc.Width = size_in_bytes; + resource_desc.Height = 1; + resource_desc.DepthOrArraySize = 1; + resource_desc.MipLevels = 1; + resource_desc.SampleDesc.Count = 1; + resource_desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; D3D12CreateCommittedResource( device, (D3D12_HEAP_PROPERTIES*)&heap_props, D3D12_HEAP_FLAG_NONE, &resource_desc, @@ -530,12 +497,14 @@ void d3d12_init_texture( Release(texture->upload_buffer); { + D3D12_HEAP_PROPERTIES heap_props = { D3D12_HEAP_TYPE_DEFAULT, D3D12_CPU_PAGE_PROPERTY_UNKNOWN, + D3D12_MEMORY_POOL_UNKNOWN, 1, 1 }; + texture->desc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; texture->desc.DepthOrArraySize = 1; texture->desc.MipLevels = 1; texture->desc.SampleDesc.Count = 1; - D3D12_HEAP_PROPERTIES heap_props = { D3D12_HEAP_TYPE_DEFAULT, 0, 0, 1, 1 }; D3D12CreateCommittedResource( device, &heap_props, D3D12_HEAP_FLAG_NONE, &texture->desc, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, NULL, &texture->handle); @@ -546,16 +515,16 @@ void d3d12_init_texture( &texture->row_size_in_bytes, &texture->total_bytes); { - D3D12_RESOURCE_DESC buffer_desc = { - .Dimension = D3D12_RESOURCE_DIMENSION_BUFFER, - .Width = texture->total_bytes, - .Height = 1, - .DepthOrArraySize = 1, - .MipLevels = 1, - .SampleDesc.Count = 1, - .Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR, - }; - D3D12_HEAP_PROPERTIES heap_props = { D3D12_HEAP_TYPE_UPLOAD, 0, 0, 1, 1 }; + D3D12_HEAP_PROPERTIES heap_props = { D3D12_HEAP_TYPE_UPLOAD, D3D12_CPU_PAGE_PROPERTY_UNKNOWN, + D3D12_MEMORY_POOL_UNKNOWN, 1, 1 }; + D3D12_RESOURCE_DESC buffer_desc = { D3D12_RESOURCE_DIMENSION_BUFFER }; + + buffer_desc.Width = texture->total_bytes; + buffer_desc.Height = 1; + buffer_desc.DepthOrArraySize = 1; + buffer_desc.MipLevels = 1; + buffer_desc.SampleDesc.Count = 1; + buffer_desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; D3D12CreateCommittedResource( device, &heap_props, D3D12_HEAP_FLAG_NONE, &buffer_desc, @@ -563,15 +532,15 @@ void d3d12_init_texture( } { - D3D12_CPU_DESCRIPTOR_HANDLE handle; - D3D12_SHADER_RESOURCE_VIEW_DESC view_desc = { 0 }; + D3D12_CPU_DESCRIPTOR_HANDLE handle; + D3D12_SHADER_RESOURCE_VIEW_DESC view_desc = { DXGI_FORMAT_UNKNOWN }; - view_desc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; - view_desc.Format = texture->desc.Format; - view_desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D; - view_desc.Texture2D.MipLevels = texture->desc.MipLevels; + view_desc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; + view_desc.Format = texture->desc.Format; + view_desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D; + view_desc.Texture2D.MipLevels = texture->desc.MipLevels; - handle.ptr = heap->cpu.ptr + heap_index * heap->stride; + handle.ptr = heap->cpu.ptr + heap_index * heap->stride; D3D12CreateShaderResourceView(device, texture->handle, &view_desc, handle); texture->gpu_descriptor.ptr = heap->gpu.ptr + heap_index * heap->stride; @@ -583,9 +552,9 @@ void d3d12_upload_texture(D3D12GraphicsCommandList cmd, d3d12_texture_t* texture D3D12_TEXTURE_COPY_LOCATION src = { 0 }; D3D12_TEXTURE_COPY_LOCATION dst = { 0 }; - src.pResource = texture->upload_buffer; - src.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT; - src.PlacedFootprint = texture->layout; + src.pResource = texture->upload_buffer; + src.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT; + src.PlacedFootprint = texture->layout; dst.pResource = texture->handle; dst.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX; @@ -631,10 +600,10 @@ void d3d12_create_fullscreen_quad_vbo( DXGI_FORMAT d3d12_get_closest_match( D3D12Device device, DXGI_FORMAT desired_format, D3D12_FORMAT_SUPPORT1 desired_format_support) { - DXGI_FORMAT default_list[] = {desired_format, DXGI_FORMAT_UNKNOWN}; - DXGI_FORMAT* format = dxgi_get_format_fallback_list(desired_format); + DXGI_FORMAT default_list[] = { desired_format, DXGI_FORMAT_UNKNOWN }; + DXGI_FORMAT* format = dxgi_get_format_fallback_list(desired_format); - if(!format) + if (!format) format = default_list; while (*format != DXGI_FORMAT_UNKNOWN) diff --git a/gfx/common/d3d12_common.h b/gfx/common/d3d12_common.h index 58b3c985d2..d79c1ebc4a 100644 --- a/gfx/common/d3d12_common.h +++ b/gfx/common/d3d12_common.h @@ -1365,10 +1365,10 @@ typedef struct enum { - ROOT_INDEX_TEXTURE_TABLE = 0, - ROOT_INDEX_SAMPLER_TABLE, - ROOT_INDEX_UBO, - ROOT_INDEX_MAX, + ROOT_ID_TEXTURE_T = 0, + ROOT_ID_SAMPLER_T, + ROOT_ID_UBO, + ROOT_ID_MAX, } root_signature_parameter_index_t; typedef enum { @@ -1420,13 +1420,13 @@ static INLINE void d3d12_resource_transition( static INLINE void d3d12_set_texture(D3D12GraphicsCommandList cmd, const d3d12_texture_t* texture) { - D3D12SetGraphicsRootDescriptorTable(cmd, ROOT_INDEX_TEXTURE_TABLE, texture->gpu_descriptor); + D3D12SetGraphicsRootDescriptorTable(cmd, ROOT_ID_TEXTURE_T, texture->gpu_descriptor); } static INLINE void d3d12_set_sampler(D3D12GraphicsCommandList cmd, D3D12_GPU_DESCRIPTOR_HANDLE sampler) { - D3D12SetGraphicsRootDescriptorTable(cmd, ROOT_INDEX_SAMPLER_TABLE, sampler); + D3D12SetGraphicsRootDescriptorTable(cmd, ROOT_ID_SAMPLER_T, sampler); } static INLINE void d3d12_update_texture( diff --git a/gfx/common/d3dcompiler_common.c b/gfx/common/d3dcompiler_common.c index f28bde2789..45e3f7bbb5 100644 --- a/gfx/common/d3dcompiler_common.c +++ b/gfx/common/d3dcompiler_common.c @@ -13,6 +13,8 @@ * If not, see . */ +#define CINTERFACE + #include #ifdef HAVE_CONFIG_H diff --git a/gfx/common/dxgi_common.c b/gfx/common/dxgi_common.c index dae80ff877..b1fdda3c9a 100644 --- a/gfx/common/dxgi_common.c +++ b/gfx/common/dxgi_common.c @@ -143,8 +143,8 @@ DXGI_FORMAT* dxgi_get_format_fallback_list(DXGI_FORMAT format) ((src_bs == dst_bs && src_bb == dst_bb) || !dst_bb) && \ ((src_as == dst_as && src_ab == dst_ab) || !dst_ab)) \ { \ - const UINT8* in = src_data; \ - UINT8* out = dst_data; \ + const UINT8* in = (const UINT8*)src_data; \ + UINT8* out = (UINT8*)dst_data; \ for (i = 0; i < height; i++) \ { \ memcpy(out, in, width * sizeof(src_type)); \ diff --git a/gfx/common/dxgi_common.h b/gfx/common/dxgi_common.h index d5f09e78f4..cab548975d 100644 --- a/gfx/common/dxgi_common.h +++ b/gfx/common/dxgi_common.h @@ -247,17 +247,9 @@ #endif #endif +#if !defined(__cplusplus) || defined(CINTERFACE) #ifndef COM_RELEASE_DECLARED #define COM_RELEASE_DECLARED -#if defined(__cplusplus) && !defined(CINTERFACE) -static INLINE ULONG Release(IUnknown* object) -{ - if (object) - return object->Release(); - - return 0; -} -#else static INLINE ULONG Release(void* object) { if (object) diff --git a/gfx/display_servers/dispserv_win32.c b/gfx/display_servers/dispserv_win32.c index 620b4f5cf2..6bc3895f10 100644 --- a/gfx/display_servers/dispserv_win32.c +++ b/gfx/display_servers/dispserv_win32.c @@ -85,7 +85,7 @@ static void* win32_display_server_init(void) if (!SUCCEEDED(hr)) { - g_taskbarList = false; + g_taskbarList = NULL; RARCH_ERR("[dispserv]: CoCreateInstance of ITaskbarList3 failed.\n"); } #endif diff --git a/gfx/drivers/d3d10.c b/gfx/drivers/d3d10.c index e0c2bb78d7..4cfb21512c 100644 --- a/gfx/drivers/d3d10.c +++ b/gfx/drivers/d3d10.c @@ -13,6 +13,8 @@ * If not, see . */ +#define CINTERFACE + #include #include diff --git a/gfx/drivers/d3d11.c b/gfx/drivers/d3d11.c index 3698afae39..fdcf1f00df 100644 --- a/gfx/drivers/d3d11.c +++ b/gfx/drivers/d3d11.c @@ -13,6 +13,8 @@ * If not, see . */ +#define CINTERFACE + #include #include @@ -39,7 +41,7 @@ static void d3d11_set_filtering(void* data, unsigned index, bool smooth) { - unsigned i; + unsigned i; d3d11_video_t* d3d11 = (d3d11_video_t*)data; for (i = 0; i < RARCH_WRAP_MAX; i++) @@ -141,8 +143,9 @@ static void d3d11_free_shader_preset(d3d11_video_t* d3d11) static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const char* path) { #if defined(HAVE_SLANG) && defined(HAVE_SPIRV_CROSS) - unsigned i; - d3d11_video_t* d3d11 = (d3d11_video_t*)data; + unsigned i; + d3d11_texture_t* source; + d3d11_video_t* d3d11 = (d3d11_video_t*)data; if (!d3d11) return false; @@ -171,8 +174,7 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const video_shader_resolve_relative(d3d11->shader_preset, path); - d3d11_texture_t* source = &d3d11->frame.texture[0]; - + source = &d3d11->frame.texture[0]; for (i = 0; i < d3d11->shader_preset->passes; source = &d3d11->pass[i++].rt) { unsigned j; @@ -219,16 +221,16 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const /* clang-format on */ if (!slang_process( - d3d11->shader_preset, i, RARCH_SHADER_HLSL, 50, &semantics_map, - &d3d11->pass[i].semantics)) + d3d11->shader_preset, i, RARCH_SHADER_HLSL, 50, &semantics_map, + &d3d11->pass[i].semantics)) goto error; { static const D3D11_INPUT_ELEMENT_DESC desc[] = { { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, offsetof(d3d11_vertex_t, position), - D3D11_INPUT_PER_VERTEX_DATA, 0 }, + D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "TEXCOORD", 1, DXGI_FORMAT_R32G32_FLOAT, 0, offsetof(d3d11_vertex_t, texcoord), - D3D11_INPUT_PER_VERTEX_DATA, 0 }, + D3D11_INPUT_PER_VERTEX_DATA, 0 }, }; #ifdef DEBUG bool save_hlsl = true; @@ -253,13 +255,13 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const strncpy(ps_path + base_len, ps_ext, sizeof(ps_ext)); if (!d3d11_init_shader( - d3d11->device, vs_src, 0, vs_path, "main", NULL, NULL, desc, countof(desc), - &d3d11->pass[i].shader)) + d3d11->device, vs_src, 0, vs_path, "main", NULL, NULL, desc, countof(desc), + &d3d11->pass[i].shader)) save_hlsl = true; if (!d3d11_init_shader( - d3d11->device, ps_src, 0, ps_path, NULL, "main", NULL, NULL, 0, - &d3d11->pass[i].shader)) + d3d11->device, ps_src, 0, ps_path, NULL, "main", NULL, NULL, 0, + &d3d11->pass[i].shader)) save_hlsl = true; if (save_hlsl) @@ -342,7 +344,7 @@ error: static void d3d11_gfx_free(void* data) { - unsigned i; + unsigned i; d3d11_video_t* d3d11 = (d3d11_video_t*)data; if (!d3d11) @@ -400,7 +402,7 @@ static void d3d11_gfx_free(void* data) static void* d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** input_data) { - unsigned i; + unsigned i; WNDCLASSEX wndclass = { 0 }; MONITORINFOEX current_mon; HMONITOR hm_to_use; @@ -436,25 +438,25 @@ d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** i { UINT flags = 0; D3D_FEATURE_LEVEL requested_feature_level = D3D_FEATURE_LEVEL_11_0; - DXGI_SWAP_CHAIN_DESC desc = { - .BufferCount = 1, - .BufferDesc.Width = d3d11->vp.full_width, - .BufferDesc.Height = d3d11->vp.full_height, - .BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM, - .BufferDesc.RefreshRate.Numerator = 60, - .BufferDesc.RefreshRate.Denominator = 1, - .BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT, - .OutputWindow = main_window.hwnd, - .SampleDesc.Count = 1, - .SampleDesc.Quality = 0, - .Windowed = TRUE, - .SwapEffect = DXGI_SWAP_EFFECT_SEQUENTIAL, + DXGI_SWAP_CHAIN_DESC desc = { 0 }; + + desc.BufferCount = 1; + desc.BufferDesc.Width = d3d11->vp.full_width; + desc.BufferDesc.Height = d3d11->vp.full_height; + desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + desc.BufferDesc.RefreshRate.Numerator = 60; + desc.BufferDesc.RefreshRate.Denominator = 1; + desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; + desc.OutputWindow = main_window.hwnd; + desc.SampleDesc.Count = 1; + desc.SampleDesc.Quality = 0; + desc.Windowed = TRUE; + desc.SwapEffect = DXGI_SWAP_EFFECT_SEQUENTIAL; #if 0 - .SwapEffect = DXGI_SWAP_EFFECT_DISCARD, - .SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL, - .SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD, + desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; + desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; + desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD; #endif - }; #ifdef DEBUG flags |= D3D11_CREATE_DEVICE_DEBUG; @@ -508,12 +510,12 @@ d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** i d3d11_gfx_set_rotation(d3d11, 0); { - D3D11_SAMPLER_DESC desc = { - .MaxAnisotropy = 1, - .ComparisonFunc = D3D11_COMPARISON_NEVER, - .MinLOD = -D3D11_FLOAT32_MAX, - .MaxLOD = D3D11_FLOAT32_MAX, - }; + D3D11_SAMPLER_DESC desc = { D3D11_FILTER_MIN_MAG_MIP_POINT }; + desc.MaxAnisotropy = 1; + desc.ComparisonFunc = D3D11_COMPARISON_NEVER; + desc.MinLOD = -D3D11_FLOAT32_MAX; + desc.MaxLOD = D3D11_FLOAT32_MAX; + /* Initialize samplers */ for (i = 0; i < RARCH_WRAP_MAX; i++) { @@ -557,11 +559,11 @@ d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** i }; { - D3D11_BUFFER_DESC desc = { - .Usage = D3D11_USAGE_IMMUTABLE, - .ByteWidth = sizeof(vertices), - .BindFlags = D3D11_BIND_VERTEX_BUFFER, - }; + D3D11_BUFFER_DESC desc = { 0 }; + desc.Usage = D3D11_USAGE_IMMUTABLE; + desc.ByteWidth = sizeof(vertices); + desc.BindFlags = D3D11_BIND_VERTEX_BUFFER; + D3D11_SUBRESOURCE_DATA vertexData = { vertices }; D3D11CreateBuffer(d3d11->device, &desc, &vertexData, &d3d11->frame.vbo); desc.Usage = D3D11_USAGE_DYNAMIC; @@ -691,21 +693,18 @@ d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** i } { - D3D11_BLEND_DESC blend_desc = { - .AlphaToCoverageEnable = FALSE, - .IndependentBlendEnable = FALSE, - .RenderTarget[0] = - { - .BlendEnable = TRUE, - D3D11_BLEND_SRC_ALPHA, - D3D11_BLEND_INV_SRC_ALPHA, - D3D11_BLEND_OP_ADD, - D3D11_BLEND_SRC_ALPHA, - D3D11_BLEND_INV_SRC_ALPHA, - D3D11_BLEND_OP_ADD, - D3D11_COLOR_WRITE_ENABLE_ALL, - }, - }; + D3D11_BLEND_DESC blend_desc = { 0 }; + + blend_desc.AlphaToCoverageEnable = FALSE; + blend_desc.IndependentBlendEnable = FALSE; + blend_desc.RenderTarget[0].BlendEnable = TRUE; + blend_desc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA; + blend_desc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA; + blend_desc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD; + blend_desc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_SRC_ALPHA; + blend_desc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_INV_SRC_ALPHA; + blend_desc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; + blend_desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; D3D11CreateBlendState(d3d11->device, &blend_desc, &d3d11->blend_enable); blend_desc.RenderTarget[0].SrcBlend = D3D11_BLEND_ONE; @@ -716,10 +715,11 @@ d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** i D3D11CreateBlendState(d3d11->device, &blend_desc, &d3d11->blend_disable); } { - D3D11_RASTERIZER_DESC desc = { - .FillMode = D3D11_FILL_SOLID, - .CullMode = D3D11_CULL_NONE, - }; + D3D11_RASTERIZER_DESC desc = { 0 }; + + desc.FillMode = D3D11_FILL_SOLID; + desc.CullMode = D3D11_CULL_NONE; + D3D11CreateRasterizerState(d3d11->device, &desc, &d3d11->state); } D3D11SetState(d3d11->context, d3d11->state); @@ -873,8 +873,8 @@ static bool d3d11_gfx_frame( const char* msg, video_frame_info_t* video_info) { - unsigned i; - d3d11_texture_t* texture = NULL; + unsigned i; + d3d11_texture_t* texture = NULL; d3d11_video_t* d3d11 = (d3d11_video_t*)data; D3D11DeviceContext context = d3d11->context; @@ -883,7 +883,7 @@ static bool d3d11_gfx_frame( D3D11Texture2D backBuffer; Release(d3d11->renderTargetView); - DXGIResizeBuffers(d3d11->swapChain, 0, 0, 0, 0, 0); + DXGIResizeBuffers(d3d11->swapChain, 0, 0, 0, DXGI_FORMAT_UNKNOWN, 0); DXGIGetSwapChainBufferD3D11(d3d11->swapChain, 0, &backBuffer); D3D11CreateTexture2DRenderTargetView( @@ -1176,8 +1176,9 @@ static bool d3d11_gfx_read_viewport(void* data, uint8_t* buffer, bool is_idle) static void d3d11_set_menu_texture_frame( void* data, const void* frame, bool rgb32, unsigned width, unsigned height, float alpha) { - d3d11_video_t* d3d11 = (d3d11_video_t*)data; - DXGI_FORMAT format = rgb32 ? DXGI_FORMAT_B8G8R8A8_UNORM : DXGI_FORMAT_EX_A4R4G4B4_UNORM; + d3d11_video_t* d3d11 = (d3d11_video_t*)data; + DXGI_FORMAT format = + rgb32 ? DXGI_FORMAT_B8G8R8A8_UNORM : (DXGI_FORMAT)DXGI_FORMAT_EX_A4R4G4B4_UNORM; if (d3d11->menu.texture.desc.Width != width || d3d11->menu.texture.desc.Height != height) { @@ -1247,7 +1248,7 @@ static uintptr_t d3d11_gfx_load_texture( if (!d3d11) return 0; - texture = (d3d11_texture_t*)calloc(1, sizeof(*texture)); + texture = (d3d11_texture_t*)calloc(1, sizeof(*texture)); if (!texture) return 0; diff --git a/gfx/drivers/d3d12.c b/gfx/drivers/d3d12.c index f1c48a1ad2..b4d1690818 100644 --- a/gfx/drivers/d3d12.c +++ b/gfx/drivers/d3d12.c @@ -13,6 +13,8 @@ * If not, see . */ +#define CINTERFACE + #include #include @@ -236,7 +238,7 @@ static bool d3d12_gfx_frame( D3D12RSSetScissorRects(d3d12->queue.cmd, 1, &d3d12->frame.scissorRect); D3D12SetGraphicsRootConstantBufferView( - d3d12->queue.cmd, ROOT_INDEX_UBO, d3d12->frame.ubo_view.BufferLocation); + d3d12->queue.cmd, ROOT_ID_UBO, d3d12->frame.ubo_view.BufferLocation); d3d12_set_texture(d3d12->queue.cmd, &d3d12->frame.texture); d3d12_set_sampler(d3d12->queue.cmd, d3d12->frame.sampler); D3D12IASetVertexBuffers(d3d12->queue.cmd, 0, 1, &d3d12->frame.vbo_view); @@ -248,7 +250,7 @@ static bool d3d12_gfx_frame( d3d12_upload_texture(d3d12->queue.cmd, &d3d12->menu.texture); D3D12SetGraphicsRootConstantBufferView( - d3d12->queue.cmd, ROOT_INDEX_UBO, d3d12->ubo_view.BufferLocation); + d3d12->queue.cmd, ROOT_ID_UBO, d3d12->ubo_view.BufferLocation); if (d3d12->menu.fullscreen) { diff --git a/gfx/drivers_font/d3d11_font.c b/gfx/drivers_font/d3d11_font.c index 6008a74747..7b75949259 100644 --- a/gfx/drivers_font/d3d11_font.c +++ b/gfx/drivers_font/d3d11_font.c @@ -13,6 +13,8 @@ * If not, see . */ +#define CINTERFACE + #include #include #include diff --git a/libretro-common/streams/file_stream.c b/libretro-common/streams/file_stream.c index 38efa2d7c5..cc062f4169 100644 --- a/libretro-common/streams/file_stream.c +++ b/libretro-common/streams/file_stream.c @@ -31,6 +31,7 @@ #endif #include +#define VFS_FRONTEND #include static const int64_t vfs_error_return_value = -1; diff --git a/menu/drivers_display/menu_display_d3d11.c b/menu/drivers_display/menu_display_d3d11.c index e601d86ce0..111b9befb8 100644 --- a/menu/drivers_display/menu_display_d3d11.c +++ b/menu/drivers_display/menu_display_d3d11.c @@ -13,6 +13,8 @@ * If not, see . */ +#define CINTERFACE + #include #ifdef HAVE_CONFIG_H @@ -80,12 +82,12 @@ static void menu_display_d3d11_draw(void* data) { D3D11_MAPPED_SUBRESOURCE mapped_vbo; - d3d11_sprite_t *v = NULL; + d3d11_sprite_t* v = NULL; D3D11MapBuffer( d3d11->context, d3d11->sprites.vbo, 0, D3D11_MAP_WRITE_NO_OVERWRITE, 0, &mapped_vbo); - v = (d3d11_sprite_t*)mapped_vbo.pData + d3d11->sprites.offset; + v = (d3d11_sprite_t*)mapped_vbo.pData + d3d11->sprites.offset; v->pos.x = draw->x / (float)d3d11->viewport.Width; v->pos.y = (d3d11->viewport.Height - draw->y - draw->height) / (float)d3d11->viewport.Height; @@ -139,15 +141,15 @@ static void menu_display_d3d11_draw_pipeline(void* data) case VIDEO_SHADER_MENU: case VIDEO_SHADER_MENU_2: { - video_coord_array_t *ca = menu_display_get_coords_array(); + video_coord_array_t* ca = menu_display_get_coords_array(); if (!d3d11->menu_pipeline_vbo) { - D3D11_BUFFER_DESC desc = { - .Usage = D3D11_USAGE_IMMUTABLE, - .ByteWidth = ca->coords.vertices * 2 * sizeof(float), - .BindFlags = D3D11_BIND_VERTEX_BUFFER, - }; + D3D11_BUFFER_DESC desc = { 0 }; + desc.Usage = D3D11_USAGE_IMMUTABLE; + desc.ByteWidth = ca->coords.vertices * 2 * sizeof(float); + desc.BindFlags = D3D11_BIND_VERTEX_BUFFER; + D3D11_SUBRESOURCE_DATA vertexData = { ca->coords.vertex }; D3D11CreateBuffer(d3d11->device, &desc, &vertexData, &d3d11->menu_pipeline_vbo); } @@ -199,12 +201,12 @@ static bool menu_display_d3d11_font_init_first( float font_size, bool is_threaded) { - font_data_t** handle = (font_data_t**)font_handle; - font_data_t *new_handle = font_driver_init_first( - video_data, font_path, font_size, true, is_threaded, FONT_DRIVER_RENDER_D3D11_API); + font_data_t** handle = (font_data_t**)font_handle; + font_data_t* new_handle = font_driver_init_first( + video_data, font_path, font_size, true, is_threaded, FONT_DRIVER_RENDER_D3D11_API); if (!new_handle) - return false; - *handle = new_handle; + return false; + *handle = new_handle; return true; } diff --git a/network/netplay/netplay_sync.c b/network/netplay/netplay_sync.c index da8bcfc1bd..aff2359cf8 100644 --- a/network/netplay/netplay_sync.c +++ b/network/netplay/netplay_sync.c @@ -426,8 +426,8 @@ bool netplay_resolve_input(netplay_t *netplay, size_t sim_ptr, bool resim) { /* Merge them */ /* Most devices have all the digital parts in the first word. */ - static const uint32_t digital_common[3] = {-1, 0, 0}; - static const uint32_t digital_keyboard[5] = {-1, -1, -1, -1, -1}; + static const uint32_t digital_common[3] = {~0u, 0u, 0u}; + static const uint32_t digital_keyboard[5] = {~0u, ~0u, ~0u, ~0u, ~0u}; const uint32_t *digital; if (dtype == RETRO_DEVICE_KEYBOARD) digital = digital_keyboard; diff --git a/tasks/task_autodetect.c b/tasks/task_autodetect.c index 09b0ee76c5..384ab17d6b 100644 --- a/tasks/task_autodetect.c +++ b/tasks/task_autodetect.c @@ -50,8 +50,11 @@ #include #include -#ifndef __cplusplus /* Why doesn't including cguid.h work to get a GUID_NULL instead? */ +#ifdef __cplusplus +EXTERN_C __attribute__((weak)) +const GUID GUID_NULL = {0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}}; +#else __attribute__((weak)) const GUID GUID_NULL = {0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}}; #endif From 2b4890220a5e0ca90a70ab491e58d88d2758a723 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 4 Feb 2018 20:40:28 +0100 Subject: [PATCH 069/232] (D3D) Silence CXX_BUILD warnings --- gfx/common/d3d10_common.c | 2 +- gfx/common/d3d11_common.c | 14 +++++++------- gfx/common/d3d12_common.h | 18 +++++++++--------- gfx/common/dxgi_common.h | 10 +++++----- gfx/drivers/d3d10.c | 2 +- gfx/drivers/d3d11.c | 4 ++-- gfx/drivers/d3d12.c | 4 ++-- 7 files changed, 27 insertions(+), 27 deletions(-) diff --git a/gfx/common/d3d10_common.c b/gfx/common/d3d10_common.c index 77ebb31a3a..16ffa40587 100644 --- a/gfx/common/d3d10_common.c +++ b/gfx/common/d3d10_common.c @@ -84,7 +84,7 @@ void d3d10_init_texture(D3D10Device device, d3d10_texture_t* texture) D3D10CreateTexture2D(device, &texture->desc, NULL, &texture->handle); { - D3D10_SHADER_RESOURCE_VIEW_DESC view_desc = { 0 }; + D3D10_SHADER_RESOURCE_VIEW_DESC view_desc = {}; view_desc.Format = texture->desc.Format; view_desc.ViewDimension = D3D_SRV_DIMENSION_TEXTURE2D; view_desc.Texture2D.MostDetailedMip = 0; diff --git a/gfx/common/d3d11_common.c b/gfx/common/d3d11_common.c index 18484b3bb1..47f33a6c41 100644 --- a/gfx/common/d3d11_common.c +++ b/gfx/common/d3d11_common.c @@ -95,7 +95,7 @@ void d3d11_init_texture(D3D11Device device, d3d11_texture_t* texture) D3D11CreateTexture2D(device, &texture->desc, NULL, &texture->handle); { - D3D11_SHADER_RESOURCE_VIEW_DESC view_desc = { 0 }; + D3D11_SHADER_RESOURCE_VIEW_DESC view_desc = {}; view_desc.Format = texture->desc.Format; view_desc.ViewDimension = D3D_SRV_DIMENSION_TEXTURE2D; view_desc.Texture2D.MostDetailedMip = 0; @@ -190,11 +190,11 @@ bool d3d11_init_shader( if (!src) /* LPCWSTR filename */ { - if (vs_entry && !d3d_compile_from_file(src_name, vs_entry, "vs_5_0", &vs_code)) + if (vs_entry && !d3d_compile_from_file((LPCWSTR)src_name, vs_entry, "vs_5_0", &vs_code)) success = false; - if (ps_entry && !d3d_compile_from_file(src_name, ps_entry, "ps_5_0", &ps_code)) + if (ps_entry && !d3d_compile_from_file((LPCWSTR)src_name, ps_entry, "ps_5_0", &ps_code)) success = false; - if (gs_entry && !d3d_compile_from_file(src_name, gs_entry, "gs_5_0", &gs_code)) + if (gs_entry && !d3d_compile_from_file((LPCWSTR)src_name, gs_entry, "gs_5_0", &gs_code)) success = false; } else /* char array */ @@ -202,11 +202,11 @@ bool d3d11_init_shader( if (!size) size = strlen(src); - if (vs_entry && !d3d_compile(src, size, src_name, vs_entry, "vs_5_0", &vs_code)) + if (vs_entry && !d3d_compile(src, size, (LPCSTR)src_name, vs_entry, "vs_5_0", &vs_code)) success = false; - if (ps_entry && !d3d_compile(src, size, src_name, ps_entry, "ps_5_0", &ps_code)) + if (ps_entry && !d3d_compile(src, size, (LPCSTR)src_name, ps_entry, "ps_5_0", &ps_code)) success = false; - if (gs_entry && !d3d_compile(src, size, src_name, gs_entry, "gs_5_0", &gs_code)) + if (gs_entry && !d3d_compile(src, size, (LPCSTR)src_name, gs_entry, "gs_5_0", &gs_code)) success = false; } diff --git a/gfx/common/d3d12_common.h b/gfx/common/d3d12_common.h index d79c1ebc4a..dfa0010a92 100644 --- a/gfx/common/d3d12_common.h +++ b/gfx/common/d3d12_common.h @@ -49,7 +49,7 @@ typedef ID3D12InfoQueue* D3D12InfoQueue; static INLINE ULONG D3D12Release(void* object) { - return ((ID3D12Object*)object)->lpVtbl->Release(object); + return ((ID3D12Object*)object)->lpVtbl->Release((ID3D12Object*)object); } static INLINE ULONG D3D12ReleaseDeviceChild(D3D12DeviceChild device_child) { @@ -96,20 +96,20 @@ static INLINE ULONG D3D12ReleasePageable(D3D12Pageable pageable) static INLINE ULONG D3D12ReleaseHeap(D3D12Heap heap) { return heap->lpVtbl->Release(heap); } static INLINE ULONG D3D12ReleaseResource(void* resource) { - return ((ID3D12Resource*)resource)->lpVtbl->Release(resource); + return ((ID3D12Resource*)resource)->lpVtbl->Release((ID3D12Resource*)resource); } static INLINE HRESULT D3D12Map(void* resource, UINT subresource, D3D12_RANGE* read_range, void** data) { - return ((ID3D12Resource*)resource)->lpVtbl->Map(resource, subresource, read_range, data); + return ((ID3D12Resource*)resource)->lpVtbl->Map((ID3D12Resource*)resource, subresource, read_range, data); } static INLINE void D3D12Unmap(void* resource, UINT subresource, D3D12_RANGE* written_range) { - ((ID3D12Resource*)resource)->lpVtbl->Unmap(resource, subresource, written_range); + ((ID3D12Resource*)resource)->lpVtbl->Unmap((ID3D12Resource*)resource, subresource, written_range); } static INLINE D3D12_GPU_VIRTUAL_ADDRESS D3D12GetGPUVirtualAddress(void* resource) { - return ((ID3D12Resource*)resource)->lpVtbl->GetGPUVirtualAddress(resource); + return ((ID3D12Resource*)resource)->lpVtbl->GetGPUVirtualAddress((ID3D12Resource*)resource); } static INLINE HRESULT D3D12WriteToSubresource( void* resource, @@ -121,7 +121,7 @@ static INLINE HRESULT D3D12WriteToSubresource( { return ((ID3D12Resource*)resource) ->lpVtbl->WriteToSubresource( - resource, dst_subresource, dst_box, src_data, src_row_pitch, src_depth_pitch); + (ID3D12Resource*)resource, dst_subresource, dst_box, src_data, src_row_pitch, src_depth_pitch); } static INLINE HRESULT D3D12ReadFromSubresource( void* resource, @@ -133,13 +133,13 @@ static INLINE HRESULT D3D12ReadFromSubresource( { return ((ID3D12Resource*)resource) ->lpVtbl->ReadFromSubresource( - resource, dst_data, dst_row_pitch, dst_depth_pitch, src_subresource, src_box); + (ID3D12Resource*)resource, dst_data, dst_row_pitch, dst_depth_pitch, src_subresource, src_box); } static INLINE HRESULT D3D12GetHeapProperties( void* resource, D3D12_HEAP_PROPERTIES* heap_properties, D3D12_HEAP_FLAGS* heap_flags) { return ((ID3D12Resource*)resource) - ->lpVtbl->GetHeapProperties(resource, heap_properties, heap_flags); + ->lpVtbl->GetHeapProperties((ID3D12Resource*)resource, heap_properties, heap_flags); } static INLINE ULONG D3D12ReleaseCommandAllocator(D3D12CommandAllocator command_allocator) { @@ -1408,7 +1408,7 @@ static INLINE void d3d12_resource_transition( D3D12_RESOURCE_STATES state_before, D3D12_RESOURCE_STATES state_after) { - D3D12_RESOURCE_BARRIER barrier = { 0 }; + D3D12_RESOURCE_BARRIER barrier = {}; barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; barrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE; barrier.Transition.pResource = resource; diff --git a/gfx/common/dxgi_common.h b/gfx/common/dxgi_common.h index cab548975d..aefdafaa2e 100644 --- a/gfx/common/dxgi_common.h +++ b/gfx/common/dxgi_common.h @@ -253,7 +253,7 @@ static INLINE ULONG Release(void* object) { if (object) - return ((IUnknown*)object)->lpVtbl->Release(object); + return ((IUnknown*)object)->lpVtbl->Release((IUnknown*)object); return 0; } @@ -285,19 +285,19 @@ static INLINE ULONG DXGIReleaseDeviceSubObject(DXGIDeviceSubObject device_sub_ob } static INLINE HRESULT DXGIGetSharedHandle(void* resource, HANDLE* shared_handle) { - return ((IDXGIResource*)resource)->lpVtbl->GetSharedHandle(resource, shared_handle); + return ((IDXGIResource*)resource)->lpVtbl->GetSharedHandle((IDXGIResource*)resource, shared_handle); } static INLINE HRESULT DXGIGetUsage(void* resource, DXGI_USAGE* usage) { - return ((IDXGIResource*)resource)->lpVtbl->GetUsage(resource, usage); + return ((IDXGIResource*)resource)->lpVtbl->GetUsage((IDXGIResource*)resource, usage); } static INLINE HRESULT DXGISetEvictionPriority(void* resource, UINT eviction_priority) { - return ((IDXGIResource*)resource)->lpVtbl->SetEvictionPriority(resource, eviction_priority); + return ((IDXGIResource*)resource)->lpVtbl->SetEvictionPriority((IDXGIResource*)resource, eviction_priority); } static INLINE HRESULT DXGIGetEvictionPriority(void* resource, UINT* eviction_priority) { - return ((IDXGIResource*)resource)->lpVtbl->GetEvictionPriority(resource, eviction_priority); + return ((IDXGIResource*)resource)->lpVtbl->GetEvictionPriority((IDXGIResource*)resource, eviction_priority); } static INLINE ULONG DXGIReleaseKeyedMutex(DXGIKeyedMutex keyed_mutex) { diff --git a/gfx/drivers/d3d10.c b/gfx/drivers/d3d10.c index 4cfb21512c..1ba98fa8a2 100644 --- a/gfx/drivers/d3d10.c +++ b/gfx/drivers/d3d10.c @@ -301,7 +301,7 @@ static bool d3d10_gfx_frame( D3D10Texture2D backBuffer; Release(d3d10->renderTargetView); - DXGIResizeBuffers(d3d10->swapChain, 0, 0, 0, 0, 0); + DXGIResizeBuffers(d3d10->swapChain, 0, 0, 0, (DXGI_FORMAT)0, 0); DXGIGetSwapChainBufferD3D10(d3d10->swapChain, 0, &backBuffer); D3D10CreateTexture2DRenderTargetView( diff --git a/gfx/drivers/d3d11.c b/gfx/drivers/d3d11.c index fdcf1f00df..b4676e0d95 100644 --- a/gfx/drivers/d3d11.c +++ b/gfx/drivers/d3d11.c @@ -167,7 +167,7 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const if (!conf) return false; - d3d11->shader_preset = calloc(1, sizeof(*d3d11->shader_preset)); + d3d11->shader_preset = (struct video_shader*)calloc(1, sizeof(*d3d11->shader_preset)); if (!video_shader_read_conf_cgp(conf, d3d11->shader_preset)) goto error; @@ -715,7 +715,7 @@ d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** i D3D11CreateBlendState(d3d11->device, &blend_desc, &d3d11->blend_disable); } { - D3D11_RASTERIZER_DESC desc = { 0 }; + D3D11_RASTERIZER_DESC desc = {}; desc.FillMode = D3D11_FILL_SOLID; desc.CullMode = D3D11_CULL_NONE; diff --git a/gfx/drivers/d3d12.c b/gfx/drivers/d3d12.c index b4d1690818..292647717c 100644 --- a/gfx/drivers/d3d12.c +++ b/gfx/drivers/d3d12.c @@ -179,7 +179,7 @@ static bool d3d12_gfx_frame( for (i = 0; i < countof(d3d12->chain.renderTargets); i++) Release(d3d12->chain.renderTargets[i]); - DXGIResizeBuffers(d3d12->chain.handle, 0, 0, 0, 0, 0); + DXGIResizeBuffers(d3d12->chain.handle, 0, 0, 0, (DXGI_FORMAT)0, 0); for (i = 0; i < countof(d3d12->chain.renderTargets); i++) { @@ -399,7 +399,7 @@ static void d3d12_set_menu_texture_frame( { d3d12_video_t* d3d12 = (d3d12_video_t*)data; int pitch = width * (rgb32 ? sizeof(uint32_t) : sizeof(uint16_t)); - DXGI_FORMAT format = rgb32 ? DXGI_FORMAT_B8G8R8A8_UNORM : DXGI_FORMAT_EX_A4R4G4B4_UNORM; + DXGI_FORMAT format = rgb32 ? DXGI_FORMAT_B8G8R8A8_UNORM : (DXGI_FORMAT)DXGI_FORMAT_EX_A4R4G4B4_UNORM; if (d3d12->menu.texture.desc.Width != width || d3d12->menu.texture.desc.Height != height) { From 47ea7c7cb96745301a42aafc799f9d1901ec0fe9 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 4 Feb 2018 20:42:37 +0100 Subject: [PATCH 070/232] Fix libflac linking errors with CXX_BUILD --- deps/libFLAC/bitreader.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/deps/libFLAC/bitreader.c b/deps/libFLAC/bitreader.c index a29334985a..902c3a3327 100644 --- a/deps/libFLAC/bitreader.c +++ b/deps/libFLAC/bitreader.c @@ -349,17 +349,17 @@ FLAC__uint16 FLAC__bitreader_get_read_crc16(FLAC__BitReader *br) return br->read_crc16; } -INLINE FLAC__bool FLAC__bitreader_is_consumed_byte_aligned(const FLAC__BitReader *br) +FLAC__bool FLAC__bitreader_is_consumed_byte_aligned(const FLAC__BitReader *br) { return ((br->consumed_bits & 7) == 0); } -INLINE unsigned FLAC__bitreader_bits_left_for_byte_alignment(const FLAC__BitReader *br) +unsigned FLAC__bitreader_bits_left_for_byte_alignment(const FLAC__BitReader *br) { return 8 - (br->consumed_bits & 7); } -INLINE unsigned FLAC__bitreader_get_input_bits_unconsumed(const FLAC__BitReader *br) +unsigned FLAC__bitreader_get_input_bits_unconsumed(const FLAC__BitReader *br) { return (br->words-br->consumed_words)*FLAC__BITS_PER_WORD + br->bytes*8 - br->consumed_bits; } @@ -478,7 +478,7 @@ FLAC__bool FLAC__bitreader_read_raw_uint64(FLAC__BitReader *br, FLAC__uint64 *va return true; } -INLINE FLAC__bool FLAC__bitreader_read_uint32_little_endian(FLAC__BitReader *br, FLAC__uint32 *val) +FLAC__bool FLAC__bitreader_read_uint32_little_endian(FLAC__BitReader *br, FLAC__uint32 *val) { FLAC__uint32 x8, x32 = 0; From 9dd33b97976ab0a0bee518c8e5c8a6b65464d374 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 4 Feb 2018 20:57:30 +0100 Subject: [PATCH 071/232] More CXX_BUILD linking error fixing --- tasks/task_autodetect.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tasks/task_autodetect.c b/tasks/task_autodetect.c index 384ab17d6b..4f8ac88943 100644 --- a/tasks/task_autodetect.c +++ b/tasks/task_autodetect.c @@ -48,7 +48,14 @@ #include #include #include +#include +#ifdef __cplusplus +extern "C" { +#endif #include +#ifdef __cplusplus +} +#endif /* Why doesn't including cguid.h work to get a GUID_NULL instead? */ #ifdef __cplusplus From 29e1000e47215f4782c97f6ab4f25239fb6b9a92 Mon Sep 17 00:00:00 2001 From: radius Date: Sun, 4 Feb 2018 15:12:26 -0500 Subject: [PATCH 072/232] update CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 13b54d8668..4275c5a181 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -42,6 +42,7 @@ - PSP: Enable threading support through pthreads. - SHADERS: SPIRV-Cross/slang shader support for D3D11. - SHIELD ATV: Allow the remote / gamepad takeover hack to work with the 2017 gamepad +- SUBSYSTEM: Subsystem saves now respect the save directory - VULKAN: Fix swapchain recreation bug on Nvidia GPUs with Windows 10 (resolved in Windows Nvidia driver version 390.77). - WINDOWS: Improved Unicode support (for cores/directory creation and 7zip archives). - WINDOWS: Show progress meter on taskbar for downloads (Windows 7 and up). From 028fc18294a0bda153a444e04ea417037153beb9 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 4 Feb 2018 21:12:42 +0100 Subject: [PATCH 073/232] Fix more warnings --- gfx/common/d3d10_common.c | 6 +- gfx/common/d3d11_common.c | 8 +-- gfx/drivers/d3d10.c | 25 ++++--- gfx/drivers/d3d11.c | 142 +++++++++++++++++++------------------- 4 files changed, 93 insertions(+), 88 deletions(-) diff --git a/gfx/common/d3d10_common.c b/gfx/common/d3d10_common.c index 16ffa40587..c54028ffa8 100644 --- a/gfx/common/d3d10_common.c +++ b/gfx/common/d3d10_common.c @@ -84,7 +84,7 @@ void d3d10_init_texture(D3D10Device device, d3d10_texture_t* texture) D3D10CreateTexture2D(device, &texture->desc, NULL, &texture->handle); { - D3D10_SHADER_RESOURCE_VIEW_DESC view_desc = {}; + D3D10_SHADER_RESOURCE_VIEW_DESC view_desc = { DXGI_FORMAT_UNKNOWN }; view_desc.Format = texture->desc.Format; view_desc.ViewDimension = D3D_SRV_DIMENSION_TEXTURE2D; view_desc.Texture2D.MostDetailedMip = 0; @@ -134,7 +134,7 @@ void d3d10_update_texture( texture->dirty = true; } -DXGI_FORMAT + DXGI_FORMAT d3d10_get_closest_match(D3D10Device device, DXGI_FORMAT desired_format, UINT desired_format_support) { @@ -148,7 +148,7 @@ d3d10_get_closest_match(D3D10Device device, { UINT format_support; if (SUCCEEDED(D3D10CheckFormatSupport(device, *format, &format_support)) && - ((format_support & desired_format_support) == desired_format_support)) + ((format_support & desired_format_support) == desired_format_support)) break; format++; } diff --git a/gfx/common/d3d11_common.c b/gfx/common/d3d11_common.c index 47f33a6c41..8cc91ab1c8 100644 --- a/gfx/common/d3d11_common.c +++ b/gfx/common/d3d11_common.c @@ -72,7 +72,7 @@ void d3d11_init_texture(D3D11Device device, d3d11_texture_t* texture) texture->desc.SampleDesc.Quality = 0; texture->desc.BindFlags |= D3D11_BIND_SHADER_RESOURCE; texture->desc.CPUAccessFlags = - texture->desc.Usage == D3D11_USAGE_DYNAMIC ? D3D11_CPU_ACCESS_WRITE : 0; + texture->desc.Usage == D3D11_USAGE_DYNAMIC ? D3D11_CPU_ACCESS_WRITE : 0; if (texture->desc.MiscFlags & D3D11_RESOURCE_MISC_GENERATE_MIPS) { @@ -95,7 +95,7 @@ void d3d11_init_texture(D3D11Device device, d3d11_texture_t* texture) D3D11CreateTexture2D(device, &texture->desc, NULL, &texture->handle); { - D3D11_SHADER_RESOURCE_VIEW_DESC view_desc = {}; + D3D11_SHADER_RESOURCE_VIEW_DESC view_desc = { DXGI_FORMAT_UNKNOWN }; view_desc.Format = texture->desc.Format; view_desc.ViewDimension = D3D_SRV_DIMENSION_TEXTURE2D; view_desc.Texture2D.MostDetailedMip = 0; @@ -149,7 +149,7 @@ void d3d11_update_texture( D3D11GenerateMips(ctx, texture->view); } -DXGI_FORMAT + DXGI_FORMAT d3d11_get_closest_match(D3D11Device device, DXGI_FORMAT desired_format, UINT desired_format_support) { DXGI_FORMAT default_list[] = {desired_format, DXGI_FORMAT_UNKNOWN}; @@ -162,7 +162,7 @@ d3d11_get_closest_match(D3D11Device device, DXGI_FORMAT desired_format, UINT des { UINT format_support; if (SUCCEEDED(D3D11CheckFormatSupport(device, *format, &format_support)) && - ((format_support & desired_format_support) == desired_format_support)) + ((format_support & desired_format_support) == desired_format_support)) break; format++; } diff --git a/gfx/drivers/d3d10.c b/gfx/drivers/d3d10.c index 1ba98fa8a2..3dde65aaf8 100644 --- a/gfx/drivers/d3d10.c +++ b/gfx/drivers/d3d10.c @@ -73,7 +73,7 @@ static void d3d10_update_viewport(void* data, bool force_full) d3d10->resize_viewport = false; } -static void* + static void* d3d10_gfx_init(const video_info_t* video, const input_driver_t** input, void** input_data) { WNDCLASSEX wndclass = { 0 }; @@ -158,7 +158,7 @@ d3d10_gfx_init(const video_info_t* video, const input_driver_t** input, void** i d3d10->format = video->rgb32 ? DXGI_FORMAT_B8G8R8X8_UNORM : DXGI_FORMAT_B5G6R5_UNORM; d3d10->frame.texture.desc.Format = - d3d10_get_closest_match_texture2D(d3d10->device, d3d10->format); + d3d10_get_closest_match_texture2D(d3d10->device, d3d10->format); d3d10->frame.texture.desc.Usage = D3D10_USAGE_DEFAULT; d3d10->menu.texture.desc.Usage = D3D10_USAGE_DEFAULT; @@ -179,17 +179,22 @@ d3d10_gfx_init(const video_info_t* video, const input_driver_t** input, void** i d3d10_gfx_set_rotation(d3d10, 0); { - D3D10_SAMPLER_DESC desc = {}; + unsigned k; + D3D10_SAMPLER_DESC desc; desc.Filter = D3D10_FILTER_MIN_MAG_MIP_POINT; desc.AddressU = D3D10_TEXTURE_ADDRESS_BORDER; desc.AddressV = D3D10_TEXTURE_ADDRESS_BORDER; desc.AddressW = D3D10_TEXTURE_ADDRESS_BORDER; + desc.MipLODBias = 0.0f; desc.MaxAnisotropy = 1; desc.ComparisonFunc = D3D10_COMPARISON_NEVER; desc.MinLOD = -D3D10_FLOAT32_MAX; desc.MaxLOD = D3D10_FLOAT32_MAX; + for (k = 0; k < 4; k++) + desc.BorderColor[k] = 0.0f; + D3D10CreateSamplerState(d3d10->device, &desc, &d3d10->sampler_nearest); desc.Filter = D3D10_FILTER_MIN_MAG_MIP_LINEAR; @@ -228,15 +233,15 @@ d3d10_gfx_init(const video_info_t* video, const input_driver_t** input, void** i static const char stock[] = #include "d3d_shaders/opaque_sm5.hlsl.h" - ; + ; D3D10_INPUT_ELEMENT_DESC desc[] = { { "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, offsetof(d3d10_vertex_t, position), - D3D10_INPUT_PER_VERTEX_DATA, 0 }, + D3D10_INPUT_PER_VERTEX_DATA, 0 }, { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, offsetof(d3d10_vertex_t, texcoord), - D3D10_INPUT_PER_VERTEX_DATA, 0 }, + D3D10_INPUT_PER_VERTEX_DATA, 0 }, { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, offsetof(d3d10_vertex_t, color), - D3D10_INPUT_PER_VERTEX_DATA, 0 }, + D3D10_INPUT_PER_VERTEX_DATA, 0 }, }; d3d_compile(stock, sizeof(stock), NULL, "VSMain", "vs_4_0", &vs_code); @@ -340,9 +345,9 @@ static bool d3d10_gfx_frame( UINT stride = sizeof(d3d10_vertex_t); UINT offset = 0; #if 0 /* custom viewport doesn't call apply_state_changes, so we can't rely on this for now */ - if (d3d10->resize_viewport) + if (d3d10->resize_viewport) #endif - d3d10_update_viewport(d3d10, false); + d3d10_update_viewport(d3d10, false); D3D10SetViewports(d3d10->device, 1, &d3d10->frame.viewport); D3D10SetVertexBuffers(d3d10->device, 0, 1, &d3d10->frame.vbo, &stride, &offset); @@ -488,7 +493,7 @@ static void d3d10_set_menu_texture_frame( d3d10_update_texture(width, height, pitch, format, frame, &d3d10->menu.texture); d3d10->menu.sampler = config_get_ptr()->bools.menu_linear_filter ? d3d10->sampler_linear - : d3d10->sampler_nearest; + : d3d10->sampler_nearest; } static void d3d10_set_menu_texture_enable(void* data, bool state, bool full_screen) { diff --git a/gfx/drivers/d3d11.c b/gfx/drivers/d3d11.c index b4676e0d95..80829d168e 100644 --- a/gfx/drivers/d3d11.c +++ b/gfx/drivers/d3d11.c @@ -84,7 +84,7 @@ static void d3d11_update_viewport(void* data, bool force_full) d3d11->frame.viewport.MaxDepth = 1.0f; if (d3d11->shader_preset && (d3d11->frame.output_size.x != d3d11->vp.width || - d3d11->frame.output_size.y != d3d11->vp.height)) + d3d11->frame.output_size.y != d3d11->vp.height)) d3d11->resize_render_targets = true; d3d11->frame.output_size.x = d3d11->vp.width; @@ -183,33 +183,33 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const { /* Original */ { &d3d11->frame.texture[0].view, 0, - &d3d11->frame.texture[0].size_data, 0, - &d3d11->pass[i].sampler, 0 }, + &d3d11->frame.texture[0].size_data, 0, + &d3d11->pass[i].sampler, 0 }, /* Source */ { &source->view, 0, - &source->size_data, 0, - &d3d11->pass[i].sampler, 0 }, + &source->size_data, 0, + &d3d11->pass[i].sampler, 0 }, /* OriginalHistory */ { &d3d11->frame.texture[0].view, sizeof(*d3d11->frame.texture), - &d3d11->frame.texture[0].size_data, sizeof(*d3d11->frame.texture), - &d3d11->pass[i].sampler, 0 }, + &d3d11->frame.texture[0].size_data, sizeof(*d3d11->frame.texture), + &d3d11->pass[i].sampler, 0 }, /* PassOutput */ { &d3d11->pass[0].rt.view, sizeof(*d3d11->pass), - &d3d11->pass[0].rt.size_data, sizeof(*d3d11->pass), - &d3d11->pass[i].sampler, 0 }, + &d3d11->pass[0].rt.size_data, sizeof(*d3d11->pass), + &d3d11->pass[i].sampler, 0 }, /* PassFeedback */ { &d3d11->pass[0].feedback.view, sizeof(*d3d11->pass), - &d3d11->pass[0].feedback.size_data, sizeof(*d3d11->pass), - &d3d11->pass[i].sampler, 0 }, + &d3d11->pass[0].feedback.size_data, sizeof(*d3d11->pass), + &d3d11->pass[i].sampler, 0 }, /* User */ { &d3d11->luts[0].view, sizeof(*d3d11->luts), - &d3d11->luts[0].size_data, sizeof(*d3d11->luts), - &d3d11->luts[0].sampler, sizeof(*d3d11->luts) }, + &d3d11->luts[0].size_data, sizeof(*d3d11->luts), + &d3d11->luts[0].sampler, sizeof(*d3d11->luts) }, }, { &d3d11->mvp, /* MVP */ @@ -221,16 +221,16 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const /* clang-format on */ if (!slang_process( - d3d11->shader_preset, i, RARCH_SHADER_HLSL, 50, &semantics_map, - &d3d11->pass[i].semantics)) + d3d11->shader_preset, i, RARCH_SHADER_HLSL, 50, &semantics_map, + &d3d11->pass[i].semantics)) goto error; { static const D3D11_INPUT_ELEMENT_DESC desc[] = { { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, offsetof(d3d11_vertex_t, position), - D3D11_INPUT_PER_VERTEX_DATA, 0 }, + D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "TEXCOORD", 1, DXGI_FORMAT_R32G32_FLOAT, 0, offsetof(d3d11_vertex_t, texcoord), - D3D11_INPUT_PER_VERTEX_DATA, 0 }, + D3D11_INPUT_PER_VERTEX_DATA, 0 }, }; #ifdef DEBUG bool save_hlsl = true; @@ -255,13 +255,13 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const strncpy(ps_path + base_len, ps_ext, sizeof(ps_ext)); if (!d3d11_init_shader( - d3d11->device, vs_src, 0, vs_path, "main", NULL, NULL, desc, countof(desc), - &d3d11->pass[i].shader)) + d3d11->device, vs_src, 0, vs_path, "main", NULL, NULL, desc, countof(desc), + &d3d11->pass[i].shader)) save_hlsl = true; if (!d3d11_init_shader( - d3d11->device, ps_src, 0, ps_path, NULL, "main", NULL, NULL, 0, - &d3d11->pass[i].shader)) + d3d11->device, ps_src, 0, ps_path, NULL, "main", NULL, NULL, 0, + &d3d11->pass[i].shader)) save_hlsl = true; if (save_hlsl) @@ -325,7 +325,7 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const image_texture_free(&image); d3d11->luts[i].sampler = - d3d11->samplers[d3d11->shader_preset->lut[i].filter][d3d11->shader_preset->lut[i].wrap]; + d3d11->samplers[d3d11->shader_preset->lut[i].filter][d3d11->shader_preset->lut[i].wrap]; } video_shader_resolve_current_parameters(conf, d3d11->shader_preset); @@ -399,7 +399,7 @@ static void d3d11_gfx_free(void* data) free(d3d11); } -static void* + static void* d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** input_data) { unsigned i; @@ -579,52 +579,52 @@ d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** i { D3D11_INPUT_ELEMENT_DESC desc[] = { { "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, offsetof(d3d11_vertex_t, position), - D3D11_INPUT_PER_VERTEX_DATA, 0 }, + D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, offsetof(d3d11_vertex_t, texcoord), - D3D11_INPUT_PER_VERTEX_DATA, 0 }, + D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, offsetof(d3d11_vertex_t, color), - D3D11_INPUT_PER_VERTEX_DATA, 0 }, + D3D11_INPUT_PER_VERTEX_DATA, 0 }, }; static const char shader[] = #include "d3d_shaders/opaque_sm5.hlsl.h" - ; + ; if (!d3d11_init_shader( - d3d11->device, shader, sizeof(shader), NULL, "VSMain", "PSMain", NULL, desc, - countof(desc), &d3d11->shaders[VIDEO_SHADER_STOCK_BLEND])) + d3d11->device, shader, sizeof(shader), NULL, "VSMain", "PSMain", NULL, desc, + countof(desc), &d3d11->shaders[VIDEO_SHADER_STOCK_BLEND])) goto error; } { D3D11_INPUT_ELEMENT_DESC desc[] = { { "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, offsetof(d3d11_sprite_t, pos), - D3D11_INPUT_PER_VERTEX_DATA, 0 }, + D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "TEXCOORD", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, offsetof(d3d11_sprite_t, coords), - D3D11_INPUT_PER_VERTEX_DATA, 0 }, + D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, offsetof(d3d11_sprite_t, colors[0]), - D3D11_INPUT_PER_VERTEX_DATA, 0 }, + D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "COLOR", 1, DXGI_FORMAT_R8G8B8A8_UNORM, 0, offsetof(d3d11_sprite_t, colors[1]), - D3D11_INPUT_PER_VERTEX_DATA, 0 }, + D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "COLOR", 2, DXGI_FORMAT_R8G8B8A8_UNORM, 0, offsetof(d3d11_sprite_t, colors[2]), - D3D11_INPUT_PER_VERTEX_DATA, 0 }, + D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "COLOR", 3, DXGI_FORMAT_R8G8B8A8_UNORM, 0, offsetof(d3d11_sprite_t, colors[3]), - D3D11_INPUT_PER_VERTEX_DATA, 0 }, + D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "PARAMS", 0, DXGI_FORMAT_R32G32_FLOAT, 0, offsetof(d3d11_sprite_t, params), - D3D11_INPUT_PER_VERTEX_DATA, 0 }, + D3D11_INPUT_PER_VERTEX_DATA, 0 }, }; static const char shader[] = #include "d3d_shaders/sprite_sm4.hlsl.h" - ; + ; if (!d3d11_init_shader( - d3d11->device, shader, sizeof(shader), NULL, "VSMain", "PSMain", "GSMain", desc, - countof(desc), &d3d11->sprites.shader)) + d3d11->device, shader, sizeof(shader), NULL, "VSMain", "PSMain", "GSMain", desc, + countof(desc), &d3d11->sprites.shader)) goto error; if (!d3d11_init_shader( - d3d11->device, shader, sizeof(shader), NULL, "VSMain", "PSMainA8", "GSMain", desc, - countof(desc), &d3d11->sprites.shader_font)) + d3d11->device, shader, sizeof(shader), NULL, "VSMain", "PSMainA8", "GSMain", desc, + countof(desc), &d3d11->sprites.shader_font)) goto error; } @@ -635,60 +635,60 @@ d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** i static const char ribbon[] = #include "d3d_shaders/ribbon_sm4.hlsl.h" - ; + ; static const char ribbon_simple[] = #include "d3d_shaders/ribbon_simple_sm4.hlsl.h" - ; + ; if (!d3d11_init_shader( - d3d11->device, ribbon, sizeof(ribbon), NULL, "VSMain", "PSMain", NULL, desc, - countof(desc), &d3d11->shaders[VIDEO_SHADER_MENU])) + d3d11->device, ribbon, sizeof(ribbon), NULL, "VSMain", "PSMain", NULL, desc, + countof(desc), &d3d11->shaders[VIDEO_SHADER_MENU])) goto error; if (!d3d11_init_shader( - d3d11->device, ribbon_simple, sizeof(ribbon_simple), NULL, "VSMain", "PSMain", NULL, - desc, countof(desc), &d3d11->shaders[VIDEO_SHADER_MENU_2])) + d3d11->device, ribbon_simple, sizeof(ribbon_simple), NULL, "VSMain", "PSMain", NULL, + desc, countof(desc), &d3d11->shaders[VIDEO_SHADER_MENU_2])) goto error; } { D3D11_INPUT_ELEMENT_DESC desc[] = { { "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, offsetof(d3d11_vertex_t, position), - D3D11_INPUT_PER_VERTEX_DATA, 0 }, + D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, offsetof(d3d11_vertex_t, texcoord), - D3D11_INPUT_PER_VERTEX_DATA, 0 }, + D3D11_INPUT_PER_VERTEX_DATA, 0 }, }; static const char simple_snow[] = #include "d3d_shaders/simple_snow_sm4.hlsl.h" - ; + ; static const char snow[] = #include "d3d_shaders/snow_sm4.hlsl.h" - ; + ; static const char bokeh[] = #include "d3d_shaders/bokeh_sm4.hlsl.h" - ; + ; static const char snowflake[] = #include "d3d_shaders/snowflake_sm4.hlsl.h" - ; + ; if (!d3d11_init_shader( - d3d11->device, simple_snow, sizeof(simple_snow), NULL, "VSMain", "PSMain", NULL, - desc, countof(desc), &d3d11->shaders[VIDEO_SHADER_MENU_3])) + d3d11->device, simple_snow, sizeof(simple_snow), NULL, "VSMain", "PSMain", NULL, + desc, countof(desc), &d3d11->shaders[VIDEO_SHADER_MENU_3])) goto error; if (!d3d11_init_shader( - d3d11->device, snow, sizeof(snow), NULL, "VSMain", "PSMain", NULL, desc, - countof(desc), &d3d11->shaders[VIDEO_SHADER_MENU_4])) + d3d11->device, snow, sizeof(snow), NULL, "VSMain", "PSMain", NULL, desc, + countof(desc), &d3d11->shaders[VIDEO_SHADER_MENU_4])) goto error; if (!d3d11_init_shader( - d3d11->device, bokeh, sizeof(bokeh), NULL, "VSMain", "PSMain", NULL, desc, - countof(desc), &d3d11->shaders[VIDEO_SHADER_MENU_5])) + d3d11->device, bokeh, sizeof(bokeh), NULL, "VSMain", "PSMain", NULL, desc, + countof(desc), &d3d11->shaders[VIDEO_SHADER_MENU_5])) goto error; if (!d3d11_init_shader( - d3d11->device, snowflake, sizeof(snowflake), NULL, "VSMain", "PSMain", NULL, desc, - countof(desc), &d3d11->shaders[VIDEO_SHADER_MENU_6])) + d3d11->device, snowflake, sizeof(snowflake), NULL, "VSMain", "PSMain", NULL, desc, + countof(desc), &d3d11->shaders[VIDEO_SHADER_MENU_6])) goto error; } @@ -715,7 +715,7 @@ d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** i D3D11CreateBlendState(d3d11->device, &blend_desc, &d3d11->blend_disable); } { - D3D11_RASTERIZER_DESC desc = {}; + D3D11_RASTERIZER_DESC desc = {(D3D11_FILL_MODE)0}; desc.FillMode = D3D11_FILL_SOLID; desc.CullMode = D3D11_CULL_NONE; @@ -825,7 +825,7 @@ static void d3d11_init_render_targets(d3d11_video_t* d3d11, unsigned width, unsi RARCH_LOG("[D3D11]: Updating framebuffer size %u x %u.\n", width, height); if ((i != (d3d11->shader_preset->passes - 1)) || (width != d3d11->vp.width) || - (height != d3d11->vp.height)) + (height != d3d11->vp.height)) { d3d11->pass[i].viewport.Width = width; d3d11->pass[i].viewport.Height = height; @@ -908,7 +908,7 @@ static bool d3d11_gfx_frame( #if 0 /* custom viewport doesn't call apply_state_changes, so we can't rely on this for now */ if (d3d11->resize_viewport) #endif - d3d11_update_viewport(d3d11, false); + d3d11_update_viewport(d3d11, false); D3D11SetPrimitiveTopology(context, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); @@ -917,7 +917,7 @@ static bool d3d11_gfx_frame( if (d3d11->shader_preset) { if (d3d11->frame.texture[0].desc.Width != width || - d3d11->frame.texture[0].desc.Height != height) + d3d11->frame.texture[0].desc.Height != height) d3d11->resize_render_targets = true; if (d3d11->resize_render_targets) @@ -946,7 +946,7 @@ static bool d3d11_gfx_frame( /* either no history, or we moved a texture of a different size in the front slot */ if (d3d11->frame.texture[0].desc.Width != width || - d3d11->frame.texture[0].desc.Height != height) + d3d11->frame.texture[0].desc.Height != height) { d3d11->frame.texture[0].desc.Width = width; d3d11->frame.texture[0].desc.Height = height; @@ -985,7 +985,7 @@ static bool d3d11_gfx_frame( if (d3d11->shader_preset->pass[i].frame_count_mod) d3d11->pass[i].frame_count = - frame_count % d3d11->shader_preset->pass[i].frame_count_mod; + frame_count % d3d11->shader_preset->pass[i].frame_count_mod; else d3d11->pass[i].frame_count = frame_count; @@ -1178,7 +1178,7 @@ static void d3d11_set_menu_texture_frame( { d3d11_video_t* d3d11 = (d3d11_video_t*)data; DXGI_FORMAT format = - rgb32 ? DXGI_FORMAT_B8G8R8A8_UNORM : (DXGI_FORMAT)DXGI_FORMAT_EX_A4R4G4B4_UNORM; + rgb32 ? DXGI_FORMAT_B8G8R8A8_UNORM : (DXGI_FORMAT)DXGI_FORMAT_EX_A4R4G4B4_UNORM; if (d3d11->menu.texture.desc.Width != width || d3d11->menu.texture.desc.Height != height) { @@ -1190,9 +1190,9 @@ static void d3d11_set_menu_texture_frame( d3d11_update_texture(d3d11->context, width, height, 0, format, frame, &d3d11->menu.texture); d3d11->menu.texture.sampler = d3d11->samplers - [config_get_ptr()->bools.menu_linear_filter - ? RARCH_FILTER_LINEAR - : RARCH_FILTER_NEAREST][RARCH_WRAP_DEFAULT]; + [config_get_ptr()->bools.menu_linear_filter + ? RARCH_FILTER_LINEAR + : RARCH_FILTER_NEAREST][RARCH_WRAP_DEFAULT]; } static void d3d11_set_menu_texture_enable(void* data, bool state, bool full_screen) From 3ff3cada719013a44d0a972c27119da63a348cbf Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 4 Feb 2018 21:13:41 +0100 Subject: [PATCH 074/232] CXX_BUILD is fixed again for Windows --- frontend/frontend.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/frontend/frontend.c b/frontend/frontend.c index 137d9fa0bf..bd2fecde6e 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -146,6 +146,9 @@ int rarch_main(int argc, char *argv[], void *data) } #ifndef HAVE_MAIN +#ifdef __cplusplus +extern "C" +#endif int main(int argc, char *argv[]) { return rarch_main(argc, argv, NULL); From 534e5bbf345c8182bce32f05271ff9e3d4400b03 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 4 Feb 2018 21:50:05 +0100 Subject: [PATCH 075/232] Make code compatible when compiled as C++ --- gfx/common/d3d_common.c | 104 +++++++++++++-------------- gfx/display_servers/dispserv_win32.c | 2 +- gfx/drivers/d3d10.c | 70 +++++++++++------- gfx/drivers/d3d11.c | 33 +++++---- 4 files changed, 118 insertions(+), 91 deletions(-) diff --git a/gfx/common/d3d_common.c b/gfx/common/d3d_common.c index 301b53b2c7..b1e2ff0888 100644 --- a/gfx/common/d3d_common.c +++ b/gfx/common/d3d_common.c @@ -358,7 +358,7 @@ bool d3d_check_device_type(void *_d3d, LPDIRECT3D9 d3d = (LPDIRECT3D9)_d3d; if (!d3d) return false; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) if (FAILED(d3d->CheckDeviceType( 0, D3DDEVTYPE_HAL, @@ -427,7 +427,7 @@ bool d3d_get_adapter_display_mode( return false; #ifdef _XBOX return true; -#elif defined(__cplusplus) +#elif defined(__cplusplus) && !defined(CINTERFACE) if (FAILED(d3d->GetAdapterDisplayMode(idx, (D3DDISPLAYMODE*)display_mode))) return false; #else @@ -469,7 +469,7 @@ bool d3d_swap(void *data, void *_dev) { #ifdef HAVE_D3D9 LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)_dev; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) #ifdef _XBOX dev->Present(NULL, NULL, NULL, NULL); #else @@ -522,7 +522,7 @@ void d3d_set_transform(void *_dev, #ifdef HAVE_D3D9 #ifndef _XBOX LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)_dev; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) dev->SetTransform((D3DTRANSFORMSTATETYPE)state, matrix); #else IDirect3DDevice9_SetTransform(dev, (D3DTRANSFORMSTATETYPE)state, matrix); @@ -558,7 +558,7 @@ bool d3d_texture_get_level_desc(void *_tex, { #ifdef HAVE_D3D9 LPDIRECT3DTEXTURE9 tex = (LPDIRECT3DTEXTURE9)_tex; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) if (SUCCEEDED(tex->GetLevelDesc(idx, (D3DSURFACE_DESC*)_ppsurface_level))) return true; #else @@ -606,7 +606,7 @@ bool d3d_texture_get_surface_level(void *_tex, LPDIRECT3DTEXTURE9 tex = (LPDIRECT3DTEXTURE9)_tex; if (!tex) return false; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) if (SUCCEEDED(tex->GetSurfaceLevel(idx, (IDirect3DSurface9**)_ppsurface_level))) return true; #else @@ -715,7 +715,7 @@ void *d3d_texture_new(void *_dev, if (want_mipmap) usage |= D3DUSAGE_AUTOGENMIPMAP; #endif -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) hr = dev->CreateTexture( width, height, miplevels, usage, (D3DFORMAT)format, @@ -768,7 +768,7 @@ void d3d_texture_free(void *_tex) LPDIRECT3DTEXTURE9 tex = (LPDIRECT3DTEXTURE9)_tex; if (!tex) return; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) tex->Release(); #else IDirect3DTexture9_Release(tex); @@ -806,7 +806,7 @@ bool d3d_surface_lock_rect(void *data, void *data2) LPDIRECT3DSURFACE9 surf = (LPDIRECT3DSURFACE9)data; if (!surf) return false; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) if (FAILED(surf->LockRect((D3DLOCKED_RECT*)data2, NULL, D3DLOCK_READONLY))) return false; #else @@ -855,7 +855,7 @@ void d3d_surface_unlock_rect(void *data) LPDIRECT3DSURFACE9 surf = (LPDIRECT3DSURFACE9)data; if (!surf) return; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) surf->UnlockRect(); #else IDirect3DSurface9_UnlockRect(surf); @@ -893,7 +893,7 @@ void d3d_surface_free(void *data) LPDIRECT3DSURFACE9 surf = (LPDIRECT3DSURFACE9)data; if (!surf) return; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) surf->Release(); #else IDirect3DSurface9_Release(surf); @@ -930,7 +930,7 @@ void d3d_vertex_declaration_free(void *data) { case GFX_CTX_DIRECT3D9_API: #ifdef HAVE_D3D9 -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) { LPDIRECT3DVERTEXDECLARATION9 vertex_decl = (LPDIRECT3DVERTEXDECLARATION9)data; @@ -961,7 +961,7 @@ bool d3d_vertex_declaration_new(void *_dev, const D3DVERTEXELEMENT9 *vertex_elements = (const D3DVERTEXELEMENT9*)vertex_data; LPDIRECT3DVERTEXDECLARATION9 **vertex_decl = (LPDIRECT3DVERTEXDECLARATION9**)decl_data; -#if defined(__cplusplus) +#if defined(__cplusplus) && !defined(CINTERFACE) if (SUCCEEDED(dev->CreateVertexDeclaration(vertex_elements, (IDirect3DVertexDeclaration9**)vertex_decl))) return true; #else @@ -996,7 +996,7 @@ void *d3d_vertex_buffer_new(void *_dev, if (usage == 0) { #ifndef _XBOX -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) if (dev->GetSoftwareVertexProcessing()) usage = D3DUSAGE_SOFTWAREPROCESSING; #else @@ -1006,7 +1006,7 @@ void *d3d_vertex_buffer_new(void *_dev, #endif } -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) hr = dev->CreateVertexBuffer(length, usage, fvf, (D3DPOOL)pool, (LPDIRECT3DVERTEXBUFFER9*)&buf, NULL); @@ -1055,7 +1055,7 @@ void d3d_vertex_buffer_unlock(void *vertbuf_ptr) if (!vertbuf) return; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) vertbuf->Unlock(); #else IDirect3DVertexBuffer9_Unlock(vertbuf); @@ -1097,7 +1097,7 @@ void *d3d_vertex_buffer_lock(void *vertbuf_ptr) LPDIRECT3DVERTEXBUFFER9 vertbuf = (LPDIRECT3DVERTEXBUFFER9)vertbuf_ptr; if (!vertbuf) return NULL; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) vertbuf->Lock(0, 0, &buf, 0); #else IDirect3DVertexBuffer9_Lock(vertbuf, 0, 0, &buf, 0); @@ -1139,7 +1139,7 @@ void d3d_vertex_buffer_free(void *vertex_data, void *vertex_declaration) if (vertex_data) { LPDIRECT3DVERTEXBUFFER9 buf = (LPDIRECT3DVERTEXBUFFER9)vertex_data; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) buf->Release(); #else IDirect3DVertexBuffer9_Release(buf); @@ -1189,7 +1189,7 @@ void d3d_set_stream_source(void *_dev, unsigned stream_no, LPDIRECT3DVERTEXBUFFER9 stream_vertbuf = (LPDIRECT3DVERTEXBUFFER9)stream_vertbuf_ptr; if (!stream_vertbuf) return; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) dev->SetStreamSource(stream_no, stream_vertbuf, offset_bytes, stride); #else IDirect3DDevice9_SetStreamSource(dev, stream_no, stream_vertbuf, @@ -1236,7 +1236,7 @@ bool d3d_device_create_offscreen_plain_surface( #ifndef _XBOX #ifdef HAVE_D3D9 LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)_dev; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) if (SUCCEEDED(dev->CreateOffscreenPlainSurface(width, height, (D3DFORMAT)format, (D3DPOOL)pool, (LPDIRECT3DSURFACE9*)surf_data, @@ -1274,7 +1274,7 @@ static void d3d_set_texture_stage_state(void *_dev, #ifndef _XBOX #ifdef HAVE_D3D9 LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)_dev; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) if (dev->SetTextureStageState(sampler, (D3DTEXTURESTAGESTATETYPE)type, value) != D3D_OK) RARCH_ERR("SetTextureStageState call failed, sampler: %d, value: %d, type: %d\n", sampler, value, type); #else @@ -1314,7 +1314,7 @@ void d3d_set_sampler_address_u(void *_dev, { #ifdef HAVE_D3D9 LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)_dev; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) dev->SetSamplerState(sampler, D3DSAMP_ADDRESSU, value); #else IDirect3DDevice9_SetSamplerState(dev, sampler, D3DSAMP_ADDRESSU, value); @@ -1345,7 +1345,7 @@ void d3d_set_sampler_address_v(void *_dev, { #ifdef HAVE_D3D9 LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)_dev; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) dev->SetSamplerState(sampler, D3DSAMP_ADDRESSV, value); #else IDirect3DDevice9_SetSamplerState(dev, sampler, D3DSAMP_ADDRESSV, value); @@ -1378,7 +1378,7 @@ void d3d_set_sampler_minfilter(void *_dev, LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)_dev; if (!dev) return; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) dev->SetSamplerState(sampler, D3DSAMP_MINFILTER, value); #else IDirect3DDevice9_SetSamplerState(dev, sampler, D3DSAMP_MINFILTER, value); @@ -1408,7 +1408,7 @@ void d3d_set_sampler_magfilter(void *_dev, LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)_dev; if (!dev) return; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) dev->SetSamplerState(sampler, D3DSAMP_MAGFILTER, value); #else IDirect3DDevice9_SetSamplerState(dev, sampler, D3DSAMP_MAGFILTER, value); @@ -1460,7 +1460,7 @@ bool d3d_begin_scene(void *_dev) LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)_dev; if (!dev) return false; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) if (FAILED(dev->BeginScene())) return false; #else @@ -1516,7 +1516,7 @@ void d3d_end_scene(void *_dev) LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)_dev; if (!dev) return; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) dev->EndScene(); #else IDirect3DDevice9_EndScene(dev); @@ -1555,7 +1555,7 @@ static void d3d_draw_primitive_internal(void *_dev, LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)_dev; if (!dev) return; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) dev->DrawPrimitive(type, start, count); #else IDirect3DDevice9_DrawPrimitive(dev, type, start, count); @@ -1605,7 +1605,7 @@ void d3d_clear(void *_dev, LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)_dev; if (!dev) return; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) dev->Clear(count, (const D3DRECT*)rects, flags, color, z, stencil); #else IDirect3DDevice9_Clear(dev, count, (const D3DRECT*)rects, flags, @@ -1650,7 +1650,7 @@ bool d3d_device_get_render_target_data(void *_dev, LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)_dev; if (!dev) return false; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) if (SUCCEEDED(dev->GetRenderTargetData(src, dst))) return true; #else @@ -1682,7 +1682,7 @@ bool d3d_device_get_render_target(void *_dev, LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)_dev; if (!dev) return false; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) if (SUCCEEDED(dev->GetRenderTarget(idx, (LPDIRECT3DSURFACE9*)data))) return true; @@ -1735,7 +1735,7 @@ bool d3d_lock_rectangle(void *_tex, LPDIRECT3DTEXTURE9 tex = (LPDIRECT3DTEXTURE9)_tex; if (!tex) return false; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) if (FAILED(tex->LockRect(level, lr, rect, flags))) return false; #else @@ -1783,7 +1783,7 @@ void d3d_unlock_rectangle(void *_tex) LPDIRECT3DTEXTURE9 tex = (LPDIRECT3DTEXTURE9)_tex; if (!tex) return; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) tex->UnlockRect(0); #else IDirect3DTexture9_UnlockRect(tex, 0); @@ -1834,7 +1834,7 @@ void d3d_set_viewports(void *_dev, void *_vp) D3DVIEWPORT9 *vp = (D3DVIEWPORT9*)_vp; if (!dev) return; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) dev->SetViewport(vp); #else IDirect3DDevice9_SetViewport(dev, vp); @@ -1875,7 +1875,7 @@ void d3d_set_texture(void *_dev, unsigned sampler, LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)_dev; if (!dev || !tex) return; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) dev->SetTexture(sampler, tex); #else IDirect3DDevice9_SetTexture(dev, sampler, @@ -1917,7 +1917,7 @@ void d3d_free_vertex_shader(void *_dev, void *data) IDirect3DVertexShader9 *vs = (IDirect3DVertexShader9*)data; if (!dev || !vs) return; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) vs->Release(); #else IDirect3DVertexShader9_Release(vs); @@ -1943,7 +1943,7 @@ void d3d_free_pixel_shader(void *_dev, void *data) IDirect3DPixelShader9 *ps = (IDirect3DPixelShader9*)data; if (!dev || !ps) return; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) ps->Release(); #else IDirect3DPixelShader9_Release(ps); @@ -1969,7 +1969,7 @@ bool d3d_create_vertex_shader(void *_dev, const DWORD *a, void **b) { #ifdef HAVE_D3D9 LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)_dev; -#if defined(__cplusplus) +#if defined(__cplusplus) && !defined(CINTERFACE) if (dev->CreateVertexShader(a, (IDirect3DVertexShader9**)b) == D3D_OK) return true; #else @@ -2000,7 +2000,7 @@ bool d3d_create_pixel_shader(void *_dev, const DWORD *a, void **b) { #ifdef HAVE_D3D9 LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)_dev; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) if (dev->CreatePixelShader(a, (IDirect3DPixelShader9**)b) == D3D_OK) return true; #else @@ -2031,7 +2031,7 @@ bool d3d_set_pixel_shader(void *_dev, void *data) LPDIRECT3DPIXELSHADER9 d3dps = (LPDIRECT3DPIXELSHADER9)data; if (!dev || !d3dps) return false; -#if defined(__cplusplus) +#if defined(__cplusplus) && !defined(CINTERFACE) if (dev->SetPixelShader(d3dps) == D3D_OK) return true; #else @@ -2066,7 +2066,7 @@ bool d3d_set_vertex_shader(void *_dev, unsigned index, #ifdef HAVE_D3D9 LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)_dev; LPDIRECT3DVERTEXSHADER9 shader = (LPDIRECT3DVERTEXSHADER9)data; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) if (dev->SetVertexShader(shader) != D3D_OK) return false; #else @@ -2114,7 +2114,7 @@ bool d3d_set_vertex_shader_constantf(void *_dev, { #if defined(HAVE_D3D9) LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)_dev; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) #ifdef _XBOX dev->SetVertexShaderConstantF( start_register, constant_data, vector4f_count); @@ -2170,7 +2170,7 @@ bool d3d_get_render_state(void *data, INT32 state, DWORD *value) { #ifdef HAVE_D3D9 LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)data; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) if (dev && dev->GetRenderState((D3DRENDERSTATETYPE)state, value) == D3D_OK) return true; #else @@ -2219,7 +2219,7 @@ void d3d_set_render_state(void *data, INT32 state, DWORD value) LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)data; if (!dev) return; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) dev->SetRenderState((D3DRENDERSTATETYPE)state, value); #else IDirect3DDevice9_SetRenderState(dev, (D3DRENDERSTATETYPE)state, value); @@ -2270,7 +2270,7 @@ void d3d_device_set_render_target(void *_dev, unsigned idx, LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)_dev; if (!dev) return; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) dev->SetRenderTarget(idx, surf); #else IDirect3DDevice9_SetRenderTarget(dev, idx, surf); @@ -2354,7 +2354,7 @@ void d3d_set_vertex_declaration(void *data, void *vertex_data) LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)data; if (!dev) return; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) dev->SetVertexDeclaration((LPDIRECT3DVERTEXDECLARATION9)vertex_data); #else IDirect3DDevice9_SetVertexDeclaration(dev, (LPDIRECT3DVERTEXDECLARATION9)vertex_data); @@ -2381,7 +2381,7 @@ static bool d3d_reset_internal(void *data, LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)data; if (!dev) return false; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) if ((dev->Reset(d3dpp) == D3D_OK)) return true; #else @@ -2426,7 +2426,7 @@ static HRESULT d3d_test_cooperative_level(void *data) LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)data; if (!dev) return E_FAIL; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) return dev->TestCooperativeLevel(); #else return IDirect3DDevice9_TestCooperativeLevel(dev); @@ -2476,7 +2476,7 @@ static bool d3d_create_device_internal( LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)data; if (!dev) return false; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) if (SUCCEEDED(d3d->CreateDevice( cur_mon_id, D3DDEVTYPE_HAL, @@ -2602,7 +2602,7 @@ bool d3d_device_get_backbuffer(void *_dev, LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)_dev; if (!dev) return false; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) if (SUCCEEDED(dev->GetBackBuffer( swapchain_idx, idx, (D3DBACKBUFFER_TYPE)backbuffer_type, @@ -2658,7 +2658,7 @@ void d3d_device_free(void *_dev, void *_pd3d) LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)_dev; if (dev) { -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) dev->Release(); #else IDirect3DDevice9_Release(dev); @@ -2667,7 +2667,7 @@ void d3d_device_free(void *_dev, void *_pd3d) if (pd3d) { -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) pd3d->Release(); #else IDirect3D9_Release(pd3d); diff --git a/gfx/display_servers/dispserv_win32.c b/gfx/display_servers/dispserv_win32.c index 6bc3895f10..715d1ddc24 100644 --- a/gfx/display_servers/dispserv_win32.c +++ b/gfx/display_servers/dispserv_win32.c @@ -42,7 +42,7 @@ static ITaskbarList3 *g_taskbarList = NULL; /* MSVC really doesn't want CINTERFACE to be used with shobjidl for some reason, but since we use C++ mode, * we need a workaround... so use the names of the COBJMACROS functions instead. */ -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) #define ITaskbarList3_Release(x) g_taskbarList->Release() #define ITaskbarList3_SetProgressState(a, b, c) g_taskbarList->SetProgressState(b, c) #define ITaskbarList3_SetProgressValue(a, b, c, d) g_taskbarList->SetProgressValue(b, c, d) diff --git a/gfx/drivers/d3d10.c b/gfx/drivers/d3d10.c index 3dde65aaf8..7ccc229863 100644 --- a/gfx/drivers/d3d10.c +++ b/gfx/drivers/d3d10.c @@ -166,13 +166,19 @@ d3d10_gfx_init(const video_info_t* video, const input_driver_t** input, void** i matrix_4x4_ortho(d3d10->mvp_no_rot, 0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f); { - D3D10_BUFFER_DESC desc = { - .ByteWidth = sizeof(math_matrix_4x4), - .Usage = D3D10_USAGE_DYNAMIC, - .BindFlags = D3D10_BIND_CONSTANT_BUFFER, - .CPUAccessFlags = D3D10_CPU_ACCESS_WRITE, - }; - D3D10_SUBRESOURCE_DATA ubo_data = { &d3d10->mvp_no_rot }; + D3D10_BUFFER_DESC desc; + D3D10_SUBRESOURCE_DATA ubo_data; + + desc.ByteWidth = sizeof(math_matrix_4x4); + desc.Usage = D3D10_USAGE_DYNAMIC; + desc.BindFlags = D3D10_BIND_CONSTANT_BUFFER; + desc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE; + desc.MiscFlags = 0; + + ubo_data.pSysMem = &d3d10->mvp_no_rot; + ubo_data.SysMemPitch = 0; + ubo_data.SysMemSlicePitch = 0; + D3D10CreateBuffer(d3d10->device, &desc, &ubo_data, &d3d10->ubo); D3D10CreateBuffer(d3d10->device, &desc, NULL, &d3d10->frame.ubo); } @@ -212,13 +218,19 @@ d3d10_gfx_init(const video_info_t* video, const input_driver_t** input, void** i }; { - D3D10_BUFFER_DESC desc = { - .ByteWidth = sizeof(vertices), - .Usage = D3D10_USAGE_DYNAMIC, - .BindFlags = D3D10_BIND_VERTEX_BUFFER, - .CPUAccessFlags = D3D10_CPU_ACCESS_WRITE, - }; - D3D10_SUBRESOURCE_DATA vertexData = { vertices }; + D3D10_SUBRESOURCE_DATA vertexData; + D3D10_BUFFER_DESC desc; + + desc.ByteWidth = sizeof(vertices); + desc.Usage = D3D10_USAGE_DYNAMIC; + desc.BindFlags = D3D10_BIND_VERTEX_BUFFER; + desc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE; + desc.MiscFlags = 0; + + vertexData.pSysMem = vertices; + vertexData.SysMemPitch = 0; + vertexData.SysMemSlicePitch = 0; + D3D10CreateBuffer(d3d10->device, &desc, &vertexData, &d3d10->frame.vbo); desc.Usage = D3D10_USAGE_IMMUTABLE; desc.CPUAccessFlags = 0; @@ -264,17 +276,25 @@ d3d10_gfx_init(const video_info_t* video, const input_driver_t** input, void** i D3D10SetPShader(d3d10->device, d3d10->ps); { - D3D10_BLEND_DESC blend_desc = { - .AlphaToCoverageEnable = FALSE, - .BlendEnable = { TRUE }, - D3D10_BLEND_SRC_ALPHA, - D3D10_BLEND_INV_SRC_ALPHA, - D3D10_BLEND_OP_ADD, - D3D10_BLEND_SRC_ALPHA, - D3D10_BLEND_INV_SRC_ALPHA, - D3D10_BLEND_OP_ADD, - { D3D10_COLOR_WRITE_ENABLE_ALL }, - }; + unsigned k; + D3D10_BLEND_DESC blend_desc; + + + + for (k = 0; k < 8; k++) + { + blend_desc.BlendEnable[k] = TRUE; + blend_desc.RenderTargetWriteMask[k] = D3D10_COLOR_WRITE_ENABLE_ALL; + } + + blend_desc.AlphaToCoverageEnable = FALSE; + blend_desc.SrcBlend = D3D10_BLEND_SRC_ALPHA; + blend_desc.DestBlend = D3D10_BLEND_INV_SRC_ALPHA; + blend_desc.BlendOp = D3D10_BLEND_OP_ADD; + blend_desc.SrcBlendAlpha = D3D10_BLEND_SRC_ALPHA; + blend_desc.DestBlendAlpha = D3D10_BLEND_INV_SRC_ALPHA; + blend_desc.BlendOpAlpha = D3D10_BLEND_OP_ADD; + D3D10CreateBlendState(d3d10->device, &blend_desc, &d3d10->blend_enable); blend_desc.BlendEnable[0] = FALSE; D3D10CreateBlendState(d3d10->device, &blend_desc, &d3d10->blend_disable); diff --git a/gfx/drivers/d3d11.c b/gfx/drivers/d3d11.c index 80829d168e..c16463b6a0 100644 --- a/gfx/drivers/d3d11.c +++ b/gfx/drivers/d3d11.c @@ -287,12 +287,13 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const for (j = 0; j < SLANG_CBUFFER_MAX; j++) { - D3D11_BUFFER_DESC desc = { - .ByteWidth = d3d11->pass[i].semantics.cbuffers[j].size, - .Usage = D3D11_USAGE_DYNAMIC, - .BindFlags = D3D11_BIND_CONSTANT_BUFFER, - .CPUAccessFlags = D3D11_CPU_ACCESS_WRITE, - }; + D3D11_BUFFER_DESC desc; + desc.ByteWidth = d3d11->pass[i].semantics.cbuffers[j].size; + desc.Usage = D3D11_USAGE_DYNAMIC; + desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; + desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + desc.MiscFlags = 0; + desc.StructureByteStride = 0; if (!desc.ByteWidth) continue; @@ -496,13 +497,19 @@ d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** i d3d11->ubo_values.OutputSize.height = d3d11->viewport.Height; { - D3D11_BUFFER_DESC desc = { - .ByteWidth = sizeof(d3d11->ubo_values), - .Usage = D3D11_USAGE_DYNAMIC, - .BindFlags = D3D11_BIND_CONSTANT_BUFFER, - .CPUAccessFlags = D3D11_CPU_ACCESS_WRITE, - }; - D3D11_SUBRESOURCE_DATA ubo_data = { &d3d11->ubo_values.mvp }; + D3D11_SUBRESOURCE_DATA ubo_data; + D3D11_BUFFER_DESC desc; + desc.ByteWidth = sizeof(d3d11->ubo_values); + desc.Usage = D3D11_USAGE_DYNAMIC; + desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; + desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + desc.MiscFlags = 0; + desc.StructureByteStride = 0; + + ubo_data.pSysMem = &d3d11->ubo_values.mvp; + ubo_data.SysMemPitch = 0; + ubo_data.SysMemSlicePitch = 0; + D3D11CreateBuffer(d3d11->device, &desc, &ubo_data, &d3d11->ubo); D3D11CreateBuffer(d3d11->device, &desc, NULL, &d3d11->frame.ubo); } From cbd5e87711128e078c221d80c45c7dd28afcfc25 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 4 Feb 2018 22:12:53 +0100 Subject: [PATCH 076/232] Indenting nits --- gfx/drivers/d3d10.c | 66 ++++++++++++++++++++++----------------------- gfx/drivers/d3d11.c | 32 +++++++++++----------- gfx/drivers/d3d12.c | 14 +++++----- 3 files changed, 56 insertions(+), 56 deletions(-) diff --git a/gfx/drivers/d3d10.c b/gfx/drivers/d3d10.c index 7ccc229863..c0f41e9f2d 100644 --- a/gfx/drivers/d3d10.c +++ b/gfx/drivers/d3d10.c @@ -166,18 +166,18 @@ d3d10_gfx_init(const video_info_t* video, const input_driver_t** input, void** i matrix_4x4_ortho(d3d10->mvp_no_rot, 0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f); { - D3D10_BUFFER_DESC desc; - D3D10_SUBRESOURCE_DATA ubo_data; + D3D10_BUFFER_DESC desc; + D3D10_SUBRESOURCE_DATA ubo_data; - desc.ByteWidth = sizeof(math_matrix_4x4); - desc.Usage = D3D10_USAGE_DYNAMIC; + desc.ByteWidth = sizeof(math_matrix_4x4); + desc.Usage = D3D10_USAGE_DYNAMIC; desc.BindFlags = D3D10_BIND_CONSTANT_BUFFER; desc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE; - desc.MiscFlags = 0; + desc.MiscFlags = 0; - ubo_data.pSysMem = &d3d10->mvp_no_rot; - ubo_data.SysMemPitch = 0; - ubo_data.SysMemSlicePitch = 0; + ubo_data.pSysMem = &d3d10->mvp_no_rot; + ubo_data.SysMemPitch = 0; + ubo_data.SysMemSlicePitch = 0; D3D10CreateBuffer(d3d10->device, &desc, &ubo_data, &d3d10->ubo); D3D10CreateBuffer(d3d10->device, &desc, NULL, &d3d10->frame.ubo); @@ -218,18 +218,18 @@ d3d10_gfx_init(const video_info_t* video, const input_driver_t** input, void** i }; { - D3D10_SUBRESOURCE_DATA vertexData; - D3D10_BUFFER_DESC desc; + D3D10_SUBRESOURCE_DATA vertexData; + D3D10_BUFFER_DESC desc; - desc.ByteWidth = sizeof(vertices); - desc.Usage = D3D10_USAGE_DYNAMIC; - desc.BindFlags = D3D10_BIND_VERTEX_BUFFER; - desc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE; - desc.MiscFlags = 0; + desc.ByteWidth = sizeof(vertices); + desc.Usage = D3D10_USAGE_DYNAMIC; + desc.BindFlags = D3D10_BIND_VERTEX_BUFFER; + desc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE; + desc.MiscFlags = 0; - vertexData.pSysMem = vertices; - vertexData.SysMemPitch = 0; - vertexData.SysMemSlicePitch = 0; + vertexData.pSysMem = vertices; + vertexData.SysMemPitch = 0; + vertexData.SysMemSlicePitch = 0; D3D10CreateBuffer(d3d10->device, &desc, &vertexData, &d3d10->frame.vbo); desc.Usage = D3D10_USAGE_IMMUTABLE; @@ -276,24 +276,24 @@ d3d10_gfx_init(const video_info_t* video, const input_driver_t** input, void** i D3D10SetPShader(d3d10->device, d3d10->ps); { - unsigned k; - D3D10_BLEND_DESC blend_desc; + unsigned k; + D3D10_BLEND_DESC blend_desc; - - for (k = 0; k < 8; k++) - { - blend_desc.BlendEnable[k] = TRUE; - blend_desc.RenderTargetWriteMask[k] = D3D10_COLOR_WRITE_ENABLE_ALL; - } - blend_desc.AlphaToCoverageEnable = FALSE; - blend_desc.SrcBlend = D3D10_BLEND_SRC_ALPHA; - blend_desc.DestBlend = D3D10_BLEND_INV_SRC_ALPHA; - blend_desc.BlendOp = D3D10_BLEND_OP_ADD; - blend_desc.SrcBlendAlpha = D3D10_BLEND_SRC_ALPHA; - blend_desc.DestBlendAlpha = D3D10_BLEND_INV_SRC_ALPHA; - blend_desc.BlendOpAlpha = D3D10_BLEND_OP_ADD; + for (k = 0; k < 8; k++) + { + blend_desc.BlendEnable[k] = TRUE; + blend_desc.RenderTargetWriteMask[k] = D3D10_COLOR_WRITE_ENABLE_ALL; + } + + blend_desc.AlphaToCoverageEnable = FALSE; + blend_desc.SrcBlend = D3D10_BLEND_SRC_ALPHA; + blend_desc.DestBlend = D3D10_BLEND_INV_SRC_ALPHA; + blend_desc.BlendOp = D3D10_BLEND_OP_ADD; + blend_desc.SrcBlendAlpha = D3D10_BLEND_SRC_ALPHA; + blend_desc.DestBlendAlpha = D3D10_BLEND_INV_SRC_ALPHA; + blend_desc.BlendOpAlpha = D3D10_BLEND_OP_ADD; D3D10CreateBlendState(d3d10->device, &blend_desc, &d3d10->blend_enable); blend_desc.BlendEnable[0] = FALSE; diff --git a/gfx/drivers/d3d11.c b/gfx/drivers/d3d11.c index c16463b6a0..1546a32a18 100644 --- a/gfx/drivers/d3d11.c +++ b/gfx/drivers/d3d11.c @@ -287,13 +287,13 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const for (j = 0; j < SLANG_CBUFFER_MAX; j++) { - D3D11_BUFFER_DESC desc; - desc.ByteWidth = d3d11->pass[i].semantics.cbuffers[j].size; - desc.Usage = D3D11_USAGE_DYNAMIC; - desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; - desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - desc.MiscFlags = 0; - desc.StructureByteStride = 0; + D3D11_BUFFER_DESC desc; + desc.ByteWidth = d3d11->pass[i].semantics.cbuffers[j].size; + desc.Usage = D3D11_USAGE_DYNAMIC; + desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; + desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + desc.MiscFlags = 0; + desc.StructureByteStride = 0; if (!desc.ByteWidth) continue; @@ -499,16 +499,16 @@ d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** i { D3D11_SUBRESOURCE_DATA ubo_data; D3D11_BUFFER_DESC desc; - desc.ByteWidth = sizeof(d3d11->ubo_values); - desc.Usage = D3D11_USAGE_DYNAMIC; - desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; - desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - desc.MiscFlags = 0; - desc.StructureByteStride = 0; + desc.ByteWidth = sizeof(d3d11->ubo_values); + desc.Usage = D3D11_USAGE_DYNAMIC; + desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; + desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + desc.MiscFlags = 0; + desc.StructureByteStride = 0; - ubo_data.pSysMem = &d3d11->ubo_values.mvp; - ubo_data.SysMemPitch = 0; - ubo_data.SysMemSlicePitch = 0; + ubo_data.pSysMem = &d3d11->ubo_values.mvp; + ubo_data.SysMemPitch = 0; + ubo_data.SysMemSlicePitch = 0; D3D11CreateBuffer(d3d11->device, &desc, &ubo_data, &d3d11->ubo); D3D11CreateBuffer(d3d11->device, &desc, NULL, &d3d11->frame.ubo); diff --git a/gfx/drivers/d3d12.c b/gfx/drivers/d3d12.c index 292647717c..7c8fa7232f 100644 --- a/gfx/drivers/d3d12.c +++ b/gfx/drivers/d3d12.c @@ -80,7 +80,7 @@ static void d3d12_update_viewport(void* data, bool force_full) d3d12->resize_viewport = false; } -static void* + static void* d3d12_gfx_init(const video_info_t* video, const input_driver_t** input, void** input_data) { WNDCLASSEX wndclass = { 0 }; @@ -127,15 +127,15 @@ d3d12_gfx_init(const video_info_t* video, const input_driver_t** input, void** i d3d12->chain.vsync = video->vsync; d3d12->format = video->rgb32 ? DXGI_FORMAT_B8G8R8X8_UNORM : DXGI_FORMAT_B5G6R5_UNORM; d3d12->frame.texture.desc.Format = - d3d12_get_closest_match_texture2D(d3d12->device, d3d12->format); + d3d12_get_closest_match_texture2D(d3d12->device, d3d12->format); d3d12->ubo_view.SizeInBytes = sizeof(math_matrix_4x4); d3d12->ubo_view.BufferLocation = - d3d12_create_buffer(d3d12->device, d3d12->ubo_view.SizeInBytes, &d3d12->ubo); + d3d12_create_buffer(d3d12->device, d3d12->ubo_view.SizeInBytes, &d3d12->ubo); d3d12->frame.ubo_view.SizeInBytes = sizeof(math_matrix_4x4); d3d12->frame.ubo_view.BufferLocation = - d3d12_create_buffer(d3d12->device, d3d12->frame.ubo_view.SizeInBytes, &d3d12->frame.ubo); + d3d12_create_buffer(d3d12->device, d3d12->frame.ubo_view.SizeInBytes, &d3d12->frame.ubo); matrix_4x4_ortho(d3d12->mvp_no_rot, 0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f); @@ -200,7 +200,7 @@ static bool d3d12_gfx_frame( D3D12SetGraphicsRootSignature(d3d12->queue.cmd, d3d12->pipe.rootSignature); { D3D12DescriptorHeap desc_heaps[] = { d3d12->pipe.srv_heap.handle, - d3d12->pipe.sampler_heap.handle }; + d3d12->pipe.sampler_heap.handle }; D3D12SetDescriptorHeaps(d3d12->queue.cmd, countof(desc_heaps), desc_heaps); } @@ -232,7 +232,7 @@ static bool d3d12_gfx_frame( #if 0 /* custom viewport doesn't call apply_state_changes, so we can't rely on this for now */ if (d3d12->resize_viewport) #endif - d3d12_update_viewport(d3d12, false); + d3d12_update_viewport(d3d12, false); D3D12RSSetViewports(d3d12->queue.cmd, 1, &d3d12->frame.viewport); D3D12RSSetScissorRects(d3d12->queue.cmd, 1, &d3d12->frame.scissorRect); @@ -426,7 +426,7 @@ static void d3d12_set_menu_texture_frame( D3D12Unmap(d3d12->menu.vbo, 0, NULL); } d3d12->menu.sampler = config_get_ptr()->bools.menu_linear_filter ? d3d12->sampler_linear - : d3d12->sampler_nearest; + : d3d12->sampler_nearest; } static void d3d12_set_menu_texture_enable(void* data, bool state, bool full_screen) { From b67bb87c8d266402bc218c79b72e99ec78f8c660 Mon Sep 17 00:00:00 2001 From: orbea Date: Sun, 4 Feb 2018 13:06:58 -0800 Subject: [PATCH 077/232] qb: Add --datarootdir to configure. This allows a user to use --datarootdir=PATH to configure the share directory used for pixmaps, desktop files, man pages and assets. By default this will be '/usr/local/share'. Assets and man page install paths can still be configured with: --with-man_dir=PATH and --with-assets_dir=PATH Some operating systems like Haiku use unconventional install paths and this should allow them to configure their build correctly. --- Makefile | 26 +++++++++++++------------- qb/config.libs.sh | 5 +++-- qb/qb.libs.sh | 3 ++- qb/qb.params.sh | 2 ++ 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index c4867112bb..d8d336f203 100644 --- a/Makefile +++ b/Makefile @@ -201,29 +201,29 @@ install: $(TARGET) rm -f $(OBJDIR)/git_version.o mkdir -p $(DESTDIR)$(BIN_DIR) 2>/dev/null || /bin/true mkdir -p $(DESTDIR)$(GLOBAL_CONFIG_DIR) 2>/dev/null || /bin/true - mkdir -p $(DESTDIR)$(PREFIX)/share/applications 2>/dev/null || /bin/true + mkdir -p $(DESTDIR)$(DATA_DIR)/applications 2>/dev/null || /bin/true mkdir -p $(DESTDIR)$(MAN_DIR)/man6 2>/dev/null || /bin/true - mkdir -p $(DESTDIR)$(PREFIX)/share/pixmaps 2>/dev/null || /bin/true + mkdir -p $(DESTDIR)$(DATA_DIR)/pixmaps 2>/dev/null || /bin/true cp $(TARGET) $(DESTDIR)$(BIN_DIR) cp tools/cg2glsl.py $(DESTDIR)$(BIN_DIR)/retroarch-cg2glsl cp retroarch.cfg $(DESTDIR)$(GLOBAL_CONFIG_DIR) - cp retroarch.desktop $(DESTDIR)$(PREFIX)/share/applications + cp retroarch.desktop $(DESTDIR)$(DATA_DIR)/applications cp docs/retroarch.6 $(DESTDIR)$(MAN_DIR)/man6 cp docs/retroarch-cg2glsl.6 $(DESTDIR)$(MAN_DIR)/man6 - cp media/retroarch.svg $(DESTDIR)$(PREFIX)/share/pixmaps + cp media/retroarch.svg $(DESTDIR)$(DATA_DIR)/pixmaps chmod 755 $(DESTDIR)$(BIN_DIR)/$(TARGET) chmod 755 $(DESTDIR)$(BIN_DIR)/retroarch-cg2glsl chmod 644 $(DESTDIR)$(GLOBAL_CONFIG_DIR)/retroarch.cfg - chmod 644 $(DESTDIR)$(PREFIX)/share/applications/retroarch.desktop + chmod 644 $(DESTDIR)$(DATA_DIR)/applications/retroarch.desktop chmod 644 $(DESTDIR)$(MAN_DIR)/man6/retroarch.6 chmod 644 $(DESTDIR)$(MAN_DIR)/man6/retroarch-cg2glsl.6 - chmod 644 $(DESTDIR)$(PREFIX)/share/pixmaps/retroarch.svg + chmod 644 $(DESTDIR)$(DATA_DIR)/pixmaps/retroarch.svg @if test -d media/assets; then \ echo "Installing media assets..."; \ - mkdir -p $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/xmb; \ - mkdir -p $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/glui; \ - cp -r media/assets/xmb/ $(DESTDIR)$(ASSETS_DIR)/retroarch/assets; \ - cp -r media/assets/glui/ $(DESTDIR)$(ASSETS_DIR)/retroarch/assets; \ + mkdir -p $(DESTDIR)$(ASSETS_DIR)/assets/xmb; \ + mkdir -p $(DESTDIR)$(ASSETS_DIR)/assets/glui; \ + cp -r media/assets/xmb/ $(DESTDIR)$(ASSETS_DIR)/assets; \ + cp -r media/assets/glui/ $(DESTDIR)$(ASSETS_DIR)/assets; \ echo "Asset copying done."; \ fi @@ -231,11 +231,11 @@ uninstall: rm -f $(DESTDIR)$(BIN_DIR)/retroarch rm -f $(DESTDIR)$(BIN_DIR)/retroarch-cg2glsl rm -f $(DESTDIR)$(GLOBAL_CONFIG_DIR)/retroarch.cfg - rm -f $(DESTDIR)$(PREFIX)/share/applications/retroarch.desktop + rm -f $(DESTDIR)$(DATA_DIR)/applications/retroarch.desktop rm -f $(DESTDIR)$(MAN_DIR)/man6/retroarch.6 rm -f $(DESTDIR)$(MAN_DIR)/man6/retroarch-cg2glsl.6 - rm -f $(DESTDIR)$(PREFIX)/share/pixmaps/retroarch.svg - rm -rf $(DESTDIR)$(ASSETS_DIR)/retroarch + rm -f $(DESTDIR)$(DATA_DIR)/pixmaps/retroarch.svg + rm -rf $(DESTDIR)$(ASSETS_DIR) clean: rm -rf $(OBJDIR_BASE) diff --git a/qb/config.libs.sh b/qb/config.libs.sh index f1b5ca6dbe..b790669ddd 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -44,6 +44,7 @@ elif [ "$OS" = 'SunOS' ]; then SORT='gsort' fi +add_define MAKEFILE DATA_DIR "$SHARE_DIR" add_define MAKEFILE DYLIB_LIB "$DYLIB" check_lib '' SYSTEMD -lsystemd sd_get_machine_names @@ -157,9 +158,9 @@ fi add_define MAKEFILE libretro "$LIBRETRO" } -add_define MAKEFILE ASSETS_DIR "${ASSETS_DIR:-${PREFIX}/share}" +add_define MAKEFILE ASSETS_DIR "${ASSETS_DIR:-$SHARE_DIR}/retroarch" add_define MAKEFILE BIN_DIR "${BIN_DIR:-${PREFIX}/bin}" -add_define MAKEFILE MAN_DIR "${MAN_DIR:-${PREFIX}/share/man}" +add_define MAKEFILE MAN_DIR "${MAN_DIR:-${SHARE_DIR}/man}" if [ "$OS" = 'DOS' ]; then HAVE_SHADERPIPELINE=no diff --git a/qb/qb.libs.sh b/qb/qb.libs.sh index c259f6e128..453de6a612 100644 --- a/qb/qb.libs.sh +++ b/qb/qb.libs.sh @@ -1,7 +1,8 @@ MAKEFILE_DEFINES='' CONFIG_DEFINES='' -[ "$PREFIX" ] || PREFIX="/usr/local" +PREFIX="${PREFIX:-/usr/local}" +SHARE_DIR="${SHARE_DIR:-${PREFIX}/share}" add_define() # $1 = MAKEFILE or CONFIG $2 = define $3 = value { eval "${1}_DEFINES=\"\${${1}_DEFINES} $2=$3\""; } diff --git a/qb/qb.params.sh b/qb/qb.params.sh index d574c60057..f90b28aecb 100644 --- a/qb/qb.params.sh +++ b/qb/qb.params.sh @@ -34,6 +34,7 @@ General options: EOF print_help_option "--prefix=PATH" "Install path prefix" print_help_option "--global-config-dir=PATH" "System wide config file prefix" + print_help_option "--datarootdir=PATH" "Read-only data install directory" print_help_option "--build=BUILD" "The build system (no-op)" print_help_option "--host=HOST" "Cross-compile with HOST-gcc instead of gcc" print_help_option "--help" "Show this help" @@ -85,6 +86,7 @@ parse_input() # Parse stuff :V --prefix=*) PREFIX=${1##--prefix=};; --global-config-dir=*) GLOBAL_CONFIG_DIR=${1##--global-config-dir=};; --build=*) BUILD="${1#*=}";; + --datarootdir=*) SHARE_DIR="${1#*=}";; --host=*) CROSS_COMPILE=${1##--host=}-;; --enable-*) opt_exists "${1##--enable-}" "$1" From 32888c1f17974d6f0ab45a00c0de24daab87bb81 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 4 Feb 2018 23:02:52 +0100 Subject: [PATCH 078/232] Cleanup some allocations --- command.c | 24 +++++----- configuration.c | 125 ++++++++++++++++++++++-------------------------- retroarch.c | 13 ++--- 3 files changed, 74 insertions(+), 88 deletions(-) diff --git a/command.c b/command.c index ec0fcfbf02..abb22894df 100644 --- a/command.c +++ b/command.c @@ -1418,16 +1418,15 @@ static bool command_event_save_core_config(void) bool found_path = false; bool overrides_active = false; const char *core_path = NULL; + char *config_name = NULL; + char *config_path = NULL; char *config_dir = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); - char *config_name = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); - char *config_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); size_t config_size = PATH_MAX_LENGTH * sizeof(char); settings_t *settings = config_get_ptr(); - config_dir[0] = config_name[0] = - config_path[0] = msg[0] = '\0'; + config_dir[0] = msg[0] = '\0'; - if (!string_is_empty(settings->paths.directory_menu_config)) + if (settings && !string_is_empty(settings->paths.directory_menu_config)) strlcpy(config_dir, settings->paths.directory_menu_config, config_size); else if (!path_is_empty(RARCH_PATH_CONFIG)) /* Fallback */ @@ -1437,10 +1436,15 @@ static bool command_event_save_core_config(void) { runloop_msg_queue_push(msg_hash_to_str(MSG_CONFIG_DIRECTORY_NOT_SET), 1, 180, true); RARCH_ERR("[Config]: %s\n", msg_hash_to_str(MSG_CONFIG_DIRECTORY_NOT_SET)); - goto error; + free(config_dir); + return false; } - core_path = path_get(RARCH_PATH_CORE); + core_path = path_get(RARCH_PATH_CORE); + config_name = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + config_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + config_name[0] = '\0'; + config_path[0] = '\0'; /* Infer file name based on libretro core. */ if (!string_is_empty(core_path) && filestream_exists(core_path)) @@ -1514,12 +1518,6 @@ static bool command_event_save_core_config(void) free(config_name); free(config_path); return ret; - -error: - free(config_dir); - free(config_name); - free(config_path); - return false; } /** diff --git a/configuration.c b/configuration.c index 6193363d11..6ade326f55 100644 --- a/configuration.c +++ b/configuration.c @@ -2940,24 +2940,23 @@ end: bool config_load_override(void) { size_t path_size = PATH_MAX_LENGTH * sizeof(char); - char *buf = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); - char *config_directory = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); - char *core_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); - char *game_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + char *buf = NULL; + char *core_path = NULL; + char *game_path = NULL; + char *config_directory = NULL; config_file_t *new_conf = NULL; - const char *core_name = NULL; - const char *game_name = NULL; bool should_append = false; rarch_system_info_t *system = runloop_get_system_info(); - - if (system) - core_name = system->info.library_name; - - game_name = path_basename(path_get(RARCH_PATH_BASENAME)); + const char *core_name = system ? system->info.library_name : NULL; + const char *game_name = path_basename(path_get(RARCH_PATH_BASENAME)); if (string_is_empty(core_name) || string_is_empty(game_name)) - goto error; + return false; + game_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + core_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + buf = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + config_directory = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); config_directory[0] = core_path[0] = game_path[0] = '\0'; fill_pathname_application_special(config_directory, path_size, @@ -3110,28 +3109,29 @@ bool config_unload_override(void) bool config_load_remap(void) { size_t path_size = PATH_MAX_LENGTH * sizeof(char); - char *remap_directory = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); /* path to the directory containing retroarch.cfg (prefix) */ - char *core_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); /* final path for core-specific configuration (prefix+suffix) */ - char *game_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); /* final path for game-specific configuration (prefix+suffix) */ + char *remap_directory = NULL; + char *core_path = NULL; + char *game_path = NULL; config_file_t *new_conf = NULL; - const char *core_name = NULL; - const char *game_name = NULL; settings_t *settings = config_get_ptr(); rarch_system_info_t *system = runloop_get_system_info(); - - if (system) - core_name = system->info.library_name; - - game_name = path_basename(path_get(RARCH_PATH_BASENAME)); + const char *core_name = system ? system->info.library_name : NULL; + const char *game_name = path_basename(path_get(RARCH_PATH_BASENAME)); if (string_is_empty(core_name) || string_is_empty(game_name)) - goto error; + return false; /* Remap directory: remap_directory. * Try remap directory setting, no fallbacks defined */ if (string_is_empty(settings->paths.directory_input_remapping)) - goto error; + return false; + /* path to the directory containing retroarch.cfg (prefix) */ + remap_directory = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + /* final path for core-specific configuration (prefix+suffix) */ + core_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + /* final path for game-specific configuration (prefix+suffix) */ + game_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); remap_directory[0] = core_path[0] = game_path[0] = '\0'; strlcpy(remap_directory, @@ -3194,7 +3194,6 @@ bool config_load_remap(void) new_conf = NULL; -error: free(remap_directory); free(core_path); free(game_path); @@ -3223,29 +3222,30 @@ success: bool config_load_shader_preset(void) { unsigned idx; - config_file_t *new_conf = NULL; size_t path_size = PATH_MAX_LENGTH * sizeof(char); - char *shader_directory = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); /* path to the directory containing retroarch.cfg (prefix) */ - char *core_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); /* final path for core-specific configuration (prefix+suffix) */ - char *game_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); /* final path for game-specific configuration (prefix+suffix) */ - const char *core_name = NULL; - const char *game_name = NULL; + config_file_t *new_conf = NULL; + char *shader_directory = NULL; + char *core_path = NULL; + char *game_path = NULL; settings_t *settings = config_get_ptr(); rarch_system_info_t *system = runloop_get_system_info(); - - if (system) - core_name = system->info.library_name; - - game_name = path_basename(path_get(RARCH_PATH_BASENAME)); + const char *core_name = system ? system->info.library_name : NULL; + const char *game_name = path_basename(path_get(RARCH_PATH_BASENAME)); if (string_is_empty(core_name) || string_is_empty(game_name)) - goto error; + return false; /* Shader directory: shader_directory. * Try shader directory setting, no fallbacks defined */ if (string_is_empty(settings->paths.directory_video_shader)) - goto error; + return false; + /* path to the directory containing retroarch.cfg (prefix) */ + shader_directory = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + /* final path for core-specific configuration (prefix+suffix) */ + core_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + /* final path for game-specific configuration (prefix+suffix) */ + game_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); shader_directory[0] = core_path[0] = game_path[0] = '\0'; fill_pathname_join (shader_directory, settings->paths.directory_video_shader, @@ -3315,7 +3315,6 @@ bool config_load_shader_preset(void) goto success; } -error: free(shader_directory); free(core_path); free(game_path); @@ -3596,24 +3595,25 @@ static bool config_save_keybinds_file(const char *path) bool config_save_autoconf_profile(const char *path, unsigned user) { unsigned i; - char *buf = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); - char *autoconf_file = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + char *buf = NULL; + char *autoconf_file = NULL; char *path_new = NULL; + config_file_t *conf = NULL; size_t path_size = PATH_MAX_LENGTH * sizeof(char); int32_t pid_user = 0; int32_t vid_user = 0; bool ret = false; - config_file_t *conf = NULL; settings_t *settings = config_get_ptr(); const char *autoconf_dir = settings->paths.directory_autoconfig; const char *joypad_ident = settings->arrays.input_joypad_driver; - buf[0] = autoconf_file[0] = '\0'; - if (string_is_empty(path)) - goto error; + return false; - path_new = strdup(path); + buf = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + autoconf_file = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + buf[0] = autoconf_file[0] = '\0'; + path_new = strdup(path); for (i = 0; invalid_filename_chars[i]; i++) { @@ -3920,15 +3920,9 @@ bool config_save_file(const char *path) bool config_save_overrides(int override_type) { size_t path_size = PATH_MAX_LENGTH * sizeof(char); - char *config_directory = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); - char *override_directory = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); - char *core_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); - char *game_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); int tmp_i = 0; unsigned i = 0; bool ret = false; - const char *core_name = NULL; - const char *game_name = NULL; config_file_t *conf = NULL; settings_t *settings = NULL; struct config_bool_setting *bool_settings = NULL; @@ -3943,6 +3937,10 @@ bool config_save_overrides(int override_type) struct config_array_setting *array_overrides= NULL; struct config_path_setting *path_settings = NULL; struct config_path_setting *path_overrides = NULL; + char *config_directory = NULL; + char *override_directory = NULL; + char *core_path = NULL; + char *game_path = NULL; settings_t *overrides = config_get_ptr(); int bool_settings_size = sizeof(settings->bools) / sizeof(settings->bools.placeholder); int float_settings_size = sizeof(settings->floats) / sizeof(settings->floats.placeholder); @@ -3951,16 +3949,17 @@ bool config_save_overrides(int override_type) int array_settings_size = sizeof(settings->arrays) / sizeof(settings->arrays.placeholder); int path_settings_size = sizeof(settings->paths) / sizeof(settings->paths.placeholder); rarch_system_info_t *system = runloop_get_system_info(); - - if (system) - core_name = system->info.library_name; - - game_name = path_basename(path_get(RARCH_PATH_BASENAME)); + const char *core_name = system ? system->info.library_name : NULL; + const char *game_name = path_basename(path_get(RARCH_PATH_BASENAME)); if (string_is_empty(core_name) || string_is_empty(game_name)) - goto error; + return false; - settings = (settings_t*)calloc(1, sizeof(settings_t)); + settings = (settings_t*)calloc(1, sizeof(settings_t)); + config_directory = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + override_directory = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + core_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + game_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); config_directory[0] = override_directory[0] = core_path[0] = game_path[0] = '\0'; @@ -4175,14 +4174,6 @@ bool config_save_overrides(int override_type) free(game_path); return ret; - -error: - free(config_directory); - free(override_directory); - free(core_path); - free(game_path); - - return false; } /* Replaces currently loaded configuration file with diff --git a/retroarch.c b/retroarch.c index a50fd67277..a5afe79e6e 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1114,15 +1114,17 @@ static bool retroarch_init_state(void) bool retroarch_validate_game_options(char *s, size_t len, bool mkdir) { - char *core_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); - char *config_directory = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + char *core_path = NULL; + char *config_directory = NULL; size_t str_size = PATH_MAX_LENGTH * sizeof(char); const char *core_name = runloop_system.info.library_name; const char *game_name = path_basename(path_get(RARCH_PATH_BASENAME)); if (string_is_empty(core_name) || string_is_empty(game_name)) - goto error; + return false; + core_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + config_directory = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); config_directory[0] = core_path[0] = '\0'; fill_pathname_application_special(config_directory, @@ -1143,11 +1145,6 @@ bool retroarch_validate_game_options(char *s, size_t len, bool mkdir) free(core_path); free(config_directory); return true; - -error: - free(core_path); - free(config_directory); - return false; } /* Validates CPU features for given processor architecture. From c830d0273d7f591c2e914f67bf90eef1ca838bbb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 4 Feb 2018 23:07:24 +0100 Subject: [PATCH 079/232] (core_info.c) cleanup memory allocations --- core_info.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/core_info.c b/core_info.c index 91fd882698..76b979046b 100644 --- a/core_info.c +++ b/core_info.c @@ -522,19 +522,21 @@ static bool core_info_list_update_missing_firmware_internal( { size_t i; core_info_t *info = NULL; + char *path = NULL; size_t path_size = PATH_MAX_LENGTH * sizeof(char); - char *path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); if (!core_info_list || !core) - goto error; + return false; - path[0] = '\0'; - info = core_info_find_internal(core_info_list, core); + info = core_info_find_internal(core_info_list, core); if (!info) - goto error; + return false; + path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + path[0] = '\0'; rarch_ctl(RARCH_CTL_UNSET_MISSING_BIOS, NULL); + for (i = 0; i < info->firmware_count; i++) { if (string_is_empty(info->firmware[i].path)) @@ -552,10 +554,6 @@ static bool core_info_list_update_missing_firmware_internal( free(path); return true; - -error: - free(path); - return false; } #if 0 From f364d2d3ecadc2b51bf6004ebe6a33a7e462b04f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 4 Feb 2018 23:25:12 +0100 Subject: [PATCH 080/232] (C89) Don't build D3D9/10/11/12 --- gfx/common/d3d11_common.c | 11 +++++++---- qb/config.params.sh | 4 ++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/gfx/common/d3d11_common.c b/gfx/common/d3d11_common.c index 8cc91ab1c8..3a2c043405 100644 --- a/gfx/common/d3d11_common.c +++ b/gfx/common/d3d11_common.c @@ -70,15 +70,18 @@ void d3d11_init_texture(D3D11Device device, d3d11_texture_t* texture) texture->desc.ArraySize = 1; texture->desc.SampleDesc.Count = 1; texture->desc.SampleDesc.Quality = 0; - texture->desc.BindFlags |= D3D11_BIND_SHADER_RESOURCE; - texture->desc.CPUAccessFlags = + texture->desc.BindFlags |= D3D11_BIND_SHADER_RESOURCE; + texture->desc.CPUAccessFlags = texture->desc.Usage == D3D11_USAGE_DYNAMIC ? D3D11_CPU_ACCESS_WRITE : 0; if (texture->desc.MiscFlags & D3D11_RESOURCE_MISC_GENERATE_MIPS) { + unsigned width, height; + texture->desc.BindFlags |= D3D11_BIND_RENDER_TARGET; - unsigned width = texture->desc.Width >> 5; - unsigned height = texture->desc.Height >> 5; + width = texture->desc.Width >> 5; + height = texture->desc.Height >> 5; + while (width && height) { width >>= 1; diff --git a/qb/config.params.sh b/qb/config.params.sh index 6cbeec3fc6..6a06ebfebb 100644 --- a/qb/config.params.sh +++ b/qb/config.params.sh @@ -37,9 +37,13 @@ HAVE_BUILTINMINIUPNPC=yes # Bake in Mini UPnP client library (for NAT traversal C89_BUILTINMINIUPNPC=no HAVE_D3D8=no # Direct3D 8 support HAVE_D3D9=yes # Direct3D 9 support +C89_D3D9=no HAVE_D3D10=yes # Direct3D 10 support +C89_D3D10=no HAVE_D3D11=yes # Direct3D 11 support +C89_D3D11=no HAVE_D3D12=yes # Direct3D 12 support +C89_D3D12=no HAVE_D3DX=yes # Direct3DX support HAVE_OPENGL=auto # OpenGL support HAVE_MALI_FBDEV=no # Mali fbdev context support From fa07570f76726f918f06f9ad4e3fdb4a799fbe65 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 4 Feb 2018 23:40:27 +0100 Subject: [PATCH 081/232] Simplify fill_pathname_representation_wrapper --- file_path_special.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/file_path_special.c b/file_path_special.c index f248a0bc6d..e58d10032f 100644 --- a/file_path_special.c +++ b/file_path_special.c @@ -383,19 +383,18 @@ void fill_pathname_application_special(char *s, void fill_short_pathname_representation_wrapper(char* out_rep, const char *in_path, size_t size) { - char *path_short = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); #ifdef HAVE_COMPRESSION + char *path_short = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); char *last_slash = NULL; -#endif - path_short[0] = '\0'; + path_short[0] = '\0'; fill_pathname(path_short, path_basename(in_path), "", PATH_MAX_LENGTH * sizeof(char) ); -#ifdef HAVE_COMPRESSION last_slash = find_last_slash(path_short); + if (last_slash != NULL) { /* We handle paths like: @@ -410,8 +409,9 @@ void fill_short_pathname_representation_wrapper(char* out_rep, free(path_short); return; } + + free(path_short); #endif fill_short_pathname_representation(out_rep, in_path, size); - free(path_short); } From 6982dd838f04d1d0f80534a9d88d6cc32e46ff2c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 5 Feb 2018 00:04:41 +0100 Subject: [PATCH 082/232] (MSVC 2017) Fix VS 2017 solution --- gfx/common/d3d12_common.c | 2 +- gfx/common/d3d12_common.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gfx/common/d3d12_common.c b/gfx/common/d3d12_common.c index ac2b82f636..b54a3604aa 100644 --- a/gfx/common/d3d12_common.c +++ b/gfx/common/d3d12_common.c @@ -310,7 +310,7 @@ bool d3d12_init_descriptors(d3d12_video_t* d3d12) }, }; - D3D12_ROOT_PARAMETER rootParameters[ROOT_ID_MAX] = {}; + D3D12_ROOT_PARAMETER rootParameters[ROOT_ID_MAX]; rootParameters[ROOT_ID_TEXTURE_T].ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; rootParameters[ROOT_ID_TEXTURE_T].DescriptorTable.NumDescriptorRanges = countof(srv_table); diff --git a/gfx/common/d3d12_common.h b/gfx/common/d3d12_common.h index dfa0010a92..38ca8994e0 100644 --- a/gfx/common/d3d12_common.h +++ b/gfx/common/d3d12_common.h @@ -1408,7 +1408,7 @@ static INLINE void d3d12_resource_transition( D3D12_RESOURCE_STATES state_before, D3D12_RESOURCE_STATES state_after) { - D3D12_RESOURCE_BARRIER barrier = {}; + D3D12_RESOURCE_BARRIER barrier; barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; barrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE; barrier.Transition.pResource = resource; From 5549b136c2d31b66a846fdb0aef25b736616b4eb Mon Sep 17 00:00:00 2001 From: aliaspider Date: Mon, 5 Feb 2018 00:25:03 +0100 Subject: [PATCH 083/232] (msvc) CXX_BUILD + griffin fixes. --- Makefile.msvc | 13 ++++--- audio/drivers/xaudio.c | 22 ++++++------ audio/drivers/xaudio.h | 40 ++++++++++++++------- deps/libz/adler32.c | 1 + frontend/drivers/platform_win32.c | 1 + gfx/common/d3d12_common.c | 56 +++++++++--------------------- gfx/common/d3d12_common.h | 2 +- gfx/common/d3d_common.c | 6 ++-- gfx/common/win32_common.c | 2 -- gfx/include/d3d9/d3dx9core.h | 2 +- griffin/griffin.c | 1 + libretro-common/net/net_http.c | 4 +-- network/netplay/netplay_delta.c | 2 +- ui/drivers/ui_win32.h | 2 ++ ui/drivers/win32/ui_win32_window.c | 5 --- 15 files changed, 76 insertions(+), 83 deletions(-) diff --git a/Makefile.msvc b/Makefile.msvc index b21810c96f..7760279670 100644 --- a/Makefile.msvc +++ b/Makefile.msvc @@ -5,6 +5,7 @@ OS = Win32 ARCH = amd64 #TARGET_ARCH = x86 BUILD_DIR = objs/msvc +CXX_BUILD = 0 WindowsSdkDir = C:\Program Files (x86)\Windows Kits\10\$(NOTHING) @@ -59,7 +60,6 @@ include Makefile.common INCLUDE_DIRS := $(patsubst -isystem%,-I%,$(INCLUDE_DIRS)) CFLAGS := $(filter-out -Wno-unknown-pragmas,$(CFLAGS)) CXXFLAGS := $(filter-out -fpermissive -Wno-switch -Wno-sign-compare -fno-strict-aliasing -Wno-maybe-uninitialized -Wno-reorder -Wno-parentheses,$(CXXFLAGS)) -CXXFLAGS += $(CFLAGS) LIBS := $(filter-out -lstdc++,$(LIBS)) ifeq ($(ARCH),x64) @@ -124,11 +124,16 @@ FLAGS += -Gm- -Zc:inline -fp:precise -Zc:forScope -GR- -Gd -Oi -volatile:iso #FLAGS += -utf-8 #FLAGS += -source-charset:utf-8 +CXXFLAGS += $(CFLAGS) -TP -EHsc +ifeq ($(CXX_BUILD),1) + CFLAGS := $(CXXFLAGS) + DEFINES += -DCXX_BUILD +else + CFLAGS += -TC +endif -CFLAGS += -TC -CXXFLAGS += -TP -EHsc WARNINGS += -WX -W3 -WARNINGS += -wd4101 -wd4996 -wd4244 -wd4267 -wd4090 -wd4305 -wd4146 -wd4334 -wd4018 -wd4800 +WARNINGS += -wd4101 -wd4996 -wd4244 -wd4267 -wd4090 -wd4305 -wd4146 -wd4334 -wd4018 -wd4800 -wd4838 CC = cl.exe CXX = cl.exe diff --git a/audio/drivers/xaudio.c b/audio/drivers/xaudio.c index f267cb04e0..d344508b70 100644 --- a/audio/drivers/xaudio.c +++ b/audio/drivers/xaudio.c @@ -59,13 +59,13 @@ typedef struct size_t bufsize; } xa_t; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) struct xaudio2 : public IXAudio2VoiceCallback #else struct xaudio2 #endif { -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) xaudio2() : buf(0), pXAudio2(0), pMasterVoice(0), pSourceVoice(0), hEvent(0), buffers(0), bufsize(0), @@ -101,8 +101,8 @@ struct xaudio2 unsigned write_buffer; }; -#ifndef __cplusplus -static void WINAPI voice_on_buffer_end(void *handle_, void *data) +#if !defined(__cplusplus) || defined(CINTERFACE) +static void WINAPI voice_on_buffer_end(IXAudio2VoiceCallback *handle_, void *data) { xaudio2_t *handle = (xaudio2_t*)handle_; (void)data; @@ -110,10 +110,10 @@ static void WINAPI voice_on_buffer_end(void *handle_, void *data) SetEvent(handle->hEvent); } -static void WINAPI dummy_voidp(void *handle, void *data) { (void)handle; (void)data; } -static void WINAPI dummy_nil(void *handle) { (void)handle; } -static void WINAPI dummy_uint32(void *handle, UINT32 dummy) { (void)handle; (void)dummy; } -static void WINAPI dummy_voidp_hresult(void *handle, void *data, HRESULT dummy) { (void)handle; (void)data; (void)dummy; } +static void WINAPI dummy_voidp(IXAudio2VoiceCallback *handle, void *data) { (void)handle; (void)data; } +static void WINAPI dummy_nil(IXAudio2VoiceCallback *handle) { (void)handle; } +static void WINAPI dummy_uint32(IXAudio2VoiceCallback *handle, UINT32 dummy) { (void)handle; (void)dummy; } +static void WINAPI dummy_voidp_hresult(IXAudio2VoiceCallback *handle, void *data, HRESULT dummy) { (void)handle; (void)data; (void)dummy; } const struct IXAudio2VoiceCallbackVtbl voice_vtable = { dummy_uint32, @@ -189,7 +189,7 @@ static void xaudio2_free(xaudio2_t *handle) free(handle->buf); -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) delete handle; #else free(handle); @@ -206,7 +206,7 @@ static xaudio2_t *xaudio2_new(unsigned samplerate, unsigned channels, CoInitializeEx(0, COINIT_MULTITHREADED); #endif -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) handle = new xaudio2; #else handle = (xaudio2_t*)calloc(1, sizeof(*handle)); @@ -215,7 +215,7 @@ static xaudio2_t *xaudio2_new(unsigned samplerate, unsigned channels, if (!handle) goto error; -#ifndef __cplusplus +#if !defined(__cplusplus) || defined(CINTERFACE) handle->lpVtbl = &voice_vtable; #endif diff --git a/audio/drivers/xaudio.h b/audio/drivers/xaudio.h index 4c03e60035..788fe16789 100644 --- a/audio/drivers/xaudio.h +++ b/audio/drivers/xaudio.h @@ -26,7 +26,7 @@ /* All structures defined in this file use tight field packing */ #pragma pack(push, 1) -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) #define X2DEFAULT(x) = (x) #else #define X2DEFAULT(x) @@ -183,6 +183,9 @@ typedef struct XAUDIO2_BUFFER void *pContext; } XAUDIO2_BUFFER; +#undef INTERFACE +#define INTERFACE IXAudio2VoiceCallback + DECLARE_INTERFACE(IXAudio2VoiceCallback) { STDMETHOD_(void, OnVoiceProcessingPassStart) (THIS_ UINT32 BytesRequired) PURE; @@ -194,6 +197,9 @@ DECLARE_INTERFACE(IXAudio2VoiceCallback) STDMETHOD_(void, OnVoiceError) (THIS_ void *pBufferContext, HRESULT Error) PURE; }; +#undef INTERFACE +#define INTERFACE IXAudio2Voice + DECLARE_INTERFACE(IXAudio2Voice) { #define Declare_IXAudio2Voice_Methods() \ @@ -235,11 +241,17 @@ DECLARE_INTERFACE(IXAudio2Voice) Declare_IXAudio2Voice_Methods(); }; +#undef INTERFACE +#define INTERFACE IXAudio2MasteringVoice + DECLARE_INTERFACE_(IXAudio2MasteringVoice, IXAudio2Voice) { Declare_IXAudio2Voice_Methods(); }; +#undef INTERFACE +#define INTERFACE IXAudio2SourceVoice + DECLARE_INTERFACE_(IXAudio2SourceVoice, IXAudio2Voice) { Declare_IXAudio2Voice_Methods(); @@ -255,6 +267,8 @@ DECLARE_INTERFACE_(IXAudio2SourceVoice, IXAudio2Voice) STDMETHOD_(void, GetFrequencyRatio) (THIS_ float* pRatio) PURE; }; +#undef INTERFACE +#define INTERFACE IXAudio2 DECLARE_INTERFACE_(IXAudio2, IUnknown) { @@ -292,7 +306,7 @@ DECLARE_INTERFACE_(IXAudio2, IUnknown) void *pReserved X2DEFAULT(NULL)) PURE; }; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) /* C++ hooks */ #define IXAudio2_Initialize(handle,a,b) handle->Initialize(a, b) #define IXAudio2SourceVoice_SubmitSourceBuffer(handle, a, b) handle->SubmitSourceBuffer(a, b) @@ -305,17 +319,17 @@ DECLARE_INTERFACE_(IXAudio2, IUnknown) #define IXAudio2SourceVoice_Start(handle, a, b) handle->Start(a, b) #else /* C hooks */ -#define IXAudio2_Initialize(THIS,a,b) (THIS)->lpVtbl->Initialize(THIS, a, b) -#define IXAudio2_Release(THIS) (THIS)->lpVtbl->Release(THIS) -#define IXAudio2_CreateSourceVoice(THIS,ppSourceVoice,pSourceFormat,Flags,MaxFrequencyRatio,pCallback,pSendList,pEffectChain) (THIS)->lpVtbl->CreateSourceVoice(THIS, ppSourceVoice,pSourceFormat,Flags,MaxFrequencyRatio,pCallback,pSendList,pEffectChain) -#define IXAudio2_CreateMasteringVoice(THIS,ppMasteringVoice,InputChannels,InputSampleRate,Flags,DeviceIndex,pEffectChain) (THIS)->lpVtbl->CreateMasteringVoice(THIS, ppMasteringVoice,InputChannels,InputSampleRate,Flags,DeviceIndex,pEffectChain) -#define IXAudio2_GetDeviceCount(THIS, puCount) (THIS)->lpVtbl->GetDeviceCount(THIS, puCount) -#define IXAudio2_GetDeviceDetails(THIS, Index,pDeviceDetails) (THIS)->lpVtbl->GetDeviceDetails(THIS, Index, pDeviceDetails) -#define IXAudio2SourceVoice_Start(THIS, Flags, OperationSet) (THIS)->lpVtbl->Start(THIS, Flags, OperationSet) -#define IXAudio2SourceVoice_Stop(THIS, Flags, OperationSet) (THIS)->lpVtbl->Stop(THIS, Flags, OperationSet) -#define IXAudio2SourceVoice_SubmitSourceBuffer(THIS, pBuffer, pBufferWMA) (THIS)->lpVtbl->SubmitSourceBuffer(THIS, pBuffer, pBufferWMA) -#define IXAudio2SourceVoice_DestroyVoice(THIS) (THIS)->lpVtbl->DestroyVoice(THIS) -#define IXAudio2MasteringVoice_DestroyVoice(THIS) (THIS)->lpVtbl->DestroyVoice(THIS) +#define IXAudio2_Initialize(handle,a,b) (handle)->lpVtbl->Initialize(handle, a, b) +#define IXAudio2_Release(handle) (handle)->lpVtbl->Release(handle) +#define IXAudio2_CreateSourceVoice(handle,ppSourceVoice,pSourceFormat,Flags,MaxFrequencyRatio,pCallback,pSendList,pEffectChain) (handle)->lpVtbl->CreateSourceVoice(handle, ppSourceVoice,pSourceFormat,Flags,MaxFrequencyRatio,pCallback,pSendList,pEffectChain) +#define IXAudio2_CreateMasteringVoice(handle,ppMasteringVoice,InputChannels,InputSampleRate,Flags,DeviceIndex,pEffectChain) (handle)->lpVtbl->CreateMasteringVoice(handle, ppMasteringVoice,InputChannels,InputSampleRate,Flags,DeviceIndex,pEffectChain) +#define IXAudio2_GetDeviceCount(handle, puCount) (handle)->lpVtbl->GetDeviceCount(handle, puCount) +#define IXAudio2_GetDeviceDetails(handle, Index,pDeviceDetails) (handle)->lpVtbl->GetDeviceDetails(handle, Index, pDeviceDetails) +#define IXAudio2SourceVoice_Start(handle, Flags, OperationSet) (handle)->lpVtbl->Start(handle, Flags, OperationSet) +#define IXAudio2SourceVoice_Stop(handle, Flags, OperationSet) (handle)->lpVtbl->Stop(handle, Flags, OperationSet) +#define IXAudio2SourceVoice_SubmitSourceBuffer(handle, pBuffer, pBufferWMA) (handle)->lpVtbl->SubmitSourceBuffer(handle, pBuffer, pBufferWMA) +#define IXAudio2SourceVoice_DestroyVoice(handle) (handle)->lpVtbl->DestroyVoice(handle) +#define IXAudio2MasteringVoice_DestroyVoice(handle) (handle)->lpVtbl->DestroyVoice(handle) #endif #ifdef _XBOX diff --git a/deps/libz/adler32.c b/deps/libz/adler32.c index 67d6030f95..dad0dacf9d 100644 --- a/deps/libz/adler32.c +++ b/deps/libz/adler32.c @@ -8,6 +8,7 @@ #define ZLIB_INTERNAL #include #include +#include #define BASE 65521UL /* largest prime smaller than 65536 */ #define NMAX 5552 diff --git a/frontend/drivers/platform_win32.c b/frontend/drivers/platform_win32.c index b0dec9dd78..cce85bce6e 100644 --- a/frontend/drivers/platform_win32.c +++ b/frontend/drivers/platform_win32.c @@ -41,6 +41,7 @@ #include "../../defaults.h" #include "../../retroarch.h" #include "../../verbosity.h" +#include "../../ui/drivers/ui_win32.h" /* We only load this library once, so we let it be * unloaded at application shutdown, since unloading diff --git a/gfx/common/d3d12_common.c b/gfx/common/d3d12_common.c index b54a3604aa..d5d74b8b65 100644 --- a/gfx/common/d3d12_common.c +++ b/gfx/common/d3d12_common.c @@ -268,19 +268,12 @@ static void d3d12_init_sampler( D3D12_TEXTURE_ADDRESS_MODE address_mode, D3D12_GPU_DESCRIPTOR_HANDLE* dst) { - D3D12_SAMPLER_DESC sampler_desc = { - .Filter = filter, - .AddressU = address_mode, - .AddressV = address_mode, - .AddressW = address_mode, - .MipLODBias = 0, - .MaxAnisotropy = 0, - .ComparisonFunc = D3D12_COMPARISON_FUNC_NEVER, - .BorderColor = { 0.0f }, - .MinLOD = 0.0f, - .MaxLOD = D3D12_FLOAT32_MAX, - }; - D3D12_CPU_DESCRIPTOR_HANDLE handle = { heap->cpu.ptr + heap_index * heap->stride }; + D3D12_SAMPLER_DESC sampler_desc = { filter, address_mode, address_mode, address_mode }; + D3D12_CPU_DESCRIPTOR_HANDLE handle = { heap->cpu.ptr + heap_index * heap->stride }; + + sampler_desc.ComparisonFunc = D3D12_COMPARISON_FUNC_NEVER; + sampler_desc.MaxLOD = D3D12_FLOAT32_MAX; + D3D12CreateSampler(device, &sampler_desc, handle); dst->ptr = heap->gpu.ptr + heap_index * heap->stride; } @@ -290,23 +283,20 @@ bool d3d12_init_descriptors(d3d12_video_t* d3d12) D3D12_ROOT_SIGNATURE_DESC desc; static const D3D12_DESCRIPTOR_RANGE srv_table[] = { { - .RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV, - .NumDescriptors = 1, - .BaseShaderRegister = 0, - .RegisterSpace = 0, -#if 0 - .Flags = D3D12_DESCRIPTOR_RANGE_FLAG_DATA_STATIC, /* version 1_1 only */ -#endif - .OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND, + D3D12_DESCRIPTOR_RANGE_TYPE_SRV, + 1, + 0, + 0, + D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND, }, }; static const D3D12_DESCRIPTOR_RANGE sampler_table[] = { { - .RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER, - .NumDescriptors = 1, - .BaseShaderRegister = 0, - .RegisterSpace = 0, - .OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND, + D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER, + 1, + 0, + 0, + D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND, }, }; @@ -397,20 +387,6 @@ bool d3d12_init_pipeline(d3d12_video_t* d3d12) D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, }; - static const D3D12_RASTERIZER_DESC rasterizerDesc = { - .FillMode = D3D12_FILL_MODE_SOLID, - .CullMode = D3D12_CULL_MODE_BACK, - .FrontCounterClockwise = FALSE, - .DepthBias = D3D12_DEFAULT_DEPTH_BIAS, - .DepthBiasClamp = D3D12_DEFAULT_DEPTH_BIAS_CLAMP, - .SlopeScaledDepthBias = D3D12_DEFAULT_SLOPE_SCALED_DEPTH_BIAS, - .DepthClipEnable = TRUE, - .MultisampleEnable = FALSE, - .AntialiasedLineEnable = FALSE, - .ForcedSampleCount = 0, - .ConservativeRaster = D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF, - }; - if (!d3d_compile(stock, sizeof(stock), NULL, "VSMain", "vs_5_0", &vs_code)) return false; diff --git a/gfx/common/d3d12_common.h b/gfx/common/d3d12_common.h index 38ca8994e0..6dce196957 100644 --- a/gfx/common/d3d12_common.h +++ b/gfx/common/d3d12_common.h @@ -1363,7 +1363,7 @@ typedef struct #endif } d3d12_video_t; -enum +typedef enum { ROOT_ID_TEXTURE_T = 0, ROOT_ID_SAMPLER_T, diff --git a/gfx/common/d3d_common.c b/gfx/common/d3d_common.c index b1e2ff0888..4d8fc4406b 100644 --- a/gfx/common/d3d_common.c +++ b/gfx/common/d3d_common.c @@ -2872,7 +2872,7 @@ void d3dxbuffer_release(void *data) if (!p) return; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) p->Release(); #else p->lpVtbl->Release(p); @@ -3053,7 +3053,7 @@ const void *d3dx_get_buffer_ptr(void *data) ID3DXBuffer *listing = (ID3DXBuffer*)data; if (!listing) return NULL; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) return listing->GetBufferPointer(); #else return listing->lpVtbl->GetBufferPointer(listing); @@ -3073,7 +3073,7 @@ const bool d3dx_constant_table_set_float(void *p, LPD3DXCONSTANTTABLE consttbl = (LPD3DXCONSTANTTABLE)p; if (!consttbl || !dev || !handle) return false; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) if (consttbl->SetFloat(dev, handle, val) == D3D_OK) return true; #else diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index ab37d7ab1e..64403356b1 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -561,8 +561,6 @@ static LRESULT CALLBACK WndProcCommon(bool *quit, HWND hwnd, UINT message, return 0; } -extern VOID (WINAPI *DragAcceptFiles_func)(HWND, BOOL); - static void win32_set_droppable(ui_window_win32_t *window, bool droppable) { if (DragAcceptFiles_func != NULL) diff --git a/gfx/include/d3d9/d3dx9core.h b/gfx/include/d3d9/d3dx9core.h index 1c0b755cdf..92ac586356 100644 --- a/gfx/include/d3d9/d3dx9core.h +++ b/gfx/include/d3d9/d3dx9core.h @@ -194,7 +194,7 @@ DECLARE_INTERFACE_(ID3DXFont, IUnknown) STDMETHOD(OnLostDevice)(THIS) PURE; STDMETHOD(OnResetDevice)(THIS) PURE; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) #ifdef UNICODE HRESULT GetDesc(D3DXFONT_DESCW *pDesc) { return GetDescW(pDesc); } HRESULT PreloadText(LPCWSTR pString, INT Count) { return PreloadTextW(pString, Count); } diff --git a/griffin/griffin.c b/griffin/griffin.c index 7243b2fbcc..2cfe446c80 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -14,6 +14,7 @@ * If not, see . */ +#define CINTERFACE #define HAVE_IBXM 1 #if defined(HAVE_CG) || defined(HAVE_HLSL) || defined(HAVE_GLSL) diff --git a/libretro-common/net/net_http.c b/libretro-common/net/net_http.c index be1b90b91b..fb40d89b7d 100644 --- a/libretro-common/net/net_http.c +++ b/libretro-common/net/net_http.c @@ -398,9 +398,9 @@ struct http_t *net_http_new(struct http_connection_t *conn) post_len = strlen(conn->postdatacopy); #ifdef _WIN32 - len = snprintf(NULL, 0, "%"PRIuPTR, post_len); + len = snprintf(NULL, 0, "%" PRIuPTR, post_len); len_str = (char*)malloc(len + 1); - snprintf(len_str, len + 1, "%"PRIuPTR, post_len); + snprintf(len_str, len + 1, "%" PRIuPTR, post_len); #else len = snprintf(NULL, 0, "%llu", (long long unsigned)post_len); len_str = (char*)malloc(len + 1); diff --git a/network/netplay/netplay_delta.c b/network/netplay/netplay_delta.c index edfd225427..d6b7efe58b 100644 --- a/network/netplay/netplay_delta.c +++ b/network/netplay/netplay_delta.c @@ -152,7 +152,7 @@ netplay_input_state_t netplay_input_state_for(netplay_input_state_t *list, return NULL; /* Couldn't find a slot, allocate a fresh one */ - ret = calloc(1, sizeof(struct netplay_input_state) + (size-1) * sizeof(uint32_t)); + ret = (netplay_input_state_t)calloc(1, sizeof(struct netplay_input_state) + (size-1) * sizeof(uint32_t)); if (!ret) return NULL; *list = ret; diff --git a/ui/drivers/ui_win32.h b/ui/drivers/ui_win32.h index 89e0cb2aef..588207db57 100644 --- a/ui/drivers/ui_win32.h +++ b/ui/drivers/ui_win32.h @@ -42,6 +42,8 @@ typedef struct ui_window_win32 HWND hwnd; } ui_window_win32_t; +extern VOID (WINAPI *DragAcceptFiles_func)(HWND, BOOL); + RETRO_END_DECLS #endif diff --git a/ui/drivers/win32/ui_win32_window.c b/ui/drivers/win32/ui_win32_window.c index eb89047526..bd39aa50d6 100644 --- a/ui/drivers/win32/ui_win32_window.c +++ b/ui/drivers/win32/ui_win32_window.c @@ -75,11 +75,6 @@ static void ui_window_win32_set_title(void *data, char *buf) SetWindowText(window->hwnd, buf); } -#ifdef __cplusplus -extern "C" -#endif - VOID (WINAPI *DragAcceptFiles_func)(HWND, BOOL); - void ui_window_win32_set_droppable(void *data, bool droppable) { /* Minimum supported client: Windows XP, minimum supported server: Windows 2000 Server */ From 69fedc6b407d9cfc920da8e35ffe9b9f8176d7ee Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 5 Feb 2018 00:29:05 +0100 Subject: [PATCH 084/232] task_screenshot.c - remove XBOX1 specific code --- tasks/task_screenshot.c | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/tasks/task_screenshot.c b/tasks/task_screenshot.c index fc3ea00b36..42cc5d8d72 100644 --- a/tasks/task_screenshot.c +++ b/tasks/task_screenshot.c @@ -19,11 +19,6 @@ #include "../config.h" #endif -#ifdef _XBOX1 -#include -#include -#endif - #include #include #include @@ -76,9 +71,6 @@ struct screenshot_task_state const void *frame; char filename[PATH_MAX_LENGTH]; char shotname[256]; -#ifdef _XBOX1 - D3DSurface *surf; -#endif void *userbuf; struct scaler_ctx scaler; }; @@ -113,11 +105,7 @@ static void task_screenshot_handler(retro_task_t *task) (void)bmp_type; #endif -#if defined(_XBOX1) - if (XGWriteSurfaceToFile(state->surf, state->filename) == S_OK) - ret = true; - d3d_surface_free(state->surf); -#elif defined(HAVE_RPNG) +#if defined(HAVE_RPNG) if (state->bgr24) scaler->in_fmt = SCALER_FMT_BGR24; else if (state->pixel_format_type == RETRO_PIXEL_FORMAT_XRGB8888) @@ -194,9 +182,6 @@ static bool screenshot_dump( { char screenshot_path[PATH_MAX_LENGTH]; uint8_t *buf = NULL; -#ifdef _XBOX1 - d3d_video_t *d3d = (d3d_video_t*)video_driver_get_ptr(true); -#endif settings_t *settings = config_get_ptr(); retro_task_t *task = (retro_task_t*)calloc(1, sizeof(*task)); screenshot_task_state_t *state = (screenshot_task_state_t*) @@ -240,10 +225,7 @@ static bool screenshot_dump( state->shotname, sizeof(state->filename)); } -#ifdef _XBOX1 - d3d_device_get_backbuffer(d3d->dev, -1, 0, D3DBACKBUFFER_TYPE_MONO, - &state->surf); -#elif defined(HAVE_RPNG) +#if defined(HAVE_RPNG) buf = (uint8_t*)malloc(width * height * 3); if (!buf) { From b2963a9124c8d0028a227edc426c5bd23dc9da27 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 5 Feb 2018 01:26:43 +0100 Subject: [PATCH 085/232] (menu_display_d3d.c) Turn this into HAVE_D3D8 conditional instead --- menu/drivers_display/menu_display_d3d.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/menu/drivers_display/menu_display_d3d.c b/menu/drivers_display/menu_display_d3d.c index 1522782824..536e56d048 100644 --- a/menu/drivers_display/menu_display_d3d.c +++ b/menu/drivers_display/menu_display_d3d.c @@ -169,10 +169,10 @@ static void menu_display_d3d_draw(void *data) pv[i].z = 0.5f; pv[i].u = *tex_coord++; pv[i].v = *tex_coord++; -#ifdef _XBOX1 +#ifdef HAVE_D3D8 { D3DSURFACE_DESC desc; - if (d3d_texture_get_level_desc(draw->texture, 0, &desc)) + if (d3d_texture_get_level_desc((void*)draw->texture, 0, &desc)) { pv[i].u *= desc.Width; pv[i].v *= desc.Height; From e01416a0da451c89f8bf2a9a145c518c6ee2a060 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 5 Feb 2018 01:33:54 +0100 Subject: [PATCH 086/232] Split up code to platform_xdk.h --- frontend/drivers/platform_xdk.c | 1033 +------------------------------ frontend/drivers/platform_xdk.h | 1000 ++++++++++++++++++++++++++++++ 2 files changed, 1002 insertions(+), 1031 deletions(-) create mode 100644 frontend/drivers/platform_xdk.h diff --git a/frontend/drivers/platform_xdk.c b/frontend/drivers/platform_xdk.c index 461b84c523..82e68124f0 100644 --- a/frontend/drivers/platform_xdk.c +++ b/frontend/drivers/platform_xdk.c @@ -46,1031 +46,10 @@ #endif #include "../../verbosity.h" -#ifdef _XBOX360 - -#define AURORA_LAUNCHDATA_APPID 'AUOA' -#define AURORA_LAUNCHDATA_EXECUTABLE_FUNCID 'ROMS' -#define AURORA_LAUNCHDATA_EXECUTABLE_VERSION 1 - -typedef struct _AURORA_LAUNCHDATA_EXECUTABLE -{ - DWORD ApplicationId; // AURORA_LAUNCHDATA_APPID - DWORD FunctionId; // AURORA_LAUNCHDATA_EXECUTABLE_FUNCID - DWORD FunctionVersion; // AURORA_LAUNCHDATA_EXECUTABLE_VERSION - CHAR SystemPath[0x40]; // /System/Harddisk0/Parition0 - CHAR RelativePath[0x104]; // /SomeCore/Content/ - CHAR Exectutable[0x28]; // SomeContent.zip - CHAR Reserved[0x100]; // Reserved for future use -} AURORA_LAUNCHDATA_EXECUTABLE, *PAURORA_LAUNCH_DATA_EXECUTABLE; - -#endif - -#ifdef _XBOX1 - -#include - -// Don't do __declspec(dllimport) for things like emulators -#if defined(NTSYSAPI) && defined(DONT_IMPORT_INTERNAL) -#undef NTSYSAPI -#endif -#ifdef DONT_IMPORT_INTERNAL -#define NTSYSAPI -#endif - -// The normal headers don't have this...? -#define FASTCALL __fastcall - -// The usual NTSTATUS -typedef LONG NTSTATUS; - -// The usual NT_SUCCESS -#define NT_SUCCESS(Status) ((NTSTATUS)(Status) >= 0) - -// Just for documentation -#define EXPORTNUM(x) - - -// Needed for object structures and related things -typedef CONST SHORT CSHORT; - - -// String types -typedef CHAR *PSZ; -typedef CONST CHAR *PCSZ; - -// ANSI_STRING -// Differences from NT: None. -typedef struct _STRING { - USHORT Length; - USHORT MaximumLength; - PCHAR Buffer; -} STRING; -typedef STRING *PSTRING; - -typedef STRING ANSI_STRING; -typedef PSTRING PANSI_STRING; - - -// IO Status Block type (UNVERIFIED) -// Differences from NT: None. -typedef struct _IO_STATUS_BLOCK { - union { - NTSTATUS Status; - PVOID Pointer; - }; - - ULONG_PTR Information; -} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK; - -// APC routine -typedef -VOID -(NTAPI *PIO_APC_ROUTINE) ( - IN PVOID ApcContext, - IN PIO_STATUS_BLOCK IoStatusBlock, - IN ULONG Reserved - ); - - -// Header for dispatcher objects -// Differences from NT: None. -typedef struct _DISPATCHER_HEADER { - UCHAR Type; - UCHAR Absolute; - UCHAR Size; - UCHAR Inserted; - LONG SignalState; - LIST_ENTRY WaitListHead; -} DISPATCHER_HEADER; - - -// Object types -#define NotificationTimerObject 8 -#define SynchronizationTimerObject 9 -#define DpcObject 19 - - -// Object Attributes type -// Differences from NT: There are no Length, SecurityDescriptor, or -// SecurityQualityOfService fields. Also, ObjectName is ANSI, not -// Unicode. -typedef struct _OBJECT_ATTRIBUTES { - HANDLE RootDirectory; - PANSI_STRING ObjectName; - ULONG Attributes; -} OBJECT_ATTRIBUTES; -typedef OBJECT_ATTRIBUTES *POBJECT_ATTRIBUTES; - -// Flags for OBJECT_ATTRIBUTES::Attributes -#define OBJ_INHERIT 0x00000002L -#define OBJ_PERMANENT 0x00000010L -#define OBJ_EXCLUSIVE 0x00000020L -#define OBJ_CASE_INSENSITIVE 0x00000040L -#define OBJ_OPENIF 0x00000080L -#define OBJ_OPENLINK 0x00000100L -#define OBJ_KERNEL_HANDLE 0x00000200L -#define OBJ_VALID_ATTRIBUTES 0x000003F2L - -// CreateDisposition values for NtCreateFile() -#define FILE_SUPERSEDE 0x00000000 -#define FILE_OPEN 0x00000001 -#define FILE_CREATE 0x00000002 -#define FILE_OPEN_IF 0x00000003 -#define FILE_OVERWRITE 0x00000004 -#define FILE_OVERWRITE_IF 0x00000005 -#define FILE_MAXIMUM_DISPOSITION 0x00000005 - -// CreateOption values for NtCreateFile() -// FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT is what CreateFile -// uses for most things when translating to NtCreateFile. -#define FILE_DIRECTORY_FILE 0x00000001 -#define FILE_WRITE_THROUGH 0x00000002 -#define FILE_SEQUENTIAL_ONLY 0x00000004 -#define FILE_NO_INTERMEDIATE_BUFFERING 0x00000008 -#define FILE_SYNCHRONOUS_IO_ALERT 0x00000010 -#define FILE_SYNCHRONOUS_IO_NONALERT 0x00000020 -#define FILE_NON_DIRECTORY_FILE 0x00000040 -#define FILE_CREATE_TREE_CONNECTION 0x00000080 -#define FILE_COMPLETE_IF_OPLOCKED 0x00000100 -#define FILE_NO_EA_KNOWLEDGE 0x00000200 -#define FILE_OPEN_FOR_RECOVERY 0x00000400 -#define FILE_RANDOM_ACCESS 0x00000800 -#define FILE_DELETE_ON_CLOSE 0x00001000 -#define FILE_OPEN_BY_FILE_ID 0x00002000 -#define FILE_OPEN_FOR_BACKUP_INTENT 0x00004000 -#define FILE_NO_COMPRESSION 0x00008000 -#define FILE_RESERVE_OPFILTER 0x00100000 -#define FILE_OPEN_REPARSE_POINT 0x00200000 -#define FILE_OPEN_NO_RECALL 0x00400000 -#define FILE_OPEN_FOR_FREE_SPACE_QUERY 0x00800000 -#define FILE_COPY_STRUCTURED_STORAGE 0x00000041 -#define FILE_STRUCTURED_STORAGE 0x00000441 -#define FILE_VALID_OPTION_FLAGS 0x00ffffff -#define FILE_VALID_PIPE_OPTION_FLAGS 0x00000032 -#define FILE_VALID_MAILSLOT_OPTION_FLAGS 0x00000032 -#define FILE_VALID_SET_FLAGS 0x00000036 - - -// NtQueryVolumeInformation / NtSetVolumeInformation stuff -// Type of information to retrieve; FileFsSizeInformation and -// FileFsDeviceInformation are the only ones confirmed to work. -typedef enum _FSINFOCLASS { - FileFsVolumeInformation = 1, - FileFsLabelInformation, - FileFsSizeInformation, - FileFsDeviceInformation, - FileFsAttributeInformation, - FileFsControlInformation, - FileFsFullSizeInformation, - FileFsObjectInformation -} FS_INFORMATION_CLASS, *PFS_INFORMATION_CLASS; - -// Structure of FileFsSizeInformation -typedef struct _FILE_FS_SIZE_INFORMATION { - LARGE_INTEGER TotalAllocationUnits; - LARGE_INTEGER AvailableAllocationUnits; - ULONG SectorsPerAllocationUnit; - ULONG BytesPerSector; -} FILE_FS_SIZE_INFORMATION, *PFILE_FS_SIZE_INFORMATION; - -#define DEVICE_TYPE ULONG - -// Structure of FileFsDeviceInformation -typedef struct _FILE_FS_DEVICE_INFORMATION { - DEVICE_TYPE DeviceType; - ULONG Characteristics; -} FILE_FS_DEVICE_INFORMATION, *PFILE_FS_DEVICE_INFORMATION; - -// DEVICE_TYPEs (I took a guess as to which the XBOX might have.) -#define FILE_DEVICE_CD_ROM 0x00000002 -#define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003 -#define FILE_DEVICE_CONTROLLER 0x00000004 -#define FILE_DEVICE_DISK 0x00000007 -#define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008 -#define FILE_DEVICE_FILE_SYSTEM 0x00000009 -#define FILE_DEVICE_NULL 0x00000015 -#define FILE_DEVICE_SCREEN 0x0000001c -#define FILE_DEVICE_SOUND 0x0000001d -#define FILE_DEVICE_UNKNOWN 0x00000022 -#define FILE_DEVICE_VIDEO 0x00000023 -#define FILE_DEVICE_VIRTUAL_DISK 0x00000024 -#define FILE_DEVICE_FULLSCREEN_VIDEO 0x00000034 - -// Characteristics -#define FILE_REMOVABLE_MEDIA 0x00000001 -#define FILE_READ_ONLY_DEVICE 0x00000002 -#define FILE_FLOPPY_DISKETTE 0x00000004 -#define FILE_WRITE_ONCE_MEDIA 0x00000008 -#define FILE_REMOTE_DEVICE 0x00000010 -#define FILE_DEVICE_IS_MOUNTED 0x00000020 -#define FILE_VIRTUAL_VOLUME 0x00000040 -#define FILE_AUTOGENERATED_DEVICE_NAME 0x00000080 -#define FILE_DEVICE_SECURE_OPEN 0x00000100 - -/* Physical address - * Differences from NT: 32 bit address instead of 64. */ -typedef ULONG PHYSICAL_ADDRESS, *PPHYSICAL_ADDRESS; - -/* NtCreateFile/NtOpenFile stuff */ -#define FILE_SUPERSEDED 0x00000000 -#define FILE_OPENED 0x00000001 -#define FILE_CREATED 0x00000002 -#define FILE_OVERWRITTEN 0x00000003 -#define FILE_EXISTS 0x00000004 -#define FILE_DOES_NOT_EXIST 0x00000005 - -// NtReadFile/NtWriteFile stuff -#define FILE_WRITE_TO_END_OF_FILE 0xffffffff -#define FILE_USE_FILE_POINTER_POSITION 0xfffffffe - -// Device types -#define FILE_DEVICE_CD_ROM 0x00000002 -#define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003 -#define FILE_DEVICE_CONTROLLER 0x00000004 -#define FILE_DEVICE_SCSI FILE_DEVICE_CONTROLLER -#define IOCTL_SCSI_BASE FILE_DEVICE_CONTROLLER -#define FILE_DEVICE_DISK 0x00000007 -#define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008 -#define FILE_DEVICE_DVD 0x00000033 - -// Access types -#define FILE_ANY_ACCESS 0 -#define FILE_READ_ACCESS 0x0001 /* file & pipe */ -#define FILE_WRITE_ACCESS 0x0002 /* file & pipe */ - -// Method types -#define METHOD_BUFFERED 0 -#define METHOD_IN_DIRECT 1 -#define METHOD_OUT_DIRECT 2 -#define METHOD_NEITHER 3 - -// The all-important CTL_CODE -#define CTL_CODE( DeviceType, Function, Method, Access ) ( \ - ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \ -) - -// IDE/SCSI codes -// IOCTL_SCSI_PASS_THROUGH_DIRECT is the only one known to be used. -// Differences from NT: None. -#define IOCTL_SCSI_PASS_THROUGH CTL_CODE(IOCTL_SCSI_BASE, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) -#define IOCTL_SCSI_MINIPORT CTL_CODE(IOCTL_SCSI_BASE, 0x0402, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) -#define IOCTL_SCSI_GET_INQUIRY_DATA CTL_CODE(IOCTL_SCSI_BASE, 0x0403, METHOD_BUFFERED, FILE_ANY_ACCESS) -#define IOCTL_SCSI_GET_CAPABILITIES CTL_CODE(IOCTL_SCSI_BASE, 0x0404, METHOD_BUFFERED, FILE_ANY_ACCESS) -#define IOCTL_SCSI_PASS_THROUGH_DIRECT CTL_CODE(IOCTL_SCSI_BASE, 0x0405, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) -#define IOCTL_SCSI_GET_ADDRESS CTL_CODE(IOCTL_SCSI_BASE, 0x0406, METHOD_BUFFERED, FILE_ANY_ACCESS) -#define IOCTL_SCSI_RESCAN_BUS CTL_CODE(IOCTL_SCSI_BASE, 0x0407, METHOD_BUFFERED, FILE_ANY_ACCESS) -#define IOCTL_SCSI_GET_DUMP_POINTERS CTL_CODE(IOCTL_SCSI_BASE, 0x0408, METHOD_BUFFERED, FILE_ANY_ACCESS) -#define IOCTL_SCSI_FREE_DUMP_POINTERS CTL_CODE(IOCTL_SCSI_BASE, 0x0409, METHOD_BUFFERED, FILE_ANY_ACCESS) -#define IOCTL_IDE_PASS_THROUGH CTL_CODE(IOCTL_SCSI_BASE, 0x040a, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) - -// Special XBOX code? -#define IOCTL_CDROM_AUTHENTICATE_DISK CTL_CODE(FILE_DEVICE_CD_ROM, 0x0020, METHOD_BUFFERED, FILE_READ_ACCESS) - -/* Structure for IOCTL_SCSI_PASS_THROUGH_DIRECT - * Differences from NT: None, believe it or not. */ -typedef struct _SCSI_PASS_THROUGH_DIRECT { - /*000*/ USHORT Length; - /*002*/ UCHAR ScsiStatus; - /*003*/ UCHAR PathId; - /*004*/ UCHAR TargetId; - /*005*/ UCHAR Lun; - /*006*/ UCHAR CdbLength; - /*007*/ UCHAR SenseInfoLength; - /*008*/ UCHAR DataIn; - /*00C*/ ULONG DataTransferLength; - /*010*/ ULONG TimeOutValue; - /*014*/ PVOID DataBuffer; - /*018*/ ULONG SenseInfoOffset; - /*01C*/ UCHAR Cdb[16]; -}SCSI_PASS_THROUGH_DIRECT, *PSCSI_PASS_THROUGH_DIRECT; - -/* DataIn fields for IOCTL_SCSI_PASS_THROUGH_DIRECT */ -#define SCSI_IOCTL_DATA_OUT 0 -#define SCSI_IOCTL_DATA_IN 1 -#define SCSI_IOCTL_DATA_UNSPECIFIED 2 - -/* Kernel object type (unsure about the structure...) */ -typedef struct _OBJECT_TYPE -{ - // Same prototype as ExAllocatePoolWithTag, because that's the usual one - PVOID - (NTAPI *AllocationFunction)( - SIZE_T NumberOfBytes, - ULONG Tag - ); - - // Same prototype as ExFreePool, because that's the usual one - VOID - (NTAPI *FreeFunction)( - IN PVOID P - ); - - // The prototypes of these are unknown - void *CloseFunction; - void *DeleteFunction; - void *ParseFunction; - - // Unknown DWORD... Size of this object type maybe? - void *DefaultObjectMaybe; - - // 4 letter tag for this object type - CHAR Tag[4]; -} OBJECT_TYPE; -typedef OBJECT_TYPE *POBJECT_TYPE; - -// Object types -extern POBJECT_TYPE IoFileObjectType; -extern POBJECT_TYPE ExEventObjectType; -extern POBJECT_TYPE ExSemaphoreObjectType; -extern POBJECT_TYPE IoCompletionObjectType; -extern POBJECT_TYPE IoDeviceObjectType; - - -// *_OBJECT and related structures (mostly opaque since I'm lazy) -typedef struct _DRIVER_OBJECT { - CSHORT Type; - CSHORT Size; - struct _DEVICE_OBJECT *DeviceObject; - // ... -} DRIVER_OBJECT; -typedef DRIVER_OBJECT *PDRIVER_OBJECT; - -typedef struct _DEVICE_OBJECT { - CSHORT Type; - USHORT Size; - LONG ReferenceCount; - PDRIVER_OBJECT DriverObject; - // ... -} DEVICE_OBJECT; -typedef DEVICE_OBJECT *PDEVICE_OBJECT; - -typedef struct _FILE_OBJECT { - CSHORT Type; - CSHORT Size; - PDEVICE_OBJECT DeviceObject; - // ... -} FILE_OBJECT; -typedef FILE_OBJECT *PFILE_OBJECT; - - -/* Thread information structures */ - -/* IRQL */ -typedef UCHAR KIRQL, *PKIRQL; -#define PASSIVE_LEVEL 0 // Passive release level -#define LOW_LEVEL 0 // Lowest interrupt level -#define APC_LEVEL 1 // APC interrupt level -#define DISPATCH_LEVEL 2 // Dispatcher level - -// Thread entry point -// NOTE: This is not a standard call! You can't call this function from C code! -// You push registers like stdcall, but ebp + 4 must point to the first argument before the call! -// -// Differences from NT: 2 parameters instead of 1; strange calling convention -typedef -VOID -(NTAPI *PKSTART_ROUTINE) ( - IN PVOID StartContext1, - IN PVOID StartContext2 - ); - -// Structure of a critical section -// Same as the XBOX's RTL_CRITICAL_SECTION, but with the more explicit header -typedef struct _KCRITICAL_SECTION -{ - // 000 Dispatcher header - DISPATCHER_HEADER Header; - // 010 Lock count of the critical section - LONG LockCount; - // 014 Recursion count of the critical section - LONG RecursionCount; - // 018 Thread ID of the thread that currently owns this critical section - ULONG OwningThread; -} KCRITICAL_SECTION, *PKCRITICAL_SECTION; - -// Structure of a thread object -typedef struct _KTHREAD -{ - // 000 Dispatcher header - DISPATCHER_HEADER Header; - // 010 Unknown - BYTE unknown[0x18]; - // 028 Pointer to TLS data - PVOID TlsData; - // ??? just padding - real size is unknown - BYTE unknown2[0x100]; -} KTHREAD, *PKTHREAD; - -// Structure of the data at FS -typedef struct _FS_STRUCTURE -{ - // 000 Current exception handler information - PVOID *ExceptionFrame; - // 004 Pointer to current TLS data top - PVOID TlsDataTop; - // 008 - BYTE unknown2[0x1C]; - // 024 Current IRQL of the OS - KIRQL CurrentIrql; - // 028 Thread structure of the current thread - PKTHREAD ThreadObject; - // ??? just padding - real size is unknown - BYTE unknown3[0x100]; -} FS_STRUCTURE, *PFS_STRUCTURE; - -// DPC routine -typedef -VOID -(*PKDEFERRED_ROUTINE) ( - IN struct _KDPC *Dpc, - IN PVOID DeferredContext, - IN PVOID SystemArgument1, - IN PVOID SystemArgument2 - ); - -// DPC information -// It's not known which of these fields are used on XBOX. -typedef struct _KDPC { - CSHORT Type; - UCHAR Number; - UCHAR Importance; - LIST_ENTRY DpcListEntry; - PKDEFERRED_ROUTINE DeferredRoutine; - PVOID DeferredContext; - PVOID SystemArgument1; - PVOID SystemArgument2; - PULONG_PTR Lock; -} KDPC, *PKDPC; - - -// Timers -typedef enum _TIMER_TYPE { - NotificationTimer, - SynchronizationTimer - } TIMER_TYPE; - -typedef struct _KTIMER { - DISPATCHER_HEADER Header; - ULARGE_INTEGER DueTime; - LIST_ENTRY TimerListEntry; - struct _KDPC *Dpc; - LONG Period; -} KTIMER, *PKTIMER; - -/* XBE stuff - * Not used in any exported kernel calls, but still useful. - */ - -/* XBE header information */ -typedef struct _XBE_HEADER -{ - // 000 "XBEH" - CHAR Magic[4]; - // 004 RSA digital signature of the entire header area - UCHAR HeaderSignature[256]; - // 104 Base address of XBE image (must be 0x00010000?) - PVOID BaseAddress; - // 108 Size of all headers combined - other headers must be within this - ULONG HeaderSize; - // 10C Size of entire image - ULONG ImageSize; - // 110 Size of this header (always 0x178?) - ULONG XbeHeaderSize; - // 114 Image timestamp - unknown format - ULONG Timestamp; - // 118 Pointer to certificate data (must be within HeaderSize) - struct _XBE_CERTIFICATE *Certificate; - // 11C Number of sections - DWORD NumSections; - // 120 Pointer to section headers (must be within HeaderSize) - struct _XBE_SECTION *Sections; - // 124 Initialization flags - ULONG InitFlags; - // 128 Entry point (XOR'd; see xboxhacker.net) - PVOID EntryPoint; - // 12C Pointer to TLS directory - struct _XBE_TLS_DIRECTORY *TlsDirectory; - // 130 Stack commit size - ULONG StackCommit; - // 134 Heap reserve size - ULONG HeapReserve; - // 138 Heap commit size - ULONG HeapCommit; - // 13C PE base address (?) - PVOID PeBaseAddress; - // 140 PE image size (?) - ULONG PeImageSize; - // 144 PE checksum (?) - ULONG PeChecksum; - // 148 PE timestamp (?) - ULONG PeTimestamp; - // 14C PC path and filename to EXE file from which XBE is derived - PCSZ PcExePath; - // 150 PC filename (last part of PcExePath) from which XBE is derived - PCSZ PcExeFilename; - // 154 PC filename (Unicode version of PcExeFilename) - PWSTR PcExeFilenameUnicode; - // 158 Pointer to kernel thunk table (XOR'd; EFB1F152 debug) - ULONG_PTR *KernelThunkTable; - // 15C Non-kernel import table (debug only) - PVOID DebugImportTable; - // 160 Number of library headers - ULONG NumLibraries; - // 164 Pointer to library headers - struct _XBE_LIBRARY *Libraries; - // 168 Pointer to kernel library header - struct _XBE_LIBRARY *KernelLibrary; - // 16C Pointer to XAPI library - struct _XBE_LIBRARY *XapiLibrary; - // 170 Pointer to logo bitmap (NULL = use default of Microsoft) - PVOID LogoBitmap; - // 174 Size of logo bitmap - ULONG LogoBitmapSize; - // 178 -} XBE_HEADER, *PXBE_HEADER; - -// Certificate structure -typedef struct _XBE_CERTIFICATE { - // 000 Size of certificate - ULONG Size; - // 004 Certificate timestamp (unknown format) - ULONG Timestamp; - // 008 Title ID - ULONG TitleId; - // 00C Name of the game (Unicode) - WCHAR TitleName[40]; - // 05C Alternate title ID's (0-terminated) - ULONG AlternateTitleIds[16]; - // 09C Allowed media types - 1 bit match between XBE and media = boots - ULONG MediaTypes; - // 0A0 Allowed game regions - 1 bit match between this and XBOX = boots - ULONG GameRegion; - // 0A4 Allowed game ratings - 1 bit match between this and XBOX = boots - ULONG GameRating; - // 0A8 Disk number (?) - ULONG DiskNumber; - // 0AC Version (?) - ULONG Version; - // 0B0 LAN key for this game - UCHAR LanKey[16]; - // 0C0 Signature key for this game - UCHAR SignatureKey[16]; - // 0D0 Signature keys for the alternate title ID's - UCHAR AlternateSignatureKeys[16][16]; - // 1D0 -} XBE_CERTIFICATE, *PXBE_CERTIFICATE; - -// Section headers -typedef struct _XBE_SECTION { - // 000 Flags - ULONG Flags; - // 004 Virtual address (where this section loads in RAM) - PVOID VirtualAddress; - // 008 Virtual size (size of section in RAM; after FileSize it's 00'd) - ULONG VirtualSize; - // 00C File address (where in the file from which this section comes) - ULONG FileAddress; - // 010 File size (size of the section in the XBE file) - ULONG FileSize; - // 014 Pointer to section name - PCSZ SectionName; - // 018 Section reference count - when >= 1, section is loaded - LONG SectionReferenceCount; - // 01C Pointer to head shared page reference count - WORD *HeadReferenceCount; - // 020 Pointer to tail shared page reference count - WORD *TailReferenceCount; - // 024 SHA hash. Hash DWORD containing FileSize, then hash section. - DWORD ShaHash[5]; - // 038 -} XBE_SECTION, *PXBE_SECTION; - -/* TLS directory information needed later - * Library version data needed later */ - -/* Initialization flags */ -#define XBE_INIT_MOUNT_UTILITY 0x00000001 -#define XBE_INIT_FORMAT_UTILITY 0x00000002 -#define XBE_INIT_64M_RAM_ONLY 0x00000004 -#define XBE_INIT_DONT_SETUP_HDD 0x00000008 - -/* Region codes */ -#define XBE_REGION_US_CANADA 0x00000001 -#define XBE_REGION_JAPAN 0x00000002 -#define XBE_REGION_ELSEWHERE 0x00000004 -#define XBE_REGION_DEBUG 0x80000000 - -/* Media types */ -#define XBE_MEDIA_HDD 0x00000001 -#define XBE_MEDIA_XBOX_DVD 0x00000002 -#define XBE_MEDIA_ANY_CD_OR_DVD 0x00000004 -#define XBE_MEDIA_CD 0x00000008 -#define XBE_MEDIA_1LAYER_DVDROM 0x00000010 -#define XBE_MEDIA_2LAYER_DVDROM 0x00000020 -#define XBE_MEDIA_1LAYER_DVDR 0x00000040 -#define XBE_MEDIA_2LAYER_DVDR 0x00000080 -#define XBE_MEDIA_USB 0x00000100 -#define XBE_MEDIA_ALLOW_UNLOCKED_HDD 0x40000000 - -/* Section flags */ -#define XBE_SEC_WRITABLE 0x00000001 -#define XBE_SEC_PRELOAD 0x00000002 -#define XBE_SEC_EXECUTABLE 0x00000004 -#define XBE_SEC_INSERTED_FILE 0x00000008 -#define XBE_SEC_RO_HEAD_PAGE 0x00000010 -#define XBE_SEC_RO_TAIL_PAGE 0x00000020 - -/* x86 page size */ -#define PAGE_SIZE 0x1000 - -/* Native NT API calls on the XBOX */ - -/* PAGE_ALIGN: - * Returns an address rounded down to the nearest page boundary. - * - * Differences from NT: None. - */ -#define PAGE_ALIGN(Va) ((PVOID)((ULONG_PTR)(Va) & ~(PAGE_SIZE - 1))) - -// NtReadFile: -// Reads a file. -// -// Differences from NT: There is no Key parameter. -NTSYSAPI -EXPORTNUM(219) -NTSTATUS -NTAPI -NtReadFile( - IN HANDLE FileHandle, - IN HANDLE Event OPTIONAL, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - OUT PVOID Buffer, - IN ULONG Length, - IN PLARGE_INTEGER ByteOffset - ); - -// NtWriteFile: -// Writes a file. -// -// Differences from NT: There is no Key parameter. -NTSYSAPI -EXPORTNUM(236) -NTSTATUS -NTAPI -NtWriteFile( - IN HANDLE FileHandle, - IN HANDLE Event OPTIONAL, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN PVOID Buffer, - IN ULONG Length, - IN PLARGE_INTEGER ByteOffset - ); - -// NtQueryVolumeInformation: -// Queries information about a file system. This is not documented by -// Microsoft even under NT. -// -// Differences from NT: None known. -NTSYSAPI -EXPORTNUM(218) -NTSTATUS -NTAPI -NtQueryVolumeInformationFile( - IN HANDLE FileHandle, - OUT PIO_STATUS_BLOCK IoStatusBlock, - OUT PVOID VolumeInformation, - IN ULONG VolumeInformationLength, - IN FS_INFORMATION_CLASS VolumeInformationClass - ); - -// NtClose: -// Closes a file or other handle. -// -// Differences from NT: None. -NTSYSAPI -EXPORTNUM(187) -NTSTATUS -NTAPI -NtClose( - IN HANDLE Handle - ); - -// NtAllocateVirtualMemory: -// Allocates virtual memory. -// -// Differences from NT: There is no ProcessHandle parameter. -NTSYSAPI -EXPORTNUM(184) -NTSTATUS -NTAPI -NtAllocateVirtualMemory( - IN OUT PVOID *BaseAddress, - IN ULONG ZeroBits, - IN OUT PULONG AllocationSize, - IN ULONG AllocationType, - IN ULONG Protect - ); - -// NtFreeVirtualMemory: -// Frees virtual memory. -// -// Differences from NT: There is no ProcessHandle parameter. -NTSYSAPI -EXPORTNUM(199) -NTSTATUS -NTAPI -NtFreeVirtualMemory( - IN OUT PVOID *BaseAddress, - IN OUT PULONG FreeSize, - IN ULONG FreeType - ); - - -// Kernel-level routines - -// MmMapIoSpace: -// Maps a physical address area into the virtual address space. -// DO NOT USE MEMORY MAPPED WITH THIS AS A BUFFER TO OTHER CALLS. For -// example, don't WriteFile or NtWriteFile these buffers. Copy them first. -// -// Differences from NT: PhysicalAddress is 32 bit, not 64. ProtectionType -// specifies the page protections, but it's a Win32 PAGE_ macro instead -// of the normal NT enumeration. PAGE_READWRITE is probably what you -// want... -NTSYSAPI -EXPORTNUM(177) -PVOID -NTAPI -MmMapIoSpace( - IN PHYSICAL_ADDRESS PhysicalAddress, - IN ULONG NumberOfBytes, - IN ULONG ProtectionType - ); - -// MmGetPhysicalAddress: -// Translates a virtual address into a physical address. -// -// Differences from NT: PhysicalAddress is 32 bit, not 64. -NTSYSAPI -EXPORTNUM(173) -PHYSICAL_ADDRESS -NTAPI -MmGetPhysicalAddress( - IN PVOID BaseAddress - ); - -// MmUnmapIoSpace: -// Unmaps a virtual address mapping made by MmMapIoSpace. -// -// Differences from NT: None. -NTSYSAPI -EXPORTNUM(183) -PVOID -NTAPI -MmUnmapIoSpace( - IN PVOID BaseAddress, - IN ULONG NumberOfBytes - ); - -// MmAllocateContiguousMemory: -// Allocates a range of physically contiguous, cache-aligned memory from the -// non-paged pool (= main pool on XBOX). -// -// Differences from NT: HighestAcceptableAddress was deleted, opting instead -// to not care about the highest address. -NTSYSAPI -EXPORTNUM(165) -PVOID -NTAPI -MmAllocateContiguousMemory( - IN ULONG NumberOfBytes - ); - -// MmFreeContiguousMemory: -// Frees memory allocated with MmAllocateContiguousMemory. -// -// Differences from NT: None. -NTSYSAPI -EXPORTNUM(171) -VOID -NTAPI -MmFreeContiguousMemory( - IN PVOID BaseAddress - ); - -// IoCreateSymbolicLink: -// Creates a symbolic link in the object namespace. -// NtCreateSymbolicLinkObject is much harder to use than this simple -// function, so just use this one. -// -// Differences from NT: Uses ANSI_STRING instead of UNICODE_STRING. -NTSYSAPI -EXPORTNUM(67) -NTSTATUS -NTAPI -IoCreateSymbolicLink( - IN PANSI_STRING SymbolicLinkName, - IN PANSI_STRING DeviceName - ); - -// IoDeleteSymbolicLink: -// Creates a symbolic link in the object namespace. Deleting symbolic links -// through the Nt* functions is a pain, so use this instead. -// -// Differences from NT: Uses ANSI_STRING instead of UNICODE_STRING. -NTSYSAPI -EXPORTNUM(69) -NTSTATUS -NTAPI -IoDeleteSymbolicLink( - IN PANSI_STRING SymbolicLinkName - ); - - -// ObReferenceObjectByHandle: -// Turns a handle into a kernel object pointer. The ObjectType parameter -// specifies what type of object it is. This function also increments the -// object's reference count. -// -// Differences from NT: There are no DesiredAccess, AccessMode, or -// HandleInformation parameters. -NTSYSAPI -EXPORTNUM(246) -NTSTATUS -NTAPI -ObReferenceObjectByHandle( - IN HANDLE Handle, - IN POBJECT_TYPE ObjectType OPTIONAL, - OUT PVOID *Object - ); - -// ObfReferenceObject/ObReferenceObject: -// Increments the object's reference count. -// -// Differences from NT: None. -#define ObReferenceObject(Object) ObfReferenceObject(Object) -NTSYSAPI -EXPORTNUM(251) -VOID -FASTCALL -ObfReferenceObject( - IN PVOID Object - ); - -// ObfDereferenceObject/ObDereferenceObject: -// Decrements the object's reference count, deleting it if it is now unused. -// -// Differences from NT: None. -#define ObDereferenceObject(a) ObfDereferenceObject(a) -NTSYSAPI -EXPORTNUM(250) -VOID -FASTCALL -ObfDereferenceObject( - IN PVOID Object - ); - -// Kernel routines only in the XBOX - -// HalEnableSecureTrayEject: -// Notifies the SMBUS that ejecting the DVD-ROM should not reset the system. -// Note that this function can't really be called directly... -// -// New to the XBOX. -NTSYSAPI -EXPORTNUM(365) -VOID -NTAPI -HalEnableSecureTrayEject( - VOID - ); - -// XeLoadSection: -// Adds one to the reference count of the specified section and loads if the -// count is now above zero. -// -// New to the XBOX. -NTSYSAPI -EXPORTNUM(327) -NTSTATUS -NTAPI -XeLoadSection( - IN OUT PXBE_SECTION section - ); - -/* Error codes */ -#define STATUS_SUCCESS 0x00000000 -#define STATUS_UNSUCCESSFUL 0xC0000001 -#define STATUS_UNRECOGNIZED_MEDIA 0xC0000014 - -/* The SCSI input buffer was too large (not necessarily an error!) */ -#define STATUS_DATA_OVERRUN 0xC000003C -#define STATUS_INVALID_IMAGE_FORMAT 0xC000007B -#define STATUS_INSUFFICIENT_RESOURCES 0xC000009A -#define STATUS_TOO_MANY_SECRETS 0xC0000156 -#define STATUS_REGION_MISMATCH 0xC0050001 - -#include - - // Thanks and credit go to Woodoo - extern VOID WINAPI HalWriteSMBusValue(BYTE, BYTE, BOOL, BYTE); - extern VOID WINAPI HalReadSMCTrayState(DWORD* state, DWORD* count); - - // Thanks and credit go to Team Evox - extern VOID WINAPI HalReturnToFirmware(DWORD); - - extern INT WINAPI XNetLoadConfigParams(LPBYTE); - extern INT WINAPI XNetSaveConfigParams(LPBYTE); - - extern INT WINAPI XWriteTitleInfoNoReboot(LPVOID,LPVOID,DWORD,DWORD,LPVOID); - - extern DWORD* LaunchDataPage; -#endif +#include "platform_xdk.h" static enum frontend_fork xdk_fork_mode = FRONTEND_FORK_NONE; -#ifdef _XBOX360 -typedef struct _STRING -{ - USHORT Length; - USHORT MaximumLength; - PCHAR Buffer; -} STRING, *PSTRING; - -VOID RtlInitAnsiString(PSTRING DestinationString, PCHAR SourceString); -HRESULT ObDeleteSymbolicLink(PSTRING SymbolicLinkName); -HRESULT ObCreateSymbolicLink(PSTRING SymbolicLinkName, PSTRING DeviceName); - -static HRESULT xbox_io_mount(const char* szDrive, char* szDevice) -{ - STRING DeviceName, LinkName; - char szDestinationDrive[PATH_MAX_LENGTH]; - - snprintf(szDestinationDrive, sizeof(szDestinationDrive), - "\\??\\%s", szDrive); - RtlInitAnsiString(&DeviceName, szDevice); - RtlInitAnsiString(&LinkName, (PCHAR)szDestinationDrive); - ObDeleteSymbolicLink(&LinkName); - return (HRESULT)ObCreateSymbolicLink(&LinkName, &DeviceName); -} -#endif - -#ifdef _XBOX1 -static HRESULT xbox_io_mount(char *szDrive, char *szDevice) -{ - STRING DeviceName, LinkName; -#ifndef IS_SALAMANDER - bool original_verbose = verbosity_is_enabled(); -#endif - char szSourceDevice[48] = {0}; - char szDestinationDrive[16] = {0}; - - snprintf(szSourceDevice, sizeof(szSourceDevice), - "\\Device\\%s", szDevice); - snprintf(szDestinationDrive, sizeof(szDestinationDrive), - "\\??\\%s", szDrive); - - DeviceName.Length = strlen(szSourceDevice); - DeviceName.MaximumLength = strlen(szSourceDevice) + 1; - DeviceName.Buffer = szSourceDevice; - - LinkName.Length = strlen(szDestinationDrive); - LinkName.MaximumLength = strlen(szDestinationDrive) + 1; - LinkName.Buffer = szDestinationDrive; - - IoCreateSymbolicLink(&LinkName, &DeviceName); - -#ifndef IS_SALAMANDER - if (original_verbose) - verbosity_enable(); - else - verbosity_disable(); -#endif - return S_OK; -} - -static HRESULT xbox_io_unmount(char *szDrive) -{ - STRING LinkName; - char szDestinationDrive[16] = {0}; - - snprintf(szDestinationDrive, sizeof(szDestinationDrive), - "\\??\\%s", szDrive); - - LinkName.Length = strlen(szDestinationDrive); - LinkName.MaximumLength = strlen(szDestinationDrive) + 1; - LinkName.Buffer = szDestinationDrive; - - IoDeleteSymbolicLink(&LinkName); - - return S_OK; -} -#endif - static void frontend_xdk_get_environment_settings(int *argc, char *argv[], void *args, void *params_data) { @@ -1189,19 +168,11 @@ static void frontend_xdk_get_environment_settings(int *argc, char *argv[], { char *extracted_path = (char*)calloc(dwLaunchDataSize, sizeof(char)); BYTE* pLaunchData = (BYTE*)calloc(dwLaunchDataSize, sizeof(BYTE)); - AURORA_LAUNCHDATA_EXECUTABLE* aurora = (AURORA_LAUNCHDATA_EXECUTABLE*)pLaunchData; XGetLaunchData(pLaunchData, dwLaunchDataSize); memset(extracted_path, 0, dwLaunchDataSize); - if (aurora->ApplicationId == AURORA_LAUNCHDATA_APPID && aurora->FunctionId == AURORA_LAUNCHDATA_EXECUTABLE_FUNCID) - { - if (xbox_io_mount("aurora:", aurora->SystemPath) >= 0) - snprintf(extracted_path, dwLaunchDataSize, - "aurora:%s%s", aurora->RelativePath, aurora->Exectutable); - } - else - strlcpy(extracted_path, pLaunchData, dwLaunchDataSize); + strlcpy(extracted_path, pLaunchData, dwLaunchDataSize); /* Auto-start game */ if (!string_is_empty(extracted_path)) diff --git a/frontend/drivers/platform_xdk.h b/frontend/drivers/platform_xdk.h new file mode 100644 index 0000000000..fa6121fca6 --- /dev/null +++ b/frontend/drivers/platform_xdk.h @@ -0,0 +1,1000 @@ +#ifdef _XBOX1 +#include + +// Don't do __declspec(dllimport) for things like emulators +#if defined(NTSYSAPI) && defined(DONT_IMPORT_INTERNAL) +#undef NTSYSAPI +#endif +#ifdef DONT_IMPORT_INTERNAL +#define NTSYSAPI +#endif + +// The normal headers don't have this...? +#define FASTCALL __fastcall + +// The usual NTSTATUS +typedef LONG NTSTATUS; + +// The usual NT_SUCCESS +#define NT_SUCCESS(Status) ((NTSTATUS)(Status) >= 0) + +// Just for documentation +#define EXPORTNUM(x) + + +// Needed for object structures and related things +typedef CONST SHORT CSHORT; + + +// String types +typedef CHAR *PSZ; +typedef CONST CHAR *PCSZ; + +// ANSI_STRING +// Differences from NT: None. +typedef struct _STRING { + USHORT Length; + USHORT MaximumLength; + PCHAR Buffer; +} STRING; +typedef STRING *PSTRING; + +typedef STRING ANSI_STRING; +typedef PSTRING PANSI_STRING; + + +// IO Status Block type (UNVERIFIED) +// Differences from NT: None. +typedef struct _IO_STATUS_BLOCK { + union { + NTSTATUS Status; + PVOID Pointer; + }; + + ULONG_PTR Information; +} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK; + +// APC routine +typedef +VOID +(NTAPI *PIO_APC_ROUTINE) ( + IN PVOID ApcContext, + IN PIO_STATUS_BLOCK IoStatusBlock, + IN ULONG Reserved + ); + + +// Header for dispatcher objects +// Differences from NT: None. +typedef struct _DISPATCHER_HEADER { + UCHAR Type; + UCHAR Absolute; + UCHAR Size; + UCHAR Inserted; + LONG SignalState; + LIST_ENTRY WaitListHead; +} DISPATCHER_HEADER; + + +// Object types +#define NotificationTimerObject 8 +#define SynchronizationTimerObject 9 +#define DpcObject 19 + + +// Object Attributes type +// Differences from NT: There are no Length, SecurityDescriptor, or +// SecurityQualityOfService fields. Also, ObjectName is ANSI, not +// Unicode. +typedef struct _OBJECT_ATTRIBUTES { + HANDLE RootDirectory; + PANSI_STRING ObjectName; + ULONG Attributes; +} OBJECT_ATTRIBUTES; +typedef OBJECT_ATTRIBUTES *POBJECT_ATTRIBUTES; + +// Flags for OBJECT_ATTRIBUTES::Attributes +#define OBJ_INHERIT 0x00000002L +#define OBJ_PERMANENT 0x00000010L +#define OBJ_EXCLUSIVE 0x00000020L +#define OBJ_CASE_INSENSITIVE 0x00000040L +#define OBJ_OPENIF 0x00000080L +#define OBJ_OPENLINK 0x00000100L +#define OBJ_KERNEL_HANDLE 0x00000200L +#define OBJ_VALID_ATTRIBUTES 0x000003F2L + +// CreateDisposition values for NtCreateFile() +#define FILE_SUPERSEDE 0x00000000 +#define FILE_OPEN 0x00000001 +#define FILE_CREATE 0x00000002 +#define FILE_OPEN_IF 0x00000003 +#define FILE_OVERWRITE 0x00000004 +#define FILE_OVERWRITE_IF 0x00000005 +#define FILE_MAXIMUM_DISPOSITION 0x00000005 + +// CreateOption values for NtCreateFile() +// FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT is what CreateFile +// uses for most things when translating to NtCreateFile. +#define FILE_DIRECTORY_FILE 0x00000001 +#define FILE_WRITE_THROUGH 0x00000002 +#define FILE_SEQUENTIAL_ONLY 0x00000004 +#define FILE_NO_INTERMEDIATE_BUFFERING 0x00000008 +#define FILE_SYNCHRONOUS_IO_ALERT 0x00000010 +#define FILE_SYNCHRONOUS_IO_NONALERT 0x00000020 +#define FILE_NON_DIRECTORY_FILE 0x00000040 +#define FILE_CREATE_TREE_CONNECTION 0x00000080 +#define FILE_COMPLETE_IF_OPLOCKED 0x00000100 +#define FILE_NO_EA_KNOWLEDGE 0x00000200 +#define FILE_OPEN_FOR_RECOVERY 0x00000400 +#define FILE_RANDOM_ACCESS 0x00000800 +#define FILE_DELETE_ON_CLOSE 0x00001000 +#define FILE_OPEN_BY_FILE_ID 0x00002000 +#define FILE_OPEN_FOR_BACKUP_INTENT 0x00004000 +#define FILE_NO_COMPRESSION 0x00008000 +#define FILE_RESERVE_OPFILTER 0x00100000 +#define FILE_OPEN_REPARSE_POINT 0x00200000 +#define FILE_OPEN_NO_RECALL 0x00400000 +#define FILE_OPEN_FOR_FREE_SPACE_QUERY 0x00800000 +#define FILE_COPY_STRUCTURED_STORAGE 0x00000041 +#define FILE_STRUCTURED_STORAGE 0x00000441 +#define FILE_VALID_OPTION_FLAGS 0x00ffffff +#define FILE_VALID_PIPE_OPTION_FLAGS 0x00000032 +#define FILE_VALID_MAILSLOT_OPTION_FLAGS 0x00000032 +#define FILE_VALID_SET_FLAGS 0x00000036 + + +// NtQueryVolumeInformation / NtSetVolumeInformation stuff +// Type of information to retrieve; FileFsSizeInformation and +// FileFsDeviceInformation are the only ones confirmed to work. +typedef enum _FSINFOCLASS { + FileFsVolumeInformation = 1, + FileFsLabelInformation, + FileFsSizeInformation, + FileFsDeviceInformation, + FileFsAttributeInformation, + FileFsControlInformation, + FileFsFullSizeInformation, + FileFsObjectInformation +} FS_INFORMATION_CLASS, *PFS_INFORMATION_CLASS; + +// Structure of FileFsSizeInformation +typedef struct _FILE_FS_SIZE_INFORMATION { + LARGE_INTEGER TotalAllocationUnits; + LARGE_INTEGER AvailableAllocationUnits; + ULONG SectorsPerAllocationUnit; + ULONG BytesPerSector; +} FILE_FS_SIZE_INFORMATION, *PFILE_FS_SIZE_INFORMATION; + +#define DEVICE_TYPE ULONG + +// Structure of FileFsDeviceInformation +typedef struct _FILE_FS_DEVICE_INFORMATION { + DEVICE_TYPE DeviceType; + ULONG Characteristics; +} FILE_FS_DEVICE_INFORMATION, *PFILE_FS_DEVICE_INFORMATION; + +// DEVICE_TYPEs (I took a guess as to which the XBOX might have.) +#define FILE_DEVICE_CD_ROM 0x00000002 +#define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003 +#define FILE_DEVICE_CONTROLLER 0x00000004 +#define FILE_DEVICE_DISK 0x00000007 +#define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008 +#define FILE_DEVICE_FILE_SYSTEM 0x00000009 +#define FILE_DEVICE_NULL 0x00000015 +#define FILE_DEVICE_SCREEN 0x0000001c +#define FILE_DEVICE_SOUND 0x0000001d +#define FILE_DEVICE_UNKNOWN 0x00000022 +#define FILE_DEVICE_VIDEO 0x00000023 +#define FILE_DEVICE_VIRTUAL_DISK 0x00000024 +#define FILE_DEVICE_FULLSCREEN_VIDEO 0x00000034 + +// Characteristics +#define FILE_REMOVABLE_MEDIA 0x00000001 +#define FILE_READ_ONLY_DEVICE 0x00000002 +#define FILE_FLOPPY_DISKETTE 0x00000004 +#define FILE_WRITE_ONCE_MEDIA 0x00000008 +#define FILE_REMOTE_DEVICE 0x00000010 +#define FILE_DEVICE_IS_MOUNTED 0x00000020 +#define FILE_VIRTUAL_VOLUME 0x00000040 +#define FILE_AUTOGENERATED_DEVICE_NAME 0x00000080 +#define FILE_DEVICE_SECURE_OPEN 0x00000100 + +/* Physical address + * Differences from NT: 32 bit address instead of 64. */ +typedef ULONG PHYSICAL_ADDRESS, *PPHYSICAL_ADDRESS; + +/* NtCreateFile/NtOpenFile stuff */ +#define FILE_SUPERSEDED 0x00000000 +#define FILE_OPENED 0x00000001 +#define FILE_CREATED 0x00000002 +#define FILE_OVERWRITTEN 0x00000003 +#define FILE_EXISTS 0x00000004 +#define FILE_DOES_NOT_EXIST 0x00000005 + +// NtReadFile/NtWriteFile stuff +#define FILE_WRITE_TO_END_OF_FILE 0xffffffff +#define FILE_USE_FILE_POINTER_POSITION 0xfffffffe + +// Device types +#define FILE_DEVICE_CD_ROM 0x00000002 +#define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003 +#define FILE_DEVICE_CONTROLLER 0x00000004 +#define FILE_DEVICE_SCSI FILE_DEVICE_CONTROLLER +#define IOCTL_SCSI_BASE FILE_DEVICE_CONTROLLER +#define FILE_DEVICE_DISK 0x00000007 +#define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008 +#define FILE_DEVICE_DVD 0x00000033 + +// Access types +#define FILE_ANY_ACCESS 0 +#define FILE_READ_ACCESS 0x0001 /* file & pipe */ +#define FILE_WRITE_ACCESS 0x0002 /* file & pipe */ + +// Method types +#define METHOD_BUFFERED 0 +#define METHOD_IN_DIRECT 1 +#define METHOD_OUT_DIRECT 2 +#define METHOD_NEITHER 3 + +// The all-important CTL_CODE +#define CTL_CODE( DeviceType, Function, Method, Access ) ( \ + ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \ +) + +// IDE/SCSI codes +// IOCTL_SCSI_PASS_THROUGH_DIRECT is the only one known to be used. +// Differences from NT: None. +#define IOCTL_SCSI_PASS_THROUGH CTL_CODE(IOCTL_SCSI_BASE, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) +#define IOCTL_SCSI_MINIPORT CTL_CODE(IOCTL_SCSI_BASE, 0x0402, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) +#define IOCTL_SCSI_GET_INQUIRY_DATA CTL_CODE(IOCTL_SCSI_BASE, 0x0403, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_SCSI_GET_CAPABILITIES CTL_CODE(IOCTL_SCSI_BASE, 0x0404, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_SCSI_PASS_THROUGH_DIRECT CTL_CODE(IOCTL_SCSI_BASE, 0x0405, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) +#define IOCTL_SCSI_GET_ADDRESS CTL_CODE(IOCTL_SCSI_BASE, 0x0406, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_SCSI_RESCAN_BUS CTL_CODE(IOCTL_SCSI_BASE, 0x0407, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_SCSI_GET_DUMP_POINTERS CTL_CODE(IOCTL_SCSI_BASE, 0x0408, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_SCSI_FREE_DUMP_POINTERS CTL_CODE(IOCTL_SCSI_BASE, 0x0409, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_IDE_PASS_THROUGH CTL_CODE(IOCTL_SCSI_BASE, 0x040a, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) + +// Special XBOX code? +#define IOCTL_CDROM_AUTHENTICATE_DISK CTL_CODE(FILE_DEVICE_CD_ROM, 0x0020, METHOD_BUFFERED, FILE_READ_ACCESS) + +/* Structure for IOCTL_SCSI_PASS_THROUGH_DIRECT + * Differences from NT: None, believe it or not. */ +typedef struct _SCSI_PASS_THROUGH_DIRECT { + /*000*/ USHORT Length; + /*002*/ UCHAR ScsiStatus; + /*003*/ UCHAR PathId; + /*004*/ UCHAR TargetId; + /*005*/ UCHAR Lun; + /*006*/ UCHAR CdbLength; + /*007*/ UCHAR SenseInfoLength; + /*008*/ UCHAR DataIn; + /*00C*/ ULONG DataTransferLength; + /*010*/ ULONG TimeOutValue; + /*014*/ PVOID DataBuffer; + /*018*/ ULONG SenseInfoOffset; + /*01C*/ UCHAR Cdb[16]; +}SCSI_PASS_THROUGH_DIRECT, *PSCSI_PASS_THROUGH_DIRECT; + +/* DataIn fields for IOCTL_SCSI_PASS_THROUGH_DIRECT */ +#define SCSI_IOCTL_DATA_OUT 0 +#define SCSI_IOCTL_DATA_IN 1 +#define SCSI_IOCTL_DATA_UNSPECIFIED 2 + +/* Kernel object type (unsure about the structure...) */ +typedef struct _OBJECT_TYPE +{ + // Same prototype as ExAllocatePoolWithTag, because that's the usual one + PVOID + (NTAPI *AllocationFunction)( + SIZE_T NumberOfBytes, + ULONG Tag + ); + + // Same prototype as ExFreePool, because that's the usual one + VOID + (NTAPI *FreeFunction)( + IN PVOID P + ); + + // The prototypes of these are unknown + void *CloseFunction; + void *DeleteFunction; + void *ParseFunction; + + // Unknown DWORD... Size of this object type maybe? + void *DefaultObjectMaybe; + + // 4 letter tag for this object type + CHAR Tag[4]; +} OBJECT_TYPE; +typedef OBJECT_TYPE *POBJECT_TYPE; + +// Object types +extern POBJECT_TYPE IoFileObjectType; +extern POBJECT_TYPE ExEventObjectType; +extern POBJECT_TYPE ExSemaphoreObjectType; +extern POBJECT_TYPE IoCompletionObjectType; +extern POBJECT_TYPE IoDeviceObjectType; + + +// *_OBJECT and related structures (mostly opaque since I'm lazy) +typedef struct _DRIVER_OBJECT { + CSHORT Type; + CSHORT Size; + struct _DEVICE_OBJECT *DeviceObject; + // ... +} DRIVER_OBJECT; +typedef DRIVER_OBJECT *PDRIVER_OBJECT; + +typedef struct _DEVICE_OBJECT { + CSHORT Type; + USHORT Size; + LONG ReferenceCount; + PDRIVER_OBJECT DriverObject; + // ... +} DEVICE_OBJECT; +typedef DEVICE_OBJECT *PDEVICE_OBJECT; + +typedef struct _FILE_OBJECT { + CSHORT Type; + CSHORT Size; + PDEVICE_OBJECT DeviceObject; + // ... +} FILE_OBJECT; +typedef FILE_OBJECT *PFILE_OBJECT; + + +/* Thread information structures */ + +/* IRQL */ +typedef UCHAR KIRQL, *PKIRQL; +#define PASSIVE_LEVEL 0 // Passive release level +#define LOW_LEVEL 0 // Lowest interrupt level +#define APC_LEVEL 1 // APC interrupt level +#define DISPATCH_LEVEL 2 // Dispatcher level + +// Thread entry point +// NOTE: This is not a standard call! You can't call this function from C code! +// You push registers like stdcall, but ebp + 4 must point to the first argument before the call! +// +// Differences from NT: 2 parameters instead of 1; strange calling convention +typedef +VOID +(NTAPI *PKSTART_ROUTINE) ( + IN PVOID StartContext1, + IN PVOID StartContext2 + ); + +// Structure of a critical section +// Same as the XBOX's RTL_CRITICAL_SECTION, but with the more explicit header +typedef struct _KCRITICAL_SECTION +{ + // 000 Dispatcher header + DISPATCHER_HEADER Header; + // 010 Lock count of the critical section + LONG LockCount; + // 014 Recursion count of the critical section + LONG RecursionCount; + // 018 Thread ID of the thread that currently owns this critical section + ULONG OwningThread; +} KCRITICAL_SECTION, *PKCRITICAL_SECTION; + +// Structure of a thread object +typedef struct _KTHREAD +{ + // 000 Dispatcher header + DISPATCHER_HEADER Header; + // 010 Unknown + BYTE unknown[0x18]; + // 028 Pointer to TLS data + PVOID TlsData; + // ??? just padding - real size is unknown + BYTE unknown2[0x100]; +} KTHREAD, *PKTHREAD; + +// Structure of the data at FS +typedef struct _FS_STRUCTURE +{ + // 000 Current exception handler information + PVOID *ExceptionFrame; + // 004 Pointer to current TLS data top + PVOID TlsDataTop; + // 008 + BYTE unknown2[0x1C]; + // 024 Current IRQL of the OS + KIRQL CurrentIrql; + // 028 Thread structure of the current thread + PKTHREAD ThreadObject; + // ??? just padding - real size is unknown + BYTE unknown3[0x100]; +} FS_STRUCTURE, *PFS_STRUCTURE; + +// DPC routine +typedef +VOID +(*PKDEFERRED_ROUTINE) ( + IN struct _KDPC *Dpc, + IN PVOID DeferredContext, + IN PVOID SystemArgument1, + IN PVOID SystemArgument2 + ); + +// DPC information +// It's not known which of these fields are used on XBOX. +typedef struct _KDPC { + CSHORT Type; + UCHAR Number; + UCHAR Importance; + LIST_ENTRY DpcListEntry; + PKDEFERRED_ROUTINE DeferredRoutine; + PVOID DeferredContext; + PVOID SystemArgument1; + PVOID SystemArgument2; + PULONG_PTR Lock; +} KDPC, *PKDPC; + + +// Timers +typedef enum _TIMER_TYPE { + NotificationTimer, + SynchronizationTimer + } TIMER_TYPE; + +typedef struct _KTIMER { + DISPATCHER_HEADER Header; + ULARGE_INTEGER DueTime; + LIST_ENTRY TimerListEntry; + struct _KDPC *Dpc; + LONG Period; +} KTIMER, *PKTIMER; + +/* XBE stuff + * Not used in any exported kernel calls, but still useful. + */ + +/* XBE header information */ +typedef struct _XBE_HEADER +{ + // 000 "XBEH" + CHAR Magic[4]; + // 004 RSA digital signature of the entire header area + UCHAR HeaderSignature[256]; + // 104 Base address of XBE image (must be 0x00010000?) + PVOID BaseAddress; + // 108 Size of all headers combined - other headers must be within this + ULONG HeaderSize; + // 10C Size of entire image + ULONG ImageSize; + // 110 Size of this header (always 0x178?) + ULONG XbeHeaderSize; + // 114 Image timestamp - unknown format + ULONG Timestamp; + // 118 Pointer to certificate data (must be within HeaderSize) + struct _XBE_CERTIFICATE *Certificate; + // 11C Number of sections + DWORD NumSections; + // 120 Pointer to section headers (must be within HeaderSize) + struct _XBE_SECTION *Sections; + // 124 Initialization flags + ULONG InitFlags; + // 128 Entry point (XOR'd; see xboxhacker.net) + PVOID EntryPoint; + // 12C Pointer to TLS directory + struct _XBE_TLS_DIRECTORY *TlsDirectory; + // 130 Stack commit size + ULONG StackCommit; + // 134 Heap reserve size + ULONG HeapReserve; + // 138 Heap commit size + ULONG HeapCommit; + // 13C PE base address (?) + PVOID PeBaseAddress; + // 140 PE image size (?) + ULONG PeImageSize; + // 144 PE checksum (?) + ULONG PeChecksum; + // 148 PE timestamp (?) + ULONG PeTimestamp; + // 14C PC path and filename to EXE file from which XBE is derived + PCSZ PcExePath; + // 150 PC filename (last part of PcExePath) from which XBE is derived + PCSZ PcExeFilename; + // 154 PC filename (Unicode version of PcExeFilename) + PWSTR PcExeFilenameUnicode; + // 158 Pointer to kernel thunk table (XOR'd; EFB1F152 debug) + ULONG_PTR *KernelThunkTable; + // 15C Non-kernel import table (debug only) + PVOID DebugImportTable; + // 160 Number of library headers + ULONG NumLibraries; + // 164 Pointer to library headers + struct _XBE_LIBRARY *Libraries; + // 168 Pointer to kernel library header + struct _XBE_LIBRARY *KernelLibrary; + // 16C Pointer to XAPI library + struct _XBE_LIBRARY *XapiLibrary; + // 170 Pointer to logo bitmap (NULL = use default of Microsoft) + PVOID LogoBitmap; + // 174 Size of logo bitmap + ULONG LogoBitmapSize; + // 178 +} XBE_HEADER, *PXBE_HEADER; + +// Certificate structure +typedef struct _XBE_CERTIFICATE { + // 000 Size of certificate + ULONG Size; + // 004 Certificate timestamp (unknown format) + ULONG Timestamp; + // 008 Title ID + ULONG TitleId; + // 00C Name of the game (Unicode) + WCHAR TitleName[40]; + // 05C Alternate title ID's (0-terminated) + ULONG AlternateTitleIds[16]; + // 09C Allowed media types - 1 bit match between XBE and media = boots + ULONG MediaTypes; + // 0A0 Allowed game regions - 1 bit match between this and XBOX = boots + ULONG GameRegion; + // 0A4 Allowed game ratings - 1 bit match between this and XBOX = boots + ULONG GameRating; + // 0A8 Disk number (?) + ULONG DiskNumber; + // 0AC Version (?) + ULONG Version; + // 0B0 LAN key for this game + UCHAR LanKey[16]; + // 0C0 Signature key for this game + UCHAR SignatureKey[16]; + // 0D0 Signature keys for the alternate title ID's + UCHAR AlternateSignatureKeys[16][16]; + // 1D0 +} XBE_CERTIFICATE, *PXBE_CERTIFICATE; + +// Section headers +typedef struct _XBE_SECTION { + // 000 Flags + ULONG Flags; + // 004 Virtual address (where this section loads in RAM) + PVOID VirtualAddress; + // 008 Virtual size (size of section in RAM; after FileSize it's 00'd) + ULONG VirtualSize; + // 00C File address (where in the file from which this section comes) + ULONG FileAddress; + // 010 File size (size of the section in the XBE file) + ULONG FileSize; + // 014 Pointer to section name + PCSZ SectionName; + // 018 Section reference count - when >= 1, section is loaded + LONG SectionReferenceCount; + // 01C Pointer to head shared page reference count + WORD *HeadReferenceCount; + // 020 Pointer to tail shared page reference count + WORD *TailReferenceCount; + // 024 SHA hash. Hash DWORD containing FileSize, then hash section. + DWORD ShaHash[5]; + // 038 +} XBE_SECTION, *PXBE_SECTION; + +/* TLS directory information needed later + * Library version data needed later */ + +/* Initialization flags */ +#define XBE_INIT_MOUNT_UTILITY 0x00000001 +#define XBE_INIT_FORMAT_UTILITY 0x00000002 +#define XBE_INIT_64M_RAM_ONLY 0x00000004 +#define XBE_INIT_DONT_SETUP_HDD 0x00000008 + +/* Region codes */ +#define XBE_REGION_US_CANADA 0x00000001 +#define XBE_REGION_JAPAN 0x00000002 +#define XBE_REGION_ELSEWHERE 0x00000004 +#define XBE_REGION_DEBUG 0x80000000 + +/* Media types */ +#define XBE_MEDIA_HDD 0x00000001 +#define XBE_MEDIA_XBOX_DVD 0x00000002 +#define XBE_MEDIA_ANY_CD_OR_DVD 0x00000004 +#define XBE_MEDIA_CD 0x00000008 +#define XBE_MEDIA_1LAYER_DVDROM 0x00000010 +#define XBE_MEDIA_2LAYER_DVDROM 0x00000020 +#define XBE_MEDIA_1LAYER_DVDR 0x00000040 +#define XBE_MEDIA_2LAYER_DVDR 0x00000080 +#define XBE_MEDIA_USB 0x00000100 +#define XBE_MEDIA_ALLOW_UNLOCKED_HDD 0x40000000 + +/* Section flags */ +#define XBE_SEC_WRITABLE 0x00000001 +#define XBE_SEC_PRELOAD 0x00000002 +#define XBE_SEC_EXECUTABLE 0x00000004 +#define XBE_SEC_INSERTED_FILE 0x00000008 +#define XBE_SEC_RO_HEAD_PAGE 0x00000010 +#define XBE_SEC_RO_TAIL_PAGE 0x00000020 + +/* x86 page size */ +#define PAGE_SIZE 0x1000 + +/* Native NT API calls on the XBOX */ + +/* PAGE_ALIGN: + * Returns an address rounded down to the nearest page boundary. + * + * Differences from NT: None. + */ +#define PAGE_ALIGN(Va) ((PVOID)((ULONG_PTR)(Va) & ~(PAGE_SIZE - 1))) + +// NtReadFile: +// Reads a file. +// +// Differences from NT: There is no Key parameter. +NTSYSAPI +EXPORTNUM(219) +NTSTATUS +NTAPI +NtReadFile( + IN HANDLE FileHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PVOID Buffer, + IN ULONG Length, + IN PLARGE_INTEGER ByteOffset + ); + +// NtWriteFile: +// Writes a file. +// +// Differences from NT: There is no Key parameter. +NTSYSAPI +EXPORTNUM(236) +NTSTATUS +NTAPI +NtWriteFile( + IN HANDLE FileHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PVOID Buffer, + IN ULONG Length, + IN PLARGE_INTEGER ByteOffset + ); + +// NtQueryVolumeInformation: +// Queries information about a file system. This is not documented by +// Microsoft even under NT. +// +// Differences from NT: None known. +NTSYSAPI +EXPORTNUM(218) +NTSTATUS +NTAPI +NtQueryVolumeInformationFile( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PVOID VolumeInformation, + IN ULONG VolumeInformationLength, + IN FS_INFORMATION_CLASS VolumeInformationClass + ); + +// NtClose: +// Closes a file or other handle. +// +// Differences from NT: None. +NTSYSAPI +EXPORTNUM(187) +NTSTATUS +NTAPI +NtClose( + IN HANDLE Handle + ); + +// NtAllocateVirtualMemory: +// Allocates virtual memory. +// +// Differences from NT: There is no ProcessHandle parameter. +NTSYSAPI +EXPORTNUM(184) +NTSTATUS +NTAPI +NtAllocateVirtualMemory( + IN OUT PVOID *BaseAddress, + IN ULONG ZeroBits, + IN OUT PULONG AllocationSize, + IN ULONG AllocationType, + IN ULONG Protect + ); + +// NtFreeVirtualMemory: +// Frees virtual memory. +// +// Differences from NT: There is no ProcessHandle parameter. +NTSYSAPI +EXPORTNUM(199) +NTSTATUS +NTAPI +NtFreeVirtualMemory( + IN OUT PVOID *BaseAddress, + IN OUT PULONG FreeSize, + IN ULONG FreeType + ); + + +// Kernel-level routines + +// MmMapIoSpace: +// Maps a physical address area into the virtual address space. +// DO NOT USE MEMORY MAPPED WITH THIS AS A BUFFER TO OTHER CALLS. For +// example, don't WriteFile or NtWriteFile these buffers. Copy them first. +// +// Differences from NT: PhysicalAddress is 32 bit, not 64. ProtectionType +// specifies the page protections, but it's a Win32 PAGE_ macro instead +// of the normal NT enumeration. PAGE_READWRITE is probably what you +// want... +NTSYSAPI +EXPORTNUM(177) +PVOID +NTAPI +MmMapIoSpace( + IN PHYSICAL_ADDRESS PhysicalAddress, + IN ULONG NumberOfBytes, + IN ULONG ProtectionType + ); + +// MmGetPhysicalAddress: +// Translates a virtual address into a physical address. +// +// Differences from NT: PhysicalAddress is 32 bit, not 64. +NTSYSAPI +EXPORTNUM(173) +PHYSICAL_ADDRESS +NTAPI +MmGetPhysicalAddress( + IN PVOID BaseAddress + ); + +// MmUnmapIoSpace: +// Unmaps a virtual address mapping made by MmMapIoSpace. +// +// Differences from NT: None. +NTSYSAPI +EXPORTNUM(183) +PVOID +NTAPI +MmUnmapIoSpace( + IN PVOID BaseAddress, + IN ULONG NumberOfBytes + ); + +// MmAllocateContiguousMemory: +// Allocates a range of physically contiguous, cache-aligned memory from the +// non-paged pool (= main pool on XBOX). +// +// Differences from NT: HighestAcceptableAddress was deleted, opting instead +// to not care about the highest address. +NTSYSAPI +EXPORTNUM(165) +PVOID +NTAPI +MmAllocateContiguousMemory( + IN ULONG NumberOfBytes + ); + +// MmFreeContiguousMemory: +// Frees memory allocated with MmAllocateContiguousMemory. +// +// Differences from NT: None. +NTSYSAPI +EXPORTNUM(171) +VOID +NTAPI +MmFreeContiguousMemory( + IN PVOID BaseAddress + ); + +// IoCreateSymbolicLink: +// Creates a symbolic link in the object namespace. +// NtCreateSymbolicLinkObject is much harder to use than this simple +// function, so just use this one. +// +// Differences from NT: Uses ANSI_STRING instead of UNICODE_STRING. +NTSYSAPI +EXPORTNUM(67) +NTSTATUS +NTAPI +IoCreateSymbolicLink( + IN PANSI_STRING SymbolicLinkName, + IN PANSI_STRING DeviceName + ); + +// IoDeleteSymbolicLink: +// Creates a symbolic link in the object namespace. Deleting symbolic links +// through the Nt* functions is a pain, so use this instead. +// +// Differences from NT: Uses ANSI_STRING instead of UNICODE_STRING. +NTSYSAPI +EXPORTNUM(69) +NTSTATUS +NTAPI +IoDeleteSymbolicLink( + IN PANSI_STRING SymbolicLinkName + ); + + +// ObReferenceObjectByHandle: +// Turns a handle into a kernel object pointer. The ObjectType parameter +// specifies what type of object it is. This function also increments the +// object's reference count. +// +// Differences from NT: There are no DesiredAccess, AccessMode, or +// HandleInformation parameters. +NTSYSAPI +EXPORTNUM(246) +NTSTATUS +NTAPI +ObReferenceObjectByHandle( + IN HANDLE Handle, + IN POBJECT_TYPE ObjectType OPTIONAL, + OUT PVOID *Object + ); + +// ObfReferenceObject/ObReferenceObject: +// Increments the object's reference count. +// +// Differences from NT: None. +#define ObReferenceObject(Object) ObfReferenceObject(Object) +NTSYSAPI +EXPORTNUM(251) +VOID +FASTCALL +ObfReferenceObject( + IN PVOID Object + ); + +// ObfDereferenceObject/ObDereferenceObject: +// Decrements the object's reference count, deleting it if it is now unused. +// +// Differences from NT: None. +#define ObDereferenceObject(a) ObfDereferenceObject(a) +NTSYSAPI +EXPORTNUM(250) +VOID +FASTCALL +ObfDereferenceObject( + IN PVOID Object + ); + +// Kernel routines only in the XBOX + +// HalEnableSecureTrayEject: +// Notifies the SMBUS that ejecting the DVD-ROM should not reset the system. +// Note that this function can't really be called directly... +// +// New to the XBOX. +NTSYSAPI +EXPORTNUM(365) +VOID +NTAPI +HalEnableSecureTrayEject( + VOID + ); + +// XeLoadSection: +// Adds one to the reference count of the specified section and loads if the +// count is now above zero. +// +// New to the XBOX. +NTSYSAPI +EXPORTNUM(327) +NTSTATUS +NTAPI +XeLoadSection( + IN OUT PXBE_SECTION section + ); + +/* Error codes */ +#define STATUS_SUCCESS 0x00000000 +#define STATUS_UNSUCCESSFUL 0xC0000001 +#define STATUS_UNRECOGNIZED_MEDIA 0xC0000014 + +/* The SCSI input buffer was too large (not necessarily an error!) */ +#define STATUS_DATA_OVERRUN 0xC000003C +#define STATUS_INVALID_IMAGE_FORMAT 0xC000007B +#define STATUS_INSUFFICIENT_RESOURCES 0xC000009A +#define STATUS_TOO_MANY_SECRETS 0xC0000156 +#define STATUS_REGION_MISMATCH 0xC0050001 + +#include + + // Thanks and credit go to Woodoo + extern VOID WINAPI HalWriteSMBusValue(BYTE, BYTE, BOOL, BYTE); + extern VOID WINAPI HalReadSMCTrayState(DWORD* state, DWORD* count); + + // Thanks and credit go to Team Evox + extern VOID WINAPI HalReturnToFirmware(DWORD); + + extern INT WINAPI XNetLoadConfigParams(LPBYTE); + extern INT WINAPI XNetSaveConfigParams(LPBYTE); + + extern INT WINAPI XWriteTitleInfoNoReboot(LPVOID,LPVOID,DWORD,DWORD,LPVOID); + + extern DWORD* LaunchDataPage; + +static HRESULT xbox_io_mount(char *szDrive, char *szDevice) +{ + STRING DeviceName, LinkName; +#ifndef IS_SALAMANDER + bool original_verbose = verbosity_is_enabled(); +#endif + char szSourceDevice[48] = {0}; + char szDestinationDrive[16] = {0}; + + snprintf(szSourceDevice, sizeof(szSourceDevice), + "\\Device\\%s", szDevice); + snprintf(szDestinationDrive, sizeof(szDestinationDrive), + "\\??\\%s", szDrive); + + DeviceName.Length = strlen(szSourceDevice); + DeviceName.MaximumLength = strlen(szSourceDevice) + 1; + DeviceName.Buffer = szSourceDevice; + + LinkName.Length = strlen(szDestinationDrive); + LinkName.MaximumLength = strlen(szDestinationDrive) + 1; + LinkName.Buffer = szDestinationDrive; + + IoCreateSymbolicLink(&LinkName, &DeviceName); + +#ifndef IS_SALAMANDER + if (original_verbose) + verbosity_enable(); + else + verbosity_disable(); +#endif + return S_OK; +} + +static HRESULT xbox_io_unmount(char *szDrive) +{ + STRING LinkName; + char szDestinationDrive[16] = {0}; + + snprintf(szDestinationDrive, sizeof(szDestinationDrive), + "\\??\\%s", szDrive); + + LinkName.Length = strlen(szDestinationDrive); + LinkName.MaximumLength = strlen(szDestinationDrive) + 1; + LinkName.Buffer = szDestinationDrive; + + IoDeleteSymbolicLink(&LinkName); + + return S_OK; +} +#endif + +#ifdef _XBOX360 +typedef struct _STRING +{ + USHORT Length; + USHORT MaximumLength; + PCHAR Buffer; +} STRING, *PSTRING; + +VOID RtlInitAnsiString(PSTRING DestinationString, PCHAR SourceString); +HRESULT ObDeleteSymbolicLink(PSTRING SymbolicLinkName); +HRESULT ObCreateSymbolicLink(PSTRING SymbolicLinkName, PSTRING DeviceName); + +static HRESULT xbox_io_mount(const char* szDrive, char* szDevice) +{ + STRING DeviceName, LinkName; + char szDestinationDrive[PATH_MAX_LENGTH]; + + snprintf(szDestinationDrive, sizeof(szDestinationDrive), + "\\??\\%s", szDrive); + RtlInitAnsiString(&DeviceName, szDevice); + RtlInitAnsiString(&LinkName, (PCHAR)szDestinationDrive); + ObDeleteSymbolicLink(&LinkName); + return (HRESULT)ObCreateSymbolicLink(&LinkName, &DeviceName); +} +#endif From 27c6e3c5c42675da9e178bf825c860518cd5e679 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 5 Feb 2018 01:52:11 +0100 Subject: [PATCH 087/232] (Zarch) Buildfix --- menu/drivers/zarch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menu/drivers/zarch.c b/menu/drivers/zarch.c index 654490c301..191d93946c 100644 --- a/menu/drivers/zarch.c +++ b/menu/drivers/zarch.c @@ -1142,7 +1142,7 @@ static bool zarch_menu_init_list(void *data) file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0); file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); - menu_displaylist_info_free(&info); + menu_displaylist_info_init(&info); info.label = strdup( msg_hash_to_str(MENU_ENUM_LABEL_HISTORY_TAB)); From 966a1d49e73c14d4ba734eaad89720403a3cd9c1 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Sun, 4 Feb 2018 22:58:10 -0500 Subject: [PATCH 088/232] fix typos --- intl/msg_hash_us.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 4cb8c174a8..9c694e7f55 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -84,7 +84,7 @@ MSG_HASH( ) MSG_HASH( MSG_NETPLAY_DIFFERENT_CORE_VERSIONS, - "WARNING: A netlpay peer is running a different version of the core. If problems occur, use the same version." + "WARNING: A netplay peer is running a different version of the core. If problems occur, use the same version." ) MSG_HASH( MSG_NETPLAY_ENDIAN_DEPENDENT, @@ -2676,7 +2676,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_SUBLABEL_VIDEO_FULLSCREEN, - "Start in fullscreen. Can be changed at runtime. Can be overriden by a command line switch" + "Start in fullscreen. Can be changed at runtime. Can be overridden by a command line switch" ) MSG_HASH( MENU_ENUM_SUBLABEL_VIDEO_WINDOWED_FULLSCREEN, From 12cf1bf5f84078c1e20a205520f75cb81db0f073 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Sun, 4 Feb 2018 22:58:18 -0500 Subject: [PATCH 089/232] update JP translation --- intl/msg_hash_ja.h | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/intl/msg_hash_ja.h b/intl/msg_hash_ja.h index 1eabc2694b..58f93f3eb8 100644 --- a/intl/msg_hash_ja.h +++ b/intl/msg_hash_ja.h @@ -55,6 +55,42 @@ MSG_HASH( MSG_NETPLAY_YOU_HAVE_JOINED_AS_PLAYER_N, "「プレイヤー%d」で接続しました" ) +MSG_HASH( + MSG_NETPLAY_YOU_HAVE_JOINED_WITH_INPUT_DEVICES_S, + "入力デバイス「%.*s」で接続しました" + ) +MSG_HASH( + MSG_NETPLAY_PLAYER_S_LEFT, + "プレヤー「%.*s」が退出しました" + ) +MSG_HASH( + MSG_NETPLAY_S_HAS_JOINED_AS_PLAYER_N, + "「%2$.*1$s」がプレヤー「%3$u」で接続しました" + ) +MSG_HASH( + MSG_NETPLAY_S_HAS_JOINED_WITH_INPUT_DEVICES_S, + "「%2$.*1$s」が入力デバイス「%4$.*3$s」で接続しました" + ) +MSG_HASH( + MSG_NETPLAY_NOT_RETROARCH, + "相手の接続が失敗しました。古いRetroArchバージョンを使っているかもしれません。" + ) +MSG_HASH( + MSG_NETPLAY_OUT_OF_DATE, + "相手のRetroArchバージョンは古いから接続できません。" + ) +MSG_HASH( + MSG_NETPLAY_DIFFERENT_VERSIONS, + "警告:相手が違うRetroArchバージョンを使っています。問題があれば同じバージョンを使って下さい。" + ) +MSG_HASH( + MSG_NETPLAY_DIFFERENT_CORES, + "相手が違うコアを使っています。接続できません。" + ) +MSG_HASH( + MSG_NETPLAY_DIFFERENT_CORE_VERSIONS, + "警告:相手が違うコアのバージョンを使っています。問題があれば同じバージョンを使って下さい。" + ) MSG_HASH( MSG_NETPLAY_ENDIAN_DEPENDENT, "This core does not support inter-architecture netplay between these systems" @@ -91,6 +127,10 @@ MSG_HASH( MSG_NETPLAY_CANNOT_PLAY_NO_SLOTS, "空きプレイヤースロットはありません" ) +MSG_HASH( + MSG_NETPLAY_CANNOT_PLAY_NOT_AVAILABLE, + "選択した入力デバイスが使えません。" + ) MSG_HASH( MSG_NETPLAY_CANNOT_PLAY, "プレイモードを切り替えに出来ませんでした" @@ -1022,7 +1062,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_LINEAR_FILTER, MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_HORIZONTAL_ANIMATION, "横アニメーション") MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_SETTINGS, - "メニュー") + "外観") MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_WALLPAPER, "メニューの壁紙") MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_WALLPAPER_OPACITY, From a43d2b627a0bc4a66c41466a3c640c271350e17a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 5 Feb 2018 13:33:17 +0100 Subject: [PATCH 090/232] (Menu) Cleanups --- menu/cbs/menu_cbs_deferred_push.c | 8 +- menu/cbs/menu_cbs_title.c | 323 +++++++++++++++--------------- msg_hash.h | 1 - 3 files changed, 161 insertions(+), 171 deletions(-) diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index 6d29ea73d7..b6d8c3b8ef 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -882,6 +882,11 @@ static int menu_cbs_init_bind_deferred_push_compare_label( { BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_input_hotkey_binds_list); } + else if (strstr(label, + msg_hash_to_str(MENU_ENUM_LABEL_LOAD_CONTENT_LIST))) + { + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_load_content_list); + } else { if (cbs->enum_idx != MSG_UNKNOWN) @@ -1226,9 +1231,6 @@ static int menu_cbs_init_bind_deferred_push_compare_label( case MENU_LABEL_ADD_CONTENT_LIST: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_add_content_list); break; - case MENU_LABEL_LOAD_CONTENT_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_load_content_list); - break; case MENU_LABEL_MANAGEMENT: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_management_options); break; diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index c5f99e6dc6..b3ab022fcd 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -305,9 +305,157 @@ static int action_get_title_input_binds_list(const char *path, const char *label return 0; } +struct cbs_title_lbl_callback +{ + enum msg_hash_enums id; + int (*cbs)(const char *path, const char *label, + unsigned type, char *s, size_t len); +}; + +static struct cbs_title_lbl_callback cbs_title_lbl_list[] = { + { + MENU_ENUM_LABEL_DEFERRED_CORE_SETTINGS_LIST, + action_get_title_group_settings + }, + { + MENU_ENUM_LABEL_DEFERRED_CONFIGURATION_SETTINGS_LIST, + action_get_configuration_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_SAVING_SETTINGS_LIST, + action_get_saving_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_LOGGING_SETTINGS_LIST, + action_get_logging_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_FRAME_THROTTLE_SETTINGS_LIST, + action_get_frame_throttle_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_REWIND_SETTINGS_LIST, + action_get_rewind_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_ONSCREEN_DISPLAY_SETTINGS_LIST, + action_get_onscreen_display_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_ONSCREEN_NOTIFICATIONS_SETTINGS_LIST, + action_get_onscreen_notifications_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_ONSCREEN_OVERLAY_SETTINGS_LIST, + action_get_onscreen_overlay_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_MENU_VIEWS_SETTINGS_LIST, + action_get_menu_views_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_QUICK_MENU_VIEWS_SETTINGS_LIST, + action_get_quick_menu_views_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_MENU_SETTINGS_LIST, + action_get_menu_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_USER_INTERFACE_SETTINGS_LIST, + action_get_user_interface_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_MENU_FILE_BROWSER_SETTINGS_LIST, + action_get_menu_file_browser_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_RETRO_ACHIEVEMENTS_SETTINGS_LIST, + action_get_retro_achievements_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_WIFI_SETTINGS_LIST, + action_get_wifi_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_UPDATER_SETTINGS_LIST, + action_get_updater_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_NETWORK_SETTINGS_LIST, + action_get_network_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_NETPLAY_LAN_SCAN_SETTINGS_LIST, + action_get_netplay_lan_scan_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_LAKKA_SERVICES_LIST, + action_get_lakka_services_list + }, + { + MENU_ENUM_LABEL_DEFERRED_USER_SETTINGS_LIST, + action_get_user_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_DIRECTORY_SETTINGS_LIST, + action_get_directory_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_PRIVACY_SETTINGS_LIST, + action_get_privacy_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_CORE_CONTENT_DIRS_LIST, + action_get_download_core_content_list + }, + { + MENU_ENUM_LABEL_DEFERRED_CORE_CONTENT_DIRS_SUBDIR_LIST, + action_get_download_core_content_list, + }, + { + MENU_ENUM_LABEL_DEFERRED_FAVORITES_LIST, + action_get_title_goto_favorites + }, + { + MENU_ENUM_LABEL_DEFERRED_IMAGES_LIST, + action_get_title_goto_image + }, + { + MENU_ENUM_LABEL_DEFERRED_MUSIC_LIST, + action_get_title_goto_music + }, + { + MENU_ENUM_LABEL_DEFERRED_VIDEO_LIST, + action_get_title_goto_video + }, + { + MENU_ENUM_LABEL_DEFERRED_DRIVER_SETTINGS_LIST, + action_get_driver_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_AUDIO_SETTINGS_LIST, + action_get_audio_settings_list + }, + { + MENU_ENUM_LABEL_SYSTEM_INFORMATION, + action_get_system_information_list + }, + { + MENU_ENUM_LABEL_NETWORK_INFORMATION, + action_get_network_information_list + }, + { + MENU_ENUM_LABEL_LOAD_CONTENT_LIST, + action_get_load_content_list + } +}; + static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, const char *label, uint32_t label_hash) { + unsigned k; + if (cbs->setting) { const char *parent_group = cbs->setting->parent_group; @@ -320,172 +468,16 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, } } - if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_CORE_SETTINGS_LIST))) + for (k = 0; k < ARRAY_SIZE(cbs_title_lbl_list); k++) { - BIND_ACTION_GET_TITLE(cbs, action_get_core_settings_list); - return 0; + if (string_is_equal(label, msg_hash_to_str(cbs_title_lbl_list[k].id))) + { + BIND_ACTION_GET_TITLE(cbs, cbs_title_lbl_list[k].cbs); + return 0; + } } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_CONFIGURATION_SETTINGS_LIST))) - { - BIND_ACTION_GET_TITLE(cbs, action_get_configuration_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_SAVING_SETTINGS_LIST))) - { - BIND_ACTION_GET_TITLE(cbs, action_get_saving_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_LOGGING_SETTINGS_LIST))) - { - BIND_ACTION_GET_TITLE(cbs, action_get_logging_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_FRAME_THROTTLE_SETTINGS_LIST))) - { - BIND_ACTION_GET_TITLE(cbs, action_get_frame_throttle_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_REWIND_SETTINGS_LIST))) - { - BIND_ACTION_GET_TITLE(cbs, action_get_rewind_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_ONSCREEN_DISPLAY_SETTINGS_LIST))) - { - BIND_ACTION_GET_TITLE(cbs, action_get_onscreen_display_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_ONSCREEN_NOTIFICATIONS_SETTINGS_LIST))) - { - BIND_ACTION_GET_TITLE(cbs, action_get_onscreen_notifications_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_ONSCREEN_OVERLAY_SETTINGS_LIST))) - { - BIND_ACTION_GET_TITLE(cbs, action_get_onscreen_overlay_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_MENU_VIEWS_SETTINGS_LIST))) - { - BIND_ACTION_GET_TITLE(cbs, action_get_menu_views_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_QUICK_MENU_VIEWS_SETTINGS_LIST))) - { - BIND_ACTION_GET_TITLE(cbs, action_get_quick_menu_views_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_MENU_SETTINGS_LIST))) - { - BIND_ACTION_GET_TITLE(cbs, action_get_menu_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_USER_INTERFACE_SETTINGS_LIST))) - { - BIND_ACTION_GET_TITLE(cbs, action_get_user_interface_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_MENU_FILE_BROWSER_SETTINGS_LIST))) - { - BIND_ACTION_GET_TITLE(cbs, action_get_menu_file_browser_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_RETRO_ACHIEVEMENTS_SETTINGS_LIST))) - { - BIND_ACTION_GET_TITLE(cbs, action_get_retro_achievements_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_WIFI_SETTINGS_LIST))) - { - BIND_ACTION_GET_TITLE(cbs, action_get_wifi_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_UPDATER_SETTINGS_LIST))) - { - BIND_ACTION_GET_TITLE(cbs, action_get_updater_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_NETWORK_SETTINGS_LIST))) - { - BIND_ACTION_GET_TITLE(cbs, action_get_network_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_NETPLAY_LAN_SCAN_SETTINGS_LIST))) - { - BIND_ACTION_GET_TITLE(cbs, action_get_netplay_lan_scan_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_LAKKA_SERVICES_LIST))) - { - BIND_ACTION_GET_TITLE(cbs, action_get_lakka_services_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_USER_SETTINGS_LIST))) - { - BIND_ACTION_GET_TITLE(cbs, action_get_user_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_DIRECTORY_SETTINGS_LIST))) - { - BIND_ACTION_GET_TITLE(cbs, action_get_directory_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_PRIVACY_SETTINGS_LIST))) - { - BIND_ACTION_GET_TITLE(cbs, action_get_privacy_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_CORE_CONTENT_DIRS_LIST))) - { - BIND_ACTION_GET_TITLE(cbs, action_get_download_core_content_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_CORE_CONTENT_DIRS_SUBDIR_LIST))) - { - BIND_ACTION_GET_TITLE(cbs, action_get_download_core_content_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_FAVORITES_LIST))) - { - BIND_ACTION_GET_TITLE(cbs, action_get_title_goto_favorites); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_IMAGES_LIST))) - { - BIND_ACTION_GET_TITLE(cbs, action_get_title_goto_image); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_MUSIC_LIST))) - { - BIND_ACTION_GET_TITLE(cbs, action_get_title_goto_music); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_VIDEO_LIST))) - { - BIND_ACTION_GET_TITLE(cbs, action_get_title_goto_video); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_DRIVER_SETTINGS_LIST))) - { - BIND_ACTION_GET_TITLE(cbs, action_get_driver_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_AUDIO_SETTINGS_LIST))) - { - BIND_ACTION_GET_TITLE(cbs, action_get_audio_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_SYSTEM_INFORMATION))) - { - BIND_ACTION_GET_TITLE(cbs, action_get_system_information_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_NETWORK_INFORMATION))) - { - BIND_ACTION_GET_TITLE(cbs, action_get_network_information_list); - return 0; - } - else if (cbs->enum_idx != MSG_UNKNOWN) + + if (cbs->enum_idx != MSG_UNKNOWN) { switch (cbs->enum_idx) { @@ -937,9 +929,6 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_LOAD_CONTENT_SPECIAL: BIND_ACTION_GET_TITLE(cbs, action_get_load_content_special); break; - case MENU_LABEL_LOAD_CONTENT_LIST: - BIND_ACTION_GET_TITLE(cbs, action_get_load_content_list); - break; case MENU_LABEL_ONLINE_UPDATER: BIND_ACTION_GET_TITLE(cbs, action_get_online_updater_list); break; diff --git a/msg_hash.h b/msg_hash.h index 91673d48f3..90b010c185 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1956,7 +1956,6 @@ enum msg_hash_enums #define MENU_LABEL_HELP_AUDIO_VIDEO_TROUBLESHOOTING 0xd44d395cU /* Main menu */ -#define MENU_LABEL_LOAD_CONTENT_LIST 0x5745de1fU #define MENU_LABEL_LOAD_CONTENT_HISTORY 0xfe1d79e5U #define MENU_LABEL_ADD_CONTENT_LIST 0x046f4668U #define MENU_LABEL_ONLINE_UPDATER 0xcac0025eU From d95079465988f3dcdf4bfb370cff53b89cf5eb86 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 5 Feb 2018 13:55:04 +0100 Subject: [PATCH 091/232] (video_shader_parse.c) Be safer with memory allocations --- gfx/video_shader_parse.c | 55 +++++++++++++++------------------------- 1 file changed, 21 insertions(+), 34 deletions(-) diff --git a/gfx/video_shader_parse.c b/gfx/video_shader_parse.c index 3a2d6da9fd..227348f68a 100644 --- a/gfx/video_shader_parse.c +++ b/gfx/video_shader_parse.c @@ -144,7 +144,7 @@ static bool video_shader_parse_pass(config_file_t *conf, char frame_count_mod[64]; size_t path_size = PATH_MAX_LENGTH * sizeof(char); char *tmp_str = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); - char *tmp_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + char *tmp_path = NULL; struct gfx_fbo_scale *scale = NULL; bool tmp_bool = false; float fattr = 0.0f; @@ -165,6 +165,7 @@ static bool video_shader_parse_pass(config_file_t *conf, goto error; } + tmp_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); strlcpy(tmp_path, tmp_str, path_size); path_resolve_realpath(tmp_path, path_size); @@ -172,6 +173,7 @@ static bool video_shader_parse_pass(config_file_t *conf, strlcpy(pass->source.path, tmp_str, sizeof(pass->source.path)); else strlcpy(pass->source.path, tmp_path, sizeof(pass->source.path)); + free(tmp_path); /* Smooth */ snprintf(filter_name_buf, sizeof(filter_name_buf), "filter_linear%u", i); @@ -329,12 +331,10 @@ static bool video_shader_parse_pass(config_file_t *conf, } free(tmp_str); - free(tmp_path); return true; error: free(tmp_str); - free(tmp_path); return false; } @@ -354,14 +354,12 @@ static bool video_shader_parse_textures(config_file_t *conf, const char *id = NULL; char *save = NULL; char *textures = (char*)malloc(1024 * sizeof(char)); - char *tmp_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); - textures[0] = '\0'; + textures[0] = '\0'; if (!config_get_array(conf, "textures", textures, 1024 * sizeof(char))) { free(textures); - free(tmp_path); return true; } @@ -375,6 +373,7 @@ static bool video_shader_parse_textures(config_file_t *conf, char id_mipmap[64]; bool mipmap = false; bool smooth = false; + char *tmp_path = NULL; id_filter[0] = id_wrap[0] = wrap_mode[0] = id_mipmap[0] = '\0'; @@ -382,9 +381,12 @@ static bool video_shader_parse_textures(config_file_t *conf, sizeof(shader->lut[shader->luts].path))) { RARCH_ERR("Cannot find path to texture \"%s\" ...\n", id); - goto error; + free(textures); + return false; } + tmp_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + tmp_path[0] = '\0'; strlcpy(tmp_path, shader->lut[shader->luts].path, path_size); path_resolve_realpath(tmp_path, path_size); @@ -394,6 +396,7 @@ static bool video_shader_parse_textures(config_file_t *conf, strlcpy(shader->lut[shader->luts].path, tmp_path, sizeof(shader->lut[shader->luts].path)); } + free(tmp_path); strlcpy(shader->lut[shader->luts].id, id, sizeof(shader->lut[shader->luts].id)); @@ -417,13 +420,7 @@ static bool video_shader_parse_textures(config_file_t *conf, } free(textures); - free(tmp_path); return true; - -error: - free(textures); - free(tmp_path); - return false; } /** @@ -464,17 +461,15 @@ bool video_shader_resolve_current_parameters(config_file_t *conf, struct video_shader *shader) { size_t param_size = 4096 * sizeof(char); - char *parameters = (char*)malloc(4096 * sizeof(char)); const char *id = NULL; + char *parameters = NULL; char *save = NULL; if (!conf) - { - free(parameters); return false; - } - parameters[0] = '\0'; + parameters = (char*)malloc(4096 * sizeof(char)); + parameters[0] = '\0'; /* Read in parameters which override the defaults. */ if (!config_get_array(conf, "parameters", @@ -529,14 +524,11 @@ bool video_shader_resolve_parameters(config_file_t *conf, { intfstream_t *file = NULL; size_t line_size = 4096 * sizeof(char); - char *line = (char*)malloc(4096 * sizeof(char)); + char *line = NULL; const char *path = shader->pass[i].source.path; if (string_is_empty(path)) - { - free(line); continue; - } #if defined(HAVE_SLANG) && defined(HAVE_SPIRV_CROSS) /* First try to use the more robust slang implementation to support #includes. */ @@ -544,10 +536,7 @@ bool video_shader_resolve_parameters(config_file_t *conf, * GLSL/Cg as well, it should be the same implementation. */ if (string_is_equal(path_get_extension(path), "slang") && slang_preprocess_parse_parameters(shader->pass[i].source.path, shader)) - { - free(line); continue; - } /* If that doesn't work, fallback to the old path. * Ideally, we'd get rid of this path sooner or later. */ @@ -557,11 +546,9 @@ bool video_shader_resolve_parameters(config_file_t *conf, RETRO_VFS_FILE_ACCESS_HINT_NONE); if (!file) - { - free(line); continue; - } + line = (char*)malloc(4096 * sizeof(char)); line[0] = '\0'; while (shader->num_parameters < ARRAY_SIZE(shader->parameters) @@ -614,18 +601,17 @@ static bool video_shader_parse_imports(config_file_t *conf, struct video_shader *shader) { size_t path_size = PATH_MAX_LENGTH * sizeof(char); - char *imports = (char*)malloc(1024 * sizeof(char)); - char *tmp_str = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); const char *id = NULL; char *save = NULL; + char *tmp_str = NULL; + char *imports = (char*)malloc(1024 * sizeof(char)); - imports[0] = tmp_str[0] = '\0'; + imports[0] = '\0'; if (!config_get_array(conf, "imports", imports, 1024 * sizeof(char))) { free(imports); - free(tmp_str); return true; } @@ -730,18 +716,19 @@ static bool video_shader_parse_imports(config_file_t *conf, var->equal = equal; } + tmp_str = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + tmp_str[0] = '\0'; if (config_get_path(conf, "import_script", tmp_str, path_size)) strlcpy(shader->script_path, tmp_str, sizeof(shader->script_path)); config_get_array(conf, "import_script_class", shader->script_class, sizeof(shader->script_class)); + free(tmp_str); free(imports); - free(tmp_str); return true; error: free(imports); - free(tmp_str); return false; } From eec5d7722b9785dae3d60f66b0b3ec4a86c7daa3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 5 Feb 2018 14:19:50 +0100 Subject: [PATCH 092/232] (deferred_push.c) Cleanups --- menu/cbs/menu_cbs_deferred_push.c | 356 ++++++++++++++---------------- 1 file changed, 165 insertions(+), 191 deletions(-) diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index b6d8c3b8ef..3f40493e5b 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -586,188 +586,181 @@ generic_deferred_push_clear_general(deferred_music_history_list, PUSH_DEFAULT, D generic_deferred_push_clear_general(deferred_image_history_list, PUSH_DEFAULT, DISPLAYLIST_IMAGES_HISTORY) generic_deferred_push_clear_general(deferred_video_history_list, PUSH_DEFAULT, DISPLAYLIST_VIDEO_HISTORY) +struct cbs_deferred_lbl_callback +{ + enum msg_hash_enums id; + int (*cbs)(menu_displaylist_info_t *info); +}; + +static struct cbs_deferred_lbl_callback cbs_deferred_lbl_list[] = { + { + MENU_ENUM_LABEL_DEFERRED_FAVORITES_LIST, + deferred_push_favorites_list + }, + { + MENU_ENUM_LABEL_DEFERRED_BROWSE_URL_LIST, + deferred_push_browse_url_list + }, + { + MENU_ENUM_LABEL_DEFERRED_BROWSE_URL_START, + deferred_push_browse_url_start + }, + { + MENU_ENUM_LABEL_DEFERRED_CORE_SETTINGS_LIST, + deferred_push_core_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_CONFIGURATION_SETTINGS_LIST, + deferred_push_configuration_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_SAVING_SETTINGS_LIST, + deferred_push_saving_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_LOGGING_SETTINGS_LIST, + deferred_push_logging_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_FRAME_THROTTLE_SETTINGS_LIST, + deferred_push_frame_throttle_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_REWIND_SETTINGS_LIST, + deferred_push_rewind_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_ONSCREEN_DISPLAY_SETTINGS_LIST, + deferred_push_onscreen_display_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_ONSCREEN_NOTIFICATIONS_SETTINGS_LIST, + deferred_push_onscreen_notifications_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_ONSCREEN_OVERLAY_SETTINGS_LIST, + deferred_push_onscreen_overlay_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_MENU_FILE_BROWSER_SETTINGS_LIST, + deferred_push_menu_file_browser_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_MENU_VIEWS_SETTINGS_LIST, + deferred_push_menu_views_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_QUICK_MENU_VIEWS_SETTINGS_LIST, + deferred_push_quick_menu_views_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_MENU_SETTINGS_LIST, + deferred_push_menu_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_USER_INTERFACE_SETTINGS_LIST, + deferred_push_user_interface_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_RETRO_ACHIEVEMENTS_SETTINGS_LIST, + deferred_push_retro_achievements_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_UPDATER_SETTINGS_LIST, + deferred_push_updater_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_NETWORK_SETTINGS_LIST, + deferred_push_network_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_WIFI_SETTINGS_LIST, + deferred_push_wifi_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_LAKKA_SERVICES_LIST, + deferred_push_lakka_services_list + }, + { + MENU_ENUM_LABEL_DEFERRED_USER_SETTINGS_LIST, + deferred_push_user_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_DIRECTORY_SETTINGS_LIST, + deferred_push_directory_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_PRIVACY_SETTINGS_LIST, + deferred_push_privacy_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_MUSIC, + deferred_music_list + }, + { + MENU_ENUM_LABEL_DEFERRED_MUSIC_LIST, + deferred_music_history_list + }, + { + MENU_ENUM_LABEL_DEFERRED_PLAYLIST_LIST, + deferred_playlist_list + }, + { + MENU_ENUM_LABEL_DEFERRED_IMAGES_LIST, + deferred_image_history_list + }, +#ifdef HAVE_NETWORKING + { + MENU_ENUM_LABEL_DEFERRED_CORE_CONTENT_DIRS_SUBDIR_LIST, + deferred_push_core_content_dirs_subdir_list + }, + { + MENU_ENUM_LABEL_DEFERRED_CORE_CONTENT_DIRS_LIST, + deferred_push_core_content_dirs_list + }, +#endif + { + MENU_ENUM_LABEL_DEFERRED_VIDEO_LIST, + deferred_video_history_list + } +}; + static int menu_cbs_init_bind_deferred_push_compare_label( menu_file_list_cbs_t *cbs, const char *label, uint32_t label_hash) { - if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_FAVORITES_LIST))) + unsigned k; + + for (k = 0; k < ARRAY_SIZE(cbs_deferred_lbl_list); k++) { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_favorites_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_BROWSE_URL_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_browse_url_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_BROWSE_URL_START))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_browse_url_start); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_CORE_SETTINGS_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_CONFIGURATION_SETTINGS_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_configuration_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_SAVING_SETTINGS_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_saving_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_LOGGING_SETTINGS_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_logging_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_FRAME_THROTTLE_SETTINGS_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_frame_throttle_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_REWIND_SETTINGS_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_rewind_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_ONSCREEN_DISPLAY_SETTINGS_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_onscreen_display_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_ONSCREEN_NOTIFICATIONS_SETTINGS_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_onscreen_notifications_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_ONSCREEN_OVERLAY_SETTINGS_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_onscreen_overlay_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_MENU_FILE_BROWSER_SETTINGS_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_menu_file_browser_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_MENU_VIEWS_SETTINGS_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_menu_views_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_QUICK_MENU_VIEWS_SETTINGS_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_quick_menu_views_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_MENU_SETTINGS_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_menu_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_USER_INTERFACE_SETTINGS_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_user_interface_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_RETRO_ACHIEVEMENTS_SETTINGS_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_retro_achievements_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_UPDATER_SETTINGS_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_updater_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_NETWORK_SETTINGS_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_network_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_WIFI_SETTINGS_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_wifi_settings_list); - return 0; - } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_LAKKA_SERVICES_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_lakka_services_list); - return 0; + if (string_is_equal(label, msg_hash_to_str(cbs_deferred_lbl_list[k].id))) + { + BIND_ACTION_DEFERRED_PUSH(cbs, cbs_deferred_lbl_list[k].cbs); + return 0; + } } - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_USER_SETTINGS_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_user_settings_list); - return 0; - } - - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_DIRECTORY_SETTINGS_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_directory_settings_list); - return 0; - } - - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_PRIVACY_SETTINGS_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_privacy_settings_list); - return 0; - } - - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_CORE_CONTENT_DIRS_LIST))) - { -#ifdef HAVE_NETWORKING - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_content_dirs_list); -#endif - return 0; - } - - else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_CORE_CONTENT_DIRS_SUBDIR_LIST))) - { -#ifdef HAVE_NETWORKING - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_content_dirs_subdir_list); -#endif - return 0; - } - else if ( - string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_MUSIC))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_music_list); - return 0; - } - else if ( - string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_MUSIC_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_music_history_list); - return 0; - } - else if ( - string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_PLAYLIST_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_playlist_list); - return 0; - } - else if ( - string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_IMAGES_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_image_history_list); - return 0; - } - else if ( - string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_VIDEO_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_video_history_list); - return 0; - } - else if (strstr(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_RDB_ENTRY_DETAIL))) + if (strstr(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_RDB_ENTRY_DETAIL))) { BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_rdb_entry_detail); } +#ifdef HAVE_NETWORKING + else if (strstr(label, + msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_CORE_UPDATER_LIST))) + { + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_updater_list); + } + else if (strstr(label, + msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_THUMBNAILS_UPDATER_LIST))) + { + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_thumbnails_updater_list); + } + else if (strstr(label, + msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_CORE_CONTENT_LIST))) + { + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_content_list); + } +#endif else if (strstr(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_RPL_ENTRY_ACTIONS))) { @@ -783,13 +776,6 @@ static int menu_cbs_init_bind_deferred_push_compare_label( { BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_input_settings_list); } -#ifdef HAVE_NETWORKING - else if (strstr(label, - msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_CORE_UPDATER_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_updater_list); - } -#endif else if (strstr(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_DRIVER_SETTINGS_LIST))) { @@ -840,18 +826,6 @@ static int menu_cbs_init_bind_deferred_push_compare_label( { BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_network_information); } -#ifdef HAVE_NETWORKING - else if (strstr(label, - msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_THUMBNAILS_UPDATER_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_thumbnails_updater_list); - } - else if (strstr(label, - msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_CORE_CONTENT_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_content_list); - } -#endif else if (strstr(label, msg_hash_to_str(MENU_ENUM_LABEL_ONLINE_UPDATER))) { From e2617d56cf6e1b070b7dfb55fb6c9f0d9d344cc9 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 5 Feb 2018 14:27:00 +0100 Subject: [PATCH 093/232] (deferred_push) Cleanups --- menu/cbs/menu_cbs_deferred_push.c | 87 ++++++++++++++++--------------- 1 file changed, 46 insertions(+), 41 deletions(-) diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index 3f40493e5b..affe729513 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -725,11 +725,48 @@ static struct cbs_deferred_lbl_callback cbs_deferred_lbl_list[] = { } }; +static struct cbs_deferred_lbl_callback cbs_deferred2_lbl_list[] = { +#ifdef HAVE_NETWORKING + { + MENU_ENUM_LABEL_DEFERRED_CORE_UPDATER_LIST, + deferred_push_core_updater_list + }, + { + MENU_ENUM_LABEL_DEFERRED_THUMBNAILS_UPDATER_LIST, + deferred_push_thumbnails_updater_list + }, + { + MENU_ENUM_LABEL_DEFERRED_CORE_CONTENT_LIST, + deferred_push_core_content_list + }, +#endif + { + MENU_ENUM_LABEL_DEFERRED_RDB_ENTRY_DETAIL, + deferred_push_rdb_entry_detail + }, + { + MENU_ENUM_LABEL_DEFERRED_RPL_ENTRY_ACTIONS, + deferred_push_rpl_entry_actions + }, + { + MENU_ENUM_LABEL_DEFERRED_NETPLAY, + deferred_push_netplay_sublist + }, + { + MENU_ENUM_LABEL_DEFERRED_INPUT_SETTINGS_LIST, + deferred_push_input_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_DRIVER_SETTINGS_LIST, + deferred_push_driver_settings_list + } +}; + static int menu_cbs_init_bind_deferred_push_compare_label( menu_file_list_cbs_t *cbs, const char *label, uint32_t label_hash) { - unsigned k; + unsigned k, l; for (k = 0; k < ARRAY_SIZE(cbs_deferred_lbl_list); k++) { @@ -740,48 +777,16 @@ static int menu_cbs_init_bind_deferred_push_compare_label( } } - if (strstr(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_RDB_ENTRY_DETAIL))) + for (l = 0; l < ARRAY_SIZE(cbs_deferred2_lbl_list); l++) { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_rdb_entry_detail); + if (strstr(label, msg_hash_to_str(cbs_deferred2_lbl_list[l].id))) + { + BIND_ACTION_DEFERRED_PUSH(cbs, cbs_deferred2_lbl_list[l].cbs); + return 0; + } } -#ifdef HAVE_NETWORKING - else if (strstr(label, - msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_CORE_UPDATER_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_updater_list); - } - else if (strstr(label, - msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_THUMBNAILS_UPDATER_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_thumbnails_updater_list); - } - else if (strstr(label, - msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_CORE_CONTENT_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_content_list); - } -#endif - else if (strstr(label, - msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_RPL_ENTRY_ACTIONS))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_rpl_entry_actions); - } - else if (strstr(label, - msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_NETPLAY))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_netplay_sublist); - } - else if (strstr(label, - msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_INPUT_SETTINGS_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_input_settings_list); - } - else if (strstr(label, - msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_DRIVER_SETTINGS_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_driver_settings_list); - } - else if (strstr(label, + + if (strstr(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_VIDEO_SETTINGS_LIST))) { BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_settings_list); From bcea63b1779204ecf71b0aa7c03a64478941330c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 5 Feb 2018 14:34:54 +0100 Subject: [PATCH 094/232] Cleanups --- command.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/command.c b/command.c index abb22894df..8b9d903622 100644 --- a/command.c +++ b/command.c @@ -1420,23 +1420,26 @@ static bool command_event_save_core_config(void) const char *core_path = NULL; char *config_name = NULL; char *config_path = NULL; - char *config_dir = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + char *config_dir = NULL; size_t config_size = PATH_MAX_LENGTH * sizeof(char); settings_t *settings = config_get_ptr(); - config_dir[0] = msg[0] = '\0'; + msg[0] = '\0'; if (settings && !string_is_empty(settings->paths.directory_menu_config)) - strlcpy(config_dir, settings->paths.directory_menu_config, - config_size); + config_dir = strdup(settings->paths.directory_menu_config); else if (!path_is_empty(RARCH_PATH_CONFIG)) /* Fallback */ + { + config_dir = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + config_dir[0] = '\0'; fill_pathname_basedir(config_dir, path_get(RARCH_PATH_CONFIG), config_size); - else + } + + if (string_is_empty(config_dir)) { runloop_msg_queue_push(msg_hash_to_str(MSG_CONFIG_DIRECTORY_NOT_SET), 1, 180, true); RARCH_ERR("[Config]: %s\n", msg_hash_to_str(MSG_CONFIG_DIRECTORY_NOT_SET)); - free(config_dir); return false; } From 6eee3d68dd659cd2250412b6109bf42c033a46f5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 5 Feb 2018 15:03:54 +0100 Subject: [PATCH 095/232] Cleanups --- list_special.c | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/list_special.c b/list_special.c index 733318b329..0e4c28a5ce 100644 --- a/list_special.c +++ b/list_special.c @@ -55,39 +55,31 @@ struct string_list *dir_list_new_special(const char *input_dir, enum dir_list_type type, const char *filter) { - char ext_shaders[255]; - char ext_name[255]; - const char *dir = NULL; const char *exts = NULL; - bool include_dirs = false; bool recursive = false; settings_t *settings = config_get_ptr(); - ext_shaders[0] = ext_name[0] = '\0'; - - (void)input_dir; - switch (type) { case DIR_LIST_AUTOCONFIG: - dir = input_dir; exts = filter; break; case DIR_LIST_CORES: - dir = input_dir; + { + char ext_name[255]; + ext_name[0] = '\0'; - if (!frontend_driver_get_core_extension(ext_name, sizeof(ext_name))) - return NULL; + if (!frontend_driver_get_core_extension(ext_name, sizeof(ext_name))) + return NULL; - exts = ext_name; + exts = ext_name; + } break; case DIR_LIST_CORE_INFO: { core_info_list_t *list = NULL; core_info_get_list(&list); - dir = input_dir; - if (list) exts = list->all_ext; } @@ -97,8 +89,6 @@ struct string_list *dir_list_new_special(const char *input_dir, core_info_list_t *list = NULL; core_info_get_list(&list); - dir = input_dir; - if (list) exts = list->all_ext; recursive = true; @@ -106,6 +96,7 @@ struct string_list *dir_list_new_special(const char *input_dir, break; case DIR_LIST_SHADERS: { + char ext_shaders[255]; #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_VULKAN) union string_list_elem_attr attr; #endif @@ -113,12 +104,13 @@ struct string_list *dir_list_new_special(const char *input_dir, if (!str_list) return NULL; + + ext_shaders[0] = '\0'; #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_VULKAN) attr.i = 0; #endif - dir = input_dir; #ifdef HAVE_CG string_list_append(str_list, "cg", attr); string_list_append(str_list, "cgp", attr); @@ -137,15 +129,12 @@ struct string_list *dir_list_new_special(const char *input_dir, } break; case DIR_LIST_COLLECTIONS: - dir = input_dir; exts = "lpl"; break; case DIR_LIST_DATABASES: - dir = input_dir; exts = "rdb"; break; case DIR_LIST_PLAIN: - dir = input_dir; exts = filter; break; case DIR_LIST_NONE: @@ -153,7 +142,7 @@ struct string_list *dir_list_new_special(const char *input_dir, return NULL; } - return dir_list_new(dir, exts, include_dirs, settings->bools.show_hidden_files, + return dir_list_new(input_dir, exts, false, settings->bools.show_hidden_files, type == DIR_LIST_CORE_INFO, recursive); } From 562201bdd403abd7e8a84edfc80be0486b854b4c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 5 Feb 2018 15:10:10 +0100 Subject: [PATCH 096/232] (deferred push) Refactor --- menu/cbs/menu_cbs_deferred_push.c | 1069 ++++++++++++++--------------- 1 file changed, 525 insertions(+), 544 deletions(-) diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index affe729513..fbb2eaaf73 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -759,6 +759,70 @@ static struct cbs_deferred_lbl_callback cbs_deferred2_lbl_list[] = { { MENU_ENUM_LABEL_DEFERRED_DRIVER_SETTINGS_LIST, deferred_push_driver_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_VIDEO_SETTINGS_LIST, + deferred_push_video_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_AUDIO_SETTINGS_LIST, + deferred_push_audio_settings_list + }, + { + MENU_ENUM_LABEL_CORE_INFORMATION, + deferred_push_core_information + }, + { + MENU_ENUM_LABEL_SYSTEM_INFORMATION, + deferred_push_system_information + }, + { + MENU_ENUM_LABEL_DEFERRED_ACCOUNTS_LIST, + deferred_push_accounts_list + }, + { + MENU_ENUM_LABEL_CORE_LIST, + deferred_push_core_list + }, + { + MENU_ENUM_LABEL_LOAD_CONTENT_HISTORY, + deferred_push_history_list + }, + { + MENU_ENUM_LABEL_CORE_OPTIONS, + deferred_push_core_options + }, + { + MENU_ENUM_LABEL_NETWORK_INFORMATION, + deferred_push_network_information + }, + { + MENU_ENUM_LABEL_ONLINE_UPDATER, + deferred_push_options + }, + { + MENU_ENUM_LABEL_HELP_LIST, + deferred_push_help + }, + { + MENU_ENUM_LABEL_INFORMATION_LIST, + deferred_push_information_list + }, + { + MENU_ENUM_LABEL_SHADER_OPTIONS, + deferred_push_shader_options + }, + { + MENU_ENUM_LABEL_DEFERRED_USER_BINDS_LIST, + deferred_user_binds_list + }, + { + MENU_ENUM_LABEL_DEFERRED_INPUT_HOTKEY_BINDS_LIST, + deferred_push_input_hotkey_binds_list + }, + { + MENU_ENUM_LABEL_LOAD_CONTENT_LIST, + deferred_push_load_content_list } }; @@ -786,559 +850,476 @@ static int menu_cbs_init_bind_deferred_push_compare_label( } } - if (strstr(label, - msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_VIDEO_SETTINGS_LIST))) + if (cbs->enum_idx != MSG_UNKNOWN) { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_settings_list); - } - else if (strstr(label, - msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_AUDIO_SETTINGS_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_audio_settings_list); - } - else if (strstr(label, - msg_hash_to_str(MENU_ENUM_LABEL_CORE_INFORMATION))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_information); - } - else if (strstr(label, - msg_hash_to_str(MENU_ENUM_LABEL_SYSTEM_INFORMATION))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_system_information); - } - else if (strstr(label, - msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_ACCOUNTS_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_accounts_list); - } - else if (strstr(label, - msg_hash_to_str(MENU_ENUM_LABEL_CORE_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_list); - } - else if (strstr(label, - msg_hash_to_str(MENU_ENUM_LABEL_LOAD_CONTENT_HISTORY))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_history_list); - } - else if (strstr(label, - msg_hash_to_str(MENU_ENUM_LABEL_CORE_OPTIONS))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_options); - } - else if (strstr(label, - msg_hash_to_str(MENU_ENUM_LABEL_NETWORK_INFORMATION))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_network_information); - } - else if (strstr(label, - msg_hash_to_str(MENU_ENUM_LABEL_ONLINE_UPDATER))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_options); - } - else if (strstr(label, - msg_hash_to_str(MENU_ENUM_LABEL_HELP_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_help); - } - else if (strstr(label, - msg_hash_to_str(MENU_ENUM_LABEL_INFORMATION_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_information_list); - } - else if (strstr(label, - msg_hash_to_str(MENU_ENUM_LABEL_SHADER_OPTIONS))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_shader_options); - } - else if (strstr(label, - msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_USER_BINDS_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_user_binds_list); - } - else if (strstr(label, - msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_INPUT_HOTKEY_BINDS_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_input_hotkey_binds_list); - } - else if (strstr(label, - msg_hash_to_str(MENU_ENUM_LABEL_LOAD_CONTENT_LIST))) - { - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_load_content_list); + switch (cbs->enum_idx) + { + case MENU_ENUM_LABEL_MAIN_MENU: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_main_menu_list); + break; + case MENU_ENUM_LABEL_DEFERRED_USER_BINDS_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_user_binds_list); + break; + case MENU_ENUM_LABEL_DEFERRED_ACCOUNTS_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_accounts_list); + break; + case MENU_ENUM_LABEL_DEFERRED_PLAYLIST_SETTINGS_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_playlist_settings_list); + break; + case MENU_ENUM_LABEL_DEFERRED_RECORDING_SETTINGS_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_recording_settings_list); + break; + case MENU_ENUM_LABEL_DEFERRED_INPUT_HOTKEY_BINDS_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_input_hotkey_binds_list); + break; + case MENU_ENUM_LABEL_DEFERRED_ACCOUNTS_CHEEVOS_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_accounts_cheevos_list); + break; + case MENU_ENUM_LABEL_DEFERRED_ARCHIVE_ACTION_DETECT_CORE: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_archive_action_detect_core); + break; + case MENU_ENUM_LABEL_DEFERRED_ARCHIVE_ACTION: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_archive_action); + break; + case MENU_ENUM_LABEL_DEFERRED_ARCHIVE_OPEN_DETECT_CORE: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_archive_open_detect_core); + break; + case MENU_ENUM_LABEL_DEFERRED_ARCHIVE_OPEN: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_archive_open); + break; + case MENU_ENUM_LABEL_DEFERRED_CORE_CONTENT_LIST: +#ifdef HAVE_NETWORKING + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_content_list); +#endif + break; + case MENU_ENUM_LABEL_DEFERRED_CORE_CONTENT_DIRS_LIST: +#ifdef HAVE_NETWORKING + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_content_dirs_list); +#endif + break; + case MENU_ENUM_LABEL_DEFERRED_CORE_CONTENT_DIRS_SUBDIR_LIST: +#ifdef HAVE_NETWORKING + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_content_dirs_subdir_list); +#endif + break; + case MENU_ENUM_LABEL_DEFERRED_THUMBNAILS_UPDATER_LIST: +#ifdef HAVE_NETWORKING + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_thumbnails_updater_list); +#endif + break; + case MENU_ENUM_LABEL_DEFERRED_LAKKA_LIST: +#ifdef HAVE_NETWORKING + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_lakka_list); +#endif + break; + case MENU_ENUM_LABEL_LOAD_CONTENT_HISTORY: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_history_list); + break; + case MENU_ENUM_LABEL_DATABASE_MANAGER_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_database_manager_list); + break; + case MENU_ENUM_LABEL_CURSOR_MANAGER_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list); + break; + case MENU_ENUM_LABEL_CHEAT_FILE_LOAD: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cheat_file_load); + break; + case MENU_ENUM_LABEL_REMAP_FILE_LOAD: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_remap_file_load); + break; + case MENU_ENUM_LABEL_RECORD_CONFIG: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_record_configfile); + break; + case MENU_ENUM_LABEL_SHADER_OPTIONS: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_shader_options); + break; + case MENU_ENUM_LABEL_ONLINE_UPDATER: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_options); + break; + case MENU_ENUM_LABEL_NETPLAY: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_netplay); + break; + case MENU_ENUM_LABEL_CONTENT_SETTINGS: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_content_settings); + break; + case MENU_ENUM_LABEL_ADD_CONTENT_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_add_content_list); + break; + case MENU_ENUM_LABEL_CONFIGURATIONS_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_configurations_list); + break; + case MENU_ENUM_LABEL_LOAD_CONTENT_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_load_content_list); + break; + case MENU_ENUM_LABEL_LOAD_CONTENT_SPECIAL: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_load_content_special); + break; + case MENU_ENUM_LABEL_INFORMATION_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_information_list); + break; + case MENU_ENUM_LABEL_MANAGEMENT: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_management_options); + break; + case MENU_ENUM_LABEL_HELP_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_help); + break; + case MENU_ENUM_LABEL_DEFERRED_CORE_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_list_deferred); + break; + case MENU_ENUM_LABEL_DEFERRED_CORE_LIST_SET: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_collection_list_deferred); + break; + case MENU_ENUM_LABEL_DEFERRED_VIDEO_FILTER: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_filter); + break; + case MENU_ENUM_LABEL_DEFERRED_DATABASE_MANAGER_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_database_manager_list_deferred); + break; + case MENU_ENUM_LABEL_DEFERRED_CURSOR_MANAGER_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred); + break; +#ifdef HAVE_LIBRETRODB + case MENU_ENUM_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_PUBLISHER: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_publisher); + break; + case MENU_ENUM_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_DEVELOPER: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_developer); + break; + case MENU_ENUM_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_ORIGIN: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_origin); + break; + case MENU_ENUM_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_FRANCHISE: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_franchise); + break; + case MENU_ENUM_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_ENHANCEMENT_HW: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_enhancement_hw); + break; + case MENU_ENUM_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_ESRB_RATING: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_esrb_rating); + break; + case MENU_ENUM_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_BBFC_RATING: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_bbfc_rating); + break; + case MENU_ENUM_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_ELSPA_RATING: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_elspa_rating); + break; + case MENU_ENUM_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_PEGI_RATING: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_pegi_rating); + break; + case MENU_ENUM_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_CERO_RATING: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_cero_rating); + break; + case MENU_ENUM_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_EDGE_MAGAZINE_RATING: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_edge_magazine_rating); + break; + case MENU_ENUM_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_EDGE_MAGAZINE_ISSUE: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_edge_magazine_issue); + break; + case MENU_ENUM_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_FAMITSU_MAGAZINE_RATING: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_famitsu_magazine_rating); + break; + case MENU_ENUM_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_MAX_USERS: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_max_users); + break; + case MENU_ENUM_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_RELEASEMONTH: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_releasemonth); + break; + case MENU_ENUM_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_RELEASEYEAR: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_releaseyear); + break; +#endif + case MENU_ENUM_LABEL_NETWORK_INFORMATION: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_network_information); + break; + case MENU_ENUM_LABEL_ACHIEVEMENT_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_achievement_list); + break; + case MENU_ENUM_LABEL_CORE_COUNTERS: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_counters); + break; + case MENU_ENUM_LABEL_FRONTEND_COUNTERS: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_frontend_counters); + break; + case MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_PARAMETERS: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_shader_preset_parameters); + break; + case MENU_ENUM_LABEL_VIDEO_SHADER_PARAMETERS: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_shader_parameters); + break; + case MENU_ENUM_LABEL_SETTINGS: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_settings); + break; + case MENU_ENUM_LABEL_CORE_OPTIONS: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_options); + break; + case MENU_ENUM_LABEL_CORE_CHEAT_OPTIONS: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_cheat_options); + break; + case MENU_ENUM_LABEL_CORE_INPUT_REMAPPING_OPTIONS: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_input_remapping_options); + break; + case MENU_ENUM_LABEL_CORE_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_list); + break; + case MENU_ENUM_LABEL_CONTENT_COLLECTION_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_content_collection_list); + break; + case MENU_ENUM_LABEL_CONFIGURATIONS: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_configurations); + break; + case MENU_ENUM_LABEL_VIDEO_SHADER_PRESET: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_shader_preset); + break; + case MENU_ENUM_LABEL_VIDEO_SHADER_PASS: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_shader_pass); + break; + case MENU_ENUM_LABEL_VIDEO_FILTER: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_filter); + break; + case MENU_ENUM_LABEL_MENU_WALLPAPER: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_images); + break; + case MENU_ENUM_LABEL_AUDIO_DSP_PLUGIN: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_audio_dsp_plugin); + break; + case MENU_ENUM_LABEL_INPUT_OVERLAY: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_input_overlay); + break; + case MENU_ENUM_LABEL_VIDEO_FONT_PATH: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_font_path); + break; + case MENU_ENUM_LABEL_XMB_FONT: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_xmb_font_path); + break; + case MENU_ENUM_LABEL_CONTENT_HISTORY_PATH: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_content_history_path); + break; + case MENU_ENUM_LABEL_DEFERRED_VIDEO_SETTINGS_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_settings_list); + break; + case MENU_ENUM_LABEL_DEFERRED_CONFIGURATION_SETTINGS_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_configuration_settings_list); + break; + case MENU_ENUM_LABEL_DEFERRED_SAVING_SETTINGS_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_saving_settings_list); + break; + case MENU_ENUM_LABEL_DEFERRED_LOGGING_SETTINGS_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_saving_settings_list); + break; + case MENU_ENUM_LABEL_DEFERRED_FRAME_THROTTLE_SETTINGS_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_frame_throttle_settings_list); + break; + case MENU_ENUM_LABEL_DEFERRED_REWIND_SETTINGS_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_rewind_settings_list); + break; + case MENU_ENUM_LABEL_DEFERRED_ONSCREEN_DISPLAY_SETTINGS_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_onscreen_display_settings_list); + break; + case MENU_ENUM_LABEL_DEFERRED_ONSCREEN_OVERLAY_SETTINGS_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_onscreen_overlay_settings_list); + break; + case MENU_ENUM_LABEL_DEFERRED_AUDIO_SETTINGS_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_audio_settings_list); + break; + case MENU_ENUM_LABEL_DEFERRED_CORE_SETTINGS_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_settings_list); + break; + case MENU_ENUM_LABEL_DOWNLOADED_FILE_DETECT_CORE_LIST: + case MENU_ENUM_LABEL_FAVORITES: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_detect_core_list); + break; + default: + return -1; + } } else { - if (cbs->enum_idx != MSG_UNKNOWN) + switch (label_hash) { - switch (cbs->enum_idx) - { - case MENU_ENUM_LABEL_MAIN_MENU: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_main_menu_list); - break; - case MENU_ENUM_LABEL_DEFERRED_USER_BINDS_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_user_binds_list); - break; - case MENU_ENUM_LABEL_DEFERRED_ACCOUNTS_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_accounts_list); - break; - case MENU_ENUM_LABEL_DEFERRED_PLAYLIST_SETTINGS_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_playlist_settings_list); - break; - case MENU_ENUM_LABEL_DEFERRED_RECORDING_SETTINGS_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_recording_settings_list); - break; - case MENU_ENUM_LABEL_DEFERRED_INPUT_HOTKEY_BINDS_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_input_hotkey_binds_list); - break; - case MENU_ENUM_LABEL_DEFERRED_ACCOUNTS_CHEEVOS_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_accounts_cheevos_list); - break; - case MENU_ENUM_LABEL_DEFERRED_ARCHIVE_ACTION_DETECT_CORE: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_archive_action_detect_core); - break; - case MENU_ENUM_LABEL_DEFERRED_ARCHIVE_ACTION: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_archive_action); - break; - case MENU_ENUM_LABEL_DEFERRED_ARCHIVE_OPEN_DETECT_CORE: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_archive_open_detect_core); - break; - case MENU_ENUM_LABEL_DEFERRED_ARCHIVE_OPEN: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_archive_open); - break; - case MENU_ENUM_LABEL_DEFERRED_CORE_CONTENT_LIST: + case MENU_LABEL_SETTINGS: /* TODO/FIXME */ + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_settings); + break; + case MENU_LABEL_DEFERRED_CONFIGURATIONS_LIST: /* TODO/FIXME */ + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_configurations_list); + break; + case MENU_LABEL_DEFERRED_PLAYLIST_SETTINGS_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_playlist_settings_list); + break; + case MENU_LABEL_DEFERRED_RECORDING_SETTINGS_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_recording_settings_list); + break; + case MENU_LABEL_DEFERRED_ACCOUNTS_CHEEVOS_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_accounts_cheevos_list); + break; + case MENU_LABEL_DEFERRED_ARCHIVE_ACTION_DETECT_CORE: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_archive_action_detect_core); + break; + case MENU_LABEL_DEFERRED_ARCHIVE_ACTION: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_archive_action); + break; + case MENU_LABEL_DEFERRED_ARCHIVE_OPEN_DETECT_CORE: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_archive_open_detect_core); + break; + case MENU_LABEL_DEFERRED_ARCHIVE_OPEN: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_archive_open); + break; + case MENU_LABEL_DEFERRED_LAKKA_LIST: #ifdef HAVE_NETWORKING - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_content_list); + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_lakka_list); #endif - break; - case MENU_ENUM_LABEL_DEFERRED_CORE_CONTENT_DIRS_LIST: -#ifdef HAVE_NETWORKING - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_content_dirs_list); -#endif - break; - case MENU_ENUM_LABEL_DEFERRED_CORE_CONTENT_DIRS_SUBDIR_LIST: -#ifdef HAVE_NETWORKING - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_content_dirs_subdir_list); -#endif - break; - case MENU_ENUM_LABEL_DEFERRED_THUMBNAILS_UPDATER_LIST: -#ifdef HAVE_NETWORKING - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_thumbnails_updater_list); -#endif - break; - case MENU_ENUM_LABEL_DEFERRED_LAKKA_LIST: -#ifdef HAVE_NETWORKING - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_lakka_list); -#endif - break; - case MENU_ENUM_LABEL_LOAD_CONTENT_HISTORY: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_history_list); - break; - case MENU_ENUM_LABEL_DATABASE_MANAGER_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_database_manager_list); - break; - case MENU_ENUM_LABEL_CURSOR_MANAGER_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list); - break; - case MENU_ENUM_LABEL_CHEAT_FILE_LOAD: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cheat_file_load); - break; - case MENU_ENUM_LABEL_REMAP_FILE_LOAD: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_remap_file_load); - break; - case MENU_ENUM_LABEL_RECORD_CONFIG: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_record_configfile); - break; - case MENU_ENUM_LABEL_SHADER_OPTIONS: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_shader_options); - break; - case MENU_ENUM_LABEL_ONLINE_UPDATER: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_options); - break; - case MENU_ENUM_LABEL_NETPLAY: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_netplay); - break; - case MENU_ENUM_LABEL_CONTENT_SETTINGS: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_content_settings); - break; - case MENU_ENUM_LABEL_ADD_CONTENT_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_add_content_list); - break; - case MENU_ENUM_LABEL_CONFIGURATIONS_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_configurations_list); - break; - case MENU_ENUM_LABEL_LOAD_CONTENT_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_load_content_list); - break; - case MENU_ENUM_LABEL_LOAD_CONTENT_SPECIAL: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_load_content_special); - break; - case MENU_ENUM_LABEL_INFORMATION_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_information_list); - break; - case MENU_ENUM_LABEL_MANAGEMENT: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_management_options); - break; - case MENU_ENUM_LABEL_HELP_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_help); - break; - case MENU_ENUM_LABEL_DEFERRED_CORE_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_list_deferred); - break; - case MENU_ENUM_LABEL_DEFERRED_CORE_LIST_SET: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_collection_list_deferred); - break; - case MENU_ENUM_LABEL_DEFERRED_VIDEO_FILTER: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_filter); - break; - case MENU_ENUM_LABEL_DEFERRED_DATABASE_MANAGER_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_database_manager_list_deferred); - break; - case MENU_ENUM_LABEL_DEFERRED_CURSOR_MANAGER_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred); - break; + break; + case MENU_LABEL_DATABASE_MANAGER_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_database_manager_list); + break; + case MENU_LABEL_CURSOR_MANAGER_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list); + break; + case MENU_LABEL_CHEAT_FILE_LOAD: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cheat_file_load); + break; + case MENU_LABEL_REMAP_FILE_LOAD: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_remap_file_load); + break; + case MENU_LABEL_RECORD_CONFIG: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_record_configfile); + break; + case MENU_LABEL_NETPLAY: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_netplay); + break; + case MENU_LABEL_CONTENT_SETTINGS: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_content_settings); + break; + case MENU_LABEL_ADD_CONTENT_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_add_content_list); + break; + case MENU_LABEL_MANAGEMENT: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_management_options); + break; + case MENU_LABEL_DEFERRED_CORE_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_list_deferred); + break; + case MENU_LABEL_DEFERRED_CORE_LIST_SET: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_collection_list_deferred); + break; + case MENU_LABEL_DEFERRED_VIDEO_FILTER: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_filter); + break; + case MENU_LABEL_DEFERRED_DATABASE_MANAGER_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_database_manager_list_deferred); + break; #ifdef HAVE_LIBRETRODB - case MENU_ENUM_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_PUBLISHER: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_publisher); - break; - case MENU_ENUM_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_DEVELOPER: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_developer); - break; - case MENU_ENUM_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_ORIGIN: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_origin); - break; - case MENU_ENUM_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_FRANCHISE: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_franchise); - break; - case MENU_ENUM_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_ENHANCEMENT_HW: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_enhancement_hw); - break; - case MENU_ENUM_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_ESRB_RATING: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_esrb_rating); - break; - case MENU_ENUM_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_BBFC_RATING: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_bbfc_rating); - break; - case MENU_ENUM_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_ELSPA_RATING: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_elspa_rating); - break; - case MENU_ENUM_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_PEGI_RATING: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_pegi_rating); - break; - case MENU_ENUM_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_CERO_RATING: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_cero_rating); - break; - case MENU_ENUM_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_EDGE_MAGAZINE_RATING: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_edge_magazine_rating); - break; - case MENU_ENUM_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_EDGE_MAGAZINE_ISSUE: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_edge_magazine_issue); - break; - case MENU_ENUM_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_FAMITSU_MAGAZINE_RATING: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_famitsu_magazine_rating); - break; - case MENU_ENUM_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_MAX_USERS: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_max_users); - break; - case MENU_ENUM_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_RELEASEMONTH: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_releasemonth); - break; - case MENU_ENUM_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_RELEASEYEAR: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_releaseyear); - break; + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred); + break; + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_PUBLISHER: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_publisher); + break; + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_DEVELOPER: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_developer); + break; + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_ORIGIN: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_origin); + break; + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_FRANCHISE: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_franchise); + break; + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_ENHANCEMENT_HW: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_enhancement_hw); + break; + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_ESRB_RATING: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_esrb_rating); + break; + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_BBFC_RATING: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_bbfc_rating); + break; + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_ELSPA_RATING: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_elspa_rating); + break; + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_PEGI_RATING: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_pegi_rating); + break; + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_CERO_RATING: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_cero_rating); + break; + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_EDGE_MAGAZINE_RATING: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_edge_magazine_rating); + break; + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_EDGE_MAGAZINE_ISSUE: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_edge_magazine_issue); + break; + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_FAMITSU_MAGAZINE_RATING: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_famitsu_magazine_rating); + break; + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_MAX_USERS: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_max_users); + break; + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_RELEASEMONTH: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_releasemonth); + break; + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_RELEASEYEAR: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_releaseyear); + break; #endif - case MENU_ENUM_LABEL_NETWORK_INFORMATION: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_network_information); - break; - case MENU_ENUM_LABEL_ACHIEVEMENT_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_achievement_list); - break; - case MENU_ENUM_LABEL_CORE_COUNTERS: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_counters); - break; - case MENU_ENUM_LABEL_FRONTEND_COUNTERS: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_frontend_counters); - break; - case MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_PARAMETERS: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_shader_preset_parameters); - break; - case MENU_ENUM_LABEL_VIDEO_SHADER_PARAMETERS: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_shader_parameters); - break; - case MENU_ENUM_LABEL_SETTINGS: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_settings); - break; - case MENU_ENUM_LABEL_CORE_OPTIONS: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_options); - break; - case MENU_ENUM_LABEL_CORE_CHEAT_OPTIONS: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_cheat_options); - break; - case MENU_ENUM_LABEL_CORE_INPUT_REMAPPING_OPTIONS: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_input_remapping_options); - break; - case MENU_ENUM_LABEL_CORE_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_list); - break; - case MENU_ENUM_LABEL_CONTENT_COLLECTION_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_content_collection_list); - break; - case MENU_ENUM_LABEL_CONFIGURATIONS: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_configurations); - break; - case MENU_ENUM_LABEL_VIDEO_SHADER_PRESET: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_shader_preset); - break; - case MENU_ENUM_LABEL_VIDEO_SHADER_PASS: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_shader_pass); - break; - case MENU_ENUM_LABEL_VIDEO_FILTER: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_filter); - break; - case MENU_ENUM_LABEL_MENU_WALLPAPER: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_images); - break; - case MENU_ENUM_LABEL_AUDIO_DSP_PLUGIN: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_audio_dsp_plugin); - break; - case MENU_ENUM_LABEL_INPUT_OVERLAY: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_input_overlay); - break; - case MENU_ENUM_LABEL_VIDEO_FONT_PATH: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_font_path); - break; - case MENU_ENUM_LABEL_XMB_FONT: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_xmb_font_path); - break; - case MENU_ENUM_LABEL_CONTENT_HISTORY_PATH: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_content_history_path); - break; - case MENU_ENUM_LABEL_DEFERRED_VIDEO_SETTINGS_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_settings_list); - break; - case MENU_ENUM_LABEL_DEFERRED_CONFIGURATION_SETTINGS_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_configuration_settings_list); - break; - case MENU_ENUM_LABEL_DEFERRED_SAVING_SETTINGS_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_saving_settings_list); - break; - case MENU_ENUM_LABEL_DEFERRED_LOGGING_SETTINGS_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_saving_settings_list); - break; - case MENU_ENUM_LABEL_DEFERRED_FRAME_THROTTLE_SETTINGS_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_frame_throttle_settings_list); - break; - case MENU_ENUM_LABEL_DEFERRED_REWIND_SETTINGS_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_rewind_settings_list); - break; - case MENU_ENUM_LABEL_DEFERRED_ONSCREEN_DISPLAY_SETTINGS_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_onscreen_display_settings_list); - break; - case MENU_ENUM_LABEL_DEFERRED_ONSCREEN_OVERLAY_SETTINGS_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_onscreen_overlay_settings_list); - break; - case MENU_ENUM_LABEL_DEFERRED_AUDIO_SETTINGS_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_audio_settings_list); - break; - case MENU_ENUM_LABEL_DEFERRED_CORE_SETTINGS_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_settings_list); - break; - case MENU_ENUM_LABEL_DOWNLOADED_FILE_DETECT_CORE_LIST: - case MENU_ENUM_LABEL_FAVORITES: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_detect_core_list); - break; - default: - return -1; - } - } - else - { - switch (label_hash) - { - case MENU_LABEL_SETTINGS: /* TODO/FIXME */ - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_settings); - break; - case MENU_LABEL_DEFERRED_CONFIGURATIONS_LIST: /* TODO/FIXME */ - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_configurations_list); - break; - case MENU_LABEL_DEFERRED_PLAYLIST_SETTINGS_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_playlist_settings_list); - break; - case MENU_LABEL_DEFERRED_RECORDING_SETTINGS_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_recording_settings_list); - break; - case MENU_LABEL_DEFERRED_ACCOUNTS_CHEEVOS_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_accounts_cheevos_list); - break; - case MENU_LABEL_DEFERRED_ARCHIVE_ACTION_DETECT_CORE: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_archive_action_detect_core); - break; - case MENU_LABEL_DEFERRED_ARCHIVE_ACTION: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_archive_action); - break; - case MENU_LABEL_DEFERRED_ARCHIVE_OPEN_DETECT_CORE: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_archive_open_detect_core); - break; - case MENU_LABEL_DEFERRED_ARCHIVE_OPEN: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_archive_open); - break; - case MENU_LABEL_DEFERRED_LAKKA_LIST: -#ifdef HAVE_NETWORKING - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_lakka_list); -#endif - break; - case MENU_LABEL_DATABASE_MANAGER_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_database_manager_list); - break; - case MENU_LABEL_CURSOR_MANAGER_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list); - break; - case MENU_LABEL_CHEAT_FILE_LOAD: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cheat_file_load); - break; - case MENU_LABEL_REMAP_FILE_LOAD: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_remap_file_load); - break; - case MENU_LABEL_RECORD_CONFIG: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_record_configfile); - break; - case MENU_LABEL_NETPLAY: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_netplay); - break; - case MENU_LABEL_CONTENT_SETTINGS: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_content_settings); - break; - case MENU_LABEL_ADD_CONTENT_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_add_content_list); - break; - case MENU_LABEL_MANAGEMENT: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_management_options); - break; - case MENU_LABEL_DEFERRED_CORE_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_list_deferred); - break; - case MENU_LABEL_DEFERRED_CORE_LIST_SET: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_collection_list_deferred); - break; - case MENU_LABEL_DEFERRED_VIDEO_FILTER: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_filter); - break; - case MENU_LABEL_DEFERRED_DATABASE_MANAGER_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_database_manager_list_deferred); - break; -#ifdef HAVE_LIBRETRODB - case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred); - break; - case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_PUBLISHER: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_publisher); - break; - case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_DEVELOPER: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_developer); - break; - case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_ORIGIN: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_origin); - break; - case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_FRANCHISE: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_franchise); - break; - case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_ENHANCEMENT_HW: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_enhancement_hw); - break; - case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_ESRB_RATING: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_esrb_rating); - break; - case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_BBFC_RATING: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_bbfc_rating); - break; - case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_ELSPA_RATING: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_elspa_rating); - break; - case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_PEGI_RATING: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_pegi_rating); - break; - case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_CERO_RATING: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_cero_rating); - break; - case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_EDGE_MAGAZINE_RATING: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_edge_magazine_rating); - break; - case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_EDGE_MAGAZINE_ISSUE: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_edge_magazine_issue); - break; - case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_FAMITSU_MAGAZINE_RATING: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_famitsu_magazine_rating); - break; - case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_MAX_USERS: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_max_users); - break; - case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_RELEASEMONTH: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_releasemonth); - break; - case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_RELEASEYEAR: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_releaseyear); - break; -#endif - case MENU_LABEL_ACHIEVEMENT_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_achievement_list); - break; - case MENU_LABEL_CORE_COUNTERS: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_counters); - break; - case MENU_LABEL_FRONTEND_COUNTERS: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_frontend_counters); - break; - case MENU_LABEL_VIDEO_SHADER_PRESET_PARAMETERS: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_shader_preset_parameters); - break; - case MENU_LABEL_VIDEO_SHADER_PARAMETERS: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_shader_parameters); - break; - case MENU_LABEL_CORE_CHEAT_OPTIONS: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_cheat_options); - break; - case MENU_LABEL_CORE_INPUT_REMAPPING_OPTIONS: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_input_remapping_options); - break; - case MENU_LABEL_CONTENT_COLLECTION_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_content_collection_list); - break; - case MENU_LABEL_CONFIGURATIONS: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_configurations); - break; - case MENU_LABEL_VIDEO_SHADER_PRESET: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_shader_preset); - break; - case MENU_LABEL_VIDEO_SHADER_PASS: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_shader_pass); - break; - case MENU_LABEL_VIDEO_FILTER: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_filter); - break; - case MENU_LABEL_MENU_WALLPAPER: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_images); - break; - case MENU_LABEL_AUDIO_DSP_PLUGIN: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_audio_dsp_plugin); - break; - case MENU_LABEL_INPUT_OVERLAY: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_input_overlay); - break; - case MENU_LABEL_VIDEO_FONT_PATH: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_font_path); - break; - case MENU_LABEL_XMB_FONT: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_xmb_font_path); - break; - case MENU_LABEL_CONTENT_HISTORY_PATH: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_content_history_path); - break; - case MENU_LABEL_DOWNLOADED_FILE_DETECT_CORE_LIST: - case MENU_LABEL_FAVORITES: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_detect_core_list); - break; - default: - return -1; - } + case MENU_LABEL_ACHIEVEMENT_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_achievement_list); + break; + case MENU_LABEL_CORE_COUNTERS: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_counters); + break; + case MENU_LABEL_FRONTEND_COUNTERS: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_frontend_counters); + break; + case MENU_LABEL_VIDEO_SHADER_PRESET_PARAMETERS: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_shader_preset_parameters); + break; + case MENU_LABEL_VIDEO_SHADER_PARAMETERS: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_shader_parameters); + break; + case MENU_LABEL_CORE_CHEAT_OPTIONS: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_cheat_options); + break; + case MENU_LABEL_CORE_INPUT_REMAPPING_OPTIONS: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_input_remapping_options); + break; + case MENU_LABEL_CONTENT_COLLECTION_LIST: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_content_collection_list); + break; + case MENU_LABEL_CONFIGURATIONS: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_configurations); + break; + case MENU_LABEL_VIDEO_SHADER_PRESET: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_shader_preset); + break; + case MENU_LABEL_VIDEO_SHADER_PASS: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_shader_pass); + break; + case MENU_LABEL_VIDEO_FILTER: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_filter); + break; + case MENU_LABEL_MENU_WALLPAPER: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_images); + break; + case MENU_LABEL_AUDIO_DSP_PLUGIN: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_audio_dsp_plugin); + break; + case MENU_LABEL_INPUT_OVERLAY: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_input_overlay); + break; + case MENU_LABEL_VIDEO_FONT_PATH: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_font_path); + break; + case MENU_LABEL_XMB_FONT: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_xmb_font_path); + break; + case MENU_LABEL_CONTENT_HISTORY_PATH: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_content_history_path); + break; + case MENU_LABEL_DOWNLOADED_FILE_DETECT_CORE_LIST: + case MENU_LABEL_FAVORITES: + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_detect_core_list); + break; + default: + return -1; } } From d2aa12149f1f54f629b523d02ea4b2f541127b32 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 5 Feb 2018 15:37:43 +0100 Subject: [PATCH 097/232] task_load_content - simplify code --- tasks/task_content.c | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/tasks/task_content.c b/tasks/task_content.c index f5cba6a6ba..946bb0b44f 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -857,27 +857,7 @@ static bool task_load_content(content_ctx_info_t *content_info, if (!content_load(content_info)) { - /* TODO/FIXME - Hardcoded sizes */ - char *name = (char*)malloc(255 * sizeof(char)); - char *msg = (char*)malloc(255 * sizeof(char)); - - name[0] = msg[0] = '\0'; - - if (launched_from_menu) - { - if (!path_is_empty(RARCH_PATH_CONTENT) && !string_is_empty(name)) - { - snprintf(msg, - 255 * sizeof(char), "%s %s.\n", - msg_hash_to_str(MSG_FAILED_TO_LOAD), - name); - *error_string = strdup(msg); - } - } - if (string_is_empty(name)) - *error_string = strdup("This core requires a content file.\n"); - free(name); - free(msg); + *error_string = strdup("This core requires a content file, could not load content.\n"); return false; } From 7e67a1bf364c074aba948bf5d94ccc1243a92326 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 5 Feb 2018 15:50:16 +0100 Subject: [PATCH 098/232] Get rid of more hashes --- menu/cbs/menu_cbs_deferred_push.c | 7 ++++--- menu/cbs/menu_cbs_title.c | 14 ++++++++------ msg_hash.h | 2 -- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index fbb2eaaf73..a8aa520b02 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -823,6 +823,10 @@ static struct cbs_deferred_lbl_callback cbs_deferred2_lbl_list[] = { { MENU_ENUM_LABEL_LOAD_CONTENT_LIST, deferred_push_load_content_list + }, + { + MENU_ENUM_LABEL_SETTINGS, + deferred_push_settings } }; @@ -1136,9 +1140,6 @@ static int menu_cbs_init_bind_deferred_push_compare_label( { switch (label_hash) { - case MENU_LABEL_SETTINGS: /* TODO/FIXME */ - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_settings); - break; case MENU_LABEL_DEFERRED_CONFIGURATIONS_LIST: /* TODO/FIXME */ BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_configurations_list); break; diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index b3ab022fcd..203fe7c632 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -448,6 +448,14 @@ static struct cbs_title_lbl_callback cbs_title_lbl_list[] = { { MENU_ENUM_LABEL_LOAD_CONTENT_LIST, action_get_load_content_list + }, + { + MENU_ENUM_LABEL_LOAD_CONTENT_HISTORY, + action_get_load_recent_list + }, + { + MENU_ENUM_LABEL_SETTINGS, + action_get_settings_list } }; @@ -911,9 +919,6 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_INFORMATION_LIST: BIND_ACTION_GET_TITLE(cbs, action_get_title_information_list); break; - case MENU_LABEL_SETTINGS: - BIND_ACTION_GET_TITLE(cbs, action_get_settings_list); - break; case MENU_LABEL_DATABASE_MANAGER_LIST: BIND_ACTION_GET_TITLE(cbs, action_get_database_manager_list); break; @@ -950,9 +955,6 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_CORE_OPTIONS: BIND_ACTION_GET_TITLE(cbs, action_get_core_options_list); break; - case MENU_LABEL_LOAD_CONTENT_HISTORY: - BIND_ACTION_GET_TITLE(cbs, action_get_load_recent_list); - break; case MENU_LABEL_CONTENT_SETTINGS: BIND_ACTION_GET_TITLE(cbs, action_get_quick_menu_list); break; diff --git a/msg_hash.h b/msg_hash.h index 90b010c185..8f65790247 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1956,11 +1956,9 @@ enum msg_hash_enums #define MENU_LABEL_HELP_AUDIO_VIDEO_TROUBLESHOOTING 0xd44d395cU /* Main menu */ -#define MENU_LABEL_LOAD_CONTENT_HISTORY 0xfe1d79e5U #define MENU_LABEL_ADD_CONTENT_LIST 0x046f4668U #define MENU_LABEL_ONLINE_UPDATER 0xcac0025eU #define MENU_LABEL_NETPLAY 0x0b511d22U -#define MENU_LABEL_SETTINGS 0x1304dc16U #define MENU_LABEL_HELP 0x7c97d2eeU #define MENU_VALUE_HORIZONTAL_MENU 0x35761704U From fb94ccbfd2217daf606c0fd40e7dbf63deb7c916 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 5 Feb 2018 15:55:58 +0100 Subject: [PATCH 099/232] Remove some hashes --- menu/cbs/menu_cbs_deferred_push.c | 7 ++++--- menu/cbs/menu_cbs_title.c | 14 ++++++++------ msg_hash.h | 2 -- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index a8aa520b02..07690c409d 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -827,6 +827,10 @@ static struct cbs_deferred_lbl_callback cbs_deferred2_lbl_list[] = { { MENU_ENUM_LABEL_SETTINGS, deferred_push_settings + }, + { + MENU_ENUM_LABEL_ADD_CONTENT_LIST, + deferred_push_add_content_list } }; @@ -1190,9 +1194,6 @@ static int menu_cbs_init_bind_deferred_push_compare_label( case MENU_LABEL_CONTENT_SETTINGS: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_content_settings); break; - case MENU_LABEL_ADD_CONTENT_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_add_content_list); - break; case MENU_LABEL_MANAGEMENT: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_management_options); break; diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index 203fe7c632..d0f5d9b66d 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -456,6 +456,14 @@ static struct cbs_title_lbl_callback cbs_title_lbl_list[] = { { MENU_ENUM_LABEL_SETTINGS, action_get_settings_list + }, + { + MENU_ENUM_LABEL_ADD_CONTENT_LIST, + action_get_add_content_list + }, + { + MENU_ENUM_LABEL_ONLINE_UPDATER, + action_get_online_updater_list } }; @@ -934,9 +942,6 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_LOAD_CONTENT_SPECIAL: BIND_ACTION_GET_TITLE(cbs, action_get_load_content_special); break; - case MENU_LABEL_ONLINE_UPDATER: - BIND_ACTION_GET_TITLE(cbs, action_get_online_updater_list); - break; case MENU_LABEL_NETPLAY: BIND_ACTION_GET_TITLE(cbs, action_get_netplay_list); break; @@ -949,9 +954,6 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_DEFERRED_CONFIGURATIONS_LIST: BIND_ACTION_GET_TITLE(cbs, action_get_configurations_list); break; - case MENU_LABEL_ADD_CONTENT_LIST: - BIND_ACTION_GET_TITLE(cbs, action_get_add_content_list); - break; case MENU_LABEL_CORE_OPTIONS: BIND_ACTION_GET_TITLE(cbs, action_get_core_options_list); break; diff --git a/msg_hash.h b/msg_hash.h index 8f65790247..58de4774cb 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1956,8 +1956,6 @@ enum msg_hash_enums #define MENU_LABEL_HELP_AUDIO_VIDEO_TROUBLESHOOTING 0xd44d395cU /* Main menu */ -#define MENU_LABEL_ADD_CONTENT_LIST 0x046f4668U -#define MENU_LABEL_ONLINE_UPDATER 0xcac0025eU #define MENU_LABEL_NETPLAY 0x0b511d22U #define MENU_LABEL_HELP 0x7c97d2eeU #define MENU_VALUE_HORIZONTAL_MENU 0x35761704U From b979e6209ebf0ecfa3982cb6cd437f2dd8bfa80f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 5 Feb 2018 16:00:26 +0100 Subject: [PATCH 100/232] Remove another unused hash --- msg_hash.h | 1 - 1 file changed, 1 deletion(-) diff --git a/msg_hash.h b/msg_hash.h index 58de4774cb..a9c6df2322 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1880,7 +1880,6 @@ enum msg_hash_enums /* RDB settings */ -#define MENU_LABEL_NO_PLAYLIST_ENTRIES_AVAILABLE 0x8888c5acU #define MENU_LABEL_RDB_ENTRY_START_CONTENT 0x95025a55U #define MENU_LABEL_RDB_ENTRY_PUBLISHER 0x4d7bcdfbU #define MENU_LABEL_RDB_ENTRY_DEVELOPER 0x06f61093U From 0adba21410b7aaef029f1cbd8f2ddcea5d7df66a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 5 Feb 2018 16:18:32 +0100 Subject: [PATCH 101/232] Cleanup hashes --- menu/cbs/menu_cbs_title.c | 7 ++++--- msg_hash.h | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index d0f5d9b66d..19ff1e68ae 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -464,6 +464,10 @@ static struct cbs_title_lbl_callback cbs_title_lbl_list[] = { { MENU_ENUM_LABEL_ONLINE_UPDATER, action_get_online_updater_list + }, + { + MENU_ENUM_LABEL_DEFERRED_THUMBNAILS_UPDATER_LIST, + action_get_online_thumbnails_updater_list } }; @@ -945,9 +949,6 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_NETPLAY: BIND_ACTION_GET_TITLE(cbs, action_get_netplay_list); break; - case MENU_LABEL_DEFERRED_THUMBNAILS_UPDATER_LIST: - BIND_ACTION_GET_TITLE(cbs, action_get_online_thumbnails_updater_list); - break; case MENU_LABEL_DEFERRED_CORE_UPDATER_LIST: BIND_ACTION_GET_TITLE(cbs, action_get_core_updater_list); break; diff --git a/msg_hash.h b/msg_hash.h index a9c6df2322..33af68faec 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1742,7 +1742,6 @@ enum msg_hash_enums /* Deferred */ -#define MENU_LABEL_DEFERRED_THUMBNAILS_UPDATER_LIST 0x364dfa2bU #define MENU_LABEL_DEFERRED_VIDEO_FILTER 0x966ad201U #define MENU_LABEL_DEFERRED_CORE_LIST_SET 0xa6d5fdb4U #define MENU_LABEL_DEFERRED_DATABASE_MANAGER_LIST 0x7c0b704fU From 8d835d9b51453310ff98b59ae492669696720cbe Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 5 Feb 2018 16:41:02 +0100 Subject: [PATCH 102/232] Cleanup code --- tasks/task_content.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/tasks/task_content.c b/tasks/task_content.c index 946bb0b44f..5cc6d41fa8 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -849,7 +849,7 @@ static void menu_content_environment_get(int *argc, char *argv[], static bool task_load_content(content_ctx_info_t *content_info, content_information_ctx_t *content_ctx, bool launched_from_menu, - bool launched_from_cli, + bool loading_from_cli, char **error_string) { bool contentless = false; @@ -888,12 +888,6 @@ static bool task_load_content(content_ctx_info_t *content_info, PATH_MAX_LENGTH * sizeof(char)); } -#ifdef HAVE_MENU - /* Push quick menu onto menu stack */ - if (launched_from_cli) - menu_driver_ctl(RARCH_MENU_CTL_SET_PENDING_QUICK_MENU, NULL); -#endif - if (info && !string_is_empty(tmp)) { const char *core_path = NULL; @@ -929,7 +923,7 @@ static bool task_load_content(content_ctx_info_t *content_info, break; } - if (launched_from_cli) + if (loading_from_cli) { settings_t *settings = config_get_ptr(); content_ctx->history_list_enable = settings->bools.history_list_enable; @@ -958,7 +952,6 @@ static bool task_load_content(content_ctx_info_t *content_info, #ifdef HAVE_MENU static bool command_event_cmd_exec(const char *data, content_information_ctx_t *content_ctx, - bool launched_from_cli, char **error_string) { #if defined(HAVE_DYNAMIC) @@ -980,7 +973,7 @@ static bool command_event_cmd_exec(const char *data, #if defined(HAVE_DYNAMIC) if (!task_load_content(&content_info, content_ctx, - true, launched_from_cli, error_string)) + true, false, error_string)) return false; #else frontend_driver_set_fork(FRONTEND_FORK_CORE_WITH_ARGS); @@ -1192,7 +1185,7 @@ bool task_push_load_content_from_playlist_from_menu( /* On targets that have no dynamic core loading support, we'd * execute the new core from this point. If this returns false, * we assume we can dynamically load the core. */ - if (!command_event_cmd_exec(fullpath, &content_ctx, CONTENT_MODE_LOAD_NONE, &error_string)) + if (!command_event_cmd_exec(fullpath, &content_ctx, &error_string)) { if (error_string) { @@ -1439,7 +1432,7 @@ bool task_push_load_content_with_new_core_from_menu( #else command_event_cmd_exec(path_get(RARCH_PATH_CONTENT), &content_ctx, - false, &error_string); + &error_string); command_event(CMD_EVENT_QUIT, NULL); #endif @@ -1582,6 +1575,11 @@ bool task_push_load_content_from_cli( if (!task_load_content_callback(content_info, true, true)) return false; +#ifdef HAVE_MENU + /* Push quick menu onto menu stack */ + menu_driver_ctl(RARCH_MENU_CTL_SET_PENDING_QUICK_MENU, NULL); +#endif + return true; } From 969067b359dbebb4b2e240abf64120852af03a9d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 5 Feb 2018 16:42:02 +0100 Subject: [PATCH 103/232] Revert "Cleanup code" This reverts commit 8d835d9b51453310ff98b59ae492669696720cbe. --- tasks/task_content.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/tasks/task_content.c b/tasks/task_content.c index 5cc6d41fa8..946bb0b44f 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -849,7 +849,7 @@ static void menu_content_environment_get(int *argc, char *argv[], static bool task_load_content(content_ctx_info_t *content_info, content_information_ctx_t *content_ctx, bool launched_from_menu, - bool loading_from_cli, + bool launched_from_cli, char **error_string) { bool contentless = false; @@ -888,6 +888,12 @@ static bool task_load_content(content_ctx_info_t *content_info, PATH_MAX_LENGTH * sizeof(char)); } +#ifdef HAVE_MENU + /* Push quick menu onto menu stack */ + if (launched_from_cli) + menu_driver_ctl(RARCH_MENU_CTL_SET_PENDING_QUICK_MENU, NULL); +#endif + if (info && !string_is_empty(tmp)) { const char *core_path = NULL; @@ -923,7 +929,7 @@ static bool task_load_content(content_ctx_info_t *content_info, break; } - if (loading_from_cli) + if (launched_from_cli) { settings_t *settings = config_get_ptr(); content_ctx->history_list_enable = settings->bools.history_list_enable; @@ -952,6 +958,7 @@ static bool task_load_content(content_ctx_info_t *content_info, #ifdef HAVE_MENU static bool command_event_cmd_exec(const char *data, content_information_ctx_t *content_ctx, + bool launched_from_cli, char **error_string) { #if defined(HAVE_DYNAMIC) @@ -973,7 +980,7 @@ static bool command_event_cmd_exec(const char *data, #if defined(HAVE_DYNAMIC) if (!task_load_content(&content_info, content_ctx, - true, false, error_string)) + true, launched_from_cli, error_string)) return false; #else frontend_driver_set_fork(FRONTEND_FORK_CORE_WITH_ARGS); @@ -1185,7 +1192,7 @@ bool task_push_load_content_from_playlist_from_menu( /* On targets that have no dynamic core loading support, we'd * execute the new core from this point. If this returns false, * we assume we can dynamically load the core. */ - if (!command_event_cmd_exec(fullpath, &content_ctx, &error_string)) + if (!command_event_cmd_exec(fullpath, &content_ctx, CONTENT_MODE_LOAD_NONE, &error_string)) { if (error_string) { @@ -1432,7 +1439,7 @@ bool task_push_load_content_with_new_core_from_menu( #else command_event_cmd_exec(path_get(RARCH_PATH_CONTENT), &content_ctx, - &error_string); + false, &error_string); command_event(CMD_EVENT_QUIT, NULL); #endif @@ -1575,11 +1582,6 @@ bool task_push_load_content_from_cli( if (!task_load_content_callback(content_info, true, true)) return false; -#ifdef HAVE_MENU - /* Push quick menu onto menu stack */ - menu_driver_ctl(RARCH_MENU_CTL_SET_PENDING_QUICK_MENU, NULL); -#endif - return true; } From 1bbdad462147a2bfadf62b0b6ac44a6a212f4e42 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 5 Feb 2018 16:49:04 +0100 Subject: [PATCH 104/232] Cleanups --- menu/menu_displaylist.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index c32e72de3f..43088b4979 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -1274,19 +1274,13 @@ static int menu_displaylist_parse_playlist(menu_displaylist_info_t *info, for (i = 0; i < list_size; i++) { - char *path_copy = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); char *fill_buf = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); size_t path_size = PATH_MAX_LENGTH * sizeof(char); const char *core_name = NULL; const char *path = NULL; const char *label = NULL; - fill_buf[0] = path_copy[0] = '\0'; - - if (!string_is_empty(info->path)) - strlcpy(path_copy, info->path, path_size); - - path = path_copy; + fill_buf[0] = '\0'; playlist_get_index(playlist, i, &path, &label, NULL, &core_name, NULL, NULL); @@ -1349,7 +1343,6 @@ static int menu_displaylist_parse_playlist(menu_displaylist_info_t *info, menu_entries_append_enum(info->list, label, path, MENU_ENUM_LABEL_PLAYLIST_ENTRY, FILE_TYPE_RPL_ENTRY, 0, i); - free(path_copy); free(fill_buf); } From 9e372c6c29b9ef175e7f892d0a9f8c00f4fb8299 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 5 Feb 2018 16:50:11 +0100 Subject: [PATCH 105/232] Prevent leak --- menu/menu_displaylist.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 43088b4979..120fb20077 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -1297,8 +1297,9 @@ static int menu_displaylist_parse_playlist(menu_displaylist_info_t *info, menu_driver_set_thumbnail_content(content_basename, strlen(content_basename) + 1); menu_driver_ctl(RARCH_MENU_CTL_UPDATE_THUMBNAIL_PATH, NULL); menu_driver_ctl(RARCH_MENU_CTL_UPDATE_THUMBNAIL_IMAGE, NULL); - free(content_basename); } + + free(content_basename); } if (path) From e8941ec437a9f025efb71cafda76d40c8f84c5f3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 5 Feb 2018 17:14:03 +0100 Subject: [PATCH 106/232] Get rid of more hashes in menu_generic.c --- intl/msg_hash_lbl.h | 2 + menu/drivers/menu_generic.c | 103 +++++++++++++++++++++++++----------- msg_hash.h | 5 +- 3 files changed, 75 insertions(+), 35 deletions(-) diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index 28e4c248e2..aa0ee31eda 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -433,6 +433,8 @@ MSG_HASH(MENU_ENUM_LABEL_GAME_SPECIFIC_OPTIONS_IN_USE, "game_specific_options_in_use") MSG_HASH(MENU_ENUM_LABEL_HELP, "help") +MSG_HASH(MENU_ENUM_LABEL_HELP_CHEEVOS_DESCRIPTION, + "help_cheevos_description") MSG_HASH(MENU_ENUM_LABEL_HELP_AUDIO_VIDEO_TROUBLESHOOTING, "help_audio_video_troubleshooting") MSG_HASH(MENU_ENUM_LABEL_HELP_CHANGE_VIRTUAL_GAMEPAD, diff --git a/menu/drivers/menu_generic.c b/menu/drivers/menu_generic.c index fce4d72480..e22ed99c83 100644 --- a/menu/drivers/menu_generic.c +++ b/menu/drivers/menu_generic.c @@ -29,29 +29,62 @@ #include "../../content.h" #include "../../retroarch.h" -static enum action_iterate_type action_iterate_type(uint32_t hash) +struct menu_generic_iterate_type { - switch (hash) - { - case MENU_LABEL_HELP: - case MENU_LABEL_HELP_CONTROLS: - case MENU_LABEL_HELP_WHAT_IS_A_CORE: - case MENU_LABEL_HELP_LOADING_CONTENT: - case MENU_LABEL_HELP_CHANGE_VIRTUAL_GAMEPAD: - case MENU_LABEL_CHEEVOS_DESCRIPTION: - case MENU_LABEL_HELP_AUDIO_VIDEO_TROUBLESHOOTING: - case MENU_LABEL_HELP_SCANNING_CONTENT: - return ITERATE_TYPE_HELP; - case MENU_LABEL_INFO_SCREEN: - return ITERATE_TYPE_INFO; - case MENU_LABEL_CUSTOM_BIND: - case MENU_LABEL_CUSTOM_BIND_ALL: - case MENU_LABEL_CUSTOM_BIND_DEFAULTS: - return ITERATE_TYPE_BIND; - } + enum msg_hash_enums id; + enum action_iterate_type type; +}; - return ITERATE_TYPE_DEFAULT; -} +static struct menu_generic_iterate_type iterate_lbl_list[] = { + { + MENU_ENUM_LABEL_HELP, + ITERATE_TYPE_HELP + }, + { + MENU_ENUM_LABEL_HELP_CONTROLS, + ITERATE_TYPE_HELP + }, + { + MENU_ENUM_LABEL_HELP_WHAT_IS_A_CORE, + ITERATE_TYPE_HELP + }, + { + MENU_ENUM_LABEL_HELP_LOADING_CONTENT, + ITERATE_TYPE_HELP + }, + { + MENU_ENUM_LABEL_HELP_CHANGE_VIRTUAL_GAMEPAD, + ITERATE_TYPE_HELP + }, + { + MENU_ENUM_LABEL_HELP_CHEEVOS_DESCRIPTION, + ITERATE_TYPE_HELP + }, + { + MENU_ENUM_LABEL_HELP_AUDIO_VIDEO_TROUBLESHOOTING, + ITERATE_TYPE_HELP + }, + { + MENU_ENUM_LABEL_HELP_SCANNING_CONTENT, + ITERATE_TYPE_HELP + }, + { + MENU_ENUM_LABEL_INFO_SCREEN, + ITERATE_TYPE_INFO + }, + { + MENU_ENUM_LABEL_CUSTOM_BIND, + ITERATE_TYPE_BIND + }, + { + MENU_ENUM_LABEL_CUSTOM_BIND_ALL, + ITERATE_TYPE_BIND + }, + { + MENU_ENUM_LABEL_CUSTOM_BIND_DEFAULTS, + ITERATE_TYPE_BIND + } +}; /** * menu_iterate: @@ -66,14 +99,13 @@ static enum action_iterate_type action_iterate_type(uint32_t hash) **/ int generic_menu_iterate(void *data, void *userdata, enum menu_action action) { - enum action_iterate_type iterate_type; - unsigned file_type = 0; - int ret = 0; - uint32_t hash = 0; - enum msg_hash_enums enum_idx = MSG_UNKNOWN; - const char *label = NULL; - menu_handle_t *menu = (menu_handle_t*)data; - size_t selection = menu_navigation_get_selection(); + enum action_iterate_type iterate_type = ITERATE_TYPE_DEFAULT; + unsigned file_type = 0; + int ret = 0; + enum msg_hash_enums enum_idx = MSG_UNKNOWN; + const char *label = NULL; + menu_handle_t *menu = (menu_handle_t*)data; + size_t selection = menu_navigation_get_selection(); menu_entries_get_last_stack(NULL, &label, &file_type, &enum_idx, NULL); @@ -83,8 +115,17 @@ int generic_menu_iterate(void *data, void *userdata, enum menu_action action) menu->menu_state_msg[0] = '\0'; if (!string_is_empty(label)) - hash = msg_hash_calculate(label); - iterate_type = action_iterate_type(hash); + { + unsigned k; + for (k = 0; k < ARRAY_SIZE(iterate_lbl_list); k++) + { + if (string_is_equal(label, msg_hash_to_str(iterate_lbl_list[k].id))) + { + iterate_type = iterate_lbl_list[k].type; + break; + } + } + } menu_driver_set_binding_state(iterate_type == ITERATE_TYPE_BIND); diff --git a/msg_hash.h b/msg_hash.h index 33af68faec..ebe0948cc7 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -908,6 +908,7 @@ enum msg_hash_enums MENU_LABEL(HELP_LOADING_CONTENT), MENU_LABEL(HELP_LIST), MENU_LABEL(HELP_CONTROLS), + MENU_LABEL(HELP_CHEEVOS_DESCRIPTION), MENU_ENUM_LABEL_VALUE_EXTRACTING_PLEASE_WAIT, @@ -1785,10 +1786,6 @@ enum msg_hash_enums #define MENU_LABEL_DEFERRED_CONFIGURATIONS_LIST 0x679a1b0bU #define MENU_LABEL_DEFERRED_BROWSE_URL_START 0xcef58296U -/* Cheevos settings */ - -#define MENU_LABEL_CHEEVOS_DESCRIPTION 0x7e00e0f5U - /* Accounts settings */ #define MENU_LABEL_ACCOUNTS_RETRO_ACHIEVEMENTS 0xe6b7c16cU From c9fd0d4a779a52e86553064a7cd9380ed9851c3e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 5 Feb 2018 17:18:54 +0100 Subject: [PATCH 107/232] Get rid of more hashes --- msg_hash.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/msg_hash.h b/msg_hash.h index ebe0948cc7..c1188ed066 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1942,13 +1942,7 @@ enum msg_hash_enums #define MENU_LABEL_AUDIO_RESAMPLER_DRIVER_CC 0x0059732bU #define MENU_LABEL_VIDEO_FILTER 0x1c0eb741U -#define MENU_LABEL_HELP_CONTROLS 0x04859221U #define MENU_LABEL_HELP_LIST 0x006af669U -#define MENU_LABEL_HELP_WHAT_IS_A_CORE 0x83fcbc44U -#define MENU_LABEL_HELP_LOADING_CONTENT 0x231d8245U -#define MENU_LABEL_HELP_SCANNING_CONTENT 0x1dec52b8U -#define MENU_LABEL_HELP_CHANGE_VIRTUAL_GAMEPAD 0x6e66ef07U -#define MENU_LABEL_HELP_AUDIO_VIDEO_TROUBLESHOOTING 0xd44d395cU /* Main menu */ #define MENU_LABEL_NETPLAY 0x0b511d22U From 85e7920b665aa2758260669b40eb1a0f79b2096b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 5 Feb 2018 17:40:32 +0100 Subject: [PATCH 108/232] Start getting rid of msg_hash_calculate in menu code --- menu/cbs/menu_cbs_left.c | 5 +---- menu/cbs/menu_cbs_right.c | 5 +---- menu/menu_setting.c | 7 +------ 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/menu/cbs/menu_cbs_left.c b/menu/cbs/menu_cbs_left.c index 9453af6f02..9157273f13 100644 --- a/menu/cbs/menu_cbs_left.c +++ b/menu/cbs/menu_cbs_left.c @@ -485,15 +485,12 @@ static int menu_cbs_init_bind_left_compare_label(menu_file_list_cbs_t *cbs, unsigned i; for (i = 0; i < MAX_USERS; i++) { - uint32_t label_setting_hash; char label_setting[128]; - label_setting[0] = '\0'; snprintf(label_setting, sizeof(label_setting), "input_player%d_joypad_index", i + 1); - label_setting_hash = msg_hash_calculate(label_setting); - if (label_hash != label_setting_hash) + if (!string_is_equal(label_setting, label)) continue; BIND_ACTION_LEFT(cbs, bind_left_generic); diff --git a/menu/cbs/menu_cbs_right.c b/menu/cbs/menu_cbs_right.c index f5bbc5af20..cfa41a5156 100644 --- a/menu/cbs/menu_cbs_right.c +++ b/menu/cbs/menu_cbs_right.c @@ -595,15 +595,12 @@ static int menu_cbs_init_bind_right_compare_label(menu_file_list_cbs_t *cbs, unsigned i; for (i = 0; i < MAX_USERS; i++) { - uint32_t label_setting_hash; char label_setting[128]; - label_setting[0] = '\0'; snprintf(label_setting, sizeof(label_setting), "input_player%d_joypad_index", i + 1); - label_setting_hash = msg_hash_calculate(label_setting); - if (label_hash != label_setting_hash) + if (!string_is_equal(label, label_setting)) continue; BIND_ACTION_RIGHT(cbs, bind_right_generic); diff --git a/menu/menu_setting.c b/menu/menu_setting.c index e323ff140e..883549f70a 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -820,19 +820,14 @@ int menu_action_handle_setting(rarch_setting_t *setting, static rarch_setting_t *menu_setting_find_internal(rarch_setting_t *setting, const char *label) { - uint32_t needle = msg_hash_calculate(label); rarch_setting_t **list = &setting; for (; setting_get_type(setting) != ST_NONE; (*list = *list + 1)) { - if ( (needle == setting->name_hash) + if (string_is_equal(label, setting->name) && (setting_get_type(setting) <= ST_GROUP)) { - const char *name = setting->name; const char *short_description = setting->short_description; - /* make sure this isn't a collision */ - if (!string_is_equal(label, name)) - continue; if (string_is_empty(short_description)) return NULL; From c61230cdbe062c1f410a797eae52a3ad62347a14 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 5 Feb 2018 17:42:54 +0100 Subject: [PATCH 109/232] setting->name_hash can be safely removed now --- menu/menu_setting.c | 1 - setting_list.c | 48 --------------------------------------------- setting_list.h | 1 - 3 files changed, 50 deletions(-) diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 883549f70a..39809ffe85 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -7786,7 +7786,6 @@ static void menu_setting_terminate_last(rarch_setting_t *list, unsigned pos) (*&list)[pos].type = ST_NONE; (*&list)[pos].size = 0; (*&list)[pos].name = NULL; - (*&list)[pos].name_hash = 0; (*&list)[pos].short_description = NULL; (*&list)[pos].group = NULL; (*&list)[pos].subgroup = NULL; diff --git a/setting_list.c b/setting_list.c index 09b0eff5a1..254bd62e38 100644 --- a/setting_list.c +++ b/setting_list.c @@ -618,7 +618,6 @@ static rarch_setting_t setting_action_setting(const char* name, result.size = 0; result.name = name; - result.name_hash = 0; result.short_description = short_description; result.group = group; result.subgroup = subgroup; @@ -681,7 +680,6 @@ static rarch_setting_t setting_group_setting(enum setting_type type, const char* result.size = 0; result.name = name; - result.name_hash = 0; result.short_description = name; result.group = NULL; result.subgroup = NULL; @@ -755,7 +753,6 @@ static rarch_setting_t setting_float_setting(const char* name, result.size = sizeof(float); result.name = name; - result.name_hash = 0; result.short_description = short_description; result.group = group; result.subgroup = subgroup; @@ -832,7 +829,6 @@ static rarch_setting_t setting_uint_setting(const char* name, result.size = sizeof(unsigned int); result.name = name; - result.name_hash = 0; result.short_description = short_description; result.group = group; result.subgroup = subgroup; @@ -909,7 +905,6 @@ static rarch_setting_t setting_hex_setting(const char* name, result.size = sizeof(unsigned int); result.name = name; - result.name_hash = 0; result.short_description = short_description; result.group = group; result.subgroup = subgroup; @@ -987,7 +982,6 @@ static rarch_setting_t setting_bind_setting(const char* name, result.size = 0; result.name = name; - result.name_hash = 0; result.short_description = short_description; result.group = group; result.subgroup = subgroup; @@ -1147,7 +1141,6 @@ static rarch_setting_t setting_string_setting(enum setting_type type, result.size = size; result.name = name; - result.name_hash = 0; result.short_description = short_description; result.group = group; result.subgroup = subgroup; @@ -1269,7 +1262,6 @@ static rarch_setting_t setting_subgroup_setting(enum setting_type type, result.size = 0; result.name = name; - result.name_hash = 0; result.short_description = name; result.group = parent_name; result.parent_group = parent_group; @@ -1344,7 +1336,6 @@ static rarch_setting_t setting_bool_setting(const char* name, result.size = sizeof(bool); result.name = name; - result.name_hash = name ? msg_hash_calculate(name) : 0; result.short_description = short_description; result.group = group; result.subgroup = subgroup; @@ -1423,7 +1414,6 @@ static rarch_setting_t setting_int_setting(const char* name, result.size = sizeof(int); result.name = name; - result.name_hash = name ? msg_hash_calculate(name) : 0; result.short_description = short_description; result.group = group; result.subgroup = subgroup; @@ -1493,8 +1483,6 @@ bool CONFIG_BOOL_ALT( if (!settings_list_append(list, list_info)) return false; - if (value.name) - value.name_hash = msg_hash_calculate(value.name); (*list)[list_info->index++] = value; if (flags != SD_FLAG_NONE) settings_data_list_current_add_flags(list, list_info, flags); @@ -1529,8 +1517,6 @@ bool CONFIG_BOOL( if (!settings_list_append(list, list_info)) return false; - if (value.name) - value.name_hash = msg_hash_calculate(value.name); (*list)[list_info->index++] = value; if (flags != SD_FLAG_NONE) settings_data_list_current_add_flags(list, list_info, flags); @@ -1564,8 +1550,6 @@ bool CONFIG_INT( false); if (!(settings_list_append(list, list_info))) return false; - if (value.name) - value.name_hash = msg_hash_calculate(value.name); (*list)[list_info->index++] = value; #ifdef HAVE_MENU @@ -1593,8 +1577,6 @@ bool CONFIG_UINT_ALT( true); if (!(settings_list_append(list, list_info))) return false; - if (value.name) - value.name_hash = msg_hash_calculate(value.name); (*list)[list_info->index++] = value; return true; } @@ -1621,8 +1603,6 @@ bool CONFIG_UINT( false); if (!(settings_list_append(list, list_info))) return false; - if (value.name) - value.name_hash = msg_hash_calculate(value.name); (*list)[list_info->index++] = value; #ifdef HAVE_MENU @@ -1651,8 +1631,6 @@ bool CONFIG_FLOAT( false); if (!(settings_list_append(list, list_info))) return false; - if (value.name) - value.name_hash = msg_hash_calculate(value.name); (*list)[list_info->index++] = value; #ifdef HAVE_MENU @@ -1684,8 +1662,6 @@ bool CONFIG_PATH( false); if (!(settings_list_append(list, list_info))) return false; - if (value.name) - value.name_hash = msg_hash_calculate(value.name); (*list)[list_info->index++] = value; settings_data_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_EMPTY); #ifdef HAVE_MENU @@ -1718,8 +1694,6 @@ bool CONFIG_DIR( false); if (!(settings_list_append(list, list_info))) return false; - if (value.name) - value.name_hash = msg_hash_calculate(value.name); (*list)[list_info->index++] = value; settings_data_list_current_add_flags( list, @@ -1753,8 +1727,6 @@ bool CONFIG_STRING( change_handler, read_handler, false); if (!(settings_list_append(list, list_info))) return false; - if (value.name) - value.name_hash = msg_hash_calculate(value.name); (*list)[list_info->index++] = value; #ifdef HAVE_MENU menu_settings_list_current_add_enum_idx(list, list_info, name_enum_idx); @@ -1784,8 +1756,6 @@ bool CONFIG_STRING_OPTIONS( if (!(settings_list_append(list, list_info))) return false; - if (value.name) - value.name_hash = msg_hash_calculate(value.name); (*list)[list_info->index++] = value; #ifdef HAVE_MENU @@ -1818,8 +1788,6 @@ bool CONFIG_HEX( change_handler, read_handler, false); if (!(settings_list_append(list, list_info))) return false; - if (value.name) - value.name_hash = msg_hash_calculate(value.name); (*list)[list_info->index++] = value; #ifdef HAVE_MENU @@ -1849,8 +1817,6 @@ bool CONFIG_BIND( if (!(settings_list_append(list, list_info))) return false; - if (value.name) - value.name_hash = msg_hash_calculate(value.name); (*list)[list_info->index++] = value; /* Request name and short description to be freed later */ settings_data_list_current_add_free_flags(list, list_info, SD_FREE_FLAG_NAME | SD_FREE_FLAG_SHORT); @@ -1876,8 +1842,6 @@ bool CONFIG_BIND_ALT( if (!(settings_list_append(list, list_info))) return false; - if (value.name) - value.name_hash = msg_hash_calculate(value.name); (*list)[list_info->index++] = value; /* Request name and short description to be freed later */ settings_data_list_current_add_free_flags(list, list_info, SD_FREE_FLAG_NAME | SD_FREE_FLAG_SHORT); @@ -1899,8 +1863,6 @@ bool CONFIG_ACTION_ALT( if (!settings_list_append(list, list_info)) return false; - if (value.name) - value.name_hash = msg_hash_calculate(value.name); (*list)[list_info->index++] = value; return true; } @@ -1923,8 +1885,6 @@ bool CONFIG_ACTION( if (!settings_list_append(list, list_info)) return false; - if (value.name) - value.name_hash = msg_hash_calculate(value.name); (*list)[list_info->index++] = value; #ifdef HAVE_MENU @@ -1944,8 +1904,6 @@ bool START_GROUP(rarch_setting_t **list, rarch_setting_info_t *list_info, if (!(settings_list_append(list, list_info))) return false; - if (value.name) - value.name_hash = msg_hash_calculate(value.name); (*list)[list_info->index++] = value; return true; } @@ -1956,8 +1914,6 @@ bool END_GROUP(rarch_setting_t **list, rarch_setting_info_t *list_info, rarch_setting_t value = setting_group_setting (ST_END_GROUP, 0, parent_group); if (!(settings_list_append(list, list_info))) return false; - if (value.name) - value.name_hash = msg_hash_calculate(value.name); (*list)[list_info->index++] = value; return true; } @@ -1975,8 +1931,6 @@ bool START_SUB_GROUP(rarch_setting_t **list, if (!(settings_list_append(list, list_info))) return false; - if (value.name) - value.name_hash = msg_hash_calculate(value.name); (*list)[list_info->index++] = value; return true; } @@ -1989,8 +1943,6 @@ bool END_SUB_GROUP( rarch_setting_t value = setting_group_setting (ST_END_SUB_GROUP, 0, parent_group); if (!(settings_list_append(list, list_info))) return false; - if (value.name) - value.name_hash = msg_hash_calculate(value.name); (*list)[list_info->index++] = value; return true; } diff --git a/setting_list.h b/setting_list.h index 08a8c9e4e2..abd5a26652 100644 --- a/setting_list.h +++ b/setting_list.h @@ -104,7 +104,6 @@ struct rarch_setting unsigned bind_type; uint32_t size; - uint32_t name_hash; float step; From 457d543cb1de9f2b499ddfc35a214850dac536b7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 5 Feb 2018 19:14:55 +0100 Subject: [PATCH 110/232] Get rid of callback function hashes --- menu/cbs/menu_cbs_ok.c | 32 ++++++++++++++++++-------------- msg_hash.h | 6 ------ tasks/task_decompress.c | 2 +- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 247ebba9bb..33148cb6f4 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -2266,23 +2266,24 @@ static int action_ok_undo_save_state(const char *path, #ifdef HAVE_ZLIB static void cb_decompressed(void *task_data, void *user_data, const char *err) { - decompress_task_data_t *dec = (decompress_task_data_t*)task_data; + decompress_task_data_t *dec = (decompress_task_data_t*)task_data; + enum msg_hash_enums *enum_idx = (enum msg_hash_enums*)user_data; - if (dec && !err) + if (dec && !err && enum_idx) { - unsigned type_hash = (unsigned)(uintptr_t)user_data; + const char *msg = msg_hash_to_str(*enum_idx); - switch (type_hash) - { - case CB_CORE_UPDATER_DOWNLOAD: - generic_action_ok_command(CMD_EVENT_CORE_INFO_INIT); - break; - case CB_UPDATE_ASSETS: - generic_action_ok_command(CMD_EVENT_REINIT); - break; - } + if (string_is_equal(msg, + msg_hash_to_str(MENU_ENUM_LABEL_CB_CORE_UPDATER_DOWNLOAD))) + generic_action_ok_command(CMD_EVENT_CORE_INFO_INIT); + else if (string_is_equal(msg, + msg_hash_to_str(MENU_ENUM_LABEL_CB_UPDATE_ASSETS))) + generic_action_ok_command(CMD_EVENT_REINIT); } + if (user_data) + free(user_data); + if (err) RARCH_ERR("%s", err); @@ -2538,10 +2539,13 @@ static void cb_generic_download(void *task_data, if (path_is_compressed_file(output_path)) { + enum msg_hash_enums *idx = (enum msg_hash_enums*)calloc(1, sizeof(*idx)); + + *idx = transf->enum_idx; + if (!task_push_decompress(output_path, dir_path, NULL, NULL, NULL, - cb_decompressed, (void*)(uintptr_t) - msg_hash_calculate(msg_hash_to_str(transf->enum_idx)))) + cb_decompressed, idx)) { err = msg_hash_to_str(MSG_DECOMPRESSION_FAILED); goto finish; diff --git a/msg_hash.h b/msg_hash.h index c1188ed066..bd252f8c90 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1735,12 +1735,6 @@ enum msg_hash_enums MSG_LAST }; - -/* Callback strings */ - -#define CB_CORE_UPDATER_DOWNLOAD 0x7412da7dU -#define CB_UPDATE_ASSETS 0xbf85795eU - /* Deferred */ #define MENU_LABEL_DEFERRED_VIDEO_FILTER 0x966ad201U diff --git a/tasks/task_decompress.c b/tasks/task_decompress.c index a0d610cebc..2c3cca0962 100644 --- a/tasks/task_decompress.c +++ b/tasks/task_decompress.c @@ -243,7 +243,7 @@ bool task_check_decompress(const char *source_file) task_finder_data_t find_data; /* Prepare find parameters */ - find_data.func = task_decompress_finder; + find_data.func = task_decompress_finder; find_data.userdata = (void *)source_file; /* Return whether decompressing is in progress or not */ From 45580cb9a8f0fcd0a87f00eadf26d87f05289485 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Mon, 5 Feb 2018 20:54:55 +0100 Subject: [PATCH 111/232] add basic support for arabic. --- Makefile.common | 3 +- gfx/font_driver.c | 241 ++ griffin/griffin.c | 1 + intl/msg_hash_ar.c | 2089 +++++++++++++++++ intl/msg_hash_ar.h | 3417 ++++++++++++++++++++++++++++ intl/msg_hash_chs.h | 2 + intl/msg_hash_cht.h | 2 + intl/msg_hash_de.h | 2 + intl/msg_hash_eo.h | 2 + intl/msg_hash_es.h | 6 +- intl/msg_hash_fr.h | 2 + intl/msg_hash_it.h | 2 + intl/msg_hash_ja.h | 2 + intl/msg_hash_ko.h | 2 + intl/msg_hash_nl.h | 2 + intl/msg_hash_pl.h | 2 + intl/msg_hash_pt_br.h | 4 + intl/msg_hash_pt_pt.h | 2 + intl/msg_hash_ru.h | 2 + intl/msg_hash_vn.h | 2 + libretro-common/include/libretro.h | 1 + menu/drivers/xmb.c | 14 +- menu/menu_setting.c | 1 + msg_hash.c | 6 + msg_hash.h | 4 + 25 files changed, 5810 insertions(+), 3 deletions(-) create mode 100644 intl/msg_hash_ar.c create mode 100644 intl/msg_hash_ar.h diff --git a/Makefile.common b/Makefile.common index fcf90a92d9..498be0f888 100644 --- a/Makefile.common +++ b/Makefile.common @@ -284,7 +284,8 @@ OBJ += intl/msg_hash_de.o \ intl/msg_hash_ru.o \ intl/msg_hash_vn.o \ intl/msg_hash_chs.o \ - intl/msg_hash_cht.o + intl/msg_hash_cht.o \ + intl/msg_hash_ar.o endif diff --git a/gfx/font_driver.c b/gfx/font_driver.c index fd54e019fa..c020dfa5d4 100644 --- a/gfx/font_driver.c +++ b/gfx/font_driver.c @@ -470,14 +470,255 @@ static bool font_init_first( return false; } +#ifdef HAVE_LANGEXTRA + +/* ACII: 0xxxxxxx (c & 0x80) == 0x00 + * other start: 11xxxxxx (c & 0xC0) == 0xC0 + * other cont: 10xxxxxx (c & 0xC0) == 0x80 + * Neutral : + * 0020 - 002F : 001xxxxx (c & 0xE0) == 0x20 + * Arabic: + * 0600 - 07FF : 11011xxx (c & 0xF8) == 0xD8 (2 bytes) + * 0800 - 08FF : 11100000 101000xx c == 0xE0 && (c1 & 0xAC) == 0xA0 (3 bytes) */ + +/* clang-format off */ +#define IS_ASCII(p) ((*(p)&0x80) == 0x00) +#define IS_MBSTART(p) ((*(p)&0xC0) == 0xC0) +#define IS_MBCONT(p) ((*(p)&0xC0) == 0x80) +#define IS_DIR_NEUTRAL(p) ((*(p)&0xE0) == 0x20) +#define IS_ARABIC0(p) ((*(p)&0xF8) == 0xD8) +#define IS_ARABIC1(p) ((*(p) == 0xE0) && ((*((p) + 1) & 0xAC) == 0xA0)) +#define IS_ARABIC(p) (IS_ARABIC0(p) || IS_ARABIC1(p)) +#define IS_RTL(p) IS_ARABIC(p) + +/* 0x0620 to 0x064F */ +static const unsigned arabic_shape_map[0x50 - 0x20][0x4] = { + { 0 }, /* 0x0620 */ + { 0xFE80 }, + { 0xFE81, 0xFE82 }, + { 0xFE83, 0xFE84 }, + { 0xFE85, 0xFE86 }, + { 0xFE87, 0xFE88 }, + { 0xFE89, 0xFE8A, 0xFE8B, 0xFE8C }, + { 0xFE8D, 0xFE8E }, + + { 0xFE8F, 0xFE90, 0xFE91, 0xFE92 }, + { 0xFE93, 0xFE94 }, + { 0xFE95, 0xFE96, 0xFE97, 0xFE98 }, + { 0xFE99, 0xFE9A, 0xFE9B, 0xFE9C }, + { 0xFE9D, 0xFE9E, 0xFE9F, 0xFEA0 }, + { 0xFEA1, 0xFEA2, 0xFEA3, 0xFEA4 }, + { 0xFEA5, 0xFEA6, 0xFEA7, 0xFEA8 }, + { 0xFEA9, 0xFEAA }, + + { 0xFEAB, 0xFEAC }, /* 0x0630 */ + { 0xFEAD, 0xFEAE }, + { 0xFEAF, 0xFEB0 }, + { 0xFEB1, 0xFEB2, 0xFEB3, 0xFEB4 }, + { 0xFEB5, 0xFEB6, 0xFEB7, 0xFEB8 }, + { 0xFEB9, 0xFEBA, 0xFEBB, 0xFEBC }, + { 0xFEBD, 0xFEBE, 0xFEBF, 0xFEC0 }, + { 0xFEC1, 0xFEC2, 0xFEC3, 0xFEC4 }, + { 0xFEC5, 0xFEC6, 0xFEC7, 0xFEC8 }, + + { 0xFEC9, 0xFECA, 0xFECB, 0xFECC }, + { 0xFECD, 0xFECE, 0xFECF, 0xFED0 }, + { 0 }, + { 0 }, + { 0 }, + { 0 }, + { 0 }, + { 0 }, + + { 0xFED1, 0xFED2, 0xFED3, 0xFED4 }, /* 0x0640 */ + { 0xFED5, 0xFED6, 0xFED7, 0xFED8 }, + { 0xFED9, 0xFEDA, 0xFEDB, 0xFEDC }, + { 0xFEDD, 0xFEDE, 0xFEDF, 0xFEE0 }, + { 0xFEE1, 0xFEE2, 0xFEE3, 0xFEE4 }, + { 0xFEE5, 0xFEE6, 0xFEE7, 0xFEE8 }, + { 0xFEE9, 0xFEEA, 0xFEEB, 0xFEEC }, + { 0xFEED, 0xFEEE }, + + { 0xFEEF, 0xFEF0, 0xFBE8, 0xFBE9 }, + { 0xFEF1, 0xFEF2, 0xFEF3, 0xFEF4 }, +}; +/* clang-format on */ + +static INLINE unsigned font_get_replacement(const char* src, const char* start) +{ + if ((*src & 0xFC) == 0xD8) /* 0x0600 to 0x06FF */ + { + int lookup; + unsigned result; + bool prev_connected = false; + bool next_connected = false; + unsigned char id = (src[0] << 6) | (src[1] & 0x3F); + const char* prev1 = src - 2; + const char* prev2 = src - 4; + + if (id < 0x21 || id > 0x4A) + return 0; + + if(prev2 < start) + { + prev2 = NULL; + if(prev1 < start) + prev1 = NULL; + } + + if (prev1 && (*prev1 & 0xFC) == 0xD8) + { + unsigned char prev1_id = 0; + + if (prev1) + prev1_id = (prev1[0] << 6) | (prev1[1] & 0x3F); + + if (prev1_id == 0x44) + { + unsigned char prev2_id = 0; + + if (prev2) + prev2_id = (prev2[0] << 6) | (prev2[1] & 0x3F); + + if (prev2_id > 0x20 || prev2_id < 0x50) + prev_connected = !!arabic_shape_map[prev2_id - 0x20][2]; + + switch (id) + { + case 0x22: + return 0xFEF5 + prev_connected; + case 0x23: + return 0xFEF7 + prev_connected; + case 0x25: + return 0xFEF9 + prev_connected; + case 0x27: + return 0xFEFB + prev_connected; + } + } + if (prev1_id > 0x20 || prev1_id < 0x50) + prev_connected = !!arabic_shape_map[prev1_id - 0x20][2]; + } + + if ((src[2] & 0xFC) == 0xD8) + { + unsigned char next_id = (src[2] << 6) | (src[3] & 0x3F); + + if (next_id > 0x20 || next_id < 0x50) + next_connected = true; + } + + result = arabic_shape_map[id - 0x20][prev_connected | (next_connected << 1)]; + + if (result) + return result; + + return arabic_shape_map[id - 0x20][prev_connected]; + } + + return 0; +} + +static char* font_driver_reshape_msg(const char* msg) +{ + /* worst case transformations are 2 bytes to 4 bytes */ + char* buffer = (char*)malloc((strlen(msg) * 2) + 1); + const char* src = msg; + char* dst = buffer; + bool reverse = false; + + while (*src || reverse) + { + if (reverse) + { + src--; + while (IS_MBCONT(src)) + src--; + + if (IS_RTL(src) || IS_DIR_NEUTRAL(src)) + { + unsigned replacement = font_get_replacement(src, msg); + if (replacement) + { + if (replacement < 0x80) + *dst++ = replacement; + else if (replacement < 0x8000) + { + *dst++ = 0xC0 | (replacement >> 6); + *dst++ = 0x80 | (replacement & 0x3F); + } + else if (replacement < 0x10000) + { + /* merged glyphs */ + if ((replacement >= 0xFEF5) && (replacement <= 0xFEFC)) + src -= 2; + + *dst++ = 0xE0 | (replacement >> 12); + *dst++ = 0x80 | ((replacement >> 6) & 0x3F); + *dst++ = 0x80 | (replacement & 0x3F); + } + else + { + *dst++ = 0xF0 | (replacement >> 18); + *dst++ = 0x80 | ((replacement >> 12) & 0x3F); + *dst++ = 0x80 | ((replacement >> 6) & 0x3F); + *dst++ = 0x80 | (replacement & 0x3F); + } + + continue; + } + + *dst++ = *src++; + while (IS_MBCONT(src)) + *dst++ = *src++; + src--; + + while (IS_MBCONT(src)) + src--; + } + else + { + reverse = false; + src++; + while (IS_MBCONT(src) || IS_RTL(src) || IS_DIR_NEUTRAL(src)) + src++; + } + } + else + { + if (IS_RTL(src)) + { + reverse = true; + while (IS_MBCONT(src) || IS_RTL(src) || IS_DIR_NEUTRAL(src)) + src++; + } + else + *dst++ = *src++; + } + } + + *dst = '\0'; + + return buffer; +} +#endif + void font_driver_render_msg( video_frame_info_t *video_info, void *font_data, const char *msg, const void *params) { font_data_t *font = (font_data_t*)(font_data ? font_data : video_font_driver); + if (font && font->renderer && font->renderer->render_msg) + { +#ifdef HAVE_LANGEXTRA + char* new_msg = font_driver_reshape_msg(msg); + font->renderer->render_msg(video_info, font->renderer_data, new_msg, params); + free(new_msg); +#else font->renderer->render_msg(video_info, font->renderer_data, msg, params); +#endif + } } void font_driver_bind_block(void *font_data, void *block) diff --git a/griffin/griffin.c b/griffin/griffin.c index 2cfe446c80..dad50dc0a9 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -995,6 +995,7 @@ RETROARCH #include "../intl/msg_hash_vn.c" #include "../intl/msg_hash_chs.c" #include "../intl/msg_hash_cht.c" +#include "../intl/msg_hash_ar.c" #endif #include "../intl/msg_hash_us.c" diff --git a/intl/msg_hash_ar.c b/intl/msg_hash_ar.c new file mode 100644 index 0000000000..37675d467b --- /dev/null +++ b/intl/msg_hash_ar.c @@ -0,0 +1,2089 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2011-2017 - Daniel De Matteis + * Copyright (C) 2016-2017 - Brad Parker + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#include +#include +#include + +#include +#include + +#include "../msg_hash.h" +#include "../configuration.h" +#include "../verbosity.h" + +#if defined(_MSC_VER) && !defined(_XBOX) +/* https://support.microsoft.com/en-us/kb/980263 */ +#pragma execution_character_set("utf-8") +#pragma warning(disable: 4566) +#endif + +int menu_hash_get_help_ar_enum(enum msg_hash_enums msg, char *s, size_t len) +{ + uint32_t driver_hash = 0; + settings_t *settings = config_get_ptr(); + + if (msg == MENU_ENUM_LABEL_CONNECT_NETPLAY_ROOM) + { + snprintf(s, len, + "TODO/FIXME - Fill in message here." + ); + return 0; + } + if (msg <= MENU_ENUM_LABEL_INPUT_HOTKEY_BIND_END && + msg >= MENU_ENUM_LABEL_INPUT_HOTKEY_BIND_BEGIN) + { + unsigned idx = msg - MENU_ENUM_LABEL_INPUT_HOTKEY_BIND_BEGIN; + + switch (idx) + { + case RARCH_FAST_FORWARD_KEY: + snprintf(s, len, + "Toggles between fast-forwarding and \n" + "normal speed." + ); + break; + case RARCH_FAST_FORWARD_HOLD_KEY: + snprintf(s, len, + "Hold for fast-forward. \n" + " \n" + "Releasing button disables fast-forward." + ); + break; + case RARCH_PAUSE_TOGGLE: + snprintf(s, len, + "Toggle between paused and non-paused state."); + break; + case RARCH_FRAMEADVANCE: + snprintf(s, len, + "Frame advance when content is paused."); + break; + case RARCH_SHADER_NEXT: + snprintf(s, len, + "Applies next shader in directory."); + break; + case RARCH_SHADER_PREV: + snprintf(s, len, + "Applies previous shader in directory."); + break; + case RARCH_CHEAT_INDEX_PLUS: + case RARCH_CHEAT_INDEX_MINUS: + case RARCH_CHEAT_TOGGLE: + snprintf(s, len, + "Cheats."); + break; + case RARCH_RESET: + snprintf(s, len, + "Reset the content."); + break; + case RARCH_SCREENSHOT: + snprintf(s, len, + "Take screenshot."); + break; + case RARCH_MUTE: + snprintf(s, len, + "Mute/unmute audio."); + break; + case RARCH_OSK: + snprintf(s, len, + "Toggles onscreen keyboard."); + break; + case RARCH_NETPLAY_GAME_WATCH: + snprintf(s, len, + "Netplay toggle play/spectate mode."); + break; + case RARCH_SLOWMOTION: + snprintf(s, len, + "Hold for slowmotion."); + break; + case RARCH_ENABLE_HOTKEY: + snprintf(s, len, + "Enable other hotkeys. \n" + " \n" + "If this hotkey is bound to either\n" + "a keyboard, joybutton or joyaxis, \n" + "all other hotkeys will be enabled only \n" + "if this one is held at the same time. \n" + " \n" + "Alternatively, all hotkeys for keyboard \n" + "could be disabled by the user."); + break; + case RARCH_VOLUME_UP: + snprintf(s, len, + "Increases audio volume."); + break; + case RARCH_VOLUME_DOWN: + snprintf(s, len, + "Decreases audio volume."); + break; + case RARCH_OVERLAY_NEXT: + snprintf(s, len, + "Switches to next overlay. Wraps around."); + break; + case RARCH_DISK_EJECT_TOGGLE: + snprintf(s, len, + "Toggles eject for disks. \n" + " \n" + "Used for multiple-disk content. "); + break; + case RARCH_DISK_NEXT: + case RARCH_DISK_PREV: + snprintf(s, len, + "Cycles through disk images. Use after ejecting. \n" + " \n" + "Complete by toggling eject again."); + break; + case RARCH_GRAB_MOUSE_TOGGLE: + snprintf(s, len, + "Toggles mouse grab. \n" + " \n" + "When mouse is grabbed, RetroArch hides the \n" + "mouse, and keeps the mouse pointer inside \n" + "the window to allow relative mouse input to \n" + "work better."); + break; + case RARCH_GAME_FOCUS_TOGGLE: + snprintf(s, len, + "Toggles game focus.\n" + " \n" + "When a game has focus, RetroArch will both disable \n" + "hotkeys and keep/warp the mouse pointer inside the window."); + break; + case RARCH_MENU_TOGGLE: + snprintf(s, len, "Toggles menu."); + break; + case RARCH_LOAD_STATE_KEY: + snprintf(s, len, + "Loads state."); + break; + case RARCH_FULLSCREEN_TOGGLE_KEY: + snprintf(s, len, + "Toggles fullscreen."); + break; + case RARCH_QUIT_KEY: + snprintf(s, len, + "Key to exit RetroArch cleanly. \n" + " \n" + "Killing it in any hard way (SIGKILL, etc.) will \n" + "terminate RetroArch without saving RAM, etc." +#ifdef __unix__ + "\nOn Unix-likes, SIGINT/SIGTERM allows a clean \n" + "deinitialization." +#endif + ""); + break; + case RARCH_STATE_SLOT_PLUS: + case RARCH_STATE_SLOT_MINUS: + snprintf(s, len, + "State slots. \n" + " \n" + "With slot set to 0, save state name is \n" + "*.state (or whatever defined on commandline). \n" + " \n" + "When slot is not 0, path will be , \n" + "where is slot number."); + break; + case RARCH_SAVE_STATE_KEY: + snprintf(s, len, + "Saves state."); + break; + case RARCH_REWIND: + snprintf(s, len, + "Hold button down to rewind. \n" + " \n" + "Rewinding must be enabled."); + break; + case RARCH_MOVIE_RECORD_TOGGLE: + snprintf(s, len, + "Toggle between recording and not."); + break; + default: + if (string_is_empty(s)) + strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_INFORMATION_AVAILABLE), len); + break; + } + + return 0; + } + + switch (msg) + { + case MENU_ENUM_LABEL_ACCOUNTS_RETRO_ACHIEVEMENTS: + snprintf(s, len, "Login details for your \n" + "Retro Achievements account. \n" + " \n" + "Visit retroachievements.org and sign up \n" + "for a free account. \n" + " \n" + "After you are done registering, you need \n" + "to input the username and password into \n" + "RetroArch."); + break; + case MENU_ENUM_LABEL_CHEEVOS_USERNAME: + snprintf(s, len, "Username for your Retro Achievements account."); + break; + case MENU_ENUM_LABEL_CHEEVOS_PASSWORD: + snprintf(s, len, "Password for your Retro Achievements account."); + break; + case MENU_ENUM_LABEL_USER_LANGUAGE: + snprintf(s, len, "Localizes the menu and all onscreen messages \n" + "according to the language you have selected \n" + "here. \n" + " \n" + "Requires a restart for the changes \n" + "to take effect. \n" + " \n" + "Note: not all languages might be currently \n" + "implemented. \n" + " \n" + "In case a language is not implemented, \n" + "we fallback to English."); + break; + case MENU_ENUM_LABEL_VIDEO_FONT_PATH: + snprintf(s, len, "Change the font that is used \n" + "for the Onscreen Display text."); + break; + case MENU_ENUM_LABEL_GAME_SPECIFIC_OPTIONS: + snprintf(s, len, "Automatically load content-specific core options."); + break; + case MENU_ENUM_LABEL_AUTO_OVERRIDES_ENABLE: + snprintf(s, len, "Automatically load override configurations."); + break; + case MENU_ENUM_LABEL_AUTO_REMAPS_ENABLE: + snprintf(s, len, "Automatically load input remapping files."); + break; + case MENU_ENUM_LABEL_SORT_SAVESTATES_ENABLE: + snprintf(s, len, "Sort save states in folders \n" + "named after the libretro core used."); + break; + case MENU_ENUM_LABEL_SORT_SAVEFILES_ENABLE: + snprintf(s, len, "Sort save files in folders \n" + "named after the libretro core used."); + break; + case MENU_ENUM_LABEL_RESUME_CONTENT: + snprintf(s, len, "Exits from the menu and returns back \n" + "to the content."); + break; + case MENU_ENUM_LABEL_RESTART_CONTENT: + snprintf(s, len, "Restarts the content from the beginning."); + break; + case MENU_ENUM_LABEL_CLOSE_CONTENT: + snprintf(s, len, "Closes the content and unloads it from \n" + "memory."); + break; + case MENU_ENUM_LABEL_UNDO_LOAD_STATE: + snprintf(s, len, "If a state was loaded, content will \n" + "go back to the state prior to loading."); + break; + case MENU_ENUM_LABEL_UNDO_SAVE_STATE: + snprintf(s, len, "If a state was overwritten, it will \n" + "roll back to the previous save state."); + break; + case MENU_ENUM_LABEL_TAKE_SCREENSHOT: + snprintf(s, len, "Create a screenshot. \n" + " \n" + "The screenshot will be stored inside the \n" + "Screenshot Directory."); + break; + case MENU_ENUM_LABEL_ADD_TO_FAVORITES: + snprintf(s, len, "Add the entry to your Favorites."); + break; + case MENU_ENUM_LABEL_RUN: + snprintf(s, len, "Start the content."); + break; + case MENU_ENUM_LABEL_INFORMATION: + snprintf(s, len, "Show additional metadata information \n" + "about the content."); + break; + case MENU_ENUM_LABEL_FILE_BROWSER_CONFIG: + snprintf(s, len, "Configuration file."); + break; + case MENU_ENUM_LABEL_FILE_BROWSER_COMPRESSED_ARCHIVE: + snprintf(s, len, "Compressed archive file."); + break; + case MENU_ENUM_LABEL_FILE_BROWSER_RECORD_CONFIG: + snprintf(s, len, "Recording configuration file."); + break; + case MENU_ENUM_LABEL_FILE_BROWSER_CURSOR: + snprintf(s, len, "Database cursor file."); + break; + case MENU_ENUM_LABEL_FILE_CONFIG: + snprintf(s, len, "Configuration file."); + break; + case MENU_ENUM_LABEL_SCAN_THIS_DIRECTORY: + snprintf(s, len, + "Select this to scan the current directory \n" + "for content."); + break; + case MENU_ENUM_LABEL_USE_THIS_DIRECTORY: + snprintf(s, len, + "Select this to set this as the directory."); + break; + case MENU_ENUM_LABEL_CONTENT_DATABASE_DIRECTORY: + snprintf(s, len, + "Content Database Directory. \n" + " \n" + "Path to content database \n" + "directory."); + break; + case MENU_ENUM_LABEL_THUMBNAILS_DIRECTORY: + snprintf(s, len, + "Thumbnails Directory. \n" + " \n" + "To store thumbnail files."); + break; + case MENU_ENUM_LABEL_LIBRETRO_INFO_PATH: + snprintf(s, len, + "Core Info Directory. \n" + " \n" + "A directory for where to search \n" + "for libretro core information."); + break; + case MENU_ENUM_LABEL_PLAYLIST_DIRECTORY: + snprintf(s, len, + "Playlist Directory. \n" + " \n" + "Save all playlist files to this \n" + "directory."); + break; + case MENU_ENUM_LABEL_DUMMY_ON_CORE_SHUTDOWN: + snprintf(s, len, + "Some cores might have \n" + "a shutdown feature. \n" + " \n" + "If this option is left disabled, \n" + "selecting the shutdown procedure \n" + "would trigger RetroArch being shut \n" + "down. \n" + " \n" + "Enabling this option will load a \n" + "dummy core instead so that we remain \n" + "inside the menu and RetroArch won't \n" + "shutdown."); + break; + case MENU_ENUM_LABEL_CHECK_FOR_MISSING_FIRMWARE: + snprintf(s, len, + "Some cores might need \n" + "firmware or bios files. \n" + " \n" + "If this option is disabled, \n" + "it will try to load even if such \n" + "firmware is missing. \n"); + break; + case MENU_ENUM_LABEL_PARENT_DIRECTORY: + snprintf(s, len, + "Go back to the parent directory."); + break; + case MENU_ENUM_LABEL_FILE_BROWSER_SHADER_PRESET: + snprintf(s, len, + "Shader preset file."); + break; + case MENU_ENUM_LABEL_FILE_BROWSER_SHADER: + snprintf(s, len, + "Shader file."); + break; + case MENU_ENUM_LABEL_FILE_BROWSER_REMAP: + snprintf(s, len, + "Remap controls file."); + break; + case MENU_ENUM_LABEL_FILE_BROWSER_CHEAT: + snprintf(s, len, + "Cheat file."); + break; + case MENU_ENUM_LABEL_FILE_BROWSER_OVERLAY: + snprintf(s, len, + "Overlay file."); + break; + case MENU_ENUM_LABEL_FILE_BROWSER_RDB: + snprintf(s, len, + "Database file."); + break; + case MENU_ENUM_LABEL_FILE_BROWSER_FONT: + snprintf(s, len, + "TrueType font file."); + break; + case MENU_ENUM_LABEL_FILE_BROWSER_PLAIN_FILE: + snprintf(s, len, + "Plain file."); + break; + case MENU_ENUM_LABEL_FILE_BROWSER_MOVIE_OPEN: + snprintf(s, len, + "Video. \n" + " \n" + "Select it to open this file with the \n" + "video player."); + break; + case MENU_ENUM_LABEL_FILE_BROWSER_MUSIC_OPEN: + snprintf(s, len, + "Music. \n" + " \n" + "Select it to open this file with the \n" + "music player."); + break; + case MENU_ENUM_LABEL_FILE_BROWSER_IMAGE: + snprintf(s, len, + "Image file."); + break; + case MENU_ENUM_LABEL_FILE_BROWSER_IMAGE_OPEN_WITH_VIEWER: + snprintf(s, len, + "Image. \n" + " \n" + "Select it to open this file with the \n" + "image viewer."); + break; + case MENU_ENUM_LABEL_FILE_BROWSER_CORE_SELECT_FROM_COLLECTION: + snprintf(s, len, + "Libretro core. \n" + " \n" + "Selecting this will associate this core \n" + "to the game."); + break; + case MENU_ENUM_LABEL_FILE_BROWSER_CORE: + snprintf(s, len, + "Libretro core. \n" + " \n" + "Select this file to have RetroArch load this core."); + break; + case MENU_ENUM_LABEL_FILE_BROWSER_DIRECTORY: + snprintf(s, len, + "Directory. \n" + " \n" + "Select it to open this directory."); + break; + case MENU_ENUM_LABEL_CACHE_DIRECTORY: + snprintf(s, len, + "Cache Directory. \n" + " \n" + "Content decompressed by RetroArch will be \n" + "temporarily extracted to this directory."); + break; + case MENU_ENUM_LABEL_HISTORY_LIST_ENABLE: + snprintf(s, len, + "If enabled, every content loaded \n" + "in RetroArch will be automatically \n" + "added to the recent history list."); + break; + case MENU_ENUM_LABEL_RGUI_BROWSER_DIRECTORY: + snprintf(s, len, + "File Browser Directory. \n" + " \n" + "Sets start directory for menu file browser."); + break; + case MENU_ENUM_LABEL_INPUT_POLL_TYPE_BEHAVIOR: + snprintf(s, len, + "Influence how input polling is done inside \n" + "RetroArch. \n" + " \n" + "Early - Input polling is performed before \n" + "the frame is processed. \n" + "Normal - Input polling is performed when \n" + "polling is requested. \n" + "Late - Input polling is performed on \n" + "first input state request per frame.\n" + " \n" + "Setting it to 'Early' or 'Late' can result \n" + "in less latency, \n" + "depending on your configuration.\n\n" + "Will be ignored when using netplay." + ); + break; + case MENU_ENUM_LABEL_INPUT_DESCRIPTOR_HIDE_UNBOUND: + snprintf(s, len, + "Hide input descriptors that were not set \n" + "by the core."); + break; + case MENU_ENUM_LABEL_VIDEO_REFRESH_RATE: + snprintf(s, len, + "Video refresh rate of your monitor. \n" + "Used to calculate a suitable audio input rate."); + break; + case MENU_ENUM_LABEL_VIDEO_FORCE_SRGB_DISABLE: + snprintf(s, len, + "Forcibly disable sRGB FBO support. Some Intel \n" + "OpenGL drivers on Windows have video problems \n" + "with sRGB FBO support enabled."); + break; + case MENU_ENUM_LABEL_AUDIO_ENABLE: + snprintf(s, len, + "Enable audio output."); + break; + case MENU_ENUM_LABEL_AUDIO_SYNC: + snprintf(s, len, + "Synchronize audio (recommended)."); + break; + case MENU_ENUM_LABEL_AUDIO_LATENCY: + snprintf(s, len, + "Desired audio latency in milliseconds. \n" + "Might not be honored if the audio driver \n" + "can't provide given latency."); + break; + case MENU_ENUM_LABEL_VIDEO_ALLOW_ROTATE: + snprintf(s, len, + "Allow cores to set rotation. If false, \n" + "rotation requests are honored, but ignored.\n\n" + "Used for setups where one manually rotates \n" + "the monitor."); + break; + case MENU_ENUM_LABEL_INPUT_DESCRIPTOR_LABEL_SHOW: + snprintf(s, len, + "Show the input descriptors set by the core \n" + "instead of the default ones."); + break; + case MENU_ENUM_LABEL_CONTENT_HISTORY_SIZE: + snprintf(s, len, + "Number of entries that will be kept in \n" + "content history playlist."); + break; + case MENU_ENUM_LABEL_VIDEO_WINDOWED_FULLSCREEN: + snprintf(s, len, + "To use windowed mode or not when going \n" + "fullscreen."); + break; + case MENU_ENUM_LABEL_VIDEO_FONT_SIZE: + snprintf(s, len, + "Font size for on-screen messages."); + break; + case MENU_ENUM_LABEL_SAVESTATE_AUTO_INDEX: + snprintf(s, len, + "Automatically increment slot index on each save, \n" + "generating multiple savestate files. \n" + "When the content is loaded, state slot will be \n" + "set to the highest existing value (last savestate)."); + break; + case MENU_ENUM_LABEL_FPS_SHOW: + snprintf(s, len, + "Enables displaying the current frames \n" + "per second."); + break; + case MENU_ENUM_LABEL_VIDEO_FONT_ENABLE: + snprintf(s, len, + "Show and/or hide onscreen messages."); + break; + case MENU_ENUM_LABEL_VIDEO_MESSAGE_POS_X: + case MENU_ENUM_LABEL_VIDEO_MESSAGE_POS_Y: + snprintf(s, len, + "Offset for where messages will be placed \n" + "onscreen. Values are in range [0.0, 1.0]."); + break; + case MENU_ENUM_LABEL_INPUT_OVERLAY_ENABLE: + snprintf(s, len, + "Enable or disable the current overlay."); + break; + case MENU_ENUM_LABEL_INPUT_OVERLAY_HIDE_IN_MENU: + snprintf(s, len, + "Hide the current overlay from appearing \n" + "inside the menu."); + break; + case MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS: + snprintf(s, len, + "Show keyboard/controller button presses on \n" + "the onscreen overlay."); + break; + case MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS_PORT: + snprintf(s, len, + "Select the port to listen for controller input \n" + "to display on the onscreen overlay."); + break; + case MENU_ENUM_LABEL_OVERLAY_PRESET: + snprintf(s, len, + "Path to input overlay."); + break; + case MENU_ENUM_LABEL_OVERLAY_OPACITY: + snprintf(s, len, + "Overlay opacity."); + break; + case MENU_ENUM_LABEL_INPUT_BIND_TIMEOUT: + snprintf(s, len, + "Input bind timer timeout (in seconds). \n" + "Amount of seconds to wait until proceeding \n" + "to the next bind."); + break; + case MENU_ENUM_LABEL_OVERLAY_SCALE: + snprintf(s, len, + "Overlay scale."); + break; + case MENU_ENUM_LABEL_AUDIO_OUTPUT_RATE: + snprintf(s, len, + "Audio output samplerate."); + break; + case MENU_ENUM_LABEL_VIDEO_SHARED_CONTEXT: + snprintf(s, len, + "Set to true if hardware-rendered cores \n" + "should get their private context. \n" + "Avoids having to assume hardware state changes \n" + "inbetween frames." + ); + break; + case MENU_ENUM_LABEL_CORE_LIST: + snprintf(s, len, + "Load Core. \n" + " \n" + "Browse for a libretro core \n" + "implementation. Where the browser \n" + "starts depends on your Core Directory \n" + "path. If blank, it will start in root. \n" + " \n" + "If Core Directory is a directory, the menu \n" + "will use that as top folder. If Core \n" + "Directory is a full path, it will start \n" + "in the folder where the file is."); + break; + case MENU_ENUM_LABEL_VALUE_MENU_ENUM_CONTROLS_PROLOG: + snprintf(s, len, + "You can use the following controls below \n" + "on either your gamepad or keyboard in order\n" + "to control the menu: \n" + " \n" + ); + break; + case MENU_ENUM_LABEL_WELCOME_TO_RETROARCH: + snprintf(s, len, + "Welcome to RetroArch\n" + ); + break; + case MENU_ENUM_LABEL_VALUE_HELP_AUDIO_VIDEO_TROUBLESHOOTING_DESC: { + /* Work around C89 limitations */ + char u[501]; + const char *t = + "RetroArch relies on an unique form of\n" + "audio/video synchronization where it needs to be\n" + "calibrated against the refresh rate of your\n" + "display for best performance results.\n" + " \n" + "If you experience any audio crackling or video\n" + "tearing, usually it means that you need to\n" + "calibrate the settings. Some choices below:\n" + " \n"; + snprintf(u, sizeof(u), /* can't inline this due to the printf arguments */ + "a) Go to '%s' -> '%s', and enable\n" + "'Threaded Video'. Refresh rate will not matter\n" + "in this mode, framerate will be higher,\n" + "but video might be less smooth.\n" + "b) Go to '%s' -> '%s', and look at\n" + "'%s'. Let it run for\n" + "2048 frames, then press 'OK'.", + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SETTINGS), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SETTINGS), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SETTINGS), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SETTINGS), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_REFRESH_RATE_AUTO)); + strlcpy(s, t, len); + strlcat(s, u, len); + } + break; + case MENU_ENUM_LABEL_VALUE_HELP_SCANNING_CONTENT_DESC: + snprintf(s, len, + "To scan for content, go to '%s' and\n" + "select either '%s' or %s'.\n" + " \n" + "Files will be compared to database entries.\n" + "If there is a match, it will add an entry\n" + "to a collection.\n" + " \n" + "You can then easily access this content by\n" + "going to '%s' ->\n" + "'%s'\n" + "instead of having to go through the\n" + "filebrowser everytime.\n" + " \n" + "NOTE: Content for some cores might still not be\n" + "scannable.", + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_ADD_CONTENT_LIST), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SCAN_DIRECTORY), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SCAN_FILE), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_LOAD_CONTENT_LIST), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CONTENT_COLLECTION_LIST) + ); + break; + case MENU_ENUM_LABEL_VALUE_EXTRACTING_PLEASE_WAIT: + snprintf(s, len, + "Welcome to RetroArch\n" + "\n" + "Extracting assets, please wait.\n" + "This might take a while...\n" + ); + break; + case MENU_ENUM_LABEL_INPUT_DRIVER: + if (settings) + driver_hash = msg_hash_calculate(settings->arrays.input_driver); + + switch (driver_hash) { + case MENU_LABEL_INPUT_DRIVER_UDEV: + snprintf(s, len, + "udev Input driver. \n" + " \n" + "It uses the recent evdev joypad API \n" + "for joystick support. It supports \n" + "hotplugging and force feedback. \n" + " \n" + "The driver reads evdev events for keyboard \n" + "support. It also supports keyboard callback, \n" + "mice and touchpads. \n" + " \n" + "By default in most distros, /dev/input nodes \n" + "are root-only (mode 600). You can set up a udev \n" + "rule which makes these accessible to non-root." + ); + break; + case MENU_LABEL_INPUT_DRIVER_LINUXRAW: + snprintf(s, len, + "linuxraw Input driver. \n" + " \n" + "This driver requires an active TTY. Keyboard \n" + "events are read directly from the TTY which \n" + "makes it simpler, but not as flexible as udev. \n" "Mice, etc, are not supported at all. \n" + " \n" + "This driver uses the older joystick API \n" + "(/dev/input/js*)."); + break; + default: + snprintf(s, len, + "Input driver.\n" + " \n" + "Depending on video driver, it might \n" + "force a different input driver."); + break; + } + break; + case MENU_ENUM_LABEL_LOAD_CONTENT_LIST: + snprintf(s, len, + "Load Content. \n" + "Browse for content. \n" + " \n" + "To load content, you need a \n" + "'Core' to use, and a content file. \n" + " \n" + "To control where the menu starts \n" + "to browse for content, set \n" + "'File Browser Directory'. \n" + "If not set, it will start in root. \n" + " \n" + "The browser will filter out \n" + "extensions for the last core set \n" + "in 'Load Core', and use that core \n" + "when content is loaded." + ); + break; + case MENU_ENUM_LABEL_LOAD_CONTENT_HISTORY: + snprintf(s, len, + "Loading content from history. \n" + " \n" + "As content is loaded, content and libretro \n" + "core combinations are saved to history. \n" + " \n" + "The history is saved to a file in the same \n" + "directory as the RetroArch config file. If \n" + "no config file was loaded in startup, history \n" + "will not be saved or loaded, and will not exist \n" + "in the main menu." + ); + break; + case MENU_ENUM_LABEL_VIDEO_DRIVER: + snprintf(s, len, + "Current Video driver."); + + if (string_is_equal(settings->arrays.video_driver, "gl")) + { + snprintf(s, len, + "OpenGL Video driver. \n" + " \n" + "This driver allows libretro GL cores to \n" + "be used in addition to software-rendered \n" + "core implementations.\n" + " \n" + "Performance for software-rendered and \n" + "libretro GL core implementations is \n" + "dependent on your graphics card's \n" + "underlying GL driver)."); + } + else if (string_is_equal(settings->arrays.video_driver, "sdl2")) + { + snprintf(s, len, + "SDL 2 Video driver.\n" + " \n" + "This is an SDL 2 software-rendered video \n" + "driver.\n" + " \n" + "Performance for software-rendered libretro \n" + "core implementations is dependent \n" + "on your platform SDL implementation."); + } + else if (string_is_equal(settings->arrays.video_driver, "sdl1")) + { + snprintf(s, len, + "SDL Video driver.\n" + " \n" + "This is an SDL 1.2 software-rendered video \n" + "driver.\n" + " \n" + "Performance is considered to be suboptimal. \n" + "Consider using it only as a last resort."); + } + else if (string_is_equal(settings->arrays.video_driver, "d3d")) + { + snprintf(s, len, + "Direct3D Video driver. \n" + " \n" + "Performance for software-rendered cores \n" + "is dependent on your graphic card's \n" + "underlying D3D driver)."); + } + else if (string_is_equal(settings->arrays.video_driver, "exynos")) + { + snprintf(s, len, + "Exynos-G2D Video Driver. \n" + " \n" + "This is a low-level Exynos video driver. \n" + "Uses the G2D block in Samsung Exynos SoC \n" + "for blit operations. \n" + " \n" + "Performance for software rendered cores \n" + "should be optimal."); + } + else if (string_is_equal(settings->arrays.video_driver, "drm")) + { + snprintf(s, len, + "Plain DRM Video Driver. \n" + " \n" + "This is a low-level video driver using. \n" + "libdrm for hardware scaling using \n" + "GPU overlays."); + } + else if (string_is_equal(settings->arrays.video_driver, "sunxi")) + { + snprintf(s, len, + "Sunxi-G2D Video Driver. \n" + " \n" + "This is a low-level Sunxi video driver. \n" + "Uses the G2D block in Allwinner SoCs."); + } + break; + case MENU_ENUM_LABEL_AUDIO_DSP_PLUGIN: + snprintf(s, len, + "Audio DSP plugin.\n" + " Processes audio before it's sent to \n" + "the driver." + ); + break; + case MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER: + if (settings) + driver_hash = msg_hash_calculate(settings->arrays.audio_resampler); + + switch (driver_hash) { + case MENU_LABEL_AUDIO_RESAMPLER_DRIVER_SINC: + snprintf(s, len, + "Windowed SINC implementation."); + break; + case MENU_LABEL_AUDIO_RESAMPLER_DRIVER_CC: + snprintf(s, len, + "Convoluted Cosine implementation."); + break; + default: + if (string_is_empty(s)) + strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_INFORMATION_AVAILABLE), len); + break; + } + break; + case MENU_ENUM_LABEL_VIDEO_SHADER_PRESET: + snprintf(s, len, + "Load Shader Preset. \n" + " \n" + " Load a shader preset directly. \n" + "The menu shader menu is updated accordingly. \n" + " \n" + "If the CGP uses scaling methods which are not \n" + "simple, (i.e. source scaling, same scaling \n" + "factor for X/Y), the scaling factor displayed \n" + "in the menu might not be correct." + ); + break; + case MENU_ENUM_LABEL_VIDEO_SHADER_SCALE_PASS: + snprintf(s, len, + "Scale for this pass. \n" + " \n" + "The scale factor accumulates, i.e. 2x \n" + "for first pass and 2x for second pass \n" + "will give you a 4x total scale. \n" + " \n" + "If there is a scale factor for last \n" + "pass, the result is stretched to \n" + "screen with the filter specified in \n" + "'Default Filter'. \n" + " \n" + "If 'Don't Care' is set, either 1x \n" + "scale or stretch to fullscreen will \n" + "be used depending if it's not the last \n" + "pass or not." + ); + break; + case MENU_ENUM_LABEL_VIDEO_SHADER_NUM_PASSES: + snprintf(s, len, + "Shader Passes. \n" + " \n" + "RetroArch allows you to mix and match various \n" + "shaders with arbitrary shader passes, with \n" + "custom hardware filters and scale factors. \n" + " \n" + "This option specifies the number of shader \n" + "passes to use. If you set this to 0, and use \n" + "Apply Shader Changes, you use a 'blank' shader. \n" + " \n" + "The Default Filter option will affect the \n" + "stretching filter."); + break; + case MENU_ENUM_LABEL_VIDEO_SHADER_PARAMETERS: + snprintf(s, len, + "Shader Parameters. \n" + " \n" + "Modifies current shader directly. Will not be \n" + "saved to CGP/GLSLP preset file."); + break; + case MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_PARAMETERS: + snprintf(s, len, + "Shader Preset Parameters. \n" + " \n" + "Modifies shader preset currently in menu." + ); + break; + case MENU_ENUM_LABEL_VIDEO_SHADER_PASS: + snprintf(s, len, + "Path to shader. \n" + " \n" + "All shaders must be of the same \n" + "type (i.e. CG, GLSL or HLSL). \n" + " \n" + "Set Shader Directory to set where \n" + "the browser starts to look for \n" + "shaders." + ); + break; + case MENU_ENUM_LABEL_CONFIGURATION_SETTINGS: + snprintf(s, len, + "Determines how configuration files \n" + "are loaded and prioritized."); + break; + case MENU_ENUM_LABEL_CONFIG_SAVE_ON_EXIT: + snprintf(s, len, + "Saves config to disk on exit.\n" + "Useful for menu as settings can be\n" + "modified. Overwrites the config.\n" + " \n" + "#include's and comments are not \n" + "preserved. \n" + " \n" + "By design, the config file is \n" + "considered immutable as it is \n" + "likely maintained by the user, \n" + "and should not be overwritten \n" + "behind the user's back." +#if defined(RARCH_CONSOLE) || defined(RARCH_MOBILE) + "\nThis is not not the case on \n" + "consoles however, where \n" + "looking at the config file \n" + "manually isn't really an option." +#endif + ); + break; + case MENU_ENUM_LABEL_CONFIRM_ON_EXIT: + snprintf(s, len, "Are you sure you want to quit?"); + break; + case MENU_ENUM_LABEL_SHOW_HIDDEN_FILES: + snprintf(s, len, "Show hidden files\n" + "and folders."); + break; + case MENU_ENUM_LABEL_VIDEO_SHADER_FILTER_PASS: + snprintf(s, len, + "Hardware filter for this pass. \n" + " \n" + "If 'Don't Care' is set, 'Default \n" + "Filter' will be used." + ); + break; + case MENU_ENUM_LABEL_AUTOSAVE_INTERVAL: + snprintf(s, len, + "Autosaves the non-volatile SRAM \n" + "at a regular interval.\n" + " \n" + "This is disabled by default unless set \n" + "otherwise. The interval is measured in \n" + "seconds. \n" + " \n" + "A value of 0 disables autosave."); + break; + case MENU_ENUM_LABEL_INPUT_BIND_DEVICE_TYPE: + snprintf(s, len, + "Input Device Type. \n" + " \n" + "Picks which device type to use. This is \n" + "relevant for the libretro core itself." + ); + break; + case MENU_ENUM_LABEL_LIBRETRO_LOG_LEVEL: + snprintf(s, len, + "Sets log level for libretro cores \n" + "(GET_LOG_INTERFACE). \n" + " \n" + " If a log level issued by a libretro \n" + " core is below libretro_log level, it \n" + " is ignored.\n" + " \n" + " DEBUG logs are always ignored unless \n" + " verbose mode is activated (--verbose).\n" + " \n" + " DEBUG = 0\n" + " INFO = 1\n" + " WARN = 2\n" + " ERROR = 3" + ); + break; + case MENU_ENUM_LABEL_STATE_SLOT_INCREASE: + case MENU_ENUM_LABEL_STATE_SLOT_DECREASE: + snprintf(s, len, + "State slots.\n" + " \n" + " With slot set to 0, save state name is *.state \n" + " (or whatever defined on commandline).\n" + "When slot is != 0, path will be (path)(d), \n" + "where (d) is slot number."); + break; + case MENU_ENUM_LABEL_SHADER_APPLY_CHANGES: + snprintf(s, len, + "Apply Shader Changes. \n" + " \n" + "After changing shader settings, use this to \n" + "apply changes. \n" + " \n" + "Changing shader settings is a somewhat \n" + "expensive operation so it has to be \n" + "done explicitly. \n" + " \n" + "When you apply shaders, the menu shader \n" + "settings are saved to a temporary file (either \n" + "menu.cgp or menu.glslp) and loaded. The file \n" + "persists after RetroArch exits. The file is \n" + "saved to Shader Directory." + ); + break; + case MENU_ENUM_LABEL_SHADER_WATCH_FOR_CHANGES: + snprintf(s, len, + "Watch shader files for new changes. \n" + " \n" + "After saving changes to a shader on disk, \n" + "it will automatically be recompiled \n" + "and applied to the running content." + ); + break; + case MENU_ENUM_LABEL_MENU_TOGGLE: + snprintf(s, len, + "Toggles menu."); + break; + case MENU_ENUM_LABEL_GRAB_MOUSE_TOGGLE: + snprintf(s, len, + "Toggles mouse grab.\n" + " \n" + "When mouse is grabbed, RetroArch hides the \n" + "mouse, and keeps the mouse pointer inside \n" + "the window to allow relative mouse input to \n" + "work better."); + break; + case MENU_ENUM_LABEL_GAME_FOCUS_TOGGLE: + snprintf(s, len, + "Toggles game focus.\n" + " \n" + "When a game has focus, RetroArch will both disable \n" + "hotkeys and keep/warp the mouse pointer inside the window."); + break; + case MENU_ENUM_LABEL_DISK_NEXT: + snprintf(s, len, + "Cycles through disk images. Use after \n" + "ejecting. \n" + " \n" + " Complete by toggling eject again."); + break; + case MENU_ENUM_LABEL_VIDEO_FILTER: +#ifdef HAVE_FILTERS_BUILTIN + snprintf(s, len, + "CPU-based video filter."); +#else + snprintf(s, len, + "CPU-based video filter.\n" + " \n" + "Path to a dynamic library."); +#endif + break; + case MENU_ENUM_LABEL_AUDIO_DEVICE: + snprintf(s, len, + "Override the default audio device \n" + "the audio driver uses.\n" + "This is driver dependent. E.g.\n" +#ifdef HAVE_ALSA + " \n" + "ALSA wants a PCM device." +#endif +#ifdef HAVE_OSS + " \n" + "OSS wants a path (e.g. /dev/dsp)." +#endif +#ifdef HAVE_JACK + " \n" + "JACK wants portnames (e.g. system:playback1\n" + ",system:playback_2)." +#endif +#ifdef HAVE_RSOUND + " \n" + "RSound wants an IP address to an RSound \n" + "server." +#endif + ); + break; + case MENU_ENUM_LABEL_DISK_EJECT_TOGGLE: + snprintf(s, len, + "Toggles eject for disks.\n" + " \n" + "Used for multiple-disk content."); + break; + case MENU_ENUM_LABEL_ENABLE_HOTKEY: + snprintf(s, len, + "Enable other hotkeys.\n" + " \n" + " If this hotkey is bound to either keyboard, \n" + "joybutton or joyaxis, all other hotkeys will \n" + "be disabled unless this hotkey is also held \n" + "at the same time. \n" + " \n" + "This is useful for RETRO_KEYBOARD centric \n" + "implementations which query a large area of \n" + "the keyboard, where it is not desirable that \n" + "hotkeys get in the way."); + break; + case MENU_ENUM_LABEL_REWIND_ENABLE: + snprintf(s, len, + "Enable rewinding.\n" + " \n" + "This will take a performance hit, \n" + "so it is disabled by default."); + break; + case MENU_ENUM_LABEL_LIBRETRO_DIR_PATH: + snprintf(s, len, + "Core Directory. \n" + " \n" + "A directory for where to search for \n" + "libretro core implementations."); + break; + case MENU_ENUM_LABEL_VIDEO_REFRESH_RATE_AUTO: + snprintf(s, len, + "Refresh Rate Auto.\n" + " \n" + "The accurate refresh rate of our monitor (Hz).\n" + "This is used to calculate audio input rate with \n" + "the formula: \n" + " \n" + "audio_input_rate = game input rate * display \n" + "refresh rate / game refresh rate\n" + " \n" + "If the implementation does not report any \n" + "values, NTSC defaults will be assumed for \n" + "compatibility.\n" + " \n" + "This value should stay close to 60Hz to avoid \n" + "large pitch changes. If your monitor does \n" + "not run at 60Hz, or something close to it, \n" + "disable VSync, and leave this at its default."); + break; + case MENU_ENUM_LABEL_VIDEO_ROTATION: + snprintf(s, len, + "Forces a certain rotation \n" + "of the screen.\n" + " \n" + "The rotation is added to rotations which\n" + "the libretro core sets (see Video Allow\n" + "Rotate)."); + break; + case MENU_ENUM_LABEL_VIDEO_SCALE: + snprintf(s, len, + "Fullscreen resolution.\n" + " \n" + "Resolution of 0 uses the \n" + "resolution of the environment.\n"); + break; + case MENU_ENUM_LABEL_FASTFORWARD_RATIO: + snprintf(s, len, + "Fastforward ratio." + " \n" + "The maximum rate at which content will\n" + "be run when using fast forward.\n" + " \n" + " (E.g. 5.0 for 60 fps content => 300 fps \n" + "cap).\n" + " \n" + "RetroArch will go to sleep to ensure that \n" + "the maximum rate will not be exceeded.\n" + "Do not rely on this cap to be perfectly \n" + "accurate."); + break; + case MENU_ENUM_LABEL_VIDEO_MONITOR_INDEX: + snprintf(s, len, + "Which monitor to prefer.\n" + " \n" + "0 (default) means no particular monitor \n" + "is preferred, 1 and up (1 being first \n" + "monitor), suggests RetroArch to use that \n" + "particular monitor."); + break; + case MENU_ENUM_LABEL_VIDEO_CROP_OVERSCAN: + snprintf(s, len, + "Forces cropping of overscanned \n" + "frames.\n" + " \n" + "Exact behavior of this option is \n" + "core-implementation specific."); + break; + case MENU_ENUM_LABEL_VIDEO_SCALE_INTEGER: + snprintf(s, len, + "Only scales video in integer \n" + "steps.\n" + " \n" + "The base size depends on system-reported \n" + "geometry and aspect ratio.\n" + " \n" + "If Force Aspect is not set, X/Y will be \n" + "integer scaled independently."); + break; + case MENU_ENUM_LABEL_AUDIO_VOLUME: + snprintf(s, len, + "Audio volume, expressed in dB.\n" + " \n" + " 0 dB is normal volume. No gain will be applied.\n" + "Gain can be controlled in runtime with Input\n" + "Volume Up / Input Volume Down."); + break; + case MENU_ENUM_LABEL_AUDIO_RATE_CONTROL_DELTA: + snprintf(s, len, + "Audio rate control.\n" + " \n" + "Setting this to 0 disables rate control.\n" + "Any other value controls audio rate control \n" + "delta.\n" + " \n" + "Defines how much input rate can be adjusted \n" + "dynamically.\n" + " \n" + " Input rate is defined as: \n" + " input rate * (1.0 +/- (rate control delta))"); + break; + case MENU_ENUM_LABEL_AUDIO_MAX_TIMING_SKEW: + snprintf(s, len, + "Maximum audio timing skew.\n" + " \n" + "Defines the maximum change in input rate.\n" + "You may want to increase this to enable\n" + "very large changes in timing, for example\n" + "running PAL cores on NTSC displays, at the\n" + "cost of inaccurate audio pitch.\n" + " \n" + " Input rate is defined as: \n" + " input rate * (1.0 +/- (max timing skew))"); + break; + case MENU_ENUM_LABEL_OVERLAY_NEXT: + snprintf(s, len, + "Toggles to next overlay.\n" + " \n" + "Wraps around."); + break; + case MENU_ENUM_LABEL_LOG_VERBOSITY: + snprintf(s, len, + "Enable or disable verbosity level \n" + "of frontend."); + break; + case MENU_ENUM_LABEL_VOLUME_UP: + snprintf(s, len, + "Increases audio volume."); + break; + case MENU_ENUM_LABEL_VOLUME_DOWN: + snprintf(s, len, + "Decreases audio volume."); + break; + case MENU_ENUM_LABEL_VIDEO_DISABLE_COMPOSITION: + snprintf(s, len, + "Forcibly disable composition.\n" + "Only valid on Windows Vista/7 for now."); + break; + case MENU_ENUM_LABEL_PERFCNT_ENABLE: + snprintf(s, len, + "Enable or disable frontend \n" + "performance counters."); + break; + case MENU_ENUM_LABEL_SYSTEM_DIRECTORY: + snprintf(s, len, + "System Directory. \n" + " \n" + "Sets the 'system' directory.\n" + "Cores can query for this\n" + "directory to load BIOSes, \n" + "system-specific configs, etc."); + break; + case MENU_ENUM_LABEL_SAVESTATE_AUTO_SAVE: + case MENU_ENUM_LABEL_SAVESTATE_AUTO_LOAD: + snprintf(s, len, + "Automatically saves a savestate at the \n" + "end of RetroArch's lifetime.\n" + " \n" + "RetroArch will automatically load any savestate\n" + "with this path on startup if 'Auto Load State\n" + "is enabled."); + break; + case MENU_ENUM_LABEL_VIDEO_THREADED: + snprintf(s, len, + "Use threaded video driver.\n" + " \n" + "Using this might improve performance at the \n" + "possible cost of latency and more video \n" + "stuttering."); + break; + case MENU_ENUM_LABEL_VIDEO_VSYNC: + snprintf(s, len, + "Video V-Sync.\n"); + break; + case MENU_ENUM_LABEL_VIDEO_HARD_SYNC: + snprintf(s, len, + "Attempts to hard-synchronize \n" + "CPU and GPU.\n" + " \n" + "Can reduce latency at the cost of \n" + "performance."); + break; + case MENU_ENUM_LABEL_REWIND_GRANULARITY: + snprintf(s, len, + "Rewind granularity.\n" + " \n" + " When rewinding defined number of \n" + "frames, you can rewind several frames \n" + "at a time, increasing the rewinding \n" + "speed."); + break; + case MENU_ENUM_LABEL_SCREENSHOT: + snprintf(s, len, + "Take screenshot."); + break; + case MENU_ENUM_LABEL_VIDEO_FRAME_DELAY: + snprintf(s, len, + "Sets how many milliseconds to delay\n" + "after VSync before running the core.\n" + "\n" + "Can reduce latency at the cost of\n" + "higher risk of stuttering.\n" + " \n" + "Maximum is 15."); + break; + case MENU_ENUM_LABEL_VIDEO_HARD_SYNC_FRAMES: + snprintf(s, len, + "Sets how many frames CPU can \n" + "run ahead of GPU when using 'GPU \n" + "Hard Sync'.\n" + " \n" + "Maximum is 3.\n" + " \n" + " 0: Syncs to GPU immediately.\n" + " 1: Syncs to previous frame.\n" + " 2: Etc ..."); + break; + case MENU_ENUM_LABEL_VIDEO_BLACK_FRAME_INSERTION: + snprintf(s, len, + "Inserts a black frame inbetween \n" + "frames.\n" + " \n" + "Useful for 120 Hz monitors who want to \n" + "play 60 Hz material with eliminated \n" + "ghosting.\n" + " \n" + "Video refresh rate should still be \n" + "configured as if it is a 60 Hz monitor \n" + "(divide refresh rate by 2)."); + break; + case MENU_ENUM_LABEL_RGUI_SHOW_START_SCREEN: + snprintf(s, len, + "Show startup screen in menu.\n" + "Is automatically set to false when seen\n" + "for the first time.\n" + " \n" + "This is only updated in config if\n" + "'Save Configuration on Exit' is enabled.\n"); + break; + case MENU_ENUM_LABEL_VIDEO_FULLSCREEN: + snprintf(s, len, "Toggles fullscreen."); + break; + case MENU_ENUM_LABEL_BLOCK_SRAM_OVERWRITE: + snprintf(s, len, + "Block SRAM from being overwritten \n" + "when loading save states.\n" + " \n" + "Might potentially lead to buggy games."); + break; + case MENU_ENUM_LABEL_PAUSE_NONACTIVE: + snprintf(s, len, + "Pause gameplay when window focus \n" + "is lost."); + break; + case MENU_ENUM_LABEL_VIDEO_GPU_SCREENSHOT: + snprintf(s, len, + "Screenshots output of GPU shaded \n" + "material if available."); + break; + case MENU_ENUM_LABEL_SCREENSHOT_DIRECTORY: + snprintf(s, len, + "Screenshot Directory. \n" + " \n" + "Directory to dump screenshots to." + ); + break; + case MENU_ENUM_LABEL_VIDEO_SWAP_INTERVAL: + snprintf(s, len, + "VSync Swap Interval.\n" + " \n" + "Uses a custom swap interval for VSync. Set this \n" + "to effectively halve monitor refresh rate."); + break; + case MENU_ENUM_LABEL_SAVEFILE_DIRECTORY: + snprintf(s, len, + "Savefile Directory. \n" + " \n" + "Save all save files (*.srm) to this \n" + "directory. This includes related files like \n" + ".bsv, .rt, .psrm, etc...\n" + " \n" + "This will be overridden by explicit command line\n" + "options."); + break; + case MENU_ENUM_LABEL_SAVESTATE_DIRECTORY: + snprintf(s, len, + "Savestate Directory. \n" + " \n" + "Save all save states (*.state) to this \n" + "directory.\n" + " \n" + "This will be overridden by explicit command line\n" + "options."); + break; + case MENU_ENUM_LABEL_ASSETS_DIRECTORY: + snprintf(s, len, + "Assets Directory. \n" + " \n" + " This location is queried by default when \n" + "menu interfaces try to look for loadable \n" + "assets, etc."); + break; + case MENU_ENUM_LABEL_DYNAMIC_WALLPAPERS_DIRECTORY: + snprintf(s, len, + "Dynamic Wallpapers Directory. \n" + " \n" + " The place to store backgrounds that will \n" + "be loaded dynamically by the menu depending \n" + "on context."); + break; + case MENU_ENUM_LABEL_SLOWMOTION_RATIO: + snprintf(s, len, + "Slowmotion ratio." + " \n" + "When slowmotion, content will slow\n" + "down by factor."); + break; + case MENU_ENUM_LABEL_INPUT_AXIS_THRESHOLD: + snprintf(s, len, + "Defines axis threshold.\n" + " \n" + "How far an axis must be tilted to result\n" + "in a button press.\n" + " Possible values are [0.0, 1.0]."); + break; + case MENU_ENUM_LABEL_INPUT_TURBO_PERIOD: + snprintf(s, len, + "Turbo period.\n" + " \n" + "Describes the period of which turbo-enabled\n" + "buttons toggle.\n" + " \n" + "Numbers are described in frames." + ); + break; + case MENU_ENUM_LABEL_INPUT_DUTY_CYCLE: + snprintf(s, len, + "Duty cycle.\n" + " \n" + "Describes how long the period of a turbo-enabled\n" + "should be.\n" + " \n" + "Numbers are described in frames." + ); + break; + case MENU_ENUM_LABEL_INPUT_TOUCH_ENABLE: + snprintf(s, len, "Enable touch support."); + break; + case MENU_ENUM_LABEL_INPUT_PREFER_FRONT_TOUCH: + snprintf(s, len, "Use front instead of back touch."); + break; + case MENU_ENUM_LABEL_MOUSE_ENABLE: + snprintf(s, len, "Enable mouse input inside the menu."); + break; + case MENU_ENUM_LABEL_POINTER_ENABLE: + snprintf(s, len, "Enable touch input inside the menu."); + break; + case MENU_ENUM_LABEL_MENU_WALLPAPER: + snprintf(s, len, "Path to an image to set as the background."); + break; + case MENU_ENUM_LABEL_NAVIGATION_WRAPAROUND: + snprintf(s, len, + "Wrap-around to beginning and/or end \n" + "if boundary of list is reached \n" + "horizontally and/or vertically."); + break; + case MENU_ENUM_LABEL_PAUSE_LIBRETRO: + snprintf(s, len, + "If disabled, the game will keep \n" + "running in the background when we are in the \n" + "menu."); + break; + case MENU_ENUM_LABEL_SUSPEND_SCREENSAVER_ENABLE: + snprintf(s, len, + "Suspends the screensaver. Is a hint that \n" + "does not necessarily have to be \n" + "honored by the video driver."); + break; + case MENU_ENUM_LABEL_NETPLAY_MODE: + snprintf(s, len, + "Netplay client mode for the current user. \n" + "Will be 'Server' mode if disabled."); + break; + case MENU_ENUM_LABEL_NETPLAY_DELAY_FRAMES: + snprintf(s, len, + "The amount of delay frames to use for netplay. \n" + " \n" + "Increasing this value will increase \n" + "performance, but introduce more latency."); + break; + case MENU_ENUM_LABEL_NETPLAY_PUBLIC_ANNOUNCE: + snprintf(s, len, + "Whether to announce netplay games publicly. \n" + " \n" + "If set to false, clients must manually connect \n" + "rather than using the public lobby."); + break; + case MENU_ENUM_LABEL_NETPLAY_START_AS_SPECTATOR: + snprintf(s, len, + "Whether to start netplay in spectator mode. \n" + " \n" + "If set to true, netplay will be in spectator mode \n" + "on start. It's always possible to change mode \n" + "later."); + break; + case MENU_ENUM_LABEL_NETPLAY_ALLOW_SLAVES: + snprintf(s, len, + "Whether to allow connections in slave mode. \n" + " \n" + "Slave-mode clients require very little processing \n" + "power on either side, but will suffer \n" + "significantly from network latency."); + break; + case MENU_ENUM_LABEL_NETPLAY_REQUIRE_SLAVES: + snprintf(s, len, + "Whether to disallow connections not in slave mode. \n" + " \n" + "Not recommended except for very fast networks \n" + "with very weak machines. \n"); + break; + case MENU_ENUM_LABEL_NETPLAY_STATELESS_MODE: + snprintf(s, len, + "Whether to run netplay in a mode not requiring\n" + "save states. \n" + " \n" + "If set to true, a very fast network is required,\n" + "but no rewinding is performed, so there will be\n" + "no netplay jitter.\n"); + break; + case MENU_ENUM_LABEL_NETPLAY_CHECK_FRAMES: + snprintf(s, len, + "The frequency in frames with which netplay \n" + "will verify that the host and client are in \n" + "sync. \n" + " \n" + "With most cores, this value will have no \n" + "visible effect and can be ignored. With \n" + "nondeterminstic cores, this value determines \n" + "how often the netplay peers will be brought \n" + "into sync. With buggy cores, setting this \n" + "to any non-zero value will cause severe \n" + "performance issues. Set to zero to perform \n" + "no checks. This value is only used on the \n" + "netplay host. \n"); + break; + case MENU_ENUM_LABEL_NETPLAY_INPUT_LATENCY_FRAMES_MIN: + snprintf(s, len, + "The number of frames of input latency for \n" + "netplay to use to hide network latency. \n" + " \n" + "When in netplay, this option delays local \n" + "input, so that the frame being run is \n" + "closer to the frames being received from \n" + "the network. This reduces jitter and makes \n" + "netplay less CPU-intensive, but at the \n" + "price of noticeable input lag. \n"); + break; + case MENU_ENUM_LABEL_NETPLAY_INPUT_LATENCY_FRAMES_RANGE: + snprintf(s, len, + "The range of frames of input latency that \n" + "may be used by netplay to hide network \n" + "latency. \n" + "\n" + "If set, netplay will adjust the number of \n" + "frames of input latency dynamically to \n" + "balance CPU time, input latency and \n" + "network latency. This reduces jitter and \n" + "makes netplay less CPU-intensive, but at \n" + "the price of unpredictable input lag. \n"); + break; + case MENU_ENUM_LABEL_NETPLAY_NAT_TRAVERSAL: + snprintf(s, len, + "When hosting, attempt to listen for\n" + "connections from the public internet, using\n" + "UPnP or similar technologies to escape LANs. \n"); + break; + case MENU_ENUM_LABEL_NETPLAY_USE_MITM_SERVER: + snprintf(s, len, + "When hosting a netplay session, relay connection through a \n" + "man-in-the-middle server \n" + "to get around firewalls or NAT/UPnP issues. \n"); + break; + case MENU_ENUM_LABEL_NETPLAY_MITM_SERVER: + snprintf(s, len, + "Specifies the man-in-the-middle server \n" + "to use for netplay. A server that is \n" + "located closer to you may have less latency. \n"); + break; + case MENU_ENUM_LABEL_VIDEO_MAX_SWAPCHAIN_IMAGES: + snprintf(s, len, + "Maximum amount of swapchain images. This \n" + "can tell the video driver to use a specific \n" + "video buffering mode. \n" + " \n" + "Single buffering - 1\n" + "Double buffering - 2\n" + "Triple buffering - 3\n" + " \n" + "Setting the right buffering mode can have \n" + "a big impact on latency."); + break; + case MENU_ENUM_LABEL_VIDEO_SMOOTH: + snprintf(s, len, + "Smoothens picture with bilinear filtering. \n" + "Should be disabled if using shaders."); + break; + case MENU_ENUM_LABEL_TIMEDATE_ENABLE: + snprintf(s, len, + "Shows current date and/or time inside menu."); + break; + case MENU_ENUM_LABEL_BATTERY_LEVEL_ENABLE: + snprintf(s, len, + "Shows current battery level inside menu."); + break; + case MENU_ENUM_LABEL_CORE_ENABLE: + snprintf(s, len, + "Shows current core inside menu."); + break; + case MENU_ENUM_LABEL_NETPLAY_ENABLE_HOST: + snprintf(s, len, + "Enables Netplay in host (server) mode."); + break; + case MENU_ENUM_LABEL_NETPLAY_ENABLE_CLIENT: + snprintf(s, len, + "Enables Netplay in client mode."); + break; + case MENU_ENUM_LABEL_NETPLAY_DISCONNECT: + snprintf(s, len, + "Disconnects an active Netplay connection."); + break; + case MENU_ENUM_LABEL_NETPLAY_LAN_SCAN_SETTINGS: + snprintf(s, len, + "Search for and connect to netplay hosts on the local network."); + break; + case MENU_ENUM_LABEL_NETPLAY_SETTINGS: + snprintf(s, len, + "Setting related to Netplay."); + break; + case MENU_ENUM_LABEL_DYNAMIC_WALLPAPER: + snprintf(s, len, + "Dynamically load a new background \n" + "depending on context."); + break; + case MENU_ENUM_LABEL_CORE_UPDATER_BUILDBOT_URL: + snprintf(s, len, + "URL to core updater directory on the \n" + "Libretro buildbot."); + break; + case MENU_ENUM_LABEL_BUILDBOT_ASSETS_URL: + snprintf(s, len, + "URL to assets updater directory on the \n" + "Libretro buildbot."); + break; + case MENU_ENUM_LABEL_INPUT_REMAP_BINDS_ENABLE: + snprintf(s, len, + "if enabled, overrides the input binds \n" + "with the remapped binds set for the \n" + "current core."); + break; + case MENU_ENUM_LABEL_OVERLAY_DIRECTORY: + snprintf(s, len, + "Overlay Directory. \n" + " \n" + "Defines a directory where overlays are \n" + "kept for easy access."); + break; + case MENU_ENUM_LABEL_INPUT_MAX_USERS: + snprintf(s, len, + "Maximum amount of users supported by \n" + "RetroArch."); + break; + case MENU_ENUM_LABEL_CORE_UPDATER_AUTO_EXTRACT_ARCHIVE: + snprintf(s, len, + "After downloading, automatically extract \n" + "archives that the downloads are contained \n" + "inside."); + break; + case MENU_ENUM_LABEL_NAVIGATION_BROWSER_FILTER_SUPPORTED_EXTENSIONS_ENABLE: + snprintf(s, len, + "Filter files being shown by \n" + "supported extensions."); + break; + case MENU_ENUM_LABEL_NETPLAY_NICKNAME: + snprintf(s, len, + "The username of the person running RetroArch. \n" + "This will be used for playing online games."); + break; + case MENU_ENUM_LABEL_NETPLAY_TCP_UDP_PORT: + snprintf(s, len, + "The port of the host IP address. \n" + "Can be either a TCP or UDP port."); + break; + case MENU_ENUM_LABEL_NETPLAY_SPECTATOR_MODE_ENABLE: + snprintf(s, len, + "Enable or disable spectator mode for \n" + "the user during netplay."); + break; + case MENU_ENUM_LABEL_NETPLAY_IP_ADDRESS: + snprintf(s, len, + "The address of the host to connect to."); + break; + case MENU_ENUM_LABEL_NETPLAY_PASSWORD: + snprintf(s, len, + "The password for connecting to the netplay \n" + "host. Used only in host mode."); + break; + case MENU_ENUM_LABEL_NETPLAY_SPECTATE_PASSWORD: + snprintf(s, len, + "The password for connecting to the netplay \n" + "host with only spectator privileges. Used \n" + "only in host mode."); + break; + case MENU_ENUM_LABEL_STDIN_CMD_ENABLE: + snprintf(s, len, + "Enable stdin command interface."); + break; + case MENU_ENUM_LABEL_UI_COMPANION_START_ON_BOOT: + snprintf(s, len, + "Start User Interface companion driver \n" + "on boot (if available)."); + break; + case MENU_ENUM_LABEL_MENU_DRIVER: + snprintf(s, len, "Menu driver to use."); + break; + case MENU_ENUM_LABEL_INPUT_MENU_ENUM_TOGGLE_GAMEPAD_COMBO: + snprintf(s, len, + "Gamepad button combination to toggle menu. \n" + " \n" + "0 - None \n" + "1 - Press L + R + Y + D-Pad Down \n" + "simultaneously. \n" + "2 - Press L3 + R3 simultaneously. \n" + "3 - Press Start + Select simultaneously."); + break; + case MENU_ENUM_LABEL_INPUT_ALL_USERS_CONTROL_MENU: + snprintf(s, len, "Allows any user to control the menu. \n" + " \n" + "When disabled, only user 1 can control the menu."); + break; + case MENU_ENUM_LABEL_INPUT_AUTODETECT_ENABLE: + snprintf(s, len, + "Enable input auto-detection.\n" + " \n" + "Will attempt to auto-configure \n" + "joypads, Plug-and-Play style."); + break; + case MENU_ENUM_LABEL_CAMERA_ALLOW: + snprintf(s, len, + "Allow or disallow camera access by \n" + "cores."); + break; + case MENU_ENUM_LABEL_LOCATION_ALLOW: + snprintf(s, len, + "Allow or disallow location services \n" + "access by cores."); + break; + case MENU_ENUM_LABEL_TURBO: + snprintf(s, len, + "Turbo enable.\n" + " \n" + "Holding the turbo while pressing another \n" + "button will let the button enter a turbo \n" + "mode where the button state is modulated \n" + "with a periodic signal. \n" + " \n" + "The modulation stops when the button \n" + "itself (not turbo button) is released."); + break; + case MENU_ENUM_LABEL_OSK_ENABLE: + snprintf(s, len, + "Enable/disable on-screen keyboard."); + break; + case MENU_ENUM_LABEL_AUDIO_MUTE: + snprintf(s, len, + "Mute/unmute audio."); + break; + case MENU_ENUM_LABEL_REWIND: + snprintf(s, len, + "Hold button down to rewind.\n" + " \n" + "Rewind must be enabled."); + break; + case MENU_ENUM_LABEL_EXIT_EMULATOR: + snprintf(s, len, + "Key to exit RetroArch cleanly." +#if !defined(RARCH_MOBILE) && !defined(RARCH_CONSOLE) + "\nKilling it in any hard way (SIGKILL, \n" + "etc) will terminate without saving\n" + "RAM, etc. On Unix-likes,\n" + "SIGINT/SIGTERM allows\n" + "a clean deinitialization." +#endif + ); + break; + case MENU_ENUM_LABEL_LOAD_STATE: + snprintf(s, len, + "Loads state."); + break; + case MENU_ENUM_LABEL_SAVE_STATE: + snprintf(s, len, + "Saves state."); + break; + case MENU_ENUM_LABEL_NETPLAY_GAME_WATCH: + snprintf(s, len, + "Netplay toggle play/spectate mode."); + break; + case MENU_ENUM_LABEL_CHEAT_INDEX_PLUS: + snprintf(s, len, + "Increment cheat index.\n"); + break; + case MENU_ENUM_LABEL_CHEAT_INDEX_MINUS: + snprintf(s, len, + "Decrement cheat index.\n"); + break; + case MENU_ENUM_LABEL_SHADER_PREV: + snprintf(s, len, + "Applies previous shader in directory."); + break; + case MENU_ENUM_LABEL_SHADER_NEXT: + snprintf(s, len, + "Applies next shader in directory."); + break; + case MENU_ENUM_LABEL_RESET: + snprintf(s, len, + "Reset the content.\n"); + break; + case MENU_ENUM_LABEL_PAUSE_TOGGLE: + snprintf(s, len, + "Toggle between paused and non-paused state."); + break; + case MENU_ENUM_LABEL_CHEAT_TOGGLE: + snprintf(s, len, + "Toggle cheat index.\n"); + break; + case MENU_ENUM_LABEL_HOLD_FAST_FORWARD: + snprintf(s, len, + "Hold for fast-forward. Releasing button \n" + "disables fast-forward."); + break; + case MENU_ENUM_LABEL_SLOWMOTION: + snprintf(s, len, + "Hold for slowmotion."); + break; + case MENU_ENUM_LABEL_FRAME_ADVANCE: + snprintf(s, len, + "Frame advance when content is paused."); + break; + case MENU_ENUM_LABEL_MOVIE_RECORD_TOGGLE: + snprintf(s, len, + "Toggle between recording and not."); + break; + case MENU_ENUM_LABEL_L_X_PLUS: + case MENU_ENUM_LABEL_L_X_MINUS: + case MENU_ENUM_LABEL_L_Y_PLUS: + case MENU_ENUM_LABEL_L_Y_MINUS: + case MENU_ENUM_LABEL_R_X_PLUS: + case MENU_ENUM_LABEL_R_X_MINUS: + case MENU_ENUM_LABEL_R_Y_PLUS: + case MENU_ENUM_LABEL_R_Y_MINUS: + snprintf(s, len, + "Axis for analog stick (DualShock-esque).\n" + " \n" + "Bound as usual, however, if a real analog \n" + "axis is bound, it can be read as a true analog.\n" + " \n" + "Positive X axis is right. \n" + "Positive Y axis is down."); + break; + case MENU_ENUM_LABEL_VALUE_WHAT_IS_A_CORE_DESC: + snprintf(s, len, + "RetroArch by itself does nothing. \n" + " \n" + "To make it do things, you need to \n" + "load a program into it. \n" + "\n" + "We call such a program 'Libretro core', \n" + "or 'core' in short. \n" + " \n" + "To load a core, select one from\n" + "'Load Core'.\n" + " \n" +#ifdef HAVE_NETWORKING + "You can obtain cores in several ways: \n" + "* Download them by going to\n" + "'%s' -> '%s'.\n" + "* Manually move them over to\n" + "'%s'.", + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_ONLINE_UPDATER), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_UPDATER_LIST), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_LIBRETRO_DIR_PATH) +#else + "You can obtain cores by\n" + "manually moving them over to\n" + "'%s'.", + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_LIBRETRO_DIR_PATH) +#endif + ); + break; + case MENU_ENUM_LABEL_VALUE_HELP_CHANGE_VIRTUAL_GAMEPAD_DESC: + snprintf(s, len, + "You can change the virtual gamepad overlay\n" + "by going to '%s' -> '%s'." + " \n" + "From there you can change the overlay,\n" + "change the size and opacity of the buttons, etc.\n" + " \n" + "NOTE: By default, virtual gamepad overlays are\n" + "hidden when in the menu.\n" + "If you'd like to change this behavior,\n" + "you can set '%s' to false.", + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SETTINGS), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OVERLAY_SETTINGS), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_INPUT_OVERLAY_HIDE_IN_MENU) + ); + break; + case MENU_ENUM_LABEL_VALUE_VIDEO_MESSAGE_BGCOLOR_ENABLE: + snprintf(s, len, + "Enables a background color for the OSD."); + break; + case MENU_ENUM_LABEL_VALUE_VIDEO_MESSAGE_BGCOLOR_RED: + snprintf(s, len, + "Sets the red value of the OSD background color. Valid values are between 0 and 255."); + break; + case MENU_ENUM_LABEL_VALUE_VIDEO_MESSAGE_BGCOLOR_GREEN: + snprintf(s, len, + "Sets the green value of the OSD background color. Valid values are between 0 and 255."); + break; + case MENU_ENUM_LABEL_VALUE_VIDEO_MESSAGE_BGCOLOR_BLUE: + snprintf(s, len, + "Sets the blue value of the OSD background color. Valid values are between 0 and 255."); + break; + case MENU_ENUM_LABEL_VALUE_VIDEO_MESSAGE_BGCOLOR_OPACITY: + snprintf(s, len, + "Sets the opacity of the OSD background color. Valid values are between 0.0 and 1.0."); + break; + case MENU_ENUM_LABEL_VALUE_VIDEO_MESSAGE_COLOR_RED: + snprintf(s, len, + "Sets the red value of the OSD text color. Valid values are between 0 and 255."); + break; + case MENU_ENUM_LABEL_VALUE_VIDEO_MESSAGE_COLOR_GREEN: + snprintf(s, len, + "Sets the green value of the OSD text color. Valid values are between 0 and 255."); + break; + case MENU_ENUM_LABEL_VALUE_VIDEO_MESSAGE_COLOR_BLUE: + snprintf(s, len, + "Sets the blue value of the OSD text color. Valid values are between 0 and 255."); + break; + default: + if (string_is_empty(s)) + strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_INFORMATION_AVAILABLE), len); + return -1; + } + + return 0; +} + +#ifdef HAVE_MENU +static const char *menu_hash_to_str_ar_label_enum(enum msg_hash_enums msg) +{ + if (msg <= MENU_ENUM_LABEL_INPUT_HOTKEY_BIND_END && + msg >= MENU_ENUM_LABEL_INPUT_HOTKEY_BIND_BEGIN) + { + static char hotkey_lbl[128] = {0}; + unsigned idx = msg - MENU_ENUM_LABEL_INPUT_HOTKEY_BIND_BEGIN; + snprintf(hotkey_lbl, sizeof(hotkey_lbl), "input_hotkey_binds_%d", idx); + return hotkey_lbl; + } + + switch (msg) + { +#include "msg_hash_lbl.h" + default: +#if 0 + RARCH_LOG("Unimplemented: [%d]\n", msg); +#endif + break; + } + + return "null"; +} +#endif + +const char *msg_hash_to_str_ar(enum msg_hash_enums msg) { +#ifdef HAVE_MENU + const char *ret = menu_hash_to_str_ar_label_enum(msg); + + if (ret && !string_is_equal(ret, "null")) + return ret; +#endif + + switch (msg) { +#include "msg_hash_ar.h" + default: +#if 0 + RARCH_LOG("Unimplemented: [%d]\n", msg); + { + RARCH_LOG("[%d] : %s\n", msg - 1, msg_hash_to_str(((enum msg_hash_enums)(msg - 1)))); + } +#endif + break; + } + + return "null"; +} diff --git a/intl/msg_hash_ar.h b/intl/msg_hash_ar.h new file mode 100644 index 0000000000..1c8028c465 --- /dev/null +++ b/intl/msg_hash_ar.h @@ -0,0 +1,3417 @@ +MSG_HASH( + MSG_COMPILER, + "Compiler" + ) +MSG_HASH( + MSG_UNKNOWN_COMPILER, + "Unknown compiler" + ) +MSG_HASH( + MSG_DEVICE_DISCONNECTED_FROM_PORT, + "Device disconnected from port" + ) +MSG_HASH( + MSG_UNKNOWN_NETPLAY_COMMAND_RECEIVED, + "Unknown netplay command received" + ) +MSG_HASH( + MSG_FILE_ALREADY_EXISTS_SAVING_TO_BACKUP_BUFFER, + "File already exists. Saving to backup buffer" + ) +MSG_HASH( + MSG_GOT_CONNECTION_FROM, + "Got connection from: \"%s\"" + ) +MSG_HASH( + MSG_GOT_CONNECTION_FROM_NAME, + "Got connection from: \"%s (%s)\"" + ) +MSG_HASH( + MSG_PUBLIC_ADDRESS, + "Public address" + ) +MSG_HASH( + MSG_NO_ARGUMENTS_SUPPLIED_AND_NO_MENU_BUILTIN, + "No arguments supplied and no menu builtin, displaying help..." + ) +MSG_HASH( + MSG_SETTING_DISK_IN_TRAY, + "Setting disk in tray" + ) +MSG_HASH( + MSG_WAITING_FOR_CLIENT, + "Waiting for client ..." + ) +MSG_HASH( + MSG_NETPLAY_YOU_HAVE_LEFT_THE_GAME, + "You have left the game" + ) +MSG_HASH( + MSG_NETPLAY_YOU_HAVE_JOINED_AS_PLAYER_N, + "You have joined as player %u" + ) +MSG_HASH( + MSG_NETPLAY_YOU_HAVE_JOINED_WITH_INPUT_DEVICES_S, + "You have joined with input devices %.*s" + ) +MSG_HASH( + MSG_NETPLAY_PLAYER_S_LEFT, + "Player %.*s has left the game" + ) +MSG_HASH( + MSG_NETPLAY_S_HAS_JOINED_AS_PLAYER_N, + "%2$.*1$s has joined as player %3$u" + ) +MSG_HASH( + MSG_NETPLAY_S_HAS_JOINED_WITH_INPUT_DEVICES_S, + "%2$.*1$s has joined with input devices %4$.*3$s" + ) +MSG_HASH( + MSG_NETPLAY_NOT_RETROARCH, + "A netplay connection attempt failed because the peer is not running RetroArch, or is running an old version of RetroArch." + ) +MSG_HASH( + MSG_NETPLAY_OUT_OF_DATE, + "The netplay peer is running an old version of RetroArch. Cannot connect." + ) +MSG_HASH( + MSG_NETPLAY_DIFFERENT_VERSIONS, + "WARNING: A netplay peer is running a different version of RetroArch. If problems occur, use the same version." + ) +MSG_HASH( + MSG_NETPLAY_DIFFERENT_CORES, + "A netplay peer is running a different core. Cannot connect." + ) +MSG_HASH( + MSG_NETPLAY_DIFFERENT_CORE_VERSIONS, + "WARNING: A netlpay peer is running a different version of the core. If problems occur, use the same version." + ) +MSG_HASH( + MSG_NETPLAY_ENDIAN_DEPENDENT, + "This core does not support inter-architecture netplay between these systems" + ) +MSG_HASH( + MSG_NETPLAY_PLATFORM_DEPENDENT, + "This core does not support inter-architecture netplay" + ) +MSG_HASH( + MSG_NETPLAY_ENTER_PASSWORD, + "Enter netplay server password:" + ) +MSG_HASH( + MSG_NETPLAY_INCORRECT_PASSWORD, + "Incorrect password" + ) +MSG_HASH( + MSG_NETPLAY_SERVER_NAMED_HANGUP, + "\"%s\" has disconnected" + ) +MSG_HASH( + MSG_NETPLAY_SERVER_HANGUP, + "A netplay client has disconnected" + ) +MSG_HASH( + MSG_NETPLAY_CLIENT_HANGUP, + "Netplay disconnected" + ) +MSG_HASH( + MSG_NETPLAY_CANNOT_PLAY_UNPRIVILEGED, + "You do not have permission to play" + ) +MSG_HASH( + MSG_NETPLAY_CANNOT_PLAY_NO_SLOTS, + "There are no free player slots" + ) +MSG_HASH( + MSG_NETPLAY_CANNOT_PLAY_NOT_AVAILABLE, + "The input devices requested are not available" + ) +MSG_HASH( + MSG_NETPLAY_CANNOT_PLAY, + "Cannot switch to play mode" + ) +MSG_HASH( + MSG_NETPLAY_PEER_PAUSED, + "Netplay peer \"%s\" paused" + ) +MSG_HASH( + MSG_NETPLAY_CHANGED_NICK, + "Your nickname changed to \"%s\"" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_SHARED_CONTEXT, + "Give hardware-rendered cores their own private context. Avoids having to assume hardware state changes inbetween frames." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_MENU_SETTINGS, + "Adjusts menu screen appearance settings." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_HARD_SYNC, + "Hard-synchronize the CPU and GPU. Reduces latency at the cost of performance." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_THREADED, + "Improves performance at the cost of latency and more video stuttering. Use only if you cannot obtain full speed otherwise." + ) +MSG_HASH( + MSG_AUDIO_VOLUME, + "Audio volume" + ) +MSG_HASH( + MSG_AUTODETECT, + "Autodetect" + ) +MSG_HASH( + MSG_AUTOLOADING_SAVESTATE_FROM, + "Auto-loading savestate from" + ) +MSG_HASH( + MSG_CAPABILITIES, + "Capabilities" + ) +MSG_HASH( + MSG_CONNECTING_TO_NETPLAY_HOST, + "Connecting to netplay host" + ) +MSG_HASH( + MSG_CONNECTING_TO_PORT, + "Connecting to port" + ) +MSG_HASH( + MSG_CONNECTION_SLOT, + "Connection slot" + ) +MSG_HASH( + MSG_SORRY_UNIMPLEMENTED_CORES_DONT_DEMAND_CONTENT_NETPLAY, + "Sorry, unimplemented: cores that don't demand content cannot participate in netplay." + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_ACCOUNTS_CHEEVOS_PASSWORD, + "Password" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_ACCOUNTS_CHEEVOS_SETTINGS, + "Accounts Cheevos" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_ACCOUNTS_CHEEVOS_USERNAME, + "Username" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_ACCOUNTS_LIST, + "Accounts" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_ACCOUNTS_LIST_END, + "Accounts List Endpoint" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_ACCOUNTS_RETRO_ACHIEVEMENTS, + "RetroAchievements" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_ACHIEVEMENT_LIST, + "Achievement List" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_ACHIEVEMENT_LIST_HARDCORE, + "Achievement List (Hardcore)" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_ADD_CONTENT_LIST, + "Scan Content" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CONFIGURATIONS_LIST, + "ملفات التكوين" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_ADD_TAB, + "Import content" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_NETPLAY_TAB, + "Netplay Rooms" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_ASK_ARCHIVE, + "Ask" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_ASSETS_DIRECTORY, + "Assets" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_AUDIO_BLOCK_FRAMES, + "Block Frames" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_AUDIO_DEVICE, + "Audio Device" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_AUDIO_DRIVER, + "Audio Driver" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_AUDIO_DSP_PLUGIN, + "Audio DSP Plugin" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_AUDIO_ENABLE, + "Audio Enable" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_AUDIO_FILTER_DIR, + "Audio Filter" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_TURBO_DEADZONE_LIST, + "Turbo/Deadzone" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_AUDIO_LATENCY, + "Audio Latency (ms)" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_AUDIO_MAX_TIMING_SKEW, + "Audio Maximum Timing Skew" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_AUDIO_MUTE, + "Audio Mute" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_AUDIO_OUTPUT_RATE, + "Audio Output Rate (Hz)" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_AUDIO_RATE_CONTROL_DELTA, + "Dynamic Audio Rate Control" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_AUDIO_RESAMPLER_DRIVER, + "Audio Resampler Driver" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_AUDIO_SETTINGS, + "Audio" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_AUDIO_SYNC, + "Audio Sync" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_AUDIO_VOLUME, + "Audio Volume Level (dB)" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_AUDIO_WASAPI_EXCLUSIVE_MODE, + "WASAPI Exclusive Mode" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_AUDIO_WASAPI_FLOAT_FORMAT, + "WASAPI Float Format" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_AUDIO_WASAPI_SH_BUFFER_LENGTH, + "WASAPI Shared Buffer Length" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_AUTOSAVE_INTERVAL, + "SaveRAM Autosave Interval" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_AUTO_OVERRIDES_ENABLE, + "Load Override Files Automatically" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_AUTO_REMAPS_ENABLE, + "Load Remap Files Automatically" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_AUTO_SHADERS_ENABLE, + "Load Shader Presets Automatically" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_BASIC_MENU_CONTROLS_BACK, + "Back" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_BASIC_MENU_CONTROLS_CONFIRM, + "Confirm" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_BASIC_MENU_CONTROLS_INFO, + "Info" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_BASIC_MENU_CONTROLS_QUIT, + "Quit" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_BASIC_MENU_CONTROLS_SCROLL_DOWN, + "Scroll Down" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_BASIC_MENU_CONTROLS_SCROLL_UP, + "Scroll Up" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_BASIC_MENU_CONTROLS_START, + "Start" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_BASIC_MENU_CONTROLS_TOGGLE_KEYBOARD, + "Toggle Keyboard" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_BASIC_MENU_CONTROLS_TOGGLE_MENU, + "Toggle Menu" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_BASIC_MENU_ENUM_CONTROLS, + "Basic menu controls" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_BASIC_MENU_ENUM_CONTROLS_CONFIRM, + "Confirm/OK" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_BASIC_MENU_ENUM_CONTROLS_INFO, + "Info" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_BASIC_MENU_ENUM_CONTROLS_QUIT, + "Quit" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_BASIC_MENU_ENUM_CONTROLS_SCROLL_UP, + "Scroll Up" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_BASIC_MENU_ENUM_CONTROLS_START, + "Defaults" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_BASIC_MENU_ENUM_CONTROLS_TOGGLE_KEYBOARD, + "Toggle Keyboard" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_BASIC_MENU_ENUM_CONTROLS_TOGGLE_MENU, + "Toggle Menu" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_BLOCK_SRAM_OVERWRITE, + "Don't overwrite SaveRAM on loading savestate" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_BLUETOOTH_ENABLE, + "Bluetooth Enable" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_BUILDBOT_ASSETS_URL, + "Buildbot Assets URL" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CACHE_DIRECTORY, + "Cache" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CAMERA_ALLOW, + "Allow Camera" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CAMERA_DRIVER, + "Camera Driver" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CHEAT, + "Cheat" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CHEAT_APPLY_CHANGES, + "Apply Changes" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CHEAT_DATABASE_PATH, + "Cheat File" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CHEAT_FILE, + "Cheat File" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CHEAT_FILE_LOAD, + "Load Cheat File" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CHEAT_FILE_SAVE_AS, + "Save Cheat File As" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CHEAT_NUM_PASSES, + "Cheat Passes" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CHEEVOS_DESCRIPTION, + "Description" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CHEEVOS_HARDCORE_MODE_ENABLE, + "Achievements Hardcore Mode" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CHEEVOS_LEADERBOARDS_ENABLE, + "Leaderboards" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CHEEVOS_BADGES_ENABLE, + "Achievement Badges" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CHEEVOS_LOCKED_ACHIEVEMENTS, + "Locked Achievements:" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CHEEVOS_LOCKED_ENTRY, + "Locked" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CHEEVOS_SETTINGS, + "RetroAchievements" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CHEEVOS_TEST_UNOFFICIAL, + "Test Unofficial Achievements" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CHEEVOS_UNLOCKED_ACHIEVEMENTS, + "Unlocked Achievements:" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CHEEVOS_UNLOCKED_ENTRY, + "Unlocked" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CHEEVOS_UNLOCKED_ENTRY_HARDCORE, + "Hardcore" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CHEEVOS_VERBOSE_ENABLE, + "Achievements Verbose Mode" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CLOSE_CONTENT, + "Close Content" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CONFIG, + "Config" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CONFIGURATIONS, + "تحميل ملف التكوين" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CONFIGURATION_SETTINGS, + "ملفات التكوين" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CONFIG_SAVE_ON_EXIT, + "Save Configuration on Exit" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CONTENT_COLLECTION_LIST, + "Collections" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CONTENT_DATABASE_DIRECTORY, + "Database" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CONTENT_DIR, + "Content" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CONTENT_HISTORY_SIZE, + "History List Size") +MSG_HASH(MENU_ENUM_LABEL_VALUE_PLAYLIST_ENTRY_REMOVE, + "Allow to remove entries") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CONTENT_SETTINGS, + "القائمة السريعة") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CORE_ASSETS_DIR, + "Downloads") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CORE_ASSETS_DIRECTORY, + "Downloads") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CORE_CHEAT_OPTIONS, + "Cheats") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CORE_COUNTERS, + "Core Counters") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CORE_ENABLE, + "Show core name") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CORE_INFORMATION, + "Core Information") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CORE_INFO_AUTHORS, + "Authors") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CORE_INFO_CATEGORIES, + "Categories") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CORE_INFO_CORE_LABEL, + "Core label") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CORE_INFO_CORE_NAME, + "Core name") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CORE_INFO_FIRMWARE, + "Firmware(s)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CORE_INFO_LICENSES, + "License(s)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CORE_INFO_PERMISSIONS, + "Permissions") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CORE_INFO_SUPPORTED_EXTENSIONS, + "Supported extensions") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CORE_INFO_SYSTEM_MANUFACTURER, + "System manufacturer") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CORE_INFO_SYSTEM_NAME, + "System name") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CORE_INPUT_REMAPPING_OPTIONS, + "Controls") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CORE_LIST, + "تحميل الكور") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CORE_OPTIONS, + "Options") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CORE_SETTINGS, + "Core") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CORE_SET_SUPPORTS_NO_CONTENT_ENABLE, + "Start a Core Automatically") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CORE_UPDATER_AUTO_EXTRACT_ARCHIVE, + "Automatically extract downloaded archive") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CORE_UPDATER_BUILDBOT_URL, + "Buildbot Cores URL") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CORE_UPDATER_LIST, + "Core Updater") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CORE_UPDATER_SETTINGS, + "Updater") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CPU_ARCHITECTURE, + "CPU Architecture:") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CPU_CORES, + "CPU Cores:") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CURSOR_DIRECTORY, + "Cursor") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CURSOR_MANAGER, + "Cursor Manager") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CUSTOM_RATIO, + "Custom Ratio") +MSG_HASH(MENU_ENUM_LABEL_VALUE_DATABASE_MANAGER, + "Database Manager") +MSG_HASH(MENU_ENUM_LABEL_VALUE_DATABASE_SELECTION, + "Database Selection") +MSG_HASH(MENU_ENUM_LABEL_VALUE_DELETE_ENTRY, + "Remove") +MSG_HASH(MENU_ENUM_LABEL_VALUE_FAVORITES, + "Start directory") +MSG_HASH(MENU_ENUM_LABEL_VALUE_DIRECTORY_CONTENT, + "") +MSG_HASH(MENU_ENUM_LABEL_VALUE_DIRECTORY_DEFAULT, + "") +MSG_HASH(MENU_ENUM_LABEL_VALUE_DIRECTORY_NONE, + "") +MSG_HASH(MENU_ENUM_LABEL_VALUE_DIRECTORY_NOT_FOUND, + "Directory not found.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_DIRECTORY_SETTINGS, + "Directory") +MSG_HASH(MENU_ENUM_LABEL_VALUE_DISK_CYCLE_TRAY_STATUS, + "Disk Cycle Tray Status") +MSG_HASH(MENU_ENUM_LABEL_VALUE_DISK_IMAGE_APPEND, + "Disk Image Append") +MSG_HASH(MENU_ENUM_LABEL_VALUE_DISK_INDEX, + "Disk Index") +MSG_HASH(MENU_ENUM_LABEL_VALUE_DISK_OPTIONS, + "Disk Control") +MSG_HASH(MENU_ENUM_LABEL_VALUE_DONT_CARE, + "Don't care") +MSG_HASH(MENU_ENUM_LABEL_VALUE_DOWNLOADED_FILE_DETECT_CORE_LIST, + "Downloads") +MSG_HASH(MENU_ENUM_LABEL_VALUE_DOWNLOAD_CORE, + "Download Core...") +MSG_HASH(MENU_ENUM_LABEL_VALUE_DOWNLOAD_CORE_CONTENT, + "Content Downloader") +MSG_HASH(MENU_ENUM_LABEL_VALUE_DPI_OVERRIDE_ENABLE, + "DPI Override Enable") +MSG_HASH(MENU_ENUM_LABEL_VALUE_DPI_OVERRIDE_VALUE, + "DPI Override") +MSG_HASH(MENU_ENUM_LABEL_VALUE_DRIVER_SETTINGS, + "Driver") +MSG_HASH(MENU_ENUM_LABEL_VALUE_DUMMY_ON_CORE_SHUTDOWN, + "Load Dummy on Core Shutdown") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CHECK_FOR_MISSING_FIRMWARE, + "Check for Missing Firmware Before Loading") +MSG_HASH(MENU_ENUM_LABEL_VALUE_DYNAMIC_WALLPAPER, + "Dynamic Background") +MSG_HASH(MENU_ENUM_LABEL_VALUE_DYNAMIC_WALLPAPERS_DIRECTORY, + "Dynamic Backgrounds") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CHEEVOS_ENABLE, + "Enable Achievements") +MSG_HASH(MENU_ENUM_LABEL_VALUE_ENTRY_HOVER_COLOR, + "Menu entry hover color") +MSG_HASH(MENU_ENUM_LABEL_VALUE_ENTRY_NORMAL_COLOR, + "Menu entry normal color") +MSG_HASH(MENU_ENUM_LABEL_VALUE_FALSE, + "False") +MSG_HASH(MENU_ENUM_LABEL_VALUE_FASTFORWARD_RATIO, + "Maximum Run Speed") +MSG_HASH(MENU_ENUM_LABEL_VALUE_FAVORITES_TAB, + "Favorites") +MSG_HASH(MENU_ENUM_LABEL_VALUE_FPS_SHOW, + "Display Framerate") +MSG_HASH(MENU_ENUM_LABEL_VALUE_FRAME_THROTTLE_ENABLE, + "Limit Maximum Run Speed") +MSG_HASH(MENU_ENUM_LABEL_VALUE_FRAME_THROTTLE_SETTINGS, + "Frame Throttle") +MSG_HASH(MENU_ENUM_LABEL_VALUE_FRONTEND_COUNTERS, + "Frontend Counters") +MSG_HASH(MENU_ENUM_LABEL_VALUE_GAME_SPECIFIC_OPTIONS, + "Load Content-Specific Core Options Automatically") +MSG_HASH(MENU_ENUM_LABEL_VALUE_GAME_SPECIFIC_OPTIONS_CREATE, + "Create game-options file") +MSG_HASH(MENU_ENUM_LABEL_VALUE_GAME_SPECIFIC_OPTIONS_IN_USE, + "Game-options file") +MSG_HASH(MENU_ENUM_LABEL_VALUE_HELP, + "مساعدة") +MSG_HASH(MENU_ENUM_LABEL_VALUE_HELP_AUDIO_VIDEO_TROUBLESHOOTING, + "Audio/Video Troubleshooting") +MSG_HASH(MENU_ENUM_LABEL_VALUE_HELP_CHANGE_VIRTUAL_GAMEPAD, + "Changing Virtual Gamepad Overlay") +MSG_HASH(MENU_ENUM_LABEL_VALUE_HELP_CONTROLS, + "Basic Menu Controls") +MSG_HASH(MENU_ENUM_LABEL_VALUE_HELP_LIST, + "مساعدة") +MSG_HASH(MENU_ENUM_LABEL_VALUE_HELP_LOADING_CONTENT, + "Loading Content") +MSG_HASH(MENU_ENUM_LABEL_VALUE_HELP_SCANNING_CONTENT, + "Scanning For Content") +MSG_HASH(MENU_ENUM_LABEL_VALUE_HELP_WHAT_IS_A_CORE, + "What Is A Core?") +MSG_HASH(MENU_ENUM_LABEL_VALUE_HISTORY_LIST_ENABLE, + "History List Enable") +MSG_HASH(MENU_ENUM_LABEL_VALUE_HISTORY_TAB, + "History") +MSG_HASH(MENU_ENUM_LABEL_VALUE_HORIZONTAL_MENU, + "Horizontal Menu") +MSG_HASH(MENU_ENUM_LABEL_VALUE_IMAGES_TAB, + "Image") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INFORMATION, + "معلومات") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INFORMATION_LIST, + "معلومات") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ADC_TYPE, + "Analog To Digital Type") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ALL_USERS_CONTROL_MENU, + "All Users Control Menu") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X, + "Left Analog X") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_MINUS, + "Left analog X- (left)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_PLUS, + "Left analog X+ (right)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y, + "Left Analog Y") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_MINUS, + "Left analog Y- (up)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_PLUS, + "Left analog Y+ (down)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X, + "Right Analog X") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_MINUS, + "Right analog X- (left)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_PLUS, + "Right analog X+ (right)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y, + "Right Analog Y") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, + "Right analog Y- (up)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, + "Right analog Y+ (down)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, + "Gun Trigger") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, + "Gun Reload") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, + "Gun Aux A") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, + "Gun Aux B") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, + "Gun Aux C") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, + "Gun Start") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, + "Gun Select") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, + "Gun D-pad Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, + "Gun D-pad Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, + "Gun D-pad Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, + "Gun D-pad Right") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AUTODETECT_ENABLE, + "Autoconfig Enable") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AXIS_THRESHOLD, + "Analog Stick Deadzone") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_INPUT_SWAP_OK_CANCEL, + "Menu Swap OK & Cancel Buttons") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_BIND_ALL, + "Bind All") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_BIND_DEFAULT_ALL, + "Bind Default All") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_BIND_TIMEOUT, + "Bind Timeout") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_DESCRIPTOR_HIDE_UNBOUND, + "Hide Unbound Core Input Descriptors") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_DESCRIPTOR_LABEL_SHOW, + "Display Input Descriptor Labels") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_DEVICE_INDEX, + "Device Index") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_DEVICE_TYPE, + "Device Type") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_INDEX, + "Mouse Index") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_DRIVER, + "Input Driver") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_DUTY_CYCLE, + "Duty Cycle") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_HOTKEY_BINDS, + "Input Hotkey Binds") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ICADE_ENABLE, + "Keyboard Gamepad Mapping Enable") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_A, + "A button (right)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_B, + "B button (down)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_DOWN, + "Down D-pad") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L2, + "L2 button (trigger)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L3, + "L3 button (thumb)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L, + "L button (shoulder)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_LEFT, + "Left D-pad") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R2, + "R2 button (trigger)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R3, + "R3 button (thumb)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R, + "R button (shoulder)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_RIGHT, + "Right D-pad") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_SELECT, + "Select button") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_START, + "Start button") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_UP, + "Up D-pad") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_X, + "X button (top)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, + "Y button (left)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, + "(Key: %s)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, + "Mouse 1") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, + "Mouse 2") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, + "Mouse 3") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, + "Mouse 4") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, + "Mouse 5") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, + "Wheel Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, + "Wheel Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, + "Wheel Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, + "Wheel Right") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, + "Keyboard Gamepad Mapping Type") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, + "Max Users") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MENU_ENUM_TOGGLE_GAMEPAD_COMBO, + "Menu Toggle Gamepad Combo") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_INDEX_MINUS, + "Cheat index -") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_INDEX_PLUS, + "Cheat index +") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_TOGGLE, + "Cheat toggle") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_EJECT_TOGGLE, + "Disk eject toggle") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_NEXT, + "Disk next") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_PREV, + "Disk prev") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_ENABLE_HOTKEY, + "Enable hotkeys") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_FAST_FORWARD_HOLD_KEY, + "Fast forward hold") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_FAST_FORWARD_KEY, + "Fast forward toggle") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_FRAMEADVANCE, + "Frameadvance") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_FULLSCREEN_TOGGLE_KEY, + "Fullscreen toggle") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_GRAB_MOUSE_TOGGLE, + "Grab mouse toggle") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_GAME_FOCUS_TOGGLE, + "Game focus toggle") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_LOAD_STATE_KEY, + "Load state") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_MENU_TOGGLE, + "Menu toggle") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_MOVIE_RECORD_TOGGLE, + "Movie record toggle") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_MUTE, + "Audio mute toggle") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_GAME_WATCH, + "Netplay toggle play/spectate mode") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_OSK, + "On-screen keyboard toggle") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_OVERLAY_NEXT, + "Overlay next") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_PAUSE_TOGGLE, + "Pause toggle") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_QUIT_KEY, + "Quit RetroArch") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_RESET, + "Reset game") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_REWIND, + "Rewind") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_SAVE_STATE_KEY, + "Save state") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_SCREENSHOT, + "Take screenshot") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_SHADER_NEXT, + "Next shader") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_SHADER_PREV, + "Previous shader") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_SLOWMOTION, + "Slow motion") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_STATE_SLOT_MINUS, + "Savestate slot -") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_STATE_SLOT_PLUS, + "Savestate slot +") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_DOWN, + "Volume -") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_UP, + "Volume +") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_OVERLAY_ENABLE, + "Display Overlay") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_OVERLAY_HIDE_IN_MENU, + "Hide Overlay In Menu") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS, + "Show Inputs On Overlay") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS_PORT, + "Show Inputs Listen Port") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_POLL_TYPE_BEHAVIOR, + "Poll Type Behavior") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_POLL_TYPE_BEHAVIOR_EARLY, + "Early") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_POLL_TYPE_BEHAVIOR_LATE, + "Late") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_POLL_TYPE_BEHAVIOR_NORMAL, + "Normal") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_PREFER_FRONT_TOUCH, + "Prefer Front Touch") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_REMAPPING_DIRECTORY, + "Input Remapping") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_REMAP_BINDS_ENABLE, + "Remap Binds Enable") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_SAVE_AUTOCONFIG, + "Save Autoconfig") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_SETTINGS, + "Input") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_SMALL_KEYBOARD_ENABLE, + "Small Keyboard Enable") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_TOUCH_ENABLE, + "Touch Enable") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_TURBO_ENABLE, + "Turbo enable") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_TURBO_PERIOD, + "Turbo Period") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_USER_BINDS, + "Input User %u Binds") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INTERNAL_STORAGE_STATUS, + "Internal storage status") +MSG_HASH(MENU_ENUM_LABEL_VALUE_JOYPAD_AUTOCONFIG_DIR, + "Input Autoconfig") +MSG_HASH(MENU_ENUM_LABEL_VALUE_JOYPAD_DRIVER, + "Joypad Driver") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LAKKA_SERVICES, + "Services") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_CHINESE_SIMPLIFIED, + "Chinese (Simplified)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_CHINESE_TRADITIONAL, + "Chinese (Traditional)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_DUTCH, + "Dutch") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_ENGLISH, + "English") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_ESPERANTO, + "Esperanto") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_FRENCH, + "French") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_GERMAN, + "German") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_ITALIAN, + "Italian") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_JAPANESE, + "Japanese") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_KOREAN, + "Korean") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_POLISH, + "Polish") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_PORTUGUESE_BRAZIL, + "Portuguese (Brazil)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_PORTUGUESE_PORTUGAL, + "Portuguese (Portugal)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_RUSSIAN, + "Russian") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_SPANISH, + "Spanish") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_VIETNAMESE, + "Vietnamese") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_ARABIC, + "عربى") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LEFT_ANALOG, + "Left Analog") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LIBRETRO_DIR_PATH, + "Core") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LIBRETRO_INFO_PATH, + "Core Info") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LIBRETRO_LOG_LEVEL, + "Core Logging Level") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LINEAR, + "Linear") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LOAD_ARCHIVE, + "Load Archive") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LOAD_CONTENT_HISTORY, + "Load Recent") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LOAD_CONTENT_LIST, + "تحميل المحتوى") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LOAD_STATE, + "Load State") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LOCATION_ALLOW, + "Allow Location") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LOCATION_DRIVER, + "Location Driver") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LOGGING_SETTINGS, + "Logging") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LOG_VERBOSITY, + "Logging Verbosity") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MAIN_MENU, + "القائمة الرئيسية") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MANAGEMENT, + "Database Settings") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MATERIALUI_MENU_COLOR_THEME, + "Menu Color Theme") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MATERIALUI_MENU_COLOR_THEME_BLUE, + "Blue") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MATERIALUI_MENU_COLOR_THEME_BLUE_GREY, + "Blue Grey") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MATERIALUI_MENU_COLOR_THEME_DARK_BLUE, + "Dark Blue") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MATERIALUI_MENU_COLOR_THEME_GREEN, + "Green") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MATERIALUI_MENU_COLOR_THEME_NVIDIA_SHIELD, + "Shield") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MATERIALUI_MENU_COLOR_THEME_RED, + "Red") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MATERIALUI_MENU_COLOR_THEME_YELLOW, + "Yellow") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MATERIALUI_MENU_FOOTER_OPACITY, + "Footer Opacity") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MATERIALUI_MENU_HEADER_OPACITY, + "Header Opacity") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_DRIVER, + "Menu Driver") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_ENUM_THROTTLE_FRAMERATE, + "Throttle Menu Framerate") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_FILE_BROWSER_SETTINGS, + "Settings") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_LINEAR_FILTER, + "Menu Linear Filter") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_HORIZONTAL_ANIMATION, + "Horizontal Animation") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_SETTINGS, + "Appearance") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_WALLPAPER, + "Background") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_WALLPAPER_OPACITY, + "Background opacity") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MISSING, + "Missing") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MORE, + "...") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MOUSE_ENABLE, + "Mouse Support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MULTIMEDIA_SETTINGS, + "Multimedia") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MUSIC_TAB, + "Music") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NAVIGATION_BROWSER_FILTER_SUPPORTED_EXTENSIONS_ENABLE, + "Filter unknown extensions") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NAVIGATION_WRAPAROUND, + "Navigation Wrap-Around") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NEAREST, + "Nearest") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY, + "Netplay") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ALLOW_SLAVES, + "Allow Slave-Mode Clients") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_CHECK_FRAMES, + "Netplay Check Frames") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_INPUT_LATENCY_FRAMES_MIN, + "Input Latency Frames") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_INPUT_LATENCY_FRAMES_RANGE, + "Input Latency Frames Range") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_DELAY_FRAMES, + "Netplay Delay Frames") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_DISCONNECT, + "Disconnect from netplay host") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE, + "Netplay Enable") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE_CLIENT, + "Connect to netplay host") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE_HOST, + "Start netplay host") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_DISABLE_HOST, + "Stop netplay host") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_IP_ADDRESS, + "Server Address") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_LAN_SCAN_SETTINGS, + "Scan local network") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_MODE, + "Netplay Client Enable") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_NICKNAME, + "Username") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_PASSWORD, + "Server Password") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_PUBLIC_ANNOUNCE, + "Publicly Announce Netplay") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_REQUEST_DEVICE_I, + "Request Device %u") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_REQUIRE_SLAVES, + "Disallow Non-Slave-Mode Clients") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_SETTINGS, + "Netplay settings") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_ANALOG, + "Analog Input Sharing") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_ANALOG_MAX, + "Max") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_ANALOG_AVERAGE, + "Average") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_DIGITAL, + "Digital Input Sharing") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_DIGITAL_OR, + "Share") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_DIGITAL_XOR, + "Grapple") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_DIGITAL_VOTE, + "Vote") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_NONE, + "None") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_NO_PREFERENCE, + "No preference") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_START_AS_SPECTATOR, + "Netplay Spectator Mode") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_STATELESS_MODE, + "Netplay Stateless Mode") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_SPECTATE_PASSWORD, + "Server Spectate-Only Password") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_SPECTATOR_MODE_ENABLE, + "Netplay Spectator Enable") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_TCP_UDP_PORT, + "Netplay TCP Port") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_NAT_TRAVERSAL, + "Netplay NAT Traversal") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETWORK_CMD_ENABLE, + "Network Commands") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETWORK_CMD_PORT, + "Network Command Port") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETWORK_INFORMATION, + "Network Information") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETWORK_REMOTE_ENABLE, + "Network Gamepad") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETWORK_REMOTE_PORT, + "Network Remote Base Port") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETWORK_SETTINGS, + "Network") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NO, + "No") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NONE, + "None") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE, + "N/A") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NO_ACHIEVEMENTS_TO_DISPLAY, + "No achievements to display.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NO_CORE, + "No Core") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NO_CORES_AVAILABLE, + "No cores available.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NO_CORE_INFORMATION_AVAILABLE, + "No core information available.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NO_CORE_OPTIONS_AVAILABLE, + "No core options available.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NO_ENTRIES_TO_DISPLAY, + "No entries to display.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NO_HISTORY_AVAILABLE, + "No history available.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NO_INFORMATION_AVAILABLE, + "No information is available.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NO_ITEMS, + "No items.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NO_NETPLAY_HOSTS_FOUND, + "No netplay hosts found.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NO_NETWORKS_FOUND, + "No networks found.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NO_PERFORMANCE_COUNTERS, + "No performance counters.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NO_PLAYLISTS, + "No playlists.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NO_PLAYLIST_ENTRIES_AVAILABLE, + "No playlist entries available.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NO_SETTINGS_FOUND, + "No settings found.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NO_SHADER_PARAMETERS, + "No shader parameters.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_OFF, + "OFF") +MSG_HASH(MENU_ENUM_LABEL_VALUE_ON, + "ON") +MSG_HASH(MENU_ENUM_LABEL_VALUE_ONLINE, + "Online") +MSG_HASH(MENU_ENUM_LABEL_VALUE_ONLINE_UPDATER, + "التحديث عبر الانترنت") +MSG_HASH(MENU_ENUM_LABEL_VALUE_ONSCREEN_DISPLAY_SETTINGS, + "Onscreen Display") +MSG_HASH(MENU_ENUM_LABEL_VALUE_ONSCREEN_OVERLAY_SETTINGS, + "Onscreen Overlay") +MSG_HASH(MENU_ENUM_LABEL_VALUE_ONSCREEN_NOTIFICATIONS_SETTINGS, + "Onscreen Notifications") +MSG_HASH(MENU_ENUM_LABEL_VALUE_OPEN_ARCHIVE, + "Browse Archive") +MSG_HASH(MENU_ENUM_LABEL_VALUE_OPTIONAL, + "Optional") +MSG_HASH(MENU_ENUM_LABEL_VALUE_OVERLAY, + "Overlay") +MSG_HASH(MENU_ENUM_LABEL_VALUE_OVERLAY_AUTOLOAD_PREFERRED, + "Autoload Preferred Overlay") +MSG_HASH(MENU_ENUM_LABEL_VALUE_OVERLAY_DIRECTORY, + "Overlay") +MSG_HASH(MENU_ENUM_LABEL_VALUE_OVERLAY_OPACITY, + "Overlay Opacity") +MSG_HASH(MENU_ENUM_LABEL_VALUE_OVERLAY_PRESET, + "Overlay Preset") +MSG_HASH(MENU_ENUM_LABEL_VALUE_OVERLAY_SCALE, + "Overlay Scale") +MSG_HASH(MENU_ENUM_LABEL_VALUE_OVERLAY_SETTINGS, + "Onscreen Overlay") +MSG_HASH(MENU_ENUM_LABEL_VALUE_PAL60_ENABLE, + "Use PAL60 Mode") +MSG_HASH(MENU_ENUM_LABEL_VALUE_PARENT_DIRECTORY, + "Parent directory") +MSG_HASH(MENU_ENUM_LABEL_VALUE_PAUSE_LIBRETRO, + "Pause when menu activated") +MSG_HASH(MENU_ENUM_LABEL_VALUE_PAUSE_NONACTIVE, + "Don't run in background") +MSG_HASH(MENU_ENUM_LABEL_VALUE_PERFCNT_ENABLE, + "Performance Counters") +MSG_HASH(MENU_ENUM_LABEL_VALUE_PLAYLISTS_TAB, + "Playlists") +MSG_HASH(MENU_ENUM_LABEL_VALUE_PLAYLIST_DIRECTORY, + "Playlist") +MSG_HASH(MENU_ENUM_LABEL_VALUE_PLAYLIST_SETTINGS, + "Playlists") +MSG_HASH(MENU_ENUM_LABEL_VALUE_POINTER_ENABLE, + "Touch Support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_PORT, + "Port") +MSG_HASH(MENU_ENUM_LABEL_VALUE_PRESENT, + "Present") +MSG_HASH(MENU_ENUM_LABEL_VALUE_PRIVACY_SETTINGS, + "Privacy") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QUIT_RETROARCH, + "إنهاء البرنامج") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_ANALOG, + "Analog supported") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_BBFC_RATING, + "BBFC Rating") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_CERO_RATING, + "CERO Rating") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_COOP, + "Co-op supported") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_CRC32, + "CRC32") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_DESCRIPTION, + "Description") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_DEVELOPER, + "Developer") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_EDGE_MAGAZINE_ISSUE, + "Edge Magazine Issue") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_EDGE_MAGAZINE_RATING, + "Edge Magazine Rating") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_EDGE_MAGAZINE_REVIEW, + "Edge Magazine Review") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_ELSPA_RATING, + "ELSPA Rating") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_ENHANCEMENT_HW, + "Enhancement Hardware") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_ESRB_RATING, + "ESRB Rating") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_FAMITSU_MAGAZINE_RATING, + "Famitsu Magazine Rating") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_FRANCHISE, + "Franchise") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_GENRE, + "Genre") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_MD5, + "MD5") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_NAME, + "Name") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_ORIGIN, + "Origin") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_PEGI_RATING, + "PEGI Rating") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_PUBLISHER, + "Publisher") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_RELEASE_MONTH, + "Releasedate Month") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_RELEASE_YEAR, + "Releasedate Year") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_RUMBLE, + "Rumble supported") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_SERIAL, + "Serial") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_SHA1, + "SHA1") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_START_CONTENT, + "Start Content") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_TGDB_RATING, + "TGDB Rating") +MSG_HASH(MENU_ENUM_LABEL_VALUE_REBOOT, + "Reboot") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RECORDING_CONFIG_DIRECTORY, + "Recording Config") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RECORDING_OUTPUT_DIRECTORY, + "Recording Output") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RECORDING_SETTINGS, + "Recording") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RECORD_CONFIG, + "Load Recording Config...") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RECORD_DRIVER, + "Record Driver") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RECORD_ENABLE, + "Enable Recording") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RECORD_PATH, + "Save Output Recording as...") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RECORD_USE_OUTPUT_DIRECTORY, + "Save Recordings in Output Dir") +MSG_HASH(MENU_ENUM_LABEL_VALUE_REMAP_FILE, + "Remap File") +MSG_HASH(MENU_ENUM_LABEL_VALUE_REMAP_FILE_LOAD, + "Load Remap File") +MSG_HASH(MENU_ENUM_LABEL_VALUE_REMAP_FILE_SAVE_CORE, + "Save Core Remap File") +MSG_HASH(MENU_ENUM_LABEL_VALUE_REMAP_FILE_SAVE_GAME, + "Save Game Remap File") +MSG_HASH(MENU_ENUM_LABEL_VALUE_REMAP_FILE_REMOVE_CORE, + "Delete Core Remap File") +MSG_HASH(MENU_ENUM_LABEL_VALUE_REMAP_FILE_REMOVE_GAME, + "Delete Game Remap File") +MSG_HASH(MENU_ENUM_LABEL_VALUE_REQUIRED, + "Required") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RESTART_CONTENT, + "Restart") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RESTART_RETROARCH, + "Restart RetroArch") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RESUME, + "Resume") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RESUME_CONTENT, + "Resume") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RETROKEYBOARD, + "RetroKeyboard") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RETROPAD, + "RetroPad") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RETROPAD_WITH_ANALOG, + "RetroPad w/ Analog") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RETRO_ACHIEVEMENTS_SETTINGS, + "Achievements") +MSG_HASH(MENU_ENUM_LABEL_VALUE_REWIND_ENABLE, + "Rewind Enable") +MSG_HASH(MENU_ENUM_LABEL_VALUE_REWIND_GRANULARITY, + "Rewind Granularity") +MSG_HASH(MENU_ENUM_LABEL_VALUE_REWIND_SETTINGS, + "Rewind") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RGUI_BROWSER_DIRECTORY, + "File Browser") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RGUI_CONFIG_DIRECTORY, + "Config") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RGUI_SHOW_START_SCREEN, + "Display Start Screen") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RIGHT_ANALOG, + "Right Analog") +MSG_HASH(MENU_ENUM_LABEL_VALUE_ADD_TO_FAVORITES, + "Add to Favorites") +MSG_HASH(MENU_ENUM_LABEL_VALUE_ADD_TO_FAVORITES_PLAYLIST, + "Add to Favorites") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RUN, + "Run") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RUN_MUSIC, + "Run") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SAMBA_ENABLE, + "SAMBA Enable") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SAVEFILE_DIRECTORY, + "Savefile") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SAVESTATE_AUTO_INDEX, + "Save State Auto Index") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SAVESTATE_AUTO_LOAD, + "Auto Load State") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SAVESTATE_AUTO_SAVE, + "Auto Save State") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SAVESTATE_DIRECTORY, + "Savestate") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SAVESTATE_THUMBNAIL_ENABLE, + "Savestate Thumbnails") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SAVE_CURRENT_CONFIG, + "Save Current Configuration") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SAVE_CURRENT_CONFIG_OVERRIDE_CORE, + "Save Core Overrides") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SAVE_CURRENT_CONFIG_OVERRIDE_GAME, + "Save Game Overrides") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SAVE_NEW_CONFIG, + "Save New Configuration") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SAVE_STATE, + "Save State") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SAVING_SETTINGS, + "Saving") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SCAN_DIRECTORY, + "Scan Directory") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SCAN_FILE, + "Scan File") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SCAN_THIS_DIRECTORY, + "") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SCREENSHOT_DIRECTORY, + "Screenshot") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SCREEN_RESOLUTION, + "Screen Resolution") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SEARCH, + "Search") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SECONDS, + "seconds") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SETTINGS, + "Settings") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SETTINGS_TAB, + "Settings") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SHADER, + "Shader") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SHADER_APPLY_CHANGES, + "Apply Changes") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SHADER_OPTIONS, + "Shaders") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SHADER_PIPELINE_RIBBON, + "Ribbon") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SHADER_PIPELINE_RIBBON_SIMPLIFIED, + "Ribbon (simplified)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SHADER_PIPELINE_SIMPLE_SNOW, + "Simple Snow") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SHADER_PIPELINE_SNOW, + "Snow") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SHOW_ADVANCED_SETTINGS, + "Show Advanced Settings") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SHOW_HIDDEN_FILES, + "Show Hidden Files and Folders") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SHUTDOWN, + "Shutdown") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SLOWMOTION_RATIO, + "Slow-Motion Ratio") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SORT_SAVEFILES_ENABLE, + "Sort Saves In Folders") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SORT_SAVESTATES_ENABLE, + "Sort Savestates In Folders") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SAVESTATES_IN_CONTENT_DIR_ENABLE, + "Write Savestates to Content Dir") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SAVEFILES_IN_CONTENT_DIR_ENABLE, + "Write Saves to Content Dir") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEMFILES_IN_CONTENT_DIR_ENABLE, + "System Files are in Content Dir") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SCREENSHOTS_IN_CONTENT_DIR_ENABLE, + "Write Screenshots to Content Dir") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SSH_ENABLE, + "SSH Enable") +MSG_HASH(MENU_ENUM_LABEL_VALUE_START_CORE, + "Start Core") +MSG_HASH(MENU_ENUM_LABEL_VALUE_START_NET_RETROPAD, + "Start Remote RetroPad") +MSG_HASH(MENU_ENUM_LABEL_VALUE_START_VIDEO_PROCESSOR, + "Start Video Processor") +MSG_HASH(MENU_ENUM_LABEL_VALUE_STATE_SLOT, + "State Slot") +MSG_HASH(MENU_ENUM_LABEL_VALUE_STATUS, + "Status") +MSG_HASH(MENU_ENUM_LABEL_VALUE_STDIN_CMD_ENABLE, + "stdin Commands") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SUPPORTED_CORES, + "Suggested cores") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SUSPEND_SCREENSAVER_ENABLE, + "Suspend Screensaver") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_BGM_ENABLE, + "System BGM Enable") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_DIRECTORY, + "System/BIOS") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFORMATION, + "System Information") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_7ZIP_SUPPORT, + "7zip support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_ALSA_SUPPORT, + "ALSA support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_BUILD_DATE, + "Build date") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_CG_SUPPORT, + "Cg support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_COCOA_SUPPORT, + "Cocoa support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_COMMAND_IFACE_SUPPORT, + "Command interface support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_CORETEXT_SUPPORT, + "CoreText support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_CPU_FEATURES, + "CPU Features") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_DISPLAY_METRIC_DPI, + "Display metric DPI") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_DISPLAY_METRIC_MM_HEIGHT, + "Display metric height (mm)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_DISPLAY_METRIC_MM_WIDTH, + "Display metric width (mm)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_DSOUND_SUPPORT, + "DirectSound support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_WASAPI_SUPPORT, + "WASAPI support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_DYLIB_SUPPORT, + "Dynamic library support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_DYNAMIC_SUPPORT, + "Dynamic run-time loading of libretro library") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_EGL_SUPPORT, + "EGL support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_FBO_SUPPORT, + "OpenGL/Direct3D render-to-texture (multi-pass shaders) support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_FFMPEG_SUPPORT, + "FFmpeg support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_FREETYPE_SUPPORT, + "FreeType support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_FRONTEND_IDENTIFIER, + "Frontend identifier") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_FRONTEND_NAME, + "Frontend name") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_FRONTEND_OS, + "Frontend OS") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_GIT_VERSION, + "Git version") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_GLSL_SUPPORT, + "GLSL support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_HLSL_SUPPORT, + "HLSL support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_JACK_SUPPORT, + "JACK support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_KMS_SUPPORT, + "KMS/EGL support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_LAKKA_VERSION, + "Lakka Version") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_LIBRETRODB_SUPPORT, + "LibretroDB support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_LIBUSB_SUPPORT, + "Libusb support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_LIBXML2_SUPPORT, + "libxml2 XML parsing support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_NETPLAY_SUPPORT, + "Netplay (peer-to-peer) support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_NETWORK_COMMAND_IFACE_SUPPORT, + "Network Command interface support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_NETWORK_REMOTE_SUPPORT, + "Network Gamepad support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_OPENAL_SUPPORT, + "OpenAL support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_OPENGLES_SUPPORT, + "OpenGL ES support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_OPENGL_SUPPORT, + "OpenGL support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_OPENSL_SUPPORT, + "OpenSL support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_OPENVG_SUPPORT, + "OpenVG support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_OSS_SUPPORT, + "OSS support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_OVERLAY_SUPPORT, + "Overlay support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_POWER_SOURCE, + "Power source") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_POWER_SOURCE_CHARGED, + "Charged") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_POWER_SOURCE_CHARGING, + "Charging") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_POWER_SOURCE_DISCHARGING, + "Discharging") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_POWER_SOURCE_NO_SOURCE, + "No source") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_PULSEAUDIO_SUPPORT, + "PulseAudio support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_PYTHON_SUPPORT, + "Python (script support in shaders) support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_RBMP_SUPPORT, + "BMP support (RBMP)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_RETRORATING_LEVEL, + "RetroRating level") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_RJPEG_SUPPORT, + "JPEG support (RJPEG)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_ROARAUDIO_SUPPORT, + "RoarAudio support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_RPNG_SUPPORT, + "PNG support (RPNG)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_RSOUND_SUPPORT, + "RSound support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_RTGA_SUPPORT, + "TGA support (RTGA)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_SDL2_SUPPORT, + "SDL2 support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_SDL_IMAGE_SUPPORT, + "SDL image support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_SDL_SUPPORT, + "SDL1.2 support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_SLANG_SUPPORT, + "Slang support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_THREADING_SUPPORT, + "Threading support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_UDEV_SUPPORT, + "Udev support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_V4L2_SUPPORT, + "Video4Linux2 support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_VIDEO_CONTEXT_DRIVER, + "Video context driver") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_VULKAN_SUPPORT, + "Vulkan support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_WAYLAND_SUPPORT, + "Wayland support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_X11_SUPPORT, + "X11 support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_XAUDIO2_SUPPORT, + "XAudio2 support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_XVIDEO_SUPPORT, + "XVideo support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_ZLIB_SUPPORT, + "Zlib support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_TAKE_SCREENSHOT, + "Take Screenshot") +MSG_HASH(MENU_ENUM_LABEL_VALUE_THREADED_DATA_RUNLOOP_ENABLE, + "Threaded tasks") +MSG_HASH(MENU_ENUM_LABEL_VALUE_THUMBNAILS, + "Thumbnails") +MSG_HASH(MENU_ENUM_LABEL_VALUE_THUMBNAILS_DIRECTORY, + "Thumbnails") +MSG_HASH(MENU_ENUM_LABEL_VALUE_THUMBNAILS_UPDATER_LIST, + "Thumbnails Updater") +MSG_HASH(MENU_ENUM_LABEL_VALUE_THUMBNAIL_MODE_BOXARTS, + "Boxarts") +MSG_HASH(MENU_ENUM_LABEL_VALUE_THUMBNAIL_MODE_SCREENSHOTS, + "Screenshots") +MSG_HASH(MENU_ENUM_LABEL_VALUE_THUMBNAIL_MODE_TITLE_SCREENS, + "Title Screens") +MSG_HASH(MENU_ENUM_LABEL_VALUE_TIMEDATE_ENABLE, + "Show date / time") +MSG_HASH(MENU_ENUM_LABEL_VALUE_TITLE_COLOR, + "Menu title color") +MSG_HASH(MENU_ENUM_LABEL_VALUE_TRUE, + "True") +MSG_HASH(MENU_ENUM_LABEL_VALUE_UI_COMPANION_ENABLE, + "UI Companion Enable") +MSG_HASH(MENU_ENUM_LABEL_VALUE_UI_COMPANION_START_ON_BOOT, + "UI Companion Start On Boot") +MSG_HASH(MENU_ENUM_LABEL_VALUE_UI_MENUBAR_ENABLE, + "Menubar") +MSG_HASH(MENU_ENUM_LABEL_VALUE_UNABLE_TO_READ_COMPRESSED_FILE, + "Unable to read compressed file.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_UNDO_LOAD_STATE, + "Undo Load State") +MSG_HASH(MENU_ENUM_LABEL_VALUE_UNDO_SAVE_STATE, + "Undo Save State") +MSG_HASH(MENU_ENUM_LABEL_VALUE_UNKNOWN, + "Unknown") +MSG_HASH(MENU_ENUM_LABEL_VALUE_UPDATER_SETTINGS, + "Updater") +MSG_HASH(MENU_ENUM_LABEL_VALUE_UPDATE_ASSETS, + "Update Assets") +MSG_HASH(MENU_ENUM_LABEL_VALUE_UPDATE_AUTOCONFIG_PROFILES, + "Update Joypad Profiles") +MSG_HASH(MENU_ENUM_LABEL_VALUE_UPDATE_CG_SHADERS, + "Update Cg Shaders") +MSG_HASH(MENU_ENUM_LABEL_VALUE_UPDATE_CHEATS, + "Update Cheats") +MSG_HASH(MENU_ENUM_LABEL_VALUE_UPDATE_CORE_INFO_FILES, + "Update Core Info Files") +MSG_HASH(MENU_ENUM_LABEL_VALUE_UPDATE_DATABASES, + "Update Databases") +MSG_HASH(MENU_ENUM_LABEL_VALUE_UPDATE_GLSL_SHADERS, + "Update GLSL Shaders") +MSG_HASH(MENU_ENUM_LABEL_VALUE_UPDATE_LAKKA, + "Update Lakka") +MSG_HASH(MENU_ENUM_LABEL_VALUE_UPDATE_OVERLAYS, + "Update Overlays") +MSG_HASH(MENU_ENUM_LABEL_VALUE_UPDATE_SLANG_SHADERS, + "Update Slang Shaders") +MSG_HASH(MENU_ENUM_LABEL_VALUE_USER, + "User") +MSG_HASH(MENU_ENUM_LABEL_VALUE_KEYBOARD, + "Kbd") +MSG_HASH(MENU_ENUM_LABEL_VALUE_USER_INTERFACE_SETTINGS, + "User Interface") +MSG_HASH(MENU_ENUM_LABEL_VALUE_USER_LANGUAGE, + "Language") +MSG_HASH(MENU_ENUM_LABEL_VALUE_USER_SETTINGS, + "User") +MSG_HASH(MENU_ENUM_LABEL_VALUE_USE_BUILTIN_IMAGE_VIEWER, + "Use Builtin Image Viewer") +MSG_HASH(MENU_ENUM_LABEL_VALUE_USE_BUILTIN_PLAYER, + "Use Builtin Media Player") +MSG_HASH(MENU_ENUM_LABEL_VALUE_USE_THIS_DIRECTORY, + "") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_ALLOW_ROTATE, + "Allow rotation") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_ASPECT_RATIO, + "Config Aspect Ratio") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_ASPECT_RATIO_AUTO, + "Auto Aspect Ratio") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_ASPECT_RATIO_INDEX, + "Aspect Ratio") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_BLACK_FRAME_INSERTION, + "Black Frame Insertion") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_CROP_OVERSCAN, + "Crop Overscan (Reload)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_DISABLE_COMPOSITION, + "Disable Desktop Composition") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_DRIVER, + "Video Driver") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_FILTER, + "Video Filter") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_FILTER_DIR, + "Video Filter") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_FILTER_FLICKER, + "Flicker filter") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_FONT_ENABLE, + "Enable Onscreen Notifications") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_FONT_PATH, + "Notification Font") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_FONT_SIZE, + "Notification Size") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_FORCE_ASPECT, + "Force aspect ratio") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_FORCE_SRGB_DISABLE, + "Force-disable sRGB FBO") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_FRAME_DELAY, + "Frame Delay") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_FULLSCREEN, + "Start in Fullscreen Mode") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_GAMMA, + "Video Gamma") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_GPU_RECORD, + "Use GPU Recording") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_GPU_SCREENSHOT, + "GPU Screenshot Enable") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_HARD_SYNC, + "Hard GPU Sync") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_HARD_SYNC_FRAMES, + "Hard GPU Sync Frames") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_MAX_SWAPCHAIN_IMAGES, + "Max swapchain images") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_MESSAGE_POS_X, + "Notification X Position") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_MESSAGE_POS_Y, + "Notification Y Position") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_MONITOR_INDEX, + "Monitor Index") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_POST_FILTER_RECORD, + "Use Post Filter Recording") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_REFRESH_RATE, + "Vertical Refresh Rate") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_REFRESH_RATE_AUTO, + "Estimated Screen Framerate") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_ROTATION, + "Rotation") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SCALE, + "Windowed Scale") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SCALE_INTEGER, + "Integer Scale") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SETTINGS, + "Video") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_DIR, + "Video Shader") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_NUM_PASSES, + "Shader Passes") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PARAMETERS, + "Preview Shader Parameters") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET, + "Load Shader Preset") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_PARAMETERS, + "Menu Shader Parameters") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_AS, + "Save Shader Preset As") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_CORE, + "Save Core Preset") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_GAME, + "Save Game Preset") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHARED_CONTEXT, + "Enable Hardware Shared Context") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SMOOTH, + "Bilinear Filtering") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SOFT_FILTER, + "Soft Filter Enable") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SWAP_INTERVAL, + "Vertical Sync (Vsync) Swap Interval") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_TAB, + "Video") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_THREADED, + "Threaded Video") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_VFILTER, + "Deflicker") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_VIEWPORT_CUSTOM_HEIGHT, + "Custom Aspect Ratio Height") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_VIEWPORT_CUSTOM_WIDTH, + "Custom Aspect Ratio Width") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_VIEWPORT_CUSTOM_X, + "Custom Aspect Ratio X Pos.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_VIEWPORT_CUSTOM_Y, + "Custom Aspect Ratio Y Pos.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_VI_WIDTH, + "Set VI Screen Width") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_VSYNC, + "Vertical Sync (Vsync)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOWED_FULLSCREEN, + "Windowed Fullscreen Mode") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_WIDTH, + "Window Width") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_HEIGHT, + "Window Height") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_FULLSCREEN_X, + "Fullscreen Width") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_FULLSCREEN_Y, + "Fullscreen Height") +MSG_HASH(MENU_ENUM_LABEL_VALUE_WIFI_DRIVER, + "Wi-Fi Driver") +MSG_HASH(MENU_ENUM_LABEL_VALUE_WIFI_SETTINGS, + "Wi-Fi") +MSG_HASH(MENU_ENUM_LABEL_VALUE_XMB_ALPHA_FACTOR, + "Menu Alpha Factor") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_FONT_COLOR_RED, + "Menu Font Red Color") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_FONT_COLOR_GREEN, + "Menu Font Green Color") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_FONT_COLOR_BLUE, + "Menu Font Blue Color") +MSG_HASH(MENU_ENUM_LABEL_VALUE_XMB_FONT, + "Menu Font") +MSG_HASH(MENU_ENUM_LABEL_VALUE_XMB_ICON_THEME_CUSTOM, + "Custom") +MSG_HASH(MENU_ENUM_LABEL_VALUE_XMB_ICON_THEME_FLATUI, + "FlatUI") +MSG_HASH(MENU_ENUM_LABEL_VALUE_XMB_ICON_THEME_MONOCHROME, + "Monochrome") +MSG_HASH(MENU_ENUM_LABEL_VALUE_XMB_ICON_THEME_MONOCHROME_INVERTED, + "Monochrome Inverted") +MSG_HASH(MENU_ENUM_LABEL_VALUE_XMB_ICON_THEME_SYSTEMATIC, + "Systematic") +MSG_HASH(MENU_ENUM_LABEL_VALUE_XMB_ICON_THEME_NEOACTIVE, + "NeoActive") +MSG_HASH(MENU_ENUM_LABEL_VALUE_XMB_ICON_THEME_PIXEL, + "Pixel") +MSG_HASH(MENU_ENUM_LABEL_VALUE_XMB_ICON_THEME_RETROACTIVE, + "RetroActive") +MSG_HASH(MENU_ENUM_LABEL_VALUE_XMB_ICON_THEME_RETROSYSTEM, + "Retrosystem") +MSG_HASH(MENU_ENUM_LABEL_VALUE_XMB_ICON_THEME_DOTART, + "Dot-Art") +MSG_HASH(MENU_ENUM_LABEL_VALUE_XMB_MENU_COLOR_THEME, + "Menu Color Theme") +MSG_HASH(MENU_ENUM_LABEL_VALUE_XMB_MENU_COLOR_THEME_APPLE_GREEN, + "Apple Green") +MSG_HASH(MENU_ENUM_LABEL_VALUE_XMB_MENU_COLOR_THEME_DARK, + "Dark") +MSG_HASH(MENU_ENUM_LABEL_VALUE_XMB_MENU_COLOR_THEME_LIGHT, + "Light") +MSG_HASH(MENU_ENUM_LABEL_VALUE_XMB_MENU_COLOR_THEME_DARK_PURPLE, + "Dark Purple") +MSG_HASH(MENU_ENUM_LABEL_VALUE_XMB_MENU_COLOR_THEME_ELECTRIC_BLUE, + "Electric Blue") +MSG_HASH(MENU_ENUM_LABEL_VALUE_XMB_MENU_COLOR_THEME_GOLDEN, + "Golden") +MSG_HASH(MENU_ENUM_LABEL_VALUE_XMB_MENU_COLOR_THEME_LEGACY_RED, + "Legacy Red") +MSG_HASH(MENU_ENUM_LABEL_VALUE_XMB_MENU_COLOR_THEME_MIDNIGHT_BLUE, + "Midnight Blue") +MSG_HASH(MENU_ENUM_LABEL_VALUE_XMB_MENU_COLOR_THEME_PLAIN, + "Plain") +MSG_HASH(MENU_ENUM_LABEL_VALUE_XMB_MENU_COLOR_THEME_UNDERSEA, + "Undersea") +MSG_HASH(MENU_ENUM_LABEL_VALUE_XMB_MENU_COLOR_THEME_VOLCANIC_RED, + "Volcanic Red") +MSG_HASH(MENU_ENUM_LABEL_VALUE_XMB_RIBBON_ENABLE, + "Menu Shader Pipeline") +MSG_HASH(MENU_ENUM_LABEL_VALUE_XMB_SCALE_FACTOR, + "Menu Scale Factor") +MSG_HASH(MENU_ENUM_LABEL_VALUE_XMB_SHADOWS_ENABLE, + "Icon Shadows Enable") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CONTENT_SHOW_HISTORY, + "Show History Tab") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CONTENT_SHOW_ADD, + "Show Import content Tab") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CONTENT_SHOW_FAVORITES, + "Show Favorites Tab") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CONTENT_SHOW_IMAGES, + "Show Image Tab") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CONTENT_SHOW_MUSIC, + "Show Music Tab") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CONTENT_SHOW_SETTINGS, + "Show Settings Tab") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CONTENT_SHOW_VIDEO, + "Show Video Tab") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CONTENT_SHOW_NETPLAY, + "Show Netplay Tab") +MSG_HASH(MENU_ENUM_LABEL_VALUE_XMB_THEME, + "Menu Icon Theme") +MSG_HASH(MENU_ENUM_LABEL_VALUE_YES, + "Yes") +MSG_HASH(MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_TWO, + "Shader Preset") +MSG_HASH(MENU_ENUM_SUBLABEL_CHEEVOS_ENABLE, + "Enable or disable achievements. For more information, visit http://retroachievements.org") +MSG_HASH(MENU_ENUM_SUBLABEL_CHEEVOS_TEST_UNOFFICIAL, + "Enable or disable unofficial achievements and/or beta features for testing purposes.") +MSG_HASH(MENU_ENUM_SUBLABEL_CHEEVOS_HARDCORE_MODE_ENABLE, + "Enable or disable savestates, cheats, rewind, fast-forward, pause, and slow-motion for all games.") +MSG_HASH(MENU_ENUM_SUBLABEL_CHEEVOS_LEADERBOARDS_ENABLE, + "Enable or disable in-game leaderboards. Has no effect if Hardcore Mode is disabled.") +MSG_HASH(MENU_ENUM_SUBLABEL_CHEEVOS_BADGES_ENABLE, + "Enable or disable badge display in Achievement List.") +MSG_HASH(MENU_ENUM_SUBLABEL_CHEEVOS_VERBOSE_ENABLE, + "Enable or disable OSD verbosity for achievements.") +MSG_HASH(MENU_ENUM_SUBLABEL_DRIVER_SETTINGS, + "Change drivers used by the system.") +MSG_HASH(MENU_ENUM_SUBLABEL_RETRO_ACHIEVEMENTS_SETTINGS, + "Change achievement settings.") +MSG_HASH(MENU_ENUM_SUBLABEL_CORE_SETTINGS, + "Change core settings.") +MSG_HASH(MENU_ENUM_SUBLABEL_RECORDING_SETTINGS, + "Change recording settings.") +MSG_HASH(MENU_ENUM_SUBLABEL_ONSCREEN_DISPLAY_SETTINGS, + "Change display overlay and keyboard overlay, and onscreen notification settings.") +MSG_HASH(MENU_ENUM_SUBLABEL_FRAME_THROTTLE_SETTINGS, + "Change rewind, fast-forward, and slow-motion settings.") +MSG_HASH(MENU_ENUM_SUBLABEL_SAVING_SETTINGS, + "Change saving settings.") +MSG_HASH(MENU_ENUM_SUBLABEL_LOGGING_SETTINGS, + "Change logging settings.") +MSG_HASH(MENU_ENUM_SUBLABEL_USER_INTERFACE_SETTINGS, + "Change user interface settings.") +MSG_HASH(MENU_ENUM_SUBLABEL_USER_SETTINGS, + "Change account, username, and language settings.") +MSG_HASH(MENU_ENUM_SUBLABEL_PRIVACY_SETTINGS, + "Change your privacy settings.") +MSG_HASH(MENU_ENUM_SUBLABEL_DIRECTORY_SETTINGS, + "Change default directories where files are located.") +MSG_HASH(MENU_ENUM_SUBLABEL_PLAYLIST_SETTINGS, + "Change playlist settings.") +MSG_HASH(MENU_ENUM_SUBLABEL_NETWORK_SETTINGS, + "Configure server and network settings.") +MSG_HASH(MENU_ENUM_SUBLABEL_ADD_CONTENT_LIST, + "Scan content and add to the database.") +MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_SETTINGS, + "Change audio output settings.") +MSG_HASH(MENU_ENUM_SUBLABEL_BLUETOOTH_ENABLE, + "Enable or disable bluetooth.") +MSG_HASH(MENU_ENUM_SUBLABEL_CONFIG_SAVE_ON_EXIT, + "Saves changes to the configuration file on exit.") +MSG_HASH(MENU_ENUM_SUBLABEL_CONFIGURATION_SETTINGS, + "Change default settings for configuration files.") +MSG_HASH(MENU_ENUM_SUBLABEL_CONFIGURATIONS_LIST, + "Manage and create configuration files.") +MSG_HASH(MENU_ENUM_SUBLABEL_CPU_CORES, + "Amount of cores that the CPU has.") +MSG_HASH(MENU_ENUM_SUBLABEL_FPS_SHOW, + "Displays the current framerate per second onscreen.") +MSG_HASH(MENU_ENUM_SUBLABEL_INPUT_HOTKEY_BINDS, + "Configure hotkey settings.") +MSG_HASH(MENU_ENUM_SUBLABEL_INPUT_MENU_ENUM_TOGGLE_GAMEPAD_COMBO, + "Gamepad button combination to toggle menu.") +MSG_HASH(MENU_ENUM_SUBLABEL_INPUT_SETTINGS, + "Change joypad, keyboard, and mouse settings.") +MSG_HASH(MENU_ENUM_SUBLABEL_INPUT_USER_BINDS, + "Configure controls for this user.") +MSG_HASH(MENU_ENUM_SUBLABEL_LOG_VERBOSITY, + "Enable or disable logging to the terminal.") +MSG_HASH(MENU_ENUM_SUBLABEL_NETPLAY, + "Join or host a netplay session.") +MSG_HASH(MENU_ENUM_SUBLABEL_NETPLAY_LAN_SCAN_SETTINGS, + "Search for and connect to netplay hosts on the local network.") +MSG_HASH(MENU_ENUM_SUBLABEL_INFORMATION_LIST_LIST, + "Display system information.") +MSG_HASH(MENU_ENUM_SUBLABEL_ONLINE_UPDATER, + "Download add-ons, components, and content for RetroArch.") +MSG_HASH(MENU_ENUM_SUBLABEL_SAMBA_ENABLE, + "Enable or disable network sharing of your folders.") +MSG_HASH(MENU_ENUM_SUBLABEL_SERVICES_SETTINGS, + "Manage operating system level services.") +MSG_HASH(MENU_ENUM_SUBLABEL_SHOW_HIDDEN_FILES, + "Show hidden files/directories inside the file browser.") +MSG_HASH(MENU_ENUM_SUBLABEL_SSH_ENABLE, + "Enable or disable remote command line access.") +MSG_HASH(MENU_ENUM_SUBLABEL_SUSPEND_SCREENSAVER_ENABLE, + "Prevents your system's screensaver from becoming active.") +MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_WINDOW_SCALE, + "Sets the window size relative to the core viewport size. Alternatively, you can set a window width and height below for a fixed window size.") +MSG_HASH(MENU_ENUM_SUBLABEL_USER_LANGUAGE, + "Sets the language of the interface.") +MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_BLACK_FRAME_INSERTION, + "Inserts a black frame inbetween frames. Useful for users with 120Hz screens who want to play 60Hz content to eliminate ghosting.") +MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_FRAME_DELAY, + "Reduces latency at the cost of a higher risk of video stuttering. Adds a delay after V-Sync (in ms).") +MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_HARD_SYNC_FRAMES, + "Sets how many frames the CPU can run ahead of the GPU when using 'Hard GPU Sync'.") +MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_MAX_SWAPCHAIN_IMAGES, + "Tells the video driver to explicitly use a specified buffering mode.") +MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_MONITOR_INDEX, + "Selects which display screen to use.") +MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_REFRESH_RATE_AUTO, + "The accurate estimated refresh rate of the screen in Hz.") +MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_SETTINGS, + "Change video output settings.") +MSG_HASH(MENU_ENUM_SUBLABEL_WIFI_SETTINGS, + "Scans for wireless networks and establishes connection.") +MSG_HASH(MENU_ENUM_SUBLABEL_HELP_LIST, + "Learn more about how the program works.") +MSG_HASH(MSG_ADDED_TO_FAVORITES, + "Added to favorites") +MSG_HASH(MSG_APPENDED_DISK, + "Appended disk") +MSG_HASH(MSG_APPLICATION_DIR, + "Application Dir") +MSG_HASH(MSG_APPLYING_CHEAT, + "Applying cheat changes.") +MSG_HASH(MSG_APPLYING_SHADER, + "Applying shader") +MSG_HASH(MSG_AUDIO_MUTED, + "Audio muted.") +MSG_HASH(MSG_AUDIO_UNMUTED, + "Audio unmuted.") +MSG_HASH(MSG_AUTOCONFIG_FILE_ERROR_SAVING, + "Error saving autoconf file.") +MSG_HASH(MSG_AUTOCONFIG_FILE_SAVED_SUCCESSFULLY, + "Autoconfig file saved successfully.") +MSG_HASH(MSG_AUTOSAVE_FAILED, + "Could not initialize autosave.") +MSG_HASH(MSG_AUTO_SAVE_STATE_TO, + "Auto save state to") +MSG_HASH(MSG_BLOCKING_SRAM_OVERWRITE, + "Blocking SRAM Overwrite") +MSG_HASH(MSG_BRINGING_UP_COMMAND_INTERFACE_ON_PORT, + "Bringing up command interface on port") +MSG_HASH(MSG_BYTES, + "bytes") +MSG_HASH(MSG_CANNOT_INFER_NEW_CONFIG_PATH, + "Cannot infer new config path. Use current time.") +MSG_HASH(MSG_CHEEVOS_HARDCORE_MODE_ENABLE, + "Hardcore Mode Enabled, savestate & rewind were disabled.") +MSG_HASH(MSG_COMPARING_WITH_KNOWN_MAGIC_NUMBERS, + "Comparing with known magic numbers...") +MSG_HASH(MSG_COMPILED_AGAINST_API, + "Compiled against API") +MSG_HASH(MSG_CONFIG_DIRECTORY_NOT_SET, + "Config directory not set. Cannot save new config.") +MSG_HASH(MSG_CONNECTED_TO, + "Connected to") +MSG_HASH(MSG_CONTENT_CRC32S_DIFFER, + "Content CRC32s differ. Cannot use different games.") +MSG_HASH(MSG_CONTENT_LOADING_SKIPPED_IMPLEMENTATION_WILL_DO_IT, + "Content loading skipped. Implementation will load it on its own.") +MSG_HASH(MSG_CORE_DOES_NOT_SUPPORT_SAVESTATES, + "Core does not support save states.") +MSG_HASH(MSG_CORE_OPTIONS_FILE_CREATED_SUCCESSFULLY, + "Core options file created successfully.") +MSG_HASH(MSG_COULD_NOT_FIND_ANY_NEXT_DRIVER, + "Could not find any next driver") +MSG_HASH(MSG_COULD_NOT_FIND_COMPATIBLE_SYSTEM, + "Could not find compatible system.") +MSG_HASH(MSG_COULD_NOT_FIND_VALID_DATA_TRACK, + "Could not find valid data track") +MSG_HASH(MSG_COULD_NOT_OPEN_DATA_TRACK, + "could not open data track") +MSG_HASH(MSG_COULD_NOT_READ_CONTENT_FILE, + "Could not read content file") +MSG_HASH(MSG_COULD_NOT_READ_MOVIE_HEADER, + "Could not read movie header.") +MSG_HASH(MSG_COULD_NOT_READ_STATE_FROM_MOVIE, + "Could not read state from movie.") +MSG_HASH(MSG_CRC32_CHECKSUM_MISMATCH, + "CRC32 checksum mismatch between content file and saved content checksum in replay file header. Replay highly likely to desync on playback.") +MSG_HASH(MSG_CUSTOM_TIMING_GIVEN, + "Custom timing given") +MSG_HASH(MSG_DECOMPRESSION_ALREADY_IN_PROGRESS, + "Decompression already in progress.") +MSG_HASH(MSG_DECOMPRESSION_FAILED, + "Decompression failed.") +MSG_HASH(MSG_DETECTED_VIEWPORT_OF, + "Detected viewport of") +MSG_HASH(MSG_DID_NOT_FIND_A_VALID_CONTENT_PATCH, + "Did not find a valid content patch.") +MSG_HASH(MSG_DISCONNECT_DEVICE_FROM_A_VALID_PORT, + "Disconnect device from a valid port.") +MSG_HASH(MSG_DISK_CLOSED, + "Closed") +MSG_HASH(MSG_DISK_EJECTED, + "Ejected") +MSG_HASH(MSG_DOWNLOADING, + "Downloading") +MSG_HASH(MSG_DOWNLOAD_FAILED, + "Download failed") +MSG_HASH(MSG_ERROR, + "Error") +MSG_HASH(MSG_ERROR_LIBRETRO_CORE_REQUIRES_CONTENT, + "Libretro core requires content, but nothing was provided.") +MSG_HASH(MSG_ERROR_LIBRETRO_CORE_REQUIRES_SPECIAL_CONTENT, + "Libretro core requires special content, but none were provided.") +MSG_HASH(MSG_ERROR_PARSING_ARGUMENTS, + "Error parsing arguments.") +MSG_HASH(MSG_ERROR_SAVING_CORE_OPTIONS_FILE, + "Error saving core options file.") +MSG_HASH(MSG_ERROR_SAVING_REMAP_FILE, + "Error saving remap file.") +MSG_HASH(MSG_ERROR_REMOVING_REMAP_FILE, + "Error removing remap file.") +MSG_HASH(MSG_ERROR_SAVING_SHADER_PRESET, + "Error saving shader preset.") +MSG_HASH(MSG_EXTERNAL_APPLICATION_DIR, + "External Application Dir") +MSG_HASH(MSG_EXTRACTING, + "Extracting") +MSG_HASH(MSG_EXTRACTING_FILE, + "Extracting file") +MSG_HASH(MSG_FAILED_SAVING_CONFIG_TO, + "Failed saving config to") +MSG_HASH(MSG_FAILED_TO, + "Failed to") +MSG_HASH(MSG_FAILED_TO_ACCEPT_INCOMING_SPECTATOR, + "Failed to accept incoming spectator.") +MSG_HASH(MSG_FAILED_TO_ALLOCATE_MEMORY_FOR_PATCHED_CONTENT, + "Failed to allocate memory for patched content...") +MSG_HASH(MSG_FAILED_TO_APPLY_SHADER, + "Failed to apply shader.") +MSG_HASH(MSG_FAILED_TO_BIND_SOCKET, + "Failed to bind socket.") +MSG_HASH(MSG_FAILED_TO_CREATE_THE_DIRECTORY, + "Failed to create the directory.") +MSG_HASH(MSG_FAILED_TO_EXTRACT_CONTENT_FROM_COMPRESSED_FILE, + "Failed to extract content from compressed file") +MSG_HASH(MSG_FAILED_TO_GET_NICKNAME_FROM_CLIENT, + "Failed to get nickname from client.") +MSG_HASH(MSG_FAILED_TO_LOAD, + "Failed to load") +MSG_HASH(MSG_FAILED_TO_LOAD_CONTENT, + "Failed to load content") +MSG_HASH(MSG_FAILED_TO_LOAD_MOVIE_FILE, + "Failed to load movie file") +MSG_HASH(MSG_FAILED_TO_LOAD_OVERLAY, + "Failed to load overlay.") +MSG_HASH(MSG_FAILED_TO_LOAD_STATE, + "Failed to load state from") +MSG_HASH(MSG_FAILED_TO_OPEN_LIBRETRO_CORE, + "Failed to open libretro core") +MSG_HASH(MSG_FAILED_TO_PATCH, + "Failed to patch") +MSG_HASH(MSG_FAILED_TO_RECEIVE_HEADER_FROM_CLIENT, + "Failed to receive header from client.") +MSG_HASH(MSG_FAILED_TO_RECEIVE_NICKNAME, + "Failed to receive nickname.") +MSG_HASH(MSG_FAILED_TO_RECEIVE_NICKNAME_FROM_HOST, + "Failed to receive nickname from host.") +MSG_HASH(MSG_FAILED_TO_RECEIVE_NICKNAME_SIZE_FROM_HOST, + "Failed to receive nickname size from host.") +MSG_HASH(MSG_FAILED_TO_RECEIVE_SRAM_DATA_FROM_HOST, + "Failed to receive SRAM data from host.") +MSG_HASH(MSG_FAILED_TO_REMOVE_DISK_FROM_TRAY, + "Failed to remove disk from tray.") +MSG_HASH(MSG_FAILED_TO_REMOVE_TEMPORARY_FILE, + "Failed to remove temporary file") +MSG_HASH(MSG_FAILED_TO_SAVE_SRAM, + "Failed to save SRAM") +MSG_HASH(MSG_FAILED_TO_SAVE_STATE_TO, + "Failed to save state to") +MSG_HASH(MSG_FAILED_TO_SEND_NICKNAME, + "Failed to send nickname.") +MSG_HASH(MSG_FAILED_TO_SEND_NICKNAME_SIZE, + "Failed to send nickname size.") +MSG_HASH(MSG_FAILED_TO_SEND_NICKNAME_TO_CLIENT, + "Failed to send nickname to client.") +MSG_HASH(MSG_FAILED_TO_SEND_NICKNAME_TO_HOST, + "Failed to send nickname to host.") +MSG_HASH(MSG_FAILED_TO_SEND_SRAM_DATA_TO_CLIENT, + "Failed to send SRAM data to client.") +MSG_HASH(MSG_FAILED_TO_START_AUDIO_DRIVER, + "Failed to start audio driver. Will continue without audio.") +MSG_HASH(MSG_FAILED_TO_START_MOVIE_RECORD, + "Failed to start movie record.") +MSG_HASH(MSG_FAILED_TO_START_RECORDING, + "Failed to start recording.") +MSG_HASH(MSG_FAILED_TO_TAKE_SCREENSHOT, + "Failed to take screenshot.") +MSG_HASH(MSG_FAILED_TO_UNDO_LOAD_STATE, + "Failed to undo load state.") +MSG_HASH(MSG_FAILED_TO_UNDO_SAVE_STATE, + "Failed to undo save state.") +MSG_HASH(MSG_FAILED_TO_UNMUTE_AUDIO, + "Failed to unmute audio.") +MSG_HASH(MSG_FATAL_ERROR_RECEIVED_IN, + "Fatal error received in") +MSG_HASH(MSG_FILE_NOT_FOUND, + "File not found") +MSG_HASH(MSG_FOUND_AUTO_SAVESTATE_IN, + "Found auto savestate in") +MSG_HASH(MSG_FOUND_DISK_LABEL, + "Found disk label") +MSG_HASH(MSG_FOUND_FIRST_DATA_TRACK_ON_FILE, + "Found first data track on file") +MSG_HASH(MSG_FOUND_LAST_STATE_SLOT, + "Found last state slot") +MSG_HASH(MSG_FOUND_SHADER, + "Found shader") +MSG_HASH(MSG_FRAMES, + "Frames") +MSG_HASH(MSG_GAME_SPECIFIC_CORE_OPTIONS_FOUND_AT, + "Per-Game Options: game-specific core options found at") +MSG_HASH(MSG_GOT_INVALID_DISK_INDEX, + "Got invalid disk index.") +MSG_HASH(MSG_GRAB_MOUSE_STATE, + "Grab mouse state") +MSG_HASH(MSG_GAME_FOCUS_ON, + "Game focus on") +MSG_HASH(MSG_GAME_FOCUS_OFF, + "Game focus off") +MSG_HASH(MSG_HW_RENDERED_MUST_USE_POSTSHADED_RECORDING, + "Libretro core is hardware rendered. Must use post-shaded recording as well.") +MSG_HASH(MSG_INFLATED_CHECKSUM_DID_NOT_MATCH_CRC32, + "Inflated checksum did not match CRC32.") +MSG_HASH(MSG_INPUT_CHEAT, + "Input Cheat") +MSG_HASH(MSG_INPUT_CHEAT_FILENAME, + "Input Cheat Filename") +MSG_HASH(MSG_INPUT_PRESET_FILENAME, + "Input Preset Filename") +MSG_HASH(MSG_INPUT_RENAME_ENTRY, + "Rename Title") +MSG_HASH(MSG_INTERFACE, + "Interface") +MSG_HASH(MSG_INTERNAL_STORAGE, + "Internal Storage") +MSG_HASH(MSG_REMOVABLE_STORAGE, + "Removable Storage") +MSG_HASH(MSG_INVALID_NICKNAME_SIZE, + "Invalid nickname size.") +MSG_HASH(MSG_IN_BYTES, + "in bytes") +MSG_HASH(MSG_IN_GIGABYTES, + "in gigabytes") +MSG_HASH(MSG_IN_MEGABYTES, + "in megabytes") +MSG_HASH(MSG_LIBRETRO_ABI_BREAK, + "is compiled against a different version of libretro than this libretro implementation.") +MSG_HASH(MSG_LIBRETRO_FRONTEND, + "Frontend for libretro") +MSG_HASH(MSG_LOADED_STATE_FROM_SLOT, + "Loaded state from slot #%d.") +MSG_HASH(MSG_LOADED_STATE_FROM_SLOT_AUTO, + "Loaded state from slot #-1 (auto).") +MSG_HASH(MSG_LOADING, + "Loading") +MSG_HASH(MSG_FIRMWARE, + "One or more firmware files are missing") +MSG_HASH(MSG_LOADING_CONTENT_FILE, + "Loading content file") +MSG_HASH(MSG_LOADING_HISTORY_FILE, + "Loading history file") +MSG_HASH(MSG_LOADING_STATE, + "Loading state") +MSG_HASH(MSG_MEMORY, + "Memory") +MSG_HASH(MSG_MOVIE_FILE_IS_NOT_A_VALID_BSV1_FILE, + "Movie file is not a valid BSV1 file.") +MSG_HASH(MSG_MOVIE_FORMAT_DIFFERENT_SERIALIZER_VERSION, + "Movie format seems to have a different serializer version. Will most likely fail.") +MSG_HASH(MSG_MOVIE_PLAYBACK_ENDED, + "Movie playback ended.") +MSG_HASH(MSG_MOVIE_RECORD_STOPPED, + "Stopping movie record.") +MSG_HASH(MSG_NETPLAY_FAILED, + "Failed to initialize netplay.") +MSG_HASH(MSG_NO_CONTENT_STARTING_DUMMY_CORE, + "No content, starting dummy core.") +MSG_HASH(MSG_NO_SAVE_STATE_HAS_BEEN_OVERWRITTEN_YET, + "No save state has been overwritten yet.") +MSG_HASH(MSG_NO_STATE_HAS_BEEN_LOADED_YET, + "No state has been loaded yet.") +MSG_HASH(MSG_OVERRIDES_ERROR_SAVING, + "Error saving overrides.") +MSG_HASH(MSG_OVERRIDES_SAVED_SUCCESSFULLY, + "Overrides saved successfully.") +MSG_HASH(MSG_PAUSED, + "Paused.") +MSG_HASH(MSG_PROGRAM, + "رتروارش") +MSG_HASH(MSG_READING_FIRST_DATA_TRACK, + "Reading first data track...") +MSG_HASH(MSG_RECEIVED, + "received") +MSG_HASH(MSG_RECORDING_TERMINATED_DUE_TO_RESIZE, + "Recording terminated due to resize.") +MSG_HASH(MSG_RECORDING_TO, + "Recording to") +MSG_HASH(MSG_REDIRECTING_CHEATFILE_TO, + "Redirecting cheat file to") +MSG_HASH(MSG_REDIRECTING_SAVEFILE_TO, + "Redirecting save file to") +MSG_HASH(MSG_REDIRECTING_SAVESTATE_TO, + "Redirecting savestate to") +MSG_HASH(MSG_REMAP_FILE_SAVED_SUCCESSFULLY, + "Remap file saved successfully.") +MSG_HASH(MSG_REMAP_FILE_REMOVED_SUCCESSFULLY, + "Remap file removed successfully.") +MSG_HASH(MSG_REMOVED_DISK_FROM_TRAY, + "Removed disk from tray.") +MSG_HASH(MSG_REMOVING_TEMPORARY_CONTENT_FILE, + "Removing temporary content file") +MSG_HASH(MSG_RESET, + "Reset") +MSG_HASH(MSG_RESTARTING_RECORDING_DUE_TO_DRIVER_REINIT, + "Restarting recording due to driver reinit.") +MSG_HASH(MSG_RESTORED_OLD_SAVE_STATE, + "Restored old save state.") +MSG_HASH(MSG_RESTORING_DEFAULT_SHADER_PRESET_TO, + "Shaders: restoring default shader preset to") +MSG_HASH(MSG_REVERTING_SAVEFILE_DIRECTORY_TO, + "Reverting savefile directory to") +MSG_HASH(MSG_REVERTING_SAVESTATE_DIRECTORY_TO, + "Reverting savestate directory to") +MSG_HASH(MSG_REWINDING, + "Rewinding.") +MSG_HASH(MSG_REWIND_INIT, + "Initializing rewind buffer with size") +MSG_HASH(MSG_REWIND_INIT_FAILED, + "Failed to initialize rewind buffer. Rewinding will be disabled.") +MSG_HASH(MSG_REWIND_INIT_FAILED_THREADED_AUDIO, + "Implementation uses threaded audio. Cannot use rewind.") +MSG_HASH(MSG_REWIND_REACHED_END, + "Reached end of rewind buffer.") +MSG_HASH(MSG_SAVED_NEW_CONFIG_TO, + "Saved new config to") +MSG_HASH(MSG_SAVED_STATE_TO_SLOT, + "Saved state to slot #%d.") +MSG_HASH(MSG_SAVED_STATE_TO_SLOT_AUTO, + "Saved state to slot #-1 (auto).") +MSG_HASH(MSG_SAVED_SUCCESSFULLY_TO, + "Saved successfully to") +MSG_HASH(MSG_SAVING_RAM_TYPE, + "Saving RAM type") +MSG_HASH(MSG_SAVING_STATE, + "Saving state") +MSG_HASH(MSG_SCANNING, + "Scanning") +MSG_HASH(MSG_SCANNING_OF_DIRECTORY_FINISHED, + "Scanning of directory finished") +MSG_HASH(MSG_SENDING_COMMAND, + "Sending command") +MSG_HASH(MSG_SEVERAL_PATCHES_ARE_EXPLICITLY_DEFINED, + "Several patches are explicitly defined, ignoring all...") +MSG_HASH(MSG_SHADER, + "Shader") +MSG_HASH(MSG_SHADER_PRESET_SAVED_SUCCESSFULLY, + "Shader preset saved successfully.") +MSG_HASH(MSG_SKIPPING_SRAM_LOAD, + "Skipping SRAM load.") +MSG_HASH(MSG_SLOW_MOTION, + "Slow motion.") +MSG_HASH(MSG_FAST_FORWARD, + "Fast forward.") +MSG_HASH(MSG_SLOW_MOTION_REWIND, + "Slow motion rewind.") +MSG_HASH(MSG_SRAM_WILL_NOT_BE_SAVED, + "SRAM will not be saved.") +MSG_HASH(MSG_STARTING_MOVIE_PLAYBACK, + "Starting movie playback.") +MSG_HASH(MSG_STARTING_MOVIE_RECORD_TO, + "Starting movie record to") +MSG_HASH(MSG_STATE_SIZE, + "State size") +MSG_HASH(MSG_STATE_SLOT, + "State slot") +MSG_HASH(MSG_TAKING_SCREENSHOT, + "Taking screenshot.") +MSG_HASH(MSG_TO, + "to") +MSG_HASH(MSG_UNDID_LOAD_STATE, + "Undid load state.") +MSG_HASH(MSG_UNDOING_SAVE_STATE, + "Undoing save state") +MSG_HASH(MSG_UNKNOWN, + "Unknown") +MSG_HASH(MSG_UNPAUSED, + "Unpaused.") +MSG_HASH(MSG_UNRECOGNIZED_COMMAND, + "Unrecognized command") +MSG_HASH(MSG_USING_CORE_NAME_FOR_NEW_CONFIG, + "Using core name for new config.") +MSG_HASH(MSG_USING_LIBRETRO_DUMMY_CORE_RECORDING_SKIPPED, + "Using libretro dummy core. Skipping recording.") +MSG_HASH(MSG_VALUE_CONNECT_DEVICE_FROM_A_VALID_PORT, + "Connect device from a valid port.") +MSG_HASH(MSG_VALUE_DISCONNECTING_DEVICE_FROM_PORT, + "Disconnecting device from port") +MSG_HASH(MSG_VALUE_REBOOTING, + "Rebooting...") +MSG_HASH(MSG_VALUE_SHUTTING_DOWN, + "Shutting down...") +MSG_HASH(MSG_VERSION_OF_LIBRETRO_API, + "Version of libretro API") +MSG_HASH(MSG_VIEWPORT_SIZE_CALCULATION_FAILED, + "Viewport size calculation failed! Will continue using raw data. This will probably not work right ...") +MSG_HASH(MSG_VIRTUAL_DISK_TRAY, + "virtual disk tray.") +MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_LATENCY, + "Desired audio latency in milliseconds. Might not be honored if the audio driver can't provide given latency.") +MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_MUTE, + "Mute/unmute audio.") +MSG_HASH( + MENU_ENUM_SUBLABEL_AUDIO_RATE_CONTROL_DELTA, + "Helps smooth out imperfections in timing when synchronizing audio and video. Be aware that if disabled, proper synchronization is nearly impossible to obtain." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_CAMERA_ALLOW, + "Allow or disallow camera access by cores." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_LOCATION_ALLOW, + "Allow or disallow location services access by cores." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_INPUT_MAX_USERS, + "Maximum amount of users supported by RetroArch." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_INPUT_POLL_TYPE_BEHAVIOR, + "Influence how input polling is done inside RetroArch. Setting it to 'Early' or 'Late' can result in less latency, depending on your configuration." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_INPUT_ALL_USERS_CONTROL_MENU, + "Allows any user to control the menu. If disabled, only User 1 can control the menu." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_AUDIO_VOLUME, + "Audio volume (in dB). 0 dB is normal volume, and no gain is applied." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_AUDIO_WASAPI_EXCLUSIVE_MODE, + "Allow the WASAPI driver to take exclusive control of the audio device. If disabled, it will use shared mode instead." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_AUDIO_WASAPI_FLOAT_FORMAT, + "Use float format for the WASAPI driver, if supported by your audio device." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_AUDIO_WASAPI_SH_BUFFER_LENGTH, + "The intermediate buffer length (in frames) when using the WASAPI driver in shared mode." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_AUDIO_SYNC, + "Synchronize audio. Recommended." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_INPUT_AXIS_THRESHOLD, + "How far an axis must be tilted to result in a button press." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_INPUT_BIND_TIMEOUT, + "Amount of seconds to wait until proceeding to the next bind." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_INPUT_TURBO_PERIOD, + "Describes the period when turbo-enabled buttons are toggled. Numbers are described in frames." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_INPUT_DUTY_CYCLE, + "Describes how long the period of a turbo-enabled button should be. Numbers are described in frames." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_VSYNC, + "Synchronizes the output video of the graphics card to the refresh rate of the screen. Recommended." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_ALLOW_ROTATE, + "Allow cores to set rotation. When disabled, rotation requests are ignored. Useful for setups where one manually rotates the screen." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_DUMMY_ON_CORE_SHUTDOWN, + "Some cores might have a shutdown feature. If enabled, it will prevent the core from shutting RetroArch down. Instead, it loads a dummy core." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_CHECK_FOR_MISSING_FIRMWARE, + "Check if all the required firmware is present before attempting to load content." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_REFRESH_RATE, + "Vertical refresh rate of your screen. Used to calculate a suitable audio input rate. NOTE: This will be ignored if 'Threaded Video' is enabled." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_AUDIO_ENABLE, + "Enable audio output." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_AUDIO_MAX_TIMING_SKEW, + "The maximum change in audio input rate. Increasing this enables very large changes in timing at the cost of an inaccurate audio pitch (e.g., running PAL cores on NTSC displays)." + ) +MSG_HASH( + MSG_FAILED, + "failed" + ) +MSG_HASH( + MSG_SUCCEEDED, + "succeeded" + ) +MSG_HASH( + MSG_DEVICE_NOT_CONFIGURED, + "not configured" + ) +MSG_HASH( + MSG_DEVICE_NOT_CONFIGURED_FALLBACK, + "not configured, using fallback" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_DATABASE_CURSOR_LIST, + "Database Cursor List" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_DATABASE_CURSOR_LIST_ENTRY_DEVELOPER, + "Database - Filter : Developer" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_DATABASE_CURSOR_LIST_ENTRY_PUBLISHER, + "Database - Filter : Publisher" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_DISABLED, + "Disabled" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_ENABLED, + "Enabled" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CONTENT_HISTORY_PATH, + "Content History Path" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_DATABASE_CURSOR_LIST_ENTRY_ORIGIN, + "Database - Filter : Origin") +MSG_HASH(MENU_ENUM_LABEL_VALUE_DATABASE_CURSOR_LIST_ENTRY_FRANCHISE, + "Database - Filter : Franchise") +MSG_HASH(MENU_ENUM_LABEL_VALUE_DATABASE_CURSOR_LIST_ENTRY_ESRB_RATING, + "Database - Filter : ESRB Rating") +MSG_HASH(MENU_ENUM_LABEL_VALUE_DATABASE_CURSOR_LIST_ENTRY_ELSPA_RATING, + "Database - Filter : ELSPA Rating") +MSG_HASH(MENU_ENUM_LABEL_VALUE_DATABASE_CURSOR_LIST_ENTRY_PEGI_RATING, + "Database - Filter : PEGI Rating") +MSG_HASH(MENU_ENUM_LABEL_VALUE_DATABASE_CURSOR_LIST_ENTRY_CERO_RATING, + "Database - Filter : CERO Rating") +MSG_HASH(MENU_ENUM_LABEL_VALUE_DATABASE_CURSOR_LIST_ENTRY_BBFC_RATING, + "Database - Filter : BBFC Rating") +MSG_HASH(MENU_ENUM_LABEL_VALUE_DATABASE_CURSOR_LIST_ENTRY_MAX_USERS, + "Database - Filter : Max Users") +MSG_HASH(MENU_ENUM_LABEL_VALUE_DATABASE_CURSOR_LIST_ENTRY_RELEASEDATE_BY_MONTH, + "Database - Filter : Releasedate By Month") +MSG_HASH(MENU_ENUM_LABEL_VALUE_DATABASE_CURSOR_LIST_ENTRY_RELEASEDATE_BY_YEAR, + "Database - Filter : Releasedate By Year") +MSG_HASH(MENU_ENUM_LABEL_VALUE_DATABASE_CURSOR_LIST_ENTRY_EDGE_MAGAZINE_ISSUE, + "Database - Filter : Edge Magazine Issue") +MSG_HASH(MENU_ENUM_LABEL_VALUE_DATABASE_CURSOR_LIST_ENTRY_EDGE_MAGAZINE_RATING, + "Database - Filter : Edge Magazine Rating") +MSG_HASH(MENU_ENUM_LABEL_VALUE_DATABASE_CURSOR_LIST_ENTRY_DATABASE_INFO, + "Database Info") +MSG_HASH(MSG_WIFI_SCAN_COMPLETE, + "Wi-Fi scan complete.") +MSG_HASH(MSG_SCANNING_WIRELESS_NETWORKS, + "Scanning wireless networks...") +MSG_HASH(MSG_NETPLAY_LAN_SCAN_COMPLETE, + "Netplay scan complete.") +MSG_HASH(MSG_NETPLAY_LAN_SCANNING, + "Scanning for netplay hosts...") +MSG_HASH(MENU_ENUM_SUBLABEL_PAUSE_NONACTIVE, + "Pause gameplay when RetroArch is not the active window.") +MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_DISABLE_COMPOSITION, + "Enable or disable composition (Windows only).") +MSG_HASH(MENU_ENUM_SUBLABEL_HISTORY_LIST_ENABLE, + "Enable or disable recent playlist for games, images, music, and videos.") +MSG_HASH(MENU_ENUM_SUBLABEL_CONTENT_HISTORY_SIZE, + "Limit the number of entries in recent playlist for games, images, music, and videos.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_UNIFIED_MENU_CONTROLS, + "Unified Menu Controls") +MSG_HASH(MENU_ENUM_SUBLABEL_INPUT_UNIFIED_MENU_CONTROLS, + "Use the same controls for both the menu and the game. Applies to the keyboard.") +MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_FONT_ENABLE, + "Show onscreen messages.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETWORK_USER_REMOTE_ENABLE, + "User %d Remote Enable") +MSG_HASH(MENU_ENUM_LABEL_VALUE_BATTERY_LEVEL_ENABLE, + "Show battery level") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SELECT_FILE, + "Select File") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SELECT_FROM_COLLECTION, + "Select From Collection") +MSG_HASH(MENU_ENUM_LABEL_VALUE_FILTER, + "Filter") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SCALE, + "Scale") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_START_WHEN_LOADED, + "Netplay will start when content is loaded.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_LOAD_CONTENT_MANUALLY, + "Couldn't find a suitable core or content file, load manually.") +MSG_HASH( + MENU_ENUM_LABEL_VALUE_BROWSE_URL_LIST, + "Browse URL" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_BROWSE_URL, + "URL Path" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_BROWSE_START, + "Start" + ) +MSG_HASH(MENU_ENUM_LABEL_VALUE_SHADER_PIPELINE_BOKEH, + "Bokeh") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SHADER_PIPELINE_SNOWFLAKE, + "Snowflake") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_REFRESH_ROOMS, + "Refresh Room List") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ROOM_NICKNAME, + "Nickname: %s") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ROOM_NICKNAME_LAN, + "Nickname (lan): %s") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_COMPAT_CONTENT_FOUND, + "Compatible content found") +MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_CROP_OVERSCAN, + "Cuts off a few pixels around the edges of the image customarily left blank by developers which sometimes also contain garbage pixels.") +MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_SMOOTH, + "Adds a slight blur to the image to take the edge off of the hard pixel edges. This option has very little impact on performance.") +MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_FILTER, + "Apply a CPU-powered video filter. NOTE: Might come at a high performance cost. Some video filters might only work for cores that use 32bit or 16bit color.") +MSG_HASH(MENU_ENUM_SUBLABEL_CHEEVOS_USERNAME, + "Input the username of your RetroAchievements account.") +MSG_HASH(MENU_ENUM_SUBLABEL_CHEEVOS_PASSWORD, + "Input the password of your RetroAchievements account.") +MSG_HASH(MENU_ENUM_SUBLABEL_NETPLAY_NICKNAME, + "Input your user name here. This will be used for netplay sessions, among other things.") +MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_POST_FILTER_RECORD, + "Capture the image after filters (but not shaders) are applied. Your video will look as fancy as what you see on your screen.") +MSG_HASH(MENU_ENUM_SUBLABEL_CORE_LIST, + "Select which core to use.") +MSG_HASH(MENU_ENUM_SUBLABEL_LOAD_CONTENT_LIST, + "Select which content to start.") +MSG_HASH(MENU_ENUM_SUBLABEL_NETWORK_INFORMATION, + "Show network interface(s) and associated IP addresses.") +MSG_HASH(MENU_ENUM_SUBLABEL_SYSTEM_INFORMATION, + "Show information specific to the device.") +MSG_HASH(MENU_ENUM_SUBLABEL_QUIT_RETROARCH, + "Quit the program.") +MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_WINDOW_WIDTH, + "Set the custom width size for the display window. Leaving it at 0 will attempt to scale the window as large as possible.") +MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_WINDOW_HEIGHT, + "Set the custom height size for the display window. Leaving it at 0 will attempt to scale the window as large as possible.") +MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_FULLSCREEN_X, + "Set the custom width size for the non-windowed fullscreen mode. Leaving it at 0 will use the desktop resolution.") +MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_FULLSCREEN_Y, + "Set the custom height size for the non-windowed fullscreen mode. Leaving it at 0 will use the desktop resolution") +MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_MESSAGE_POS_X, + "Specify custom X axis position for onscreen text.") +MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_MESSAGE_POS_Y, + "Specify custom Y axis position for onscreen text.") +MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_FONT_SIZE, + "Specify the font size in points.") +MSG_HASH(MENU_ENUM_SUBLABEL_INPUT_OVERLAY_HIDE_IN_MENU, + "Hide the overlay while inside the menu, and show it again when exiting the menu.") +MSG_HASH(MENU_ENUM_SUBLABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS, + "Show keyboard/controller inputs on the onscreen overlay.") +MSG_HASH(MENU_ENUM_SUBLABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS_PORT, + "Select the port for the overlay to listen to if Show Inputs On Overlay is enabled.") +MSG_HASH( + MENU_ENUM_SUBLABEL_CONTENT_COLLECTION_LIST, + "Scanned content will appear here." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_SCALE_INTEGER, + "Only scales video in integer steps. The base size depends on system-reported geometry and aspect ratio. If 'Force Aspect' is not set, X/Y will be integer scaled independently." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_GPU_SCREENSHOT, + "Screenshots output of GPU shaded material if available." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_ROTATION, + "Forces a certain rotation of the screen. The rotation is added to rotations which the core sets." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_FORCE_SRGB_DISABLE, + "Forcibly disable sRGB FBO support. Some Intel OpenGL drivers on Windows have video problems with sRGB FBO support if this is enabled. Enabling this can work around it." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_FULLSCREEN, + "Start in fullscreen. Can be changed at runtime. Can be overriden by a command line switch" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_WINDOWED_FULLSCREEN, + "If fullscreen, prefer using a windowed fullscreen mode." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_GPU_RECORD, + "Records output of GPU shaded material if available." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_SAVESTATE_AUTO_INDEX, + "When making a savestate, save state index is automatically increased before it is saved. When loading content, the index will be set to the highest existing index." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_BLOCK_SRAM_OVERWRITE, + "Block Save RAM from being overwritten when loading save states. Might potentially lead to buggy games." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_FASTFORWARD_RATIO, + "The maximum rate at which content will be run when using fast forward (e.g., 5.0x for 60 fps content = 300 fps cap). If set to 0.0x, fastforward ratio is unlimited (no FPS cap)." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_SLOWMOTION_RATIO, + "When in slow motion, content will slow down by the factor specified/set." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_REWIND_ENABLE, + "Enable rewinding. This will take a performance hit when playing." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_REWIND_GRANULARITY, + "When rewinding a defined number of frames, you can rewind several frames at a time, increasing the rewind speed." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_LIBRETRO_LOG_LEVEL, + "Sets log level for cores. If a log level issued by a core is below this value, it is ignored." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_PERFCNT_ENABLE, + "Enable performance counters for RetroArch (and cores)." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_SAVESTATE_AUTO_SAVE, + "Automatically makes a savestate at the end of RetroArch's runtime. RetroArch will automatically load this savestate if 'Auto Load State' is enabled." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_SAVESTATE_AUTO_LOAD, + "Automatically load the auto save state on startup." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_SAVESTATE_THUMBNAIL_ENABLE, + "Show thumbnails of save states inside the menu." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_AUTOSAVE_INTERVAL, + "Autosaves the non-volatile Save RAM at a regular interval. This is disabled by default unless set otherwise. The interval is measured in seconds. A value of 0 disables autosave." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_INPUT_REMAP_BINDS_ENABLE, + "If enabled, overrides the input binds with the remapped binds set for the current core." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_INPUT_AUTODETECT_ENABLE, + "Enable input auto-detection. Will attempt to autoconfigure joypads, Plug-and-Play style." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_MENU_INPUT_SWAP_OK_CANCEL, + "Swap buttons for OK/Cancel. Disabled is the Japanese button orientation, enabled is the western orientation." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_PAUSE_LIBRETRO, + "If disabled, the content will keep running in the background when RetroArch's menu is toggled." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_DRIVER, + "Video driver to use." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_AUDIO_DRIVER, + "Audio driver to use." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_INPUT_DRIVER, + "Input driver to use. Depending on the video driver, it might force a different input driver." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_JOYPAD_DRIVER, + "Joypad driver to use." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_AUDIO_RESAMPLER_DRIVER, + "Audio resampler driver to use." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_CAMERA_DRIVER, + "Camera driver to use." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_LOCATION_DRIVER, + "Location driver to use." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_MENU_DRIVER, + "Menu driver to use." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_RECORD_DRIVER, + "Record driver to use." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_WIFI_DRIVER, + "WiFi driver to use." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_NAVIGATION_BROWSER_FILTER_SUPPORTED_EXTENSIONS_ENABLE, + "Filter files being shown in filebrowser by supported extensions." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_MENU_WALLPAPER, + "Select an image to set as menu wallpaper." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_DYNAMIC_WALLPAPER, + "Dynamically load a new wallpaper depending on context." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_AUDIO_DEVICE, + "Override the default audio device the audio driver uses. This is driver dependent." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_AUDIO_DSP_PLUGIN, + "Audio DSP plugin that processes audio before it's sent to the driver." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_AUDIO_OUTPUT_RATE, + "Audio output sample rate." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_OVERLAY_OPACITY, + "Opacity of all UI elements of the overlay." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_OVERLAY_SCALE, + "Scale of all UI elements of the overlay." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_INPUT_OVERLAY_ENABLE, + "Enable the overlay." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_OVERLAY_PRESET, + "Select an overlay from the file browser." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_NETPLAY_IP_ADDRESS, + "The address of the host to connect to." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_NETPLAY_TCP_UDP_PORT, + "The port of the host IP address. Can be either a TCP or UDP port." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_NETPLAY_PASSWORD, + "The password for connecting to the netplay host. Used only in host mode." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_NETPLAY_PUBLIC_ANNOUNCE, + "Whether to announce netplay games publicly. If unset, clients must manually connect rather than using the public lobby." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_NETPLAY_SPECTATE_PASSWORD, + "The password for connecting to the netplay host with only spectator privileges. Used only in host mode." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_NETPLAY_START_AS_SPECTATOR, + "Whether to start netplay in spectator mode." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_NETPLAY_ALLOW_SLAVES, + "Whether to allow connections in slave mode. Slave-mode clients require very little processing power on either side, but will suffer significantly from network latency." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_NETPLAY_REQUIRE_SLAVES, + "Whether to disallow connections not in slave mode. Not recommended except for very fast networks with very weak machines." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_NETPLAY_STATELESS_MODE, + "Whether to run netplay in a mode not requiring save states. If set to true, a very fast network is required, but no rewinding is performed, so there will be no netplay jitter." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_NETPLAY_CHECK_FRAMES, + "The frequency in frames with which netplay will verify that the host and client are in sync." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_NETPLAY_NAT_TRAVERSAL, + "When hosting, attempt to listen for connections from the public Internet, using UPnP or similar technologies to escape LANs." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_STDIN_CMD_ENABLE, + "Enable stdin command interface." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_MOUSE_ENABLE, + "Enable mouse controls inside the menu." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_POINTER_ENABLE, + "Enable touch controls inside the menu." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_THUMBNAILS, + "Type of thumbnail to display." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_TIMEDATE_ENABLE, + "Shows current date and/or time inside the menu." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_BATTERY_LEVEL_ENABLE, + "Shows current battery level inside the menu." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_NAVIGATION_WRAPAROUND, + "Wrap-around to beginning and/or end if boundary of list is reached horizontally or vertically." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_NETPLAY_ENABLE_HOST, + "Enables netplay in host (server) mode." + ) +MSG_HASH(MENU_ENUM_SUBLABEL_NETPLAY_ENABLE_CLIENT, + "Enables netplay in client mode.") +MSG_HASH(MENU_ENUM_SUBLABEL_NETPLAY_DISCONNECT, + "Disconnects an active Netplay connection.") +MSG_HASH(MENU_ENUM_SUBLABEL_SCAN_DIRECTORY, + "Scans a directory for compatible files and add them to the collection.") +MSG_HASH(MENU_ENUM_SUBLABEL_SCAN_FILE, + "Scans a compatible file and add it to the collection.") +MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_SWAP_INTERVAL, + "Uses a custom swap interval for Vsync. Set this to effectively halve monitor refresh rate." + ) +MSG_HASH(MENU_ENUM_SUBLABEL_SORT_SAVEFILES_ENABLE, + "Sort save files in folders named after the core used." + ) +MSG_HASH(MENU_ENUM_SUBLABEL_SORT_SAVESTATES_ENABLE, + "Sort save states in folders named after the core used." + ) +MSG_HASH(MENU_ENUM_SUBLABEL_NETPLAY_REQUEST_DEVICE_I, + "Request to play with the given input device.") +MSG_HASH(MENU_ENUM_SUBLABEL_CORE_UPDATER_BUILDBOT_URL, + "URL to core updater directory on the Libretro buildbot.") +MSG_HASH(MENU_ENUM_SUBLABEL_BUILDBOT_ASSETS_URL, + "URL to assets updater directory on the Libretro buildbot.") +MSG_HASH(MENU_ENUM_SUBLABEL_CORE_UPDATER_AUTO_EXTRACT_ARCHIVE, + "After downloading, automatically extract files contained in the downloaded archives." + ) +MSG_HASH(MENU_ENUM_SUBLABEL_NETPLAY_REFRESH_ROOMS, + "Scan for new rooms.") +MSG_HASH(MENU_ENUM_SUBLABEL_DELETE_ENTRY, + "Remove this entry from the collection.") +MSG_HASH(MENU_ENUM_SUBLABEL_INFORMATION, + "View more information about the content.") +MSG_HASH(MENU_ENUM_SUBLABEL_ADD_TO_FAVORITES, + "Add the entry to your favorites.") +MSG_HASH(MENU_ENUM_SUBLABEL_ADD_TO_FAVORITES_PLAYLIST, + "Add the entry to your favorites.") +MSG_HASH(MENU_ENUM_SUBLABEL_RUN, + "Start the content.") +MSG_HASH(MENU_ENUM_SUBLABEL_MENU_FILE_BROWSER_SETTINGS, + "Adjusts filebrowser settings.") +MSG_HASH( + MENU_ENUM_SUBLABEL_AUTO_REMAPS_ENABLE, + "Enable customized controls by default at startup." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_AUTO_OVERRIDES_ENABLE, + "Enable customized configuration by default at startup." + ) +MSG_HASH(MENU_ENUM_SUBLABEL_GAME_SPECIFIC_OPTIONS, + "Enable customized core options by default at startup.") +MSG_HASH(MENU_ENUM_SUBLABEL_CORE_ENABLE, + "Shows current core name inside menu.") +MSG_HASH(MENU_ENUM_SUBLABEL_DATABASE_MANAGER, + "View databases.") +MSG_HASH(MENU_ENUM_SUBLABEL_CURSOR_MANAGER, + "View previous searches.") +MSG_HASH(MENU_ENUM_SUBLABEL_TAKE_SCREENSHOT, + "Captures an image of the screen.") +MSG_HASH( + MENU_ENUM_SUBLABEL_CLOSE_CONTENT, + "Closes the current content. Any unsaved changes might be lost." + ) +MSG_HASH(MENU_ENUM_SUBLABEL_LOAD_STATE, + "Load a saved state from the currently selected slot.") +MSG_HASH(MENU_ENUM_SUBLABEL_SAVE_STATE, + "Save a state to the currently selected slot.") +MSG_HASH(MENU_ENUM_SUBLABEL_RESUME, + "Resume the currently running content and leave the Quick Menu.") +MSG_HASH(MENU_ENUM_SUBLABEL_RESUME_CONTENT, + "Resume the currently running content and leave the Quick Menu.") +MSG_HASH(MENU_ENUM_SUBLABEL_STATE_SLOT, + "Changes the currently selected state slot.") +MSG_HASH(MENU_ENUM_SUBLABEL_UNDO_LOAD_STATE, + "If a state was loaded, content will go back to the state prior to loading.") +MSG_HASH(MENU_ENUM_SUBLABEL_UNDO_SAVE_STATE, + "If a state was overwritten, it will roll back to the previous save state.") +MSG_HASH( + MENU_ENUM_SUBLABEL_ACCOUNTS_RETRO_ACHIEVEMENTS, + "RetroAchievements service. For more information, visit http://retroachievements.org" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_ACCOUNTS_LIST, + "Manages currently configured accounts." + ) +MSG_HASH(MENU_ENUM_SUBLABEL_INPUT_META_REWIND, + "Manages rewind settings.") +MSG_HASH(MENU_ENUM_SUBLABEL_RESTART_CONTENT, + "Restarts the content from the beginning.") +MSG_HASH(MENU_ENUM_SUBLABEL_SAVE_CURRENT_CONFIG_OVERRIDE_CORE, + "Saves an override configuration file which will apply for all content loaded with this core. Will take precedence over the main configuration.") +MSG_HASH(MENU_ENUM_SUBLABEL_SAVE_CURRENT_CONFIG_OVERRIDE_GAME, + "Saves an override configuration file which will apply for the current content only. Will take precedence over the main configuration.") +MSG_HASH(MENU_ENUM_SUBLABEL_CORE_CHEAT_OPTIONS, + "Set up cheat codes.") +MSG_HASH(MENU_ENUM_SUBLABEL_SHADER_OPTIONS, + "Set up shaders to visually augment the image.") +MSG_HASH(MENU_ENUM_SUBLABEL_CORE_INPUT_REMAPPING_OPTIONS, + "Change the controls for the currently running content.") +MSG_HASH(MENU_ENUM_SUBLABEL_CORE_OPTIONS, + "Change the options for the currently running content.") +MSG_HASH(MENU_ENUM_SUBLABEL_SHOW_ADVANCED_SETTINGS, + "Show advanced settings for power users (hidden by default).") +MSG_HASH(MENU_ENUM_SUBLABEL_THREADED_DATA_RUNLOOP_ENABLE, + "Perform tasks on a separate thread.") +MSG_HASH(MENU_ENUM_SUBLABEL_PLAYLIST_ENTRY_REMOVE, + "Allow the user to remove entries from collections.") +MSG_HASH(MENU_ENUM_SUBLABEL_SYSTEM_DIRECTORY, + "Sets the System directory. Cores can query for this directory to load BIOSes, system-specific configs, etc.") +MSG_HASH(MENU_ENUM_SUBLABEL_RGUI_BROWSER_DIRECTORY, + "Sets start directory for the filebrowser.") +MSG_HASH( + MENU_ENUM_SUBLABEL_CONTENT_DIR, + "Usually set by developers who bundle libretro/RetroArch apps to point to assets." + ) +MSG_HASH(MENU_ENUM_SUBLABEL_DYNAMIC_WALLPAPERS_DIRECTORY, + "Directory to store wallpapers dynamically loaded by the menu depending on context.") +MSG_HASH(MENU_ENUM_SUBLABEL_THUMBNAILS_DIRECTORY, + "Supplementary thumbnails (boxarts/misc. images, etc.) are stored here." + ) +MSG_HASH(MENU_ENUM_SUBLABEL_RGUI_CONFIG_DIRECTORY, + "Sets start directory for menu configuration browser.") +MSG_HASH(MENU_ENUM_SUBLABEL_NETPLAY_INPUT_LATENCY_FRAMES_MIN, + "The number of frames of input latency for netplay to use to hide network latency. Reduces jitter and makes netplay less CPU-intensive, at the expense of noticeable input lag.") +MSG_HASH(MENU_ENUM_SUBLABEL_NETPLAY_INPUT_LATENCY_FRAMES_RANGE, + "The range of frames of input latency that may be used to hide network latency. Reduces jitter and makes netplay less CPU-intensive, at the expense of unpredictable input lag.") +MSG_HASH(MENU_ENUM_SUBLABEL_DISK_CYCLE_TRAY_STATUS, + "Cycle the current disk. If the disk is inserted, it will eject the disk. If the disk has not been inserted, it will be inserted. ") +MSG_HASH(MENU_ENUM_SUBLABEL_DISK_INDEX, + "Change the disk index.") +MSG_HASH(MENU_ENUM_SUBLABEL_DISK_OPTIONS, + "Disk image management.") +MSG_HASH(MENU_ENUM_SUBLABEL_DISK_IMAGE_APPEND, + "Select a disk image to insert.") +MSG_HASH(MENU_ENUM_SUBLABEL_MENU_ENUM_THROTTLE_FRAMERATE, + "Makes sure the framerate is capped while inside the menu.") +MSG_HASH(MENU_ENUM_SUBLABEL_XMB_THEME, + "Select a different theme for the icon. Changes will take effect after you restart the program.") +MSG_HASH(MENU_ENUM_SUBLABEL_XMB_SHADOWS_ENABLE, + "Enable drop shadows for all icons. This will have a minor performance hit.") +MSG_HASH(MENU_ENUM_SUBLABEL_MATERIALUI_MENU_COLOR_THEME, + "Select a different background color gradient theme.") +MSG_HASH(MENU_ENUM_SUBLABEL_MENU_WALLPAPER_OPACITY, + "Modify the opacity of the background wallpaper.") +MSG_HASH(MENU_ENUM_SUBLABEL_XMB_MENU_COLOR_THEME, + "Select a different background color gradient theme.") +MSG_HASH(MENU_ENUM_SUBLABEL_XMB_RIBBON_ENABLE, + "Select an animated background effect. Can be GPU-intensive depending on the effect. If performance is unsatisfactory, either turn this off or revert to a simpler effect.") +MSG_HASH(MENU_ENUM_SUBLABEL_XMB_FONT, + "Select a different main font to be used by the menu.") +MSG_HASH(MENU_ENUM_SUBLABEL_CONTENT_SHOW_FAVORITES, + "Show the favorites tab inside the main menu.") +MSG_HASH(MENU_ENUM_SUBLABEL_CONTENT_SHOW_IMAGES, + "Show the image tab inside the main menu.") +MSG_HASH(MENU_ENUM_SUBLABEL_CONTENT_SHOW_MUSIC, + "Show the music tab inside the main menu.") +MSG_HASH(MENU_ENUM_SUBLABEL_CONTENT_SHOW_VIDEO, + "Show the video tab inside the main menu.") +MSG_HASH(MENU_ENUM_SUBLABEL_CONTENT_SHOW_NETPLAY, + "Show the netplay tab inside the main menu.") +MSG_HASH(MENU_ENUM_SUBLABEL_CONTENT_SHOW_SETTINGS, + "Show the settings tab inside the main menu.") +MSG_HASH(MENU_ENUM_SUBLABEL_CONTENT_SHOW_HISTORY, + "Show the recent history tab inside the main menu.") +MSG_HASH(MENU_ENUM_SUBLABEL_CONTENT_SHOW_ADD, + "Show the import content tab inside the main menu.") +MSG_HASH(MENU_ENUM_SUBLABEL_RGUI_SHOW_START_SCREEN, + "Show startup screen in menu. This is automatically set to false after the program starts for the first time.") +MSG_HASH(MENU_ENUM_SUBLABEL_MATERIALUI_MENU_HEADER_OPACITY, + "Modify the opacity of the header graphic.") +MSG_HASH(MENU_ENUM_SUBLABEL_MATERIALUI_MENU_FOOTER_OPACITY, + "Modify the opacity of the footer graphic.") +MSG_HASH(MENU_ENUM_SUBLABEL_DPI_OVERRIDE_ENABLE, + "The menu normally scales itself dynamically. If you want to set a specific scaling size instead, enable this.") +MSG_HASH(MENU_ENUM_SUBLABEL_DPI_OVERRIDE_VALUE, + "Set the custom scaling size here. NOTE: You have to enable 'DPI Override' for this scaling size to take effect.") +MSG_HASH(MENU_ENUM_SUBLABEL_CORE_ASSETS_DIRECTORY, + "Save all downloaded files to this directory.") +MSG_HASH(MENU_ENUM_SUBLABEL_INPUT_REMAPPING_DIRECTORY, + "Save all remapped controls to this directory.") +MSG_HASH(MENU_ENUM_SUBLABEL_LIBRETRO_DIR_PATH, + "Directory where the program searches for content/cores.") +MSG_HASH(MENU_ENUM_SUBLABEL_LIBRETRO_INFO_PATH, + "Application/core information files are stored here.") +MSG_HASH(MENU_ENUM_SUBLABEL_JOYPAD_AUTOCONFIG_DIR, + "If a joypad is plugged in, that joypad will be autoconfigured if a config file corresponding to it is present inside this directory.") +MSG_HASH(MENU_ENUM_SUBLABEL_PLAYLIST_DIRECTORY, + "Save all collections to this directory.") +MSG_HASH( + MENU_ENUM_SUBLABEL_CACHE_DIRECTORY, + "If set to a directory, content which is temporarily extracted (e.g. from archives) will be extracted to this directory." + ) +MSG_HASH(MENU_ENUM_SUBLABEL_CURSOR_DIRECTORY, + "Saved queries are stored to this directory.") +MSG_HASH( + MENU_ENUM_SUBLABEL_CONTENT_DATABASE_DIRECTORY, + "Databases are stored to this directory." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_ASSETS_DIRECTORY, + "This location is queried by default when menu interfaces try to look for loadable assets, etc." + ) +MSG_HASH(MENU_ENUM_SUBLABEL_SAVEFILE_DIRECTORY, + "Save all save files to this directory. If not set, will try to save inside the content file's working directory.") +MSG_HASH(MENU_ENUM_SUBLABEL_SAVESTATE_DIRECTORY, + "Save all save states to this directory. If not set, will try to save inside the content file's working directory.") +MSG_HASH(MENU_ENUM_SUBLABEL_SCREENSHOT_DIRECTORY, + "Directory to dump screenshots to.") +MSG_HASH(MENU_ENUM_SUBLABEL_OVERLAY_DIRECTORY, + "Defines a directory where overlays are kept for easy access.") +MSG_HASH( + MENU_ENUM_SUBLABEL_CHEAT_DATABASE_PATH, + "Cheat files are kept here." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_AUDIO_FILTER_DIR, + "Directory where audio DSP filter files are kept." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_FILTER_DIR, + "Directory where CPU-based video filter files are kept." + ) +MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_SHADER_DIR, + "Defines a directory where GPU-based video shader files are kept for easy access.") +MSG_HASH(MENU_ENUM_SUBLABEL_RECORDING_OUTPUT_DIRECTORY, + "Recordings will be dumped to this directory.") +MSG_HASH(MENU_ENUM_SUBLABEL_RECORDING_CONFIG_DIRECTORY, + "Recording configurations will be kept here.") +MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_FONT_PATH, + "Select a different font for onscreen notifications.") +MSG_HASH(MENU_ENUM_SUBLABEL_SHADER_APPLY_CHANGES, + "Changes to the shader configuration will take effect immediately. Use this if you changed the amount of shader passes, filtering, FBO scale, etc.") +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_SHADER_NUM_PASSES, + "Increase or decrease the amount of shader pipeline passes. You can bind a separate shader to each pipeline pass and configure its scale and filtering." + ) +MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET, + "Load a shader preset. The shader pipeline will be automatically set-up.") +MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_SAVE_AS, + "Save the current shader settings as a new shader preset.") +MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_SAVE_CORE, + "Save the current shader settings as the default settings for this application/core.") +MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_SAVE_GAME, + "Save the current shader settings as the default settings for the content.") +MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_SHADER_PARAMETERS, + "Modifies the current shader directly. Changes will not be saved to the preset file.") +MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_PARAMETERS, + "Modifies the shader preset itself currently used in the menu.") +MSG_HASH( + MENU_ENUM_SUBLABEL_CHEAT_NUM_PASSES, + "Increase or decrease the amount of cheats." + ) +MSG_HASH(MENU_ENUM_SUBLABEL_CHEAT_APPLY_CHANGES, + "Cheat changes will take effect immediately.") +MSG_HASH( + MENU_ENUM_SUBLABEL_CHEAT_FILE_LOAD, + "Load a cheat file." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_CHEAT_FILE_SAVE_AS, + "Save current cheats as a save file." + ) +MSG_HASH(MENU_ENUM_SUBLABEL_CONTENT_SETTINGS, + "Quickly access all relevant in-game settings.") +MSG_HASH(MENU_ENUM_SUBLABEL_CORE_INFORMATION, + "View information pertaining to the application/core.") +MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_ASPECT_RATIO, + "Floating point value for video aspect ratio (width / height), used if the Aspect Ratio is set to 'Config'.") +MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_VIEWPORT_CUSTOM_HEIGHT, + "Custom viewport height that is used if the Aspect Ratio is set to 'Custom'.") +MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_VIEWPORT_CUSTOM_WIDTH, + "Custom viewport width that is used if the Aspect Ratio is set to 'Custom'.") +MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_VIEWPORT_CUSTOM_X, + "Custom viewport offset used for defining the X-axis position of the viewport. These are ignored if 'Integer Scale' is enabled. It will be automatically centered then.") +MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_VIEWPORT_CUSTOM_Y, + "Custom viewport offset used for defining the Y-axis position of the viewport. These are ignored if 'Integer Scale' is enabled. It will be automatically centered then.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_USE_MITM_SERVER, + "Use Relay Server") +MSG_HASH(MENU_ENUM_SUBLABEL_NETPLAY_USE_MITM_SERVER, + "Forward netplay connections through a man-in-the-middle server. Useful if the host is behind a firewall or has NAT/UPnP problems.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_MITM_SERVER, + "Relay Server Location") +MSG_HASH(MENU_ENUM_SUBLABEL_NETPLAY_MITM_SERVER, + "Choose a specific relay server to use. Geographically closer locations tend to have lower latency.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_ADD_TO_MIXER, + "Add to mixer") +MSG_HASH(MENU_ENUM_LABEL_VALUE_ADD_TO_MIXER_AND_COLLECTION, + "Add to mixer") +MSG_HASH(MENU_ENUM_LABEL_VALUE_FILTER_BY_CURRENT_CORE, + "Filter by current core") +MSG_HASH( + MSG_AUDIO_MIXER_VOLUME, + "Global audio mixer volume" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_AUDIO_MIXER_VOLUME, + "Global audio mixer volume (in dB). 0 dB is normal volume, and no gain is applied." + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_AUDIO_MIXER_VOLUME, + "Audio Mixer Volume Level (dB)" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_AUDIO_MIXER_MUTE, + "Audio Mixer Mute" + ) +MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_MIXER_MUTE, + "Mute/unmute mixer audio.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_SHOW_ONLINE_UPDATER, + "Show Online Updater") +MSG_HASH(MENU_ENUM_SUBLABEL_MENU_SHOW_ONLINE_UPDATER, + "Show/hide the 'Online Updater' option.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_VIEWS_SETTINGS, + "Views") +MSG_HASH( + MENU_ENUM_SUBLABEL_MENU_VIEWS_SETTINGS, + "Show or hide elements on the menu screen." + ) +MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_SHOW_CORE_UPDATER, + "Show Core Updater") +MSG_HASH(MENU_ENUM_SUBLABEL_MENU_SHOW_CORE_UPDATER, + "Show/hide the ability to update cores (and core info files).") +MSG_HASH(MSG_PREPARING_FOR_CONTENT_SCAN, + "Preparing for content scan...") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CORE_DELETE, + "Delete core") +MSG_HASH(MENU_ENUM_SUBLABEL_CORE_DELETE, + "Remove this core from disk.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_FRAMEBUFFER_OPACITY, + "Framebuffer Opacity") +MSG_HASH(MENU_ENUM_SUBLABEL_MENU_FRAMEBUFFER_OPACITY, + "Modify the opacity of the framebuffer.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_GOTO_FAVORITES, + "Favorites") +MSG_HASH(MENU_ENUM_SUBLABEL_GOTO_FAVORITES, + "Content which you have added to 'Favorites' will appear here.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_GOTO_MUSIC, + "Music") +MSG_HASH(MENU_ENUM_SUBLABEL_GOTO_MUSIC, + "Music which has been previously played will appear here.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_GOTO_IMAGES, + "Image") +MSG_HASH(MENU_ENUM_SUBLABEL_GOTO_IMAGES, + "Images which have been previously viewed will appear here.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_GOTO_VIDEO, + "Video") +MSG_HASH(MENU_ENUM_SUBLABEL_GOTO_VIDEO, + "Videos which have been previously played will appear here.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MATERIALUI_ICONS_ENABLE, + "Menu Icons") +MSG_HASH(MENU_ENUM_SUBLABEL_MATERIALUI_ICONS_ENABLE, + "Enable/disable the menu icons shown at the lefthand side of the menu entries.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_XMB_MAIN_MENU_ENABLE_SETTINGS, + "Enable Settings Tab") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CONTENT_SHOW_SETTINGS_PASSWORD, + "Set Password For Enabling Settings Tab") +MSG_HASH(MSG_INPUT_ENABLE_SETTINGS_PASSWORD, + "Enter Password") +MSG_HASH(MSG_INPUT_ENABLE_SETTINGS_PASSWORD_OK, + "Password correct.") +MSG_HASH(MSG_INPUT_ENABLE_SETTINGS_PASSWORD_NOK, + "Password incorrect.") +MSG_HASH(MENU_ENUM_SUBLABEL_XMB_MAIN_MENU_ENABLE_SETTINGS, + "Enables the Settings tab. A restart is required for the tab to appear.") +MSG_HASH(MENU_ENUM_SUBLABEL_CONTENT_SHOW_SETTINGS_PASSWORD, + "Supplying a password when hiding the settings tab makes it possible to later restore it from the menu, by going to the Main Menu tab, selecting Enable Settings Tab and entering the password.") +MSG_HASH(MENU_ENUM_SUBLABEL_PLAYLIST_ENTRY_RENAME, + "Allow the user to rename entries in collections.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_PLAYLIST_ENTRY_RENAME, + "Allow to rename entries") +MSG_HASH(MENU_ENUM_SUBLABEL_RENAME_ENTRY, + "Rename the title of the entry.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_RENAME_ENTRY, + "Rename") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_SHOW_LOAD_CORE, + "Show Load Core") +MSG_HASH(MENU_ENUM_SUBLABEL_MENU_SHOW_LOAD_CORE, + "Show/hide the 'Load Core' option.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_SHOW_LOAD_CONTENT, + "Show Load Content") +MSG_HASH(MENU_ENUM_SUBLABEL_MENU_SHOW_LOAD_CONTENT, + "Show/hide the 'Load Content' option.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_SHOW_INFORMATION, + "Show Information") +MSG_HASH(MENU_ENUM_SUBLABEL_MENU_SHOW_INFORMATION, + "Show/hide the 'Information' option.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_SHOW_CONFIGURATIONS, + "Show Configurations") +MSG_HASH(MENU_ENUM_SUBLABEL_MENU_SHOW_CONFIGURATIONS, + "Show/hide the 'Configurations' option.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_SHOW_HELP, + "Show Help") +MSG_HASH(MENU_ENUM_SUBLABEL_MENU_SHOW_HELP, + "Show/hide the 'Help' option.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_SHOW_QUIT_RETROARCH, + "Show Quit RetroArch") +MSG_HASH(MENU_ENUM_SUBLABEL_MENU_SHOW_QUIT_RETROARCH, + "Show/hide the 'Quit RetroArch' option.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_SHOW_REBOOT, + "Show Reboot") +MSG_HASH(MENU_ENUM_SUBLABEL_MENU_SHOW_REBOOT, + "Show/hide the 'Reboot' option.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_VIEWS_SETTINGS, + "القائمة السريعة") +MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_VIEWS_SETTINGS, + "Show or hide elements on the Quick Menu screen.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_TAKE_SCREENSHOT, + "Show Take Screenshot") +MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_TAKE_SCREENSHOT, + "Show/hide the 'Take Screenshot' option.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_SAVE_LOAD_STATE, + "Show Save/Load State") +MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_SAVE_LOAD_STATE, + "Show/hide the options for saving/loading state.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_UNDO_SAVE_LOAD_STATE, + "Show Undo Save/Load State") +MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_UNDO_SAVE_LOAD_STATE, + "Show/hide the options for undoing save/load state.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_ADD_TO_FAVORITES, + "Show Add to Favorites") +MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_ADD_TO_FAVORITES, + "Show/hide the 'Add to Favorites' option.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_OPTIONS, + "Show Options") +MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_OPTIONS, + "Show/hide the 'Options' option.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_CONTROLS, + "Show Controls") +MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_CONTROLS, + "Show/hide the 'Controls' option.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_CHEATS, + "Show Cheats") +MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_CHEATS, + "Show/hide the 'Cheats' option.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_SHADERS, + "Show Shaders") +MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_SHADERS, + "Show/hide the 'Shaders' option.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_SAVE_CORE_OVERRIDES, + "Show Save Core Overrides") +MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_SAVE_CORE_OVERRIDES, + "Show/hide the 'Save Core Overrides' option.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_SAVE_GAME_OVERRIDES, + "Show Save Game Overrides") +MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_SAVE_GAME_OVERRIDES, + "Show/hide the 'Save Game Overrides' option.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_INFORMATION, + "Show Information") +MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_INFORMATION, + "Show/hide the 'Information' option.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_MESSAGE_BGCOLOR_ENABLE, + "Notification Background Enable") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_MESSAGE_BGCOLOR_RED, + "Notification Background Red Color") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_MESSAGE_BGCOLOR_GREEN, + "Notification Background Green Color") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_MESSAGE_BGCOLOR_BLUE, + "Notification Background Blue Color") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_MESSAGE_BGCOLOR_OPACITY, + "Notification Background Opacity") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_DISABLE_KIOSK_MODE, + "Disable Kiosk Mode") +MSG_HASH(MENU_ENUM_SUBLABEL_MENU_DISABLE_KIOSK_MODE, + "Disables kiosk mode. A restart is required for the change to take full effect.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_ENABLE_KIOSK_MODE, + "Enable Kiosk Mode") +MSG_HASH(MENU_ENUM_SUBLABEL_MENU_ENABLE_KIOSK_MODE, + "Protects the setup by hiding all configuration related settings.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_KIOSK_MODE_PASSWORD, + "Set Password For Disabling Kiosk Mode") +MSG_HASH(MENU_ENUM_SUBLABEL_MENU_KIOSK_MODE_PASSWORD, + "Supplying a password when enabling kiosk mode makes it possible to later disable it from the menu, by going to the Main Menu, selecting Disable Kiosk Mode and entering the password.") +MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD, + "Enter Password") +MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_OK, + "Password correct.") +MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_NOK, + "Password incorrect.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_MESSAGE_COLOR_RED, + "Notification Red Color") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_MESSAGE_COLOR_GREEN, + "Notification Green Color") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_MESSAGE_COLOR_BLUE, + "Notification Blue Color") +MSG_HASH(MENU_ENUM_LABEL_VALUE_FRAMECOUNT_SHOW, + "Show frame count on FPS display") +MSG_HASH(MSG_CONFIG_OVERRIDE_LOADED, + "Configuration override loaded.") +MSG_HASH(MSG_GAME_REMAP_FILE_LOADED, + "Game remap file loaded.") +MSG_HASH(MSG_CORE_REMAP_FILE_LOADED, + "Core remap file loaded.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically add content to playlist") +MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically scans loaded content so they appear inside playlists.") +MSG_HASH(MSG_SCANNING_OF_FILE_FINISHED, + "Scanning of file finished") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_OPACITY, + "Window Opacity") +MSG_HASH(MENU_ENUM_LABEL_VALUE_AUDIO_RESAMPLER_QUALITY, + "Audio Resampler Quality") +MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_RESAMPLER_QUALITY, + "Lower this value to favor performance/lower latency over audio quality, increase if you want better audio quality at the expense of performance/lower latency.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SHADER_WATCH_FOR_CHANGES, + "Watch shader files for changes") +MSG_HASH(MENU_ENUM_SUBLABEL_SHADER_WATCH_FOR_CHANGES, + "Auto-apply changes made to shader files on disk.") diff --git a/intl/msg_hash_chs.h b/intl/msg_hash_chs.h index e6a0cdf061..7e72e839ce 100644 --- a/intl/msg_hash_chs.h +++ b/intl/msg_hash_chs.h @@ -922,6 +922,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_SPANISH, "西班牙语") MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_VIETNAMESE, "越南语") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_ARABIC, + "Arabic") MSG_HASH(MENU_ENUM_LABEL_VALUE_LEFT_ANALOG, "左侧摇杆") MSG_HASH(MENU_ENUM_LABEL_VALUE_LIBRETRO_DIR_PATH, diff --git a/intl/msg_hash_cht.h b/intl/msg_hash_cht.h index 2644f450a8..9fcc387aca 100644 --- a/intl/msg_hash_cht.h +++ b/intl/msg_hash_cht.h @@ -922,6 +922,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_SPANISH, "西班牙語") MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_VIETNAMESE, "越南語") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_ARABIC, + "Arabic") MSG_HASH(MENU_ENUM_LABEL_VALUE_LEFT_ANALOG, "左側搖桿") MSG_HASH(MENU_ENUM_LABEL_VALUE_LIBRETRO_DIR_PATH, diff --git a/intl/msg_hash_de.h b/intl/msg_hash_de.h index 3140125ee4..10449b4f9a 100644 --- a/intl/msg_hash_de.h +++ b/intl/msg_hash_de.h @@ -931,6 +931,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_SPANISH, "Spanisch") MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_VIETNAMESE, "Vietnamesisch") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_ARABIC, + "Arabisch") MSG_HASH(MENU_ENUM_LABEL_VALUE_LEFT_ANALOG, "Linker Analogstick") MSG_HASH(MENU_ENUM_LABEL_VALUE_LIBRETRO_DIR_PATH, diff --git a/intl/msg_hash_eo.h b/intl/msg_hash_eo.h index 4052dcfe41..e37169d050 100644 --- a/intl/msg_hash_eo.h +++ b/intl/msg_hash_eo.h @@ -836,6 +836,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_SPANISH, "Spanish") MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_VIETNAMESE, "Vietnamese") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_ARABIC, + "Arabic") MSG_HASH(MENU_ENUM_LABEL_VALUE_LEFT_ANALOG, "Left Analog") MSG_HASH(MENU_ENUM_LABEL_VALUE_LIBRETRO_DIR_PATH, diff --git a/intl/msg_hash_es.h b/intl/msg_hash_es.h index 49bd2f839e..5d7656a46c 100644 --- a/intl/msg_hash_es.h +++ b/intl/msg_hash_es.h @@ -1390,6 +1390,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_LANG_VIETNAMESE, "Vietnamita" ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_LANG_ARABIC, + "Arabic" + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_LEFT_ANALOG, "Analogico izquierdo" @@ -5701,4 +5705,4 @@ MSG_HASH( MSG_HASH( MENU_ENUM_SUBLABEL_AUDIO_RESAMPLER_QUALITY, "Valores mas bajos favorecen el rendimiento y bajan la latencia a costa de la calidad, incrementar el valor aumentará la calidad a costa del rendimiento y latencia" - ) \ No newline at end of file + ) diff --git a/intl/msg_hash_fr.h b/intl/msg_hash_fr.h index 96ac3c3425..7e724453d5 100644 --- a/intl/msg_hash_fr.h +++ b/intl/msg_hash_fr.h @@ -921,6 +921,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_SPANISH, "Espagnol") MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_VIETNAMESE, "Vietnamien") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_ARABIC, + "Arabe") MSG_HASH(MENU_ENUM_LABEL_VALUE_LEFT_ANALOG, "Analogique gauche") MSG_HASH(MENU_ENUM_LABEL_VALUE_LIBRETRO_DIR_PATH, diff --git a/intl/msg_hash_it.h b/intl/msg_hash_it.h index f3ee9a8317..9ba49a2bd7 100644 --- a/intl/msg_hash_it.h +++ b/intl/msg_hash_it.h @@ -931,6 +931,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_SPANISH, "Spagnolo") MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_VIETNAMESE, "Vietnamese") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_ARABIC, + "Arabic") MSG_HASH(MENU_ENUM_LABEL_VALUE_LEFT_ANALOG, "Analogico sinistro") MSG_HASH(MENU_ENUM_LABEL_VALUE_LIBRETRO_DIR_PATH, diff --git a/intl/msg_hash_ja.h b/intl/msg_hash_ja.h index 1eabc2694b..280eddc6cc 100644 --- a/intl/msg_hash_ja.h +++ b/intl/msg_hash_ja.h @@ -961,6 +961,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_SPANISH, "スペイン語") MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_VIETNAMESE, "ベトナム語") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_ARABIC, + "アラビア語") MSG_HASH(MENU_ENUM_LABEL_VALUE_LEFT_ANALOG, "左のアナログ") MSG_HASH(MENU_ENUM_LABEL_VALUE_LIBRETRO_DIR_PATH, diff --git a/intl/msg_hash_ko.h b/intl/msg_hash_ko.h index 26db263322..5787dd7154 100644 --- a/intl/msg_hash_ko.h +++ b/intl/msg_hash_ko.h @@ -907,6 +907,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_SPANISH, "스페인어") MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_VIETNAMESE, "베트남어") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_ARABIC, + "Arabic") MSG_HASH(MENU_ENUM_LABEL_VALUE_LEFT_ANALOG, "좌 아날로그") MSG_HASH(MENU_ENUM_LABEL_VALUE_LIBRETRO_DIR_PATH, diff --git a/intl/msg_hash_nl.h b/intl/msg_hash_nl.h index d5729cb759..2c820d871a 100644 --- a/intl/msg_hash_nl.h +++ b/intl/msg_hash_nl.h @@ -836,6 +836,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_SPANISH, "Spaans") MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_VIETNAMESE, "Vietnamees") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_ARABIC, + "Arabic") MSG_HASH(MENU_ENUM_LABEL_VALUE_LEFT_ANALOG, "Linkse Analoog Stick") MSG_HASH(MENU_ENUM_LABEL_VALUE_LIBRETRO_DIR_PATH, diff --git a/intl/msg_hash_pl.h b/intl/msg_hash_pl.h index 8a64d8cc08..0d517a6ff3 100644 --- a/intl/msg_hash_pl.h +++ b/intl/msg_hash_pl.h @@ -943,6 +943,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_SPANISH, "Spanish") MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_VIETNAMESE, "wietnamski") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_ARABIC, + "Arabic") MSG_HASH(MENU_ENUM_LABEL_VALUE_LEFT_ANALOG, "Lewy analogowy") MSG_HASH(MENU_ENUM_LABEL_VALUE_LIBRETRO_DIR_PATH, diff --git a/intl/msg_hash_pt_br.h b/intl/msg_hash_pt_br.h index a37db1a1e6..e85ec3b3ab 100644 --- a/intl/msg_hash_pt_br.h +++ b/intl/msg_hash_pt_br.h @@ -1013,6 +1013,10 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_SPANISH, MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_VIETNAMESE, "Vietnamita" ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_LANG_ARABIC, + "Arabic" + ) MSG_HASH(MENU_ENUM_LABEL_VALUE_LEFT_ANALOG, "Analógico Esquerdo" ) diff --git a/intl/msg_hash_pt_pt.h b/intl/msg_hash_pt_pt.h index f0244906f9..b28dcbb2ba 100644 --- a/intl/msg_hash_pt_pt.h +++ b/intl/msg_hash_pt_pt.h @@ -907,6 +907,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_SPANISH, "Espanhol") MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_VIETNAMESE, "Vietnamita") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_ARABIC, + "Arabic") MSG_HASH(MENU_ENUM_LABEL_VALUE_LEFT_ANALOG, "Analógico Esquerdo") MSG_HASH(MENU_ENUM_LABEL_VALUE_LIBRETRO_DIR_PATH, diff --git a/intl/msg_hash_ru.h b/intl/msg_hash_ru.h index cc391e57ef..5fe069db60 100644 --- a/intl/msg_hash_ru.h +++ b/intl/msg_hash_ru.h @@ -930,6 +930,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_SPANISH, "Испанский") MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_VIETNAMESE, "Вьетнамский") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_ARABIC, + "Arabic") MSG_HASH(MENU_ENUM_LABEL_VALUE_LEFT_ANALOG, "Левый аналоговый стик") MSG_HASH(MENU_ENUM_LABEL_VALUE_LIBRETRO_DIR_PATH, diff --git a/intl/msg_hash_vn.h b/intl/msg_hash_vn.h index 77a36a6753..c685d4354b 100644 --- a/intl/msg_hash_vn.h +++ b/intl/msg_hash_vn.h @@ -919,6 +919,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_SPANISH, "Tiếng Tây Ban Nha") MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_VIETNAMESE, "Tiếng Việt") +MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_ARABIC, + "Arabic") MSG_HASH(MENU_ENUM_LABEL_VALUE_LEFT_ANALOG, "Left Analog") MSG_HASH(MENU_ENUM_LABEL_VALUE_LIBRETRO_DIR_PATH, diff --git a/libretro-common/include/libretro.h b/libretro-common/include/libretro.h index 9c923db2ef..e15403d8b6 100644 --- a/libretro-common/include/libretro.h +++ b/libretro-common/include/libretro.h @@ -270,6 +270,7 @@ enum retro_language RETRO_LANGUAGE_ESPERANTO = 13, RETRO_LANGUAGE_POLISH = 14, RETRO_LANGUAGE_VIETNAMESE = 15, + RETRO_LANGUAGE_ARABIC = 16, RETRO_LANGUAGE_LAST, /* Ensure sizeof(enum) == sizeof(int) */ diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 7cb6b230a7..a3829eb651 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -2936,7 +2936,19 @@ static void xmb_frame(void *data, video_frame_info_t *video_info) strlcpy(title_truncated, xmb->title_name, sizeof(title_truncated)); if (selection > 1) - title_truncated[25] = '\0'; + { + /* skip 25 utf8 multi-byte chars */ + char* end = title_truncated; + + for(i = 0; i < 25 && *end; i++) + { + end++; + while((*end & 0xC0) == 0x80) + end++; + } + + *end = '\0'; + } /* Title text */ xmb_draw_text(menu_disp_info, xmb, diff --git a/menu/menu_setting.c b/menu/menu_setting.c index e323ff140e..ff952fec2d 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -605,6 +605,7 @@ static void setting_get_string_representation_uint_user_language(void *data, modes[RETRO_LANGUAGE_ESPERANTO] = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_LANG_ESPERANTO); modes[RETRO_LANGUAGE_POLISH] = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_LANG_POLISH); modes[RETRO_LANGUAGE_VIETNAMESE] = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_LANG_VIETNAMESE); + modes[RETRO_LANGUAGE_ARABIC] = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_LANG_ARABIC); strlcpy(s, modes[*msg_hash_get_uint(MSG_HASH_USER_LANGUAGE)], len); } diff --git a/msg_hash.c b/msg_hash.c index 1ce3f6bc33..37a871b222 100644 --- a/msg_hash.c +++ b/msg_hash.c @@ -78,6 +78,9 @@ int menu_hash_get_help_enum(enum msg_hash_enums msg, char *s, size_t len) case RETRO_LANGUAGE_CHINESE_TRADITIONAL: ret = menu_hash_get_help_cht_enum(msg, s, len); break; + case RETRO_LANGUAGE_ARABIC: + ret = menu_hash_get_help_ar_enum(msg, s, len); + break; default: break; } @@ -141,6 +144,9 @@ const char *msg_hash_to_str(enum msg_hash_enums msg) case RETRO_LANGUAGE_CHINESE_TRADITIONAL: ret = msg_hash_to_str_cht(msg); break; + case RETRO_LANGUAGE_ARABIC: + ret = msg_hash_to_str_ar(msg); + break; default: break; } diff --git a/msg_hash.h b/msg_hash.h index 91673d48f3..db3bbb9125 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1658,6 +1658,7 @@ enum msg_hash_enums MENU_ENUM_LABEL_VALUE_LANG_ESPERANTO, MENU_ENUM_LABEL_VALUE_LANG_POLISH, MENU_ENUM_LABEL_VALUE_LANG_VIETNAMESE, + MENU_ENUM_LABEL_VALUE_LANG_ARABIC, MENU_ENUM_LABEL_VALUE_NONE, MENU_ENUM_LABEL_VALUE_NO_INFORMATION_AVAILABLE, @@ -2014,6 +2015,9 @@ int menu_hash_get_help_cht_enum(enum msg_hash_enums msg, char *s, size_t len); const char *msg_hash_to_str_us(enum msg_hash_enums msg); int menu_hash_get_help_us_enum(enum msg_hash_enums msg, char *s, size_t len); +const char *msg_hash_to_str_ar(enum msg_hash_enums msg); +int menu_hash_get_help_ar_enum(enum msg_hash_enums msg, char *s, size_t len); + int menu_hash_get_help_enum(enum msg_hash_enums msg, char *s, size_t len); enum msg_file_type msg_hash_to_file_type(uint32_t hash); From 81859c805f43bb72f6bcff19d683fe7fc3cdbbab Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 5 Feb 2018 20:59:59 +0100 Subject: [PATCH 112/232] Get rid of MENU_LABEL_FAVORITES --- menu/cbs/menu_cbs_deferred_push.c | 5 ++- menu/cbs/menu_cbs_ok.c | 75 +++++++++++++++---------------- msg_hash.h | 1 - 3 files changed, 40 insertions(+), 41 deletions(-) diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index 07690c409d..d8b9b260a1 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -722,6 +722,10 @@ static struct cbs_deferred_lbl_callback cbs_deferred_lbl_list[] = { { MENU_ENUM_LABEL_DEFERRED_VIDEO_LIST, deferred_video_history_list + }, + { + MENU_ENUM_LABEL_FAVORITES, + deferred_push_detect_core_list } }; @@ -1317,7 +1321,6 @@ static int menu_cbs_init_bind_deferred_push_compare_label( BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_content_history_path); break; case MENU_LABEL_DOWNLOADED_FILE_DETECT_CORE_LIST: - case MENU_LABEL_FAVORITES: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_detect_core_list); break; default: diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 33148cb6f4..106f8e24eb 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -3772,7 +3772,12 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, return 0; } - if (cbs->enum_idx != MSG_UNKNOWN) + if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_FAVORITES))) + { + BIND_ACTION_OK(cbs, action_ok_push_content_list); + return 0; + } + else if (cbs->enum_idx != MSG_UNKNOWN) { switch (cbs->enum_idx) { @@ -4242,9 +4247,6 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_ACCOUNTS_RETRO_ACHIEVEMENTS: BIND_ACTION_OK(cbs, action_ok_push_accounts_cheevos_list); break; - case MENU_LABEL_FAVORITES: - BIND_ACTION_OK(cbs, action_ok_push_content_list); - break; case MENU_LABEL_DOWNLOADED_FILE_DETECT_CORE_LIST: BIND_ACTION_OK(cbs, action_ok_push_downloads_dir); break; @@ -4284,6 +4286,7 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, } static int menu_cbs_init_bind_ok_compare_type(menu_file_list_cbs_t *cbs, + const char *menu_label, uint32_t label_hash, uint32_t menu_label_hash, unsigned type) { if (type == MENU_SETTINGS_CUSTOM_BIND_KEYBOARD || @@ -4381,17 +4384,14 @@ static int menu_cbs_init_bind_ok_compare_type(menu_file_list_cbs_t *cbs, BIND_ACTION_OK(cbs, action_ok_scan_file); #endif } + else if (string_is_equal(menu_label, + msg_hash_to_str(MENU_ENUM_LABEL_FAVORITES))) + { + BIND_ACTION_OK(cbs, action_ok_compressed_archive_push_detect_core); + } else { - switch (menu_label_hash) - { - case MENU_LABEL_FAVORITES: - BIND_ACTION_OK(cbs, action_ok_compressed_archive_push_detect_core); - break; - default: - BIND_ACTION_OK(cbs, action_ok_compressed_archive_push); - break; - } + BIND_ACTION_OK(cbs, action_ok_compressed_archive_push); } break; case FILE_TYPE_CORE: @@ -4523,33 +4523,30 @@ static int menu_cbs_init_bind_ok_compare_type(menu_file_list_cbs_t *cbs, break; } } + else if (string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_FAVORITES)) || + string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_DOWNLOADED_FILE_DETECT_CORE_LIST)) || + string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_ARCHIVE_OPEN_DETECT_CORE)) + ) + { +#ifdef HAVE_COMPRESSION + if (type == FILE_TYPE_IN_CARCHIVE) + { + BIND_ACTION_OK(cbs, action_ok_file_load_with_detect_core_carchive); + } + else +#endif + if (filebrowser_get_type() == FILEBROWSER_APPEND_IMAGE) + { + BIND_ACTION_OK(cbs, action_ok_disk_image_append); + } + else + { + BIND_ACTION_OK(cbs, action_ok_file_load_with_detect_core); + } + } else { - switch (menu_label_hash) - { - case MENU_LABEL_DOWNLOADED_FILE_DETECT_CORE_LIST: - case MENU_LABEL_FAVORITES: - case MENU_LABEL_DEFERRED_ARCHIVE_OPEN_DETECT_CORE: -#ifdef HAVE_COMPRESSION - if (type == FILE_TYPE_IN_CARCHIVE) - { - BIND_ACTION_OK(cbs, action_ok_file_load_with_detect_core_carchive); - } - else -#endif - if (filebrowser_get_type() == FILEBROWSER_APPEND_IMAGE) - { - BIND_ACTION_OK(cbs, action_ok_disk_image_append); - } - else - { - BIND_ACTION_OK(cbs, action_ok_file_load_with_detect_core); - } - break; - default: - BIND_ACTION_OK(cbs, action_ok_file_load); - break; - } + BIND_ACTION_OK(cbs, action_ok_file_load); } break; case FILE_TYPE_MOVIE: @@ -4599,7 +4596,7 @@ int menu_cbs_init_bind_ok(menu_file_list_cbs_t *cbs, if (menu_cbs_init_bind_ok_compare_label(cbs, label, label_hash) == 0) return 0; - if (menu_cbs_init_bind_ok_compare_type(cbs, label_hash, menu_label_hash, type) == 0) + if (menu_cbs_init_bind_ok_compare_type(cbs, label, label_hash, menu_label_hash, type) == 0) return 0; return -1; diff --git a/msg_hash.h b/msg_hash.h index bd252f8c90..5b0e4dc6da 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1888,7 +1888,6 @@ enum msg_hash_enums #define MENU_LABEL_RDB_ENTRY_RELEASE_YEAR 0x14c9c6bfU #define MENU_LABEL_RDB_ENTRY_MAX_USERS 0xfae91cc4U -#define MENU_LABEL_FAVORITES 0x67325138U #define MENU_LABEL_DETECT_CORE_LIST 0xaa07c341U #define MENU_LABEL_DETECT_CORE_LIST_OK 0xabba2a7aU #define MENU_LABEL_CORE_LIST 0xa22bb14dU From da070061b05d74e65907f8b7a3ef240340c797d8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 5 Feb 2018 21:09:59 +0100 Subject: [PATCH 113/232] Cleanups --- menu/cbs/menu_cbs_deferred_push.c | 7 ++++--- menu/cbs/menu_cbs_ok.c | 23 +++++++++++++++-------- menu/cbs/menu_cbs_title.c | 12 ++++++++---- msg_hash.h | 4 ---- 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index d8b9b260a1..bb7c606ab8 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -726,6 +726,10 @@ static struct cbs_deferred_lbl_callback cbs_deferred_lbl_list[] = { { MENU_ENUM_LABEL_FAVORITES, deferred_push_detect_core_list + }, + { + MENU_ENUM_LABEL_VIDEO_FILTER, + deferred_push_video_filter } }; @@ -1299,9 +1303,6 @@ static int menu_cbs_init_bind_deferred_push_compare_label( case MENU_LABEL_VIDEO_SHADER_PASS: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_shader_pass); break; - case MENU_LABEL_VIDEO_FILTER: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_filter); - break; case MENU_LABEL_MENU_WALLPAPER: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_images); break; diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 106f8e24eb..7f01a5cebb 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -4444,15 +4444,22 @@ static int menu_cbs_init_bind_ok_compare_type(menu_file_list_cbs_t *cbs, case FILE_TYPE_DOWNLOAD_CORE_INFO: break; case FILE_TYPE_RDB: - switch (menu_label_hash) + if (string_is_equal(menu_label, + msg_hash_to_str(MENU_ENUM_LABEL_HORIZONTAL_MENU))) { - case MENU_LABEL_DEFERRED_DATABASE_MANAGER_LIST: - BIND_ACTION_OK(cbs, action_ok_deferred_list_stub); - break; - case MENU_LABEL_DATABASE_MANAGER_LIST: - case MENU_VALUE_HORIZONTAL_MENU: - BIND_ACTION_OK(cbs, action_ok_database_manager_list); - break; + BIND_ACTION_OK(cbs, action_ok_database_manager_list); + } + else + { + switch (menu_label_hash) + { + case MENU_LABEL_DEFERRED_DATABASE_MANAGER_LIST: + BIND_ACTION_OK(cbs, action_ok_deferred_list_stub); + break; + case MENU_LABEL_DATABASE_MANAGER_LIST: + BIND_ACTION_OK(cbs, action_ok_database_manager_list); + break; + } } break; case FILE_TYPE_RDB_ENTRY: diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index 19ff1e68ae..c4c680debc 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -468,6 +468,14 @@ static struct cbs_title_lbl_callback cbs_title_lbl_list[] = { { MENU_ENUM_LABEL_DEFERRED_THUMBNAILS_UPDATER_LIST, action_get_online_thumbnails_updater_list + }, + { + MENU_ENUM_LABEL_VIDEO_FILTER, + action_get_title_video_filter + }, + { + MENU_ENUM_LABEL_HELP_LIST, + action_get_title_help } }; @@ -1033,7 +1041,6 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_DEFERRED_ACCOUNTS_LIST: BIND_ACTION_GET_TITLE(cbs, action_get_user_accounts_list); break; - case MENU_LABEL_HELP_LIST: case MENU_LABEL_HELP: BIND_ACTION_GET_TITLE(cbs, action_get_title_help); break; @@ -1044,9 +1051,6 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_XMB_FONT: BIND_ACTION_GET_TITLE(cbs, action_get_title_font_path); break; - case MENU_LABEL_VIDEO_FILTER: - BIND_ACTION_GET_TITLE(cbs, action_get_title_video_filter); - break; case MENU_LABEL_AUDIO_DSP_PLUGIN: BIND_ACTION_GET_TITLE(cbs, action_get_title_audio_filter); break; diff --git a/msg_hash.h b/msg_hash.h index 5b0e4dc6da..ca5ddfad21 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1934,13 +1934,9 @@ enum msg_hash_enums #define MENU_LABEL_AUDIO_RESAMPLER_DRIVER_SINC 0x7c9dec52U #define MENU_LABEL_AUDIO_RESAMPLER_DRIVER_CC 0x0059732bU -#define MENU_LABEL_VIDEO_FILTER 0x1c0eb741U -#define MENU_LABEL_HELP_LIST 0x006af669U - /* Main menu */ #define MENU_LABEL_NETPLAY 0x0b511d22U #define MENU_LABEL_HELP 0x7c97d2eeU -#define MENU_VALUE_HORIZONTAL_MENU 0x35761704U const char *msg_hash_to_str(enum msg_hash_enums msg); From 6fa5822bb27a9bd290ead923ef61b4e7ce246b1e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 5 Feb 2018 21:14:49 +0100 Subject: [PATCH 114/232] Cleanup hashes --- menu/cbs/menu_cbs_deferred_push.c | 7 ++++--- menu/cbs/menu_cbs_title.c | 14 ++++++++------ msg_hash.h | 4 ---- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index bb7c606ab8..b1dc149909 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -730,6 +730,10 @@ static struct cbs_deferred_lbl_callback cbs_deferred_lbl_list[] = { { MENU_ENUM_LABEL_VIDEO_FILTER, deferred_push_video_filter + }, + { + MENU_ENUM_LABEL_NETPLAY, + deferred_push_netplay } }; @@ -1196,9 +1200,6 @@ static int menu_cbs_init_bind_deferred_push_compare_label( case MENU_LABEL_RECORD_CONFIG: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_record_configfile); break; - case MENU_LABEL_NETPLAY: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_netplay); - break; case MENU_LABEL_CONTENT_SETTINGS: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_content_settings); break; diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index c4c680debc..488eda10af 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -476,6 +476,14 @@ static struct cbs_title_lbl_callback cbs_title_lbl_list[] = { { MENU_ENUM_LABEL_HELP_LIST, action_get_title_help + }, + { + MENU_ENUM_LABEL_HELP, + action_get_title_help + }, + { + MENU_ENUM_LABEL_NETPLAY, + action_get_netplay_list } }; @@ -954,9 +962,6 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_LOAD_CONTENT_SPECIAL: BIND_ACTION_GET_TITLE(cbs, action_get_load_content_special); break; - case MENU_LABEL_NETPLAY: - BIND_ACTION_GET_TITLE(cbs, action_get_netplay_list); - break; case MENU_LABEL_DEFERRED_CORE_UPDATER_LIST: BIND_ACTION_GET_TITLE(cbs, action_get_core_updater_list); break; @@ -1041,9 +1046,6 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_DEFERRED_ACCOUNTS_LIST: BIND_ACTION_GET_TITLE(cbs, action_get_user_accounts_list); break; - case MENU_LABEL_HELP: - BIND_ACTION_GET_TITLE(cbs, action_get_title_help); - break; case MENU_LABEL_INPUT_OVERLAY: BIND_ACTION_GET_TITLE(cbs, action_get_title_overlay); break; diff --git a/msg_hash.h b/msg_hash.h index ca5ddfad21..49ec2a5536 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1934,10 +1934,6 @@ enum msg_hash_enums #define MENU_LABEL_AUDIO_RESAMPLER_DRIVER_SINC 0x7c9dec52U #define MENU_LABEL_AUDIO_RESAMPLER_DRIVER_CC 0x0059732bU -/* Main menu */ -#define MENU_LABEL_NETPLAY 0x0b511d22U -#define MENU_LABEL_HELP 0x7c97d2eeU - const char *msg_hash_to_str(enum msg_hash_enums msg); const char *msg_hash_to_str_fr(enum msg_hash_enums msg); From 18c708d29afcb47704e052d9149267bdcc38a6d0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 5 Feb 2018 21:22:57 +0100 Subject: [PATCH 115/232] Get rid of more hashes --- menu/cbs/menu_cbs_deferred_push.c | 21 ++++++++++++--------- menu/cbs/menu_cbs_title.c | 26 ++++++++++++++++---------- msg_hash.h | 12 ------------ 3 files changed, 28 insertions(+), 31 deletions(-) diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index b1dc149909..c6dbae7825 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -734,6 +734,18 @@ static struct cbs_deferred_lbl_callback cbs_deferred_lbl_list[] = { { MENU_ENUM_LABEL_NETPLAY, deferred_push_netplay + }, + { + MENU_ENUM_LABEL_VIDEO_FONT_PATH, + deferred_push_video_font_path + }, + { + MENU_ENUM_LABEL_XMB_FONT, + deferred_push_xmb_font_path + }, + { + MENU_ENUM_LABEL_CONTENT_SETTINGS, + deferred_push_content_settings } }; @@ -1200,9 +1212,6 @@ static int menu_cbs_init_bind_deferred_push_compare_label( case MENU_LABEL_RECORD_CONFIG: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_record_configfile); break; - case MENU_LABEL_CONTENT_SETTINGS: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_content_settings); - break; case MENU_LABEL_MANAGEMENT: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_management_options); break; @@ -1313,12 +1322,6 @@ static int menu_cbs_init_bind_deferred_push_compare_label( case MENU_LABEL_INPUT_OVERLAY: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_input_overlay); break; - case MENU_LABEL_VIDEO_FONT_PATH: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_font_path); - break; - case MENU_LABEL_XMB_FONT: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_xmb_font_path); - break; case MENU_LABEL_CONTENT_HISTORY_PATH: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_content_history_path); break; diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index 488eda10af..43a2f2b77e 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -484,6 +484,22 @@ static struct cbs_title_lbl_callback cbs_title_lbl_list[] = { { MENU_ENUM_LABEL_NETPLAY, action_get_netplay_list + }, + { + MENU_ENUM_LABEL_INFORMATION_LIST, + action_get_title_information_list + }, + { + MENU_ENUM_LABEL_VIDEO_FONT_PATH, + action_get_title_font_path + }, + { + MENU_ENUM_LABEL_XMB_FONT, + action_get_title_font_path + }, + { + MENU_ENUM_LABEL_CONTENT_SETTINGS, + action_get_quick_menu_list } }; @@ -944,9 +960,6 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_RGUI_CONFIG_DIRECTORY: BIND_ACTION_GET_TITLE(cbs, action_get_title_config_directory); break; - case MENU_LABEL_INFORMATION_LIST: - BIND_ACTION_GET_TITLE(cbs, action_get_title_information_list); - break; case MENU_LABEL_DATABASE_MANAGER_LIST: BIND_ACTION_GET_TITLE(cbs, action_get_database_manager_list); break; @@ -971,9 +984,6 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_CORE_OPTIONS: BIND_ACTION_GET_TITLE(cbs, action_get_core_options_list); break; - case MENU_LABEL_CONTENT_SETTINGS: - BIND_ACTION_GET_TITLE(cbs, action_get_quick_menu_list); - break; case MENU_LABEL_CORE_INPUT_REMAPPING_OPTIONS: BIND_ACTION_GET_TITLE(cbs, action_get_input_remapping_options_list); break; @@ -1049,10 +1059,6 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_INPUT_OVERLAY: BIND_ACTION_GET_TITLE(cbs, action_get_title_overlay); break; - case MENU_LABEL_VIDEO_FONT_PATH: - case MENU_LABEL_XMB_FONT: - BIND_ACTION_GET_TITLE(cbs, action_get_title_font_path); - break; case MENU_LABEL_AUDIO_DSP_PLUGIN: BIND_ACTION_GET_TITLE(cbs, action_get_title_audio_filter); break; diff --git a/msg_hash.h b/msg_hash.h index 49ec2a5536..2567ef977d 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1792,21 +1792,9 @@ enum msg_hash_enums #define MENU_LABEL_UPDATE_LAKKA 0x19b51eebU /* Information settings */ - -#define MENU_LABEL_INFORMATION_LIST 0x225e7606U - -#define MENU_LABEL_CONTENT_SETTINGS 0xe789f7f6U - #define MENU_LABEL_SCREEN_RESOLUTION 0x5c9b3a58U -/* Menu settings */ -#define MENU_LABEL_XMB_FONT 0x0ECA56CA2 - -#define MENU_LABEL_PERFCNT_ENABLE 0x6823dbddU - /* Video settings */ -#define MENU_LABEL_VIDEO_FONT_PATH 0xd0de729eU - #define MENU_LABEL_VIDEO_SHADER_PRESET_SAVE_AS 0x3d6e5ce5U #define MENU_LABEL_VIDEO_SHADER_DEFAULT_FILTER 0x4468cb1bU #define MENU_LABEL_VIDEO_SHADER_NUM_PASSES 0x79b2992fU From fb1c44c9001f9c12d599d904923bd40b0bdd70cd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 5 Feb 2018 21:41:34 +0100 Subject: [PATCH 116/232] Get rid of more hashes --- menu/cbs/menu_cbs_deferred_push.c | 42 ++++++++++++---------- menu/cbs/menu_cbs_ok.c | 58 ++++++++++++++++++++----------- menu/cbs/menu_cbs_title.c | 21 ++++++----- msg_hash.h | 22 ------------ 4 files changed, 73 insertions(+), 70 deletions(-) diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index c6dbae7825..a800786a4f 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -746,6 +746,30 @@ static struct cbs_deferred_lbl_callback cbs_deferred_lbl_list[] = { { MENU_ENUM_LABEL_CONTENT_SETTINGS, deferred_push_content_settings + }, + { + MENU_ENUM_LABEL_RECORD_CONFIG, + deferred_push_record_configfile + }, + { + MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_PARAMETERS, + deferred_push_video_shader_preset_parameters + }, + { + MENU_ENUM_LABEL_VIDEO_SHADER_PARAMETERS, + deferred_push_video_shader_parameters + }, + { + MENU_ENUM_LABEL_VIDEO_SHADER_PASS, + deferred_push_video_shader_pass + }, + { + MENU_ENUM_LABEL_VIDEO_SHADER_PRESET, + deferred_push_video_shader_preset + }, + { + MENU_ENUM_LABEL_MENU_WALLPAPER, + deferred_push_images } }; @@ -1209,9 +1233,6 @@ static int menu_cbs_init_bind_deferred_push_compare_label( case MENU_LABEL_REMAP_FILE_LOAD: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_remap_file_load); break; - case MENU_LABEL_RECORD_CONFIG: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_record_configfile); - break; case MENU_LABEL_MANAGEMENT: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_management_options); break; @@ -1289,12 +1310,6 @@ static int menu_cbs_init_bind_deferred_push_compare_label( case MENU_LABEL_FRONTEND_COUNTERS: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_frontend_counters); break; - case MENU_LABEL_VIDEO_SHADER_PRESET_PARAMETERS: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_shader_preset_parameters); - break; - case MENU_LABEL_VIDEO_SHADER_PARAMETERS: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_shader_parameters); - break; case MENU_LABEL_CORE_CHEAT_OPTIONS: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_cheat_options); break; @@ -1307,15 +1322,6 @@ static int menu_cbs_init_bind_deferred_push_compare_label( case MENU_LABEL_CONFIGURATIONS: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_configurations); break; - case MENU_LABEL_VIDEO_SHADER_PRESET: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_shader_preset); - break; - case MENU_LABEL_VIDEO_SHADER_PASS: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_shader_pass); - break; - case MENU_LABEL_MENU_WALLPAPER: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_images); - break; case MENU_LABEL_AUDIO_DSP_PLUGIN: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_audio_dsp_plugin); break; diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 7f01a5cebb..94c860fa3e 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -3777,6 +3777,43 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, BIND_ACTION_OK(cbs, action_ok_push_content_list); return 0; } + else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_RECORD_CONFIG))) + { + BIND_ACTION_OK(cbs, action_ok_record_configfile); + return 0; + } + else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PARAMETERS))) + { + BIND_ACTION_OK(cbs, action_ok_shader_parameters); + return 0; + } + else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_PARAMETERS))) + { + BIND_ACTION_OK(cbs, action_ok_shader_parameters); + return 0; + } + else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PASS))) + { + BIND_ACTION_OK(cbs, action_ok_shader_pass); + return 0; + } + else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PRESET))) + { + BIND_ACTION_OK(cbs, action_ok_shader_preset); + return 0; + } + else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_SAVE_AS))) + { + BIND_ACTION_OK(cbs, action_ok_shader_preset_save_as); + return 0; + } +#ifdef HAVE_NETWORKING + else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_UPDATE_LAKKA))) + { + BIND_ACTION_OK(cbs, action_ok_lakka_list); + return 0; + } +#endif else if (cbs->enum_idx != MSG_UNKNOWN) { switch (cbs->enum_idx) @@ -4214,12 +4251,6 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_LOAD_ARCHIVE: BIND_ACTION_OK(cbs, action_ok_load_archive); break; - case MENU_LABEL_VIDEO_SHADER_PASS: - BIND_ACTION_OK(cbs, action_ok_shader_pass); - break; - case MENU_LABEL_VIDEO_SHADER_PRESET: - BIND_ACTION_OK(cbs, action_ok_shader_preset); - break; case MENU_LABEL_CHEAT_FILE_LOAD: BIND_ACTION_OK(cbs, action_ok_cheat_file); break; @@ -4229,18 +4260,6 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_REMAP_FILE_LOAD: BIND_ACTION_OK(cbs, action_ok_remap_file); break; - case MENU_LABEL_RECORD_CONFIG: - BIND_ACTION_OK(cbs, action_ok_record_configfile); - break; -#ifdef HAVE_NETWORKING - case MENU_LABEL_UPDATE_LAKKA: - BIND_ACTION_OK(cbs, action_ok_lakka_list); - break; -#endif - case MENU_LABEL_VIDEO_SHADER_PARAMETERS: - case MENU_LABEL_VIDEO_SHADER_PRESET_PARAMETERS: - BIND_ACTION_OK(cbs, action_ok_shader_parameters); - break; case MENU_LABEL_ACCOUNTS_LIST: BIND_ACTION_OK(cbs, action_ok_push_accounts_list); break; @@ -4259,9 +4278,6 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_CHEAT_APPLY_CHANGES: BIND_ACTION_OK(cbs, action_ok_cheat_apply_changes); break; - case MENU_LABEL_VIDEO_SHADER_PRESET_SAVE_AS: - BIND_ACTION_OK(cbs, action_ok_shader_preset_save_as); - break; case MENU_LABEL_CHEAT_FILE_SAVE_AS: BIND_ACTION_OK(cbs, action_ok_cheat_file_save_as); break; diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index 43a2f2b77e..1f6003fdb1 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -500,6 +500,18 @@ static struct cbs_title_lbl_callback cbs_title_lbl_list[] = { { MENU_ENUM_LABEL_CONTENT_SETTINGS, action_get_quick_menu_list + }, + { + MENU_ENUM_LABEL_VIDEO_SHADER_PARAMETERS, + action_get_title_video_shader_parameters + }, + { + MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_PARAMETERS, + action_get_title_video_shader_preset_parameters + }, + { + MENU_ENUM_LABEL_VIDEO_SHADER_PRESET, + action_get_title_video_shader_preset } }; @@ -1026,21 +1038,12 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_ACHIEVEMENT_LIST: BIND_ACTION_GET_TITLE(cbs, action_get_title_cheevos_list); break; - case MENU_LABEL_VIDEO_SHADER_PARAMETERS: - BIND_ACTION_GET_TITLE(cbs, action_get_title_video_shader_parameters); - break; - case MENU_LABEL_VIDEO_SHADER_PRESET_PARAMETERS: - BIND_ACTION_GET_TITLE(cbs, action_get_title_video_shader_preset_parameters); - break; case MENU_LABEL_MANAGEMENT: BIND_ACTION_GET_TITLE(cbs, action_get_title_action_generic); break; case MENU_LABEL_DISK_IMAGE_APPEND: BIND_ACTION_GET_TITLE(cbs, action_get_title_disk_image_append); break; - case MENU_LABEL_VIDEO_SHADER_PRESET: - BIND_ACTION_GET_TITLE(cbs, action_get_title_video_shader_preset); - break; case MENU_LABEL_CHEAT_FILE_LOAD: BIND_ACTION_GET_TITLE(cbs, action_get_title_cheat_file_load); break; diff --git a/msg_hash.h b/msg_hash.h index 0013605588..4d692071b9 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1788,30 +1788,13 @@ enum msg_hash_enums #define MENU_LABEL_DOWNLOADED_FILE_DETECT_CORE_LIST 0xb4f82700U -/* Online updater settings */ - -#define MENU_LABEL_UPDATE_LAKKA 0x19b51eebU - /* Information settings */ #define MENU_LABEL_SCREEN_RESOLUTION 0x5c9b3a58U -/* Video settings */ -#define MENU_LABEL_VIDEO_SHADER_PRESET_SAVE_AS 0x3d6e5ce5U -#define MENU_LABEL_VIDEO_SHADER_DEFAULT_FILTER 0x4468cb1bU -#define MENU_LABEL_VIDEO_SHADER_NUM_PASSES 0x79b2992fU -#define MENU_LABEL_VIDEO_SHADER_PARAMETERS 0x9895c3e5U -#define MENU_LABEL_VIDEO_SHADER_PRESET_PARAMETERS 0xd18158d7U -#define MENU_LABEL_VIDEO_SHADER_PASS 0x4fa31028U -#define MENU_LABEL_VIDEO_SHADER_PRESET 0xc5d3bae4U - /* Input settings */ #define MENU_LABEL_INPUT_OVERLAY 0x24e24796U #define MENU_LABEL_INPUT_OSK_OVERLAY 0x11f1c582U -/* Record settings */ - -#define MENU_LABEL_RECORD_CONFIG 0x11c3daf9U - /* Cheat options */ #define MENU_LABEL_CHEAT_DATABASE_PATH 0x01388b8aU @@ -1824,11 +1807,6 @@ enum msg_hash_enums #define MENU_LABEL_DISK_OPTIONS 0xc61ab5fbU #define MENU_LABEL_DISK_IMAGE_APPEND 0x5af7d709U -/* Menu settings */ - -#define MENU_LABEL_MENU_WALLPAPER 0x3b84de01U -#define MENU_LABEL_MENU_SETTINGS 0x61e4544bU - /* Directory settings */ #define MENU_LABEL_CURSOR_DIRECTORY 0xdee8d377U From 754c9d4db972366dd51e7c5fa3c95dfb29f3a78b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 5 Feb 2018 23:37:27 +0100 Subject: [PATCH 117/232] Cleanup more hashes --- menu/cbs/menu_cbs_ok.c | 40 ++++++++++++++++++++++++--------------- menu/cbs/menu_cbs_title.c | 21 +++++++++++--------- msg_hash.h | 12 ------------ 3 files changed, 37 insertions(+), 36 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 94c860fa3e..f728168d77 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -3807,6 +3807,11 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, BIND_ACTION_OK(cbs, action_ok_shader_preset_save_as); return 0; } + else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DISK_IMAGE_APPEND))) + { + BIND_ACTION_OK(cbs, action_ok_disk_image_append_list); + return 0; + } #ifdef HAVE_NETWORKING else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_UPDATE_LAKKA))) { @@ -3814,6 +3819,26 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, return 0; } #endif + else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_OPEN_ARCHIVE))) + { + BIND_ACTION_OK(cbs, action_ok_open_archive); + return 0; + } + else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_OPEN_ARCHIVE_DETECT_CORE))) + { + BIND_ACTION_OK(cbs, action_ok_open_archive_detect_core); + return 0; + } + else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_LOAD_ARCHIVE_DETECT_CORE))) + { + BIND_ACTION_OK(cbs, action_ok_load_archive_detect_core); + return 0; + } + else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_LOAD_ARCHIVE))) + { + BIND_ACTION_OK(cbs, action_ok_load_archive); + return 0; + } else if (cbs->enum_idx != MSG_UNKNOWN) { switch (cbs->enum_idx) @@ -4239,18 +4264,6 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, { switch (hash) { - case MENU_LABEL_OPEN_ARCHIVE_DETECT_CORE: - BIND_ACTION_OK(cbs, action_ok_open_archive_detect_core); - break; - case MENU_LABEL_OPEN_ARCHIVE: - BIND_ACTION_OK(cbs, action_ok_open_archive); - break; - case MENU_LABEL_LOAD_ARCHIVE_DETECT_CORE: - BIND_ACTION_OK(cbs, action_ok_load_archive_detect_core); - break; - case MENU_LABEL_LOAD_ARCHIVE: - BIND_ACTION_OK(cbs, action_ok_load_archive); - break; case MENU_LABEL_CHEAT_FILE_LOAD: BIND_ACTION_OK(cbs, action_ok_cheat_file); break; @@ -4287,9 +4300,6 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_REMAP_FILE_SAVE_GAME: BIND_ACTION_OK(cbs, action_ok_remap_file_save_game); break; - case MENU_LABEL_DISK_IMAGE_APPEND: - BIND_ACTION_OK(cbs, action_ok_disk_image_append_list); - break; case MENU_LABEL_SCREEN_RESOLUTION: BIND_ACTION_OK(cbs, action_ok_video_resolution); break; diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index 1f6003fdb1..e1c8ee26c5 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -512,6 +512,18 @@ static struct cbs_title_lbl_callback cbs_title_lbl_list[] = { { MENU_ENUM_LABEL_VIDEO_SHADER_PRESET, action_get_title_video_shader_preset + }, + { + MENU_ENUM_LABEL_LIBRETRO_INFO_PATH, + action_get_title_core_info_directory + }, + { + MENU_ENUM_LABEL_DISK_OPTIONS, + action_get_disk_options_list + }, + { + MENU_ENUM_LABEL_DISK_IMAGE_APPEND, + action_get_title_disk_image_append } }; @@ -1005,9 +1017,6 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_SHADER_OPTIONS: BIND_ACTION_GET_TITLE(cbs, action_get_shader_options_list); break; - case MENU_LABEL_DISK_OPTIONS: - BIND_ACTION_GET_TITLE(cbs, action_get_disk_options_list); - break; case MENU_LABEL_FRONTEND_COUNTERS: BIND_ACTION_GET_TITLE(cbs, action_get_frontend_counters_list); break; @@ -1041,9 +1050,6 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_MANAGEMENT: BIND_ACTION_GET_TITLE(cbs, action_get_title_action_generic); break; - case MENU_LABEL_DISK_IMAGE_APPEND: - BIND_ACTION_GET_TITLE(cbs, action_get_title_disk_image_append); - break; case MENU_LABEL_CHEAT_FILE_LOAD: BIND_ACTION_GET_TITLE(cbs, action_get_title_cheat_file_load); break; @@ -1071,9 +1077,6 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_LIBRETRO_DIR_PATH: BIND_ACTION_GET_TITLE(cbs, action_get_title_core_directory); break; - case MENU_LABEL_LIBRETRO_INFO_PATH: - BIND_ACTION_GET_TITLE(cbs, action_get_title_core_info_directory); - break; default: return -1; } diff --git a/msg_hash.h b/msg_hash.h index 4d692071b9..792fd6ac78 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1802,11 +1802,6 @@ enum msg_hash_enums #define MENU_LABEL_CHEAT_FILE_SAVE_AS 0x1f58dccaU #define MENU_LABEL_CHEAT_APPLY_CHANGES 0xde88aa27U -/* Disk settings */ - -#define MENU_LABEL_DISK_OPTIONS 0xc61ab5fbU -#define MENU_LABEL_DISK_IMAGE_APPEND 0x5af7d709U - /* Directory settings */ #define MENU_LABEL_CURSOR_DIRECTORY 0xdee8d377U @@ -1885,14 +1880,7 @@ enum msg_hash_enums #define MENU_LABEL_CONTENT_COLLECTION_LIST 0x32d1df83U #define MENU_LABEL_COLLECTION 0x5fea5991U -#define MENU_LABEL_OPEN_ARCHIVE 0x78c0ca58U -#define MENU_LABEL_OPEN_ARCHIVE_DETECT_CORE 0x92442638U -#define MENU_LABEL_LOAD_ARCHIVE_DETECT_CORE 0x681f2f46U -#define MENU_LABEL_LOAD_ARCHIVE 0xc3834e66U - /* Help */ -#define MENU_LABEL_LIBRETRO_INFO_PATH 0xe552b25fU - #define MENU_LABEL_INPUT_DRIVER_LINUXRAW 0xc33c6b9fU #define MENU_LABEL_INPUT_DRIVER_UDEV 0x7c9eeeb9U From 226206e2f8b2be24618f15a01411d771c64baac3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 5 Feb 2018 23:40:38 +0100 Subject: [PATCH 118/232] Remove more hashes --- msg_hash.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/msg_hash.h b/msg_hash.h index 792fd6ac78..5d120e0b29 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1871,9 +1871,6 @@ enum msg_hash_enums #define MENU_LABEL_CONTENT_HISTORY_PATH 0x6f22fb9dU #define MENU_LABEL_ONSCREEN_KEYBOARD_OVERLAY_SETTINGS 0xa6de9ba6U #define MENU_LABEL_SHADER_APPLY_CHANGES 0x4f7306b9U -#define MENU_LABEL_CUSTOM_BIND 0x1e84b3fcU -#define MENU_LABEL_CUSTOM_BIND_ALL 0x79ac14f4U -#define MENU_LABEL_CUSTOM_BIND_DEFAULTS 0xe88f7b13U #define MENU_LABEL_CONFIGURATIONS 0x3e930a50U #define MENU_LABEL_REMAP_FILE_SAVE_CORE 0x7c9d4c8fU #define MENU_LABEL_REMAP_FILE_SAVE_GAME 0x7c9f41e0U From 8e21e619233431424665db2db8cb9ea6c61593d2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 5 Feb 2018 23:43:26 +0100 Subject: [PATCH 119/232] Cleanups --- menu/cbs/menu_cbs_ok.c | 8 +++++--- msg_hash.h | 2 -- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index f728168d77..22fbcf73b4 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -3839,6 +3839,11 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, BIND_ACTION_OK(cbs, action_ok_load_archive); return 0; } + else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_SHADER_APPLY_CHANGES))) + { + BIND_ACTION_OK(cbs, action_ok_shader_apply_changes); + return 0; + } else if (cbs->enum_idx != MSG_UNKNOWN) { switch (cbs->enum_idx) @@ -4285,9 +4290,6 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_DETECT_CORE_LIST_OK: BIND_ACTION_OK(cbs, action_ok_file_load_detect_core); break; - case MENU_LABEL_SHADER_APPLY_CHANGES: - BIND_ACTION_OK(cbs, action_ok_shader_apply_changes); - break; case MENU_LABEL_CHEAT_APPLY_CHANGES: BIND_ACTION_OK(cbs, action_ok_cheat_apply_changes); break; diff --git a/msg_hash.h b/msg_hash.h index 5d120e0b29..c17b677666 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1869,8 +1869,6 @@ enum msg_hash_enums #define MENU_LABEL_CUSTOM_RATIO 0xf038731eU #define MENU_LABEL_PAL60_ENABLE 0x62bc416eU #define MENU_LABEL_CONTENT_HISTORY_PATH 0x6f22fb9dU -#define MENU_LABEL_ONSCREEN_KEYBOARD_OVERLAY_SETTINGS 0xa6de9ba6U -#define MENU_LABEL_SHADER_APPLY_CHANGES 0x4f7306b9U #define MENU_LABEL_CONFIGURATIONS 0x3e930a50U #define MENU_LABEL_REMAP_FILE_SAVE_CORE 0x7c9d4c8fU #define MENU_LABEL_REMAP_FILE_SAVE_GAME 0x7c9f41e0U From b726959297ff08e3100b822e6f14fac6260425e3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 5 Feb 2018 23:49:46 +0100 Subject: [PATCH 120/232] Get rid of hashes --- menu/cbs/menu_cbs_deferred_push.c | 7 ++++--- menu/cbs/menu_cbs_ok.c | 24 +++++++++++++++--------- menu/cbs/menu_cbs_title.c | 14 ++++++++------ msg_hash.h | 7 ------- 4 files changed, 27 insertions(+), 25 deletions(-) diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index a800786a4f..2ba307713c 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -770,6 +770,10 @@ static struct cbs_deferred_lbl_callback cbs_deferred_lbl_list[] = { { MENU_ENUM_LABEL_MENU_WALLPAPER, deferred_push_images + }, + { + MENU_ENUM_LABEL_CHEAT_FILE_LOAD, + deferred_push_cheat_file_load } }; @@ -1227,9 +1231,6 @@ static int menu_cbs_init_bind_deferred_push_compare_label( case MENU_LABEL_CURSOR_MANAGER_LIST: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list); break; - case MENU_LABEL_CHEAT_FILE_LOAD: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cheat_file_load); - break; case MENU_LABEL_REMAP_FILE_LOAD: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_remap_file_load); break; diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 22fbcf73b4..fb36802d73 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -3844,6 +3844,21 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, BIND_ACTION_OK(cbs, action_ok_shader_apply_changes); return 0; } + else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_CHEAT_APPLY_CHANGES))) + { + BIND_ACTION_OK(cbs, action_ok_cheat_apply_changes); + return 0; + } + else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_CHEAT_FILE_SAVE_AS))) + { + BIND_ACTION_OK(cbs, action_ok_cheat_file_save_as); + return 0; + } + else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_CHEAT_FILE_LOAD))) + { + BIND_ACTION_OK(cbs, action_ok_cheat_file); + return 0; + } else if (cbs->enum_idx != MSG_UNKNOWN) { switch (cbs->enum_idx) @@ -4269,9 +4284,6 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, { switch (hash) { - case MENU_LABEL_CHEAT_FILE_LOAD: - BIND_ACTION_OK(cbs, action_ok_cheat_file); - break; case MENU_LABEL_AUDIO_DSP_PLUGIN: BIND_ACTION_OK(cbs, action_ok_audio_dsp_plugin); break; @@ -4290,12 +4302,6 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_DETECT_CORE_LIST_OK: BIND_ACTION_OK(cbs, action_ok_file_load_detect_core); break; - case MENU_LABEL_CHEAT_APPLY_CHANGES: - BIND_ACTION_OK(cbs, action_ok_cheat_apply_changes); - break; - case MENU_LABEL_CHEAT_FILE_SAVE_AS: - BIND_ACTION_OK(cbs, action_ok_cheat_file_save_as); - break; case MENU_LABEL_REMAP_FILE_SAVE_CORE: BIND_ACTION_OK(cbs, action_ok_remap_file_save_core); break; diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index e1c8ee26c5..bfe05972f0 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -524,6 +524,14 @@ static struct cbs_title_lbl_callback cbs_title_lbl_list[] = { { MENU_ENUM_LABEL_DISK_IMAGE_APPEND, action_get_title_disk_image_append + }, + { + MENU_ENUM_LABEL_CHEAT_FILE_LOAD, + action_get_title_cheat_file_load + }, + { + MENU_ENUM_LABEL_CHEAT_DATABASE_PATH, + action_get_title_cheat_directory } }; @@ -1050,9 +1058,6 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_MANAGEMENT: BIND_ACTION_GET_TITLE(cbs, action_get_title_action_generic); break; - case MENU_LABEL_CHEAT_FILE_LOAD: - BIND_ACTION_GET_TITLE(cbs, action_get_title_cheat_file_load); - break; case MENU_LABEL_REMAP_FILE_LOAD: BIND_ACTION_GET_TITLE(cbs, action_get_title_remap_file_load); break; @@ -1071,9 +1076,6 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_AUDIO_DSP_PLUGIN: BIND_ACTION_GET_TITLE(cbs, action_get_title_audio_filter); break; - case MENU_LABEL_CHEAT_DATABASE_PATH: - BIND_ACTION_GET_TITLE(cbs, action_get_title_cheat_directory); - break; case MENU_LABEL_LIBRETRO_DIR_PATH: BIND_ACTION_GET_TITLE(cbs, action_get_title_core_directory); break; diff --git a/msg_hash.h b/msg_hash.h index c17b677666..53850d8677 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1795,13 +1795,6 @@ enum msg_hash_enums #define MENU_LABEL_INPUT_OVERLAY 0x24e24796U #define MENU_LABEL_INPUT_OSK_OVERLAY 0x11f1c582U -/* Cheat options */ - -#define MENU_LABEL_CHEAT_DATABASE_PATH 0x01388b8aU -#define MENU_LABEL_CHEAT_FILE_LOAD 0x57336148U -#define MENU_LABEL_CHEAT_FILE_SAVE_AS 0x1f58dccaU -#define MENU_LABEL_CHEAT_APPLY_CHANGES 0xde88aa27U - /* Directory settings */ #define MENU_LABEL_CURSOR_DIRECTORY 0xdee8d377U From 942c61cb589482665809e651297a827fb9ce1e80 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 5 Feb 2018 23:58:10 +0100 Subject: [PATCH 121/232] Remove hashes --- menu/cbs/menu_cbs_deferred_push.c | 7 ++++--- menu/cbs/menu_cbs_title.c | 7 ++++--- msg_hash.h | 4 ---- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index 2ba307713c..ff55ae5d0e 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -774,6 +774,10 @@ static struct cbs_deferred_lbl_callback cbs_deferred_lbl_list[] = { { MENU_ENUM_LABEL_CHEAT_FILE_LOAD, deferred_push_cheat_file_load + }, + { + MENU_ENUM_LABEL_INPUT_OVERLAY, + deferred_push_input_overlay } }; @@ -1326,9 +1330,6 @@ static int menu_cbs_init_bind_deferred_push_compare_label( case MENU_LABEL_AUDIO_DSP_PLUGIN: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_audio_dsp_plugin); break; - case MENU_LABEL_INPUT_OVERLAY: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_input_overlay); - break; case MENU_LABEL_CONTENT_HISTORY_PATH: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_content_history_path); break; diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index bfe05972f0..62c25abb19 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -532,6 +532,10 @@ static struct cbs_title_lbl_callback cbs_title_lbl_list[] = { { MENU_ENUM_LABEL_CHEAT_DATABASE_PATH, action_get_title_cheat_directory + }, + { + MENU_ENUM_LABEL_INPUT_OVERLAY, + action_get_title_overlay } }; @@ -1070,9 +1074,6 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_DEFERRED_ACCOUNTS_LIST: BIND_ACTION_GET_TITLE(cbs, action_get_user_accounts_list); break; - case MENU_LABEL_INPUT_OVERLAY: - BIND_ACTION_GET_TITLE(cbs, action_get_title_overlay); - break; case MENU_LABEL_AUDIO_DSP_PLUGIN: BIND_ACTION_GET_TITLE(cbs, action_get_title_audio_filter); break; diff --git a/msg_hash.h b/msg_hash.h index 53850d8677..9bbb6561b3 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1791,10 +1791,6 @@ enum msg_hash_enums /* Information settings */ #define MENU_LABEL_SCREEN_RESOLUTION 0x5c9b3a58U -/* Input settings */ -#define MENU_LABEL_INPUT_OVERLAY 0x24e24796U -#define MENU_LABEL_INPUT_OSK_OVERLAY 0x11f1c582U - /* Directory settings */ #define MENU_LABEL_CURSOR_DIRECTORY 0xdee8d377U From 76267cf05fc0217aebc51e46062fcf09daeedb71 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 6 Feb 2018 00:00:55 +0100 Subject: [PATCH 122/232] Remove hashes --- menu/cbs/menu_cbs_deferred_push.c | 7 ++++--- menu/cbs/menu_cbs_ok.c | 8 +++++--- menu/cbs/menu_cbs_title.c | 7 ++++--- msg_hash.h | 2 -- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index ff55ae5d0e..2858c37df3 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -778,6 +778,10 @@ static struct cbs_deferred_lbl_callback cbs_deferred_lbl_list[] = { { MENU_ENUM_LABEL_INPUT_OVERLAY, deferred_push_input_overlay + }, + { + MENU_ENUM_LABEL_AUDIO_DSP_PLUGIN, + deferred_push_audio_dsp_plugin } }; @@ -1327,9 +1331,6 @@ static int menu_cbs_init_bind_deferred_push_compare_label( case MENU_LABEL_CONFIGURATIONS: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_configurations); break; - case MENU_LABEL_AUDIO_DSP_PLUGIN: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_audio_dsp_plugin); - break; case MENU_LABEL_CONTENT_HISTORY_PATH: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_content_history_path); break; diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index fb36802d73..e010027191 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -3859,6 +3859,11 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, BIND_ACTION_OK(cbs, action_ok_cheat_file); return 0; } + else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_AUDIO_DSP_PLUGIN))) + { + BIND_ACTION_OK(cbs, action_ok_audio_dsp_plugin); + return 0; + } else if (cbs->enum_idx != MSG_UNKNOWN) { switch (cbs->enum_idx) @@ -4284,9 +4289,6 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, { switch (hash) { - case MENU_LABEL_AUDIO_DSP_PLUGIN: - BIND_ACTION_OK(cbs, action_ok_audio_dsp_plugin); - break; case MENU_LABEL_REMAP_FILE_LOAD: BIND_ACTION_OK(cbs, action_ok_remap_file); break; diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index 62c25abb19..4957ff81d3 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -536,6 +536,10 @@ static struct cbs_title_lbl_callback cbs_title_lbl_list[] = { { MENU_ENUM_LABEL_INPUT_OVERLAY, action_get_title_overlay + }, + { + MENU_ENUM_LABEL_AUDIO_DSP_PLUGIN, + action_get_title_audio_filter } }; @@ -1074,9 +1078,6 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_DEFERRED_ACCOUNTS_LIST: BIND_ACTION_GET_TITLE(cbs, action_get_user_accounts_list); break; - case MENU_LABEL_AUDIO_DSP_PLUGIN: - BIND_ACTION_GET_TITLE(cbs, action_get_title_audio_filter); - break; case MENU_LABEL_LIBRETRO_DIR_PATH: BIND_ACTION_GET_TITLE(cbs, action_get_title_core_directory); break; diff --git a/msg_hash.h b/msg_hash.h index 9bbb6561b3..0ecf225557 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1868,8 +1868,6 @@ enum msg_hash_enums #define MENU_LABEL_INPUT_DRIVER_LINUXRAW 0xc33c6b9fU #define MENU_LABEL_INPUT_DRIVER_UDEV 0x7c9eeeb9U -#define MENU_LABEL_AUDIO_DSP_PLUGIN 0x4a69572bU - #define MENU_LABEL_AUDIO_RESAMPLER_DRIVER_SINC 0x7c9dec52U #define MENU_LABEL_AUDIO_RESAMPLER_DRIVER_CC 0x0059732bU From 532462702ee8d45f71f06ce695273ed9501d1a5c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 6 Feb 2018 00:03:27 +0100 Subject: [PATCH 123/232] Remove hash --- menu/cbs/menu_cbs_ok.c | 8 +++++--- msg_hash.h | 1 - 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index e010027191..e021aff4f0 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -3864,6 +3864,11 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, BIND_ACTION_OK(cbs, action_ok_audio_dsp_plugin); return 0; } + else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_ACCOUNTS_LIST))) + { + BIND_ACTION_OK(cbs, action_ok_push_accounts_list); + return 0; + } else if (cbs->enum_idx != MSG_UNKNOWN) { switch (cbs->enum_idx) @@ -4292,9 +4297,6 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_REMAP_FILE_LOAD: BIND_ACTION_OK(cbs, action_ok_remap_file); break; - case MENU_LABEL_ACCOUNTS_LIST: - BIND_ACTION_OK(cbs, action_ok_push_accounts_list); - break; case MENU_LABEL_ACCOUNTS_RETRO_ACHIEVEMENTS: BIND_ACTION_OK(cbs, action_ok_push_accounts_cheevos_list); break; diff --git a/msg_hash.h b/msg_hash.h index 0ecf225557..da7b157736 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1784,7 +1784,6 @@ enum msg_hash_enums /* Accounts settings */ #define MENU_LABEL_ACCOUNTS_RETRO_ACHIEVEMENTS 0xe6b7c16cU -#define MENU_LABEL_ACCOUNTS_LIST 0x774c15a0U #define MENU_LABEL_DOWNLOADED_FILE_DETECT_CORE_LIST 0xb4f82700U From cef20c41355accf473b3861f41caf3def16ad4dc Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 6 Feb 2018 00:05:47 +0100 Subject: [PATCH 124/232] remove hash --- menu/cbs/menu_cbs_deferred_push.c | 7 ++++--- menu/cbs/menu_cbs_ok.c | 8 +++++--- msg_hash.h | 3 --- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index 2858c37df3..1363f35300 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -782,6 +782,10 @@ static struct cbs_deferred_lbl_callback cbs_deferred_lbl_list[] = { { MENU_ENUM_LABEL_AUDIO_DSP_PLUGIN, deferred_push_audio_dsp_plugin + }, + { + MENU_ENUM_LABEL_DOWNLOADED_FILE_DETECT_CORE_LIST, + deferred_push_detect_core_list } }; @@ -1334,9 +1338,6 @@ static int menu_cbs_init_bind_deferred_push_compare_label( case MENU_LABEL_CONTENT_HISTORY_PATH: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_content_history_path); break; - case MENU_LABEL_DOWNLOADED_FILE_DETECT_CORE_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_detect_core_list); - break; default: return -1; } diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index e021aff4f0..7ad19c177b 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -3869,6 +3869,11 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, BIND_ACTION_OK(cbs, action_ok_push_accounts_list); return 0; } + else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DOWNLOADED_FILE_DETECT_CORE_LIST))) + { + BIND_ACTION_OK(cbs, action_ok_push_downloads_dir); + return 0; + } else if (cbs->enum_idx != MSG_UNKNOWN) { switch (cbs->enum_idx) @@ -4300,9 +4305,6 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_ACCOUNTS_RETRO_ACHIEVEMENTS: BIND_ACTION_OK(cbs, action_ok_push_accounts_cheevos_list); break; - case MENU_LABEL_DOWNLOADED_FILE_DETECT_CORE_LIST: - BIND_ACTION_OK(cbs, action_ok_push_downloads_dir); - break; case MENU_LABEL_DETECT_CORE_LIST_OK: BIND_ACTION_OK(cbs, action_ok_file_load_detect_core); break; diff --git a/msg_hash.h b/msg_hash.h index da7b157736..c1a41e85bd 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1782,11 +1782,8 @@ enum msg_hash_enums #define MENU_LABEL_DEFERRED_BROWSE_URL_START 0xcef58296U /* Accounts settings */ - #define MENU_LABEL_ACCOUNTS_RETRO_ACHIEVEMENTS 0xe6b7c16cU -#define MENU_LABEL_DOWNLOADED_FILE_DETECT_CORE_LIST 0xb4f82700U - /* Information settings */ #define MENU_LABEL_SCREEN_RESOLUTION 0x5c9b3a58U From 410188ce901e35db1f6ba947c7913c74fbf0f719 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 6 Feb 2018 00:10:40 +0100 Subject: [PATCH 125/232] Cleanups --- menu/cbs/menu_cbs_ok.c | 16 ++++++++++------ menu/cbs/menu_cbs_start.c | 16 ++++++++++------ msg_hash.h | 6 ------ 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 7ad19c177b..374b457efa 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -3874,6 +3874,16 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, BIND_ACTION_OK(cbs, action_ok_push_downloads_dir); return 0; } + else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_ACCOUNTS_RETRO_ACHIEVEMENTS))) + { + BIND_ACTION_OK(cbs, action_ok_push_accounts_cheevos_list); + return 0; + } + else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_SCREEN_RESOLUTION))) + { + BIND_ACTION_OK(cbs, action_ok_video_resolution); + return 0; + } else if (cbs->enum_idx != MSG_UNKNOWN) { switch (cbs->enum_idx) @@ -4302,9 +4312,6 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_REMAP_FILE_LOAD: BIND_ACTION_OK(cbs, action_ok_remap_file); break; - case MENU_LABEL_ACCOUNTS_RETRO_ACHIEVEMENTS: - BIND_ACTION_OK(cbs, action_ok_push_accounts_cheevos_list); - break; case MENU_LABEL_DETECT_CORE_LIST_OK: BIND_ACTION_OK(cbs, action_ok_file_load_detect_core); break; @@ -4314,9 +4321,6 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_REMAP_FILE_SAVE_GAME: BIND_ACTION_OK(cbs, action_ok_remap_file_save_game); break; - case MENU_LABEL_SCREEN_RESOLUTION: - BIND_ACTION_OK(cbs, action_ok_video_resolution); - break; default: return -1; } diff --git a/menu/cbs/menu_cbs_start.c b/menu/cbs/menu_cbs_start.c index 84f028c2ce..e573cbbbd4 100644 --- a/menu/cbs/menu_cbs_start.c +++ b/menu/cbs/menu_cbs_start.c @@ -16,6 +16,7 @@ #include #include #include +#include #ifdef HAVE_CONFIG_H #include "../../config.h" @@ -274,8 +275,15 @@ static int action_start_lookup_setting(unsigned type, const char *label) return menu_setting_set(type, label, MENU_ACTION_START, false); } -static int menu_cbs_init_bind_start_compare_label(menu_file_list_cbs_t *cbs) +static int menu_cbs_init_bind_start_compare_label(menu_file_list_cbs_t *cbs, + const char *label) { + if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_SCREEN_RESOLUTION))) + { + BIND_ACTION_START(cbs, action_start_video_resolution); + return 0; + } + if (cbs->enum_idx != MSG_UNKNOWN) { switch (cbs->enum_idx) @@ -354,10 +362,6 @@ static int menu_cbs_init_bind_start_compare_type(menu_file_list_cbs_t *cbs, { BIND_ACTION_START(cbs, action_start_core_setting); } - else if (type == MENU_LABEL_SCREEN_RESOLUTION) - { - BIND_ACTION_START(cbs, action_start_video_resolution); - } else return -1; @@ -372,7 +376,7 @@ int menu_cbs_init_bind_start(menu_file_list_cbs_t *cbs, BIND_ACTION_START(cbs, action_start_lookup_setting); - if (menu_cbs_init_bind_start_compare_label(cbs) == 0) + if (menu_cbs_init_bind_start_compare_label(cbs, label) == 0) return 0; if (menu_cbs_init_bind_start_compare_type(cbs, type) == 0) diff --git a/msg_hash.h b/msg_hash.h index c1a41e85bd..fef1017aeb 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1781,12 +1781,6 @@ enum msg_hash_enums #define MENU_LABEL_DEFERRED_CONFIGURATIONS_LIST 0x679a1b0bU #define MENU_LABEL_DEFERRED_BROWSE_URL_START 0xcef58296U -/* Accounts settings */ -#define MENU_LABEL_ACCOUNTS_RETRO_ACHIEVEMENTS 0xe6b7c16cU - -/* Information settings */ -#define MENU_LABEL_SCREEN_RESOLUTION 0x5c9b3a58U - /* Directory settings */ #define MENU_LABEL_CURSOR_DIRECTORY 0xdee8d377U From 0e46a6b77e2eba5e39a0d3e89dcf8e4798277dae Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 6 Feb 2018 00:16:49 +0100 Subject: [PATCH 126/232] Update --- menu/cbs/menu_cbs_ok.c | 8 +++++--- msg_hash.h | 2 -- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 374b457efa..ad4759734c 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -3884,6 +3884,11 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, BIND_ACTION_OK(cbs, action_ok_video_resolution); return 0; } + else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DETECT_CORE_LIST_OK))) + { + BIND_ACTION_OK(cbs, action_ok_file_load_detect_core); + return 0; + } else if (cbs->enum_idx != MSG_UNKNOWN) { switch (cbs->enum_idx) @@ -4312,9 +4317,6 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_REMAP_FILE_LOAD: BIND_ACTION_OK(cbs, action_ok_remap_file); break; - case MENU_LABEL_DETECT_CORE_LIST_OK: - BIND_ACTION_OK(cbs, action_ok_file_load_detect_core); - break; case MENU_LABEL_REMAP_FILE_SAVE_CORE: BIND_ACTION_OK(cbs, action_ok_remap_file_save_core); break; diff --git a/msg_hash.h b/msg_hash.h index fef1017aeb..2ce5758cd0 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1829,8 +1829,6 @@ enum msg_hash_enums #define MENU_LABEL_RDB_ENTRY_RELEASE_YEAR 0x14c9c6bfU #define MENU_LABEL_RDB_ENTRY_MAX_USERS 0xfae91cc4U -#define MENU_LABEL_DETECT_CORE_LIST 0xaa07c341U -#define MENU_LABEL_DETECT_CORE_LIST_OK 0xabba2a7aU #define MENU_LABEL_CORE_LIST 0xa22bb14dU #define MENU_LABEL_MANAGEMENT 0x2516c88aU #define MENU_LABEL_FRONTEND_COUNTERS 0xe5696877U From 1523976d2cb7a96d5b4902d4273e7194c44074b9 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 6 Feb 2018 00:26:00 +0100 Subject: [PATCH 127/232] Updates --- menu/cbs/menu_cbs_deferred_push.c | 7 ++++--- menu/cbs/menu_cbs_title.c | 7 ++++--- msg_hash.h | 1 - 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index 1363f35300..ba53d54ef1 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -786,6 +786,10 @@ static struct cbs_deferred_lbl_callback cbs_deferred_lbl_list[] = { { MENU_ENUM_LABEL_DOWNLOADED_FILE_DETECT_CORE_LIST, deferred_push_detect_core_list + }, + { + MENU_ENUM_LABEL_CONFIGURATIONS, + deferred_push_configurations } }; @@ -1332,9 +1336,6 @@ static int menu_cbs_init_bind_deferred_push_compare_label( case MENU_LABEL_CONTENT_COLLECTION_LIST: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_content_collection_list); break; - case MENU_LABEL_CONFIGURATIONS: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_configurations); - break; case MENU_LABEL_CONTENT_HISTORY_PATH: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_content_history_path); break; diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index 4957ff81d3..b8bd77d8dd 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -540,6 +540,10 @@ static struct cbs_title_lbl_callback cbs_title_lbl_list[] = { { MENU_ENUM_LABEL_AUDIO_DSP_PLUGIN, action_get_title_audio_filter + }, + { + MENU_ENUM_LABEL_CONFIGURATIONS, + action_get_title_configurations } }; @@ -928,9 +932,6 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_DEFERRED_CORE_LIST: BIND_ACTION_GET_TITLE(cbs, action_get_title_deferred_core_list); break; - case MENU_LABEL_CONFIGURATIONS: - BIND_ACTION_GET_TITLE(cbs, action_get_title_configurations); - break; case MENU_LABEL_JOYPAD_AUTOCONFIG_DIR: BIND_ACTION_GET_TITLE(cbs, action_get_title_autoconfig_directory); break; diff --git a/msg_hash.h b/msg_hash.h index 2ce5758cd0..67002857a9 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1846,7 +1846,6 @@ enum msg_hash_enums #define MENU_LABEL_CUSTOM_RATIO 0xf038731eU #define MENU_LABEL_PAL60_ENABLE 0x62bc416eU #define MENU_LABEL_CONTENT_HISTORY_PATH 0x6f22fb9dU -#define MENU_LABEL_CONFIGURATIONS 0x3e930a50U #define MENU_LABEL_REMAP_FILE_SAVE_CORE 0x7c9d4c8fU #define MENU_LABEL_REMAP_FILE_SAVE_GAME 0x7c9f41e0U #define MENU_LABEL_CONTENT_COLLECTION_LIST 0x32d1df83U From d89f268d98cf904a874ff53520d2d58c708f88fd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 6 Feb 2018 01:07:52 +0100 Subject: [PATCH 128/232] Fix regression with load archive --- menu/cbs/menu_cbs_ok.c | 66 ++++++++++++++++++++++++------------------ msg_hash.h | 4 +++ 2 files changed, 42 insertions(+), 28 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index ad4759734c..d69cd8fb71 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -4314,6 +4314,9 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, { switch (hash) { + case MENU_LABEL_FAVORITES: + BIND_ACTION_OK(cbs, action_ok_push_content_list); + break; case MENU_LABEL_REMAP_FILE_LOAD: BIND_ACTION_OK(cbs, action_ok_remap_file); break; @@ -4430,14 +4433,18 @@ static int menu_cbs_init_bind_ok_compare_type(menu_file_list_cbs_t *cbs, BIND_ACTION_OK(cbs, action_ok_scan_file); #endif } - else if (string_is_equal(menu_label, - msg_hash_to_str(MENU_ENUM_LABEL_FAVORITES))) - { - BIND_ACTION_OK(cbs, action_ok_compressed_archive_push_detect_core); - } else { - BIND_ACTION_OK(cbs, action_ok_compressed_archive_push); + switch (menu_label_hash) + { + case MENU_LABEL_FAVORITES: + BIND_ACTION_OK(cbs, + action_ok_compressed_archive_push_detect_core); + break; + default: + BIND_ACTION_OK(cbs, action_ok_compressed_archive_push); + break; + } } break; case FILE_TYPE_CORE: @@ -4576,30 +4583,33 @@ static int menu_cbs_init_bind_ok_compare_type(menu_file_list_cbs_t *cbs, break; } } - else if (string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_FAVORITES)) || - string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_DOWNLOADED_FILE_DETECT_CORE_LIST)) || - string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_ARCHIVE_OPEN_DETECT_CORE)) - ) - { -#ifdef HAVE_COMPRESSION - if (type == FILE_TYPE_IN_CARCHIVE) - { - BIND_ACTION_OK(cbs, action_ok_file_load_with_detect_core_carchive); - } - else -#endif - if (filebrowser_get_type() == FILEBROWSER_APPEND_IMAGE) - { - BIND_ACTION_OK(cbs, action_ok_disk_image_append); - } - else - { - BIND_ACTION_OK(cbs, action_ok_file_load_with_detect_core); - } - } else { - BIND_ACTION_OK(cbs, action_ok_file_load); + switch (menu_label_hash) + { + case MENU_LABEL_DOWNLOADED_FILE_DETECT_CORE_LIST: + case MENU_LABEL_FAVORITES: + case MENU_LABEL_DEFERRED_ARCHIVE_OPEN_DETECT_CORE: +#ifdef HAVE_COMPRESSION + if (type == FILE_TYPE_IN_CARCHIVE) + { + BIND_ACTION_OK(cbs, action_ok_file_load_with_detect_core_carchive); + } + else +#endif + if (filebrowser_get_type() == FILEBROWSER_APPEND_IMAGE) + { + BIND_ACTION_OK(cbs, action_ok_disk_image_append); + } + else + { + BIND_ACTION_OK(cbs, action_ok_file_load_with_detect_core); + } + break; + default: + BIND_ACTION_OK(cbs, action_ok_file_load); + break; + } } break; case FILE_TYPE_MOVIE: diff --git a/msg_hash.h b/msg_hash.h index 67002857a9..f2b1b214c1 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1851,6 +1851,10 @@ enum msg_hash_enums #define MENU_LABEL_CONTENT_COLLECTION_LIST 0x32d1df83U #define MENU_LABEL_COLLECTION 0x5fea5991U + +#define MENU_LABEL_DOWNLOADED_FILE_DETECT_CORE_LIST 0xb4f82700U +#define MENU_LABEL_FAVORITES 0x67325138U + /* Help */ #define MENU_LABEL_INPUT_DRIVER_LINUXRAW 0xc33c6b9fU #define MENU_LABEL_INPUT_DRIVER_UDEV 0x7c9eeeb9U From 833285cfbfaf7d821cfcbe2fbabf47993b232f02 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 6 Feb 2018 02:22:49 +0100 Subject: [PATCH 129/232] Fix Playlist settings --- menu/cbs/menu_cbs_deferred_push.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index ba53d54ef1..d3746dc59c 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -836,6 +836,10 @@ static struct cbs_deferred_lbl_callback cbs_deferred2_lbl_list[] = { MENU_ENUM_LABEL_DEFERRED_AUDIO_SETTINGS_LIST, deferred_push_audio_settings_list }, + { + MENU_ENUM_LABEL_DEFERRED_PLAYLIST_SETTINGS_LIST, + deferred_push_playlist_settings_list + }, { MENU_ENUM_LABEL_CORE_INFORMATION, deferred_push_core_information From cc879a7bcc6b8984f43cb14afd72e49e4dcd3cdb Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Mon, 5 Feb 2018 20:34:43 -0500 Subject: [PATCH 130/232] update JP translation --- intl/msg_hash_ja.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/intl/msg_hash_ja.h b/intl/msg_hash_ja.h index 75deb5b429..1c257a27bc 100644 --- a/intl/msg_hash_ja.h +++ b/intl/msg_hash_ja.h @@ -298,7 +298,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_LABEL_VALUE_AUDIO_RESAMPLER_DRIVER, - "オーディをリサンプルのドライバ" + "オーディオリサンプラーのドライバ" ) MSG_HASH( MENU_ENUM_LABEL_VALUE_AUDIO_SETTINGS, @@ -1804,11 +1804,11 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_WIFI_SETTINGS, MSG_HASH(MENU_ENUM_LABEL_VALUE_XMB_ALPHA_FACTOR, "メニューの透明性") MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_FONT_COLOR_RED, - "Menu Font Red Color") + "メニューフォントの赤色値") MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_FONT_COLOR_GREEN, - "Menu Font Green Color") + "メニューフォントの緑色値") MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_FONT_COLOR_BLUE, - "Menu Font Blue Color") + "メニューフォントの青色値") MSG_HASH(MENU_ENUM_LABEL_VALUE_XMB_FONT, "メニューのフォント") MSG_HASH(MENU_ENUM_LABEL_VALUE_XMB_ICON_THEME_CUSTOM, @@ -2728,7 +2728,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_SUBLABEL_AUDIO_RESAMPLER_DRIVER, - "使用するオーディオリサンプルドライバ" + "使用するオーディオリサンプラーのドライバ" ) MSG_HASH( MENU_ENUM_SUBLABEL_CAMERA_DRIVER, @@ -3308,7 +3308,7 @@ MSG_HASH(MSG_SCANNING_OF_FILE_FINISHED, MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_OPACITY, "ウィンドウの不透明性") MSG_HASH(MENU_ENUM_LABEL_VALUE_AUDIO_RESAMPLER_QUALITY, - "Audio Resampler Quality") + "オーディオリサンプラーの音質") MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_RESAMPLER_QUALITY, "Lower this value to favor performance/lower latency over audio quality, increase if you want better audio quality at the expense of performance/lower latency.") MSG_HASH(MENU_ENUM_LABEL_VALUE_SHADER_WATCH_FOR_CHANGES, From 67af3758df79b7472dfd18500a81e4acd46e9b20 Mon Sep 17 00:00:00 2001 From: Alfredo Monclus Date: Mon, 5 Feb 2018 23:40:46 -0300 Subject: [PATCH 131/232] Update Spanish translation --- intl/msg_hash_es.h | 101 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 99 insertions(+), 2 deletions(-) diff --git a/intl/msg_hash_es.h b/intl/msg_hash_es.h index 5d7656a46c..f255e13581 100644 --- a/intl/msg_hash_es.h +++ b/intl/msg_hash_es.h @@ -50,6 +50,41 @@ MSG_HASH( MSG_NETPLAY_YOU_HAVE_JOINED_AS_PLAYER_N, "Unido como jugador %d" ) +MSG_HASH( + MSG_NETPLAY_YOU_HAVE_JOINED_WITH_INPUT_DEVICES_S, + "Se ha unido con el dispositivo de entrada %.*s" + ) +MSG_HASH( + MSG_NETPLAY_PLAYER_S_LEFT, + "Jugador %.*s dejó el juego" + ) +MSG_HASH( + MSG_NETPLAY_S_HAS_JOINED_AS_PLAYER_N, + "%2$.*1$s se ha unido como jugador %3$u" + ) +MSG_HASH( + MSG_NETPLAY_S_HAS_JOINED_WITH_INPUT_DEVICES_S, + "%2$.*1$s se ha unido con los dispositivos de entrada %4$.*3$s" + ) +MSG_HASH( + MSG_NETPLAY_NOT_RETROARCH, + "Una conexión de netplay falló, probablemente no este usando RetroArch o esté usando una versión antigua de RetroArch" + ) +MSG_HASH( + MSG_NETPLAY_OUT_OF_DATE, + "El par de netplay esta usando una versión antigua de RetroArch. No se puede conectar" + ) +MSG_HASH( + MSG_NETPLAY_DIFFERENT_VERSIONS, + "ADVERTENCIA: Un par de netplay esta usando una versión diferente de Retroarch. Si ocurren problemas, use la misma versión" + ) +MSG_HASH( + MSG_NETPLAY_DIFFERENT_CORES, + "Un par de netplay esta usando una versión diferente del núcleo. No se puede conectar" +MSG_HASH( + MSG_NETPLAY_DIFFERENT_CORE_VERSIONS, + "ADVERTENCIA: Un par de netplay está ejecutando una versión diferente del núcleo. Si ocurren problemas, use la misma versión" + ) MSG_HASH( MSG_NETPLAY_ENDIAN_DEPENDENT, "Este núcleo no soporta juego en red entre diferentes arquitecturas de sistemas" @@ -86,6 +121,10 @@ MSG_HASH( MSG_NETPLAY_CANNOT_PLAY_NO_SLOTS, "No hay lugar disponible" ) +MSG_HASH( + MSG_NETPLAY_CANNOT_PLAY_NOT_AVAILABLE, + "El dispositivo de entrada pedido no esta disponible" + ) MSG_HASH( MSG_NETPLAY_CANNOT_PLAY, "No se puede cambiar al modo juego" @@ -1392,11 +1431,11 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_LABEL_VALUE_LANG_ARABIC, - "Arabic" + "Árabe" ) MSG_HASH( MENU_ENUM_LABEL_VALUE_LEFT_ANALOG, - "Analogico izquierdo" + "Analógico izquierdo" ) MSG_HASH( MENU_ENUM_LABEL_VALUE_LIBRETRO_DIR_PATH, @@ -1626,6 +1665,9 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_NETPLAY_PUBLIC_ANNOUNCE, "Anunciar juego en red públicamente" ) +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_REQUEST_DEVICE_I, + "Pedir dispositivo %u" + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_NETPLAY_REQUIRE_SLAVES, "Desactivar clientes sin modo esclavo" @@ -1634,6 +1676,42 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_NETPLAY_SETTINGS, "Configurar juego en red" ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_ANALOG, + "Comparir entrada analoga" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_ANALOG_MAX, + "Max" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_ANALOG_AVERAGE, + "Promedio" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_DIGITAL, + "Compartir entrada digital" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_DIGITAL_OR, + "Compartir" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_DIGITAL_XOR, + "Grapple" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_DIGITAL_VOTE, + "Votar" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_NONE, + "Nada" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_NO_PREFERENCE, + "Sin preferencia" + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_NETPLAY_START_AS_SPECTATOR, "Juego en red: modo espectador" @@ -4834,6 +4912,10 @@ MSG_HASH( MENU_ENUM_SUBLABEL_SORT_SAVESTATES_ENABLE, "Ordenar guardados rápidos en carpetas nombradas por núcleo" ) +MSG_HASH( + MENU_ENUM_SUBLABEL_NETPLAY_REQUEST_DEVICE_I, + "Pedir jugar con el dispositivo de entrada dado" + ) MSG_HASH( MENU_ENUM_SUBLABEL_CORE_UPDATER_BUILDBOT_URL, "URL de la carpeta del actualizador de núcleos en el buildbot Libretro" @@ -5286,6 +5368,13 @@ MSG_HASH( MENU_ENUM_SUBLABEL_NETPLAY_USE_MITM_SERVER, "Enviar conexiones de juego en red a través de otro servidor (man-in-the-middle). Útil si el servidor está detrás de un firewall o tiene problemas NAT/UPnP" ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_NETPLAY_MITM_SERVER, + "Ubicación del servidor relé" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_NETPLAY_MITM_SERVER, + "Elegir un servidor relé especifico. Las ubicaciones geográficamente cercanas tienden a tener menor latencia" MSG_HASH( MENU_ENUM_LABEL_VALUE_ADD_TO_MIXER, "Agregar al mezclador" @@ -5706,3 +5795,11 @@ MSG_HASH( MENU_ENUM_SUBLABEL_AUDIO_RESAMPLER_QUALITY, "Valores mas bajos favorecen el rendimiento y bajan la latencia a costa de la calidad, incrementar el valor aumentará la calidad a costa del rendimiento y latencia" ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_SHADER_WATCH_FOR_CHANGES, + "Vigilar cambios en los shader" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_SHADER_WATCH_FOR_CHANGES, + "Auto-aplica los cambios hechos a los archivos shader del disco" + ) \ No newline at end of file From f5d923caecbc16e9ae0f0678938b38e0eab6e00d Mon Sep 17 00:00:00 2001 From: gblues Date: Mon, 5 Feb 2018 23:23:24 -0800 Subject: [PATCH 132/232] Fix build == DETAILS `intl/msg_hash_es.h` was missing some parenthesis, causing the build to fail. == TESTING tested local build successfully --- intl/msg_hash_es.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/intl/msg_hash_es.h b/intl/msg_hash_es.h index f255e13581..58b4e74a5d 100644 --- a/intl/msg_hash_es.h +++ b/intl/msg_hash_es.h @@ -81,6 +81,7 @@ MSG_HASH( MSG_HASH( MSG_NETPLAY_DIFFERENT_CORES, "Un par de netplay esta usando una versión diferente del núcleo. No se puede conectar" + ) MSG_HASH( MSG_NETPLAY_DIFFERENT_CORE_VERSIONS, "ADVERTENCIA: Un par de netplay está ejecutando una versión diferente del núcleo. Si ocurren problemas, use la misma versión" @@ -1430,9 +1431,9 @@ MSG_HASH( "Vietnamita" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_LANG_ARABIC, - "Árabe" - ) + MENU_ENUM_LABEL_VALUE_LANG_ARABIC, + "Árabe" + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_LEFT_ANALOG, "Analógico izquierdo" @@ -5375,6 +5376,7 @@ MSG_HASH( MSG_HASH( MENU_ENUM_SUBLABEL_NETPLAY_MITM_SERVER, "Elegir un servidor relé especifico. Las ubicaciones geográficamente cercanas tienden a tener menor latencia" + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_ADD_TO_MIXER, "Agregar al mezclador" @@ -5802,4 +5804,4 @@ MSG_HASH( MSG_HASH( MENU_ENUM_SUBLABEL_SHADER_WATCH_FOR_CHANGES, "Auto-aplica los cambios hechos a los archivos shader del disco" - ) \ No newline at end of file + ) From 9b1e1af86e4378de4f553ebc9ffa8b942c3a8145 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Tue, 6 Feb 2018 09:28:18 +0100 Subject: [PATCH 133/232] check for empty string in font_driver_render_msg. --- gfx/font_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/font_driver.c b/gfx/font_driver.c index c020dfa5d4..afb343abb9 100644 --- a/gfx/font_driver.c +++ b/gfx/font_driver.c @@ -709,7 +709,7 @@ void font_driver_render_msg( { font_data_t *font = (font_data_t*)(font_data ? font_data : video_font_driver); - if (font && font->renderer && font->renderer->render_msg) + if (msg && *msg && font && font->renderer && font->renderer->render_msg) { #ifdef HAVE_LANGEXTRA char* new_msg = font_driver_reshape_msg(msg); From d8f1a08a4758851d5530d311303146257cbf8216 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Tue, 6 Feb 2018 09:29:55 +0100 Subject: [PATCH 134/232] add byte-order-marker to msg_hash_ar.* --- intl/msg_hash_ar.c | 2 +- intl/msg_hash_ar.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/intl/msg_hash_ar.c b/intl/msg_hash_ar.c index 37675d467b..808463ba57 100644 --- a/intl/msg_hash_ar.c +++ b/intl/msg_hash_ar.c @@ -1,4 +1,4 @@ -/* RetroArch - A frontend for libretro. +/* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2016-2017 - Brad Parker * diff --git a/intl/msg_hash_ar.h b/intl/msg_hash_ar.h index 1c8028c465..60b0b5e323 100644 --- a/intl/msg_hash_ar.h +++ b/intl/msg_hash_ar.h @@ -1,4 +1,4 @@ -MSG_HASH( +MSG_HASH( MSG_COMPILER, "Compiler" ) From 2b70e9d9eca565426b8b77b547db5b054b35fdb4 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Tue, 6 Feb 2018 11:12:01 +0100 Subject: [PATCH 135/232] update arabic translation. --- intl/msg_hash_ar.h | 50 +++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/intl/msg_hash_ar.h b/intl/msg_hash_ar.h index 60b0b5e323..dd11b87f83 100644 --- a/intl/msg_hash_ar.h +++ b/intl/msg_hash_ar.h @@ -252,7 +252,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_LABEL_VALUE_AUDIO_DRIVER, - "Audio Driver" + "نظام تشغيل الصوت" ) MSG_HASH( MENU_ENUM_LABEL_VALUE_AUDIO_DSP_PLUGIN, @@ -296,7 +296,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_LABEL_VALUE_AUDIO_SETTINGS, - "Audio" + "الصوت" ) MSG_HASH( MENU_ENUM_LABEL_VALUE_AUDIO_SYNC, @@ -424,7 +424,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_LABEL_VALUE_CAMERA_DRIVER, - "Camera Driver" + "نظام تشغيل الكاميرا" ) MSG_HASH( MENU_ENUM_LABEL_VALUE_CHEAT, @@ -618,7 +618,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_DIRECTORY_NONE, MSG_HASH(MENU_ENUM_LABEL_VALUE_DIRECTORY_NOT_FOUND, "Directory not found.") MSG_HASH(MENU_ENUM_LABEL_VALUE_DIRECTORY_SETTINGS, - "Directory") + "الدلائل") MSG_HASH(MENU_ENUM_LABEL_VALUE_DISK_CYCLE_TRAY_STATUS, "Disk Cycle Tray Status") MSG_HASH(MENU_ENUM_LABEL_VALUE_DISK_IMAGE_APPEND, @@ -640,7 +640,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_DPI_OVERRIDE_ENABLE, MSG_HASH(MENU_ENUM_LABEL_VALUE_DPI_OVERRIDE_VALUE, "DPI Override") MSG_HASH(MENU_ENUM_LABEL_VALUE_DRIVER_SETTINGS, - "Driver") + "أنظمة التشغيل") MSG_HASH(MENU_ENUM_LABEL_VALUE_DUMMY_ON_CORE_SHUTDOWN, "Load Dummy on Core Shutdown") MSG_HASH(MENU_ENUM_LABEL_VALUE_CHECK_FOR_MISSING_FIRMWARE, @@ -776,7 +776,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_DEVICE_TYPE, MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_INDEX, "Mouse Index") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_DRIVER, - "Input Driver") + "نظام تشغيل أجهزة الادخال") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_DUTY_CYCLE, "Duty Cycle") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_HOTKEY_BINDS, @@ -932,7 +932,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_REMAP_BINDS_ENABLE, MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_SAVE_AUTOCONFIG, "Save Autoconfig") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_SETTINGS, - "Input") + "أجهزة الادخال") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_SMALL_KEYBOARD_ENABLE, "Small Keyboard Enable") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_TOUCH_ENABLE, @@ -948,7 +948,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INTERNAL_STORAGE_STATUS, MSG_HASH(MENU_ENUM_LABEL_VALUE_JOYPAD_AUTOCONFIG_DIR, "Input Autoconfig") MSG_HASH(MENU_ENUM_LABEL_VALUE_JOYPAD_DRIVER, - "Joypad Driver") + "نظام تشغيل الجوي باد") MSG_HASH(MENU_ENUM_LABEL_VALUE_LAKKA_SERVICES, "Services") MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_CHINESE_SIMPLIFIED, @@ -1036,7 +1036,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_MATERIALUI_MENU_FOOTER_OPACITY, MSG_HASH(MENU_ENUM_LABEL_VALUE_MATERIALUI_MENU_HEADER_OPACITY, "Header Opacity") MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_DRIVER, - "Menu Driver") + "نظام تشغيل القائمة") MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_ENUM_THROTTLE_FRAMERATE, "Throttle Menu Framerate") MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_FILE_BROWSER_SETTINGS, @@ -1148,7 +1148,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_NETWORK_REMOTE_ENABLE, MSG_HASH(MENU_ENUM_LABEL_VALUE_NETWORK_REMOTE_PORT, "Network Remote Base Port") MSG_HASH(MENU_ENUM_LABEL_VALUE_NETWORK_SETTINGS, - "Network") + "الشبكة") MSG_HASH(MENU_ENUM_LABEL_VALUE_NO, "No") MSG_HASH(MENU_ENUM_LABEL_VALUE_NONE, @@ -1196,7 +1196,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_ONLINE, MSG_HASH(MENU_ENUM_LABEL_VALUE_ONLINE_UPDATER, "التحديث عبر الانترنت") MSG_HASH(MENU_ENUM_LABEL_VALUE_ONSCREEN_DISPLAY_SETTINGS, - "Onscreen Display") + "العرض على الشاشة") MSG_HASH(MENU_ENUM_LABEL_VALUE_ONSCREEN_OVERLAY_SETTINGS, "Onscreen Overlay") MSG_HASH(MENU_ENUM_LABEL_VALUE_ONSCREEN_NOTIFICATIONS_SETTINGS, @@ -1230,11 +1230,11 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_PAUSE_NONACTIVE, MSG_HASH(MENU_ENUM_LABEL_VALUE_PERFCNT_ENABLE, "Performance Counters") MSG_HASH(MENU_ENUM_LABEL_VALUE_PLAYLISTS_TAB, - "Playlists") + "قوائم التشغيل") MSG_HASH(MENU_ENUM_LABEL_VALUE_PLAYLIST_DIRECTORY, - "Playlist") + "قائمة التشغيل") MSG_HASH(MENU_ENUM_LABEL_VALUE_PLAYLIST_SETTINGS, - "Playlists") + "قوائم التشغيل") MSG_HASH(MENU_ENUM_LABEL_VALUE_POINTER_ENABLE, "Touch Support") MSG_HASH(MENU_ENUM_LABEL_VALUE_PORT, @@ -1242,7 +1242,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_PORT, MSG_HASH(MENU_ENUM_LABEL_VALUE_PRESENT, "Present") MSG_HASH(MENU_ENUM_LABEL_VALUE_PRIVACY_SETTINGS, - "Privacy") + "خصوصية") MSG_HASH(MENU_ENUM_LABEL_VALUE_QUIT_RETROARCH, "إنهاء البرنامج") MSG_HASH(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_ANALOG, @@ -1312,7 +1312,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_RECORDING_SETTINGS, MSG_HASH(MENU_ENUM_LABEL_VALUE_RECORD_CONFIG, "Load Recording Config...") MSG_HASH(MENU_ENUM_LABEL_VALUE_RECORD_DRIVER, - "Record Driver") + "نظام تشغيل التسجيل") MSG_HASH(MENU_ENUM_LABEL_VALUE_RECORD_ENABLE, "Enable Recording") MSG_HASH(MENU_ENUM_LABEL_VALUE_RECORD_PATH, @@ -1348,7 +1348,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_RETROPAD, MSG_HASH(MENU_ENUM_LABEL_VALUE_RETROPAD_WITH_ANALOG, "RetroPad w/ Analog") MSG_HASH(MENU_ENUM_LABEL_VALUE_RETRO_ACHIEVEMENTS_SETTINGS, - "Achievements") + "الإنجازات") MSG_HASH(MENU_ENUM_LABEL_VALUE_REWIND_ENABLE, "Rewind Enable") MSG_HASH(MENU_ENUM_LABEL_VALUE_REWIND_GRANULARITY, @@ -1396,7 +1396,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_SAVE_NEW_CONFIG, MSG_HASH(MENU_ENUM_LABEL_VALUE_SAVE_STATE, "Save State") MSG_HASH(MENU_ENUM_LABEL_VALUE_SAVING_SETTINGS, - "Saving") + "الحفظ") MSG_HASH(MENU_ENUM_LABEL_VALUE_SCAN_DIRECTORY, "Scan Directory") MSG_HASH(MENU_ENUM_LABEL_VALUE_SCAN_FILE, @@ -1670,15 +1670,15 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_UPDATE_OVERLAYS, MSG_HASH(MENU_ENUM_LABEL_VALUE_UPDATE_SLANG_SHADERS, "Update Slang Shaders") MSG_HASH(MENU_ENUM_LABEL_VALUE_USER, - "User") + "المستخدم") MSG_HASH(MENU_ENUM_LABEL_VALUE_KEYBOARD, "Kbd") MSG_HASH(MENU_ENUM_LABEL_VALUE_USER_INTERFACE_SETTINGS, - "User Interface") + "واجهة المستخدم") MSG_HASH(MENU_ENUM_LABEL_VALUE_USER_LANGUAGE, "Language") MSG_HASH(MENU_ENUM_LABEL_VALUE_USER_SETTINGS, - "User") + "المستخدم") MSG_HASH(MENU_ENUM_LABEL_VALUE_USE_BUILTIN_IMAGE_VIEWER, "Use Builtin Image Viewer") MSG_HASH(MENU_ENUM_LABEL_VALUE_USE_BUILTIN_PLAYER, @@ -1700,7 +1700,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_CROP_OVERSCAN, MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_DISABLE_COMPOSITION, "Disable Desktop Composition") MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_DRIVER, - "Video Driver") + "نظام تشغيل الفيديو") MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_FILTER, "Video Filter") MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_FILTER_DIR, @@ -1752,7 +1752,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SCALE, MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SCALE_INTEGER, "Integer Scale") MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SETTINGS, - "Video") + "الفيديو") MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_DIR, "Video Shader") MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_NUM_PASSES, @@ -1806,7 +1806,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_FULLSCREEN_X, MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_FULLSCREEN_Y, "Fullscreen Height") MSG_HASH(MENU_ENUM_LABEL_VALUE_WIFI_DRIVER, - "Wi-Fi Driver") + "نظام تشغيل الواي-فاي") MSG_HASH(MENU_ENUM_LABEL_VALUE_WIFI_SETTINGS, "Wi-Fi") MSG_HASH(MENU_ENUM_LABEL_VALUE_XMB_ALPHA_FACTOR, @@ -1904,7 +1904,7 @@ MSG_HASH(MENU_ENUM_SUBLABEL_CHEEVOS_BADGES_ENABLE, MSG_HASH(MENU_ENUM_SUBLABEL_CHEEVOS_VERBOSE_ENABLE, "Enable or disable OSD verbosity for achievements.") MSG_HASH(MENU_ENUM_SUBLABEL_DRIVER_SETTINGS, - "Change drivers used by the system.") + "تغيير أنظمة التشغيل المستخدمة من قبل البرنامج.") MSG_HASH(MENU_ENUM_SUBLABEL_RETRO_ACHIEVEMENTS_SETTINGS, "Change achievement settings.") MSG_HASH(MENU_ENUM_SUBLABEL_CORE_SETTINGS, From 11ff498f3db2c49f963af225f33c290afb30904b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 6 Feb 2018 13:14:46 +0100 Subject: [PATCH 136/232] Get rid of hash --- menu/cbs/menu_cbs_ok.c | 8 +++++--- menu/cbs/menu_cbs_title.c | 7 ++++--- msg_hash.h | 1 - 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index d69cd8fb71..c410f4b0bf 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -4460,6 +4460,11 @@ static int menu_cbs_init_bind_ok_compare_type(menu_file_list_cbs_t *cbs, break; } } + else if (string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_CORE_LIST))) + { + BIND_ACTION_OK(cbs, action_ok_load_core); + break; + } else { switch (menu_label_hash) @@ -4470,9 +4475,6 @@ static int menu_cbs_init_bind_ok_compare_type(menu_file_list_cbs_t *cbs, case MENU_LABEL_DEFERRED_CORE_LIST_SET: BIND_ACTION_OK(cbs, action_ok_core_deferred_set); break; - case MENU_LABEL_CORE_LIST: - BIND_ACTION_OK(cbs, action_ok_load_core); - break; } } break; diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index b8bd77d8dd..dc9bee36db 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -544,6 +544,10 @@ static struct cbs_title_lbl_callback cbs_title_lbl_list[] = { { MENU_ENUM_LABEL_CONFIGURATIONS, action_get_title_configurations + }, + { + MENU_ENUM_LABEL_CORE_LIST, + action_get_core_list } }; @@ -1010,9 +1014,6 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_CORE_INFORMATION: BIND_ACTION_GET_TITLE(cbs, action_get_core_information_list); break; - case MENU_LABEL_CORE_LIST: - BIND_ACTION_GET_TITLE(cbs, action_get_core_list); - break; case MENU_ENUM_LABEL_LOAD_CONTENT_SPECIAL: BIND_ACTION_GET_TITLE(cbs, action_get_load_content_special); break; diff --git a/msg_hash.h b/msg_hash.h index f2b1b214c1..c7d9478c6c 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1829,7 +1829,6 @@ enum msg_hash_enums #define MENU_LABEL_RDB_ENTRY_RELEASE_YEAR 0x14c9c6bfU #define MENU_LABEL_RDB_ENTRY_MAX_USERS 0xfae91cc4U -#define MENU_LABEL_CORE_LIST 0xa22bb14dU #define MENU_LABEL_MANAGEMENT 0x2516c88aU #define MENU_LABEL_FRONTEND_COUNTERS 0xe5696877U #define MENU_LABEL_CORE_COUNTERS 0x64cc83e0U From a2f2a726bb97d729c6814ad37d93d84fa07bcf22 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 6 Feb 2018 13:47:34 +0100 Subject: [PATCH 137/232] Get rid of more hashes --- menu/cbs/menu_cbs_title.c | 14 ++++++++------ msg_hash.h | 2 -- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index dc9bee36db..e511a5566d 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -548,6 +548,14 @@ static struct cbs_title_lbl_callback cbs_title_lbl_list[] = { { MENU_ENUM_LABEL_CORE_LIST, action_get_core_list + }, + { + MENU_ENUM_LABEL_CORE_INFORMATION, + action_get_core_information_list + }, + { + MENU_ENUM_LABEL_CORE_OPTIONS, + action_get_core_options_list } }; @@ -1011,9 +1019,6 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_CURSOR_MANAGER_LIST: BIND_ACTION_GET_TITLE(cbs, action_get_cursor_manager_list); break; - case MENU_LABEL_CORE_INFORMATION: - BIND_ACTION_GET_TITLE(cbs, action_get_core_information_list); - break; case MENU_ENUM_LABEL_LOAD_CONTENT_SPECIAL: BIND_ACTION_GET_TITLE(cbs, action_get_load_content_special); break; @@ -1023,9 +1028,6 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_DEFERRED_CONFIGURATIONS_LIST: BIND_ACTION_GET_TITLE(cbs, action_get_configurations_list); break; - case MENU_LABEL_CORE_OPTIONS: - BIND_ACTION_GET_TITLE(cbs, action_get_core_options_list); - break; case MENU_LABEL_CORE_INPUT_REMAPPING_OPTIONS: BIND_ACTION_GET_TITLE(cbs, action_get_input_remapping_options_list); break; diff --git a/msg_hash.h b/msg_hash.h index c7d9478c6c..3d23073c70 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1833,8 +1833,6 @@ enum msg_hash_enums #define MENU_LABEL_FRONTEND_COUNTERS 0xe5696877U #define MENU_LABEL_CORE_COUNTERS 0x64cc83e0U #define MENU_LABEL_ACHIEVEMENT_LIST 0x7b90fc49U -#define MENU_LABEL_CORE_INFORMATION 0xb638e0d3U -#define MENU_LABEL_CORE_OPTIONS 0xf65e60f9U #define MENU_LABEL_SHADER_OPTIONS 0x1f7d2fc7U #define MENU_LABEL_CORE_CHEAT_OPTIONS 0x9293171dU #define MENU_LABEL_CORE_INPUT_REMAPPING_OPTIONS 0x7836a8caU From 409c541494b24b0599974c07760aa226f5373b1d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 6 Feb 2018 13:52:23 +0100 Subject: [PATCH 138/232] Cleanups --- menu/cbs/menu_cbs_deferred_push.c | 7 ++++--- menu/cbs/menu_cbs_title.c | 14 ++++++++------ msg_hash.h | 2 -- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index d3746dc59c..be6b057b88 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -790,6 +790,10 @@ static struct cbs_deferred_lbl_callback cbs_deferred_lbl_list[] = { { MENU_ENUM_LABEL_CONFIGURATIONS, deferred_push_configurations + }, + { + MENU_ENUM_LABEL_CORE_CHEAT_OPTIONS, + deferred_push_core_cheat_options } }; @@ -1331,9 +1335,6 @@ static int menu_cbs_init_bind_deferred_push_compare_label( case MENU_LABEL_FRONTEND_COUNTERS: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_frontend_counters); break; - case MENU_LABEL_CORE_CHEAT_OPTIONS: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_cheat_options); - break; case MENU_LABEL_CORE_INPUT_REMAPPING_OPTIONS: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_input_remapping_options); break; diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index e511a5566d..f89ff8b8a8 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -556,6 +556,14 @@ static struct cbs_title_lbl_callback cbs_title_lbl_list[] = { { MENU_ENUM_LABEL_CORE_OPTIONS, action_get_core_options_list + }, + { + MENU_ENUM_LABEL_CORE_CHEAT_OPTIONS, + action_get_core_cheat_options_list + }, + { + MENU_ENUM_LABEL_SHADER_OPTIONS, + action_get_shader_options_list } }; @@ -1031,12 +1039,6 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_CORE_INPUT_REMAPPING_OPTIONS: BIND_ACTION_GET_TITLE(cbs, action_get_input_remapping_options_list); break; - case MENU_LABEL_CORE_CHEAT_OPTIONS: - BIND_ACTION_GET_TITLE(cbs, action_get_core_cheat_options_list); - break; - case MENU_LABEL_SHADER_OPTIONS: - BIND_ACTION_GET_TITLE(cbs, action_get_shader_options_list); - break; case MENU_LABEL_FRONTEND_COUNTERS: BIND_ACTION_GET_TITLE(cbs, action_get_frontend_counters_list); break; diff --git a/msg_hash.h b/msg_hash.h index 3d23073c70..2b7aba8fa4 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1833,8 +1833,6 @@ enum msg_hash_enums #define MENU_LABEL_FRONTEND_COUNTERS 0xe5696877U #define MENU_LABEL_CORE_COUNTERS 0x64cc83e0U #define MENU_LABEL_ACHIEVEMENT_LIST 0x7b90fc49U -#define MENU_LABEL_SHADER_OPTIONS 0x1f7d2fc7U -#define MENU_LABEL_CORE_CHEAT_OPTIONS 0x9293171dU #define MENU_LABEL_CORE_INPUT_REMAPPING_OPTIONS 0x7836a8caU #define MENU_LABEL_DATABASE_MANAGER_LIST 0x7f853d8fU #define MENU_LABEL_CURSOR_MANAGER_LIST 0xa969e378U From 962e1f710e2dcb03c19ba0f5f6a799b858c7288e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 6 Feb 2018 13:56:49 +0100 Subject: [PATCH 139/232] Updates --- menu/cbs/menu_cbs_deferred_push.c | 7 ++++--- menu/cbs/menu_cbs_title.c | 7 ++++--- msg_hash.h | 5 ----- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index be6b057b88..db95173633 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -794,6 +794,10 @@ static struct cbs_deferred_lbl_callback cbs_deferred_lbl_list[] = { { MENU_ENUM_LABEL_CORE_CHEAT_OPTIONS, deferred_push_core_cheat_options + }, + { + MENU_ENUM_LABEL_CORE_INPUT_REMAPPING_OPTIONS, + deferred_push_core_input_remapping_options } }; @@ -1335,9 +1339,6 @@ static int menu_cbs_init_bind_deferred_push_compare_label( case MENU_LABEL_FRONTEND_COUNTERS: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_frontend_counters); break; - case MENU_LABEL_CORE_INPUT_REMAPPING_OPTIONS: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_input_remapping_options); - break; case MENU_LABEL_CONTENT_COLLECTION_LIST: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_content_collection_list); break; diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index f89ff8b8a8..f53a7ef076 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -564,6 +564,10 @@ static struct cbs_title_lbl_callback cbs_title_lbl_list[] = { { MENU_ENUM_LABEL_SHADER_OPTIONS, action_get_shader_options_list + }, + { + MENU_ENUM_LABEL_CORE_INPUT_REMAPPING_OPTIONS, + action_get_input_remapping_options_list } }; @@ -1036,9 +1040,6 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_DEFERRED_CONFIGURATIONS_LIST: BIND_ACTION_GET_TITLE(cbs, action_get_configurations_list); break; - case MENU_LABEL_CORE_INPUT_REMAPPING_OPTIONS: - BIND_ACTION_GET_TITLE(cbs, action_get_input_remapping_options_list); - break; case MENU_LABEL_FRONTEND_COUNTERS: BIND_ACTION_GET_TITLE(cbs, action_get_frontend_counters_list); break; diff --git a/msg_hash.h b/msg_hash.h index 2b7aba8fa4..a025562786 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1833,20 +1833,15 @@ enum msg_hash_enums #define MENU_LABEL_FRONTEND_COUNTERS 0xe5696877U #define MENU_LABEL_CORE_COUNTERS 0x64cc83e0U #define MENU_LABEL_ACHIEVEMENT_LIST 0x7b90fc49U -#define MENU_LABEL_CORE_INPUT_REMAPPING_OPTIONS 0x7836a8caU #define MENU_LABEL_DATABASE_MANAGER_LIST 0x7f853d8fU #define MENU_LABEL_CURSOR_MANAGER_LIST 0xa969e378U #define MENU_LABEL_REMAP_FILE_LOAD 0x9c2799b8U -#define MENU_LABEL_INFO_SCREEN 0xd97853d0U -#define MENU_LABEL_CUSTOM_RATIO 0xf038731eU -#define MENU_LABEL_PAL60_ENABLE 0x62bc416eU #define MENU_LABEL_CONTENT_HISTORY_PATH 0x6f22fb9dU #define MENU_LABEL_REMAP_FILE_SAVE_CORE 0x7c9d4c8fU #define MENU_LABEL_REMAP_FILE_SAVE_GAME 0x7c9f41e0U #define MENU_LABEL_CONTENT_COLLECTION_LIST 0x32d1df83U #define MENU_LABEL_COLLECTION 0x5fea5991U - #define MENU_LABEL_DOWNLOADED_FILE_DETECT_CORE_LIST 0xb4f82700U #define MENU_LABEL_FAVORITES 0x67325138U From 84e253beccdeed38e9e616996fc918c8574813a1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 6 Feb 2018 14:25:25 +0100 Subject: [PATCH 140/232] Remove more hashes --- menu/cbs/menu_cbs_deferred_push.c | 14 ++- menu/cbs/menu_cbs_title.c | 180 +++++++++++++++++------------- msg_hash.h | 30 ----- 3 files changed, 113 insertions(+), 111 deletions(-) diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index db95173633..4e184ac115 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -798,6 +798,14 @@ static struct cbs_deferred_lbl_callback cbs_deferred_lbl_list[] = { { MENU_ENUM_LABEL_CORE_INPUT_REMAPPING_OPTIONS, deferred_push_core_input_remapping_options + }, + { + MENU_ENUM_LABEL_MANAGEMENT, + deferred_push_management_options + }, + { + MENU_ENUM_LABEL_CONTENT_HISTORY_PATH, + deferred_push_content_history_path } }; @@ -1262,9 +1270,6 @@ static int menu_cbs_init_bind_deferred_push_compare_label( case MENU_LABEL_REMAP_FILE_LOAD: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_remap_file_load); break; - case MENU_LABEL_MANAGEMENT: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_management_options); - break; case MENU_LABEL_DEFERRED_CORE_LIST: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_list_deferred); break; @@ -1342,9 +1347,6 @@ static int menu_cbs_init_bind_deferred_push_compare_label( case MENU_LABEL_CONTENT_COLLECTION_LIST: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_content_collection_list); break; - case MENU_LABEL_CONTENT_HISTORY_PATH: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_content_history_path); - break; default: return -1; } diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index f53a7ef076..18ed001faf 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -154,6 +154,7 @@ default_fill_title_macro(action_get_title_configurations, MENU_ENUM_LABEL_ default_fill_title_macro(action_get_title_content_database_directory, MENU_ENUM_LABEL_VALUE_CONTENT_DATABASE_DIRECTORY) default_fill_title_macro(action_get_title_savestate_directory, MENU_ENUM_LABEL_VALUE_SAVESTATE_DIRECTORY) default_fill_title_macro(action_get_title_dynamic_wallpapers_directory, MENU_ENUM_LABEL_VALUE_DYNAMIC_WALLPAPERS_DIRECTORY) +default_fill_title_macro(action_get_title_thumbnails_directory, MENU_ENUM_LABEL_VALUE_THUMBNAILS_DIRECTORY) default_fill_title_macro(action_get_title_core_assets_directory, MENU_ENUM_LABEL_VALUE_CORE_ASSETS_DIR) default_fill_title_macro(action_get_title_config_directory, MENU_ENUM_LABEL_VALUE_RGUI_CONFIG_DIRECTORY) default_fill_title_macro(action_get_title_input_remapping_directory, MENU_ENUM_LABEL_VALUE_INPUT_REMAPPING_DIRECTORY) @@ -568,6 +569,110 @@ static struct cbs_title_lbl_callback cbs_title_lbl_list[] = { { MENU_ENUM_LABEL_CORE_INPUT_REMAPPING_OPTIONS, action_get_input_remapping_options_list + }, + { + MENU_ENUM_LABEL_MANAGEMENT, + action_get_title_action_generic + }, + { + MENU_ENUM_LABEL_LIBRETRO_DIR_PATH, + action_get_title_core_directory + }, + { + MENU_ENUM_LABEL_JOYPAD_AUTOCONFIG_DIR, + action_get_title_autoconfig_directory + }, + { + MENU_ENUM_LABEL_CURSOR_DIRECTORY, + action_get_title_cursor_directory + }, + { + MENU_ENUM_LABEL_OSK_OVERLAY_DIRECTORY, + action_get_title_onscreen_overlay_keyboard_directory + }, + { + MENU_ENUM_LABEL_ASSETS_DIRECTORY, + action_get_title_assets_directory + }, + { + MENU_ENUM_LABEL_CACHE_DIRECTORY, + action_get_title_extraction_directory + }, + { + MENU_ENUM_LABEL_RGUI_CONFIG_DIRECTORY, + action_get_title_config_directory + }, + { + MENU_ENUM_LABEL_VIDEO_SHADER_DIR, + action_get_title_video_shader_directory + }, + { + MENU_ENUM_LABEL_AUDIO_FILTER_DIR, + action_get_title_audio_filter_directory + }, + { + MENU_ENUM_LABEL_SAVEFILE_DIRECTORY, + action_get_title_savefile_directory + }, + { + MENU_ENUM_LABEL_SAVESTATE_DIRECTORY, + action_get_title_savestate_directory + }, + { + MENU_ENUM_LABEL_CORE_ASSETS_DIRECTORY, + action_get_title_core_assets_directory + }, + { + MENU_ENUM_LABEL_PLAYLIST_DIRECTORY, + action_get_title_playlist_directory + }, + { + MENU_ENUM_LABEL_CONTENT_DIRECTORY, + action_get_title_content_directory + }, + { + MENU_ENUM_LABEL_SCREENSHOT_DIRECTORY, + action_get_title_screenshot_directory + }, + { + MENU_ENUM_LABEL_SYSTEM_DIRECTORY, + action_get_title_system_directory + }, + { + MENU_ENUM_LABEL_OVERLAY_DIRECTORY, + action_get_title_overlay_directory + }, + { + MENU_ENUM_LABEL_RGUI_BROWSER_DIRECTORY, + action_get_title_browser_directory + }, + { + MENU_ENUM_LABEL_VIDEO_FILTER_DIR, + action_get_title_video_filter_directory + }, + { + MENU_ENUM_LABEL_RECORDING_CONFIG_DIRECTORY, + action_get_title_recording_config_directory + }, + { + MENU_ENUM_LABEL_RECORDING_OUTPUT_DIRECTORY, + action_get_title_recording_output_directory + }, + { + MENU_ENUM_LABEL_INPUT_REMAPPING_DIRECTORY, + action_get_title_input_remapping_directory + }, + { + MENU_ENUM_LABEL_CONTENT_DATABASE_DIRECTORY, + action_get_title_content_database_directory + }, + { + MENU_ENUM_LABEL_DYNAMIC_WALLPAPERS_DIRECTORY, + action_get_title_dynamic_wallpapers_directory + }, + { + MENU_ENUM_LABEL_THUMBNAILS_DIRECTORY, + action_get_title_thumbnails_directory } }; @@ -956,75 +1061,6 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_DEFERRED_CORE_LIST: BIND_ACTION_GET_TITLE(cbs, action_get_title_deferred_core_list); break; - case MENU_LABEL_JOYPAD_AUTOCONFIG_DIR: - BIND_ACTION_GET_TITLE(cbs, action_get_title_autoconfig_directory); - break; - case MENU_LABEL_CACHE_DIRECTORY: - BIND_ACTION_GET_TITLE(cbs, action_get_title_extraction_directory); - break; - case MENU_LABEL_SYSTEM_DIRECTORY: - BIND_ACTION_GET_TITLE(cbs, action_get_title_system_directory); - break; - case MENU_LABEL_ASSETS_DIRECTORY: - BIND_ACTION_GET_TITLE(cbs, action_get_title_assets_directory); - break; - case MENU_LABEL_SAVEFILE_DIRECTORY: - BIND_ACTION_GET_TITLE(cbs, action_get_title_savefile_directory); - break; - case MENU_LABEL_OVERLAY_DIRECTORY: - BIND_ACTION_GET_TITLE(cbs, action_get_title_overlay_directory); - break; - case MENU_LABEL_RGUI_BROWSER_DIRECTORY: - BIND_ACTION_GET_TITLE(cbs, action_get_title_browser_directory); - break; - case MENU_LABEL_PLAYLIST_DIRECTORY: - BIND_ACTION_GET_TITLE(cbs, action_get_title_playlist_directory); - break; - case MENU_LABEL_CONTENT_DIRECTORY: - BIND_ACTION_GET_TITLE(cbs, action_get_title_content_directory); - break; - case MENU_LABEL_SCREENSHOT_DIRECTORY: - BIND_ACTION_GET_TITLE(cbs, action_get_title_screenshot_directory); - break; - case MENU_LABEL_VIDEO_SHADER_DIR: - BIND_ACTION_GET_TITLE(cbs, action_get_title_video_shader_directory); - break; - case MENU_LABEL_VIDEO_FILTER_DIR: - BIND_ACTION_GET_TITLE(cbs, action_get_title_video_filter_directory); - break; - case MENU_LABEL_AUDIO_FILTER_DIR: - BIND_ACTION_GET_TITLE(cbs, action_get_title_audio_filter_directory); - break; - case MENU_LABEL_CURSOR_DIRECTORY: - BIND_ACTION_GET_TITLE(cbs, action_get_title_cursor_directory); - break; - case MENU_LABEL_RECORDING_CONFIG_DIRECTORY: - BIND_ACTION_GET_TITLE(cbs, action_get_title_recording_config_directory); - break; - case MENU_LABEL_RECORDING_OUTPUT_DIRECTORY: - BIND_ACTION_GET_TITLE(cbs, action_get_title_recording_output_directory); - break; - case MENU_LABEL_OSK_OVERLAY_DIRECTORY: - BIND_ACTION_GET_TITLE(cbs, action_get_title_onscreen_overlay_keyboard_directory); - break; - case MENU_LABEL_INPUT_REMAPPING_DIRECTORY: - BIND_ACTION_GET_TITLE(cbs, action_get_title_input_remapping_directory); - break; - case MENU_LABEL_CONTENT_DATABASE_DIRECTORY: - BIND_ACTION_GET_TITLE(cbs, action_get_title_content_database_directory); - break; - case MENU_LABEL_SAVESTATE_DIRECTORY: - BIND_ACTION_GET_TITLE(cbs, action_get_title_savestate_directory); - break; - case MENU_LABEL_DYNAMIC_WALLPAPERS_DIRECTORY: - BIND_ACTION_GET_TITLE(cbs, action_get_title_dynamic_wallpapers_directory); - break; - case MENU_LABEL_CORE_ASSETS_DIRECTORY: - BIND_ACTION_GET_TITLE(cbs, action_get_title_core_assets_directory); - break; - case MENU_LABEL_RGUI_CONFIG_DIRECTORY: - BIND_ACTION_GET_TITLE(cbs, action_get_title_config_directory); - break; case MENU_LABEL_DATABASE_MANAGER_LIST: BIND_ACTION_GET_TITLE(cbs, action_get_database_manager_list); break; @@ -1070,9 +1106,6 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_ACHIEVEMENT_LIST: BIND_ACTION_GET_TITLE(cbs, action_get_title_cheevos_list); break; - case MENU_LABEL_MANAGEMENT: - BIND_ACTION_GET_TITLE(cbs, action_get_title_action_generic); - break; case MENU_LABEL_REMAP_FILE_LOAD: BIND_ACTION_GET_TITLE(cbs, action_get_title_remap_file_load); break; @@ -1085,9 +1118,6 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_DEFERRED_ACCOUNTS_LIST: BIND_ACTION_GET_TITLE(cbs, action_get_user_accounts_list); break; - case MENU_LABEL_LIBRETRO_DIR_PATH: - BIND_ACTION_GET_TITLE(cbs, action_get_title_core_directory); - break; default: return -1; } diff --git a/msg_hash.h b/msg_hash.h index a025562786..a51edb9820 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1781,34 +1781,6 @@ enum msg_hash_enums #define MENU_LABEL_DEFERRED_CONFIGURATIONS_LIST 0x679a1b0bU #define MENU_LABEL_DEFERRED_BROWSE_URL_START 0xcef58296U -/* Directory settings */ - -#define MENU_LABEL_CURSOR_DIRECTORY 0xdee8d377U -#define MENU_LABEL_OSK_OVERLAY_DIRECTORY 0xcce86287U -#define MENU_LABEL_JOYPAD_AUTOCONFIG_DIR 0x2f4822d8U -#define MENU_LABEL_RECORDING_OUTPUT_DIRECTORY 0x30bece06U -#define MENU_LABEL_RECORDING_CONFIG_DIRECTORY 0x3c3f274bU -#define MENU_LABEL_LIBRETRO_DIR_PATH 0x1af1eb72U -#define MENU_LABEL_AUDIO_FILTER_DIR 0x4bd96ebaU -#define MENU_LABEL_VIDEO_SHADER_DIR 0x30f53b10U -#define MENU_LABEL_VIDEO_FILTER_DIR 0x67603f1fU -#define MENU_LABEL_SCREENSHOT_DIRECTORY 0x552612d7U -#define MENU_LABEL_SYSTEM_DIRECTORY 0x35a6fb9eU -#define MENU_LABEL_INPUT_REMAPPING_DIRECTORY 0x5233c20bU -#define MENU_LABEL_OVERLAY_DIRECTORY 0xc4ed3d1bU -#define MENU_LABEL_SAVEFILE_DIRECTORY 0x92773488U -#define MENU_LABEL_SAVESTATE_DIRECTORY 0x90551289U -#define MENU_LABEL_DYNAMIC_WALLPAPERS_DIRECTORY 0x62f975b8U -#define MENU_LABEL_THUMBNAILS_DIRECTORY 0xdea77410U -#define MENU_LABEL_RGUI_BROWSER_DIRECTORY 0xa86cba73U -#define MENU_LABEL_CONTENT_DATABASE_DIRECTORY 0x6b443f80U -#define MENU_LABEL_PLAYLIST_DIRECTORY 0x6361820bU -#define MENU_LABEL_CORE_ASSETS_DIRECTORY 0x8ba5ee54U -#define MENU_LABEL_CONTENT_DIRECTORY 0x7738dc14U -#define MENU_LABEL_RGUI_CONFIG_DIRECTORY 0x0cb3e005U -#define MENU_LABEL_ASSETS_DIRECTORY 0xde1ae8ecU -#define MENU_LABEL_CACHE_DIRECTORY 0x851dfb8dU - /* RDB settings */ #define MENU_LABEL_RDB_ENTRY_START_CONTENT 0x95025a55U @@ -1829,14 +1801,12 @@ enum msg_hash_enums #define MENU_LABEL_RDB_ENTRY_RELEASE_YEAR 0x14c9c6bfU #define MENU_LABEL_RDB_ENTRY_MAX_USERS 0xfae91cc4U -#define MENU_LABEL_MANAGEMENT 0x2516c88aU #define MENU_LABEL_FRONTEND_COUNTERS 0xe5696877U #define MENU_LABEL_CORE_COUNTERS 0x64cc83e0U #define MENU_LABEL_ACHIEVEMENT_LIST 0x7b90fc49U #define MENU_LABEL_DATABASE_MANAGER_LIST 0x7f853d8fU #define MENU_LABEL_CURSOR_MANAGER_LIST 0xa969e378U #define MENU_LABEL_REMAP_FILE_LOAD 0x9c2799b8U -#define MENU_LABEL_CONTENT_HISTORY_PATH 0x6f22fb9dU #define MENU_LABEL_REMAP_FILE_SAVE_CORE 0x7c9d4c8fU #define MENU_LABEL_REMAP_FILE_SAVE_GAME 0x7c9f41e0U #define MENU_LABEL_CONTENT_COLLECTION_LIST 0x32d1df83U From 0ac208c91d99e91a3557005273557e44b47d5a9a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 6 Feb 2018 14:27:51 +0100 Subject: [PATCH 141/232] Remove more hashes --- msg_hash.h | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/msg_hash.h b/msg_hash.h index a51edb9820..fe0962a679 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1781,25 +1781,7 @@ enum msg_hash_enums #define MENU_LABEL_DEFERRED_CONFIGURATIONS_LIST 0x679a1b0bU #define MENU_LABEL_DEFERRED_BROWSE_URL_START 0xcef58296U -/* RDB settings */ - #define MENU_LABEL_RDB_ENTRY_START_CONTENT 0x95025a55U -#define MENU_LABEL_RDB_ENTRY_PUBLISHER 0x4d7bcdfbU -#define MENU_LABEL_RDB_ENTRY_DEVELOPER 0x06f61093U -#define MENU_LABEL_RDB_ENTRY_ORIGIN 0xb176aad5U -#define MENU_LABEL_RDB_ENTRY_FRANCHISE 0xb31764a0U -#define MENU_LABEL_RDB_ENTRY_ENHANCEMENT_HW 0x79ee4f11U -#define MENU_LABEL_RDB_ENTRY_ESRB_RATING 0xe138fa3dU -#define MENU_LABEL_RDB_ENTRY_BBFC_RATING 0x82dbc01eU -#define MENU_LABEL_RDB_ENTRY_ELSPA_RATING 0x0def0906U -#define MENU_LABEL_RDB_ENTRY_PEGI_RATING 0xd814cb56U -#define MENU_LABEL_RDB_ENTRY_CERO_RATING 0x9d436f5aU -#define MENU_LABEL_RDB_ENTRY_EDGE_MAGAZINE_RATING 0x9735f631U -#define MENU_LABEL_RDB_ENTRY_EDGE_MAGAZINE_ISSUE 0xd5706415U -#define MENU_LABEL_RDB_ENTRY_FAMITSU_MAGAZINE_RATING 0x01a50315U -#define MENU_LABEL_RDB_ENTRY_RELEASE_MONTH 0xad2f2c54U -#define MENU_LABEL_RDB_ENTRY_RELEASE_YEAR 0x14c9c6bfU -#define MENU_LABEL_RDB_ENTRY_MAX_USERS 0xfae91cc4U #define MENU_LABEL_FRONTEND_COUNTERS 0xe5696877U #define MENU_LABEL_CORE_COUNTERS 0x64cc83e0U From 5d0c4a023733f41ecc0b70d8e9b7dcf22c58742b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 6 Feb 2018 14:45:04 +0100 Subject: [PATCH 142/232] Get rid of more hashes --- intl/msg_hash_lbl.h | 2 ++ menu/cbs/menu_cbs_deferred_push.c | 14 +++++---- menu/cbs/menu_cbs_title.c | 49 ++++++++++++++++++------------- msg_hash.h | 10 +------ 4 files changed, 39 insertions(+), 36 deletions(-) diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index aa0ee31eda..b82f0dc95c 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -235,6 +235,8 @@ MSG_HASH(MENU_ENUM_LABEL_DATABASE_MANAGER, "database_manager") MSG_HASH(MENU_ENUM_LABEL_DATABASE_MANAGER_LIST, "database_manager_list") +MSG_HASH(MENU_ENUM_LABEL_DEFERRED_CONFIGURATIONS_LIST, + "deferred_configurations_list") MSG_HASH(MENU_ENUM_LABEL_DEFERRED_PLAYLIST_LIST, "deferred_playlist_list") MSG_HASH(MENU_ENUM_LABEL_DEFERRED_FAVORITES_LIST, diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index 4e184ac115..1d47973cbc 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -806,6 +806,14 @@ static struct cbs_deferred_lbl_callback cbs_deferred_lbl_list[] = { { MENU_ENUM_LABEL_CONTENT_HISTORY_PATH, deferred_push_content_history_path + }, + { + MENU_ENUM_LABEL_DEFERRED_PLAYLIST_SETTINGS_LIST, + deferred_push_playlist_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_CONFIGURATIONS_LIST, + deferred_push_configurations_list } }; @@ -1232,12 +1240,6 @@ static int menu_cbs_init_bind_deferred_push_compare_label( { switch (label_hash) { - case MENU_LABEL_DEFERRED_CONFIGURATIONS_LIST: /* TODO/FIXME */ - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_configurations_list); - break; - case MENU_LABEL_DEFERRED_PLAYLIST_SETTINGS_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_playlist_settings_list); - break; case MENU_LABEL_DEFERRED_RECORDING_SETTINGS_LIST: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_recording_settings_list); break; diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index 18ed001faf..53df22f484 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -434,6 +434,10 @@ static struct cbs_title_lbl_callback cbs_title_lbl_list[] = { MENU_ENUM_LABEL_DEFERRED_DRIVER_SETTINGS_LIST, action_get_driver_settings_list }, + { + MENU_ENUM_LABEL_DEFERRED_VIDEO_SETTINGS_LIST, + action_get_video_settings_list + }, { MENU_ENUM_LABEL_DEFERRED_AUDIO_SETTINGS_LIST, action_get_audio_settings_list @@ -673,6 +677,30 @@ static struct cbs_title_lbl_callback cbs_title_lbl_list[] = { { MENU_ENUM_LABEL_THUMBNAILS_DIRECTORY, action_get_title_thumbnails_directory + }, + { + MENU_ENUM_LABEL_DEFERRED_INPUT_SETTINGS_LIST, + action_get_input_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_PLAYLIST_SETTINGS_LIST, + action_get_playlist_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_CORE_UPDATER_LIST, + action_get_core_updater_list + }, + { + MENU_ENUM_LABEL_DEFERRED_USER_BINDS_LIST, + action_get_title_input_binds_list + }, + { + MENU_ENUM_LABEL_DEFERRED_INPUT_HOTKEY_BINDS_LIST, + action_get_input_hotkey_binds_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_CONFIGURATIONS_LIST, + action_get_configurations_list } }; @@ -1070,36 +1098,15 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_LOAD_CONTENT_SPECIAL: BIND_ACTION_GET_TITLE(cbs, action_get_load_content_special); break; - case MENU_LABEL_DEFERRED_CORE_UPDATER_LIST: - BIND_ACTION_GET_TITLE(cbs, action_get_core_updater_list); - break; - case MENU_LABEL_DEFERRED_CONFIGURATIONS_LIST: - BIND_ACTION_GET_TITLE(cbs, action_get_configurations_list); - break; case MENU_LABEL_FRONTEND_COUNTERS: BIND_ACTION_GET_TITLE(cbs, action_get_frontend_counters_list); break; case MENU_LABEL_CORE_COUNTERS: BIND_ACTION_GET_TITLE(cbs, action_get_core_counters_list); break; - case MENU_LABEL_DEFERRED_USER_BINDS_LIST: - BIND_ACTION_GET_TITLE(cbs, action_get_title_input_binds_list); - break; - case MENU_LABEL_DEFERRED_INPUT_HOTKEY_BINDS_LIST: - BIND_ACTION_GET_TITLE(cbs, action_get_input_hotkey_binds_settings_list); - break; - case MENU_LABEL_DEFERRED_VIDEO_SETTINGS_LIST: - BIND_ACTION_GET_TITLE(cbs, action_get_video_settings_list); - break; - case MENU_LABEL_DEFERRED_INPUT_SETTINGS_LIST: - BIND_ACTION_GET_TITLE(cbs, action_get_input_settings_list); - break; case MENU_LABEL_DEFERRED_RECORDING_SETTINGS_LIST: BIND_ACTION_GET_TITLE(cbs, action_get_recording_settings_list); break; - case MENU_LABEL_DEFERRED_PLAYLIST_SETTINGS_LIST: - BIND_ACTION_GET_TITLE(cbs, action_get_playlist_settings_list); - break; case MENU_LABEL_CONTENT_COLLECTION_LIST: BIND_ACTION_GET_TITLE(cbs, action_get_title_collection); break; diff --git a/msg_hash.h b/msg_hash.h index fe0962a679..2d64443246 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -917,6 +917,7 @@ enum msg_hash_enums MENU_LABEL(BROWSE_URL), MENU_LABEL(BROWSE_START), /* Deferred */ + MENU_ENUM_LABEL_DEFERRED_CONFIGURATIONS_LIST, MENU_ENUM_LABEL_DEFERRED_FAVORITES_LIST, MENU_ENUM_LABEL_DEFERRED_PLAYLIST_LIST, MENU_ENUM_LABEL_DEFERRED_IMAGES_LIST, @@ -1761,14 +1762,7 @@ enum msg_hash_enums #define MENU_LABEL_DEFERRED_RDB_ENTRY_DETAIL 0xc35416c0U #define MENU_LABEL_DEFERRED_RPL_ENTRY_ACTIONS 0x358a7494U #define MENU_LABEL_DEFERRED_CORE_LIST 0xf157d289U -#define MENU_LABEL_DEFERRED_CORE_UPDATER_LIST 0xc315f682U -#define MENU_LABEL_DEFERRED_DRIVER_SETTINGS_LIST 0xaa5efefcU -#define MENU_LABEL_DEFERRED_VIDEO_SETTINGS_LIST 0x83c65827U -#define MENU_LABEL_DEFERRED_AUDIO_SETTINGS_LIST 0x5bba25e2U #define MENU_LABEL_DEFERRED_RECORDING_SETTINGS_LIST 0x05548d52U -#define MENU_LABEL_DEFERRED_PLAYLIST_SETTINGS_LIST 0x9518e0c7U -#define MENU_LABEL_DEFERRED_INPUT_SETTINGS_LIST 0x050bec60U -#define MENU_LABEL_DEFERRED_USER_BINDS_LIST 0x28c5750eU #define MENU_LABEL_DEFERRED_ACCOUNTS_CHEEVOS_LIST 0x1322324cU #define MENU_LABEL_DEFERRED_ACCOUNTS_LIST 0x3d2b8860U #define MENU_LABEL_DEFERRED_ARCHIVE_ACTION_DETECT_CORE 0xdc9c0064U @@ -1777,8 +1771,6 @@ enum msg_hash_enums #define MENU_LABEL_DEFERRED_ARCHIVE_OPEN 0xfa0938b8U #define MENU_LABEL_DEFERRED_CORE_CONTENT_LIST 0x76150c63U #define MENU_LABEL_DEFERRED_LAKKA_LIST 0x3db437c4U -#define MENU_LABEL_DEFERRED_INPUT_HOTKEY_BINDS_LIST 0x10b41d97U -#define MENU_LABEL_DEFERRED_CONFIGURATIONS_LIST 0x679a1b0bU #define MENU_LABEL_DEFERRED_BROWSE_URL_START 0xcef58296U #define MENU_LABEL_RDB_ENTRY_START_CONTENT 0x95025a55U From 94369514377a11962efb84e1b1806c5834854563 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 6 Feb 2018 17:16:21 +0100 Subject: [PATCH 143/232] Cleanups --- intl/msg_hash_ar.c | 98 ++++++++++++++++++-------------------- intl/msg_hash_chs.c | 42 ++++++----------- intl/msg_hash_cht.c | 42 ++++++----------- intl/msg_hash_de.c | 52 ++++++++------------- intl/msg_hash_es.c | 91 ++++++++++++++++-------------------- intl/msg_hash_it.c | 82 ++++++++++++++------------------ intl/msg_hash_ja.c | 42 ++++++----------- intl/msg_hash_ko.c | 101 ++++++++++++++++++---------------------- intl/msg_hash_lbl.h | 8 ++++ intl/msg_hash_pt_br.c | 106 +++++++++++++++++++----------------------- intl/msg_hash_pt_pt.c | 36 ++++++-------- intl/msg_hash_us.c | 101 +++++++++++++++++++--------------------- intl/msg_hash_vn.c | 86 +++++++++++++++------------------- msg_hash.h | 7 --- 14 files changed, 385 insertions(+), 509 deletions(-) diff --git a/intl/msg_hash_ar.c b/intl/msg_hash_ar.c index 808463ba57..ab9d5ba34a 100644 --- a/intl/msg_hash_ar.c +++ b/intl/msg_hash_ar.c @@ -33,7 +33,6 @@ int menu_hash_get_help_ar_enum(enum msg_hash_enums msg, char *s, size_t len) { - uint32_t driver_hash = 0; settings_t *settings = config_get_ptr(); if (msg == MENU_ENUM_LABEL_CONNECT_NETPLAY_ROOM) @@ -717,45 +716,41 @@ int menu_hash_get_help_ar_enum(enum msg_hash_enums msg, char *s, size_t len) ); break; case MENU_ENUM_LABEL_INPUT_DRIVER: - if (settings) - driver_hash = msg_hash_calculate(settings->arrays.input_driver); + { + const char *lbl = settings ? settings->arrays.input_driver : NULL; - switch (driver_hash) { - case MENU_LABEL_INPUT_DRIVER_UDEV: - snprintf(s, len, - "udev Input driver. \n" - " \n" - "It uses the recent evdev joypad API \n" - "for joystick support. It supports \n" - "hotplugging and force feedback. \n" - " \n" - "The driver reads evdev events for keyboard \n" - "support. It also supports keyboard callback, \n" - "mice and touchpads. \n" - " \n" - "By default in most distros, /dev/input nodes \n" - "are root-only (mode 600). You can set up a udev \n" - "rule which makes these accessible to non-root." - ); - break; - case MENU_LABEL_INPUT_DRIVER_LINUXRAW: - snprintf(s, len, - "linuxraw Input driver. \n" - " \n" - "This driver requires an active TTY. Keyboard \n" - "events are read directly from the TTY which \n" - "makes it simpler, but not as flexible as udev. \n" "Mice, etc, are not supported at all. \n" - " \n" - "This driver uses the older joystick API \n" - "(/dev/input/js*)."); - break; - default: - snprintf(s, len, - "Input driver.\n" - " \n" - "Depending on video driver, it might \n" - "force a different input driver."); - break; + if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_INPUT_DRIVER_UDEV))) + snprintf(s, len, + "udev Input driver. \n" + " \n" + "It uses the recent evdev joypad API \n" + "for joystick support. It supports \n" + "hotplugging and force feedback. \n" + " \n" + "The driver reads evdev events for keyboard \n" + "support. It also supports keyboard callback, \n" + "mice and touchpads. \n" + " \n" + "By default in most distros, /dev/input nodes \n" + "are root-only (mode 600). You can set up a udev \n" + "rule which makes these accessible to non-root." + ); + else if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_INPUT_DRIVER_LINUXRAW))) + snprintf(s, len, + "linuxraw Input driver. \n" + " \n" + "This driver requires an active TTY. Keyboard \n" + "events are read directly from the TTY which \n" + "makes it simpler, but not as flexible as udev. \n" "Mice, etc, are not supported at all. \n" + " \n" + "This driver uses the older joystick API \n" + "(/dev/input/js*)."); + else + snprintf(s, len, + "Input driver.\n" + " \n" + "Depending on video driver, it might \n" + "force a different input driver."); } break; case MENU_ENUM_LABEL_LOAD_CONTENT_LIST: @@ -879,22 +874,17 @@ int menu_hash_get_help_ar_enum(enum msg_hash_enums msg, char *s, size_t len) ); break; case MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER: - if (settings) - driver_hash = msg_hash_calculate(settings->arrays.audio_resampler); + { + const char *lbl = settings ? settings->arrays.audio_resampler : NULL; - switch (driver_hash) { - case MENU_LABEL_AUDIO_RESAMPLER_DRIVER_SINC: - snprintf(s, len, - "Windowed SINC implementation."); - break; - case MENU_LABEL_AUDIO_RESAMPLER_DRIVER_CC: - snprintf(s, len, - "Convoluted Cosine implementation."); - break; - default: - if (string_is_empty(s)) - strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_INFORMATION_AVAILABLE), len); - break; + if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER_SINC))) + strlcpy(s, + "Windowed SINC implementation.", len); + else if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER_CC))) + strlcpy(s, + "Convoluted Cosine implementation.", len); + else if (string_is_empty(s)) + strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_INFORMATION_AVAILABLE), len); } break; case MENU_ENUM_LABEL_VIDEO_SHADER_PRESET: diff --git a/intl/msg_hash_chs.c b/intl/msg_hash_chs.c index 7831fbcc7d..91ba1d0d3a 100644 --- a/intl/msg_hash_chs.c +++ b/intl/msg_hash_chs.c @@ -32,7 +32,6 @@ int menu_hash_get_help_chs_enum(enum msg_hash_enums msg, char *s, size_t len) { - uint32_t driver_hash = 0; settings_t *settings = config_get_ptr(); if (msg <= MENU_ENUM_LABEL_INPUT_HOTKEY_BIND_END && @@ -673,12 +672,10 @@ int menu_hash_get_help_chs_enum(enum msg_hash_enums msg, char *s, size_t len) ); break; case MENU_ENUM_LABEL_INPUT_DRIVER: - if (settings) - driver_hash = msg_hash_calculate(settings->arrays.input_driver); - - switch (driver_hash) { - case MENU_LABEL_INPUT_DRIVER_UDEV: + const char *lbl = settings ? settings->arrays.input_driver : NULL; + + if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_INPUT_DRIVER_UDEV))) snprintf(s, len, "udev Input driver. \n" " \n" @@ -697,8 +694,7 @@ int menu_hash_get_help_chs_enum(enum msg_hash_enums msg, char *s, size_t len) "are root-only (mode 600). You can set up a udev \n" "rule which makes these accessible to non-root." ); - break; - case MENU_LABEL_INPUT_DRIVER_LINUXRAW: + else if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_INPUT_DRIVER_LINUXRAW))) snprintf(s, len, "linuxraw Input driver. \n" " \n" @@ -708,14 +704,12 @@ int menu_hash_get_help_chs_enum(enum msg_hash_enums msg, char *s, size_t len) " \n" "This driver uses the older joystick API \n" "(/dev/input/js*)."); - break; - default: + else snprintf(s, len, "Input driver.\n" " \n" "Depending on video driver, it might \n" "force a different input driver."); - break; } break; case MENU_ENUM_LABEL_LOAD_CONTENT_LIST: @@ -837,23 +831,17 @@ int menu_hash_get_help_chs_enum(enum msg_hash_enums msg, char *s, size_t len) ); break; case MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER: - if (settings) - driver_hash = msg_hash_calculate(settings->arrays.audio_resampler); - - switch (driver_hash) { - case MENU_LABEL_AUDIO_RESAMPLER_DRIVER_SINC: - snprintf(s, len, - "Windowed SINC implementation."); - break; - case MENU_LABEL_AUDIO_RESAMPLER_DRIVER_CC: - snprintf(s, len, - "Convoluted Cosine implementation."); - break; - default: - if (string_is_empty(s)) - strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_INFORMATION_AVAILABLE), len); - break; + const char *lbl = settings ? settings->arrays.audio_resampler : NULL; + + if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER_SINC))) + strlcpy(s, + "Windowed SINC implementation.", len); + else if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER_CC))) + strlcpy(s, + "Convoluted Cosine implementation.", len); + else if (string_is_empty(s)) + strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_INFORMATION_AVAILABLE), len); } break; case MENU_ENUM_LABEL_VIDEO_SHADER_PRESET: diff --git a/intl/msg_hash_cht.c b/intl/msg_hash_cht.c index ba696a59a2..36c7d0d5b2 100644 --- a/intl/msg_hash_cht.c +++ b/intl/msg_hash_cht.c @@ -32,7 +32,6 @@ int menu_hash_get_help_cht_enum(enum msg_hash_enums msg, char *s, size_t len) { - uint32_t driver_hash = 0; settings_t *settings = config_get_ptr(); if (msg <= MENU_ENUM_LABEL_INPUT_HOTKEY_BIND_END && @@ -670,12 +669,10 @@ int menu_hash_get_help_cht_enum(enum msg_hash_enums msg, char *s, size_t len) ); break; case MENU_ENUM_LABEL_INPUT_DRIVER: - if (settings) - driver_hash = msg_hash_calculate(settings->arrays.input_driver); - - switch (driver_hash) { - case MENU_LABEL_INPUT_DRIVER_UDEV: + const char *lbl = settings ? settings->arrays.input_driver : NULL; + + if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_INPUT_DRIVER_UDEV))) snprintf(s, len, "udev Input driver. \n" " \n" @@ -694,8 +691,7 @@ int menu_hash_get_help_cht_enum(enum msg_hash_enums msg, char *s, size_t len) "are root-only (mode 600). You can set up a udev \n" "rule which makes these accessible to non-root." ); - break; - case MENU_LABEL_INPUT_DRIVER_LINUXRAW: + else if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_INPUT_DRIVER_LINUXRAW))) snprintf(s, len, "linuxraw Input driver. \n" " \n" @@ -705,14 +701,12 @@ int menu_hash_get_help_cht_enum(enum msg_hash_enums msg, char *s, size_t len) " \n" "This driver uses the older joystick API \n" "(/dev/input/js*)."); - break; - default: + else snprintf(s, len, "Input driver.\n" " \n" "Depending on video driver, it might \n" "force a different input driver."); - break; } break; case MENU_ENUM_LABEL_LOAD_CONTENT_LIST: @@ -834,23 +828,17 @@ int menu_hash_get_help_cht_enum(enum msg_hash_enums msg, char *s, size_t len) ); break; case MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER: - if (settings) - driver_hash = msg_hash_calculate(settings->arrays.audio_resampler); - - switch (driver_hash) { - case MENU_LABEL_AUDIO_RESAMPLER_DRIVER_SINC: - snprintf(s, len, - "Windowed SINC implementation."); - break; - case MENU_LABEL_AUDIO_RESAMPLER_DRIVER_CC: - snprintf(s, len, - "Convoluted Cosine implementation."); - break; - default: - if (string_is_empty(s)) - strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_INFORMATION_AVAILABLE), len); - break; + const char *lbl = settings ? settings->arrays.audio_resampler : NULL; + + if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER_SINC))) + strlcpy(s, + "Windowed SINC implementation.", len); + else if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER_CC))) + strlcpy(s, + "Convoluted Cosine implementation.", len); + else if (string_is_empty(s)) + strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_INFORMATION_AVAILABLE), len); } break; case MENU_ENUM_LABEL_VIDEO_SHADER_PRESET: diff --git a/intl/msg_hash_de.c b/intl/msg_hash_de.c index ececc198a5..559709b335 100644 --- a/intl/msg_hash_de.c +++ b/intl/msg_hash_de.c @@ -28,7 +28,6 @@ int menu_hash_get_help_de_enum(enum msg_hash_enums msg, char *s, size_t len) { - uint32_t driver_hash = 0; settings_t *settings = config_get_ptr(); if (msg <= MENU_ENUM_LABEL_INPUT_HOTKEY_BIND_END && @@ -702,12 +701,10 @@ int menu_hash_get_help_de_enum(enum msg_hash_enums msg, char *s, size_t len) ); break; case MENU_ENUM_LABEL_INPUT_DRIVER: - if (settings) - driver_hash = msg_hash_calculate(settings->arrays.input_driver); - - switch (driver_hash) { - case MENU_LABEL_INPUT_DRIVER_UDEV: + const char *lbl = settings ? settings->arrays.input_driver : NULL; + + if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_INPUT_DRIVER_UDEV))) snprintf(s, len, "udev-Eingabetreiber. \n" " \n" @@ -725,8 +722,7 @@ int menu_hash_get_help_de_enum(enum msg_hash_enums msg, char *s, size_t len) "Regel erstellen, die auch den Zugriff für andere \n" "Benutzer erlaubt." ); - break; - case MENU_LABEL_INPUT_DRIVER_LINUXRAW: + else if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_INPUT_DRIVER_LINUXRAW))) snprintf(s, len, "linuxraw-Eingabetreiber. \n" " \n" @@ -737,14 +733,12 @@ int menu_hash_get_help_de_enum(enum msg_hash_enums msg, char *s, size_t len) " \n" "Dieser Treiber verwendet die alte Joystick-API \n" "(/dev/input/js*)."); - break; - default: - snprintf(s, len, - "Eingabetreiber.\n" - " \n" - "Abhängig vom Grafiktreiber kann ein anderer Eingabe- \n" - "treiber erzwungen werden."); - break; + else + snprintf(s, len, + "Eingabetreiber.\n" + " \n" + "Abhängig vom Grafiktreiber kann ein anderer Eingabe- \n" + "treiber erzwungen werden."); } break; case MENU_ENUM_LABEL_LOAD_CONTENT_LIST: @@ -866,23 +860,17 @@ int menu_hash_get_help_de_enum(enum msg_hash_enums msg, char *s, size_t len) ); break; case MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER: - if (settings) - driver_hash = msg_hash_calculate(settings->arrays.audio_resampler); - - switch (driver_hash) { - case MENU_LABEL_AUDIO_RESAMPLER_DRIVER_SINC: - snprintf(s, len, - "Windowed-SINC-Implementierung."); - break; - case MENU_LABEL_AUDIO_RESAMPLER_DRIVER_CC: - snprintf(s, len, - "Convoluted-Kosinus-Implementierung."); - break; - default: - if (string_is_empty(s)) - strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_INFORMATION_AVAILABLE), len); - break; + const char *lbl = settings ? settings->arrays.audio_resampler : NULL; + + if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER_SINC))) + strlcpy(s, + "Windowed-SINC-Implementierung.", len); + else if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER_CC))) + strlcpy(s, + "Convoluted-Kosinus-Implementierung.", len); + else if (string_is_empty(s)) + strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_INFORMATION_AVAILABLE), len); } break; case MENU_ENUM_LABEL_VIDEO_SHADER_PRESET: diff --git a/intl/msg_hash_es.c b/intl/msg_hash_es.c index 3d97751946..00bf838c73 100644 --- a/intl/msg_hash_es.c +++ b/intl/msg_hash_es.c @@ -30,7 +30,6 @@ int menu_hash_get_help_es_enum(enum msg_hash_enums msg, char *s, size_t len) { - uint32_t driver_hash = 0; settings_t *settings = config_get_ptr(); switch (msg) @@ -129,43 +128,41 @@ int menu_hash_get_help_es_enum(enum msg_hash_enums msg, char *s, size_t len) strlcpy(s, "Extrayendo, espera, por favor...\n", len); break; case MENU_ENUM_LABEL_INPUT_DRIVER: - if (settings) - driver_hash = msg_hash_calculate(settings->arrays.input_driver); - - switch (driver_hash) { - case MENU_LABEL_INPUT_DRIVER_UDEV: - { - /* Work around C89 limitations */ - char u[501]; - char t[501]; + const char *lbl = settings ? settings->arrays.input_driver : NULL; - strlcpy(t, - "Controlador de entrada udev. \n" - " \n" - "Utiliza la API evdev más reciente \n" - "para dar compatibilidad con mandos. \n" - "Permite hotplug (conexión en caliente) \n" - "y force feedback (fuerza de respuesta). \n", - sizeof(t)); - strlcpy(u, - " \n" - "El controlador lee los eventos evdev para \n" - "dar compatibilidad con teclados. También \n" - "es compatible con callbacks de teclado, \n" - "ratones y pantallas táctiles. \n" - " \n" - "La mayoría de las distros tienen los nodos \n" - "/dev/input en modo solo root (modo 600). \n" - "Puedes configurar una regla udev que los haga \n" - "accesibles a otros usuarios.", sizeof(u) - ); + if (string_is_equal(lbl, msg_hash_to_str( + MENU_ENUM_LABEL_INPUT_DRIVER_UDEV))) + { + /* Work around C89 limitations */ + char u[501]; + char t[501]; - strlcpy(s, t, len); - strlcat(s, u, len); - } - break; - case MENU_LABEL_INPUT_DRIVER_LINUXRAW: + strlcpy(t, + "Controlador de entrada udev. \n" + " \n" + "Utiliza la API evdev más reciente \n" + "para dar compatibilidad con mandos. \n" + "Permite hotplug (conexión en caliente) \n" + "y force feedback (fuerza de respuesta). \n", + sizeof(t)); + strlcpy(u, + " \n" + "El controlador lee los eventos evdev para \n" + "dar compatibilidad con teclados. También \n" + "es compatible con callbacks de teclado, \n" + "ratones y pantallas táctiles. \n" + " \n" + "La mayoría de las distros tienen los nodos \n" + "/dev/input en modo solo root (modo 600). \n" + "Puedes configurar una regla udev que los haga \n" + "accesibles a otros usuarios.", sizeof(u) + ); + + strlcpy(s, t, len); + strlcat(s, u, len); + } + else if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_INPUT_DRIVER_LINUXRAW))) snprintf(s, len, "Controlador de entrada linuxraw. \n" " \n" @@ -177,15 +174,13 @@ int menu_hash_get_help_es_enum(enum msg_hash_enums msg, char *s, size_t len) " \n" "Este controlador utiliza la antigua API de mandos \n" "(/dev/input/js*)."); - break; - default: + else snprintf(s, len, "Controlador de entrada.\n" " \n" "El controlador de vídeo podría forzar \n" "el uso de un controlador de entrada \n" "distinto."); - break; } break; case MENU_ENUM_LABEL_LOAD_CONTENT_LIST: @@ -320,19 +315,15 @@ int menu_hash_get_help_es_enum(enum msg_hash_enums msg, char *s, size_t len) ); break; case MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER: - if (settings) - driver_hash = msg_hash_calculate(settings->arrays.audio_resampler); - - switch (driver_hash) { - case MENU_LABEL_AUDIO_RESAMPLER_DRIVER_SINC: - snprintf(s, len, - "Implementación windowed SINC."); - break; - case MENU_LABEL_AUDIO_RESAMPLER_DRIVER_CC: - snprintf(s, len, - "Implementación de cosenos complejos."); - break; + const char *lbl = settings ? settings->arrays.audio_resampler : NULL; + + if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER_SINC))) + strlcpy(s, + "Implementación windowed SINC.", len); + else if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER_CC))) + strlcpy(s, + "Implementación de cosenos complejos.", len); } break; case MENU_ENUM_LABEL_VIDEO_SHADER_PRESET: diff --git a/intl/msg_hash_it.c b/intl/msg_hash_it.c index d8dc11aa19..8fd5c4a755 100644 --- a/intl/msg_hash_it.c +++ b/intl/msg_hash_it.c @@ -25,7 +25,6 @@ int menu_hash_get_help_it_enum(enum msg_hash_enums msg, char *s, size_t len) { - uint32_t driver_hash = 0; settings_t *settings = config_get_ptr(); switch (msg) @@ -122,37 +121,34 @@ int menu_hash_get_help_it_enum(enum msg_hash_enums msg, char *s, size_t len) strlcpy(s, "Estraendo, per favore attendi...\n", len); break; case MENU_ENUM_LABEL_INPUT_DRIVER: - if (settings) - driver_hash = msg_hash_calculate(settings->arrays.input_driver); - - switch (driver_hash) { - case MENU_LABEL_INPUT_DRIVER_UDEV: - { - /* Work around C89 limitations */ - const char * t = - "udev Input driver. \n" - " \n" - "Questo driver può caricare senza X. \n" - " \n" - "Usa la recente evdev joypad API \n" - "per il supporto del joystick. Supporta \n" - "hotplugging e force feedback (se \n" - "supportato dal dispositivo). \n" - " \n"; - const char * u = - "Il driver legge gli eventi evdev per il supporto \n" - "della tastiera. Supporta anche la callback della tastiera, \n" - "mouse e touchpads. \n" - " \n" - "Come predefinito nella maggior parte delle distribuzioni, i nodi /dev/input \n" - "sono only-root (modalità 600). Puoi settare una regola udev \n" - "che fa queste accessibili ai non-root."; - strlcpy(s, t, len); - strlcat(s, u, len); - } - break; - case MENU_LABEL_INPUT_DRIVER_LINUXRAW: + const char *lbl = settings ? settings->arrays.input_driver : NULL; + + if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_INPUT_DRIVER_UDEV))) + { + /* Work around C89 limitations */ + const char * t = + "udev Input driver. \n" + " \n" + "Questo driver può caricare senza X. \n" + " \n" + "Usa la recente evdev joypad API \n" + "per il supporto del joystick. Supporta \n" + "hotplugging e force feedback (se \n" + "supportato dal dispositivo). \n" + " \n"; + const char * u = + "Il driver legge gli eventi evdev per il supporto \n" + "della tastiera. Supporta anche la callback della tastiera, \n" + "mouse e touchpads. \n" + " \n" + "Come predefinito nella maggior parte delle distribuzioni, i nodi /dev/input \n" + "sono only-root (modalità 600). Puoi settare una regola udev \n" + "che fa queste accessibili ai non-root."; + strlcpy(s, t, len); + strlcat(s, u, len); + } + else if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_INPUT_DRIVER_LINUXRAW))) snprintf(s, len, "linuxraw Input driver. \n" " \n" @@ -162,14 +158,12 @@ int menu_hash_get_help_it_enum(enum msg_hash_enums msg, char *s, size_t len) " \n" "Questo driver usa la più vecchia API per il joystick \n" "(/dev/input/js*)."); - break; - default: + else snprintf(s, len, "Driver input.\n" " \n" "Dipende dal driver video, potrebbe \n" "forzare un differente driver input."); - break; } break; case MENU_ENUM_LABEL_LOAD_CONTENT_LIST: @@ -284,19 +278,15 @@ int menu_hash_get_help_it_enum(enum msg_hash_enums msg, char *s, size_t len) ); break; case MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER: - if (settings) - driver_hash = msg_hash_calculate(settings->arrays.audio_resampler); - - switch (driver_hash) { - case MENU_LABEL_AUDIO_RESAMPLER_DRIVER_SINC: - snprintf(s, len, - "Implementazione SINC in modalità finestra."); - break; - case MENU_LABEL_AUDIO_RESAMPLER_DRIVER_CC: - snprintf(s, len, - "Implementazione coseno complesso."); - break; + const char *lbl = settings ? settings->arrays.audio_resampler : NULL; + + if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER_SINC))) + strlcpy(s, + "Implementazione SINC in modalità finestra.", len); + else if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER_CC))) + strlcpy(s, + "Implementazione coseno complesso.", len); } break; case MENU_ENUM_LABEL_VIDEO_SHADER_PRESET: diff --git a/intl/msg_hash_ja.c b/intl/msg_hash_ja.c index fcef9422c0..31e93307aa 100644 --- a/intl/msg_hash_ja.c +++ b/intl/msg_hash_ja.c @@ -33,7 +33,6 @@ int menu_hash_get_help_jp_enum(enum msg_hash_enums msg, char *s, size_t len) { - uint32_t driver_hash = 0; settings_t *settings = config_get_ptr(); if (msg <= MENU_ENUM_LABEL_INPUT_HOTKEY_BIND_END && @@ -695,12 +694,10 @@ int menu_hash_get_help_jp_enum(enum msg_hash_enums msg, char *s, size_t len) ); break; case MENU_ENUM_LABEL_INPUT_DRIVER: - if (settings) - driver_hash = msg_hash_calculate(settings->arrays.input_driver); - - switch (driver_hash) { - case MENU_LABEL_INPUT_DRIVER_UDEV: + const char *lbl = settings ? settings->arrays.input_driver : NULL; + + if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_INPUT_DRIVER_UDEV))) snprintf(s, len, "udev Input driver. \n" " \n" @@ -719,8 +716,7 @@ int menu_hash_get_help_jp_enum(enum msg_hash_enums msg, char *s, size_t len) "are root-only (mode 600). You can set up a udev \n" "rule which makes these accessible to non-root." ); - break; - case MENU_LABEL_INPUT_DRIVER_LINUXRAW: + else if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_INPUT_DRIVER_LINUXRAW))) snprintf(s, len, "linuxraw Input driver. \n" " \n" @@ -730,14 +726,12 @@ int menu_hash_get_help_jp_enum(enum msg_hash_enums msg, char *s, size_t len) " \n" "This driver uses the older joystick API \n" "(/dev/input/js*)."); - break; - default: + else snprintf(s, len, "Input driver.\n" " \n" "Depending on video driver, it might \n" "force a different input driver."); - break; } break; case MENU_ENUM_LABEL_LOAD_CONTENT_LIST: @@ -861,23 +855,17 @@ int menu_hash_get_help_jp_enum(enum msg_hash_enums msg, char *s, size_t len) ); break; case MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER: - if (settings) - driver_hash = msg_hash_calculate(settings->arrays.audio_resampler); - - switch (driver_hash) { - case MENU_LABEL_AUDIO_RESAMPLER_DRIVER_SINC: - snprintf(s, len, - "Windowed SINC implementation."); - break; - case MENU_LABEL_AUDIO_RESAMPLER_DRIVER_CC: - snprintf(s, len, - "Convoluted Cosine implementation."); - break; - default: - if (string_is_empty(s)) - strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_INFORMATION_AVAILABLE), len); - break; + const char *lbl = settings ? settings->arrays.audio_resampler : NULL; + + if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER_SINC))) + strlcpy(s, + "Windowed SINC implementation.", len); + else if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER_CC))) + strlcpy(s, + "Convoluted Cosine implementation.", len); + else if (string_is_empty(s)) + strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_INFORMATION_AVAILABLE), len); } break; case MENU_ENUM_LABEL_VIDEO_SHADER_PRESET: diff --git a/intl/msg_hash_ko.c b/intl/msg_hash_ko.c index eda672f460..faa82fb500 100644 --- a/intl/msg_hash_ko.c +++ b/intl/msg_hash_ko.c @@ -31,8 +31,8 @@ #pragma warning(disable: 4566) #endif -int menu_hash_get_help_ko_enum(enum msg_hash_enums msg, char *s, size_t len) { - uint32_t driver_hash = 0; +int menu_hash_get_help_ko_enum(enum msg_hash_enums msg, char *s, size_t len) +{ settings_t *settings = config_get_ptr(); if (msg <= MENU_ENUM_LABEL_INPUT_HOTKEY_BIND_END && @@ -694,45 +694,41 @@ int menu_hash_get_help_ko_enum(enum msg_hash_enums msg, char *s, size_t len) { ); break; case MENU_ENUM_LABEL_INPUT_DRIVER: - if (settings) - driver_hash = msg_hash_calculate(settings->arrays.input_driver); + { + const char *lbl = settings ? settings->arrays.input_driver : NULL; - switch (driver_hash) { - case MENU_LABEL_INPUT_DRIVER_UDEV: - snprintf(s, len, - "udev Input driver. \n" - " \n" - "It uses the recent evdev joypad API \n" - "for joystick support. It supports \n" - "hotplugging and force feedback. \n" - " \n" - "The driver reads evdev events for keyboard \n" - "support. It also supports keyboard callback, \n" - "mice and touchpads. \n" - " \n" - "By default in most distros, /dev/input nodes \n" - "are root-only (mode 600). You can set up a udev \n" - "rule which makes these accessible to non-root." - ); - break; - case MENU_LABEL_INPUT_DRIVER_LINUXRAW: - snprintf(s, len, - "linuxraw Input driver. \n" - " \n" - "This driver requires an active TTY. Keyboard \n" - "events are read directly from the TTY which \n" - "makes it simpler, but not as flexible as udev. \n" "Mice, etc, are not supported at all. \n" - " \n" - "This driver uses the older joystick API \n" - "(/dev/input/js*)."); - break; - default: - snprintf(s, len, - "Input driver.\n" - " \n" - "Depending on video driver, it might \n" - "force a different input driver."); - break; + if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_INPUT_DRIVER_UDEV))) + snprintf(s, len, + "udev Input driver. \n" + " \n" + "It uses the recent evdev joypad API \n" + "for joystick support. It supports \n" + "hotplugging and force feedback. \n" + " \n" + "The driver reads evdev events for keyboard \n" + "support. It also supports keyboard callback, \n" + "mice and touchpads. \n" + " \n" + "By default in most distros, /dev/input nodes \n" + "are root-only (mode 600). You can set up a udev \n" + "rule which makes these accessible to non-root." + ); + else if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_INPUT_DRIVER_LINUXRAW))) + snprintf(s, len, + "linuxraw Input driver. \n" + " \n" + "This driver requires an active TTY. Keyboard \n" + "events are read directly from the TTY which \n" + "makes it simpler, but not as flexible as udev. \n" "Mice, etc, are not supported at all. \n" + " \n" + "This driver uses the older joystick API \n" + "(/dev/input/js*)."); + else + snprintf(s, len, + "Input driver.\n" + " \n" + "Depending on video driver, it might \n" + "force a different input driver."); } break; case MENU_ENUM_LABEL_LOAD_CONTENT_LIST: @@ -855,22 +851,17 @@ int menu_hash_get_help_ko_enum(enum msg_hash_enums msg, char *s, size_t len) { ); break; case MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER: - if (settings) - driver_hash = msg_hash_calculate(settings->arrays.audio_resampler); + { + const char *lbl = settings ? settings->arrays.audio_resampler : NULL; - switch (driver_hash) { - case MENU_LABEL_AUDIO_RESAMPLER_DRIVER_SINC: - snprintf(s, len, - "Windowed SINC implementation."); - break; - case MENU_LABEL_AUDIO_RESAMPLER_DRIVER_CC: - snprintf(s, len, - "Convoluted Cosine implementation."); - break; - default: - if (string_is_empty(s)) - strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_INFORMATION_AVAILABLE), len); - break; + if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER_SINC))) + strlcpy(s, + "Windowed SINC implementation.", len); + else if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER_CC))) + strlcpy(s, + "Convoluted Cosine implementation.", len); + else if (string_is_empty(s)) + strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_INFORMATION_AVAILABLE), len); } break; case MENU_ENUM_LABEL_VIDEO_SHADER_PRESET: diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index b82f0dc95c..435b040115 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -1399,3 +1399,11 @@ MSG_HASH(MENU_ENUM_LABEL_VIDEO_WINDOW_OPACITY, "video_window_opacity") MSG_HASH(MENU_ENUM_LABEL_AUDIO_RESAMPLER_QUALITY, "audio_resampler_quality") +MSG_HASH(MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER_SINC, + "sinc") +MSG_HASH(MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER_CC, + "cc") +MSG_HASH(MENU_ENUM_LABEL_INPUT_DRIVER_UDEV, + "udev") +MSG_HASH(MENU_ENUM_LABEL_INPUT_DRIVER_LINUXRAW, + "linuxraw") diff --git a/intl/msg_hash_pt_br.c b/intl/msg_hash_pt_br.c index 5b0d02eaa1..cd955d0e7c 100644 --- a/intl/msg_hash_pt_br.c +++ b/intl/msg_hash_pt_br.c @@ -26,7 +26,6 @@ #include "../verbosity.h" int menu_hash_get_help_pt_br_enum(enum msg_hash_enums msg, char *s, size_t len) { - uint32_t driver_hash = 0; settings_t *settings = config_get_ptr(); if (msg == MENU_ENUM_LABEL_CONNECT_NETPLAY_ROOM) @@ -733,49 +732,45 @@ int menu_hash_get_help_pt_br_enum(enum msg_hash_enums msg, char *s, size_t len) ); break; case MENU_ENUM_LABEL_INPUT_DRIVER: - if (settings) - driver_hash = msg_hash_calculate(settings->arrays.input_driver); + { + const char *lbl = settings ? settings->arrays.input_driver : NULL; - switch (driver_hash) { - case MENU_LABEL_INPUT_DRIVER_UDEV: - snprintf(s, len, - "Driver de entrada udev. \n" - " \n" - "Utiliza a recente API evdev joypad \n" - "para suporte a Joystick. Suporta \n" - "hotplugging e force feedback. \n" - " \n" - "O driver lê eventos evdev para suporte \n" - "a teclado. Tambêm suporta keyboard callback, \n" - "Mouses e Touchpads. \n" - " \n" - "Por padrão na maioria das distros, \n" - "nodes /dev/input são somente root (mode 600). \n" - "Você pode criar uma regra udev para torná-los \n" - "acessíveis para não root." - ); - break; - case MENU_LABEL_INPUT_DRIVER_LINUXRAW: - snprintf(s, len, - "Driver de entrada linuxraw. \n" - " \n" - "Este driver requer um TTY ativo. Eventos de \n" - "teclado são lidos diretamente do TTY o que \n" - "o torna simples, mas não tão flexível, \n" - "quanto udev. \n" - "Mouses, etc, não são suportados de nenhum \n" - "modo. \n" - " \n" - "Este driver utiliza a antiga API de Joystick \n" - "(/dev/input/js*)."); - break; - default: - snprintf(s, len, - "Driver de entrada.\n" - " \n" - "Dependendo do driver de vídeo, pode \n" - "forçar um driver de entrada diferente."); - break; + if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_INPUT_DRIVER_UDEV))) + snprintf(s, len, + "Driver de entrada udev. \n" + " \n" + "Utiliza a recente API evdev joypad \n" + "para suporte a Joystick. Suporta \n" + "hotplugging e force feedback. \n" + " \n" + "O driver lê eventos evdev para suporte \n" + "a teclado. Tambêm suporta keyboard callback, \n" + "Mouses e Touchpads. \n" + " \n" + "Por padrão na maioria das distros, \n" + "nodes /dev/input são somente root (mode 600). \n" + "Você pode criar uma regra udev para torná-los \n" + "acessíveis para não root." + ); + else if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_INPUT_DRIVER_LINUXRAW))) + snprintf(s, len, + "Driver de entrada linuxraw. \n" + " \n" + "Este driver requer um TTY ativo. Eventos de \n" + "teclado são lidos diretamente do TTY o que \n" + "o torna simples, mas não tão flexível, \n" + "quanto udev. \n" + "Mouses, etc, não são suportados de nenhum \n" + "modo. \n" + " \n" + "Este driver utiliza a antiga API de Joystick \n" + "(/dev/input/js*)."); + else + snprintf(s, len, + "Driver de entrada.\n" + " \n" + "Dependendo do driver de vídeo, pode \n" + "forçar um driver de entrada diferente."); } break; case MENU_ENUM_LABEL_LOAD_CONTENT_LIST: @@ -902,22 +897,17 @@ int menu_hash_get_help_pt_br_enum(enum msg_hash_enums msg, char *s, size_t len) ); break; case MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER: - if (settings) - driver_hash = msg_hash_calculate(settings->arrays.audio_resampler); + { + const char *lbl = settings ? settings->arrays.audio_resampler : NULL; - switch (driver_hash) { - case MENU_LABEL_AUDIO_RESAMPLER_DRIVER_SINC: - snprintf(s, len, - "Implementação SINC windowed."); - break; - case MENU_LABEL_AUDIO_RESAMPLER_DRIVER_CC: - snprintf(s, len, - "Implementação Convoluted Cosine."); - break; - default: - if (string_is_empty(s)) - strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_INFORMATION_AVAILABLE), len); - break; + if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER_SINC))) + strlcpy(s, + "Implementação SINC windowed.", len); + else if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER_CC))) + strlcpy(s, + "Implementação Convoluted Cosine.", len); + else if (string_is_empty(s)) + strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_INFORMATION_AVAILABLE), len); } break; case MENU_ENUM_LABEL_VIDEO_SHADER_PRESET: diff --git a/intl/msg_hash_pt_pt.c b/intl/msg_hash_pt_pt.c index bdff63fadd..7dfa930401 100644 --- a/intl/msg_hash_pt_pt.c +++ b/intl/msg_hash_pt_pt.c @@ -25,7 +25,6 @@ int menu_hash_get_help_pt_pt_enum(enum msg_hash_enums msg, char *s, size_t len) { - uint32_t driver_hash = 0; settings_t *settings = config_get_ptr(); switch (msg) @@ -45,12 +44,10 @@ int menu_hash_get_help_pt_pt_enum(enum msg_hash_enums msg, char *s, size_t len) "o arquivo estiver."); break; case MENU_ENUM_LABEL_INPUT_DRIVER: - if (settings) - driver_hash = msg_hash_calculate(settings->arrays.input_driver); - - switch (driver_hash) { - case MENU_LABEL_INPUT_DRIVER_UDEV: + const char *lbl = settings ? settings->arrays.input_driver : NULL; + + if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_INPUT_DRIVER_UDEV))) snprintf(s, len, "Driver de entrada udev. \n" " \n" @@ -69,8 +66,7 @@ int menu_hash_get_help_pt_pt_enum(enum msg_hash_enums msg, char *s, size_t len) "/dev/input são root-only (modo 600). Mas você pode \n" "definir uma regra udev para dar acesso a non-roots." ); - break; - case MENU_LABEL_INPUT_DRIVER_LINUXRAW: + else if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_INPUT_DRIVER_LINUXRAW))) snprintf(s, len, "Driver de Entrada linuxraw. \n" " \n" @@ -80,14 +76,12 @@ int menu_hash_get_help_pt_pt_enum(enum msg_hash_enums msg, char *s, size_t len) " \n" "Esse driver usa a antiga API de joysticks \n" "(/dev/input/js*)."); - break; - default: + else snprintf(s, len, "Driver de Entrada.\n" " \n" "Dependendo do driver de vídeo, pode ser necessário \n" "forçar um driver de entrada diferente."); - break; } break; case MENU_ENUM_LABEL_LOAD_CONTENT_HISTORY: @@ -183,19 +177,15 @@ int menu_hash_get_help_pt_pt_enum(enum msg_hash_enums msg, char *s, size_t len) ); break; case MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER: - if (settings) - driver_hash = msg_hash_calculate(settings->arrays.audio_resampler); - - switch (driver_hash) { - case MENU_LABEL_AUDIO_RESAMPLER_DRIVER_SINC: - snprintf(s, len, - "Implementação Windowed SINC."); - break; - case MENU_LABEL_AUDIO_RESAMPLER_DRIVER_CC: - snprintf(s, len, - "Implementação Convoluted Cosine."); - break; + const char *lbl = settings ? settings->arrays.audio_resampler : NULL; + + if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER_SINC))) + strlcpy(s, + "Implementação Windowed SINC.", len); + else if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER_CC))) + strlcpy(s, + "Implementação Convoluted Cosine.", len); } break; case MENU_ENUM_LABEL_VIDEO_SHADER_PRESET: diff --git a/intl/msg_hash_us.c b/intl/msg_hash_us.c index a215541dc9..86de76a8cd 100644 --- a/intl/msg_hash_us.c +++ b/intl/msg_hash_us.c @@ -27,7 +27,6 @@ int menu_hash_get_help_us_enum(enum msg_hash_enums msg, char *s, size_t len) { - uint32_t driver_hash = 0; settings_t *settings = config_get_ptr(); if (msg == MENU_ENUM_LABEL_CONNECT_NETPLAY_ROOM) @@ -711,45 +710,42 @@ int menu_hash_get_help_us_enum(enum msg_hash_enums msg, char *s, size_t len) ); break; case MENU_ENUM_LABEL_INPUT_DRIVER: - if (settings) - driver_hash = msg_hash_calculate(settings->arrays.input_driver); + { + const char *lbl = settings ? settings->arrays.input_driver : NULL; - switch (driver_hash) { - case MENU_LABEL_INPUT_DRIVER_UDEV: - snprintf(s, len, - "udev Input driver. \n" - " \n" - "It uses the recent evdev joypad API \n" - "for joystick support. It supports \n" - "hotplugging and force feedback. \n" - " \n" - "The driver reads evdev events for keyboard \n" - "support. It also supports keyboard callback, \n" - "mice and touchpads. \n" - " \n" - "By default in most distros, /dev/input nodes \n" - "are root-only (mode 600). You can set up a udev \n" - "rule which makes these accessible to non-root." - ); - break; - case MENU_LABEL_INPUT_DRIVER_LINUXRAW: - snprintf(s, len, - "linuxraw Input driver. \n" - " \n" - "This driver requires an active TTY. Keyboard \n" - "events are read directly from the TTY which \n" - "makes it simpler, but not as flexible as udev. \n" "Mice, etc, are not supported at all. \n" - " \n" - "This driver uses the older joystick API \n" - "(/dev/input/js*)."); - break; - default: - snprintf(s, len, - "Input driver.\n" - " \n" - "Depending on video driver, it might \n" - "force a different input driver."); - break; + if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_INPUT_DRIVER_UDEV))) + snprintf(s, len, + "udev Input driver. \n" + " \n" + "It uses the recent evdev joypad API \n" + "for joystick support. It supports \n" + "hotplugging and force feedback. \n" + " \n" + "The driver reads evdev events for keyboard \n" + "support. It also supports keyboard callback, \n" + "mice and touchpads. \n" + " \n" + "By default in most distros, /dev/input nodes \n" + "are root-only (mode 600). You can set up a udev \n" + "rule which makes these accessible to non-root." + ); + else if (string_is_equal(lbl, + msg_hash_to_str(MENU_ENUM_LABEL_INPUT_DRIVER_LINUXRAW))) + snprintf(s, len, + "linuxraw Input driver. \n" + " \n" + "This driver requires an active TTY. Keyboard \n" + "events are read directly from the TTY which \n" + "makes it simpler, but not as flexible as udev. \n" "Mice, etc, are not supported at all. \n" + " \n" + "This driver uses the older joystick API \n" + "(/dev/input/js*)."); + else + snprintf(s, len, + "Input driver.\n" + " \n" + "Depending on video driver, it might \n" + "force a different input driver."); } break; case MENU_ENUM_LABEL_LOAD_CONTENT_LIST: @@ -873,22 +869,19 @@ int menu_hash_get_help_us_enum(enum msg_hash_enums msg, char *s, size_t len) ); break; case MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER: - if (settings) - driver_hash = msg_hash_calculate(settings->arrays.audio_resampler); + { + const char *lbl = settings ? settings->arrays.audio_resampler : NULL; - switch (driver_hash) { - case MENU_LABEL_AUDIO_RESAMPLER_DRIVER_SINC: - snprintf(s, len, - "Windowed SINC implementation."); - break; - case MENU_LABEL_AUDIO_RESAMPLER_DRIVER_CC: - snprintf(s, len, - "Convoluted Cosine implementation."); - break; - default: - if (string_is_empty(s)) - strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_INFORMATION_AVAILABLE), len); - break; + if (string_is_equal(lbl, msg_hash_to_str( + MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER_SINC))) + strlcpy(s, + "Windowed SINC implementation.", len); + else if (string_is_equal(lbl, msg_hash_to_str( + MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER_CC))) + strlcpy(s, + "Convoluted Cosine implementation.", len); + else if (string_is_empty(s)) + strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_INFORMATION_AVAILABLE), len); } break; case MENU_ENUM_LABEL_VIDEO_SHADER_PRESET: diff --git a/intl/msg_hash_vn.c b/intl/msg_hash_vn.c index e7f6e46416..110a4c26e4 100644 --- a/intl/msg_hash_vn.c +++ b/intl/msg_hash_vn.c @@ -32,7 +32,6 @@ int menu_hash_get_help_vn_enum(enum msg_hash_enums msg, char *s, size_t len) { - uint32_t driver_hash = 0; settings_t *settings = config_get_ptr(); if (msg <= MENU_ENUM_LABEL_INPUT_HOTKEY_BIND_END && @@ -695,33 +694,30 @@ int menu_hash_get_help_vn_enum(enum msg_hash_enums msg, char *s, size_t len) ); break; case MENU_ENUM_LABEL_INPUT_DRIVER: - if (settings) - driver_hash = msg_hash_calculate(settings->arrays.input_driver); - - switch (driver_hash) { - case MENU_LABEL_INPUT_DRIVER_UDEV: - snprintf(s, len, - "udev Input driver. \n" - " \n" - "This driver can run without X. \n" - " \n" - "It uses the recent evdev joypad API \n" - "for joystick support. It supports \n" - "hotplugging and force feedback (if \n" - "supported by device). \n" - " \n" - "The driver reads evdev events for keyboard \n" - "support. It also supports keyboard callback, \n" - "mice and touchpads. \n" - " \n" - "By default in most distros, /dev/input nodes \n" - "are root-only (mode 600). You can set up a udev \n" - "rule which makes these accessible to non-root." - ); - break; - case MENU_LABEL_INPUT_DRIVER_LINUXRAW: - snprintf(s, len, + const char *lbl = settings ? settings->arrays.input_driver : NULL; + + if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_INPUT_DRIVER_UDEV))) + snprintf(s, len, + "udev Input driver. \n" + " \n" + "This driver can run without X. \n" + " \n" + "It uses the recent evdev joypad API \n" + "for joystick support. It supports \n" + "hotplugging and force feedback (if \n" + "supported by device). \n" + " \n" + "The driver reads evdev events for keyboard \n" + "support. It also supports keyboard callback, \n" + "mice and touchpads. \n" + " \n" + "By default in most distros, /dev/input nodes \n" + "are root-only (mode 600). You can set up a udev \n" + "rule which makes these accessible to non-root." + ); + else if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_INPUT_DRIVER_LINUXRAW))) + strlcpy(s, "linuxraw Input driver. \n" " \n" "This driver requires an active TTY. Keyboard \n" @@ -729,15 +725,13 @@ int menu_hash_get_help_vn_enum(enum msg_hash_enums msg, char *s, size_t len) "makes it simpler, but not as flexible as udev. \n" "Mice, etc, are not supported at all. \n" " \n" "This driver uses the older joystick API \n" - "(/dev/input/js*)."); - break; - default: - snprintf(s, len, + "(/dev/input/js*).", len); + else + strlcpy(s, "Input driver.\n" " \n" "Depending on video driver, it might \n" - "force a different input driver."); - break; + "force a different input driver.", len); } break; case MENU_ENUM_LABEL_LOAD_CONTENT_LIST: @@ -861,23 +855,17 @@ int menu_hash_get_help_vn_enum(enum msg_hash_enums msg, char *s, size_t len) ); break; case MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER: - if (settings) - driver_hash = msg_hash_calculate(settings->arrays.audio_resampler); - - switch (driver_hash) { - case MENU_LABEL_AUDIO_RESAMPLER_DRIVER_SINC: - snprintf(s, len, - "Windowed SINC implementation."); - break; - case MENU_LABEL_AUDIO_RESAMPLER_DRIVER_CC: - snprintf(s, len, - "Convoluted Cosine implementation."); - break; - default: - if (string_is_empty(s)) - strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_INFORMATION_AVAILABLE), len); - break; + const char *lbl = settings ? settings->arrays.audio_resampler : NULL; + + if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER_SINC))) + strlcpy(s, + "Windowed SINC implementation.", len); + else if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER_CC))) + strlcpy(s, + "Convoluted Cosine implementation.", len); + else if (string_is_empty(s)) + strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_INFORMATION_AVAILABLE), len); } break; case MENU_ENUM_LABEL_VIDEO_SHADER_PRESET: diff --git a/msg_hash.h b/msg_hash.h index 2d64443246..d873506e75 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1789,13 +1789,6 @@ enum msg_hash_enums #define MENU_LABEL_DOWNLOADED_FILE_DETECT_CORE_LIST 0xb4f82700U #define MENU_LABEL_FAVORITES 0x67325138U -/* Help */ -#define MENU_LABEL_INPUT_DRIVER_LINUXRAW 0xc33c6b9fU -#define MENU_LABEL_INPUT_DRIVER_UDEV 0x7c9eeeb9U - -#define MENU_LABEL_AUDIO_RESAMPLER_DRIVER_SINC 0x7c9dec52U -#define MENU_LABEL_AUDIO_RESAMPLER_DRIVER_CC 0x0059732bU - const char *msg_hash_to_str(enum msg_hash_enums msg); const char *msg_hash_to_str_fr(enum msg_hash_enums msg); From 83aa0842ca7be9d09ca6135e32f2804c86093aa8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 6 Feb 2018 17:21:19 +0100 Subject: [PATCH 144/232] Remove another hash --- menu/cbs/menu_cbs_deferred_push.c | 7 ++++--- menu/cbs/menu_cbs_title.c | 7 ++++--- msg_hash.h | 1 - 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index 1d47973cbc..f92dbb0593 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -814,6 +814,10 @@ static struct cbs_deferred_lbl_callback cbs_deferred_lbl_list[] = { { MENU_ENUM_LABEL_DEFERRED_CONFIGURATIONS_LIST, deferred_push_configurations_list + }, + { + MENU_ENUM_LABEL_ACHIEVEMENT_LIST, + deferred_push_achievement_list } }; @@ -1337,9 +1341,6 @@ static int menu_cbs_init_bind_deferred_push_compare_label( BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_releaseyear); break; #endif - case MENU_LABEL_ACHIEVEMENT_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_achievement_list); - break; case MENU_LABEL_CORE_COUNTERS: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_counters); break; diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index 53df22f484..fed7db49df 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -701,6 +701,10 @@ static struct cbs_title_lbl_callback cbs_title_lbl_list[] = { { MENU_ENUM_LABEL_DEFERRED_CONFIGURATIONS_LIST, action_get_configurations_list + }, + { + MENU_ENUM_LABEL_ACHIEVEMENT_LIST, + action_get_title_cheevos_list } }; @@ -1110,9 +1114,6 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_CONTENT_COLLECTION_LIST: BIND_ACTION_GET_TITLE(cbs, action_get_title_collection); break; - case MENU_LABEL_ACHIEVEMENT_LIST: - BIND_ACTION_GET_TITLE(cbs, action_get_title_cheevos_list); - break; case MENU_LABEL_REMAP_FILE_LOAD: BIND_ACTION_GET_TITLE(cbs, action_get_title_remap_file_load); break; diff --git a/msg_hash.h b/msg_hash.h index d873506e75..df948d21a1 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1777,7 +1777,6 @@ enum msg_hash_enums #define MENU_LABEL_FRONTEND_COUNTERS 0xe5696877U #define MENU_LABEL_CORE_COUNTERS 0x64cc83e0U -#define MENU_LABEL_ACHIEVEMENT_LIST 0x7b90fc49U #define MENU_LABEL_DATABASE_MANAGER_LIST 0x7f853d8fU #define MENU_LABEL_CURSOR_MANAGER_LIST 0xa969e378U #define MENU_LABEL_REMAP_FILE_LOAD 0x9c2799b8U From 23ae113bfb9350b3efd2cb5bc0d0780dacc86704 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 6 Feb 2018 17:25:19 +0100 Subject: [PATCH 145/232] Get rid of another hash --- menu/cbs/menu_cbs_title.c | 7 ++++--- msg_hash.h | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index fed7db49df..f255b7f438 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -705,6 +705,10 @@ static struct cbs_title_lbl_callback cbs_title_lbl_list[] = { { MENU_ENUM_LABEL_ACHIEVEMENT_LIST, action_get_title_cheevos_list + }, + { + MENU_ENUM_LABEL_DEFERRED_CORE_CONTENT_LIST, + action_get_download_core_content_list } }; @@ -1120,9 +1124,6 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_DEFERRED_ACCOUNTS_CHEEVOS_LIST: BIND_ACTION_GET_TITLE(cbs, action_get_user_accounts_cheevos_list); break; - case MENU_LABEL_DEFERRED_CORE_CONTENT_LIST: - BIND_ACTION_GET_TITLE(cbs, action_get_download_core_content_list); - break; case MENU_LABEL_DEFERRED_ACCOUNTS_LIST: BIND_ACTION_GET_TITLE(cbs, action_get_user_accounts_list); break; diff --git a/msg_hash.h b/msg_hash.h index df948d21a1..d7984fcba6 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1769,7 +1769,6 @@ enum msg_hash_enums #define MENU_LABEL_DEFERRED_ARCHIVE_ACTION 0x7faf0284U #define MENU_LABEL_DEFERRED_ARCHIVE_OPEN_DETECT_CORE 0xd9452498U #define MENU_LABEL_DEFERRED_ARCHIVE_OPEN 0xfa0938b8U -#define MENU_LABEL_DEFERRED_CORE_CONTENT_LIST 0x76150c63U #define MENU_LABEL_DEFERRED_LAKKA_LIST 0x3db437c4U #define MENU_LABEL_DEFERRED_BROWSE_URL_START 0xcef58296U From e6bf3227370a8235c3facb5318603f7c6787516e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 6 Feb 2018 21:38:25 +0100 Subject: [PATCH 146/232] Remove hashes --- menu/cbs/menu_cbs_deferred_push.c | 14 ++++++++------ menu/cbs/menu_cbs_title.c | 21 ++++++++++++--------- msg_hash.h | 3 --- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index f92dbb0593..a14c6ce58a 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -818,6 +818,14 @@ static struct cbs_deferred_lbl_callback cbs_deferred_lbl_list[] = { { MENU_ENUM_LABEL_ACHIEVEMENT_LIST, deferred_push_achievement_list + }, + { + MENU_ENUM_LABEL_DEFERRED_RECORDING_SETTINGS_LIST, + deferred_push_recording_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_ACCOUNTS_CHEEVOS_LIST, + deferred_push_accounts_cheevos_list } }; @@ -1244,12 +1252,6 @@ static int menu_cbs_init_bind_deferred_push_compare_label( { switch (label_hash) { - case MENU_LABEL_DEFERRED_RECORDING_SETTINGS_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_recording_settings_list); - break; - case MENU_LABEL_DEFERRED_ACCOUNTS_CHEEVOS_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_accounts_cheevos_list); - break; case MENU_LABEL_DEFERRED_ARCHIVE_ACTION_DETECT_CORE: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_archive_action_detect_core); break; diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index f255b7f438..441c021fbe 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -709,6 +709,18 @@ static struct cbs_title_lbl_callback cbs_title_lbl_list[] = { { MENU_ENUM_LABEL_DEFERRED_CORE_CONTENT_LIST, action_get_download_core_content_list + }, + { + MENU_ENUM_LABEL_DEFERRED_RECORDING_SETTINGS_LIST, + action_get_recording_settings_list + }, + { + MENU_ENUM_LABEL_DEFERRED_ACCOUNTS_CHEEVOS_LIST, + action_get_user_accounts_cheevos_list + }, + { + MENU_ENUM_LABEL_DEFERRED_ACCOUNTS_LIST, + action_get_user_accounts_list } }; @@ -1112,21 +1124,12 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_CORE_COUNTERS: BIND_ACTION_GET_TITLE(cbs, action_get_core_counters_list); break; - case MENU_LABEL_DEFERRED_RECORDING_SETTINGS_LIST: - BIND_ACTION_GET_TITLE(cbs, action_get_recording_settings_list); - break; case MENU_LABEL_CONTENT_COLLECTION_LIST: BIND_ACTION_GET_TITLE(cbs, action_get_title_collection); break; case MENU_LABEL_REMAP_FILE_LOAD: BIND_ACTION_GET_TITLE(cbs, action_get_title_remap_file_load); break; - case MENU_LABEL_DEFERRED_ACCOUNTS_CHEEVOS_LIST: - BIND_ACTION_GET_TITLE(cbs, action_get_user_accounts_cheevos_list); - break; - case MENU_LABEL_DEFERRED_ACCOUNTS_LIST: - BIND_ACTION_GET_TITLE(cbs, action_get_user_accounts_list); - break; default: return -1; } diff --git a/msg_hash.h b/msg_hash.h index d7984fcba6..f9eb5e2539 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1762,9 +1762,6 @@ enum msg_hash_enums #define MENU_LABEL_DEFERRED_RDB_ENTRY_DETAIL 0xc35416c0U #define MENU_LABEL_DEFERRED_RPL_ENTRY_ACTIONS 0x358a7494U #define MENU_LABEL_DEFERRED_CORE_LIST 0xf157d289U -#define MENU_LABEL_DEFERRED_RECORDING_SETTINGS_LIST 0x05548d52U -#define MENU_LABEL_DEFERRED_ACCOUNTS_CHEEVOS_LIST 0x1322324cU -#define MENU_LABEL_DEFERRED_ACCOUNTS_LIST 0x3d2b8860U #define MENU_LABEL_DEFERRED_ARCHIVE_ACTION_DETECT_CORE 0xdc9c0064U #define MENU_LABEL_DEFERRED_ARCHIVE_ACTION 0x7faf0284U #define MENU_LABEL_DEFERRED_ARCHIVE_OPEN_DETECT_CORE 0xd9452498U From 934d5782a79b4e8ad74c8423a4b92ff4075e9e63 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 6 Feb 2018 21:42:06 +0100 Subject: [PATCH 147/232] Cleanups --- msg_hash.h | 1 - 1 file changed, 1 deletion(-) diff --git a/msg_hash.h b/msg_hash.h index f9eb5e2539..ed2a09e497 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1767,7 +1767,6 @@ enum msg_hash_enums #define MENU_LABEL_DEFERRED_ARCHIVE_OPEN_DETECT_CORE 0xd9452498U #define MENU_LABEL_DEFERRED_ARCHIVE_OPEN 0xfa0938b8U #define MENU_LABEL_DEFERRED_LAKKA_LIST 0x3db437c4U -#define MENU_LABEL_DEFERRED_BROWSE_URL_START 0xcef58296U #define MENU_LABEL_RDB_ENTRY_START_CONTENT 0x95025a55U From 5202afb173fe0fdb30b41ed896cbdc5b5653dbc1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 6 Feb 2018 21:55:49 +0100 Subject: [PATCH 148/232] Get rid of more hashes --- menu/cbs/menu_cbs_deferred_push.c | 33 ++++++++++++--------- menu/cbs/menu_cbs_ok.c | 48 +++++++++++++------------------ menu/cbs/menu_cbs_title.c | 21 ++++++++------ msg_hash.h | 4 --- 4 files changed, 51 insertions(+), 55 deletions(-) diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index a14c6ce58a..1f3df6359b 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -826,11 +826,26 @@ static struct cbs_deferred_lbl_callback cbs_deferred_lbl_list[] = { { MENU_ENUM_LABEL_DEFERRED_ACCOUNTS_CHEEVOS_LIST, deferred_push_accounts_cheevos_list + }, +#ifdef HAVE_LIBRETRODB + { + MENU_ENUM_LABEL_DEFERRED_CURSOR_MANAGER_LIST, + deferred_push_cursor_manager_list_deferred + }, +#endif + { + MENU_ENUM_LABEL_DEFERRED_CORE_LIST, + deferred_push_core_list_deferred } }; static struct cbs_deferred_lbl_callback cbs_deferred2_lbl_list[] = { #ifdef HAVE_NETWORKING + { + MENU_ENUM_LABEL_DEFERRED_LAKKA_LIST, + deferred_push_lakka_list + + }, { MENU_ENUM_LABEL_DEFERRED_CORE_UPDATER_LIST, deferred_push_core_updater_list @@ -939,6 +954,10 @@ static struct cbs_deferred_lbl_callback cbs_deferred2_lbl_list[] = { { MENU_ENUM_LABEL_ADD_CONTENT_LIST, deferred_push_add_content_list + }, + { + MENU_ENUM_LABEL_DEFERRED_DATABASE_MANAGER_LIST, + deferred_push_database_manager_list_deferred } }; @@ -1264,11 +1283,6 @@ static int menu_cbs_init_bind_deferred_push_compare_label( case MENU_LABEL_DEFERRED_ARCHIVE_OPEN: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_archive_open); break; - case MENU_LABEL_DEFERRED_LAKKA_LIST: -#ifdef HAVE_NETWORKING - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_lakka_list); -#endif - break; case MENU_LABEL_DATABASE_MANAGER_LIST: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_database_manager_list); break; @@ -1278,22 +1292,13 @@ static int menu_cbs_init_bind_deferred_push_compare_label( case MENU_LABEL_REMAP_FILE_LOAD: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_remap_file_load); break; - case MENU_LABEL_DEFERRED_CORE_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_list_deferred); - break; case MENU_LABEL_DEFERRED_CORE_LIST_SET: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_collection_list_deferred); break; case MENU_LABEL_DEFERRED_VIDEO_FILTER: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_filter); break; - case MENU_LABEL_DEFERRED_DATABASE_MANAGER_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_database_manager_list_deferred); - break; #ifdef HAVE_LIBRETRODB - case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred); - break; case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_PUBLISHER: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_publisher); break; diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index c410f4b0bf..437b9519a8 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -4463,19 +4463,14 @@ static int menu_cbs_init_bind_ok_compare_type(menu_file_list_cbs_t *cbs, else if (string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_CORE_LIST))) { BIND_ACTION_OK(cbs, action_ok_load_core); - break; } - else + else if (string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_CORE_LIST))) { - switch (menu_label_hash) - { - case MENU_LABEL_DEFERRED_CORE_LIST: - BIND_ACTION_OK(cbs, action_ok_load_core_deferred); - break; - case MENU_LABEL_DEFERRED_CORE_LIST_SET: - BIND_ACTION_OK(cbs, action_ok_core_deferred_set); - break; - } + BIND_ACTION_OK(cbs, action_ok_load_core_deferred); + } + else if (menu_label_hash == MENU_LABEL_DEFERRED_CORE_LIST_SET) + { + BIND_ACTION_OK(cbs, action_ok_core_deferred_set); } break; case FILE_TYPE_DOWNLOAD_CORE_CONTENT: @@ -4504,17 +4499,14 @@ static int menu_cbs_init_bind_ok_compare_type(menu_file_list_cbs_t *cbs, { BIND_ACTION_OK(cbs, action_ok_database_manager_list); } - else + else if (string_is_equal(menu_label, + msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_DATABASE_MANAGER_LIST))) { - switch (menu_label_hash) - { - case MENU_LABEL_DEFERRED_DATABASE_MANAGER_LIST: - BIND_ACTION_OK(cbs, action_ok_deferred_list_stub); - break; - case MENU_LABEL_DATABASE_MANAGER_LIST: - BIND_ACTION_OK(cbs, action_ok_database_manager_list); - break; - } + BIND_ACTION_OK(cbs, action_ok_deferred_list_stub); + } + else if (menu_label_hash == MENU_LABEL_DATABASE_MANAGER_LIST) + { + BIND_ACTION_OK(cbs, action_ok_database_manager_list); } break; case FILE_TYPE_RDB_ENTRY: @@ -4527,14 +4519,14 @@ static int menu_cbs_init_bind_ok_compare_type(menu_file_list_cbs_t *cbs, BIND_ACTION_OK(cbs, action_ok_netplay_lan_scan); break; case FILE_TYPE_CURSOR: - switch (menu_label_hash) + if (string_is_equal(menu_label, + msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_DATABASE_MANAGER_LIST))) { - case MENU_LABEL_DEFERRED_DATABASE_MANAGER_LIST: - BIND_ACTION_OK(cbs, action_ok_deferred_list_stub); - break; - case MENU_LABEL_CURSOR_MANAGER_LIST: - BIND_ACTION_OK(cbs, action_ok_cursor_manager_list); - break; + BIND_ACTION_OK(cbs, action_ok_deferred_list_stub); + } + else if (menu_label_hash == MENU_LABEL_CURSOR_MANAGER_LIST) + { + BIND_ACTION_OK(cbs, action_ok_cursor_manager_list); } break; case FILE_TYPE_VIDEOFILTER: diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index 441c021fbe..f9c7daebb7 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -721,6 +721,18 @@ static struct cbs_title_lbl_callback cbs_title_lbl_list[] = { { MENU_ENUM_LABEL_DEFERRED_ACCOUNTS_LIST, action_get_user_accounts_list + }, + { + MENU_ENUM_LABEL_DEFERRED_CORE_LIST, + action_get_title_deferred_core_list + }, + { + MENU_ENUM_LABEL_DEFERRED_CURSOR_MANAGER_LIST, + action_get_title_deferred_cursor_manager_list + }, + { + MENU_ENUM_LABEL_DEFERRED_DATABASE_MANAGER_LIST, + action_get_title_deferred_database_manager_list } }; @@ -1055,12 +1067,6 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, { switch (label_hash) { - case MENU_LABEL_DEFERRED_DATABASE_MANAGER_LIST: - BIND_ACTION_GET_TITLE(cbs, action_get_title_deferred_database_manager_list); - break; - case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST: - BIND_ACTION_GET_TITLE(cbs, action_get_title_deferred_cursor_manager_list); - break; case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_DEVELOPER: BIND_ACTION_GET_TITLE(cbs, action_get_title_list_rdb_entry_developer); break; @@ -1106,9 +1112,6 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_DEFERRED_RDB_ENTRY_DETAIL: BIND_ACTION_GET_TITLE(cbs, action_get_title_list_rdb_entry_database_info); break; - case MENU_LABEL_DEFERRED_CORE_LIST: - BIND_ACTION_GET_TITLE(cbs, action_get_title_deferred_core_list); - break; case MENU_LABEL_DATABASE_MANAGER_LIST: BIND_ACTION_GET_TITLE(cbs, action_get_database_manager_list); break; diff --git a/msg_hash.h b/msg_hash.h index ed2a09e497..193f4e3510 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1741,8 +1741,6 @@ enum msg_hash_enums #define MENU_LABEL_DEFERRED_VIDEO_FILTER 0x966ad201U #define MENU_LABEL_DEFERRED_CORE_LIST_SET 0xa6d5fdb4U -#define MENU_LABEL_DEFERRED_DATABASE_MANAGER_LIST 0x7c0b704fU -#define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST 0x45446638U #define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_DEVELOPER 0xcbd89be5U #define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_PUBLISHER 0x125e594dU #define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_ORIGIN 0x4ebaa767U @@ -1761,12 +1759,10 @@ enum msg_hash_enums #define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_MAX_USERS 0xbfcba816U #define MENU_LABEL_DEFERRED_RDB_ENTRY_DETAIL 0xc35416c0U #define MENU_LABEL_DEFERRED_RPL_ENTRY_ACTIONS 0x358a7494U -#define MENU_LABEL_DEFERRED_CORE_LIST 0xf157d289U #define MENU_LABEL_DEFERRED_ARCHIVE_ACTION_DETECT_CORE 0xdc9c0064U #define MENU_LABEL_DEFERRED_ARCHIVE_ACTION 0x7faf0284U #define MENU_LABEL_DEFERRED_ARCHIVE_OPEN_DETECT_CORE 0xd9452498U #define MENU_LABEL_DEFERRED_ARCHIVE_OPEN 0xfa0938b8U -#define MENU_LABEL_DEFERRED_LAKKA_LIST 0x3db437c4U #define MENU_LABEL_RDB_ENTRY_START_CONTENT 0x95025a55U From f30f5974997c08b2693efff576a1eba097367268 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 6 Feb 2018 22:04:17 +0100 Subject: [PATCH 149/232] Get rid of more hashes --- menu/cbs/menu_cbs_deferred_push.c | 14 ++++++++------ menu/cbs/menu_cbs_title.c | 14 ++++++++------ msg_hash.h | 4 ---- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index 1f3df6359b..cadd27047b 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -836,6 +836,14 @@ static struct cbs_deferred_lbl_callback cbs_deferred_lbl_list[] = { { MENU_ENUM_LABEL_DEFERRED_CORE_LIST, deferred_push_core_list_deferred + }, + { + MENU_ENUM_LABEL_CORE_COUNTERS, + deferred_push_core_counters + }, + { + MENU_ENUM_LABEL_FRONTEND_COUNTERS, + deferred_push_frontend_counters } }; @@ -1348,12 +1356,6 @@ static int menu_cbs_init_bind_deferred_push_compare_label( BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_cursor_manager_list_deferred_query_rdb_entry_releaseyear); break; #endif - case MENU_LABEL_CORE_COUNTERS: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_counters); - break; - case MENU_LABEL_FRONTEND_COUNTERS: - BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_frontend_counters); - break; case MENU_LABEL_CONTENT_COLLECTION_LIST: BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_content_collection_list); break; diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index f9c7daebb7..24dd1abae8 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -733,6 +733,14 @@ static struct cbs_title_lbl_callback cbs_title_lbl_list[] = { { MENU_ENUM_LABEL_DEFERRED_DATABASE_MANAGER_LIST, action_get_title_deferred_database_manager_list + }, + { + MENU_ENUM_LABEL_FRONTEND_COUNTERS, + action_get_frontend_counters_list + }, + { + MENU_ENUM_LABEL_CORE_COUNTERS, + action_get_core_counters_list } }; @@ -1121,12 +1129,6 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_LOAD_CONTENT_SPECIAL: BIND_ACTION_GET_TITLE(cbs, action_get_load_content_special); break; - case MENU_LABEL_FRONTEND_COUNTERS: - BIND_ACTION_GET_TITLE(cbs, action_get_frontend_counters_list); - break; - case MENU_LABEL_CORE_COUNTERS: - BIND_ACTION_GET_TITLE(cbs, action_get_core_counters_list); - break; case MENU_LABEL_CONTENT_COLLECTION_LIST: BIND_ACTION_GET_TITLE(cbs, action_get_title_collection); break; diff --git a/msg_hash.h b/msg_hash.h index 193f4e3510..8d1e8f53d3 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1737,8 +1737,6 @@ enum msg_hash_enums MSG_LAST }; -/* Deferred */ - #define MENU_LABEL_DEFERRED_VIDEO_FILTER 0x966ad201U #define MENU_LABEL_DEFERRED_CORE_LIST_SET 0xa6d5fdb4U #define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_DEVELOPER 0xcbd89be5U @@ -1766,8 +1764,6 @@ enum msg_hash_enums #define MENU_LABEL_RDB_ENTRY_START_CONTENT 0x95025a55U -#define MENU_LABEL_FRONTEND_COUNTERS 0xe5696877U -#define MENU_LABEL_CORE_COUNTERS 0x64cc83e0U #define MENU_LABEL_DATABASE_MANAGER_LIST 0x7f853d8fU #define MENU_LABEL_CURSOR_MANAGER_LIST 0xa969e378U #define MENU_LABEL_REMAP_FILE_LOAD 0x9c2799b8U From 35300bf08b5dd8ba47e8a54d6867b4214028320c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 7 Feb 2018 01:10:14 +0100 Subject: [PATCH 150/232] UINT32_MAX not defined on random platforms even though we are including stdint - just resort to dropping in real value instead --- deps/SPIRV-Cross/spirv_msl.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/SPIRV-Cross/spirv_msl.hpp b/deps/SPIRV-Cross/spirv_msl.hpp index c9a1820485..6187585577 100644 --- a/deps/SPIRV-Cross/spirv_msl.hpp +++ b/deps/SPIRV-Cross/spirv_msl.hpp @@ -65,7 +65,7 @@ using MSLStructMemberKey = uint64_t; // Special constant used in a MSLResourceBinding desc_set // element to indicate the bindings for the push constants. -static const uint32_t kPushConstDescSet = UINT32_MAX; +static const uint32_t kPushConstDescSet = ((uint32_t)-1); // Special constant used in a MSLResourceBinding binding // element to indicate the bindings for the push constants. From ee9c786297294e425450bbb47696e6b720f9dff6 Mon Sep 17 00:00:00 2001 From: radius Date: Tue, 6 Feb 2018 22:05:21 -0500 Subject: [PATCH 151/232] add missing bundle files --- pkg/emscripten/libretro/browserfs.min.js | 10 +++++++ pkg/emscripten/libretro/indexer | 35 ++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 pkg/emscripten/libretro/browserfs.min.js create mode 100644 pkg/emscripten/libretro/indexer diff --git a/pkg/emscripten/libretro/browserfs.min.js b/pkg/emscripten/libretro/browserfs.min.js new file mode 100644 index 0000000000..181710b74a --- /dev/null +++ b/pkg/emscripten/libretro/browserfs.min.js @@ -0,0 +1,10 @@ +!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.BrowserFS=a()}}(function(){var a;return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g-1&&a%1==0&&a<=Bb}function q(a){return null!=a&&p(Ab(a))&&!f(a)}function r(){}function s(a){return function(){if(null!==a){var b=a;a=null,b.apply(this,arguments)}}}function t(a){return Cb&&a[Cb]&&a[Cb]()}function u(a){return Db(Object(a))}function v(a,b){return null!=a&&(Fb.call(a,b)||"object"==typeof a&&b in a&&null===u(a))}function w(a){return Gb(Object(a))}function x(a,b){for(var c=-1,d=Array(a);++c-1&&a%1==0&&a0&&(c=b.apply(this,arguments)),a<=1&&(b=void 0),c}}function O(a){return N(2,a)}function P(a,b,c){function d(a){a?c(a):++f===g&&c(null)}c=O(c||r);var e=0,f=0,g=a.length;for(0===g&&c(null);e1?e(n,d):e(d)}}function i(){for(var a,b=0;u.length;)a=u.pop(),b++,V(j(a),function(a){0===--v[a]&&u.push(a)});if(b!==m)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}function j(b){var c=[];return X(a,function(a,d){Mb(a)&&Z(a,b,0)>=0&&c.push(d)}),c}"function"==typeof b&&(c=b,b=null),c=s(c||r);var k=E(a),m=k.length;if(!m)return c(null);b||(b=m);var n={},o=0,p=!1,q={},t=[],u=[],v={};X(a,function(b,c){if(!Mb(b))return d(c,[b]),void u.push(c);var e=b.slice(0,b.length-1),g=e.length;return 0===g?(d(c,b),void u.push(c)):(v[c]=g,void V(e,function(h){if(!a[h])throw new Error("async.auto task `"+c+"` has a non-existent dependency in "+e.join(", "));f(h,function(){g--,0===g&&d(c,b)})}))}),i(),e()}function _(a,b){for(var c=-1,d=a?a.length:0,e=Array(d);++ce?0:e+b),c=c>e?e:c,c<0&&(c+=e),e=b>c?0:c-b>>>0,b>>>=0;for(var f=Array(e);++d=d?a:da(a,b,c)}function fa(a,b){for(var c=a.length;c--&&Z(b,a[c],0)>-1;);return c}function ga(a,b){for(var c=-1,d=a.length;++c-1;);return c}function ha(a){return a.match(zc)}function ia(a){return null==a?"":ca(a)}function ja(a,b,c){if(a=ia(a),a&&(c||void 0===b))return a.replace(Ac,"");if(!a||!(b=ca(b)))return a;var d=ha(a),e=ha(b),f=ga(d,e),g=fa(d,e)+1;return ea(d,f,g).join("")}function ka(a){return a=a.toString().replace(Ec,""),a=a.match(Bc)[2].replace(" ",""),a=a?a.split(Cc):[],a=a.map(function(a){return ja(a.replace(Dc,""))})}function la(a,b){var c={};X(a,function(a,b){function d(b,c){var d=_(e,function(a){return b[a]});d.push(c),a.apply(null,d)}var e;if(Mb(a))e=aa(a),a=e.pop(),c[b]=e.concat(e.length>0?d:a);else if(1===a.length)c[b]=a;else{if(e=ka(a),0===a.length&&0===e.length)throw new Error("autoInject task functions require explicit parameters.");e.pop(),c[b]=e.concat(d)}}),$(c,b)}function ma(a){setTimeout(a,0)}function na(a){return l(function(b,c){a(function(){b.apply(null,c)})})}function oa(){this.head=this.tail=null,this.length=0}function pa(a,b){a.length=1,a.head=a.tail=b}function qa(a,b,c){function d(a,b,c){if(null!=c&&"function"!=typeof c)throw new Error("task callback must be a function");return h.started=!0,Mb(a)||(a=[a]),0===a.length&&h.idle()?Hc(function(){h.drain()}):(V(a,function(a){var d={data:a,callback:c||r};b?h._tasks.unshift(d):h._tasks.push(d)}),void Hc(h.process))}function e(a){return l(function(b){f-=1,V(a,function(a){V(g,function(b,c){if(b===a)return g.splice(c,1),!1}),a.callback.apply(a,b),null!=b[0]&&h.error(b[0],a.data)}),f<=h.concurrency-h.buffer&&h.unsaturated(),h.idle()&&h.drain(),h.process()})}if(null==b)b=1;else if(0===b)throw new Error("Concurrency must not be zero");var f=0,g=[],h={_tasks:new oa,concurrency:b,payload:c,saturated:r,unsaturated:r,buffer:b/4,empty:r,drain:r,error:r,started:!1,paused:!1,push:function(a,b){d(a,!1,b)},kill:function(){h.drain=r,h._tasks.empty()},unshift:function(a,b){d(a,!0,b)},process:function(){for(;!h.paused&&f3?(g=g||r,a(d,e,i,h)):(g=f,g=g||r,f=e,a(d,i,h))}}function xa(a,b){return b}function ya(a){return l(function(b,c){b.apply(null,c.concat([l(function(b,c){"object"==typeof console&&(b?console.error&&console.error(b):console[a]&&V(c,function(b){console[a](b)}))})]))})}function za(a,b,c){function d(b,d){return b?c(b):d?void a(e):c(null)}c=J(c||r);var e=l(function(a,e){return a?c(a):(e.push(d),void b.apply(this,e))});d(null,!0)}function Aa(a,b,c){c=J(c||r);var d=l(function(e,f){return e?c(e):b.apply(this,f)?a(d):void c.apply(null,[null].concat(f))});a(d)}function Ba(a,b,c){Aa(a,function(){return!b.apply(this,arguments)},c)}function Ca(a,b,c){function d(b){return b?c(b):void a(e)}function e(a,e){return a?c(a):e?void b(d):c(null)}c=J(c||r),a(e)}function Da(a){return function(b,c,d){return a(b,d)}}function Ea(a,b,c){Q(a,Da(b),c)}function Fa(a,b,c,d){K(b)(a,Da(c),d)}function Ga(a){return m(function(b,c){var d=!0;b.push(function(){var a=arguments;d?Hc(function(){c.apply(null,a)}):c.apply(null,a)}),a.apply(this,b),d=!1})}function Ha(a){return!a}function Ia(a,b,c,d){d=s(d||r);var e=[];a(b,function(a,b,d){c(a,function(c,f){c?d(c):(f&&e.push({index:b,value:a}),d())})},function(a){a?d(a):d(null,_(e.sort(function(a,b){return a.index-b.index}),o("value")))})}function Ja(a,b){function c(a){return a?d(a):void e(c)}var d=J(b||r),e=Ga(a);c()}function Ka(a,b,c,d){d=s(d||r);var e={};L(a,b,function(a,b,d){c(a,b,function(a,c){return a?d(a):(e[b]=c,void d())})},function(a){d(a,e)})}function La(a,b){return b in a}function Ma(a,b){var c=Object.create(null),d=Object.create(null);b=b||va;var e=m(function(e,f){var g=b.apply(null,e);La(c,g)?Hc(function(){f.apply(null,c[g])}):La(d,g)?d[g].push(f):(d[g]=[f],a.apply(null,e.concat([l(function(a){c[g]=a;var b=d[g];delete d[g];for(var e=0,f=b.length;e=e.priority;)e=e.next;V(a,function(a){var f={data:a,priority:b,callback:d};e?c._tasks.insertBefore(e,f):c._tasks.push(f)}),Hc(c.process)},delete c.unshift,c}function Sa(a,b){return b=s(b||r),Mb(a)?a.length?void V(a,function(a){a(b)}):b():b(new TypeError("First argument to race must be an array of functions"))}function Ta(a,b,c,d){var e=cd.call(a).reverse();sa(e,b,c,d)}function Ua(a){return m(function(b,c){return b.push(l(function(a,b){if(a)c(null,{error:a});else{var d=null;1===b.length?d=b[0]:b.length>1&&(d=b),c(null,{value:d})}})),a.apply(this,b)})}function Va(a,b,c,d){Ia(a,b,function(a,b){c(a,function(a,c){a?b(a):b(null,!c)})},d)}function Wa(a){var b;return Mb(a)?b=_(a,Ua):(b={},X(a,function(a,c){b[c]=Ua.call(this,a)})),b}function Xa(a){return function(){return a}}function Ya(a,b,c){function d(a,b){if("object"==typeof b)a.times=+b.times||f,a.intervalFunc="function"==typeof b.interval?b.interval:Xa(+b.interval||g);else{if("number"!=typeof b&&"string"!=typeof b)throw new Error("Invalid arguments for async.retry");a.times=+b||f}}function e(){b(function(a){a&&i++d?1:0}Vb(a,function(a,c){b(a,function(b,d){return b?c(b):void c(null,{value:a,criteria:d})})},function(a,b){return a?c(a):void c(null,_(b.sort(d),o("value")))})}function ab(a,b,c){function d(){h||(f.apply(null,arguments),clearTimeout(g))}function e(){var b=a.name||"anonymous",d=new Error('Callback function "'+b+'" timed out.');d.code="ETIMEDOUT",c&&(d.info=c),h=!0,f(d)}var f,g,h=!1;return m(function(c,h){f=h,g=setTimeout(e,b),a.apply(null,c.concat(d))})}function bb(a,b,c,d){for(var e=-1,f=kd(jd((b-a)/(c||1)),0),g=Array(f);f--;)g[d?f:++e]=a,a+=c;return g}function cb(a,b,c,d){Xb(bb(0,a,1),b,c,d)}function db(a,b,c,d){3===arguments.length&&(d=c,c=b,b=Mb(a)?[]:{}),d=s(d||r),Q(a,function(a,d,e){c(b,a,d,e)},function(a){d(a,b)})}function eb(a){return function(){return(a.unmemoized||a).apply(null,arguments)}}function fb(a,b,c){if(c=J(c||r),!a())return c(null);var d=l(function(e,f){return e?c(e):a()?b(d):void c.apply(null,[null].concat(f))});b(d)}function gb(a,b,c){fb(function(){return!a.apply(this,arguments)},b,c)}function hb(a,b){function c(e){if(d===a.length)return b.apply(null,[null].concat(e));var f=J(l(function(a,d){return a?b.apply(null,[a].concat(d)):void c(d)}));e.push(f);var g=a[d++];g.apply(null,e)}if(b=s(b||r),!Mb(a))return b(new Error("First argument to waterfall must be an array of functions"));if(!a.length)return b();var d=0;c([])}var ib,jb="[object Function]",kb="[object GeneratorFunction]",lb=Object.prototype,mb=lb.toString,nb="[object Symbol]",ob=Object.prototype,pb=ob.toString,qb=NaN,rb=/^\s+|\s+$/g,sb=/^[-+]0x[0-9a-f]+$/i,tb=/^0b[01]+$/i,ub=/^0o[0-7]+$/i,vb=parseInt,wb=1/0,xb=1.7976931348623157e308,yb="Expected a function",zb=Math.max,Ab=o("length"),Bb=9007199254740991,Cb="function"==typeof Symbol&&Symbol.iterator,Db=Object.getPrototypeOf,Eb=Object.prototype,Fb=Eb.hasOwnProperty,Gb=Object.keys,Hb="[object Arguments]",Ib=Object.prototype,Jb=Ib.hasOwnProperty,Kb=Ib.toString,Lb=Ib.propertyIsEnumerable,Mb=Array.isArray,Nb="[object String]",Ob=Object.prototype,Pb=Ob.toString,Qb=9007199254740991,Rb=/^(?:0|[1-9]\d*)$/,Sb=Object.prototype,Tb="Expected a function",Ub=M(L,1/0),Vb=R(S),Wb=n(Vb),Xb=T(S),Yb=M(Xb,1),Zb=n(Yb),$b=l(function(a,b){return l(function(c){return a.apply(null,b.concat(c))})}),_b=W(),ac=ba("object"==typeof e&&e),bc=ba("object"==typeof self&&self),cc=ba("object"==typeof this&&this),dc=ac||bc||cc||Function("return this")(),ec=dc.Symbol,fc=1/0,gc=ec?ec.prototype:void 0,hc=gc?gc.toString:void 0,ic="\\ud800-\\udfff",jc="\\u0300-\\u036f\\ufe20-\\ufe23",kc="\\u20d0-\\u20f0",lc="\\ufe0e\\ufe0f",mc="["+ic+"]",nc="["+jc+kc+"]",oc="\\ud83c[\\udffb-\\udfff]",pc="(?:"+nc+"|"+oc+")",qc="[^"+ic+"]",rc="(?:\\ud83c[\\udde6-\\uddff]){2}",sc="[\\ud800-\\udbff][\\udc00-\\udfff]",tc="\\u200d",uc=pc+"?",vc="["+lc+"]?",wc="(?:"+tc+"(?:"+[qc,rc,sc].join("|")+")"+vc+uc+")*",xc=vc+uc+wc,yc="(?:"+[qc+nc+"?",nc,rc,sc,mc].join("|")+")",zc=RegExp(oc+"(?="+oc+")|"+yc+xc,"g"),Ac=/^\s+|\s+$/g,Bc=/^(function)?\s*[^\(]*\(\s*([^\)]*)\)/m,Cc=/,/,Dc=/(=.+)?(\s*)$/,Ec=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm,Fc="function"==typeof setImmediate&&setImmediate,Gc="object"==typeof b&&"function"==typeof b.nextTick;ib=Fc?setImmediate:Gc?b.nextTick:ma;var Hc=na(ib);oa.prototype.removeLink=function(a){return a.prev?a.prev.next=a.next:this.head=a.next,a.next?a.next.prev=a.prev:this.tail=a.prev,a.prev=a.next=null,this.length-=1,a},oa.prototype.empty=oa,oa.prototype.insertAfter=function(a,b){b.prev=a,b.next=a.next,a.next?a.next.prev=b:this.tail=b,a.next=b,this.length+=1},oa.prototype.insertBefore=function(a,b){b.prev=a.prev,b.next=a,a.prev?a.prev.next=b:this.head=b,a.prev=b,this.length+=1},oa.prototype.unshift=function(a){this.head?this.insertBefore(this.head,a):pa(this,a)},oa.prototype.push=function(a){this.tail?this.insertAfter(this.tail,a):pa(this,a)},oa.prototype.shift=function(){return this.head&&this.removeLink(this.head)},oa.prototype.pop=function(){return this.tail&&this.removeLink(this.tail)};var Ic,Jc=M(L,1),Kc=l(function(a){return l(function(b){var c=this,d=b[b.length-1];"function"==typeof d?b.pop():d=r,sa(a,b,function(a,b,d){b.apply(c,a.concat([l(function(a,b){d(a,b)})]))},function(a,b){d.apply(c,[a].concat(b))})})}),Lc=l(function(a){return Kc.apply(null,a.reverse())}),Mc=R(ta),Nc=ua(ta),Oc=l(function(a){var b=[null].concat(a);return m(function(a,c){return c.apply(this,b)})}),Pc=wa(Q,va,xa),Qc=wa(L,va,xa),Rc=wa(Jc,va,xa),Sc=ya("dir"),Tc=M(Fa,1),Uc=wa(Q,Ha,Ha),Vc=wa(L,Ha,Ha),Wc=M(Vc,1),Xc=R(Ia),Yc=T(Ia),Zc=M(Yc,1),$c=ya("log"),_c=M(Ka,1/0),ad=M(Ka,1);Ic=Gc?b.nextTick:Fc?setImmediate:ma;var bd=na(Ic),cd=Array.prototype.slice,dd=R(Va),ed=T(Va),fd=M(ed,1),gd=wa(Q,Boolean,va),hd=wa(L,Boolean,va),id=M(hd,1),jd=Math.ceil,kd=Math.max,ld=M(cb,1/0),md=M(cb,1),nd={applyEach:Wb,applyEachSeries:Zb,apply:$b,asyncify:U,auto:$,autoInject:la,cargo:ra,compose:Lc,concat:Mc,concatSeries:Nc,constant:Oc,detect:Pc,detectLimit:Qc,detectSeries:Rc,dir:Sc,doDuring:za,doUntil:Ba,doWhilst:Aa,during:Ca,each:Ea,eachLimit:Fa,eachOf:Q,eachOfLimit:L,eachOfSeries:Jc,eachSeries:Tc,ensureAsync:Ga,every:Uc,everyLimit:Vc,everySeries:Wc,filter:Xc,filterLimit:Yc,filterSeries:Zc,forever:Ja,log:$c,map:Vb,mapLimit:Xb,mapSeries:Yb,mapValues:_c,mapValuesLimit:Ka,mapValuesSeries:ad,memoize:Ma,nextTick:bd,parallel:Oa,parallelLimit:Pa,priorityQueue:Ra,queue:Qa,race:Sa,reduce:sa,reduceRight:Ta,reflect:Ua,reflectAll:Wa,reject:dd,rejectLimit:ed,rejectSeries:fd,retry:Ya,retryable:Za,seq:Kc,series:$a,setImmediate:Hc,some:gd,someLimit:hd,someSeries:id,sortBy:_a,timeout:ab,times:ld,timesLimit:cb,timesSeries:md,transform:db,unmemoize:eb,until:gb,waterfall:hb,whilst:fb,all:Uc,any:gd,forEach:Ea,forEachSeries:Tc,forEachLimit:Fa,forEachOf:Q,forEachOfSeries:Jc,forEachOfLimit:L,inject:sa,foldl:sa,foldr:Ta,select:Xc,selectLimit:Yc,selectSeries:Zc,wrapSync:U};a.default=nd,a.applyEach=Wb,a.applyEachSeries=Zb,a.apply=$b,a.asyncify=U,a.auto=$,a.autoInject=la,a.cargo=ra,a.compose=Lc,a.concat=Mc,a.concatSeries=Nc,a.constant=Oc,a.detect=Pc,a.detectLimit=Qc,a.detectSeries=Rc,a.dir=Sc,a.doDuring=za,a.doUntil=Ba,a.doWhilst=Aa,a.during=Ca,a.each=Ea,a.eachLimit=Fa,a.eachOf=Q,a.eachOfLimit=L,a.eachOfSeries=Jc,a.eachSeries=Tc,a.ensureAsync=Ga,a.every=Uc,a.everyLimit=Vc,a.everySeries=Wc,a.filter=Xc,a.filterLimit=Yc,a.filterSeries=Zc,a.forever=Ja,a.log=$c,a.map=Vb,a.mapLimit=Xb,a.mapSeries=Yb,a.mapValues=_c,a.mapValuesLimit=Ka,a.mapValuesSeries=ad,a.memoize=Ma,a.nextTick=bd,a.parallel=Oa,a.parallelLimit=Pa,a.priorityQueue=Ra,a.queue=Qa,a.race=Sa,a.reduce=sa,a.reduceRight=Ta,a.reflect=Ua,a.reflectAll=Wa,a.reject=dd,a.rejectLimit=ed,a.rejectSeries=fd,a.retry=Ya,a.retryable=Za,a.seq=Kc,a.series=$a,a.setImmediate=Hc,a.some=gd,a.someLimit=hd,a.someSeries=id,a.sortBy=_a,a.timeout=ab,a.times=ld,a.timesLimit=cb,a.timesSeries=md,a.transform=db,a.unmemoize=eb,a.until=gb,a.waterfall=hb,a.whilst=fb,a.all=Uc,a.allLimit=Vc,a.allSeries=Wc,a.any=gd,a.anyLimit=hd,a.anySeries=id,a.find=Pc,a.findLimit=Qc,a.findSeries=Rc,a.forEach=Ea,a.forEachSeries=Tc,a.forEachLimit=Fa,a.forEachOf=Q,a.forEachOfSeries=Jc,a.forEachOfLimit=L,a.inject=sa,a.foldl=sa,a.foldr=Ta,a.select=Xc,a.selectLimit=Yc,a.selectSeries=Zc,a.wrapSync=U})}).call(this,b("bfs-process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"bfs-process":11}],2:[function(a,b,c){"use strict";function d(a,b,c,d,e,f){if(b>e||ba.length)throw new RangeError("index out of range")}function e(a,b,c,d){if(c+d>a.length)throw new RangeError("index out of range")}function f(a,b,c){if(a+b>c)throw new RangeError("index out of range")}var g=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)},h=a("./buffer_core"),i=a("./buffer_core_array"),j=a("./buffer_core_arraybuffer"),k=a("./buffer_core_imagedata"),l=a("./string_util"),m=a("./util"),n=[j,k,i],o=function(){var a,b;for(a=0;a>>0)throw new RangeError("Buffer size must be a uint32.");this.length=b,this.data=new o(b)}else if(m.isArrayBufferView(b))this.data=new j(b),this.length=b.byteLength;else if(m.isArrayBuffer(b))this.data=new j(b),this.length=b.byteLength;else if(b instanceof a){var i=b;this.data=new o(b.length),this.length=b.length,i.copy(this)}else if(Array.isArray(b)||null!=b&&"object"==typeof b&&"number"==typeof b[0]){for(this.data=new o(b.length),e=0;ethis.length||c<0)throw new RangeError("Invalid offset.");var f=l.FindUtil(e);return d=d+c>this.length?this.length-c:d,c+=this.offset,f.str2byte(b,0===c&&d===this.length?this:new a(this.data,c,d+c))},a.prototype.toString=function(b,c,d){if(void 0===b&&(b="utf8"),void 0===c&&(c=0),void 0===d&&(d=this.length),!(c<=d))throw new Error("Invalid start/end positions: "+c+" - "+d);if(c===d)return"";d>this.length&&(d=this.length);var e=l.FindUtil(b);return e.byte2str(0===c&&d===this.length?this:new a(this.data,c+this.offset,d+this.offset))},a.prototype.toJSON=function(){for(var a=this.length,b=new Array(a),c=0;cd?" ... ":"")+">"},a.prototype.toArrayBuffer=function(){var b=this.getBufferCore();if(b instanceof j){var c=b.getDataView(),d=c.buffer;return 0===this.offset&&0===c.byteOffset&&c.byteLength===d.byteLength&&this.length===c.byteLength?d:d.slice(this.offset+c.byteOffset,this.length)}var d=new ArrayBuffer(this.length),e=new a(d);return this.copy(e,0,0,this.length),d},a.prototype.toUint8Array=function(){var b=this.getBufferCore();if(b instanceof j){var c=b.getDataView(),d=c.buffer,e=this.offset+c.byteOffset,f=this.length;return new Uint8Array(d).subarray(e,e+f)}var d=new ArrayBuffer(this.length),g=new a(d);return this.copy(g,0,0,this.length),new Uint8Array(d)},a.prototype.indexOf=function(b,c){void 0===c&&(c=0);var d;if("string"==typeof b)d=new a(b,"utf8");else if(a.isBuffer(b))d=b;else{if("number"!=typeof b)throw new TypeError("indexOf only operates on strings, buffers, and numbers.");d=new a([b])}c>2147483647?c=2147483647:c<-2147483648&&(c=-2147483648),c>>=0,c<0&&(c=this.length+c,c<0&&(c=0));var e=0,f=d.length,g=this.length;if(0===f)return-1;for(;e=this.length||c>b.length)return 0;var f=Math.min(e-d,b.length-c,this.length-d);if(b instanceof a&&this.data instanceof j){var g=b.getBufferCore();if(g instanceof j)return this.data.copyTo(g,c+b.offset,d+this.offset,d+f+this.offset)}for(var h=0;h>=0,c>>=0,b<0&&(b+=this.length,b<0&&(b=0)),c<0&&(c+=this.length,c<0&&(c=0)),c>this.length&&(c=this.length),b>c&&(b=c),b<0||c<0||b>this.length||c>this.length)throw new Error("Invalid slice indices.");return new a(this.data,b+this.offset,c+this.offset)},a.prototype.sliceCopy=function(b,c){if(void 0===b&&(b=0),void 0===c&&(c=this.length),b<0&&(b+=this.length,b<0&&(b=0)),c<0&&(c+=this.length,c<0&&(c=0)),c>this.length&&(c=this.length),b>c&&(b=c),b<0||c<0||b>=this.length||c>this.length)throw new Error("Invalid slice indices.");return new a(this.data.copy(b+this.offset,c+this.offset))},a.prototype.fill=function(b,c,d){void 0===c&&(c=0),void 0===d&&(d=this.length);if(c>>=0,d>>=0,c<0||d>this.length)throw new RangeError("out of range index");if(d<=c)return this;if("string"!=typeof b)b>>>=0;else if(1===b.length){var e=b.charCodeAt(0);e<256&&(b=e)}if("number"==typeof b)c+=this.offset,d+=this.offset,this.data.fill(b,c,d);else if(b.length>0){for(var f=a.byteLength(b,"utf8"),g=d-f;c>>=0,b>>>=0,c||f(a,b,this.length),a+=this.offset;var d=0;switch(b){case 1:return this.data.readUInt8(a);case 2:return this.data.readUInt16LE(a);case 3:return this.data.readUInt8(a)|this.data.readUInt16LE(a+1)<<8;case 4:return this.data.readUInt32LE(a);case 6:d+=131072*(this.data.readUInt8(a+5)<<23);case 5:return d+=512*(this.data.readUInt8(a+4)<<23),d+this.data.readUInt32LE(a);default:throw new Error("Invalid byteLength: "+b)}},a.prototype.readUIntBE=function(a,b,c){void 0===c&&(c=!1),a>>>=0,b>>>=0,c||f(a,b,this.length),a+=this.offset;var d=0;switch(b){case 1:return this.data.readUInt8(a);case 2:return this.data.readUInt16BE(a);case 3:return this.data.readUInt8(a+2)|this.data.readUInt16BE(a)<<8;case 4:return this.data.readUInt32BE(a);case 6:d+=131072*(this.data.readUInt8(a)<<23),a++;case 5:return d+=512*(this.data.readUInt8(a)<<23),d+this.data.readUInt32BE(a+1);default:throw new Error("Invalid byteLength: "+b)}},a.prototype.readIntLE=function(a,b,c){switch(void 0===c&&(c=!1),a>>>=0,b>>>=0,c||f(a,b,this.length),a+=this.offset,b){case 1:return this.data.readInt8(a);case 2:return this.data.readInt16LE(a);case 3:return this.data.readUInt8(a)|this.data.readInt16LE(a+1)<<8;case 4:return this.data.readInt32LE(a);case 6:return 131072*(this.data.readInt8(a+5)<<23)+this.readUIntLE(a-this.offset,5,c);case 5:return 512*(this.data.readInt8(a+4)<<23)+this.data.readUInt32LE(a);default:throw new Error("Invalid byteLength: "+b)}},a.prototype.readIntBE=function(a,b,c){switch(void 0===c&&(c=!1),a>>>=0,b>>>=0,c||f(a,b,this.length),a+=this.offset,b){case 1:return this.data.readInt8(a);case 2:return this.data.readInt16BE(a);case 3:return this.data.readUInt8(a+2)|this.data.readInt16BE(a)<<8;case 4:return this.data.readInt32BE(a);case 6:return 131072*(this.data.readInt8(a)<<23)+this.readUIntBE(a-this.offset+1,5,c);case 5:return 512*(this.data.readInt8(a)<<23)+this.data.readUInt32BE(a+1);default:throw new Error("Invalid byteLength: "+b)}},a.prototype.readUInt8=function(a,b){return void 0===b&&(b=!1),a>>>=0,b||f(a,1,this.length),a+=this.offset,this.data.readUInt8(a)},a.prototype.readUInt16LE=function(a,b){return void 0===b&&(b=!1),a>>>=0,b||f(a,2,this.length),a+=this.offset,this.data.readUInt16LE(a)},a.prototype.readUInt16BE=function(a,b){return void 0===b&&(b=!1),a>>>=0,b||f(a,2,this.length),a+=this.offset,this.data.readUInt16BE(a)},a.prototype.readUInt32LE=function(a,b){return void 0===b&&(b=!1),a>>>=0,b||f(a,4,this.length),a+=this.offset,this.data.readUInt32LE(a)},a.prototype.readUInt32BE=function(a,b){return void 0===b&&(b=!1),a>>>=0,b||f(a,4,this.length),a+=this.offset,this.data.readUInt32BE(a)},a.prototype.readInt8=function(a,b){return void 0===b&&(b=!1),a>>>=0,b||f(a,1,this.length),a+=this.offset,this.data.readInt8(a)},a.prototype.readInt16LE=function(a,b){return void 0===b&&(b=!1),a>>>=0,b||f(a,2,this.length),a+=this.offset,this.data.readInt16LE(a)},a.prototype.readInt16BE=function(a,b){return void 0===b&&(b=!1),a>>>=0,b||f(a,2,this.length),a+=this.offset,this.data.readInt16BE(a)},a.prototype.readInt32LE=function(a,b){return void 0===b&&(b=!1),a>>>=0,b||f(a,4,this.length),a+=this.offset,this.data.readInt32LE(a)},a.prototype.readInt32BE=function(a,b){return void 0===b&&(b=!1),a>>>=0,b||f(a,4,this.length),a+=this.offset,this.data.readInt32BE(a)},a.prototype.readFloatLE=function(a,b){return void 0===b&&(b=!1),a>>>=0, +b||f(a,4,this.length),a+=this.offset,this.data.readFloatLE(a)},a.prototype.readFloatBE=function(a,b){return void 0===b&&(b=!1),a>>>=0,b||f(a,4,this.length),a+=this.offset,this.data.readFloatBE(a)},a.prototype.readDoubleLE=function(a,b){return void 0===b&&(b=!1),a>>>=0,b||f(a,8,this.length),a+=this.offset,this.data.readDoubleLE(a)},a.prototype.readDoubleBE=function(a,b){return void 0===b&&(b=!1),a>>>=0,b||f(a,8,this.length),a+=this.offset,this.data.readDoubleBE(a)},a.prototype.writeUIntLE=function(a,b,c,e){void 0===e&&(e=!1),b>>>=0,e||d(this,a,b,c,r[c],0);var f=b+c;switch(b+=this.offset,c){case 1:this.data.writeUInt8(b,a);break;case 2:this.data.writeUInt16LE(b,a);break;case 3:this.data.writeUInt8(b,255&a),this.data.writeUInt16LE(b+1,a>>8);break;case 4:this.data.writeUInt32LE(b,a);break;case 6:this.data.writeUInt8(b,255&a),a=Math.floor(a/256),b++;case 5:this.data.writeUInt8(b,255&a),a=Math.floor(a/256),this.data.writeUInt32LE(b+1,a);break;default:throw new Error("Invalid byteLength: "+c)}return f},a.prototype.writeUIntBE=function(a,b,c,e){void 0===e&&(e=!1),b>>>=0,e||d(this,a,b,c,r[c],0);var f=b+c;switch(b+=this.offset,c){case 1:this.data.writeUInt8(b,a);break;case 2:this.data.writeUInt16BE(b,a);break;case 3:this.data.writeUInt8(b+2,255&a),this.data.writeUInt16BE(b,a>>8);break;case 4:this.data.writeUInt32BE(b,a);break;case 6:this.data.writeUInt8(b+5,255&a),a=Math.floor(a/256);case 5:this.data.writeUInt8(b+4,255&a),a=Math.floor(a/256),this.data.writeUInt32BE(b,a);break;default:throw new Error("Invalid byteLength: "+c)}return f},a.prototype.writeIntLE=function(a,b,c,e){void 0===e&&(e=!1),b>>>=0,e||d(this,a,b,c,p[c],q[c]);var f=b+c;switch(b+=this.offset,c){case 1:this.data.writeInt8(b,a);break;case 2:this.data.writeInt16LE(b,a);break;case 3:this.data.writeUInt8(b,255&a),this.data.writeInt16LE(b+1,a>>8);break;case 4:this.data.writeInt32LE(b,a);break;case 6:this.data.writeUInt8(b,255&a),a=Math.floor(a/256),b++;case 5:this.data.writeUInt8(b,255&a),a=Math.floor(a/256),this.data.writeInt32LE(b+1,a);break;default:throw new Error("Invalid byteLength: "+c)}return f},a.prototype.writeIntBE=function(a,b,c,e){void 0===e&&(e=!1),b>>>=0,e||d(this,a,b,c,p[c],q[c]);var f=b+c;switch(b+=this.offset,c){case 1:this.data.writeInt8(b,a);break;case 2:this.data.writeInt16BE(b,a);break;case 3:this.data.writeUInt8(b+2,255&a),this.data.writeInt16BE(b,a>>8);break;case 4:this.data.writeInt32BE(b,a);break;case 6:this.data.writeUInt8(b+5,255&a),a=Math.floor(a/256);case 5:this.data.writeUInt8(b+4,255&a),a=Math.floor(a/256),this.data.writeInt32BE(b,a);break;default:throw new Error("Invalid byteLength: "+c)}return f},a.prototype.writeUInt8=function(a,b,c){return void 0===c&&(c=!1),b>>>=0,c||d(this,a,b,1,255,0),this.data.writeUInt8(b+this.offset,a),b+1},a.prototype.writeUInt16LE=function(a,b,c){return void 0===c&&(c=!1),b>>>=0,c||d(this,a,b,2,65535,0),this.data.writeUInt16LE(b+this.offset,a),b+2},a.prototype.writeUInt16BE=function(a,b,c){return void 0===c&&(c=!1),b>>>=0,c||d(this,a,b,2,65535,0),this.data.writeUInt16BE(b+this.offset,a),b+2},a.prototype.writeUInt32LE=function(a,b,c){return void 0===c&&(c=!1),b>>>=0,c||d(this,a,b,4,4294967295,0),this.data.writeUInt32LE(b+this.offset,a),b+4},a.prototype.writeUInt32BE=function(a,b,c){return void 0===c&&(c=!1),b>>>=0,c||d(this,a,b,4,4294967295,0),this.data.writeUInt32BE(b+this.offset,a),b+4},a.prototype.writeInt8=function(a,b,c){return void 0===c&&(c=!1),b>>>=0,c||d(this,a,b,1,127,-128),this.data.writeInt8(b+this.offset,a),b+1},a.prototype.writeInt16LE=function(a,b,c){return void 0===c&&(c=!1),b>>>=0,c||d(this,a,b,2,32767,-32768),this.data.writeInt16LE(b+this.offset,a),b+2},a.prototype.writeInt16BE=function(a,b,c){return void 0===c&&(c=!1),b>>>=0,c||d(this,a,b,2,32767,-32768),this.data.writeInt16BE(b+this.offset,a),b+2},a.prototype.writeInt32LE=function(a,b,c){return void 0===c&&(c=!1),b>>>=0,c||d(this,a,b,4,2147483647,-2147483648),this.data.writeInt32LE(b+this.offset,a),b+4},a.prototype.writeInt32BE=function(a,b,c){return void 0===c&&(c=!1),b>>>=0,c||d(this,a,b,4,2147483647,-2147483648),this.data.writeInt32BE(b+this.offset,a),b+4},a.prototype.writeFloatLE=function(a,b,c){return void 0===c&&(c=!1),b>>>=0,c||e(this,a,b,4),this.data.writeFloatLE(b+this.offset,a),b+4},a.prototype.writeFloatBE=function(a,b,c){return void 0===c&&(c=!1),b>>>=0,c||e(this,a,b,4),this.data.writeFloatBE(b+this.offset,a),b+4},a.prototype.writeDoubleLE=function(a,b,c){return void 0===c&&(c=!1),b>>>=0,c||e(this,a,b,8),this.data.writeDoubleLE(b+this.offset,a),b+8},a.prototype.writeDoubleBE=function(a,b,c){return void 0===c&&(c=!1),b>>>=0,c||e(this,a,b,8),this.data.writeDoubleBE(b+this.offset,a),b+8},a.isEncoding=function(a){try{l.FindUtil(a)}catch(a){return!1}return!0},a.compare=function(a,b){if(a===b)return 0;var c,d,e,f=a.length,g=b.length,h=Math.min(f,g);for(c=0;ce?1:-1;return f===g?0:f>g?1:-1},a.isBuffer=function(b){return b instanceof a},a.byteLength=function(a,b){void 0===b&&(b="utf8");var c;try{c=l.FindUtil(b)}catch(a){c=l.FindUtil("utf8")}return"string"!=typeof a&&(a=""+a),c.byteLength(a)},a.concat=function(b,c){var d;if(0===b.length||0===c)return new a(0);if(void 0===c){c=0;for(var e=0;e>>24)},a.prototype.writeInt16LE=function(a,b){this.writeUInt8(a,255&b),this.writeUInt8(a+1,b>>>8&255|(2147483648&b)>>>24)},a.prototype.writeInt16BE=function(a,b){this.writeUInt8(a+1,255&b),this.writeUInt8(a,b>>>8&255|(2147483648&b)>>>24)},a.prototype.writeInt32LE=function(a,b){this.writeUInt8(a,255&b),this.writeUInt8(a+1,b>>>8&255),this.writeUInt8(a+2,b>>>16&255),this.writeUInt8(a+3,b>>>24&255)},a.prototype.writeInt32BE=function(a,b){this.writeUInt8(a+3,255&b),this.writeUInt8(a+2,b>>>8&255),this.writeUInt8(a+1,b>>>16&255),this.writeUInt8(a,b>>>24&255)},a.prototype.writeUInt8=function(a,b){throw new Error("BufferCore implementations should implement writeUInt8.")},a.prototype.writeUInt16LE=function(a,b){this.writeUInt8(a,255&b),this.writeUInt8(a+1,b>>8&255)},a.prototype.writeUInt16BE=function(a,b){this.writeUInt8(a+1,255&b),this.writeUInt8(a,b>>8&255)},a.prototype.writeUInt32LE=function(a,b){this.writeInt32LE(a,0|b)},a.prototype.writeUInt32BE=function(a,b){this.writeInt32BE(a,0|b)},a.prototype.writeFloatLE=function(a,b){this.writeInt32LE(a,this.float2intbits(b))},a.prototype.writeFloatBE=function(a,b){this.writeInt32BE(a,this.float2intbits(b))},a.prototype.writeDoubleLE=function(a,b){var c=this.double2longbits(b);this.writeInt32LE(a,c[0]),this.writeInt32LE(a+4,c[1])},a.prototype.writeDoubleBE=function(a,b){var c=this.double2longbits(b);this.writeInt32BE(a+4,c[0]),this.writeInt32BE(a,c[1])},a.prototype.readInt8=function(a){var b=this.readUInt8(a);return 128&b?4294967168|b:b},a.prototype.readInt16LE=function(a){var b=this.readUInt16LE(a);return 32768&b?4294934528|b:b},a.prototype.readInt16BE=function(a){var b=this.readUInt16BE(a);return 32768&b?4294934528|b:b},a.prototype.readInt32LE=function(a){return 0|this.readUInt32LE(a)},a.prototype.readInt32BE=function(a){return 0|this.readUInt32BE(a)},a.prototype.readUInt8=function(a){throw new Error("BufferCore implementations should implement readUInt8.")},a.prototype.readUInt16LE=function(a){return this.readUInt8(a+1)<<8|this.readUInt8(a)},a.prototype.readUInt16BE=function(a){return this.readUInt8(a)<<8|this.readUInt8(a+1)},a.prototype.readUInt32LE=function(a){return(this.readUInt8(a+3)<<24|this.readUInt8(a+2)<<16|this.readUInt8(a+1)<<8|this.readUInt8(a))>>>0},a.prototype.readUInt32BE=function(a){return(this.readUInt8(a)<<24|this.readUInt8(a+1)<<16|this.readUInt8(a+2)<<8|this.readUInt8(a+3))>>>0},a.prototype.readFloatLE=function(a){return this.intbits2float(this.readInt32LE(a))},a.prototype.readFloatBE=function(a){return this.intbits2float(this.readInt32BE(a))},a.prototype.readDoubleLE=function(a){return this.longbits2double(this.readInt32LE(a+4),this.readInt32LE(a))},a.prototype.readDoubleBE=function(a){return this.longbits2double(this.readInt32BE(a),this.readInt32BE(a+4))},a.prototype.copy=function(a,b){throw new Error("BufferCore implementations should implement copy.")},a.prototype.fill=function(a,b,c){for(var d=b;d=1.401298464324817e-45?(b=0,c=Math.round(a/Math.pow(2,-126)*Math.pow(2,23)),d<<31|b<<23|c):(b=Math.floor(Math.log(a)/Math.LN2),c=Math.round((a/Math.pow(2,b)-1)*Math.pow(2,23)),d<<31|b+127<<23|c))},a.prototype.double2longbits=function(a){var b,c,d,e;return 0===a?[0,0]:a===Number.POSITIVE_INFINITY?[0,2146435072]:a===Number.NEGATIVE_INFINITY?[0,-1048576]:isNaN(a)?[0,2146959360]:(e=a<0?1<<31:0,a=Math.abs(a),a<=2.225073858507201e-308&&a>=5e-324?(b=0,d=a/Math.pow(2,-1022)*Math.pow(2,52)):(b=Math.floor(Math.log(a)/Math.LN2),a>>31,h=(2139095040&a)>>>23,i=8388607&a;return b=0===h?Math.pow(-1,c)*i*Math.pow(2,-149):Math.pow(-1,c)*(1+i*Math.pow(2,-23))*Math.pow(2,h-127),(bd)&&(b=NaN),b},a.prototype.longbits2double=function(a,b){var c=(2147483648&a)>>>31,d=(2146435072&a)>>>20,e=(1048575&a)*Math.pow(2,32)+b;return 0===d&&0===e?0:2047===d?0===e?1===c?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY:NaN:0===d?Math.pow(-1,c)*e*Math.pow(2,-1074):Math.pow(-1,c)*(1+e*Math.pow(2,-52))*Math.pow(2,d-1023)},a}();c.BufferCoreCommon=i},{}],4:[function(a,b,c){"use strict";var d=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)},e=a("./buffer_core"),f=[4294967040,4294902015,4278255615,16777215],g=function(a){function b(b){a.call(this),this.length=b,this.buff=new Array(Math.ceil(b/4));for(var c=this.buff.length,d=0;d>2,d=3&a;this.buff[c]=this.buff[c]&f[d],this.buff[c]=this.buff[c]|b<<(d<<3)},b.prototype.readUInt8=function(a){var b=a>>2,c=3&a;return this.buff[b]>>(c<<3)&255},b.prototype.copy=function(a,c){for(var d=new b(c-a),e=a;ec.length?c.length:b.length,e=0;e127){var g=a.extendedChars.indexOf(b.charAt(e));g>-1&&(f=g+128)}c.writeUInt8(f,e)}return d},a.byte2str=function(b){for(var c=new Array(b.length),d=0;d127?c[d]=a.extendedChars[e-128]:c[d]=String.fromCharCode(e)}return c.join("")},a.byteLength=function(a){return a.length},a.extendedChars=["Ç","ü","é","â","ä","à","å","ç","ê","ë","è","ï","î","ì","Ä","Å","É","æ","Æ","ô","ö","ò","û","ù","ÿ","Ö","Ü","ø","£","Ø","×","ƒ","á","í","ó","ú","ñ","Ñ","ª","º","¿","®","¬","½","¼","¡","«","»","_","_","_","¦","¦","Á","Â","À","©","¦","¦","+","+","¢","¥","+","+","-","-","+","-","+","ã","Ã","+","+","-","-","¦","-","+","¤","ð","Ð","Ê","Ë","È","i","Í","Î","Ï","+","+","_","_","¦","Ì","_","Ó","ß","Ô","Ò","õ","Õ","µ","þ","Þ","Ú","Û","Ù","ý","Ý","¯","´","­","±","_","¾","¶","§","÷","¸","°","¨","·","¹","³","²","_"," "],a}();c.__esModule=!0,c.default=d},{}],8:[function(a,b,c){"use strict";function d(a){var b,c=a.length,d=(c-1>>13)+1,e=new Array(d);for(b=0;b=c||d>=f)break;var h=a.charCodeAt(d);if(56320<=h&&h<=57343){var i=(1023&g|1024)<<10|1023&h;b.writeUInt8(i>>18|240,e++),b.writeUInt8(i>>12&63|128,e++),b.writeUInt8(i>>6&63|128,e++),b.writeUInt8(63&i|128,e++),d++}else b.writeUInt8(239,e++),b.writeUInt8(191,e++),b.writeUInt8(189,e++)}else if(56320<=g&&g<=57343)b.writeUInt8(239,e++),b.writeUInt8(191,e++),b.writeUInt8(189,e++);else if(g<128)b.writeUInt8(g,e++);else if(g<2048){if(e+1>=c)break;b.writeUInt8(g>>6|192,e++),b.writeUInt8(63&g|128,e++)}else if(g<65536){if(e+2>=c)break;b.writeUInt8(g>>12|224,e++),b.writeUInt8(g>>6&63|128,e++),b.writeUInt8(63&g|128,e++)}}return e},a.byte2str=function(a){for(var b=[],c=0;c>4)|55296),b.push((15&f)<<6|63&a.readUInt8(c++)|56320)}}}return d(b)},a.byteLength=function(a){for(var b=a.length,c=a.length-1;c>=0;c--){var d=a.charCodeAt(c);d>127&&d<=2047?b++:d>2047&&d<=65535&&(b+=2),d>=56320&&d<=57343&&c--}return b},a}();c.UTF8=h;var i=function(){function a(){}return a.str2byte=function(a,b){for(var c=a.length>b.length?b.length:a.length,d=0;db.length?b.length:a.length,d=0;d>2,i=(3&e)<<4|f>>4,j=(15&f)<<2|g>>6,k=63&g;isNaN(f)?j=k=64:isNaN(g)&&(k=64),c=c+a.num2b64[h]+a.num2b64[i]+a.num2b64[j]+a.num2b64[k]}return c},a.str2byte=function(b,c){var d=c.length,e="",f=0;b=b.replace(/[^A-Za-z0-9\+\/\=\-\_]/g,"");for(var g=0;f>4,m=(15&i)<<4|j>>2,n=(3&j)<<6|k;if(c.writeUInt8(l,g++),g===d)break;if(64!==j&&(e+=c.writeUInt8(m,g++)),g===d)break;if(64!==k&&(e+=c.writeUInt8(n,g++)),g===d)break}return g},a.byteLength=function(a){return Math.floor(6*a.replace(/[^A-Za-z0-9\+\/\-\_]/g,"").length/8)},a.b64chars=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9","+","/","="],a.num2b64=function(){for(var b=new Array(a.b64chars.length),c=0;cb.length&&(c=b.length%2===1?(b.length-1)/2:b.length/2);for(var d=0;d>1;c>b.length&&(c=b.length);for(var d=0;d>4;c[d++]=this.num2hex[g],c[d++]=this.num2hex[f]}return c.join("")},a.byteLength=function(a){return a.length>>1},a.HEXCHARS="0123456789abcdef",a.num2hex=function(){for(var b=new Array(a.HEXCHARS.length),c=0;cc.length&&(d=c.length);var e=0,f=0,g=f+d,h=b.charCodeAt(e++);0!==h&&(c.writeUInt8(255&h,0),f=1);for(var i=f;i>8,i),g-i>=2&&c.writeUInt16BE(j,i)}return d},a.byte2str=function(a){var b=a.length;if(0===b)return"";var c,e=(b>>1)+1,f=new Array(e),g=0;for(1===(1&b)?f[0]=256|a.readUInt8(g++):f[0]=0,c=1;cb.length?b.length:a.length,d=0;d0&&".."!==e[0])?e.pop():e.push(g))}if(!c&&e.length<2)switch(e.length){case 1:""===e[0]&&e.unshift(".");break;default:e.push(".")}return a=e.join(b.sep),c&&a.charAt(0)!==b.sep&&(a=b.sep+a),a},b.join=function(){for(var a=[],c=0;c1&&h.charAt(h.length-1)===b.sep)return h.substr(0,h.length-1);if(h.charAt(0)!==b.sep){"."!==h.charAt(0)||1!==h.length&&h.charAt(1)!==b.sep||(h=1===h.length?"":h.substr(2));var i=a.cwd();h=""!==h?this.normalize(i+("/"!==i?b.sep:"")+h):i}return h},b.relative=function(a,c){var d;a=b.resolve(a),c=b.resolve(c);var e=a.split(b.sep),f=c.split(b.sep);f.shift(),e.shift();var g=0,h=[];for(d=0;de.length&&(g=e.length);var j="";for(d=0;d1&&j.charAt(j.length-1)===b.sep&&(j=j.substr(0,j.length-1)),j},b.dirname=function(a){a=b._removeDuplicateSeps(a);var c=a.charAt(0)===b.sep,d=a.split(b.sep);return""===d.pop()&&d.length>0&&d.pop(),d.length>1||1===d.length&&!c?d.join(b.sep):c?b.sep:"."},b.basename=function(a,c){if(void 0===c&&(c=""),""===a)return a;a=b.normalize(a);var d=a.split(b.sep),e=d[d.length-1];if(""===e&&d.length>1)return d[d.length-2];if(c.length>0){var f=e.substr(e.length-c.length);if(f===c)return e.substr(0,e.length-c.length)}return e},b.extname=function(a){a=b.normalize(a);var c=a.split(b.sep);if(a=c.pop(),""===a&&c.length>0&&(a=c.pop()),".."===a)return"";var d=a.lastIndexOf(".");return d===-1||0===d?"":a.substr(d)},b.isAbsolute=function(a){return a.length>0&&a.charAt(0)===b.sep},b._makeLong=function(a){return a},b.parse=function(a){var b=c(a);return{root:b[0],dir:b[0]+b[1].slice(0,-1),base:b[2],ext:b[3],name:b[2].slice(0,b[2].length-b[3].length)}},b.format=function(a){if(null===a||"object"!=typeof a)throw new TypeError("Parameter 'pathObject' must be an object, not "+typeof a);var c=a.root||"";if("string"!=typeof c)throw new TypeError("'pathObject.root' must be a string or undefined, not "+typeof a.root);var d=a.dir?a.dir+b.sep:"",e=a.base||"";return d+e},b._removeDuplicateSeps=function(a){return a=a.replace(this._replaceRegex,this.sep)},b.sep="/",b._replaceRegex=new RegExp("//+","g"),b.delimiter=":",b.posix=b,b.win32=b,b}();b.exports=e}).call(this,a("bfs-process"))},{"bfs-process":11}],11:[function(a,b,c){"use strict";function d(a){g[a]||("function"==typeof f[a]?g[a]=function(){return f[a].apply(f,arguments)}:g[a]=f[a])}var e=a("./process"),f=new e,g={};for(var h in f)d(h);g.initializeTTYs=function(){null===f.stdin&&(f.initializeTTYs(),g.stdin=f.stdin,g.stdout=f.stdout,g.stderr=f.stderr)},f.nextTick(function(){g.initializeTTYs()}),b.exports=g},{"./process":12}],12:[function(a,b,c){(function(c){"use strict";var d=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)},e=a("events"),f=null,g=function(){function a(a,b){this.fun=a,this.array=b}return a.prototype.run=function(){this.fun.apply(null,this.array)},a}(),h=function(){function a(){this._queue=[],this._draining=!1,this._currentQueue=null,this._queueIndex=-1}return a.prototype.push=function(a){var b=this;1!==this._queue.push(a)||this._draining||setTimeout(function(){return b._drainQueue()},0)},a.prototype._cleanUpNextTick=function(){this._draining=!1,this._currentQueue&&this._currentQueue.length?this._queue=this._currentQueue.concat(this._queue):this._queueIndex=-1,this._queue.length&&this._drainQueue()},a.prototype._drainQueue=function(){var a=this;if(!this._draining){var b=setTimeout(function(){return a._cleanUpNextTick()});this._draining=!0;for(var c=this._queue.length;c;){for(this._currentQueue=this._queue,this._queue=[];++this._queueIndex0&&(this._waitingForWrites=this.push(this._bufferedWrites.shift()),this._waitingForWrites););},b}(e.Duplex);b.exports=f}).call(this,a("bfs-buffer").Buffer)},{"bfs-buffer":2,stream:34}],14:[function(a,b,c){},{}],15:[function(a,b,c){(function(b){"use strict";var d=a("buffer"),e=d.Buffer,f=d.SlowBuffer,g=d.kMaxLength||2147483647;c.alloc=function(a,b,c){if("function"==typeof e.alloc)return e.alloc(a,b,c);if("number"==typeof c)throw new TypeError("encoding must not be number");if("number"!=typeof a)throw new TypeError("size must be a number");if(a>g)throw new RangeError("size is too large");var d=c,f=b;void 0===f&&(d=void 0,f=0);var h=new e(a);if("string"==typeof f)for(var i=new e(f,d),j=i.length,k=-1;++kg)throw new RangeError("size is too large");return new e(a)},c.from=function(a,c,d){if("function"==typeof e.from&&(!b.Uint8Array||Uint8Array.from!==e.from))return e.from(a,c,d);if("number"==typeof a)throw new TypeError('"value" argument must not be a number');if("string"==typeof a)return new e(a,c);if("undefined"!=typeof ArrayBuffer&&a instanceof ArrayBuffer){var f=c;if(1===arguments.length)return new e(a);"undefined"==typeof f&&(f=0);var g=d;if("undefined"==typeof g&&(g=a.byteLength-f),f>=a.byteLength)throw new RangeError("'offset' is out of bounds");if(g>a.byteLength-f)throw new RangeError("'length' is out of bounds");return new e(a.slice(f,f+g))}if(e.isBuffer(a)){var h=new e(a.length);return a.copy(h,0,0,a.length),h}if(a){if(Array.isArray(a)||"undefined"!=typeof ArrayBuffer&&a.buffer instanceof ArrayBuffer||"length"in a)return new e(a);if("Buffer"===a.type&&Array.isArray(a.data))return new e(a.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")},c.allocUnsafeSlow=function(a){if("function"==typeof e.allocUnsafeSlow)return e.allocUnsafeSlow(a);if("number"!=typeof a)throw new TypeError("size must be a number");if(a>=g)throw new RangeError("size is too large");return new f(a)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{buffer:2}],16:[function(a,b,c){(function(a){function b(a){return Array.isArray?Array.isArray(a):"[object Array]"===q(a)}function d(a){return"boolean"==typeof a}function e(a){return null===a}function f(a){return null==a}function g(a){return"number"==typeof a}function h(a){return"string"==typeof a}function i(a){return"symbol"==typeof a}function j(a){return void 0===a}function k(a){return"[object RegExp]"===q(a)}function l(a){return"object"==typeof a&&null!==a}function m(a){return"[object Date]"===q(a)}function n(a){return"[object Error]"===q(a)||a instanceof Error}function o(a){return"function"==typeof a}function p(a){return null===a||"boolean"==typeof a||"number"==typeof a||"string"==typeof a||"symbol"==typeof a||"undefined"==typeof a}function q(a){return Object.prototype.toString.call(a)}c.isArray=b,c.isBoolean=d,c.isNull=e,c.isNullOrUndefined=f,c.isNumber=g,c.isString=h,c.isSymbol=i,c.isUndefined=j,c.isRegExp=k,c.isObject=l,c.isDate=m,c.isError=n,c.isFunction=o,c.isPrimitive=p,c.isBuffer=a.isBuffer}).call(this,{isBuffer:a("../../is-buffer/index.js")})},{"../../is-buffer/index.js":19}],17:[function(a,b,c){function d(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function e(a){return"function"==typeof a}function f(a){return"number"==typeof a}function g(a){return"object"==typeof a&&null!==a}function h(a){return void 0===a}b.exports=d,d.EventEmitter=d,d.prototype._events=void 0,d.prototype._maxListeners=void 0,d.defaultMaxListeners=10,d.prototype.setMaxListeners=function(a){if(!f(a)||a<0||isNaN(a))throw TypeError("n must be a positive number");return this._maxListeners=a,this},d.prototype.emit=function(a){var b,c,d,f,i,j;if(this._events||(this._events={}),"error"===a&&(!this._events.error||g(this._events.error)&&!this._events.error.length)){if(b=arguments[1],b instanceof Error)throw b;var k=new Error('Uncaught, unspecified "error" event. ('+b+")");throw k.context=b,k}if(c=this._events[a],h(c))return!1;if(e(c))switch(arguments.length){case 1:c.call(this);break;case 2:c.call(this,arguments[1]);break;case 3:c.call(this,arguments[1],arguments[2]);break;default:f=Array.prototype.slice.call(arguments,1),c.apply(this,f)}else if(g(c))for(f=Array.prototype.slice.call(arguments,1),j=c.slice(),d=j.length,i=0;i0&&this._events[a].length>c&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),"function"==typeof console.trace&&console.trace())),this},d.prototype.on=d.prototype.addListener,d.prototype.once=function(a,b){function c(){this.removeListener(a,c),d||(d=!0,b.apply(this,arguments))}if(!e(b))throw TypeError("listener must be a function");var d=!1;return c.listener=b,this.on(a,c),this},d.prototype.removeListener=function(a,b){var c,d,f,h;if(!e(b))throw TypeError("listener must be a function");if(!this._events||!this._events[a])return this;if(c=this._events[a],f=c.length,d=-1,c===b||e(c.listener)&&c.listener===b)delete this._events[a],this._events.removeListener&&this.emit("removeListener",a,b);else if(g(c)){for(h=f;h-- >0;)if(c[h]===b||c[h].listener&&c[h].listener===b){d=h;break}if(d<0)return this;1===c.length?(c.length=0,delete this._events[a]):c.splice(d,1),this._events.removeListener&&this.emit("removeListener",a,b)}return this},d.prototype.removeAllListeners=function(a){var b,c;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[a]&&delete this._events[a],this;if(0===arguments.length){for(b in this._events)"removeListener"!==b&&this.removeAllListeners(b);return this.removeAllListeners("removeListener"),this._events={},this}if(c=this._events[a],e(c))this.removeListener(a,c);else if(c)for(;c.length;)this.removeListener(a,c[c.length-1]);return delete this._events[a],this},d.prototype.listeners=function(a){var b;return b=this._events&&this._events[a]?e(this._events[a])?[this._events[a]]:this._events[a].slice():[]},d.prototype.listenerCount=function(a){if(this._events){var b=this._events[a];if(e(b))return 1;if(b)return b.length}return 0},d.listenerCount=function(a,b){return a.listenerCount(b)}},{}],18:[function(a,b,c){"function"==typeof Object.create?b.exports=function(a,b){a.super_=b,a.prototype=Object.create(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})}:b.exports=function(a,b){a.super_=b;var c=function(){};c.prototype=b.prototype,a.prototype=new c,a.prototype.constructor=a}},{}],19:[function(a,b,c){function d(a){return!!a.constructor&&"function"==typeof a.constructor.isBuffer&&a.constructor.isBuffer(a)}function e(a){return"function"==typeof a.readFloatLE&&"function"==typeof a.slice&&d(a.slice(0,0))}b.exports=function(a){return null!=a&&(d(a)||e(a)||!!a._isBuffer)}},{}],20:[function(b,c,d){(function(e){!function(b){if("object"==typeof d&&"undefined"!=typeof c)c.exports=b();else if("function"==typeof a&&a.amd)a([],b);else{var f;f="undefined"!=typeof window?window:"undefined"!=typeof e?e:"undefined"!=typeof self?self:this,f.pako=b()}}(function(){return function a(c,d,e){function f(h,i){if(!d[h]){if(!c[h]){var j="function"==typeof b&&b;if(!i&&j)return j(h,!0);if(g)return g(h,!0);var k=new Error("Cannot find module '"+h+"'");throw k.code="MODULE_NOT_FOUND",k}var l=d[h]={exports:{}};c[h][0].call(l.exports,function(a){var b=c[h][1][a];return f(b?b:a)},l,l.exports,a,c,d,e)}return d[h].exports}for(var g="function"==typeof b&&b,h=0;h=252?6:i>=248?5:i>=240?4:i>=224?3:i>=192?2:1;h[254]=h[254]=1,c.string2buf=function(a){var b,c,d,f,g,h=a.length,i=0;for(f=0;f>>6,b[g++]=128|63&c):c<65536?(b[g++]=224|c>>>12,b[g++]=128|c>>>6&63,b[g++]=128|63&c):(b[g++]=240|c>>>18,b[g++]=128|c>>>12&63,b[g++]=128|c>>>6&63,b[g++]=128|63&c);return b},c.buf2binstring=function(a){return d(a,a.length)},c.binstring2buf=function(a){for(var b=new e.Buf8(a.length),c=0,d=b.length;c4)j[e++]=65533,c+=g-1;else{for(f&=2===g?31:3===g?15:7;g>1&&c1?j[e++]=65533:f<65536?j[e++]=f:(f-=65536,j[e++]=55296|f>>10&1023,j[e++]=56320|1023&f)}return d(j,e)},c.utf8border=function(a,b){var c;for(b=b||a.length,b>a.length&&(b=a.length),c=b-1;c>=0&&128===(192&a[c]);)c--;return c<0?b:0===c?b:c+h[a[c]]>b?c:b}},{"./common":1}],3:[function(a,b,c){"use strict";function d(a,b,c,d){for(var e=65535&a|0,f=a>>>16&65535|0,g=0;0!==c;){g=c>2e3?2e3:c,c-=g;do e=e+b[d++]|0,f=f+e|0;while(--g);e%=65521,f%=65521}return e|f<<16|0}b.exports=d},{}],4:[function(a,b,c){"use strict";b.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],5:[function(a,b,c){"use strict";function d(){for(var a,b=[],c=0;c<256;c++){a=c;for(var d=0;d<8;d++)a=1&a?3988292384^a>>>1:a>>>1;b[c]=a}return b}function e(a,b,c,d){var e=f,g=d+c;a^=-1;for(var h=d;h>>8^e[255&(a^b[h])];return a^-1}var f=d();b.exports=e},{}],6:[function(a,b,c){"use strict";function d(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}b.exports=d},{}],7:[function(a,b,c){"use strict";var d=30,e=12;b.exports=function(a,b){var c,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C;c=a.state,f=a.next_in,B=a.input,g=f+(a.avail_in-5),h=a.next_out,C=a.output,i=h-(b-a.avail_out),j=h+(a.avail_out-257),k=c.dmax,l=c.wsize,m=c.whave,n=c.wnext,o=c.window,p=c.hold,q=c.bits,r=c.lencode,s=c.distcode,t=(1<>>24,p>>>=w,q-=w,w=v>>>16&255,0===w)C[h++]=65535&v;else{if(!(16&w)){if(0===(64&w)){v=r[(65535&v)+(p&(1<>>=w,q-=w),q<15&&(p+=B[f++]<>>24,p>>>=w,q-=w,w=v>>>16&255,!(16&w)){if(0===(64&w)){v=s[(65535&v)+(p&(1<k){a.msg="invalid distance too far back",c.mode=d;break a}if(p>>>=w,q-=w,w=h-i,y>w){if(w=y-w,w>m&&c.sane){a.msg="invalid distance too far back",c.mode=d;break a}if(z=0,A=o,0===n){if(z+=l-w,w2;)C[h++]=A[z++],C[h++]=A[z++],C[h++]=A[z++],x-=3;x&&(C[h++]=A[z++],x>1&&(C[h++]=A[z++]))}else{z=h-y;do C[h++]=C[z++],C[h++]=C[z++],C[h++]=C[z++],x-=3;while(x>2);x&&(C[h++]=C[z++],x>1&&(C[h++]=C[z++]))}break}}break}}while(f>3,f-=x,q-=x<<3,p&=(1<>>24&255)+(a>>>8&65280)+((65280&a)<<8)+((255&a)<<24)}function e(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function f(a){var b;return a&&a.state?(b=a.state,a.total_in=a.total_out=b.total=0,a.msg="",b.wrap&&(a.adler=1&b.wrap),b.mode=L,b.last=0,b.havedict=0,b.dmax=32768,b.head=null,b.hold=0,b.bits=0,b.lencode=b.lendyn=new s.Buf32(pa),b.distcode=b.distdyn=new s.Buf32(qa),b.sane=1,b.back=-1,D):G}function g(a){var b;return a&&a.state?(b=a.state,b.wsize=0,b.whave=0,b.wnext=0,f(a)):G}function h(a,b){var c,d;return a&&a.state?(d=a.state,b<0?(c=0,b=-b):(c=(b>>4)+1,b<48&&(b&=15)),b&&(b<8||b>15)?G:(null!==d.window&&d.wbits!==b&&(d.window=null),d.wrap=c,d.wbits=b,g(a))):G}function i(a,b){var c,d;return a?(d=new e,a.state=d,d.window=null,c=h(a,b),c!==D&&(a.state=null),c):G}function j(a){return i(a,sa)}function k(a){if(ta){var b;for(q=new s.Buf32(512),r=new s.Buf32(32),b=0;b<144;)a.lens[b++]=8;for(;b<256;)a.lens[b++]=9;for(;b<280;)a.lens[b++]=7;for(;b<288;)a.lens[b++]=8;for(w(y,a.lens,0,288,q,0,a.work,{bits:9}),b=0;b<32;)a.lens[b++]=5;w(z,a.lens,0,32,r,0,a.work,{bits:5}),ta=!1}a.lencode=q,a.lenbits=9,a.distcode=r,a.distbits=5}function l(a,b,c,d){var e,f=a.state;return null===f.window&&(f.wsize=1<=f.wsize?(s.arraySet(f.window,b,c-f.wsize,f.wsize,0),f.wnext=0,f.whave=f.wsize):(e=f.wsize-f.wnext,e>d&&(e=d),s.arraySet(f.window,b,c-d,e,f.wnext),d-=e,d?(s.arraySet(f.window,b,c-d,d,0),f.wnext=d,f.whave=f.wsize):(f.wnext+=e,f.wnext===f.wsize&&(f.wnext=0),f.whave>>8&255,c.check=u(c.check,Ba,2,0),m=0,n=0,c.mode=M;break}if(c.flags=0,c.head&&(c.head.done=!1),!(1&c.wrap)||(((255&m)<<8)+(m>>8))%31){a.msg="incorrect header check",c.mode=ma;break}if((15&m)!==K){a.msg="unknown compression method",c.mode=ma;break}if(m>>>=4,n-=4,wa=(15&m)+8,0===c.wbits)c.wbits=wa;else if(wa>c.wbits){a.msg="invalid window size",c.mode=ma;break}c.dmax=1<>8&1),512&c.flags&&(Ba[0]=255&m,Ba[1]=m>>>8&255,c.check=u(c.check,Ba,2,0)),m=0,n=0,c.mode=N;case N:for(;n<32;){if(0===i)break a;i--,m+=e[g++]<>>8&255,Ba[2]=m>>>16&255,Ba[3]=m>>>24&255,c.check=u(c.check,Ba,4,0)),m=0,n=0,c.mode=O;case O:for(;n<16;){if(0===i)break a;i--,m+=e[g++]<>8),512&c.flags&&(Ba[0]=255&m,Ba[1]=m>>>8&255,c.check=u(c.check,Ba,2,0)),m=0,n=0,c.mode=P;case P:if(1024&c.flags){for(;n<16;){if(0===i)break a;i--,m+=e[g++]<>>8&255,c.check=u(c.check,Ba,2,0)),m=0,n=0}else c.head&&(c.head.extra=null);c.mode=Q;case Q:if(1024&c.flags&&(q=c.length,q>i&&(q=i),q&&(c.head&&(wa=c.head.extra_len-c.length,c.head.extra||(c.head.extra=new Array(c.head.extra_len)),s.arraySet(c.head.extra,e,g,q,wa)),512&c.flags&&(c.check=u(c.check,e,q,g)),i-=q,g+=q,c.length-=q),c.length))break a;c.length=0,c.mode=R;case R:if(2048&c.flags){if(0===i)break a;q=0;do wa=e[g+q++],c.head&&wa&&c.length<65536&&(c.head.name+=String.fromCharCode(wa));while(wa&&q>9&1,c.head.done=!0),a.adler=c.check=0,c.mode=W;break;case U:for(;n<32;){if(0===i)break a;i--,m+=e[g++]<>>=7&n,n-=7&n,c.mode=ja;break}for(;n<3;){if(0===i)break a;i--,m+=e[g++]<>>=1,n-=1,3&m){case 0:c.mode=Y;break;case 1:if(k(c),c.mode=ca,b===C){m>>>=2,n-=2;break a}break;case 2:c.mode=_;break;case 3:a.msg="invalid block type",c.mode=ma}m>>>=2,n-=2;break;case Y:for(m>>>=7&n,n-=7&n;n<32;){if(0===i)break a;i--,m+=e[g++]<>>16^65535)){a.msg="invalid stored block lengths",c.mode=ma;break}if(c.length=65535&m,m=0,n=0,c.mode=Z,b===C)break a;case Z:c.mode=$;case $:if(q=c.length){if(q>i&&(q=i),q>j&&(q=j),0===q)break a;s.arraySet(f,e,g,q,h),i-=q,g+=q,j-=q,h+=q,c.length-=q;break}c.mode=W;break;case _:for(;n<14;){if(0===i)break a;i--,m+=e[g++]<>>=5,n-=5,c.ndist=(31&m)+1,m>>>=5,n-=5,c.ncode=(15&m)+4,m>>>=4,n-=4,c.nlen>286||c.ndist>30){a.msg="too many length or distance symbols",c.mode=ma;break}c.have=0,c.mode=aa;case aa:for(;c.have>>=3,n-=3}for(;c.have<19;)c.lens[Ca[c.have++]]=0;if(c.lencode=c.lendyn,c.lenbits=7,ya={bits:c.lenbits},xa=w(x,c.lens,0,19,c.lencode,0,c.work,ya),c.lenbits=ya.bits,xa){a.msg="invalid code lengths set",c.mode=ma;break}c.have=0,c.mode=ba;case ba:for(;c.have>>24,ra=Aa>>>16&255,sa=65535&Aa,!(qa<=n);){if(0===i)break a;i--,m+=e[g++]<>>=qa,n-=qa,c.lens[c.have++]=sa;else{if(16===sa){for(za=qa+2;n>>=qa,n-=qa,0===c.have){a.msg="invalid bit length repeat",c.mode=ma;break}wa=c.lens[c.have-1],q=3+(3&m),m>>>=2,n-=2}else if(17===sa){for(za=qa+3;n>>=qa,n-=qa,wa=0,q=3+(7&m),m>>>=3,n-=3}else{for(za=qa+7;n>>=qa,n-=qa,wa=0,q=11+(127&m),m>>>=7,n-=7}if(c.have+q>c.nlen+c.ndist){a.msg="invalid bit length repeat",c.mode=ma;break}for(;q--;)c.lens[c.have++]=wa}}if(c.mode===ma)break;if(0===c.lens[256]){a.msg="invalid code -- missing end-of-block",c.mode=ma;break}if(c.lenbits=9,ya={bits:c.lenbits},xa=w(y,c.lens,0,c.nlen,c.lencode,0,c.work,ya),c.lenbits=ya.bits,xa){a.msg="invalid literal/lengths set",c.mode=ma;break}if(c.distbits=6,c.distcode=c.distdyn,ya={bits:c.distbits},xa=w(z,c.lens,c.nlen,c.ndist,c.distcode,0,c.work,ya),c.distbits=ya.bits,xa){a.msg="invalid distances set",c.mode=ma;break}if(c.mode=ca,b===C)break a;case ca:c.mode=da;case da:if(i>=6&&j>=258){a.next_out=h,a.avail_out=j,a.next_in=g,a.avail_in=i,c.hold=m,c.bits=n,v(a,p),h=a.next_out,f=a.output,j=a.avail_out,g=a.next_in,e=a.input,i=a.avail_in,m=c.hold,n=c.bits,c.mode===W&&(c.back=-1);break}for(c.back=0;Aa=c.lencode[m&(1<>>24,ra=Aa>>>16&255,sa=65535&Aa,!(qa<=n);){if(0===i)break a;i--,m+=e[g++]<>ta)],qa=Aa>>>24,ra=Aa>>>16&255,sa=65535&Aa,!(ta+qa<=n);){if(0===i)break a;i--,m+=e[g++]<>>=ta,n-=ta,c.back+=ta}if(m>>>=qa,n-=qa,c.back+=qa,c.length=sa,0===ra){c.mode=ia;break}if(32&ra){c.back=-1,c.mode=W;break}if(64&ra){a.msg="invalid literal/length code",c.mode=ma;break}c.extra=15&ra,c.mode=ea;case ea:if(c.extra){for(za=c.extra;n>>=c.extra,n-=c.extra,c.back+=c.extra}c.was=c.length,c.mode=fa;case fa:for(;Aa=c.distcode[m&(1<>>24,ra=Aa>>>16&255,sa=65535&Aa,!(qa<=n);){if(0===i)break a;i--,m+=e[g++]<>ta)],qa=Aa>>>24,ra=Aa>>>16&255,sa=65535&Aa,!(ta+qa<=n);){if(0===i)break a;i--,m+=e[g++]<>>=ta,n-=ta,c.back+=ta}if(m>>>=qa,n-=qa,c.back+=qa,64&ra){a.msg="invalid distance code",c.mode=ma;break}c.offset=sa,c.extra=15&ra,c.mode=ga;case ga:if(c.extra){for(za=c.extra;n>>=c.extra,n-=c.extra,c.back+=c.extra}if(c.offset>c.dmax){a.msg="invalid distance too far back",c.mode=ma;break}c.mode=ha;case ha:if(0===j)break a;if(q=p-j,c.offset>q){if(q=c.offset-q,q>c.whave&&c.sane){a.msg="invalid distance too far back",c.mode=ma;break}q>c.wnext?(q-=c.wnext,r=c.wsize-q):r=c.wnext-q,q>c.length&&(q=c.length),pa=c.window}else pa=f,r=h-c.offset,q=c.length;q>j&&(q=j),j-=q,c.length-=q;do f[h++]=pa[r++];while(--q);0===c.length&&(c.mode=da);break;case ia:if(0===j)break a;f[h++]=c.length,j--,c.mode=da;break;case ja:if(c.wrap){for(;n<32;){if(0===i)break a;i--,m|=e[g++]<=1&&0===P[G];G--);if(H>G&&(H=G),0===G)return p[q++]=20971520,p[q++]=20971520,s.bits=1,0;for(F=1;F0&&(a===h||1!==G))return-1;for(Q[1]=0,D=1;Df||a===j&&L>g)return 1;for(var T=0;;){T++,z=D-J,r[E]y?(A=R[S+r[E]],B=N[O+r[E]]):(A=96,B=0),t=1<>J)+u]=z<<24|A<<16|B|0;while(0!==u);for(t=1<>=1;if(0!==t?(M&=t-1,M+=t):M=0,E++,0===--P[D]){if(D===G)break;D=b[c+r[E]]}if(D>H&&(M&w)!==v){for(0===J&&(J=H),x+=F,I=D-J,K=1<f||a===j&&L>g)return 1;v=M&w,p[v]=H<<24|I<<16|x-q|0}}return 0!==M&&(p[x+M]=D-J<<24|64<<16|0),s.bits=H,0}},{"../utils/common":1}],10:[function(a,b,c){"use strict";b.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],11:[function(a,b,c){"use strict";function d(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}b.exports=d},{}],"/lib/inflate.js":[function(a,b,c){"use strict";function d(a){if(!(this instanceof d))return new d(a);this.options=h.assign({chunkSize:16384,windowBits:0,to:""},a||{});var b=this.options;b.raw&&b.windowBits>=0&&b.windowBits<16&&(b.windowBits=-b.windowBits,0===b.windowBits&&(b.windowBits=-15)),!(b.windowBits>=0&&b.windowBits<16)||a&&a.windowBits||(b.windowBits+=32),b.windowBits>15&&b.windowBits<48&&0===(15&b.windowBits)&&(b.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new l,this.strm.avail_out=0;var c=g.inflateInit2(this.strm,b.windowBits);if(c!==j.Z_OK)throw new Error(k[c]);this.header=new m,g.inflateGetHeader(this.strm,this.header)}function e(a,b){var c=new d(b);if(c.push(a,!0),c.err)throw c.msg;return c.result}function f(a,b){return b=b||{},b.raw=!0,e(a,b)}var g=a("./zlib/inflate"),h=a("./utils/common"),i=a("./utils/strings"),j=a("./zlib/constants"),k=a("./zlib/messages"),l=a("./zlib/zstream"),m=a("./zlib/gzheader"),n=Object.prototype.toString;d.prototype.push=function(a,b){var c,d,e,f,k,l,m=this.strm,o=this.options.chunkSize,p=this.options.dictionary,q=!1;if(this.ended)return!1;d=b===~~b?b:b===!0?j.Z_FINISH:j.Z_NO_FLUSH,"string"==typeof a?m.input=i.binstring2buf(a):"[object ArrayBuffer]"===n.call(a)?m.input=new Uint8Array(a):m.input=a,m.next_in=0,m.avail_in=m.input.length;do{if(0===m.avail_out&&(m.output=new h.Buf8(o),m.next_out=0,m.avail_out=o),c=g.inflate(m,j.Z_NO_FLUSH),c===j.Z_NEED_DICT&&p&&(l="string"==typeof p?i.string2buf(p):"[object ArrayBuffer]"===n.call(p)?new Uint8Array(p):p,c=g.inflateSetDictionary(this.strm,l)),c===j.Z_BUF_ERROR&&q===!0&&(c=j.Z_OK,q=!1),c!==j.Z_STREAM_END&&c!==j.Z_OK)return this.onEnd(c),this.ended=!0,!1;m.next_out&&(0!==m.avail_out&&c!==j.Z_STREAM_END&&(0!==m.avail_in||d!==j.Z_FINISH&&d!==j.Z_SYNC_FLUSH)||("string"===this.options.to?(e=i.utf8border(m.output,m.next_out),f=m.next_out-e,k=i.buf2string(m.output,e),m.next_out=f,m.avail_out=o-f,f&&h.arraySet(m.output,m.output,e,f,0),this.onData(k)):this.onData(h.shrinkBuf(m.output,m.next_out)))),0===m.avail_in&&0===m.avail_out&&(q=!0)}while((m.avail_in>0||0===m.avail_out)&&c!==j.Z_STREAM_END);return c===j.Z_STREAM_END&&(d=j.Z_FINISH),d===j.Z_FINISH?(c=g.inflateEnd(this.strm),this.onEnd(c),this.ended=!0,c===j.Z_OK):d!==j.Z_SYNC_FLUSH||(this.onEnd(j.Z_OK),m.avail_out=0,!0)},d.prototype.onData=function(a){this.chunks.push(a)},d.prototype.onEnd=function(a){a===j.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=h.flattenChunks(this.chunks)),this.chunks=[],this.err=a,this.msg=this.strm.msg},c.Inflate=d,c.inflate=e,c.inflateRaw=f,c.ungzip=e},{"./utils/common":1,"./utils/strings":2,"./zlib/constants":4,"./zlib/gzheader":6,"./zlib/inflate":8,"./zlib/messages":10,"./zlib/zstream":11}]},{},[])("/lib/inflate.js")})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],21:[function(a,b,c){(function(a){"use strict";function c(b,c,d,e){if("function"!=typeof b)throw new TypeError('"callback" argument must be a function');var f,g,h=arguments.length;switch(h){case 0:case 1:return a.nextTick(b);case 2:return a.nextTick(function(){b.call(null,c)});case 3:return a.nextTick(function(){b.call(null,c,d)});case 4:return a.nextTick(function(){b.call(null,c,d,e)});default: +for(f=new Array(h-1),g=0;g0)if(b.ended&&!e){var g=new Error("stream.push() after EOF");a.emit("error",g)}else if(b.endEmitted&&e){var i=new Error("stream.unshift() after end event");a.emit("error",i)}else{var j;!b.decoder||e||d||(c=b.decoder.write(c),j=!b.objectMode&&0===c.length),e||(b.reading=!1),j||(b.flowing&&0===b.length&&!b.sync?(a.emit("data",c),a.read(0)):(b.length+=b.objectMode?1:c.length,e?b.buffer.unshift(c):b.buffer.push(c),b.needReadable&&m(a))),o(a,b)}else e||(b.reading=!1);return h(b)}function h(a){return!a.ended&&(a.needReadable||a.length=P?a=P:(a--,a|=a>>>1,a|=a>>>2,a|=a>>>4,a|=a>>>8,a|=a>>>16,a++),a}function j(a,b){return a<=0||0===b.length&&b.ended?0:b.objectMode?1:a!==a?b.flowing&&b.length?b.buffer.head.data.length:b.length:(a>b.highWaterMark&&(b.highWaterMark=i(a)),a<=b.length?a:b.ended?b.length:(b.needReadable=!0,0))}function k(a,b){var c=null;return H.isBuffer(b)||"string"==typeof b||null===b||void 0===b||a.objectMode||(c=new TypeError("Invalid non-string/buffer chunk")),c}function l(a,b){if(!b.ended){if(b.decoder){var c=b.decoder.end();c&&c.length&&(b.buffer.push(c),b.length+=b.objectMode?1:c.length)}b.ended=!0,m(a)}}function m(a){var b=a._readableState;b.needReadable=!1,b.emittedReadable||(L("emitReadable",b.flowing),b.emittedReadable=!0,b.sync?D(n,a):n(a))}function n(a){L("emit readable"),a.emit("readable"),u(a)}function o(a,b){b.readingMore||(b.readingMore=!0,D(p,a,b))}function p(a,b){for(var c=b.length;!b.reading&&!b.flowing&&!b.ended&&b.length=b.length?(c=b.decoder?b.buffer.join(""):1===b.buffer.length?b.buffer.head.data:b.buffer.concat(b.length),b.buffer.clear()):c=w(a,b.buffer,b.decoder),c}function w(a,b,c){var d;return af.length?f.length:a;if(e+=g===f.length?f:f.slice(0,a),a-=g,0===a){g===f.length?(++d,c.next?b.head=c.next:b.head=b.tail=null):(b.head=c,c.data=f.slice(g));break}++d}return b.length-=d,e}function y(a,b){var c=I.allocUnsafe(a),d=b.head,e=1;for(d.data.copy(c),a-=d.data.length;d=d.next;){var f=d.data,g=a>f.length?f.length:a;if(f.copy(c,c.length-a,0,g),a-=g,0===a){g===f.length?(++e,d.next?b.head=d.next:b.head=b.tail=null):(b.head=d,d.data=f.slice(g));break}++e}return b.length-=e,c}function z(a){var b=a._readableState;if(b.length>0)throw new Error('"endReadable()" called on non-empty stream');b.endEmitted||(b.ended=!0,D(A,b,a))}function A(a,b){a.endEmitted||0!==a.length||(a.endEmitted=!0,b.readable=!1,b.emit("end"))}function B(a,b){for(var c=0,d=a.length;c=b.highWaterMark||b.ended))return L("read: emitReadable",b.length,b.ended),0===b.length&&b.ended?z(this):m(this),null;if(a=j(a,b),0===a&&b.ended)return 0===b.length&&z(this),null;var d=b.needReadable;L("need readable",d),(0===b.length||b.length-a0?v(a,b):null,null===e?(b.needReadable=!0,a=0):b.length-=a,0===b.length&&(b.ended||(b.needReadable=!0),c!==a&&b.ended&&z(this)),null!==e&&this.emit("data",e),e},f.prototype._read=function(a){this.emit("error",new Error("not implemented"))},f.prototype.pipe=function(a,b){function e(a){L("onunpipe"),a===m&&g()}function f(){L("onend"),a.end()}function g(){L("cleanup"),a.removeListener("close",j),a.removeListener("finish",k),a.removeListener("drain",r),a.removeListener("error",i),a.removeListener("unpipe",e),m.removeListener("end",f),m.removeListener("end",g),m.removeListener("data",h),s=!0,!n.awaitDrain||a._writableState&&!a._writableState.needDrain||r()}function h(b){L("ondata"),t=!1;var c=a.write(b);!1!==c||t||((1===n.pipesCount&&n.pipes===a||n.pipesCount>1&&C(n.pipes,a)!==-1)&&!s&&(L("false write response, pause",m._readableState.awaitDrain),m._readableState.awaitDrain++,t=!0),m.pause())}function i(b){L("onerror",b),l(),a.removeListener("error",i),0===G(a,"error")&&a.emit("error",b)}function j(){a.removeListener("finish",k),l()}function k(){L("onfinish"),a.removeListener("close",j),l()}function l(){L("unpipe"),m.unpipe(a)}var m=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=a;break;case 1:n.pipes=[n.pipes,a];break;default:n.pipes.push(a)}n.pipesCount+=1,L("pipe count=%d opts=%j",n.pipesCount,b);var o=(!b||b.end!==!1)&&a!==c.stdout&&a!==c.stderr,p=o?f:g;n.endEmitted?D(p):m.once("end",p),a.on("unpipe",e);var r=q(m);a.on("drain",r);var s=!1,t=!1;return m.on("data",h),d(a,"error",i),a.once("close",j),a.once("finish",k),a.emit("pipe",m),n.flowing||(L("pipe resume"),m.resume()),a},f.prototype.unpipe=function(a){var b=this._readableState;if(0===b.pipesCount)return this;if(1===b.pipesCount)return a&&a!==b.pipes?this:(a||(a=b.pipes),b.pipes=null,b.pipesCount=0,b.flowing=!1,a&&a.emit("unpipe",this),this);if(!a){var c=b.pipes,d=b.pipesCount;b.pipes=null,b.pipesCount=0,b.flowing=!1;for(var e=0;e-1?setImmediate:x;g.WritableState=f;var z=a("core-util-is");z.inherits=a("inherits");var A,B={deprecate:a("util-deprecate")};!function(){try{A=a("stream")}catch(a){}finally{A||(A=a("events").EventEmitter)}}();var C=a("buffer").Buffer,D=a("buffer-shims");z.inherits(g,A);var E;f.prototype.getBuffer=function(){for(var a=this.bufferedRequest,b=[];a;)b.push(a),a=a.next;return b},function(){try{Object.defineProperty(f.prototype,"buffer",{get:B.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")})}catch(a){}}();var E;g.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},g.prototype.write=function(a,b,c){var e=this._writableState,f=!1;return"function"==typeof b&&(c=b,b=null),C.isBuffer(a)?b="buffer":b||(b=e.defaultEncoding),"function"!=typeof c&&(c=d),e.ended?h(this,c):i(this,e,a,c)&&(e.pendingcb++,f=k(this,e,a,b,c)),f},g.prototype.cork=function(){var a=this._writableState;a.corked++},g.prototype.uncork=function(){var a=this._writableState;a.corked&&(a.corked--,a.writing||a.corked||a.finished||a.bufferProcessing||!a.bufferedRequest||r(this,a))},g.prototype.setDefaultEncoding=function(a){if("string"==typeof a&&(a=a.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((a+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+a);return this._writableState.defaultEncoding=a,this},g.prototype._write=function(a,b,c){c(new Error("not implemented"))},g.prototype._writev=null,g.prototype.end=function(a,b,c){var d=this._writableState;"function"==typeof a?(c=a,a=null,b=null):"function"==typeof b&&(c=b,b=null),null!==a&&void 0!==a&&this.write(a,b),d.corked&&(d.corked=1,this.uncork()),d.ending||d.finished||v(this,d,c)}}).call(this,a("bfs-process"))},{"./_stream_duplex":23,"bfs-process":11,buffer:2,"buffer-shims":15,"core-util-is":16,events:17,inherits:18,"process-nextick-args":21,"util-deprecate":36}],28:[function(a,b,c){"use strict";function d(){this.head=null,this.tail=null,this.length=0}var e=(a("buffer").Buffer,a("buffer-shims"));b.exports=d,d.prototype.push=function(a){var b={data:a,next:null};this.length>0?this.tail.next=b:this.head=b,this.tail=b,++this.length},d.prototype.unshift=function(a){var b={data:a,next:this.head};0===this.length&&(this.tail=b),this.head=b,++this.length},d.prototype.shift=function(){if(0!==this.length){var a=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,a}},d.prototype.clear=function(){this.head=this.tail=null,this.length=0},d.prototype.join=function(a){if(0===this.length)return"";for(var b=this.head,c=""+b.data;b=b.next;)c+=a+b.data;return c},d.prototype.concat=function(a){if(0===this.length)return e.alloc(0);if(1===this.length)return this.head.data;for(var b=e.allocUnsafe(a>>>0),c=this.head,d=0;c;)c.data.copy(b,d),d+=c.data.length,c=c.next;return b}},{buffer:2,"buffer-shims":15}],29:[function(a,b,c){var d={}.toString;b.exports=Array.isArray||function(a){return"[object Array]"==d.call(a)}},{}],30:[function(a,b,c){b.exports=a("./lib/_stream_passthrough.js")},{"./lib/_stream_passthrough.js":24}],31:[function(a,b,c){(function(d){var e=function(){try{return a("stream")}catch(a){}}();c=b.exports=a("./lib/_stream_readable.js"),c.Stream=e||c,c.Readable=c,c.Writable=a("./lib/_stream_writable.js"),c.Duplex=a("./lib/_stream_duplex.js"),c.Transform=a("./lib/_stream_transform.js"),c.PassThrough=a("./lib/_stream_passthrough.js"),!d.browser&&"disable"===d.env.READABLE_STREAM&&e&&(b.exports=e)}).call(this,a("bfs-process"))},{"./lib/_stream_duplex.js":23,"./lib/_stream_passthrough.js":24,"./lib/_stream_readable.js":25,"./lib/_stream_transform.js":26,"./lib/_stream_writable.js":27,"bfs-process":11}],32:[function(a,b,c){b.exports=a("./lib/_stream_transform.js")},{"./lib/_stream_transform.js":26}],33:[function(a,b,c){b.exports=a("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":27}],34:[function(a,b,c){function d(){e.call(this)}b.exports=d;var e=a("events").EventEmitter,f=a("inherits");f(d,e),d.Readable=a("readable-stream/readable.js"),d.Writable=a("readable-stream/writable.js"),d.Duplex=a("readable-stream/duplex.js"),d.Transform=a("readable-stream/transform.js"),d.PassThrough=a("readable-stream/passthrough.js"),d.Stream=d,d.prototype.pipe=function(a,b){function c(b){a.writable&&!1===a.write(b)&&j.pause&&j.pause()}function d(){j.readable&&j.resume&&j.resume()}function f(){k||(k=!0,a.end())}function g(){k||(k=!0,"function"==typeof a.destroy&&a.destroy())}function h(a){if(i(),0===e.listenerCount(this,"error"))throw a}function i(){j.removeListener("data",c),a.removeListener("drain",d),j.removeListener("end",f),j.removeListener("close",g),j.removeListener("error",h),a.removeListener("error",h),j.removeListener("end",i),j.removeListener("close",i),a.removeListener("close",i)}var j=this;j.on("data",c),a.on("drain",d),a._isStdio||b&&b.end===!1||(j.on("end",f),j.on("close",g));var k=!1;return j.on("error",h),a.on("error",h),j.on("end",i),j.on("close",i),a.on("close",i),a.emit("pipe",j),a}},{events:17,inherits:18,"readable-stream/duplex.js":22,"readable-stream/passthrough.js":30,"readable-stream/readable.js":31,"readable-stream/transform.js":32,"readable-stream/writable.js":33}],35:[function(a,b,c){function d(a){if(a&&!i(a))throw new Error("Unknown encoding: "+a)}function e(a){return a.toString(this.encoding)}function f(a){this.charReceived=a.length%2,this.charLength=this.charReceived?2:0}function g(a){this.charReceived=a.length%3,this.charLength=this.charReceived?3:0}var h=a("buffer").Buffer,i=h.isEncoding||function(a){switch(a&&a.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}},j=c.StringDecoder=function(a){switch(this.encoding=(a||"utf8").toLowerCase().replace(/[-_]/,""),d(a),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=f;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=g;break;default:return void(this.write=e)}this.charBuffer=new h(6),this.charReceived=0,this.charLength=0};j.prototype.write=function(a){for(var b="";this.charLength;){var c=a.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:a.length;if(a.copy(this.charBuffer,this.charReceived,0,c),this.charReceived+=c,this.charReceived=55296&&d<=56319)){if(this.charReceived=this.charLength=0,0===a.length)return b;break}this.charLength+=this.surrogateSize,b=""}this.detectIncompleteChar(a);var e=a.length;this.charLength&&(a.copy(this.charBuffer,0,a.length-this.charReceived,e),e-=this.charReceived),b+=a.toString(this.encoding,0,e);var e=b.length-1,d=b.charCodeAt(e);if(d>=55296&&d<=56319){var f=this.surrogateSize;return this.charLength+=f,this.charReceived+=f,this.charBuffer.copy(this.charBuffer,f,0,f),a.copy(this.charBuffer,0,0,f),b.substring(0,e)}return b},j.prototype.detectIncompleteChar=function(a){for(var b=a.length>=3?3:a.length;b>0;b--){var c=a[a.length-b];if(1==b&&c>>5==6){this.charLength=2;break}if(b<=2&&c>>4==14){this.charLength=3;break}if(b<=3&&c>>3==30){this.charLength=4;break}}this.charReceived=b},j.prototype.end=function(a){var b="";if(a&&a.length&&(b=this.write(a)),this.charReceived){var c=this.charReceived,d=this.charBuffer,e=this.encoding;b+=d.slice(0,c).toString(e)}return b}},{buffer:2}],36:[function(a,b,c){(function(a){function c(a,b){function c(){if(!e){if(d("throwDeprecation"))throw new Error(b);d("traceDeprecation")?console.trace(b):console.warn(b),e=!0}return a.apply(this,arguments)}if(d("noDeprecation"))return a;var e=!1;return c}function d(b){try{if(!a.localStorage)return!1}catch(a){return!1}var c=a.localStorage[b];return null!=c&&"true"===String(c).toLowerCase()}b.exports=c}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],37:[function(a,b,c){"use strict";var d=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)},e=a("../core/file_system"),f=a("../core/api_error"),g=a("../core/file_flag"),h=a("../generic/preload_file"),i=a("path"),j=function(a){function b(b,c,d,e,f){a.call(this,b,c,d,e,f)}return d(b,a),b.prototype.syncSync=function(){this.isDirty()&&(this._fs._syncSync(this),this.resetDirty())},b.prototype.closeSync=function(){this.syncSync()},b}(h.PreloadFile),k=function(a){function b(b,c){if(a.call(this),this._queue=[],this._queueRunning=!1,this._isInitialized=!1,this._initializeCallbacks=[],this._sync=b,this._async=c,!b.supportsSynch())throw new Error("The first argument to AsyncMirror needs to be a synchronous file system.")}return d(b,a),b.prototype.getName=function(){return"AsyncMirror"},b.isAvailable=function(){return!0},b.prototype._syncSync=function(a){this._sync.writeFileSync(a.getPath(),a.getBuffer(),null,g.FileFlag.getFileFlag("w"),a.getStats().mode),this.enqueueOp({apiMethod:"writeFile",arguments:[a.getPath(),a.getBuffer(),null,a.getFlag(),a.getStats().mode]})},b.prototype.initialize=function(a){var b=this,c=this._initializeCallbacks,d=function(a){b._isInitialized=!a,b._initializeCallbacks=[],c.forEach(function(b){return b(a)})};if(this._isInitialized)a();else if(1===c.push(a)){var e=function(a,c,d){"/"!==a&&b._sync.mkdirSync(a,c),b._async.readdir(a,function(b,c){function e(b){b?d(b):f0){var d=b._queue.shift(),e=d.arguments;e.push(c),b._async[d.apiMethod].apply(b._async,e)}else b._queueRunning=!1};c()}},b.prototype.renameSync=function(a,b){this.checkInitialized(),this._sync.renameSync(a,b),this.enqueueOp({apiMethod:"rename",arguments:[a,b]})},b.prototype.statSync=function(a,b){return this.checkInitialized(),this._sync.statSync(a,b)},b.prototype.openSync=function(a,b,c){this.checkInitialized();var d=this._sync.openSync(a,b,c);return d.closeSync(),new j(this,a,b,this._sync.statSync(a,!1),this._sync.readFileSync(a,null,g.FileFlag.getFileFlag("r")))},b.prototype.unlinkSync=function(a){this.checkInitialized(),this._sync.unlinkSync(a),this.enqueueOp({apiMethod:"unlink",arguments:[a]})},b.prototype.rmdirSync=function(a){this.checkInitialized(),this._sync.rmdirSync(a),this.enqueueOp({apiMethod:"rmdir",arguments:[a]})},b.prototype.mkdirSync=function(a,b){this.checkInitialized(),this._sync.mkdirSync(a,b),this.enqueueOp({apiMethod:"mkdir",arguments:[a,b]})},b.prototype.readdirSync=function(a){return this.checkInitialized(),this._sync.readdirSync(a)},b.prototype.existsSync=function(a){return this.checkInitialized(),this._sync.existsSync(a)},b.prototype.chmodSync=function(a,b,c){this.checkInitialized(),this._sync.chmodSync(a,b,c),this.enqueueOp({apiMethod:"chmod",arguments:[a,b,c]})},b.prototype.chownSync=function(a,b,c,d){this.checkInitialized(),this._sync.chownSync(a,b,c,d),this.enqueueOp({apiMethod:"chown",arguments:[a,b,c,d]})},b.prototype.utimesSync=function(a,b,c){this.checkInitialized(),this._sync.utimesSync(a,b,c),this.enqueueOp({apiMethod:"utimes",arguments:[a,b,c]})},b}(e.SynchronousFileSystem);c.__esModule=!0,c.default=k},{"../core/api_error":52,"../core/file_flag":56,"../core/file_system":57,"../generic/preload_file":68,path:10}],38:[function(a,b,c){(function(b){"use strict";function d(){null===p&&(p={},p[Dropbox.ApiError.NETWORK_ERROR]=l.ErrorCode.EIO,p[Dropbox.ApiError.INVALID_PARAM]=l.ErrorCode.EINVAL,p[Dropbox.ApiError.INVALID_TOKEN]=l.ErrorCode.EPERM,p[Dropbox.ApiError.OAUTH_ERROR]=l.ErrorCode.EPERM,p[Dropbox.ApiError.NOT_FOUND]=l.ErrorCode.ENOENT,p[Dropbox.ApiError.INVALID_METHOD]=l.ErrorCode.EINVAL,p[Dropbox.ApiError.NOT_ACCEPTABLE]=l.ErrorCode.EINVAL,p[Dropbox.ApiError.CONFLICT]=l.ErrorCode.EINVAL,p[Dropbox.ApiError.RATE_LIMITED]=l.ErrorCode.EBUSY,p[Dropbox.ApiError.SERVER_ERROR]=l.ErrorCode.EBUSY,p[Dropbox.ApiError.OVER_QUOTA]=l.ErrorCode.ENOSPC)}function e(a){return a&&a.stat.isFile}function f(a){return a&&a.stat.isFolder}function g(a){return null===a||void 0===a||"object"==typeof a&&"number"==typeof a.byteLength}var h=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)},i=a("../generic/preload_file"),j=a("../core/file_system"),k=a("../core/node_fs_stats"),l=a("../core/api_error"),m=a("async"),n=a("path"),o=a("../core/util"),p=null,q=function(){function a(a){this._cache={},this._client=a}return a.prototype.getCachedInfo=function(a){return this._cache[a.toLowerCase()]},a.prototype.putCachedInfo=function(a,b){this._cache[a.toLowerCase()]=b},a.prototype.deleteCachedInfo=function(a){delete this._cache[a.toLowerCase()]},a.prototype.getCachedDirInfo=function(a){var b=this.getCachedInfo(a);return f(b)?b:null},a.prototype.getCachedFileInfo=function(a){var b=this.getCachedInfo(a);return e(b)?b:null},a.prototype.updateCachedDirInfo=function(a,b,c){void 0===c&&(c=null);var d=this.getCachedInfo(a);null===b.contentHash||void 0!==d&&d.stat.contentHash===b.contentHash||this.putCachedInfo(a,{stat:b,contents:c})},a.prototype.updateCachedFileInfo=function(a,b,c){ +void 0===c&&(c=null);var d=this.getCachedInfo(a);null===b.versionTag||void 0!==d&&d.stat.versionTag===b.versionTag||this.putCachedInfo(a,{stat:b,contents:c})},a.prototype.updateCachedInfo=function(a,b,c){void 0===c&&(c=null),b.isFile&&g(c)?this.updateCachedFileInfo(a,b,c):b.isFolder&&Array.isArray(c)&&this.updateCachedDirInfo(a,b,c)},a.prototype.readdir=function(a,b){var c=this,d=this.getCachedDirInfo(a);this._wrap(function(b){null!==d&&d.contents?c._client.readdir(a,{contentHash:d.stat.contentHash},b):c._client.readdir(a,b)},function(e,f,g,h){e?e.status===Dropbox.ApiError.NO_CONTENT&&null!==d?b(null,d.contents.slice(0)):b(e):(c.updateCachedDirInfo(a,g,f.slice(0)),h.forEach(function(b){c.updateCachedInfo(n.join(a,b.name),b)}),b(null,f))})},a.prototype.remove=function(a,b){var c=this;this._wrap(function(b){c._client.remove(a,b)},function(d,e){d||c.updateCachedInfo(a,e),b(d)})},a.prototype.move=function(a,b,c){var d=this;this._wrap(function(c){d._client.move(a,b,c)},function(e,f){e||(d.deleteCachedInfo(a),d.updateCachedInfo(b,f)),c(e)})},a.prototype.stat=function(a,b){var c=this;this._wrap(function(b){c._client.stat(a,b)},function(d,e){d||c.updateCachedInfo(a,e),b(d,e)})},a.prototype.readFile=function(a,b){var c=this,d=this.getCachedFileInfo(a);null!==d&&null!==d.contents?this.stat(a,function(e,f){e?b(e):f.contentHash===d.stat.contentHash?b(e,d.contents.slice(0),d.stat):c.readFile(a,b)}):this._wrap(function(b){c._client.readFile(a,{arrayBuffer:!0},b)},function(d,e,f){d||c.updateCachedInfo(a,f,e.slice(0)),b(d,e,f)})},a.prototype.writeFile=function(a,b,c){var d=this;this._wrap(function(c){d._client.writeFile(a,b,c)},function(e,f){e||d.updateCachedInfo(a,f,b.slice(0)),c(e,f)})},a.prototype.mkdir=function(a,b){var c=this;this._wrap(function(b){c._client.mkdir(a,b)},function(d,e){d||c.updateCachedInfo(a,e,[]),b(d)})},a.prototype._wrap=function(a,b){var c=0,d=function(e){var f=2;if(e&&3>++c)switch(e.status){case Dropbox.ApiError.SERVER_ERROR:case Dropbox.ApiError.NETWORK_ERROR:case Dropbox.ApiError.RATE_LIMITED:setTimeout(function(){a(d)},1e3*f);break;default:b.apply(null,arguments)}else b.apply(null,arguments)};a(d)},a}(),r=function(a){function b(b,c,d,e,f){a.call(this,b,c,d,e,f)}return h(b,a),b.prototype.sync=function(a){var b=this;if(this.isDirty()){var c=this.getBuffer(),d=o.buffer2ArrayBuffer(c);this._fs._writeFileStrict(this.getPath(),d,function(c){c||b.resetDirty(),a(c)})}else a()},b.prototype.close=function(a){this.sync(a)},b}(i.PreloadFile);c.DropboxFile=r;var s=function(a){function c(b){a.call(this),this._client=new q(b),d()}return h(c,a),c.prototype.getName=function(){return"Dropbox"},c.isAvailable=function(){return"undefined"!=typeof Dropbox},c.prototype.isReadOnly=function(){return!1},c.prototype.supportsSymlinks=function(){return!1},c.prototype.supportsProps=function(){return!1},c.prototype.supportsSynch=function(){return!1},c.prototype.empty=function(a){var b=this;this._client.readdir("/",function(c,d){if(c)a(b.convert(c,"/"));else{var e=function(a,c){var d=n.join("/",a);b._client.remove(d,function(a){c(a?b.convert(a,d):null)})},f=function(b){b?a(b):a()};m.each(d,e,f)}})},c.prototype.rename=function(a,b,c){var d=this;this._client.move(a,b,function(e){e?d._client.stat(b,function(f,g){if(f||g.isFolder){var h=e.response.error.indexOf(a)>-1?a:b;c(d.convert(e,h))}else d._client.remove(b,function(e){e?c(d.convert(e,b)):d.rename(a,b,c)})}):c()})},c.prototype.stat=function(a,b,c){var d=this;this._client.stat(a,function(b,e){if(b)c(d.convert(b,a));else{if(null==e||!e.isRemoved){var f=new k.default(d._statType(e),e.size);return c(null,f)}c(l.ApiError.FileError(l.ErrorCode.ENOENT,a))}})},c.prototype.open=function(a,c,d,e){var f=this;this._client.readFile(a,function(d,g,h){if(!d){var i;i=null===g?new b(0):o.arrayBuffer2Buffer(g);var j=f._makeFile(a,c,h,i);return e(null,j)}if(c.isReadable())e(f.convert(d,a));else switch(d.status){case Dropbox.ApiError.NOT_FOUND:var k=new ArrayBuffer(0);return f._writeFileStrict(a,k,function(b,d){if(b)e(b);else{var g=f._makeFile(a,c,d,o.arrayBuffer2Buffer(k));e(null,g)}});default:return e(f.convert(d,a))}})},c.prototype._writeFileStrict=function(a,b,c){var d=this,e=n.dirname(a);this.stat(e,!1,function(f,g){f?c(l.ApiError.FileError(l.ErrorCode.ENOENT,e)):d._client.writeFile(a,b,function(b,e){b?c(d.convert(b,a)):c(null,e)})})},c.prototype._statType=function(a){return a.isFile?k.FileType.FILE:k.FileType.DIRECTORY},c.prototype._makeFile=function(a,b,c,d){var e=this._statType(c),f=new k.default(e,c.size);return new r(this,a,b,f,d)},c.prototype._remove=function(a,b,c){var d=this;this._client.stat(a,function(e,f){e?b(d.convert(e,a)):f.isFile&&!c?b(l.ApiError.FileError(l.ErrorCode.ENOTDIR,a)):!f.isFile&&c?b(l.ApiError.FileError(l.ErrorCode.EISDIR,a)):d._client.remove(a,function(c){b(c?d.convert(c,a):null)})})},c.prototype.unlink=function(a,b){this._remove(a,b,!0)},c.prototype.rmdir=function(a,b){this._remove(a,b,!1)},c.prototype.mkdir=function(a,b,c){var d=this,e=n.dirname(a);this._client.stat(e,function(b,f){b?c(d.convert(b,e)):d._client.mkdir(a,function(b){c(b?l.ApiError.FileError(l.ErrorCode.EEXIST,a):null)})})},c.prototype.readdir=function(a,b){var c=this;this._client.readdir(a,function(a,d){return a?b(c.convert(a)):b(null,d)})},c.prototype.convert=function(a,b){void 0===b&&(b=null);var c=p[a.status];return void 0===c&&(c=l.ErrorCode.EIO),null==b?new l.ApiError(c):l.ApiError.FileError(c,b)},c}(j.BaseFileSystem);c.__esModule=!0,c.default=s}).call(this,a("bfs-buffer").Buffer)},{"../core/api_error":52,"../core/file_system":57,"../core/node_fs_stats":60,"../core/util":61,"../generic/preload_file":68,async:1,"bfs-buffer":2,path:10}],39:[function(a,b,c){(function(b){"use strict";function d(a,b){void 0===b&&(b="");for(var c=a.errno,d=a.node,e=[];d&&(e.unshift(d.name),d!==d.parent);)d=d.parent;return new j.ApiError(c,j.ErrorStrings[c],e.length>0?"/"+e.join("/"):b)}var e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)},f=a("../core/file_system"),g=a("../core/node_fs_stats"),h=a("../core/file"),i=a("../core/util"),j=a("../core/api_error"),k=function(a){function b(b,c,d,e,f){a.call(this),this._fs=b,this._FS=c,this._path=d,this._flag=e,this._stream=f}return e(b,a),b.prototype.getPos=function(){},b.prototype.close=function(a){var b=null;try{this.closeSync()}catch(a){b=a}finally{a(b)}},b.prototype.closeSync=function(){try{this._FS.close(this._stream)}catch(a){throw d(a,this._path)}},b.prototype.stat=function(a){try{a(null,this.statSync())}catch(b){a(b)}},b.prototype.statSync=function(){try{return this._fs.statSync(this._path,!1)}catch(a){throw d(a,this._path)}},b.prototype.truncate=function(a,b){var c=null;try{this.truncateSync(a)}catch(a){c=a}finally{b(c)}},b.prototype.truncateSync=function(a){try{this._FS.ftruncate(this._stream.fd,a)}catch(a){throw d(a,this._path)}},b.prototype.write=function(a,b,c,d,e){try{e(null,this.writeSync(a,b,c,d),a)}catch(a){e(a)}},b.prototype.writeSync=function(a,b,c,e){try{var f=i.buffer2Uint8array(a);return null===e&&(e=void 0),this._FS.write(this._stream,f,b,c,e)}catch(a){throw d(a,this._path)}},b.prototype.read=function(a,b,c,d,e){try{e(null,this.readSync(a,b,c,d),a)}catch(a){e(a)}},b.prototype.readSync=function(a,b,c,e){try{var f=i.buffer2Uint8array(a);return null===e&&(e=void 0),this._FS.read(this._stream,f,b,c,e)}catch(a){throw d(a,this._path)}},b.prototype.sync=function(a){a()},b.prototype.syncSync=function(){},b.prototype.chown=function(a,b,c){var d=null;try{this.chownSync(a,b)}catch(a){d=a}finally{c(d)}},b.prototype.chownSync=function(a,b){try{this._FS.fchown(this._stream.fd,a,b)}catch(a){throw d(a,this._path)}},b.prototype.chmod=function(a,b){var c=null;try{this.chmodSync(a)}catch(a){c=a}finally{b(c)}},b.prototype.chmodSync=function(a){try{this._FS.fchmod(this._stream.fd,a)}catch(a){throw d(a,this._path)}},b.prototype.utimes=function(a,b,c){var d=null;try{this.utimesSync(a,b)}catch(a){d=a}finally{c(d)}},b.prototype.utimesSync=function(a,b){this._fs.utimesSync(this._path,a,b)},b}(h.BaseFile);c.EmscriptenFile=k;var l=function(a){function c(b){a.call(this),this._FS=b}return e(c,a),c.isAvailable=function(){return!0},c.prototype.getName=function(){return this._FS.DB_NAME()},c.prototype.isReadOnly=function(){return!1},c.prototype.supportsLinks=function(){return!0},c.prototype.supportsProps=function(){return!0},c.prototype.supportsSynch=function(){return!0},c.prototype.renameSync=function(a,b){try{this._FS.rename(a,b)}catch(c){throw c.errno===j.ErrorCode.ENOENT?d(c,this.existsSync(a)?b:a):d(c)}},c.prototype.statSync=function(a,b){try{var c=b?this._FS.lstat(a):this._FS.stat(a),e=this.modeToFileType(c.mode);return new g.default(e,c.size,c.mode,c.atime,c.mtime,c.ctime)}catch(b){throw d(b,a)}},c.prototype.modeToFileType=function(a){return this._FS.isDir(a)?g.FileType.DIRECTORY:this._FS.isFile(a)?g.FileType.FILE:this._FS.isLink(a)?g.FileType.SYMLINK:void 0},c.prototype._tryStats=function(a){try{return this.statSync(a,!1)}catch(a){return null}},c.prototype.openSync=function(a,b,c){try{var e=this._FS.open(a,b.getFlagString(),c);if(this._FS.isDir(e.node.mode))throw this._FS.close(e),j.ApiError.EISDIR(a);return new k(this,this._FS,a,b,e)}catch(b){throw d(b,a)}},c.prototype.unlinkSync=function(a){try{this._FS.unlink(a)}catch(b){throw d(b,a)}},c.prototype.rmdirSync=function(a){try{this._FS.rmdir(a)}catch(b){throw d(b,a)}},c.prototype.mkdirSync=function(a,b){try{this._FS.mkdir(a,b)}catch(b){throw d(b,a)}},c.prototype.readdirSync=function(a){try{return this._FS.readdir(a).filter(function(a){return"."!==a&&".."!==a})}catch(b){throw d(b,a)}},c.prototype.truncateSync=function(a,b){try{this._FS.truncate(a,b)}catch(b){throw d(b,a)}},c.prototype.readFileSync=function(a,b,c){try{var e=this._FS.readFile(a,{flags:c.getFlagString()}),f=i.uint8Array2Buffer(e);return b?f.toString(b):f}catch(b){throw d(b,a)}},c.prototype.writeFileSync=function(a,c,e,f,g){try{e&&(c=new b(c,e));var h=i.buffer2Uint8array(c);this._FS.writeFile(a,h,{flags:f.getFlagString(),encoding:"binary"}),this._FS.chmod(a,g)}catch(b){throw d(b,a)}},c.prototype.chmodSync=function(a,b,c){try{b?this._FS.lchmod(a,c):this._FS.chmod(a,c)}catch(b){throw d(b,a)}},c.prototype.chownSync=function(a,b,c,e){try{b?this._FS.lchown(a,c,e):this._FS.chown(a,c,e)}catch(b){throw d(b,a)}},c.prototype.symlinkSync=function(a,b,c){try{this._FS.symlink(a,b)}catch(a){throw d(a)}},c.prototype.readlinkSync=function(a){try{return this._FS.readlink(a)}catch(b){throw d(b,a)}},c.prototype.utimesSync=function(a,b,c){try{this._FS.utime(a,b.getTime(),c.getTime())}catch(b){throw d(b,a)}},c}(f.SynchronousFileSystem);c.__esModule=!0,c.default=l}).call(this,a("bfs-buffer").Buffer)},{"../core/api_error":52,"../core/file":55,"../core/file_system":57,"../core/node_fs_stats":60,"../core/util":61,"bfs-buffer":2}],40:[function(a,b,c){"use strict";function d(a,b){if(null!==b&&"object"==typeof b){var c=b,d=c.path;d&&(d="/"+i.relative(a,d),c.message=c.message.replace(c.path,d),c.path=d)}return b}function e(a,b){return"function"==typeof b?function(c){arguments.length>0&&(arguments[0]=d(a,c)),b.apply(null,arguments)}:b}function f(a,b,c){return"Sync"!==a.slice(a.length-4)?function(){return arguments.length>0&&(b&&(arguments[0]=i.join(this._folder,arguments[0])),c&&(arguments[1]=i.join(this._folder,arguments[1])),arguments[arguments.length-1]=e(this._folder,arguments[arguments.length-1])),this._wrapped[a].apply(this._wrapped,arguments)}:function(){try{return b&&(arguments[0]=i.join(this._folder,arguments[0])),c&&(arguments[1]=i.join(this._folder,arguments[1])),this._wrapped[a].apply(this._wrapped,arguments)}catch(a){throw d(this._folder,a)}}}var g=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)},h=a("../core/file_system"),i=a("path"),j=a("../core/api_error"),k=function(a){function b(b,c){a.call(this),this._folder=b,this._wrapped=c}return g(b,a),b.prototype.initialize=function(a){var b=this;this._wrapped.exists(this._folder,function(c){c?a():b._wrapped.isReadOnly()?a(j.ApiError.ENOENT(b._folder)):b._wrapped.mkdir(b._folder,511,a)})},b.prototype.getName=function(){return this._wrapped.getName()},b.prototype.isReadOnly=function(){return this._wrapped.isReadOnly()},b.prototype.supportsProps=function(){return this._wrapped.supportsProps()},b.prototype.supportsSynch=function(){return this._wrapped.supportsSynch()},b.prototype.supportsLinks=function(){return!1},b.isAvailable=function(){return!0},b}(h.BaseFileSystem);c.__esModule=!0,c.default=k,["diskSpace","stat","statSync","open","openSync","unlink","unlinkSync","rmdir","rmdirSync","mkdir","mkdirSync","readdir","readdirSync","exists","existsSync","realpath","realpathSync","truncate","truncateSync","readFile","readFileSync","writeFile","writeFileSync","appendFile","appendFileSync","chmod","chmodSync","chown","chownSync","utimes","utimesSync","readlink","readlinkSync"].forEach(function(a){k.prototype[a]=f(a,!0,!1)}),["rename","renameSync","link","linkSync","symlink","symlinkSync"].forEach(function(a){k.prototype[a]=f(a,!0,!0)})},{"../core/api_error":52,"../core/file_system":57,path:10}],41:[function(a,b,c){"use strict";function d(a){return a.isDirectory}function e(a,b,c,d){if("undefined"!=typeof navigator.webkitPersistentStorage)switch(a){case n.PERSISTENT:navigator.webkitPersistentStorage.requestQuota(b,c,d);break;case n.TEMPORARY:navigator.webkitTemporaryStorage.requestQuota(b,c,d);break;default:d(new TypeError("Invalid storage type: "+a))}else n.webkitStorageInfo.requestQuota(a,b,c,d)}function f(a){return Array.prototype.slice.call(a||[],0)}var g=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)},h=a("../generic/preload_file"),i=a("../core/file_system"),j=a("../core/api_error"),k=a("../core/file_flag"),l=a("../core/node_fs_stats"),m=a("path"),n=a("../core/global"),o=a("async"),p=a("../core/util"),q=n.webkitRequestFileSystem||n.requestFileSystem||null,r=function(a){function b(b,c,d,e,f){a.call(this,b,c,d,e,f)}return g(b,a),b.prototype.sync=function(a){var b=this;if(this.isDirty()){var c={create:!1},d=this._fs,e=function(c){c.createWriter(function(c){var e=b.getBuffer(),f=new Blob([p.buffer2ArrayBuffer(e)]),g=f.size;c.onwriteend=function(){c.onwriteend=null,c.truncate(g),b.resetDirty(),a()},c.onerror=function(c){a(d.convert(c,b.getPath(),!1))},c.write(f)})},f=function(c){a(d.convert(c,b.getPath(),!1))};d.fs.root.getFile(this.getPath(),c,e,f)}else a()},b.prototype.close=function(a){this.sync(a)},b}(h.PreloadFile);c.HTML5FSFile=r;var s=function(a){function b(b,c){void 0===b&&(b=5),void 0===c&&(c=n.PERSISTENT),a.call(this),this.size=1048576*b,this.type=c}return g(b,a),b.prototype.getName=function(){return"HTML5 FileSystem"},b.isAvailable=function(){return null!=q},b.prototype.isReadOnly=function(){return!1},b.prototype.supportsSymlinks=function(){return!1},b.prototype.supportsProps=function(){return!1},b.prototype.supportsSynch=function(){return!1},b.prototype.convert=function(a,b,c){switch(a.name){case"PathExistsError":return j.ApiError.EEXIST(b);case"QuotaExceededError":return j.ApiError.FileError(j.ErrorCode.ENOSPC,b);case"NotFoundError":return j.ApiError.ENOENT(b);case"SecurityError":return j.ApiError.FileError(j.ErrorCode.EACCES,b);case"InvalidModificationError":return j.ApiError.FileError(j.ErrorCode.EPERM,b);case"TypeMismatchError":return j.ApiError.FileError(c?j.ErrorCode.ENOTDIR:j.ErrorCode.EISDIR,b);case"EncodingError":case"InvalidStateError":case"NoModificationAllowedError":default:return j.ApiError.FileError(j.ErrorCode.EINVAL,b)}},b.prototype.allocate=function(a){var b=this;void 0===a&&(a=function(){});var c=function(c){b.fs=c,a()},d=function(c){a(b.convert(c,"/",!0))};this.type===n.PERSISTENT?e(this.type,this.size,function(a){q(b.type,a,c,d)},d):q(this.type,this.size,c,d)},b.prototype.empty=function(a){var b=this;this._readdir("/",function(c,e){if(c)console.error("Failed to empty FS"),a(c);else{var f=function(b){c?(console.error("Failed to empty FS"),a(c)):a()},g=function(a,c){var e=function(){c()},f=function(d){c(b.convert(d,a.fullPath,!a.isDirectory))};d(a)?a.removeRecursively(e,f):a.remove(e,f)};o.each(e,g,f)}})},b.prototype.rename=function(a,b,c){var d=this,e=2,f=0,g=this.fs.root,h=a,i=function(a){--e<=0&&c(d.convert(a,h,!1))},k=function(e){return 2===++f?c(new j.ApiError(j.ErrorCode.EINVAL,"Something was identified as both a file and a directory. This should never happen.")):a===b?c():(h=m.dirname(b),void g.getDirectory(h,{},function(f){h=m.basename(b),e.moveTo(f,h,function(a){c()},function(f){e.isDirectory?(h=b,d.unlink(b,function(e){e?i(f):d.rename(a,b,c)})):i(f)})},i))};g.getFile(a,{},k,i),g.getDirectory(a,{},k,i)},b.prototype.stat=function(a,b,c){var d=this,e={create:!1},f=function(a){var b=function(a){var b=new l.default(l.FileType.FILE,a.size);c(null,b)};a.file(b,h)},g=function(a){var b=4096,d=new l.default(l.FileType.DIRECTORY,b);c(null,d)},h=function(b){c(d.convert(b,a,!1))},i=function(){d.fs.root.getDirectory(a,e,g,h)};this.fs.root.getFile(a,e,f,i)},b.prototype.open=function(a,b,c,d){var e=this,f=function(c){d("InvalidModificationError"===c.name&&b.isExclusive()?j.ApiError.EEXIST(a):e.convert(c,a,!1))};this.fs.root.getFile(a,{create:b.pathNotExistsAction()===k.ActionType.CREATE_FILE,exclusive:b.isExclusive()},function(c){c.file(function(c){var g=new FileReader;g.onloadend=function(f){var h=e._makeFile(a,b,c,g.result);d(null,h)},g.onerror=function(a){f(g.error)},g.readAsArrayBuffer(c)},f)},f)},b.prototype._statType=function(a){return a.isFile?l.FileType.FILE:l.FileType.DIRECTORY},b.prototype._makeFile=function(a,b,c,d){void 0===d&&(d=new ArrayBuffer(0));var e=new l.default(l.FileType.FILE,c.size),f=p.arrayBuffer2Buffer(d);return new r(this,a,b,e,f)},b.prototype._remove=function(a,b,c){var d=this,e=function(e){var f=function(){b()},g=function(e){b(d.convert(e,a,!c))};e.remove(f,g)},f=function(e){b(d.convert(e,a,!c))},g={create:!1};c?this.fs.root.getFile(a,g,e,f):this.fs.root.getDirectory(a,g,e,f)},b.prototype.unlink=function(a,b){this._remove(a,b,!0)},b.prototype.rmdir=function(a,b){var c=this;this.readdir(a,function(d,e){d?b(d):e.length>0?b(j.ApiError.ENOTEMPTY(a)):c._remove(a,b,!1)})},b.prototype.mkdir=function(a,b,c){var d=this,e={create:!0,exclusive:!0},f=function(a){c()},g=function(b){c(d.convert(b,a,!0))};this.fs.root.getDirectory(a,e,f,g)},b.prototype._readdir=function(a,b){var c=this,d=function(d){b(c.convert(d,a,!0))};this.fs.root.getDirectory(a,{create:!1},function(a){var c=a.createReader(),e=[],g=function(){c.readEntries(function(a){a.length?(e=e.concat(f(a)),g()):b(null,e)},d)};g()},d)},b.prototype.readdir=function(a,b){this._readdir(a,function(a,c){if(a)return b(a);for(var d=[],e=0;e0&&a[0]instanceof h.ApiError&&d.standardizeError(a[0],f.path,e),g.apply(null,a)}}return f.fs[a].apply(f.fs,b)}}var e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)},f=a("../core/file_system"),g=a("./InMemory"),h=a("../core/api_error"),i=a("../core/node_fs"),j=a("path"),k=a("../core/util"),l=function(a){function b(){a.call(this),this.mountList=[],this.mntMap={},this.rootFs=new g.default}return e(b,a),b.prototype.mount=function(a,b){if("/"!==a[0]&&(a="/"+a),a=j.resolve(a),this.mntMap[a])throw new h.ApiError(h.ErrorCode.EINVAL,"Mount point "+a+" is already taken.");k.mkdirpSync(a,511,this.rootFs),this.mntMap[a]=b,this.mountList.push(a),this.mountList=this.mountList.sort(function(a,b){return b.length-a.length})},b.prototype.umount=function(a){if("/"!==a[0]&&(a="/"+a),a=j.resolve(a),!this.mntMap[a])throw new h.ApiError(h.ErrorCode.EINVAL,"Mount point "+a+" is already unmounted.");for(delete this.mntMap[a],this.mountList.splice(this.mountList.indexOf(a),1);"/"!==a&&0===this.rootFs.readdirSync(a).length;)this.rootFs.rmdirSync(a),a=j.dirname(a)},b.prototype._getFs=function(a){for(var b=this.mountList,c=b.length,d=0;d1?e.length:0),""===a&&(a="/"),{fs:this.mntMap[e],path:a}}return{fs:this.rootFs,path:a}},b.prototype.getName=function(){return"MountableFileSystem"},b.isAvailable=function(){return!0},b.prototype.diskSpace=function(a,b){b(0,0)},b.prototype.isReadOnly=function(){return!1},b.prototype.supportsLinks=function(){return!1},b.prototype.supportsProps=function(){return!1},b.prototype.supportsSynch=function(){return!0},b.prototype.standardizeError=function(a,b,c){var d;return-1!==(d=a.message.indexOf(b))&&(a.message=a.message.substr(0,d)+c+a.message.substr(d+b.length),a.path=c),a},b.prototype.rename=function(a,b,c){var d=this._getFs(a),e=this._getFs(b);if(d.fs===e.fs){var f=this;return d.fs.rename(d.path,e.path,function(g){g&&f.standardizeError(f.standardizeError(g,d.path,a),e.path,b),c(g)})}return i.readFile(a,function(d,e){return d?c(d):void i.writeFile(b,e,function(b){return b?c(b):void i.unlink(a,c)})})},b.prototype.renameSync=function(a,b){var c=this._getFs(a),d=this._getFs(b);if(c.fs===d.fs)try{return c.fs.renameSync(c.path,d.path)}catch(e){throw this.standardizeError(this.standardizeError(e,c.path,a),d.path,b),e}var e=i.readFileSync(a);return i.writeFileSync(b,e),i.unlinkSync(a)},b.prototype.readdirSync=function(a){var b=this._getFs(a),c=null;if(b.fs!==this.rootFs)try{c=this.rootFs.readdirSync(a)}catch(a){}try{var d=b.fs.readdirSync(b.path);return null===c?d:d.concat(c.filter(function(a){return d.indexOf(a)===-1}))}catch(d){if(null===c)throw this.standardizeError(d,b.path,a);return c}},b.prototype.readdir=function(a,b){var c=this,d=this._getFs(a);d.fs.readdir(d.path,function(e,f){if(d.fs!==c.rootFs)try{var g=c.rootFs.readdirSync(a);f=f?f.concat(g.filter(function(a){return f.indexOf(a)===-1})):g}catch(f){if(e)return b(c.standardizeError(e,d.path,a))}else if(e)return b(c.standardizeError(e,d.path,a));b(null,f)})},b.prototype.rmdirSync=function(a){var b=this._getFs(a);if(this._containsMountPt(a))throw h.ApiError.ENOTEMPTY(a);try{b.fs.rmdirSync(b.path)}catch(c){throw this.standardizeError(c,b.path,a)}},b.prototype._containsMountPt=function(a){for(var b=this.mountList,c=b.length,d=0;d=a.length&&e.slice(0,a.length)===a)return!0}return!1},b.prototype.rmdir=function(a,b){var c=this,d=this._getFs(a);this._containsMountPt(a)?b(h.ApiError.ENOTEMPTY(a)):d.fs.rmdir(d.path,function(e){b(e?c.standardizeError(e,d.path,a):null)})},b}(f.BaseFileSystem);c.__esModule=!0,c.default=l;for(var m=[["exists","unlink","readlink"],["stat","mkdir","realpath","truncate"],["open","readFile","chmod","utimes"],["chown"],["writeFile","appendFile"]],n=0;n0)throw h.ApiError.ENOTEMPTY(b)}this._writable.existsSync(a)?this._writable.renameSync(a,b):this._writable.existsSync(b)||this._writable.mkdirSync(b,f),this._readable.existsSync(a)&&this._readable.readdirSync(a).forEach(function(d){c.renameSync(l.resolve(a,d),l.resolve(b,d))})}else{if(this.existsSync(b)&&this.statSync(b,!1).isDirectory())throw h.ApiError.EISDIR(b);this.writeFileSync(b,this.readFileSync(a,null,e("r")),null,e("w"),d.mode)}a!==b&&this.existsSync(a)&&this.unlinkSync(a)},b.prototype.stat=function(a,b,c){var e=this;this.checkInitAsync(c)&&this._writable.stat(a,b,function(f,g){f&&f.errno===h.ErrorCode.ENOENT?(e._deletedFiles[a]&&c(h.ApiError.ENOENT(a)),e._readable.stat(a,b,function(a,b){b&&(b=b.clone(),b.mode=d(b.mode)),c(a,b)})):c(f,g)})},b.prototype.statSync=function(a,b){this.checkInitialized();try{return this._writable.statSync(a,b)}catch(e){if(this._deletedFiles[a])throw h.ApiError.ENOENT(a);var c=this._readable.statSync(a,b).clone();return c.mode=d(c.mode),c}},b.prototype.open=function(a,b,c,d){var f=this;this.checkInitAsync(d)&&!this.checkPathAsync(a,d)&&this.stat(a,!1,function(g,j){if(j)switch(b.pathExistsAction()){case i.ActionType.TRUNCATE_FILE:return f.createParentDirectoriesAsync(a,function(e){return e?d(e):void f._writable.open(a,b,c,d)});case i.ActionType.NOP:return f._writable.exists(a,function(g){g?f._writable.open(a,b,c,d):(j=j.clone(),j.mode=c,f._readable.readFile(a,null,e("r"),function(c,e){if(c)return d(c);j.size===-1&&(j.size=e.length);var g=new n(f,a,b,j,e);d(null,g)}))});default:return d(h.ApiError.EEXIST(a))}else switch(b.pathNotExistsAction()){case i.ActionType.CREATE_FILE:return f.createParentDirectoriesAsync(a,function(e){return e?d(e):f._writable.open(a,b,c,d)});default:return d(h.ApiError.ENOENT(a))}})},b.prototype.openSync=function(a,b,c){if(this.checkInitialized(),this.checkPath(a),a===m)throw h.ApiError.EPERM("Cannot open deletion log.");if(this.existsSync(a))switch(b.pathExistsAction()){case i.ActionType.TRUNCATE_FILE:return this.createParentDirectories(a),this._writable.openSync(a,b,c);case i.ActionType.NOP:if(this._writable.existsSync(a))return this._writable.openSync(a,b,c);var d=this._readable.readFileSync(a,null,e("r")),f=this._readable.statSync(a,!1).clone();return f.mode=c,new n(this,a,b,f,d);default:throw h.ApiError.EEXIST(a)}else switch(b.pathNotExistsAction()){case i.ActionType.CREATE_FILE:return this.createParentDirectories(a),this._writable.openSync(a,b,c);default:throw h.ApiError.ENOENT(a)}},b.prototype.unlink=function(a,b){var c=this;this.checkInitAsync(b)&&!this.checkPathAsync(a,b)&&this.exists(a,function(d){return d?void c._writable.exists(a,function(d){return d?c._writable.unlink(a,function(d){return d?b(d):void c.exists(a,function(d){d&&c.deletePath(a),b(null)})}):(c.deletePath(a),void b(null))}):b(h.ApiError.ENOENT(a))})},b.prototype.unlinkSync=function(a){if(this.checkInitialized(),this.checkPath(a),!this.existsSync(a))throw h.ApiError.ENOENT(a);this._writable.existsSync(a)&&this._writable.unlinkSync(a),this.existsSync(a)&&this.deletePath(a)},b.prototype.rmdir=function(a,b){var c=this;if(this.checkInitAsync(b)){var d=function(){c.readdir(a,function(d,e){return d?b(d):e.length?b(h.ApiError.ENOTEMPTY(a)):(c.deletePath(a),void b(null))})};this.exists(a,function(e){return e?void c._writable.exists(a,function(e){e?c._writable.rmdir(a,function(e){return e?b(e):void c._readable.exists(a,function(a){a?d():b()})}):d()}):b(h.ApiError.ENOENT(a))})}},b.prototype.rmdirSync=function(a){if(this.checkInitialized(),!this.existsSync(a))throw h.ApiError.ENOENT(a);if(this._writable.existsSync(a)&&this._writable.rmdirSync(a),this.existsSync(a)){if(this.readdirSync(a).length>0)throw h.ApiError.ENOTEMPTY(a);this.deletePath(a)}},b.prototype.mkdir=function(a,b,c){var d=this;this.checkInitAsync(c)&&this.exists(a,function(e){return e?c(h.ApiError.EEXIST(a)):void d.createParentDirectoriesAsync(a,function(e){return e?c(e):void d._writable.mkdir(a,b,c)})})},b.prototype.mkdirSync=function(a,b){if(this.checkInitialized(),this.existsSync(a))throw h.ApiError.EEXIST(a);this.createParentDirectories(a),this._writable.mkdirSync(a,b)},b.prototype.readdir=function(a,b){var c=this;this.checkInitAsync(b)&&this.stat(a,!1,function(d,e){return d?b(d):e.isDirectory()?void c._writable.readdir(a,function(d,e){return d&&"ENOENT"!==d.code?b(d):(!d&&e||(e=[]),void c._readable.readdir(a,function(d,f){!d&&f||(f=[]);var g={},h=e.concat(f.filter(function(b){return!c._deletedFiles[a+"/"+b]})).filter(function(a){var b=!g[a];return g[a]=!0,b});b(null,h)}))}):b(h.ApiError.ENOTDIR(a))})},b.prototype.readdirSync=function(a){var b=this;this.checkInitialized();var c=this.statSync(a,!1);if(!c.isDirectory())throw h.ApiError.ENOTDIR(a);var d=[];try{d=d.concat(this._writable.readdirSync(a))}catch(a){}try{d=d.concat(this._readable.readdirSync(a).filter(function(c){return!b._deletedFiles[a+"/"+c]}))}catch(a){}var e={};return d.filter(function(a){var b=!e[a];return e[a]=!0,b})},b.prototype.exists=function(a,b){var c=this;this.checkInitialized(),this._writable.exists(a,function(d){return d?b(!0):void c._readable.exists(a,function(d){b(d&&c._deletedFiles[a]!==!0)})})},b.prototype.existsSync=function(a){return this.checkInitialized(),this._writable.existsSync(a)||this._readable.existsSync(a)&&this._deletedFiles[a]!==!0},b.prototype.chmod=function(a,b,c,d){var e=this;this.checkInitAsync(d)&&this.operateOnWritableAsync(a,function(f){return f?d(f):void e._writable.chmod(a,b,c,d)})},b.prototype.chmodSync=function(a,b,c){var d=this;this.checkInitialized(),this.operateOnWritable(a,function(){d._writable.chmodSync(a,b,c)})},b.prototype.chown=function(a,b,c,d,e){var f=this;this.checkInitAsync(e)&&this.operateOnWritableAsync(a,function(g){return g?e(g):void f._writable.chown(a,b,c,d,e)})},b.prototype.chownSync=function(a,b,c,d){var e=this;this.checkInitialized(),this.operateOnWritable(a,function(){e._writable.chownSync(a,b,c,d)})},b.prototype.utimes=function(a,b,c,d){var e=this;this.checkInitAsync(d)&&this.operateOnWritableAsync(a,function(f){return f?d(f):void e._writable.utimes(a,b,c,d)})},b.prototype.utimesSync=function(a,b,c){var d=this;this.checkInitialized(),this.operateOnWritable(a,function(){d._writable.utimesSync(a,b,c)})},b.prototype.operateOnWritable=function(a,b){if(!this.existsSync(a))throw h.ApiError.ENOENT(a);this._writable.existsSync(a)||this.copyToWritable(a),b()},b.prototype.operateOnWritableAsync=function(a,b){var c=this;this.exists(a,function(d){return d?void c._writable.exists(a,function(d){return d?void b():c.copyToWritableAsync(a,b)}):b(h.ApiError.ENOENT(a))})},b.prototype.copyToWritable=function(a){var b=this.statSync(a,!1);b.isDirectory()?this._writable.mkdirSync(a,b.mode):this.writeFileSync(a,this._readable.readFileSync(a,null,e("r")),null,e("w"),this.statSync(a,!1).mode)},b.prototype.copyToWritableAsync=function(a,b){var c=this;this.stat(a,!1,function(d,f){return d?b(d):f.isDirectory()?c._writable.mkdir(a,f.mode,b):void c._readable.readFile(a,null,e("r"),function(d,g){return d?b(d):void c.writeFile(a,g,null,e("w"),f.mode,b)})})},b}(g.BaseFileSystem);c.UnlockedOverlayFS=o;var p=function(a){function b(b,c){a.call(this,new o(b,c))}return f(b,a),b.prototype.initialize=function(b){a.prototype.initialize.call(this,b)},b.isAvailable=function(){return o.isAvailable()},b.prototype.getOverlayedFileSystems=function(){return a.prototype.getFSUnlocked.call(this).getOverlayedFileSystems()},b.prototype.unwrap=function(){return a.prototype.getFSUnlocked.call(this)},b}(k.default);c.__esModule=!0,c.default=p},{"../core/api_error":52,"../core/file_flag":56,"../core/file_system":57,"../generic/locked_fs":66,"../generic/preload_file":68,path:10}],47:[function(a,b,c){(function(b){"use strict";function d(a){return{type:r.API_ERROR,errorData:l(a.writeToBuffer())}}function e(a){return u.ApiError.fromBuffer(m(a.errorData))}function f(a){return{type:r.ERROR,name:a.name,message:a.message,stack:a.stack}}function g(a){var b=A[a.name];"function"!=typeof b&&(b=Error);var c=new b(a.message);return c.stack=a.stack,c}function h(a){return{type:r.STATS,statsData:l(a.toBuffer())}}function i(a){return y.default.fromBuffer(m(a.statsData))}function j(a){return{type:r.FILEFLAG,flagStr:a.getFlagString()}}function k(a){return v.FileFlag.getFileFlag(a.flagStr)}function l(a){return w.buffer2ArrayBuffer(a)}function m(a){return w.arrayBuffer2Buffer(a)}function n(a){return{type:r.BUFFER,data:l(a)}}function o(a){return m(a.data)}function p(a){return null!=a&&"object"==typeof a&&a.hasOwnProperty("browserfsMessage")&&a.browserfsMessage}function q(a){return null!=a&&"object"==typeof a&&a.hasOwnProperty("browserfsMessage")&&a.browserfsMessage}var r,s=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)},t=a("../core/file_system"),u=a("../core/api_error"),v=a("../core/file_flag"),w=a("../core/util"),x=a("../core/file"),y=a("../core/node_fs_stats"),z=a("../generic/preload_file"),A=a("../core/global"),B=a("../core/node_fs");!function(a){a[a.CB=0]="CB",a[a.FD=1]="FD",a[a.API_ERROR=2]="API_ERROR",a[a.STATS=3]="STATS",a[a.PROBE=4]="PROBE",a[a.FILEFLAG=5]="FILEFLAG",a[a.BUFFER=6]="BUFFER",a[a.ERROR=7]="ERROR"}(r||(r={}));var C=function(){function a(){this._callbacks={},this._nextId=0}return a.prototype.toRemoteArg=function(a){var b=this._nextId++;return this._callbacks[b]=a,{type:r.CB,id:b}},a.prototype.toLocalArg=function(a){var b=this._callbacks[a];return delete this._callbacks[a],b},a}(),D=function(){function a(){this._fileDescriptors={},this._nextId=0}return a.prototype.toRemoteArg=function(a,c,d,e){var f,g,h=this._nextId++;this._fileDescriptors[h]=a,a.stat(function(i,j){i?e(i):(g=l(j.toBuffer()),d.isReadable()?a.read(new b(j.size),0,j.size,0,function(a,b,i){a?e(a):(f=l(i),e(null,{type:r.FD,id:h,data:f,stat:g,path:c,flag:d.getFlagString()}))}):e(null,{type:r.FD,id:h,data:new ArrayBuffer(0),stat:g,path:c,flag:d.getFlagString()}))})},a.prototype._applyFdChanges=function(a,b){var c=this._fileDescriptors[a.id],d=m(a.data),e=y.default.fromBuffer(m(a.stat)),f=v.FileFlag.getFileFlag(a.flag);f.isWriteable()?c.write(d,0,d.length,f.isAppendable()?c.getPos():0,function(a){function g(){c.stat(function(a,d){a?b(a):d.mode!==e.mode?c.chmod(e.mode,function(a){b(a,c)}):b(a,c)})}a?b(a):f.isAppendable()?g():c.truncate(d.length,function(){g()})}):b(null,c)},a.prototype.applyFdAPIRequest=function(a,b){var c=this,d=a.args[0];this._applyFdChanges(d,function(e,f){e?b(e):f[a.method](function(e){"close"===a.method&&delete c._fileDescriptors[d.id],b(e)})})},a}(),E=function(a){function b(b,c,d,e,f,g){a.call(this,b,c,d,e,g),this._remoteFdId=f}return s(b,a),b.prototype.getRemoteFdId=function(){return this._remoteFdId},b.prototype.toRemoteArg=function(){return{type:r.FD,id:this._remoteFdId,data:l(this.getBuffer()),stat:l(this.getStats().toBuffer()),path:this.getPath(),flag:this.getFlag().getFlagString()}},b.prototype._syncClose=function(a,b){var c=this;this.isDirty()?this._fs.syncClose(a,this,function(a){a||c.resetDirty(),b(a)}):b()},b.prototype.sync=function(a){this._syncClose("sync",a)},b.prototype.close=function(a){this._syncClose("close",a)},b}(z.PreloadFile),F=function(a){function c(b){var c=this;a.call(this),this._callbackConverter=new C,this._isInitialized=!1,this._isReadOnly=!1,this._supportLinks=!1,this._supportProps=!1,this._outstandingRequests={},this._worker=b,this._worker.addEventListener("message",function(a){var b=a.data;if(q(b)){var d,e=b.args,f=new Array(e.length);for(d=0;d0&&(i=-1,g={browserfsMessage:!0,cbId:j,args:[d(b)]},a.postMessage(g))}var e,g,h=new Array(arguments.length),i=arguments.length;for(e=0;e0&&"/"!==c.charAt(c.length-1)&&(c+="/"),this.prefixUrl=c;var d=null;if("string"==typeof b){if(d=this._requestFileSync(b,"json"),!d)throw new Error("Unable to find listing at URL: ${listingUrlOrObj}")}else d=b;this._index=l.FileIndex.fromListing(d)}return e(b,a),b.prototype.empty=function(){this._index.fileIterator(function(a){a.file_data=null})},b.prototype.getXhrPath=function(a){return"/"===a.charAt(0)&&(a=a.slice(1)),this.prefixUrl+a},b.prototype._requestFileSizeAsync=function(a,b){k.getFileSizeAsync(this.getXhrPath(a),b)},b.prototype._requestFileSizeSync=function(a){return k.getFileSizeSync(this.getXhrPath(a))},b.prototype._requestFileAsync=function(a,b,c){k.asyncDownloadFile(this.getXhrPath(a),b,c)},b.prototype._requestFileSync=function(a,b){return k.syncDownloadFile(this.getXhrPath(a),b)},b.prototype.getName=function(){return"XmlHttpRequest"},b.isAvailable=function(){return"undefined"!=typeof XMLHttpRequest&&null!==XMLHttpRequest},b.prototype.diskSpace=function(a,b){b(0,0)},b.prototype.isReadOnly=function(){return!0},b.prototype.supportsLinks=function(){return!1},b.prototype.supportsProps=function(){return!1},b.prototype.supportsSynch=function(){return!0},b.prototype.preloadFile=function(a,b){var c=this._index.getInode(a);if(!l.isFileInode(c))throw g.ApiError.EISDIR(a);if(null===c)throw g.ApiError.ENOENT(a);var d=c.getData();d.size=b.length,d.file_data=b},b.prototype.stat=function(a,b,c){var d=this._index.getInode(a);if(null===d)return c(g.ApiError.ENOENT(a));var e;l.isFileInode(d)?(e=d.getData(),e.size<0?this._requestFileSizeAsync(a,function(a,b){return a?c(a):(e.size=b,void c(null,e.clone()))}):c(null,e.clone())):l.isDirInode(d)?(e=d.getStats(),c(null,e)):c(g.ApiError.FileError(g.ErrorCode.EINVAL,a))},b.prototype.statSync=function(a,b){var c=this._index.getInode(a);if(null===c)throw g.ApiError.ENOENT(a);var d;if(l.isFileInode(c))d=c.getData(),d.size<0&&(d.size=this._requestFileSizeSync(a));else{if(!l.isDirInode(c))throw g.ApiError.FileError(g.ErrorCode.EINVAL,a);d=c.getStats()}return d},b.prototype.open=function(a,b,c,d){if(b.isWriteable())return d(new g.ApiError(g.ErrorCode.EPERM,a));var e=this,f=this._index.getInode(a);if(null===f)return d(g.ApiError.ENOENT(a));if(!l.isFileInode(f))return d(g.ApiError.EISDIR(a));var i=f.getData();switch(b.pathExistsAction()){case h.ActionType.THROW_EXCEPTION:case h.ActionType.TRUNCATE_FILE:return d(g.ApiError.EEXIST(a));case h.ActionType.NOP:if(null!=i.file_data)return d(null,new j.NoSyncFile(e,a,b,i.clone(),i.file_data));this._requestFileAsync(a,"buffer",function(c,f){return c?d(c):(i.size=f.length,i.file_data=f,d(null,new j.NoSyncFile(e,a,b,i.clone(),f)))});break;default:return d(new g.ApiError(g.ErrorCode.EINVAL,"Invalid FileMode object."))}},b.prototype.openSync=function(a,b,c){if(b.isWriteable())throw new g.ApiError(g.ErrorCode.EPERM,a);var d=this._index.getInode(a);if(null===d)throw g.ApiError.ENOENT(a);if(!l.isFileInode(d))throw g.ApiError.EISDIR(a);var e=d.getData();switch(b.pathExistsAction()){case h.ActionType.THROW_EXCEPTION:case h.ActionType.TRUNCATE_FILE:throw g.ApiError.EEXIST(a);case h.ActionType.NOP:if(null!=e.file_data)return new j.NoSyncFile(this,a,b,e.clone(),e.file_data);var f=this._requestFileSync(a,"buffer");return e.size=f.length,e.file_data=f,new j.NoSyncFile(this,a,b,e.clone(),f);default:throw new g.ApiError(g.ErrorCode.EINVAL,"Invalid FileMode object.")}},b.prototype.readdir=function(a,b){try{b(null,this.readdirSync(a))}catch(a){b(a)}},b.prototype.readdirSync=function(a){var b=this._index.getInode(a);if(null===b)throw g.ApiError.ENOENT(a);if(l.isDirInode(b))return b.getListing();throw g.ApiError.ENOTDIR(a)},b.prototype.readFile=function(a,b,c,e){var f=e;this.open(a,c,420,function(a,c){if(a)return e(a);e=function(a,b){c.close(function(c){return null==a&&(a=c),f(a,b)})};var g=c,h=g.getBuffer();null===b?e(a,i.copyingSlice(h)):d(h,b,e)})},b.prototype.readFileSync=function(a,b,c){var d=this.openSync(a,c,420);try{var e=d,f=e.getBuffer();return null===b?i.copyingSlice(f):f.toString(b)}finally{d.closeSync()}},b}(f.BaseFileSystem);c.__esModule=!0,c.default=m},{"../core/api_error":52,"../core/file_flag":56,"../core/file_system":57,"../core/util":61,"../generic/file_index":63,"../generic/preload_file":68,"../generic/xhr":69}],49:[function(a,b,c){"use strict";function d(a,b){var c=31&b,d=(b>>5&15)-1,e=(b>>9)+1980,f=31&a,g=a>>5&63,h=a>>11;return new Date(e,d,c,h,g,f)}function e(a,b,c,d){return 0===d?"":b?a.toString("utf8",c,c+d):m.default.byte2str(a.slice(c,c+d))}var f=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)},g=a("../core/api_error"),h=a("../core/node_fs_stats"),i=a("../core/file_system"),j=a("../core/file_flag"),k=a("../generic/preload_file"),l=a("../core/util"),m=a("bfs-buffer/js/extended_ascii"),n=a("pako/dist/pako_inflate.min").inflateRaw,o=a("../generic/file_index");!function(a){a[a.MSDOS=0]="MSDOS",a[a.AMIGA=1]="AMIGA",a[a.OPENVMS=2]="OPENVMS",a[a.UNIX=3]="UNIX",a[a.VM_CMS=4]="VM_CMS",a[a.ATARI_ST=5]="ATARI_ST",a[a.OS2_HPFS=6]="OS2_HPFS",a[a.MAC=7]="MAC",a[a.Z_SYSTEM=8]="Z_SYSTEM",a[a.CP_M=9]="CP_M",a[a.NTFS=10]="NTFS",a[a.MVS=11]="MVS",a[a.VSE=12]="VSE",a[a.ACORN_RISC=13]="ACORN_RISC",a[a.VFAT=14]="VFAT",a[a.ALT_MVS=15]="ALT_MVS",a[a.BEOS=16]="BEOS",a[a.TANDEM=17]="TANDEM",a[a.OS_400=18]="OS_400",a[a.OSX=19]="OSX"}(c.ExternalFileAttributeType||(c.ExternalFileAttributeType={}));c.ExternalFileAttributeType;!function(a){a[a.STORED=0]="STORED",a[a.SHRUNK=1]="SHRUNK",a[a.REDUCED_1=2]="REDUCED_1",a[a.REDUCED_2=3]="REDUCED_2",a[a.REDUCED_3=4]="REDUCED_3",a[a.REDUCED_4=5]="REDUCED_4",a[a.IMPLODE=6]="IMPLODE",a[a.DEFLATE=8]="DEFLATE",a[a.DEFLATE64=9]="DEFLATE64",a[a.TERSE_OLD=10]="TERSE_OLD",a[a.BZIP2=12]="BZIP2",a[a.LZMA=14]="LZMA",a[a.TERSE_NEW=18]="TERSE_NEW",a[a.LZ77=19]="LZ77",a[a.WAVPACK=97]="WAVPACK",a[a.PPMD=98]="PPMD"}(c.CompressionMethod||(c.CompressionMethod={}));var p=c.CompressionMethod,q=function(){function a(a){if(this.data=a,67324752!==a.readUInt32LE(0))throw new g.ApiError(g.ErrorCode.EINVAL,"Invalid Zip file: Local file header has invalid signature: "+this.data.readUInt32LE(0))}return a.prototype.versionNeeded=function(){return this.data.readUInt16LE(4)},a.prototype.flags=function(){return this.data.readUInt16LE(6)},a.prototype.compressionMethod=function(){return this.data.readUInt16LE(8)},a.prototype.lastModFileTime=function(){return d(this.data.readUInt16LE(10),this.data.readUInt16LE(12))},a.prototype.rawLastModFileTime=function(){return this.data.readUInt32LE(10)},a.prototype.crc32=function(){return this.data.readUInt32LE(14)},a.prototype.fileNameLength=function(){return this.data.readUInt16LE(26)},a.prototype.extraFieldLength=function(){return this.data.readUInt16LE(28)},a.prototype.fileName=function(){return e(this.data,this.useUTF8(),30,this.fileNameLength())},a.prototype.extraField=function(){var a=30+this.fileNameLength();return this.data.slice(a,a+this.extraFieldLength())},a.prototype.totalSize=function(){return 30+this.fileNameLength()+this.extraFieldLength()},a.prototype.useUTF8=function(){return 2048===(2048&this.flags())},a}();c.FileHeader=q;var r=function(){function a(a,b,c){this.header=a,this.record=b,this.data=c}return a.prototype.decompress=function(){var a=this.header.compressionMethod();switch(a){case p.DEFLATE:var b=n(l.buffer2Arrayish(this.data.slice(0,this.record.compressedSize())),{chunkSize:this.record.uncompressedSize()});return l.arrayish2Buffer(b);case p.STORED:return l.copyingSlice(this.data,0,this.record.uncompressedSize());default:var c=p[a];throw c=c?c:"Unknown: "+a,new g.ApiError(g.ErrorCode.EINVAL,"Invalid compression method on file '"+this.header.fileName()+"': "+c)}},a.prototype.getHeader=function(){return this.header},a.prototype.getRecord=function(){return this.record},a.prototype.getRawData=function(){return this.data},a}();c.FileData=r;var s=function(){function a(a){this.data=a}return a.prototype.crc32=function(){return this.data.readUInt32LE(0)},a.prototype.compressedSize=function(){return this.data.readUInt32LE(4)},a.prototype.uncompressedSize=function(){return this.data.readUInt32LE(8)},a}();c.DataDescriptor=s;var t=function(){function a(a){if(this.data=a,134630224!==this.data.readUInt32LE(0))throw new g.ApiError(g.ErrorCode.EINVAL,"Invalid archive extra data record signature: "+this.data.readUInt32LE(0))}return a.prototype.length=function(){return this.data.readUInt32LE(4)},a.prototype.extraFieldData=function(){return this.data.slice(8,8+this.length())},a}();c.ArchiveExtraDataRecord=t;var u=function(){function a(a){if(this.data=a,84233040!==this.data.readUInt32LE(0))throw new g.ApiError(g.ErrorCode.EINVAL,"Invalid digital signature signature: "+this.data.readUInt32LE(0))}return a.prototype.size=function(){return this.data.readUInt16LE(4)},a.prototype.signatureData=function(){return this.data.slice(6,6+this.size())},a}();c.DigitalSignature=u;var v=function(){function a(a,b){if(this.zipData=a,this.data=b,33639248!==this.data.readUInt32LE(0))throw new g.ApiError(g.ErrorCode.EINVAL,"Invalid Zip file: Central directory record has invalid signature: "+this.data.readUInt32LE(0));this._filename=this.produceFilename()}return a.prototype.versionMadeBy=function(){return this.data.readUInt16LE(4)},a.prototype.versionNeeded=function(){return this.data.readUInt16LE(6)},a.prototype.flag=function(){return this.data.readUInt16LE(8)},a.prototype.compressionMethod=function(){return this.data.readUInt16LE(10)},a.prototype.lastModFileTime=function(){return d(this.data.readUInt16LE(12),this.data.readUInt16LE(14))},a.prototype.rawLastModFileTime=function(){return this.data.readUInt32LE(12)},a.prototype.crc32=function(){return this.data.readUInt32LE(16)},a.prototype.compressedSize=function(){return this.data.readUInt32LE(20)},a.prototype.uncompressedSize=function(){return this.data.readUInt32LE(24)},a.prototype.fileNameLength=function(){return this.data.readUInt16LE(28)},a.prototype.extraFieldLength=function(){return this.data.readUInt16LE(30)},a.prototype.fileCommentLength=function(){return this.data.readUInt16LE(32)},a.prototype.diskNumberStart=function(){return this.data.readUInt16LE(34)},a.prototype.internalAttributes=function(){return this.data.readUInt16LE(36)},a.prototype.externalAttributes=function(){return this.data.readUInt32LE(38)},a.prototype.headerRelativeOffset=function(){return this.data.readUInt32LE(42)},a.prototype.produceFilename=function(){var a=e(this.data,this.useUTF8(),46,this.fileNameLength());return a.replace(/\\/g,"/")},a.prototype.fileName=function(){return this._filename},a.prototype.rawFileName=function(){return this.data.slice(46,46+this.fileNameLength())},a.prototype.extraField=function(){var a=44+this.fileNameLength();return this.data.slice(a,a+this.extraFieldLength())},a.prototype.fileComment=function(){var a=46+this.fileNameLength()+this.extraFieldLength();return e(this.data,this.useUTF8(),a,this.fileCommentLength())},a.prototype.rawFileComment=function(){var a=46+this.fileNameLength()+this.extraFieldLength(); +return this.data.slice(a,a+this.fileCommentLength())},a.prototype.totalSize=function(){return 46+this.fileNameLength()+this.extraFieldLength()+this.fileCommentLength()},a.prototype.isDirectory=function(){var a=this.fileName();return!!(16&this.externalAttributes())||"/"===a.charAt(a.length-1)},a.prototype.isFile=function(){return!this.isDirectory()},a.prototype.useUTF8=function(){return 2048===(2048&this.flag())},a.prototype.isEncrypted=function(){return 1===(1&this.flag())},a.prototype.getFileData=function(){var a=this.headerRelativeOffset(),b=new q(this.zipData.slice(a));return new r(b,this,this.zipData.slice(a+b.totalSize()))},a.prototype.getData=function(){return this.getFileData().decompress()},a.prototype.getRawData=function(){return this.getFileData().getRawData()},a.prototype.getStats=function(){return new h.default(h.FileType.FILE,this.uncompressedSize(),365,new Date,this.lastModFileTime())},a}();c.CentralDirectory=v;var w=function(){function a(a){if(this.data=a,101010256!==this.data.readUInt32LE(0))throw new g.ApiError(g.ErrorCode.EINVAL,"Invalid Zip file: End of central directory record has invalid signature: "+this.data.readUInt32LE(0))}return a.prototype.diskNumber=function(){return this.data.readUInt16LE(4)},a.prototype.cdDiskNumber=function(){return this.data.readUInt16LE(6)},a.prototype.cdDiskEntryCount=function(){return this.data.readUInt16LE(8)},a.prototype.cdTotalEntryCount=function(){return this.data.readUInt16LE(10)},a.prototype.cdSize=function(){return this.data.readUInt32LE(12)},a.prototype.cdOffset=function(){return this.data.readUInt32LE(16)},a.prototype.cdZipCommentLength=function(){return this.data.readUInt16LE(20)},a.prototype.cdZipComment=function(){return e(this.data,!0,22,this.cdZipCommentLength())},a.prototype.rawCdZipComment=function(){return this.data.slice(22,22+this.cdZipCommentLength())},a}();c.EndOfCentralDirectory=w;var x=function(){function a(a,b,c,d){this.index=a,this.directoryEntries=b,this.eocd=c,this.data=d}return a}();c.ZipTOC=x;var y=function(a){function b(b,c){void 0===c&&(c=""),a.call(this),this.input=b,this.name=c,this._index=new o.FileIndex,this._directoryEntries=[],this._eocd=null,b instanceof x?(this._index=b.index,this._directoryEntries=b.directoryEntries,this._eocd=b.eocd,this.data=b.data):(this.data=b,this.populateIndex())}return f(b,a),b.prototype.getName=function(){return"ZipFS"+(""!==this.name?" "+this.name:"")},b.prototype.getCentralDirectoryEntry=function(a){var b=this._index.getInode(a);if(null===b)throw g.ApiError.ENOENT(a);return o.isFileInode(b)?b.getData():o.isDirInode(b)?b.getData():void 0},b.prototype.getCentralDirectoryEntryAt=function(a){var b=this._directoryEntries[a];if(!b)throw new RangeError("Invalid directory index: "+a+".");return b},b.prototype.getNumberOfCentralDirectoryEntries=function(){return this._directoryEntries.length},b.prototype.getEndOfCentralDirectory=function(){return this._eocd},b.isAvailable=function(){return!0},b.prototype.diskSpace=function(a,b){b(this.data.length,0)},b.prototype.isReadOnly=function(){return!0},b.prototype.supportsLinks=function(){return!1},b.prototype.supportsProps=function(){return!1},b.prototype.supportsSynch=function(){return!0},b.prototype.statSync=function(a,b){var c=this._index.getInode(a);if(null===c)throw g.ApiError.ENOENT(a);var d;if(o.isFileInode(c))d=c.getData().getStats();else{if(!o.isDirInode(c))throw new g.ApiError(g.ErrorCode.EINVAL,"Invalid inode.");d=c.getStats()}return d},b.prototype.openSync=function(a,b,c){if(b.isWriteable())throw new g.ApiError(g.ErrorCode.EPERM,a);var d=this._index.getInode(a);if(!d)throw g.ApiError.ENOENT(a);if(!o.isFileInode(d))throw g.ApiError.EISDIR(a);var e=d.getData(),f=e.getStats();switch(b.pathExistsAction()){case j.ActionType.THROW_EXCEPTION:case j.ActionType.TRUNCATE_FILE:throw g.ApiError.EEXIST(a);case j.ActionType.NOP:return new k.NoSyncFile(this,a,b,f,e.getData());default:throw new g.ApiError(g.ErrorCode.EINVAL,"Invalid FileMode object.")}},b.prototype.readdirSync=function(a){var b=this._index.getInode(a);if(b){if(o.isDirInode(b))return b.getListing();throw g.ApiError.ENOTDIR(a)}throw g.ApiError.ENOENT(a)},b.prototype.readFileSync=function(a,b,c){var d=this.openSync(a,c,420);try{var e=d,f=e.getBuffer();return null===b?l.copyingSlice(f):f.toString(b)}finally{d.closeSync()}},b.getEOCD=function(a){for(var b=22,c=Math.min(b+65535,a.length-1),d=b;d=0)throw new k.ApiError(k.ErrorCode.EINVAL,"Path must be a string without null bytes.");if(""===a)throw new k.ApiError(k.ErrorCode.EINVAL,"Path must not be empty.");return m.resolve(a)}function i(a,b,c,d){switch(typeof a){case"object":return{encoding:"undefined"!=typeof a.encoding?a.encoding:b,flag:"undefined"!=typeof a.flag?a.flag:c,mode:f(a.mode,d)};case"string":return{encoding:a,flag:c,mode:d};default:return{encoding:b,flag:c,mode:d}}}function j(){}var k=a("./api_error"),l=a("./file_flag"),m=a("path"),n=a("./node_fs_stats"),o=a("./global"),p=function(){function a(){this.root=null,this.fdMap={},this.nextFd=100,this.F_OK=0,this.R_OK=4,this.W_OK=2,this.X_OK=1,this._wrapCb=e}return a.prototype.getFdForFile=function(a){var b=this.nextFd++;return this.fdMap[b]=a,b},a.prototype.fd2file=function(a){var b=this.fdMap[a];if(b)return b;throw new k.ApiError(k.ErrorCode.EBADF,"Invalid file descriptor.")},a.prototype.closeFd=function(a){delete this.fdMap[a]},a.prototype.initialize=function(a){if(!a.constructor.isAvailable())throw new k.ApiError(k.ErrorCode.EINVAL,"Tried to instantiate BrowserFS with an unavailable file system.");return this.root=a},a.prototype._toUnixTimestamp=function(a){if("number"==typeof a)return a;if(a instanceof Date)return a.getTime()/1e3;throw new Error("Cannot parse time: "+a)},a.prototype.getRootFS=function(){return this.root?this.root:null},a.prototype.rename=function(a,b,c){void 0===c&&(c=j);var d=e(c,1);try{this.root.rename(h(a),h(b),d)}catch(a){d(a)}},a.prototype.renameSync=function(a,b){this.root.renameSync(h(a),h(b))},a.prototype.exists=function(a,b){void 0===b&&(b=j);var c=e(b,1);try{return this.root.exists(h(a),c)}catch(a){return c(!1)}},a.prototype.existsSync=function(a){try{return this.root.existsSync(h(a))}catch(a){return!1}},a.prototype.stat=function(a,b){void 0===b&&(b=j);var c=e(b,2);try{return this.root.stat(h(a),!1,c)}catch(a){return c(a,null)}},a.prototype.statSync=function(a){return this.root.statSync(h(a),!1)},a.prototype.lstat=function(a,b){void 0===b&&(b=j);var c=e(b,2);try{return this.root.stat(h(a),!0,c)}catch(a){return c(a,null)}},a.prototype.lstatSync=function(a){return this.root.statSync(h(a),!0)},a.prototype.truncate=function(a,b,c){void 0===b&&(b=0),void 0===c&&(c=j);var d=0;"function"==typeof b?c=b:"number"==typeof b&&(d=b);var f=e(c,1);try{if(d<0)throw new k.ApiError(k.ErrorCode.EINVAL);return this.root.truncate(h(a),d,f)}catch(a){return f(a)}},a.prototype.truncateSync=function(a,b){if(void 0===b&&(b=0),b<0)throw new k.ApiError(k.ErrorCode.EINVAL);return this.root.truncateSync(h(a),b)},a.prototype.unlink=function(a,b){void 0===b&&(b=j);var c=e(b,1);try{return this.root.unlink(h(a),c)}catch(a){return c(a)}},a.prototype.unlinkSync=function(a){return this.root.unlinkSync(h(a))},a.prototype.open=function(a,b,c,d){var g=this;void 0===d&&(d=j);var i=f(c,420);d="function"==typeof c?c:d;var k=e(d,2);try{this.root.open(h(a),l.FileFlag.getFileFlag(b),i,function(a,b){b?k(a,g.getFdForFile(b)):k(a)})}catch(a){k(a,null)}},a.prototype.openSync=function(a,b,c){return void 0===c&&(c=420),this.getFdForFile(this.root.openSync(h(a),l.FileFlag.getFileFlag(b),f(c,420)))},a.prototype.readFile=function(a,b,c){void 0===b&&(b={}),void 0===c&&(c=j);var d=i(b,null,"r",null);c="function"==typeof b?b:c;var f=e(c,2);try{var g=l.FileFlag.getFileFlag(d.flag);return g.isReadable()?this.root.readFile(h(a),d.encoding,g,f):f(new k.ApiError(k.ErrorCode.EINVAL,"Flag passed to readFile must allow for reading."))}catch(a){return f(a,null)}},a.prototype.readFileSync=function(a,b){void 0===b&&(b={});var c=i(b,null,"r",null),d=l.FileFlag.getFileFlag(c.flag);if(!d.isReadable())throw new k.ApiError(k.ErrorCode.EINVAL,"Flag passed to readFile must allow for reading.");return this.root.readFileSync(h(a),c.encoding,d)},a.prototype.writeFile=function(a,b,c,d){void 0===c&&(c={}),void 0===d&&(d=j);var f=i(c,"utf8","w",420);d="function"==typeof c?c:d;var g=e(d,1);try{var m=l.FileFlag.getFileFlag(f.flag);return m.isWriteable()?this.root.writeFile(h(a),b,f.encoding,m,f.mode,g):g(new k.ApiError(k.ErrorCode.EINVAL,"Flag passed to writeFile must allow for writing."))}catch(a){return g(a)}},a.prototype.writeFileSync=function(a,b,c){var d=i(c,"utf8","w",420),e=l.FileFlag.getFileFlag(d.flag);if(!e.isWriteable())throw new k.ApiError(k.ErrorCode.EINVAL,"Flag passed to writeFile must allow for writing.");return this.root.writeFileSync(h(a),b,d.encoding,e,d.mode)},a.prototype.appendFile=function(a,b,c,d){void 0===d&&(d=j);var f=i(c,"utf8","a",420);d="function"==typeof c?c:d;var g=e(d,1);try{var m=l.FileFlag.getFileFlag(f.flag);if(!m.isAppendable())return g(new k.ApiError(k.ErrorCode.EINVAL,"Flag passed to appendFile must allow for appending."));this.root.appendFile(h(a),b,f.encoding,m,f.mode,g)}catch(a){g(a)}},a.prototype.appendFileSync=function(a,b,c){var d=i(c,"utf8","a",420),e=l.FileFlag.getFileFlag(d.flag);if(!e.isAppendable())throw new k.ApiError(k.ErrorCode.EINVAL,"Flag passed to appendFile must allow for appending.");return this.root.appendFileSync(h(a),b,d.encoding,e,d.mode)},a.prototype.fstat=function(a,b){void 0===b&&(b=j);var c=e(b,2);try{var d=this.fd2file(a);d.stat(c)}catch(a){c(a)}},a.prototype.fstatSync=function(a){return this.fd2file(a).statSync()},a.prototype.close=function(a,b){var c=this;void 0===b&&(b=j);var d=e(b,1);try{this.fd2file(a).close(function(b){b||c.closeFd(a),d(b)})}catch(a){d(a)}},a.prototype.closeSync=function(a){this.fd2file(a).closeSync(),this.closeFd(a)},a.prototype.ftruncate=function(a,b,c){void 0===c&&(c=j);var d="number"==typeof b?b:0;c="function"==typeof b?b:c;var f=e(c,1);try{var g=this.fd2file(a);if(d<0)throw new k.ApiError(k.ErrorCode.EINVAL);g.truncate(d,f)}catch(a){f(a)}},a.prototype.ftruncateSync=function(a,b){void 0===b&&(b=0);var c=this.fd2file(a);if(b<0)throw new k.ApiError(k.ErrorCode.EINVAL);c.truncateSync(b)},a.prototype.fsync=function(a,b){void 0===b&&(b=j);var c=e(b,1);try{this.fd2file(a).sync(c)}catch(a){c(a)}},a.prototype.fsyncSync=function(a){this.fd2file(a).syncSync()},a.prototype.fdatasync=function(a,b){void 0===b&&(b=j);var c=e(b,1);try{this.fd2file(a).datasync(c)}catch(a){c(a)}},a.prototype.fdatasyncSync=function(a){this.fd2file(a).datasyncSync()},a.prototype.write=function(a,c,d,f,g,h){void 0===h&&(h=j);var i,l,m,n=null;if("string"==typeof c){var o="utf8";switch(typeof d){case"function":h=d;break;case"number":n=d,o="string"==typeof f?f:"utf8",h="function"==typeof g?g:h;break;default:return(h="function"==typeof f?f:"function"==typeof g?g:h)(new k.ApiError(k.ErrorCode.EINVAL,"Invalid arguments."))}i=new b(c,o),l=0,m=i.length}else i=c,l=d,m=f,n="number"==typeof g?g:null,h="function"==typeof g?g:h;var p=e(h,3);try{var q=this.fd2file(a);null==n&&(n=q.getPos()),q.write(i,l,m,n,p)}catch(a){p(a)}},a.prototype.writeSync=function(a,c,d,e,f){var g,h,i,j=0;if("string"==typeof c){i="number"==typeof d?d:null;var k="string"==typeof e?e:"utf8";j=0,g=new b(c,k),h=g.length}else g=c,j=d,h=e,i="number"==typeof f?f:null;var l=this.fd2file(a);return null==i&&(i=l.getPos()),l.writeSync(g,j,h,i)},a.prototype.read=function(a,c,d,f,g,h){void 0===h&&(h=j);var i,k,l,m,n;if("number"==typeof c){l=c,i=d;var o=f;h="function"==typeof g?g:h,k=0,m=new b(l),n=e(function(a,b,c){return a?h(a):void h(a,c.toString(o),b)},3)}else m=c,k=d,l=f,i=g,n=e(h,3);try{var p=this.fd2file(a);null==i&&(i=p.getPos()),p.read(m,k,l,i,n)}catch(a){n(a)}},a.prototype.readSync=function(a,c,d,e,f){var g,h,i,j,k=!1;if("number"==typeof c){i=c,j=d;var l=e;h=0,g=new b(i),k=!0}else g=c,h=d,i=e,j=f;var m=this.fd2file(a);null==j&&(j=m.getPos());var n=m.readSync(g,h,i,j);return k?[g.toString(l),n]:n},a.prototype.fchown=function(a,b,c,d){void 0===d&&(d=j);var f=e(d,1);try{this.fd2file(a).chown(b,c,f)}catch(a){f(a)}},a.prototype.fchownSync=function(a,b,c){this.fd2file(a).chownSync(b,c)},a.prototype.fchmod=function(a,b,c){var d=e(c,1);try{var f="string"==typeof b?parseInt(b,8):b;this.fd2file(a).chmod(f,d)}catch(a){d(a)}},a.prototype.fchmodSync=function(a,b){var c="string"==typeof b?parseInt(b,8):b;this.fd2file(a).chmodSync(c)},a.prototype.futimes=function(a,b,c,d){void 0===d&&(d=j);var f=e(d,1);try{var g=this.fd2file(a);"number"==typeof b&&(b=new Date(1e3*b)),"number"==typeof c&&(c=new Date(1e3*c)),g.utimes(b,c,f)}catch(a){f(a)}},a.prototype.futimesSync=function(a,b,c){this.fd2file(a).utimesSync(g(b),g(c))},a.prototype.rmdir=function(a,b){void 0===b&&(b=j);var c=e(b,1);try{a=h(a),this.root.rmdir(a,c)}catch(a){c(a)}},a.prototype.rmdirSync=function(a){return a=h(a),this.root.rmdirSync(a)},a.prototype.mkdir=function(a,b,c){void 0===c&&(c=j),"function"==typeof b&&(c=b,b=511);var d=e(c,1);try{a=h(a),this.root.mkdir(a,b,d)}catch(a){d(a)}},a.prototype.mkdirSync=function(a,b){this.root.mkdirSync(h(a),f(b,511))},a.prototype.readdir=function(a,b){void 0===b&&(b=j);var c=e(b,2);try{a=h(a),this.root.readdir(a,c)}catch(a){c(a)}},a.prototype.readdirSync=function(a){return a=h(a),this.root.readdirSync(a)},a.prototype.link=function(a,b,c){void 0===c&&(c=j);var d=e(c,1);try{a=h(a),b=h(b),this.root.link(a,b,d)}catch(a){d(a)}},a.prototype.linkSync=function(a,b){return a=h(a),b=h(b),this.root.linkSync(a,b)},a.prototype.symlink=function(a,b,c,d){void 0===d&&(d=j);var f="string"==typeof c?c:"file";d="function"==typeof c?c:d;var g=e(d,1);try{if("file"!==f&&"dir"!==f)return g(new k.ApiError(k.ErrorCode.EINVAL,"Invalid type: "+f));a=h(a),b=h(b),this.root.symlink(a,b,f,g)}catch(a){g(a)}},a.prototype.symlinkSync=function(a,b,c){if(null==c)c="file";else if("file"!==c&&"dir"!==c)throw new k.ApiError(k.ErrorCode.EINVAL,"Invalid type: "+c);return a=h(a),b=h(b),this.root.symlinkSync(a,b,c)},a.prototype.readlink=function(a,b){void 0===b&&(b=j);var c=e(b,2);try{a=h(a),this.root.readlink(a,c)}catch(a){c(a)}},a.prototype.readlinkSync=function(a){return a=h(a),this.root.readlinkSync(a)},a.prototype.chown=function(a,b,c,d){void 0===d&&(d=j);var f=e(d,1);try{a=h(a),this.root.chown(a,!1,b,c,f)}catch(a){f(a)}},a.prototype.chownSync=function(a,b,c){a=h(a),this.root.chownSync(a,!1,b,c)},a.prototype.lchown=function(a,b,c,d){void 0===d&&(d=j);var f=e(d,1);try{a=h(a),this.root.chown(a,!0,b,c,f)}catch(a){f(a)}},a.prototype.lchownSync=function(a,b,c){a=h(a),this.root.chownSync(a,!0,b,c)},a.prototype.chmod=function(a,b,c){void 0===c&&(c=j);var d=e(c,1);try{var g=f(b,-1);if(g<0)throw new k.ApiError(k.ErrorCode.EINVAL,"Invalid mode.");this.root.chmod(h(a),!1,g,d)}catch(a){d(a)}},a.prototype.chmodSync=function(a,b){var c=f(b,-1);if(c<0)throw new k.ApiError(k.ErrorCode.EINVAL,"Invalid mode.");a=h(a),this.root.chmodSync(a,!1,c)},a.prototype.lchmod=function(a,b,c){void 0===c&&(c=j);var d=e(c,1);try{var g=f(b,-1);if(g<0)throw new k.ApiError(k.ErrorCode.EINVAL,"Invalid mode.");this.root.chmod(h(a),!0,g,d)}catch(a){d(a)}},a.prototype.lchmodSync=function(a,b){var c=f(b,-1);if(c<1)throw new k.ApiError(k.ErrorCode.EINVAL,"Invalid mode.");this.root.chmodSync(h(a),!0,c)},a.prototype.utimes=function(a,b,c,d){void 0===d&&(d=j);var f=e(d,1);try{this.root.utimes(h(a),g(b),g(c),f)}catch(a){f(a)}},a.prototype.utimesSync=function(a,b,c){this.root.utimesSync(h(a),g(b),g(c))},a.prototype.realpath=function(a,b,c){void 0===c&&(c=j);var d="object"==typeof b?b:{};c="function"==typeof b?b:j;var f=e(c,2);try{a=h(a),this.root.realpath(a,d,f)}catch(a){f(a)}},a.prototype.realpathSync=function(a,b){return void 0===b&&(b={}),a=h(a),this.root.realpathSync(a,b)},a.prototype.watchFile=function(a,b,c){throw void 0===c&&(c=j),new k.ApiError(k.ErrorCode.ENOTSUP)},a.prototype.unwatchFile=function(a,b){throw void 0===b&&(b=j),new k.ApiError(k.ErrorCode.ENOTSUP)},a.prototype.watch=function(a,b,c){throw void 0===c&&(c=j),new k.ApiError(k.ErrorCode.ENOTSUP)},a.prototype.access=function(a,b,c){throw void 0===c&&(c=j),new k.ApiError(k.ErrorCode.ENOTSUP)},a.prototype.accessSync=function(a,b){throw new k.ApiError(k.ErrorCode.ENOTSUP)},a.prototype.createReadStream=function(a,b){throw new k.ApiError(k.ErrorCode.ENOTSUP)},a.prototype.createWriteStream=function(a,b){throw new k.ApiError(k.ErrorCode.ENOTSUP)},a.Stats=n.default,a}();c.__esModule=!0,c.default=p;new p}).call(this,a("bfs-buffer").Buffer,!0)},{"./api_error":52,"./file_flag":56,"./global":58,"./node_fs_stats":60,"bfs-buffer":2,path:10}],52:[function(a,b,c){(function(a){"use strict";var b=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){a[a.EPERM=1]="EPERM",a[a.ENOENT=2]="ENOENT",a[a.EIO=5]="EIO",a[a.EBADF=9]="EBADF",a[a.EACCES=13]="EACCES",a[a.EBUSY=16]="EBUSY",a[a.EEXIST=17]="EEXIST",a[a.ENOTDIR=20]="ENOTDIR",a[a.EISDIR=21]="EISDIR",a[a.EINVAL=22]="EINVAL",a[a.EFBIG=27]="EFBIG",a[a.ENOSPC=28]="ENOSPC",a[a.EROFS=30]="EROFS",a[a.ENOTEMPTY=39]="ENOTEMPTY",a[a.ENOTSUP=95]="ENOTSUP"}(c.ErrorCode||(c.ErrorCode={}));var d=c.ErrorCode;c.ErrorStrings={},c.ErrorStrings[d.EPERM]="Operation not permitted.",c.ErrorStrings[d.ENOENT]="No such file or directory.",c.ErrorStrings[d.EIO]="Input/output error.",c.ErrorStrings[d.EBADF]="Bad file descriptor.",c.ErrorStrings[d.EACCES]="Permission denied.",c.ErrorStrings[d.EBUSY]="Resource busy or locked.",c.ErrorStrings[d.EEXIST]="File exists.",c.ErrorStrings[d.ENOTDIR]="File is not a directory.",c.ErrorStrings[d.EISDIR]="File is a directory.",c.ErrorStrings[d.EINVAL]="Invalid argument.",c.ErrorStrings[d.EFBIG]="File is too big.",c.ErrorStrings[d.ENOSPC]="No space left on disk.",c.ErrorStrings[d.EROFS]="Cannot modify a read-only file system.",c.ErrorStrings[d.ENOTEMPTY]="Directory is not empty.",c.ErrorStrings[d.ENOTSUP]="Operation is not supported.";var e=function(e){function f(a,b,f){void 0===b&&(b=c.ErrorStrings[a]),void 0===f&&(f=null),e.call(this,b),this.syscall="",this.errno=a,this.code=d[a],this.path=f,this.stack=(new Error).stack,this.message="Error: "+this.code+": "+b+(this.path?", '"+this.path+"'":"")}return b(f,e),f.prototype.toString=function(){return this.message},f.prototype.toJSON=function(){return{errno:this.errno,code:this.code,path:this.path,stack:this.stack,message:this.message}},f.fromJSON=function(a){var b=new f(0);return b.errno=a.errno,b.code=a.code,b.path=a.path,b.stack=a.stack,b.message=a.message,b},f.prototype.writeToBuffer=function(b,c){void 0===b&&(b=new a(this.bufferSize())),void 0===c&&(c=0);var d=b.write(JSON.stringify(this.toJSON()),c+4);return b.writeUInt32LE(d,c),b},f.fromBuffer=function(a,b){return void 0===b&&(b=0),f.fromJSON(JSON.parse(a.toString("utf8",b+4,b+4+a.readUInt32LE(b))))},f.prototype.bufferSize=function(){return 4+a.byteLength(JSON.stringify(this.toJSON()))},f.FileError=function(a,b){return new f(a,c.ErrorStrings[a],b)},f.ENOENT=function(a){return this.FileError(d.ENOENT,a)},f.EEXIST=function(a){return this.FileError(d.EEXIST,a)},f.EISDIR=function(a){return this.FileError(d.EISDIR,a)},f.ENOTDIR=function(a){return this.FileError(d.ENOTDIR,a)},f.EPERM=function(a){return this.FileError(d.EPERM,a)},f.ENOTEMPTY=function(a){return this.FileError(d.ENOTEMPTY,a)},f}(Error);c.ApiError=e}).call(this,a("bfs-buffer").Buffer)},{"bfs-buffer":2}],53:[function(a,b,c){"use strict";var d=a("../backend/AsyncMirror");c.AsyncMirror=d.default;var e=a("../backend/Dropbox");c.Dropbox=e.default;var f=a("../backend/Emscripten");c.Emscripten=f.default;var g=a("../backend/FolderAdapter");c.FolderAdapter=g.default;var h=a("../backend/HTML5FS");c.HTML5FS=h.default;var i=a("../backend/InMemory");c.InMemory=i.default;var j=a("../backend/IndexedDB");c.IndexedDB=j.default;var k=a("../backend/LocalStorage");c.LocalStorage=k.default;var l=a("../backend/MountableFileSystem");c.MountableFileSystem=l.default;var m=a("../backend/OverlayFS");c.OverlayFS=m.default;var n=a("../backend/WorkerFS");c.WorkerFS=n.default;var o=a("../backend/XmlHttpRequest");c.XmlHttpRequest=o.default;var p=a("../backend/ZipFS");c.ZipFS=p.default},{"../backend/AsyncMirror":37,"../backend/Dropbox":38,"../backend/Emscripten":39,"../backend/FolderAdapter":40,"../backend/HTML5FS":41,"../backend/InMemory":42,"../backend/IndexedDB":43,"../backend/LocalStorage":44,"../backend/MountableFileSystem":45,"../backend/OverlayFS":46,"../backend/WorkerFS":47,"../backend/XmlHttpRequest":48,"../backend/ZipFS":49}],54:[function(a,b,c){(function(b,d){"use strict";function e(a){a.Buffer=d,a.process=b;var c=null!=a.require?a.require:null;a.require=function(a){var b=g(a);return null==b?c.apply(null,Array.prototype.slice.call(arguments,0)):b}}function f(a,b){m[a]=b}function g(a){switch(a){case"fs":return j;case"path":return k;case"buffer":return i;case"process":return b;case"bfs_utils":return n;default:return m[a]}}function h(a){return j.initialize(a)}var i=a("buffer"),j=a("./node_fs"),k=a("path"),l=a("../generic/emscripten_fs");c.EmscriptenFS=l.default;var m=a("./backends");c.FileSystem=m;var n=a("./util");b.initializeTTYs&&b.initializeTTYs(),c.install=e,c.registerFileSystem=f,c.BFSRequire=g,c.initialize=h}).call(this,a("bfs-process"),a("bfs-buffer").Buffer)},{"../generic/emscripten_fs":62,"./backends":53,"./node_fs":59,"./util":61,"bfs-buffer":2,"bfs-process":11,buffer:2,path:10}],55:[function(a,b,c){"use strict";var d=a("./api_error"),e=function(){function a(){}return a.prototype.sync=function(a){a(new d.ApiError(d.ErrorCode.ENOTSUP))},a.prototype.syncSync=function(){throw new d.ApiError(d.ErrorCode.ENOTSUP)},a.prototype.datasync=function(a){this.sync(a)},a.prototype.datasyncSync=function(){return this.syncSync()},a.prototype.chown=function(a,b,c){c(new d.ApiError(d.ErrorCode.ENOTSUP))},a.prototype.chownSync=function(a,b){throw new d.ApiError(d.ErrorCode.ENOTSUP)},a.prototype.chmod=function(a,b){b(new d.ApiError(d.ErrorCode.ENOTSUP))},a.prototype.chmodSync=function(a){throw new d.ApiError(d.ErrorCode.ENOTSUP)},a.prototype.utimes=function(a,b,c){c(new d.ApiError(d.ErrorCode.ENOTSUP))},a.prototype.utimesSync=function(a,b){throw new d.ApiError(d.ErrorCode.ENOTSUP)},a}();c.BaseFile=e},{"./api_error":52}],56:[function(a,b,c){"use strict";var d=a("./api_error");!function(a){a[a.NOP=0]="NOP",a[a.THROW_EXCEPTION=1]="THROW_EXCEPTION",a[a.TRUNCATE_FILE=2]="TRUNCATE_FILE",a[a.CREATE_FILE=3]="CREATE_FILE"}(c.ActionType||(c.ActionType={}));var e=c.ActionType,f=function(){function a(b){if(this.flagStr=b,a.validFlagStrs.indexOf(b)<0)throw new d.ApiError(d.ErrorCode.EINVAL,"Invalid flag: "+b)}return a.getFileFlag=function(b){return a.flagCache.hasOwnProperty(b)?a.flagCache[b]:a.flagCache[b]=new a(b)},a.prototype.getFlagString=function(){return this.flagStr},a.prototype.isReadable=function(){return this.flagStr.indexOf("r")!==-1||this.flagStr.indexOf("+")!==-1},a.prototype.isWriteable=function(){return this.flagStr.indexOf("w")!==-1||this.flagStr.indexOf("a")!==-1||this.flagStr.indexOf("+")!==-1},a.prototype.isTruncating=function(){return this.flagStr.indexOf("w")!==-1},a.prototype.isAppendable=function(){return this.flagStr.indexOf("a")!==-1},a.prototype.isSynchronous=function(){return this.flagStr.indexOf("s")!==-1},a.prototype.isExclusive=function(){return this.flagStr.indexOf("x")!==-1},a.prototype.pathExistsAction=function(){return this.isExclusive()?e.THROW_EXCEPTION:this.isTruncating()?e.TRUNCATE_FILE:e.NOP},a.prototype.pathNotExistsAction=function(){return(this.isWriteable()||this.isAppendable())&&"r+"!==this.flagStr?e.CREATE_FILE:e.THROW_EXCEPTION},a.flagCache={},a.validFlagStrs=["r","r+","rs","rs+","w","wx","w+","wx+","a","ax","a+","ax+"],a}();c.FileFlag=f},{"./api_error":52}],57:[function(a,b,c){(function(b){"use strict";var d=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)},e=a("./api_error"),f=a("./file_flag"),g=a("path"),h=function(){function a(){}return a.prototype.supportsLinks=function(){return!1},a.prototype.diskSpace=function(a,b){b(0,0)},a.prototype.openFile=function(a,b,c){throw new e.ApiError(e.ErrorCode.ENOTSUP)},a.prototype.createFile=function(a,b,c,d){throw new e.ApiError(e.ErrorCode.ENOTSUP)},a.prototype.open=function(a,b,c,d){var h=this,i=function(i,j){if(i)switch(b.pathNotExistsAction()){case f.ActionType.CREATE_FILE:return h.stat(g.dirname(a),!1,function(f,i){f?d(f):i.isDirectory()?h.createFile(a,b,c,d):d(e.ApiError.ENOTDIR(g.dirname(a)))});case f.ActionType.THROW_EXCEPTION:return d(e.ApiError.ENOENT(a));default:return d(new e.ApiError(e.ErrorCode.EINVAL,"Invalid FileFlag object."))}else{if(j.isDirectory())return d(e.ApiError.EISDIR(a));switch(b.pathExistsAction()){case f.ActionType.THROW_EXCEPTION:return d(e.ApiError.EEXIST(a));case f.ActionType.TRUNCATE_FILE:return h.openFile(a,b,function(a,b){a?d(a):b.truncate(0,function(){b.sync(function(){d(null,b)})})});case f.ActionType.NOP:return h.openFile(a,b,d);default:return d(new e.ApiError(e.ErrorCode.EINVAL,"Invalid FileFlag object."))}}};this.stat(a,!1,i)},a.prototype.rename=function(a,b,c){c(new e.ApiError(e.ErrorCode.ENOTSUP))},a.prototype.renameSync=function(a,b){throw new e.ApiError(e.ErrorCode.ENOTSUP)},a.prototype.stat=function(a,b,c){c(new e.ApiError(e.ErrorCode.ENOTSUP))},a.prototype.statSync=function(a,b){throw new e.ApiError(e.ErrorCode.ENOTSUP)},a.prototype.openFileSync=function(a,b,c){throw new e.ApiError(e.ErrorCode.ENOTSUP)},a.prototype.createFileSync=function(a,b,c){throw new e.ApiError(e.ErrorCode.ENOTSUP)},a.prototype.openSync=function(a,b,c){var d;try{d=this.statSync(a,!1)}catch(d){switch(b.pathNotExistsAction()){case f.ActionType.CREATE_FILE:var h=this.statSync(g.dirname(a),!1);if(!h.isDirectory())throw e.ApiError.ENOTDIR(g.dirname(a));return this.createFileSync(a,b,c);case f.ActionType.THROW_EXCEPTION:throw e.ApiError.ENOENT(a);default:throw new e.ApiError(e.ErrorCode.EINVAL,"Invalid FileFlag object.")}}if(d.isDirectory())throw e.ApiError.EISDIR(a);switch(b.pathExistsAction()){case f.ActionType.THROW_EXCEPTION:throw e.ApiError.EEXIST(a);case f.ActionType.TRUNCATE_FILE:return this.unlinkSync(a),this.createFileSync(a,b,d.mode);case f.ActionType.NOP:return this.openFileSync(a,b,c);default:throw new e.ApiError(e.ErrorCode.EINVAL,"Invalid FileFlag object.")}},a.prototype.unlink=function(a,b){b(new e.ApiError(e.ErrorCode.ENOTSUP))},a.prototype.unlinkSync=function(a){throw new e.ApiError(e.ErrorCode.ENOTSUP)},a.prototype.rmdir=function(a,b){b(new e.ApiError(e.ErrorCode.ENOTSUP))},a.prototype.rmdirSync=function(a){throw new e.ApiError(e.ErrorCode.ENOTSUP)},a.prototype.mkdir=function(a,b,c){c(new e.ApiError(e.ErrorCode.ENOTSUP))},a.prototype.mkdirSync=function(a,b){throw new e.ApiError(e.ErrorCode.ENOTSUP)},a.prototype.readdir=function(a,b){b(new e.ApiError(e.ErrorCode.ENOTSUP))},a.prototype.readdirSync=function(a){throw new e.ApiError(e.ErrorCode.ENOTSUP)},a.prototype.exists=function(a,b){this.stat(a,null,function(a){b(null==a)})},a.prototype.existsSync=function(a){try{return this.statSync(a,!0),!0}catch(a){return!1}},a.prototype.realpath=function(a,b,c){if(this.supportsLinks())for(var d=a.split(g.sep),f=0;fa.length||c>d)throw new TypeError("Invalid slice bounds on buffer of length "+a.length+": ["+c+", "+d+"]");if(0===a.length)return new b(0);if(m){var e=f(a),g=a.readUInt8(0),h=(g+1)%255;return a.writeUInt8(h,0),e[0]===h?(e[0]=g,i(e.slice(c,d))):(a.writeUInt8(g,0),i(e.subarray(c,d)))}var j=new b(d-c);return a.copy(j,0,c,d),j}var l=a("path"),m="undefined"!=typeof ArrayBuffer;c.isIE="undefined"!=typeof navigator&&(null!=/(msie) ([\w.]+)/.exec(navigator.userAgent.toLowerCase())||navigator.userAgent.indexOf("Trident")!==-1),c.isWebWorker="undefined"==typeof window,c.mkdirpSync=d,c.buffer2ArrayBuffer=e,c.buffer2Uint8array=f,c.buffer2Arrayish=g,c.arrayish2Buffer=h,c.uint8Array2Buffer=i,c.arrayBuffer2Buffer=j,"undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&(Uint8Array.prototype.slice||(Uint8Array.prototype.slice=function(a,b){void 0===a&&(a=0),void 0===b&&(b=this.length);var c=this;return a<0&&(a=this.length+a,a<0&&(a=0)),b<0&&(b=this.length+b,b<0&&(b=0)),b0;){var g,h=e.pop(),k=h[0],l=h[1],m=h[2];for(var n in l){var o=l[n],p=""+k+"/"+n;null!=o?(c._index[p]=g=new j,e.push([p,o,g])):g=new i(new f.default(f.FileType.FILE,-1,365)),null!=m&&(m._ls[n]=g)}}return c},a}();c.FileIndex=h;var i=function(){function a(a){this.data=a}return a.prototype.isFile=function(){return!0},a.prototype.isDir=function(){return!1},a.prototype.getData=function(){return this.data},a.prototype.setData=function(a){this.data=a},a}();c.FileInode=i;var j=function(){function a(a){void 0===a&&(a=null),this.data=a,this._ls={}}return a.prototype.isFile=function(){return!1},a.prototype.isDir=function(){return!0},a.prototype.getData=function(){return this.data},a.prototype.getStats=function(){return new f.default(f.FileType.DIRECTORY,4096,365)},a.prototype.getListing=function(){return Object.keys(this._ls)},a.prototype.getItem=function(a){var b;return null!=(b=this._ls[a])?b:null},a.prototype.addItem=function(a,b){return!(a in this._ls)&&(this._ls[a]=b,!0)},a.prototype.remItem=function(a){var b=this._ls[a];return void 0===b?null:(delete this._ls[a],b)},a}();c.DirInode=j,c.isFileInode=d,c.isDirInode=e},{"../core/node_fs_stats":60,path:10}],64:[function(a,b,c){(function(c){"use strict";var d=a("../core/node_fs_stats"),e=function(){function a(a,b,c,d,e,f){this.id=a,this.size=b,this.mode=c,this.atime=d,this.mtime=e,this.ctime=f}return a.prototype.toStats=function(){return new d.default((61440&this.mode)===d.FileType.DIRECTORY?d.FileType.DIRECTORY:d.FileType.FILE,this.size,this.mode,new Date(this.atime),new Date(this.mtime),new Date(this.ctime))},a.prototype.getSize=function(){return 30+this.id.length},a.prototype.toBuffer=function(a){return void 0===a&&(a=new c(this.getSize())),a.writeUInt32LE(this.size,0),a.writeUInt16LE(this.mode,4),a.writeDoubleLE(this.atime,6),a.writeDoubleLE(this.mtime,14),a.writeDoubleLE(this.ctime,22),a.write(this.id,30,this.id.length,"ascii"),a},a.prototype.update=function(a){var b=!1;this.size!==a.size&&(this.size=a.size,b=!0),this.mode!==a.mode&&(this.mode=a.mode,b=!0);var c=a.atime.getTime();this.atime!==c&&(this.atime=c,b=!0);var d=a.mtime.getTime();this.mtime!==d&&(this.mtime=d,b=!0);var e=a.ctime.getTime();return this.ctime!==e&&(this.ctime=e,b=!0),b},a.fromBuffer=function(b){if(void 0===b)throw new Error("NO");return new a(b.toString("ascii",30),b.readUInt32LE(0),b.readUInt16LE(4),b.readDoubleLE(6),b.readDoubleLE(14),b.readDoubleLE(22))},a.prototype.isFile=function(){return(61440&this.mode)===d.FileType.FILE},a.prototype.isDirectory=function(){return(61440&this.mode)===d.FileType.DIRECTORY},a}();b.exports=e}).call(this,a("bfs-buffer").Buffer)},{"../core/node_fs_stats":60,"bfs-buffer":2}],65:[function(a,b,c){(function(b){"use strict";function d(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0,c="x"==a?b:3&b|8;return c.toString(16)})}function e(a,b){return!a||(b(a),!1)}function f(a,b,c){return!a||(b.abort(function(){c(a)}),!1)}var g=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)},h=a("../core/file_system"),i=a("../core/api_error"),j=a("../core/node_fs_stats"),k=a("path"),l=a("../generic/inode"),m=a("../generic/preload_file"),n="/",o=function(){function a(a){this.store=a,this.originalData={},this.modifiedKeys=[]}return a.prototype.stashOldValue=function(a,b){this.originalData.hasOwnProperty(a)||(this.originalData[a]=b)},a.prototype.markModified=function(a){this.modifiedKeys.indexOf(a)===-1&&(this.modifiedKeys.push(a),this.originalData.hasOwnProperty(a)||(this.originalData[a]=this.store.get(a)))},a.prototype.get=function(a){var b=this.store.get(a);return this.stashOldValue(a,b),b},a.prototype.put=function(a,b,c){return this.markModified(a),this.store.put(a,b,c)},a.prototype.del=function(a){this.markModified(a),this.store.del(a)},a.prototype.commit=function(){},a.prototype.abort=function(){var a,b,c;for(a=0;a0)throw i.ApiError.ENOTEMPTY(a);this.removeEntry(a,!0)},c.prototype.mkdirSync=function(a,c){var d=this.store.beginTransaction("readwrite"),e=new b("{}");this.commitNewFile(d,a,j.FileType.DIRECTORY,c,e)},c.prototype.readdirSync=function(a){var b=this.store.beginTransaction("readonly");return Object.keys(this.getDirListing(b,a,this.findINode(b,a)))},c.prototype._syncSync=function(a,b,c){var d=this.store.beginTransaction("readwrite"),e=this._findINode(d,k.dirname(a),k.basename(a)),f=this.getINode(d,a,e),g=f.update(c);try{d.put(f.id,b,!0),g&&d.put(e,f.toBuffer(),!0)}catch(a){throw d.abort(),a}d.commit()},c}(h.SynchronousFileSystem);c.SyncKeyValueFileSystem=q;var r=function(a){function b(b,c,d,e,f){a.call(this,b,c,d,e,f)}return g(b,a),b.prototype.sync=function(a){var b=this;this.isDirty()?this._fs._sync(this.getPath(),this.getBuffer(),this.getStats(),function(c){c||b.resetDirty(),a(c)}):a()},b.prototype.close=function(a){this.sync(a)},b}(m.PreloadFile);c.AsyncKeyValueFile=r;var s=function(a){function c(){a.apply(this,arguments)}return g(c,a),c.prototype.init=function(a,b){this.store=a,this.makeRootDirectory(b)},c.isAvailable=function(){return!0},c.prototype.getName=function(){return this.store.name()},c.prototype.isReadOnly=function(){return!1},c.prototype.supportsSymlinks=function(){return!1},c.prototype.supportsProps=function(){return!1},c.prototype.supportsSynch=function(){return!1},c.prototype.makeRootDirectory=function(a){var c=this.store.beginTransaction("readwrite");c.get(n,function(e,g){if(e||void 0===g){var h=(new Date).getTime(),i=new l(d(),4096,511|j.FileType.DIRECTORY,h,h,h);c.put(i.id,new b("{}"),!1,function(b){f(b,c,a)&&c.put(n,i.toBuffer(),!1,function(b){b?c.abort(function(){a(b)}):c.commit(a)})})}else c.commit(a)})},c.prototype._findINode=function(a,b,c,d){var f=this,g=function(a,e,f){a?d(a):f[c]?d(null,f[c]):d(i.ApiError.ENOENT(k.resolve(b,c)))};"/"===b?""===c?d(null,n):this.getINode(a,b,n,function(c,h){e(c,d)&&f.getDirListing(a,b,h,function(a,b){g(a,h,b)})}):this.findINodeAndDirListing(a,b,g)},c.prototype.findINode=function(a,b,c){var d=this;this._findINode(a,k.dirname(b),k.basename(b),function(f,g){e(f,c)&&d.getINode(a,b,g,c)})},c.prototype.getINode=function(a,b,c,d){a.get(c,function(a,c){e(a,d)&&(void 0===c?d(i.ApiError.ENOENT(b)):d(null,l.fromBuffer(c)))})},c.prototype.getDirListing=function(a,b,c,d){c.isDirectory()?a.get(c.id,function(a,c){if(e(a,d))try{d(null,JSON.parse(c.toString()))}catch(a){d(i.ApiError.ENOENT(b))}}):d(i.ApiError.ENOTDIR(b))},c.prototype.findINodeAndDirListing=function(a,b,c){var d=this;this.findINode(a,b,function(f,g){e(f,c)&&d.getDirListing(a,b,g,function(a,b){e(a,c)&&c(null,g,b)})})},c.prototype.addNewNode=function(a,b,c){var e,f=0,g=function(){5===++f?c(new i.ApiError(i.ErrorCode.EIO,"Unable to commit data to key-value store.")):(e=d(),a.put(e,b,!1,function(a,b){a||!b?g():c(null,e)}))};g()},c.prototype.commitNewFile=function(a,c,d,e,g,h){var j=this,m=k.dirname(c),n=k.basename(c),o=(new Date).getTime();return"/"===c?h(i.ApiError.EEXIST(c)):void this.findINodeAndDirListing(a,m,function(k,m,p){f(k,a,h)&&(p[n]?a.abort(function(){h(i.ApiError.EEXIST(c))}):j.addNewNode(a,g,function(c,i){if(f(c,a,h)){var k=new l(i,g.length,e|d,o,o,o);j.addNewNode(a,k.toBuffer(),function(c,d){f(c,a,h)&&(p[n]=d,a.put(m.id,new b(JSON.stringify(p)),!0,function(b){f(b,a,h)&&a.commit(function(b){f(b,a,h)&&h(null,k)})}))})}}))})},c.prototype.empty=function(a){var b=this;this.store.clear(function(c){e(c,a)&&b.makeRootDirectory(a)})},c.prototype.rename=function(a,c,d){var e=this,g=this.store.beginTransaction("readwrite"),h=k.dirname(a),j=k.basename(a),l=k.dirname(c),m=k.basename(c),n={},o={},p=!1;if(0===(l+"/").indexOf(a+"/"))return d(new i.ApiError(i.ErrorCode.EBUSY,h));var q=function(){if(!p&&o.hasOwnProperty(h)&&o.hasOwnProperty(l)){var k=o[h],q=n[h],r=o[l],s=n[l];if(k[j]){var t=k[j];delete k[j];var u=function(){r[m]=t,g.put(q.id,new b(JSON.stringify(k)),!0,function(a){f(a,g,d)&&(h===l?g.commit(d):g.put(s.id,new b(JSON.stringify(r)),!0,function(a){f(a,g,d)&&g.commit(d)}))})};r[m]?e.getINode(g,c,r[m],function(a,b){f(a,g,d)&&(b.isFile()?g.del(b.id,function(a){f(a,g,d)&&g.del(r[m],function(a){f(a,g,d)&&u()})}):g.abort(function(a){d(i.ApiError.EPERM(c))}))}):u()}else d(i.ApiError.ENOENT(a))}},r=function(a){e.findINodeAndDirListing(g,a,function(b,c,e){b?p||(p=!0,g.abort(function(){d(b)})):(n[a]=c,o[a]=e,q())})};r(h),h!==l&&r(l)},c.prototype.stat=function(a,b,c){var d=this.store.beginTransaction("readonly");this.findINode(d,a,function(a,b){e(a,c)&&c(null,b.toStats())})},c.prototype.createFile=function(a,c,d,f){var g=this,h=this.store.beginTransaction("readwrite"),i=new b(0);this.commitNewFile(h,a,j.FileType.FILE,d,i,function(b,d){e(b,f)&&f(null,new r(g,a,c,d.toStats(),i))})},c.prototype.openFile=function(a,b,c){var d=this,f=this.store.beginTransaction("readonly");this.findINode(f,a,function(g,h){e(g,c)&&f.get(h.id,function(f,g){e(f,c)&&(void 0===g?c(i.ApiError.ENOENT(a)):c(null,new r(d,a,b,h.toStats(),g)))})})},c.prototype.removeEntry=function(a,c,d){var e=this,g=this.store.beginTransaction("readwrite"),h=k.dirname(a),j=k.basename(a);this.findINodeAndDirListing(g,h,function(h,k,l){if(f(h,g,d))if(l[j]){var m=l[j];delete l[j],e.getINode(g,a,m,function(e,h){f(e,g,d)&&(!c&&h.isDirectory()?g.abort(function(){d(i.ApiError.EISDIR(a))}):c&&!h.isDirectory()?g.abort(function(){d(i.ApiError.ENOTDIR(a))}):g.del(h.id,function(a){f(a,g,d)&&g.del(m,function(a){f(a,g,d)&&g.put(k.id,new b(JSON.stringify(l)),!0,function(a){f(a,g,d)&&g.commit(d)})})}))})}else g.abort(function(){d(i.ApiError.ENOENT(a))})})},c.prototype.unlink=function(a,b){this.removeEntry(a,!1,b)},c.prototype.rmdir=function(a,b){var c=this;this.readdir(a,function(d,e){d?b(d):e.length>0?b(i.ApiError.ENOTEMPTY(a)):c.removeEntry(a,!0,b)})},c.prototype.mkdir=function(a,c,d){var e=this.store.beginTransaction("readwrite"),f=new b("{}");this.commitNewFile(e,a,j.FileType.DIRECTORY,c,f,d)},c.prototype.readdir=function(a,b){var c=this,d=this.store.beginTransaction("readonly");this.findINode(d,a,function(f,g){e(f,b)&&c.getDirListing(d,a,g,function(a,c){e(a,b)&&b(null,Object.keys(c))})})},c.prototype._sync=function(a,b,c,d){var e=this,g=this.store.beginTransaction("readwrite");this._findINode(g,k.dirname(a),k.basename(a),function(h,i){f(h,g,d)&&e.getINode(g,a,i,function(a,e){if(f(a,g,d)){var h=e.update(c);g.put(e.id,b,!0,function(a){f(a,g,d)&&(h?g.put(i,e.toBuffer(),!0,function(a){f(a,g,d)&&g.commit(d)}):g.commit(d))})}})})},c}(h.BaseFileSystem);c.AsyncKeyValueFileSystem=s}).call(this,a("bfs-buffer").Buffer)},{"../core/api_error":52,"../core/file_system":57,"../core/node_fs_stats":60,"../generic/inode":64,"../generic/preload_file":68,"bfs-buffer":2,path:10}],66:[function(a,b,c){"use strict";var d=a("./mutex"),e=function(){function a(a){this._fs=a,this._mu=new d.default}return a.prototype.getName=function(){return"LockedFS<"+this._fs.getName()+">"},a.prototype.getFSUnlocked=function(){return this._fs},a.prototype.initialize=function(a){this._fs.initialize(a)},a.prototype.diskSpace=function(a,b){this._fs.diskSpace(a,b)},a.prototype.isReadOnly=function(){return this._fs.isReadOnly()},a.prototype.supportsLinks=function(){return this._fs.supportsLinks()},a.prototype.supportsProps=function(){return this._fs.supportsProps()},a.prototype.supportsSynch=function(){return this._fs.supportsSynch()},a.prototype.rename=function(a,b,c){var d=this;this._mu.lock(function(){d._fs.rename(a,b,function(a){d._mu.unlock(),c(a)})})},a.prototype.renameSync=function(a,b){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.renameSync(a,b)},a.prototype.stat=function(a,b,c){var d=this;this._mu.lock(function(){d._fs.stat(a,b,function(a,b){d._mu.unlock(),c(a,b)})})},a.prototype.statSync=function(a,b){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.statSync(a,b)},a.prototype.open=function(a,b,c,d){var e=this;this._mu.lock(function(){e._fs.open(a,b,c,function(a,b){e._mu.unlock(),d(a,b)})})},a.prototype.openSync=function(a,b,c){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.openSync(a,b,c)},a.prototype.unlink=function(a,b){var c=this;this._mu.lock(function(){c._fs.unlink(a,function(a){c._mu.unlock(),b(a)})})},a.prototype.unlinkSync=function(a){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.unlinkSync(a)},a.prototype.rmdir=function(a,b){var c=this;this._mu.lock(function(){c._fs.rmdir(a,function(a){c._mu.unlock(),b(a)})})},a.prototype.rmdirSync=function(a){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.rmdirSync(a)},a.prototype.mkdir=function(a,b,c){var d=this;this._mu.lock(function(){d._fs.mkdir(a,b,function(a){d._mu.unlock(),c(a)})})},a.prototype.mkdirSync=function(a,b){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.mkdirSync(a,b)},a.prototype.readdir=function(a,b){var c=this;this._mu.lock(function(){c._fs.readdir(a,function(a,d){c._mu.unlock(),b(a,d)})})},a.prototype.readdirSync=function(a){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.readdirSync(a)},a.prototype.exists=function(a,b){var c=this;this._mu.lock(function(){c._fs.exists(a,function(a){c._mu.unlock(),b(a)})})},a.prototype.existsSync=function(a){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.existsSync(a)},a.prototype.realpath=function(a,b,c){var d=this;this._mu.lock(function(){d._fs.realpath(a,b,function(a,b){d._mu.unlock(),c(a,b)})})},a.prototype.realpathSync=function(a,b){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.realpathSync(a,b)},a.prototype.truncate=function(a,b,c){var d=this;this._mu.lock(function(){d._fs.truncate(a,b,function(a){d._mu.unlock(),c(a)})})},a.prototype.truncateSync=function(a,b){if(this._mu.isLocked())throw new Error("invalid sync call"); +return this._fs.truncateSync(a,b)},a.prototype.readFile=function(a,b,c,d){var e=this;this._mu.lock(function(){e._fs.readFile(a,b,c,function(a,b){e._mu.unlock(),d(a,b)})})},a.prototype.readFileSync=function(a,b,c){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.readFileSync(a,b,c)},a.prototype.writeFile=function(a,b,c,d,e,f){var g=this;this._mu.lock(function(){g._fs.writeFile(a,b,c,d,e,function(a){g._mu.unlock(),f(a)})})},a.prototype.writeFileSync=function(a,b,c,d,e){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.writeFileSync(a,b,c,d,e)},a.prototype.appendFile=function(a,b,c,d,e,f){var g=this;this._mu.lock(function(){g._fs.appendFile(a,b,c,d,e,function(a){g._mu.unlock(),f(a)})})},a.prototype.appendFileSync=function(a,b,c,d,e){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.appendFileSync(a,b,c,d,e)},a.prototype.chmod=function(a,b,c,d){var e=this;this._mu.lock(function(){e._fs.chmod(a,b,c,function(a){e._mu.unlock(),d(a)})})},a.prototype.chmodSync=function(a,b,c){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.chmodSync(a,b,c)},a.prototype.chown=function(a,b,c,d,e){var f=this;this._mu.lock(function(){f._fs.chown(a,b,c,d,function(a){f._mu.unlock(),e(a)})})},a.prototype.chownSync=function(a,b,c,d){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.chownSync(a,b,c,d)},a.prototype.utimes=function(a,b,c,d){var e=this;this._mu.lock(function(){e._fs.utimes(a,b,c,function(a){e._mu.unlock(),d(a)})})},a.prototype.utimesSync=function(a,b,c){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.utimesSync(a,b,c)},a.prototype.link=function(a,b,c){var d=this;this._mu.lock(function(){d._fs.link(a,b,function(a){d._mu.unlock(),c(a)})})},a.prototype.linkSync=function(a,b){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.linkSync(a,b)},a.prototype.symlink=function(a,b,c,d){var e=this;this._mu.lock(function(){e._fs.symlink(a,b,c,function(a){e._mu.unlock(),d(a)})})},a.prototype.symlinkSync=function(a,b,c){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.symlinkSync(a,b,c)},a.prototype.readlink=function(a,b){var c=this;this._mu.lock(function(){c._fs.readlink(a,function(a,d){c._mu.unlock(),b(a,d)})})},a.prototype.readlinkSync=function(a){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.readlinkSync(a)},a}();c.__esModule=!0,c.default=e},{"./mutex":67}],67:[function(a,b,c){"use strict";var d=function(){function a(){this._locked=!1,this._waiters=[]}return a.prototype.lock=function(a){return this._locked?void this._waiters.push(a):(this._locked=!0,void a())},a.prototype.unlock=function(){if(!this._locked)throw new Error("unlock of a non-locked mutex");var a=this._waiters.shift();return a?void setImmediate(a):void(this._locked=!1)},a.prototype.tryLock=function(){return!this._locked&&(this._locked=!0,!0)},a.prototype.isLocked=function(){return this._locked},a}();c.__esModule=!0,c.default=d},{}],68:[function(a,b,c){(function(b){"use strict";var d=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)},e=a("../core/file"),f=a("../core/api_error"),g=a("../core/node_fs"),h=function(a){function c(c,d,e,f,g){if(a.call(this),this._pos=0,this._dirty=!1,this._fs=c,this._path=d,this._flag=e,this._stat=f,null!=g?this._buffer=g:this._buffer=new b(0),this._stat.size!==this._buffer.length&&this._flag.isReadable())throw new Error("Invalid buffer: Buffer is "+this._buffer.length+" long, yet Stats object specifies that file is "+this._stat.size+" long.")}return d(c,a),c.prototype.isDirty=function(){return this._dirty},c.prototype.resetDirty=function(){this._dirty=!1},c.prototype.getBuffer=function(){return this._buffer},c.prototype.getStats=function(){return this._stat},c.prototype.getFlag=function(){return this._flag},c.prototype.getPath=function(){return this._path},c.prototype.getPos=function(){return this._flag.isAppendable()?this._stat.size:this._pos},c.prototype.advancePos=function(a){return this._pos+=a},c.prototype.setPos=function(a){return this._pos=a},c.prototype.sync=function(a){try{this.syncSync(),a()}catch(b){a(b)}},c.prototype.syncSync=function(){throw new f.ApiError(f.ErrorCode.ENOTSUP)},c.prototype.close=function(a){try{this.closeSync(),a()}catch(b){a(b)}},c.prototype.closeSync=function(){throw new f.ApiError(f.ErrorCode.ENOTSUP)},c.prototype.stat=function(a){try{a(null,this._stat.clone())}catch(b){a(b)}},c.prototype.statSync=function(){return this._stat.clone()},c.prototype.truncate=function(a,b){try{this.truncateSync(a),this._flag.isSynchronous()&&!g.getRootFS().supportsSynch()&&this.sync(b),b()}catch(a){return b(a)}},c.prototype.truncateSync=function(a){if(this._dirty=!0,!this._flag.isWriteable())throw new f.ApiError(f.ErrorCode.EPERM,"File not opened with a writeable mode.");if(this._stat.mtime=new Date,a>this._buffer.length){var c=new b(a-this._buffer.length);return c.fill(0),this.writeSync(c,0,c.length,this._buffer.length),void(this._flag.isSynchronous()&&g.getRootFS().supportsSynch()&&this.syncSync())}this._stat.size=a;var d=new b(a);this._buffer.copy(d,0,0,a),this._buffer=d,this._flag.isSynchronous()&&g.getRootFS().supportsSynch()&&this.syncSync()},c.prototype.write=function(a,b,c,d,e){try{e(null,this.writeSync(a,b,c,d),a)}catch(a){e(a)}},c.prototype.writeSync=function(a,c,d,e){if(this._dirty=!0,null==e&&(e=this.getPos()),!this._flag.isWriteable())throw new f.ApiError(f.ErrorCode.EPERM,"File not opened with a writeable mode.");var g=e+d;if(g>this._stat.size&&(this._stat.size=g,g>this._buffer.length)){var h=new b(g);this._buffer.copy(h),this._buffer=h}var i=a.copy(this._buffer,e,c,c+d);return this._stat.mtime=new Date,this._flag.isSynchronous()?(this.syncSync(),i):(this.setPos(e+i),i)},c.prototype.read=function(a,b,c,d,e){try{e(null,this.readSync(a,b,c,d),a)}catch(a){e(a)}},c.prototype.readSync=function(a,b,c,d){if(!this._flag.isReadable())throw new f.ApiError(f.ErrorCode.EPERM,"File not opened with a readable mode.");null==d&&(d=this.getPos());var e=d+c;e>this._stat.size&&(c=this._stat.size-d);var g=this._buffer.copy(a,b,d,d+c);return this._stat.atime=new Date,this._pos=d+c,g},c.prototype.chmod=function(a,b){try{this.chmodSync(a),b()}catch(a){b(a)}},c.prototype.chmodSync=function(a){if(!this._fs.supportsProps())throw new f.ApiError(f.ErrorCode.ENOTSUP);this._dirty=!0,this._stat.chmod(a),this.syncSync()},c}(e.BaseFile);c.PreloadFile=h;var i=function(a){function b(b,c,d,e,f){a.call(this,b,c,d,e,f)}return d(b,a),b.prototype.sync=function(a){a()},b.prototype.syncSync=function(){},b.prototype.close=function(a){a()},b.prototype.closeSync=function(){},b}(h);c.NoSyncFile=i}).call(this,a("bfs-buffer").Buffer)},{"../core/api_error":52,"../core/file":55,"../core/node_fs":59,"bfs-buffer":2}],69:[function(a,b,c){(function(b){"use strict";function d(a){for(var b=IEBinaryToArray_ByteStr(a),c=IEBinaryToArray_ByteStr_Last(a),d=b.replace(/[\s\S]/g,function(a){var b=a.charCodeAt(0);return String.fromCharCode(255&b,b>>8)})+c,e=new Array(d.length),f=0;f>>0;if("function"!=typeof a)throw new TypeError;for(var d=[],e=arguments.length>=2?arguments[1]:void 0,f=0;f0)){var b=f.shift();return b()}};e.addEventListener?e.addEventListener("message",i,!0):e.attachEvent("onmessage",i)}else if(e.MessageChannel){var j=new e.MessageChannel;j.port1.onmessage=function(a){if(f.length>0)return f.shift()()},e.setImmediate=function(a){f.push(a),j.port2.postMessage("")}}else e.setImmediate=function(a){return setTimeout(a,0)}}if(Array.prototype.indexOf||(Array.prototype.indexOf=function(a,b){if(void 0===b&&(b=0),!this)throw new TypeError;var c=this.length;if(0===c||d>=c)return-1;var d=b;d<0&&(d=c+d);for(var e=d;e>>0;if("function"!=typeof a)throw new TypeError(a+" is not a function");for(b&&(c=b),d=new Array(g),e=0;e\r\n"+k+"\r\n");else{var l=document.createElement("script");l.type="text/vbscript",l.innerHTML=k,document.head.appendChild(l)}}var m=a("./core/browserfs");b.exports=m},{"./core/browserfs":54,"./core/global":58}]},{},[50])(50)}); +//# sourceMappingURL=browserfs.min.js.map \ No newline at end of file diff --git a/pkg/emscripten/libretro/indexer b/pkg/emscripten/libretro/indexer new file mode 100644 index 0000000000..64ada095cd --- /dev/null +++ b/pkg/emscripten/libretro/indexer @@ -0,0 +1,35 @@ +#! /usr/bin/env coffee + +fs = require 'fs' +path = require 'path' + +symLinks = {} + +rdSync = (dpath, tree, name) -> + files = fs.readdirSync(dpath) + for file in files + # ignore non-essential directories / files + continue if file in ['.git', 'node_modules', 'bower_components', 'build'] or file[0] is '.' + fpath = dpath + '/' + file + try + # Avoid infinite loops. + lstat = fs.lstatSync(fpath) + if lstat.isSymbolicLink() + symLinks[lstat.dev] ?= {} + # Ignore if we've seen it before + continue if symLinks[lstat.dev][lstat.ino]? + symLinks[lstat.dev][lstat.ino] = 0 + + fstat = fs.statSync(fpath) + if fstat.isDirectory() + tree[file] = child = {} + rdSync(fpath, child, file) + else + tree[file] = null + catch e + # Ignore and move on. + return tree + +fs_listing = rdSync(process.cwd(), {}, '/') +console.log(JSON.stringify(fs_listing)) + From 039da3bb83dc299f9a084ee56d096946325edda9 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Tue, 6 Feb 2018 22:17:32 -0500 Subject: [PATCH 152/232] C89 buildfix --- cheevos/cheevos.c | 3 ++- input/drivers/udev_input.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cheevos/cheevos.c b/cheevos/cheevos.c index a9de8db794..8fd423a885 100644 --- a/cheevos/cheevos.c +++ b/cheevos/cheevos.c @@ -2487,8 +2487,9 @@ bool cheevos_apply_cheats(bool *data_bool) bool cheevos_unload(void) { + bool running; CHEEVOS_LOCK(cheevos_locals.task_lock); - bool running = cheevos_locals.task != NULL; + running = cheevos_locals.task != NULL; CHEEVOS_UNLOCK(cheevos_locals.task_lock); if (running) diff --git a/input/drivers/udev_input.c b/input/drivers/udev_input.c index bcdacb60a6..b7de9b7253 100644 --- a/input/drivers/udev_input.c +++ b/input/drivers/udev_input.c @@ -776,6 +776,8 @@ static int16_t udev_lightgun_aiming_state(udev_input_t *udev, unsigned port, uns int16_t res_screen_x = 0; int16_t res_screen_y = 0; + udev_input_mouse_t *mouse = udev_get_mouse(udev, port); + vp.x = 0; vp.y = 0; vp.width = 0; @@ -783,8 +785,6 @@ static int16_t udev_lightgun_aiming_state(udev_input_t *udev, unsigned port, uns vp.full_width = 0; vp.full_height = 0; - udev_input_mouse_t *mouse = udev_get_mouse(udev, port); - if (!mouse) return 0; From db65537c24257238e287d007b20234f183a2b84a Mon Sep 17 00:00:00 2001 From: radius Date: Tue, 6 Feb 2018 22:17:58 -0500 Subject: [PATCH 153/232] fixup emscripten bundle --- pkg/emscripten/libretro/embed.html | 8 ++++---- pkg/emscripten/libretro/readme.txt | 11 +++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 pkg/emscripten/libretro/readme.txt diff --git a/pkg/emscripten/libretro/embed.html b/pkg/emscripten/libretro/embed.html index 6124b7a843..fbe346576c 100644 --- a/pkg/emscripten/libretro/embed.html +++ b/pkg/emscripten/libretro/embed.html @@ -31,9 +31,9 @@ FCEUmm Gambatte Genesis Plus GX - Nestopia (NES) - Snes9x 2010 (SNES) - VBA Next (Gameboy Advance) + Nestopia (NES) + Snes9x 2010 (SNES) + VBA Next (Gameboy Advance)