From 5af522224944012143d68f3e4638cb00baa4382b Mon Sep 17 00:00:00 2001 From: aliaspider Date: Fri, 26 Jan 2018 13:48:17 +0100 Subject: [PATCH] update SPIRV-Cross - https://github.com/KhronosGroup/SPIRV-Cross/commit/ 66a407285e36a0f772e3209cb86ded6e3d900f6a --- deps/SPIRV-Cross/.gitignore | 2 + deps/SPIRV-Cross/.travis.yml | 13 +- deps/SPIRV-Cross/CMakeLists.txt | 127 +- deps/SPIRV-Cross/GLSL.std.450.h | 2 +- deps/SPIRV-Cross/README.md | 151 +- .../checkout_glslang_spirv_tools.sh | 57 + .../include/spirv_cross/barrier.hpp | 2 +- .../include/spirv_cross/external_interface.h | 2 +- .../SPIRV-Cross/include/spirv_cross/image.hpp | 4 +- .../spirv_cross/internal_interface.hpp | 6 +- .../include/spirv_cross/sampler.hpp | 2 +- .../include/spirv_cross/thread_group.hpp | 2 +- deps/SPIRV-Cross/main.cpp | 263 +- deps/SPIRV-Cross/msvc/SPIRV-Cross.vcxproj | 2 + .../msvc/SPIRV-Cross.vcxproj.filters | 6 + ...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 + .../shaders/comp/loop.noopt.comp} | 4 +- .../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 | 28 +- .../shaders/asm/comp/bitcast_iequal.asm.comp | 36 +- .../shaders/asm/comp/bitcast_sar.asm.comp | 28 +- .../shaders/asm/comp/bitcast_sdiv.asm.comp | 28 +- .../shaders/asm/comp/bitcast_slr.asm.comp | 28 +- .../shaders/asm/comp/bitcast_udiv.asm.comp | 27 - .../shaders/asm/comp/logical.asm.comp | 56 + .../shaders/asm/comp/multiple-entry.asm.comp | 28 +- .../asm/comp/name-alias.asm.invalid.comp | 16 +- ...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 | 6 +- ...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/bake_gradient.comp | 4 +- .../reference/shaders/comp/barriers.comp | 83 + .../reference/shaders/comp/basic.comp | 4 +- .../shaders/comp/bitfield.noopt.comp | 19 + .../shaders/comp/cfg-preserve-parameter.comp | 74 + .../reference/shaders/comp/cfg.comp | 2 +- .../shaders/comp/coherent-block.comp | 13 + .../shaders/comp/coherent-image.comp | 15 + .../reference/shaders/comp/culling.comp | 4 +- .../reference/shaders/comp/dowhile.comp | 4 +- .../shaders/comp/generate_height.comp | 36 +- .../reference/shaders/comp/image.comp | 4 +- .../shaders/comp/inout-struct.invalid.comp | 8 +- .../reference/shaders/comp/insert.comp | 2 +- .../reference/shaders/comp/loop.noopt.comp | 105 + .../reference/shaders/comp/mat3.comp | 2 +- .../reference/shaders/comp/mod.comp | 4 +- .../reference/shaders/comp/modf.comp | 4 +- .../shaders/comp/read-write-only.comp | 27 + .../reference/shaders/comp/return.comp | 2 +- .../reference/shaders/comp/rmw-opt.comp | 27 + .../reference/shaders/comp/shared.comp | 4 +- .../reference/shaders/comp/struct-layout.comp | 4 +- .../shaders/comp/struct-packing.comp | 8 + .../reference/shaders/comp/torture-loop.comp | 4 +- .../desktop-only/comp/enhanced-layouts.comp | 40 + .../frag/hlsl-uav-block-alias.asm.frag | 24 + .../frag/image-query.desktop.frag | 53 + .../frag/in-block-qualifiers.frag | 18 +- .../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 | 16 +- .../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 | 4 +- .../shaders/frag/constant-array.frag | 2 +- .../shaders/frag/false-loop-init.frag | 25 + .../reference/shaders/frag/flush_params.frag | 2 +- .../reference/shaders/frag/frexp-modf.frag | 43 + .../reference/shaders/frag/ground.frag | 4 +- .../frag/image-load-store-uint-coord.asm.frag | 26 + .../reference/shaders/frag/mix.frag | 24 +- .../shaders/frag/partial-write-preserve.frag | 109 + .../reference/shaders/frag/pls.frag | 4 +- .../shaders/frag/sample-parameter.frag | 13 + .../reference/shaders/frag/sampler-proj.frag | 16 + .../reference/shaders/frag/sampler.frag | 4 +- .../reference/shaders/frag/unary-enclose.frag | 16 + .../reference/shaders/geom/basic.geom | 4 +- .../shaders/geom/lines-adjacency.geom | 4 +- .../reference/shaders/geom/lines.geom | 4 +- .../reference/shaders/geom/points.geom | 4 +- .../shaders/geom/single-invocation.geom | 4 +- .../shaders/geom/triangles-adjacency.geom | 4 +- .../reference/shaders/geom/triangles.geom | 4 +- .../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 | 2 +- .../reference/shaders/tesc/water_tess.tesc | 6 +- .../reference/shaders/tese/water_tess.tese | 8 +- .../reference/shaders/vert/basic.vert | 6 +- .../reference/shaders/vert/ground.vert | 64 +- .../reference/shaders/vert/ocean.vert | 84 +- .../shaders/vert/texture_buffer.vert | 2 +- .../reference/shaders/vert/ubo.vert | 6 +- .../combined-texture-sampler-shadow.vk.frag | 31 + ...combined-texture-sampler-shadow.vk.frag.vk | 32 + .../vulkan/frag/desktop-mediump.vk.frag | 12 + .../vulkan/frag/desktop-mediump.vk.frag.vk | 12 + .../vulkan/frag/input-attachment-ms.vk.frag | 10 +- .../frag/input-attachment-ms.vk.frag.vk | 10 +- .../shaders/vulkan/frag/spec-constant.vk.frag | 6 +- .../vulkan/frag/spec-constant.vk.frag.vk | 102 +- .../vulkan/vert/multiview.nocompat.vk.vert | 15 + .../vulkan/vert/multiview.nocompat.vk.vert.vk | 15 + deps/SPIRV-Cross/samples/cpp/atomics.cpp | 2 +- deps/SPIRV-Cross/samples/cpp/multiply.cpp | 2 +- deps/SPIRV-Cross/samples/cpp/shared.cpp | 2 +- ...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} | 18 +- .../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 + .../comp/loop.noopt.comp} | 0 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/logical.asm.comp | 191 + ...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 | 3 + ...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/barriers.comp | 79 + .../shaders/comp/bitfield.noopt.comp | 21 + .../shaders/comp/cfg-preserve-parameter.comp | 54 + .../shaders/comp/coherent-block.comp | 12 + .../shaders/comp/coherent-image.comp | 14 + deps/SPIRV-Cross/shaders/comp/loop.noopt.comp | 98 + .../shaders/comp/read-write-only.comp | 26 + deps/SPIRV-Cross/shaders/comp/rmw-opt.comp | 27 + .../shaders/comp/struct-packing.comp | 10 + .../desktop-only/comp/enhanced-layouts.comp | 39 + .../frag/hlsl-uav-block-alias.asm.frag | 56 + .../frag/image-query.desktop.frag | 56 + .../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 + .../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 | 4 +- .../shaders/frag/false-loop-init.frag | 19 + deps/SPIRV-Cross/shaders/frag/frexp-modf.frag | 24 + .../frag/image-load-store-uint-coord.asm.frag | 103 + .../shaders/frag/partial-write-preserve.frag | 95 + deps/SPIRV-Cross/shaders/frag/pls.frag | 4 +- .../shaders/frag/sample-parameter.frag | 11 + .../shaders/frag/sampler-proj.frag | 12 + deps/SPIRV-Cross/shaders/frag/sampler.frag | 4 +- .../shaders/frag/unary-enclose.frag | 15 + deps/SPIRV-Cross/shaders/geom/basic.geom | 4 +- .../shaders/geom/lines-adjacency.geom | 4 +- deps/SPIRV-Cross/shaders/geom/lines.geom | 4 +- deps/SPIRV-Cross/shaders/geom/points.geom | 4 +- .../shaders/geom/single-invocation.geom | 4 +- .../shaders/geom/triangles-adjacency.geom | 4 +- deps/SPIRV-Cross/shaders/geom/triangles.geom | 4 +- .../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 | 2 +- deps/SPIRV-Cross/shaders/tesc/water_tess.tesc | 6 +- deps/SPIRV-Cross/shaders/tese/water_tess.tese | 8 +- deps/SPIRV-Cross/shaders/vert/basic.vert | 7 +- deps/SPIRV-Cross/shaders/vert/ubo.vert | 6 +- .../combined-texture-sampler-shadow.vk.frag | 29 + .../vulkan/frag/desktop-mediump.vk.frag | 11 + .../vulkan/frag/input-attachment-ms.vk.frag | 9 +- .../shaders/vulkan/frag/spec-constant.vk.frag | 6 +- .../vulkan/vert/multiview.nocompat.vk.vert | 14 + deps/SPIRV-Cross/spirv.hpp | 93 +- deps/SPIRV-Cross/spirv_cfg.cpp | 22 +- deps/SPIRV-Cross/spirv_cfg.hpp | 14 +- deps/SPIRV-Cross/spirv_common.hpp | 327 +- deps/SPIRV-Cross/spirv_cpp.cpp | 19 +- deps/SPIRV-Cross/spirv_cpp.hpp | 16 +- deps/SPIRV-Cross/spirv_cross.cpp | 1444 +++++-- deps/SPIRV-Cross/spirv_cross.hpp | 227 +- deps/SPIRV-Cross/spirv_glsl.cpp | 3525 +++++++++++++--- deps/SPIRV-Cross/spirv_glsl.hpp | 222 +- deps/SPIRV-Cross/spirv_hlsl.cpp | 3676 +++++++++++++++++ deps/SPIRV-Cross/spirv_hlsl.hpp | 164 + deps/SPIRV-Cross/spirv_msl.cpp | 3270 +++++++++++---- deps/SPIRV-Cross/spirv_msl.hpp | 266 +- deps/SPIRV-Cross/test_shaders.py | 262 +- deps/SPIRV-Cross/test_shaders.sh | 17 + deps/SPIRV-Cross/update_test_shaders.sh | 17 + 891 files changed, 42215 insertions(+), 2474 deletions(-) create mode 100644 deps/SPIRV-Cross/checkout_glslang_spirv_tools.sh create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/asm/comp/specialization-constant-workgroup.nofxc.asm.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/asm/comp/storage-buffer-basic.nofxc.asm.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/asm/frag/cbuffer-stripped.asm.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/asm/frag/unreachable.asm.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/asm/vert/empty-struct-composite.asm.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/asm/vert/vertex-id-instance-id.asm.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/access-chains.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/address-buffers.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/atomic.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/barriers.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/bitfield.noopt.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/builtins.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/image.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/rwbuffer-matrix.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/shared.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/ssbo-array.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/basic.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/bit-conversions.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/boolean-mix.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/builtins.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/bvec-operations.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/combined-texture-sampler-parameter.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/combined-texture-sampler-shadow.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/constant-buffer-array.sm51.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/early-fragment-test.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/fp16-packing.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/image-query-selective.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/image-query.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/io-block.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/matrix-input.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/mod.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/mrt.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/no-return.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/no-return2.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/partial-write-preserve.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/query-lod.desktop.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/resources.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/sample-cmp-level-zero.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/sampler-array.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/spec-constant.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/swizzle-scalar.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/tex-sampling.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/texture-proj-shadow.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/unary-enclose.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/unorm-snorm-packing.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/various-glsl-ops.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/basic.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/instancing.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/locations.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/matrix-attribute.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/matrix-output.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/no-input.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/point-size-compat.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/qualifiers.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/sampler-buffers.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/struct-composite-decl.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/texture_buffer.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/bitcast_iadd.asm.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/bitcast_sar.asm.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/bitcast_sdiv.asm.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/bitcast_slr.asm.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/multiple-entry.asm.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/quantize.asm.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/specialization-constant-workgroup.asm.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/asm/comp/storage-buffer-basic.asm.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/asm/frag/default-member-names.asm.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/asm/frag/op-constant-null.asm.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/asm/frag/phi-loop-variable.asm.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/asm/frag/undef-variable-store.asm.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/asm/frag/unreachable.asm.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/asm/vert/empty-struct-composite.asm.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/atomic.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/bake_gradient.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/barriers.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/basic.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/bitfield.noopt.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/builtins.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/cfg-preserve-parameter.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/coherent-block.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/coherent-image.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/culling.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/defer-parens.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/dowhile.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/functions.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/global-invocation-id-writable-ssbo-in-function.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/global-invocation-id.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/image.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/insert.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/local-invocation-id.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/local-invocation-index.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/loop.noopt.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/mat3.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/mod.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/modf.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/read-write-only.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/return.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/rmw-opt.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/shared.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/struct-layout.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/struct-packing.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/torture-loop.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/type-alias.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/udiv.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/comp/writable-ssbo.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/desktop-only/frag/image-ms.desktop.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/desktop-only/frag/query-levels.desktop.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/desktop-only/frag/sampler-ms-query.desktop.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/desktop-only/vert/basic.desktop.sso.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/desktop-only/vert/clip-cull-distance.desktop.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/basic.flatten.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/multiindex.flatten.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/push-constant.flatten.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/rowmajor.flatten.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/struct.flatten.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/swizzle.flatten.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/types.flatten.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/frag/basic.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/frag/bitcasting.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/frag/builtins.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/frag/composite-extract-forced-temporary.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/frag/constant-array.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/frag/false-loop-init.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/frag/flush_params.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/frag/for-loop-init.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/frag/in_block.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/frag/in_block_assign.noopt.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/frag/mix.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/frag/pls.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/frag/sampler-ms.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/frag/sampler.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/frag/separate-image-sampler-argument.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/frag/swizzle.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/frag/texture-proj-shadow.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/frag/ubo_layout.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/frag/unary-enclose.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/legacy/vert/transpose.legacy.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/vert/basic.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/vert/copy.flatten.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/vert/dynamic.flatten.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/vert/functions.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/vert/out_block.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/vert/pointsize.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/vert/texture_buffer.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/vert/ubo.alignment.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/vert/ubo.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/vulkan/frag/push-constant.vk.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/vulkan/frag/spec-constant.vk.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders-msl/vulkan/vert/vulkan-vertex.vk.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag.vk create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/amd/fs.invalid.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/amd/gcn_shader.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/amd/shader_ballot.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/amd/shader_ballot_nonuniform_invocations.invalid.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/amd/shader_group_vote.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/amd/shader_trinary_minmax.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/comp/bitcast_iadd.asm.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/comp/bitcast_iequal.asm.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/comp/bitcast_sar.asm.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/comp/bitcast_sdiv.asm.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/comp/bitcast_slr.asm.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/comp/logical.asm.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/comp/multiple-entry.asm.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/comp/name-alias.asm.invalid.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/comp/quantize.asm.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/comp/specialization-constant-workgroup.asm.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/comp/storage-buffer-basic.asm.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/frag/composite-construct-struct-no-swizzle.asm.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/frag/default-member-names.asm.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/frag/hlsl-sample-cmp-level-zero-cube.asm.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/frag/hlsl-sample-cmp-level-zero.asm.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/frag/invalidation.asm.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/frag/multi-for-loop-init.asm.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/frag/op-constant-null.asm.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/frag/phi-loop-variable.asm.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/frag/sampler-buffer-without-sampler.asm.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/frag/struct-composite-extract-swizzle.asm.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/frag/temporary-phi-hoisting.asm.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/frag/undef-variable-store.asm.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/frag/unreachable.asm.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/frag/vector-shuffle-oom.asm.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/tesc/tess-fixed-input-array-builtin-array.asm.tesc create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/vert/empty-io.asm.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/vert/empty-struct-composite.asm.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/asm/vert/global-builtin.sso.asm.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/atomic.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/bake_gradient.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/barriers.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/basic.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/bitfield.noopt.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/casts.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/cfg-preserve-parameter.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/cfg.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/coherent-block.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/coherent-image.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/composite-construct.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/culling.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/defer-parens.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/dowhile.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/generate_height.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/image.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/inout-struct.invalid.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/insert.comp rename deps/SPIRV-Cross/reference/{shaders/comp/loop.comp => opt/shaders/comp/loop.noopt.comp} (94%) create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/mat3.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/mod.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/modf.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/read-write-only.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/return.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/rmw-opt.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/shared.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/ssbo-array.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/struct-layout.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/struct-packing.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/torture-loop.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/type-alias.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/comp/udiv.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/desktop-only/comp/enhanced-layouts.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/desktop-only/comp/fp64.desktop.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/desktop-only/comp/image-formats.desktop.noeliminate.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/desktop-only/comp/int64.desktop.comp create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/hlsl-uav-block-alias.asm.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/image-ms.desktop.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/image-query.desktop.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/in-block-qualifiers.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/query-levels.desktop.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/query-lod.desktop.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/sampler-ms-query.desktop.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/desktop-only/frag/texture-proj-shadow.desktop.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/desktop-only/geom/basic.desktop.sso.geom create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/desktop-only/geom/viewport-index.desktop.geom create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/desktop-only/tesc/basic.desktop.sso.tesc create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/desktop-only/tese/triangle.desktop.sso.tese create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/desktop-only/vert/basic.desktop.sso.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/desktop-only/vert/clip-cull-distance.desktop.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/desktop-only/vert/out-block-qualifiers.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/flatten/array.flatten.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/flatten/basic.flatten.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/flatten/copy.flatten.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/flatten/dynamic.flatten.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/flatten/matrixindex.flatten.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/flatten/multi-dimensional.desktop.flatten_dim.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/flatten/multiindex.flatten.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/flatten/push-constant.flatten.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/flatten/rowmajor.flatten.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/flatten/struct.flatten.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/flatten/struct.rowmajor.flatten.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/flatten/swizzle.flatten.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/flatten/types.flatten.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/basic.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/composite-extract-forced-temporary.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/constant-array.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/eliminate-dead-variables.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/false-loop-init.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/flush_params.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/for-loop-init.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/frexp-modf.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/ground.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/image-load-store-uint-coord.asm.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/mix.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/partial-write-preserve.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/pls.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/sample-parameter.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/sampler-ms-query.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/sampler-ms.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/sampler-proj.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/sampler.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/swizzle.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/temporary.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/ubo_layout.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/frag/unary-enclose.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/geom/basic.geom create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/geom/lines-adjacency.geom create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/geom/lines.geom create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/geom/points.geom create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/geom/single-invocation.geom create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/geom/triangles-adjacency.geom create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/geom/triangles.geom create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/legacy/fragment/explicit-lod.legacy.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/legacy/fragment/io-blocks.legacy.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/legacy/fragment/struct-varying.legacy.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/legacy/vert/implicit-lod.legacy.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/legacy/vert/io-block.legacy.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/legacy/vert/struct-varying.legacy.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/legacy/vert/transpose.legacy.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/tesc/basic.tesc create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/tesc/water_tess.tesc create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/tese/ccw.tese create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/tese/cw.tese create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/tese/equal.tese create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/tese/fractional_even.tese create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/tese/fractional_odd.tese create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/tese/line.tese create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/tese/triangle.tese create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/tese/water_tess.tese create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vert/basic.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vert/ground.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vert/ocean.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vert/texture_buffer.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vert/ubo.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag.vk create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/combined-texture-sampler.vk.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/combined-texture-sampler.vk.frag.vk create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/desktop-mediump.vk.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/desktop-mediump.vk.frag.vk create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/input-attachment-ms.vk.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/input-attachment-ms.vk.frag.vk create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/input-attachment.vk.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/input-attachment.vk.frag.vk create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/push-constant.vk.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/push-constant.vk.frag.vk create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/separate-sampler-texture.vk.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/separate-sampler-texture.vk.frag.vk create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/spec-constant.vk.frag create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/frag/spec-constant.vk.frag.vk create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/vert/multiview.nocompat.vk.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/vert/multiview.nocompat.vk.vert.vk create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/vert/vulkan-vertex.vk.vert create mode 100644 deps/SPIRV-Cross/reference/opt/shaders/vulkan/vert/vulkan-vertex.vk.vert.vk create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/asm/comp/specialization-constant-workgroup.nofxc.asm.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/asm/comp/storage-buffer-basic.nofxc.asm.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/asm/frag/cbuffer-stripped.asm.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/asm/frag/unreachable.asm.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/asm/vert/empty-struct-composite.asm.vert create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/asm/vert/vertex-id-instance-id.asm.vert create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/comp/access-chains.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/comp/address-buffers.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/comp/atomic.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/comp/barriers.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/comp/bitfield.noopt.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/comp/builtins.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/comp/image.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/comp/rwbuffer-matrix.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/comp/shared.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/comp/ssbo-array.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/basic.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/bit-conversions.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/boolean-mix.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/builtins.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/bvec-operations.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/combined-texture-sampler-parameter.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/combined-texture-sampler-shadow.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/constant-buffer-array.sm51.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/early-fragment-test.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/fp16-packing.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/image-query-selective.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/image-query.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/io-block.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/matrix-input.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/mod.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/mrt.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/no-return.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/no-return2.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/partial-write-preserve.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/query-lod.desktop.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/resources.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/sample-cmp-level-zero.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/sampler-array.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/spec-constant.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/swizzle-scalar.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/tex-sampling.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/texture-proj-shadow.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/unary-enclose.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/unorm-snorm-packing.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/frag/various-glsl-ops.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/vert/basic.vert create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/vert/instancing.vert create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/vert/locations.vert create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/vert/matrix-attribute.vert create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/vert/matrix-output.vert create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/vert/no-input.vert create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/vert/point-size-compat.vert create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/vert/qualifiers.vert create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/vert/sampler-buffers.vert create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/vert/struct-composite-decl.vert create mode 100644 deps/SPIRV-Cross/reference/shaders-hlsl/vert/texture_buffer.vert create mode 100644 deps/SPIRV-Cross/reference/shaders-msl-no-opt/vert/functions_nested.vert create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/asm/comp/bitcast_iadd.asm.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/asm/comp/bitcast_sar.asm.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/asm/comp/bitcast_sdiv.asm.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/asm/comp/bitcast_slr.asm.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/asm/comp/multiple-entry.asm.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/asm/comp/quantize.asm.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/asm/comp/specialization-constant-workgroup.asm.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/asm/comp/storage-buffer-basic.asm.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/asm/frag/default-member-names.asm.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/asm/frag/op-constant-null.asm.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/asm/frag/phi-loop-variable.asm.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/asm/frag/undef-variable-store.asm.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/asm/frag/unreachable.asm.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/asm/vert/empty-struct-composite.asm.vert create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/atomic.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/bake_gradient.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/barriers.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/basic.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/bitfield.noopt.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/builtins.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/cfg-preserve-parameter.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/coherent-block.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/coherent-image.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/culling.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/defer-parens.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/dowhile.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/functions.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/global-invocation-id-writable-ssbo-in-function.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/global-invocation-id.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/image.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/insert.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/local-invocation-id.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/local-invocation-index.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/loop.noopt.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/mat3.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/mod.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/modf.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/read-write-only.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/return.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/rmw-opt.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/shared.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/struct-layout.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/struct-packing.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/torture-loop.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/type-alias.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/udiv.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/comp/writable-ssbo.comp create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/desktop-only/frag/image-ms.desktop.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/desktop-only/frag/query-levels.desktop.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/desktop-only/frag/sampler-ms-query.desktop.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/desktop-only/vert/basic.desktop.sso.vert create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/desktop-only/vert/clip-cull-distance.desktop.vert create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/flatten/basic.flatten.vert create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/flatten/multiindex.flatten.vert create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/flatten/push-constant.flatten.vert create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/flatten/rowmajor.flatten.vert create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/flatten/struct.flatten.vert create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/flatten/swizzle.flatten.vert create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/flatten/types.flatten.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/frag/basic.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/frag/bitcasting.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/frag/builtins.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/frag/composite-extract-forced-temporary.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/frag/constant-array.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/frag/false-loop-init.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/frag/flush_params.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/frag/for-loop-init.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/frag/in_block.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/frag/in_block_assign.noopt.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/frag/mix.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/frag/pls.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/frag/sampler-ms.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/frag/sampler.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/frag/separate-image-sampler-argument.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/frag/swizzle.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/frag/texture-proj-shadow.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/frag/ubo_layout.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/frag/unary-enclose.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/legacy/vert/transpose.legacy.vert create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/vert/basic.vert create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/vert/copy.flatten.vert create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/vert/dynamic.flatten.vert create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/vert/functions.vert create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/vert/out_block.vert create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/vert/pointsize.vert create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/vert/texture_buffer.vert create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/vert/ubo.alignment.vert create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/vert/ubo.vert create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/vulkan/frag/push-constant.vk.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/vulkan/frag/spec-constant.vk.frag create mode 100644 deps/SPIRV-Cross/reference/shaders-msl/vulkan/vert/vulkan-vertex.vk.vert create mode 100644 deps/SPIRV-Cross/reference/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag create mode 100644 deps/SPIRV-Cross/reference/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag.vk create mode 100644 deps/SPIRV-Cross/reference/shaders/amd/fs.invalid.frag create mode 100644 deps/SPIRV-Cross/reference/shaders/amd/gcn_shader.comp create mode 100644 deps/SPIRV-Cross/reference/shaders/amd/shader_ballot.comp create mode 100644 deps/SPIRV-Cross/reference/shaders/amd/shader_ballot_nonuniform_invocations.invalid.comp create mode 100644 deps/SPIRV-Cross/reference/shaders/amd/shader_group_vote.comp create mode 100644 deps/SPIRV-Cross/reference/shaders/amd/shader_trinary_minmax.comp delete mode 100644 deps/SPIRV-Cross/reference/shaders/asm/comp/bitcast_udiv.asm.comp create mode 100644 deps/SPIRV-Cross/reference/shaders/asm/comp/logical.asm.comp create mode 100644 deps/SPIRV-Cross/reference/shaders/asm/comp/specialization-constant-workgroup.asm.comp create mode 100644 deps/SPIRV-Cross/reference/shaders/asm/comp/storage-buffer-basic.asm.comp create mode 100644 deps/SPIRV-Cross/reference/shaders/asm/frag/composite-construct-struct-no-swizzle.asm.frag create mode 100644 deps/SPIRV-Cross/reference/shaders/asm/frag/default-member-names.asm.frag create mode 100644 deps/SPIRV-Cross/reference/shaders/asm/frag/hlsl-sample-cmp-level-zero-cube.asm.frag create mode 100644 deps/SPIRV-Cross/reference/shaders/asm/frag/hlsl-sample-cmp-level-zero.asm.frag create mode 100644 deps/SPIRV-Cross/reference/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag create mode 100644 deps/SPIRV-Cross/reference/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag create mode 100644 deps/SPIRV-Cross/reference/shaders/asm/frag/multi-for-loop-init.asm.frag create mode 100644 deps/SPIRV-Cross/reference/shaders/asm/frag/op-constant-null.asm.frag create mode 100644 deps/SPIRV-Cross/reference/shaders/asm/frag/phi-loop-variable.asm.frag create mode 100644 deps/SPIRV-Cross/reference/shaders/asm/frag/sampler-buffer-without-sampler.asm.frag create mode 100644 deps/SPIRV-Cross/reference/shaders/asm/frag/struct-composite-extract-swizzle.asm.frag create mode 100644 deps/SPIRV-Cross/reference/shaders/asm/frag/temporary-phi-hoisting.asm.frag create mode 100644 deps/SPIRV-Cross/reference/shaders/asm/frag/undef-variable-store.asm.frag create mode 100644 deps/SPIRV-Cross/reference/shaders/asm/frag/unreachable.asm.frag create mode 100644 deps/SPIRV-Cross/reference/shaders/asm/frag/vector-shuffle-oom.asm.frag create mode 100644 deps/SPIRV-Cross/reference/shaders/asm/tesc/tess-fixed-input-array-builtin-array.asm.tesc create mode 100644 deps/SPIRV-Cross/reference/shaders/asm/vert/empty-io.asm.vert create mode 100644 deps/SPIRV-Cross/reference/shaders/asm/vert/empty-struct-composite.asm.vert create mode 100644 deps/SPIRV-Cross/reference/shaders/asm/vert/global-builtin.sso.asm.vert create mode 100644 deps/SPIRV-Cross/reference/shaders/comp/barriers.comp create mode 100644 deps/SPIRV-Cross/reference/shaders/comp/bitfield.noopt.comp create mode 100644 deps/SPIRV-Cross/reference/shaders/comp/cfg-preserve-parameter.comp create mode 100644 deps/SPIRV-Cross/reference/shaders/comp/coherent-block.comp create mode 100644 deps/SPIRV-Cross/reference/shaders/comp/coherent-image.comp create mode 100644 deps/SPIRV-Cross/reference/shaders/comp/loop.noopt.comp create mode 100644 deps/SPIRV-Cross/reference/shaders/comp/read-write-only.comp create mode 100644 deps/SPIRV-Cross/reference/shaders/comp/rmw-opt.comp create mode 100644 deps/SPIRV-Cross/reference/shaders/desktop-only/comp/enhanced-layouts.comp create mode 100644 deps/SPIRV-Cross/reference/shaders/desktop-only/frag/hlsl-uav-block-alias.asm.frag create mode 100644 deps/SPIRV-Cross/reference/shaders/desktop-only/frag/image-query.desktop.frag create mode 100644 deps/SPIRV-Cross/reference/shaders/desktop-only/frag/texture-proj-shadow.desktop.frag create mode 100644 deps/SPIRV-Cross/reference/shaders/desktop-only/geom/basic.desktop.sso.geom create mode 100644 deps/SPIRV-Cross/reference/shaders/desktop-only/geom/viewport-index.desktop.geom create mode 100644 deps/SPIRV-Cross/reference/shaders/desktop-only/tesc/basic.desktop.sso.tesc create mode 100644 deps/SPIRV-Cross/reference/shaders/desktop-only/tese/triangle.desktop.sso.tese create mode 100644 deps/SPIRV-Cross/reference/shaders/desktop-only/vert/basic.desktop.sso.vert create mode 100644 deps/SPIRV-Cross/reference/shaders/desktop-only/vert/clip-cull-distance.desktop.vert create mode 100644 deps/SPIRV-Cross/reference/shaders/flatten/array.flatten.vert create mode 100644 deps/SPIRV-Cross/reference/shaders/flatten/basic.flatten.vert create mode 100644 deps/SPIRV-Cross/reference/shaders/flatten/copy.flatten.vert create mode 100644 deps/SPIRV-Cross/reference/shaders/flatten/dynamic.flatten.vert create mode 100644 deps/SPIRV-Cross/reference/shaders/flatten/matrixindex.flatten.vert create mode 100644 deps/SPIRV-Cross/reference/shaders/flatten/multi-dimensional.desktop.flatten_dim.frag create mode 100644 deps/SPIRV-Cross/reference/shaders/flatten/multiindex.flatten.vert create mode 100644 deps/SPIRV-Cross/reference/shaders/flatten/push-constant.flatten.vert create mode 100644 deps/SPIRV-Cross/reference/shaders/flatten/rowmajor.flatten.vert create mode 100644 deps/SPIRV-Cross/reference/shaders/flatten/struct.flatten.vert create mode 100644 deps/SPIRV-Cross/reference/shaders/flatten/struct.rowmajor.flatten.vert create mode 100644 deps/SPIRV-Cross/reference/shaders/flatten/swizzle.flatten.vert create mode 100644 deps/SPIRV-Cross/reference/shaders/flatten/types.flatten.frag create mode 100644 deps/SPIRV-Cross/reference/shaders/frag/false-loop-init.frag create mode 100644 deps/SPIRV-Cross/reference/shaders/frag/frexp-modf.frag create mode 100644 deps/SPIRV-Cross/reference/shaders/frag/image-load-store-uint-coord.asm.frag create mode 100644 deps/SPIRV-Cross/reference/shaders/frag/partial-write-preserve.frag create mode 100644 deps/SPIRV-Cross/reference/shaders/frag/sample-parameter.frag create mode 100644 deps/SPIRV-Cross/reference/shaders/frag/sampler-proj.frag create mode 100644 deps/SPIRV-Cross/reference/shaders/frag/unary-enclose.frag create mode 100644 deps/SPIRV-Cross/reference/shaders/legacy/fragment/explicit-lod.legacy.frag create mode 100644 deps/SPIRV-Cross/reference/shaders/legacy/fragment/io-blocks.legacy.frag create mode 100644 deps/SPIRV-Cross/reference/shaders/legacy/fragment/struct-varying.legacy.frag create mode 100644 deps/SPIRV-Cross/reference/shaders/legacy/vert/implicit-lod.legacy.vert create mode 100644 deps/SPIRV-Cross/reference/shaders/legacy/vert/io-block.legacy.vert create mode 100644 deps/SPIRV-Cross/reference/shaders/legacy/vert/struct-varying.legacy.vert create mode 100644 deps/SPIRV-Cross/reference/shaders/legacy/vert/transpose.legacy.vert create mode 100644 deps/SPIRV-Cross/reference/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag create mode 100644 deps/SPIRV-Cross/reference/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag.vk create mode 100644 deps/SPIRV-Cross/reference/shaders/vulkan/frag/desktop-mediump.vk.frag create mode 100644 deps/SPIRV-Cross/reference/shaders/vulkan/frag/desktop-mediump.vk.frag.vk create mode 100644 deps/SPIRV-Cross/reference/shaders/vulkan/vert/multiview.nocompat.vk.vert create mode 100644 deps/SPIRV-Cross/reference/shaders/vulkan/vert/multiview.nocompat.vk.vert.vk create mode 100644 deps/SPIRV-Cross/shaders-hlsl/asm/comp/specialization-constant-workgroup.nofxc.asm.comp create mode 100644 deps/SPIRV-Cross/shaders-hlsl/asm/comp/storage-buffer-basic.nofxc.asm.comp create mode 100644 deps/SPIRV-Cross/shaders-hlsl/asm/frag/cbuffer-stripped.asm.frag create mode 100644 deps/SPIRV-Cross/shaders-hlsl/asm/frag/unreachable.asm.frag create mode 100644 deps/SPIRV-Cross/shaders-hlsl/asm/vert/empty-struct-composite.asm.vert create mode 100644 deps/SPIRV-Cross/shaders-hlsl/asm/vert/vertex-id-instance-id.asm.vert create mode 100644 deps/SPIRV-Cross/shaders-hlsl/comp/access-chains.comp create mode 100644 deps/SPIRV-Cross/shaders-hlsl/comp/address-buffers.comp create mode 100644 deps/SPIRV-Cross/shaders-hlsl/comp/atomic.comp create mode 100644 deps/SPIRV-Cross/shaders-hlsl/comp/barriers.comp create mode 100644 deps/SPIRV-Cross/shaders-hlsl/comp/bitfield.noopt.comp create mode 100644 deps/SPIRV-Cross/shaders-hlsl/comp/builtins.comp create mode 100644 deps/SPIRV-Cross/shaders-hlsl/comp/image.comp create mode 100644 deps/SPIRV-Cross/shaders-hlsl/comp/rwbuffer-matrix.comp create mode 100644 deps/SPIRV-Cross/shaders-hlsl/comp/shared.comp create mode 100644 deps/SPIRV-Cross/shaders-hlsl/comp/ssbo-array.comp create mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/basic.frag create mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/bit-conversions.frag create mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/boolean-mix.frag create mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/builtins.frag create mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/bvec-operations.frag create mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/combined-texture-sampler-parameter.frag create mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/combined-texture-sampler-shadow.frag create mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/constant-buffer-array.sm51.frag create mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/early-fragment-test.frag create mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/fp16-packing.frag create mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/image-query-selective.frag create mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/image-query.frag create mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/io-block.frag create mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/matrix-input.frag create mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/mod.frag create mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/mrt.frag create mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/no-return.frag create mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/no-return2.frag create mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/partial-write-preserve.frag create mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/query-lod.desktop.frag create mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/resources.frag create mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/sample-cmp-level-zero.frag create mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/sampler-array.frag create mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/spec-constant.frag create mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/swizzle-scalar.frag create mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/tex-sampling.frag create mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/texture-proj-shadow.frag create mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/unary-enclose.frag create mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/unorm-snorm-packing.frag create mode 100644 deps/SPIRV-Cross/shaders-hlsl/frag/various-glsl-ops.frag create mode 100644 deps/SPIRV-Cross/shaders-hlsl/vert/basic.vert create mode 100644 deps/SPIRV-Cross/shaders-hlsl/vert/instancing.vert create mode 100644 deps/SPIRV-Cross/shaders-hlsl/vert/locations.vert create mode 100644 deps/SPIRV-Cross/shaders-hlsl/vert/matrix-attribute.vert create mode 100644 deps/SPIRV-Cross/shaders-hlsl/vert/matrix-output.vert create mode 100644 deps/SPIRV-Cross/shaders-hlsl/vert/no-input.vert create mode 100644 deps/SPIRV-Cross/shaders-hlsl/vert/point-size-compat.vert create mode 100644 deps/SPIRV-Cross/shaders-hlsl/vert/qualifiers.vert create mode 100644 deps/SPIRV-Cross/shaders-hlsl/vert/sampler-buffers.vert create mode 100644 deps/SPIRV-Cross/shaders-hlsl/vert/struct-composite-decl.vert create mode 100644 deps/SPIRV-Cross/shaders-hlsl/vert/texture_buffer.vert create mode 100644 deps/SPIRV-Cross/shaders-msl-no-opt/vert/functions_nested.vert create mode 100644 deps/SPIRV-Cross/shaders-msl/asm/comp/bitcast_iadd.asm.comp create mode 100644 deps/SPIRV-Cross/shaders-msl/asm/comp/bitcast_sar.asm.comp rename deps/SPIRV-Cross/{shaders/asm/comp/bitcast_udiv.asm.comp => shaders-msl/asm/comp/bitcast_sdiv.asm.comp} (84%) create mode 100644 deps/SPIRV-Cross/shaders-msl/asm/comp/bitcast_slr.asm.comp create mode 100644 deps/SPIRV-Cross/shaders-msl/asm/comp/multiple-entry.asm.comp create mode 100644 deps/SPIRV-Cross/shaders-msl/asm/comp/quantize.asm.comp create mode 100644 deps/SPIRV-Cross/shaders-msl/asm/comp/specialization-constant-workgroup.asm.comp create mode 100644 deps/SPIRV-Cross/shaders-msl/asm/comp/storage-buffer-basic.asm.comp create mode 100644 deps/SPIRV-Cross/shaders-msl/asm/frag/default-member-names.asm.frag create mode 100644 deps/SPIRV-Cross/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag create mode 100644 deps/SPIRV-Cross/shaders-msl/asm/frag/op-constant-null.asm.frag create mode 100644 deps/SPIRV-Cross/shaders-msl/asm/frag/phi-loop-variable.asm.frag create mode 100644 deps/SPIRV-Cross/shaders-msl/asm/frag/undef-variable-store.asm.frag create mode 100644 deps/SPIRV-Cross/shaders-msl/asm/frag/unreachable.asm.frag create mode 100644 deps/SPIRV-Cross/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag create mode 100644 deps/SPIRV-Cross/shaders-msl/asm/vert/empty-struct-composite.asm.vert create mode 100644 deps/SPIRV-Cross/shaders-msl/comp/atomic.comp create mode 100644 deps/SPIRV-Cross/shaders-msl/comp/barriers.comp create mode 100644 deps/SPIRV-Cross/shaders-msl/comp/basic.comp create mode 100644 deps/SPIRV-Cross/shaders-msl/comp/bitfield.noopt.comp create mode 100644 deps/SPIRV-Cross/shaders-msl/comp/builtins.comp create mode 100644 deps/SPIRV-Cross/shaders-msl/comp/cfg-preserve-parameter.comp create mode 100644 deps/SPIRV-Cross/shaders-msl/comp/coherent-block.comp create mode 100644 deps/SPIRV-Cross/shaders-msl/comp/coherent-image.comp create mode 100644 deps/SPIRV-Cross/shaders-msl/comp/culling.comp create mode 100644 deps/SPIRV-Cross/shaders-msl/comp/defer-parens.comp create mode 100644 deps/SPIRV-Cross/shaders-msl/comp/dowhile.comp create mode 100644 deps/SPIRV-Cross/shaders-msl/comp/functions.comp create mode 100644 deps/SPIRV-Cross/shaders-msl/comp/global-invocation-id-writable-ssbo-in-function.comp create mode 100644 deps/SPIRV-Cross/shaders-msl/comp/global-invocation-id.comp create mode 100644 deps/SPIRV-Cross/shaders-msl/comp/image.comp create mode 100644 deps/SPIRV-Cross/shaders-msl/comp/insert.comp create mode 100644 deps/SPIRV-Cross/shaders-msl/comp/local-invocation-id.comp create mode 100644 deps/SPIRV-Cross/shaders-msl/comp/local-invocation-index.comp rename deps/SPIRV-Cross/{shaders/comp/loop.comp => shaders-msl/comp/loop.noopt.comp} (100%) create mode 100644 deps/SPIRV-Cross/shaders-msl/comp/mat3.comp create mode 100644 deps/SPIRV-Cross/shaders-msl/comp/mod.comp create mode 100644 deps/SPIRV-Cross/shaders-msl/comp/modf.comp create mode 100644 deps/SPIRV-Cross/shaders-msl/comp/read-write-only.comp create mode 100644 deps/SPIRV-Cross/shaders-msl/comp/return.comp create mode 100644 deps/SPIRV-Cross/shaders-msl/comp/rmw-opt.comp create mode 100644 deps/SPIRV-Cross/shaders-msl/comp/shared.comp create mode 100644 deps/SPIRV-Cross/shaders-msl/comp/struct-layout.comp create mode 100644 deps/SPIRV-Cross/shaders-msl/comp/struct-packing.comp create mode 100644 deps/SPIRV-Cross/shaders-msl/comp/torture-loop.comp create mode 100644 deps/SPIRV-Cross/shaders-msl/comp/type-alias.comp create mode 100644 deps/SPIRV-Cross/shaders-msl/comp/udiv.comp create mode 100644 deps/SPIRV-Cross/shaders-msl/comp/writable-ssbo.comp create mode 100644 deps/SPIRV-Cross/shaders-msl/desktop-only/frag/image-ms.desktop.frag create mode 100644 deps/SPIRV-Cross/shaders-msl/desktop-only/frag/query-levels.desktop.frag create mode 100644 deps/SPIRV-Cross/shaders-msl/desktop-only/frag/sampler-ms-query.desktop.frag create mode 100644 deps/SPIRV-Cross/shaders-msl/desktop-only/vert/basic.desktop.sso.vert create mode 100644 deps/SPIRV-Cross/shaders-msl/desktop-only/vert/clip-cull-distance.desktop.vert create mode 100644 deps/SPIRV-Cross/shaders-msl/flatten/basic.flatten.vert create mode 100644 deps/SPIRV-Cross/shaders-msl/flatten/multiindex.flatten.vert create mode 100644 deps/SPIRV-Cross/shaders-msl/flatten/push-constant.flatten.vert create mode 100644 deps/SPIRV-Cross/shaders-msl/flatten/rowmajor.flatten.vert create mode 100644 deps/SPIRV-Cross/shaders-msl/flatten/struct.flatten.vert create mode 100644 deps/SPIRV-Cross/shaders-msl/flatten/swizzle.flatten.vert create mode 100644 deps/SPIRV-Cross/shaders-msl/flatten/types.flatten.frag create mode 100644 deps/SPIRV-Cross/shaders-msl/frag/basic.frag create mode 100644 deps/SPIRV-Cross/shaders-msl/frag/bitcasting.frag create mode 100644 deps/SPIRV-Cross/shaders-msl/frag/builtins.frag create mode 100644 deps/SPIRV-Cross/shaders-msl/frag/composite-extract-forced-temporary.frag create mode 100644 deps/SPIRV-Cross/shaders-msl/frag/constant-array.frag create mode 100644 deps/SPIRV-Cross/shaders-msl/frag/false-loop-init.frag create mode 100644 deps/SPIRV-Cross/shaders-msl/frag/flush_params.frag create mode 100644 deps/SPIRV-Cross/shaders-msl/frag/for-loop-init.frag create mode 100644 deps/SPIRV-Cross/shaders-msl/frag/in_block.frag create mode 100644 deps/SPIRV-Cross/shaders-msl/frag/in_block_assign.noopt.frag create mode 100644 deps/SPIRV-Cross/shaders-msl/frag/mix.frag create mode 100644 deps/SPIRV-Cross/shaders-msl/frag/pls.frag create mode 100644 deps/SPIRV-Cross/shaders-msl/frag/sampler-ms.frag create mode 100644 deps/SPIRV-Cross/shaders-msl/frag/sampler.frag create mode 100644 deps/SPIRV-Cross/shaders-msl/frag/separate-image-sampler-argument.frag create mode 100644 deps/SPIRV-Cross/shaders-msl/frag/swizzle.frag create mode 100644 deps/SPIRV-Cross/shaders-msl/frag/texture-proj-shadow.frag create mode 100644 deps/SPIRV-Cross/shaders-msl/frag/ubo_layout.frag create mode 100644 deps/SPIRV-Cross/shaders-msl/frag/unary-enclose.frag create mode 100644 deps/SPIRV-Cross/shaders-msl/legacy/vert/transpose.legacy.vert create mode 100644 deps/SPIRV-Cross/shaders-msl/vert/basic.vert create mode 100644 deps/SPIRV-Cross/shaders-msl/vert/copy.flatten.vert create mode 100644 deps/SPIRV-Cross/shaders-msl/vert/dynamic.flatten.vert create mode 100644 deps/SPIRV-Cross/shaders-msl/vert/functions.vert create mode 100644 deps/SPIRV-Cross/shaders-msl/vert/out_block.vert create mode 100644 deps/SPIRV-Cross/shaders-msl/vert/pointsize.vert create mode 100644 deps/SPIRV-Cross/shaders-msl/vert/texture_buffer.vert create mode 100644 deps/SPIRV-Cross/shaders-msl/vert/ubo.alignment.vert create mode 100644 deps/SPIRV-Cross/shaders-msl/vert/ubo.vert create mode 100644 deps/SPIRV-Cross/shaders-msl/vulkan/frag/push-constant.vk.frag create mode 100644 deps/SPIRV-Cross/shaders-msl/vulkan/frag/spec-constant.vk.frag create mode 100644 deps/SPIRV-Cross/shaders-msl/vulkan/vert/vulkan-vertex.vk.vert create mode 100644 deps/SPIRV-Cross/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag create mode 100644 deps/SPIRV-Cross/shaders/amd/fs.invalid.frag create mode 100644 deps/SPIRV-Cross/shaders/amd/gcn_shader.comp create mode 100644 deps/SPIRV-Cross/shaders/amd/shader_ballot.comp create mode 100644 deps/SPIRV-Cross/shaders/amd/shader_ballot_nonuniform_invocations.invalid.comp create mode 100644 deps/SPIRV-Cross/shaders/amd/shader_group_vote.comp create mode 100644 deps/SPIRV-Cross/shaders/amd/shader_trinary_minmax.comp create mode 100644 deps/SPIRV-Cross/shaders/asm/comp/logical.asm.comp create mode 100644 deps/SPIRV-Cross/shaders/asm/comp/specialization-constant-workgroup.asm.comp create mode 100644 deps/SPIRV-Cross/shaders/asm/comp/storage-buffer-basic.asm.comp create mode 100644 deps/SPIRV-Cross/shaders/asm/frag/composite-construct-struct-no-swizzle.asm.frag create mode 100644 deps/SPIRV-Cross/shaders/asm/frag/default-member-names.asm.frag create mode 100644 deps/SPIRV-Cross/shaders/asm/frag/hlsl-sample-cmp-level-zero-cube.asm.frag create mode 100644 deps/SPIRV-Cross/shaders/asm/frag/hlsl-sample-cmp-level-zero.asm.frag create mode 100644 deps/SPIRV-Cross/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag create mode 100644 deps/SPIRV-Cross/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag create mode 100644 deps/SPIRV-Cross/shaders/asm/frag/multi-for-loop-init.asm.frag create mode 100644 deps/SPIRV-Cross/shaders/asm/frag/op-constant-null.asm.frag create mode 100644 deps/SPIRV-Cross/shaders/asm/frag/phi-loop-variable.asm.frag create mode 100644 deps/SPIRV-Cross/shaders/asm/frag/sampler-buffer-without-sampler.asm.frag create mode 100644 deps/SPIRV-Cross/shaders/asm/frag/struct-composite-extract-swizzle.asm.frag create mode 100644 deps/SPIRV-Cross/shaders/asm/frag/temporary-phi-hoisting.asm.frag create mode 100644 deps/SPIRV-Cross/shaders/asm/frag/undef-variable-store.asm.frag create mode 100644 deps/SPIRV-Cross/shaders/asm/frag/unreachable.asm.frag create mode 100644 deps/SPIRV-Cross/shaders/asm/frag/vector-shuffle-oom.asm.frag create mode 100644 deps/SPIRV-Cross/shaders/asm/tesc/tess-fixed-input-array-builtin-array.asm.tesc create mode 100644 deps/SPIRV-Cross/shaders/asm/vert/empty-io.asm.vert create mode 100644 deps/SPIRV-Cross/shaders/asm/vert/empty-struct-composite.asm.vert create mode 100644 deps/SPIRV-Cross/shaders/asm/vert/global-builtin.sso.asm.vert create mode 100644 deps/SPIRV-Cross/shaders/comp/barriers.comp create mode 100644 deps/SPIRV-Cross/shaders/comp/bitfield.noopt.comp create mode 100644 deps/SPIRV-Cross/shaders/comp/cfg-preserve-parameter.comp create mode 100644 deps/SPIRV-Cross/shaders/comp/coherent-block.comp create mode 100644 deps/SPIRV-Cross/shaders/comp/coherent-image.comp create mode 100644 deps/SPIRV-Cross/shaders/comp/loop.noopt.comp create mode 100644 deps/SPIRV-Cross/shaders/comp/read-write-only.comp create mode 100644 deps/SPIRV-Cross/shaders/comp/rmw-opt.comp create mode 100644 deps/SPIRV-Cross/shaders/desktop-only/comp/enhanced-layouts.comp create mode 100644 deps/SPIRV-Cross/shaders/desktop-only/frag/hlsl-uav-block-alias.asm.frag create mode 100644 deps/SPIRV-Cross/shaders/desktop-only/frag/image-query.desktop.frag create mode 100644 deps/SPIRV-Cross/shaders/desktop-only/frag/texture-proj-shadow.desktop.frag create mode 100644 deps/SPIRV-Cross/shaders/desktop-only/geom/basic.desktop.sso.geom create mode 100644 deps/SPIRV-Cross/shaders/desktop-only/geom/viewport-index.desktop.geom create mode 100644 deps/SPIRV-Cross/shaders/desktop-only/tesc/basic.desktop.sso.tesc create mode 100644 deps/SPIRV-Cross/shaders/desktop-only/tese/triangle.desktop.sso.tese create mode 100644 deps/SPIRV-Cross/shaders/desktop-only/vert/basic.desktop.sso.vert create mode 100644 deps/SPIRV-Cross/shaders/desktop-only/vert/clip-cull-distance.desktop.vert create mode 100644 deps/SPIRV-Cross/shaders/flatten/array.flatten.vert create mode 100644 deps/SPIRV-Cross/shaders/flatten/basic.flatten.vert create mode 100644 deps/SPIRV-Cross/shaders/flatten/copy.flatten.vert create mode 100644 deps/SPIRV-Cross/shaders/flatten/dynamic.flatten.vert create mode 100644 deps/SPIRV-Cross/shaders/flatten/matrixindex.flatten.vert create mode 100644 deps/SPIRV-Cross/shaders/flatten/multi-dimensional.desktop.flatten_dim.frag create mode 100644 deps/SPIRV-Cross/shaders/flatten/multiindex.flatten.vert create mode 100644 deps/SPIRV-Cross/shaders/flatten/push-constant.flatten.vert create mode 100644 deps/SPIRV-Cross/shaders/flatten/rowmajor.flatten.vert create mode 100644 deps/SPIRV-Cross/shaders/flatten/struct.flatten.vert create mode 100644 deps/SPIRV-Cross/shaders/flatten/struct.rowmajor.flatten.vert create mode 100644 deps/SPIRV-Cross/shaders/flatten/swizzle.flatten.vert create mode 100644 deps/SPIRV-Cross/shaders/flatten/types.flatten.frag create mode 100644 deps/SPIRV-Cross/shaders/frag/false-loop-init.frag create mode 100644 deps/SPIRV-Cross/shaders/frag/frexp-modf.frag create mode 100644 deps/SPIRV-Cross/shaders/frag/image-load-store-uint-coord.asm.frag create mode 100644 deps/SPIRV-Cross/shaders/frag/partial-write-preserve.frag create mode 100644 deps/SPIRV-Cross/shaders/frag/sample-parameter.frag create mode 100644 deps/SPIRV-Cross/shaders/frag/sampler-proj.frag create mode 100644 deps/SPIRV-Cross/shaders/frag/unary-enclose.frag create mode 100644 deps/SPIRV-Cross/shaders/legacy/fragment/explicit-lod.legacy.frag create mode 100644 deps/SPIRV-Cross/shaders/legacy/fragment/io-blocks.legacy.frag create mode 100644 deps/SPIRV-Cross/shaders/legacy/fragment/struct-varying.legacy.frag create mode 100644 deps/SPIRV-Cross/shaders/legacy/vert/implicit-lod.legacy.vert create mode 100644 deps/SPIRV-Cross/shaders/legacy/vert/io-block.legacy.vert create mode 100644 deps/SPIRV-Cross/shaders/legacy/vert/struct-varying.legacy.vert create mode 100644 deps/SPIRV-Cross/shaders/legacy/vert/transpose.legacy.vert create mode 100644 deps/SPIRV-Cross/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag create mode 100644 deps/SPIRV-Cross/shaders/vulkan/frag/desktop-mediump.vk.frag create mode 100644 deps/SPIRV-Cross/shaders/vulkan/vert/multiview.nocompat.vk.vert create mode 100644 deps/SPIRV-Cross/spirv_hlsl.cpp create mode 100644 deps/SPIRV-Cross/spirv_hlsl.hpp create mode 100644 deps/SPIRV-Cross/test_shaders.sh create mode 100644 deps/SPIRV-Cross/update_test_shaders.sh diff --git a/deps/SPIRV-Cross/.gitignore b/deps/SPIRV-Cross/.gitignore index bdd308add4..b89f729741 100644 --- a/deps/SPIRV-Cross/.gitignore +++ b/deps/SPIRV-Cross/.gitignore @@ -13,5 +13,7 @@ *.opensdf *.shader *.a +*.bc +/external !CMakeLists.txt diff --git a/deps/SPIRV-Cross/.travis.yml b/deps/SPIRV-Cross/.travis.yml index 593d472b8e..21af2a0203 100644 --- a/deps/SPIRV-Cross/.travis.yml +++ b/deps/SPIRV-Cross/.travis.yml @@ -2,25 +2,32 @@ 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 at a specific revision to avoid test output mismatches +# We check out glslang and SPIRV-Tools at specific revisions to avoid test output mismatches env: - - GLSLANG_REV=b56f4ac72c57f5c50f14ddb0bf1f78eaaef21c2b + - GLSLANG_REV=9c6f8cc29ba303b43ccf36deea6bb38a304f9b92 SPIRV_TOOLS_REV=e28edd458b729da7bbfd51e375feb33103709e6f before_script: - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install python3; fi + - 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 index ad852f8e40..cd3f677475 100644 --- a/deps/SPIRV-Cross/CMakeLists.txt +++ b/deps/SPIRV-Cross/CMakeLists.txt @@ -24,34 +24,6 @@ if(${CMAKE_GENERATOR} MATCHES "Makefile") endif() endif() -add_library(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) - -add_library(spirv-cross-glsl STATIC - ${CMAKE_CURRENT_SOURCE_DIR}/spirv_glsl.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/spirv_glsl.hpp) - -add_library(spirv-cross-cpp STATIC - ${CMAKE_CURRENT_SOURCE_DIR}/spirv_cpp.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/spirv_cpp.cpp) - -add_library(spirv-cross-msl STATIC - ${CMAKE_CURRENT_SOURCE_DIR}/spirv_msl.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/spirv_msl.cpp) - -add_executable(spirv-cross main.cpp) -target_link_libraries(spirv-cross spirv-cross-glsl 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-cpp spirv-cross-glsl) -target_include_directories(spirv-cross-core PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) - set(spirv-compiler-options "") set(spirv-compiler-defines "") @@ -71,27 +43,102 @@ if (NOT "${MSVC}") endif() endif() -target_compile_options(spirv-cross-core PRIVATE ${spirv-compiler-options}) -target_compile_options(spirv-cross-glsl PRIVATE ${spirv-compiler-options}) -target_compile_options(spirv-cross-msl PRIVATE ${spirv-compiler-options}) -target_compile_options(spirv-cross-cpp PRIVATE ${spirv-compiler-options}) +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-core PRIVATE ${spirv-compiler-defines}) -target_compile_definitions(spirv-cross-glsl PRIVATE ${spirv-compiler-defines}) -target_compile_definitions(spirv-cross-msl PRIVATE ${spirv-compiler-defines}) -target_compile_definitions(spirv-cross-cpp PRIVATE ${spirv-compiler-defines}) 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} AND ${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) +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") diff --git a/deps/SPIRV-Cross/GLSL.std.450.h b/deps/SPIRV-Cross/GLSL.std.450.h index 943fd8650f..54cc00e9a8 100644 --- a/deps/SPIRV-Cross/GLSL.std.450.h +++ b/deps/SPIRV-Cross/GLSL.std.450.h @@ -13,7 +13,7 @@ ** ** 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/ +** 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, diff --git a/deps/SPIRV-Cross/README.md b/deps/SPIRV-Cross/README.md index 415f9523d0..e1409a4bf7 100644 --- a/deps/SPIRV-Cross/README.md +++ b/deps/SPIRV-Cross/README.md @@ -8,6 +8,7 @@ SPIRV-Cross is a tool designed for parsing and converting SPIR-V to other shader - 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 @@ -121,9 +122,15 @@ Please see `samples/cpp` where some GLSL shaders are compiled to SPIR-V, decompi Reading through the samples should explain how to use the C++ interface. A simple Makefile is included to build all shaders in the directory. -### Using SPIRV-Cross to output GLSL shaders from glslang HLSL +### Implementation notes -#### Entry point +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. @@ -135,7 +142,73 @@ 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. ``` -#### Separate image samplers +##### 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. @@ -154,7 +227,33 @@ for (auto &remap : compiler->get_combined_image_samplers()) ``` If your target is Vulkan GLSL, `--vulkan-semantics` will emit separate image samplers as you'd expect. -The command line client does this automatically, but if you're calling the library, you'll need to do this yourself. +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 @@ -165,12 +264,38 @@ Contributions to SPIRV-Cross are welcome. See Testing and Licensing sections for 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`. -However, when improving SPIRV-Cross there are of course legitimate cases where reference output should change. -In these cases, run `./test_shaders.py shaders --update` to update the reference files and include these changes as part of the pull request. -Always make sure you are running up to date glslangValidator as well as SPIRV-Tools when updating reference files. +All pull requests should ensure that test output does not change unexpectedly. This can be tested with: -In short, the master branch should always be able to run `./test_shaders.py shaders` without failure. +``` +./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. @@ -205,6 +330,14 @@ The current reference output is contained in reference/. 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. diff --git a/deps/SPIRV-Cross/checkout_glslang_spirv_tools.sh b/deps/SPIRV-Cross/checkout_glslang_spirv_tools.sh new file mode 100644 index 0000000000..a4674c14e1 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/include/spirv_cross/barrier.hpp b/deps/SPIRV-Cross/include/spirv_cross/barrier.hpp index db7cd87e83..bfcd228431 100644 --- a/deps/SPIRV-Cross/include/spirv_cross/barrier.hpp +++ b/deps/SPIRV-Cross/include/spirv_cross/barrier.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 ARM Limited + * 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. diff --git a/deps/SPIRV-Cross/include/spirv_cross/external_interface.h b/deps/SPIRV-Cross/include/spirv_cross/external_interface.h index 3e7b1f8ba2..1d26f1e1e4 100644 --- a/deps/SPIRV-Cross/include/spirv_cross/external_interface.h +++ b/deps/SPIRV-Cross/include/spirv_cross/external_interface.h @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 ARM Limited + * 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. diff --git a/deps/SPIRV-Cross/include/spirv_cross/image.hpp b/deps/SPIRV-Cross/include/spirv_cross/image.hpp index 927c426ea7..73de894f88 100644 --- a/deps/SPIRV-Cross/include/spirv_cross/image.hpp +++ b/deps/SPIRV-Cross/include/spirv_cross/image.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 ARM Limited + * 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. @@ -33,7 +33,7 @@ template struct image2DBase { virtual ~image2DBase() = default; - inline virtual T load(glm::ivec2 coord) + inline virtual T load(glm::ivec2 coord) const { return T(0, 0, 0, 1); } diff --git a/deps/SPIRV-Cross/include/spirv_cross/internal_interface.hpp b/deps/SPIRV-Cross/include/spirv_cross/internal_interface.hpp index 6d1d636a51..e56223dfdb 100644 --- a/deps/SPIRV-Cross/include/spirv_cross/internal_interface.hpp +++ b/deps/SPIRV-Cross/include/spirv_cross/internal_interface.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 ARM Limited + * 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. @@ -19,8 +19,8 @@ // This file must only be included by the shader generated by spirv-cross! -#ifndef GLM_SWIZZLE -#define GLM_SWIZZLE +#ifndef GLM_FORCE_SWIZZLE +#define GLM_FORCE_SWIZZLE #endif #ifndef GLM_FORCE_RADIANS diff --git a/deps/SPIRV-Cross/include/spirv_cross/sampler.hpp b/deps/SPIRV-Cross/include/spirv_cross/sampler.hpp index e38e569aab..a95d489e2d 100644 --- a/deps/SPIRV-Cross/include/spirv_cross/sampler.hpp +++ b/deps/SPIRV-Cross/include/spirv_cross/sampler.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 ARM Limited + * 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. diff --git a/deps/SPIRV-Cross/include/spirv_cross/thread_group.hpp b/deps/SPIRV-Cross/include/spirv_cross/thread_group.hpp index 7aab9595fc..377f098b4f 100644 --- a/deps/SPIRV-Cross/include/spirv_cross/thread_group.hpp +++ b/deps/SPIRV-Cross/include/spirv_cross/thread_group.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 ARM Limited + * 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. diff --git a/deps/SPIRV-Cross/main.cpp b/deps/SPIRV-Cross/main.cpp index 840b0f2641..49fc8653b3 100644 --- a/deps/SPIRV-Cross/main.cpp +++ b/deps/SPIRV-Cross/main.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 ARM Limited + * 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. @@ -15,6 +15,8 @@ */ #include "spirv_cpp.hpp" +#include "spirv_glsl.hpp" +#include "spirv_hlsl.hpp" #include "spirv_msl.hpp" #include #include @@ -26,19 +28,23 @@ #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 -#define THROW(x) \ - do \ - { \ - fprintf(stderr, "%s.", x); \ - exit(1); \ - } while (0) +static inline void THROW(const char *str) +{ + fprintf(stderr, "SPIRV-Cross will abort: %s\n", str); + fflush(stderr); + abort(); +} #else -#define THROW(x) runtime_error(x) +#define THROW(x) throw runtime_error(x) #endif struct CLIParser; @@ -187,7 +193,7 @@ static bool write_string_to_file(const char *path, const char *string) FILE *file = fopen(path, "w"); if (!file) { - fprintf(file, "Failed to write file: %s\n", path); + fprintf(stderr, "Failed to write file: %s\n", path); return false; } @@ -200,11 +206,16 @@ static void print_resources(const Compiler &compiler, const char *tag, const vec { 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. @@ -217,7 +228,7 @@ static void print_resources(const Compiler &compiler, const char *tag, const vec uint32_t block_size = 0; if (is_sized_block) - block_size = compiler.get_declared_struct_size(compiler.get_type(res.base_type_id)); + block_size = uint32_t(compiler.get_declared_struct_size(compiler.get_type(res.base_type_id))); string array; for (auto arr : type.array) @@ -234,8 +245,16 @@ static void print_resources(const Compiler &compiler, const char *tag, const vec 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"); @@ -380,6 +399,21 @@ static void print_spec_constants(const Compiler &compiler) 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; @@ -399,43 +433,71 @@ struct VariableTypeRemap 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 metal = 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; - bool cfg_analysis = true; }; static void print_help() { - fprintf(stderr, "Usage: spirv-cross [--output ] [SPIR-V file] [--es] [--no-es] [--no-cfg-analysis] " - "[--version ] [--dump-resources] [--help] [--force-temporary] [--cpp] [--cpp-interface-name ] " - "[--metal] [--vulkan-semantics] [--flatten-ubo] [--fixup-clipspace] [--iterations iter] [--pls-in " - "format input-name] [--pls-out format output-name] [--remap source_name target_name components] " - "[--extension ext] [--entry name] [--remove-unused-variables] " - "[--remap-variable-type ]\n"); + 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) @@ -522,7 +584,34 @@ static PlsFormat pls_format(const char *str) return PlsNone; } -int main(int argc, char *argv[]) +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; @@ -544,18 +633,36 @@ int main(int argc, char *argv[]) args.version = parser.next_uint(); args.set_version = true; }); - cbs.add("--no-cfg-analysis", [&args](CLIParser &) { args.cfg_analysis = false; }); 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.metal = true; }); + 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(); @@ -569,6 +676,19 @@ int main(int argc, char *argv[]) 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(); @@ -579,6 +699,14 @@ int main(int argc, char *argv[]) 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; }); @@ -612,8 +740,18 @@ int main(int argc, char *argv[]) if (args.cpp_interface_name) static_cast(compiler.get())->set_interface_name(args.cpp_interface_name); } - else if (args.metal) + 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; @@ -631,6 +769,9 @@ int main(int argc, char *argv[]) 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); @@ -647,11 +788,38 @@ int main(int argc, char *argv[]) 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.cfg_analysis = args.cfg_analysis; + 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) { @@ -663,8 +831,12 @@ int main(int argc, char *argv[]) res = compiler->get_shader_resources(); if (args.flatten_ubo) + { for (auto &ubo : res.uniform_buffers) - compiler->flatten_interface_block(ubo.id); + 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); @@ -683,11 +855,25 @@ int main(int argc, char *argv[]) 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) @@ -703,10 +889,35 @@ int main(int argc, char *argv[]) string glsl; for (uint32_t i = 0; i < args.iterations; i++) - glsl = compiler->compile(); + { + 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.vcxproj b/deps/SPIRV-Cross/msvc/SPIRV-Cross.vcxproj index 6d029efc86..8c57633e94 100644 --- a/deps/SPIRV-Cross/msvc/SPIRV-Cross.vcxproj +++ b/deps/SPIRV-Cross/msvc/SPIRV-Cross.vcxproj @@ -127,6 +127,7 @@ + @@ -137,6 +138,7 @@ + diff --git a/deps/SPIRV-Cross/msvc/SPIRV-Cross.vcxproj.filters b/deps/SPIRV-Cross/msvc/SPIRV-Cross.vcxproj.filters index a0afa7e525..c9edf4608b 100644 --- a/deps/SPIRV-Cross/msvc/SPIRV-Cross.vcxproj.filters +++ b/deps/SPIRV-Cross/msvc/SPIRV-Cross.vcxproj.filters @@ -33,6 +33,9 @@ Source Files + + Source Files + @@ -59,5 +62,8 @@ 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 new file mode 100644 index 0000000000..8243347bf6 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..1bdb27d7fa --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..25eee2d954 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..e7cb790205 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..103ff46a3f --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..8d5e771fe4 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/access-chains.comp b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/access-chains.comp new file mode 100644 index 0000000000..924e919124 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/address-buffers.comp b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/address-buffers.comp new file mode 100644 index 0000000000..a252fc8ae3 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/atomic.comp b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/atomic.comp new file mode 100644 index 0000000000..72e15bf77d --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/barriers.comp b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/barriers.comp new file mode 100644 index 0000000000..7ac2a656f0 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/bitfield.noopt.comp b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/bitfield.noopt.comp new file mode 100644 index 0000000000..6839d9569e --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/builtins.comp b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/builtins.comp new file mode 100644 index 0000000000..990fc85337 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/image.comp b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/image.comp new file mode 100644 index 0000000000..a8fc137581 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/rwbuffer-matrix.comp b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/rwbuffer-matrix.comp new file mode 100644 index 0000000000..c05f8ffbf8 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/shared.comp b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/shared.comp new file mode 100644 index 0000000000..498241eaca --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/ssbo-array.comp b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/ssbo-array.comp new file mode 100644 index 0000000000..d8bce8d54b --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/basic.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/basic.frag new file mode 100644 index 0000000000..6d067041c2 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/bit-conversions.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/bit-conversions.frag new file mode 100644 index 0000000000..b60b2ebb4a --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/boolean-mix.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/boolean-mix.frag new file mode 100644 index 0000000000..f3e84898d6 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/builtins.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/builtins.frag new file mode 100644 index 0000000000..922eca7c2d --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/bvec-operations.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/bvec-operations.frag new file mode 100644 index 0000000000..886e71180e --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..18968cb193 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..6e8f833b34 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..7e613da1cf --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..ae2569d5cf --- /dev/null +++ b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/early-fragment-test.frag @@ -0,0 +1,9 @@ +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 new file mode 100644 index 0000000000..d87828225f --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..c73b742b5a --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/image-query.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/image-query.frag new file mode 100644 index 0000000000..3b50282fe0 --- /dev/null +++ b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/image-query.frag @@ -0,0 +1,8 @@ +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 new file mode 100644 index 0000000000..52c1f518bf --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/matrix-input.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/matrix-input.frag new file mode 100644 index 0000000000..92d87d396e --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/mod.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/mod.frag new file mode 100644 index 0000000000..41ac930496 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/mrt.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/mrt.frag new file mode 100644 index 0000000000..e69e91196a --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/no-return.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/no-return.frag new file mode 100644 index 0000000000..3b50282fe0 --- /dev/null +++ b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/no-return.frag @@ -0,0 +1,8 @@ +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 new file mode 100644 index 0000000000..e9d7bbc8f9 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..20da99c336 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..fd95798bf4 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/resources.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/resources.frag new file mode 100644 index 0000000000..24b93c239c --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..6f5ae7e38c --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/sampler-array.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/sampler-array.frag new file mode 100644 index 0000000000..5b8e492de6 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/spec-constant.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/spec-constant.frag new file mode 100644 index 0000000000..781e3f20b8 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/swizzle-scalar.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/swizzle-scalar.frag new file mode 100644 index 0000000000..ab310b82f2 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/tex-sampling.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/tex-sampling.frag new file mode 100644 index 0000000000..6ebca5d8d1 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..4beaa11761 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/unary-enclose.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/unary-enclose.frag new file mode 100644 index 0000000000..76e98a66d0 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..57b5950636 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..0bc2fc1a96 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/basic.vert b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/basic.vert new file mode 100644 index 0000000000..5f0a5f3d1a --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/instancing.vert b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/instancing.vert new file mode 100644 index 0000000000..48b2df20d3 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/locations.vert b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/locations.vert new file mode 100644 index 0000000000..ba36c4ae39 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/matrix-attribute.vert b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/matrix-attribute.vert new file mode 100644 index 0000000000..a3d0eef56e --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/matrix-output.vert b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/matrix-output.vert new file mode 100644 index 0000000000..dc776cb5ec --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/no-input.vert b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/no-input.vert new file mode 100644 index 0000000000..c98544dbe8 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..83333d0be2 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/qualifiers.vert b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/qualifiers.vert new file mode 100644 index 0000000000..13ee2a8c1c --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/sampler-buffers.vert b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/sampler-buffers.vert new file mode 100644 index 0000000000..3652185443 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..76bd349775 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/texture_buffer.vert b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/vert/texture_buffer.vert new file mode 100644 index 0000000000..1c92f6fe65 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..47ce85f8fc --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..20d6fe9e9d --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..f18b318bbb --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..9fd60bef26 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..7652733268 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..1839ec7a3b --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..5802ddac90 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..1dff618b3a --- /dev/null +++ b/deps/SPIRV-Cross/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(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 new file mode 100644 index 0000000000..1c730c7bbc --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..98a1674865 --- /dev/null +++ b/deps/SPIRV-Cross/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]], 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 new file mode 100644 index 0000000000..9472add395 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..036774d661 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..fb39c46fbb --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..3e80051e6b --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..17cd528d41 --- /dev/null +++ b/deps/SPIRV-Cross/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(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 new file mode 100644 index 0000000000..9e024c2095 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/atomic.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/atomic.comp new file mode 100644 index 0000000000..90a39ec643 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/bake_gradient.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/bake_gradient.comp new file mode 100644 index 0000000000..fe7ac2b7d4 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/barriers.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/barriers.comp new file mode 100644 index 0000000000..23a19914c2 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/basic.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/basic.comp new file mode 100644 index 0000000000..363c207186 --- /dev/null +++ b/deps/SPIRV-Cross/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(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 new file mode 100644 index 0000000000..62ef02c997 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/builtins.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/builtins.comp new file mode 100644 index 0000000000..8278220225 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..59fc03a752 --- /dev/null +++ b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/cfg-preserve-parameter.comp @@ -0,0 +1,9 @@ +#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 new file mode 100644 index 0000000000..bec9b218c7 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/coherent-image.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/coherent-image.comp new file mode 100644 index 0000000000..0fe044fb9a --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/culling.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/culling.comp new file mode 100644 index 0000000000..64127d2c26 --- /dev/null +++ b/deps/SPIRV-Cross/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(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 new file mode 100644 index 0000000000..b9a742a13c --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/dowhile.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/dowhile.comp new file mode 100644 index 0000000000..fca434d9a4 --- /dev/null +++ b/deps/SPIRV-Cross/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(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 new file mode 100644 index 0000000000..35ee32d220 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..fe0212ec3f --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..fe0212ec3f --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/image.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/image.comp new file mode 100644 index 0000000000..edccd31bc9 --- /dev/null +++ b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/image.comp @@ -0,0 +1,10 @@ +#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 new file mode 100644 index 0000000000..1418ce35b5 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..772e5e0d86 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..41adbdca5c --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/loop.noopt.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/loop.noopt.comp new file mode 100644 index 0000000000..55d850d191 --- /dev/null +++ b/deps/SPIRV-Cross/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(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 new file mode 100644 index 0000000000..e466d25f97 --- /dev/null +++ b/deps/SPIRV-Cross/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(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 new file mode 100644 index 0000000000..01dc6726ed --- /dev/null +++ b/deps/SPIRV-Cross/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(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 new file mode 100644 index 0000000000..3a4cfd6975 --- /dev/null +++ b/deps/SPIRV-Cross/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(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 new file mode 100644 index 0000000000..ba53b334ba --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/return.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/return.comp new file mode 100644 index 0000000000..eaa25c5c7b --- /dev/null +++ b/deps/SPIRV-Cross/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(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 new file mode 100644 index 0000000000..4bbd8b3c71 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/shared.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/shared.comp new file mode 100644 index 0000000000..7408e3ecb1 --- /dev/null +++ b/deps/SPIRV-Cross/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(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 new file mode 100644 index 0000000000..28e81e7361 --- /dev/null +++ b/deps/SPIRV-Cross/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(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 new file mode 100644 index 0000000000..cf626ce63f --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/torture-loop.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/torture-loop.comp new file mode 100644 index 0000000000..47acff93b0 --- /dev/null +++ b/deps/SPIRV-Cross/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(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 new file mode 100644 index 0000000000..167d4370c0 --- /dev/null +++ b/deps/SPIRV-Cross/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)]], 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 new file mode 100644 index 0000000000..ed82369b99 --- /dev/null +++ b/deps/SPIRV-Cross/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)]], 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 new file mode 100644 index 0000000000..9dc53b6dd5 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..4083e4ea16 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..922796b749 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..4d2eee11c5 --- /dev/null +++ b/deps/SPIRV-Cross/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)]], 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 new file mode 100644 index 0000000000..1592b5c5cf --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..32f0d9aa0d --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/basic.flatten.vert b/deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/basic.flatten.vert new file mode 100644 index 0000000000..1592b5c5cf --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/multiindex.flatten.vert b/deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/multiindex.flatten.vert new file mode 100644 index 0000000000..84c4b408b2 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..83def9c0bb --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/rowmajor.flatten.vert b/deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/rowmajor.flatten.vert new file mode 100644 index 0000000000..3e0fcdbb75 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/struct.flatten.vert b/deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/struct.flatten.vert new file mode 100644 index 0000000000..594d29fe57 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/swizzle.flatten.vert b/deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/swizzle.flatten.vert new file mode 100644 index 0000000000..53fc21f99e --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/types.flatten.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/flatten/types.flatten.frag new file mode 100644 index 0000000000..cee53d9e58 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/basic.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/basic.frag new file mode 100644 index 0000000000..4d33ee7bca --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/bitcasting.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/bitcasting.frag new file mode 100644 index 0000000000..8a7f750f90 --- /dev/null +++ b/deps/SPIRV-Cross/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)]], 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 new file mode 100644 index 0000000000..9283d1a66b --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..5539c2508f --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/constant-array.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/constant-array.frag new file mode 100644 index 0000000000..7a9a0dea1c --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..c67bb9d396 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/flush_params.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/flush_params.frag new file mode 100644 index 0000000000..059167fd4b --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..0e5c92c7e5 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/in_block.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/in_block.frag new file mode 100644 index 0000000000..43b4a05897 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..d06863d99c --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/mix.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/mix.frag new file mode 100644 index 0000000000..9c9b8398cf --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/pls.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/pls.frag new file mode 100644 index 0000000000..42b5d2bf59 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/sampler-ms.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/sampler-ms.frag new file mode 100644 index 0000000000..5fcb3bcbfb --- /dev/null +++ b/deps/SPIRV-Cross/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(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 new file mode 100644 index 0000000000..4d33ee7bca --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..e576b49e7e --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/swizzle.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/swizzle.frag new file mode 100644 index 0000000000..eb46111f00 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..c31e6d9623 --- /dev/null +++ b/deps/SPIRV-Cross/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)]], 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 new file mode 100644 index 0000000000..8c03e33b39 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/unary-enclose.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/unary-enclose.frag new file mode 100644 index 0000000000..7437f1dfe8 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..b28067e589 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/basic.vert b/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/basic.vert new file mode 100644 index 0000000000..1592b5c5cf --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/copy.flatten.vert b/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/copy.flatten.vert new file mode 100644 index 0000000000..dc87c849dc --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/dynamic.flatten.vert b/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/dynamic.flatten.vert new file mode 100644 index 0000000000..eb38ab4fd1 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/functions.vert b/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/functions.vert new file mode 100644 index 0000000000..8ec2484c3e --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/out_block.vert b/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/out_block.vert new file mode 100644 index 0000000000..3ae18387a6 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/pointsize.vert b/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/pointsize.vert new file mode 100644 index 0000000000..faf828b4d3 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/texture_buffer.vert b/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/texture_buffer.vert new file mode 100644 index 0000000000..690757b830 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/ubo.alignment.vert b/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/ubo.alignment.vert new file mode 100644 index 0000000000..6e48ae0e42 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/ubo.vert b/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/ubo.vert new file mode 100644 index 0000000000..4a1adcd7f6 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..bc97e3cc51 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..aee290f5a2 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..53e26e4a8e --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..d670898481 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..4aaf397a0f --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/amd/fs.invalid.frag b/deps/SPIRV-Cross/reference/opt/shaders/amd/fs.invalid.frag new file mode 100644 index 0000000000..97e7bcd180 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/amd/gcn_shader.comp b/deps/SPIRV-Cross/reference/opt/shaders/amd/gcn_shader.comp new file mode 100644 index 0000000000..85851de5f9 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/amd/shader_ballot.comp b/deps/SPIRV-Cross/reference/opt/shaders/amd/shader_ballot.comp new file mode 100644 index 0000000000..8bdbfc9c0d --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..a14343ae12 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/amd/shader_group_vote.comp b/deps/SPIRV-Cross/reference/opt/shaders/amd/shader_group_vote.comp new file mode 100644 index 0000000000..77ea03495f --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/amd/shader_trinary_minmax.comp b/deps/SPIRV-Cross/reference/opt/shaders/amd/shader_trinary_minmax.comp new file mode 100644 index 0000000000..77ea03495f --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..bed2dffccb --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..79398b404b --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..42a4ed0233 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..eeb97e14a2 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..25245e63eb --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/logical.asm.comp b/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/logical.asm.comp new file mode 100644 index 0000000000..124652b322 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..6418464f19 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..870b1df98d --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/quantize.asm.comp b/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/quantize.asm.comp new file mode 100644 index 0000000000..c089213800 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..1b2285a8da --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..3de823fb10 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..23af17026c --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..2cf68fd201 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..924b6f656c --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..c4e3704e52 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..98116cfdc7 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/invalidation.asm.frag b/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/invalidation.asm.frag new file mode 100644 index 0000000000..c0dc7b682b --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..4fb4b75740 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..c41c77c701 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..cb882cd7b1 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..786ac74de5 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..560a4e79b9 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..b2473f4d03 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..3917594d98 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..23576ed850 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/unreachable.asm.frag b/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/unreachable.asm.frag new file mode 100644 index 0000000000..d8126d752e --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..1c211caa6d --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..dc43d91a9b --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..5286269337 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..05ce10adfa --- /dev/null +++ b/deps/SPIRV-Cross/reference/opt/shaders/asm/vert/empty-struct-composite.asm.vert @@ -0,0 +1,6 @@ +#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 new file mode 100644 index 0000000000..2fc44c526e --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/comp/atomic.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/atomic.comp new file mode 100644 index 0000000000..89b1351c0c --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/comp/bake_gradient.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/bake_gradient.comp new file mode 100644 index 0000000000..0af4833926 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/comp/barriers.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/barriers.comp new file mode 100644 index 0000000000..a091497a49 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/comp/basic.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/basic.comp new file mode 100644 index 0000000000..f025d53c6f --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/comp/bitfield.noopt.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/bitfield.noopt.comp new file mode 100644 index 0000000000..49bbddb0ab --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/comp/casts.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/casts.comp new file mode 100644 index 0000000000..11ef36287b --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/comp/cfg-preserve-parameter.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/cfg-preserve-parameter.comp new file mode 100644 index 0000000000..124652b322 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/comp/cfg.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/cfg.comp new file mode 100644 index 0000000000..c2c7136bbd --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/comp/coherent-block.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/coherent-block.comp new file mode 100644 index 0000000000..bfab6bbea8 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/comp/coherent-image.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/coherent-image.comp new file mode 100644 index 0000000000..b3992f242e --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/comp/composite-construct.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/composite-construct.comp new file mode 100644 index 0000000000..5371f7e528 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/comp/culling.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/culling.comp new file mode 100644 index 0000000000..f4dea4b359 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/comp/defer-parens.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/defer-parens.comp new file mode 100644 index 0000000000..51fa7f0abf --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/comp/dowhile.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/dowhile.comp new file mode 100644 index 0000000000..61a3735d13 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/comp/generate_height.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/generate_height.comp new file mode 100644 index 0000000000..1b5e0c3dc1 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/comp/image.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/image.comp new file mode 100644 index 0000000000..8bd7dd06ab --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/comp/inout-struct.invalid.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/inout-struct.invalid.comp new file mode 100644 index 0000000000..640e25bb95 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/comp/insert.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/insert.comp new file mode 100644 index 0000000000..5ff719449a --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/comp/loop.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/loop.noopt.comp similarity index 94% rename from deps/SPIRV-Cross/reference/shaders/comp/loop.comp rename to deps/SPIRV-Cross/reference/opt/shaders/comp/loop.noopt.comp index 9853acaa35..049a30669c 100644 --- a/deps/SPIRV-Cross/reference/shaders/comp/loop.comp +++ b/deps/SPIRV-Cross/reference/opt/shaders/comp/loop.noopt.comp @@ -1,13 +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 +layout(binding = 0, std430) readonly buffer SSBO { mat4 mvp; vec4 in_data[]; } _24; -layout(binding = 1, std430) buffer SSBO2 +layout(binding = 1, std430) writeonly buffer SSBO2 { vec4 out_data[]; } _177; diff --git a/deps/SPIRV-Cross/reference/opt/shaders/comp/mat3.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/mat3.comp new file mode 100644 index 0000000000..b1c585b849 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/comp/mod.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/mod.comp new file mode 100644 index 0000000000..d8ee0ff83a --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/comp/modf.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/modf.comp new file mode 100644 index 0000000000..3c8ab6ecd7 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/comp/read-write-only.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/read-write-only.comp new file mode 100644 index 0000000000..06227ee2c6 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/comp/return.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/return.comp new file mode 100644 index 0000000000..ea41907a7b --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/comp/rmw-opt.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/rmw-opt.comp new file mode 100644 index 0000000000..7d4d24b29f --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/comp/shared.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/shared.comp new file mode 100644 index 0000000000..66ec1c2cc7 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/comp/ssbo-array.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/ssbo-array.comp new file mode 100644 index 0000000000..6caf8f49f5 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/comp/struct-layout.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/struct-layout.comp new file mode 100644 index 0000000000..0f73fa7fa9 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/comp/struct-packing.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/struct-packing.comp new file mode 100644 index 0000000000..3c30aa6088 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/comp/torture-loop.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/torture-loop.comp new file mode 100644 index 0000000000..8002984f18 --- /dev/null +++ b/deps/SPIRV-Cross/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 _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 new file mode 100644 index 0000000000..c0f57f4bda --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/comp/udiv.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/udiv.comp new file mode 100644 index 0000000000..0c1f926ad0 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..ba37ca237b --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..3839a091f5 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..37b2863558 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..702456b303 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..2d0809fdbf --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..1276981768 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..fa1ac0abae --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..d4622801df --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..4a80cbf81f --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..f43543b8c0 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..4c30ed1529 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..d5e45bda43 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..f1afee69ec --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..773aeb8bfd --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..5e958256af --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..31027dae80 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..5f527e08c1 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..566809db23 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..7c731684bc --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/flatten/array.flatten.vert b/deps/SPIRV-Cross/reference/opt/shaders/flatten/array.flatten.vert new file mode 100644 index 0000000000..de4eb3b78d --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/flatten/basic.flatten.vert b/deps/SPIRV-Cross/reference/opt/shaders/flatten/basic.flatten.vert new file mode 100644 index 0000000000..f7eb758f2a --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/flatten/copy.flatten.vert b/deps/SPIRV-Cross/reference/opt/shaders/flatten/copy.flatten.vert new file mode 100644 index 0000000000..59f0dc1b42 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/flatten/dynamic.flatten.vert b/deps/SPIRV-Cross/reference/opt/shaders/flatten/dynamic.flatten.vert new file mode 100644 index 0000000000..c08f7445be --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/flatten/matrixindex.flatten.vert b/deps/SPIRV-Cross/reference/opt/shaders/flatten/matrixindex.flatten.vert new file mode 100644 index 0000000000..f6d0fa486d --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..6ccede21a9 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/flatten/multiindex.flatten.vert b/deps/SPIRV-Cross/reference/opt/shaders/flatten/multiindex.flatten.vert new file mode 100644 index 0000000000..3850bf6c70 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/flatten/push-constant.flatten.vert b/deps/SPIRV-Cross/reference/opt/shaders/flatten/push-constant.flatten.vert new file mode 100644 index 0000000000..216c1f9d1b --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/flatten/rowmajor.flatten.vert b/deps/SPIRV-Cross/reference/opt/shaders/flatten/rowmajor.flatten.vert new file mode 100644 index 0000000000..b74aa004b4 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/flatten/struct.flatten.vert b/deps/SPIRV-Cross/reference/opt/shaders/flatten/struct.flatten.vert new file mode 100644 index 0000000000..35db010c76 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/flatten/struct.rowmajor.flatten.vert b/deps/SPIRV-Cross/reference/opt/shaders/flatten/struct.rowmajor.flatten.vert new file mode 100644 index 0000000000..0dfa3b46ce --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/flatten/swizzle.flatten.vert b/deps/SPIRV-Cross/reference/opt/shaders/flatten/swizzle.flatten.vert new file mode 100644 index 0000000000..92afb475e6 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/flatten/types.flatten.frag b/deps/SPIRV-Cross/reference/opt/shaders/flatten/types.flatten.frag new file mode 100644 index 0000000000..a74327d97b --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/frag/basic.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/basic.frag new file mode 100644 index 0000000000..2a4e440421 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..eb59732fdc --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/frag/constant-array.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/constant-array.frag new file mode 100644 index 0000000000..a6ffda0737 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/frag/eliminate-dead-variables.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/eliminate-dead-variables.frag new file mode 100644 index 0000000000..c97ae20f9a --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/frag/false-loop-init.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/false-loop-init.frag new file mode 100644 index 0000000000..1db46c1bd5 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/frag/flush_params.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/flush_params.frag new file mode 100644 index 0000000000..5f386dffbb --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/frag/for-loop-init.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/for-loop-init.frag new file mode 100644 index 0000000000..626d7c8d5e --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/frag/frexp-modf.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/frexp-modf.frag new file mode 100644 index 0000000000..25f3360aaa --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/frag/ground.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/ground.frag new file mode 100644 index 0000000000..aaca58c1cd --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..5dfb4d0028 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/frag/mix.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/mix.frag new file mode 100644 index 0000000000..f1494e0775 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/frag/partial-write-preserve.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/partial-write-preserve.frag new file mode 100644 index 0000000000..527b661bcc --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/frag/pls.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/pls.frag new file mode 100644 index 0000000000..1cafdbd365 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/frag/sample-parameter.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/sample-parameter.frag new file mode 100644 index 0000000000..3c130e68d4 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/frag/sampler-ms-query.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/sampler-ms-query.frag new file mode 100644 index 0000000000..4c30ed1529 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/frag/sampler-ms.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/sampler-ms.frag new file mode 100644 index 0000000000..d78b805d09 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/frag/sampler-proj.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/sampler-proj.frag new file mode 100644 index 0000000000..865dec6c8b --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/frag/sampler.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/sampler.frag new file mode 100644 index 0000000000..2a4e440421 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/frag/swizzle.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/swizzle.frag new file mode 100644 index 0000000000..e619be2f48 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/frag/temporary.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/temporary.frag new file mode 100644 index 0000000000..ec9d3e4958 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/frag/ubo_layout.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/ubo_layout.frag new file mode 100644 index 0000000000..bc0b01c065 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/frag/unary-enclose.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/unary-enclose.frag new file mode 100644 index 0000000000..118787bdf9 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/geom/basic.geom b/deps/SPIRV-Cross/reference/opt/shaders/geom/basic.geom new file mode 100644 index 0000000000..296ce5792c --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/geom/lines-adjacency.geom b/deps/SPIRV-Cross/reference/opt/shaders/geom/lines-adjacency.geom new file mode 100644 index 0000000000..46a21e9fb0 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/geom/lines.geom b/deps/SPIRV-Cross/reference/opt/shaders/geom/lines.geom new file mode 100644 index 0000000000..c5aaa53d35 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/geom/points.geom b/deps/SPIRV-Cross/reference/opt/shaders/geom/points.geom new file mode 100644 index 0000000000..4d59137c3a --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/geom/single-invocation.geom b/deps/SPIRV-Cross/reference/opt/shaders/geom/single-invocation.geom new file mode 100644 index 0000000000..fdccacc04f --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/geom/triangles-adjacency.geom b/deps/SPIRV-Cross/reference/opt/shaders/geom/triangles-adjacency.geom new file mode 100644 index 0000000000..e9e6857a1f --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/geom/triangles.geom b/deps/SPIRV-Cross/reference/opt/shaders/geom/triangles.geom new file mode 100644 index 0000000000..fdccacc04f --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..6e8dbf1a9c --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..d5a60d53e9 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..e131f2e21c --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..6e44107448 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..3c518dc79e --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..8520e2d562 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/legacy/vert/transpose.legacy.vert b/deps/SPIRV-Cross/reference/opt/shaders/legacy/vert/transpose.legacy.vert new file mode 100644 index 0000000000..0d30c0e243 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/tesc/basic.tesc b/deps/SPIRV-Cross/reference/opt/shaders/tesc/basic.tesc new file mode 100644 index 0000000000..6019151adb --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/tesc/water_tess.tesc b/deps/SPIRV-Cross/reference/opt/shaders/tesc/water_tess.tesc new file mode 100644 index 0000000000..0320fff2ca --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/tese/ccw.tese b/deps/SPIRV-Cross/reference/opt/shaders/tese/ccw.tese new file mode 100644 index 0000000000..a2a4508ac0 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/tese/cw.tese b/deps/SPIRV-Cross/reference/opt/shaders/tese/cw.tese new file mode 100644 index 0000000000..95781493d8 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/tese/equal.tese b/deps/SPIRV-Cross/reference/opt/shaders/tese/equal.tese new file mode 100644 index 0000000000..6d30518a30 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/tese/fractional_even.tese b/deps/SPIRV-Cross/reference/opt/shaders/tese/fractional_even.tese new file mode 100644 index 0000000000..95781493d8 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/tese/fractional_odd.tese b/deps/SPIRV-Cross/reference/opt/shaders/tese/fractional_odd.tese new file mode 100644 index 0000000000..608c19aba7 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/tese/line.tese b/deps/SPIRV-Cross/reference/opt/shaders/tese/line.tese new file mode 100644 index 0000000000..8b6ad8da20 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/tese/triangle.tese b/deps/SPIRV-Cross/reference/opt/shaders/tese/triangle.tese new file mode 100644 index 0000000000..95781493d8 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/tese/water_tess.tese b/deps/SPIRV-Cross/reference/opt/shaders/tese/water_tess.tese new file mode 100644 index 0000000000..6efa9f0a69 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/vert/basic.vert b/deps/SPIRV-Cross/reference/opt/shaders/vert/basic.vert new file mode 100644 index 0000000000..05504eb2f2 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/vert/ground.vert b/deps/SPIRV-Cross/reference/opt/shaders/vert/ground.vert new file mode 100644 index 0000000000..790c4c8249 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/vert/ocean.vert b/deps/SPIRV-Cross/reference/opt/shaders/vert/ocean.vert new file mode 100644 index 0000000000..d37a0a8a4c --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/vert/texture_buffer.vert b/deps/SPIRV-Cross/reference/opt/shaders/vert/texture_buffer.vert new file mode 100644 index 0000000000..e9442ce119 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/opt/shaders/vert/ubo.vert b/deps/SPIRV-Cross/reference/opt/shaders/vert/ubo.vert new file mode 100644 index 0000000000..4e7236b290 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..f0729fdcdf --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..b6ad1e39c4 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..29c247d6d9 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..7a543c4168 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..8f7508ee8e --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..4c0506b110 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..ea460c1fae --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..462df22a19 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..8d216b2c49 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..c8b5d9a70d --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..c04a7ca488 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..6cec90f19e --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..a52d5bc77c --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..105ca76e44 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..4f9b6f515f --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..0b74896aef --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..533738efc3 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..90055473d9 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..60ba1882f8 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..8c4930d7a8 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..8243347bf6 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..1887eaa88f --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..851dfa1aa8 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/asm/frag/unreachable.asm.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/asm/frag/unreachable.asm.frag new file mode 100644 index 0000000000..c2fa519df8 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..103ff46a3f --- /dev/null +++ b/deps/SPIRV-Cross/reference/shaders-hlsl/asm/vert/empty-struct-composite.asm.vert @@ -0,0 +1,8 @@ +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 new file mode 100644 index 0000000000..8d5e771fe4 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/comp/access-chains.comp b/deps/SPIRV-Cross/reference/shaders-hlsl/comp/access-chains.comp new file mode 100644 index 0000000000..924e919124 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/comp/address-buffers.comp b/deps/SPIRV-Cross/reference/shaders-hlsl/comp/address-buffers.comp new file mode 100644 index 0000000000..a252fc8ae3 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/comp/atomic.comp b/deps/SPIRV-Cross/reference/shaders-hlsl/comp/atomic.comp new file mode 100644 index 0000000000..72e15bf77d --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/comp/barriers.comp b/deps/SPIRV-Cross/reference/shaders-hlsl/comp/barriers.comp new file mode 100644 index 0000000000..15af8ac11d --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/comp/bitfield.noopt.comp b/deps/SPIRV-Cross/reference/shaders-hlsl/comp/bitfield.noopt.comp new file mode 100644 index 0000000000..6839d9569e --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/comp/builtins.comp b/deps/SPIRV-Cross/reference/shaders-hlsl/comp/builtins.comp new file mode 100644 index 0000000000..5d84883b2f --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/comp/image.comp b/deps/SPIRV-Cross/reference/shaders-hlsl/comp/image.comp new file mode 100644 index 0000000000..c8504e636c --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/comp/rwbuffer-matrix.comp b/deps/SPIRV-Cross/reference/shaders-hlsl/comp/rwbuffer-matrix.comp new file mode 100644 index 0000000000..0e352f1f83 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/comp/shared.comp b/deps/SPIRV-Cross/reference/shaders-hlsl/comp/shared.comp new file mode 100644 index 0000000000..5d12900382 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/comp/ssbo-array.comp b/deps/SPIRV-Cross/reference/shaders-hlsl/comp/ssbo-array.comp new file mode 100644 index 0000000000..90927421c6 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/frag/basic.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/basic.frag new file mode 100644 index 0000000000..6d067041c2 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/frag/bit-conversions.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/bit-conversions.frag new file mode 100644 index 0000000000..2ed359bfc7 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/frag/boolean-mix.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/boolean-mix.frag new file mode 100644 index 0000000000..f3e84898d6 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/frag/builtins.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/builtins.frag new file mode 100644 index 0000000000..922eca7c2d --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/frag/bvec-operations.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/bvec-operations.frag new file mode 100644 index 0000000000..2398d8c6af --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..7fcff423b3 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..af5b0b5579 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..7e613da1cf --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/frag/early-fragment-test.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/early-fragment-test.frag new file mode 100644 index 0000000000..ae2569d5cf --- /dev/null +++ b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/early-fragment-test.frag @@ -0,0 +1,9 @@ +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 new file mode 100644 index 0000000000..d87828225f --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/frag/image-query-selective.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/image-query-selective.frag new file mode 100644 index 0000000000..25c12da669 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/frag/image-query.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/image-query.frag new file mode 100644 index 0000000000..71cefc1030 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/frag/io-block.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/io-block.frag new file mode 100644 index 0000000000..52c1f518bf --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/frag/matrix-input.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/matrix-input.frag new file mode 100644 index 0000000000..92d87d396e --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/frag/mod.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/mod.frag new file mode 100644 index 0000000000..1da8f21e45 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/frag/mrt.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/mrt.frag new file mode 100644 index 0000000000..e69e91196a --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/frag/no-return.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/no-return.frag new file mode 100644 index 0000000000..3b50282fe0 --- /dev/null +++ b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/no-return.frag @@ -0,0 +1,8 @@ +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 new file mode 100644 index 0000000000..a22ffa7725 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/frag/partial-write-preserve.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/partial-write-preserve.frag new file mode 100644 index 0000000000..4ed4d42747 --- /dev/null +++ b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/partial-write-preserve.frag @@ -0,0 +1,73 @@ +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 new file mode 100644 index 0000000000..fd95798bf4 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/frag/resources.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/resources.frag new file mode 100644 index 0000000000..60b709e696 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..b52b1df554 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/frag/sampler-array.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/sampler-array.frag new file mode 100644 index 0000000000..7fc5e3f37e --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/frag/spec-constant.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/spec-constant.frag new file mode 100644 index 0000000000..70b029dc68 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/frag/swizzle-scalar.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/swizzle-scalar.frag new file mode 100644 index 0000000000..ab310b82f2 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/frag/tex-sampling.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/tex-sampling.frag new file mode 100644 index 0000000000..7e10bfdd24 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/frag/texture-proj-shadow.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/texture-proj-shadow.frag new file mode 100644 index 0000000000..4beaa11761 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/frag/unary-enclose.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/unary-enclose.frag new file mode 100644 index 0000000000..597c57f800 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/frag/unorm-snorm-packing.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/unorm-snorm-packing.frag new file mode 100644 index 0000000000..57b5950636 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/frag/various-glsl-ops.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/various-glsl-ops.frag new file mode 100644 index 0000000000..f0b345482b --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/vert/basic.vert b/deps/SPIRV-Cross/reference/shaders-hlsl/vert/basic.vert new file mode 100644 index 0000000000..5f0a5f3d1a --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/vert/instancing.vert b/deps/SPIRV-Cross/reference/shaders-hlsl/vert/instancing.vert new file mode 100644 index 0000000000..48b2df20d3 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/vert/locations.vert b/deps/SPIRV-Cross/reference/shaders-hlsl/vert/locations.vert new file mode 100644 index 0000000000..b06b204bdd --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/vert/matrix-attribute.vert b/deps/SPIRV-Cross/reference/shaders-hlsl/vert/matrix-attribute.vert new file mode 100644 index 0000000000..a3d0eef56e --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/vert/matrix-output.vert b/deps/SPIRV-Cross/reference/shaders-hlsl/vert/matrix-output.vert new file mode 100644 index 0000000000..dc776cb5ec --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/vert/no-input.vert b/deps/SPIRV-Cross/reference/shaders-hlsl/vert/no-input.vert new file mode 100644 index 0000000000..c98544dbe8 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/vert/point-size-compat.vert b/deps/SPIRV-Cross/reference/shaders-hlsl/vert/point-size-compat.vert new file mode 100644 index 0000000000..83333d0be2 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/vert/qualifiers.vert b/deps/SPIRV-Cross/reference/shaders-hlsl/vert/qualifiers.vert new file mode 100644 index 0000000000..13ee2a8c1c --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/vert/sampler-buffers.vert b/deps/SPIRV-Cross/reference/shaders-hlsl/vert/sampler-buffers.vert new file mode 100644 index 0000000000..a4329dbf36 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/vert/struct-composite-decl.vert b/deps/SPIRV-Cross/reference/shaders-hlsl/vert/struct-composite-decl.vert new file mode 100644 index 0000000000..5b2c5824fc --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-hlsl/vert/texture_buffer.vert b/deps/SPIRV-Cross/reference/shaders-hlsl/vert/texture_buffer.vert new file mode 100644 index 0000000000..1c92f6fe65 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..ff0f60dbef --- /dev/null +++ b/deps/SPIRV-Cross/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)]], 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 new file mode 100644 index 0000000000..47ce85f8fc --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..20d6fe9e9d --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..f18b318bbb --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..9fd60bef26 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..7652733268 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/asm/comp/quantize.asm.comp b/deps/SPIRV-Cross/reference/shaders-msl/asm/comp/quantize.asm.comp new file mode 100644 index 0000000000..1839ec7a3b --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..5802ddac90 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..19d753afa7 --- /dev/null +++ b/deps/SPIRV-Cross/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(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 new file mode 100644 index 0000000000..3628c4eaae --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..98a1674865 --- /dev/null +++ b/deps/SPIRV-Cross/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]], 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 new file mode 100644 index 0000000000..588e7d1572 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..036774d661 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..2cefeb6693 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/asm/frag/unreachable.asm.frag b/deps/SPIRV-Cross/reference/shaders-msl/asm/frag/unreachable.asm.frag new file mode 100644 index 0000000000..7a98487221 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..17cd528d41 --- /dev/null +++ b/deps/SPIRV-Cross/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(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 new file mode 100644 index 0000000000..9e024c2095 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/comp/atomic.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/atomic.comp new file mode 100644 index 0000000000..90a39ec643 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/comp/bake_gradient.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/bake_gradient.comp new file mode 100644 index 0000000000..1118f18f8e --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/comp/barriers.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/barriers.comp new file mode 100644 index 0000000000..3b8474c757 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/comp/basic.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/basic.comp new file mode 100644 index 0000000000..2c34c3543c --- /dev/null +++ b/deps/SPIRV-Cross/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(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 new file mode 100644 index 0000000000..62ef02c997 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/comp/builtins.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/builtins.comp new file mode 100644 index 0000000000..4330d57831 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/comp/cfg-preserve-parameter.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/cfg-preserve-parameter.comp new file mode 100644 index 0000000000..d65beee5d2 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/comp/coherent-block.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/coherent-block.comp new file mode 100644 index 0000000000..bec9b218c7 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/comp/coherent-image.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/coherent-image.comp new file mode 100644 index 0000000000..0fe044fb9a --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/comp/culling.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/culling.comp new file mode 100644 index 0000000000..7eb6fe864e --- /dev/null +++ b/deps/SPIRV-Cross/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(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 new file mode 100644 index 0000000000..76dce77734 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/comp/dowhile.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/dowhile.comp new file mode 100644 index 0000000000..ff772941a4 --- /dev/null +++ b/deps/SPIRV-Cross/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(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 new file mode 100644 index 0000000000..6127a39ca7 --- /dev/null +++ b/deps/SPIRV-Cross/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) +{ + 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 new file mode 100644 index 0000000000..1b525c1f90 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/comp/global-invocation-id.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/global-invocation-id.comp new file mode 100644 index 0000000000..fe0212ec3f --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/comp/image.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/image.comp new file mode 100644 index 0000000000..85b48da797 --- /dev/null +++ b/deps/SPIRV-Cross/reference/shaders-msl/comp/image.comp @@ -0,0 +1,11 @@ +#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 new file mode 100644 index 0000000000..0f56a65153 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/comp/local-invocation-id.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/local-invocation-id.comp new file mode 100644 index 0000000000..772e5e0d86 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/comp/local-invocation-index.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/local-invocation-index.comp new file mode 100644 index 0000000000..41adbdca5c --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/comp/loop.noopt.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/loop.noopt.comp new file mode 100644 index 0000000000..55d850d191 --- /dev/null +++ b/deps/SPIRV-Cross/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(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 new file mode 100644 index 0000000000..4a315ce72c --- /dev/null +++ b/deps/SPIRV-Cross/reference/shaders-msl/comp/mat3.comp @@ -0,0 +1,16 @@ +#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 new file mode 100644 index 0000000000..9d13a2edd2 --- /dev/null +++ b/deps/SPIRV-Cross/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(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 new file mode 100644 index 0000000000..b358e9478c --- /dev/null +++ b/deps/SPIRV-Cross/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(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 new file mode 100644 index 0000000000..ba53b334ba --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/comp/return.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/return.comp new file mode 100644 index 0000000000..24e498c1f4 --- /dev/null +++ b/deps/SPIRV-Cross/reference/shaders-msl/comp/return.comp @@ -0,0 +1,36 @@ +#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 new file mode 100644 index 0000000000..060f9f9c71 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/comp/shared.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/shared.comp new file mode 100644 index 0000000000..20f9538bd2 --- /dev/null +++ b/deps/SPIRV-Cross/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(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 new file mode 100644 index 0000000000..27714ef09c --- /dev/null +++ b/deps/SPIRV-Cross/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(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 new file mode 100644 index 0000000000..cf626ce63f --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/comp/torture-loop.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/torture-loop.comp new file mode 100644 index 0000000000..759af12685 --- /dev/null +++ b/deps/SPIRV-Cross/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(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 new file mode 100644 index 0000000000..e47c2ba946 --- /dev/null +++ b/deps/SPIRV-Cross/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)]], 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 new file mode 100644 index 0000000000..ed82369b99 --- /dev/null +++ b/deps/SPIRV-Cross/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)]], 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 new file mode 100644 index 0000000000..9dc53b6dd5 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..7957b209d6 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..922796b749 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..4d2eee11c5 --- /dev/null +++ b/deps/SPIRV-Cross/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)]], 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 new file mode 100644 index 0000000000..1592b5c5cf --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..32f0d9aa0d --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/flatten/basic.flatten.vert b/deps/SPIRV-Cross/reference/shaders-msl/flatten/basic.flatten.vert new file mode 100644 index 0000000000..1592b5c5cf --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/flatten/multiindex.flatten.vert b/deps/SPIRV-Cross/reference/shaders-msl/flatten/multiindex.flatten.vert new file mode 100644 index 0000000000..84c4b408b2 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/flatten/push-constant.flatten.vert b/deps/SPIRV-Cross/reference/shaders-msl/flatten/push-constant.flatten.vert new file mode 100644 index 0000000000..83def9c0bb --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/flatten/rowmajor.flatten.vert b/deps/SPIRV-Cross/reference/shaders-msl/flatten/rowmajor.flatten.vert new file mode 100644 index 0000000000..3ea6d78b8a --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/flatten/struct.flatten.vert b/deps/SPIRV-Cross/reference/shaders-msl/flatten/struct.flatten.vert new file mode 100644 index 0000000000..75f58e1e29 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/flatten/swizzle.flatten.vert b/deps/SPIRV-Cross/reference/shaders-msl/flatten/swizzle.flatten.vert new file mode 100644 index 0000000000..53fc21f99e --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/flatten/types.flatten.frag b/deps/SPIRV-Cross/reference/shaders-msl/flatten/types.flatten.frag new file mode 100644 index 0000000000..cee53d9e58 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/frag/basic.frag b/deps/SPIRV-Cross/reference/shaders-msl/frag/basic.frag new file mode 100644 index 0000000000..4d33ee7bca --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/frag/bitcasting.frag b/deps/SPIRV-Cross/reference/shaders-msl/frag/bitcasting.frag new file mode 100644 index 0000000000..fcbced0efe --- /dev/null +++ b/deps/SPIRV-Cross/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)]], 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 new file mode 100644 index 0000000000..9283d1a66b --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..2d68f01299 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/frag/constant-array.frag b/deps/SPIRV-Cross/reference/shaders-msl/frag/constant-array.frag new file mode 100644 index 0000000000..15aa8fdce2 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/frag/false-loop-init.frag b/deps/SPIRV-Cross/reference/shaders-msl/frag/false-loop-init.frag new file mode 100644 index 0000000000..e0792474b5 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/frag/flush_params.frag b/deps/SPIRV-Cross/reference/shaders-msl/frag/flush_params.frag new file mode 100644 index 0000000000..e2f2a48cb2 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/frag/for-loop-init.frag b/deps/SPIRV-Cross/reference/shaders-msl/frag/for-loop-init.frag new file mode 100644 index 0000000000..9f3191b971 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/frag/in_block.frag b/deps/SPIRV-Cross/reference/shaders-msl/frag/in_block.frag new file mode 100644 index 0000000000..43b4a05897 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..d06863d99c --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/frag/mix.frag b/deps/SPIRV-Cross/reference/shaders-msl/frag/mix.frag new file mode 100644 index 0000000000..2d35766621 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/frag/pls.frag b/deps/SPIRV-Cross/reference/shaders-msl/frag/pls.frag new file mode 100644 index 0000000000..42b5d2bf59 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/frag/sampler-ms.frag b/deps/SPIRV-Cross/reference/shaders-msl/frag/sampler-ms.frag new file mode 100644 index 0000000000..6b5e20d720 --- /dev/null +++ b/deps/SPIRV-Cross/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(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 new file mode 100644 index 0000000000..5d23492905 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..46c0524ab7 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/frag/swizzle.frag b/deps/SPIRV-Cross/reference/shaders-msl/frag/swizzle.frag new file mode 100644 index 0000000000..eb46111f00 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/frag/texture-proj-shadow.frag b/deps/SPIRV-Cross/reference/shaders-msl/frag/texture-proj-shadow.frag new file mode 100644 index 0000000000..c31e6d9623 --- /dev/null +++ b/deps/SPIRV-Cross/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)]], 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 new file mode 100644 index 0000000000..8c03e33b39 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/frag/unary-enclose.frag b/deps/SPIRV-Cross/reference/shaders-msl/frag/unary-enclose.frag new file mode 100644 index 0000000000..5a80f4d77c --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/legacy/vert/transpose.legacy.vert b/deps/SPIRV-Cross/reference/shaders-msl/legacy/vert/transpose.legacy.vert new file mode 100644 index 0000000000..ad9ed8d7fd --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/vert/basic.vert b/deps/SPIRV-Cross/reference/shaders-msl/vert/basic.vert new file mode 100644 index 0000000000..1592b5c5cf --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/vert/copy.flatten.vert b/deps/SPIRV-Cross/reference/shaders-msl/vert/copy.flatten.vert new file mode 100644 index 0000000000..9ae5fcdb17 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/vert/dynamic.flatten.vert b/deps/SPIRV-Cross/reference/shaders-msl/vert/dynamic.flatten.vert new file mode 100644 index 0000000000..696966ca0b --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/vert/functions.vert b/deps/SPIRV-Cross/reference/shaders-msl/vert/functions.vert new file mode 100644 index 0000000000..8ec2484c3e --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/vert/out_block.vert b/deps/SPIRV-Cross/reference/shaders-msl/vert/out_block.vert new file mode 100644 index 0000000000..3ae18387a6 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/vert/pointsize.vert b/deps/SPIRV-Cross/reference/shaders-msl/vert/pointsize.vert new file mode 100644 index 0000000000..faf828b4d3 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/vert/texture_buffer.vert b/deps/SPIRV-Cross/reference/shaders-msl/vert/texture_buffer.vert new file mode 100644 index 0000000000..690757b830 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/vert/ubo.alignment.vert b/deps/SPIRV-Cross/reference/shaders-msl/vert/ubo.alignment.vert new file mode 100644 index 0000000000..6e48ae0e42 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders-msl/vert/ubo.vert b/deps/SPIRV-Cross/reference/shaders-msl/vert/ubo.vert new file mode 100644 index 0000000000..4a1adcd7f6 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..bc97e3cc51 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..47dabb1771 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..53e26e4a8e --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..d670898481 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..4aaf397a0f --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/amd/fs.invalid.frag b/deps/SPIRV-Cross/reference/shaders/amd/fs.invalid.frag new file mode 100644 index 0000000000..97e7bcd180 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/amd/gcn_shader.comp b/deps/SPIRV-Cross/reference/shaders/amd/gcn_shader.comp new file mode 100644 index 0000000000..1c0c5ae38b --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/amd/shader_ballot.comp b/deps/SPIRV-Cross/reference/shaders/amd/shader_ballot.comp new file mode 100644 index 0000000000..64ac64d0d2 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..a14343ae12 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/amd/shader_group_vote.comp b/deps/SPIRV-Cross/reference/shaders/amd/shader_group_vote.comp new file mode 100644 index 0000000000..007d9f9841 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/amd/shader_trinary_minmax.comp b/deps/SPIRV-Cross/reference/shaders/amd/shader_trinary_minmax.comp new file mode 100644 index 0000000000..ece39b7106 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/asm/comp/bitcast_iadd.asm.comp b/deps/SPIRV-Cross/reference/shaders/asm/comp/bitcast_iadd.asm.comp index 2d27240a90..bed2dffccb 100644 --- a/deps/SPIRV-Cross/reference/shaders/asm/comp/bitcast_iadd.asm.comp +++ b/deps/SPIRV-Cross/reference/shaders/asm/comp/bitcast_iadd.asm.comp @@ -1,27 +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 +layout(binding = 0, std430) restrict buffer _3_5 { - ivec4 _0; - uvec4 _1; + ivec4 _m0; + uvec4 _m1; } _5; -layout(binding = 1, std430) restrict buffer _4 +layout(binding = 1, std430) restrict buffer _4_6 { - uvec4 _0; - ivec4 _1; + uvec4 _m0; + ivec4 _m1; } _6; void main() { - _6._0 = _5._1 + uvec4(_5._0); - _6._0 = uvec4(_5._0) + _5._1; - _6._0 = _5._1 + _5._1; - _6._0 = uvec4(_5._0 + _5._0); - _6._1 = ivec4(_5._1 + _5._1); - _6._1 = _5._0 + _5._0; - _6._1 = ivec4(_5._1) + _5._0; - _6._1 = _5._0 + ivec4(_5._1); + _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 index 2663a70ab4..79398b404b 100644 --- a/deps/SPIRV-Cross/reference/shaders/asm/comp/bitcast_iequal.asm.comp +++ b/deps/SPIRV-Cross/reference/shaders/asm/comp/bitcast_iequal.asm.comp @@ -1,31 +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 +layout(binding = 0, std430) buffer _3_5 { - ivec4 _0; - uvec4 _1; + ivec4 _m0; + uvec4 _m1; } _5; -layout(binding = 1, std430) buffer _4 +layout(binding = 1, std430) buffer _4_6 { - uvec4 _0; - ivec4 _1; + uvec4 _m0; + ivec4 _m1; } _6; void main() { - bvec4 _34 = equal(ivec4(_5._1), _5._0); - bvec4 _35 = equal(_5._0, ivec4(_5._1)); - bvec4 _36 = equal(_5._1, _5._1); - bvec4 _37 = equal(_5._0, _5._0); - _6._0 = mix(uvec4(0u), uvec4(1u), _34); - _6._0 = mix(uvec4(0u), uvec4(1u), _35); - _6._0 = mix(uvec4(0u), uvec4(1u), _36); - _6._0 = mix(uvec4(0u), uvec4(1u), _37); - _6._1 = mix(ivec4(0), ivec4(1), _34); - _6._1 = mix(ivec4(0), ivec4(1), _35); - _6._1 = mix(ivec4(0), ivec4(1), _36); - _6._1 = mix(ivec4(0), ivec4(1), _37); + 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 index 7699302167..42a4ed0233 100644 --- a/deps/SPIRV-Cross/reference/shaders/asm/comp/bitcast_sar.asm.comp +++ b/deps/SPIRV-Cross/reference/shaders/asm/comp/bitcast_sar.asm.comp @@ -1,27 +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 +layout(binding = 0, std430) buffer _3_5 { - ivec4 _0; - uvec4 _1; + ivec4 _m0; + uvec4 _m1; } _5; -layout(binding = 1, std430) buffer _4 +layout(binding = 1, std430) buffer _4_6 { - uvec4 _0; - ivec4 _1; + uvec4 _m0; + ivec4 _m1; } _6; void main() { - _6._0 = uvec4(ivec4(_5._1) >> _5._0); - _6._0 = uvec4(_5._0 >> ivec4(_5._1)); - _6._0 = uvec4(ivec4(_5._1) >> ivec4(_5._1)); - _6._0 = uvec4(_5._0 >> _5._0); - _6._1 = ivec4(_5._1) >> ivec4(_5._1); - _6._1 = _5._0 >> _5._0; - _6._1 = ivec4(_5._1) >> _5._0; - _6._1 = _5._0 >> ivec4(_5._1); + _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 index afa5e41d1a..eeb97e14a2 100644 --- a/deps/SPIRV-Cross/reference/shaders/asm/comp/bitcast_sdiv.asm.comp +++ b/deps/SPIRV-Cross/reference/shaders/asm/comp/bitcast_sdiv.asm.comp @@ -1,27 +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 +layout(binding = 0, std430) buffer _3_5 { - ivec4 _0; - uvec4 _1; + ivec4 _m0; + uvec4 _m1; } _5; -layout(binding = 1, std430) buffer _4 +layout(binding = 1, std430) buffer _4_6 { - uvec4 _0; - ivec4 _1; + uvec4 _m0; + ivec4 _m1; } _6; void main() { - _6._0 = uvec4(ivec4(_5._1) / _5._0); - _6._0 = uvec4(_5._0 / ivec4(_5._1)); - _6._0 = uvec4(ivec4(_5._1) / ivec4(_5._1)); - _6._0 = uvec4(_5._0 / _5._0); - _6._1 = ivec4(_5._1) / ivec4(_5._1); - _6._1 = _5._0 / _5._0; - _6._1 = ivec4(_5._1) / _5._0; - _6._1 = _5._0 / ivec4(_5._1); + _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 index 6de9201737..25245e63eb 100644 --- a/deps/SPIRV-Cross/reference/shaders/asm/comp/bitcast_slr.asm.comp +++ b/deps/SPIRV-Cross/reference/shaders/asm/comp/bitcast_slr.asm.comp @@ -1,27 +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 +layout(binding = 0, std430) buffer _3_5 { - ivec4 _0; - uvec4 _1; + ivec4 _m0; + uvec4 _m1; } _5; -layout(binding = 1, std430) buffer _4 +layout(binding = 1, std430) buffer _4_6 { - uvec4 _0; - ivec4 _1; + uvec4 _m0; + ivec4 _m1; } _6; void main() { - _6._0 = _5._1 >> uvec4(_5._0); - _6._0 = uvec4(_5._0) >> _5._1; - _6._0 = _5._1 >> _5._1; - _6._0 = uvec4(_5._0) >> uvec4(_5._0); - _6._1 = ivec4(_5._1 >> _5._1); - _6._1 = ivec4(uvec4(_5._0) >> uvec4(_5._0)); - _6._1 = ivec4(_5._1 >> uvec4(_5._0)); - _6._1 = ivec4(uvec4(_5._0) >> _5._1); + _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/bitcast_udiv.asm.comp b/deps/SPIRV-Cross/reference/shaders/asm/comp/bitcast_udiv.asm.comp deleted file mode 100644 index aa9d68fe85..0000000000 --- a/deps/SPIRV-Cross/reference/shaders/asm/comp/bitcast_udiv.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 -{ - ivec4 _0; - uvec4 _1; -} _5; - -layout(binding = 1, std430) buffer _4 -{ - uvec4 _0; - ivec4 _1; -} _6; - -void main() -{ - _6._0 = _5._1 / uvec4(_5._0); - _6._0 = uvec4(_5._0) / _5._1; - _6._0 = _5._1 / _5._1; - _6._0 = uvec4(_5._0) / uvec4(_5._0); - _6._1 = ivec4(_5._1 / _5._1); - _6._1 = ivec4(uvec4(_5._0) / uvec4(_5._0)); - _6._1 = ivec4(_5._1 / uvec4(_5._0)); - _6._1 = ivec4(uvec4(_5._0) / _5._1); -} - diff --git a/deps/SPIRV-Cross/reference/shaders/asm/comp/logical.asm.comp b/deps/SPIRV-Cross/reference/shaders/asm/comp/logical.asm.comp new file mode 100644 index 0000000000..9ae25f78a9 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/asm/comp/multiple-entry.asm.comp b/deps/SPIRV-Cross/reference/shaders/asm/comp/multiple-entry.asm.comp index 65a528cd4b..6418464f19 100644 --- a/deps/SPIRV-Cross/reference/shaders/asm/comp/multiple-entry.asm.comp +++ b/deps/SPIRV-Cross/reference/shaders/asm/comp/multiple-entry.asm.comp @@ -1,27 +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 +layout(binding = 0, std430) restrict buffer _6_8 { - ivec4 _0; - uvec4 _1; + ivec4 _m0; + uvec4 _m1; } _8; -layout(binding = 1, std430) restrict buffer _7 +layout(binding = 1, std430) restrict buffer _7_9 { - uvec4 _0; - ivec4 _1; + uvec4 _m0; + ivec4 _m1; } _9; void main() { - _9._0 = _8._1 + uvec4(_8._0); - _9._0 = uvec4(_8._0) + _8._1; - _9._0 = _8._1 + _8._1; - _9._0 = uvec4(_8._0 + _8._0); - _9._1 = ivec4(_8._1 + _8._1); - _9._1 = _8._0 + _8._0; - _9._1 = ivec4(_8._1) + _8._0; - _9._1 = _8._0 + ivec4(_8._1); + _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 index 4928e7c4bd..870b1df98d 100644 --- 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 @@ -19,19 +19,19 @@ struct alias_2 alias_1 alias_1; }; -layout(binding = 0, std430) buffer _10 -{ - alias_2 alias; -} alias_3; - -layout(binding = 1, std140) buffer _15 +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_5 = alias_3.alias; - alias_4.alias = alias_5; + alias_2 alias_7 = alias_4.alias; + alias_6.alias = alias_7; } 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 new file mode 100644 index 0000000000..1b2285a8da --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..a2210eb169 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..c64818d2bf --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..57d4536c9b --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..3585285eb6 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..63856ddd46 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..98116cfdc7 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/asm/frag/invalidation.asm.frag b/deps/SPIRV-Cross/reference/shaders/asm/frag/invalidation.asm.frag index 1cdc9761f9..db1181804c 100644 --- a/deps/SPIRV-Cross/reference/shaders/asm/frag/invalidation.asm.frag +++ b/deps/SPIRV-Cross/reference/shaders/asm/frag/invalidation.asm.frag @@ -1,8 +1,8 @@ #version 450 -in float v0; -in float v1; -out float FragColor; +layout(location = 0) in float v0; +layout(location = 1) in float v1; +layout(location = 0) out float FragColor; void main() { 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 new file mode 100644 index 0000000000..e1edccff69 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..b5f30a2471 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..c4ae981f64 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..786ac74de5 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..a4cf078308 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..b2473f4d03 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..3917594d98 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..26ad568ad0 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/asm/frag/unreachable.asm.frag b/deps/SPIRV-Cross/reference/shaders/asm/frag/unreachable.asm.frag new file mode 100644 index 0000000000..8bc88b9f0a --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..1c211caa6d --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..8cb7a4e64c --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/asm/vert/empty-io.asm.vert b/deps/SPIRV-Cross/reference/shaders/asm/vert/empty-io.asm.vert new file mode 100644 index 0000000000..e1a56d9d4c --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..05ce10adfa --- /dev/null +++ b/deps/SPIRV-Cross/reference/shaders/asm/vert/empty-struct-composite.asm.vert @@ -0,0 +1,6 @@ +#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 new file mode 100644 index 0000000000..7578827019 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/comp/bake_gradient.comp b/deps/SPIRV-Cross/reference/shaders/comp/bake_gradient.comp index 41facc8c3c..7b0bb34c64 100644 --- a/deps/SPIRV-Cross/reference/shaders/comp/bake_gradient.comp +++ b/deps/SPIRV-Cross/reference/shaders/comp/bake_gradient.comp @@ -9,8 +9,8 @@ layout(binding = 4, std140) uniform UBO layout(binding = 0) uniform mediump sampler2D uHeight; layout(binding = 1) uniform mediump sampler2D uDisplacement; -layout(binding = 2, rgba16f) uniform mediump writeonly image2D iHeightDisplacement; -layout(binding = 3, rgba16f) uniform mediump writeonly image2D iGradJacobian; +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) { diff --git a/deps/SPIRV-Cross/reference/shaders/comp/barriers.comp b/deps/SPIRV-Cross/reference/shaders/comp/barriers.comp new file mode 100644 index 0000000000..a1b975de83 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/comp/basic.comp b/deps/SPIRV-Cross/reference/shaders/comp/basic.comp index ca2503bd3b..1485089951 100644 --- a/deps/SPIRV-Cross/reference/shaders/comp/basic.comp +++ b/deps/SPIRV-Cross/reference/shaders/comp/basic.comp @@ -1,12 +1,12 @@ #version 310 es layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; -layout(binding = 0, std430) buffer SSBO +layout(binding = 0, std430) readonly buffer SSBO { vec4 in_data[]; } _23; -layout(binding = 1, std430) buffer SSBO2 +layout(binding = 1, std430) writeonly buffer SSBO2 { vec4 out_data[]; } _45; diff --git a/deps/SPIRV-Cross/reference/shaders/comp/bitfield.noopt.comp b/deps/SPIRV-Cross/reference/shaders/comp/bitfield.noopt.comp new file mode 100644 index 0000000000..49bbddb0ab --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/comp/cfg-preserve-parameter.comp b/deps/SPIRV-Cross/reference/shaders/comp/cfg-preserve-parameter.comp new file mode 100644 index 0000000000..72bde44a90 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/comp/cfg.comp b/deps/SPIRV-Cross/reference/shaders/comp/cfg.comp index 707968e7e5..77ad312cda 100644 --- a/deps/SPIRV-Cross/reference/shaders/comp/cfg.comp +++ b/deps/SPIRV-Cross/reference/shaders/comp/cfg.comp @@ -8,7 +8,6 @@ layout(binding = 0, std430) buffer SSBO void test() { - float m; if (_11.data != 0.0) { float tmp = 10.0; @@ -68,6 +67,7 @@ void test() { } _11.data = h; + float m; do { } while (m != 20.0); diff --git a/deps/SPIRV-Cross/reference/shaders/comp/coherent-block.comp b/deps/SPIRV-Cross/reference/shaders/comp/coherent-block.comp new file mode 100644 index 0000000000..bfab6bbea8 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/comp/coherent-image.comp b/deps/SPIRV-Cross/reference/shaders/comp/coherent-image.comp new file mode 100644 index 0000000000..b3992f242e --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/comp/culling.comp b/deps/SPIRV-Cross/reference/shaders/comp/culling.comp index cd284b96c6..fd83bfcb5b 100644 --- a/deps/SPIRV-Cross/reference/shaders/comp/culling.comp +++ b/deps/SPIRV-Cross/reference/shaders/comp/culling.comp @@ -1,12 +1,12 @@ #version 310 es layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in; -layout(binding = 0, std430) buffer SSBO +layout(binding = 0, std430) readonly buffer SSBO { float in_data[]; } _22; -layout(binding = 1, std430) buffer SSBO2 +layout(binding = 1, std430) writeonly buffer SSBO2 { float out_data[]; } _38; diff --git a/deps/SPIRV-Cross/reference/shaders/comp/dowhile.comp b/deps/SPIRV-Cross/reference/shaders/comp/dowhile.comp index 16ba4001b8..e717961abd 100644 --- a/deps/SPIRV-Cross/reference/shaders/comp/dowhile.comp +++ b/deps/SPIRV-Cross/reference/shaders/comp/dowhile.comp @@ -1,13 +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 +layout(binding = 0, std430) readonly buffer SSBO { mat4 mvp; vec4 in_data[]; } _28; -layout(binding = 1, std430) buffer SSBO2 +layout(binding = 1, std430) writeonly buffer SSBO2 { vec4 out_data[]; } _52; diff --git a/deps/SPIRV-Cross/reference/shaders/comp/generate_height.comp b/deps/SPIRV-Cross/reference/shaders/comp/generate_height.comp index a2128dd8a1..30ec624cfb 100644 --- a/deps/SPIRV-Cross/reference/shaders/comp/generate_height.comp +++ b/deps/SPIRV-Cross/reference/shaders/comp/generate_height.comp @@ -1,43 +1,43 @@ #version 310 es layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; -layout(binding = 0, std430) buffer Distribution +layout(binding = 0, std430) readonly buffer Distribution { vec2 distribution[]; -} _190; +} _136; layout(binding = 2, std140) uniform UBO { vec4 uModTime; -} _218; +} _165; -layout(binding = 1, std430) buffer HeightmapFFT +layout(binding = 1, std430) writeonly buffer HeightmapFFT { uint heights[]; -} _276; +} _224; uvec2 workaround_mix(uvec2 a, uvec2 b, bvec2 sel) { - uint _137; + uint _83; if (sel.x) { - _137 = b.x; + _83 = b.x; } else { - _137 = a.x; + _83 = a.x; } - uint _147 = _137; - uint _148; + uint _93 = _83; + uint _94; if (sel.y) { - _148 = b.y; + _94 = b.y; } else { - _148 = a.y; + _94 = a.y; } - return uvec2(_147, _148); + return uvec2(_93, _94); } vec2 alias(vec2 i, vec2 N) @@ -68,13 +68,13 @@ void generate_heightmap() uvec2 param_1 = uvec2(0u); bvec2 param_2 = equal(i, uvec2(0u)); uvec2 wi = workaround_mix(param, param_1, param_2); - vec2 a = _190.distribution[(i.y * N.x) + i.x]; - vec2 b = _190.distribution[(wi.y * N.x) + wi.x]; + 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 = _218.uModTime.xy * alias(param_3, param_4); + vec2 k = _165.uModTime.xy * alias(param_3, param_4); float k_len = length(k); - float w = sqrt(9.81000041961669921875 * k_len) * _218.uModTime.z; + float w = sqrt(9.81000041961669921875 * k_len) * _165.uModTime.z; float cw = cos(w); float sw = sin(w); vec2 param_5 = a; @@ -86,7 +86,7 @@ void generate_heightmap() b = vec2(b.x, -b.y); vec2 res = a + b; vec2 param_9 = res; - _276.heights[(i.y * N.x) + i.x] = pack2(param_9); + _224.heights[(i.y * N.x) + i.x] = pack2(param_9); } void main() diff --git a/deps/SPIRV-Cross/reference/shaders/comp/image.comp b/deps/SPIRV-Cross/reference/shaders/comp/image.comp index 7479905003..b2bf0d65bb 100644 --- a/deps/SPIRV-Cross/reference/shaders/comp/image.comp +++ b/deps/SPIRV-Cross/reference/shaders/comp/image.comp @@ -1,8 +1,8 @@ #version 310 es layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; -layout(binding = 0, rgba8) uniform mediump readonly image2D uImageIn; -layout(binding = 1, rgba8) uniform mediump writeonly image2D uImageOut; +layout(binding = 0, rgba8) uniform readonly mediump image2D uImageIn; +layout(binding = 1, rgba8) uniform writeonly mediump image2D uImageOut; void main() { diff --git a/deps/SPIRV-Cross/reference/shaders/comp/inout-struct.invalid.comp b/deps/SPIRV-Cross/reference/shaders/comp/inout-struct.invalid.comp index 1aaa48f2ae..640e25bb95 100644 --- a/deps/SPIRV-Cross/reference/shaders/comp/inout-struct.invalid.comp +++ b/deps/SPIRV-Cross/reference/shaders/comp/inout-struct.invalid.comp @@ -9,22 +9,22 @@ struct Foo vec4 d; }; -layout(binding = 1, std430) buffer SSBO2 +layout(binding = 1, std430) readonly buffer SSBO2 { vec4 data[]; } indata; -layout(binding = 0, std430) buffer SSBO +layout(binding = 0, std430) writeonly buffer SSBO { vec4 data[]; } outdata; -layout(binding = 2, std430) buffer SSBO3 +layout(binding = 2, std430) readonly buffer SSBO3 { Foo foos[]; } foobar; -void baz(out Foo foo) +void baz(inout Foo foo) { uint ident = gl_GlobalInvocationID.x; foo.a = indata.data[(4u * ident) + 0u]; diff --git a/deps/SPIRV-Cross/reference/shaders/comp/insert.comp b/deps/SPIRV-Cross/reference/shaders/comp/insert.comp index 6c10020c3c..cbe1e27f45 100644 --- a/deps/SPIRV-Cross/reference/shaders/comp/insert.comp +++ b/deps/SPIRV-Cross/reference/shaders/comp/insert.comp @@ -1,7 +1,7 @@ #version 310 es layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; -layout(binding = 0, std430) buffer SSBO +layout(binding = 0, std430) writeonly buffer SSBO { vec4 out_data[]; } _27; diff --git a/deps/SPIRV-Cross/reference/shaders/comp/loop.noopt.comp b/deps/SPIRV-Cross/reference/shaders/comp/loop.noopt.comp new file mode 100644 index 0000000000..049a30669c --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/comp/mat3.comp b/deps/SPIRV-Cross/reference/shaders/comp/mat3.comp index dc302396a5..2b050f5d01 100644 --- a/deps/SPIRV-Cross/reference/shaders/comp/mat3.comp +++ b/deps/SPIRV-Cross/reference/shaders/comp/mat3.comp @@ -1,7 +1,7 @@ #version 310 es layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; -layout(binding = 1, std430) buffer SSBO2 +layout(binding = 1, std430) writeonly buffer SSBO2 { mat3 out_data[]; } _22; diff --git a/deps/SPIRV-Cross/reference/shaders/comp/mod.comp b/deps/SPIRV-Cross/reference/shaders/comp/mod.comp index dfb9cf4c70..4be0c5f7f4 100644 --- a/deps/SPIRV-Cross/reference/shaders/comp/mod.comp +++ b/deps/SPIRV-Cross/reference/shaders/comp/mod.comp @@ -1,12 +1,12 @@ #version 310 es layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; -layout(binding = 0, std430) buffer SSBO +layout(binding = 0, std430) readonly buffer SSBO { vec4 in_data[]; } _23; -layout(binding = 1, std430) buffer SSBO2 +layout(binding = 1, std430) writeonly buffer SSBO2 { vec4 out_data[]; } _33; diff --git a/deps/SPIRV-Cross/reference/shaders/comp/modf.comp b/deps/SPIRV-Cross/reference/shaders/comp/modf.comp index 721d812f10..c92149bf94 100644 --- a/deps/SPIRV-Cross/reference/shaders/comp/modf.comp +++ b/deps/SPIRV-Cross/reference/shaders/comp/modf.comp @@ -1,12 +1,12 @@ #version 310 es layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; -layout(binding = 0, std430) buffer SSBO +layout(binding = 0, std430) readonly buffer SSBO { vec4 in_data[]; } _23; -layout(binding = 1, std430) buffer SSBO2 +layout(binding = 1, std430) writeonly buffer SSBO2 { vec4 out_data[]; } _35; diff --git a/deps/SPIRV-Cross/reference/shaders/comp/read-write-only.comp b/deps/SPIRV-Cross/reference/shaders/comp/read-write-only.comp new file mode 100644 index 0000000000..06227ee2c6 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/comp/return.comp b/deps/SPIRV-Cross/reference/shaders/comp/return.comp index 20d61d25dc..4be20e93e4 100644 --- a/deps/SPIRV-Cross/reference/shaders/comp/return.comp +++ b/deps/SPIRV-Cross/reference/shaders/comp/return.comp @@ -1,7 +1,7 @@ #version 310 es layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; -layout(binding = 1, std430) buffer SSBO2 +layout(binding = 1, std430) writeonly buffer SSBO2 { vec4 out_data[]; } _27; diff --git a/deps/SPIRV-Cross/reference/shaders/comp/rmw-opt.comp b/deps/SPIRV-Cross/reference/shaders/comp/rmw-opt.comp new file mode 100644 index 0000000000..e3fba7810d --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/comp/shared.comp b/deps/SPIRV-Cross/reference/shaders/comp/shared.comp index e2ff604563..d0987a6528 100644 --- a/deps/SPIRV-Cross/reference/shaders/comp/shared.comp +++ b/deps/SPIRV-Cross/reference/shaders/comp/shared.comp @@ -1,12 +1,12 @@ #version 310 es layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in; -layout(binding = 0, std430) buffer SSBO +layout(binding = 0, std430) readonly buffer SSBO { float in_data[]; } _22; -layout(binding = 1, std430) buffer SSBO2 +layout(binding = 1, std430) writeonly buffer SSBO2 { float out_data[]; } _44; diff --git a/deps/SPIRV-Cross/reference/shaders/comp/struct-layout.comp b/deps/SPIRV-Cross/reference/shaders/comp/struct-layout.comp index 1cbf5dfb97..4feea8be54 100644 --- a/deps/SPIRV-Cross/reference/shaders/comp/struct-layout.comp +++ b/deps/SPIRV-Cross/reference/shaders/comp/struct-layout.comp @@ -6,12 +6,12 @@ struct Foo mat4 m; }; -layout(binding = 1, std430) buffer SSBO2 +layout(binding = 1, std430) writeonly buffer SSBO2 { Foo out_data[]; } _23; -layout(binding = 0, std430) buffer SSBO +layout(binding = 0, std430) readonly buffer SSBO { Foo in_data[]; } _30; diff --git a/deps/SPIRV-Cross/reference/shaders/comp/struct-packing.comp b/deps/SPIRV-Cross/reference/shaders/comp/struct-packing.comp index a6ea8d581e..3c30aa6088 100644 --- a/deps/SPIRV-Cross/reference/shaders/comp/struct-packing.comp +++ b/deps/SPIRV-Cross/reference/shaders/comp/struct-packing.comp @@ -64,6 +64,14 @@ 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; diff --git a/deps/SPIRV-Cross/reference/shaders/comp/torture-loop.comp b/deps/SPIRV-Cross/reference/shaders/comp/torture-loop.comp index ae18319061..645af5c374 100644 --- a/deps/SPIRV-Cross/reference/shaders/comp/torture-loop.comp +++ b/deps/SPIRV-Cross/reference/shaders/comp/torture-loop.comp @@ -1,13 +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 +layout(binding = 0, std430) readonly buffer SSBO { mat4 mvp; vec4 in_data[]; } _24; -layout(binding = 1, std430) buffer SSBO2 +layout(binding = 1, std430) writeonly buffer SSBO2 { vec4 out_data[]; } _89; 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 new file mode 100644 index 0000000000..ba37ca237b --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..70843a8563 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..6f36d5db3b --- /dev/null +++ b/deps/SPIRV-Cross/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/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 index 281053c820..d4622801df 100644 --- 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 @@ -1,18 +1,18 @@ #version 450 layout(location = 0) out vec4 FragColor; -in VertexData +layout(location = 0) in VertexData { - layout(location = 0) flat float f; - layout(location = 1) centroid vec4 g; - layout(location = 2) flat int h; - layout(location = 3) float i; + 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 = 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() { 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 new file mode 100644 index 0000000000..d5e45bda43 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..f1afee69ec --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..773aeb8bfd --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..5e958256af --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..31027dae80 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..5f527e08c1 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..566809db23 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 index 4a3be5c028..7c731684bc 100644 --- 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 @@ -1,16 +1,16 @@ #version 450 -out VertexData +layout(location = 0) out VertexData { - layout(location = 0) flat float f; - layout(location = 1) centroid vec4 g; - layout(location = 2) flat int h; - layout(location = 3) float i; + 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 = 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() diff --git a/deps/SPIRV-Cross/reference/shaders/flatten/array.flatten.vert b/deps/SPIRV-Cross/reference/shaders/flatten/array.flatten.vert new file mode 100644 index 0000000000..5afde34c55 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/flatten/basic.flatten.vert b/deps/SPIRV-Cross/reference/shaders/flatten/basic.flatten.vert new file mode 100644 index 0000000000..f7eb758f2a --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/flatten/copy.flatten.vert b/deps/SPIRV-Cross/reference/shaders/flatten/copy.flatten.vert new file mode 100644 index 0000000000..2bdd723886 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/flatten/dynamic.flatten.vert b/deps/SPIRV-Cross/reference/shaders/flatten/dynamic.flatten.vert new file mode 100644 index 0000000000..6214ca450a --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/flatten/matrixindex.flatten.vert b/deps/SPIRV-Cross/reference/shaders/flatten/matrixindex.flatten.vert new file mode 100644 index 0000000000..f6d0fa486d --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..21c3363ca6 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/flatten/multiindex.flatten.vert b/deps/SPIRV-Cross/reference/shaders/flatten/multiindex.flatten.vert new file mode 100644 index 0000000000..3850bf6c70 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/flatten/push-constant.flatten.vert b/deps/SPIRV-Cross/reference/shaders/flatten/push-constant.flatten.vert new file mode 100644 index 0000000000..216c1f9d1b --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/flatten/rowmajor.flatten.vert b/deps/SPIRV-Cross/reference/shaders/flatten/rowmajor.flatten.vert new file mode 100644 index 0000000000..721c4905c0 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/flatten/struct.flatten.vert b/deps/SPIRV-Cross/reference/shaders/flatten/struct.flatten.vert new file mode 100644 index 0000000000..3468d52929 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/flatten/struct.rowmajor.flatten.vert b/deps/SPIRV-Cross/reference/shaders/flatten/struct.rowmajor.flatten.vert new file mode 100644 index 0000000000..a40aea08af --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/flatten/swizzle.flatten.vert b/deps/SPIRV-Cross/reference/shaders/flatten/swizzle.flatten.vert new file mode 100644 index 0000000000..92afb475e6 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/flatten/types.flatten.frag b/deps/SPIRV-Cross/reference/shaders/flatten/types.flatten.frag new file mode 100644 index 0000000000..a74327d97b --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/frag/basic.frag b/deps/SPIRV-Cross/reference/shaders/frag/basic.frag index f83b28156a..2a4e440421 100644 --- a/deps/SPIRV-Cross/reference/shaders/frag/basic.frag +++ b/deps/SPIRV-Cross/reference/shaders/frag/basic.frag @@ -5,8 +5,8 @@ precision highp int; layout(binding = 0) uniform mediump sampler2D uTex; layout(location = 0) out vec4 FragColor; -in vec4 vColor; -in vec2 vTex; +layout(location = 0) in vec4 vColor; +layout(location = 1) in vec2 vTex; void main() { diff --git a/deps/SPIRV-Cross/reference/shaders/frag/constant-array.frag b/deps/SPIRV-Cross/reference/shaders/frag/constant-array.frag index ef9b794739..4da9b8948b 100644 --- a/deps/SPIRV-Cross/reference/shaders/frag/constant-array.frag +++ b/deps/SPIRV-Cross/reference/shaders/frag/constant-array.frag @@ -9,7 +9,7 @@ struct Foobar }; layout(location = 0) out vec4 FragColor; -layout(location = 0) in mediump flat int index; +layout(location = 0) flat in mediump int index; vec4 resolve(Foobar f) { diff --git a/deps/SPIRV-Cross/reference/shaders/frag/false-loop-init.frag b/deps/SPIRV-Cross/reference/shaders/frag/false-loop-init.frag new file mode 100644 index 0000000000..b0ed5577d3 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/frag/flush_params.frag b/deps/SPIRV-Cross/reference/shaders/frag/flush_params.frag index ee99395a1f..b4b36ff90d 100644 --- a/deps/SPIRV-Cross/reference/shaders/frag/flush_params.frag +++ b/deps/SPIRV-Cross/reference/shaders/frag/flush_params.frag @@ -9,7 +9,7 @@ struct Structy layout(location = 0) out vec4 FragColor; -void foo2(out Structy f) +void foo2(inout Structy f) { f.c = vec4(10.0); } diff --git a/deps/SPIRV-Cross/reference/shaders/frag/frexp-modf.frag b/deps/SPIRV-Cross/reference/shaders/frag/frexp-modf.frag new file mode 100644 index 0000000000..e495bb3169 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/frag/ground.frag b/deps/SPIRV-Cross/reference/shaders/frag/ground.frag index 4b0ea829bd..4d998d5689 100644 --- a/deps/SPIRV-Cross/reference/shaders/frag/ground.frag +++ b/deps/SPIRV-Cross/reference/shaders/frag/ground.frag @@ -10,7 +10,7 @@ layout(binding = 4, std140) uniform GlobalPSData vec4 g_ResolutionParams; vec4 g_TimeParams; vec4 g_FogColor_Distance; -} _56; +} _101; layout(binding = 2) uniform mediump sampler2D TexNormalmap; @@ -47,7 +47,7 @@ void main() 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, (_56.g_CamPos.y + EyeVec.y) / 200.0); + 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)); 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 new file mode 100644 index 0000000000..414dd956af --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/frag/mix.frag b/deps/SPIRV-Cross/reference/shaders/frag/mix.frag index 68e82273ed..2b288dff02 100644 --- a/deps/SPIRV-Cross/reference/shaders/frag/mix.frag +++ b/deps/SPIRV-Cross/reference/shaders/frag/mix.frag @@ -13,26 +13,8 @@ void main() bvec4 l = bvec4(false, true, false, false); FragColor = mix(vIn0, vIn1, l); bool f = true; - FragColor = vec4(mix(vIn2, vIn3, f)); - highp vec4 _35; - if (f) - { - _35 = vIn0; - } - else - { - _35 = vIn1; - } - FragColor = _35; - highp float _44; - if (f) - { - _44 = vIn2; - } - else - { - _44 = vIn3; - } - FragColor = vec4(_44); + 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 new file mode 100644 index 0000000000..cf8a83cf0c --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/frag/pls.frag b/deps/SPIRV-Cross/reference/shaders/frag/pls.frag index e0c8f270db..1cafdbd365 100644 --- a/deps/SPIRV-Cross/reference/shaders/frag/pls.frag +++ b/deps/SPIRV-Cross/reference/shaders/frag/pls.frag @@ -7,9 +7,9 @@ layout(location = 0) in vec4 PLSIn0; layout(location = 1) out vec4 PLSOut1; layout(location = 1) in vec4 PLSIn1; layout(location = 2) out vec4 PLSOut2; -in vec4 PLSIn2; +layout(location = 2) in vec4 PLSIn2; layout(location = 3) out vec4 PLSOut3; -in vec4 PLSIn3; +layout(location = 3) in vec4 PLSIn3; void main() { diff --git a/deps/SPIRV-Cross/reference/shaders/frag/sample-parameter.frag b/deps/SPIRV-Cross/reference/shaders/frag/sample-parameter.frag new file mode 100644 index 0000000000..3c130e68d4 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/frag/sampler-proj.frag b/deps/SPIRV-Cross/reference/shaders/frag/sampler-proj.frag new file mode 100644 index 0000000000..865dec6c8b --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/frag/sampler.frag b/deps/SPIRV-Cross/reference/shaders/frag/sampler.frag index 406cec6d45..0ec200c714 100644 --- a/deps/SPIRV-Cross/reference/shaders/frag/sampler.frag +++ b/deps/SPIRV-Cross/reference/shaders/frag/sampler.frag @@ -5,8 +5,8 @@ precision highp int; layout(binding = 0) uniform mediump sampler2D uTex; layout(location = 0) out vec4 FragColor; -in vec4 vColor; -in vec2 vTex; +layout(location = 0) in vec4 vColor; +layout(location = 1) in vec2 vTex; vec4 sample_texture(mediump sampler2D tex, vec2 uv) { diff --git a/deps/SPIRV-Cross/reference/shaders/frag/unary-enclose.frag b/deps/SPIRV-Cross/reference/shaders/frag/unary-enclose.frag new file mode 100644 index 0000000000..3006e86cb5 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/geom/basic.geom b/deps/SPIRV-Cross/reference/shaders/geom/basic.geom index f2eea50a65..296ce5792c 100644 --- a/deps/SPIRV-Cross/reference/shaders/geom/basic.geom +++ b/deps/SPIRV-Cross/reference/shaders/geom/basic.geom @@ -3,8 +3,8 @@ layout(invocations = 4, triangles) in; layout(max_vertices = 3, triangle_strip) out; -out vec3 vNormal; -in VertexData +layout(location = 0) out vec3 vNormal; +layout(location = 0) in VertexData { vec3 normal; } vin[3]; diff --git a/deps/SPIRV-Cross/reference/shaders/geom/lines-adjacency.geom b/deps/SPIRV-Cross/reference/shaders/geom/lines-adjacency.geom index 0083b8b299..46a21e9fb0 100644 --- a/deps/SPIRV-Cross/reference/shaders/geom/lines-adjacency.geom +++ b/deps/SPIRV-Cross/reference/shaders/geom/lines-adjacency.geom @@ -3,8 +3,8 @@ layout(lines_adjacency) in; layout(max_vertices = 3, line_strip) out; -out vec3 vNormal; -in VertexData +layout(location = 0) out vec3 vNormal; +layout(location = 0) in VertexData { vec3 normal; } vin[4]; diff --git a/deps/SPIRV-Cross/reference/shaders/geom/lines.geom b/deps/SPIRV-Cross/reference/shaders/geom/lines.geom index 6d20ec8253..c5aaa53d35 100644 --- a/deps/SPIRV-Cross/reference/shaders/geom/lines.geom +++ b/deps/SPIRV-Cross/reference/shaders/geom/lines.geom @@ -3,8 +3,8 @@ layout(lines) in; layout(max_vertices = 2, line_strip) out; -out vec3 vNormal; -in VertexData +layout(location = 0) out vec3 vNormal; +layout(location = 0) in VertexData { vec3 normal; } vin[2]; diff --git a/deps/SPIRV-Cross/reference/shaders/geom/points.geom b/deps/SPIRV-Cross/reference/shaders/geom/points.geom index 76d2a2dfcd..4d59137c3a 100644 --- a/deps/SPIRV-Cross/reference/shaders/geom/points.geom +++ b/deps/SPIRV-Cross/reference/shaders/geom/points.geom @@ -3,8 +3,8 @@ layout(points) in; layout(max_vertices = 3, points) out; -out vec3 vNormal; -in VertexData +layout(location = 0) out vec3 vNormal; +layout(location = 0) in VertexData { vec3 normal; } vin[1]; diff --git a/deps/SPIRV-Cross/reference/shaders/geom/single-invocation.geom b/deps/SPIRV-Cross/reference/shaders/geom/single-invocation.geom index 592f7996c7..fdccacc04f 100644 --- a/deps/SPIRV-Cross/reference/shaders/geom/single-invocation.geom +++ b/deps/SPIRV-Cross/reference/shaders/geom/single-invocation.geom @@ -3,8 +3,8 @@ layout(triangles) in; layout(max_vertices = 3, triangle_strip) out; -out vec3 vNormal; -in VertexData +layout(location = 0) out vec3 vNormal; +layout(location = 0) in VertexData { vec3 normal; } vin[3]; diff --git a/deps/SPIRV-Cross/reference/shaders/geom/triangles-adjacency.geom b/deps/SPIRV-Cross/reference/shaders/geom/triangles-adjacency.geom index 44d36548ab..e9e6857a1f 100644 --- a/deps/SPIRV-Cross/reference/shaders/geom/triangles-adjacency.geom +++ b/deps/SPIRV-Cross/reference/shaders/geom/triangles-adjacency.geom @@ -3,8 +3,8 @@ layout(triangles_adjacency) in; layout(max_vertices = 3, triangle_strip) out; -out vec3 vNormal; -in VertexData +layout(location = 0) out vec3 vNormal; +layout(location = 0) in VertexData { vec3 normal; } vin[6]; diff --git a/deps/SPIRV-Cross/reference/shaders/geom/triangles.geom b/deps/SPIRV-Cross/reference/shaders/geom/triangles.geom index 592f7996c7..fdccacc04f 100644 --- a/deps/SPIRV-Cross/reference/shaders/geom/triangles.geom +++ b/deps/SPIRV-Cross/reference/shaders/geom/triangles.geom @@ -3,8 +3,8 @@ layout(triangles) in; layout(max_vertices = 3, triangle_strip) out; -out vec3 vNormal; -in VertexData +layout(location = 0) out vec3 vNormal; +layout(location = 0) in VertexData { vec3 normal; } vin[3]; 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 new file mode 100644 index 0000000000..6e8dbf1a9c --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/legacy/fragment/io-blocks.legacy.frag b/deps/SPIRV-Cross/reference/shaders/legacy/fragment/io-blocks.legacy.frag new file mode 100644 index 0000000000..d5a60d53e9 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/legacy/fragment/struct-varying.legacy.frag b/deps/SPIRV-Cross/reference/shaders/legacy/fragment/struct-varying.legacy.frag new file mode 100644 index 0000000000..81b95dd816 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/legacy/vert/implicit-lod.legacy.vert b/deps/SPIRV-Cross/reference/shaders/legacy/vert/implicit-lod.legacy.vert new file mode 100644 index 0000000000..6e44107448 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/legacy/vert/io-block.legacy.vert b/deps/SPIRV-Cross/reference/shaders/legacy/vert/io-block.legacy.vert new file mode 100644 index 0000000000..3c518dc79e --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/legacy/vert/struct-varying.legacy.vert b/deps/SPIRV-Cross/reference/shaders/legacy/vert/struct-varying.legacy.vert new file mode 100644 index 0000000000..261e986034 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/legacy/vert/transpose.legacy.vert b/deps/SPIRV-Cross/reference/shaders/legacy/vert/transpose.legacy.vert new file mode 100644 index 0000000000..c73d1a11d9 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/tesc/basic.tesc b/deps/SPIRV-Cross/reference/shaders/tesc/basic.tesc index daf9b33c50..6019151adb 100644 --- a/deps/SPIRV-Cross/reference/shaders/tesc/basic.tesc +++ b/deps/SPIRV-Cross/reference/shaders/tesc/basic.tesc @@ -2,7 +2,7 @@ #extension GL_EXT_tessellation_shader : require layout(vertices = 1) out; -out patch vec3 vFoo; +layout(location = 0) patch out vec3 vFoo; void main() { diff --git a/deps/SPIRV-Cross/reference/shaders/tesc/water_tess.tesc b/deps/SPIRV-Cross/reference/shaders/tesc/water_tess.tesc index 422a467e3d..26611b8b25 100644 --- a/deps/SPIRV-Cross/reference/shaders/tesc/water_tess.tesc +++ b/deps/SPIRV-Cross/reference/shaders/tesc/water_tess.tesc @@ -12,9 +12,9 @@ layout(std140) uniform UBO vec4 uFrustum[6]; } _41; -out patch vec2 vOutPatchPosBase; -out patch vec4 vPatchLods; -in vec2 vPatchPosBase[32]; +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) { diff --git a/deps/SPIRV-Cross/reference/shaders/tese/water_tess.tese b/deps/SPIRV-Cross/reference/shaders/tese/water_tess.tese index 758c2b4e43..e743ed3e9c 100644 --- a/deps/SPIRV-Cross/reference/shaders/tese/water_tess.tese +++ b/deps/SPIRV-Cross/reference/shaders/tese/water_tess.tese @@ -14,10 +14,10 @@ layout(binding = 1, std140) uniform UBO layout(binding = 0) uniform mediump sampler2D uHeightmapDisplacement; -in patch vec2 vOutPatchPosBase; -in patch vec4 vPatchLods; -out vec4 vGradNormalTex; -out vec3 vWorld; +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) { diff --git a/deps/SPIRV-Cross/reference/shaders/vert/basic.vert b/deps/SPIRV-Cross/reference/shaders/vert/basic.vert index 429b36d58a..05504eb2f2 100644 --- a/deps/SPIRV-Cross/reference/shaders/vert/basic.vert +++ b/deps/SPIRV-Cross/reference/shaders/vert/basic.vert @@ -5,9 +5,9 @@ layout(std140) uniform UBO mat4 uMVP; } _16; -in vec4 aVertex; -out vec3 vNormal; -in vec3 aNormal; +layout(location = 0) in vec4 aVertex; +layout(location = 0) out vec3 vNormal; +layout(location = 1) in vec3 aNormal; void main() { diff --git a/deps/SPIRV-Cross/reference/shaders/vert/ground.vert b/deps/SPIRV-Cross/reference/shaders/vert/ground.vert index 44b19a99f7..b028cc34c6 100644 --- a/deps/SPIRV-Cross/reference/shaders/vert/ground.vert +++ b/deps/SPIRV-Cross/reference/shaders/vert/ground.vert @@ -6,6 +6,18 @@ struct PatchData 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; @@ -26,19 +38,7 @@ layout(binding = 0, std140) uniform GlobalVSData vec4 g_ShadowVP_Row1; vec4 g_ShadowVP_Row2; vec4 g_ShadowVP_Row3; -} _58; - -layout(binding = 0, std140) uniform PerPatch -{ - PatchData Patches[256]; -} _284; - -layout(binding = 2, std140) uniform GlobalGround -{ - vec4 GroundScale; - vec4 GroundPosition; - vec4 InvGroundSize_PatchScale; -} _381; +} _236; layout(binding = 1) uniform mediump sampler2D TexLOD; layout(binding = 0) uniform mediump sampler2D TexHeightmap; @@ -51,34 +51,34 @@ layout(location = 0) out vec2 TexCoord; vec2 warp_position() { - float vlod = dot(LODWeights, _284.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].LODs); - vlod = mix(vlod, _284.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].Position.w, all(equal(LODWeights, vec4(0.0)))); + 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 _332; + uint _106; if (uPosition.x < 32u) { - _332 = mask.x; + _106 = mask.x; } else { - _332 = 0u; + _106 = 0u; } - uint _342 = _332; - uint _343; + uint _116 = _106; + uint _117; if (uPosition.y < 32u) { - _343 = mask.y; + _117 = mask.y; } else { - _343 = 0u; + _117 = 0u; } - uvec2 rounding = uvec2(_342, _343); - vec4 lower_upper_snapped = vec4((uPosition + rounding).xyxy & ~mask.xxyy); + 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)); } @@ -92,19 +92,19 @@ vec2 lod_factor(vec2 uv) void main() { - vec2 PatchPos = _284.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].Position.xz * _381.InvGroundSize_PatchScale.zw; + 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 * _381.InvGroundSize_PatchScale.xy; + vec2 NormalizedPos = VertexPos * _156.InvGroundSize_PatchScale.xy; vec2 param = NormalizedPos; vec2 lod = lod_factor(param); - vec2 Offset = _381.InvGroundSize_PatchScale.xy * exp2(lod.x); + 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 *= _381.GroundScale.xyz; - WorldPos += _381.GroundPosition.xyz; - EyeVec = WorldPos - _58.g_CamPos.xyz; - TexCoord = NormalizedPos + (_381.InvGroundSize_PatchScale.xy * 0.5); - gl_Position = (((_58.g_ViewProj_Row0 * WorldPos.x) + (_58.g_ViewProj_Row1 * WorldPos.y)) + (_58.g_ViewProj_Row2 * WorldPos.z)) + _58.g_ViewProj_Row3; + 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 index c542fe25a4..d77a29fcbf 100644 --- a/deps/SPIRV-Cross/reference/shaders/vert/ocean.vert +++ b/deps/SPIRV-Cross/reference/shaders/vert/ocean.vert @@ -6,6 +6,19 @@ struct PatchData 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; @@ -26,20 +39,7 @@ layout(binding = 0, std140) uniform GlobalVSData vec4 g_ShadowVP_Row1; vec4 g_ShadowVP_Row2; vec4 g_ShadowVP_Row3; -} _58; - -layout(binding = 0, std140) uniform Offsets -{ - PatchData Patches[256]; -} _284; - -layout(binding = 4, std140) uniform GlobalOcean -{ - vec4 OceanScale; - vec4 OceanPosition; - vec4 InvOceanSize_PatchScale; - vec4 NormalTexCoordScale; -} _405; +} _273; layout(binding = 1) uniform mediump sampler2D TexLOD; layout(binding = 0) uniform mediump sampler2D TexDisplacement; @@ -52,55 +52,55 @@ layout(location = 1) out vec4 TexCoord; vec2 warp_position() { - float vlod = dot(LODWeights, _284.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].LODs); - vlod = mix(vlod, _284.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].Position.w, all(equal(LODWeights, vec4(0.0)))); + 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 _333; + uint _107; if (uPosition.x < 32u) { - _333 = mask.x; + _107 = mask.x; } else { - _333 = 0u; + _107 = 0u; } uvec4 rounding; - rounding.x = _333; - uint _345; + rounding.x = _107; + uint _119; if (uPosition.y < 32u) { - _345 = mask.x; + _119 = mask.x; } else { - _345 = 0u; + _119 = 0u; } - rounding.y = _345; - uint _356; + rounding.y = _119; + uint _130; if (uPosition.x < 32u) { - _356 = mask.y; + _130 = mask.y; } else { - _356 = 0u; + _130 = 0u; } - rounding.z = _356; - uint _368; + rounding.z = _130; + uint _142; if (uPosition.y < 32u) { - _368 = mask.y; + _142 = mask.y; } else { - _368 = 0u; + _142 = 0u; } - rounding.w = _368; - vec4 lower_upper_snapped = vec4((uPosition.xyxy + rounding) & ~mask.xxyy); + 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)); } @@ -114,20 +114,20 @@ vec2 lod_factor(vec2 uv) void main() { - vec2 PatchPos = _284.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].Position.xz * _405.InvOceanSize_PatchScale.zw; + 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 * _405.InvOceanSize_PatchScale.xy; - vec2 NormalizedTex = NormalizedPos * _405.NormalTexCoordScale.zw; + vec2 NormalizedPos = VertexPos * _180.InvOceanSize_PatchScale.xy; + vec2 NormalizedTex = NormalizedPos * _180.NormalTexCoordScale.zw; vec2 param = NormalizedPos; vec2 lod = lod_factor(param); - vec2 Offset = (_405.InvOceanSize_PatchScale.xy * exp2(lod.x)) * _405.NormalTexCoordScale.zw; + 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 *= _405.OceanScale.xyz; - WorldPos += _405.OceanPosition.xyz; - EyeVec = WorldPos - _58.g_CamPos.xyz; - TexCoord = vec4(NormalizedTex, NormalizedTex * _405.NormalTexCoordScale.xy) + ((_405.InvOceanSize_PatchScale.xyxy * 0.5) * _405.NormalTexCoordScale.zwzw); - gl_Position = (((_58.g_ViewProj_Row0 * WorldPos.x) + (_58.g_ViewProj_Row1 * WorldPos.y)) + (_58.g_ViewProj_Row2 * WorldPos.z)) + _58.g_ViewProj_Row3; + 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 index 0a198e75e0..e9442ce119 100644 --- a/deps/SPIRV-Cross/reference/shaders/vert/texture_buffer.vert +++ b/deps/SPIRV-Cross/reference/shaders/vert/texture_buffer.vert @@ -2,7 +2,7 @@ #extension GL_OES_texture_buffer : require layout(binding = 4) uniform highp samplerBuffer uSamp; -layout(binding = 5, rgba32f) uniform highp readonly imageBuffer uSampo; +layout(binding = 5, rgba32f) uniform readonly highp imageBuffer uSampo; void main() { diff --git a/deps/SPIRV-Cross/reference/shaders/vert/ubo.vert b/deps/SPIRV-Cross/reference/shaders/vert/ubo.vert index 335c1fe1b8..4e7236b290 100644 --- a/deps/SPIRV-Cross/reference/shaders/vert/ubo.vert +++ b/deps/SPIRV-Cross/reference/shaders/vert/ubo.vert @@ -5,9 +5,9 @@ layout(binding = 0, std140) uniform UBO mat4 mvp; } _16; -in vec4 aVertex; -out vec3 vNormal; -in vec3 aNormal; +layout(location = 0) in vec4 aVertex; +layout(location = 0) out vec3 vNormal; +layout(location = 1) in vec3 aNormal; void main() { 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 new file mode 100644 index 0000000000..af64fb87aa --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..f475ae53a9 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/reference/shaders/vulkan/frag/desktop-mediump.vk.frag b/deps/SPIRV-Cross/reference/shaders/vulkan/frag/desktop-mediump.vk.frag new file mode 100644 index 0000000000..8f7508ee8e --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..4c0506b110 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 index cb6745be0b..ea460c1fae 100644 --- 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 @@ -1,14 +1,12 @@ -#version 310 es -precision mediump float; -precision highp int; +#version 450 -layout(binding = 0) uniform mediump sampler2DMS uSubpass0; -layout(binding = 1) uniform mediump sampler2DMS uSubpass1; +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); + 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 index 488c8939be..462df22a19 100644 --- 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 @@ -1,14 +1,12 @@ -#version 310 es -precision mediump float; -precision highp int; +#version 450 -layout(input_attachment_index = 0, set = 0, binding = 0) uniform mediump subpassInputMS uSubpass0; -layout(input_attachment_index = 1, set = 0, binding = 1) uniform mediump subpassInputMS uSubpass1; +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); + FragColor = (subpassLoad(uSubpass0, 1) + subpassLoad(uSubpass1, 2)) + subpassLoad(uSubpass0, gl_SampleID); } 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 index 6fa15eeb5f..7976042a85 100644 --- a/deps/SPIRV-Cross/reference/shaders/vulkan/frag/spec-constant.vk.frag +++ b/deps/SPIRV-Cross/reference/shaders/vulkan/frag/spec-constant.vk.frag @@ -51,9 +51,9 @@ void main() mediump int c35 = int(false); mediump uint c36 = uint(false); float c37 = float(false); - float vec0[4][(3 + 3)]; - float vec1[(3 + 2)][(4 + 5)]; + float vec0[(3 + 3)][8]; + float vec1[(3 + 2)]; Foo foo; - FragColor = ((vec4(t0 + t1) + vec4(vec0[0][0])) + vec4(vec1[0][0])) + vec4(foo.elems[3]); + 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 index 14747d103f..d0765cc8bd 100644 --- 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 @@ -2,67 +2,67 @@ precision mediump float; precision highp int; -layout(constant_id = 1) const float _9 = 1.0; -layout(constant_id = 2) const float _11 = 2.0; -layout(constant_id = 3) const int _16 = 3; -layout(constant_id = 4) const int _25 = 4; -layout(constant_id = 5) const uint _34 = 5u; -layout(constant_id = 6) const uint _35 = 6u; -layout(constant_id = 7) const bool _56 = false; -layout(constant_id = 8) const bool _57 = true; +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[(_25 + 2)]; + float elems[(d + 2)]; }; layout(location = 0) out vec4 FragColor; void main() { - float t0 = _9; - float t1 = _11; - mediump uint c0 = (uint(_16) + 0u); - mediump int c1 = (-_16); - mediump int c2 = (~_16); - mediump int c3 = (_16 + _25); - mediump int c4 = (_16 - _25); - mediump int c5 = (_16 * _25); - mediump int c6 = (_16 / _25); - mediump uint c7 = (_34 / _35); - mediump int c8 = (_16 % _25); - mediump uint c9 = (_34 % _35); - mediump int c10 = (_16 >> _25); - mediump uint c11 = (_34 >> _35); - mediump int c12 = (_16 << _25); - mediump int c13 = (_16 | _25); - mediump int c14 = (_16 ^ _25); - mediump int c15 = (_16 & _25); - bool c16 = (_56 || _57); - bool c17 = (_56 && _57); - bool c18 = (!_56); - bool c19 = (_56 == _57); - bool c20 = (_56 != _57); - bool c21 = (_16 == _25); - bool c22 = (_16 != _25); - bool c23 = (_16 < _25); - bool c24 = (_34 < _35); - bool c25 = (_16 > _25); - bool c26 = (_34 > _35); - bool c27 = (_16 <= _25); - bool c28 = (_34 <= _35); - bool c29 = (_16 >= _25); - bool c30 = (_34 >= _35); + 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(_34 + 0u); - bool c33 = (_16 != int(0u)); - bool c34 = (_34 != 0u); - mediump int c35 = int(_56); - mediump uint c36 = uint(_56); - float c37 = float(_56); - float vec0[_25][(_16 + 3)]; - float vec1[(_16 + 2)][(_25 + 5)]; + 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][0])) + vec4(foo.elems[_16]); + 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 new file mode 100644 index 0000000000..533738efc3 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..90055473d9 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/samples/cpp/atomics.cpp b/deps/SPIRV-Cross/samples/cpp/atomics.cpp index 9591461483..89351a5ae5 100644 --- a/deps/SPIRV-Cross/samples/cpp/atomics.cpp +++ b/deps/SPIRV-Cross/samples/cpp/atomics.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 ARM Limited + * 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. diff --git a/deps/SPIRV-Cross/samples/cpp/multiply.cpp b/deps/SPIRV-Cross/samples/cpp/multiply.cpp index 5b2a8cdd3c..daa1fc6477 100644 --- a/deps/SPIRV-Cross/samples/cpp/multiply.cpp +++ b/deps/SPIRV-Cross/samples/cpp/multiply.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 ARM Limited + * 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. diff --git a/deps/SPIRV-Cross/samples/cpp/shared.cpp b/deps/SPIRV-Cross/samples/cpp/shared.cpp index d5c7f2214d..5be62d681f 100644 --- a/deps/SPIRV-Cross/samples/cpp/shared.cpp +++ b/deps/SPIRV-Cross/samples/cpp/shared.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 ARM Limited + * 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. 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 new file mode 100644 index 0000000000..188e3fec36 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..edb1a05e54 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/asm/frag/cbuffer-stripped.asm.frag b/deps/SPIRV-Cross/shaders-hlsl/asm/frag/cbuffer-stripped.asm.frag new file mode 100644 index 0000000000..d778034b5f --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/asm/frag/unreachable.asm.frag b/deps/SPIRV-Cross/shaders-hlsl/asm/frag/unreachable.asm.frag new file mode 100644 index 0000000000..e2ce2eb56a --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..37a2d87937 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..85acc47ff2 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/comp/access-chains.comp b/deps/SPIRV-Cross/shaders-hlsl/comp/access-chains.comp new file mode 100644 index 0000000000..639f3cac15 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/comp/address-buffers.comp b/deps/SPIRV-Cross/shaders-hlsl/comp/address-buffers.comp new file mode 100644 index 0000000000..3ba582ccd6 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/comp/atomic.comp b/deps/SPIRV-Cross/shaders-hlsl/comp/atomic.comp new file mode 100644 index 0000000000..6f69ec725c --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/comp/barriers.comp b/deps/SPIRV-Cross/shaders-hlsl/comp/barriers.comp new file mode 100644 index 0000000000..7e0ea42d4e --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/comp/bitfield.noopt.comp b/deps/SPIRV-Cross/shaders-hlsl/comp/bitfield.noopt.comp new file mode 100644 index 0000000000..a2ef9aa0b7 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/comp/builtins.comp b/deps/SPIRV-Cross/shaders-hlsl/comp/builtins.comp new file mode 100644 index 0000000000..b41cb53913 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/comp/image.comp b/deps/SPIRV-Cross/shaders-hlsl/comp/image.comp new file mode 100644 index 0000000000..1d3c8b4c65 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/comp/rwbuffer-matrix.comp b/deps/SPIRV-Cross/shaders-hlsl/comp/rwbuffer-matrix.comp new file mode 100644 index 0000000000..0e722e0a51 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/comp/shared.comp b/deps/SPIRV-Cross/shaders-hlsl/comp/shared.comp new file mode 100644 index 0000000000..4deff93597 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/comp/ssbo-array.comp b/deps/SPIRV-Cross/shaders-hlsl/comp/ssbo-array.comp new file mode 100644 index 0000000000..38b56e9a0a --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/frag/basic.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/basic.frag new file mode 100644 index 0000000000..dd9a8f8507 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/frag/bit-conversions.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/bit-conversions.frag new file mode 100644 index 0000000000..faacdc0f15 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/frag/boolean-mix.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/boolean-mix.frag new file mode 100644 index 0000000000..9fd8ab3475 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/frag/builtins.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/builtins.frag new file mode 100644 index 0000000000..99e6e2df5b --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/frag/bvec-operations.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/bvec-operations.frag new file mode 100644 index 0000000000..7221604d9a --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/frag/combined-texture-sampler-parameter.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/combined-texture-sampler-parameter.frag new file mode 100644 index 0000000000..e5721b9026 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/frag/combined-texture-sampler-shadow.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/combined-texture-sampler-shadow.frag new file mode 100644 index 0000000000..2fabb5ea8a --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/frag/constant-buffer-array.sm51.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/constant-buffer-array.sm51.frag new file mode 100644 index 0000000000..d60002a0f2 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/frag/early-fragment-test.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/early-fragment-test.frag new file mode 100644 index 0000000000..9f84e09880 --- /dev/null +++ b/deps/SPIRV-Cross/shaders-hlsl/frag/early-fragment-test.frag @@ -0,0 +1,7 @@ +#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 new file mode 100644 index 0000000000..98ca24e2f8 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/frag/image-query-selective.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/image-query-selective.frag new file mode 100644 index 0000000000..bb595bcb9b --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/frag/image-query.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/image-query.frag new file mode 100644 index 0000000000..8e840fba11 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/frag/io-block.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/io-block.frag new file mode 100644 index 0000000000..1e3e3d77e8 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/frag/matrix-input.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/matrix-input.frag new file mode 100644 index 0000000000..ffe242cec2 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/frag/mod.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/mod.frag new file mode 100644 index 0000000000..32edb61841 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/frag/mrt.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/mrt.frag new file mode 100644 index 0000000000..77a2bb29c7 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/frag/no-return.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/no-return.frag new file mode 100644 index 0000000000..f0ef8702ce --- /dev/null +++ b/deps/SPIRV-Cross/shaders-hlsl/frag/no-return.frag @@ -0,0 +1,5 @@ +#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 new file mode 100644 index 0000000000..46bf9fbf20 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/frag/partial-write-preserve.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/partial-write-preserve.frag new file mode 100644 index 0000000000..f30270b91b --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/frag/query-lod.desktop.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/query-lod.desktop.frag new file mode 100644 index 0000000000..0cb160402f --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/frag/resources.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/resources.frag new file mode 100644 index 0000000000..16178bfd77 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/frag/sample-cmp-level-zero.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/sample-cmp-level-zero.frag new file mode 100644 index 0000000000..c40d742eeb --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/frag/sampler-array.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/sampler-array.frag new file mode 100644 index 0000000000..75910ed163 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/frag/spec-constant.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/spec-constant.frag new file mode 100644 index 0000000000..a6c8d94e78 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/frag/swizzle-scalar.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/swizzle-scalar.frag new file mode 100644 index 0000000000..c27524f7a6 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/frag/tex-sampling.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/tex-sampling.frag new file mode 100644 index 0000000000..4a386c0d33 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/frag/texture-proj-shadow.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/texture-proj-shadow.frag new file mode 100644 index 0000000000..0c4cf8f5a8 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/frag/unary-enclose.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/unary-enclose.frag new file mode 100644 index 0000000000..ea502e1de8 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/frag/unorm-snorm-packing.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/unorm-snorm-packing.frag new file mode 100644 index 0000000000..c0a01aaf8b --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/frag/various-glsl-ops.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/various-glsl-ops.frag new file mode 100644 index 0000000000..0d4af80a6e --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/vert/basic.vert b/deps/SPIRV-Cross/shaders-hlsl/vert/basic.vert new file mode 100644 index 0000000000..f03114feef --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/vert/instancing.vert b/deps/SPIRV-Cross/shaders-hlsl/vert/instancing.vert new file mode 100644 index 0000000000..0e62ef6b0e --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/vert/locations.vert b/deps/SPIRV-Cross/shaders-hlsl/vert/locations.vert new file mode 100644 index 0000000000..df1a44e923 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/vert/matrix-attribute.vert b/deps/SPIRV-Cross/shaders-hlsl/vert/matrix-attribute.vert new file mode 100644 index 0000000000..8a1393f8d6 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/vert/matrix-output.vert b/deps/SPIRV-Cross/shaders-hlsl/vert/matrix-output.vert new file mode 100644 index 0000000000..1151d4bd32 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/vert/no-input.vert b/deps/SPIRV-Cross/shaders-hlsl/vert/no-input.vert new file mode 100644 index 0000000000..8de8e816a0 --- /dev/null +++ b/deps/SPIRV-Cross/shaders-hlsl/vert/no-input.vert @@ -0,0 +1,6 @@ +#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 new file mode 100644 index 0000000000..64eff36315 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/vert/qualifiers.vert b/deps/SPIRV-Cross/shaders-hlsl/vert/qualifiers.vert new file mode 100644 index 0000000000..080a70915c --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/vert/sampler-buffers.vert b/deps/SPIRV-Cross/shaders-hlsl/vert/sampler-buffers.vert new file mode 100644 index 0000000000..dccbf77849 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/vert/struct-composite-decl.vert b/deps/SPIRV-Cross/shaders-hlsl/vert/struct-composite-decl.vert new file mode 100644 index 0000000000..c527fdf518 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-hlsl/vert/texture_buffer.vert b/deps/SPIRV-Cross/shaders-hlsl/vert/texture_buffer.vert new file mode 100644 index 0000000000..b071e0c966 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl-no-opt/vert/functions_nested.vert b/deps/SPIRV-Cross/shaders-msl-no-opt/vert/functions_nested.vert new file mode 100644 index 0000000000..2eec5ac551 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/asm/comp/bitcast_iadd.asm.comp b/deps/SPIRV-Cross/shaders-msl/asm/comp/bitcast_iadd.asm.comp new file mode 100644 index 0000000000..3b31ab2851 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/asm/comp/bitcast_sar.asm.comp b/deps/SPIRV-Cross/shaders-msl/asm/comp/bitcast_sar.asm.comp new file mode 100644 index 0000000000..64f19fc349 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/asm/comp/bitcast_udiv.asm.comp b/deps/SPIRV-Cross/shaders-msl/asm/comp/bitcast_sdiv.asm.comp similarity index 84% rename from deps/SPIRV-Cross/shaders/asm/comp/bitcast_udiv.asm.comp rename to deps/SPIRV-Cross/shaders-msl/asm/comp/bitcast_sdiv.asm.comp index 090f37e8d3..ab73ec83df 100644 --- a/deps/SPIRV-Cross/shaders/asm/comp/bitcast_udiv.asm.comp +++ b/deps/SPIRV-Cross/shaders-msl/asm/comp/bitcast_sdiv.asm.comp @@ -55,15 +55,15 @@ %output_ptr_uvec4 = OpAccessChain %uvec4_ptr %outputs %zero %output_ptr_ivec4 = OpAccessChain %ivec4_ptr %outputs %one -; Test all variants of UDiv - %result_iadd_0 = OpUDiv %uvec4 %input0 %input1 - %result_iadd_1 = OpUDiv %uvec4 %input1 %input0 - %result_iadd_2 = OpUDiv %uvec4 %input0 %input0 - %result_iadd_3 = OpUDiv %uvec4 %input1 %input1 - %result_iadd_4 = OpUDiv %ivec4 %input0 %input0 - %result_iadd_5 = OpUDiv %ivec4 %input1 %input1 - %result_iadd_6 = OpUDiv %ivec4 %input0 %input1 - %result_iadd_7 = OpUDiv %ivec4 %input1 %input0 +; 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 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 new file mode 100644 index 0000000000..6741f5cb58 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/asm/comp/multiple-entry.asm.comp b/deps/SPIRV-Cross/shaders-msl/asm/comp/multiple-entry.asm.comp new file mode 100644 index 0000000000..0cfb5543d1 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/asm/comp/quantize.asm.comp b/deps/SPIRV-Cross/shaders-msl/asm/comp/quantize.asm.comp new file mode 100644 index 0000000000..f5afc6570c --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..188e3fec36 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..bdf2027a80 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..4d616fe493 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..8b09e5b68f --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..61d2e579c8 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..74c46b4af8 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..966c2d9d5a --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/asm/frag/unreachable.asm.frag b/deps/SPIRV-Cross/shaders-msl/asm/frag/unreachable.asm.frag new file mode 100644 index 0000000000..e2ce2eb56a --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..d60c6f52d4 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..37a2d87937 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/comp/atomic.comp b/deps/SPIRV-Cross/shaders-msl/comp/atomic.comp new file mode 100644 index 0000000000..417284d5de --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/comp/barriers.comp b/deps/SPIRV-Cross/shaders-msl/comp/barriers.comp new file mode 100644 index 0000000000..c49b626363 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/comp/basic.comp b/deps/SPIRV-Cross/shaders-msl/comp/basic.comp new file mode 100644 index 0000000000..f9bf55670f --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/comp/bitfield.noopt.comp b/deps/SPIRV-Cross/shaders-msl/comp/bitfield.noopt.comp new file mode 100644 index 0000000000..0cac0b257c --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/comp/builtins.comp b/deps/SPIRV-Cross/shaders-msl/comp/builtins.comp new file mode 100644 index 0000000000..88bb5951e4 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/comp/cfg-preserve-parameter.comp b/deps/SPIRV-Cross/shaders-msl/comp/cfg-preserve-parameter.comp new file mode 100644 index 0000000000..9ef9092005 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/comp/coherent-block.comp b/deps/SPIRV-Cross/shaders-msl/comp/coherent-block.comp new file mode 100644 index 0000000000..0a174e8ef0 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/comp/coherent-image.comp b/deps/SPIRV-Cross/shaders-msl/comp/coherent-image.comp new file mode 100644 index 0000000000..fd6e280182 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/comp/culling.comp b/deps/SPIRV-Cross/shaders-msl/comp/culling.comp new file mode 100644 index 0000000000..9f8331b10b --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/comp/defer-parens.comp b/deps/SPIRV-Cross/shaders-msl/comp/defer-parens.comp new file mode 100644 index 0000000000..4e8ea6b399 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/comp/dowhile.comp b/deps/SPIRV-Cross/shaders-msl/comp/dowhile.comp new file mode 100644 index 0000000000..709db75a17 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/comp/functions.comp b/deps/SPIRV-Cross/shaders-msl/comp/functions.comp new file mode 100644 index 0000000000..478c8ebe83 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..2fe074df7c --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/comp/global-invocation-id.comp b/deps/SPIRV-Cross/shaders-msl/comp/global-invocation-id.comp new file mode 100644 index 0000000000..f484637e1f --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/comp/image.comp b/deps/SPIRV-Cross/shaders-msl/comp/image.comp new file mode 100644 index 0000000000..e375534a51 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/comp/insert.comp b/deps/SPIRV-Cross/shaders-msl/comp/insert.comp new file mode 100644 index 0000000000..07c1f8d7aa --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/comp/local-invocation-id.comp b/deps/SPIRV-Cross/shaders-msl/comp/local-invocation-id.comp new file mode 100644 index 0000000000..281700f197 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/comp/local-invocation-index.comp b/deps/SPIRV-Cross/shaders-msl/comp/local-invocation-index.comp new file mode 100644 index 0000000000..68942da8e1 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/comp/loop.comp b/deps/SPIRV-Cross/shaders-msl/comp/loop.noopt.comp similarity index 100% rename from deps/SPIRV-Cross/shaders/comp/loop.comp rename to deps/SPIRV-Cross/shaders-msl/comp/loop.noopt.comp diff --git a/deps/SPIRV-Cross/shaders-msl/comp/mat3.comp b/deps/SPIRV-Cross/shaders-msl/comp/mat3.comp new file mode 100644 index 0000000000..7c5bb1e4f5 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/comp/mod.comp b/deps/SPIRV-Cross/shaders-msl/comp/mod.comp new file mode 100644 index 0000000000..1631456e30 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/comp/modf.comp b/deps/SPIRV-Cross/shaders-msl/comp/modf.comp new file mode 100644 index 0000000000..edadefcf05 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/comp/read-write-only.comp b/deps/SPIRV-Cross/shaders-msl/comp/read-write-only.comp new file mode 100644 index 0000000000..b224b6f121 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/comp/return.comp b/deps/SPIRV-Cross/shaders-msl/comp/return.comp new file mode 100644 index 0000000000..617f437182 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/comp/rmw-opt.comp b/deps/SPIRV-Cross/shaders-msl/comp/rmw-opt.comp new file mode 100644 index 0000000000..a6e1e7fe75 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/comp/shared.comp b/deps/SPIRV-Cross/shaders-msl/comp/shared.comp new file mode 100644 index 0000000000..4deff93597 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/comp/struct-layout.comp b/deps/SPIRV-Cross/shaders-msl/comp/struct-layout.comp new file mode 100644 index 0000000000..5a2b7802df --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/comp/struct-packing.comp b/deps/SPIRV-Cross/shaders-msl/comp/struct-packing.comp new file mode 100644 index 0000000000..04b933dd18 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/comp/torture-loop.comp b/deps/SPIRV-Cross/shaders-msl/comp/torture-loop.comp new file mode 100644 index 0000000000..54a1221a15 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/comp/type-alias.comp b/deps/SPIRV-Cross/shaders-msl/comp/type-alias.comp new file mode 100644 index 0000000000..343d350a2f --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/comp/udiv.comp b/deps/SPIRV-Cross/shaders-msl/comp/udiv.comp new file mode 100644 index 0000000000..33fe564f07 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/comp/writable-ssbo.comp b/deps/SPIRV-Cross/shaders-msl/comp/writable-ssbo.comp new file mode 100644 index 0000000000..1d5128ce8a --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..e145cb8f00 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..4a80cbf81f --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..4c30ed1529 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..9ddab08cda --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..9e4a0b7ac9 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/flatten/basic.flatten.vert b/deps/SPIRV-Cross/shaders-msl/flatten/basic.flatten.vert new file mode 100644 index 0000000000..e60a9067b1 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/flatten/multiindex.flatten.vert b/deps/SPIRV-Cross/shaders-msl/flatten/multiindex.flatten.vert new file mode 100644 index 0000000000..0b471d86e0 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/flatten/push-constant.flatten.vert b/deps/SPIRV-Cross/shaders-msl/flatten/push-constant.flatten.vert new file mode 100644 index 0000000000..c7b1b42e1b --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/flatten/rowmajor.flatten.vert b/deps/SPIRV-Cross/shaders-msl/flatten/rowmajor.flatten.vert new file mode 100644 index 0000000000..88c468c8f2 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/flatten/struct.flatten.vert b/deps/SPIRV-Cross/shaders-msl/flatten/struct.flatten.vert new file mode 100644 index 0000000000..936bb41b85 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/flatten/swizzle.flatten.vert b/deps/SPIRV-Cross/shaders-msl/flatten/swizzle.flatten.vert new file mode 100644 index 0000000000..e310cdf336 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/flatten/types.flatten.frag b/deps/SPIRV-Cross/shaders-msl/flatten/types.flatten.frag new file mode 100644 index 0000000000..faab5b7e05 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/frag/basic.frag b/deps/SPIRV-Cross/shaders-msl/frag/basic.frag new file mode 100644 index 0000000000..dd9a8f8507 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/frag/bitcasting.frag b/deps/SPIRV-Cross/shaders-msl/frag/bitcasting.frag new file mode 100644 index 0000000000..5dac78ef33 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/frag/builtins.frag b/deps/SPIRV-Cross/shaders-msl/frag/builtins.frag new file mode 100644 index 0000000000..99e6e2df5b --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/frag/composite-extract-forced-temporary.frag b/deps/SPIRV-Cross/shaders-msl/frag/composite-extract-forced-temporary.frag new file mode 100644 index 0000000000..35fdbe8624 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/frag/constant-array.frag b/deps/SPIRV-Cross/shaders-msl/frag/constant-array.frag new file mode 100644 index 0000000000..b862cb1dbf --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/frag/false-loop-init.frag b/deps/SPIRV-Cross/shaders-msl/frag/false-loop-init.frag new file mode 100644 index 0000000000..7ce5b52bd7 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/frag/flush_params.frag b/deps/SPIRV-Cross/shaders-msl/frag/flush_params.frag new file mode 100644 index 0000000000..8a26ad3a28 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/frag/for-loop-init.frag b/deps/SPIRV-Cross/shaders-msl/frag/for-loop-init.frag new file mode 100644 index 0000000000..0cde26765e --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/frag/in_block.frag b/deps/SPIRV-Cross/shaders-msl/frag/in_block.frag new file mode 100644 index 0000000000..59b97074ec --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/frag/in_block_assign.noopt.frag b/deps/SPIRV-Cross/shaders-msl/frag/in_block_assign.noopt.frag new file mode 100644 index 0000000000..760a3ba2d3 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/frag/mix.frag b/deps/SPIRV-Cross/shaders-msl/frag/mix.frag new file mode 100644 index 0000000000..a5d589dd08 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/frag/pls.frag b/deps/SPIRV-Cross/shaders-msl/frag/pls.frag new file mode 100644 index 0000000000..e3863e4e0e --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/frag/sampler-ms.frag b/deps/SPIRV-Cross/shaders-msl/frag/sampler-ms.frag new file mode 100644 index 0000000000..6593928271 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/frag/sampler.frag b/deps/SPIRV-Cross/shaders-msl/frag/sampler.frag new file mode 100644 index 0000000000..e38f76886a --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/frag/separate-image-sampler-argument.frag b/deps/SPIRV-Cross/shaders-msl/frag/separate-image-sampler-argument.frag new file mode 100644 index 0000000000..0475b019d2 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/frag/swizzle.frag b/deps/SPIRV-Cross/shaders-msl/frag/swizzle.frag new file mode 100644 index 0000000000..271ba6cb64 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/frag/texture-proj-shadow.frag b/deps/SPIRV-Cross/shaders-msl/frag/texture-proj-shadow.frag new file mode 100644 index 0000000000..547532e648 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/frag/ubo_layout.frag b/deps/SPIRV-Cross/shaders-msl/frag/ubo_layout.frag new file mode 100644 index 0000000000..80f9f16d3d --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/frag/unary-enclose.frag b/deps/SPIRV-Cross/shaders-msl/frag/unary-enclose.frag new file mode 100644 index 0000000000..ea502e1de8 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/legacy/vert/transpose.legacy.vert b/deps/SPIRV-Cross/shaders-msl/legacy/vert/transpose.legacy.vert new file mode 100644 index 0000000000..84f618262a --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/vert/basic.vert b/deps/SPIRV-Cross/shaders-msl/vert/basic.vert new file mode 100644 index 0000000000..8191dc2d0f --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/vert/copy.flatten.vert b/deps/SPIRV-Cross/shaders-msl/vert/copy.flatten.vert new file mode 100644 index 0000000000..4f1b8805e7 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/vert/dynamic.flatten.vert b/deps/SPIRV-Cross/shaders-msl/vert/dynamic.flatten.vert new file mode 100644 index 0000000000..a341d45288 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/vert/functions.vert b/deps/SPIRV-Cross/shaders-msl/vert/functions.vert new file mode 100644 index 0000000000..b92074f465 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/vert/out_block.vert b/deps/SPIRV-Cross/shaders-msl/vert/out_block.vert new file mode 100644 index 0000000000..d7a50c783d --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/vert/pointsize.vert b/deps/SPIRV-Cross/shaders-msl/vert/pointsize.vert new file mode 100644 index 0000000000..0fc7136387 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/vert/texture_buffer.vert b/deps/SPIRV-Cross/shaders-msl/vert/texture_buffer.vert new file mode 100644 index 0000000000..6bc7ddfae2 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/vert/ubo.alignment.vert b/deps/SPIRV-Cross/shaders-msl/vert/ubo.alignment.vert new file mode 100644 index 0000000000..2e9d16df43 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/vert/ubo.vert b/deps/SPIRV-Cross/shaders-msl/vert/ubo.vert new file mode 100644 index 0000000000..82e4626e12 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/vulkan/frag/push-constant.vk.frag b/deps/SPIRV-Cross/shaders-msl/vulkan/frag/push-constant.vk.frag new file mode 100644 index 0000000000..6180faba31 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/vulkan/frag/spec-constant.vk.frag b/deps/SPIRV-Cross/shaders-msl/vulkan/frag/spec-constant.vk.frag new file mode 100644 index 0000000000..3cb75da5c0 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders-msl/vulkan/vert/vulkan-vertex.vk.vert b/deps/SPIRV-Cross/shaders-msl/vulkan/vert/vulkan-vertex.vk.vert new file mode 100644 index 0000000000..4d0438ace6 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag b/deps/SPIRV-Cross/shaders/amd/fragmentMaskFetch_subpassInput.vk.nocompat.invalid.frag new file mode 100644 index 0000000000..a3f03664ca --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/amd/fs.invalid.frag b/deps/SPIRV-Cross/shaders/amd/fs.invalid.frag new file mode 100644 index 0000000000..8cbd73e336 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/amd/gcn_shader.comp b/deps/SPIRV-Cross/shaders/amd/gcn_shader.comp new file mode 100644 index 0000000000..037cdde6b6 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/amd/shader_ballot.comp b/deps/SPIRV-Cross/shaders/amd/shader_ballot.comp new file mode 100644 index 0000000000..d2a7271128 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/amd/shader_ballot_nonuniform_invocations.invalid.comp b/deps/SPIRV-Cross/shaders/amd/shader_ballot_nonuniform_invocations.invalid.comp new file mode 100644 index 0000000000..afcc31d99e --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/amd/shader_group_vote.comp b/deps/SPIRV-Cross/shaders/amd/shader_group_vote.comp new file mode 100644 index 0000000000..d24aa92f84 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/amd/shader_trinary_minmax.comp b/deps/SPIRV-Cross/shaders/amd/shader_trinary_minmax.comp new file mode 100644 index 0000000000..f836146a17 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/asm/comp/logical.asm.comp b/deps/SPIRV-Cross/shaders/asm/comp/logical.asm.comp new file mode 100644 index 0000000000..4174e77f3d --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/asm/comp/specialization-constant-workgroup.asm.comp b/deps/SPIRV-Cross/shaders/asm/comp/specialization-constant-workgroup.asm.comp new file mode 100644 index 0000000000..188e3fec36 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/asm/comp/storage-buffer-basic.asm.comp b/deps/SPIRV-Cross/shaders/asm/comp/storage-buffer-basic.asm.comp new file mode 100644 index 0000000000..edb1a05e54 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..f33c48617a --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/asm/frag/default-member-names.asm.frag b/deps/SPIRV-Cross/shaders/asm/frag/default-member-names.asm.frag new file mode 100644 index 0000000000..4d616fe493 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..2be18cfeeb --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..34fb6e834b --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..8b09e5b68f --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/asm/frag/invalidation.asm.frag b/deps/SPIRV-Cross/shaders/asm/frag/invalidation.asm.frag index 1c171b6d27..8e753d50fe 100644 --- a/deps/SPIRV-Cross/shaders/asm/frag/invalidation.asm.frag +++ b/deps/SPIRV-Cross/shaders/asm/frag/invalidation.asm.frag @@ -15,6 +15,9 @@ 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 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 new file mode 100644 index 0000000000..fa53940b14 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..d74f7ce568 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/asm/frag/op-constant-null.asm.frag b/deps/SPIRV-Cross/shaders/asm/frag/op-constant-null.asm.frag new file mode 100644 index 0000000000..61d2e579c8 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/asm/frag/phi-loop-variable.asm.frag b/deps/SPIRV-Cross/shaders/asm/frag/phi-loop-variable.asm.frag new file mode 100644 index 0000000000..74c46b4af8 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..9c08fc2830 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..33bd1c9163 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/asm/frag/temporary-phi-hoisting.asm.frag b/deps/SPIRV-Cross/shaders/asm/frag/temporary-phi-hoisting.asm.frag new file mode 100644 index 0000000000..7cedcd5819 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/asm/frag/undef-variable-store.asm.frag b/deps/SPIRV-Cross/shaders/asm/frag/undef-variable-store.asm.frag new file mode 100644 index 0000000000..966c2d9d5a --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/asm/frag/unreachable.asm.frag b/deps/SPIRV-Cross/shaders/asm/frag/unreachable.asm.frag new file mode 100644 index 0000000000..e2ce2eb56a --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/asm/frag/vector-shuffle-oom.asm.frag b/deps/SPIRV-Cross/shaders/asm/frag/vector-shuffle-oom.asm.frag new file mode 100644 index 0000000000..d60c6f52d4 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..0fd4dce256 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/asm/vert/empty-io.asm.vert b/deps/SPIRV-Cross/shaders/asm/vert/empty-io.asm.vert new file mode 100644 index 0000000000..0ba6cb7963 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/asm/vert/empty-struct-composite.asm.vert b/deps/SPIRV-Cross/shaders/asm/vert/empty-struct-composite.asm.vert new file mode 100644 index 0000000000..37a2d87937 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/asm/vert/global-builtin.sso.asm.vert b/deps/SPIRV-Cross/shaders/asm/vert/global-builtin.sso.asm.vert new file mode 100644 index 0000000000..d7306deb24 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/comp/barriers.comp b/deps/SPIRV-Cross/shaders/comp/barriers.comp new file mode 100644 index 0000000000..7e0ea42d4e --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/comp/bitfield.noopt.comp b/deps/SPIRV-Cross/shaders/comp/bitfield.noopt.comp new file mode 100644 index 0000000000..d75b556b62 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/comp/cfg-preserve-parameter.comp b/deps/SPIRV-Cross/shaders/comp/cfg-preserve-parameter.comp new file mode 100644 index 0000000000..9ef9092005 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/comp/coherent-block.comp b/deps/SPIRV-Cross/shaders/comp/coherent-block.comp new file mode 100644 index 0000000000..0a174e8ef0 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/comp/coherent-image.comp b/deps/SPIRV-Cross/shaders/comp/coherent-image.comp new file mode 100644 index 0000000000..fd6e280182 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/comp/loop.noopt.comp b/deps/SPIRV-Cross/shaders/comp/loop.noopt.comp new file mode 100644 index 0000000000..6d6c324243 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/comp/read-write-only.comp b/deps/SPIRV-Cross/shaders/comp/read-write-only.comp new file mode 100644 index 0000000000..b224b6f121 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/comp/rmw-opt.comp b/deps/SPIRV-Cross/shaders/comp/rmw-opt.comp new file mode 100644 index 0000000000..a6e1e7fe75 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/comp/struct-packing.comp b/deps/SPIRV-Cross/shaders/comp/struct-packing.comp index 04b933dd18..53a54e4927 100644 --- a/deps/SPIRV-Cross/shaders/comp/struct-packing.comp +++ b/deps/SPIRV-Cross/shaders/comp/struct-packing.comp @@ -66,6 +66,16 @@ 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; diff --git a/deps/SPIRV-Cross/shaders/desktop-only/comp/enhanced-layouts.comp b/deps/SPIRV-Cross/shaders/desktop-only/comp/enhanced-layouts.comp new file mode 100644 index 0000000000..470b73e9bd --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..1c6dd7b8b7 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/desktop-only/frag/image-query.desktop.frag b/deps/SPIRV-Cross/shaders/desktop-only/frag/image-query.desktop.frag new file mode 100644 index 0000000000..a5cbe011e2 --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..0c4cf8f5a8 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/desktop-only/geom/basic.desktop.sso.geom b/deps/SPIRV-Cross/shaders/desktop-only/geom/basic.desktop.sso.geom new file mode 100644 index 0000000000..f3d331dd15 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/desktop-only/geom/viewport-index.desktop.geom b/deps/SPIRV-Cross/shaders/desktop-only/geom/viewport-index.desktop.geom new file mode 100644 index 0000000000..e02e81daf6 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/desktop-only/tesc/basic.desktop.sso.tesc b/deps/SPIRV-Cross/shaders/desktop-only/tesc/basic.desktop.sso.tesc new file mode 100644 index 0000000000..8ff739b0af --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/desktop-only/tese/triangle.desktop.sso.tese b/deps/SPIRV-Cross/shaders/desktop-only/tese/triangle.desktop.sso.tese new file mode 100644 index 0000000000..c964fbe263 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/desktop-only/vert/basic.desktop.sso.vert b/deps/SPIRV-Cross/shaders/desktop-only/vert/basic.desktop.sso.vert new file mode 100644 index 0000000000..9ddab08cda --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..9e4a0b7ac9 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/flatten/array.flatten.vert b/deps/SPIRV-Cross/shaders/flatten/array.flatten.vert new file mode 100644 index 0000000000..fa6da076c9 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/flatten/basic.flatten.vert b/deps/SPIRV-Cross/shaders/flatten/basic.flatten.vert new file mode 100644 index 0000000000..e60a9067b1 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/flatten/copy.flatten.vert b/deps/SPIRV-Cross/shaders/flatten/copy.flatten.vert new file mode 100644 index 0000000000..4f1b8805e7 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/flatten/dynamic.flatten.vert b/deps/SPIRV-Cross/shaders/flatten/dynamic.flatten.vert new file mode 100644 index 0000000000..a341d45288 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/flatten/matrixindex.flatten.vert b/deps/SPIRV-Cross/shaders/flatten/matrixindex.flatten.vert new file mode 100644 index 0000000000..0ee7838432 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/flatten/multi-dimensional.desktop.flatten_dim.frag b/deps/SPIRV-Cross/shaders/flatten/multi-dimensional.desktop.flatten_dim.frag new file mode 100644 index 0000000000..24b2ff1d2a --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/flatten/multiindex.flatten.vert b/deps/SPIRV-Cross/shaders/flatten/multiindex.flatten.vert new file mode 100644 index 0000000000..0b471d86e0 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/flatten/push-constant.flatten.vert b/deps/SPIRV-Cross/shaders/flatten/push-constant.flatten.vert new file mode 100644 index 0000000000..c7b1b42e1b --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/flatten/rowmajor.flatten.vert b/deps/SPIRV-Cross/shaders/flatten/rowmajor.flatten.vert new file mode 100644 index 0000000000..88c468c8f2 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/flatten/struct.flatten.vert b/deps/SPIRV-Cross/shaders/flatten/struct.flatten.vert new file mode 100644 index 0000000000..936bb41b85 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/flatten/struct.rowmajor.flatten.vert b/deps/SPIRV-Cross/shaders/flatten/struct.rowmajor.flatten.vert new file mode 100644 index 0000000000..231389b8f4 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/flatten/swizzle.flatten.vert b/deps/SPIRV-Cross/shaders/flatten/swizzle.flatten.vert new file mode 100644 index 0000000000..fafff7734e --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/flatten/types.flatten.frag b/deps/SPIRV-Cross/shaders/flatten/types.flatten.frag new file mode 100644 index 0000000000..faab5b7e05 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/frag/basic.frag b/deps/SPIRV-Cross/shaders/frag/basic.frag index 7c3ad20ba4..dd9a8f8507 100644 --- a/deps/SPIRV-Cross/shaders/frag/basic.frag +++ b/deps/SPIRV-Cross/shaders/frag/basic.frag @@ -1,8 +1,8 @@ #version 310 es precision mediump float; -in vec4 vColor; -in vec2 vTex; +layout(location = 0) in vec4 vColor; +layout(location = 1) in vec2 vTex; layout(binding = 0) uniform sampler2D uTex; layout(location = 0) out vec4 FragColor; diff --git a/deps/SPIRV-Cross/shaders/frag/false-loop-init.frag b/deps/SPIRV-Cross/shaders/frag/false-loop-init.frag new file mode 100644 index 0000000000..7ce5b52bd7 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/frag/frexp-modf.frag b/deps/SPIRV-Cross/shaders/frag/frexp-modf.frag new file mode 100644 index 0000000000..6a26a4175f --- /dev/null +++ b/deps/SPIRV-Cross/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/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 new file mode 100644 index 0000000000..a9bf1a7497 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/frag/partial-write-preserve.frag b/deps/SPIRV-Cross/shaders/frag/partial-write-preserve.frag new file mode 100644 index 0000000000..227df95086 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/frag/pls.frag b/deps/SPIRV-Cross/shaders/frag/pls.frag index 314fd99427..e3863e4e0e 100644 --- a/deps/SPIRV-Cross/shaders/frag/pls.frag +++ b/deps/SPIRV-Cross/shaders/frag/pls.frag @@ -3,8 +3,8 @@ precision mediump float; layout(location = 0) in vec4 PLSIn0; layout(location = 1) in vec4 PLSIn1; -in vec4 PLSIn2; -in vec4 PLSIn3; +layout(location = 2) in vec4 PLSIn2; +layout(location = 3) in vec4 PLSIn3; layout(location = 0) out vec4 PLSOut0; layout(location = 1) out vec4 PLSOut1; diff --git a/deps/SPIRV-Cross/shaders/frag/sample-parameter.frag b/deps/SPIRV-Cross/shaders/frag/sample-parameter.frag new file mode 100644 index 0000000000..8470bfd672 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/frag/sampler-proj.frag b/deps/SPIRV-Cross/shaders/frag/sampler-proj.frag new file mode 100644 index 0000000000..21fa5c0260 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/frag/sampler.frag b/deps/SPIRV-Cross/shaders/frag/sampler.frag index fb4292f2e7..e38f76886a 100644 --- a/deps/SPIRV-Cross/shaders/frag/sampler.frag +++ b/deps/SPIRV-Cross/shaders/frag/sampler.frag @@ -1,8 +1,8 @@ #version 310 es precision mediump float; -in vec4 vColor; -in vec2 vTex; +layout(location = 0) in vec4 vColor; +layout(location = 1) in vec2 vTex; layout(binding = 0) uniform sampler2D uTex; layout(location = 0) out vec4 FragColor; diff --git a/deps/SPIRV-Cross/shaders/frag/unary-enclose.frag b/deps/SPIRV-Cross/shaders/frag/unary-enclose.frag new file mode 100644 index 0000000000..ea502e1de8 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/geom/basic.geom b/deps/SPIRV-Cross/shaders/geom/basic.geom index de5f515836..80b977d114 100644 --- a/deps/SPIRV-Cross/shaders/geom/basic.geom +++ b/deps/SPIRV-Cross/shaders/geom/basic.geom @@ -4,11 +4,11 @@ layout(triangles, invocations = 4) in; layout(triangle_strip, max_vertices = 3) out; -in VertexData { +layout(location = 0) in VertexData { vec3 normal; } vin[]; -out vec3 vNormal; +layout(location = 0) out vec3 vNormal; void main() { diff --git a/deps/SPIRV-Cross/shaders/geom/lines-adjacency.geom b/deps/SPIRV-Cross/shaders/geom/lines-adjacency.geom index 1c184505b5..4c34440737 100644 --- a/deps/SPIRV-Cross/shaders/geom/lines-adjacency.geom +++ b/deps/SPIRV-Cross/shaders/geom/lines-adjacency.geom @@ -4,11 +4,11 @@ layout(lines_adjacency) in; layout(line_strip, max_vertices = 3) out; -in VertexData { +layout(location = 0) in VertexData { vec3 normal; } vin[]; -out vec3 vNormal; +layout(location = 0) out vec3 vNormal; void main() { diff --git a/deps/SPIRV-Cross/shaders/geom/lines.geom b/deps/SPIRV-Cross/shaders/geom/lines.geom index 4d5a0d7e7a..c751d5cda4 100644 --- a/deps/SPIRV-Cross/shaders/geom/lines.geom +++ b/deps/SPIRV-Cross/shaders/geom/lines.geom @@ -4,11 +4,11 @@ layout(lines) in; layout(line_strip, max_vertices = 2) out; -in VertexData { +layout(location = 0) in VertexData { vec3 normal; } vin[]; -out vec3 vNormal; +layout(location = 0) out vec3 vNormal; void main() { diff --git a/deps/SPIRV-Cross/shaders/geom/points.geom b/deps/SPIRV-Cross/shaders/geom/points.geom index d416e5e826..f7dce10d7f 100644 --- a/deps/SPIRV-Cross/shaders/geom/points.geom +++ b/deps/SPIRV-Cross/shaders/geom/points.geom @@ -4,11 +4,11 @@ layout(points) in; layout(points, max_vertices = 3) out; -in VertexData { +layout(location = 0) in VertexData { vec3 normal; } vin[]; -out vec3 vNormal; +layout(location = 0) out vec3 vNormal; void main() { diff --git a/deps/SPIRV-Cross/shaders/geom/single-invocation.geom b/deps/SPIRV-Cross/shaders/geom/single-invocation.geom index 92f60011ca..c3c8d1526f 100644 --- a/deps/SPIRV-Cross/shaders/geom/single-invocation.geom +++ b/deps/SPIRV-Cross/shaders/geom/single-invocation.geom @@ -4,11 +4,11 @@ layout(triangles) in; layout(triangle_strip, max_vertices = 3) out; -in VertexData { +layout(location = 0) in VertexData { vec3 normal; } vin[]; -out vec3 vNormal; +layout(location = 0) out vec3 vNormal; void main() { diff --git a/deps/SPIRV-Cross/shaders/geom/triangles-adjacency.geom b/deps/SPIRV-Cross/shaders/geom/triangles-adjacency.geom index 02040ebfb9..017cef7b52 100644 --- a/deps/SPIRV-Cross/shaders/geom/triangles-adjacency.geom +++ b/deps/SPIRV-Cross/shaders/geom/triangles-adjacency.geom @@ -4,11 +4,11 @@ layout(triangles_adjacency) in; layout(triangle_strip, max_vertices = 3) out; -in VertexData { +layout(location = 0) in VertexData { vec3 normal; } vin[]; -out vec3 vNormal; +layout(location = 0) out vec3 vNormal; void main() { diff --git a/deps/SPIRV-Cross/shaders/geom/triangles.geom b/deps/SPIRV-Cross/shaders/geom/triangles.geom index 92f60011ca..c3c8d1526f 100644 --- a/deps/SPIRV-Cross/shaders/geom/triangles.geom +++ b/deps/SPIRV-Cross/shaders/geom/triangles.geom @@ -4,11 +4,11 @@ layout(triangles) in; layout(triangle_strip, max_vertices = 3) out; -in VertexData { +layout(location = 0) in VertexData { vec3 normal; } vin[]; -out vec3 vNormal; +layout(location = 0) out vec3 vNormal; void main() { diff --git a/deps/SPIRV-Cross/shaders/legacy/fragment/explicit-lod.legacy.frag b/deps/SPIRV-Cross/shaders/legacy/fragment/explicit-lod.legacy.frag new file mode 100644 index 0000000000..5a2eeb9913 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/legacy/fragment/io-blocks.legacy.frag b/deps/SPIRV-Cross/shaders/legacy/fragment/io-blocks.legacy.frag new file mode 100644 index 0000000000..0a151dc2d6 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/legacy/fragment/struct-varying.legacy.frag b/deps/SPIRV-Cross/shaders/legacy/fragment/struct-varying.legacy.frag new file mode 100644 index 0000000000..5df5c87704 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/legacy/vert/implicit-lod.legacy.vert b/deps/SPIRV-Cross/shaders/legacy/vert/implicit-lod.legacy.vert new file mode 100644 index 0000000000..1f32faebdc --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/legacy/vert/io-block.legacy.vert b/deps/SPIRV-Cross/shaders/legacy/vert/io-block.legacy.vert new file mode 100644 index 0000000000..4fbc9347cf --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/legacy/vert/struct-varying.legacy.vert b/deps/SPIRV-Cross/shaders/legacy/vert/struct-varying.legacy.vert new file mode 100644 index 0000000000..3f491be831 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/legacy/vert/transpose.legacy.vert b/deps/SPIRV-Cross/shaders/legacy/vert/transpose.legacy.vert new file mode 100644 index 0000000000..84f618262a --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/tesc/basic.tesc b/deps/SPIRV-Cross/shaders/tesc/basic.tesc index 1a0e1d6cc8..0a41f98c83 100644 --- a/deps/SPIRV-Cross/shaders/tesc/basic.tesc +++ b/deps/SPIRV-Cross/shaders/tesc/basic.tesc @@ -1,7 +1,7 @@ #version 310 es #extension GL_EXT_tessellation_shader : require -patch out vec3 vFoo; +layout(location = 0) patch out vec3 vFoo; layout(vertices = 1) out; diff --git a/deps/SPIRV-Cross/shaders/tesc/water_tess.tesc b/deps/SPIRV-Cross/shaders/tesc/water_tess.tesc index 9e9c0d477e..3ecdc3d1a9 100644 --- a/deps/SPIRV-Cross/shaders/tesc/water_tess.tesc +++ b/deps/SPIRV-Cross/shaders/tesc/water_tess.tesc @@ -2,7 +2,7 @@ #extension GL_EXT_tessellation_shader : require layout(vertices = 1) out; -in vec2 vPatchPosBase[]; +layout(location = 0) in vec2 vPatchPosBase[]; layout(std140) uniform UBO { @@ -14,8 +14,8 @@ layout(std140) uniform UBO vec4 uFrustum[6]; }; -patch out vec2 vOutPatchPosBase; -patch out vec4 vPatchLods; +layout(location = 1) patch out vec2 vOutPatchPosBase; +layout(location = 2) patch out vec4 vPatchLods; float lod_factor(vec2 pos_) { diff --git a/deps/SPIRV-Cross/shaders/tese/water_tess.tese b/deps/SPIRV-Cross/shaders/tese/water_tess.tese index f9628b1e18..32d6bc9391 100644 --- a/deps/SPIRV-Cross/shaders/tese/water_tess.tese +++ b/deps/SPIRV-Cross/shaders/tese/water_tess.tese @@ -4,8 +4,8 @@ precision highp int; layout(cw, quads, fractional_even_spacing) in; -patch in vec2 vOutPatchPosBase; -patch in vec4 vPatchLods; +layout(location = 0) patch in vec2 vOutPatchPosBase; +layout(location = 1) patch in vec4 vPatchLods; layout(binding = 1, std140) uniform UBO { @@ -18,8 +18,8 @@ layout(binding = 1, std140) uniform UBO }; layout(binding = 0) uniform mediump sampler2D uHeightmapDisplacement; -highp out vec3 vWorld; -highp out vec4 vGradNormalTex; +layout(location = 0) highp out vec3 vWorld; +layout(location = 1) highp out vec4 vGradNormalTex; vec2 lerp_vertex(vec2 tess_coord) { diff --git a/deps/SPIRV-Cross/shaders/vert/basic.vert b/deps/SPIRV-Cross/shaders/vert/basic.vert index 801724f325..2c75d44a43 100644 --- a/deps/SPIRV-Cross/shaders/vert/basic.vert +++ b/deps/SPIRV-Cross/shaders/vert/basic.vert @@ -4,9 +4,10 @@ layout(std140) uniform UBO { uniform mat4 uMVP; }; -in vec4 aVertex; -in vec3 aNormal; -out vec3 vNormal; + +layout(location = 0) in vec4 aVertex; +layout(location = 1) in vec3 aNormal; +layout(location = 0) out vec3 vNormal; void main() { diff --git a/deps/SPIRV-Cross/shaders/vert/ubo.vert b/deps/SPIRV-Cross/shaders/vert/ubo.vert index f304c1e561..82e4626e12 100644 --- a/deps/SPIRV-Cross/shaders/vert/ubo.vert +++ b/deps/SPIRV-Cross/shaders/vert/ubo.vert @@ -5,9 +5,9 @@ layout(binding = 0, std140) uniform UBO mat4 mvp; }; -in vec4 aVertex; -in vec3 aNormal; -out vec3 vNormal; +layout(location = 0) in vec4 aVertex; +layout(location = 1) in vec3 aNormal; +layout(location = 0) out vec3 vNormal; void main() { 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 new file mode 100644 index 0000000000..2fabb5ea8a --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/vulkan/frag/desktop-mediump.vk.frag b/deps/SPIRV-Cross/shaders/vulkan/frag/desktop-mediump.vk.frag new file mode 100644 index 0000000000..23fe3d3da0 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/shaders/vulkan/frag/input-attachment-ms.vk.frag b/deps/SPIRV-Cross/shaders/vulkan/frag/input-attachment-ms.vk.frag index 206cbe48f2..e060738846 100644 --- a/deps/SPIRV-Cross/shaders/vulkan/frag/input-attachment-ms.vk.frag +++ b/deps/SPIRV-Cross/shaders/vulkan/frag/input-attachment-ms.vk.frag @@ -1,11 +1,10 @@ -#version 310 es -precision mediump float; +#version 450 -layout(input_attachment_index = 0, set = 0, binding = 0) uniform mediump subpassInputMS uSubpass0; -layout(input_attachment_index = 1, set = 0, binding = 1) uniform mediump subpassInputMS uSubpass1; +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); + FragColor = subpassLoad(uSubpass0, 1) + subpassLoad(uSubpass1, 2) + subpassLoad(uSubpass0, gl_SampleID); } diff --git a/deps/SPIRV-Cross/shaders/vulkan/frag/spec-constant.vk.frag b/deps/SPIRV-Cross/shaders/vulkan/frag/spec-constant.vk.frag index 03b625bf58..2002c1272e 100644 --- a/deps/SPIRV-Cross/shaders/vulkan/frag/spec-constant.vk.frag +++ b/deps/SPIRV-Cross/shaders/vulkan/frag/spec-constant.vk.frag @@ -69,9 +69,9 @@ void main() float c37 = float(g); // bool -> float // Flexible sized arrays with spec constants and spec constant ops. - float vec0[d][c + 3]; - float vec1[c + 2][d + 5]; + float vec0[c + 3][8]; + float vec1[c + 2]; Foo foo; - FragColor = vec4(t0 + t1) + vec0[0][0] + vec1[0][0] + foo.elems[c]; + 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 new file mode 100644 index 0000000000..eb1bc766f2 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/spirv.hpp b/deps/SPIRV-Cross/spirv.hpp index 987f3c1d67..efa1dbdf0e 100644 --- a/deps/SPIRV-Cross/spirv.hpp +++ b/deps/SPIRV-Cross/spirv.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2016 The Khronos Group Inc. +// 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"), @@ -47,11 +47,11 @@ namespace spv { typedef unsigned int Id; #define SPV_VERSION 0x10000 -#define SPV_REVISION 5 +#define SPV_REVISION 10 static const unsigned int MagicNumber = 0x07230203; static const unsigned int Version = 0x00010000; -static const unsigned int Revision = 5; +static const unsigned int Revision = 10; static const unsigned int OpCodeMask = 0xffff; static const unsigned int WordCountShift = 16; @@ -61,6 +61,8 @@ enum SourceLanguage { SourceLanguageGLSL = 2, SourceLanguageOpenCL_C = 3, SourceLanguageOpenCL_CPP = 4, + SourceLanguageHLSL = 5, + SourceLanguageMax = 0x7fffffff, }; enum ExecutionModel { @@ -71,18 +73,21 @@ enum ExecutionModel { 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 { @@ -117,6 +122,7 @@ enum ExecutionMode { ExecutionModeOutputTriangleStrip = 29, ExecutionModeVecTypeHint = 30, ExecutionModeContractionOff = 31, + ExecutionModeMax = 0x7fffffff, }; enum StorageClass { @@ -132,6 +138,8 @@ enum StorageClass { StorageClassPushConstant = 9, StorageClassAtomicCounter = 10, StorageClassImage = 11, + StorageClassStorageBuffer = 12, + StorageClassMax = 0x7fffffff, }; enum Dim { @@ -142,6 +150,7 @@ enum Dim { DimRect = 4, DimBuffer = 5, DimSubpassData = 6, + DimMax = 0x7fffffff, }; enum SamplerAddressingMode { @@ -150,11 +159,13 @@ enum SamplerAddressingMode { SamplerAddressingModeClamp = 2, SamplerAddressingModeRepeat = 3, SamplerAddressingModeRepeatMirrored = 4, + SamplerAddressingModeMax = 0x7fffffff, }; enum SamplerFilterMode { SamplerFilterModeNearest = 0, SamplerFilterModeLinear = 1, + SamplerFilterModeMax = 0x7fffffff, }; enum ImageFormat { @@ -198,6 +209,7 @@ enum ImageFormat { ImageFormatRg8ui = 37, ImageFormatR16ui = 38, ImageFormatR8ui = 39, + ImageFormatMax = 0x7fffffff, }; enum ImageChannelOrder { @@ -221,6 +233,7 @@ enum ImageChannelOrder { ImageChannelOrdersRGBA = 17, ImageChannelOrdersBGRA = 18, ImageChannelOrderABGR = 19, + ImageChannelOrderMax = 0x7fffffff, }; enum ImageChannelDataType { @@ -241,6 +254,7 @@ enum ImageChannelDataType { ImageChannelDataTypeFloat = 14, ImageChannelDataTypeUnormInt24 = 15, ImageChannelDataTypeUnormInt101010_2 = 16, + ImageChannelDataTypeMax = 0x7fffffff, }; enum ImageOperandsShift { @@ -252,6 +266,7 @@ enum ImageOperandsShift { ImageOperandsConstOffsetsShift = 5, ImageOperandsSampleShift = 6, ImageOperandsMinLodShift = 7, + ImageOperandsMax = 0x7fffffff, }; enum ImageOperandsMask { @@ -272,6 +287,7 @@ enum FPFastMathModeShift { FPFastMathModeNSZShift = 2, FPFastMathModeAllowRecipShift = 3, FPFastMathModeFastShift = 4, + FPFastMathModeMax = 0x7fffffff, }; enum FPFastMathModeMask { @@ -288,17 +304,20 @@ enum FPRoundingMode { 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 { @@ -310,6 +329,7 @@ enum FunctionParameterAttribute { FunctionParameterAttributeNoCapture = 5, FunctionParameterAttributeNoWrite = 6, FunctionParameterAttributeNoReadWrite = 7, + FunctionParameterAttributeMax = 0x7fffffff, }; enum Decoration { @@ -356,6 +376,11 @@ enum Decoration { DecorationNoContraction = 42, DecorationInputAttachmentIndex = 43, DecorationAlignment = 44, + DecorationOverrideCoverageNV = 5248, + DecorationPassthroughNV = 5250, + DecorationViewportRelativeNV = 5252, + DecorationSecondaryViewportRelativeNV = 5256, + DecorationMax = 0x7fffffff, }; enum BuiltIn { @@ -400,11 +425,28 @@ enum BuiltIn { 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 { @@ -416,6 +458,7 @@ enum SelectionControlMask { enum LoopControlShift { LoopControlUnrollShift = 0, LoopControlDontUnrollShift = 1, + LoopControlMax = 0x7fffffff, }; enum LoopControlMask { @@ -429,6 +472,7 @@ enum FunctionControlShift { FunctionControlDontInlineShift = 1, FunctionControlPureShift = 2, FunctionControlConstShift = 3, + FunctionControlMax = 0x7fffffff, }; enum FunctionControlMask { @@ -450,6 +494,7 @@ enum MemorySemanticsShift { MemorySemanticsCrossWorkgroupMemoryShift = 9, MemorySemanticsAtomicCounterMemoryShift = 10, MemorySemanticsImageMemoryShift = 11, + MemorySemanticsMax = 0x7fffffff, }; enum MemorySemanticsMask { @@ -470,6 +515,7 @@ enum MemoryAccessShift { MemoryAccessVolatileShift = 0, MemoryAccessAlignedShift = 1, MemoryAccessNontemporalShift = 2, + MemoryAccessMax = 0x7fffffff, }; enum MemoryAccessMask { @@ -485,22 +531,26 @@ enum Scope { 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 { @@ -565,6 +615,26 @@ enum Capability { 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 { @@ -862,6 +932,23 @@ enum Op { 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 diff --git a/deps/SPIRV-Cross/spirv_cfg.cpp b/deps/SPIRV-Cross/spirv_cfg.cpp index db6b548289..815fdee682 100644 --- a/deps/SPIRV-Cross/spirv_cfg.cpp +++ b/deps/SPIRV-Cross/spirv_cfg.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 ARM Limited + * 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. @@ -15,6 +15,7 @@ */ #include "spirv_cfg.hpp" +#include "spirv_cross.hpp" #include #include @@ -47,14 +48,6 @@ uint32_t CFG::find_common_dominator(uint32_t a, uint32_t b) const return a; } -uint32_t CFG::update_common_dominator(uint32_t a, uint32_t b) -{ - auto dominator = find_common_dominator(immediate_dominators[a], immediate_dominators[b]); - immediate_dominators[a] = dominator; - immediate_dominators[b] = dominator; - return dominator; -} - void CFG::build_immediate_dominators() { // Traverse the post-order in reverse and build up the immediate dominator tree. @@ -73,7 +66,7 @@ void CFG::build_immediate_dominators() if (immediate_dominators[block]) { assert(immediate_dominators[edge]); - immediate_dominators[block] = update_common_dominator(block, edge); + immediate_dominators[block] = find_common_dominator(block, edge); } else immediate_dominators[block] = edge; @@ -129,6 +122,13 @@ bool CFG::post_order_visit(uint32_t block_id) 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); @@ -180,7 +180,7 @@ void DominatorBuilder::add_block(uint32_t block) void DominatorBuilder::lift_continue_block_dominator() { - // It is possible for a continue block to be the dominator if a variable is only accessed inside the while block of a do-while loop. + // 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 diff --git a/deps/SPIRV-Cross/spirv_cfg.hpp b/deps/SPIRV-Cross/spirv_cfg.hpp index e6450a7123..3f7ec01d33 100644 --- a/deps/SPIRV-Cross/spirv_cfg.hpp +++ b/deps/SPIRV-Cross/spirv_cfg.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 ARM Limited + * 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. @@ -17,11 +17,12 @@ #ifndef SPIRV_CROSS_CFG_HPP #define SPIRV_CROSS_CFG_HPP -#include "spirv_cross.hpp" +#include "spirv_common.hpp" #include namespace spirv_cross { +class Compiler; class CFG { public: @@ -67,11 +68,15 @@ public: } template - void walk_from(uint32_t block, const Op &op) const + 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(b, op); + walk_from(seen_blocks, b, op); } private: @@ -89,7 +94,6 @@ private: bool post_order_visit(uint32_t block); uint32_t visit_count = 0; - uint32_t update_common_dominator(uint32_t a, uint32_t b); bool is_back_edge(uint32_t to) const; }; diff --git a/deps/SPIRV-Cross/spirv_common.hpp b/deps/SPIRV-Cross/spirv_common.hpp index 84257d5a21..eeb8532542 100644 --- a/deps/SPIRV-Cross/spirv_common.hpp +++ b/deps/SPIRV-Cross/spirv_common.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 ARM Limited + * 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. @@ -17,10 +17,21 @@ #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 { @@ -37,6 +48,7 @@ namespace spirv_cross #else fprintf(stderr, "There was a compiler error: %s\n", msg.c_str()); #endif + fflush(stderr); abort(); } @@ -54,6 +66,16 @@ public: #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 @@ -102,6 +124,11 @@ inline std::string convert_to_string(T &&t) #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. @@ -126,6 +153,10 @@ inline std::string convert_to_string(double t) return buf; } +#ifdef _MSC_VER +#pragma warning(pop) +#endif + struct Instruction { Instruction(const std::vector &spirv, uint32_t &index); @@ -156,6 +187,8 @@ enum Types TypeExtension, TypeExpression, TypeConstantOp, + TypeCombinedImageSampler, + TypeAccessChain, TypeUndef }; @@ -172,6 +205,25 @@ struct SPIRUndef : IVariant 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 @@ -239,7 +291,7 @@ struct SPIRType : IVariant std::vector member_types; - struct Image + struct ImageType { uint32_t type; spv::Dim dim; @@ -248,6 +300,7 @@ struct SPIRType : IVariant 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. @@ -255,6 +308,10 @@ struct SPIRType : IVariant // 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; }; @@ -268,7 +325,12 @@ struct SPIRExtension : IVariant enum Extension { - GLSL + Unsupported, + GLSL, + SPV_AMD_shader_ballot, + SPV_AMD_shader_explicit_vertex_parameter, + SPV_AMD_shader_trinary_minmax, + SPV_AMD_gcn_shader }; SPIRExtension(Extension ext_) @@ -283,9 +345,10 @@ struct SPIRExtension : IVariant // 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, std::string entry_name) + SPIREntryPoint(uint32_t self_, spv::ExecutionModel execution_model, const std::string &entry_name) : self(self_) - , name(std::move(entry_name)) + , name(entry_name) + , orig_name(entry_name) , model(execution_model) { } @@ -293,12 +356,14 @@ struct SPIREntryPoint 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; @@ -338,8 +403,9 @@ struct SPIRExpression : IVariant // it is assumed that this is true almost always. bool immutable = false; - // If this expression has been used while invalidated. - bool used_while_invalidated = 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; @@ -492,6 +558,14 @@ struct SPIRFunction : IVariant 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, @@ -508,6 +582,7 @@ struct SPIRFunction : IVariant uint32_t sampler_id; bool global_image; bool global_sampler; + bool depth; }; uint32_t return_type; @@ -528,10 +603,10 @@ struct SPIRFunction : IVariant local_variables.push_back(id); } - void add_parameter(uint32_t parameter_type, uint32_t 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 }); + arguments.push_back({ parameter_type, id, 0u, 0u, alias_global_variable }); } bool active = false; @@ -540,6 +615,40 @@ struct SPIRFunction : IVariant 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 @@ -548,10 +657,11 @@ struct SPIRVariable : IVariant }; SPIRVariable() = default; - SPIRVariable(uint32_t basetype_, spv::StorageClass storage_, uint32_t initializer_ = 0) + SPIRVariable(uint32_t basetype_, spv::StorageClass storage_, uint32_t initializer_ = 0, uint32_t basevariable_ = 0) : basetype(basetype_) , storage(storage_) , initializer(initializer_) + , basevariable(basevariable_) { } @@ -559,6 +669,7 @@ struct SPIRVariable : IVariant 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; @@ -611,15 +722,29 @@ struct SPIRConstant : IVariant struct ConstantVector { Constant r[4]; - uint32_t vecsize; + // 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]; - uint32_t columns; + // 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; @@ -654,136 +779,96 @@ struct SPIRConstant : IVariant { return m.c[0]; } + inline uint32_t vector_size() const { return m.c[0].vecsize; } + inline uint32_t columns() const { return m.columns; } - SPIRConstant(uint32_t constant_type_, const uint32_t *elements, uint32_t num_elements) + 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; } - SPIRConstant(uint32_t constant_type_, uint32_t v0) + // 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; } - SPIRConstant(uint32_t constant_type_, uint32_t v0, uint32_t v1) - : constant_type(constant_type_) - { - m.c[0].r[0].u32 = v0; - m.c[0].r[1].u32 = v1; - m.c[0].vecsize = 2; - m.columns = 1; - } - - SPIRConstant(uint32_t constant_type_, uint32_t v0, uint32_t v1, uint32_t v2) - : constant_type(constant_type_) - { - m.c[0].r[0].u32 = v0; - m.c[0].r[1].u32 = v1; - m.c[0].r[2].u32 = v2; - m.c[0].vecsize = 3; - m.columns = 1; - } - - SPIRConstant(uint32_t constant_type_, uint32_t v0, uint32_t v1, uint32_t v2, uint32_t v3) - : constant_type(constant_type_) - { - m.c[0].r[0].u32 = v0; - m.c[0].r[1].u32 = v1; - m.c[0].r[2].u32 = v2; - m.c[0].r[3].u32 = v3; - m.c[0].vecsize = 4; - m.columns = 1; - } - - SPIRConstant(uint32_t constant_type_, uint64_t v0) + // 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; } - SPIRConstant(uint32_t constant_type_, uint64_t v0, uint64_t v1) + // 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) { - m.c[0].r[0].u64 = v0; - m.c[0].r[1].u64 = v1; - m.c[0].vecsize = 2; - m.columns = 1; - } + bool matrix = vector_elements[0]->m.c[0].vecsize > 1; - SPIRConstant(uint32_t constant_type_, uint64_t v0, uint64_t v1, uint64_t v2) - : constant_type(constant_type_) - { - m.c[0].r[0].u64 = v0; - m.c[0].r[1].u64 = v1; - m.c[0].r[2].u64 = v2; - m.c[0].vecsize = 3; - m.columns = 1; - } + if (matrix) + { + m.columns = num_elements; - SPIRConstant(uint32_t constant_type_, uint64_t v0, uint64_t v1, uint64_t v2, uint64_t v3) - : constant_type(constant_type_) - { - m.c[0].r[0].u64 = v0; - m.c[0].r[1].u64 = v1; - m.c[0].r[2].u64 = v2; - m.c[0].r[3].u64 = v3; - m.c[0].vecsize = 4; - m.columns = 1; - } + 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; - SPIRConstant(uint32_t constant_type_, const ConstantVector &vec0) - : constant_type(constant_type_) - { - m.columns = 1; - m.c[0] = vec0; - } - - SPIRConstant(uint32_t constant_type_, const ConstantVector &vec0, const ConstantVector &vec1) - : constant_type(constant_type_) - { - m.columns = 2; - m.c[0] = vec0; - m.c[1] = vec1; - } - - SPIRConstant(uint32_t constant_type_, const ConstantVector &vec0, const ConstantVector &vec1, - const ConstantVector &vec2) - : constant_type(constant_type_) - { - m.columns = 3; - m.c[0] = vec0; - m.c[1] = vec1; - m.c[2] = vec2; - } - - SPIRConstant(uint32_t constant_type_, const ConstantVector &vec0, const ConstantVector &vec1, - const ConstantVector &vec2, const ConstantVector &vec3) - : constant_type(constant_type_) - { - m.columns = 4; - m.c[0] = vec0; - m.c[1] = vec1; - m.c[2] = vec2; - m.c[3] = vec3; + 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 the constant is a specialization constant. + 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; @@ -841,6 +926,10 @@ public: { return type; } + uint32_t get_id() const + { + return holder ? holder->self : 0; + } bool empty() const { return !holder; @@ -890,15 +979,25 @@ struct Meta 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; - bool per_instance = 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. @@ -906,6 +1005,22 @@ struct Meta // 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 index 223a954131..45f6d6a273 100644 --- a/deps/SPIRV-Cross/spirv_cpp.cpp +++ b/deps/SPIRV-Cross/spirv_cpp.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 ARM Limited + * 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. @@ -171,8 +171,9 @@ void CompilerCPP::emit_resources() 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)))) + !is_hidden_variable(var) && + (meta[type.self].decoration.decoration_flags & + ((1ull << DecorationBlock) | (1ull << DecorationBufferBlock)))) { emit_buffer_block(var); } @@ -242,6 +243,8 @@ void CompilerCPP::emit_resources() if (emitted) statement(""); + declare_undefined_values(); + statement("inline void init(spirv_cross_shader& s)"); begin_scope(); statement(resource_type, "::init(s);"); @@ -279,6 +282,9 @@ void CompilerCPP::emit_resources() 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; @@ -294,6 +300,8 @@ string CompilerCPP::compile() backend.explicit_struct_type = true; backend.use_initializer_list = true; + update_active_builtins(); + uint32_t pass_count = 0; do { @@ -322,6 +330,9 @@ string CompilerCPP::compile() // 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(); } @@ -416,7 +427,7 @@ string CompilerCPP::argument_decl(const SPIRFunction::Parameter &arg) return join(constref ? "const " : "", base, " &", variable_name); } -string CompilerCPP::variable_decl(const SPIRType &type, const string &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); diff --git a/deps/SPIRV-Cross/spirv_cpp.hpp b/deps/SPIRV-Cross/spirv_cpp.hpp index eb77c0b10e..a2576feb9d 100644 --- a/deps/SPIRV-Cross/spirv_cpp.hpp +++ b/deps/SPIRV-Cross/spirv_cpp.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 ARM Limited + * 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. @@ -30,6 +30,12 @@ public: : 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 @@ -48,14 +54,14 @@ private: void emit_function_prototype(SPIRFunction &func, uint64_t return_flags) override; void emit_resources(); - void emit_buffer_block(const SPIRVariable &type); - void emit_push_constant_block(const SPIRVariable &var); + 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); + 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) override; + std::string variable_decl(const SPIRType &type, const std::string &name, uint32_t id) override; std::string argument_decl(const SPIRFunction::Parameter &arg); diff --git a/deps/SPIRV-Cross/spirv_cross.cpp b/deps/SPIRV-Cross/spirv_cross.cpp index 7b2d9836a6..26983a4358 100644 --- a/deps/SPIRV-Cross/spirv_cross.cpp +++ b/deps/SPIRV-Cross/spirv_cross.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 ARM Limited + * 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. @@ -27,6 +27,40 @@ 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; @@ -50,15 +84,24 @@ Compiler::Compiler(vector 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 = (meta[type.self].decoration.decoration_flags & (1ull << DecorationBufferBlock)) != 0; + 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; @@ -99,6 +142,7 @@ bool Compiler::block_is_pure(const SPIRBlock &block) case OpAtomicStore: case OpAtomicExchange: case OpAtomicCompareExchange: + case OpAtomicCompareExchangeWeak: case OpAtomicIIncrement: case OpAtomicIDecrement: case OpAtomicIAdd: @@ -124,7 +168,7 @@ bool Compiler::block_is_pure(const SPIRBlock &block) case OpMemoryBarrier: return false; - // OpExtInst is potentially impure depending on extension, but GLSL builtins are at least pure. + // OpExtInst is potentially impure depending on extension, but GLSL builtins are at least pure. default: break; @@ -134,7 +178,7 @@ bool Compiler::block_is_pure(const SPIRBlock &block) return true; } -string Compiler::to_name(uint32_t id, bool allow_alias) +string Compiler::to_name(uint32_t id, bool allow_alias) const { if (allow_alias && ids.at(id).get_type() == TypeType) { @@ -220,6 +264,10 @@ SPIRVariable *Compiler::maybe_get_backing_variable(uint32_t chain) 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; @@ -254,6 +302,10 @@ void Compiler::register_write(uint32_t chain) 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) @@ -308,30 +360,41 @@ void Compiler::flush_all_active_variables() flush_all_aliased_variables(); } -const SPIRType &Compiler::expression_type(uint32_t id) const +uint32_t Compiler::expression_type_id(uint32_t id) const { switch (ids[id].get_type()) { case TypeVariable: - return get(get(id).basetype); + return get(id).basetype; case TypeExpression: - return get(get(id).expression_type); + return get(id).expression_type; case TypeConstant: - return get(get(id).constant_type); + return get(id).constant_type; case TypeConstantOp: - return get(get(id).basetype); + return get(id).basetype; case TypeUndef: - return get(get(id).basetype); + 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); @@ -357,6 +420,8 @@ bool Compiler::is_immutable(uint32_t id) const 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 || @@ -376,6 +441,7 @@ static inline bool storage_class_is_interface(spv::StorageClass storage) case StorageClassUniformConstant: case StorageClassAtomicCounter: case StorageClassPushConstant: + case StorageClassStorageBuffer: return true; default: @@ -391,7 +457,7 @@ bool Compiler::is_hidden_variable(const SPIRVariable &var, bool include_builtins // 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)) + }) != end(combined_image_samplers)) { return false; } @@ -443,6 +509,11 @@ 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); @@ -489,7 +560,7 @@ bool Compiler::InterfaceVariableAccessHandler::handle(Op opcode, const uint32_t case OpCopyMemory: { - if (length < 3) + if (length < 2) return false; auto *var = compiler.maybe_get(args[0]); @@ -502,6 +573,37 @@ bool Compiler::InterfaceVariableAccessHandler::handle(Op opcode, const uint32_t 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: @@ -510,6 +612,7 @@ bool Compiler::InterfaceVariableAccessHandler::handle(Op opcode, const uint32_t case OpAtomicLoad: case OpAtomicExchange: case OpAtomicCompareExchange: + case OpAtomicCompareExchangeWeak: case OpAtomicIIncrement: case OpAtomicIDecrement: case OpAtomicIAdd: @@ -576,7 +679,8 @@ ShaderResources Compiler::get_shader_resources(const unordered_set *ac 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, meta[type.self].decoration.alias }); + 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 }); } @@ -589,7 +693,8 @@ ShaderResources Compiler::get_shader_resources(const unordered_set *ac 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, meta[type.self].decoration.alias }); + 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 }); } @@ -597,13 +702,21 @@ ShaderResources Compiler::get_shader_resources(const unordered_set *ac else if (type.storage == StorageClassUniform && (meta[type.self].decoration.decoration_flags & (1ull << DecorationBlock))) { - res.uniform_buffers.push_back({ var.self, var.basetype, type.self, meta[type.self].decoration.alias }); + res.uniform_buffers.push_back( + { var.self, var.basetype, type.self, get_remapped_declared_block_name(var.self) }); } - // SSBOs + // 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, meta[type.self].decoration.alias }); + 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) @@ -676,6 +789,7 @@ static bool is_valid_spirv_version(uint32_t version) case 99: case 0x10000: // SPIR-V 1.0 case 0x10100: // SPIR-V 1.1 + case 0x10200: // SPIR-V 1.2 return true; default: @@ -713,6 +827,27 @@ void Compiler::parse() 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) @@ -789,25 +924,26 @@ void Compiler::set_name(uint32_t id, const std::string &name) 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; - // Functions in glslangValidator are mangled with name( stuff. - // Normally, we would never see '(' in any legal indentifiers, so just strip them out. - str = name.substr(0, name.find('(')); - - for (uint32_t i = 0; i < str.size(); i++) - { - auto &c = str[i]; - - // _ 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 : '_'; - } + str = ensure_valid_identifier(name, false); } const SPIRType &Compiler::get_type(uint32_t id) const @@ -815,6 +951,11 @@ 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)); @@ -832,6 +973,10 @@ void Compiler::set_member_decoration(uint32_t id, uint32_t index, Decoration dec dec.location = argument; break; + case DecorationBinding: + dec.binding = argument; + break; + case DecorationOffset: dec.offset = argument; break; @@ -840,6 +985,10 @@ void Compiler::set_member_decoration(uint32_t id, uint32_t index, Decoration dec dec.spec_id = argument; break; + case DecorationMatrixStride: + dec.matrix_stride = argument; + break; + default: break; } @@ -848,7 +997,17 @@ void Compiler::set_member_decoration(uint32_t id, uint32_t index, Decoration dec 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)); - meta.at(id).members[index].alias = name; + + 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 @@ -863,10 +1022,21 @@ const std::string &Compiler::get_member_name(uint32_t id, uint32_t index) const return m.members[index].alias; } -void Compiler::set_member_qualified_name(uint32_t id, uint32_t index, const std::string &name) +void Compiler::set_member_qualified_name(uint32_t type_id, uint32_t index, const std::string &name) { - meta.at(id).members.resize(max(meta[id].members.size(), size_t(index) + 1)); - meta.at(id).members[index].qualified_alias = 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 @@ -885,12 +1055,14 @@ uint32_t Compiler::get_member_decoration(uint32_t id, uint32_t index, Decoration 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 0; + return 1; } } @@ -903,6 +1075,11 @@ uint64_t Compiler::get_member_decoration_mask(uint32_t id, uint32_t index) const 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); @@ -959,6 +1136,10 @@ void Compiler::set_decoration(uint32_t id, Decoration decoration, uint32_t argum dec.array_stride = argument; break; + case DecorationMatrixStride: + dec.matrix_stride = argument; + break; + case DecorationBinding: dec.binding = argument; break; @@ -990,12 +1171,31 @@ 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; @@ -1018,8 +1218,12 @@ uint32_t Compiler::get_decoration(uint32_t id, Decoration decoration) const return dec.input_attachment; case DecorationSpecId: return dec.spec_id; + case DecorationArrayStride: + return dec.array_stride; + case DecorationMatrixStride: + return dec.matrix_stride; default: - return 0; + return 1; } } @@ -1062,6 +1266,17 @@ void Compiler::unset_decoration(uint32_t id, Decoration decoration) } } +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); @@ -1074,6 +1289,8 @@ void Compiler::parse(const Instruction &instruction) case OpSourceExtension: case OpNop: case OpLine: + case OpNoLine: + case OpString: break; case OpSource: @@ -1085,12 +1302,22 @@ void Compiler::parse(const Instruction &instruction) 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: @@ -1113,6 +1340,15 @@ void Compiler::parse(const Instruction &instruction) 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; } @@ -1122,8 +1358,18 @@ void Compiler::parse(const Instruction &instruction) 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 - SPIRV_CROSS_THROW("Only GLSL.std.450 extension interface supported."); + set(id, SPIRExtension::Unsupported); + + // Other SPIR-V extensions currently not supported. break; } @@ -1197,7 +1443,10 @@ void Compiler::parse(const Instruction &instruction) 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); @@ -1269,6 +1518,7 @@ void Compiler::parse(const Instruction &instruction) vecbase = base; vecbase.vecsize = vecsize; vecbase.self = id; + vecbase.parent_type = ops[1]; break; } @@ -1283,23 +1533,28 @@ void Compiler::parse(const Instruction &instruction) matrixbase = base; matrixbase.columns = colcount; matrixbase.self = id; + matrixbase.parent_type = ops[1]; break; } case OpTypeArray: { uint32_t id = ops[0]; - - auto &base = get(ops[1]); auto &arraybase = set(id); - arraybase = base; + uint32_t tid = ops[1]; + auto &base = get(tid); - auto *c = maybe_get(ops[2]); + 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() : ops[2]); + arraybase.array.push_back(literal ? c->scalar() : cid); // Do NOT set arraybase.self! break; } @@ -1314,6 +1569,7 @@ void Compiler::parse(const Instruction &instruction) 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; } @@ -1330,6 +1586,11 @@ void Compiler::parse(const Instruction &instruction) 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; } @@ -1344,7 +1605,6 @@ void Compiler::parse(const Instruction &instruction) break; } - // Not really used. case OpTypeSampler: { uint32_t id = ops[0]; @@ -1369,6 +1629,8 @@ void Compiler::parse(const Instruction &instruction) if (ptrbase.storage == StorageClassAtomicCounter) ptrbase.basetype = SPIRType::AtomicCounter; + ptrbase.parent_type = ops[2]; + // Do NOT set ptrbase.self! break; } @@ -1388,17 +1650,26 @@ void Compiler::parse(const Instruction &instruction) // 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 (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); + // 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; } @@ -1435,20 +1706,17 @@ void Compiler::parse(const Instruction &instruction) 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); - // 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. - auto &vartype = expression_type(id); - if (vartype.basetype == SPIRType::Image) - { - auto &flags = meta.at(id).decoration.decoration_flags; - flags |= 1ull << DecorationNonWritable; - flags |= 1ull << DecorationNonReadable; - } - break; } @@ -1484,10 +1752,11 @@ void Compiler::parse(const Instruction &instruction) { 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)).specialization = op == OpSpecConstant; + set(id, ops[0], ops[2] | (uint64_t(ops[3]) << 32), op == OpSpecConstant); else - set(id, ops[0], ops[2]).specialization = op == OpSpecConstant; + set(id, ops[0], ops[2], op == OpSpecConstant); break; } @@ -1495,7 +1764,7 @@ void Compiler::parse(const Instruction &instruction) case OpConstantFalse: { uint32_t id = ops[1]; - set(id, ops[0], uint32_t(0)).specialization = op == OpSpecConstantFalse; + set(id, ops[0], uint32_t(0), op == OpSpecConstantFalse); break; } @@ -1503,7 +1772,15 @@ void Compiler::parse(const Instruction &instruction) case OpConstantTrue: { uint32_t id = ops[1]; - set(id, ops[0], uint32_t(1)).specialization = op == OpSpecConstantTrue; + 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; } @@ -1514,109 +1791,25 @@ void Compiler::parse(const Instruction &instruction) uint32_t type = ops[0]; auto &ctype = get(type); - SPIRConstant *constant = nullptr; // 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()) { - constant = &set(id, type, ops + 2, length - 2); - constant->specialization = op == OpSpecConstantComposite; - break; - } - - bool type_64bit = ctype.width > 32; - bool matrix = ctype.columns > 1; - - if (matrix) - { - switch (length - 2) - { - case 1: - constant = &set(id, type, get(ops[2]).vector()); - break; - - case 2: - constant = &set(id, type, get(ops[2]).vector(), - get(ops[3]).vector()); - break; - - case 3: - constant = &set(id, type, get(ops[2]).vector(), - get(ops[3]).vector(), get(ops[4]).vector()); - break; - - case 4: - constant = - &set(id, type, get(ops[2]).vector(), get(ops[3]).vector(), - get(ops[4]).vector(), get(ops[5]).vector()); - break; - - default: - SPIRV_CROSS_THROW("OpConstantComposite only supports 1, 2, 3 and 4 columns."); - } + set(id, type, ops + 2, length - 2, op == OpSpecConstantComposite); } else { - switch (length - 2) - { - case 1: - if (type_64bit) - constant = &set(id, type, get(ops[2]).scalar_u64()); - else - constant = &set(id, type, get(ops[2]).scalar()); - break; + uint32_t elements = length - 2; + if (elements > 4) + SPIRV_CROSS_THROW("OpConstantComposite only supports 1, 2, 3 and 4 elements."); - case 2: - if (type_64bit) - { - constant = &set(id, type, get(ops[2]).scalar_u64(), - get(ops[3]).scalar_u64()); - } - else - { - constant = &set(id, type, get(ops[2]).scalar(), - get(ops[3]).scalar()); - } - break; - - case 3: - if (type_64bit) - { - constant = &set(id, type, get(ops[2]).scalar_u64(), - get(ops[3]).scalar_u64(), - get(ops[4]).scalar_u64()); - } - else - { - constant = - &set(id, type, get(ops[2]).scalar(), - get(ops[3]).scalar(), get(ops[4]).scalar()); - } - break; - - case 4: - if (type_64bit) - { - constant = &set( - id, type, get(ops[2]).scalar_u64(), get(ops[3]).scalar_u64(), - get(ops[4]).scalar_u64(), get(ops[5]).scalar_u64()); - } - else - { - constant = &set( - id, type, get(ops[2]).scalar(), get(ops[3]).scalar(), - get(ops[4]).scalar(), get(ops[5]).scalar()); - } - break; - - default: - SPIRV_CROSS_THROW("OpConstantComposite only supports 1, 2, 3 and 4 components."); - } + 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); } - - constant->specialization = op == OpSpecConstantComposite; break; } @@ -1791,6 +1984,8 @@ void Compiler::parse(const Instruction &instruction) 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. @@ -2054,6 +2249,17 @@ uint32_t Compiler::type_struct_member_array_stride(const SPIRType &type, uint32_ 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); @@ -2067,63 +2273,53 @@ size_t Compiler::get_declared_struct_member_size(const SPIRType &struct_type, ui auto flags = get_member_decoration_mask(struct_type.self, index); auto &type = get(struct_type.member_types[index]); - if (type.basetype != SPIRType::Struct) + switch (type.basetype) { - 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.\n"); + 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; - } + default: + break; + } - size_t component_size = type.width / 8; - unsigned vecsize = type.vecsize; - unsigned columns = type.columns; - - if (type.array.empty()) - { - // Vectors. - if (columns == 1) - return vecsize * component_size; - else - { - // Per SPIR-V spec, matrices must be tightly packed and aligned up for vec3 accesses. - if ((flags & (1ull << DecorationRowMajor)) && columns == 3) - columns = 4; - else if ((flags & (1ull << DecorationColMajor)) && vecsize == 3) - vecsize = 4; - - return vecsize * columns * component_size; - } - } - else - { - // For arrays, we can use ArrayStride to get an easy check. - return type_struct_member_array_stride(struct_type, index) * type.array.back(); - } + 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 { - // Recurse. - uint32_t last = uint32_t(struct_type.member_types.size() - 1); - uint32_t offset = type_struct_member_offset(struct_type, last); - size_t size; + unsigned vecsize = type.vecsize; + unsigned columns = type.columns; - // If we have an array of structs inside our struct, handle that with array strides instead. - auto &last_type = get(struct_type.member_types.back()); - if (last_type.array.empty()) - size = get_declared_struct_size(last_type); + // Vectors. + if (columns == 1) + { + size_t component_size = type.width / 8; + return vecsize * component_size; + } else - size = type_struct_member_array_stride(struct_type, last) * last_type.array.back(); - return offset + size; + { + 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."); + } } } @@ -2263,6 +2459,40 @@ void Compiler::unset_execution_mode(ExecutionMode mode) 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(); @@ -2320,6 +2550,14 @@ uint32_t Compiler::get_subpass_input_remapped_components(uint32_t id) const 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) @@ -2340,10 +2578,17 @@ vector Compiler::get_entry_points() const { vector entries; for (auto &entry : entry_points) - entries.push_back(entry.second.name); + 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); @@ -2353,8 +2598,9 @@ void Compiler::set_entry_point(const std::string &name) 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.name == name; }); + 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."); @@ -2365,8 +2611,9 @@ SPIREntryPoint &Compiler::get_entry_point(const std::string &name) 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.name == name; }); + 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."); @@ -2374,6 +2621,11 @@ const SPIREntryPoint &Compiler::get_entry_point(const std::string &name) const 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; @@ -2387,8 +2639,9 @@ SPIREntryPoint &Compiler::get_entry_point() bool Compiler::interface_variable_exists_in_entry_point(uint32_t id) const { auto &var = get(id); - if (var.storage != StorageClassInput && var.storage != StorageClassOutput) - SPIRV_CROSS_THROW("Only Input and Output variables are part of a shader linking interface."); + 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. @@ -2455,7 +2708,6 @@ bool Compiler::CombinedImageSamplerHandler::end_function_scope(const uint32_t *a auto &callee = compiler.get(args[2]); args += 3; - length -= 3; // There are two types of cases we have to handle, // a callee might call sampler2D(texture2D, sampler) directly where @@ -2489,7 +2741,7 @@ bool Compiler::CombinedImageSamplerHandler::end_function_scope(const uint32_t *a if (s) sampler_id = s->self; - register_combined_image_sampler(caller, image_id, sampler_id); + register_combined_image_sampler(caller, image_id, sampler_id, param.depth); } } @@ -2497,13 +2749,13 @@ bool Compiler::CombinedImageSamplerHandler::end_function_scope(const uint32_t *a } void Compiler::CombinedImageSamplerHandler::register_combined_image_sampler(SPIRFunction &caller, uint32_t image_id, - uint32_t sampler_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, + 0u, image_id, sampler_id, true, true, depth, }; auto texture_itr = find_if(begin(caller.arguments), end(caller.arguments), @@ -2530,7 +2782,7 @@ void Compiler::CombinedImageSamplerHandler::register_combined_image_sampler(SPIR [¶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)) { @@ -2547,6 +2799,7 @@ void Compiler::CombinedImageSamplerHandler::register_combined_image_sampler(SPIR type.basetype = SPIRType::SampledImage; type.pointer = false; type.storage = StorageClassGeneric; + type.image.depth = depth; ptr_type = type; ptr_type.pointer = true; @@ -2566,7 +2819,7 @@ void Compiler::CombinedImageSamplerHandler::register_combined_image_sampler(SPIR 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 }); + caller.shadow_arguments.push_back({ ptr_type_id, combined_id, 0u, 0u, true }); } } @@ -2613,11 +2866,12 @@ bool Compiler::CombinedImageSamplerHandler::handle(Op opcode, const uint32_t *ar 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 of separate images. This is not possible to statically remap to plain GLSL."); + 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 of separate samplers. This is not possible to statically " - "remap to plain GLSL."); + SPIRV_CROSS_THROW( + "Attempting to use arrays or structs of separate samplers. This is not possible to statically " + "remap to plain GLSL."); return true; } @@ -2650,7 +2904,8 @@ bool Compiler::CombinedImageSamplerHandler::handle(Op opcode, const uint32_t *ar if (sampler) sampler_id = sampler->self; - register_combined_image_sampler(callee, image_id, sampler_id); + auto &combined_type = compiler.get(args[0]); + register_combined_image_sampler(callee, image_id, sampler_id, combined_type.image.depth); } } @@ -2664,7 +2919,7 @@ bool Compiler::CombinedImageSamplerHandler::handle(Op opcode, const uint32_t *ar 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)) { @@ -2740,13 +2995,114 @@ 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_) + AccessHandler(Compiler &compiler_, SPIRFunction &entry_) : compiler(compiler_) + , entry(entry_) { } @@ -2767,22 +3123,33 @@ void Compiler::analyze_variable_scope(SPIRFunction &entry) 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) @@ -2794,8 +3161,38 @@ void Compiler::analyze_variable_scope(SPIRFunction &entry) } } + 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: @@ -2807,6 +3204,13 @@ void Compiler::analyze_variable_scope(SPIRFunction &entry) 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; } @@ -2820,12 +3224,17 @@ void Compiler::analyze_variable_scope(SPIRFunction &entry) 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 < 3) + if (length < 2) return false; uint32_t lhs = args[0]; @@ -2834,6 +3243,10 @@ void Compiler::analyze_variable_scope(SPIRFunction &entry) 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); @@ -2848,6 +3261,9 @@ void Compiler::analyze_variable_scope(SPIRFunction &entry) 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; } @@ -2859,6 +3275,9 @@ void Compiler::analyze_variable_scope(SPIRFunction &entry) 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; } @@ -2874,33 +3293,72 @@ void Compiler::analyze_variable_scope(SPIRFunction &entry) 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 OpPhi: + case OpExtInst: { - if (length < 2) - return false; - - // Phi nodes are implemented as function variables, so register an access here. - accessed_variables_to_block[args[1]].insert(current_block->self); + 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; } - // Atomics shouldn't be able to access function-local variables. - // Some GLSL builtins access a pointer. + 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); + } handler(*this, entry); // First, we map out all variable access within a function. // Essentially a map of block -> { variables accessed in the basic block } @@ -2909,6 +3367,10 @@ void Compiler::analyze_variable_scope(SPIRFunction &entry) // 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. @@ -2916,23 +3378,34 @@ void Compiler::analyze_variable_scope(SPIRFunction &entry) { DominatorBuilder builder(cfg); auto &blocks = var.second; - auto &type = expression_type(var.first); + 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 (is_continue(block) && type.vecsize == 1 && type.columns == 1) + if (this->is_continue(block)) { - // 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]; + // 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 (potential == 0) - potential = block; - else - potential = -1u; + 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); } @@ -2941,25 +3414,74 @@ void Compiler::analyze_variable_scope(SPIRFunction &entry) // 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); - get(var.first).dominator = dominating_block; + 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 = get(loop_variable.first); + 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 == -1u || block == 0) + if (block == ~(0u) || block == 0) continue; // Dead code. @@ -2969,9 +3491,9 @@ void Compiler::analyze_variable_scope(SPIRFunction &entry) uint32_t header = 0; // Find the loop header for this block. - for (auto b : loop_blocks) + for (auto b : this->loop_blocks) { - auto &potential_header = get(b); + auto &potential_header = this->get(b); if (potential_header.continue_block == block) { header = b; @@ -2980,7 +3502,11 @@ void Compiler::analyze_variable_scope(SPIRFunction &entry) } assert(header); - auto &header_block = get(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, @@ -2991,6 +3517,9 @@ void Compiler::analyze_variable_scope(SPIRFunction &entry) 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) { @@ -3008,13 +3537,14 @@ void Compiler::analyze_variable_scope(SPIRFunction &entry) dominator = succ.front(); } - if (!static_loop_init) + 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. - auto &blocks = handler.accessed_variables_to_block[loop_variable.first]; - cfg.walk_from(header_block.merge_block, [&](uint32_t walk_block) { + + 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; @@ -3028,6 +3558,400 @@ void Compiler::analyze_variable_scope(SPIRFunction &entry) // 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)); - get(loop_variable.first).loop_variable = true; + 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 index 5ba62585fc..ce928f7eb9 100644 --- a/deps/SPIRV-Cross/spirv_cross.hpp +++ b/deps/SPIRV-Cross/spirv_cross.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 ARM Limited + * 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. @@ -18,19 +18,11 @@ #define SPIRV_CROSS_HPP #include "spirv.hpp" -#include -#include -#include -#include -#include -#include -#include -#include - #include "spirv_common.hpp" namespace spirv_cross { +class CFG; struct Resource { // Resources are identified with their SPIR-V ID. @@ -106,6 +98,16 @@ struct BufferRange size_t range; }; +enum BufferPackingStandard +{ + BufferPackingStd140, + BufferPackingStd430, + BufferPackingStd140EnhancedLayout, + BufferPackingStd430EnhancedLayout, + BufferPackingHLSLCbuffer, + BufferPackingHLSLCbufferPackOffset +}; + class Compiler { public: @@ -114,6 +116,7 @@ public: // 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; @@ -137,7 +140,12 @@ public: // 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; @@ -145,19 +153,23 @@ public: // Removes the decoration for a an ID. void unset_decoration(uint32_t id, spv::Decoration decoration); - // Gets the SPIR-V associated with ID. + // 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 - { - return join("_", id); - } + 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. @@ -169,12 +181,19 @@ public: // 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 id, uint32_t index, const std::string &name); + 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); @@ -189,7 +208,7 @@ public: // 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 (SSBO) and PushConstant blocks. + // 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; @@ -199,12 +218,8 @@ public: // 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. - // Takes a variable with a block interface and flattens it into a T array[N]; array instead. - // For this to work, all types in the block must not themselves be composites - // (except vectors and matrices), and all types must be the same. - // The name of the uniform will be the same as the interface block name. - void flatten_interface_block(uint32_t id); + // 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. @@ -249,10 +264,26 @@ public: 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); @@ -264,6 +295,25 @@ public: 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 @@ -317,6 +367,62 @@ public: 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 { @@ -395,6 +501,7 @@ protected: uint32_t version = 0; bool es = false; bool known = false; + bool hlsl = false; Source() = default; } source; @@ -404,8 +511,9 @@ protected: 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); + 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; @@ -413,10 +521,13 @@ protected: 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); @@ -459,9 +570,6 @@ protected: bool force_recompile = false; - 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; - bool block_is_loop_candidate(const SPIRBlock &block, SPIRBlock::Method method) const; uint32_t increase_bound_by(uint32_t incr_amount); @@ -483,7 +591,6 @@ protected: void analyze_variable_scope(SPIRFunction &function); -private: void parse(); void parse(const Instruction &i); @@ -567,7 +674,19 @@ private: 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); + 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; @@ -578,6 +697,56 @@ private: 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); }; } diff --git a/deps/SPIRV-Cross/spirv_glsl.cpp b/deps/SPIRV-Cross/spirv_glsl.cpp index 3e501d12c1..ea80c20ce4 100644 --- a/deps/SPIRV-Cross/spirv_glsl.cpp +++ b/deps/SPIRV-Cross/spirv_glsl.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 ARM Limited + * 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. @@ -16,13 +16,98 @@ #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) { @@ -129,6 +214,19 @@ static uint32_t pls_format_to_components(PlsFormat format) } } +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, @@ -235,7 +333,7 @@ void CompilerGLSL::find_static_extensions() case ExecutionModelGeometry: if (options.es && options.version < 320) require_extension("GL_EXT_geometry_shader"); - if (!options.es && options.version < 320) + if (!options.es && options.version < 150) require_extension("GL_ARB_geometry_shader4"); if ((execution.flags & (1ull << ExecutionModeInvocations)) && execution.invocations != 1) @@ -260,12 +358,25 @@ void CompilerGLSL::find_static_extensions() 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 @@ -286,12 +397,15 @@ string CompilerGLSL::compile() 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->str(); + return buffer ? buffer->str() : "No compiled source available yet."; } void CompilerGLSL::emit_header() @@ -299,12 +413,18 @@ void CompilerGLSL::emit_header() auto &execution = get_entry_point(); statement("#version ", options.version, options.es && options.version > 100 ? " es" : ""); - // Needed for binding = # on UBOs, etc. if (!options.es && options.version < 420) { - statement("#ifdef GL_ARB_shading_language_420pack"); - statement("#extension GL_ARB_shading_language_420pack : require"); - statement("#endif"); + // 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) @@ -372,10 +492,50 @@ void CompilerGLSL::emit_header() break; case ExecutionModelGLCompute: - 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)); + { + 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) @@ -438,6 +598,11 @@ void CompilerGLSL::emit_header() 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 @@ -447,6 +612,12 @@ void CompilerGLSL::emit_struct(SPIRType &type) 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); @@ -460,9 +631,7 @@ void CompilerGLSL::emit_struct(SPIRType &type) for (auto &member : type.member_types) { add_member_name(type, i); - - auto &membertype = get(member); - statement(member_decl(type, membertype, i), ";"); + emit_struct_member(type, member, i); i++; emitted = true; } @@ -511,6 +680,9 @@ string CompilerGLSL::to_interpolation_qualifiers(uint64_t flags) 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) @@ -545,9 +717,14 @@ string CompilerGLSL::layout_for_member(const SPIRType &type, uint32_t index) //if (flags & (1ull << DecorationColMajor)) // attr.push_back("column_major"); - if (dec.decoration_flags & (1ull << DecorationLocation)) + 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 ""; @@ -677,7 +854,7 @@ const char *CompilerGLSL::format_to_glsl(spv::ImageFormat format) } } -uint32_t CompilerGLSL::type_to_std430_base_size(const SPIRType &type) +uint32_t CompilerGLSL::type_to_packed_base_size(const SPIRType &type, BufferPackingStandard) { switch (type.basetype) { @@ -690,9 +867,23 @@ uint32_t CompilerGLSL::type_to_std430_base_size(const SPIRType &type) } } -uint32_t CompilerGLSL::type_to_std430_alignment(const SPIRType &type, uint64_t flags) +uint32_t CompilerGLSL::type_to_packed_alignment(const SPIRType &type, uint64_t flags, BufferPackingStandard packing) { - const uint32_t base_alignment = type_to_std430_base_size(type); + 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) { @@ -701,13 +892,23 @@ uint32_t CompilerGLSL::type_to_std430_alignment(const SPIRType &type, uint64_t f 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_std430_alignment(get(type.member_types[i]), member_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) @@ -727,7 +928,9 @@ uint32_t CompilerGLSL::type_to_std430_alignment(const SPIRType &type, uint64_t f // vectors. if ((flags & (1ull << DecorationColMajor)) && type.columns > 1) { - if (type.vecsize == 3) + 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; @@ -738,7 +941,9 @@ uint32_t CompilerGLSL::type_to_std430_alignment(const SPIRType &type, uint64_t f // Rule 7. if ((flags & (1ull << DecorationRowMajor)) && type.vecsize > 1) { - if (type.columns == 3) + 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; @@ -747,26 +952,40 @@ uint32_t CompilerGLSL::type_to_std430_alignment(const SPIRType &type, uint64_t f // Rule 8 implied. } - SPIRV_CROSS_THROW("Did not find suitable std430 rule for type. Bogus decorations?"); + SPIRV_CROSS_THROW("Did not find suitable rule for type. Bogus decorations?"); } -uint32_t CompilerGLSL::type_to_std430_array_stride(const SPIRType &type, uint64_t flags) +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. - SPIRType tmp = type; - tmp.array.pop_back(); - tmp.array_size_literal.pop_back(); - uint32_t size = type_to_std430_size(tmp, flags); - uint32_t alignment = type_to_std430_alignment(tmp, flags); - return (size + alignment - 1) & ~(alignment - 1); + 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_std430_size(const SPIRType &type, uint64_t flags) +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_std430_array_stride(type, flags); + { + 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_std430_base_size(type); + const uint32_t base_alignment = type_to_packed_base_size(type, packing); uint32_t size = 0; if (type.basetype == SPIRType::Struct) @@ -778,18 +997,18 @@ uint32_t CompilerGLSL::type_to_std430_size(const SPIRType &type, uint64_t flags) auto member_flags = meta[type.self].members.at(i).decoration_flags; auto &member_type = get(type.member_types[i]); - uint32_t std430_alignment = type_to_std430_alignment(member_type, member_flags); - uint32_t alignment = max(std430_alignment, pad_alignment); + 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 = std430_alignment; + pad_alignment = packed_alignment; else pad_alignment = 1; size = (size + alignment - 1) & ~(alignment - 1); - size += type_to_std430_size(member_type, member_flags); + size += type_to_packed_size(member_type, member_flags, packing); } } else @@ -799,7 +1018,9 @@ uint32_t CompilerGLSL::type_to_std430_size(const SPIRType &type, uint64_t flags) if ((flags & (1ull << DecorationColMajor)) && type.columns > 1) { - if (type.vecsize == 3) + 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; @@ -807,7 +1028,9 @@ uint32_t CompilerGLSL::type_to_std430_size(const SPIRType &type, uint64_t flags) if ((flags & (1ull << DecorationRowMajor)) && type.vecsize > 1) { - if (type.columns == 3) + 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; @@ -817,7 +1040,7 @@ uint32_t CompilerGLSL::type_to_std430_size(const SPIRType &type, uint64_t flags) return size; } -bool CompilerGLSL::ssbo_is_std430_packing(const SPIRType &type) +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. @@ -841,32 +1064,76 @@ bool CompilerGLSL::ssbo_is_std430_packing(const SPIRType &type) auto member_flags = meta[type.self].members.at(i).decoration_flags; // Verify alignment rules. - uint32_t std430_alignment = type_to_std430_alignment(memb_type, member_flags); - uint32_t alignment = max(std430_alignment, pad_alignment); + 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 = std430_alignment; + pad_alignment = packed_alignment; else pad_alignment = 1; - uint32_t actual_offset = type_struct_member_offset(type, i); - if (actual_offset != offset) // This cannot be std430. - return false; + // 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_std430_array_stride(memb_type, member_flags) != type_struct_member_array_stride(type, i)) + 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 std430 rules. - if (!memb_type.member_types.empty() && !ssbo_is_std430_packing(memb_type)) + // 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 += type_to_std430_size(memb_type, member_flags); + 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; @@ -902,7 +1169,7 @@ string CompilerGLSL::layout_for_variable(const SPIRVariable &var) attr.push_back(join("input_attachment_index = ", dec.input_attachment)); } - if (flags & (1ull << DecorationLocation)) + 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++) @@ -922,24 +1189,96 @@ string CompilerGLSL::layout_for_variable(const SPIRVariable &var) attr.push_back(join("set = ", dec.set)); } - if (flags & (1ull << DecorationBinding)) + 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 << DecorationCoherent)) - attr.push_back("coherent"); + 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))) - attr.push_back("std140"); - else if (var.storage == StorageClassUniform && (typeflags & (1ull << DecorationBufferBlock))) - attr.push_back(ssbo_is_std430_packing(type) ? "std430" : "std140"); - else if (options.vulkan_semantics && var.storage == StorageClassPushConstant) - attr.push_back(ssbo_is_std430_packing(type) ? "std430" : "std140"); + { + 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. - if (type.basetype == SPIRType::Image) + // 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) @@ -957,7 +1296,9 @@ string CompilerGLSL::layout_for_variable(const SPIRVariable &var) void CompilerGLSL::emit_push_constant_block(const SPIRVariable &var) { - if (options.vulkan_semantics) + 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); @@ -997,24 +1338,69 @@ void CompilerGLSL::emit_push_constant_block_glsl(const SPIRVariable &var) } 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 = (meta[type.self].decoration.decoration_flags & (1ull << DecorationBufferBlock)) != 0; - bool is_restrict = (meta[var.self].decoration.decoration_flags & (1ull << DecorationRestrict)) != 0; + 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."); - add_resource_name(var.self); + // 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(""); +} - // Block names should never alias. +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 (resource_names.find(buffer_name) != end(resource_names)) - buffer_name = get_fallback_name(type.self); - else - resource_names.insert(buffer_name); + 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); - statement(layout_for_variable(var), is_restrict ? "restrict " : "", ssbo ? "buffer " : "uniform ", buffer_name); begin_scope(); type.member_name_cache.clear(); @@ -1023,68 +1409,173 @@ void CompilerGLSL::emit_buffer_block(const SPIRVariable &var) for (auto &member : type.member_types) { add_member_name(type, i); - - auto &membertype = get(member); - statement(member_decl(type, membertype, 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_interface_block(const SPIRVariable &var) +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 = nullptr; - if (is_legacy() && execution.model == ExecutionModelVertex) - qual = var.storage == StorageClassInput ? "attribute " : "varying "; - else if (is_legacy() && execution.model == ExecutionModelFragment) - qual = "varying "; // Fragment outputs are renamed so they never hit this case. - else - qual = var.storage == StorageClassInput ? "in " : "out "; + const char *qual = to_storage_qualifiers_glsl(var); if (block) { - add_resource_name(var.self); - - // 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) + // 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)) { - add_member_name(type, i); - - auto &membertype = get(member); - statement(member_decl(type, membertype, i), ";"); - i++; + // 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"); + } - end_scope_decl(join(to_name(var.self), type_to_array_glsl(type))); - statement(""); + // 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 { - add_resource_name(var.self); - statement(layout_for_variable(var), qual, variable_decl(var), ";"); + // 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), ";"); + } } } @@ -1100,7 +1591,7 @@ void CompilerGLSL::emit_uniform(const SPIRVariable &var) } add_resource_name(var.self); - statement(layout_for_variable(var), "uniform ", variable_decl(var), ";"); + statement(layout_for_variable(var), variable_decl(var), ";"); } void CompilerGLSL::emit_specialization_constant(const SPIRConstant &constant) @@ -1108,36 +1599,54 @@ void CompilerGLSL::emit_specialization_constant(const SPIRConstant &constant) auto &type = get(constant.constant_type); auto name = to_name(constant.self); - statement("layout(constant_id = ", get_decoration(constant.self, DecorationSpecId), ") const ", - variable_decl(type, name), " = ", constant_expression(constant), ";"); + 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" + "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 @@ -1210,22 +1719,22 @@ void CompilerGLSL::replace_fragment_outputs() } } -string CompilerGLSL::remap_swizzle(uint32_t result_type, uint32_t input_components, uint32_t expr) +string CompilerGLSL::remap_swizzle(const SPIRType &out_type, uint32_t input_components, const string &expr) { - auto &out_type = get(result_type); - if (out_type.vecsize == input_components) - return to_expression(expr); - else if (input_components == 1) - return join(type_to_glsl(out_type), "(", to_expression(expr), ")"); + return expr; + else if (input_components == 1 && !backend.can_swizzle_scalar) + return join(type_to_glsl(out_type), "(", expr, ")"); else { - auto e = to_enclosed_expression(expr) + "."; + 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; } } @@ -1263,6 +1772,136 @@ void CompilerGLSL::emit_pls() } } +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(); @@ -1278,6 +1917,27 @@ void CompilerGLSL::emit_resources() 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, @@ -1330,9 +1990,12 @@ void CompilerGLSL::emit_resources() 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)))) + 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); } @@ -1367,9 +2030,11 @@ void CompilerGLSL::emit_resources() // 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 (separate_image || separate_sampler) + if (!sampler_buffer && (separate_image || separate_sampler)) continue; } @@ -1395,6 +2060,11 @@ void CompilerGLSL::emit_resources() 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)) @@ -1429,6 +2099,8 @@ void CompilerGLSL::emit_resources() if (emitted) statement(""); + + declare_undefined_values(); } // Returns a string representation of the ID, usable as a function arg. @@ -1441,19 +2113,21 @@ string CompilerGLSL::to_func_call_arg(uint32_t id) void CompilerGLSL::handle_invalid_expression(uint32_t id) { - auto &expr = get(id); - - // This expression has been invalidated in the past. - // Be careful with this expression next pass ... - // Used for OpCompositeInsert forwarding atm. - expr.used_while_invalidated = true; - // 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) { @@ -1476,32 +2150,43 @@ void CompilerGLSL::strip_enclosed_expression(string &expr) return; } } - expr.pop_back(); + expr.erase(expr.size() - 1, 1); expr.erase(begin(expr)); } -// Just like to_expression except that we enclose the expression inside parentheses if needed. -string CompilerGLSL::to_enclosed_expression(uint32_t id) +string CompilerGLSL::enclose_expression(const string &expr) { - auto expr = to_expression(id); bool need_parens = false; - uint32_t paren_count = 0; - for (auto c : expr) + + // 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()) { - if (c == '(') - paren_count++; - else if (c == ')') - { - assert(paren_count); - paren_count--; - } - else if (c == ' ' && paren_count == 0) - { + auto c = expr.front(); + if (c == '-' || c == '+' || c == '!' || c == '~') need_parens = true; - break; - } } - assert(paren_count == 0); + + 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. @@ -1512,6 +2197,12 @@ string CompilerGLSL::to_enclosed_expression(uint32_t id) 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); @@ -1546,14 +2237,31 @@ string CompilerGLSL::to_expression(uint32_t id) 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 - return e.expression; + { + 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); - if (c.specialization && options.vulkan_semantics) + + // 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); @@ -1574,16 +2282,32 @@ string CompilerGLSL::to_expression(uint32_t id) 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); + 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); } @@ -1745,7 +2469,7 @@ string CompilerGLSL::constant_expression(const SPIRConstant &c) if (subc.specialization && options.vulkan_semantics) res += to_name(elem); else - res += constant_expression(get(elem)); + res += constant_expression(subc); if (&elem != &c.subconstants.back()) res += ", "; @@ -1763,7 +2487,11 @@ string CompilerGLSL::constant_expression(const SPIRConstant &c) 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 (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 += ", "; } @@ -1778,42 +2506,82 @@ string CompilerGLSL::constant_expression_vector(const SPIRConstant &c, uint32_t type.columns = 1; string res; - if (c.vector_size() > 1) - res += type_to_glsl(type) + "("; + bool splat = backend.use_constructor_splatting && c.vector_size() > 1; + bool swizzle_splat = backend.can_swizzle_scalar && c.vector_size() > 1; - bool splat = c.vector_size() > 1; - if (splat) + if (type.basetype != SPIRType::Float && type.basetype != SPIRType::Double) { - if (type_to_std430_base_size(type) == 8) + // 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) + 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++) { - res += convert_to_string(c.scalar_f32(vector, 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()) @@ -1823,19 +2591,28 @@ string CompilerGLSL::constant_expression_vector(const SPIRConstant &c, uint32_t break; case SPIRType::Double: - if (splat) + 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++) { - res += convert_to_string(c.scalar_f64(vector, i)); - if (backend.double_literal_suffix) - res += "lf"; + 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 += ", "; } @@ -1855,11 +2632,17 @@ string CompilerGLSL::constant_expression_vector(const SPIRConstant &c, uint32_t { for (uint32_t i = 0; i < c.vector_size(); i++) { - res += convert_to_string(c.scalar_i64(vector, i)); - if (backend.long_long_literal_suffix) - res += "ll"; + 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 += "l"; + { + 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 += ", "; } @@ -1879,11 +2662,17 @@ string CompilerGLSL::constant_expression_vector(const SPIRConstant &c, uint32_t { for (uint32_t i = 0; i < c.vector_size(); i++) { - res += convert_to_string(c.scalar_u64(vector, i)); - if (backend.long_long_literal_suffix) - res += "ull"; + 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 += "ul"; + { + 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 += ", "; } @@ -1901,9 +2690,15 @@ string CompilerGLSL::constant_expression_vector(const SPIRConstant &c, uint32_t { for (uint32_t i = 0; i < c.vector_size(); i++) { - res += convert_to_string(c.scalar(vector, i)); - if (backend.uint32_t_literal_suffix) - res += "u"; + 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 += ", "; } @@ -1917,7 +2712,10 @@ string CompilerGLSL::constant_expression_vector(const SPIRConstant &c, uint32_t { for (uint32_t i = 0; i < c.vector_size(); i++) { - res += convert_to_string(c.scalar_i32(vector, 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 += ", "; } @@ -1931,7 +2729,11 @@ string CompilerGLSL::constant_expression_vector(const SPIRConstant &c, uint32_t { for (uint32_t i = 0; i < c.vector_size(); i++) { - res += c.scalar(vector, i) ? "true" : "false"; + 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 += ", "; } @@ -1942,7 +2744,7 @@ string CompilerGLSL::constant_expression_vector(const SPIRConstant &c, uint32_t SPIRV_CROSS_THROW("Invalid constant expression basetype."); } - if (c.vector_size() > 1) + if (c.vector_size() > 1 && !swizzle_splat) res += ")"; return res; @@ -1955,20 +2757,26 @@ string CompilerGLSL::declare_temporary(uint32_t result_type, uint32_t result_id) // 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) + 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)) + }) == 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. @@ -2005,9 +2813,7 @@ void CompilerGLSL::emit_unary_op(uint32_t result_type, uint32_t result_id, uint3 { bool forward = should_forward(op0); emit_op(result_type, result_id, join(op, to_enclosed_expression(op0)), forward); - - if (forward && forced_temporaries.find(result_id) == end(forced_temporaries)) - inherit_expression_dependencies(result_id, op0); + 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) @@ -2016,11 +2822,61 @@ void CompilerGLSL::emit_binary_op(uint32_t result_type, uint32_t result_id, uint emit_op(result_type, result_id, join(to_enclosed_expression(op0), " ", op, " ", to_enclosed_expression(op1)), forward); - if (forward && forced_temporaries.find(result_id) == end(forced_temporaries)) + 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++) { - inherit_expression_dependencies(result_id, op0); - inherit_expression_dependencies(result_id, op1); + // 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, @@ -2087,8 +2943,7 @@ void CompilerGLSL::emit_unary_func_op(uint32_t result_type, uint32_t result_id, { bool forward = should_forward(op0); emit_op(result_type, result_id, join(op, "(", to_expression(op0), ")"), forward); - if (forward && forced_temporaries.find(result_id) == end(forced_temporaries)) - inherit_expression_dependencies(result_id, op0); + 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, @@ -2096,12 +2951,8 @@ void CompilerGLSL::emit_binary_func_op(uint32_t result_type, uint32_t result_id, { bool forward = should_forward(op0) && should_forward(op1); emit_op(result_type, result_id, join(op, "(", to_expression(op0), ", ", to_expression(op1), ")"), forward); - - if (forward && forced_temporaries.find(result_id) == end(forced_temporaries)) - { - inherit_expression_dependencies(result_id, op0); - inherit_expression_dependencies(result_id, op1); - } + 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, @@ -2136,32 +2987,46 @@ void CompilerGLSL::emit_trinary_func_op(uint32_t result_type, uint32_t result_id emit_op(result_type, result_id, join(op, "(", to_expression(op0), ", ", to_expression(op1), ", ", to_expression(op2), ")"), forward); - if (forward && forced_temporaries.find(result_id) == end(forced_temporaries)) - { - inherit_expression_dependencies(result_id, op0); - inherit_expression_dependencies(result_id, op1); - inherit_expression_dependencies(result_id, op2); - } + 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), ")"), + emit_op(result_type, result_id, + join(op, "(", to_expression(op0), ", ", to_expression(op1), ", ", to_expression(op2), ", ", + to_expression(op3), ")"), forward); - if (forward && forced_temporaries.find(result_id) == end(forced_temporaries)) - { - inherit_expression_dependencies(result_id, op0); - inherit_expression_dependencies(result_id, op1); - inherit_expression_dependencies(result_id, op2); - inherit_expression_dependencies(result_id, op3); - } + inherit_expression_dependencies(result_id, op0); + inherit_expression_dependencies(result_id, op1); + inherit_expression_dependencies(result_id, op2); + inherit_expression_dependencies(result_id, op3); } -string CompilerGLSL::legacy_tex_op(const std::string &op, const SPIRType &imgtype) +// 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) @@ -2189,10 +3054,15 @@ string CompilerGLSL::legacy_tex_op(const std::string &op, const SPIRType &imgtyp break; } + bool use_explicit_lod = check_explicit_lod_allowed(lod); + if (op == "textureLod" || op == "textureProjLod") { if (is_legacy_es()) - require_extension("GL_EXT_shader_texture_lod"); + { + if (use_explicit_lod) + require_extension("GL_EXT_shader_texture_lod"); + } else if (is_legacy()) require_extension("GL_ARB_shader_texture_lod"); } @@ -2200,11 +3070,21 @@ string CompilerGLSL::legacy_tex_op(const std::string &op, const SPIRType &imgtyp if (op == "texture") return join("texture", type); else if (op == "textureLod") - return join("texture", type, is_legacy_es() ? "LodEXT" : "Lod"); + { + 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") - return join("texture", type, is_legacy_es() ? "ProjLodEXT" : "ProjLod"); + { + 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)); @@ -2267,9 +3147,15 @@ void CompilerGLSL::emit_mix_op(uint32_t result_type, uint32_t id, uint32_t left, auto &restype = get(result_type); string mix_op; - bool has_boolean_mix = (options.es && options.version >= 310) || (!options.es && options.version >= 450); + 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. @@ -2404,6 +3290,7 @@ void CompilerGLSL::emit_texture_op(const Instruction &i) uint32_t comp = 0; bool gather = false; bool proj = false; + bool fetch = false; const uint32_t *opt = nullptr; switch (op) @@ -2418,23 +3305,30 @@ void CompilerGLSL::emit_texture_op(const Instruction &i) case OpImageSampleProjDrefImplicitLod: case OpImageSampleProjDrefExplicitLod: dref = ops[4]; - proj = true; opt = &ops[5]; length -= 5; + proj = true; break; case OpImageDrefGather: dref = ops[4]; opt = &ops[5]; - gather = true; length -= 5; + gather = true; break; case OpImageGather: comp = ops[4]; opt = &ops[5]; - gather = true; 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: @@ -2450,7 +3344,10 @@ void CompilerGLSL::emit_texture_op(const Instruction &i) break; } - auto &imgtype = expression_type(img); + // 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) { @@ -2491,8 +3388,7 @@ void CompilerGLSL::emit_texture_op(const Instruction &i) if (length) { - flags = opt[0]; - opt++; + flags = *opt++; length--; } @@ -2514,35 +3410,70 @@ void CompilerGLSL::emit_texture_op(const Instruction &i) test(sample, ImageOperandsSampleMask); string expr; - string texop; + 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 += ")"; - if (op == OpImageFetch) - texop += "texelFetch"; - else + 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) { - texop += "texture"; - - if (gather) - texop += "Gather"; - if (coffsets) - texop += "Offsets"; - if (proj) - texop += "Proj"; - if (grad_x || grad_y) - texop += "Grad"; - if (lod) - texop += "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 (coffset || offset) - texop += "Offset"; + if (is_fetch) + fname += "texelFetch"; + else + { + fname += "texture"; - if (is_legacy()) - texop = legacy_tex_op(texop, imgtype); + 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"; + } - expr += texop; - expr += "("; - expr += to_expression(img); + 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 * { @@ -2569,7 +3500,22 @@ void CompilerGLSL::emit_texture_op(const Instruction &i) // Only enclose the UV expression if needed. auto coord_expr = (*swizzle_expr == '\0') ? to_expression(coord) : (to_enclosed_expression(coord) + swizzle_expr); - // TODO: implement rest ... A bit intensive. + // 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) { @@ -2578,84 +3524,128 @@ void CompilerGLSL::emit_texture_op(const Instruction &i) // SPIR-V splits dref and coordinate. if (coord_components == 4) // GLSL also splits the arguments in two. { - expr += ", "; - expr += to_expression(coord); - expr += ", "; - expr += to_expression(dref); + 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; - expr += ", "; - expr += type_to_glsl_constructor(type); - expr += "("; - expr += coord_expr; - expr += ", "; - expr += to_expression(dref); - expr += ")"; + 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 { - expr += ", "; - expr += coord_expr; + farg_str += ", "; + farg_str += coord_expr; } if (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); + farg_str += ", "; + farg_str += to_expression(grad_x); + farg_str += ", "; + farg_str += to_expression(grad_y); } if (lod) { - forward = forward && should_forward(lod); - expr += ", "; - expr += to_expression(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); - expr += ", "; - expr += to_expression(coffset); + farg_str += ", "; + farg_str += to_expression(coffset); } else if (offset) { forward = forward && should_forward(offset); - expr += ", "; - expr += to_expression(offset); + farg_str += ", "; + farg_str += to_expression(offset); } if (bias) { forward = forward && should_forward(bias); - expr += ", "; - expr += to_expression(bias); + farg_str += ", "; + farg_str += to_expression(bias); } if (comp) { forward = forward && should_forward(comp); - expr += ", "; - expr += to_expression(comp); + farg_str += ", "; + farg_str += to_expression(comp); } if (sample) { - expr += ", "; - expr += to_expression(sample); + farg_str += ", "; + farg_str += to_expression(sample); } - expr += ")"; + *p_forward = forward; - emit_op(result_type, id, expr, 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) @@ -2711,6 +3701,19 @@ void CompilerGLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop, 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: @@ -2820,6 +3823,20 @@ void CompilerGLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop, 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; @@ -2910,6 +3927,150 @@ void CompilerGLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop, } } +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) @@ -2936,6 +4097,8 @@ string CompilerGLSL::bitcast_glsl_op(const SPIRType &out_type, const SPIRType &i 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 ""; } @@ -2949,7 +4112,32 @@ string CompilerGLSL::bitcast_glsl(const SPIRType &result_type, uint32_t argument return join(op, "(", to_expression(argument), ")"); } -string CompilerGLSL::builtin_to_glsl(BuiltIn builtin) +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) { @@ -2957,6 +4145,10 @@ string CompilerGLSL::builtin_to_glsl(BuiltIn builtin) 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( @@ -2983,6 +4175,8 @@ string CompilerGLSL::builtin_to_glsl(BuiltIn builtin) return "gl_InvocationID"; case BuiltInLayer: return "gl_Layer"; + case BuiltInViewportIndex: + return "gl_ViewportIndex"; case BuiltInTessLevelOuter: return "gl_TessLevelOuter"; case BuiltInTessLevelInner: @@ -3009,8 +4203,46 @@ string CompilerGLSL::builtin_to_glsl(BuiltIn builtin) 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 "gl_???"; + return join("gl_BuiltIn_", convert_to_string(builtin)); } } @@ -3031,20 +4263,30 @@ const char *CompilerGLSL::index_to_swizzle(uint32_t index) } } -string CompilerGLSL::access_chain(uint32_t base, const uint32_t *indices, uint32_t count, bool index_is_literal, - bool chain_only) +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); - const auto *type = &expression_type(base); + uint32_t type_id = expression_type_id(base); + const auto *type = &get(type_id); - // For resolving array accesses, etc, keep a local copy for poking. - SPIRType temp; + // 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++) { @@ -3053,18 +4295,87 @@ string CompilerGLSL::access_chain(uint32_t base, const uint32_t *indices, uint32 // Arrays if (!type->array.empty()) { - expr += "["; - if (index_is_literal) - expr += convert_to_string(index); - else - expr += to_expression(index); - expr += "]"; + // 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 += "["; + } - // We have to modify the type, so keep a local copy. - if (&temp != type) - temp = *type; - type = &temp; - temp.array.pop_back(); + 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; } @@ -3087,16 +4398,25 @@ string CompilerGLSL::access_chain(uint32_t base, const uint32_t *indices, uint32 if (access_chain_is_arrayed) { expr += "."; - expr += builtin_to_glsl(builtin); + expr += builtin_to_glsl(builtin, type->storage); } else - expr = builtin_to_glsl(builtin); + expr = builtin_to_glsl(builtin, type->storage); } else { - expr += "."; - expr += to_member_name(*type, index); + // 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]); } @@ -3105,7 +4425,7 @@ string CompilerGLSL::access_chain(uint32_t base, const uint32_t *indices, uint32 { if (row_major_matrix_needs_conversion) { - expr = convert_row_major_matrix(expr); + expr = convert_row_major_matrix(expr, *type); row_major_matrix_needs_conversion = false; } @@ -3116,15 +4436,18 @@ string CompilerGLSL::access_chain(uint32_t base, const uint32_t *indices, uint32 expr += to_expression(index); expr += "]"; - // We have to modify the type, so keep a local copy. - if (&temp != type) - temp = *type; - type = &temp; - temp.columns = 1; + 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 += "."; @@ -3143,19 +4466,424 @@ string CompilerGLSL::access_chain(uint32_t base, const uint32_t *indices, uint32 expr += "]"; } - // We have to modify the type, so keep a local copy. - if (&temp != type) - temp = *type; - type = &temp; - temp.vecsize = 1; + 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. @@ -3227,12 +4955,25 @@ void CompilerGLSL::register_call_out_argument(uint32_t id) 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(*var), ";"); + statement(variable_decl_function_local(*var), ";"); var->deferred_declaration = false; } } @@ -3340,20 +5081,24 @@ bool CompilerGLSL::remove_unity_swizzle(uint32_t base, string &op) return true; } -string CompilerGLSL::build_composite_combiner(const uint32_t *elems, uint32_t length) +string CompilerGLSL::build_composite_combiner(uint32_t return_type, const uint32_t *elems, uint32_t length) { uint32_t base = 0; - bool swizzle_optimization = false; 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 (e && e->base_expression && e->base_expression == base) + 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() == '.'); @@ -3364,7 +5109,7 @@ string CompilerGLSL::build_composite_combiner(const uint32_t *elems, uint32_t le { // We'll likely end up with duplicated swizzles, e.g. // foobar.xyz.xyz from patterns like - // OpVectorSwizzle + // OpVectorShuffle // OpCompositeExtract x 3 // OpCompositeConstruct 3x + other scalar. // Just modify op in-place. @@ -3444,6 +5189,10 @@ bool CompilerGLSL::optimize_read_modify_write(const string &lhs, const string &r 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. @@ -3455,6 +5204,14 @@ bool CompilerGLSL::optimize_read_modify_write(const string &lhs, const string &r 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); @@ -3489,14 +5246,34 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) // 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, convert it to column-major + // 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 (is_non_native_row_major_matrix(ptr)) - expr = convert_row_major_matrix(expr); + + 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. - emit_op(result_type, id, expr, forward, true); + 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; } @@ -3509,9 +5286,18 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) // 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. - auto e = access_chain(ops[2], &ops[3], length - 3, false); + 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; } @@ -3523,15 +5309,19 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) 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 lhs = to_expression(ops[0]); auto rhs = to_expression(ops[1]); - - // It is possible with OpLoad/OpCompositeInsert/OpStore that we get = . - // For this case, we don't need to invalidate anything and emit any opcode. - if (lhs != rhs) + // 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. @@ -3548,7 +5338,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) { uint32_t result_type = ops[0]; uint32_t id = ops[1]; - auto e = access_chain(ops[2], &ops[3], length - 3, true); + auto e = access_chain_internal(ops[2], &ops[3], length - 3, true); set(id, e + ".length()", result_type, true); break; } @@ -3657,48 +5447,82 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) const auto *elems = &ops[2]; length -= 2; - if (!length) - SPIRV_CROSS_THROW("Invalid input to OpCompositeConstruct."); - bool forward = true; for (uint32_t i = 0; i < length; i++) forward = forward && should_forward(elems[i]); - auto &in_type = expression_type(elems[0]); 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; + 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 (splat) + 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(elems, length); + 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(elems, length); + constructor_op += build_composite_combiner(result_type, elems, length); constructor_op += ")"; } @@ -3719,7 +5543,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) // 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(id, &index, 1, false); + auto chain = access_chain_internal(id, &index, 1, false); statement(chain, " = ", to_expression(comp), ";"); break; } @@ -3729,7 +5553,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) uint32_t result_type = ops[0]; uint32_t id = ops[1]; - auto expr = access_chain(ops[2], &ops[3], 1, false); + auto expr = access_chain_internal(ops[2], &ops[3], 1, false); emit_op(result_type, id, expr, should_forward(ops[2])); break; } @@ -3745,6 +5569,11 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) // 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) { @@ -3760,13 +5589,13 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) // // 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(ops[2], &ops[3], length, true, true); + 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(ops[2], &ops[3], length, true); + 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; @@ -3783,26 +5612,12 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) flush_variable_declaration(composite); - auto *expr = maybe_get(id); - if ((expr && expr->used_while_invalidated) || !should_forward(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(id, elems, length, true); - statement(chain, " = ", to_expression(obj), ";"); - } - else - { - auto chain = access_chain(composite, elems, length, true); - statement(chain, " = ", to_expression(obj), ";"); - set(id, to_expression(composite), result_type, true); + // 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), ";"); - register_write(composite); - register_read(id, composite, true); - // Invalidate the old expression we inserted into. - invalid_expressions.insert(composite); - } break; } @@ -3866,10 +5681,11 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) shuffle = true; string expr; - bool trivial_forward; + 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. @@ -3885,13 +5701,19 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) } 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 += "()"; } @@ -3899,7 +5721,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) // 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_forward(vec0) && should_forward(vec1), trivial_forward); + emit_op(result_type, id, expr, should_fwd, trivial_forward); break; } @@ -3947,11 +5769,25 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) break; } - case OpFMul: + 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 OpVectorTimesMatrix: case OpMatrixTimesMatrix: BOP(*); break; @@ -4046,16 +5882,42 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) break; case OpLogicalOr: - BOP(||); + { + // 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: - BOP(&&); + { + // 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: - UOP(!); + { + auto &type = get(ops[0]); + if (type.vecsize > 1) + UFOP(not); + else + UOP(!); break; + } case OpIEqual: { @@ -4255,6 +6117,46 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) 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()) @@ -4263,12 +6165,14 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) // 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: - QFOP(bitfieldExtract); + // TODO: The signedness of inputs is strict in GLSL, but not in SPIR-V, bitcast if necessary. + TFOP(bitfieldExtract); break; case OpBitReverse: @@ -4312,12 +6216,13 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) 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; - // OpAtomicStore unimplemented. Not sure what would use that. - // OpAtomicLoad seems to only be relevant for atomic counters. + case OpAtomicStore: + SPIRV_CROSS_THROW("Unsupported opcode OpAtomicStore."); case OpAtomicIIncrement: forced_temporaries.insert(ops[1]); @@ -4470,27 +6375,36 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) 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."); - UFOP(textureQueryLevels); + + 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 *var = maybe_get_backing_variable(ops[2]); - if (!var) - SPIRV_CROSS_THROW( - "Bug. OpImageQuerySamples must have a backing variable so we know if the image is sampled or not."); + auto &type = expression_type(ops[2]); + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; - auto &type = get(var->basetype); - bool image = type.image.sampled == 2; - if (image) - UFOP(imageSamples); + string expr; + if (type.image.sampled == 2) + expr = join("imageSamples(", to_expression(ops[2]), ")"); else - UFOP(textureSamples); + 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; } @@ -4503,8 +6417,16 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) } case OpImageQuerySizeLod: - BFOP(textureSize); + { + 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: @@ -4544,14 +6466,14 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) // 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(result_type, var->remapped_components, ops[2]); + 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(result_type, components, ops[2]); + imgexpr = remap_swizzle(get(result_type), components, to_expression(ops[2])); } pure = true; } @@ -4592,10 +6514,17 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) 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) { @@ -4604,23 +6533,27 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) 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]), ", ", to_expression(ops[3]), ", ", - to_expression(samples), ")"); + imgexpr = + join("imageLoad(", to_expression(ops[2]), ", ", coord_expr, ", ", to_expression(samples), ")"); } else - imgexpr = join("imageLoad(", to_expression(ops[2]), ", ", to_expression(ops[3]), ")"); + imgexpr = join("imageLoad(", to_expression(ops[2]), ", ", coord_expr, ")"); + + imgexpr = remap_swizzle(get(result_type), 4, imgexpr); pure = false; } if (var && var->forwardable) { - auto &e = emit_op(result_type, id, imgexpr, true); + 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; - var->dependees.push_back(id); + if (forward) + var->dependees.push_back(id); } } else @@ -4657,18 +6590,28 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) } 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]), ", ", to_expression(ops[1]), ", ", to_expression(samples), - ", ", to_expression(ops[2]), ");"); + 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]), ", ", to_expression(ops[1]), ", ", to_expression(ops[2]), - ");"); + 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(); @@ -4683,8 +6626,21 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) if (type.basetype == SPIRType::Image) { - // The size of an image is always constant. - emit_op(result_type, id, join("imageSize(", to_expression(ops[2]), ")"), true); + 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."); @@ -4693,45 +6649,282 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) // Compute case OpControlBarrier: - { - // Ignore execution and memory scope. - if (get_entry_point().model == ExecutionModelGLCompute) - { - uint32_t mem = get(ops[2]).scalar(); - if (mem == MemorySemanticsWorkgroupMemoryMask) - statement("memoryBarrierShared();"); - else if (mem) - statement("memoryBarrier();"); - } - statement("barrier();"); - break; - } - case OpMemoryBarrier: { - uint32_t mem = get(ops[1]).scalar(); + if (get_entry_point().model == ExecutionModelTessellationControl) + { + // Control shaders only have barriers, and it implies memory barriers. + if (opcode == OpControlBarrier) + statement("barrier();"); + break; + } - // We cannot forward any loads beyond the memory barrier. - if (mem) + 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 (mem == MemorySemanticsWorkgroupMemoryMask) - statement("memoryBarrierShared();"); - else if (mem) - statement("memoryBarrier();"); + 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) + + 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; } - emit_glsl_op(ops[0], ops[1], ops[3], &ops[4], length - 4); + 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; } @@ -4748,13 +6941,23 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) // 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 calls all the way up the nesting chain. +// 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++) - arglist.push_back(to_func_call_arg(args[arg_idx].id)); + { + 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) @@ -4763,7 +6966,7 @@ string CompilerGLSL::to_member_name(const SPIRType &type, uint32_t index) if (index < memb.size() && !memb[index].alias.empty()) return memb[index].alias; else - return join("_", index); + return join("_m", index); } void CompilerGLSL::add_member_name(SPIRType &type, uint32_t index) @@ -4786,11 +6989,12 @@ void CompilerGLSL::add_member_name(SPIRType &type, uint32_t index) } } -// Checks whether the member is a row_major matrix that requires conversion before use +// 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. - if (backend.native_row_major_matrix) + // 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. @@ -4811,7 +7015,7 @@ bool CompilerGLSL::is_non_native_row_major_matrix(uint32_t id) 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) + if (backend.native_row_major_matrix && !is_legacy()) return false; // Non-matrix or column-major matrix types do not need to be converted. @@ -4828,25 +7032,37 @@ bool CompilerGLSL::member_is_non_native_row_major_matrix(const SPIRType &type, u 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) +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) +string CompilerGLSL::variable_decl(const SPIRType &type, const string &name, uint32_t id) { - string type_name = type_to_glsl(type); + 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)); } -string CompilerGLSL::member_decl(const SPIRType &type, const SPIRType &membertype, uint32_t index) +// 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()) @@ -4858,22 +7074,23 @@ string CompilerGLSL::member_decl(const SPIRType &type, const SPIRType &membertyp if (is_block) qualifiers = to_interpolation_qualifiers(memberflags); - return join(layout_for_member(type, index), flags_to_precision_qualifiers_glsl(membertype, memberflags), qualifiers, - variable_decl(membertype, to_member_name(type, index))); + 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(); - // 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 (flags & (1ull << DecorationRelaxedPrecision)) { bool implied_fmediump = type.basetype == SPIRType::Float && @@ -4901,6 +7118,19 @@ const char *CompilerGLSL::flags_to_precision_qualifiers_glsl(const SPIRType &typ 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 ""; } @@ -4920,24 +7150,31 @@ string CompilerGLSL::to_qualifiers_glsl(uint32_t id) if (var && var->storage == StorageClassWorkgroup && !backend.shared_is_implied) res += "shared "; - res += to_precision_qualifiers_glsl(id); 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 ... - // Not sure if argument being pointer type should make the argument inout. auto &type = expression_type(arg.id); const char *direction = ""; @@ -4949,18 +7186,28 @@ string CompilerGLSL::argument_decl(const SPIRFunction::Parameter &arg) direction = "out "; } - return join(direction, to_qualifiers_glsl(arg.id), variable_decl(type, to_name(arg.id))); + 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))); - if (variable.loop_variable) - res += join(" = ", to_expression(variable.static_expression)); + + 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) - res += join(" = ", to_expression(variable.initializer)); + { + uint32_t expr = variable.initializer; + if (ids[expr].get_type() != TypeUndef) + res += join(" = ", to_expression(variable.initializer)); + } return res; } @@ -4999,6 +7246,11 @@ 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); @@ -5023,17 +7275,43 @@ string CompilerGLSL::type_to_array_glsl(const SPIRType &type) if (type.array.empty()) return ""; - string res; - for (auto i = uint32_t(type.array.size()); i; i--) + if (options.flatten_multidimensional_arrays) { + string res; res += "["; - res += to_array_size(type, i - 1); + 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; } - return res; } -string CompilerGLSL::image_type_glsl(const SPIRType &type) +string CompilerGLSL::image_type_glsl(const SPIRType &type, uint32_t /* id */) { auto &imagetype = get(type.image.type); string res; @@ -5056,7 +7334,13 @@ string CompilerGLSL::image_type_glsl(const SPIRType &type) // 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) - res += type.image.sampled == 2 ? "image" : "texture"; + { + // 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"; @@ -5106,13 +7390,26 @@ string CompilerGLSL::image_type_glsl(const SPIRType &type) 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; } -string CompilerGLSL::type_to_glsl(const SPIRType &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 CompilerGLSL::type_to_glsl(const SPIRType &type, uint32_t id) { // Ignore the pointer type since GLSL doesn't have pointers. @@ -5127,11 +7424,12 @@ string CompilerGLSL::type_to_glsl(const SPIRType &type) case SPIRType::Image: case SPIRType::SampledImage: - return image_type_glsl(type); + return image_type_glsl(type, id); case SPIRType::Sampler: - // Not really used. - return "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"; @@ -5226,9 +7524,8 @@ string CompilerGLSL::type_to_glsl(const SPIRType &type) } } -void CompilerGLSL::add_variable(unordered_set &variables, uint32_t id) +void CompilerGLSL::add_variable(unordered_set &variables, string &name) { - auto &name = meta[id].decoration.alias; if (name.empty()) return; @@ -5242,6 +7539,12 @@ void CompilerGLSL::add_variable(unordered_set &variables, uint32_t id) 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); @@ -5257,15 +7560,40 @@ 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 (forced_extensions.find(ext) == end(forced_extensions)) + if (!has_extension(ext)) { - forced_extensions.insert(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); @@ -5388,41 +7716,36 @@ void CompilerGLSL::emit_function(SPIRFunction &func, uint64_t return_flags) if (!func.analyzed_variable_scope) { - if (options.cfg_analysis) + 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) { - analyze_variable_scope(func); + auto &b = get(block); + if (b.loop_variables.size() < 2) + continue; - // 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) + 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) { - 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) { - 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(); + invalid_initializers = true; + break; } } + + if (invalid_initializers) + { + for (auto loop_variable : b.loop_variables) + get(loop_variable).loop_variable = false; + b.loop_variables.clear(); + } } - else - entry_block.dominated_variables = func.local_variables; func.analyzed_variable_scope = true; } @@ -5434,18 +7757,21 @@ void CompilerGLSL::emit_function(SPIRFunction &func, uint64_t return_flags) add_local_variable_name(var.self); if (var.initializer) - statement(variable_decl(var), ";"); + 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. - var.deferred_declaration = true; + // 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: SPIRV likes to use samplers and images as local variables, but GLSL does not allow this. + // 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. @@ -5471,10 +7797,16 @@ void CompilerGLSL::emit_function(SPIRFunction &func, uint64_t return_flags) void CompilerGLSL::emit_fixup() { auto &execution = get_entry_point(); - if (execution.model == ExecutionModelVertex && options.vertex.fixup_clipspace) + if (execution.model == ExecutionModelVertex) { - const char *suffix = backend.float_literal_suffix ? "f" : ""; - statement("gl_Position.z = 2.0", suffix, " * gl_Position.z - gl_Position.w;"); + 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;"); } } @@ -5492,8 +7824,27 @@ void CompilerGLSL::flush_phi(uint32_t from, uint32_t to) auto &child = get(to); for (auto &phi : child.phi_variables) + { if (phi.parent == from) - statement(to_expression(phi.function_variable), " = ", to_expression(phi.local_variable), ";"); + { + 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) @@ -5655,8 +8006,7 @@ string CompilerGLSL::emit_continue_block(uint32_t continue_block) { propagate_loop_dominators(*block); // Write out all instructions we have in this block. - for (auto &op : block->ops) - emit_instruction(op); + emit_block_instructions(*block); // For plain branchless for/while continue blocks. if (block->next_block) @@ -5692,31 +8042,95 @@ string CompilerGLSL::emit_for_loop_initializers(const SPIRBlock &block) if (block.loop_variables.empty()) return ""; - if (block.loop_variables.size() == 1) + 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 { - auto &var = get(block.loop_variables.front()); - auto &type = get(var.basetype); - - // Don't remap the type here as we have multiple names, - // doesn't make sense to remap types for loop variables anyways. - // It is assumed here that all relevant qualifiers are equal for all loop variables. - string expr = join(to_qualifiers_glsl(var.self), type_to_glsl(type), " "); + // 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) { - auto &v = get(loop_var); - expr += join(to_name(loop_var), " = ", to_expression(v.static_expression)); - if (&loop_var != &block.loop_variables.back()) - expr += ", "; + 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)); @@ -5727,8 +8141,7 @@ bool CompilerGLSL::attempt_emit_loop_header(SPIRBlock &block, SPIRBlock::Method // 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. - for (auto &op : block.ops) - emit_instruction(op); + emit_block_instructions(block); bool condition_is_temporary = forced_temporaries.find(block.condition) == end(forced_temporaries); @@ -5738,11 +8151,22 @@ bool CompilerGLSL::attempt_emit_loop_header(SPIRBlock &block, SPIRBlock::Method switch (continue_type) { case SPIRBlock::ForLoop: - statement("for (", emit_for_loop_initializers(block), "; ", to_expression(block.condition), "; ", - emit_continue_block(block.continue_block), ")"); + { + // 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; @@ -5773,8 +8197,7 @@ bool CompilerGLSL::attempt_emit_loop_header(SPIRBlock &block, SPIRBlock::Method // 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. - for (auto &op : child.ops) - emit_instruction(op); + emit_block_instructions(child); bool condition_is_temporary = forced_temporaries.find(child.condition) == end(forced_temporaries); @@ -5785,9 +8208,15 @@ bool CompilerGLSL::attempt_emit_loop_header(SPIRBlock &block, SPIRBlock::Method switch (continue_type) { case SPIRBlock::ForLoop: - statement("for (", emit_for_loop_initializers(block), "; ", to_expression(child.condition), "; ", - emit_continue_block(block.continue_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(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), ")"); @@ -5815,6 +8244,9 @@ bool CompilerGLSL::attempt_emit_loop_header(SPIRBlock &block, SPIRBlock::Method 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); @@ -5872,10 +8304,11 @@ void CompilerGLSL::emit_block_chain(SPIRBlock &block) } else if (continue_type == SPIRBlock::DoWhileLoop) { + flush_undeclared_variables(block); statement("do"); begin_scope(); - for (auto &op : block.ops) - emit_instruction(op); + + emit_block_instructions(block); } else if (block.merge == SPIRBlock::MergeLoop) { @@ -5887,13 +8320,12 @@ void CompilerGLSL::emit_block_chain(SPIRBlock &block) statement("for (;;)"); begin_scope(); - for (auto &op : block.ops) - emit_instruction(op); + + emit_block_instructions(block); } else { - for (auto &op : block.ops) - emit_instruction(op); + emit_block_instructions(block); } // If we didn't successfully emit a loop header and we had loop variable candidates, we have a problem @@ -6000,6 +8432,10 @@ void CompilerGLSL::emit_block_chain(SPIRBlock &block) statement(backend.discard_literal, ";"); break; + case SPIRBlock::Unreachable: + emit_next_block = false; + break; + default: SPIRV_CROSS_THROW("Unimplemented block terminator."); } @@ -6090,3 +8526,20 @@ void CompilerGLSL::check_function_call_constraints(const uint32_t *args, uint32_ } } } + +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 index a8824f6b46..5421f258e9 100644 --- a/deps/SPIRV-Cross/spirv_glsl.hpp +++ b/deps/SPIRV-Cross/spirv_glsl.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 ARM Limited + * 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. @@ -56,17 +56,37 @@ class CompilerGLSL : public Compiler public: struct Options { + // The shading language version. Corresponds to #version $VALUE. uint32_t version = 450; - bool es = false; - bool force_temporary = false; - // If true, variables will be moved to their appropriate scope through CFG analysis. - bool cfg_analysis = true; + // 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, @@ -77,8 +97,13 @@ public: struct { - // In vertex shaders, rewrite [0, w] depth (Vulkan/D3D style) to [-w, w] depth (GL style). - bool fixup_clipspace = true; + // 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 @@ -100,11 +125,13 @@ public: CompilerGLSL(std::vector spirv_) : Compiler(move(spirv_)) { - if (source.known) - { - options.es = source.es; - options.version = source.version; - } + init(); + } + + CompilerGLSL(const uint32_t *ir, size_t word_count) + : Compiler(ir, word_count) + { + init(); } const Options &get_options() const @@ -138,28 +165,63 @@ public: // 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); - virtual std::string builtin_to_glsl(spv::BuiltIn builtin); - virtual std::string member_decl(const SPIRType &type, const SPIRType &member_type, uint32_t member); - virtual std::string image_type_glsl(const SPIRType &type); + 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); + 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; @@ -181,6 +243,14 @@ protected: 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 @@ -219,14 +289,16 @@ protected: 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); - bool is_non_native_row_major_matrix(uint32_t id); - bool member_is_non_native_row_major_matrix(const SPIRType &type, uint32_t index); - virtual std::string convert_row_major_matrix(std::string exp_str); + 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; @@ -249,21 +321,30 @@ protected: 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(const SPIRVariable &type); - void emit_push_constant_block(const SPIRVariable &var); + 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 emit_uniform(const SPIRVariable &var); void propagate_loop_dominators(const SPIRBlock &block); void branch(uint32_t from, uint32_t to); @@ -284,7 +365,9 @@ protected: 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); @@ -295,39 +378,64 @@ protected: 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(uint32_t base, const uint32_t *indices, uint32_t count, bool index_is_literal, - bool chain_only = 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(uint32_t result_type, uint32_t input_components, uint32_t expr); + 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); - std::string to_qualifiers_glsl(uint32_t id); + 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); - std::string layout_for_member(const SPIRType &type, uint32_t index); - std::string to_interpolation_qualifiers(uint64_t flags); + 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); - bool skip_argument(uint32_t id) const; + virtual bool skip_argument(uint32_t id) const; - bool ssbo_is_std430_packing(const SPIRType &type); - uint32_t type_to_std430_base_size(const SPIRType &type); - uint32_t type_to_std430_alignment(const SPIRType &type, uint64_t flags); - uint32_t type_to_std430_array_stride(const SPIRType &type, uint64_t flags); - uint32_t type_to_std430_size(const SPIRType &type, uint64_t flags); + 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); - std::string bitcast_glsl_op(const SPIRType &result_type, const SPIRType &argument_type); - std::string build_composite_combiner(const uint32_t *elems, uint32_t length); + 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); @@ -335,24 +443,30 @@ protected: // and force recompile. bool check_atomic_image(uint32_t id); - void replace_illegal_names(); + virtual void replace_illegal_names(); void replace_fragment_output(SPIRVariable &var); void replace_fragment_outputs(); - std::string legacy_tex_op(const std::string &op, const SPIRType &imgtype); + 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; - std::unordered_set forced_temporaries; - std::unordered_set forwarded_temporaries; void track_expression_read(uint32_t id); - std::unordered_set forced_extensions; + std::vector forced_extensions; std::vector header_lines; uint32_t statement_count; @@ -385,13 +499,35 @@ protected: 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; + } + } }; } diff --git a/deps/SPIRV-Cross/spirv_hlsl.cpp b/deps/SPIRV-Cross/spirv_hlsl.cpp new file mode 100644 index 0000000000..09c6a502aa --- /dev/null +++ b/deps/SPIRV-Cross/spirv_hlsl.cpp @@ -0,0 +1,3676 @@ +/* + * 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 new file mode 100644 index 0000000000..7144b5cdca --- /dev/null +++ b/deps/SPIRV-Cross/spirv_hlsl.hpp @@ -0,0 +1,164 @@ +/* + * 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 index 8ab5b3999f..70e9b4108f 100644 --- a/deps/SPIRV-Cross/spirv_msl.cpp +++ b/deps/SPIRV-Cross/spirv_msl.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 The Brenwill Workshop Ltd. + * 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. @@ -16,6 +16,7 @@ #include "spirv_msl.hpp" #include "GLSL.std.450.h" + #include #include @@ -23,40 +24,43 @@ using namespace spv; using namespace spirv_cross; using namespace std; -CompilerMSL::CompilerMSL(vector spirv_) +static const uint32_t k_unknown_location = ~0; + +CompilerMSL::CompilerMSL(vector spirv_, vector *p_vtx_attrs, + vector *p_res_bindings) : CompilerGLSL(move(spirv_)) { - options.vertex.fixup_clipspace = false; -} - -string CompilerMSL::compile(MSLConfiguration &msl_cfg, vector *p_vtx_attrs, - std::vector *p_res_bindings) -{ - pad_type_ids_by_pad_len.clear(); - - msl_config = msl_cfg; - - vtx_attrs_by_location.clear(); if (p_vtx_attrs) for (auto &va : *p_vtx_attrs) vtx_attrs_by_location[va.location] = &va; - resource_bindings.clear(); if (p_res_bindings) - { - resource_bindings.reserve(p_res_bindings->size()); for (auto &rb : *p_res_bindings) resource_bindings.push_back(&rb); - } +} - extract_builtins(); - localize_global_variables(); - add_interface_structs(); - extract_global_variables_from_functions(); +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]; - // Do not deal with ES-isms like precision, older extensions and such. - options.es = false; - options.version = 120; + 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"; @@ -64,7 +68,41 @@ string CompilerMSL::compile(MSLConfiguration &msl_cfg, vector *p_ 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 @@ -80,8 +118,9 @@ string CompilerMSL::compile(MSLConfiguration &msl_cfg, vector *p_ buffer = unique_ptr(new ostringstream()); emit_header(); + emit_specialization_constants(); emit_resources(); - emit_function_declarations(); + emit_custom_functions(); emit_function(get(entry_point), 0); pass_count++; @@ -90,60 +129,51 @@ string CompilerMSL::compile(MSLConfiguration &msl_cfg, vector *p_ return buffer->str(); } -string CompilerMSL::compile() +string CompilerMSL::compile(vector *p_vtx_attrs, vector *p_res_bindings) { - MSLConfiguration default_msl_cfg; - return compile(default_msl_cfg, nullptr, nullptr); -} - -// Adds any builtins used by this shader to the builtin_vars collection -void CompilerMSL::extract_builtins() -{ - builtin_vars.clear(); - - for (auto &id : ids) + if (p_vtx_attrs) { - if (id.get_type() == TypeVariable) - { - auto &var = id.get(); - auto &dec = meta[var.self].decoration; - - if (dec.builtin) - builtin_vars[dec.builtin_type] = var.self; - } + vtx_attrs_by_location.clear(); + for (auto &va : *p_vtx_attrs) + vtx_attrs_by_location[va.location] = &va; } - auto &execution = get_entry_point(); - if (execution.model == ExecutionModelVertex) + if (p_res_bindings) { - if (!(builtin_vars[BuiltInVertexIndex] || builtin_vars[BuiltInVertexId])) - add_builtin(BuiltInVertexIndex); + resource_bindings.clear(); + for (auto &rb : *p_res_bindings) + resource_bindings.push_back(&rb); + } - if (!(builtin_vars[BuiltInInstanceIndex] || builtin_vars[BuiltInInstanceId])) - add_builtin(BuiltInInstanceIndex); + 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\""); } } -// Adds an appropriate built-in variable for the specified builtin type. -void CompilerMSL::add_builtin(BuiltIn builtin_type) -{ - - // Add a new typed variable for this interface structure. - uint32_t next_id = increase_bound_by(2); - uint32_t ib_type_id = next_id++; - auto &ib_type = set(ib_type_id); - ib_type.basetype = SPIRType::UInt; - ib_type.storage = StorageClassInput; - - uint32_t ib_var_id = next_id++; - set(ib_var_id, ib_type_id, StorageClassInput, 0); - set_decoration(ib_var_id, DecorationBuiltIn, builtin_type); - set_name(ib_var_id, builtin_to_glsl(builtin_type)); - - builtin_vars[builtin_type] = ib_var_id; -} - -// Move the Private global variables to the entry function. +// 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() { @@ -151,16 +181,30 @@ void CompilerMSL::localize_global_variables() auto iter = global_variables.begin(); while (iter != global_variables.end()) { - uint32_t gv_id = *iter; - auto &gbl_var = get(gv_id); - if (gbl_var.storage == StorageClassPrivate) + uint32_t v_id = *iter; + auto &var = get(v_id); + if (var.storage == StorageClassPrivate || var.storage == StorageClassWorkgroup) { - entry_func.add_local_variable(gv_id); + 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; } } } @@ -171,20 +215,28 @@ void CompilerMSL::extract_global_variables_from_functions() { // Uniforms - std::set global_var_ids; + 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 == 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; - std::set processed_func_ids; + unordered_set processed_func_ids; extract_global_variables_from_function(entry_point, added_arg_ids, global_var_ids, processed_func_ids); } @@ -192,12 +244,16 @@ void CompilerMSL::extract_global_variables_from_functions() // 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, - std::set &global_var_ids, - std::set &processed_func_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); @@ -220,10 +276,20 @@ void CompilerMSL::extract_global_variables_from_function(uint32_t func_id, std:: 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, @@ -238,127 +304,115 @@ void CompilerMSL::extract_global_variables_from_function(uint32_t func_id, std:: } } + 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) { - uint32_t type_id = get(arg_id).basetype; - func.add_parameter(type_id, next_id); - set(next_id, type_id, StorageClassFunction); + 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 both the existing and new variables have the same name, and the name is valid - string vld_name = ensure_valid_name(to_name(arg_id), "v"); - set_name(arg_id, vld_name); - set_name(next_id, vld_name); + // 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]; - meta[next_id].decoration.qualified_alias = meta[arg_id].decoration.qualified_alias; next_id++; } } } -// Adds any interface structure variables needed by this shader -void CompilerMSL::add_interface_structs() +// 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() { - auto &execution = get_entry_point(); - - stage_in_var_ids.clear(); - qual_pos_var_name = ""; - - uint32_t var_id; - if (execution.model == ExecutionModelVertex && !vtx_attrs_by_location.empty()) + for (auto &id : ids) { - std::set vtx_bindings; - bind_vertex_attributes(vtx_bindings); - for (uint32_t vb : vtx_bindings) + if (id.get_type() == TypeVariable) { - var_id = add_interface_struct(StorageClassInput, vb); - if (var_id) - stage_in_var_ids.push_back(var_id); - } - } - else - { - var_id = add_interface_struct(StorageClassInput); - if (var_id) - stage_in_var_ids.push_back(var_id); - } - - stage_out_var_id = add_interface_struct(StorageClassOutput); -} - -// Iterate through the variables and populates each input vertex attribute variable -// from the binding info provided during compiler construction, matching by location. -void CompilerMSL::bind_vertex_attributes(std::set &bindings) -{ - auto &execution = get_entry_point(); - - if (execution.model == ExecutionModelVertex) - { - for (auto &id : ids) - { - if (id.get_type() == TypeVariable) + auto &var = id.get(); + if (var.storage != StorageClassFunction && !is_hidden_variable(var)) { - auto &var = id.get(); auto &type = get(var.basetype); - - if (var.storage == StorageClassInput && interface_variable_exists_in_entry_point(var.self) && - !is_hidden_variable(var) && type.pointer) - { - auto &dec = meta[var.self].decoration; - MSLVertexAttr *p_va = vtx_attrs_by_location[dec.location]; - if (p_va) - { - dec.binding = p_va->msl_buffer; - dec.offset = p_va->msl_offset; - dec.array_stride = p_va->msl_stride; - dec.per_instance = p_va->per_instance; - - // Mark the vertex attributes that were used. - p_va->used_by_shader = true; - bindings.insert(p_va->msl_buffer); - } - } + 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); } } } } -// Add an the interface structure for the type of storage. For vertex inputs, each -// binding must have its own structure, and a structure is created for vtx_binding. -// For non-vertex input, and all outputs, the vtx_binding argument is ignored. -// Returns the ID of the newly added variable, or zero if no variable was added. -uint32_t CompilerMSL::add_interface_struct(StorageClass storage, uint32_t vtx_binding) +// 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) { - auto &execution = get_entry_point(); - bool incl_builtins = (storage == StorageClassOutput); - bool match_binding = (execution.model == ExecutionModelVertex) && (storage == StorageClassInput); + // 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); - auto &dec = meta[var.self].decoration; - if (var.storage == storage && interface_variable_exists_in_entry_point(var.self) && - !is_hidden_variable(var, incl_builtins) && (!match_binding || (vtx_binding == dec.binding)) && - type.pointer) + !is_hidden_variable(var, incl_builtins) && type.pointer) { vars.push_back(&var); } } } + // If no variables qualify, leave if (vars.empty()) - { return 0; - } // Leave if no variables qualify // Add a new typed variable for this interface structure. // The initializer expression is allocated here, but populated when the function @@ -368,32 +422,20 @@ uint32_t CompilerMSL::add_interface_struct(StorageClass storage, uint32_t vtx_bi auto &ib_type = set(ib_type_id); ib_type.basetype = SPIRType::Struct; ib_type.storage = storage; - set_decoration(ib_type.self, DecorationBlock); + 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++; - // Set the binding of the variable and mark if packed (used only with vertex inputs) - auto &var_dec = meta[ib_var_id].decoration; - var_dec.binding = vtx_binding; - - // Track whether this is vertex input that is indexed, as opposed to stage_in - bool is_indxd_vtx_input = (execution.model == ExecutionModelVertex && storage == StorageClassInput && - var_dec.binding != msl_config.vtx_attr_stage_in_binding); - string ib_var_ref; - - if (storage == StorageClassInput) + switch (storage) { + case StorageClassInput: ib_var_ref = stage_in_var_name; + break; - // Multiple vertex input bindings are available, so qualify each with the Metal buffer index - if (execution.model == ExecutionModelVertex) - ib_var_ref += convert_to_string(vtx_binding); - } - - if (storage == StorageClassOutput) + case StorageClassOutput: { ib_var_ref = stage_out_var_name; @@ -408,169 +450,781 @@ uint32_t CompilerMSL::add_interface_struct(StorageClass storage, uint32_t vtx_bi 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); - size_t struct_size = 0; - bool first_elem = true; for (auto p_var : vars) { - // For index-accessed vertex attributes, copy the attribute characteristics to the parent - // structure (all components have same vertex attribute characteristics except offset), - // and add a reference to the vertex index builtin to the parent struct variable name. - if (is_indxd_vtx_input && first_elem) - { - auto &elem_dec = meta[p_var->self].decoration; - var_dec.binding = elem_dec.binding; - var_dec.array_stride = elem_dec.array_stride; - var_dec.per_instance = elem_dec.per_instance; - ib_var_ref += "[" + get_vtx_idx_var_name(var_dec.per_instance) + "]"; - first_elem = false; - } - - auto &type = get(p_var->basetype); + 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 i = 0; - for (auto &member : type.member_types) + uint32_t mbr_idx = 0; + for (auto &mbr_type_id : type.member_types) { - // If needed, add a padding member to the struct to align to the next member's offset. - uint32_t mbr_offset = get_member_decoration(type.self, i, DecorationOffset); - struct_size = - pad_to_offset(ib_type, is_indxd_vtx_input, (var_dec.offset + mbr_offset), uint32_t(struct_size)); + BuiltIn builtin; + bool is_builtin = is_member_builtin(type, mbr_idx, &builtin); - // Add a reference to the member to the interface struct. - auto &membertype = get(member); + 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(membertype.self); + ib_type.member_types.push_back(type_id); - // Give the member a name, and assign it an offset within the struct. - string mbr_name = ensure_valid_name(to_qualified_member_name(type, i), "m"); - set_member_name(ib_type.self, ib_mbr_idx, mbr_name); - set_member_decoration(ib_type.self, ib_mbr_idx, DecorationOffset, uint32_t(struct_size)); - struct_size = get_declared_struct_size(ib_type); + // 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; - set_member_qualified_name(type.self, i, qual_var_name); + meta[p_var->self].decoration.qualified_alias = qual_var_name; // Copy the variable location from the original variable to the member - uint32_t locn = get_member_decoration(type.self, i, DecorationLocation); - set_member_decoration(ib_type.self, ib_mbr_idx, DecorationLocation, locn); + 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 - BuiltIn builtin; - if (is_member_builtin(type, i, &builtin)) + if (is_builtin) { - set_member_decoration(ib_type.self, ib_mbr_idx, DecorationBuiltIn, builtin); + set_member_decoration(ib_type_id, ib_mbr_idx, DecorationBuiltIn, builtin); if (builtin == BuiltInPosition) qual_pos_var_name = qual_var_name; } - - i++; - } - } - else - { - // If needed, add a padding member to the struct to align to the next member's offset. - struct_size = pad_to_offset(ib_type, is_indxd_vtx_input, var_dec.offset, uint32_t(struct_size)); - - // 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.self); - - // Give the member a name, and assign it an offset within the struct. - string mbr_name = ensure_valid_name(to_name(p_var->self), "m"); - set_member_name(ib_type.self, ib_mbr_idx, mbr_name); - set_member_decoration(ib_type.self, ib_mbr_idx, DecorationOffset, uint32_t(struct_size)); - struct_size = get_declared_struct_size(ib_type); - - // 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 - auto &dec = meta[p_var->self].decoration; - set_member_decoration(ib_type.self, ib_mbr_idx, DecorationLocation, dec.location); - - // Mark the member as builtin if needed - if (is_builtin_variable(*p_var)) - { - set_member_decoration(ib_type.self, ib_mbr_idx, DecorationBuiltIn, dec.builtin_type); - if (dec.builtin_type == BuiltInPosition) - qual_pos_var_name = qual_var_name; } } } - // Sort the members of the interface structure by their offsets - MemberSorter memberSorter(ib_type, meta[ib_type.self], MemberSorter::Offset); - memberSorter.sort(); + // 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 &header : header_lines) - statement(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 all basic struct types which are not Block or BufferBlock as these are declared inplace - // when such variables are instantiated. + // 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(); - if (type.basetype == SPIRType::Struct && type.array.empty() && !type.pointer && - (meta[type.self].decoration.decoration_flags & - ((1ull << DecorationBlock) | (1ull << DecorationBufferBlock))) == 0) + 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); } } } - // Output Uniform buffers and constants - for (auto &id : ids) - { - if (id.get_type() == TypeVariable) - { - auto &var = id.get(); - auto &type = get(var.basetype); + declare_undefined_values(); - if (var.storage != StorageClassFunction && type.pointer && - (type.storage == StorageClassUniform || type.storage == StorageClassUniformConstant || - type.storage == StorageClassPushConstant) && - !is_hidden_variable(var) && (meta[type.self].decoration.decoration_flags & - ((1ull << DecorationBlock) | (1ull << DecorationBufferBlock)))) - { - emit_struct(type); - } - } - } - - // Output interface blocks. - for (uint32_t var_id : stage_in_var_ids) - emit_interface_block(var_id); + // 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); +} - // TODO: Consolidate and output loose uniforms into an input struct +// 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 @@ -586,7 +1240,6 @@ void CompilerMSL::emit_instruction(const Instruction &instruction) #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) auto ops = stream(instruction); @@ -595,11 +1248,6 @@ void CompilerMSL::emit_instruction(const Instruction &instruction) switch (opcode) { - // ALU - case OpFMod: - BFOP(fmod); - break; - // Comparisons case OpIEqual: case OpLogicalEqual: @@ -639,63 +1287,549 @@ void CompilerMSL::emit_instruction(const Instruction &instruction) // Derivatives case OpDPdx: + case OpDPdxFine: + case OpDPdxCoarse: UFOP(dfdx); break; case OpDPdy: + case OpDPdyFine: + case OpDPdyCoarse: UFOP(dfdy); break; - case OpImageQuerySize: + // 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: { - auto &type = expression_type(ops[2]); uint32_t result_type = ops[0]; uint32_t id = ops[1]; - - if (type.basetype == SPIRType::Image) - { - string img_exp = to_expression(ops[2]); - auto &img_type = type.image; - switch (img_type.dim) - { - case Dim1D: - if (img_type.arrayed) - emit_op(result_type, id, join("uint2(", img_exp, ".get_width(), ", img_exp, ".get_array_size())"), - false); - else - emit_op(result_type, id, join(img_exp, ".get_width()"), true); - break; - - case Dim2D: - case DimCube: - if (img_type.arrayed) - emit_op(result_type, id, join("uint3(", img_exp, ".get_width(), ", img_exp, ".get_height(), ", - img_exp, ".get_array_size())"), - false); - else - emit_op(result_type, id, join("uint2(", img_exp, ".get_width(), ", img_exp, ".get_height())"), - false); - break; - - case Dim3D: - emit_op(result_type, id, - join("uint3(", img_exp, ".get_width(), ", img_exp, ".get_height(), ", img_exp, ".get_depth())"), - false); - break; - - default: - break; - } - } - else - SPIRV_CROSS_THROW("Invalid type for OpImageQuerySize."); + 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 @@ -708,6 +1842,83 @@ void CompilerMSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop, 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); @@ -722,32 +1933,15 @@ void CompilerMSL::emit_interface_block(uint32_t ib_var_id) { auto &ib_var = get(ib_var_id); auto &ib_type = get(ib_var.basetype); - emit_struct(ib_type); + auto &m = meta.at(ib_type.self); + if (m.members.size() > 0) + emit_struct(ib_type); } } -// Output a declaration statement for each function. -void CompilerMSL::emit_function_declarations() -{ - for (auto &id : ids) - if (id.get_type() == TypeFunction) - { - auto &func = id.get(); - if (func.self != entry_point) - emit_function_prototype(func, true); - } - - statement(""); -} - -void CompilerMSL::emit_function_prototype(SPIRFunction &func, uint64_t) -{ - emit_function_prototype(func, false); -} - // 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, bool is_decl) +void CompilerMSL::emit_function_prototype(SPIRFunction &func, uint64_t) { local_variable_names = resource_names; string decl; @@ -757,7 +1951,7 @@ void CompilerMSL::emit_function_prototype(SPIRFunction &func, bool is_decl) auto &type = get(func.return_type); decl += func_type_decl(type); decl += " "; - decl += clean_func_name(to_name(func.self)); + decl += to_name(func.self); decl += "("; @@ -780,27 +1974,21 @@ void CompilerMSL::emit_function_prototype(SPIRFunction &func, bool is_decl) { add_local_variable_name(arg.id); - bool is_uniform_struct = false; + 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. - - // Check if this arg is one of the synthetic uniform args - // created to handle uniform access inside the function - auto &var_type = get(var->basetype); - is_uniform_struct = - ((var_type.basetype == SPIRType::Struct) && - (var_type.storage == StorageClassUniform || var_type.storage == StorageClassUniformConstant || - var_type.storage == StorageClassPushConstant)); + address_space = get_argument_address_space(*var); } - decl += (is_uniform_struct ? "constant " : "thread "); + 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) + 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()) @@ -808,219 +1996,159 @@ void CompilerMSL::emit_function_prototype(SPIRFunction &func, bool is_decl) } decl += ")"; - statement(decl, (is_decl ? ";" : "")); + statement(decl); } -// Emit a texture operation -void CompilerMSL::emit_texture_op(const Instruction &i) +// 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) { - 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::compile() 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 comp = 0; - bool gather = false; - bool fetch = false; - const uint32_t *opt = nullptr; - - switch (op) - { - case OpImageSampleDrefImplicitLod: - case OpImageSampleDrefExplicitLod: - opt = &ops[5]; - length -= 5; - break; - - case OpImageSampleProjDrefImplicitLod: - case OpImageSampleProjDrefExplicitLod: - opt = &ops[5]; - length -= 5; - break; - - case OpImageDrefGather: - opt = &ops[5]; - gather = true; - length -= 5; - break; - - case OpImageGather: - comp = ops[4]; - opt = &ops[5]; - gather = true; - length -= 5; - break; - - case OpImageFetch: - fetch = true; - opt = &ops[4]; - length -= 4; - break; - - case OpImageSampleImplicitLod: - case OpImageSampleExplicitLod: - case OpImageSampleProjImplicitLod: - case OpImageSampleProjExplicitLod: - default: - opt = &ops[4]; - length -= 4; - break; - } - - 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; - 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); - - auto &img_type = expression_type(img).image; - // Texture reference - string expr = to_expression(img); + string fname = to_expression(img) + "."; // Texture function and sampler - if (fetch) - { - expr += ".read("; - } + if (is_fetch) + fname += "read"; + else if (is_gather) + fname += "gather"; else - { - expr += std::string(".") + (gather ? "gather" : "sample") + "(" + to_sampler_expression(img) + ", "; - } + fname += "sample"; - // Add texture coordinates + 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); - string tex_coords = coord_expr; - string array_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; - switch (img_type.dim) + string tex_coords = coord_expr; + const char *alt_coord = ""; + + switch (imgtype.image.dim) { - case spv::DimBuffer: - break; + case Dim1D: - if (img_type.arrayed) - { - tex_coords = coord_expr + ".x"; - array_coord = coord_expr + ".y"; - remove_duplicate_swizzle(tex_coords); - remove_duplicate_swizzle(array_coord); - } - else - { - tex_coords = coord_expr + ".x"; - } + 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 (msl_config.flip_frag_y) - { - string coord_x = coord_expr + ".x"; - remove_duplicate_swizzle(coord_x); - string coord_y = coord_expr + ".y"; - remove_duplicate_swizzle(coord_y); - tex_coords = "float2(" + coord_x + ", (1.0 - " + coord_y + "))"; - } - else - { - tex_coords = coord_expr + ".xy"; - remove_duplicate_swizzle(tex_coords); - } + if (coord_type.vecsize > 2) + tex_coords += ".xy"; - if (img_type.arrayed) - { - array_coord = coord_expr + ".z"; - remove_duplicate_swizzle(array_coord); - } + 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 (msl_config.flip_frag_y) + if (is_fetch) { - string coord_x = coord_expr + ".x"; - remove_duplicate_swizzle(coord_x); - string coord_y = coord_expr + ".y"; - remove_duplicate_swizzle(coord_y); - string coord_z = coord_expr + ".z"; - remove_duplicate_swizzle(coord_z); - tex_coords = "float3(" + coord_x + ", (1.0 - " + coord_y + "), " + coord_z + ")"; + is_cube_fetch = true; + tex_coords += ".xy"; + tex_coords = "uint2(" + round_fp_tex_coords(tex_coords, coord_is_fp) + ")"; } else { - tex_coords = coord_expr + ".xyz"; - remove_duplicate_swizzle(tex_coords); + if (coord_type.vecsize > 3) + tex_coords += ".xyz"; } - if (img_type.arrayed) - { - array_coord = coord_expr + ".w"; - remove_duplicate_swizzle(array_coord); - } + alt_coord = ".w"; break; default: break; } - expr += tex_coords; - // Add texture array index - if (!array_coord.empty()) - expr += ", " + array_coord; + // 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); - expr += ", bias(" + to_expression(bias) + ")"; + farg_str += ", bias(" + to_expression(bias) + ")"; } if (lod) { forward = forward && should_forward(lod); - if (fetch) + if (is_fetch) { - expr += ", " + to_expression(lod); + farg_str += ", " + to_expression(lod); } else { - expr += ", level(" + to_expression(lod) + ")"; + farg_str += ", level(" + to_expression(lod) + ")"; } } @@ -1029,7 +2157,7 @@ void CompilerMSL::emit_texture_op(const Instruction &i) forward = forward && should_forward(grad_x); forward = forward && should_forward(grad_y); string grad_opt; - switch (img_type.dim) + switch (imgtype.image.dim) { case Dim2D: grad_opt = "2d"; @@ -1044,7 +2172,7 @@ void CompilerMSL::emit_texture_op(const Instruction &i) grad_opt = "unsupported_gradient_dimension"; break; } - expr += ", gradient" + grad_opt + "(" + to_expression(grad_x) + ", " + to_expression(grad_y) + ")"; + farg_str += ", gradient" + grad_opt + "(" + to_expression(grad_x) + ", " + to_expression(grad_y) + ")"; } // Add offsets @@ -1062,44 +2190,20 @@ void CompilerMSL::emit_texture_op(const Instruction &i) if (!offset_expr.empty()) { - switch (img_type.dim) + switch (imgtype.image.dim) { case Dim2D: - if (msl_config.flip_frag_y) - { - string coord_x = offset_expr + ".x"; - remove_duplicate_swizzle(coord_x); - string coord_y = offset_expr + ".y"; - remove_duplicate_swizzle(coord_y); - offset_expr = "float2(" + coord_x + ", (1.0 - " + coord_y + "))"; - } - else - { - offset_expr = offset_expr + ".xy"; - remove_duplicate_swizzle(offset_expr); - } + if (coord_type.vecsize > 2) + offset_expr += ".xy"; - expr += ", " + offset_expr; + farg_str += ", " + offset_expr; break; case Dim3D: - if (msl_config.flip_frag_y) - { - string coord_x = offset_expr + ".x"; - remove_duplicate_swizzle(coord_x); - string coord_y = offset_expr + ".y"; - remove_duplicate_swizzle(coord_y); - string coord_z = offset_expr + ".z"; - remove_duplicate_swizzle(coord_z); - offset_expr = "float3(" + coord_x + ", (1.0 - " + coord_y + "), " + coord_z + ")"; - } - else - { - offset_expr = offset_expr + ".xyz"; - remove_duplicate_swizzle(offset_expr); - } + if (coord_type.vecsize > 3) + offset_expr += ".xyz"; - expr += ", " + offset_expr; + farg_str += ", " + offset_expr; break; default: @@ -1110,12 +2214,53 @@ void CompilerMSL::emit_texture_op(const Instruction &i) if (comp) { forward = forward && should_forward(comp); - expr += ", " + to_expression(comp); + farg_str += ", " + to_component_argument(comp); } - expr += ")"; + if (sample) + { + farg_str += ", "; + farg_str += to_expression(sample); + } - emit_op(result_type, id, expr, forward); + *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. @@ -1137,7 +2282,7 @@ string CompilerMSL::to_func_call_arg(uint32_t id) { auto &var = id_v.get(); auto &type = get(var.basetype); - if (type.basetype == SPIRType::SampledImage) + if (type.basetype == SPIRType::SampledImage && type.image.dim != DimBuffer) arg_str += ", " + to_sampler_expression(id); } @@ -1153,6 +2298,84 @@ string CompilerMSL::to_sampler_expression(uint32_t id) 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() { @@ -1160,23 +2383,32 @@ void CompilerMSL::emit_fixup() if ((execution.model == ExecutionModelVertex) && stage_out_var_id && !qual_pos_var_name.empty()) { - if (options.vertex.fixup_clipspace) - { - const char *suffix = backend.float_literal_suffix ? "f" : ""; - statement(qual_pos_var_name, ".z = 2.0", suffix, " * ", qual_pos_var_name, ".z - ", qual_pos_var_name, - ".w;", " // Adjust clip-space for Metal"); - } + 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 (msl_config.flip_vert_y) + if (CompilerGLSL::options.vertex.flip_vert_y) statement(qual_pos_var_name, ".y = -(", qual_pos_var_name, ".y);", " // Invert Y-axis for Metal"); } } -// Returns a declaration for a structure member. -string CompilerMSL::member_decl(const SPIRType &type, const SPIRType &membertype, uint32_t index) +// 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) { - return join(type_to_glsl(membertype), " ", to_member_name(type, index), type_to_array_glsl(membertype), - member_attribute_qualifier(type, index)); + 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 @@ -1184,6 +2416,9 @@ string CompilerMSL::member_attribute_qualifier(const SPIRType &type, uint32_t in { 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); @@ -1205,7 +2440,8 @@ string CompilerMSL::member_attribute_qualifier(const SPIRType &type, uint32_t in } } uint32_t locn = get_ordered_member_location(type.self, index); - return string(" [[attribute(") + convert_to_string(locn) + ")]]"; + if (locn != k_unknown_location) + return string(" [[attribute(") + convert_to_string(locn) + ")]]"; } // Vertex function outputs @@ -1215,22 +2451,25 @@ string CompilerMSL::member_attribute_qualifier(const SPIRType &type, uint32_t in { switch (builtin) { - case BuiltInClipDistance: - return " /* [[clip_distance]] built-in not yet supported under Metal. */"; - - case BuiltInPointSize: // Must output only if really rendering points - return msl_config.is_rendering_points ? (string(" [[") + builtin_qualifier(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: - return string(" [[") + builtin_qualifier(builtin) + "]]"; + case BuiltInClipDistance: + return string(" [[") + builtin_qualifier(builtin) + "]]" + (mbr_type.array.empty() ? "" : " "); default: return ""; } } uint32_t locn = get_ordered_member_location(type.self, index); - return string(" [[user(locn") + convert_to_string(locn) + ")]]"; + if (locn != k_unknown_location) + return string(" [[user(locn") + convert_to_string(locn) + ")]]"; } // Fragment function inputs @@ -1253,7 +2492,8 @@ string CompilerMSL::member_attribute_qualifier(const SPIRType &type, uint32_t in } } uint32_t locn = get_ordered_member_location(type.self, index); - return string(" [[user(locn") + convert_to_string(locn) + ")]]"; + if (locn != k_unknown_location) + return string(" [[user(locn") + convert_to_string(locn) + ")]]"; } // Fragment function outputs @@ -1272,7 +2512,28 @@ string CompilerMSL::member_attribute_qualifier(const SPIRType &type, uint32_t in } } uint32_t locn = get_ordered_member_location(type.self, index); - return string(" [[color(") + convert_to_string(locn) + ")]]"; + 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 ""; @@ -1370,36 +2631,65 @@ string CompilerMSL::func_type_decl(SPIRType &type) return entry_type + " " + return_type; } -// Ensures the function name is not "main", which is illegal in MSL -string CompilerMSL::clean_func_name(string func_name) +// In MSL, address space qualifiers are required for all pointer or reference arguments +string CompilerMSL::get_argument_address_space(const SPIRVariable &argument) { - static std::string _clean_msl_main_func_name = "mmain"; - return (func_name == "main") ? _clean_msl_main_func_name : func_name; + 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) { - auto &execution = get_entry_point(); string ep_args; - // Stage-in structures - for (uint32_t var_id : stage_in_var_ids) + // Stage-in structure + if (stage_in_var_id) { - auto &var = get(var_id); + auto &var = get(stage_in_var_id); auto &type = get(var.basetype); - auto &dec = meta[var.self].decoration; - - bool use_stage_in = - (execution.model != ExecutionModelVertex || dec.binding == msl_config.vtx_attr_stage_in_binding); if (!ep_args.empty()) ep_args += ", "; - if (use_stage_in) - ep_args += type_to_glsl(type) + " " + to_name(var.self) + " [[stage_in]]"; - else - ep_args += "device " + type_to_glsl(type) + "* " + to_name(var.self) + " [[buffer(" + - convert_to_string(dec.binding) + ")]]"; + + 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 @@ -1410,41 +2700,46 @@ string CompilerMSL::entry_point_args(bool append_comma) auto &var = id.get(); auto &type = get(var.basetype); - if (is_hidden_variable(var, true)) - continue; + uint32_t var_id = var.self; - if (var.storage == StorageClassUniform || var.storage == StorageClassUniformConstant || - var.storage == StorageClassPushConstant) + 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 += "constant " + type_to_glsl(type) + "& " + to_name(var.self); + 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.self); + 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) + " " + to_name(var.self); + 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) + " " + to_name(var.self); + 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.self); + ep_args += ", sampler " + to_sampler_expression(var_id); ep_args += " [[sampler(" + convert_to_string(get_metal_resource_index(var, SPIRType::Sampler)) + ")]]"; } @@ -1457,13 +2752,21 @@ string CompilerMSL::entry_point_args(bool append_comma) { if (!ep_args.empty()) ep_args += ", "; - BuiltIn bi_type = meta[var.self].decoration.builtin_type; - ep_args += builtin_type_decl(bi_type) + " " + to_expression(var.self); + + 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 += ", "; @@ -1517,80 +2820,41 @@ uint32_t CompilerMSL::get_metal_resource_index(SPIRVariable &var, SPIRType::Base // Returns the name of the entry point of this shader string CompilerMSL::get_entry_point_name() { - return clean_func_name(to_name(entry_point)); -} - -// Returns the name of either the vertex index or instance index builtin -string CompilerMSL::get_vtx_idx_var_name(bool per_instance) -{ - BuiltIn builtin; - uint32_t var_id; - - // Try modern builtin name first - builtin = per_instance ? BuiltInInstanceIndex : BuiltInVertexIndex; - var_id = builtin_vars[builtin]; - if (var_id) - return to_expression(var_id); - - // Try legacy builtin name second - builtin = per_instance ? BuiltInInstanceId : BuiltInVertexId; - var_id = builtin_vars[builtin]; - if (var_id) - return to_expression(var_id); - - return "missing_vtx_idx_var"; -} - -// If the struct contains indexed vertex input, and the offset is greater than the current -// size of the struct, appends a padding member to the struct, and returns the offset to -// use for the next member, which is the offset provided. Otherwise, no padding is added, -// and the struct size is returned. -uint32_t CompilerMSL::pad_to_offset(SPIRType &struct_type, bool is_indxd_vtx_input, uint32_t offset, - uint32_t struct_size) -{ - if (!(is_indxd_vtx_input && offset > struct_size)) - return struct_size; - - auto &pad_type = get_pad_type(offset - struct_size); - uint32_t mbr_idx = uint32_t(struct_type.member_types.size()); - struct_type.member_types.push_back(pad_type.self); - set_member_name(struct_type.self, mbr_idx, ("pad" + convert_to_string(mbr_idx))); - set_member_decoration(struct_type.self, mbr_idx, DecorationOffset, struct_size); - return offset; -} - -// Returns a char array type suitable for use as a padding member in a packed struct -SPIRType &CompilerMSL::get_pad_type(uint32_t pad_len) -{ - uint32_t pad_type_id = pad_type_ids_by_pad_len[pad_len]; - if (pad_type_id != 0) - return get(pad_type_id); - - pad_type_id = increase_bound_by(1); - auto &ib_type = set(pad_type_id); - ib_type.storage = StorageClassGeneric; - ib_type.basetype = SPIRType::Char; - ib_type.width = 8; - ib_type.array.push_back(pad_len); - ib_type.array_size_literal.push_back(true); - set_decoration(ib_type.self, DecorationArrayStride, pad_len); - - pad_type_ids_by_pad_len[pad_len] = pad_type_id; - return ib_type; + return to_name(entry_point); } string CompilerMSL::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); - return join(constref ? "const " : "", type_to_glsl(type), "& ", to_name(var.self), type_to_array_glsl(type)); + 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) +string CompilerMSL::to_name(uint32_t id, bool allow_alias) const { if (current_function && (current_function->self == entry_point)) { @@ -1604,16 +2868,15 @@ string CompilerMSL::to_name(uint32_t id, bool 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) { - //Start with existing member name - string mbr_name = to_member_name(type, index); - // Don't qualify Builtin names because they are unique and are treated as such when building expressions - if (is_member_builtin(type, index, nullptr)) - return mbr_name; + 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 != std::string::npos) ? mbr_name.substr(startPos) : ""; + mbr_name = (startPos != string::npos) ? mbr_name.substr(startPos) : ""; return join(to_name(type.self), "_", mbr_name); } @@ -1621,17 +2884,90 @@ string CompilerMSL::to_qualified_member_name(const SPIRType &type, uint32_t inde // if the first chars are _ and a digit, which indicate a transient name. string CompilerMSL::ensure_valid_name(string name, string pfx) { - if (name.size() >= 2 && name[0] == '_' && isdigit(name[1])) - return join(pfx, name); - else - return name; + return (name.size() >= 2 && name[0] == '_' && isdigit(name[1])) ? (pfx + name) : name; } -// Returns an MSL string describing the SPIR-V type -string CompilerMSL::type_to_glsl(const SPIRType &type) +// 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: @@ -1640,87 +2976,80 @@ string CompilerMSL::type_to_glsl(const SPIRType &type) case SPIRType::Image: case SPIRType::SampledImage: - return image_type_glsl(type); + return image_type_glsl(type, id); case SPIRType::Sampler: - // Not really used. return "sampler"; case SPIRType::Void: return "void"; - default: + 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"; } - if (is_scalar(type)) // Scalar builtin - { - switch (type.basetype) - { - case SPIRType::Boolean: - return "bool"; - case SPIRType::Char: - return "char"; - case SPIRType::Int: - return (type.width == 16 ? "short" : "int"); - case SPIRType::UInt: - return (type.width == 16 ? "ushort" : "uint"); - case SPIRType::AtomicCounter: - return "atomic_uint"; - case SPIRType::Float: - return (type.width == 16 ? "half" : "float"); - default: - return "unknown_type"; - } - } - else if (is_vector(type)) // Vector builtin - { - switch (type.basetype) - { - case SPIRType::Boolean: - return join("bool", type.vecsize); - case SPIRType::Char: - return join("char", type.vecsize); - ; - case SPIRType::Int: - return join((type.width == 16 ? "short" : "int"), type.vecsize); - case SPIRType::UInt: - return join((type.width == 16 ? "ushort" : "uint"), type.vecsize); - case SPIRType::Float: - return join((type.width == 16 ? "half" : "float"), type.vecsize); - default: - return "unknown_type"; - } - } - else - { - switch (type.basetype) - { - case SPIRType::Boolean: - case SPIRType::Int: - case SPIRType::UInt: - case SPIRType::Float: - return join((type.width == 16 ? "half" : "float"), type.columns, "x", type.vecsize); - 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) +string CompilerMSL::image_type_glsl(const SPIRType &type, uint32_t id) { string img_type_name; - auto &img_type = type.image; + // 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 spv::Dim2D: + 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 spv::DimCube: + case Dim3D: + img_type_name += "depth3d_unsupported_by_metal"; + break; + case DimCube: img_type_name += (img_type.arrayed ? "depthcube_array" : "depthcube"); break; default: @@ -1732,17 +3061,17 @@ string CompilerMSL::image_type_glsl(const SPIRType &type) { switch (img_type.dim) { - case spv::Dim1D: + case Dim1D: img_type_name += (img_type.arrayed ? "texture1d_array" : "texture1d"); break; - case spv::DimBuffer: - case spv::Dim2D: + case DimBuffer: + case Dim2D: img_type_name += (img_type.ms ? "texture2d_ms" : (img_type.arrayed ? "texture2d_array" : "texture2d")); break; - case spv::Dim3D: + case Dim3D: img_type_name += "texture3d"; break; - case spv::DimCube: + case DimCube: img_type_name += (img_type.arrayed ? "texturecube_array" : "texturecube"); break; default: @@ -1752,21 +3081,81 @@ string CompilerMSL::image_type_glsl(const SPIRType &type) } // Append the pixel type - auto &img_pix_type = get(img_type.type); - img_type_name += "<" + type_to_glsl(img_pix_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; } -// Returns an MSL string identifying the name of a SPIR-V builtin -string CompilerMSL::builtin_to_glsl(BuiltIn builtin) +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) { - case BuiltInPosition: - return qual_pos_var_name.empty() ? (stage_out_var_name + ".gl_Position") : qual_pos_var_name; - case BuiltInPointSize: - return (stage_out_var_name + ".gl_PointSize"); + + // Override GLSL compiler strictness case BuiltInVertexId: return "gl_VertexID"; case BuiltInInstanceId: @@ -1775,40 +3164,21 @@ string CompilerMSL::builtin_to_glsl(BuiltIn builtin) return "gl_VertexIndex"; case BuiltInInstanceIndex: return "gl_InstanceIndex"; - case BuiltInPrimitiveId: - return "gl_PrimitiveID"; - case BuiltInInvocationId: - return "gl_InvocationID"; + + // When used in the entry function, output builtins are qualified with output struct name. + case BuiltInPosition: + case BuiltInPointSize: + case BuiltInClipDistance: + case BuiltInCullDistance: case BuiltInLayer: - return "gl_Layer"; - 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"; + 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 "gl_???"; + return CompilerGLSL::builtin_to_glsl(builtin, storage); } } @@ -1853,16 +3223,28 @@ string CompilerMSL::builtin_qualifier(BuiltIn builtin) // Fragment function out case BuiltInFragDepth: - { if (execution.flags & (1ull << ExecutionModeDepthGreater)) return "depth(greater)"; - - if (execution.flags & (1ull << ExecutionModeDepthLess)) + else if (execution.flags & (1ull << ExecutionModeDepthLess)) return "depth(less)"; - - if (execution.flags & (1ull << ExecutionModeDepthUnchanged)) + 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"; @@ -1891,6 +3273,8 @@ string CompilerMSL::builtin_type_decl(BuiltIn builtin) return "float"; case BuiltInPosition: return "float4"; + case BuiltInLayer: + return "uint"; // Fragment function in case BuiltInFrontFacing: @@ -1904,31 +3288,39 @@ string CompilerMSL::builtin_type_decl(BuiltIn builtin) 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 effective size of a buffer block struct member. +// 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 &type = get(struct_type.member_types[index]); auto dec_mask = get_member_decoration_mask(struct_type.self, index); - return get_declared_type_size(type, dec_mask); -} - -// Returns the effective size of a variable type. -size_t CompilerMSL::get_declared_type_size(const SPIRType &type) const -{ - return get_declared_type_size(type, get_decoration_mask(type.self)); -} - -// Returns the effective size of a variable type or member type, -// taking into consideration the specified mask of decorations. -size_t CompilerMSL::get_declared_type_size(const SPIRType &type, uint64_t dec_mask) const -{ - if (type.basetype == SPIRType::Struct) - return get_declared_struct_size(type); + auto &type = get(struct_type.member_types[index]); switch (type.basetype) { @@ -1938,54 +3330,218 @@ size_t CompilerMSL::get_declared_type_size(const SPIRType &type, uint64_t dec_ma case SPIRType::Image: case SPIRType::SampledImage: case SPIRType::Sampler: - SPIRV_CROSS_THROW("Querying size of object with opaque size."); + 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; } - size_t component_size = type.width / 8; - unsigned vecsize = type.vecsize; - unsigned columns = type.columns; + // 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; - if (type.array.empty()) - { - // Vectors. - if (columns == 1) - return vecsize * component_size; - else - { - // Per SPIR-V spec, matrices must be tightly packed and aligned up for vec3 accesses. - if ((dec_mask & (1ull << DecorationRowMajor)) && columns == 3) - columns = 4; - else if ((dec_mask & (1ull << DecorationColMajor)) && vecsize == 3) - vecsize = 4; - - return vecsize * columns * component_size; - } - } - else - { - // For arrays, we can use ArrayStride to get an easy check. - // ArrayStride is part of the array type not OpMemberDecorate. - auto &dec = meta[type.self].decoration; - if (dec.decoration_flags & (1ull << DecorationArrayStride)) - return dec.array_stride * to_array_size_literal(type, uint32_t(type.array.size()) - 1); - else - { - SPIRV_CROSS_THROW("Type does not have ArrayStride set."); - } - } + return true; } -// Sort both type and meta member content based on builtin status (put builtins at end), then by location. -void MemberSorter::sort() +// 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) { - // Create a temporary array of consecutive member indices and sort it base on - // how the members should be reordered, based on builtin and location meta info. + 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 member locations + 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 @@ -1999,8 +3555,8 @@ void MemberSorter::sort() } } -// Sort first by builtin status (put builtins at end), then by location. -bool MemberSorter::operator()(uint32_t mbr_idx1, uint32_t mbr_idx2) +// 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]; @@ -2011,9 +3567,25 @@ bool MemberSorter::operator()(uint32_t mbr_idx1, uint32_t mbr_idx2) { 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 index eadaea2fb2..fbc8dadf40 100644 --- a/deps/SPIRV-Cross/spirv_msl.hpp +++ b/deps/SPIRV-Cross/spirv_msl.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 The Brenwill Workshop Ltd. + * 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. @@ -18,21 +18,16 @@ #define SPIRV_CROSS_MSL_HPP #include "spirv_glsl.hpp" +#include +#include #include +#include +#include #include namespace spirv_cross { -// Options for compiling to Metal Shading Language -struct MSLConfiguration -{ - uint32_t vtx_attr_stage_in_binding = 0; - bool flip_vert_y = true; - bool flip_frag_y = true; - bool is_rendering_points = false; -}; - // 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. @@ -64,9 +59,12 @@ struct MSLResourceBinding 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 = UINT32_MAX; +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. @@ -76,11 +74,80 @@ static const uint32_t kPushConstBinding = 0; class CompilerMSL : public CompilerGLSL { public: - // Constructs an instance to compile the SPIR-V code into Metal Shading Language. - CompilerMSL(std::vector spirv); + // Options for compiling to Metal Shading Language + struct Options + { + typedef enum { + iOS, + macOS, + } Platform; - // Compiles the SPIR-V code into Metal Shading Language using the specified configuration parameters. - // - msl_cfg indicates some general configuration for directing the compilation. + 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 @@ -89,12 +156,28 @@ public: // 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); - // Compiles the SPIR-V code into Metal Shading Language using default configuration parameters. - std::string compile() override; - 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, @@ -102,34 +185,56 @@ protected: 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_texture_op(const Instruction &i) override; void emit_fixup() override; - std::string type_to_glsl(const SPIRType &type) override; - std::string image_type_glsl(const SPIRType &type) override; - std::string builtin_to_glsl(spv::BuiltIn builtin) override; - std::string member_decl(const SPIRType &type, const SPIRType &member_type, uint32_t member) 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) 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 extract_builtins(); - void add_builtin(spv::BuiltIn builtin_type); + 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::set &global_var_ids, - std::set &processed_func_ids); - void add_interface_structs(); - void bind_vertex_attributes(std::set &bindings); - uint32_t add_interface_struct(spv::StorageClass storage, uint32_t vtx_binding = 0); + 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); - void emit_function_prototype(SPIRFunction &func, bool is_decl); - void emit_function_declarations(); + 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 clean_func_name(std::string func_name); 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); @@ -137,52 +242,89 @@ protected: 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 get_vtx_idx_var_name(bool per_instance); + 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); - uint32_t pad_to_offset(SPIRType &struct_type, bool is_indxd_vtx_input, uint32_t offset, uint32_t struct_size); - SPIRType &get_pad_type(uint32_t pad_len); - size_t get_declared_type_size(const SPIRType &type) const; - size_t get_declared_type_size(const SPIRType &type, uint64_t dec_mask) const; + 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); - MSLConfiguration msl_config; + 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; - std::unordered_map builtin_vars; MSLResourceBinding next_metal_resource_index; - std::unordered_map pad_type_ids_by_pad_len; - std::vector stage_in_var_ids; + 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; -// 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 + // OpcodeHandler that handles several MSL preprocessing operations. + struct OpCodePreprocessor : OpcodeHandler { - Location, - Offset, + 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; }; - void sort(); - bool operator()(uint32_t mbr_idx1, uint32_t mbr_idx2); - MemberSorter(SPIRType &t, Meta &m, SortAspect sa) - : type(t) - , meta(m) - , sort_aspect(sa) + // 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 { - } - SPIRType &type; - Meta &meta; - SortAspect sort_aspect; + 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; + }; }; } diff --git a/deps/SPIRV-Cross/test_shaders.py b/deps/SPIRV-Cross/test_shaders.py index daac82a660..1ca8f9af5f 100755 --- a/deps/SPIRV-Cross/test_shaders.py +++ b/deps/SPIRV-Cross/test_shaders.py @@ -2,6 +2,7 @@ import sys import os +import os.path import subprocess import tempfile import re @@ -9,6 +10,9 @@ 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) @@ -60,13 +64,124 @@ def get_shader_stats(shader): 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, eliminate, invalid_spirv): +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) @@ -81,32 +196,46 @@ def cross_compile(shader, vulkan, spirv, eliminate, invalid_spirv): 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]) - spirv_cross_path = './spirv-cross' + extra_args = [] if eliminate: - subprocess.check_call([spirv_cross_path, '--remove-unused-variables', '--entry', 'main', '--output', glsl_path, spirv_path]) - else: - subprocess.check_call([spirv_cross_path, '--entry', 'main', '--output', glsl_path, spirv_path]) + 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: - if eliminate: - subprocess.check_call([spirv_cross_path, '--remove-unused-variables', '--entry', 'main', '--vulkan-semantics', '--output', vulkan_glsl_path, spirv_path]) - else: - subprocess.check_call([spirv_cross_path, '--entry', 'main', '--vulkan-semantics', '--output', vulkan_glsl_path, spirv_path]) - validate_shader(vulkan_glsl_path, vulkan) + 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: f.read(8192), b''): + for chunk in iter(lambda: make_unix_newline(f.read(8192)), b''): md5.update(chunk) return md5.digest() @@ -115,28 +244,28 @@ def make_reference_dir(path): if not os.path.exists(base): os.makedirs(base) -def reference_path(directory, relpath): +def reference_path(directory, relpath, opt): split_paths = os.path.split(directory) - reference_dir = os.path.join(split_paths[0], 'reference/') + 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): - reference = reference_path(shader[0], shader[1]) +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 GLSL has changed for {}!'.format(reference)) + 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 GLSL in {} does not match reference {}!'.format(glsl, reference)) + print('Generated source code in {} does not match reference {}!'.format(glsl, reference)) with open(glsl, 'r') as f: print('') print('Generated:') @@ -152,7 +281,7 @@ def regression_check(shader, glsl, update, keep): else: os.remove(glsl) else: - print('Found new shader {}. Placing GLSL in {}'.format(joined_path, reference)) + print('Found new shader {}. Placing generated source code in {}'.format(joined_path, reference)) make_reference_dir(reference) shutil.move(glsl, reference) @@ -171,24 +300,44 @@ def shader_is_spirv(shader): def shader_is_invalid_spirv(shader): return '.invalid.' in shader -def test_shader(stats, shader, update, keep): +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, eliminate, invalid_spirv) + 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) + regression_check(shader, glsl, update, keep, opt) if vulkan_glsl: - regression_check((shader[0], shader[1] + '.vk'), vulkan_glsl, update, keep) + 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): @@ -202,20 +351,56 @@ def test_shader(stats, shader, update, keep): a.append(str(i)) print(','.join(a), file = stats) -def test_shaders_helper(stats, shader_dir, update, malisc, keep): +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) - test_shader(stats, (shader_dir, relpath), update, keep) + 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): +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) + test_shaders_helper(stats, shader_dir, update, malisc, keep, backend) else: - test_shaders_helper(None, shader_dir, update, malisc, keep) + test_shaders_helper(None, shader_dir, update, malisc, keep, opt, backend) def main(): parser = argparse.ArgumentParser(description = 'Script for regression testing.') @@ -230,13 +415,34 @@ def main(): 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) - test_shaders(args.folder, args.update, args.malisc, args.keep) + 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!') diff --git a/deps/SPIRV-Cross/test_shaders.sh b/deps/SPIRV-Cross/test_shaders.sh new file mode 100644 index 0000000000..a3608730b9 --- /dev/null +++ b/deps/SPIRV-Cross/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/deps/SPIRV-Cross/update_test_shaders.sh b/deps/SPIRV-Cross/update_test_shaders.sh new file mode 100644 index 0000000000..712c3eec5d --- /dev/null +++ b/deps/SPIRV-Cross/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 +